From 45c63f4d118bfc99924edb8685442035349af6db Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Wed, 15 Dec 2010 12:48:56 -0800
Subject: Use mt_rand() instead of rand() since it provides better portability.
Fixes #1527.
---
modules/gallery/controllers/upgrader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index b2646874..50f6b8f0 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -23,7 +23,7 @@ class Upgrader_Controller extends Controller {
// Make sure we have an upgrade token
if (!($upgrade_token = $session->get("upgrade_token", null))) {
- $session->set("upgrade_token", $upgrade_token = md5(rand()));
+ $session->set("upgrade_token", $upgrade_token = md5(time() . mt_rand()));
}
// If the upgrade token exists, then bless this session
--
cgit v1.2.3
From cd48b89f3166e7fa732b5cb06d33fba018af9127 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Wed, 15 Dec 2010 14:57:00 -0800
Subject: Consolidate all the random code into a random helper that offers:
random::hash() random::string() random::percent() random::int()
So that we don't have lots of different ways to get random values all
over the code. Follow-on to #1527.
---
modules/digibug/controllers/digibug.php | 2 +-
modules/digibug/tests/Digibug_Controller_Test.php | 2 +-
modules/gallery/controllers/upgrader.php | 2 +-
modules/gallery/helpers/access.php | 2 +-
modules/gallery/helpers/block_manager.php | 2 +-
modules/gallery/helpers/gallery_installer.php | 4 +-
modules/gallery/helpers/item.php | 2 +-
modules/gallery/helpers/random.php | 50 +++++++++++++++++++++++
modules/gallery/models/item.php | 6 +--
modules/gallery/tests/Albums_Controller_Test.php | 2 +-
modules/gallery/tests/Cache_Test.php | 30 +++++++-------
modules/gallery/tests/Item_Helper_Test.php | 2 +-
modules/gallery/tests/Item_Model_Test.php | 14 +++----
modules/gallery_unit_test/helpers/test.php | 12 +++---
modules/rest/helpers/rest.php | 2 +-
modules/rest/helpers/rest_event.php | 6 +--
modules/user/controllers/password.php | 2 +-
17 files changed, 96 insertions(+), 46 deletions(-)
create mode 100644 modules/gallery/helpers/random.php
(limited to 'modules/gallery/controllers')
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index a9e49de7..bc0c7c5e 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -28,7 +28,7 @@ class Digibug_Controller extends Controller {
$thumb_url = $item->thumb_url(true);
} else {
$proxy = ORM::factory("digibug_proxy");
- $proxy->uuid = md5(mt_rand());
+ $proxy->uuid = random::hash();
$proxy->item_id = $item->id;
$proxy->save();
$full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid");
diff --git a/modules/digibug/tests/Digibug_Controller_Test.php b/modules/digibug/tests/Digibug_Controller_Test.php
index 6f9e20df..d331b0ae 100644
--- a/modules/digibug/tests/Digibug_Controller_Test.php
+++ b/modules/digibug/tests/Digibug_Controller_Test.php
@@ -36,7 +36,7 @@ class Digibug_Controller_Test extends Gallery_Unit_Test_Case {
access::deny(identity::registered_users(), "view_full", $album);
$proxy = ORM::factory("digibug_proxy");
- $proxy->uuid = md5(mt_rand());
+ $proxy->uuid = random::hash();
$proxy->item_id = $photo->id;
return $proxy->save();
}
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index 50f6b8f0..66c71648 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -23,7 +23,7 @@ class Upgrader_Controller extends Controller {
// Make sure we have an upgrade token
if (!($upgrade_token = $session->get("upgrade_token", null))) {
- $session->set("upgrade_token", $upgrade_token = md5(time() . mt_rand()));
+ $session->set("upgrade_token", $upgrade_token = random::hash());
}
// If the upgrade token exists, then bless this session
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 6a948999..a7ac3f9f 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -426,7 +426,7 @@ class access_Core {
$session = Session::instance();
$csrf = $session->get("csrf");
if (empty($csrf)) {
- $csrf = md5(time() . mt_rand());
+ $csrf = random::hash();
$session->set("csrf", $csrf);
}
return $csrf;
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php
index e7247edc..4bd649c2 100644
--- a/modules/gallery/helpers/block_manager.php
+++ b/modules/gallery/helpers/block_manager.php
@@ -28,7 +28,7 @@ class block_manager_Core {
static function add($location, $module_name, $block_id) {
$blocks = block_manager::get_active($location);
- $blocks[mt_rand()] = array($module_name, $block_id);
+ $blocks[random::int()] = array($module_name, $block_id);
block_manager::set_active($location, $blocks);
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 9c42caad..a6b8e6a2 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -459,7 +459,7 @@ class gallery_installer {
$blocks = block_manager::get_active($location);
$new_blocks = array();
foreach ($blocks as $block) {
- $new_blocks[mt_rand()] = $block;
+ $new_blocks[random::int()] = $block;
}
block_manager::set_active($location, $new_blocks);
}
@@ -507,7 +507,7 @@ class gallery_installer {
->execute() as $row) {
$new_slug = item::convert_filename_to_slug($row->slug);
if (empty($new_slug)) {
- $new_slug = mt_rand();
+ $new_slug = random::int();
}
db::build()
->update("items")
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 052b1c8e..664da812 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -232,7 +232,7 @@ class item_Core {
// distributed so this is going to be more efficient with larger data sets.
return ORM::factory("item")
->viewable()
- ->where("rand_key", "<", ((float)mt_rand()) / (float)mt_getrandmax())
+ ->where("rand_key", "<", random::percent())
->order_by("rand_key", "DESC");
}
}
\ No newline at end of file
diff --git a/modules/gallery/helpers/random.php b/modules/gallery/helpers/random.php
new file mode 100644
index 00000000..a26762bd
--- /dev/null
+++ b/modules/gallery/helpers/random.php
@@ -0,0 +1,50 @@
+loaded()) {
// Set reasonable defaults
$this->created = time();
- $this->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
+ $this->rand_key = random::percent();
$this->thumb_dirty = 1;
$this->resize_dirty = 1;
$this->sort_column = "created";
@@ -390,7 +390,7 @@ class Item_Model_Core extends ORM_MPTT {
if (file_exists($this->resize_path()) ||
file_exists($this->thumb_path())) {
$pi = pathinfo($this->name);
- $this->name = $pi["filename"] . "-" . mt_rand() . "." . $pi["extension"];
+ $this->name = $pi["filename"] . "-" . random::int() . "." . $pi["extension"];
parent::save();
}
@@ -512,7 +512,7 @@ class Item_Model_Core extends ORM_MPTT {
->or_where("slug", "=", $this->slug)
->close()
->find()->id) {
- $rand = mt_rand();
+ $rand = random::int();
if ($base_ext) {
$this->name = "$base_name-$rand.$base_ext";
} else {
diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php
index 86c74890..35a3bdbb 100644
--- a/modules/gallery/tests/Albums_Controller_Test.php
+++ b/modules/gallery/tests/Albums_Controller_Test.php
@@ -31,7 +31,7 @@ class Albums_Controller_Test extends Gallery_Unit_Test_Case {
$album = test::random_album();
// Randomize to avoid conflicts.
- $new_name = "new_name_" . mt_rand();
+ $new_name = "new_name_" . random::string(6);
$_POST["name"] = $new_name;
$_POST["title"] = "new title";
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index 6cee2862..b95ef0a2 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -27,7 +27,7 @@ class Cache_Test extends Gallery_Unit_Test_Case {
public function cache_exists_test() {
$this->assert_false($this->_driver->exists("test_key"), "test_key should not be defined");
- $id = md5(mt_rand());
+ $id = random::hash();
db::build()
->insert("caches")
->columns("key", "tags", "expiration", "cache")
@@ -38,7 +38,7 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_get_test() {
- $id = md5(mt_rand());
+ $id = random::hash();
db::build()
->insert("caches")
@@ -54,7 +54,7 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_set_test() {
- $id = md5(mt_rand());
+ $id = random::hash();
$original_data = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id => $original_data), array("tag1", "tag2"), 84600);
@@ -63,15 +63,15 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_get_tag_test() {
- $id1 = md5(mt_rand());
+ $id1 = random::hash();
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(mt_rand());
+ $id2 = random::hash();
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 84600);
- $id3 = md5(mt_rand());
+ $id3 = random::hash();
$value3 = array("field5" => "value5", "field6" => "value6");
$this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
@@ -86,15 +86,15 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_delete_id_test() {
- $id1 = md5(mt_rand());
+ $id1 = random::hash();
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(mt_rand());
+ $id2 = random::hash();
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(mt_rand());
+ $id3 = random::hash();
$value3 = array("field5" => "value5", "field6" => "value6");
$this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
@@ -106,15 +106,15 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_delete_tag_test() {
- $id1 = md5(mt_rand());
+ $id1 = random::hash();
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(mt_rand());
+ $id2 = random::hash();
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(mt_rand());
+ $id3 = random::hash();
$value3 = array("field5" => "value5", "field6" => "value6");
$this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
@@ -126,15 +126,15 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_delete_all_test() {
- $id1 = md5(mt_rand());
+ $id1 = random::hash();
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(mt_rand());
+ $id2 = random::hash();
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(mt_rand());
+ $id3 = random::hash();
$value3 = array("field5" => "value5", "field6" => "value6");
$this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index c93cc239..26db5a63 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -92,7 +92,7 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
}
public function move_conflicts_result_in_a_rename_test() {
- $rand = mt_rand();
+ $rand = random::int();
$photo1 = test::random_photo_unsaved(item::root());
$photo1->name = "{$rand}.jpg";
$photo1->slug = (string)$rand;
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 0d6d10af..4987d2f9 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -278,10 +278,10 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
public function basic_validation_test() {
$item = ORM::factory("item");
- $item->album_cover_item_id = mt_rand(); // invalid
+ $item->album_cover_item_id = random::int(); // invalid
$item->description = str_repeat("x", 70000); // invalid
$item->name = null;
- $item->parent_id = mt_rand();
+ $item->parent_id = random::int();
$item->slug = null;
$item->sort_column = "bogus";
$item->sort_order = "bogus";
@@ -411,24 +411,24 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
public function urls_test() {
$photo = test::random_photo();
$this->assert_true(
- preg_match("|http://./var/resizes/name_\d+\.jpg\?m=\d+|", $photo->resize_url()),
+ preg_match("|http://./var/resizes/name_\w+\.jpg\?m=\d+|", $photo->resize_url()),
$photo->resize_url() . " is malformed");
$this->assert_true(
- preg_match("|http://./var/thumbs/name_\d+\.jpg\?m=\d+|", $photo->thumb_url()),
+ preg_match("|http://./var/thumbs/name_\w+\.jpg\?m=\d+|", $photo->thumb_url()),
$photo->thumb_url() . " is malformed");
$this->assert_true(
- preg_match("|http://./var/albums/name_\d+\.jpg\?m=\d+|", $photo->file_url()),
+ preg_match("|http://./var/albums/name_\w+\.jpg\?m=\d+|", $photo->file_url()),
$photo->file_url() . " is malformed");
// Albums have special thumbnails. Empty album has cachebuster of 0 since it has no thumbnail
$album = test::random_album();
$this->assert_true(
- preg_match("|http://./var/thumbs/name_\d+/\.album\.jpg\?m=0|", $album->thumb_url()),
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=0|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
$photo = test::random_photo($album);
$this->assert_true(
- preg_match("|http://./var/thumbs/name_\d+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
}
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php
index d5149492..65c7f6b4 100644
--- a/modules/gallery_unit_test/helpers/test.php
+++ b/modules/gallery_unit_test/helpers/test.php
@@ -19,7 +19,7 @@
*/
class test_Core {
static function random_album_unsaved($parent=null) {
- $rand = mt_rand();
+ $rand = random::string(6);
$album = ORM::factory("item");
$album->type = "album";
@@ -34,7 +34,7 @@ class test_Core {
}
static function random_photo_unsaved($parent=null) {
- $rand = mt_rand();
+ $rand = random::string(6);
$photo = ORM::factory("item");
$photo->type = "photo";
$photo->parent_id = $parent ? $parent->id : 1;
@@ -49,16 +49,16 @@ class test_Core {
}
static function random_user($password="password") {
- $rand = "name_" . mt_rand();
+ $rand = "name_" . random::string(6);
return identity::create_user($rand, $rand, $password, "$rand@rand.com");
}
static function random_group() {
- return identity::create_group((string)mt_rand());
+ return identity::create_group(random::string(6));
}
static function random_name($item=null) {
- $rand = "name_" . mt_rand();
+ $rand = "name_" . random::string(6);
if ($item && $item->is_photo()) {
$rand .= ".jpg";
}
@@ -77,7 +77,7 @@ class test_Core {
static function random_tag() {
$tag = ORM::factory("tag");
- $tag->name = (string)mt_rand();
+ $tag->name = random::string(6);
// Reload so that ORM coerces all fields into strings.
return $tag->save()->reload();
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index 58943700..9406e209 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -104,7 +104,7 @@ class rest_Core {
if (!$key->loaded()) {
$key->user_id = identity::active_user()->id;
- $key->access_key = md5(md5(uniqid(mt_rand(), true) . access::private_key()));
+ $key->access_key = md5(random::hash() . access::private_key());
$key->save();
}
diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php
index 4d7a4a1b..9e241bd0 100644
--- a/modules/rest/helpers/rest_event.php
+++ b/modules/rest/helpers/rest_event.php
@@ -43,7 +43,7 @@ class rest_event {
static function user_add_form_admin_completed($user, $form) {
$key = ORM::factory("user_access_key");
$key->user_id = $user->id;
- $key->access_key = md5($user->name . time() . mt_rand());
+ $key->access_key = random::hash($user->name);
$key->save();
}
@@ -64,7 +64,7 @@ class rest_event {
if (!$key->loaded()) {
$key->user_id = $user->id;
- $key->access_key = md5($user->name . time() . mt_rand());
+ $key->access_key = random::hash($user->name);
$key->save();
}
@@ -93,7 +93,7 @@ class rest_event {
if (!$key->loaded()) {
$key->user_id = $data->user->id;
- $key->access_key = md5($data->user->name . time() . mt_rand());
+ $key->access_key = random::hash($data->user->name);
$key->save();
}
$view->rest_key = $key->access_key;
diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php
index 2e5eac5f..567e56dc 100644
--- a/modules/user/controllers/password.php
+++ b/modules/user/controllers/password.php
@@ -51,7 +51,7 @@ class Password_Controller extends Controller {
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
- $user->hash = md5(uniqid(mt_rand(), true));
+ $user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key=$user->hash");
--
cgit v1.2.3
From c5ede5881bfdc0544e1ab59984dad7e7dc20a6ac Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 19:36:23 -0800
Subject: Updated to use the new item::find_by_path() API.
---
modules/gallery/controllers/file_proxy.php | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index b17310c4..22854fbd 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -56,28 +56,16 @@ class File_Proxy_Controller extends Controller {
// If the last element is .album.jpg, pop that off since it's not a real item
$path = preg_replace("|/.album.jpg$|", "", $path);
- $encoded_path = array();
- foreach (explode("/", $path) as $path_part) {
- $encoded_path[] = rawurlencode($path_part);
- }
- $encoded_path = implode("/", $encoded_path);
- // We now have the relative path to the item. Search for it in the path cache
- // The patch cache is urlencoded so re-encode the path. (it was decoded earlier to
- // insure that the paths are normalized.
- $item = ORM::factory("item")
- ->where("relative_path_cache", "=", $encoded_path)->find();
- if (!$item->loaded()) {
- // We didn't turn it up. It's possible that the relative_path_cache is out of date here.
- // There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be
- // necessary, it's easily resurrected.
- // If we're looking for a .jpg then it's it's possible that we're requesting the thumbnail
- // for a movie. In that case, the .flv, .mp4 or .m4v file would have been converted to a
- // .jpg. So try some alternate types:
+ $item = item::find_by_path($path);
+ if (!$item->loaded()) {
+ // We didn't turn it up. If we're looking for a .jpg then it's it's possible that we're
+ // requesting the thumbnail for a movie. In that case, the .flv, .mp4 or .m4v file would
+ // have been converted to a .jpg. So try some alternate types:
if (preg_match('/.jpg$/', $path)) {
foreach (array("flv", "mp4", "m4v") as $ext) {
- $movie_path = preg_replace('/.jpg$/', ".$ext", $encoded_path);
- $item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find();
+ $movie_path = preg_replace('/.jpg$/', ".$ext", $path);
+ $item = item::find_by_path($movie_path);
if ($item->loaded()) {
break;
}
--
cgit v1.2.3
From b5ba61fc53e44d55978dd0d35ada80da4c47715d Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 23 Dec 2010 23:34:04 -0800
Subject: Create a way for controllers to exempty themselves from maintenance
mode and private gallery mode by setting the following constants in the
controller to true.
ALLOW_MAINTENANCE_MODE
ALLOW_PRIVATE_GALLERY
Fixes #1411 and the subsequent refactoring fixes #1551 as well.
---
modules/digibug/controllers/digibug.php | 2 +
modules/gallery/controllers/combined.php | 3 ++
modules/gallery/controllers/login.php | 2 +
modules/gallery/helpers/gallery.php | 68 ++++++++++++++++++--------------
modules/rest/controllers/rest.php | 2 +
5 files changed, 48 insertions(+), 29 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index bc0c7c5e..22bbe1a6 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Digibug_Controller extends Controller {
+ const ALLOW_PRIVATE_GALLERY = true;
+
public function print_photo($id) {
access::verify_csrf();
$item = ORM::factory("item", $id);
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php
index 4b1a342a..64f8d22b 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Combined_Controller extends Controller {
+ const ALLOW_MAINTENANCE_MODE = true;
+ const ALLOW_PRIVATE_GALLERY = true;
+
/**
* Return the combined Javascript bundle associated with the given key.
*/
diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php
index 62d33345..adb2e50b 100644
--- a/modules/gallery/controllers/login.php
+++ b/modules/gallery/controllers/login.php
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Login_Controller extends Controller {
+ const ALLOW_MAINTENANCE_MODE = true;
+ const ALLOW_PRIVATE_GALLERY = true;
public function ajax() {
$view = new View("login_ajax.html");
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 2bb55ccb..69aabc4f 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -25,18 +25,27 @@ class gallery_Core {
* down for maintenance" page.
*/
static function maintenance_mode() {
- // @todo: we need a mechanism here to identify controllers that are still legally accessible
- // when the entire Gallery is in maintenance mode. Perhaps a controller class function or
- // method?
- // https://sourceforge.net/apps/trac/gallery/ticket/1411
- if (Router::$controller != "login" &&
- Router::$controller != "combined" &&
- module::get_var("gallery", "maintenance_mode", 0) &&
+ if (module::get_var("gallery", "maintenance_mode", 0) &&
!identity::active_user()->admin) {
- Session::instance()->set("continue_url", url::abs_site("admin/maintenance"));
- Router::$controller = "login";
- Router::$controller_path = MODPATH . "gallery/controllers/login.php";
- Router::$method = "html";
+ try {
+ $class = new ReflectionClass(ucfirst(Router::$controller).'_Controller');
+ $allowed = $class->getConstant("ALLOW_MAINTENANCE_MODE") === true;
+ } catch (ReflectionClass $e) {
+ $allowed = false;
+ }
+ if (!$allowed) {
+ 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_site("admin/maintenance"));
+ Router::$controller = "login";
+ Router::$controller_path = MODPATH . "gallery/controllers/login.php";
+ Router::$method = "html";
+ }
+ }
}
}
@@ -45,26 +54,27 @@ class gallery_Core {
* the login page.
*/
static function private_gallery() {
- // @todo: we need a mechanism here to identify controllers that are still legally accessible
- // when the entire Gallery is private. Perhaps a controller class function or method?
- // https://sourceforge.net/apps/trac/gallery/ticket/1411
- if (Router::$controller != "login" &&
- Router::$controller != "combined" &&
- Router::$controller != "digibug" &&
- Router::$controller != "rest" &&
- identity::active_user()->guest &&
+ if (identity::active_user()->guest &&
!access::user_can(identity::guest(), "view", item::root()) &&
php_sapi_name() != "cli") {
- 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";
+ try {
+ $class = new ReflectionClass(ucfirst(Router::$controller).'_Controller');
+ $allowed = $class->getConstant("ALLOW_PRIVATE_GALLERY") === true;
+ } catch (ReflectionClass $e) {
+ $allowed = false;
+ }
+ if (!$allowed) {
+ 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";
+ }
}
}
}
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index c4e0fda4..00c7cda2 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Rest_Controller extends Controller {
+ const ALLOW_PRIVATE_GALLERY = true;
+
public function index() {
$username = Input::instance()->post("user");
$password = Input::instance()->post("password");
--
cgit v1.2.3
From b42fcb9cda4dafdb9db86770f54965b3fb2fc7ab Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 28 Dec 2010 23:10:05 -0800
Subject: Use db::expr instead of "new Database_Expression". Resolves #1560.
---
.../comment/controllers/admin_manage_comments.php | 2 +-
modules/digibug/controllers/digibug.php | 2 +-
modules/gallery/controllers/admin_maintenance.php | 2 +-
modules/gallery/helpers/gallery_installer.php | 6 +++---
modules/gallery/helpers/gallery_task.php | 6 +++---
modules/gallery/helpers/module.php | 2 +-
modules/gallery/libraries/ORM_MPTT.php | 22 +++++++++++-----------
modules/gallery/tests/Gallery_Installer_Test.php | 2 +-
modules/notification/helpers/notification.php | 2 +-
modules/tag/helpers/tag.php | 2 +-
10 files changed, 24 insertions(+), 24 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php
index 49bd85d5..ec876fc4 100644
--- a/modules/comment/controllers/admin_manage_comments.php
+++ b/modules/comment/controllers/admin_manage_comments.php
@@ -25,7 +25,7 @@ class Admin_Manage_Comments_Controller extends Admin_Controller {
db::build()
->delete("comments")
->where("state", "IN", array("deleted", "spam"))
- ->where("updated", "<", new Database_Expression("UNIX_TIMESTAMP() - 86400 * 7"))
+ ->where("updated", "<", db::expr("UNIX_TIMESTAMP() - 86400 * 7"))
->execute();
// Redirect to the appropriate queue
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index 22bbe1a6..c48e3e87 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -114,7 +114,7 @@ class Digibug_Controller extends Controller {
private function _clean_expired() {
db::build()
->delete("digibug_proxies")
- ->where("request_date", "<=", new Database_Expression("(CURDATE() - INTERVAL 10 DAY)"))
+ ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 10 DAY)"))
->limit(20)
->execute();
}
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 7729d797..80247a0f 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -27,7 +27,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
->set("state", "stalled")
->where("done", "=", 0)
->where("state", "<>", "stalled")
- ->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))
+ ->where(db::expr("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))
->execute();
$stalled_count = $query->count();
if ($stalled_count) {
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index a6b8e6a2..fb7933f7 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -503,7 +503,7 @@ class gallery_installer {
foreach (db::build()
->from("items")
->select("id", "slug")
- ->where(new Database_Expression("`slug` REGEXP '[^_A-Za-z0-9-]'"), "=", 1)
+ ->where(db::expr("`slug` REGEXP '[^_A-Za-z0-9-]'"), "=", 1)
->execute() as $row) {
$new_slug = item::convert_filename_to_slug($row->slug);
if (empty($new_slug)) {
@@ -540,7 +540,7 @@ class gallery_installer {
if ($version == 25) {
db::build()
->update("items")
- ->set("title", new Database_Expression("`name`"))
+ ->set("title", db::expr("`name`"))
->and_open()
->where("title", "IS", null)
->or_where("title", "=", "")
@@ -581,7 +581,7 @@ class gallery_installer {
$db->query("ALTER TABLE {modules} ADD COLUMN `weight` int(9) DEFAULT NULL");
$db->query("ALTER TABLE {modules} ADD KEY (`weight`)");
db::update("modules")
- ->set("weight", new Database_Expression("`id`"))
+ ->set("weight", db::expr("`id`"))
->execute();
module::set_version("gallery", $version = 32);
}
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index e69ff91a..9ccff152 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -74,7 +74,7 @@ class gallery_task_Core {
// Choose the dirty images in a random order so that if we run this task multiple times
// concurrently each task is rebuilding different images simultaneously.
$result = graphics::find_dirty_images_query()->select("id")
- ->select(new Database_Expression("RAND() as r"))
+ ->select(db::expr("RAND() as r"))
->order_by("r", "ASC")
->execute();
$total_count = $task->get("total_count", $result->count());
@@ -608,7 +608,7 @@ class gallery_task_Core {
static function find_dupe_slugs() {
return db::build()
->select_distinct(
- array("parent_slug" => new Database_Expression("CONCAT(`parent_id`, ':', LOWER(`slug`))")))
+ array("parent_slug" => db::expr("CONCAT(`parent_id`, ':', LOWER(`slug`))")))
->select("id")
->select(array("C" => "COUNT(\"*\")"))
->from("items")
@@ -620,7 +620,7 @@ class gallery_task_Core {
static function find_dupe_names() {
return db::build()
->select_distinct(
- array("parent_name" => new Database_Expression("CONCAT(`parent_id`, ':', LOWER(`name`))")))
+ array("parent_name" => db::expr("CONCAT(`parent_id`, ':', LOWER(`name`))")))
->select("id")
->select(array("C" => "COUNT(\"*\")"))
->from("items")
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 2b446daa..7c5578af 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -488,7 +488,7 @@ class module_Core {
static function incr_var($module_name, $name, $increment=1) {
db::build()
->update("vars")
- ->set("value", new Database_Expression("`value` + $increment"))
+ ->set("value", db::expr("`value` + $increment"))
->where("module_name", "=", $module_name)
->where("name", "=", $name)
->execute();
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index f20fafa0..4556273c 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -54,12 +54,12 @@ class ORM_MPTT_Core extends ORM {
// Make a hole in the parent for this new item
db::build()
->update($this->table_name)
- ->set("left_ptr", new Database_Expression("`left_ptr` + 2"))
+ ->set("left_ptr", db::expr("`left_ptr` + 2"))
->where("left_ptr", ">=", $parent->right_ptr)
->execute();
db::build()
->update($this->table_name)
- ->set("right_ptr", new Database_Expression("`right_ptr` + 2"))
+ ->set("right_ptr", db::expr("`right_ptr` + 2"))
->where("right_ptr", ">=", $parent->right_ptr)
->execute();
$parent->right_ptr += 2;
@@ -109,12 +109,12 @@ class ORM_MPTT_Core extends ORM {
try {
db::build()
->update($this->table_name)
- ->set("left_ptr", new Database_Expression("`left_ptr` - 2"))
+ ->set("left_ptr", db::expr("`left_ptr` - 2"))
->where("left_ptr", ">", $this->right_ptr)
->execute();
db::build()
->update($this->table_name)
- ->set("right_ptr", new Database_Expression("`right_ptr` - 2"))
+ ->set("right_ptr", db::expr("`right_ptr` - 2"))
->where("right_ptr", ">", $this->right_ptr)
->execute();
} catch (Exception $e) {
@@ -253,7 +253,7 @@ class ORM_MPTT_Core extends ORM {
// Update the levels for the to-be-moved items
db::build()
->update($this->table_name)
- ->set("level", new Database_Expression("`level` + $level_delta"))
+ ->set("level", db::expr("`level` + $level_delta"))
->where("left_ptr", ">=", $original_left_ptr)
->where("right_ptr", "<=", $original_right_ptr)
->execute();
@@ -262,12 +262,12 @@ class ORM_MPTT_Core extends ORM {
// Make a hole in the target for the move
db::build()
->update($this->table_name)
- ->set("left_ptr", new Database_Expression("`left_ptr` + $size_of_hole"))
+ ->set("left_ptr", db::expr("`left_ptr` + $size_of_hole"))
->where("left_ptr", ">=", $target_right_ptr)
->execute();
db::build()
->update($this->table_name)
- ->set("right_ptr", new Database_Expression("`right_ptr` + $size_of_hole"))
+ ->set("right_ptr", db::expr("`right_ptr` + $size_of_hole"))
->where("right_ptr", ">=", $target_right_ptr)
->execute();
@@ -290,8 +290,8 @@ class ORM_MPTT_Core extends ORM {
$new_offset = $target->right_ptr - $left_ptr;
db::build()
->update($this->table_name)
- ->set("left_ptr", new Database_Expression("`left_ptr` + $new_offset"))
- ->set("right_ptr", new Database_Expression("`right_ptr` + $new_offset"))
+ ->set("left_ptr", db::expr("`left_ptr` + $new_offset"))
+ ->set("right_ptr", db::expr("`right_ptr` + $new_offset"))
->where("left_ptr", ">=", $left_ptr)
->where("right_ptr", "<=", $right_ptr)
->execute();
@@ -299,12 +299,12 @@ class ORM_MPTT_Core extends ORM {
// Close the hole in the source's parent after the move
db::build()
->update($this->table_name)
- ->set("left_ptr", new Database_Expression("`left_ptr` - $size_of_hole"))
+ ->set("left_ptr", db::expr("`left_ptr` - $size_of_hole"))
->where("left_ptr", ">", $right_ptr)
->execute();
db::build()
->update($this->table_name)
- ->set("right_ptr", new Database_Expression("`right_ptr` - $size_of_hole"))
+ ->set("right_ptr", db::expr("`right_ptr` - $size_of_hole"))
->where("right_ptr", ">", $right_ptr)
->execute();
} catch (Exception $e) {
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index 67e712de..d34c3b0e 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -35,7 +35,7 @@ class Gallery_Installer_Test extends Gallery_Unit_Test_Case {
public function install_creates_root_item_test() {
$max_right_ptr = ORM::factory("item")
- ->select(new Database_Expression("MAX(`right_ptr`) AS `right_ptr`"))
+ ->select(db::expr("MAX(`right_ptr`) AS `right_ptr`"))
->find()->right_ptr;
$root = ORM::factory('item')->find(1);
$this->assert_equal("Gallery", $root->title);
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index 0564d336..2ff8ff48 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -160,7 +160,7 @@ class notification {
static function send_pending_notifications() {
foreach (db::build()
- ->select(new Database_Expression("DISTINCT `email`"))
+ ->select(db::expr("DISTINCT `email`"))
->from("pending_notifications")
->execute() as $row) {
$email = $row->email;
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 14d27c94..bcd3b0c0 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -118,7 +118,7 @@ class tag_Core {
static function clear_all($item) {
db::build()
->update("tags")
- ->set("count", new Database_Expression("`count` - 1"))
+ ->set("count", db::expr("`count` - 1"))
->where("count", ">", 0)
->where("id", "IN", db::build()->select("tag_id")->from("items_tags")->where("item_id", "=", $item->id))
->execute();
--
cgit v1.2.3
From 336632fea0a955d74099cd169b3178c01f250ff5 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Mon, 3 Jan 2011 13:21:54 +0100
Subject: Keep view counters of all item types accurate Added common
increment_view_count() func in item model for reuse
---
modules/gallery/controllers/albums.php | 5 +----
modules/gallery/controllers/movies.php | 3 +--
modules/gallery/controllers/photos.php | 3 +--
modules/gallery/models/item.php | 10 ++++++++++
4 files changed, 13 insertions(+), 8 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index b0887195..c0368488 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -71,10 +71,7 @@ class Albums_Controller extends Items_Controller {
$template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this
$template->content = new View("album.html");
- // We can't use math in ORM or the query builder, so do this by hand. It's important
- // that we do this with math, otherwise concurrent accesses will damage accuracy.
- db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id")
- ->execute();
+ $album->increment_view_count();
print $template;
}
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 717eb8aa..15d4f950 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -49,8 +49,7 @@ class Movies_Controller extends Items_Controller {
$template->content = new View("movie.html");
- $movie->view_count++;
- $movie->save();
+ $movie->increment_view_count();
print $template;
}
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index b22ac8e5..2dc22ca4 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -49,8 +49,7 @@ class Photos_Controller extends Items_Controller {
$template->content = new View("photo.html");
- $photo->view_count++;
- $photo->save();
+ $photo->increment_view_count();
print $template;
}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index fc5c3ff9..d4df0a78 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -1078,6 +1078,16 @@ class Item_Model_Core extends ORM_MPTT {
return $data;
}
+ /**
+ * Increments the view counter of this item
+ * We can't use math in ORM or the query builder, so do this by hand. It's important
+ * that we do this with math, otherwise concurrent accesses will damage accuracy.
+ */
+ public function increment_view_count() {
+ db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id")
+ ->execute();
+ }
+
private function _cache_buster($path) {
return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0);
}
--
cgit v1.2.3
From cfaa62370ecbdb3badf4ab68bbefa7cfedaea154 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Sun, 2 Jan 2011 18:59:23 +0100
Subject: Reimplemented Kohana 2.3's View::set_global() with array support.
Allows for cleaner code and fewer function calls.
---
modules/gallery/controllers/albums.php | 17 +++++++++--------
modules/gallery/controllers/movies.php | 17 +++++++++--------
modules/gallery/controllers/photos.php | 17 +++++++++--------
modules/gallery/libraries/MY_View.php | 10 ++++++++--
4 files changed, 35 insertions(+), 26 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index c0368488..e69f6b6d 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -61,14 +61,15 @@ class Albums_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "collection", "album");
- $template->set_global("page", $page);
- $template->set_global("page_title", null);
- $template->set_global("max_pages", $max_pages);
- $template->set_global("page_size", $page_size);
- $template->set_global("item", $album);
- $template->set_global("children", $album->viewable()->children($page_size, $offset));
- $template->set_global("children_count", $children_count);
- $template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this
+ $template->set_global(array("page" => $page,
+ "page_title" => null,
+ "max_pages" => $max_pages,
+ "page_size" => $page_size,
+ "item" => $album,
+ "children" => $album->viewable()->children($page_size, $offset),
+ "children_count" => $children_count,
+ "parents" => $album->parents()->as_array()));
+ // view calls empty() on this
$template->content = new View("album.html");
$album->increment_view_count();
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 15d4f950..1ae969c7 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -38,14 +38,15 @@ class Movies_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "movie");
- $template->set_global("item", $movie);
- $template->set_global("children", array());
- $template->set_global("children_count", 0);
- $template->set_global("parents", $movie->parents()->as_array());
- $template->set_global("next_item", $next_item);
- $template->set_global("previous_item", $previous_item);
- $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
- $template->set_global("position", $position);
+ $template->set_global(array("item" => $movie,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $movie->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count"
+ => $movie->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("movie.html");
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 2dc22ca4..e795f336 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -38,14 +38,15 @@ class Photos_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "photo");
- $template->set_global("item", $photo);
- $template->set_global("children", array());
- $template->set_global("children_count", 0);
- $template->set_global("parents", $photo->parents()->as_array());
- $template->set_global("next_item", $next_item);
- $template->set_global("previous_item", $previous_item);
- $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
- $template->set_global("position", $position);
+ $template->set_global(array("item" => $photo,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $photo->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count"
+ => $photo->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("photo.html");
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index ded77792..2230203a 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -23,8 +23,14 @@ class View extends View_Core {
/**
* Reimplement Kohana 2.3's View::set_global() functionality.
*/
- public function set_global($key, $value) {
- View::$global_data[$key] = $value;
+ public function set_global($key, $value = NULL) {
+ if (is_array($key)) {
+ foreach ($key as $key2 => $value) {
+ View::$global_data[$key2] = $value;
+ }
+ } else {
+ View::$global_data[$key] = $value;
+ }
}
public function is_set($key=null) {
--
cgit v1.2.3
From 4a882108259f9542a6c8f2ffe95c9ee0e1c102cd Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 3 Jan 2011 11:41:25 -0800
Subject: Follow on to cfaa62370ecbdb3badf4ab68bbefa7cfedaea154 to fix
indentation. Fixes #1569.
---
modules/gallery/controllers/albums.php | 18 +++++++++---------
modules/gallery/controllers/movies.php | 18 +++++++++---------
modules/gallery/controllers/photos.php | 18 +++++++++---------
3 files changed, 27 insertions(+), 27 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index e69f6b6d..25df0da7 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -61,15 +61,15 @@ class Albums_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "collection", "album");
- $template->set_global(array("page" => $page,
- "page_title" => null,
- "max_pages" => $max_pages,
- "page_size" => $page_size,
- "item" => $album,
- "children" => $album->viewable()->children($page_size, $offset),
- "children_count" => $children_count,
- "parents" => $album->parents()->as_array()));
- // view calls empty() on this
+ $template->set_global(
+ array("page" => $page,
+ "page_title" => null,
+ "max_pages" => $max_pages,
+ "page_size" => $page_size,
+ "item" => $album,
+ "children" => $album->viewable()->children($page_size, $offset),
+ "parents" => $album->parents()->as_array(), // view calls empty() on this
+ "children_count" => $children_count));
$template->content = new View("album.html");
$album->increment_view_count();
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 1ae969c7..bf50abd5 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -38,15 +38,15 @@ class Movies_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "movie");
- $template->set_global(array("item" => $movie,
- "children" => array(),
- "children_count" => 0,
- "parents" => $movie->parents()->as_array(),
- "next_item" => $next_item,
- "previous_item" => $previous_item,
- "sibling_count"
- => $movie->parent()->viewable()->children_count($where),
- "position" => $position));
+ $template->set_global(
+ array("item" => $movie,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $movie->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count" => $movie->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("movie.html");
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index e795f336..d500a92e 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -38,15 +38,15 @@ class Photos_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "photo");
- $template->set_global(array("item" => $photo,
- "children" => array(),
- "children_count" => 0,
- "parents" => $photo->parents()->as_array(),
- "next_item" => $next_item,
- "previous_item" => $previous_item,
- "sibling_count"
- => $photo->parent()->viewable()->children_count($where),
- "position" => $position));
+ $template->set_global(
+ array("item" => $photo,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $photo->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count" => $photo->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("photo.html");
--
cgit v1.2.3
From 9364f0d931883bb5f17f22c4003ee59256f9efb6 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Wed, 5 Jan 2011 23:31:50 +0100
Subject: Allow '..' segment in photo/album paths through file_proxy (as is not
forbidden in other places like add album/item) and explitely look for /../
instead Note: directory path can't end in '.' forcibly so this shall be fine
Fixes Ticket #1518
---
modules/gallery/controllers/file_proxy.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 22854fbd..5ce9b458 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -45,7 +45,7 @@ class File_Proxy_Controller extends Controller {
$file_uri = substr($request_uri, strlen($var_uri));
// Make sure that we don't leave the var dir
- if (strpos($file_uri, "..") !== false) {
+ if (strpos($file_uri, "/../") !== false) {
throw new Kohana_404_Exception();
}
--
cgit v1.2.3
From d17ba036ee2a4cadb5d1fa03397bbf975d6c254b Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 7 Jan 2011 20:40:24 -0800
Subject: Don't enable the REST module by default (fixes #1585). Bump the info
module per changes for #662.
---
installer/install.sql | 33 ++++++++++++--------------------
modules/gallery/controllers/packager.php | 2 +-
2 files changed, 13 insertions(+), 22 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/installer/install.sql b/installer/install.sql
index 6aae8014..c1d71dc2 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -242,18 +242,17 @@ CREATE TABLE {modules} (
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `weight` (`weight`)
-) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {modules} VALUES (1,1,'gallery',43,1);
INSERT INTO {modules} VALUES (2,1,'user',3,2);
INSERT INTO {modules} VALUES (3,1,'comment',3,3);
INSERT INTO {modules} VALUES (4,1,'organize',2,4);
-INSERT INTO {modules} VALUES (5,1,'info',1,5);
-INSERT INTO {modules} VALUES (6,1,'rest',3,6);
-INSERT INTO {modules} VALUES (7,1,'rss',1,7);
-INSERT INTO {modules} VALUES (8,1,'search',1,8);
-INSERT INTO {modules} VALUES (9,1,'slideshow',2,9);
-INSERT INTO {modules} VALUES (10,1,'tag',2,10);
+INSERT INTO {modules} VALUES (5,1,'info',2,5);
+INSERT INTO {modules} VALUES (6,1,'rss',1,6);
+INSERT INTO {modules} VALUES (7,1,'search',1,7);
+INSERT INTO {modules} VALUES (8,1,'slideshow',2,8);
+INSERT INTO {modules} VALUES (9,1,'tag',2,9);
DROP TABLE IF EXISTS {outgoing_translations};
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -350,18 +349,6 @@ CREATE TABLE {themes} (
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {themes} VALUES (1,'wind',1);
INSERT INTO {themes} VALUES (2,'admin_wind',1);
-DROP TABLE IF EXISTS {user_access_keys};
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE {user_access_keys} (
- `id` int(9) NOT NULL AUTO_INCREMENT,
- `user_id` int(9) NOT NULL,
- `access_key` char(32) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `access_key` (`access_key`),
- UNIQUE KEY `user_id` (`user_id`)
-) DEFAULT CHARSET=utf8;
-/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS {users};
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -395,7 +382,7 @@ CREATE TABLE {vars} (
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind');
INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind');
@@ -429,5 +416,9 @@ INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user');
INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5');
INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0');
INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody');
-INSERT INTO {vars} VALUES (NULL,'rest','allow_guest_access','0');
+INSERT INTO {vars} VALUES (NULL,'info','show_title','1');
+INSERT INTO {vars} VALUES (NULL,'info','show_description','1');
+INSERT INTO {vars} VALUES (NULL,'info','show_owner','1');
+INSERT INTO {vars} VALUES (NULL,'info','show_name','1');
+INSERT INTO {vars} VALUES (NULL,'info','show_captured','1');
INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0');
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index bd51b93c..9da34f9c 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -59,7 +59,7 @@ class Packager_Controller extends Controller {
// numbers, keeping our install.sql file more stable.
srand(0);
- foreach (array("gallery", "user", "comment", "organize", "info", "rest",
+ foreach (array("gallery", "user", "comment", "organize", "info",
"rss", "search", "slideshow", "tag") as $module_name) {
module::install($module_name);
module::activate($module_name);
--
cgit v1.2.3
From 24c0b69847d4144c29e557fa654c30247e628a9c Mon Sep 17 00:00:00 2001
From: Jérémy Subtil
Date: Sun, 9 Jan 2011 00:22:46 +0100
Subject: Fixed item controllers so that any item position is computed
correctly, when some other items belonging to the same parent album are not
viewable. Changed depracated calls to item_Model::get_position() to
item::get_position().
---
modules/gallery/controllers/albums.php | 2 +-
modules/gallery/controllers/movies.php | 4 ++--
modules/gallery/controllers/photos.php | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 25df0da7..3435465c 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -37,7 +37,7 @@ class Albums_Controller extends Items_Controller {
if ($show) {
$child = ORM::factory("item", $show);
- $index = $album->get_position($child);
+ $index = item::get_position($child);
if ($index) {
$page = ceil($index / $page_size);
if ($page == 1) {
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index bf50abd5..7c85dd98 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -28,10 +28,10 @@ class Movies_Controller extends Items_Controller {
access::required("view", $movie);
$where = array(array("type", "!=", "album"));
- $position = $movie->parent()->get_position($movie, $where);
+ $position = item::get_position($movie, $where);
if ($position > 1) {
list ($previous_item, $ignore, $next_item) =
- $movie->parent()->children(3, $position - 2, $where);
+ $movie->parent()->viewable()->children(3, $position - 2, $where);
} else {
$previous_item = null;
list ($next_item) = $movie->parent()->viewable()->children(1, $position, $where);
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index d500a92e..4578747d 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -28,10 +28,10 @@ class Photos_Controller extends Items_Controller {
access::required("view", $photo);
$where = array(array("type", "!=", "album"));
- $position = $photo->parent()->get_position($photo, $where);
+ $position = item::get_position($photo, $where);
if ($position > 1) {
list ($previous_item, $ignore, $next_item) =
- $photo->parent()->children(3, $position - 2, $where);
+ $photo->parent()->viewable()->children(3, $position - 2, $where);
} else {
$previous_item = null;
list ($next_item) = $photo->parent()->viewable()->children(1, $position, $where);
--
cgit v1.2.3
From d557b2a63e2ea424965fb53be9f6b76ad3f18015 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 10 Jan 2011 14:50:30 -0800
Subject: Allow File_Proxy_Controller to run in private gallery mode since it
does all the right permission checks. This prevents a hotlink to a private
photo in a private gallery from kicking the user out to a login page. Fixes
#1594.
---
modules/gallery/controllers/file_proxy.php | 1 +
1 file changed, 1 insertion(+)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 22854fbd..c6051dfd 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -27,6 +27,7 @@
* input is sanitized against the database before we perform any file I/O.
*/
class File_Proxy_Controller extends Controller {
+ const ALLOW_PRIVATE_GALLERY = true;
public function __call($function, $args) {
// request_uri: gallery3/var/trunk/albums/foo/bar.jpg
$request_uri = rawurldecode(Input::instance()->server("REQUEST_URI"));
--
cgit v1.2.3
From 7f6d87166df138073d85dd5201de8b9d19bc6cd2 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Tue, 11 Jan 2011 23:16:05 +0100
Subject: Removed check as input value is compared against dataset of validated
values, and request is only processed further in case of a match. => this is
unnecessary
---
modules/gallery/controllers/file_proxy.php | 5 -----
1 file changed, 5 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 5ce9b458..47e1e483 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -44,11 +44,6 @@ class File_Proxy_Controller extends Controller {
$file_uri = substr($request_uri, strlen($var_uri));
- // Make sure that we don't leave the var dir
- if (strpos($file_uri, "/../") !== false) {
- throw new Kohana_404_Exception();
- }
-
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
throw new Kohana_404_Exception();
--
cgit v1.2.3
From 049f2af1c982bb12fee6e5512e4830f63d06d343 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Wed, 12 Jan 2011 00:05:11 +0100
Subject: Returning 2 flags from l10n_client::validate_api_key(), 1 to reflect
if connection was built up properly (just a boolean, not distuingishing
between reasons in case of a failure), the other to reflect API validating
success status. Using this presenting a slightly more meaningfull error msg
to user in case the connection would fail. Fixes Ticket #1504
---
modules/gallery/controllers/admin_languages.php | 11 +++++++----
modules/gallery/helpers/l10n_client.php | 8 ++++++--
2 files changed, 13 insertions(+), 6 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php
index 573ededf..e9be2a88 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -74,9 +74,11 @@ class Admin_Languages_Controller extends Admin_Controller {
private function _save_api_key($form) {
$new_key = $form->sharing->api_key->value;
- if ($new_key && !l10n_client::validate_api_key($new_key)) {
- $form->sharing->api_key->add_error("invalid", 1);
- $valid = false;
+ if ($new_key) {
+ list($connected, $valid) = l10n_client::validate_api_key($new_key);
+ if (!$valid) {
+ $form->sharing->api_key->add_error($connected ? "invalid" : "noconn", 1);
+ }
} else {
$valid = true;
}
@@ -119,7 +121,8 @@ class Admin_Languages_Controller extends Admin_Controller {
array("server-link" => html::mark_clean(html::anchor($server_link))))
: t("API key"))
->value($api_key)
- ->error_messages("invalid", t("The API key you provided is invalid."));
+ ->error_messages("invalid", t("The API key you provided is invalid."))
+ ->error_messages("noconn", t("Could not connect to remote server to validate the API key."));
$group->submit("save")->value(t("Save settings"));
if ($api_key && $this->_outgoing_translations_count()) {
// TODO: UI improvement: hide API key / save button when API key is set.
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 8c2685a8..2af5c8d0 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -60,10 +60,14 @@ class l10n_client_Core {
"client_token" => l10n_client::client_token(),
"signature" => $signature,
"uid" => l10n_client::server_uid($api_key)));
+ if (!isset($response_data) && !isset($response_status)) {
+ return array(false, false);
+ }
+
if (!remote::success($response_status)) {
- return false;
+ return array(true, false);
}
- return true;
+ return array(true, true);
}
/**
--
cgit v1.2.3
From ee53744aa73b06f262122b6236014618fe6d742c Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 11 Jan 2011 16:59:57 -0800
Subject: Two improvements to Joe's fix for #1504: 1) Trap all exceptions, eg
dns or connectivity issues and report back in the form (but put the stack
trace in the logs) 2) Rename "noconn" to "no_connection"
---
modules/gallery/controllers/admin_languages.php | 5 +++--
modules/gallery/helpers/l10n_client.php | 15 ++++++++++-----
2 files changed, 13 insertions(+), 7 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php
index e9be2a88..f96a0eb7 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -77,7 +77,7 @@ class Admin_Languages_Controller extends Admin_Controller {
if ($new_key) {
list($connected, $valid) = l10n_client::validate_api_key($new_key);
if (!$valid) {
- $form->sharing->api_key->add_error($connected ? "invalid" : "noconn", 1);
+ $form->sharing->api_key->add_error($connected ? "invalid" : "no_connection", 1);
}
} else {
$valid = true;
@@ -122,7 +122,8 @@ class Admin_Languages_Controller extends Admin_Controller {
: t("API key"))
->value($api_key)
->error_messages("invalid", t("The API key you provided is invalid."))
- ->error_messages("noconn", t("Could not connect to remote server to validate the API key."));
+ ->error_messages(
+ "no_connection", t("Could not connect to remote server to validate the API key."));
$group->submit("save")->value(t("Save settings"));
if ($api_key && $this->_outgoing_translations_count()) {
// TODO: UI improvement: hide API key / save button when API key is set.
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 2af5c8d0..8fc66b68 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -55,11 +55,16 @@ class l10n_client_Core {
$url = self::_server_url("status");
$signature = self::_sign($version, $api_key);
- list ($response_data, $response_status) = remote::post(
- $url, array("version" => $version,
- "client_token" => l10n_client::client_token(),
- "signature" => $signature,
- "uid" => l10n_client::server_uid($api_key)));
+ try {
+ list ($response_data, $response_status) = remote::post(
+ $url, array("version" => $version,
+ "client_token" => l10n_client::client_token(),
+ "signature" => $signature,
+ "uid" => l10n_client::server_uid($api_key)));
+ } catch (ErrorException $e) {
+ // Log the error, but then return a "can't make connection" error
+ Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
if (!isset($response_data) && !isset($response_status)) {
return array(false, false);
}
--
cgit v1.2.3
From 09d34696a12ae15f6c7378a64b2359465b2d7277 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 11 Jan 2011 17:54:33 -0800
Subject: Update comments to annotate what data is where during the process.
Follow-on for #1518.
---
modules/gallery/controllers/file_proxy.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 0400d7c4..98f4e839 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -29,9 +29,11 @@
class File_Proxy_Controller extends Controller {
const ALLOW_PRIVATE_GALLERY = true;
public function __call($function, $args) {
- // request_uri: gallery3/var/trunk/albums/foo/bar.jpg
+ // request_uri: gallery3/var/albums/foo/bar.jpg?m=1234
$request_uri = rawurldecode(Input::instance()->server("REQUEST_URI"));
+ // get rid of query parameters
+ // request_uri: gallery3/var/albums/foo/bar.jpg
$request_uri = preg_replace("/\?.*/", "", $request_uri);
// var_uri: gallery3/var/
@@ -43,8 +45,11 @@ class File_Proxy_Controller extends Controller {
throw new Kohana_404_Exception();
}
+ // file_uri: albums/foo/bar.jpg
$file_uri = substr($request_uri, strlen($var_uri));
+ // type: albums
+ // path: foo/bar.jpg
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
throw new Kohana_404_Exception();
--
cgit v1.2.3
From 70abfb2a20734802c922c0e9917d2a1778aef3f2 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 22:16:09 -0800
Subject: Upgrade checking code is now here, along with a bump of the Gallery
module to v46. There's a new block in the admin dashboard which controls
whether automatic checking happens, and lets you check immediately. If a
newer version is detected, a site status message appears for admins providing
upgrade instructions.
Automatic checking is not yet implemented (even though the UI claims
that it exists). This is all for #1605.
---
.../gallery/controllers/admin_upgrade_checker.php | 49 ++++++++++++
modules/gallery/helpers/gallery_block.php | 12 ++-
modules/gallery/helpers/gallery_installer.php | 16 +++-
modules/gallery/helpers/upgrade_checker.php | 91 ++++++++++++++++++++++
modules/gallery/module.info | 2 +-
.../gallery/views/upgrade_checker_block.html.php | 45 +++++++++++
6 files changed, 212 insertions(+), 3 deletions(-)
create mode 100644 modules/gallery/controllers/admin_upgrade_checker.php
create mode 100644 modules/gallery/helpers/upgrade_checker.php
create mode 100644 modules/gallery/views/upgrade_checker_block.html.php
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/admin_upgrade_checker.php b/modules/gallery/controllers/admin_upgrade_checker.php
new file mode 100644
index 00000000..4b1467cd
--- /dev/null
+++ b/modules/gallery/controllers/admin_upgrade_checker.php
@@ -0,0 +1,49 @@
+server("HTTP_REFERER")) {
+ url::redirect($referer);
+ } else {
+ url::redirect(item::root()->abs_url());
+ }
+ }
+
+ function set_auto($val) {
+ access::verify_csrf();
+ module::set_var("gallery", "upgrade_checker_auto_enabled", (bool)$val);
+
+ if ((bool)$val) {
+ message::success(t("Automatic upgrade checking is enabled."));
+ } else {
+ message::success(t("Automatic upgrade checking is disabled."));
+ }
+ url::redirect("admin/dashboard");
+ }
+}
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index 1d92d66d..2189a710 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -25,7 +25,9 @@ class gallery_block_Core {
"log_entries" => t("Log entries"),
"stats" => t("Gallery stats"),
"platform_info" => t("Platform information"),
- "project_news" => t("Gallery project news"));
+ "project_news" => t("Gallery project news"),
+ "upgrade_checker" => t("Check for Gallery upgrades")
+ );
}
static function get_site_list() {
@@ -101,6 +103,14 @@ class gallery_block_Core {
$block = "";
}
break;
+
+ case "upgrade_checker":
+ $block = new Block();
+ $block->css_id = "g-upgrade-available-block";
+ $block->title = t("Check for Gallery upgrades");
+ $block->content = new View("upgrade_checker_block.html");
+ $block->content->version_info = upgrade_checker::version_info();
+ $block->content->auto_check_enabled = upgrade_checker::auto_check_enabled();
}
return $block;
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 92e5b7b8..1ffe9bae 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -259,6 +259,7 @@ class gallery_installer {
module::set_var("gallery", "default_locale", "en_US");
module::set_var("gallery", "image_quality", 75);
module::set_var("gallery", "image_sharpen", 15);
+ module::set_var("gallery", "upgrade_checker_auto_enabled", true);
// Add rules for generating our thumbnails and resizes
graphics::add_rule(
@@ -285,6 +286,7 @@ class gallery_installer {
block_manager::add("dashboard_sidebar", "gallery", "platform_info");
block_manager::add("dashboard_sidebar", "gallery", "project_news");
block_manager::add("dashboard_center", "gallery", "welcome");
+ block_manager::add("dashboard_center", "gallery", "upgrade_checker");
block_manager::add("dashboard_center", "gallery", "photo_stream");
block_manager::add("dashboard_center", "gallery", "log_entries");
@@ -309,7 +311,7 @@ class gallery_installer {
module::set_var("gallery", "show_user_profiles_to", "registered_users");
module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
- module::set_version("gallery", 45);
+ module::set_version("gallery", 46);
}
static function upgrade($version) {
@@ -663,6 +665,18 @@ class gallery_installer {
$db->query("ALTER TABLE {messages} CHANGE `value` `value` text default NULL");
module::set_version("gallery", $version = 45);
}
+
+ if ($version == 45) {
+ // Splice the upgrade_checker block into the admin dashboard at the top
+ // of the page, but under the welcome block if it's in the first position.
+ $blocks = block_manager::get_active("dashboard_center");
+ $index = count($blocks) && current($blocks) == array("gallery", "welcome") ? 1 : 0;
+ array_splice($blocks, $index, 0, array(random::int() => array("gallery", "upgrade_checker")));
+ block_manager::set_active("dashboard_center", $blocks);
+
+ module::set_var("gallery", "upgrade_checker_auto_enabled", true);
+ module::set_version("gallery", $version = 46);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
new file mode 100644
index 00000000..9311cf4a
--- /dev/null
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -0,0 +1,91 @@
+get("upgrade_checker_version_info"));
+ }
+
+ static function auto_check_enabled() {
+ return (bool)module::get_var("gallery", "upgrade_checker_auto_enabled");
+ }
+
+ static function fetch_version_info() {
+ $result = new stdClass();
+ try {
+ list ($status, $headers, $body) = remote::do_request(upgrade_checker::CHECK_URL);
+ if ($status == "HTTP/1.1 200 OK") {
+ $result->status = "success";
+ foreach (explode("\n", $body) as $line) {
+ if ($line) {
+ list($key, $val) = explode("=", $line, 2);
+ $result->data[$key] = $val;
+ }
+ }
+ } else {
+ $result->status = "error";
+ }
+ } catch (Exception $e) {
+ Kohana_Log::add("error",
+ sprintf("%s in %s at line %s:\n%s", $e->getMessage(), $e->getFile(),
+ $e->getLine(), $e->getTraceAsString()));
+ }
+ $result->timestamp = time();
+ Cache::instance()->set("upgrade_checker_version_info", serialize($result), null, 86400 * 365);
+ }
+
+ static function check_for_upgrade() {
+ $version_info = upgrade_checker::version_info();
+ $upgrade_available = false;
+ if ($version_info) {
+ if (gallery::RELEASE_CHANNEL == "release") {
+ if (version_compare($version_info->data["release_version"], gallery::VERSION, ">")) {
+ site_status::warning(
+ t("A newer version of Gallery is available! Upgrade now to version %version or wait until later.",
+ array("version" => $version_info->data["release_version"],
+ "upgrade-url" => $version_info->data["release_upgrade_url"],
+ "hide-url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))),
+ "upgrade_checker");
+ $upgrade_available = true;
+ }
+ } else {
+ $branch = gallery::RELEASE_BRANCH;
+ if (isset($version_info->data["{$branch}_build_number"]) &&
+ version_compare($version_info->data["{$branch}_build_number"],
+ gallery::build_number(), ">")) {
+ site_status::warning(
+ t("A newer version of Gallery is available! Upgrade now to version %version (build %build on branch %branch) or wait until later.",
+ array("version" => $version_info->data["{$branch}_version"],
+ "upgrade-url" => $version_info->data["{$branch}_upgrade_url"],
+ "build" => $version_info->data["{$branch}_build_number"],
+ "branch" => $branch,
+ "hide-url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))),
+ "upgrade_checker");
+ $upgrade_available = true;
+ }
+ }
+ }
+
+ if (!$upgrade_available) {
+ site_status::clear("upgrade_checker");
+ }
+ }
+}
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index b79df7be..4c0c8866 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 45
+version = 46
diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php
new file mode 100644
index 00000000..30e18305
--- /dev/null
+++ b/modules/gallery/views/upgrade_checker_block.html.php
@@ -0,0 +1,45 @@
+
+
+ = t("Gallery can check to see if there is a new version available for you to use. It is a good idea to upgrade your Gallery to get the latest features and security fixes. Your privacy is important so no information about your Gallery is shared during this process. You can disable this feature below.") ?>
+
+
+
+ if (gallery::RELEASE_CHANNEL == "release"): ?>
+ = t("You are using the official Gallery %version release, code named %code_name.", array("version" => gallery::VERSION, "code_name" => gallery::CODE_NAME)) ?>
+ else: ?>
+ = t("You are using an experimental snapshot of Gallery %version (build %build_number on branch %branch).", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => gallery::build_number())) ?>
+ endif ?>
+
+
+
+ ">
+ = t("Check now") ?>
+
+ if ($auto_check_enabled): ?>
+ ">
+ = t("Disable automatic checking") ?>
+
+ else: ?>
+ ">
+ = t("Enable automatic checking") ?>
+
+ endif ?>
+
+
+
+ if ($auto_check_enabled): ?>
+ = t("Automatic upgrade checking is enabled.") ?>
+ else: ?>
+ = t("Automatic upgrade checking is disabled.") ?>
+ endif ?>
+ if (!$version_info): ?>
+ = t("No upgrade checks have been made yet.") ?>
+ else: ?>
+ = t("The last upgrade check was made on %date.",
+ array("date" => gallery::date_time($version_info->timestamp))) ?>
+ endif ?>
+
+
--
cgit v1.2.3
From 45caba09f81e53dfa4264bc74c4e6ed7935bd5f9 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 20:03:11 -0800
Subject: Move the code that clears the upgrade_check site status message to
the upgrader so that it's cleared any time we run an upgrade. Part of
---
modules/gallery/controllers/upgrader.php | 3 +++
modules/gallery/helpers/gallery_installer.php | 3 ---
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index 66c71648..0932090f 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -94,6 +94,9 @@ class Upgrader_Controller extends Controller {
// If the upgrade failed, this will get recreated
site_status::clear("upgrade_now");
+ // Clear any upgrade check strings, we are probably up to date.
+ site_status::clear("upgrade_check");
+
if (php_sapi_name() == "cli") {
if ($failed) {
print "Upgrade completed ** WITH FAILURES **\n";
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 41ed1c6e..1ffe9bae 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -677,9 +677,6 @@ class gallery_installer {
module::set_var("gallery", "upgrade_checker_auto_enabled", true);
module::set_version("gallery", $version = 46);
}
-
- // Clear any upgrade check strings, we are probably up to date.
- site_status::clear("upgrade_check");
}
static function uninstall() {
--
cgit v1.2.3
From 20ae106c22b9528d34fb85d09a7ab542e6c6c880 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 21:15:33 -0800
Subject: Display a message in the "Check for Gallery upgrades" block when
there's a newer version available, even if the user has dismissed the site
status message. #1605.
---
.../gallery/controllers/admin_upgrade_checker.php | 9 ++++++-
modules/gallery/helpers/gallery_block.php | 1 +
modules/gallery/helpers/upgrade_checker.php | 31 +++++++---------------
.../gallery/views/upgrade_checker_block.html.php | 8 ++++++
themes/admin_wind/css/screen.css | 2 +-
5 files changed, 27 insertions(+), 24 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/admin_upgrade_checker.php b/modules/gallery/controllers/admin_upgrade_checker.php
index 4b1467cd..456a982c 100644
--- a/modules/gallery/controllers/admin_upgrade_checker.php
+++ b/modules/gallery/controllers/admin_upgrade_checker.php
@@ -21,7 +21,14 @@ class Admin_Upgrade_Checker_Controller extends Admin_Controller {
function check_now() {
access::verify_csrf();
upgrade_checker::fetch_version_info();
- upgrade_checker::check_for_upgrade();
+ $message = upgrade_checker::get_upgrade_message();
+ if ($message) {
+ $message .= " [x]";
+ site_status::info($message, "upgrade_checker");
+ } else {
+ site_status::clear("upgrade_checker");
+ }
url::redirect("admin/dashboard");
}
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index 2189a710..fed786cc 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -111,6 +111,7 @@ class gallery_block_Core {
$block->content = new View("upgrade_checker_block.html");
$block->content->version_info = upgrade_checker::version_info();
$block->content->auto_check_enabled = upgrade_checker::auto_check_enabled();
+ $block->content->new_version = upgrade_checker::get_upgrade_message();
}
return $block;
}
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
index 0e72bb94..f92203c8 100644
--- a/modules/gallery/helpers/upgrade_checker.php
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -77,40 +77,27 @@ class upgrade_checker_Core {
/**
* Check the latest version info blob to see if it's time for an upgrade.
*/
- static function check_for_upgrade() {
+ static function get_upgrade_message() {
$version_info = upgrade_checker::version_info();
- $upgrade_available = false;
if ($version_info) {
if (gallery::RELEASE_CHANNEL == "release") {
if (version_compare($version_info->data["release_version"], gallery::VERSION, ">")) {
- site_status::warning(
- t("A newer version of Gallery is available! Upgrade now to version %version or wait until later.",
- array("version" => $version_info->data["release_version"],
- "upgrade-url" => $version_info->data["release_upgrade_url"],
- "hide-url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))),
- "upgrade_checker");
- $upgrade_available = true;
+ return t("A newer version of Gallery is available! Upgrade now to version %version",
+ array("version" => $version_info->data["release_version"],
+ "upgrade-url" => $version_info->data["release_upgrade_url"]));
}
} else {
$branch = gallery::RELEASE_BRANCH;
if (isset($version_info->data["branch_{$branch}_build_number"]) &&
version_compare($version_info->data["branch_{$branch}_build_number"],
gallery::build_number(), ">")) {
- site_status::warning(
- t("A newer version of Gallery is available! Upgrade now to version %version (build %build on branch %branch) or wait until later.",
- array("version" => $version_info->data["branch_{$branch}_version"],
- "upgrade-url" => $version_info->data["branch_{$branch}_upgrade_url"],
- "build" => $version_info->data["branch_{$branch}_build_number"],
- "branch" => $branch,
- "hide-url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))),
- "upgrade_checker");
- $upgrade_available = true;
+ return t("A newer version of Gallery is available! Upgrade now to version %version (build %build on branch %branch)",
+ array("version" => $version_info->data["branch_{$branch}_version"],
+ "upgrade-url" => $version_info->data["branch_{$branch}_upgrade_url"],
+ "build" => $version_info->data["branch_{$branch}_build_number"],
+ "branch" => $branch));
}
}
}
-
- if (!$upgrade_available) {
- site_status::clear("upgrade_checker");
- }
}
}
diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php
index 30e18305..b04887b2 100644
--- a/modules/gallery/views/upgrade_checker_block.html.php
+++ b/modules/gallery/views/upgrade_checker_block.html.php
@@ -11,6 +11,14 @@
endif ?>
+ if ($new_version): ?>
+
+ -
+ = $new_version ?>
+
+
+ endif ?>
+
">
diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css
index 7d491cb7..a5376ff6 100644
--- a/themes/admin_wind/css/screen.css
+++ b/themes/admin_wind/css/screen.css
@@ -888,10 +888,10 @@ button {
background-position: .4em .3em;
border: 1px solid #ccc;
padding: 0;
+ margin-bottom: 1em;
}
#g-action-status {
- margin-bottom: 1em;
}
#g-action-status li,
--
cgit v1.2.3
From 83bf1d767b9dac33ca1c2f01141358cd0b657523 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 21:18:24 -0800
Subject: Fix typo: upgrade_check -> upgrade_checker #1605.
---
modules/gallery/controllers/upgrader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index 0932090f..6a34f19f 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -95,7 +95,7 @@ class Upgrader_Controller extends Controller {
site_status::clear("upgrade_now");
// Clear any upgrade check strings, we are probably up to date.
- site_status::clear("upgrade_check");
+ site_status::clear("upgrade_checker");
if (php_sapi_name() == "cli") {
if ($failed) {
--
cgit v1.2.3
From 56e6cb998f9b2f55af88fef426f8a69cc0058cb2 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 21:37:51 -0800
Subject: Change the [x] close box to "(remind me later)". #1605.
---
modules/gallery/controllers/admin_upgrade_checker.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/modules/gallery/controllers/admin_upgrade_checker.php b/modules/gallery/controllers/admin_upgrade_checker.php
index 456a982c..366bd64e 100644
--- a/modules/gallery/controllers/admin_upgrade_checker.php
+++ b/modules/gallery/controllers/admin_upgrade_checker.php
@@ -23,8 +23,9 @@ class Admin_Upgrade_Checker_Controller extends Admin_Controller {
upgrade_checker::fetch_version_info();
$message = upgrade_checker::get_upgrade_message();
if ($message) {
- $message .= " [x]";
+ $message .= t(
+ " (remind me later)",
+ array("url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__")));
site_status::info($message, "upgrade_checker");
} else {
site_status::clear("upgrade_checker");
--
cgit v1.2.3
From 423daa52d55a5298b461384baedc995eee09a0d1 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 21 Jan 2011 23:01:06 -0800
Subject: Update copyright to 2011.
---
application/Bootstrap.php | 2 +-
application/config/config.php | 2 +-
index.php | 2 +-
installer/cli.php | 2 +-
installer/index.php | 2 +-
installer/installer.php | 2 +-
installer/web.php | 2 +-
modules/akismet/controllers/admin_akismet.php | 2 +-
modules/akismet/helpers/akismet.php | 2 +-
modules/akismet/helpers/akismet_event.php | 2 +-
modules/akismet/helpers/akismet_installer.php | 2 +-
modules/akismet/tests/Akismet_Helper_Test.php | 2 +-
modules/comment/controllers/admin_comments.php | 2 +-
modules/comment/controllers/admin_manage_comments.php | 2 +-
modules/comment/controllers/comments.php | 2 +-
modules/comment/helpers/comment.php | 2 +-
modules/comment/helpers/comment_block.php | 2 +-
modules/comment/helpers/comment_event.php | 2 +-
modules/comment/helpers/comment_installer.php | 2 +-
modules/comment/helpers/comment_rest.php | 2 +-
modules/comment/helpers/comment_rss.php | 2 +-
modules/comment/helpers/comment_theme.php | 2 +-
modules/comment/helpers/comments_rest.php | 2 +-
modules/comment/helpers/item_comments_rest.php | 2 +-
modules/comment/models/comment.php | 2 +-
modules/comment/tests/Comment_Event_Test.php | 2 +-
modules/comment/tests/Comment_Helper_Test.php | 2 +-
modules/comment/tests/Comment_Model_Test.php | 2 +-
modules/digibug/config/digibug.php | 2 +-
modules/digibug/controllers/admin_digibug.php | 2 +-
modules/digibug/controllers/digibug.php | 2 +-
modules/digibug/helpers/digibug_event.php | 2 +-
modules/digibug/helpers/digibug_installer.php | 2 +-
modules/digibug/helpers/digibug_theme.php | 2 +-
modules/digibug/models/digibug_proxy.php | 2 +-
modules/digibug/tests/Digibug_Controller_Test.php | 2 +-
modules/exif/controllers/exif.php | 2 +-
modules/exif/helpers/exif.php | 2 +-
modules/exif/helpers/exif_event.php | 2 +-
modules/exif/helpers/exif_installer.php | 2 +-
modules/exif/helpers/exif_task.php | 2 +-
modules/exif/helpers/exif_theme.php | 2 +-
modules/exif/models/exif_key.php | 2 +-
modules/exif/models/exif_record.php | 2 +-
modules/exif/tests/Exif_Test.php | 2 +-
modules/g2_import/controllers/admin_g2_import.php | 2 +-
modules/g2_import/controllers/g2.php | 2 +-
modules/g2_import/helpers/g2_import.php | 2 +-
modules/g2_import/helpers/g2_import_event.php | 2 +-
modules/g2_import/helpers/g2_import_installer.php | 2 +-
modules/g2_import/helpers/g2_import_task.php | 2 +-
modules/g2_import/libraries/G2_Import_Exception.php | 2 +-
modules/g2_import/models/g2_map.php | 2 +-
modules/gallery/config/cache.php | 2 +-
modules/gallery/config/cookie.php | 2 +-
modules/gallery/config/database.php | 2 +-
modules/gallery/config/locale.php | 2 +-
modules/gallery/config/log_file.php | 2 +-
modules/gallery/config/routes.php | 2 +-
modules/gallery/config/session.php | 2 +-
modules/gallery/config/upload.php | 2 +-
modules/gallery/config/user_agents.php | 2 +-
modules/gallery/controllers/admin.php | 2 +-
modules/gallery/controllers/admin_advanced_settings.php | 2 +-
modules/gallery/controllers/admin_dashboard.php | 2 +-
modules/gallery/controllers/admin_graphics.php | 2 +-
modules/gallery/controllers/admin_languages.php | 2 +-
modules/gallery/controllers/admin_maintenance.php | 2 +-
modules/gallery/controllers/admin_modules.php | 2 +-
modules/gallery/controllers/admin_sidebar.php | 2 +-
modules/gallery/controllers/admin_theme_options.php | 2 +-
modules/gallery/controllers/admin_themes.php | 2 +-
modules/gallery/controllers/admin_upgrade_checker.php | 2 +-
modules/gallery/controllers/albums.php | 2 +-
modules/gallery/controllers/combined.php | 2 +-
modules/gallery/controllers/file_proxy.php | 2 +-
modules/gallery/controllers/items.php | 2 +-
modules/gallery/controllers/l10n_client.php | 2 +-
modules/gallery/controllers/login.php | 2 +-
modules/gallery/controllers/logout.php | 2 +-
modules/gallery/controllers/movies.php | 2 +-
modules/gallery/controllers/packager.php | 2 +-
modules/gallery/controllers/permissions.php | 2 +-
modules/gallery/controllers/photos.php | 2 +-
modules/gallery/controllers/quick.php | 2 +-
modules/gallery/controllers/reauthenticate.php | 2 +-
modules/gallery/controllers/upgrader.php | 2 +-
modules/gallery/controllers/uploader.php | 2 +-
modules/gallery/controllers/user_profile.php | 2 +-
modules/gallery/controllers/welcome_message.php | 2 +-
modules/gallery/helpers/MY_html.php | 2 +-
modules/gallery/helpers/MY_num.php | 2 +-
modules/gallery/helpers/MY_remote.php | 2 +-
modules/gallery/helpers/MY_url.php | 2 +-
modules/gallery/helpers/access.php | 2 +-
modules/gallery/helpers/album.php | 2 +-
modules/gallery/helpers/auth.php | 2 +-
modules/gallery/helpers/batch.php | 2 +-
modules/gallery/helpers/block_manager.php | 2 +-
modules/gallery/helpers/data_rest.php | 2 +-
modules/gallery/helpers/dir.php | 2 +-
modules/gallery/helpers/gallery.php | 2 +-
modules/gallery/helpers/gallery_block.php | 2 +-
modules/gallery/helpers/gallery_error.php | 2 +-
modules/gallery/helpers/gallery_event.php | 2 +-
modules/gallery/helpers/gallery_graphics.php | 2 +-
modules/gallery/helpers/gallery_installer.php | 2 +-
modules/gallery/helpers/gallery_rss.php | 2 +-
modules/gallery/helpers/gallery_task.php | 2 +-
modules/gallery/helpers/gallery_theme.php | 2 +-
modules/gallery/helpers/graphics.php | 2 +-
modules/gallery/helpers/identity.php | 2 +-
modules/gallery/helpers/item.php | 2 +-
modules/gallery/helpers/item_rest.php | 2 +-
modules/gallery/helpers/items_rest.php | 2 +-
modules/gallery/helpers/json.php | 2 +-
modules/gallery/helpers/l10n_client.php | 2 +-
modules/gallery/helpers/l10n_scanner.php | 2 +-
modules/gallery/helpers/locales.php | 2 +-
modules/gallery/helpers/log.php | 2 +-
modules/gallery/helpers/message.php | 2 +-
modules/gallery/helpers/model_cache.php | 2 +-
modules/gallery/helpers/module.php | 2 +-
modules/gallery/helpers/movie.php | 2 +-
modules/gallery/helpers/photo.php | 2 +-
modules/gallery/helpers/random.php | 2 +-
modules/gallery/helpers/site_status.php | 2 +-
modules/gallery/helpers/system.php | 2 +-
modules/gallery/helpers/task.php | 2 +-
modules/gallery/helpers/theme.php | 2 +-
modules/gallery/helpers/tree_rest.php | 2 +-
modules/gallery/helpers/upgrade_checker.php | 2 +-
modules/gallery/helpers/user_profile.php | 2 +-
modules/gallery/helpers/xml.php | 2 +-
modules/gallery/hooks/init_gallery.php | 2 +-
modules/gallery/libraries/Admin_View.php | 2 +-
modules/gallery/libraries/Block.php | 2 +-
modules/gallery/libraries/Form_Script.php | 2 +-
modules/gallery/libraries/Form_Uploadify.php | 2 +-
modules/gallery/libraries/Form_Uploadify_buttons.php | 2 +-
modules/gallery/libraries/Gallery_I18n.php | 2 +-
modules/gallery/libraries/Gallery_View.php | 2 +-
modules/gallery/libraries/IdentityProvider.php | 2 +-
modules/gallery/libraries/InPlaceEdit.php | 2 +-
modules/gallery/libraries/MY_Database.php | 2 +-
modules/gallery/libraries/MY_Forge.php | 2 +-
modules/gallery/libraries/MY_Input.php | 2 +-
modules/gallery/libraries/MY_Kohana_Exception.php | 2 +-
modules/gallery/libraries/MY_ORM.php | 2 +-
modules/gallery/libraries/MY_Pagination.php | 2 +-
modules/gallery/libraries/MY_View.php | 2 +-
modules/gallery/libraries/Menu.php | 2 +-
modules/gallery/libraries/ORM_MPTT.php | 2 +-
modules/gallery/libraries/SafeString.php | 2 +-
modules/gallery/libraries/Sendmail.php | 2 +-
modules/gallery/libraries/Task_Definition.php | 2 +-
modules/gallery/libraries/Theme_View.php | 2 +-
modules/gallery/libraries/drivers/Cache/Database.php | 2 +-
modules/gallery/libraries/drivers/IdentityProvider.php | 2 +-
modules/gallery/models/access_cache.php | 2 +-
modules/gallery/models/access_intent.php | 2 +-
modules/gallery/models/cache.php | 2 +-
modules/gallery/models/failed_auth.php | 2 +-
modules/gallery/models/graphics_rule.php | 2 +-
modules/gallery/models/incoming_translation.php | 2 +-
modules/gallery/models/item.php | 2 +-
modules/gallery/models/log.php | 2 +-
modules/gallery/models/message.php | 2 +-
modules/gallery/models/module.php | 2 +-
modules/gallery/models/outgoing_translation.php | 2 +-
modules/gallery/models/permission.php | 2 +-
modules/gallery/models/task.php | 2 +-
modules/gallery/models/theme.php | 2 +-
modules/gallery/models/var.php | 2 +-
modules/gallery/tests/Access_Helper_Test.php | 2 +-
modules/gallery/tests/Albums_Controller_Test.php | 2 +-
modules/gallery/tests/Cache_Test.php | 2 +-
modules/gallery/tests/Controller_Auth_Test.php | 2 +-
modules/gallery/tests/Database_Test.php | 2 +-
modules/gallery/tests/Dir_Helper_Test.php | 2 +-
modules/gallery/tests/DrawForm_Test.php | 2 +-
modules/gallery/tests/File_Structure_Test.php | 4 ++--
modules/gallery/tests/Gallery_Filters.php | 2 +-
modules/gallery/tests/Gallery_I18n_Test.php | 2 +-
modules/gallery/tests/Gallery_Installer_Test.php | 2 +-
modules/gallery/tests/Html_Helper_Test.php | 2 +-
modules/gallery/tests/Input_Library_Test.php | 2 +-
modules/gallery/tests/Item_Helper_Test.php | 2 +-
modules/gallery/tests/Item_Model_Test.php | 2 +-
modules/gallery/tests/Item_Rest_Helper_Test.php | 2 +-
modules/gallery/tests/Items_Rest_Helper_Test.php | 2 +-
modules/gallery/tests/Kohana_Exception_Test.php | 2 +-
modules/gallery/tests/Locales_Helper_Test.php | 2 +-
modules/gallery/tests/Menu_Test.php | 2 +-
modules/gallery/tests/ORM_MPTT_Test.php | 2 +-
modules/gallery/tests/Photos_Controller_Test.php | 2 +-
modules/gallery/tests/SafeString_Test.php | 2 +-
modules/gallery/tests/Sendmail_Test.php | 2 +-
modules/gallery/tests/Url_Security_Test.php | 2 +-
modules/gallery/tests/Var_Test.php | 2 +-
modules/gallery/tests/Xss_Security_Test.php | 2 +-
modules/gallery_unit_test/controllers/gallery_unit_test.php | 2 +-
modules/gallery_unit_test/helpers/MY_request.php | 2 +-
modules/gallery_unit_test/helpers/test.php | 2 +-
modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php | 2 +-
modules/image_block/helpers/image_block_block.php | 2 +-
modules/image_block/helpers/image_block_installer.php | 2 +-
modules/info/helpers/info_block.php | 2 +-
modules/info/helpers/info_installer.php | 2 +-
modules/info/helpers/info_theme.php | 2 +-
modules/kohana23_compat/config/pagination.php | 2 +-
modules/kohana23_compat/libraries/MY_Database_Builder.php | 2 +-
modules/kohana23_compat/libraries/Pagination.php | 2 +-
modules/notification/controllers/notification.php | 2 +-
modules/notification/helpers/notification.php | 2 +-
modules/notification/helpers/notification_event.php | 2 +-
modules/notification/helpers/notification_installer.php | 2 +-
modules/notification/models/pending_notification.php | 2 +-
modules/notification/models/subscription.php | 2 +-
modules/organize/controllers/organize.php | 2 +-
modules/organize/helpers/organize_event.php | 2 +-
modules/organize/helpers/organize_installer.php | 2 +-
modules/recaptcha/controllers/admin_recaptcha.php | 2 +-
modules/recaptcha/helpers/recaptcha.php | 2 +-
modules/recaptcha/helpers/recaptcha_event.php | 2 +-
modules/recaptcha/helpers/recaptcha_installer.php | 2 +-
modules/recaptcha/helpers/recaptcha_theme.php | 2 +-
modules/recaptcha/libraries/Form_Recaptcha.php | 2 +-
modules/rest/controllers/rest.php | 2 +-
modules/rest/helpers/registry_rest.php | 2 +-
modules/rest/helpers/rest.php | 2 +-
modules/rest/helpers/rest_event.php | 2 +-
modules/rest/helpers/rest_installer.php | 2 +-
modules/rest/libraries/Rest_Exception.php | 2 +-
modules/rest/models/user_access_key.php | 2 +-
modules/rest/tests/Rest_Controller_Test.php | 2 +-
modules/rss/controllers/rss.php | 2 +-
modules/rss/helpers/rss.php | 2 +-
modules/rss/helpers/rss_block.php | 2 +-
modules/search/controllers/search.php | 2 +-
modules/search/helpers/search.php | 2 +-
modules/search/helpers/search_event.php | 2 +-
modules/search/helpers/search_installer.php | 2 +-
modules/search/helpers/search_task.php | 2 +-
modules/search/helpers/search_theme.php | 2 +-
modules/search/models/search_record.php | 2 +-
modules/server_add/controllers/admin_server_add.php | 2 +-
modules/server_add/controllers/server_add.php | 2 +-
modules/server_add/helpers/server_add.php | 2 +-
modules/server_add/helpers/server_add_event.php | 2 +-
modules/server_add/helpers/server_add_installer.php | 2 +-
modules/server_add/helpers/server_add_theme.php | 2 +-
modules/server_add/models/server_add_entry.php | 2 +-
modules/slideshow/helpers/slideshow_event.php | 2 +-
modules/slideshow/helpers/slideshow_installer.php | 2 +-
modules/slideshow/helpers/slideshow_theme.php | 2 +-
modules/tag/controllers/admin_tags.php | 2 +-
modules/tag/controllers/tag.php | 2 +-
modules/tag/controllers/tags.php | 2 +-
modules/tag/helpers/item_tags_rest.php | 2 +-
modules/tag/helpers/tag.php | 2 +-
modules/tag/helpers/tag_block.php | 2 +-
modules/tag/helpers/tag_event.php | 2 +-
modules/tag/helpers/tag_installer.php | 2 +-
modules/tag/helpers/tag_item_rest.php | 2 +-
modules/tag/helpers/tag_items_rest.php | 2 +-
modules/tag/helpers/tag_rest.php | 2 +-
modules/tag/helpers/tag_rss.php | 2 +-
modules/tag/helpers/tag_task.php | 2 +-
modules/tag/helpers/tag_theme.php | 2 +-
modules/tag/helpers/tags_rest.php | 2 +-
modules/tag/models/tag.php | 2 +-
modules/tag/tests/Tag_Item_Rest_Helper_Test.php | 2 +-
modules/tag/tests/Tag_Rest_Helper_Test.php | 2 +-
modules/tag/tests/Tag_Test.php | 2 +-
modules/tag/tests/Tags_Rest_Helper_Test.php | 2 +-
modules/user/config/identity.php | 2 +-
modules/user/controllers/admin_users.php | 2 +-
modules/user/controllers/password.php | 2 +-
modules/user/controllers/users.php | 2 +-
modules/user/helpers/group.php | 2 +-
modules/user/helpers/user.php | 2 +-
modules/user/helpers/user_event.php | 2 +-
modules/user/helpers/user_installer.php | 2 +-
modules/user/helpers/user_theme.php | 2 +-
modules/user/libraries/drivers/IdentityProvider/Gallery.php | 2 +-
modules/user/models/group.php | 2 +-
modules/user/models/user.php | 2 +-
modules/user/tests/No_Direct_ORM_Access_Test.php | 2 +-
modules/user/tests/User_Groups_Test.php | 2 +-
modules/user/tests/User_Installer_Test.php | 2 +-
modules/watermark/controllers/admin_watermarks.php | 2 +-
modules/watermark/helpers/watermark.php | 2 +-
modules/watermark/helpers/watermark_event.php | 2 +-
modules/watermark/helpers/watermark_installer.php | 2 +-
295 files changed, 296 insertions(+), 296 deletions(-)
(limited to 'modules/gallery/controllers')
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index fbd83ce1..ff021fd5 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -1,7 +1,7 @@