From 32d18920680ee63dc75c3a2b710ef805b31c127c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Sep 2010 22:53:06 -0700 Subject: Follow on to 2a86446249c4782287e1e6e472f422b851c2fb47; fix a bug where guest access to admin pages fails because we try to go to the login page but you can't do that from the admin theme. Thanks to mamouneyya for catching this. http://github.com/gallery/gallery3/commit/2a86446249c4782287e1e6e472f422b851c2fb47 --- modules/gallery/helpers/gallery.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 924ee76a..9430231c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -45,10 +45,17 @@ class gallery_Core { Router::$controller != "combined" && identity::active_user()->guest && !access::user_can(identity::guest(), "view", item::root())) { - Session::instance()->set("continue_url", url::abs_current()); - Router::$controller = "login"; - Router::$controller_path = MODPATH . "gallery/controllers/login.php"; - Router::$method = "html"; + if (Router::$controller == "admin") { + // At this point we're in the admin theme and it doesn't have a themed login page, so + // we can't just swap in the login controller and have it work. So redirect back to the + // root item where we'll run this code again with the site theme. + url::redirect(item::root()->abs_url()); + } else { + Session::instance()->set("continue_url", url::abs_current()); + Router::$controller = "login"; + Router::$controller_path = MODPATH . "gallery/controllers/login.php"; + Router::$method = "html"; + } } } -- cgit v1.2.3 From db75ac642a6ff62e814929af99e7c9af4d492706 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 4 Sep 2010 13:40:39 -0700 Subject: Use the title of the root album as the site title for all RSS feeds. Fixes ticket #1307. --- modules/comment/helpers/comment_rss.php | 10 ++++++++-- modules/gallery/helpers/gallery_rss.php | 10 ++++++++-- modules/tag/helpers/tag_rss.php | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 26d98d21..cc4180bf 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -57,13 +57,19 @@ class comment_rss_Core { "thumb_height" => $item->thumb_height, "thumb_width" => $item->thumb_width, "item_uri" => url::abs_site("{$item->type}s/$item->id"), - "title" => html::purify($item->title), + "title" => ( + ($item->id == item::root()->id) ? + html::purify($item->title) : + t("%site_title - %item_title", + array("site_title" => item::root()->title, + "item_title" => $item->title))), "author" => html::clean($comment->author_name())), ArrayObject::ARRAY_AS_PROPS); } $feed->max_pages = ceil($comments->count_all() / $limit); - $feed->title = htmlspecialchars(t("Recent Comments")); + $feed->title = html::purify(t("%site_title - Recent Comments", + array("site_title" => item::root()->title))); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); $feed->description = t("Recent comments"); diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index bec34912..fb617934 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -40,7 +40,7 @@ class gallery_rss_Core { ->order_by("created", "DESC"); $feed->max_pages = ceil($all_items->find_all()->count() / $limit); - $feed->title = t("Recent updates"); + $feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title)); $feed->description = t("Recent updates"); return $feed; @@ -53,7 +53,13 @@ class gallery_rss_Core { ->descendants($limit, $offset, array(array("type", "=", "photo"))); $feed->max_pages = ceil( $item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit); - $feed->title = html::purify($item->title); + if ($item->id == item::root()->id) { + $feed->title = html::purify($item->title); + } else { + $feed->title = t("%site_title - %item_title", + array("site_title" => item::root()->title, + "item_title" => $item->title)); + } $feed->description = nl2br(html::purify($item->description)); return $feed; diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php index ea3865be..f60bd908 100644 --- a/modules/tag/helpers/tag_rss.php +++ b/modules/tag/helpers/tag_rss.php @@ -38,7 +38,8 @@ class tag_rss_Core { $feed = new stdClass(); $feed->items = $tag->items($limit, $offset, "photo"); $feed->max_pages = ceil($tag->count / $limit); - $feed->title = $tag->name; + $feed->title = t("%site_title - %tag_name", + array("site_title" => item::root()->title, "tag_name" => $tag->name)); $feed->description = t("Photos related to %tag_name", array("tag_name" => $tag->name)); return $feed; -- cgit v1.2.3 From ca0c3b3e7f154ffceee944049247e15cf0190e48 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 5 Sep 2010 21:25:46 -0700 Subject: Force "Options +FollowSymLinks" since that's a requirement for mod_rewrite to work. This is surprisingly obscure in the docs. Thanks to bromide for turning this up in http://gallery.menalto.com/node/97791! --- .htaccess | 1 + modules/gallery/helpers/access.php | 1 + 2 files changed, 2 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/.htaccess b/.htaccess index 5e9b96d6..bea9a10a 100644 --- a/.htaccess +++ b/.htaccess @@ -60,6 +60,7 @@ # putting this block into your Apache config files. # # +# Options +FollowSymLinks # RewriteEngine On # RewriteBase / # RewriteCond %{REQUEST_FILENAME} !-f diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index f1ea00c0..86ea9572 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -694,6 +694,7 @@ class access_Core { @mkdir(VARPATH . "security_test"); try { if ($fp = @fopen(VARPATH . "security_test/.htaccess", "w+")) { + fwrite($fp, "Options +FollowSymLinks\n"); fwrite($fp, "RewriteEngine On\n"); fwrite($fp, "RewriteRule verify $success_url [L]\n"); fclose($fp); -- cgit v1.2.3 From 46b30ce949d6371bc3d2bcfe42221c599c7a85e3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 5 Sep 2010 22:00:28 -0700 Subject: Add Setswana (tn_ZA). Fixes ticket #1336. --- modules/gallery/helpers/locales.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index aacb37ca..1f5473ff 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -103,6 +103,7 @@ class locales_Core { $l["sl_SI"] = "Slovenščina"; // Slovenian $l["sr_CS"] = "Srpski"; // Serbian $l["sv_SE"] = "Svenska"; // Swedish + $l["tn_ZA"] = "Setswana"; // Setswana $l["tr_TR"] = "Türkçe"; // Turkish $l["uk_UA"] = "українська"; // Ukrainian $l["vi_VN"] = "Tiếng Việt"; // Vietnamese -- cgit v1.2.3 From b3b6021b0a70979a1084111ae43c1170a7592b37 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 12:41:27 -0700 Subject: Don't bomb on the race condition when we're trying to create the gallery/_cache row and it already exists. Fixes ticket #1338. --- modules/gallery/helpers/module.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index ca6651f1..736b6854 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -448,7 +448,17 @@ class module_Core { $cache->module_name = "gallery"; $cache->name = "_cache"; $cache->value = serialize(self::$var_cache); - $cache->save(); + try { + $cache->save(); + } catch (Database_Exception $e) { + // There's a potential race condition here. Don't fail if that happens because it's + // bound to be transient and not a huge deal, but at least put something in the logs. + if (stristr($e->getMessage(), "duplicate entry")) { + Kohana_Log::add("error", "Failed to cache vars"); + } else { + throw $e; + } + } } } -- cgit v1.2.3 From 2d948cb39fd2da6a5f966a10cbeb4f5d5caec5a3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 14:05:48 -0700 Subject: change the Setswana locale from tn_ZA to tn_BW since it's mostly Botswana anyway according to @sagemaniac in http://gallery.menalto.com/node/97840 --- modules/gallery/helpers/locales.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index 1f5473ff..624ff9cb 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -103,7 +103,7 @@ class locales_Core { $l["sl_SI"] = "Slovenščina"; // Slovenian $l["sr_CS"] = "Srpski"; // Serbian $l["sv_SE"] = "Svenska"; // Swedish - $l["tn_ZA"] = "Setswana"; // Setswana + $l["tn_BW"] = "Setswana"; // Setswana $l["tr_TR"] = "Türkçe"; // Turkish $l["uk_UA"] = "українська"; // Ukrainian $l["vi_VN"] = "Tiếng Việt"; // Vietnamese -- cgit v1.2.3 From 8a36c24f39e7a6111f7872ec443e6efa63580c82 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 18:20:46 -0700 Subject: Fix some broken identity APIs: - add_user_to_group and remove_user_from_group should take Group_Definition instances to be consistent - add_user_to_group and remove_user_from_group in drivers/IdentityProvider.php should not be static --- modules/gallery/helpers/identity.php | 8 ++++---- modules/gallery/libraries/drivers/IdentityProvider.php | 12 ++++++------ modules/user/helpers/group.php | 8 ++++---- modules/user/libraries/drivers/IdentityProvider/Gallery.php | 7 ++----- 4 files changed, 16 insertions(+), 19 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php index 5de05948..5ca024e9 100644 --- a/modules/gallery/helpers/identity.php +++ b/modules/gallery/helpers/identity.php @@ -233,14 +233,14 @@ class identity_Core { /** * @see IdentityProvider_Driver::add_user_to_group. */ - static function add_user_to_group($user, $group_id) { - return IdentityProvider::instance()->add_user_to_group($user, $group_id); + static function add_user_to_group($user, $group) { + return IdentityProvider::instance()->add_user_to_group($user, $group); } /** * @see IdentityProvider_Driver::remove_user_to_group. */ - static function remove_user_from_group($user, $group_id) { - return IdentityProvider::instance()->remove_user_from_group($user, $group_id); + static function remove_user_from_group($user, $group) { + return IdentityProvider::instance()->remove_user_from_group($user, $group); } } \ No newline at end of file diff --git a/modules/gallery/libraries/drivers/IdentityProvider.php b/modules/gallery/libraries/drivers/IdentityProvider.php index 3e85a57b..ac2473f5 100644 --- a/modules/gallery/libraries/drivers/IdentityProvider.php +++ b/modules/gallery/libraries/drivers/IdentityProvider.php @@ -116,17 +116,17 @@ interface IdentityProvider_Driver { /** * Add the user to the specified group - * @param User_Definition the user to add to the group - * @param int the group_id + * @param User_Definition the user to add + * @param Group_Definition the target group */ - static function add_user_to_group($user, $group_id); + public function add_user_to_group($user, $group); /** * Remove the user to the specified group - * @param User_Definition the user to add to the group - * @param int the group id + * @param User_Definition the user to remove + * @param Group_Definition the owning group */ - static function remove_user_from_group($user, $group_id); + public function remove_user_from_group($user, $group); } // End Identity Driver Definition interface Group_Definition {} diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php index c84910f1..88bfac35 100644 --- a/modules/user/helpers/group.php +++ b/modules/user/helpers/group.php @@ -68,13 +68,13 @@ class group_Core { */ private static function _lookup_by_field($field_name, $value) { try { - $user = model_cache::get("group", $value, $field_name); - if ($user->loaded()) { - return $user; + $group = model_cache::get("group", $value, $field_name); + if ($group->loaded()) { + return $group; } } catch (Exception $e) { if (strpos($e->getMessage(), "MISSING_MODEL") === false) { - throw $e; + throw $e; } } return null; diff --git a/modules/user/libraries/drivers/IdentityProvider/Gallery.php b/modules/user/libraries/drivers/IdentityProvider/Gallery.php index 1ed7dd4f..44433ad7 100644 --- a/modules/user/libraries/drivers/IdentityProvider/Gallery.php +++ b/modules/user/libraries/drivers/IdentityProvider/Gallery.php @@ -148,9 +148,7 @@ class IdentityProvider_Gallery_Driver implements IdentityProvider_Driver { /** * @see IdentityProvider_Driver::add_user_to_group. */ - static function add_user_to_group($user, $group_id) { - $group = self::lookup_group($group_id); - + public function add_user_to_group($user, $group) { $group->add($user); $group->save(); } @@ -158,8 +156,7 @@ class IdentityProvider_Gallery_Driver implements IdentityProvider_Driver { /** * @see IdentityProvider_Driver::remove_user_to_group. */ - static function remove_user_from_group($user, $group_id) { - $group = self::lookup_group_by_name($group_id); + public function remove_user_from_group($user, $group_id) { $group->remove($user); $group->save(); } -- cgit v1.2.3 From 886b88fccf5de7fb3b17e1f3a2acd539268d1e8b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 18:49:37 -0700 Subject: Revert "change the Setswana locale from tn_ZA to tn_BW since it's mostly" This reverts commit 2d948cb39fd2da6a5f966a10cbeb4f5d5caec5a3. Valiant said that tn_ZA is right: http://gallery.menalto.com/node/97840#comment-352865 --- modules/gallery/helpers/locales.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index 624ff9cb..1f5473ff 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -103,7 +103,7 @@ class locales_Core { $l["sl_SI"] = "Slovenščina"; // Slovenian $l["sr_CS"] = "Srpski"; // Serbian $l["sv_SE"] = "Svenska"; // Swedish - $l["tn_BW"] = "Setswana"; // Setswana + $l["tn_ZA"] = "Setswana"; // Setswana $l["tr_TR"] = "Türkçe"; // Turkish $l["uk_UA"] = "українська"; // Ukrainian $l["vi_VN"] = "Tiếng Việt"; // Vietnamese -- cgit v1.2.3 From fa1fe47b6a0a377929a70748406eae589ecf2a00 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 22:13:41 -0700 Subject: Use the absolute site url when logging out of the admin site else we wind up with weird url doubling effects. Fixes ticket #1342. --- modules/gallery/helpers/gallery_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index ec7d1882..0ba98025 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -210,7 +210,7 @@ class gallery_event_Core { ->label($user->display_name())); if (Router::$controller == "admin") { - $continue_url = url::site(""); + $continue_url = url::abs_site(""); } else if (isset($theme->item)) { if (access::user_can(identity::guest(), "view", $theme->item)) { $continue_url = $theme->item->abs_url(); -- cgit v1.2.3