From 1fc79046568a5fe0c75c520ae643d0c7279ad64b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 06:35:35 -0700 Subject: 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. --- modules/gallery/helpers/MY_url.php | 21 ++++++++++++++------- modules/user/controllers/logout.php | 7 ++++++- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index c8645c4d..e9a5f860 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -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; } /** diff --git a/modules/user/controllers/logout.php b/modules/user/controllers/logout.php index 6ceb7192..a541ed9b 100644 --- a/modules/user/controllers/logout.php +++ b/modules/user/controllers/logout.php @@ -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(""); + } } } } \ No newline at end of file -- cgit v1.2.3 From 01042b6d8528a396df1cfa145a43ca589f51ec7c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 06:44:08 -0700 Subject: Removed extra whitespace --- modules/gallery/helpers/MY_url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index e9a5f860..7bee70ca 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -46,7 +46,7 @@ class url extends url_Core { return; } - $item = self:: get_item_from_uri(Router::$current_uri); + $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"; -- cgit v1.2.3 From b84ef45eb13f218c63cd904386db6bb737ef8bee Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 07:18:41 -0700 Subject: Rather than just displaying the "unformatted" login screen when the root album is not viewable by a guest, display the root album as if it was empty. When the page finishes loading force the login dialog to be displayed. --- modules/gallery/controllers/albums.php | 12 ++++++++++-- themes/default/views/page.html.php | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index efde4f09..0fd89f05 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -23,16 +23,24 @@ class Albums_Controller extends Items_Controller { * @see REST_Controller::_show($resource) */ public function _show($album) { + $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - print new Theme_View("login_page.html", "album"); + $template = new Theme_View("page.html", "album"); + $template->set_global("page_size", $page_size); + $template->set_global("item", $album); + $template->set_global("children", array()); + $template->set_global("children_count", 0); + $template->set_global("parents", $album->parents()); + $template->unauthorized = true; + $template->content = new View("album.html"); + print $template; return; } else { access::forbidden(); } } - $page_size = module::get_var("gallery", "page_size", 9); $show = $this->input->get("show"); if ($show) { diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index 6c77fb72..a17b643d 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -52,6 +52,13 @@ head() ?> + + + main_element_attributes() ?>> -- cgit v1.2.3 From 08d8d320466f676e74a7c04a2fe874fd3a568429 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 16:18:47 -0700 Subject: Changed how directories are processed when the parent directory is selected and the branch was never opened on the client. This should fix some of the issues with the server_add as I was able to select the staging directory and then add over 400 images in a multi-tier structure. --- modules/server_add/controllers/server_add.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 2c6eb5e0..c92b4f7e 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -87,17 +87,20 @@ class Server_Add_Controller extends Controller { foreach (array_keys($paths) as $valid_path) { $path_length = strlen($valid_path); foreach ($input_files as $key => $path) { - if (!empty($path) && $valid_path != $path && strpos($path, $valid_path) === 0) { - $relative_path = substr(dirname($path), $path_length); - $name = basename($path); - $files[$valid_path][] = array("path" => $relative_path, - "parent_id" => $id, "name" => basename($path), + if (!empty($path)) { + if ($valid_path != $path && strpos($path, $valid_path) === 0) { + $relative_path = substr(dirname($path), $path_length); + $name = basename($path); + $files[$valid_path][] = array("path" => $relative_path, + "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file"); - $total_count++; + $total_count++; + } if ($collapsed[$key] === "true") { $total_count += $this->_select_children($id, $valid_path, $path, $files[$valid_path]); } unset($input_files[$key]); + unset($collapsed[$key]); } } } -- cgit v1.2.3 From e7a3b6fa55d4eda9140b122bc50681b979229da3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 17:17:27 -0700 Subject: Created not_authorized.html.php which is a prettier login screen if the root album is not publicly browsable. --- modules/gallery/controllers/albums.php | 10 ++-------- themes/default/views/page.html.php | 7 ------- 2 files changed, 2 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 0fd89f05..9b837442 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,14 +26,8 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $template = new Theme_View("page.html", "album"); - $template->set_global("page_size", $page_size); - $template->set_global("item", $album); - $template->set_global("children", array()); - $template->set_global("children_count", 0); - $template->set_global("parents", $album->parents()); - $template->unauthorized = true; - $template->content = new View("album.html"); + $template = new Theme_View("not_authorized.html", "album"); + $template->content = new View("login_page.html"); print $template; return; } else { diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index a17b643d..6c77fb72 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -52,13 +52,6 @@ head() ?> - - - main_element_attributes() ?>> -- cgit v1.2.3 From 7e61bcbbecefb6b12343a8c6d3f700d282a3528b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 17:38:21 -0700 Subject: Add some window dressing to login_page.html in order to make it more in line with the overall look of the Gallery3 theme --- modules/gallery/controllers/albums.php | 4 +- themes/default/views/login_page.html.php | 48 ++++++++++++++++++- themes/default/views/not_authorized.html.php | 69 ---------------------------- 3 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 themes/default/views/not_authorized.html.php (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 9b837442..f37609e6 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,9 +26,7 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $template = new Theme_View("not_authorized.html", "album"); - $template->content = new View("login_page.html"); - print $template; + print new Theme_View("login_page.html"); return; } else { access::forbidden(); diff --git a/themes/default/views/login_page.html.php b/themes/default/views/login_page.html.php index 27f8571e..c4880727 100644 --- a/themes/default/views/login_page.html.php +++ b/themes/default/views/login_page.html.php @@ -7,11 +7,55 @@ <?= t("Please Login to Gallery") ?> + " type="image/x-icon" /> + " + media="screen,print,projection" /> + " + media="screen" /> + " + media="screen,print,projection" /> " media="screen,print,projection" /> + + + + + + + + + + + + head() ?> - - + main_element_attributes() ?>> + page_top() ?> +
+ site_status() ?> +
+ display("header.html") ?> +
+
+
+
+
+ messages() ?> + +
+
+
+
+
+
+
+ display("footer.html") ?> +
+
+ page_bottom() ?> diff --git a/themes/default/views/not_authorized.html.php b/themes/default/views/not_authorized.html.php deleted file mode 100644 index d009a4ac..00000000 --- a/themes/default/views/not_authorized.html.php +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - <? if (empty($page_title)): ?> - <?= t("Gallery3 Login") ?> - <? if (!empty($item)): ?> - :: <?= p::clean($item->title) ?> - <? endif ?> - <? else: ?> - <?= $page_title ?> - <? endif ?> - <?= $theme->page_type ?> - - " type="image/x-icon" /> - " - media="screen,print,projection" /> - " - media="screen" /> - " - media="screen,print,projection" /> - " - media="screen,print,projection" /> - - - - - - - - - - - - head() ?> - - - main_element_attributes() ?>> - page_top() ?> -
- site_status() ?> -
- display("header.html") ?> -
-
-
-
-
- messages() ?> - -
-
-
-
-
-
-
- display("footer.html") ?> -
-
- page_bottom() ?> - - -- cgit v1.2.3 From 0c5cb026a72c3e894cbb7c6a637267f867cc323a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 10 Jun 2009 08:26:40 -0700 Subject: Only add the comment rss feeds if the comment module is active. fix for #365 --- modules/rss/helpers/rss_theme.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/rss/helpers/rss_theme.php b/modules/rss/helpers/rss_theme.php index d47d3313..54bba210 100644 --- a/modules/rss/helpers/rss_theme.php +++ b/modules/rss/helpers/rss_theme.php @@ -40,12 +40,16 @@ class rss_theme_Core { $block->css_id = "gRss"; $block->title = t("Available RSS Feeds"); $block->content = new View("rss_block.html"); - $block->content->feeds = array( - t("New photos or movies") => url::site("rss/updates"), - t("All new comments") => url::site("rss/comments"), - sprintf(t("Comments on %s"), - $theme->item()->title) => url::site("rss/comments/{$theme->item()->id}") - ); + // @todo consider pushing the code for the feeds back to the associated modules + // and create an event 'generate_rss_feeds' that modules can respond to create + // the list of feeds. + $feeds = array(t("New photos or movies") => url::site("rss/updates")); + if (module::is_active("comment")) { + $feeds[t("All new comments")] = url::site("rss/comments"); + $feeds[sprintf(t("Comments on %s"), $theme->item()->title)] = + url::site("rss/comments/{$theme->item()->id}"); + } + $block->content->feeds = $feeds; return $block; } } -- cgit v1.2.3