summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain LE DISEZ <romain.git@ledisez.net>2009-06-24 23:02:57 +0200
committerRomain LE DISEZ <romain.git@ledisez.net>2009-06-24 23:02:57 +0200
commit6111272568a732465c330597a068a048f6705ef9 (patch)
treef8829dfb4c4ee566a69f91d397e74e74aec56dbd
parentde28b0350e5d5bf6c3e1eb5a9531298b08fd7cba (diff)
parentf56d372629df5b08a30d0182d4e1e7c97a44d79f (diff)
Merge commit 'upstream/master'
Conflicts: modules/comment/helpers/comment_installer.php modules/gallery/models/item.php
-rwxr-xr-xinstaller/install.sql2
-rw-r--r--installer/web.php2
-rw-r--r--modules/akismet/helpers/akismet_installer.php5
-rw-r--r--modules/comment/helpers/comment_installer.php64
-rw-r--r--modules/comment/module.info2
-rw-r--r--modules/digibug/controllers/admin_digibug.php74
-rw-r--r--modules/digibug/controllers/digibug.php95
-rw-r--r--modules/digibug/css/digibug.css91
-rw-r--r--modules/digibug/css/logo.pngbin0 -> 17296 bytes
-rw-r--r--modules/digibug/helpers/digibug.php57
-rw-r--r--modules/digibug/helpers/digibug_installer.php45
-rw-r--r--modules/digibug/helpers/digibug_menu.php43
-rw-r--r--modules/digibug/helpers/digibug_task.php68
-rw-r--r--modules/digibug/helpers/digibug_theme.php42
-rw-r--r--modules/digibug/js/digibug.js46
-rw-r--r--modules/digibug/models/proxy.php22
-rw-r--r--modules/digibug/module.info3
-rw-r--r--modules/digibug/views/admin_digibug.html.php70
-rw-r--r--modules/digibug/views/digibug_album.html.php8
-rw-r--r--modules/digibug/views/digibug_form.html.php16
-rw-r--r--modules/exif/helpers/exif_installer.php26
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php3
-rw-r--r--modules/g2_import/helpers/g2_import.php2
-rw-r--r--modules/g2_import/helpers/g2_import_installer.php21
-rw-r--r--modules/g2_import/helpers/g2_import_task.php8
-rw-r--r--modules/gallery/controllers/admin_modules.php6
-rw-r--r--modules/gallery/controllers/admin_theme_options.php1
-rw-r--r--modules/gallery/controllers/albums.php7
-rw-r--r--modules/gallery/controllers/quick.php6
-rw-r--r--modules/gallery/controllers/upgrader.php6
-rw-r--r--modules/gallery/helpers/gallery_block.php5
-rw-r--r--modules/gallery/helpers/gallery_installer.php432
-rw-r--r--modules/gallery/helpers/gallery_quick.php7
-rw-r--r--modules/gallery/helpers/module.php34
-rw-r--r--modules/gallery/helpers/theme.php2
-rw-r--r--modules/gallery/models/item.php38
-rw-r--r--modules/gallery/module.info2
-rw-r--r--modules/image_block/helpers/image_block_installer.php4
-rw-r--r--modules/info/helpers/info_installer.php5
-rw-r--r--modules/notification/helpers/notification_installer.php36
-rw-r--r--modules/organize/helpers/organize_installer.php5
-rw-r--r--modules/recaptcha/helpers/recaptcha_installer.php5
-rw-r--r--modules/rss/helpers/rss_installer.php5
-rw-r--r--modules/search/helpers/search_installer.php23
-rw-r--r--modules/server_add/helpers/server_add_installer.php6
-rw-r--r--modules/slideshow/helpers/slideshow_installer.php5
-rw-r--r--modules/tag/helpers/tag_installer.php35
-rw-r--r--modules/user/helpers/user_installer.php106
-rw-r--r--modules/watermark/helpers/watermark_installer.php29
-rw-r--r--themes/default/views/album.html.php2
-rw-r--r--themes/default/views/footer.html.php4
51 files changed, 1176 insertions, 455 deletions
diff --git a/installer/install.sql b/installer/install.sql
index b9c56043..d02d8d69 100755
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -335,4 +335,4 @@ CREATE TABLE {vars} (
UNIQUE KEY `module_name` (`module_name`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
-INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(20,'gallery','date_format','Y-M-d'),(21,'gallery','date_time_format','Y-M-d H:i:s'),(22,'gallery','time_format','H:i:s'),(24,'comment','spam_caught','0');
+INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','date_format','Y-M-d'),(20,'gallery','date_time_format','Y-M-d H:i:s'),(21,'gallery','time_format','H:i:s'),(22,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>'),(24,'comment','spam_caught','0');
diff --git a/installer/web.php b/installer/web.php
index 61f26f7d..78784539 100644
--- a/installer/web.php
+++ b/installer/web.php
@@ -81,7 +81,7 @@ function oops($error) {
function check_environment() {
if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) {
- $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
+ $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
}
if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
diff --git a/modules/akismet/helpers/akismet_installer.php b/modules/akismet/helpers/akismet_installer.php
index 920c58b7..5d8c0e07 100644
--- a/modules/akismet/helpers/akismet_installer.php
+++ b/modules/akismet/helpers/akismet_installer.php
@@ -19,10 +19,7 @@
*/
class akismet_installer {
static function install() {
- $version = module::get_version("akismet");
- if ($version == 0) {
- module::set_version("akismet", 1);
- }
+ module::set_version("akismet", 1);
}
static function activate() {
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index 58bce8e0..f54913c3 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -20,38 +20,42 @@
class comment_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("comment");
+ $db->query("CREATE TABLE IF NOT EXISTS {comments} (
+ `author_id` int(9) default NULL,
+ `created` int(9) NOT NULL,
+ `guest_email` varchar(128) default NULL,
+ `guest_name` varchar(128) default NULL,
+ `guest_url` varchar(255) default NULL,
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9) NOT NULL,
+ `server_http_accept_charset` varchar(64) default NULL,
+ `server_http_accept_encoding` varchar(64) default NULL,
+ `server_http_accept_language` varchar(64) default NULL,
+ `server_http_accept` varchar(128) default NULL,
+ `server_http_connection` varchar(64) default NULL,
+ `server_http_host` varchar(64) default NULL,
+ `server_http_referer` varchar(255) default NULL,
+ `server_http_user_agent` varchar(128) default NULL,
+ `server_query_string` varchar(64) default NULL,
+ `server_remote_addr` varchar(32) default NULL,
+ `server_remote_host` varchar(64) default NULL,
+ `server_remote_port` varchar(16) default NULL,
+ `state` varchar(15) default 'unpublished',
+ `text` text,
+ `updated` int(9) NOT NULL,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {comments} (
- `author_id` int(9) default NULL,
- `created` int(9) NOT NULL,
- `guest_email` varchar(128) default NULL,
- `guest_name` varchar(128) default NULL,
- `guest_url` varchar(255) default NULL,
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9) NOT NULL,
- `server_http_accept_charset` varchar(64) default NULL,
- `server_http_accept_encoding` varchar(64) default NULL,
- `server_http_accept_language` varchar(64) default NULL,
- `server_http_accept` varchar(128) default NULL,
- `server_http_connection` varchar(64) default NULL,
- `server_http_host` varchar(64) default NULL,
- `server_http_referer` varchar(255) default NULL,
- `server_http_user_agent` varchar(128) default NULL,
- `server_query_string` varchar(64) default NULL,
- `server_remote_addr` varchar(32) default NULL,
- `server_remote_host` varchar(64) default NULL,
- `server_remote_port` varchar(16) default NULL,
- `state` varchar(15) default 'unpublished',
- `text` text,
- `updated` int(9) NOT NULL,
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ block_manager::add("dashboard_center", "comment", "recent_comments");
+ module::set_var("comment", "spam_caught", 0);
+ module::set_version("comment", 2);
+ }
- block_manager::add("dashboard_center", "comment", "recent_comments");
- module::set_var("comment", "spam_caught", 0);
- module::set_version("comment", 1);
+ static function upgrade($version) {
+ if ($version == 1) {
+ $db = Database::instance();
+ $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'");
+ module::set_version("comment", 2);
}
}
diff --git a/modules/comment/module.info b/modules/comment/module.info
index 08a800a6..946f1d39 100644
--- a/modules/comment/module.info
+++ b/modules/comment/module.info
@@ -1,3 +1,3 @@
name = Comments
description = Allows users and guests to leave comments on photos and albums.
-version = 1
+version = 2
diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php
new file mode 100644
index 00000000..8263fc83
--- /dev/null
+++ b/modules/digibug/controllers/admin_digibug.php
@@ -0,0 +1,74 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Admin_Digibug_Controller extends Admin_Controller {
+ public function index() {
+ print $this->_get_view();
+ }
+
+ public function basic() {
+ access::verify_csrf();
+
+ module::set_var("digibug", "mode", "basic");
+ message::success(t("Successfully set Digibug mode to basic"));
+
+ url::redirect("admin/digibug");
+ }
+
+ public function advanced() {
+ access::verify_csrf();
+
+ $form = $this->_get_form();
+ if ($form->validate()) {
+ module::set_var("digibug", "company_id", $form->group->company_id->value);
+ module::set_var("digibug", "event_id", $form->group->event_id->value);
+ module::set_var("digibug", "mode", "advanced");
+ message::success(t("Successfully set Digibug mode to advanced"));
+
+ url::redirect("admin/digibug");
+ }
+
+ print $this->_get_view($form);
+ }
+
+ private function _get_view($form=null) {
+ $v = new Admin_View("admin.html");
+ $v->content = new View("admin_digibug.html");
+ $v->content->mode = module::get_var("digibug", "mode", "basic");
+ $v->content->form = empty($form) ? $this->_get_form() : $form;
+ return $v;
+ }
+
+ private function _get_form() {
+ $form = new Forge("admin/digibug/advanced", "", "post",
+ array("id" => "gAdminForm"));
+ $group = $form->group("group");
+ $group->input("company_id")
+ ->label(t("Company Id"))
+ ->rules("required")
+ ->value(module::get_var("digibug", "company_id", ""));
+ $group->input("event_id")
+ ->label(t("Event Id"))
+ ->rules("required")
+ ->value(module::get_var("digibug", "event_id", ""));
+ $group->submit("submit")->value(t("Submit"));
+
+ return $form;
+ }
+} \ No newline at end of file
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
new file mode 100644
index 00000000..3a427149
--- /dev/null
+++ b/modules/digibug/controllers/digibug.php
@@ -0,0 +1,95 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Digibug_Controller extends Controller {
+ public function print_photo($id) {
+ access::verify_csrf();
+
+ $item = ORM::factory("item", $id);
+
+ $proxy = ORM::factory("proxy");
+ $proxy->uuid = digibug::uuid();
+ $proxy->item_id = $item->id;
+ $proxy->save();
+
+ $url = url::abs_site("digibug/print_proxy/{$proxy->uuid}");
+ if (module::get_var("digibug", "mode", "basic")) {
+ $company_id = module::get_var("digibug", "basic_company_id");
+ $event_id = module::get_var("digibug", "basic_event_id");
+ } else {
+ $company_id = module::get_var("digibug", "company_id");
+ $event_id = module::get_var("digibug", "event_id");
+ }
+ $v = new View("digibug_form.html");
+ $v->order_parms = array(
+ "digibug_api_version" => "100",
+ "company_id" => $company_id,
+ "event_id" => $event_id,
+ "cmd" => "addimg",
+ "return_url" => url::abs_site("digibug/close_window"),
+ "num_images" => "1",
+ "image_1" => $url,
+ "thumb_1" => "$url/thumb",
+ "image_height_1" => $item->height,
+ "image_width_1" => $item->width,
+ "thumb_height_1" => $item->thumb_height,
+ "thumb_width_1" => $item->thumb_width,
+ "title_1" => $item->title);
+
+ print $v;
+ }
+
+ public function print_proxy($id, $thumb=null) {
+ $proxy = ORM::factory("proxy")
+ ->where("uuid", $id)
+ ->find();
+
+ if (!$proxy->loaded) {
+ Kohana::show_404();
+ }
+
+ if (!$proxy->item->loaded) {
+ Kohana::show_404();
+ }
+
+ $file = empty($thumb) ? $proxy->item->file_path() : $proxy->item->thumb_path();
+ if (!file_exists($file)) {
+ kohana::show_404();
+ }
+
+ // We don't need to save the session for this request
+ Session::abort_save();
+
+ // Dump out the image
+ header("Content-Type: $proxy->item->mime_type");
+ Kohana::close_buffers(false);
+ $fd = fopen($file, "rb");
+ fpassthru($fd);
+ fclose($fd);
+
+ // If the request was for the image and not the thumb, then delete the proxy.
+ if (empty($thumb)) {
+ $proxy->delete();
+ }
+ }
+
+ public function close_window() {
+ print "<script type=\"text/javascript\">window.close();</script>";
+ }
+} \ No newline at end of file
diff --git a/modules/digibug/css/digibug.css b/modules/digibug/css/digibug.css
new file mode 100644
index 00000000..a09e4551
--- /dev/null
+++ b/modules/digibug/css/digibug.css
@@ -0,0 +1,91 @@
+.gAdminDigibugIntro {
+ background-image: url(logo.png);
+ background-repeat: no-repeat;
+ padding-bottom: 20px;
+ width: 820px;
+}
+
+.gAdminDigibugIntro p {
+ font-family: Trebuchet MS,Arial,Verdana,Helvetica,sans-serif;
+ font-size: 1.3em;
+ font-weight: bold;
+ padding-left: 110px;
+ padding-top: 15px;
+}
+
+.gDigibugTab {
+ width: 820px;
+ height: 420px;
+}
+
+.gDigibugTab .gDigibugTitle {
+ font-family: Georgia;
+ font-size: 20px;
+ font-weight: bold;
+ padding-bottom: 10px;
+}
+
+.gDigibugTab .gDigibugText {
+ font-size: 12px;
+ font-weight: bold;
+ line-height: 17px;
+ padding-bottom: 15px;
+}
+
+.gDigibugListItems ul {
+ list-style-type: disc;
+ padding-left: 20px;
+ font-size: 12px;
+ font-weight: bold;
+ line-height: 15px;
+}
+
+.gDigibugListItems ul li{
+ padding-top: 10px;
+}
+
+.gDigibugRounded {
+ background-color:#5C9CCC;
+ color: white;
+ width: 308px;
+ height: 45px;
+ text-align: center;
+ line-height: 15px;
+ margin-top: 10px;
+ font-weight: bold;
+ font-size: 12px;
+ margin-left: 60px;
+ margin-right: -50px;
+ margin-left: 20px;
+ margin-right: 0px;
+}
+
+.gDigibugRounded a {
+ color: white !important;
+ font-weight: bold;
+ text-decoration: underline;
+}
+
+.gDigibugSignIn {
+ width: 115px;
+ float: left;
+}
+
+.gDigibugSignIn a {
+ color: black;
+ font-size: 16px;
+ font-weight: bold;
+ text-decoration: underline;
+}
+
+.gDigibugAdvancedForm {
+ float: left;
+ padding-left: 30px;
+ width: 180px;
+}
+
+.gDigibugPrintButton {
+ float: left;
+}
+
+
diff --git a/modules/digibug/css/logo.png b/modules/digibug/css/logo.png
new file mode 100644
index 00000000..5eac2c7d
--- /dev/null
+++ b/modules/digibug/css/logo.png
Binary files differ
diff --git a/modules/digibug/helpers/digibug.php b/modules/digibug/helpers/digibug.php
new file mode 100644
index 00000000..46c9d945
--- /dev/null
+++ b/modules/digibug/helpers/digibug.php
@@ -0,0 +1,57 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_Core {
+ /**
+ * Get a unique id for a print request.
+ * Its a good thing we only support linux as this won't work on Windows
+ */
+ static function uuid() {
+ $fp = @fopen("/dev/urandom", "rb");
+ $bits = @fread($fp, 16);
+ @fclose($fp);
+
+ $time_low = bin2hex(substr($bits, 0, 4));
+ $time_mid = bin2hex(substr($bits, 4, 2));
+ $time_hi_and_version = bin2hex(substr($bits, 6, 2));
+ $clock_seq_hi_and_reserved = bin2hex(substr($bits, 8, 2));
+ $node = bin2hex ( substr ( $bits, 10, 6 ) );
+
+ /**
+ * Set the four most significant bits (bits 12 through 15) of the
+ * time_hi_and_version field to the 4-bit version number from
+ * Section 4.1.3.
+ * @see http://tools.ietf.org/html/rfc4122#section-4.1.3
+ */
+ $time_hi_and_version = hexdec ( $time_hi_and_version );
+ $time_hi_and_version = $time_hi_and_version >> 4;
+ $time_hi_and_version = $time_hi_and_version | 0x4000;
+
+ /**
+ * Set the two most significant bits (bits 6 and 7) of the
+ * clock_seq_hi_and_reserved to zero and one, respectively.
+ */
+ $clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved );
+ $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
+ $clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
+
+ return sprintf ('%08s-%04s-%04x-%04x-%012s',
+ $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node);
+ }
+}
diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php
new file mode 100644
index 00000000..baff2075
--- /dev/null
+++ b/modules/digibug/helpers/digibug_installer.php
@@ -0,0 +1,45 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_installer {
+ static function install() {
+ $version = module::get_version("digibug");
+ if ($version == 0) {
+ Database::instance()
+ ->query("CREATE TABLE {proxies} (
+ `id` int(9) NOT NULL AUTO_INCREMENT,
+ `uuid` char(36) NOT NULL,
+ `request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp,
+ `item_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
+ module::set_var("digibug", "basic_company_id", "3153");
+ module::set_var("digibug", "basic_event_id", "8491");
+ module::set_var("digibug", "mode", "basic");
+
+ module::set_version("digibug", 1);
+ }
+ }
+
+ static function uninstall() {
+ Database::instance()->query("DROP TABLE IF EXISTS {proxies}");
+ module::delete("digibug");
+ }
+}
diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php
new file mode 100644
index 00000000..1ff0f6bf
--- /dev/null
+++ b/modules/digibug/helpers/digibug_menu.php
@@ -0,0 +1,43 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_menu {
+ static function admin($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("digibug_menu")
+ ->label(t("Digibug Administration"))
+ ->url(url::site("admin/digibug")));
+ }
+
+ static function photo($menu, $theme) {
+ }
+
+ static function site($menu, $theme) {
+ $item = $theme->item();
+
+ if ($item && access::can("edit", $item)) {
+ $options_menu = $menu->get("options_menu")
+ ->append(Menu::factory("dialog")
+ ->id("digibug")
+ ->label(t("Peform Digibug Processing"))
+ ->url(url::site("digibug/index/$item->id")));
+ }
+ }
+}
diff --git a/modules/digibug/helpers/digibug_task.php b/modules/digibug/helpers/digibug_task.php
new file mode 100644
index 00000000..98f79731
--- /dev/null
+++ b/modules/digibug/helpers/digibug_task.php
@@ -0,0 +1,68 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_task_Core {
+ static function available_tasks() {
+ // Delete extra exif_records
+ $expired_request_count = Database::instance()->query(
+ "SELECT count(*) as print_requests
+ FROM {proxies}
+ WHERE `request_date` <= (CURDATE() - INTERVAL 10 DAY)")->current()->print_requests;
+
+ return array(Task_Definition::factory()
+ ->callback("digibug_task::remove_expired")
+ ->name(t("Remove Digibug print requests"))
+ ->description($expired_request_count
+ ? t2("1 Digibug print request has expired",
+ "%count Digibug print requests have expired",
+ $expired_request_count)
+ : t("All print requests are current"))
+ ->severity($expired_request_count ? log::WARNING : log::SUCCESS));
+ }
+
+ static function remove_expired($task) {
+ $completed = $task->get("completed", 0);
+ $expired = ORM::factory("proxy")
+ ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)")
+ ->find_all();
+ $remaining = $expired->count();
+
+ $start = microtime(true);
+ foreach ($expired as $proxy) {
+ if (microtime(true) - $start > 1.5) {
+ break;
+ }
+ $proxy->delete();
+ $completed++;
+ $remaining--;
+ }
+
+ if ($completed + $remaining > 0) {
+ $task->percent_complete = (int)(100 * $completed / ($completed + $remaining));
+ } else {
+ $task->percent_complete = 100;
+ }
+
+ $task->set("completed", $completed);
+ if ($remaining == 0) {
+ $task->done = true;
+ $task->state = "success";
+ }
+ }
+}
diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php
new file mode 100644
index 00000000..e52fcc7f
--- /dev/null
+++ b/modules/digibug/helpers/digibug_theme.php
@@ -0,0 +1,42 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 digibug_theme_Core {
+ static function head($theme) {
+ $head[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" .
+ url::file("modules/digibug/css/digibug.css") . "\" />";
+ $head[] = html::script("modules/digibug/js/digibug.js");;
+ return implode("\n", $head);
+ }
+
+ static function admin_head($theme) {
+ return "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" .
+ url::file("modules/digibug/css/digibug.css") . "\" />";
+ }
+
+ static function thumb_bottom($theme, $child) {
+ if ($theme->page_type() == "album" && $child->type == "photo") {
+ $v = new View("digibug_album.html");
+ $v->id = $child->id;
+ $v->title = t("Print photo with Digibug");
+ return $v->render();
+ }
+ return "";
+ }
+}
diff --git a/modules/digibug/js/digibug.js b/modules/digibug/js/digibug.js
new file mode 100644
index 00000000..e9e8933e
--- /dev/null
+++ b/modules/digibug/js/digibug.js
@@ -0,0 +1,46 @@
+$(document).ready(function() {
+ $(".gDigibugPrintButton a").click(function(e) {
+ e.preventDefault();
+ queue_print(e);
+ });
+});
+
+function popUp(url, options) {
+ options = $.extend({
+ /* default options */
+ width: 400,
+ height: 400,
+ target: 'dbPopWin',
+ scrollbars: 'yes',
+ resizable: 'no',
+ menuBar: 'no',
+ addressBar: 'yes'}, options);
+
+ /* center the window by default. */
+ if (!options.winY) {
+ options.winY = screen.height / 2 - options.height / 2;
+ };
+ if (!options.winX) {
+ options.winX = screen.width / 2 - options.width / 2;
+ };
+
+ open(
+ url,
+ options['target'],
+ 'width= ' + options.width +
+ ',height=' + options.height +
+ ',top=' + options.winY +
+ ',left=' + options.winX +
+ ',scrollbars=' + options.scrollbars +
+ ',resizable=' + options.resizable +
+ ',menubar=' + options.menuBar +
+ ',location=' + options.addressBar
+ );
+
+ return false;
+
+}
+
+function queue_print(e) {
+ return popUp(e.currentTarget.href, { width: 800, height: 600 } );
+};
diff --git a/modules/digibug/models/proxy.php b/modules/digibug/models/proxy.php
new file mode 100644
index 00000000..ce10c592
--- /dev/null
+++ b/modules/digibug/models/proxy.php
@@ -0,0 +1,22 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Proxy_Model extends ORM {
+ protected $has_one = array("item");
+}
diff --git a/modules/digibug/module.info b/modules/digibug/module.info
new file mode 100644
index 00000000..58602c0d
--- /dev/null
+++ b/modules/digibug/module.info
@@ -0,0 +1,3 @@
+name = Digibug
+description = Digibug Photo Printing Module
+version = 1
diff --git a/modules/digibug/views/admin_digibug.html.php b/modules/digibug/views/admin_digibug.html.php
new file mode 100644
index 00000000..33ce5f83
--- /dev/null
+++ b/modules/digibug/views/admin_digibug.html.php
@@ -0,0 +1,70 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<script type="text/javascript">
+ $("#gDigibugTabs").ready(function() {
+ $("#gDigibugTabs").tabs({
+ event: "mouseover"
+ });
+ });
+</script>
+<div id="gAdminDigibug">
+ <h2><?= t("Digibug Adminstration") ?> </h2>
+ <div class="gAdminDigibugIntro">
+ <p>
+ <?= t("Digibug offers you two options for turning your photos into a wide variety of prints, gifts and games. Choose your solution and get started today!") ?>
+ </p>
+ </div>
+ <div id="gDigibugTabs">
+ <ul>
+ <li><a href="#gDigibugTabBasic"><?= t("Basic") ?></a></li>
+ <li><a href="#gDigibugTabAdvanced"><?= t("Advanced") ?></a></li>
+ </ul>
+ <div id="gDigibugTabBasic" class="gDigibugTab">
+ <div class="gDigibugTitle">
+ <?= t("Digibug Basic") ?>
+ <br/>
+ <?= t("Fast Easy Photo Fulfillment") ?>
+ </div>
+ <div class="gDigibugText">
+ <?= t("Power up your Gallery with professional level fulfillment from Kodak. Just use Digibug Basic and there's nothing else to do - no registration, no administration, no hassles.") ?>
+ </div>
+ <div class="gDigibugListItems">
+ <ul>
+ <li><?= t("Matte and Glossy prints, from 4x6 to as big as 30x40") ?></li>
+ <li><?= t("Great photo gifts like canvases, apparel, bags, puzzles, mugs and sports memorabilia and more") ?></li>
+ <li><?= t("Outstanding quality and customer service") ?></li>
+ </ul>
+ </div>
+ <div class="gDigibugRounded ui-corner-all">
+ <br/>
+ <? if ($mode == "basic"): ?>
+ <?= t("You are currently using Basic mode!") ?>
+ <? else: ?>
+ <a href='<?= url::site("admin/digibug/basic?csrf=$csrf") ?>'><?= t("Click Here") ?></a>
+ <?= t(" to switch back to basic") ?>
+ <? endif ?>
+ </div>
+ </div>
+ <div id="gDigibugTabAdvanced" class="gDigibugTab">
+ <div class="gDigibugTitle">
+ <?= t("Digibug ADVANCED") ?>
+ <br/>
+ <?= t("The Pro\'s Solution") ?>
+ </div>
+ <div class="gDigibugText">
+ <?= t("Digibug ADVANCED allows you to set your own price for photos and gifts. Simply provide us with your account information and we'll send you a check each month with your profits. It's the perfect online retail business solution for a photographer - no inventory, no overhead... just profits!") ?>
+ </div>
+ <div class="gDigibugText">
+ <?= t("Enjoy the same range of professional level photo prints and gifts, but set your own price and charge what you believe your photos are worth. We'll take care of the rest.") ?>
+ </div>
+ <div style="width: 120px;" class="gDigibugText gDigibugSignIn">
+ <?= t("New to Digibug ADVANCED?") ?>
+ <br/> <br/>
+ <a href="http://www.digibug.com/signup.php" style=""><?= t("Sign up") ?></a><?= t(" to get started") ?>
+ </div>
+ <div class="gDigibugAdvancedForm">
+ <div class="gDigibugText"><?= t("Do you have a Digibug Company ID and Event ID?") ?></div>
+ <?= $form ?>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/modules/digibug/views/digibug_album.html.php b/modules/digibug/views/digibug_album.html.php
new file mode 100644
index 00000000..c3337324
--- /dev/null
+++ b/modules/digibug/views/digibug_album.html.php
@@ -0,0 +1,8 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div class="gDigibugPrintButton">
+ <a class="gButtonLink ui-corner-all ui-state-default ui-icon-left"
+ href="<?= url::site("digibug/print_photo/$id?csrf={$csrf}") ?>"
+ title="<?= $title ?>">
+ <span class="ui-icon ui-icon-print"><?= $title ?></span>
+ </a>
+</div> \ No newline at end of file
diff --git a/modules/digibug/views/digibug_form.html.php b/modules/digibug/views/digibug_form.html.php
new file mode 100644
index 00000000..c2cd889e
--- /dev/null
+++ b/modules/digibug/views/digibug_form.html.php
@@ -0,0 +1,16 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<html>
+<head>
+ <?= html::script("lib/jquery.js") ?>
+ <script type="text/javascript">
+ $("body form").ready(function() {
+ $("body form").submit();
+ });
+ </script>
+</head>
+<body>
+ <?= form::open("http://www.digibug.com/dapi/order.php") ?>
+ <?= form::hidden($order_parms) ?>
+ <?= form::close() ?>
+</body>
+</html> \ No newline at end of file
diff --git a/modules/exif/helpers/exif_installer.php b/modules/exif/helpers/exif_installer.php
index da49f649..0233f2bb 100644
--- a/modules/exif/helpers/exif_installer.php
+++ b/modules/exif/helpers/exif_installer.php
@@ -19,21 +19,17 @@
*/
class exif_installer {
static function install() {
- $version = module::get_version("exif");
-
- if ($version == 0) {
- $db = Database::instance();
- $db->query("CREATE TABLE IF NOT EXISTS {exif_records} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` INTEGER(9) NOT NULL,
- `key_count` INTEGER(9) default 0,
- `data` TEXT,
- `dirty` BOOLEAN default 1,
- PRIMARY KEY (`id`),
- KEY(`item_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- module::set_version("exif", 1);
- }
+ $db = Database::instance();
+ $db->query("CREATE TABLE IF NOT EXISTS {exif_records} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` INTEGER(9) NOT NULL,
+ `key_count` INTEGER(9) default 0,
+ `data` TEXT,
+ `dirty` BOOLEAN default 1,
+ PRIMARY KEY (`id`),
+ KEY(`item_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ module::set_version("exif", 1);
}
static function activate() {
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index f2969f49..18d09363 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -21,6 +21,9 @@ class Admin_g2_import_Controller extends Admin_Controller {
public function index() {
if (g2_import::is_configured()) {
g2_import::init();
+ }
+
+ if (class_exists("GalleryCoreApi")) {
$g2_stats = g2_import::stats();
$g2_sizes = g2_import::common_sizes();
}
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 2eee564a..91ca1e63 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -113,11 +113,13 @@ class g2_import_Core {
"require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');",
"define('GALLERY_CONFIG_DIR', dirname(__FILE__));",
"\$gallery =& new Gallery();",
+ "\$GLOBALS['gallery'] =& new Gallery();",
"\$gallery = new Gallery();"),
array("require_once(dirname(__FILE__) . '/Gallery.class');",
"require_once('$base_dir/modules/core/classes/GalleryDataCache.class');",
"define('GALLERY_CONFIG_DIR', '$config_dir');",
"\$gallery =& new G2_Gallery();",
+ "\$GLOBALS['gallery'] =& new G2_Gallery();",
"\$gallery = new G2_Gallery();"),
array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"),
file("$base_dir/bootstrap.inc"))));
diff --git a/modules/g2_import/helpers/g2_import_installer.php b/modules/g2_import/helpers/g2_import_installer.php
index 5f414d42..0f87da6c 100644
--- a/modules/g2_import/helpers/g2_import_installer.php
+++ b/modules/g2_import/helpers/g2_import_installer.php
@@ -20,19 +20,16 @@
class g2_import_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("g2_import");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {g2_maps} (
- `id` int(9) NOT NULL auto_increment,
- `g2_id` int(9) NOT NULL,
- `g3_id` int(9) NOT NULL,
- PRIMARY KEY (`id`),
- KEY (`g2_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {g2_maps} (
+ `id` int(9) NOT NULL auto_increment,
+ `g2_id` int(9) NOT NULL,
+ `g3_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY (`g2_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- module::set_version("g2_import", 1);
- mkdir(VARPATH . "modules/g2_import");
- }
+ module::set_version("g2_import", 1);
+ mkdir(VARPATH . "modules/g2_import");
}
static function uninstall() {
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 4cd95581..3961097d 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -21,15 +21,19 @@ class g2_import_task_Core {
static function available_tasks() {
if (g2_import::is_configured()) {
g2_import::init();
+ }
+
+
+ if (class_exists("GalleryCoreApi")) {
return array(Task_Definition::factory()
->callback("g2_import_task::import")
->name(t("Import from Gallery 2"))
->description(
t("Gallery %version detected", array("version" => g2_import::version())))
->severity(log::SUCCESS));
- } else {
- return array();
}
+
+ return array();
}
static function import($task) {
diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php
index f7dd909d..ed1f7665 100644
--- a/modules/gallery/controllers/admin_modules.php
+++ b/modules/gallery/controllers/admin_modules.php
@@ -45,7 +45,11 @@ class Admin_Modules_Controller extends Admin_Controller {
} else if (!$info->active && $desired && !module::is_active($module_name)) {
$changes->activate[] = $module_name;
$activated_names[] = $info->name;
- module::install($module_name);
+ if (module::is_installed($module_name)) {
+ module::upgrade($module_name);
+ } else {
+ module::install($module_name);
+ }
module::activate($module_name);
}
}
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index 2716ed93..8970c3c9 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -56,6 +56,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
module::set_var("gallery", "header_text", $form->edit_theme->header_text->value);
module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
+ module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
message::success(t("Updated theme details"));
url::redirect("admin/theme_options");
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 17fdec6b..22f50fb8 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -167,7 +167,8 @@ class Albums_Controller extends Items_Controller {
$form = album::get_edit_form($album);
if ($valid = $form->validate()) {
// Make sure that there's not a conflict
- if (Database::instance()
+ if ($album->id != 1 &&
+ Database::instance()
->from("items")
->where("parent_id", $album->parent_id)
->where("id <>", $album->id)
@@ -188,7 +189,9 @@ class Albums_Controller extends Items_Controller {
$album->description = $form->edit_album->description->value;
$album->sort_column = $form->edit_album->sort_order->column->value;
$album->sort_order = $form->edit_album->sort_order->direction->value;
- $album->rename($form->edit_album->dirname->value);
+ if ($album->id != 1) {
+ $album->rename($form->edit_album->dirname->value);
+ }
$album->save();
module::event("item_updated", $orig, $album);
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index 6203728c..e89d9701 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -25,10 +25,10 @@ class Quick_Controller extends Controller {
}
$view = new View("quick_pane.html");
- $view->button_list =
- gallery_quick::get_quick_buttons($item, Input::instance()->get("page_type"));
+ $page_type = Input::instance()->get("page_type");
+ $view->button_list = gallery_quick::get_quick_buttons($item, $page_type);
$view->item = $item;
- $view->page_type = Input::instance()->get("page_type");
+ $view->page_type = $page_type;
print $view;
}
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index 5eb96fdd..91952fa9 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -50,8 +50,8 @@ class Upgrader_Controller extends Controller {
}
// Upgrade gallery and user first
- module::install("gallery");
- module::install("user");
+ module::upgrade("gallery");
+ module::upgrade("user");
// Then upgrade the rest
foreach (module::available() as $id => $module) {
@@ -60,7 +60,7 @@ class Upgrader_Controller extends Controller {
}
if ($module->active && $module->code_version != $module->version) {
- module::install($id);
+ module::upgrade($id);
}
}
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index c3837f54..a10f2bbf 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -49,8 +49,9 @@ class gallery_block_Core {
$block->css_id = "gLogEntries";
$block->title = t("Log Entries");
$block->content = new View("admin_block_log_entries.html");
- $block->content->entries = ORM::factory("log")->orderby("timestamp", "DESC")->find_all(5);
- break;
+ $block->content->entries = ORM::factory("log")
+ ->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
+ break;
case "stats":
$block->css_id = "gStats";
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index cd871c17..df555d52 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -18,244 +18,241 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_installer {
- static function install($initial_install=false) {
+ static function install() {
$db = Database::instance();
- if ($initial_install) {
- $version = 0;
- } else {
- $version = module::get_version("gallery");
- }
-
- if ($version == 0) {
- $db->query("CREATE TABLE {access_caches} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9),
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-
- $db->query("CREATE TABLE {access_intents} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9),
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {access_caches} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9),
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {graphics_rules} (
- `id` int(9) NOT NULL auto_increment,
- `active` BOOLEAN default 0,
- `args` varchar(255) default NULL,
- `module_name` varchar(64) NOT NULL,
- `operation` varchar(64) NOT NULL,
- `priority` int(9) NOT NULL,
- `target` varchar(32) NOT NULL,
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {access_intents} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9),
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {incoming_translations} (
- `id` int(9) NOT NULL auto_increment,
- `key` char(32) NOT NULL,
- `locale` char(10) NOT NULL,
- `message` text NOT NULL,
- `revision` int(9) DEFAULT NULL,
- `translation` text,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`key`, `locale`),
- KEY `locale_key` (`locale`, `key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {graphics_rules} (
+ `id` int(9) NOT NULL auto_increment,
+ `active` BOOLEAN default 0,
+ `args` varchar(255) default NULL,
+ `module_name` varchar(64) NOT NULL,
+ `operation` varchar(64) NOT NULL,
+ `priority` int(9) NOT NULL,
+ `target` varchar(32) NOT NULL,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {items} (
- `id` int(9) NOT NULL auto_increment,
- `album_cover_item_id` int(9) default NULL,
- `captured` int(9) default NULL,
- `created` int(9) default NULL,
- `description` varchar(2048) default NULL,
- `height` int(9) default NULL,
- `left` int(9) NOT NULL,
- `level` int(9) NOT NULL,
- `mime_type` varchar(64) default NULL,
- `name` varchar(255) default NULL,
- `owner_id` int(9) default NULL,
- `parent_id` int(9) NOT NULL,
- `rand_key` float default NULL,
- `relative_path_cache` varchar(255) default NULL,
- `resize_dirty` boolean default 1,
- `resize_height` int(9) default NULL,
- `resize_width` int(9) default NULL,
- `right` int(9) NOT NULL,
- `sort_column` varchar(64) default NULL,
- `sort_order` char(4) default 'ASC',
- `thumb_dirty` boolean default 1,
- `thumb_height` int(9) default NULL,
- `thumb_width` int(9) default NULL,
- `title` varchar(255) default NULL,
- `type` varchar(32) NOT NULL,
- `updated` int(9) default NULL,
- `view_count` int(9) default 0,
- `weight` int(9) NOT NULL default 0,
- `width` int(9) default NULL,
- PRIMARY KEY (`id`),
- KEY `parent_id` (`parent_id`),
- KEY `type` (`type`),
- KEY `random` (`rand_key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {incoming_translations} (
+ `id` int(9) NOT NULL auto_increment,
+ `key` char(32) NOT NULL,
+ `locale` char(10) NOT NULL,
+ `message` text NOT NULL,
+ `revision` int(9) DEFAULT NULL,
+ `translation` text,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`key`, `locale`),
+ KEY `locale_key` (`locale`, `key`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {logs} (
- `id` int(9) NOT NULL auto_increment,
- `category` varchar(64) default NULL,
- `html` varchar(255) default NULL,
- `message` text default NULL,
- `referer` varchar(255) default NULL,
- `severity` int(9) default 0,
- `timestamp` int(9) default 0,
- `url` varchar(255) default NULL,
- `user_id` int(9) default 0,
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {items} (
+ `id` int(9) NOT NULL auto_increment,
+ `album_cover_item_id` int(9) default NULL,
+ `captured` int(9) default NULL,
+ `created` int(9) default NULL,
+ `description` varchar(2048) default NULL,
+ `height` int(9) default NULL,
+ `left` int(9) NOT NULL,
+ `level` int(9) NOT NULL,
+ `mime_type` varchar(64) default NULL,
+ `name` varchar(255) default NULL,
+ `owner_id` int(9) default NULL,
+ `parent_id` int(9) NOT NULL,
+ `rand_key` float default NULL,
+ `relative_path_cache` varchar(255) default NULL,
+ `resize_dirty` boolean default 1,
+ `resize_height` int(9) default NULL,
+ `resize_width` int(9) default NULL,
+ `right` int(9) NOT NULL,
+ `sort_column` varchar(64) default NULL,
+ `sort_order` char(4) default 'ASC',
+ `thumb_dirty` boolean default 1,
+ `thumb_height` int(9) default NULL,
+ `thumb_width` int(9) default NULL,
+ `title` varchar(255) default NULL,
+ `type` varchar(32) NOT NULL,
+ `updated` int(9) default NULL,
+ `view_count` int(9) default 0,
+ `weight` int(9) NOT NULL default 0,
+ `width` int(9) default NULL,
+ PRIMARY KEY (`id`),
+ KEY `parent_id` (`parent_id`),
+ KEY `type` (`type`),
+ KEY `random` (`rand_key`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {messages} (
- `id` int(9) NOT NULL auto_increment,
- `key` varchar(255) default NULL,
- `severity` varchar(32) default NULL,
- `value` varchar(255) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {logs} (
+ `id` int(9) NOT NULL auto_increment,
+ `category` varchar(64) default NULL,
+ `html` varchar(255) default NULL,
+ `message` text default NULL,
+ `referer` varchar(255) default NULL,
+ `severity` int(9) default 0,
+ `timestamp` int(9) default 0,
+ `url` varchar(255) default NULL,
+ `user_id` int(9) default 0,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {modules} (
- `id` int(9) NOT NULL auto_increment,
- `active` BOOLEAN default 0,
- `name` varchar(64) default NULL,
- `version` int(9) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {messages} (
+ `id` int(9) NOT NULL auto_increment,
+ `key` varchar(255) default NULL,
+ `severity` varchar(32) default NULL,
+ `value` varchar(255) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`key`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {outgoing_translations} (
- `id` int(9) NOT NULL auto_increment,
- `base_revision` int(9) DEFAULT NULL,
- `key` char(32) NOT NULL,
- `locale` char(10) NOT NULL,
- `message` text NOT NULL,
- `translation` text,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`key`, `locale`),
- KEY `locale_key` (`locale`, `key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {modules} (
+ `id` int(9) NOT NULL auto_increment,
+ `active` BOOLEAN default 0,
+ `name` varchar(64) default NULL,
+ `version` int(9) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {permissions} (
- `id` int(9) NOT NULL auto_increment,
- `display_name` varchar(64) default NULL,
- `name` varchar(64) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {outgoing_translations} (
+ `id` int(9) NOT NULL auto_increment,
+ `base_revision` int(9) DEFAULT NULL,
+ `key` char(32) NOT NULL,
+ `locale` char(10) NOT NULL,
+ `message` text NOT NULL,
+ `translation` text,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`key`, `locale`),
+ KEY `locale_key` (`locale`, `key`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {sessions} (
- `session_id` varchar(127) NOT NULL,
- `data` text NOT NULL,
- `last_activity` int(10) UNSIGNED NOT NULL,
- PRIMARY KEY (`session_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {permissions} (
+ `id` int(9) NOT NULL auto_increment,
+ `display_name` varchar(64) default NULL,
+ `name` varchar(64) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {tasks} (
- `id` int(9) NOT NULL auto_increment,
- `callback` varchar(128) default NULL,
- `context` text NOT NULL,
- `done` boolean default 0,
- `name` varchar(128) default NULL,
- `owner_id` int(9) default NULL,
- `percent_complete` int(9) default 0,
- `state` varchar(32) default NULL,
- `status` varchar(255) default NULL,
- `updated` int(9) default NULL,
- PRIMARY KEY (`id`),
- KEY (`owner_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {sessions} (
+ `session_id` varchar(127) NOT NULL,
+ `data` text NOT NULL,
+ `last_activity` int(10) UNSIGNED NOT NULL,
+ PRIMARY KEY (`session_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {themes} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(64) default NULL,
- `version` int(9) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {tasks} (
+ `id` int(9) NOT NULL auto_increment,
+ `callback` varchar(128) default NULL,
+ `context` text NOT NULL,
+ `done` boolean default 0,
+ `name` varchar(128) default NULL,
+ `owner_id` int(9) default NULL,
+ `percent_complete` int(9) default 0,
+ `state` varchar(32) default NULL,
+ `status` varchar(255) default NULL,
+ `updated` int(9) default NULL,
+ PRIMARY KEY (`id`),
+ KEY (`owner_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {vars} (
- `id` int(9) NOT NULL auto_increment,
- `module_name` varchar(64) NOT NULL,
- `name` varchar(64) NOT NULL,
- `value` text,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`module_name`, `name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {themes} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(64) default NULL,
+ `version` int(9) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) {
- @mkdir(VARPATH . $dir);
- }
+ $db->query("CREATE TABLE {vars} (
+ `id` int(9) NOT NULL auto_increment,
+ `module_name` varchar(64) NOT NULL,
+ `name` varchar(64) NOT NULL,
+ `value` text,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`module_name`, `name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- access::register_permission("view", "View");
- access::register_permission("view_full", "View Full Size");
- access::register_permission("edit", "Edit");
- access::register_permission("add", "Add");
+ foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) {
+ @mkdir(VARPATH . $dir);
+ }
- $root = ORM::factory("item");
- $root->type = "album";
- $root->title = "Gallery";
- $root->description = "";
- $root->left = 1;
- $root->right = 2;
- $root->parent_id = 0;
- $root->level = 1;
- $root->thumb_dirty = 1;
- $root->resize_dirty = 1;
- $root->sort_column = "weight";
- $root->sort_order = "ASC";
- $root->save();
- access::add_item($root);
+ access::register_permission("view", "View");
+ access::register_permission("view_full", "View Full Size");
+ access::register_permission("edit", "Edit");
+ access::register_permission("add", "Add");
- module::set_var("gallery", "active_site_theme", "default");
- module::set_var("gallery", "active_admin_theme", "admin_default");
- module::set_var("gallery", "page_size", 9);
- module::set_var("gallery", "thumb_size", 200);
- module::set_var("gallery", "resize_size", 640);
- module::set_var("gallery", "default_locale", "en_US");
- module::set_var("gallery", "image_quality", 75);
+ $root = ORM::factory("item");
+ $root->type = "album";
+ $root->title = "Gallery";
+ $root->description = "";
+ $root->left = 1;
+ $root->right = 2;
+ $root->parent_id = 0;
+ $root->level = 1;
+ $root->thumb_dirty = 1;
+ $root->resize_dirty = 1;
+ $root->sort_column = "weight";
+ $root->sort_order = "ASC";
+ $root->save();
+ access::add_item($root);
- // Add rules for generating our thumbnails and resizes
- graphics::add_rule(
- "gallery", "thumb", "resize",
- array("width" => 200, "height" => 200, "master" => Image::AUTO),
- 100);
- graphics::add_rule(
- "gallery", "resize", "resize",
- array("width" => 640, "height" => 480, "master" => Image::AUTO),
- 100);
+ module::set_var("gallery", "active_site_theme", "default");
+ module::set_var("gallery", "active_admin_theme", "admin_default");
+ module::set_var("gallery", "page_size", 9);
+ module::set_var("gallery", "thumb_size", 200);
+ module::set_var("gallery", "resize_size", 640);
+ module::set_var("gallery", "default_locale", "en_US");
+ module::set_var("gallery", "image_quality", 75);
- // Instantiate default themes (site and admin)
- foreach (array("default", "admin_default") as $theme_name) {
- $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"),
- ArrayObject::ARRAY_AS_PROPS);
- $theme = ORM::factory("theme");
- $theme->name = $theme_name;
- $theme->version = $theme_info->version;
- $theme->save();
- }
+ // Add rules for generating our thumbnails and resizes
+ graphics::add_rule(
+ "gallery", "thumb", "resize",
+ array("width" => 200, "height" => 200, "master" => Image::AUTO),
+ 100);
+ graphics::add_rule(
+ "gallery", "resize", "resize",
+ array("width" => 640, "height" => 480, "master" => Image::AUTO),
+ 100);
- block_manager::add("dashboard_sidebar", "gallery", "block_adder");
- block_manager::add("dashboard_sidebar", "gallery", "stats");
- 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", "photo_stream");
- block_manager::add("dashboard_center", "gallery", "log_entries");
+ // Instantiate default themes (site and admin)
+ foreach (array("default", "admin_default") as $theme_name) {
+ $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"),
+ ArrayObject::ARRAY_AS_PROPS);
+ $theme = ORM::factory("theme");
+ $theme->name = $theme_name;
+ $theme->version = $theme_info->version;
+ $theme->save();
+ }
- module::set_version("gallery", $version = 1);
- module::set_var("gallery", "version", "3.0 beta 1");
- module::set_var("gallery", "choose_default_tookit", 1);
+ block_manager::add("dashboard_sidebar", "gallery", "block_adder");
+ block_manager::add("dashboard_sidebar", "gallery", "stats");
+ 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", "photo_stream");
+ block_manager::add("dashboard_center", "gallery", "log_entries");
- // @todo this string needs to be picked up by l10n_scanner
- module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
- }
+ module::set_var("gallery", "version", "3.0 pre beta 2 (git)");
+ module::set_var("gallery", "choose_default_tookit", 1);
+ module::set_var("gallery", "date_format", "Y-M-d");
+ module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
+ module::set_var("gallery", "time_format", "H:i:s");
+ module::set_var("gallery", "show_credits", 1);
+ // @todo this string needs to be picked up by l10n_scanner
+ module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
+ module::set_version("gallery", 3);
+ }
+ static function upgrade($version) {
if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
@@ -263,6 +260,11 @@ class gallery_installer {
module::set_var("gallery", "version", "3.0 pre beta 2 (git)");
module::set_version("gallery", $version = 2);
}
+
+ if ($version == 2) {
+ module::set_var("gallery", "show_credits", 1);
+ module::set_version("gallery", $version = 3);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php
index bb791c33..d0ffc584 100644
--- a/modules/gallery/helpers/gallery_quick.php
+++ b/modules/gallery/helpers/gallery_quick.php
@@ -83,19 +83,20 @@ class gallery_quick_Core {
"class" => "gDialogLink gButtonLink",
"icon" => "ui-icon-pencil",
"href" => url::site("quick/form_edit/$item->id?page_type=$page_type"));
+
if ($item->is_photo() && graphics::can("rotate")) {
$elements["left"][] =
(object)array(
"title" => t("Rotate 90 degrees counter clockwise"),
"class" => "gButtonLink",
"icon" => "ui-icon-rotate-ccw",
- "href" => url::site("quick/form_edit/$item->id/ccw?csrf=$csrf&?page_type=$page_type"));
+ "href" => url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type"));
$elements["left"][] =
(object)array(
"title" => t("Rotate 90 degrees clockwise"),
"class" => "gButtonLink",
"icon" => "ui-icon-rotate-cw",
- "href" => url::site("quick/form_edit/$item->id/cw?csrf=$csrf&page_type=$page_type"));
+ "href" => url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type"));
}
// Don't move photos from the photo page; we don't yet have a good way of redirecting after move
@@ -118,7 +119,7 @@ class gallery_quick_Core {
$elements["right"][] = (object)array(
"title" => $delete_title,
- "class" => "gButtonLink",
+ "class" => "gDialogLink gButtonLink",
"icon" => "ui-icon-trash",
"id" => "gQuickDelete",
"href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type"));
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index dea8e22c..0d483206 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -107,7 +107,7 @@ class module_Core {
/**
* Install a module. This will call <module>_installer::install(), which is responsible for
- * creating database tables, setting module variables and and calling module::set_version().
+ * creating database tables, setting module variables and calling module::set_version().
* Note that after installing, the module must be activated before it is available for use.
* @param string $module_name
*/
@@ -131,6 +131,38 @@ class module_Core {
}
/**
+ * Upgrade a module. This will call <module>_installer::upgrade(), which is responsible for
+ * modifying database tables, changing module variables and calling module::set_version().
+ * Note that after upgrading, the module must be activated before it is available for use.
+ * @param string $module_name
+ */
+ static function upgrade($module_name) {
+ $kohana_modules = Kohana::config("core.modules");
+ array_unshift($kohana_modules, MODPATH . $module_name);
+ Kohana::config_set("core.modules", $kohana_modules);
+
+ $version_before = module::get_version($module_name);
+ $installer_class = "{$module_name}_installer";
+ if (method_exists($installer_class, "upgrade")) {
+ call_user_func_array(array($installer_class, "upgrade"), array($version_before));
+ }
+ module::load_modules();
+
+ // Now the module is upgraded but inactive, so don't leave it in the active path
+ array_shift($kohana_modules);
+ Kohana::config_set("core.modules", $kohana_modules);
+
+ $version_after = module::get_version($module_name);
+ if ($version_before != $version_after) {
+ log::success(
+ "module", t("Upgraded module %module_name from %version_before to %version_after",
+ array("module_name" => $module_name,
+ "version_before" => $version_before,
+ "version_after" => $version_after)));
+ }
+ }
+
+ /**
* Activate an installed module. This will call <module>_installer::activate() which should take
* any steps to make sure that the module is ready for use. This will also activate any
* existing graphics rules for this module.
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index 0a43f25c..b46a2c14 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -55,6 +55,8 @@ class theme_Core {
->value(module::get_var("gallery", "header_text"));
$group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText")
->value(module::get_var("gallery", "footer_text"));
+ $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText")
+ ->checked(module::get_var("gallery", "show_credits"));
$group->submit("")->value(t("Save"));
return $form;
}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 44d79d5b..430119b5 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -378,13 +378,41 @@ class Item_Model extends ORM_MPTT {
* the first child in the album is at position 1.
*/
public function get_position($child_id) {
- $result = Database::instance()->query("
+ if ($this->sort_order == "DESC") {
+ $comp = ">";
+ } else {
+ $comp = "<";
+ }
+
+ $db = Database::instance();
+ $position = $db->query("
SELECT COUNT(*) AS position FROM {items}
- WHERE parent_id = {$this->id}
- AND {$this->sort_column} <= (SELECT {$this->sort_column}
- FROM {items} WHERE id = $child_id)");
+ WHERE parent_id = {$this->id}
+ AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}`
+ FROM {items} WHERE id = $child_id)
+ ORDER BY `{$this->sort_column}` {$this->sort_order}")->current()->position;
+
+ // 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.
+ $result = $db->query("
+ SELECT id FROM {items}
+ WHERE parent_id = {$this->id}
+ AND `{$this->sort_column}` = (SELECT `{$this->sort_column}`
+ FROM {items} WHERE id = $child_id)");
+ foreach ($result as $row) {
+ $position++;
+ if ($row->id == $child_id) {
+ break;
+ }
+ }
- return $result->current()->position;
+ return $position;
}
/**
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 3a5dd593..e5b1f809 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = Gallery 3
description = Gallery core application
-version = 2
+version = 3
diff --git a/modules/image_block/helpers/image_block_installer.php b/modules/image_block/helpers/image_block_installer.php
index 57279d05..7ea6a229 100644
--- a/modules/image_block/helpers/image_block_installer.php
+++ b/modules/image_block/helpers/image_block_installer.php
@@ -19,8 +19,6 @@
*/
class image_block_installer {
static function install() {
- if (module::get_version("image_block") == 0) {
- module::set_version("image_block", 1);
- }
+ module::set_version("image_block", 1);
}
}
diff --git a/modules/info/helpers/info_installer.php b/modules/info/helpers/info_installer.php
index 94fc22d0..e3e78b90 100644
--- a/modules/info/helpers/info_installer.php
+++ b/modules/info/helpers/info_installer.php
@@ -19,9 +19,6 @@
*/
class info_installer {
static function install() {
- $version = module::get_version("info");
- if ($version == 0) {
- module::set_version("info", 1);
- }
+ module::set_version("info", 1);
}
}
diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php
index ad10184b..3d450258 100644
--- a/modules/notification/helpers/notification_installer.php
+++ b/modules/notification/helpers/notification_installer.php
@@ -20,27 +20,23 @@
class notification_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("notification");
+ $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9) NOT NULL,
+ `user_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY (`item_id`, `user_id`),
+ UNIQUE KEY (`user_id`, `item_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} (
+ `id` int(9) NOT NULL auto_increment,
+ `email` varchar(128) NOT NULL,
+ `subject` varchar(255) NOT NULL,
+ `text` text,
+ PRIMARY KEY (`id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9) NOT NULL,
- `user_id` int(9) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`item_id`, `user_id`),
- UNIQUE KEY (`user_id`, `item_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} (
- `id` int(9) NOT NULL auto_increment,
- `email` varchar(128) NOT NULL,
- `subject` varchar(255) NOT NULL,
- `text` text,
- PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-
- module::set_version("notification", 1);
- }
+ module::set_version("notification", 1);
}
static function uninstall() {
diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php
index ea0f4e3d..22ca1793 100644
--- a/modules/organize/helpers/organize_installer.php
+++ b/modules/organize/helpers/organize_installer.php
@@ -19,9 +19,6 @@
*/
class organize_installer {
static function install() {
- $version = module::get_version("organize");
- if ($version == 0) {
- module::set_version("organize", 1);
- }
+ module::set_version("organize", 1);
}
}
diff --git a/modules/recaptcha/helpers/recaptcha_installer.php b/modules/recaptcha/helpers/recaptcha_installer.php
index f74bf558..12044a1b 100644
--- a/modules/recaptcha/helpers/recaptcha_installer.php
+++ b/modules/recaptcha/helpers/recaptcha_installer.php
@@ -19,10 +19,7 @@
*/
class recaptcha_installer {
static function install() {
- $version = module::get_version("recaptcha");
- if ($version == 0) {
- module::set_version("recaptcha", 1);
- }
+ module::set_version("recaptcha", 1);
}
static function activate() {
diff --git a/modules/rss/helpers/rss_installer.php b/modules/rss/helpers/rss_installer.php
index 2beafb33..7766fdfa 100644
--- a/modules/rss/helpers/rss_installer.php
+++ b/modules/rss/helpers/rss_installer.php
@@ -19,9 +19,6 @@
*/
class rss_installer {
static function install() {
- $version = module::get_version("rss");
- if ($version == 0) {
- module::set_version("rss", 1);
- }
+ module::set_version("rss", 1);
}
}
diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php
index ed4a3a90..cd253be4 100644
--- a/modules/search/helpers/search_installer.php
+++ b/modules/search/helpers/search_installer.php
@@ -19,20 +19,17 @@
*/
class search_installer {
static function install() {
- $version = module::get_version("search");
$db = Database::instance();
- if ($version == 0) {
- $db->query("CREATE TABLE {search_records} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9),
- `dirty` boolean default 1,
- `data` LONGTEXT default NULL,
- PRIMARY KEY (`id`),
- KEY(`item_id`),
- FULLTEXT INDEX (`data`))
- ENGINE=MyISAM DEFAULT CHARSET=utf8;");
- module::set_version("search", 1);
- }
+ $db->query("CREATE TABLE {search_records} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9),
+ `dirty` boolean default 1,
+ `data` LONGTEXT default NULL,
+ PRIMARY KEY (`id`),
+ KEY(`item_id`),
+ FULLTEXT INDEX (`data`))
+ ENGINE=MyISAM DEFAULT CHARSET=utf8;");
+ module::set_version("search", 1);
}
static function activate() {
diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php
index f8773a2e..c9d92e69 100644
--- a/modules/server_add/helpers/server_add_installer.php
+++ b/modules/server_add/helpers/server_add_installer.php
@@ -19,11 +19,7 @@
*/
class server_add_installer {
static function install() {
- $db = Database::instance();
- $version = module::get_version("server_add");
- if ($version == 0) {
- module::set_version("server_add", 1);
- }
+ module::set_version("server_add", 1);
server_add::check_config();
}
diff --git a/modules/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php
index b46f5471..cd1c6e05 100644
--- a/modules/slideshow/helpers/slideshow_installer.php
+++ b/modules/slideshow/helpers/slideshow_installer.php
@@ -19,10 +19,7 @@
*/
class slideshow_installer {
static function install() {
- $version = module::get_version("slideshow");
- if ($version == 0) {
- module::set_version("slideshow", 1);
- }
+ module::set_version("slideshow", 1);
}
static function deactivate() {
diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php
index 07544c54..3c16e3f3 100644
--- a/modules/tag/helpers/tag_installer.php
+++ b/modules/tag/helpers/tag_installer.php
@@ -20,26 +20,23 @@
class tag_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("tag");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {tags} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(64) NOT NULL,
- `count` int(10) unsigned NOT NULL DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {tags} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(64) NOT NULL,
+ `count` int(10) unsigned NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS {items_tags} (
- `id` int(9) NOT NULL auto_increment,
- `item_id` int(9) NOT NULL,
- `tag_id` int(9) NOT NULL,
- PRIMARY KEY (`id`),
- KEY(`tag_id`, `id`),
- KEY(`item_id`, `id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- module::set_version("tag", 1);
- }
+ $db->query("CREATE TABLE IF NOT EXISTS {items_tags} (
+ `id` int(9) NOT NULL auto_increment,
+ `item_id` int(9) NOT NULL,
+ `tag_id` int(9) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY(`tag_id`, `id`),
+ KEY(`item_id`, `id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ module::set_version("tag", 1);
}
static function uninstall() {
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index 68868fc1..1959d038 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -20,70 +20,66 @@
class user_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("user");
+ $db->query("CREATE TABLE IF NOT EXISTS {users} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(32) NOT NULL,
+ `full_name` varchar(255) NOT NULL,
+ `password` varchar(64) NOT NULL,
+ `login_count` int(10) unsigned NOT NULL DEFAULT 0,
+ `last_login` int(10) unsigned NOT NULL DEFAULT 0,
+ `email` varchar(64) default NULL,
+ `admin` BOOLEAN default 0,
+ `guest` BOOLEAN default 0,
+ `hash` char(32) default NULL,
+ `url` varchar(255) default NULL,
+ `locale` char(10) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`hash`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {users} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(32) NOT NULL,
- `full_name` varchar(255) NOT NULL,
- `password` varchar(64) NOT NULL,
- `login_count` int(10) unsigned NOT NULL DEFAULT 0,
- `last_login` int(10) unsigned NOT NULL DEFAULT 0,
- `email` varchar(64) default NULL,
- `admin` BOOLEAN default 0,
- `guest` BOOLEAN default 0,
- `hash` char(32) default NULL,
- `url` varchar(255) default NULL,
- `locale` char(10) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`hash`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {groups} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` char(64) default NULL,
+ `special` BOOLEAN default 0,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS {groups} (
- `id` int(9) NOT NULL auto_increment,
- `name` char(64) default NULL,
- `special` BOOLEAN default 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (
+ `group_id` int(9) NOT NULL,
+ `user_id` int(9) NOT NULL,
+ PRIMARY KEY (`group_id`, `user_id`),
+ UNIQUE KEY(`user_id`, `group_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (
- `group_id` int(9) NOT NULL,
- `user_id` int(9) NOT NULL,
- PRIMARY KEY (`group_id`, `user_id`),
- UNIQUE KEY(`user_id`, `group_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $everybody = group::create("Everybody");
+ $everybody->special = true;
+ $everybody->save();
- $everybody = group::create("Everybody");
- $everybody->special = true;
- $everybody->save();
+ $registered = group::create("Registered Users");
+ $registered->special = true;
+ $registered->save();
- $registered = group::create("Registered Users");
- $registered->special = true;
- $registered->save();
+ $guest = user::create("guest", "Guest User", "");
+ $guest->guest = true;
+ $guest->remove($registered);
+ $guest->save();
- $guest = user::create("guest", "Guest User", "");
- $guest->guest = true;
- $guest->remove($registered);
- $guest->save();
+ $admin = user::create("admin", "Gallery Administrator", "admin");
+ $admin->admin = true;
+ $admin->save();
- $admin = user::create("admin", "Gallery Administrator", "admin");
- $admin->admin = true;
- $admin->save();
+ // Let the admin own everything
+ $db->update("items", array("owner_id" => $admin->id), array("owner_id" => "IS NULL"));
+ module::set_version("user", 1);
- // Let the admin own everything
- $db->update("items", array("owner_id" => $admin->id), array("owner_id" => "IS NULL"));
- module::set_version("user", 1);
+ $root = ORM::factory("item", 1);
+ access::allow($everybody, "view", $root);
+ access::allow($everybody, "view_full", $root);
- $root = ORM::factory("item", 1);
- access::allow($everybody, "view", $root);
- access::allow($everybody, "view_full", $root);
-
- access::allow($registered, "view", $root);
- access::allow($registered, "view_full", $root);
- }
+ access::allow($registered, "view", $root);
+ access::allow($registered, "view_full", $root);
}
static function uninstall() {
diff --git a/modules/watermark/helpers/watermark_installer.php b/modules/watermark/helpers/watermark_installer.php
index ed4265ec..705b89d4 100644
--- a/modules/watermark/helpers/watermark_installer.php
+++ b/modules/watermark/helpers/watermark_installer.php
@@ -20,23 +20,20 @@
class watermark_installer {
static function install() {
$db = Database::instance();
- $version = module::get_version("watermark");
- if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS {watermarks} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(32) NOT NULL,
- `width` int(9) NOT NULL,
- `height` int(9) NOT NULL,
- `active` boolean default 0,
- `position` boolean default 0,
- `mime_type` varchar(64) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE IF NOT EXISTS {watermarks} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(32) NOT NULL,
+ `width` int(9) NOT NULL,
+ `height` int(9) NOT NULL,
+ `active` boolean default 0,
+ `position` boolean default 0,
+ `mime_type` varchar(64) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- @mkdir(VARPATH . "modules/watermark");
- module::set_version("watermark", 1);
- }
+ @mkdir(VARPATH . "modules/watermark");
+ module::set_version("watermark", 1);
}
static function uninstall() {
diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php
index 799d94c1..7e6913df 100644
--- a/themes/default/views/album.html.php
+++ b/themes/default/views/album.html.php
@@ -19,7 +19,7 @@
<?= $child->thumb_img(array("class" => "gThumbnail")) ?>
</a>
<?= $theme->thumb_bottom($child) ?>
- <h2><a href="<?= $child->url() ?>"><?= p::clean($child->title) ?></a></h2>
+ <h2><span></span><a href="<?= $child->url() ?>"><?= p::clean($child->title) ?></a></h2>
<ul class="gMetadata">
<?= $theme->thumb_info($child) ?>
</ul>
diff --git a/themes/default/views/footer.html.php b/themes/default/views/footer.html.php
index d7111922..040a4062 100644
--- a/themes/default/views/footer.html.php
+++ b/themes/default/views/footer.html.php
@@ -2,7 +2,9 @@
<?= $theme->footer() ?>
<? if ($footer_text = module::get_var("gallery", "footer_text")): ?>
<?= $footer_text ?>
-<? else: ?>
+<? endif ?>
+
+<? if (module::get_var("gallery", "show_credits")): ?>
<ul id="gCredits">
<?= $theme->credits() ?>
</ul>