From 9bede5763a63bec7b1a7ea2ba9f4e8cea33087d5 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 6 Feb 2010 13:15:02 -0800 Subject: Fix g2_import admin screen: It wouldn't work if it didn't know the location of G2 yet. --- modules/g2_import/controllers/admin_g2_import.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/controllers') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 6dd155b9..f216091a 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -32,13 +32,14 @@ class Admin_g2_import_Controller extends Admin_Controller { $view = new Admin_View("admin.html"); $view->content = new View("admin_g2_import.html"); $view->content->form = $this->_get_import_form(); - $view->content->version = g2_import::version(); + $view->content->version = ''; if (g2_import::is_initialized()) { $view->content->g2_stats = $g2_stats; $view->content->g2_sizes = $g2_sizes; $view->content->thumb_size = module::get_var("gallery", "thumb_size"); $view->content->resize_size = module::get_var("gallery", "resize_size"); + $view->content->version = g2_import::version(); } g2_import::restore_error_reporting(); print $view; -- cgit v1.2.3 From d069155228acb9c9e86814a89cb2400434d18321 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 6 Feb 2010 15:08:10 -0800 Subject: Fix g2 redirects for non-admins. The g2 URL mapping controller was accidentally declared as admin controller. (The previous attempt to fix this isn't a bad change either, thus keeping the external permenant redirect). --- modules/g2_import/controllers/g2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/g2_import/controllers') diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 5fd4400c..70461600 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class G2_Controller extends Admin_Controller { +class G2_Controller extends Controller { /** * Redirect Gallery 2 urls to their appropriate matching Gallery 3 url. * -- cgit v1.2.3 From 33b39efb491d730c8653ca3c06a22297338aa8b8 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 6 Feb 2010 15:46:13 -0800 Subject: Add core.DownloadItem redirect for G2's Photo and Movie items (was previously omitted, but we already had core.DownloadItem redirects for derivatives) --- modules/g2_import/controllers/g2.php | 1 + modules/g2_import/helpers/g2_import.php | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'modules/g2_import/controllers') diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 70461600..8260cf9f 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -64,6 +64,7 @@ class G2_Controller extends Controller { case "resize": url::redirect($item->resize_url(true)); + case "file": case "full": url::redirect($item->file_url(true)); diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 0fcc0539..f13c63b1 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -541,6 +541,10 @@ class g2_import_Core { $item->save(); self::set_map($g2_item_id, $item->id, "item", $g2_item_url); + + self::set_map($g2_item_id, $item->id, "file", + self::g2_url(array("view" => "core.DownloadItem", "itemId" => $g2_item_id))); + $derivatives = g2(GalleryCoreApi::fetchDerivativesByItemIds(array($g2_item_id))); if (!empty($derivatives[$g2_item_id])) { foreach ($derivatives[$g2_item_id] as $derivative) { -- cgit v1.2.3 From 7232b6c026c3fe371b6846a8a4536a1b661804c4 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 6 Feb 2010 16:29:51 -0800 Subject: Fixing G2 url mapping for G2 default style URLs (where ShowItem and DownloadItem URLs aren't rewritten in G2). Note: For a perfect solution, we should add 2 map entries for each of G2's ShowItem and DownloadItem URLs, one for short and one for long style URLs. E.g. A G2 installation might have been using short style URLs not for its complete lifetime. And long style URLs are supposed to work in G2 even when short style URLs are enabled (and its used that way in bbcode / as a way to get permenant, id based URLs from G2). --- modules/g2_import/controllers/g2.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'modules/g2_import/controllers') diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 8260cf9f..347da649 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -35,15 +35,25 @@ class G2_Controller extends Controller { $id = $input->get("g2_itemId"); if ($id) { - $where = array("g2_id", "=", $id); + // Requests by id are either core.DownloadItem or + // core.ShowItem requests. + // Later versions of Gallery 2 don't specify g2_view if + // it's the default (core.ShowItem). + // And in some cases (bbcode, embedding) people are using + // the id style URLs although URL rewriting is enabled. + $where = array(array("g2_id", "=", $id)); + $view = $input->get("g2_view"); + if ($view) { + $where[] = array("g2_url", "like", "%g2_view=$view%"); + } // else: Assuming that the first search hit is sufficiently good. } else if ($path) { - $where = array("g2_url", "=", $path); + $where = array(array("g2_url", "=", $path)); } else { throw new Kohana_404_Exception(); } $g2_map = ORM::factory("g2_map") - ->merge_where(array($where)) + ->merge_where($where) ->find(); if (!$g2_map->loaded()) { -- cgit v1.2.3 From c0a598417cc1f9a5534348ec5edb9c138293bc01 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Tue, 9 Feb 2010 13:54:14 -0800 Subject: Change access::can to access::required in g2 redirect, to please the controller auth code audit test. --- modules/g2_import/controllers/g2.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/controllers') diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 347da649..1d97653a 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -61,9 +61,10 @@ class G2_Controller extends Controller { } $item = ORM::factory("item", $g2_map->g3_id); - if (!$item->loaded() || !access::can("view", $item)) { + if (!$item->loaded()) { throw new Kohana_404_Exception(); } + access::required("view", $item); // Redirect the user to the new url -- cgit v1.2.3