mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-04-21 21:19:18 -04:00
Create a new method in MY_url.php "get_item_from_uri" which loads the item
based on the uri. Then use this helper method in logout.php to insure that the guest user has access to the "continue" uri. If they don't redirect to the root album and let it deal with access issues. Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
This commit is contained in:
@@ -46,7 +46,19 @@ class url extends url_Core {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES);
|
||||
$item = self:: get_item_from_uri(Router::$current_uri);
|
||||
if ($item && $item->loaded) {
|
||||
Router::$controller = "{$item->type}s";
|
||||
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
|
||||
Router::$method = $item->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the item that the uri is referencing
|
||||
*/
|
||||
static function get_item_from_uri($uri) {
|
||||
$current_uri = html_entity_decode($uri);
|
||||
$item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find();
|
||||
if (!$item->loaded) {
|
||||
// It's possible that the relative path cache for the item we're looking for is out of date,
|
||||
@@ -61,12 +73,7 @@ class url extends url_Core {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($item && $item->loaded) {
|
||||
Router::$controller = "{$item->type}s";
|
||||
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
|
||||
Router::$method = $item->id;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,12 @@ class Logout_Controller extends Controller {
|
||||
log::info("user", t("User %name logged out", array("name" => $user->name)),
|
||||
html::anchor("user/$user->id", $user->name));
|
||||
if ($this->input->get("continue")) {
|
||||
url::redirect($this->input->get("continue"));
|
||||
$item = url::get_item_from_uri($this->input->get("continue"));
|
||||
if (access::can("view", $item)) {
|
||||
url::redirect($this->input->get("continue"));
|
||||
} else {
|
||||
url::redirect("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user