summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/MY_html.php2
-rw-r--r--modules/gallery/helpers/MY_num.php2
-rw-r--r--modules/gallery/helpers/MY_remote.php2
-rw-r--r--modules/gallery/helpers/MY_url.php2
-rw-r--r--modules/gallery/helpers/access.php2
-rw-r--r--modules/gallery/helpers/album.php2
-rw-r--r--modules/gallery/helpers/auth.php2
-rw-r--r--modules/gallery/helpers/batch.php2
-rw-r--r--modules/gallery/helpers/block_manager.php2
-rw-r--r--modules/gallery/helpers/data_rest.php2
-rw-r--r--modules/gallery/helpers/dir.php2
-rw-r--r--modules/gallery/helpers/gallery.php28
-rw-r--r--modules/gallery/helpers/gallery_block.php15
-rw-r--r--modules/gallery/helpers/gallery_error.php2
-rw-r--r--modules/gallery/helpers/gallery_event.php2
-rw-r--r--modules/gallery/helpers/gallery_graphics.php2
-rw-r--r--modules/gallery/helpers/gallery_installer.php32
-rw-r--r--modules/gallery/helpers/gallery_rss.php2
-rw-r--r--modules/gallery/helpers/gallery_task.php2
-rw-r--r--modules/gallery/helpers/gallery_theme.php51
-rw-r--r--modules/gallery/helpers/graphics.php2
-rw-r--r--modules/gallery/helpers/identity.php2
-rw-r--r--modules/gallery/helpers/item.php2
-rw-r--r--modules/gallery/helpers/item_rest.php2
-rw-r--r--modules/gallery/helpers/items_rest.php2
-rw-r--r--modules/gallery/helpers/json.php2
-rw-r--r--modules/gallery/helpers/l10n_client.php2
-rw-r--r--modules/gallery/helpers/l10n_scanner.php2
-rw-r--r--modules/gallery/helpers/locales.php2
-rw-r--r--modules/gallery/helpers/log.php2
-rw-r--r--modules/gallery/helpers/message.php2
-rw-r--r--modules/gallery/helpers/model_cache.php2
-rw-r--r--modules/gallery/helpers/module.php2
-rw-r--r--modules/gallery/helpers/movie.php2
-rw-r--r--modules/gallery/helpers/photo.php2
-rw-r--r--modules/gallery/helpers/random.php10
-rw-r--r--modules/gallery/helpers/site_status.php2
-rw-r--r--modules/gallery/helpers/system.php2
-rw-r--r--modules/gallery/helpers/task.php2
-rw-r--r--modules/gallery/helpers/theme.php2
-rw-r--r--modules/gallery/helpers/tree_rest.php2
-rw-r--r--modules/gallery/helpers/upgrade_checker.php103
-rw-r--r--modules/gallery/helpers/user_profile.php2
-rw-r--r--modules/gallery/helpers/xml.php2
44 files changed, 249 insertions, 66 deletions
diff --git a/modules/gallery/helpers/MY_html.php b/modules/gallery/helpers/MY_html.php
index d15bd816..f5d36ad4 100644
--- a/modules/gallery/helpers/MY_html.php
+++ b/modules/gallery/helpers/MY_html.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php
index e784b1ac..9787044c 100644
--- a/modules/gallery/helpers/MY_num.php
+++ b/modules/gallery/helpers/MY_num.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/MY_remote.php b/modules/gallery/helpers/MY_remote.php
index a1d2a3d1..67de36ff 100644
--- a/modules/gallery/helpers/MY_remote.php
+++ b/modules/gallery/helpers/MY_remote.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index 8ac26602..47898687 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 4148049a..545e544f 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 89185e50..d8e918e0 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index fa6242b9..3b2318c3 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/batch.php b/modules/gallery/helpers/batch.php
index 72d24400..461d5b2c 100644
--- a/modules/gallery/helpers/batch.php
+++ b/modules/gallery/helpers/batch.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php
index 4bd649c2..c385a987 100644
--- a/modules/gallery/helpers/block_manager.php
+++ b/modules/gallery/helpers/block_manager.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php
index 791de9c0..552df34e 100644
--- a/modules/gallery/helpers/data_rest.php
+++ b/modules/gallery/helpers/data_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/dir.php b/modules/gallery/helpers/dir.php
index f66f443e..e1d11a14 100644
--- a/modules/gallery/helpers/dir.php
+++ b/modules/gallery/helpers/dir.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 282289b5..1fafdef7 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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,25 @@ 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() {
+ $result = parse_ini_file(DOCROOT . ".build_number");
+ return $result["build_number"];
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index 1d92d66d..b9ccf25b 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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,15 @@ 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();
+ $block->content->new_version = upgrade_checker::get_upgrade_message();
}
return $block;
}
diff --git a/modules/gallery/helpers/gallery_error.php b/modules/gallery/helpers/gallery_error.php
index f9bbedfc..16699f84 100644
--- a/modules/gallery/helpers/gallery_error.php
+++ b/modules/gallery/helpers/gallery_error.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 13a0bdb4..07817187 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php
index 4cd7143e..e63b9336 100644
--- a/modules/gallery/helpers/gallery_graphics.php
+++ b/modules/gallery/helpers/gallery_graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index f7b8da5f..01c59eaa 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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,
@@ -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;");
@@ -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", 43);
+ module::set_version("gallery", 46);
}
static function upgrade($version) {
@@ -653,6 +655,28 @@ 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);
+ }
+
+ if ($version == 44) {
+ $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/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php
index fb617934..612872e6 100644
--- a/modules/gallery/helpers/gallery_rss.php
+++ b/modules/gallery/helpers/gallery_rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 9ccff152..4a97d865 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 978c69a6..c4a82390 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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) {
@@ -75,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 .= '<script type="text/javascript">
+ $.ajax({url: "' . url::site("admin/upgrade_checker/check_now?csrf=" .
+ access::csrf_token()) . '"});
+ </script>';
}
+ return $content;
}
static function admin_page_bottom($theme) {
@@ -106,6 +116,13 @@ class gallery_theme_Core {
setInterval("adminReauthCheck();", 60 * 1000);
</script>';
+ if (upgrade_checker::should_auto_check()) {
+ $content .= '<script type="text/javascript">
+ $.ajax({url: "' . url::site("admin/upgrade_checker/check_now?csrf=" .
+ access::csrf_token()) . '"});
+ </script>';
+ }
+
if ($session->get("l10n_mode", false)) {
$content .= "\n" . L10n_Client_Controller::l10n_form();
}
@@ -114,7 +131,7 @@ class gallery_theme_Core {
static function credits() {
$version_string = SafeString::of_safe_html(
- '<bdo dir="ltr">Gallery ' . gallery::VERSION . '</bdo>');
+ '<bdo dir="ltr">Gallery ' . gallery::version_string() . '</bdo>');
return "<li class=\"g-first\">" .
t(module::get_var("gallery", "credits"),
array("url" => "http://gallery.menalto.com",
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 18820ed7..72c563b7 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php
index f45f72c3..ae888d6a 100644
--- a/modules/gallery/helpers/identity.php
+++ b/modules/gallery/helpers/identity.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 8aa14934..1a5c631e 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index a8bc36ad..2cc1b75d 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php
index 3c09faa8..80db25b8 100644
--- a/modules/gallery/helpers/items_rest.php
+++ b/modules/gallery/helpers/items_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/json.php b/modules/gallery/helpers/json.php
index a88608aa..c89b9f30 100644
--- a/modules/gallery/helpers/json.php
+++ b/modules/gallery/helpers/json.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 8fc66b68..6d580249 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php
index 843c74f7..572099ea 100644
--- a/modules/gallery/helpers/l10n_scanner.php
+++ b/modules/gallery/helpers/l10n_scanner.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index d06bb319..47c2f76a 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/log.php b/modules/gallery/helpers/log.php
index 37154522..fe491ab1 100644
--- a/modules/gallery/helpers/log.php
+++ b/modules/gallery/helpers/log.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/message.php b/modules/gallery/helpers/message.php
index 64dd703c..f5a5eede 100644
--- a/modules/gallery/helpers/message.php
+++ b/modules/gallery/helpers/message.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index b39d599e..10d85f3b 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 6efe6162..37f7f68a 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index dd0b437e..ddced0d2 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index a38b4fb2..8913f567 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/random.php b/modules/gallery/helpers/random.php
index a26762bd..6016df7b 100644
--- a/modules/gallery/helpers/random.php
+++ b/modules/gallery/helpers/random.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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
diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php
index 85f30dba..2ba7fca5 100644
--- a/modules/gallery/helpers/site_status.php
+++ b/modules/gallery/helpers/site_status.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
index 4a6a3c0f..c39c7227 100644
--- a/modules/gallery/helpers/system.php
+++ b/modules/gallery/helpers/system.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 4dda568f..0421035f 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index 1dc1f3b6..f285834c 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/tree_rest.php b/modules/gallery/helpers/tree_rest.php
index 21928cbe..d9468ed8 100644
--- a/modules/gallery/helpers/tree_rest.php
+++ b/modules/gallery/helpers/tree_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
new file mode 100644
index 00000000..ff65608b
--- /dev/null
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -0,0 +1,103 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+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 {
+ 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);
+ }
+
+ /**
+ * Check the latest version info blob to see if it's time for an upgrade.
+ */
+ static function get_upgrade_message() {
+ $version_info = upgrade_checker::version_info();
+ if ($version_info) {
+ if (gallery::RELEASE_CHANNEL == "release") {
+ if (version_compare($version_info->data["release_version"], gallery::VERSION, ">")) {
+ return t("A newer version of Gallery is available! <a href=\"%upgrade-url\">Upgrade now</a> 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(), ">")) {
+ return t("A newer version of Gallery is available! <a href=\"%upgrade-url\">Upgrade now</a> 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));
+ }
+ }
+ }
+ }
+}
diff --git a/modules/gallery/helpers/user_profile.php b/modules/gallery/helpers/user_profile.php
index d9cc8ace..d2a7441d 100644
--- a/modules/gallery/helpers/user_profile.php
+++ b/modules/gallery/helpers/user_profile.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/helpers/xml.php b/modules/gallery/helpers/xml.php
index 2d3a2545..569ba5b2 100644
--- a/modules/gallery/helpers/xml.php
+++ b/modules/gallery/helpers/xml.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by