From 6029c2bf7a3b57289e16545b98ed2a5aa3f71be2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 19 Jun 2009 12:03:35 -0700 Subject: Catch exceptions from tag::add() that can be caused by character encoding issues resulting from embedded keywords in encodings we can't decipher. This can lead to weird truncation issues which in turn can lead to multiple tags getting truncated to the same value in MySQL which leads to mysql complaining that we're adding a duplicate tag. --- modules/tag/helpers/tag_event.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/tag/helpers') diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 735422b5..946326c0 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -45,7 +45,12 @@ class tag_event_Core { // @todo figure out how to read the keywords from xmp foreach(array_keys($tags) as $tag) { - tag::add($photo, $tag); + try { + tag::add($photo, $tag); + } catch (Exception $e) { + Kohana::log("error", "Error adding tag: $tag\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } } return; -- cgit v1.2.3 From bfca0c79030d5b8a18e41e8b80f5560ebaf6f202 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Jun 2009 12:00:49 -0700 Subject: Refactor the install/upgrade code to be more flexible. Add xxx_installer::upgrade($version) method so that upgrade stanzas are separate from install stanzas. In the old code, to do an upgrade meant that you had to re-evolve everything from the initial install because we'd step through each version's changes. But what we really want is for the initial install to start off in the perfect initial state, and the upgrades to do the work behind the scenes. So now the install() function gets things set up properly the first time, and the upgrade() function does any work to catch you up to the latest code. See gallery_installer.php for a good example. --- installer/install.sql | 2 +- modules/akismet/helpers/akismet_installer.php | 5 +- modules/comment/helpers/comment_installer.php | 60 ++- modules/exif/helpers/exif_installer.php | 26 +- modules/g2_import/helpers/g2_import_installer.php | 21 +- modules/gallery/controllers/admin_modules.php | 6 +- modules/gallery/controllers/upgrader.php | 6 +- modules/gallery/helpers/gallery_installer.php | 426 ++++++++++----------- modules/gallery/helpers/module.php | 34 +- .../image_block/helpers/image_block_installer.php | 4 +- modules/info/helpers/info_installer.php | 5 +- .../helpers/notification_installer.php | 36 +- modules/organize/helpers/organize_installer.php | 5 +- modules/recaptcha/helpers/recaptcha_installer.php | 5 +- modules/rss/helpers/rss_installer.php | 5 +- modules/search/helpers/search_installer.php | 23 +- .../server_add/helpers/server_add_installer.php | 6 +- modules/slideshow/helpers/slideshow_installer.php | 5 +- modules/tag/helpers/tag_installer.php | 35 +- modules/user/helpers/user_installer.php | 106 +++-- modules/watermark/helpers/watermark_installer.php | 29 +- 21 files changed, 415 insertions(+), 435 deletions(-) (limited to 'modules/tag/helpers') diff --git a/installer/install.sql b/installer/install.sql index 432aee64..91108460 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 Gallery %version'),(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 Gallery %version'),(24,'comment','spam_caught','0'); 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 b1cfcdc0..2bfb7330 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -20,39 +20,35 @@ 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` char(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` char(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", 1); - } + block_manager::add("dashboard_center", "comment", "recent_comments"); + module::set_var("comment", "spam_caught", 0); + module::set_version("comment", 1); } static function uninstall() { 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/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/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/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_installer.php b/modules/gallery/helpers/gallery_installer.php index cd871c17..4f6342b4 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -18,244 +18,240 @@ * 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_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_intents} ( + `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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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 {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;"); - foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { - @mkdir(VARPATH . $dir); - } - - 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 Gallery %version"); - } + 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"); + // @todo this string needs to be picked up by l10n_scanner + module::set_var("gallery", "credits", "Powered by Gallery %version"); + module::set_version("gallery", 2); + } + 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"); 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 _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 */ @@ -130,6 +130,38 @@ class module_Core { "module", t("Installed module %module_name", array("module_name" => $module_name))); } + /** + * Upgrade a module. This will call _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 _installer::activate() which should take * any steps to make sure that the module is ready for use. This will also activate any 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() { -- cgit v1.2.3 From 5e83ebd6d0e1eccb1a865dc6c5fe2ef712bd421b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 28 Jun 2009 16:50:55 -0700 Subject: Use $theme->script() method to render module javascript files --- modules/digibug/helpers/digibug_theme.php | 2 +- modules/organize/helpers/organize_theme.php | 8 +++----- modules/server_add/helpers/server_add_theme.php | 6 +++--- modules/tag/helpers/tag_theme.php | 7 +++++-- modules/tag/views/admin_tags.html.php | 1 - modules/user/helpers/user_theme.php | 5 +---- 6 files changed, 13 insertions(+), 16 deletions(-) (limited to 'modules/tag/helpers') diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 3b5be3b3..f94d07c6 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -19,6 +19,6 @@ */ class digibug_theme_Core { static function head($theme) { - return html::script("modules/digibug/js/digibug.js"); + $theme->script("modules/digibug/js/digibug.js"); } } diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index 27f8cdb2..cddc48b6 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -20,11 +20,9 @@ class organize_theme { static function head($theme) { // @tdo remove the addition css and organize.js (just here to test) - $script[] = html::script("modules/organize/js/organize_init.js"); - $script[] = html::script("modules/organize/js/organize.js"); - $script[] = "script("modules/organize/js/organize_init.js"); + $theme->script("modules/organize/js/organize.js"); + return ""; - return implode("\n", $script); - //return html::script("modules/organize/js/organize_init.js"); } } diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php index 4f307a2e..3df57ee4 100644 --- a/modules/server_add/helpers/server_add_theme.php +++ b/modules/server_add/helpers/server_add_theme.php @@ -20,7 +20,7 @@ class server_add_theme_Core { static function head($theme) { if (user::active()->admin) { - return html::script("modules/server_add/js/server_add.js"); + $theme->script("modules/server_add/js/server_add.js"); } } @@ -33,8 +33,8 @@ class server_add_theme_Core { $csrf = access::csrf_token(); $head[] = ""; - $head[] = html::script("lib/jquery.autocomplete.js"); - $head[] = html::script("modules/server_add/js/admin.js"); + $theme->script("lib/jquery.autocomplete.js"); + $theme->script("modules/server_add/js/admin.js"); } return implode("\n", $head); diff --git a/modules/tag/helpers/tag_theme.php b/modules/tag/helpers/tag_theme.php index a32d71b6..b48ad178 100644 --- a/modules/tag/helpers/tag_theme.php +++ b/modules/tag/helpers/tag_theme.php @@ -19,8 +19,11 @@ */ class tag_theme_Core { static function head($theme) { - $url = url::file("modules/tag/js/tag.js"); - return ""; + $theme->script("modules/tag/js/tag.js"); + } + + static function admin_head($theme) { + $theme->script("modules/tag/js/tag.js"); } static function sidebar_blocks($theme) { diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php index 21661c48..7d201da7 100644 --- a/modules/tag/views/admin_tags.html.php +++ b/modules/tag/views/admin_tags.html.php @@ -1,5 +1,4 @@ -