From f8890be62b6c1ab14001111f10a8cbcdf973cdc1 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Wed, 15 Dec 2010 11:57:46 -0800
Subject: Follow on to d2be26e407aeb620082bcad2d5a45272868b38a1 to convert tabs
to spaces.
---
modules/gallery/helpers/items_rest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php
index 08aa3279..3c09faa8 100644
--- a/modules/gallery/helpers/items_rest.php
+++ b/modules/gallery/helpers/items_rest.php
@@ -84,9 +84,9 @@ class items_rest_Core {
if ($item->type == "album") {
$members = array();
foreach ($item->viewable()->children() as $child) {
- if (empty($types) || in_array($child->type, $types)) {
- $members[] = rest::url("item", $child);
- }
+ if (empty($types) || in_array($child->type, $types)) {
+ $members[] = rest::url("item", $child);
+ }
}
$item_rest["members"] = $members;
}
--
cgit v1.2.3
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.
---
installer/installer.php | 4 +--
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/models/item.php | 4 +--
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 | 4 +--
modules/gallery_unit_test/helpers/test.php | 12 ++++-----
modules/rest/helpers/rest_event.php | 6 ++---
14 files changed, 39 insertions(+), 39 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/installer.php b/installer/installer.php
index 9a957b43..7d358e70 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -138,7 +138,7 @@ class installer {
$char += ($char > 90) ? 13 : ($char > 57) ? 7 : 0;
$salt .= chr($char);
}
- $password = substr(md5(time() * rand()), 0, 6);
+ $password = substr(md5(time() . mt_rand()), 0, 6);
// Escape backslash in preparation for our UPDATE statement.
$hashed_password = str_replace("\\", "\\\\", $salt . md5($salt . $password));
$sql = self::prepend_prefix($config["prefix"],
@@ -152,7 +152,7 @@ class installer {
}
static function create_admin_session($config) {
- $session_id = md5(time() * rand());
+ $session_id = md5(time() . mt_rand());
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$user_agent_len = strlen($user_agent);
$now = time();
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index 88d1ace0..a9e49de7 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(rand());
+ $proxy->uuid = md5(mt_rand());
$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 19a3f9da..6f9e20df 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(rand());
+ $proxy->uuid = md5(mt_rand());
$proxy->item_id = $photo->id;
return $proxy->save();
}
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
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 0b0dcbc1..6a948999 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(rand());
+ $csrf = md5(time() . mt_rand());
$session->set("csrf", $csrf);
}
return $csrf;
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php
index 2237b702..e7247edc 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[rand()] = array($module_name, $block_id);
+ $blocks[mt_rand()] = 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 3d82bc69..9c42caad 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[rand()] = $block;
+ $new_blocks[mt_rand()] = $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 = rand();
+ $new_slug = mt_rand();
}
db::build()
->update("items")
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index a4d24b8f..b6713fc3 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -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"] . "-" . rand() . "." . $pi["extension"];
+ $this->name = $pi["filename"] . "-" . mt_rand() . "." . $pi["extension"];
parent::save();
}
@@ -512,7 +512,7 @@ class Item_Model_Core extends ORM_MPTT {
->or_where("slug", "=", $this->slug)
->close()
->find()->id) {
- $rand = rand();
+ $rand = mt_rand();
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 6c64394d..86c74890 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_" . rand();
+ $new_name = "new_name_" . mt_rand();
$_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 e8d8b6f4..6cee2862 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(rand());
+ $id = md5(mt_rand());
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(rand());
+ $id = md5(mt_rand());
db::build()
->insert("caches")
@@ -54,7 +54,7 @@ class Cache_Test extends Gallery_Unit_Test_Case {
}
public function cache_set_test() {
- $id = md5(rand());
+ $id = md5(mt_rand());
$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(rand());
+ $id1 = md5(mt_rand());
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(rand());
+ $id2 = md5(mt_rand());
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 84600);
- $id3 = md5(rand());
+ $id3 = md5(mt_rand());
$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(rand());
+ $id1 = md5(mt_rand());
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(rand());
+ $id2 = md5(mt_rand());
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(rand());
+ $id3 = md5(mt_rand());
$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(rand());
+ $id1 = md5(mt_rand());
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(rand());
+ $id2 = md5(mt_rand());
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(rand());
+ $id3 = md5(mt_rand());
$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(rand());
+ $id1 = md5(mt_rand());
$value1 = array("field1" => "value1", "field2" => "value2");
$this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
- $id2 = md5(rand());
+ $id2 = md5(mt_rand());
$value2 = array("field3" => "value3", "field4" => "value4");
$this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
- $id3 = md5(rand());
+ $id3 = md5(mt_rand());
$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 eb2458cb..c93cc239 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 = rand();
+ $rand = mt_rand();
$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 1e6d54d0..0d6d10af 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 = rand(); // invalid
+ $item->album_cover_item_id = mt_rand(); // invalid
$item->description = str_repeat("x", 70000); // invalid
$item->name = null;
- $item->parent_id = rand();
+ $item->parent_id = mt_rand();
$item->slug = null;
$item->sort_column = "bogus";
$item->sort_order = "bogus";
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php
index 1be82a74..d5149492 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 = rand();
+ $rand = mt_rand();
$album = ORM::factory("item");
$album->type = "album";
@@ -34,7 +34,7 @@ class test_Core {
}
static function random_photo_unsaved($parent=null) {
- $rand = rand();
+ $rand = mt_rand();
$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_" . rand();
+ $rand = "name_" . mt_rand();
return identity::create_user($rand, $rand, $password, "$rand@rand.com");
}
static function random_group() {
- return identity::create_group((string)rand());
+ return identity::create_group((string)mt_rand());
}
static function random_name($item=null) {
- $rand = "name_" . rand();
+ $rand = "name_" . mt_rand();
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)rand();
+ $tag->name = (string)mt_rand();
// Reload so that ORM coerces all fields into strings.
return $tag->save()->reload();
diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php
index d8c69e94..4d7a4a1b 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 . rand());
+ $key->access_key = md5($user->name . time() . mt_rand());
$key->save();
}
@@ -64,7 +64,7 @@ class rest_event {
if (!$key->loaded()) {
$key->user_id = $user->id;
- $key->access_key = md5($user->name . rand());
+ $key->access_key = md5($user->name . time() . mt_rand());
$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 . rand());
+ $key->access_key = md5($data->user->name . time() . mt_rand());
$key->save();
}
$view->rest_key = $key->access_key;
--
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/helpers')
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 53a2652fd6ba652b1b6604f8a4930403376a3ef5 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 16 Dec 2010 20:36:00 -0800
Subject: Create url::merge_querystring() which merges a query string into an
existing url. Fixes #1537.
---
modules/gallery/helpers/MY_url.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index 877c5ada..d3ab1b4d 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -101,4 +101,18 @@ class url extends url_Core {
static function current($qs=false, $suffix=false) {
return htmlspecialchars(parent::current($qs, $suffix));
}
+
+ /**
+ * Merge extra an query string onto a given url safely.
+ * @param string the original url
+ * @param array the query string data in key=value form
+ */
+ static function merge_querystring($url, $query_params) {
+ $qs = implode("&", $query_params);
+ if (strpos($url, "?") === false) {
+ return $url . "?$qs";
+ } else {
+ return $url . "&$qs";
+ }
+ }
}
--
cgit v1.2.3
From 7eaf49a6ca97afbe6c82fc830602e7006d53f704 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 16 Dec 2010 20:38:01 -0800
Subject: Create a "tree" rest resource that can return the entire album tree
in a single fast request, among other operations. Fixes #1538.
---
modules/gallery/helpers/tree_rest.php | 91 +++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
create mode 100644 modules/gallery/helpers/tree_rest.php
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/tree_rest.php b/modules/gallery/helpers/tree_rest.php
new file mode 100644
index 00000000..616bebe3
--- /dev/null
+++ b/modules/gallery/helpers/tree_rest.php
@@ -0,0 +1,91 @@
+
+ * Only traverse this far down into the tree. If there are more albums
+ * below this depth, provide RESTful urls to other tree resources in
+ * the members section. Default is infinite.
+ *
+ * type=
+ * Restrict the items displayed to the given type. Default is all types.
+ *
+ * fields=
+ * In the entity section only return these fields for each item.
+ * Default is all fields.
+ */
+ static function get($request) {
+ $item = rest::resolve($request->url);
+ access::required("view", $item);
+
+ $query_params = array();
+ $p = $request->params;
+ $where = array();
+ if (isset($p->type)) {
+ $where[] = array("type", "=", $p->type);
+ $query_params[] = "type={$p->type}";
+ }
+
+ if (isset($p->depth)) {
+ $lowest_depth = $item->level + $p->depth;
+ $where[] = array("level", "<=", $lowest_depth);
+ $query_params[] = "depth={$p->depth}";
+ }
+
+ $fields = array();
+ if (isset($p->fields)) {
+ $fields = explode(",", $p->fields);
+ $query_params[] = "fields={$p->fields}";
+ }
+
+ $entity = array();
+ $members = array();
+ foreach ($item->viewable()->descendants(null, null, $where) as $child) {
+ $entity[] = array("url" => rest::url("item", $child),
+ "entity" => $child->as_restful_array($fields));
+ if (isset($lowest_depth) && $child->level == $lowest_depth) {
+ $members[] = url::merge_querystring(rest::url("tree", $child), $query_params);
+ }
+ }
+
+ $result = array(
+ "url" => $request->url,
+ "entity" => $entity,
+ "members" => $members,
+ "relationships" => rest::relationships("tree", $item));
+ return $result;
+ }
+
+ static function resolve($id) {
+ $item = ORM::factory("item", $id);
+ if (!access::can("view", $item)) {
+ throw new Kohana_404_Exception();
+ }
+ return $item;
+ }
+
+ static function url($item) {
+ return url::abs_site("rest/tree/{$item->id}");
+ }
+}
--
cgit v1.2.3
From 16555935ee45a09b8d5b5b351222631ba2ce2132 Mon Sep 17 00:00:00 2001
From: Kriss Andsten
Date: Fri, 17 Dec 2010 11:32:58 +0800
Subject: Fetch permissions for non-albumbs by parent rather than by item,
allowing the result to be cached.
---
modules/gallery/helpers/access.php | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index a7ac3f9f..bfe02b3c 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -99,8 +99,15 @@ class access_Core {
return true;
}
+ /*
+ We do this for cache reasons - if you check n photos in an album, it makes more sense
+ to check the album permissions once and let the cache deal with that, rather than check
+ every item individually and generate cache misses.
+ */
+ $id = ($item->type == 'album') ? $item->id : $item->parent_id;
$resource = $perm_name == "view" ?
- $item : model_cache::get("access_cache", $item->id, "item_id");
+ $item : model_cache::get("access_cache", $id, "item_id");
+
foreach ($user->groups() as $group) {
if ($resource->__get("{$perm_name}_{$group->id}") === access::ALLOW) {
return true;
@@ -136,8 +143,15 @@ class access_Core {
* @return boolean
*/
static function group_can($group, $perm_name, $item) {
+ /*
+ We do this for cache reasons - if you check n photos in an album, it makes more sense
+ to check the album permissions once and let the cache deal with that, rather than check
+ every item individually and generate cache misses.
+ */
+ $id = ($item->type == 'album') ? $item->id : $item->parent_id;
$resource = $perm_name == "view" ?
- $item : model_cache::get("access_cache", $item->id, "item_id");
+ $item : model_cache::get("access_cache", $id, "item_id");
+
return $resource->__get("{$perm_name}_{$group->id}") === access::ALLOW;
}
--
cgit v1.2.3
From 6e58fced201705d73f5e080f16f482ae0f15e333 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 16 Dec 2010 21:01:51 -0800
Subject: Follow on to 16555935ee45a09b8d5b5b351222631ba2ce2132 to clean up the
style a bit. Tracked in #1539.
---
modules/gallery/helpers/access.php | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index bfe02b3c..4148049a 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -99,15 +99,12 @@ class access_Core {
return true;
}
- /*
- We do this for cache reasons - if you check n photos in an album, it makes more sense
- to check the album permissions once and let the cache deal with that, rather than check
- every item individually and generate cache misses.
- */
- $id = ($item->type == 'album') ? $item->id : $item->parent_id;
+ // Use the nearest parent album (including the current item) so that we take advantage
+ // of the cache when checking many items in a single album.
+ $id = ($item->type == "album") ? $item->id : $item->parent_id;
$resource = $perm_name == "view" ?
$item : model_cache::get("access_cache", $id, "item_id");
-
+
foreach ($user->groups() as $group) {
if ($resource->__get("{$perm_name}_{$group->id}") === access::ALLOW) {
return true;
@@ -143,15 +140,12 @@ class access_Core {
* @return boolean
*/
static function group_can($group, $perm_name, $item) {
- /*
- We do this for cache reasons - if you check n photos in an album, it makes more sense
- to check the album permissions once and let the cache deal with that, rather than check
- every item individually and generate cache misses.
- */
- $id = ($item->type == 'album') ? $item->id : $item->parent_id;
+ // Use the nearest parent album (including the current item) so that we take advantage
+ // of the cache when checking many items in a single album.
+ $id = ($item->type == "album") ? $item->id : $item->parent_id;
$resource = $perm_name == "view" ?
$item : model_cache::get("access_cache", $id, "item_id");
-
+
return $resource->__get("{$perm_name}_{$group->id}") === access::ALLOW;
}
--
cgit v1.2.3
From e60edcdeba577e8cdbdbbc700cb3dfe9d0dd9443 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 17 Dec 2010 17:30:00 -0800
Subject: Include the root in the tree output.
---
modules/gallery/helpers/tree_rest.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/tree_rest.php b/modules/gallery/helpers/tree_rest.php
index 616bebe3..21928cbe 100644
--- a/modules/gallery/helpers/tree_rest.php
+++ b/modules/gallery/helpers/tree_rest.php
@@ -59,7 +59,8 @@ class tree_rest_Core {
$query_params[] = "fields={$p->fields}";
}
- $entity = array();
+ $entity = array(array("url" => rest::url("item", $item),
+ "entity" => $item->as_restful_array($fields)));
$members = array();
foreach ($item->viewable()->descendants(null, null, $where) as $child) {
$entity[] = array("url" => rest::url("item", $child),
--
cgit v1.2.3
From dbb9b8b1c8ee5395a65b6329c793e7a2c398ef00 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 17 Dec 2010 22:19:46 -0800
Subject: Sort the Admin > Settings menu instead of relying on module
activation order. Requires making Menu::get() return a reference. Fixes
#1545.
---
modules/gallery/helpers/gallery_event.php | 3 +++
modules/gallery/libraries/Admin_View.php | 4 ++++
modules/gallery/libraries/Menu.php | 5 +++--
3 files changed, 10 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index b59bb9b9..cbb939bb 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -371,6 +371,9 @@ class gallery_event_Core {
->id("admin_menu")
->label(t("Admin")));
module::event("admin_menu", $admin_menu, $theme);
+
+ $settings_menu = $admin_menu->get("settings_menu");
+ sort($settings_menu->elements);
}
}
}
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 74ed4fb3..11f8ad14 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -44,6 +44,10 @@ class Admin_View_Core extends Gallery_View {
public function admin_menu() {
$menu = Menu::factory("root");
module::event("admin_menu", $menu, $this);
+
+ $settings_menu = $menu->get("settings_menu");
+ sort($settings_menu->elements);
+
return $menu->render();
}
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 3ad6ebef..58852a72 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -223,12 +223,13 @@ class Menu_Core extends Menu_Element {
/**
* Retrieve a Menu_Element by id
*/
- public function get($id) {
+ public function &get($id) {
if (array_key_exists($id, $this->elements)) {
return $this->elements[$id];
}
- return null;
+ $null = null;
+ return $null;
}
public function is_empty() {
--
cgit v1.2.3
From 612ddd7050889974fc1f7e449e715b4c1129c0bb Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 18 Dec 2010 11:55:04 -0800
Subject: Warn admins after login if their PHP install has the
session.use_trans_sid feature enabled, since this will cause random logouts.
Partial fix for #1316.
---
modules/gallery/helpers/gallery_event.php | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index cbb939bb..5d3ee6ee 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -178,6 +178,10 @@ class gallery_event_Core {
}
Session::instance()->set("active_auth_timestamp", time());
auth::clear_failed_attempts($user);
+
+ if ($user->admin && ini_get("session.use_trans_sid")) {
+ message::info(t("PHP is configured with session.use_trans_sid enabled which will cause random logouts. Please disable this setting.", array("url" => "http://www.php.net/manual/en/session.configuration.php#ini.session.use-trans-sid")));
+ }
}
static function user_auth_failed($name) {
--
cgit v1.2.3
From 48640005a4edac955d9087f62fed1ab5f756b686 Mon Sep 17 00:00:00 2001
From: Kriss Andsten
Date: Tue, 21 Dec 2010 09:03:46 +0800
Subject: Packaging + tests of Bharat's find_by_path routine.
---
modules/gallery/helpers/item.php | 25 +++++++++++++++-
modules/gallery/tests/Item_Helper_Test.php | 48 ++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 664da812..dbad59b9 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -208,7 +208,30 @@ class item_Core {
return $model;
}
-
+
+ static function find_by_path($path) {
+ $path = trim($path, '/');
+
+ // The root path name is NULL, not '', hence this workaround.
+ if ($path == '') {
+ return ORM::factory("item", 1);
+ }
+
+ $paths = explode("/", $path);
+ $count = count($paths);
+ foreach (ORM::factory("item")
+ ->where('name', '=', $paths[$count - 1])
+ ->where('level', '=', $count + 1)
+ ->find_all() as $item) {
+ if (urldecode($item->relative_path()) == $path) {
+ return $item;
+ }
+ }
+
+ return false;
+ }
+
+
/**
* Return the root Item_Model
* @return Item_Model
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 26db5a63..1fced654 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -125,4 +125,52 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$this->assert_same($photo2->id, $album->album_cover_item_id);
$this->assert_same($photo2->id, $parent->album_cover_item_id);
}
+
+ public function find_by_path_does_the_right_thing_test() {
+ $level1 = test::random_album();
+ $level2 = test::random_album($level1);
+ $level3 = test::random_photo($level2);
+ $level3->name = 'same.jpg';
+ $level3->save();
+
+ $level2b = test::random_album($level1);
+ $level3b = test::random_photo($level2b);
+ $level3b->name = 'same.jpg';
+ $level3b->save();
+
+ // Item in album
+ $this->assert_same(
+ item::find_by_path('/' . $level1->name . '/' . $level2->name . '/' . $level3->name)->id,
+ $level3->id);
+
+ // Album, ends with a slash
+ $this->assert_same(
+ item::find_by_path($level1->name . '/' . $level2->name . '/')->id,
+ $level2->id);
+
+ // Album, ends without a slash
+ $this->assert_same(
+ item::find_by_path('/' . $level1->name . '/' . $level2->name)->id,
+ $level2->id);
+
+ // Return root if '' is passed
+ $this->assert_same(
+ item::find_by_path('')->id,
+ "1");
+
+ // Verify that we don't get confused by the part names
+ $this->assert_same(
+ item::find_by_path($level1->name . '/' . $level2->name . '/' . $level3->name)->id,
+ $level3->id);
+
+ $this->assert_same(
+ item::find_by_path($level1->name . '/' . $level2b->name . '/' . $level3b->name)->id,
+ $level3b->id);
+
+ // Verify that we don't get false positives
+ $this->assert_same(
+ item::find_by_path('foo/bar/baz'),
+ false);
+
+ }
}
--
cgit v1.2.3
From addd384bbdca6a9f066403c1d2919f3e863e072e Mon Sep 17 00:00:00 2001
From: Kriss Andsten
Date: Wed, 22 Dec 2010 07:55:26 +0800
Subject: Minor changes to satisfy the G3 code standards.
---
modules/gallery/helpers/item.php | 15 ++++++++++-----
modules/gallery/tests/Item_Helper_Test.php | 18 +++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index dbad59b9..f38d9888 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -208,20 +208,25 @@ class item_Core {
return $model;
}
-
+
+ /**
+ * Return an item by path.
+ * @param string $path
+ * @return object item
+ */
static function find_by_path($path) {
- $path = trim($path, '/');
+ $path = trim($path, "/");
// The root path name is NULL, not '', hence this workaround.
if ($path == '') {
- return ORM::factory("item", 1);
+ return ORM::factory("item", item::root());
}
$paths = explode("/", $path);
$count = count($paths);
foreach (ORM::factory("item")
- ->where('name', '=', $paths[$count - 1])
- ->where('level', '=', $count + 1)
+ ->where("name", "=", $paths[$count - 1])
+ ->where("level", "=", $count + 1)
->find_all() as $item) {
if (urldecode($item->relative_path()) == $path) {
return $item;
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 1fced654..4bc64ff0 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -130,46 +130,46 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level1 = test::random_album();
$level2 = test::random_album($level1);
$level3 = test::random_photo($level2);
- $level3->name = 'same.jpg';
+ $level3->name = "same.jpg";
$level3->save();
$level2b = test::random_album($level1);
$level3b = test::random_photo($level2b);
- $level3b->name = 'same.jpg';
+ $level3b->name = "same.jpg";
$level3b->save();
// Item in album
$this->assert_same(
- item::find_by_path('/' . $level1->name . '/' . $level2->name . '/' . $level3->name)->id,
+ item::find_by_path("/" . $level1->name . "/" . $level2->name . "/" . $level3->name)->id,
$level3->id);
// Album, ends with a slash
$this->assert_same(
- item::find_by_path($level1->name . '/' . $level2->name . '/')->id,
+ item::find_by_path($level1->name . "/" . $level2->name . "/")->id,
$level2->id);
// Album, ends without a slash
$this->assert_same(
- item::find_by_path('/' . $level1->name . '/' . $level2->name)->id,
+ item::find_by_path("/" . $level1->name . "/" . $level2->name)->id,
$level2->id);
// Return root if '' is passed
$this->assert_same(
- item::find_by_path('')->id,
+ item::find_by_path("")->id,
"1");
// Verify that we don't get confused by the part names
$this->assert_same(
- item::find_by_path($level1->name . '/' . $level2->name . '/' . $level3->name)->id,
+ item::find_by_path($level1->name . "/" . $level2->name . "/" . $level3->name)->id,
$level3->id);
$this->assert_same(
- item::find_by_path($level1->name . '/' . $level2b->name . '/' . $level3b->name)->id,
+ item::find_by_path($level1->name . "/" . $level2b->name . "/" . $level3b->name)->id,
$level3b->id);
// Verify that we don't get false positives
$this->assert_same(
- item::find_by_path('foo/bar/baz'),
+ item::find_by_path("foo/bar/baz"),
false);
}
--
cgit v1.2.3
From f493130e59f26d41f090c5ca40e95b416b9b154b Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 16:55:01 -0800
Subject: Tighten up item::find_by_path slightly. Augment the tests to cover
special characters in the file name ("+" is an edge case differentiator
between rawurlencode and urlencode).
---
modules/gallery/helpers/item.php | 25 ++++++++++++-------------
modules/gallery/tests/Item_Helper_Test.php | 2 +-
2 files changed, 13 insertions(+), 14 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index f38d9888..3596a2bf 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -210,33 +210,32 @@ class item_Core {
}
/**
- * Return an item by path.
+ * Find an item by its path. If there's no match, return an empty Item_Model.
* @param string $path
- * @return object item
+ * @return object Item_Model
*/
static function find_by_path($path) {
$path = trim($path, "/");
-
- // The root path name is NULL, not '', hence this workaround.
- if ($path == '') {
- return ORM::factory("item", item::root());
+
+ // The root path name is NULL not "", hence this workaround.
+ if ($path == "") {
+ return item::root();
}
-
+
$paths = explode("/", $path);
- $count = count($paths);
foreach (ORM::factory("item")
- ->where("name", "=", $paths[$count - 1])
- ->where("level", "=", $count + 1)
+ ->where("name", "=", end($paths))
+ ->where("level", "=", count($paths) + 1)
->find_all() as $item) {
if (urldecode($item->relative_path()) == $path) {
return $item;
}
}
-
+
return false;
}
-
-
+
+
/**
* Return the root Item_Model
* @return Item_Model
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index d60380f0..4124e453 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -135,7 +135,7 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level2b = test::random_album($level1);
$level3b = test::random_photo($level2b);
- $level3b->name = "same.jpg";
+ $level3b->name = "has spaces+plusses.jpg";
$level3b->save();
// Item in album
--
cgit v1.2.3
From 2a08cbf76da0f9984c0e182e6c448b516d8d7db3 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 16:58:54 -0800
Subject: Return an empty Item_Model when item::find_by_path fails
---
modules/gallery/helpers/item.php | 2 +-
modules/gallery/tests/Item_Helper_Test.php | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 3596a2bf..08a04ad0 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -232,7 +232,7 @@ class item_Core {
}
}
- return false;
+ return new Item_Model();
}
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 4124e453..0aa7504e 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -166,8 +166,7 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
item::find_by_path("{$level1->name}/{$level2b->name}/{$level3b->name}")->id);
// Verify that we don't get false positives
- $this->assert_same(
- false,
- item::find_by_path("foo/bar/baz"));
+ $this->assert_false(
+ item::find_by_path("foo/bar/baz")->loaded());
}
}
--
cgit v1.2.3
From d9299f3b3f4b1a52f5b68399cfcaa96d5b367899 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 19:33:47 -0800
Subject: Change item::find_by_path() to check the relative_path_cache first,
and only fall back the name/level comparison if there's no cached entry.
Update tests accordingly.
---
modules/gallery/helpers/item.php | 16 ++++++++++++++++
modules/gallery/tests/Item_Helper_Test.php | 20 ++++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 08a04ad0..bac189f4 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -211,6 +211,7 @@ class item_Core {
/**
* Find an item by its path. If there's no match, return an empty Item_Model.
+ * NOTE: the caller is responsible for performing security checks on the resulting item.
* @param string $path
* @return object Item_Model
*/
@@ -222,6 +223,21 @@ class item_Core {
return item::root();
}
+ // Check to see if there's an item in the database with a matching relative_path_cache value.
+ // Since that field is urlencoded, we must urlencoded the components of the path.
+ foreach (explode("/", $path) as $part) {
+ $encoded_array[] = rawurlencode($part);
+ }
+ $encoded_path = join("/", $encoded_array);
+ $item = ORM::factory("item")
+ ->where("relative_path_cache", "=", $encoded_path)
+ ->find();
+ if ($item->loaded()) {
+ return $item;
+ }
+
+ // Since the relative_path_cache field is a cache, it can be unavailable. If we don't find
+ // anything, fall back to checking the path the hard way.
$paths = explode("/", $path);
foreach (ORM::factory("item")
->where("name", "=", end($paths))
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 0aa7504e..13ecec2b 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -129,14 +129,21 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
public function find_by_path_test() {
$level1 = test::random_album();
$level2 = test::random_album($level1);
- $level3 = test::random_photo($level2);
+ $level3 = test::random_photo_unsaved($level2);
$level3->name = "same.jpg";
- $level3->save();
+ $level3->save()->reload();
$level2b = test::random_album($level1);
- $level3b = test::random_photo($level2b);
+ $level3b = test::random_photo_unsaved($level2b);
$level3b->name = "has spaces+plusses.jpg";
- $level3b->save();
+ $level3b->save()->reload();
+
+ // Make sure that some of the calls below use the fallback code.
+ db::build()
+ ->update("items")
+ ->set(array("relative_url_cache" => null, "relative_path_cache" => null))
+ ->where("id", "IN", array($level3->id, $level3b->id))
+ ->execute();
// Item in album
$this->assert_same(
@@ -168,5 +175,10 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
// Verify that we don't get false positives
$this->assert_false(
item::find_by_path("foo/bar/baz")->loaded());
+
+ // Verify that the fallback code works
+ $this->assert_same(
+ $level3b->id,
+ item::find_by_path("{$level1->name}/{$level2b->name}/{$level3b->name}")->id);
}
}
--
cgit v1.2.3
From 98fd1e9957ff0d65d1bbb0eaa2df6c1e59487b25 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 20:47:07 -0800
Subject: Implement item::find_by_relative_url with tests.
---
modules/gallery/helpers/item.php | 26 +++++++++++
modules/gallery/tests/Item_Helper_Test.php | 70 +++++++++++++++++++++++++-----
2 files changed, 86 insertions(+), 10 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index bac189f4..29dd8603 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -252,6 +252,32 @@ class item_Core {
}
+ /**
+ * Locate an item using the URL. We assume that the url is in the form /a/b/c where each
+ * component matches up with an item slug. If there's no match, return an empty Item_Model
+ * NOTE: the caller is responsible for performing security checks on the resulting item.
+ * @param string $url the relative url fragment
+ * @return Item_Model
+ */
+ static function find_by_relative_url($relative_url) {
+ // In most cases, we'll have an exact match in the relative_url_cache item field.
+ // but failing that, walk down the tree until we find it. The fallback code will fix caches
+ // as it goes, so it'll never be run frequently.
+ $item = ORM::factory("item")->where("relative_url_cache", "=", $relative_url)->find();
+ if (!$item->loaded()) {
+ $segments = explode("/", $relative_url);
+ foreach (ORM::factory("item")
+ ->where("slug", "=", end($segments))
+ ->where("level", "=", count($segments) + 1)
+ ->find_all() as $match) {
+ if ($match->relative_url() == $relative_url) {
+ $item = $match;
+ }
+ }
+ }
+ return $item;
+ }
+
/**
* Return the root Item_Model
* @return Item_Model
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 13ecec2b..42acfb18 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -128,23 +128,19 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
public function find_by_path_test() {
$level1 = test::random_album();
- $level2 = test::random_album($level1);
+ $level2 = test::random_album_unsaved($level1);
+ $level2->name = "plus + space";
+ $level2->save()->reload();
+
$level3 = test::random_photo_unsaved($level2);
$level3->name = "same.jpg";
$level3->save()->reload();
$level2b = test::random_album($level1);
$level3b = test::random_photo_unsaved($level2b);
- $level3b->name = "has spaces+plusses.jpg";
+ $level3b->name = "same.jpg";
$level3b->save()->reload();
- // Make sure that some of the calls below use the fallback code.
- db::build()
- ->update("items")
- ->set(array("relative_url_cache" => null, "relative_path_cache" => null))
- ->where("id", "IN", array($level3->id, $level3b->id))
- ->execute();
-
// Item in album
$this->assert_same(
$level3->id,
@@ -163,7 +159,12 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
// Return root if "" is passed
$this->assert_same(item::root()->id, item::find_by_path("")->id);
- // Verify that we don't get confused by the part names
+ // Verify that we don't get confused by the part names, using the fallback code.
+ db::build()
+ ->update("items")
+ ->set(array("relative_path_cache" => null))
+ ->where("id", "IN", array($level3->id, $level3b->id))
+ ->execute();
$this->assert_same(
$level3->id,
item::find_by_path("{$level1->name}/{$level2->name}/{$level3->name}")->id);
@@ -181,4 +182,53 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level3b->id,
item::find_by_path("{$level1->name}/{$level2b->name}/{$level3b->name}")->id);
}
+
+ public function find_by_relative_url_test() {
+ $level1 = test::random_album();
+ $level2 = test::random_album($level1);
+ $level3 = test::random_photo_unsaved($level2);
+ $level3->slug = "same";
+ $level3->save()->reload();
+
+ $level2b = test::random_album($level1);
+ $level3b = test::random_photo_unsaved($level2b);
+ $level3b->slug = "same";
+ $level3b->save()->reload();
+
+ // Item in album
+ $this->assert_same(
+ $level3->id,
+ item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
+
+ // Album, ends without a slash
+ $this->assert_same(
+ $level2->id,
+ item::find_by_relative_url("{$level1->slug}/{$level2->slug}")->id);
+
+ // Return root if "" is passed
+ $this->assert_same(item::root()->id, item::find_by_relative_url("")->id);
+
+ // Verify that we don't get confused by the part slugs, using the fallback code.
+ db::build()
+ ->update("items")
+ ->set(array("relative_url_cache" => null))
+ ->where("id", "IN", array($level3->id, $level3b->id))
+ ->execute();
+ $this->assert_same(
+ $level3->id,
+ item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
+
+ $this->assert_same(
+ $level3b->id,
+ item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
+
+ // Verify that we don't get false positives
+ $this->assert_false(
+ item::find_by_relative_url("foo/bar/baz")->loaded());
+
+ // Verify that the fallback code works
+ $this->assert_same(
+ $level3b->id,
+ item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
+ }
}
--
cgit v1.2.3
From 032e6fde5f99c3150a4ae70e410ce314d8c3877a Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 21 Dec 2010 20:47:14 -0800
Subject: Change MY_url::parse_url to use item::find_by_relative_url.
---
modules/gallery/helpers/MY_url.php | 28 +---------------------------
1 file changed, 1 insertion(+), 27 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index d3ab1b4d..8ac26602 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -31,7 +31,7 @@ class url extends url_Core {
return;
}
- $item = self::get_item_from_uri(Router::$current_uri);
+ $item = item::find_by_relative_url(html_entity_decode(Router::$current_uri, ENT_QUOTES));
if ($item && $item->loaded()) {
Router::$controller = "{$item->type}s";
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
@@ -40,32 +40,6 @@ class url extends url_Core {
}
}
- /**
- * Locate an item using the URI. We assume that the uri is in the form /a/b/c where each
- * component matches up with an item slug.
- * @param string $uri the uri fragment
- * @return Item_Model
- */
- static function get_item_from_uri($uri) {
- $current_uri = html_entity_decode($uri, ENT_QUOTES);
- // In most cases, we'll have an exact match in the relative_url_cache item field.
- // but failing that, walk down the tree until we find it. The fallback code will fix caches
- // as it goes, so it'll never be run frequently.
- $item = ORM::factory("item")->where("relative_url_cache", "=", $current_uri)->find();
- if (!$item->loaded()) {
- $count = count(Router::$segments);
- foreach (ORM::factory("item")
- ->where("slug", "=", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES))
- ->where("level", "=", $count + 1)
- ->find_all() as $match) {
- if ($match->relative_url() == $current_uri) {
- $item = $match;
- }
- }
- }
- return $item;
- }
-
/**
* Just like url::file() except that it returns an absolute URI
*/
--
cgit v1.2.3
From 2b83918efd387dac1b86667a6c9027758dd4dbef Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Thu, 23 Dec 2010 23:16:30 -0800
Subject: Fix PHPDoc for composite().
---
modules/gallery/helpers/gallery_graphics.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php
index 6038a95b..fca18076 100644
--- a/modules/gallery/helpers/gallery_graphics.php
+++ b/modules/gallery/helpers/gallery_graphics.php
@@ -75,7 +75,7 @@ class gallery_graphics_Core {
/**
* Overlay an image on top of the input file.
*
- * Valid options are: file, mime_type, position, transparency_percent, padding
+ * Valid options are: file, position, transparency, padding
*
* Valid positions: northwest, north, northeast,
* west, center, east,
--
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/helpers')
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 11df9f204f110ebb1a82e851a668bbaa4b7560ee Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 24 Dec 2010 01:10:17 -0800
Subject: Added Croatian as hr_HR. Fixes #1514.
---
modules/gallery/helpers/locales.php | 2 ++
1 file changed, 2 insertions(+)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 565e9da8..d06bb319 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -64,6 +64,7 @@ class locales_Core {
// @todo Might want to add a localizable language name as well.
// ref: http://cldr.unicode.org/
// ref: http://cldr.unicode.org/index/cldr-spec/picking-the-right-language-code
+ // ref: http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/likely_subtags.html
private static function _init_language_data() {
$l["af_ZA"] = "Afrikaans"; // Afrikaans
$l["ar_SA"] = "العربية"; // Arabic
@@ -88,6 +89,7 @@ class locales_Core {
$l["fr_FR"] = "Français"; // French
$l["ga_IE"] = "Gaeilge"; // Irish
$l["he_IL"] = "עברית"; // Hebrew
+ $l["hr_HR"] = "hr̀vātskī"; // Croatian
$l["hu_HU"] = "Magyar"; // Hungarian
$l["is_IS"] = "Icelandic"; // Icelandic
$l["it_IT"] = "Italiano"; // Italian
--
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/helpers')
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 440597356d8719bdc6733d2d86aaef5f86d05a1e Mon Sep 17 00:00:00 2001
From: Joe7
Date: Mon, 27 Dec 2010 22:16:29 +0100
Subject: Added changes to installer and upgrader scripts to support INSERT ON
DUPLICATE KEY UPDATE SYNTAX in cache lib
---
installer/install.sql | 2 +-
modules/gallery/helpers/gallery_installer.php | 7 ++++++-
modules/gallery/module.info | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/install.sql b/installer/install.sql
index 427a3283..baee2b9d 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -43,7 +43,7 @@ CREATE TABLE {caches} (
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
- KEY `key` (`key`),
+ UNIQUE KEY `key` (`key`),
KEY `tags` (`tags`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index fb7933f7..bf6186a9 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -309,7 +309,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", 41);
+ module::set_version("gallery", 42);
}
static function upgrade($version) {
@@ -642,6 +642,11 @@ class gallery_installer {
module::clear_var("gallery", "_cache");
module::set_version("gallery", $version = 41);
}
+
+ if ($version == 41) {
+ $db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)");
+ module::set_version("gallery", $version = 42);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 2b684e5e..0cc3f6d1 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 41
+version = 42
--
cgit v1.2.3
From 869bba5e132ceb960b72744fc3ebad5e6af14439 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Tue, 28 Dec 2010 18:42:43 +0100
Subject: Truncating table first againt collides when converting INDEX into
Unique
---
modules/gallery/helpers/gallery_installer.php | 1 +
1 file changed, 1 insertion(+)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index bf6186a9..cb314527 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -644,6 +644,7 @@ class gallery_installer {
}
if ($version == 41) {
+ $db->query("TRUNCATE TABLE {caches}");
$db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)");
module::set_version("gallery", $version = 42);
}
--
cgit v1.2.3
From a8b0254e4a64b46bef303fbf2dafc4d9553ae38f Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Wed, 29 Dec 2010 17:31:28 -0800
Subject: Improve the solution for #1545 by sorting the settings menu properly
to be naturally ordered and case insensitive.
---
modules/gallery/helpers/gallery_event.php | 2 +-
modules/gallery/libraries/Admin_View.php | 2 +-
modules/gallery/libraries/Menu.php | 4 ++++
3 files changed, 6 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 5d3ee6ee..689e21d1 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -377,7 +377,7 @@ class gallery_event_Core {
module::event("admin_menu", $admin_menu, $theme);
$settings_menu = $admin_menu->get("settings_menu");
- sort($settings_menu->elements);
+ uasort($settings_menu->elements, array("Menu", "title_comparator"));
}
}
}
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 11f8ad14..bff13ace 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -46,7 +46,7 @@ class Admin_View_Core extends Gallery_View {
module::event("admin_menu", $menu, $this);
$settings_menu = $menu->get("settings_menu");
- sort($settings_menu->elements);
+ uasort($settings_menu->elements, array("Menu", "title_comparator"));
return $menu->render();
}
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 58852a72..78b60196 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -250,4 +250,8 @@ class Menu_Core extends Menu_Element {
$view->menu = $this;
return $view;
}
+
+ static function title_comparator($a, $b) {
+ return strnatcasecmp((string)$a->label, (string)$b->label);
+ }
}
--
cgit v1.2.3
From b26eff7f23b970a7983baf5e211ba88968effb9d Mon Sep 17 00:00:00 2001
From: Joe7
Date: Mon, 3 Jan 2011 15:44:36 +0100
Subject: Bugfix: input validation validates description up to length of 65535
chars, but DB trimmed data over 2048 chars. Converting column into TEXT type.
Note: The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is
subject to the maximum row size (65,535 bytes, which is shared among all
columns) and the character set used. In contrast to CHAR, VARCHAR values are
stored as a one-byte or two-byte length prefix plus data. The length prefix
indicates the number of bytes in the value. A column uses one length byte if
values require no more than 255 bytes, two length bytes if values may require
more than 255 bytes.
---
installer/install.sql | 2 +-
modules/gallery/helpers/gallery_installer.php | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/install.sql b/installer/install.sql
index 2a2bf269..7a0f99c4 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -152,7 +152,7 @@ CREATE TABLE {items} (
`album_cover_item_id` int(9) DEFAULT NULL,
`captured` int(9) DEFAULT NULL,
`created` int(9) DEFAULT NULL,
- `description` varchar(2048) DEFAULT NULL,
+ `description` TEXT DEFAULT NULL,
`height` int(9) DEFAULT NULL,
`left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index cb314527..90d6d4b7 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -309,7 +309,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", 42);
+ module::set_version("gallery", 43);
}
static function upgrade($version) {
@@ -648,6 +648,11 @@ class gallery_installer {
$db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)");
module::set_version("gallery", $version = 42);
}
+
+ if ($version == 42) {
+ $db->query("ALTER TABLE {items} CHANGE `description` `description` TEXT DEFAULT NULL");
+ module::set_version("gallery", $version = 43);
+ }
}
static function uninstall() {
--
cgit v1.2.3
From e6a5f39b9113fa9cfc526b873947e365793d4e3e Mon Sep 17 00:00:00 2001
From: Joe7
Date: Mon, 3 Jan 2011 20:07:12 +0100
Subject: case fix
---
modules/gallery/helpers/gallery_installer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 90d6d4b7..834a27fa 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -650,7 +650,7 @@ class gallery_installer {
}
if ($version == 42) {
- $db->query("ALTER TABLE {items} CHANGE `description` `description` TEXT DEFAULT NULL");
+ $db->query("ALTER TABLE {items} CHANGE `description` `description` text DEFAULT NULL");
module::set_version("gallery", $version = 43);
}
}
--
cgit v1.2.3
From d74aad072d8ccca70efb1c8b673e8368566a1974 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 3 Jan 2011 12:25:51 -0800
Subject: Some small follow on fixes for #1559 and #1568: 1) Make database
changes in gallery_installer::install() instead of in installer/install.ql
2) Bump the version number in modules/gallery/module.info
---
installer/install.sql | 4 ++--
modules/gallery/helpers/gallery_installer.php | 4 ++--
modules/gallery/module.info | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/install.sql b/installer/install.sql
index 84a975ae..6aae8014 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -43,7 +43,7 @@ CREATE TABLE {caches} (
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
- KEY `key` (`key`),
+ UNIQUE KEY `key` (`key`),
KEY `tags` (`tags`)
) DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -152,7 +152,7 @@ CREATE TABLE {items} (
`album_cover_item_id` int(9) DEFAULT NULL,
`captured` int(9) DEFAULT NULL,
`created` int(9) DEFAULT NULL,
- `description` varchar(2048) DEFAULT NULL,
+ `description` text,
`height` int(9) DEFAULT NULL,
`left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 834a27fa..f7b8da5f 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -44,7 +44,7 @@ class gallery_installer {
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
- KEY (`key`),
+ UNIQUE KEY (`key`),
KEY (`tags`))
DEFAULT CHARSET=utf8;");
@@ -84,7 +84,7 @@ class gallery_installer {
`album_cover_item_id` int(9) default NULL,
`captured` int(9) default NULL,
`created` int(9) default NULL,
- `description` varchar(2048) default NULL,
+ `description` text default NULL,
`height` int(9) default NULL,
`left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 0cc3f6d1..eb579ab6 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 42
+version = 43
--
cgit v1.2.3
From 3ec0ba956dced01a97f2ee7bd943d326c42350e3 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Sat, 8 Jan 2011 19:39:23 +0100
Subject: Refactored graphics::detect_toolkits() so ImageMagick and
GraphicsMagick shares the same loop. Just as premarked as todo. Will make
https://sourceforge.net/apps/trac/gallery/ticket/1555#comment:3 an even
quicker task
---
modules/gallery/helpers/graphics.php | 76 ++++++++++++++----------------------
1 file changed, 29 insertions(+), 47 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index edba6b76..cb48ce82 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -318,55 +318,37 @@ class graphics_Core {
getenv("PATH"),
module::get_var("gallery", "extra_binary_paths")));
- // @todo: consider refactoring the two segments below into a loop since they are so
- // similar.
-
- // ImageMagick
- $path = exec("which convert");
- $toolkits->imagemagick->name = "ImageMagick";
- if ($path) {
- if (@is_file($path)) {
- preg_match('/Version: \S+ (\S+)/', `convert -v`, $matches);
- $version = $matches[1];
-
- $toolkits->imagemagick->installed = true;
- $toolkits->imagemagick->version = $version;
- $toolkits->imagemagick->binary = $path;
- $toolkits->imagemagick->dir = dirname($path);
- $toolkits->imagemagick->rotate = true;
- $toolkits->imagemagick->sharpen = true;
- } else {
- $toolkits->imagemagick->installed = false;
- $toolkits->imagemagick->error =
- t("ImageMagick is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
- }
- } else {
- $toolkits->imagemagick->installed = false;
- $toolkits->imagemagick->error = t("We could not locate ImageMagick on your system.");
- }
-
- // GraphicsMagick
- $path = exec("which gm");
- $toolkits->graphicsmagick->name = "GraphicsMagick";
- if ($path) {
- if (@is_file($path)) {
- preg_match('/\S+ (\S+)/', `gm version`, $matches);
- $version = $matches[1];
-
- $toolkits->graphicsmagick->installed = true;
- $toolkits->graphicsmagick->version = $version;
- $toolkits->graphicsmagick->binary = $path;
- $toolkits->graphicsmagick->dir = dirname($path);
- $toolkits->graphicsmagick->rotate = true;
- $toolkits->graphicsmagick->sharpen = true;
+ // ImageMagick & GraphicsMagick
+ $magick_kits = array(
+ "imagemagick" => array(
+ "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v"),
+ "graphicsmagick" => array(
+ "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version"));
+ // Loop through the kits
+ foreach ( $magick_kits as $index => $settings ) {
+ $path = exec("which " . $settings["binary"]);
+ $toolkits->$index->name = $settings["name"];
+ if ($path) {
+ if (@is_file($path)) {
+ preg_match('/Version: \S+ (\S+)/', shell_exec($settings["version"]), $matches);
+ $version = $matches[1];
+
+ $toolkits->$index->installed = true;
+ $toolkits->$index->version = $version;
+ $toolkits->$index->binary = $path;
+ $toolkits->$index->dir = dirname($path);
+ $toolkits->$index->rotate = true;
+ $toolkits->$index->sharpen = true;
+ } else {
+ $toolkits->$index->installed = false;
+ $toolkits->$index->error =
+ t($settings["name"] . " is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
+ }
} else {
- $toolkits->graphicsmagick->installed = false;
- $toolkits->graphicsmagick->error =
- t("GraphicsMagick is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
+ $toolkits->$index->installed = false;
+ $toolkits->$index->error =
+ t("We could not locate " . $settings["name"] . " on your system.");
}
- } else {
- $toolkits->graphicsmagick->installed = false;
- $toolkits->graphicsmagick->error = t("We could not locate GraphicsMagick on your system.");
}
}
--
cgit v1.2.3
From 7dd63630d8f7fc46847388c307ecf160a729aafb Mon Sep 17 00:00:00 2001
From: Joe7
Date: Sat, 8 Jan 2011 19:44:46 +0100
Subject: Minor coding style fix
---
modules/gallery/helpers/graphics.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index cb48ce82..96a6ceba 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -325,7 +325,7 @@ class graphics_Core {
"graphicsmagick" => array(
"name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version"));
// Loop through the kits
- foreach ( $magick_kits as $index => $settings ) {
+ foreach ($magick_kits as $index => $settings) {
$path = exec("which " . $settings["binary"]);
$toolkits->$index->name = $settings["name"];
if ($path) {
--
cgit v1.2.3
From e1e1e860cd1b19ebef491f0c0f82a3cd18e63721 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 8 Jan 2011 16:51:25 -0800
Subject: Use the code version when installing a module that has no installer,
instead of hardcoding version 1. Fixes #1589.
---
installer/install.sql | 2 +-
modules/gallery/helpers/module.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/install.sql b/installer/install.sql
index 09fabc7d..0ed7f2f3 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -247,7 +247,7 @@ CREATE TABLE {modules} (
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',1,4);
+INSERT INTO {modules} VALUES (4,1,'organize',3,4);
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);
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 7c5578af..6efe6162 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -168,7 +168,7 @@ class module_Core {
if (method_exists($installer_class, "install")) {
call_user_func_array(array($installer_class, "install"), array());
} else {
- module::set_version($module_name, 1);
+ module::set_version($module_name, module::available()->$module_name->code_version);
}
// Set the weight of the new module, which controls the order in which the modules are
--
cgit v1.2.3
From 92f66058d30a04681a01b886bdc652a70652cbfa Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 8 Jan 2011 16:58:52 -0800
Subject: Revert "Warn admins after login if their PHP install has the"
This reverts commit 612ddd7050889974fc1f7e449e715b4c1129c0bb.
---
modules/gallery/helpers/gallery_event.php | 4 ----
1 file changed, 4 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 689e21d1..13a0bdb4 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -178,10 +178,6 @@ class gallery_event_Core {
}
Session::instance()->set("active_auth_timestamp", time());
auth::clear_failed_attempts($user);
-
- if ($user->admin && ini_get("session.use_trans_sid")) {
- message::info(t("PHP is configured with session.use_trans_sid enabled which will cause random logouts. Please disable this setting.", array("url" => "http://www.php.net/manual/en/session.configuration.php#ini.session.use-trans-sid")));
- }
}
static function user_auth_failed($name) {
--
cgit v1.2.3
From eecb24429115b5f1883971befe0de18ac718fc2a Mon Sep 17 00:00:00 2001
From: Joe7
Date: Sun, 9 Jan 2011 02:06:35 +0100
Subject: Made t() calls parsable by localization scanner
---
modules/gallery/helpers/graphics.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 96a6ceba..a30699e8 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -342,12 +342,14 @@ class graphics_Core {
} else {
$toolkits->$index->installed = false;
$toolkits->$index->error =
- t($settings["name"] . " is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
+ t("%toolkit_name is installed, but PHP's open_basedir restriction prevents Gallery from using it.",
+ array("toolkit_name" => $settings["name"]));
}
} else {
$toolkits->$index->installed = false;
$toolkits->$index->error =
- t("We could not locate " . $settings["name"] . " on your system.");
+ t("We could not locate %toolkit_name on your system.",
+ array("toolkit_name" => $settings["name"]));
}
}
}
--
cgit v1.2.3
From 713bd4eb6a9bc91a244680828ce881ee8ea5f836 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 8 Jan 2011 18:10:43 -0800
Subject: Improve gallery::find_file() to do a better job of detecting the
modules/themes directories. Fixes #1590.
---
modules/gallery/helpers/gallery.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 69aabc4f..282289b5 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -153,8 +153,15 @@ class gallery_Core {
if (is_string($file_name)) {
// make relative to DOCROOT
$parts = explode("/", $file_name);
+ $count = count($parts);
foreach ($parts as $idx => $part) {
- if (in_array($part, array("application", "modules", "themes", "lib"))) {
+ // If this part is "modules" or "themes" make sure that the part 2 after this
+ // is the target directory, and if it is then we're done. This check makes
+ // sure that if Gallery is installed in a directory called "modules" or "themes"
+ // We don't parse the directory structure incorrectly.
+ if (in_array($part, array("modules", "themes")) &&
+ $idx + 2 < $count &&
+ $parts[$idx + 2] == $directory) {
break;
}
unset($parts[$idx]);
--
cgit v1.2.3
From 0d7e951aa5f7329edb25e821de95051668789bcd Mon Sep 17 00:00:00 2001
From: Jérémy Subtil
Date: Sat, 8 Jan 2011 22:57:09 +0100
Subject: Moved item_Model::get_position() method to the Item helper. It now
calls the viewable() method on every query.
---
modules/gallery/helpers/item.php | 85 ++++++++++++++++++++++++++++++++++++++++
modules/gallery/models/item.php | 79 ++-----------------------------------
2 files changed, 89 insertions(+), 75 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 29dd8603..a2d5f74d 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -304,4 +304,89 @@ class item_Core {
->where("rand_key", "<", random::percent())
->order_by("rand_key", "DESC");
}
+
+ /**
+ * Find the position of the given item in its parent album. The resulting
+ * value is 1-indexed, so the first child in the album is at position 1.
+ */
+ static function get_position($item, $where=array()) {
+ $album = $item->parent();
+
+ if (!strcasecmp($album->sort_order, "DESC")) {
+ $comp = ">";
+ } else {
+ $comp = "<";
+ }
+ $query_model = ORM::factory("item");
+
+ // If the comparison column has NULLs in it, we can't use comparators on it
+ // and will have to deal with it the hard way.
+ $count = $query_model->viewable()
+ ->where("parent_id", "=", $album->id)
+ ->where($album->sort_column, "IS", null)
+ ->merge_where($where)
+ ->count_all();
+
+ if (empty($count)) {
+ // There are no NULLs in the sort column, so we can just use it directly.
+ $sort_column = $album->sort_column;
+
+ $position = $query_model->viewable()
+ ->where("parent_id", "=", $album->id)
+ ->where($sort_column, $comp, $item->$sort_column)
+ ->merge_where($where)
+ ->count_all();
+
+ // We stopped short of our target value in the sort (notice that we're
+ // using a < comparator above) because it's possible that we have
+ // duplicate values in the sort column. An equality check would just
+ // arbitrarily pick one of those multiple possible equivalent columns,
+ // which would mean that if you choose a sort order that has duplicates,
+ // it'd pick any one of them as the child's "position".
+ //
+ // Fix this by doing a 2nd query where we iterate over the equivalent
+ // columns and add them to our base value.
+ foreach ($query_model->viewable()
+ ->select("id")
+ ->where("parent_id", "=", $album->id)
+ ->where($sort_column, "=", $item->$sort_column)
+ ->merge_where($where)
+ ->order_by(array("id" => "ASC"))
+ ->find_all() as $row) {
+ $position++;
+ if ($row->id == $item->id) {
+ break;
+ }
+ }
+ } else {
+ // There are NULLs in the sort column, so we can't use MySQL comparators.
+ // Fall back to iterating over every child row to get to the current one.
+ // This can be wildly inefficient for really large albums, but it should
+ // be a rare case that the user is sorting an album with null values in
+ // the sort column.
+ //
+ // Reproduce the children() functionality here using Database directly to
+ // avoid loading the whole ORM for each row.
+ $order_by = array($album->sort_column => $album->sort_order);
+ // Use id as a tie breaker
+ if ($album->sort_column != "id") {
+ $order_by["id"] = "ASC";
+ }
+
+ $position = 0;
+ foreach ($query_model->viewable()
+ ->select("id")
+ ->where("parent_id", "=", $album->id)
+ ->merge_where($where)
+ ->order_by($order_by)
+ ->find_all() as $row) {
+ $position++;
+ if ($row->id == $item->id) {
+ break;
+ }
+ }
+ }
+
+ return $position;
+ }
}
\ No newline at end of file
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 88a444b4..47b062b8 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -546,83 +546,12 @@ class Item_Model_Core extends ORM_MPTT {
/**
* Find the position of the given child id in this album. The resulting value is 1-indexed, so
* the first child in the album is at position 1.
+ *
+ * This method stands as a backward compatibility for gallery 3.0, and will
+ * be deprecated in version 3.1.
*/
public function get_position($child, $where=array()) {
- if (!strcasecmp($this->sort_order, "DESC")) {
- $comp = ">";
- } else {
- $comp = "<";
- }
- $db = db::build();
-
- // If the comparison column has NULLs in it, we can't use comparators on it and will have to
- // deal with it the hard way.
- $count = $db->from("items")
- ->where("parent_id", "=", $this->id)
- ->where($this->sort_column, "IS", null)
- ->merge_where($where)
- ->count_records();
-
- if (empty($count)) {
- // There are no NULLs in the sort column, so we can just use it directly.
- $sort_column = $this->sort_column;
-
- $position = $db->from("items")
- ->where("parent_id", "=", $this->id)
- ->where($sort_column, $comp, $child->$sort_column)
- ->merge_where($where)
- ->count_records();
-
- // We stopped short of our target value in the sort (notice that we're using a < comparator
- // above) because it's possible that we have duplicate values in the sort column. An
- // equality check would just arbitrarily pick one of those multiple possible equivalent
- // columns, which would mean that if you choose a sort order that has duplicates, it'd pick
- // any one of them as the child's "position".
- //
- // Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to
- // our base value.
- foreach ($db
- ->select("id")
- ->from("items")
- ->where("parent_id", "=", $this->id)
- ->where($sort_column, "=", $child->$sort_column)
- ->merge_where($where)
- ->order_by(array("id" => "ASC"))
- ->execute() as $row) {
- $position++;
- if ($row->id == $child->id) {
- break;
- }
- }
- } else {
- // There are NULLs in the sort column, so we can't use MySQL comparators. Fall back to
- // iterating over every child row to get to the current one. This can be wildly inefficient
- // for really large albums, but it should be a rare case that the user is sorting an album
- // with null values in the sort column.
- //
- // Reproduce the children() functionality here using Database directly to avoid loading the
- // whole ORM for each row.
- $order_by = array($this->sort_column => $this->sort_order);
- // Use id as a tie breaker
- if ($this->sort_column != "id") {
- $order_by["id"] = "ASC";
- }
-
- $position = 0;
- foreach ($db->select("id")
- ->from("items")
- ->where("parent_id", "=", $this->id)
- ->merge_where($where)
- ->order_by($order_by)
- ->execute() as $row) {
- $position++;
- if ($row->id == $child->id) {
- break;
- }
- }
- }
-
- return $position;
+ return item::get_position($child, $where);
}
/**
--
cgit v1.2.3
From bd6bd029a7c2e0247d4da931c49f3731498cd303 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 10 Jan 2011 14:04:15 -0800
Subject: Fix up the version detecting regex for GraphicsMagick and don't crash
if the regex doesn't return properly. Follow on to
3ec0ba956dced01a97f2ee7bd943d326c42350e3 for ticket #1595.
---
modules/gallery/helpers/graphics.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index a30699e8..29527705 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -321,16 +321,18 @@ class graphics_Core {
// ImageMagick & GraphicsMagick
$magick_kits = array(
"imagemagick" => array(
- "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v"),
+ "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v",
+ "version_regex" => "/Version: \S+ (\S+)/"),
"graphicsmagick" => array(
- "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version"));
+ "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version",
+ "version_regex" => "/\S+ (\S+)/"));
// Loop through the kits
foreach ($magick_kits as $index => $settings) {
$path = exec("which " . $settings["binary"]);
$toolkits->$index->name = $settings["name"];
if ($path) {
- if (@is_file($path)) {
- preg_match('/Version: \S+ (\S+)/', shell_exec($settings["version"]), $matches);
+ if (@is_file($path) &&
+ preg_match($settings["version_regex"], shell_exec($settings["version"]), $matches)) {
$version = $matches[1];
$toolkits->$index->installed = true;
--
cgit v1.2.3
From 23eaec7063b81d4dae04ec3f5c311a0a2f228a05 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 10 Jan 2011 15:49:15 -0800
Subject: Stop using "which" to find binaries. Create system::find_binary()
which traverses the $PATH and returns any executable binary of the
appropriate name that it can find. Fixes #1555.
---
modules/gallery/helpers/graphics.php | 8 ++-----
modules/gallery/helpers/movie.php | 14 +++++-------
modules/gallery/helpers/system.php | 43 ++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 15 deletions(-)
create mode 100644 modules/gallery/helpers/system.php
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 29527705..18820ed7 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -313,11 +313,6 @@ class graphics_Core {
$toolkits->graphicsmagick->installed = false;
$toolkits->graphicsmagick->error = t("GraphicsMagick requires the exec function");
} else {
- gallery::set_path_env(
- array(module::get_var("gallery", "graphics_toolkit_path"),
- getenv("PATH"),
- module::get_var("gallery", "extra_binary_paths")));
-
// ImageMagick & GraphicsMagick
$magick_kits = array(
"imagemagick" => array(
@@ -328,7 +323,8 @@ class graphics_Core {
"version_regex" => "/\S+ (\S+)/"));
// Loop through the kits
foreach ($magick_kits as $index => $settings) {
- $path = exec("which " . $settings["binary"]);
+ $path = system::find_binary(
+ $settings["binary"], module::get_var("gallery", "graphics_toolkit_path"));
$toolkits->$index->name = $settings["name"];
if ($path) {
if (@is_file($path) &&
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 0895c5f4..dd0b437e 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -83,22 +83,18 @@ class movie_Core {
}
}
+ /**
+ * Return the path to the ffmpeg binary if one exists and is executable, or null.
+ */
static function find_ffmpeg() {
if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
- gallery::set_path_env(
- array(module::get_var("gallery", "graphics_toolkit_path"),
- getenv("PATH"),
- module::get_var("gallery", "extra_binary_paths")));
- if (function_exists("exec")) {
- $ffmpeg_path = exec("which ffmpeg");
- }
-
+ $ffmpeg_path = system::find_binary(
+ "ffmpeg", module::get_var("gallery", "graphics_toolkit_path"));
module::set_var("gallery", "ffmpeg_path", $ffmpeg_path);
}
return $ffmpeg_path;
}
-
/**
* Return the width, height, mime_type and extension of the given movie file.
*/
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
new file mode 100644
index 00000000..4a6a3c0f
--- /dev/null
+++ b/modules/gallery/helpers/system.php
@@ -0,0 +1,43 @@
+
Date: Tue, 11 Jan 2011 01:04:10 -0800
Subject: Don't resize if the target size is the same as the original. Fixes
#1602.
---
modules/gallery/helpers/gallery_graphics.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php
index fca18076..4cd7143e 100644
--- a/modules/gallery/helpers/gallery_graphics.php
+++ b/modules/gallery/helpers/gallery_graphics.php
@@ -56,7 +56,7 @@ class gallery_graphics_Core {
}
$dims = getimagesize($input_file);
- if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) {
+ if (max($dims[0], $dims[1]) <= min($options["width"], $options["height"])) {
// Image would get upscaled; do nothing
copy($input_file, $output_file);
} else {
--
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/helpers')
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 92db7f42181f6582763e7b5c56b18b989b061e21 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 11 Jan 2011 15:23:20 -0800
Subject: Update some comments.
---
modules/gallery/helpers/item.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index a2d5f74d..8aa14934 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -308,6 +308,9 @@ class item_Core {
/**
* Find the position of the given item in its parent album. The resulting
* value is 1-indexed, so the first child in the album is at position 1.
+ *
+ * @param Item_Model $item
+ * @param array $where an array of arrays, each compatible with ORM::where()
*/
static function get_position($item, $where=array()) {
$album = $item->parent();
@@ -338,14 +341,14 @@ class item_Core {
->count_all();
// We stopped short of our target value in the sort (notice that we're
- // using a < comparator above) because it's possible that we have
+ // using a inequality comparator above) because it's possible that we have
// duplicate values in the sort column. An equality check would just
// arbitrarily pick one of those multiple possible equivalent columns,
// which would mean that if you choose a sort order that has duplicates,
// it'd pick any one of them as the child's "position".
//
// Fix this by doing a 2nd query where we iterate over the equivalent
- // columns and add them to our base value.
+ // columns and add them to our position count.
foreach ($query_model->viewable()
->select("id")
->where("parent_id", "=", $album->id)
--
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/helpers')
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 ee13b934f46d67982e5eeea21f81ac58f166741c Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 15 Jan 2011 13:14:43 -0800
Subject: Fix all the head() and admin_head() theme callbacks to return the
results of the $theme->css() and $theme->script() calls. This handles the
case where combining scripts/css returns HTML instead of putting it in the
queue for combination. Fixes #1611.
---
modules/comment/helpers/comment_theme.php | 8 +++-----
modules/digibug/helpers/digibug_theme.php | 2 +-
modules/gallery/helpers/gallery_theme.php | 27 +++++++++++++------------
modules/recaptcha/helpers/recaptcha_theme.php | 4 ++--
modules/server_add/helpers/server_add_theme.php | 18 ++++++++---------
modules/tag/helpers/tag_theme.php | 10 ++++-----
modules/user/helpers/user_theme.php | 8 ++++----
7 files changed, 38 insertions(+), 39 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/comment/helpers/comment_theme.php b/modules/comment/helpers/comment_theme.php
index b993cdae..9cc93fa1 100644
--- a/modules/comment/helpers/comment_theme.php
+++ b/modules/comment/helpers/comment_theme.php
@@ -19,14 +19,12 @@
*/
class comment_theme_Core {
static function head($theme) {
- $theme->css("comment.css");
- $theme->script("comment.js");
- return "";
+ return $theme->css("comment.css")
+ . $theme->script("comment.js");
}
static function admin_head($theme) {
- $theme->css("comment.css");
- return "";
+ return $theme->css("comment.css");
}
static function photo_bottom($theme) {
diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php
index d146e17d..1106910e 100644
--- a/modules/digibug/helpers/digibug_theme.php
+++ b/modules/digibug/helpers/digibug_theme.php
@@ -19,6 +19,6 @@
*/
class digibug_theme_Core {
static function head($theme) {
- $theme->script("digibug.js");
+ return $theme->script("digibug.js");
}
}
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 978c69a6..ebf8f38e 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -21,9 +21,9 @@ class gallery_theme_Core {
static function head($theme) {
$session = Session::instance();
$buf = "";
- $theme->css("gallery.css");
+ $buf .= $theme->css("gallery.css");
if ($session->get("debug")) {
- $theme->css("debug.css");
+ $buf .= $theme->css("debug.css");
}
if (module::is_active("rss")) {
@@ -40,32 +40,33 @@ class gallery_theme_Core {
if (count(locales::installed())) {
// Needed by the languages block
- $theme->script("jquery.cookie.js");
+ $buf .= $theme->script("jquery.cookie.js");
}
if ($session->get("l10n_mode", false)) {
- $theme->css("l10n_client.css");
- $theme->script("jquery.cookie.js");
- $theme->script("l10n_client.js");
+ $buf .= $theme->css("l10n_client.css")
+ . $theme->script("jquery.cookie.js")
+ . $theme->script("l10n_client.js");
}
- $theme->css("uploadify/uploadify.css");
+ $buf .= $theme->css("uploadify/uploadify.css");
return $buf;
}
static function admin_head($theme) {
- $theme->css("gallery.css");
- $theme->script("gallery.panel.js");
+ $buf = $theme->css("gallery.css");
+ $buf .= $theme->script("gallery.panel.js");
$session = Session::instance();
if ($session->get("debug")) {
- $theme->css("debug.css");
+ $buf .= $theme->css("debug.css");
}
if ($session->get("l10n_mode", false)) {
- $theme->css("l10n_client.css");
- $theme->script("jquery.cookie.js");
- $theme->script("l10n_client.js");
+ $buf .= $theme->css("l10n_client.css");
+ $buf .= $theme->script("jquery.cookie.js");
+ $buf .=$theme->script("l10n_client.js");
}
+ return $buf;
}
static function page_bottom($theme) {
diff --git a/modules/recaptcha/helpers/recaptcha_theme.php b/modules/recaptcha/helpers/recaptcha_theme.php
index ee880986..3677a7c7 100644
--- a/modules/recaptcha/helpers/recaptcha_theme.php
+++ b/modules/recaptcha/helpers/recaptcha_theme.php
@@ -19,10 +19,10 @@
*/
class recaptcha_theme_Core {
static function head($theme) {
- $theme->css("recaptcha.css");
+ return $theme->css("recaptcha.css");
}
static function admin_head($theme) {
- $theme->css("recaptcha.css");
+ return $theme->css("recaptcha.css");
}
}
\ No newline at end of file
diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php
index 53f78772..6395c2f0 100644
--- a/modules/server_add/helpers/server_add_theme.php
+++ b/modules/server_add/helpers/server_add_theme.php
@@ -20,24 +20,24 @@
class server_add_theme_Core {
static function head($theme) {
if (identity::active_user()->admin) {
- $theme->css("server_add.css");
- $theme->script("server_add.js");
+ return $theme->css("server_add.css")
+ . $theme->script("server_add.js");
}
}
static function admin_head($theme) {
- $head = array();
+ $buf = "";
if (strpos(Router::$current_uri, "admin/server_add") !== false) {
- $theme->css("server_add.css");
- $theme->css("jquery.autocomplete.css");
+ $buf .= $theme->css("server_add.css")
+ . $theme->css("jquery.autocomplete.css");
$base = url::site("__ARGS__");
$csrf = access::csrf_token();
- $head[] = "";
+ $buf .= "";
- $theme->script("jquery.autocomplete.js");
- $theme->script("admin.js");
+ $buf .= $theme->script("jquery.autocomplete.js")
+ . $theme->script("admin.js");
}
- return implode("\n", $head);
+ return $buf;
}
}
\ No newline at end of file
diff --git a/modules/tag/helpers/tag_theme.php b/modules/tag/helpers/tag_theme.php
index f731dbb7..3325a832 100644
--- a/modules/tag/helpers/tag_theme.php
+++ b/modules/tag/helpers/tag_theme.php
@@ -19,13 +19,13 @@
*/
class tag_theme_Core {
static function head($theme) {
- $theme->css("jquery.autocomplete.css");
- $theme->script("jquery.autocomplete.js");
- $theme->css("tag.css");
+ return $theme->css("jquery.autocomplete.css")
+ . $theme->script("jquery.autocomplete.js")
+ . $theme->css("tag.css");
}
static function admin_head($theme) {
- $theme->css("tag.css");
- $theme->script("gallery.in_place_edit.js");
+ return $theme->css("tag.css")
+ . $theme->script("gallery.in_place_edit.js");
}
}
\ No newline at end of file
diff --git a/modules/user/helpers/user_theme.php b/modules/user/helpers/user_theme.php
index 5a7161ed..70e96f70 100644
--- a/modules/user/helpers/user_theme.php
+++ b/modules/user/helpers/user_theme.php
@@ -19,12 +19,12 @@
*/
class user_theme_Core {
static function head($theme) {
- $theme->css("user.css");
- $theme->script("password_strength.js");
+ return $theme->css("user.css")
+ . $theme->script("password_strength.js");
}
static function admin_head($theme) {
- $theme->css("user.css");
- $theme->script("password_strength.js");
+ return $theme->css("user.css")
+ . $theme->script("password_strength.js");
}
}
\ No newline at end of file
--
cgit v1.2.3
From 0020f87d6a23ce00200074b678a9293d055e27a3 Mon Sep 17 00:00:00 2001
From: Joe7
Date: Sat, 15 Jan 2011 21:49:22 +0100
Subject: Fixed paging for albums ordered by random. MySql has problems when
comparing float values against -seemingly same- float input, see
http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html for details.
Fixes #1610
---
installer/install.sql | 4 ++--
modules/gallery/helpers/gallery_installer.php | 9 +++++++--
modules/gallery/module.info | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/installer/install.sql b/installer/install.sql
index 0ed7f2f3..07aae36d 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -160,7 +160,7 @@ CREATE TABLE {items} (
`name` varchar(255) DEFAULT NULL,
`owner_id` int(9) DEFAULT NULL,
`parent_id` int(9) NOT NULL,
- `rand_key` float DEFAULT NULL,
+ `rand_key` decimal(11,10) DEFAULT NULL,
`relative_path_cache` varchar(255) DEFAULT NULL,
`relative_url_cache` varchar(255) DEFAULT NULL,
`resize_dirty` tinyint(1) DEFAULT '1',
@@ -244,7 +244,7 @@ CREATE TABLE {modules} (
KEY `weight` (`weight`)
) 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 (1,1,'gallery',44,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',3,4);
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index f7b8da5f..3c7b1c84 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -92,7 +92,7 @@ class gallery_installer {
`name` varchar(255) default NULL,
`owner_id` int(9) default NULL,
`parent_id` int(9) NOT NULL,
- `rand_key` float default NULL,
+ `rand_key` decimal(11,10) default NULL,
`relative_path_cache` varchar(255) default NULL,
`relative_url_cache` varchar(255) default NULL,
`resize_dirty` boolean default 1,
@@ -309,7 +309,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", 43);
+ module::set_version("gallery", 44);
}
static function upgrade($version) {
@@ -653,6 +653,11 @@ class gallery_installer {
$db->query("ALTER TABLE {items} CHANGE `description` `description` text DEFAULT NULL");
module::set_version("gallery", $version = 43);
}
+
+ if ($version == 43) {
+ $db->query("ALTER TABLE {items} CHANGE `rand_key` `rand_key` DECIMAL(11, 10)");
+ module::set_version("gallery", $version = 44);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index eb579ab6..4c4e63a1 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 43
+version = 44
--
cgit v1.2.3
From ac44e9c930ec83545b37e1e31381919fbd849d26 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 15:49:34 -0800
Subject: First step in setting up version checking.
We now have two types of packages (release, git). Instead of using
constants, we now have gallery::version_string() which returns the
current version string. If you're on a release package, then the
version string looks like:
3.0 (Santa Fe)
If you're on a git package, then the version string looks like this:
3.0.1 (branch 3.0.x build 3)
We track the build number in a new file in the gallery3 root called
BUILD_NUMBER which we will update periodically with the latest
build number for each branch.
---
BUILD_NUMBER | 1 +
modules/gallery/helpers/gallery.php | 25 +++++++++++++++++++++++-
modules/gallery/helpers/gallery_theme.php | 2 +-
modules/gallery/views/admin_block_stats.html.php | 2 +-
4 files changed, 27 insertions(+), 3 deletions(-)
create mode 100644 BUILD_NUMBER
(limited to 'modules/gallery/helpers')
diff --git a/BUILD_NUMBER b/BUILD_NUMBER
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/BUILD_NUMBER
@@ -0,0 +1 @@
+1
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 282289b5..c4a6286c 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -18,7 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_Core {
- const VERSION = "3.0+ (git)";
+ const VERSION = "3.0+";
+ const CODE_NAME = "";
+ const RELEASE_CHANNEL = "git";
+ const RELEASE_BRANCH = "master";
/**
* If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is
@@ -184,4 +187,24 @@ class gallery_Core {
}
putenv("PATH=" . implode(":", $path_env));
}
+
+ /**
+ * Return a string describing this version of Gallery and the type of release.
+ */
+ static function version_string() {
+ if (gallery::RELEASE_CHANNEL == "git") {
+ return sprintf(
+ "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH, gallery::build_number());
+ } else {
+ return sprintf("%s (%s)", gallery::VERSION, gallery::CODE_NAME);
+ }
+ }
+
+ /**
+ * Return the contents of the BUILD_NUMBER file, which should be a single integer.
+ */
+ static function build_number() {
+ $lines = file(DOCROOT . "BUILD_NUMBER", FILE_IGNORE_NEW_LINES);
+ return $lines[0];
+ }
}
\ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index ebf8f38e..d75c6fc6 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -115,7 +115,7 @@ class gallery_theme_Core {
static function credits() {
$version_string = SafeString::of_safe_html(
- 'Gallery ' . gallery::VERSION . '');
+ 'Gallery ' . gallery::version_string() . '');
return "" .
t(module::get_var("gallery", "credits"),
array("url" => "http://gallery.menalto.com",
diff --git a/modules/gallery/views/admin_block_stats.html.php b/modules/gallery/views/admin_block_stats.html.php
index 1dec8ccd..c8c54765 100644
--- a/modules/gallery/views/admin_block_stats.html.php
+++ b/modules/gallery/views/admin_block_stats.html.php
@@ -1,7 +1,7 @@
-
- = t("Version: %version", array("version" => gallery::VERSION)) ?>
+ = t("Version: %version", array("version" => gallery::version_string())) ?>
-
= t("Albums: %count", array("count" => $album_count)) ?>
--
cgit v1.2.3
From b78b1090184dd863c984e54652935963cc502eb8 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 17:10:30 -0800
Subject: Fix indentation.
---
modules/gallery/helpers/gallery.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index c4a6286c..31b342db 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -194,7 +194,8 @@ class gallery_Core {
static function version_string() {
if (gallery::RELEASE_CHANNEL == "git") {
return sprintf(
- "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH, gallery::build_number());
+ "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH,
+ gallery::build_number());
} else {
return sprintf("%s (%s)", gallery::VERSION, gallery::CODE_NAME);
}
--
cgit v1.2.3
From 84d576606d709dcccef2549fdb926d47494a876c Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 21:46:03 -0800
Subject: Change the value column of the messages table from a varchar(255) to
a text. Fixes #1612.
---
modules/gallery/helpers/gallery_installer.php | 9 +++++++--
modules/gallery/module.info | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 3c7b1c84..92e5b7b8 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -136,7 +136,7 @@ class gallery_installer {
`id` int(9) NOT NULL auto_increment,
`key` varchar(255) default NULL,
`severity` varchar(32) default NULL,
- `value` varchar(255) default NULL,
+ `value` text default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`key`))
DEFAULT CHARSET=utf8;");
@@ -309,7 +309,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", 44);
+ module::set_version("gallery", 45);
}
static function upgrade($version) {
@@ -658,6 +658,11 @@ class gallery_installer {
$db->query("ALTER TABLE {items} CHANGE `rand_key` `rand_key` DECIMAL(11, 10)");
module::set_version("gallery", $version = 44);
}
+
+ if ($version == 44) {
+ $db->query("ALTER TABLE {messages} CHANGE `value` `value` text default NULL");
+ module::set_version("gallery", $version = 45);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 4c4e63a1..b79df7be 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 44
+version = 45
--
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/helpers')
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 167f635a6ce5a71b35450844f9b5c647aa14bcc1 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 23:06:19 -0800
Subject: Add arguments to random::int() to match mt_rand(). Follow on to
cd48b89f3166e7fa732b5cb06d33fba018af9127 for #1527.
---
modules/gallery/helpers/random.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/random.php b/modules/gallery/helpers/random.php
index a26762bd..dfc7558c 100644
--- a/modules/gallery/helpers/random.php
+++ b/modules/gallery/helpers/random.php
@@ -42,9 +42,13 @@ class random_Core {
}
/**
- * Return a random number between 0 and mt_getrandmax()
+ * Return a random number between $min and $max. If $min and $max are not specified,
+ * return a random number between 0 and mt_getrandmax()
*/
- static function int() {
+ static function int($min=null, $max=null) {
+ if ($min || $max) {
+ return mt_rand($min, $max);
+ }
return mt_rand();
}
}
\ No newline at end of file
--
cgit v1.2.3
From 66bb496b6c2ad9c5341644b2e303e694078374d1 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 16 Jan 2011 23:14:57 -0800
Subject: If the logged in user is an admin and it's been more than 7 days
since the last check and auto upgrade checking is enabled, fire off an XHR to
check for a possible upgrade. Finishes off #1605.
---
modules/gallery/helpers/gallery_installer.php | 3 +++
modules/gallery/helpers/gallery_theme.php | 20 ++++++++++++++++++--
modules/gallery/helpers/upgrade_checker.php | 25 +++++++++++++++++++++++++
3 files changed, 46 insertions(+), 2 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 1ffe9bae..41ed1c6e 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -677,6 +677,9 @@ 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() {
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index d75c6fc6..a6ca5eb7 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -76,13 +76,22 @@ class gallery_theme_Core {
$profiler = new Profiler();
$profiler->render();
}
+ $content = "";
if ($session->get("l10n_mode", false)) {
- return L10n_Client_Controller::l10n_form();
+ $content .= L10n_Client_Controller::l10n_form();
}
if ($session->get_once("after_install")) {
- return new View("welcome_message_loader.html");
+ $content .= new View("welcome_message_loader.html");
}
+
+ if (identity::active_user()->admin && upgrade_checker::should_auto_check()) {
+ $content .= '';
+ }
+ return $content;
}
static function admin_page_bottom($theme) {
@@ -107,6 +116,13 @@ class gallery_theme_Core {
setInterval("adminReauthCheck();", 60 * 1000);
';
+ if (upgrade_checker::should_auto_check()) {
+ $content .= '';
+ }
+
if ($session->get("l10n_mode", false)) {
$content .= "\n" . L10n_Client_Controller::l10n_form();
}
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
index 9311cf4a..ef1308d7 100644
--- a/modules/gallery/helpers/upgrade_checker.php
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -19,15 +19,37 @@
*/
class upgrade_checker_Core {
const CHECK_URL = "http://gallery.menalto.com/versioncheck/gallery3";
+ const AUTO_CHECK_INTERVAL = 604800; // 7 days in seconds
+ /**
+ * Return the last version info blob retrieved from the Gallery website or
+ * null if no checks have been performed.
+ */
static function version_info() {
return unserialize(Cache::instance()->get("upgrade_checker_version_info"));
}
+ /**
+ * Return true if auto checking is enabled.
+ */
static function auto_check_enabled() {
return (bool)module::get_var("gallery", "upgrade_checker_auto_enabled");
}
+ /**
+ * Return true if it's time to auto check.
+ */
+ static function should_auto_check() {
+ if (upgrade_checker::auto_check_enabled() && random::int(1, 100) == 1) {
+ $version_info = upgrade_checker::version_info();
+ return (!$version_info || (time() - $version_info->timestamp) > AUTO_CHECK_INTERVAL);
+ }
+ return false;
+ }
+
+ /**
+ * Fech version info from the Gallery website.
+ */
static function fetch_version_info() {
$result = new stdClass();
try {
@@ -52,6 +74,9 @@ class upgrade_checker_Core {
Cache::instance()->set("upgrade_checker_version_info", serialize($result), null, 86400 * 365);
}
+ /**
+ * Check the latest version info blob to see if it's time for an upgrade.
+ */
static function check_for_upgrade() {
$version_info = upgrade_checker::version_info();
$upgrade_available = false;
--
cgit v1.2.3
From 14ae5d854400d632b63a331f541f180b8d1f3ea1 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 17:07:32 -0800
Subject: Update version checking code to expect "branch_" as the prefix for
all branch related lines. For #1605.
---
modules/gallery/helpers/upgrade_checker.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
index ef1308d7..0e72bb94 100644
--- a/modules/gallery/helpers/upgrade_checker.php
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -93,14 +93,14 @@ class upgrade_checker_Core {
}
} else {
$branch = gallery::RELEASE_BRANCH;
- if (isset($version_info->data["{$branch}_build_number"]) &&
- version_compare($version_info->data["{$branch}_build_number"],
+ 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}_version"],
- "upgrade-url" => $version_info->data["{$branch}_upgrade_url"],
- "build" => $version_info->data["{$branch}_build_number"],
+ 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");
--
cgit v1.2.3
From 29be21bb0deaf70558b1aa02a115e67daefea0bd Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 17:27:16 -0800
Subject: Add BUILD_NUMBER to the security check in .htaccess Change
BUILD_NUMBER to be .ini format and add a big "do not edit" comment.
---
.htaccess | 2 +-
BUILD_NUMBER | 7 ++++++-
modules/gallery/helpers/gallery.php | 4 ++--
3 files changed, 9 insertions(+), 4 deletions(-)
(limited to 'modules/gallery/helpers')
diff --git a/.htaccess b/.htaccess
index 5a329520..771a8df0 100644
--- a/.htaccess
+++ b/.htaccess
@@ -29,7 +29,7 @@
# in your Apache2 config file before you uncomment this block or
# you'll get an "Internal Server Error".
#
-#
+#
# Order deny,allow
# Deny from all
#
diff --git a/BUILD_NUMBER b/BUILD_NUMBER
index 0691f67b..d32d51e9 100644
--- a/BUILD_NUMBER
+++ b/BUILD_NUMBER
@@ -1 +1,6 @@
-52
+; This file keeps track of the build number for the "master"
+; branch of gallery3. It's kept up to date by an automated
+; process. You don't need to edit it. In fact..
+;
+; DO NOT EDIT THIS FILE BY HAND!
+build_number=52
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 31b342db..7a60f56a 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -205,7 +205,7 @@ class gallery_Core {
* Return the contents of the BUILD_NUMBER file, which should be a single integer.
*/
static function build_number() {
- $lines = file(DOCROOT . "BUILD_NUMBER", FILE_IGNORE_NEW_LINES);
- return $lines[0];
+ $result = parse_ini_file(DOCROOT . "BUILD_NUMBER");
+ return $result["build_number"];
}
}
\ No newline at end of file
--
cgit v1.2.3
From 76411d7d6d481bc2ab51e24ec2dbf003f43ce40b Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 17 Jan 2011 17:33:10 -0800
Subject: Rename BUILD_NUMBER to .build_number so it's not so loud.
---
.build_number | 6 ++++++
.gitattributes | 2 +-
BUILD_NUMBER | 6 ------
modules/gallery/helpers/gallery.php | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
create mode 100644 .build_number
delete mode 100644 BUILD_NUMBER
(limited to 'modules/gallery/helpers')
diff --git a/.build_number b/.build_number
new file mode 100644
index 00000000..d32d51e9
--- /dev/null
+++ b/.build_number
@@ -0,0 +1,6 @@
+; This file keeps track of the build number for the "master"
+; branch of gallery3. It's kept up to date by an automated
+; process. You don't need to edit it. In fact..
+;
+; DO NOT EDIT THIS FILE BY HAND!
+build_number=52
diff --git a/.gitattributes b/.gitattributes
index 9122eeb1..fdf9d072 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,2 @@
-BUILD_NUMBER merge=merge-keep-ours
+.build_number merge=merge-keep-ours
diff --git a/BUILD_NUMBER b/BUILD_NUMBER
deleted file mode 100644
index d32d51e9..00000000
--- a/BUILD_NUMBER
+++ /dev/null
@@ -1,6 +0,0 @@
-; This file keeps track of the build number for the "master"
-; branch of gallery3. It's kept up to date by an automated
-; process. You don't need to edit it. In fact..
-;
-; DO NOT EDIT THIS FILE BY HAND!
-build_number=52
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 7a60f56a..ad9f40e8 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -202,10 +202,10 @@ class gallery_Core {
}
/**
- * Return the contents of the BUILD_NUMBER file, which should be a single integer.
+ * Return the contents of the .build_number file, which should be a single integer.
*/
static function build_number() {
- $result = parse_ini_file(DOCROOT . "BUILD_NUMBER");
+ $result = parse_ini_file(DOCROOT . ".build_number");
return $result["build_number"];
}
}
\ No newline at end of file
--
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/helpers')
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/helpers')
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 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/helpers')
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 @@