From 075cea2a4890e57c60d91157bc33982e34a42a9c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 25 Jul 2010 10:05:09 -0700 Subject: Don't use hardcoded id 1 as the everybody group; it won't work with alternative auth schemes. --- modules/gallery/helpers/access.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 87b6b313..d3f680d2 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -627,7 +627,8 @@ class access_Core { * apply the view and view_full permissions to guest users. */ private static function _update_htaccess_files($album, $group, $perm_name, $value) { - if ($group->id != 1 || !($perm_name == "view" || $perm_name == "view_full")) { + if ($group->id != identity::everybody()->id || + !($perm_name == "view" || $perm_name == "view_full")) { return; } -- cgit v1.2.3 From 055e115b6a8a999285918f666b93562fd7b32ca2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 25 Jul 2010 11:03:32 -0700 Subject: Move the "cancel all" running tasks button up to make it consistent with the "remove all finished" button. --- modules/gallery/views/admin_maintenance.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index ac597715..ad0e2f55 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -41,6 +41,9 @@ count()): ?>
+ " + class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> +

@@ -60,9 +63,6 @@ -- cgit v1.2.3 From 5be9ae3250fab24631c0fc6b900ffccd9b1755f2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 25 Jul 2010 11:10:42 -0700 Subject: Add a new maintenance task that resyncs album .htaccess files with database access intents. Use this to fix up .htaccess files after you relocate your Gallery. Fixes ticket #1252. --- modules/gallery/helpers/access.php | 14 +++++--- modules/gallery/helpers/gallery_task.php | 59 +++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index d3f680d2..b1384c19 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -222,7 +222,7 @@ class access_Core { self::_update_access_non_view_cache($group, $perm_name, $album); } - self::_update_htaccess_files($album, $group, $perm_name, $value); + self::update_htaccess_files($album, $group, $perm_name, $value); model_cache::clear(); } @@ -623,10 +623,16 @@ class access_Core { } /** - * Maintain .htacccess files to prevent direct access to albums, resizes and thumbnails when we - * apply the view and view_full permissions to guest users. + * Rebuild the .htaccess files that prevent direct access to albums, resizes and thumbnails. We + * call this internally any time we change the view or view_full permissions for guest users. + * This function is only public because we use it in maintenance tasks. + * + * @param Item_Model the album + * @param Group_Model the group whose permission is changing + * @param string the permission name + * @param string the new permission value (eg access::DENY) */ - private static function _update_htaccess_files($album, $group, $perm_name, $value) { + public static function update_htaccess_files($album, $group, $perm_name, $value) { if ($group->id != identity::everybody()->id || !($perm_name == "view" || $perm_name == "view_full")) { return; diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 96ea7c0d..4b5e9e93 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -50,7 +50,14 @@ class gallery_task_Core { ->callback("gallery_task::fix_mptt") ->name(t("Fix Album/Photo hierarchy")) ->description(t("Fix problems where your album/photo breadcrumbs are out of " . - "sync with your actual hierarchy.")) + "sync with your actual hierarchy")) + ->severity(log::SUCCESS); + + $tasks[] = Task_Definition::factory() + ->callback("gallery_task::fix_permissions") + ->name(t("Fix permissions")) + ->description(t("Resynchronize database permissions with the .htaccess " . + "files in your gallery3/var directory")) ->severity(log::SUCCESS); return $tasks; @@ -386,4 +393,54 @@ class gallery_task_Core { ->where("id", "=", $id) ->execute(); } + + static function fix_permissions($task) { + $start = microtime(true); + + $total = $task->get("total"); + if (empty($total)) { + $everybody_id = identity::everybody()->id; + $stack = array(); + foreach (db::build() + ->select("id") + ->from("access_intents") + ->where("view_{$everybody_id}", "=", 0) + ->or_where("view_full_{$everybody_id}", "=", 0) + ->execute() as $row) { + $stack[] = $row->id; + } + + $task->set("total", $total = count($stack)); + $task->set("stack", implode(" ", $stack)); + $task->set("completed", 0); + } + + $stack = explode(" ", $task->get("stack")); + $completed = $task->get("completed"); + + while ($stack && microtime(true) - $start < 1.5) { + $album = ORM::factory("item", array_pop($stack)); + $everybody = identity::everybody(); + if (!access::group_can($everybody, "view", $album)) { + access::update_htaccess_files($album, identity::everybody(), "view", access::DENY); + } else { + // It's one or the other, so if they have view then they don't have view_full + access::update_htaccess_files($album, identity::everybody(), "view_full", access::DENY); + } + $completed++; + } + + $task->set("stack", implode(" ", $stack)); + $task->set("completed", $completed); + + if ($total == $completed) { + $task->done = true; + $task->state = "success"; + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / $total); + } + $task->status = t2("One album updated", "%count / %total albums updated", $completed, + array("total" => $total)); + } } \ No newline at end of file -- cgit v1.2.3 From addbd6fb81685e42fb262882dc798b1bd040dd8c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 26 Jul 2010 21:38:40 -0700 Subject: Fix ticket #1253 where the maintenance page bombs if you have already configured your Gallery 2 import but you move your Gallery 3. --- modules/g2_import/helpers/g2_import.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index c0ea09d6..4aa9e642 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -139,6 +139,15 @@ class g2_import_Core { "function G2_Gallery"), array_merge(array("\n"), file("$base_dir/modules/core/classes/Gallery.class")))); + } else { + // Ok, this is a good one. If you're running a bytecode accelerator and you move your + // Gallery install, these files sometimes get cached with the wrong path and then fail to + // load properly. + // Documented in https://sourceforge.net/apps/trac/gallery/ticket/1253 + touch("$mod_path/embed.php"); + touch("$mod_path/main.php"); + touch("$mod_path/bootstrap.inc"); + touch("$mod_path/Gallery.class.inc"); } require("$mod_path/embed.php"); -- cgit v1.2.3 From 2e52bcedcdf6962d51aade9273472d333e91a31a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 10:14:52 -0700 Subject: Update the mock so that all responses return arrays, not stdClass(). --- modules/rest/tests/Rest_Controller_Test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php index 0c8a4a98..43139d29 100644 --- a/modules/rest/tests/Rest_Controller_Test.php +++ b/modules/rest/tests/Rest_Controller_Test.php @@ -142,8 +142,8 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { } class mock_rest { - static function get($request) { return $request; } - static function post($request) { return $request; } - static function put($request) { return $request; } - static function delete($request) { return $request; } + static function get($request) { return (array)$request; } + static function post($request) { return (array)$request; } + static function put($request) { return (array)$request; } + static function delete($request) { return (array)$request; } } \ No newline at end of file -- cgit v1.2.3 From 52f1c4b8c6a3a4043fcca3901a659b140b77f9d9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 10:49:47 -0700 Subject: Don't invoke a graphics toolkit when setting the album cover from a clean thumbnail; we can just copy it over. Should be a decent perf improvement in many cases. Fixes ticket #1255. --- modules/gallery/helpers/item.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 8fea49cc..092904a5 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -105,9 +105,15 @@ class item_Core { model_cache::clear(); $parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id; - $parent->thumb_dirty = 1; + if ($item->thumb_dirty) { + $parent->thumb_dirty = 1; + graphics::generate($parent); + } else { + copy($item->thumb_path(), $parent->thumb_path()); + $parent->thumb_width = $item->thumb_width; + $parent->thumb_height = $item->thumb_height; + } $parent->save(); - graphics::generate($parent); $grand_parent = $parent->parent(); if ($grand_parent && access::can("edit", $grand_parent) && $grand_parent->album_cover_item_id == null) { -- cgit v1.2.3 From f9137c756e325a629dbe3e28ca351871c12477c5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 10:53:31 -0700 Subject: Updated --- modules/gallery/tests/controller_auth_data.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index f7ceed90..3c9b3afc 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -9,8 +9,6 @@ modules/gallery/controllers/albums.php show modules/gallery/controllers/combined.php javascript DIRTY_AUTH modules/gallery/controllers/combined.php css DIRTY_AUTH modules/gallery/controllers/file_proxy.php __call DIRTY_CSRF|DIRTY_AUTH -modules/gallery/controllers/flash_uploader.php start DIRTY_AUTH -modules/gallery/controllers/flash_uploader.php finish DIRTY_AUTH modules/gallery/controllers/login.php ajax DIRTY_AUTH modules/gallery/controllers/login.php auth_ajax DIRTY_AUTH modules/gallery/controllers/login.php html DIRTY_AUTH @@ -19,6 +17,8 @@ modules/gallery/controllers/logout.php index modules/gallery/controllers/maintenance.php index DIRTY_AUTH modules/gallery/controllers/quick.php form_edit DIRTY_CSRF modules/gallery/controllers/upgrader.php index DIRTY_AUTH +modules/gallery/controllers/uploader.php start DIRTY_AUTH +modules/gallery/controllers/uploader.php finish DIRTY_AUTH modules/gallery/controllers/user_profile.php show DIRTY_AUTH modules/gallery/controllers/user_profile.php contact DIRTY_AUTH modules/gallery/controllers/user_profile.php send DIRTY_AUTH -- cgit v1.2.3 From 84a50e737b54acbe4a8c47b6038c45cd709c2e7c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 11:18:55 -0700 Subject: Fix the "get flashplayer" button. It was throwing a JS error before. Not sure why it was done in JS in the first place. Fixes ticket #1256. --- modules/organize/views/organize_dialog.html.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 4e8ada80..4cc6385e 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -127,16 +127,14 @@

html::purify($album->title))) ?>

-
-

- $flash_minimum_version)) ?> -

- -
+
+

+ $flash_minimum_version)) ?> +

+ + <?=for_js() ?> /> + +
-- cgit v1.2.3 From bf1e1d3d1f523ff789b137e115b95e69cf6c5b13 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 11:19:48 -0700 Subject: Verified --- modules/gallery/tests/xss_data.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 475f75c1..02483865 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -76,7 +76,7 @@ modules/gallery/views/admin_languages.html.php 61 DIRTY_ATTR ($de modules/gallery/views/admin_languages.html.php 62 DIRTY form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) modules/gallery/views/admin_languages.html.php 63 DIRTY $display_name modules/gallery/views/admin_languages.html.php 65 DIRTY form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) -modules/gallery/views/admin_languages.html.php 110 DIRTY $share_translations_form +modules/gallery/views/admin_languages.html.php 113 DIRTY $share_translations_form modules/gallery/views/admin_maintenance.html.php 24 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_maintenance.html.php 24 DIRTY_ATTR log::severity_class($task->severity) modules/gallery/views/admin_maintenance.html.php 25 DIRTY_ATTR log::severity_class($task->severity) @@ -167,7 +167,7 @@ modules/gallery/views/error_admin.html.php 251 DIRTY_ATTR $env modules/gallery/views/error_admin.html.php 257 DIRTY $key modules/gallery/views/error_admin.html.php 261 DIRTY Kohana_Exception::safe_dump($value,$key) modules/gallery/views/form_uploadify.html.php 9 DIRTY_JS url::file("lib/uploadify/uploadify.swf") -modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("flash_uploader/add_photo/{$album->id}") +modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("uploader/add_photo/{$album->id}") modules/gallery/views/form_uploadify.html.php 14 DIRTY_JS url::file("lib/uploadify/cancel.png") modules/gallery/views/form_uploadify.html.php 15 DIRTY_JS $simultaneous_upload_limit modules/gallery/views/in_place_edit.html.php 2 DIRTY form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form")) @@ -206,9 +206,9 @@ modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu- modules/gallery/views/menu_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":"" modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url -modules/gallery/views/move_browse.html.php 4 DIRTY_JS url::site("move/show_sub_tree/{$source->id}/__TARGETID__") -modules/gallery/views/move_browse.html.php 39 DIRTY $tree -modules/gallery/views/move_browse.html.php 43 DIRTY access::csrf_form_field() +modules/gallery/views/move_browse.html.php 5 DIRTY_JS url::site("move/show_sub_tree/{$source->id}/__TARGETID__") +modules/gallery/views/move_browse.html.php 40 DIRTY $tree +modules/gallery/views/move_browse.html.php 44 DIRTY access::csrf_form_field() modules/gallery/views/move_tree.html.php 2 DIRTY $parent->thumb_img(array(),25); modules/gallery/views/move_tree.html.php 4 DIRTY_JS $parent->id modules/gallery/views/move_tree.html.php 6 DIRTY_JS $parent->id @@ -255,14 +255,14 @@ modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $permi modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $item->id modules/gallery/views/quick_delete_confirm.html.php 11 DIRTY $form modules/gallery/views/reauthenticate.html.php 9 DIRTY $form -modules/gallery/views/upgrader.html.php 57 DIRTY_ATTR $done?"muted":"" -modules/gallery/views/upgrader.html.php 61 DIRTY_ATTR $done?"muted":"" -modules/gallery/views/upgrader.html.php 69 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable" -modules/gallery/views/upgrader.html.php 70 DIRTY_ATTR $id -modules/gallery/views/upgrader.html.php 74 DIRTY $module->version -modules/gallery/views/upgrader.html.php 77 DIRTY $module->code_version -modules/gallery/views/upgrader.html.php 99 DIRTY_ATTR $done?"muted":"" -modules/gallery/views/upgrader.html.php 102 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 59 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 63 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 71 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable" +modules/gallery/views/upgrader.html.php 72 DIRTY_ATTR $id +modules/gallery/views/upgrader.html.php 76 DIRTY $module->version +modules/gallery/views/upgrader.html.php 79 DIRTY $module->code_version +modules/gallery/views/upgrader.html.php 101 DIRTY_ATTR $done?"muted":"" +modules/gallery/views/upgrader.html.php 104 DIRTY_ATTR $done?"muted":"" modules/gallery/views/user_languages_block.html.php 2 DIRTY form::dropdown("g-select-session-locale",$installed_locales,$selected) modules/gallery/views/user_profile.html.php 34 DIRTY_ATTR $user->avatar_url(40,$theme->url(,true)) modules/gallery/views/user_profile.html.php 43 DIRTY $info->view @@ -289,7 +289,9 @@ modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $sort_ modules/organize/views/organize_dialog.html.php 96 DIRTY_JS $album->id modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $rest_uri modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $controller_uri +modules/organize/views/organize_dialog.html.php 104 DIRTY_JS $flash_minimum_version="10.0.0" modules/organize/views/organize_dialog.html.php 122 DIRTY_JS $swf_uri +modules/organize/views/organize_dialog.html.php 136 DIRTY_ATTR request::protocol() modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key -- cgit v1.2.3 From 185a736ff916b420a6f29f44a545cde05593bbc0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 11:27:46 -0700 Subject: Revert "Combine all the flex runtime libraries into a single downloadable file. Fixes ticket #1241." This breaks organize on Chrome 5 (Linux) and Chrome 6 (OSX). See ticket #1241. This reverts commit 423fca2d5ffca1e953694793ad118589db1756d0. --- modules/organize/lib/Gallery3WebClient.swf | Bin 760853 -> 147776 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 modules/organize/lib/Gallery3WebClient.swf (limited to 'modules') diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf old mode 100755 new mode 100644 index e6b70922..40249a73 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From dd955781aaa9c1ee9e780b6b2c545878a47bbf21 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 19:54:41 -0700 Subject: "public static" ==> "static" to match code conventions. --- modules/gallery/helpers/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index b1384c19..f1ea00c0 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -632,7 +632,7 @@ class access_Core { * @param string the permission name * @param string the new permission value (eg access::DENY) */ - public static function update_htaccess_files($album, $group, $perm_name, $value) { + static function update_htaccess_files($album, $group, $perm_name, $value) { if ($group->id != identity::everybody()->id || !($perm_name == "view" || $perm_name == "view_full")) { return; -- cgit v1.2.3
- " - class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> -