static function install() { module::set_version("auto_date", 1); if (!module::get_var("auto_date", "template")) { module::set_var("auto_date", "template", "%Y%m%d_%H%M%S"); } }
static function upgrade($version) { $db = Database::instance(); if ($version == 1) { $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); module::set_version("comment", $version = 2); } if ($version == 2) { module::set_var("comment", "access_permissions", "everybody"); module::set_version("comment", $version = 3); } if ($version == 3) { // 40 bytes for server_remote_addr is enough to swallow the longest // representation of an IPv6 addy. // // 255 bytes for server_remote_host is enough to swallow the longest // legit DNS entry, with a few bytes to spare. $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); module::set_version("comment", $version = 4); } if ($version == 4) { module::set_var("comment", "rss_visible", "all"); module::set_version("comment", $version = 5); } // In version 5 we accidentally set the installer variable to rss_available when it should // have been rss_visible. Migrate it over now, if necessary. if ($version == 5) { if (!module::get_var("comment", "rss_visible")) { module::set_var("comment", "rss_visible", module::get_var("comment", "rss_available")); } module::clear_var("comment", "rss_available"); module::set_version("comment", $version = 6); } }
static function install() { $version = module::get_version("akismet"); if ($version == 0) { module::set_version("akismet", 1); } }
static function install() { $version = module::get_version("slideshow"); if ($version == 0) { module::set_version("slideshow", 1); } }
static function install() { $version = module::get_version("recaptcha"); if ($version == 0) { module::set_version("recaptcha", 1); } }
static function initialize() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {users} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `full_name` varchar(255) NOT NULL,\n `password` varchar(64) NOT NULL,\n `login_count` int(10) unsigned NOT NULL DEFAULT 0,\n `last_login` int(10) unsigned NOT NULL DEFAULT 0,\n `email` varchar(64) default NULL,\n `admin` BOOLEAN default 0,\n `guest` BOOLEAN default 0,\n `hash` char(32) default NULL,\n `url` varchar(255) default NULL,\n `locale` char(10) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`hash`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups} (\n `id` int(9) NOT NULL auto_increment,\n `name` char(64) default NULL,\n `special` BOOLEAN default 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (\n `group_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`group_id`, `user_id`),\n UNIQUE KEY(`user_id`, `group_id`))\n DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); $everybody->name = "Everybody"; $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); $registered->name = "Registered Users"; $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; $guest->full_name = "Guest User"; $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; $admin->full_name = "Gallery Administrator"; $admin->password = "******"; $admin->email = "*****@*****.**"; $admin->admin = true; $admin->save(); $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); module::set_version("user", 2); module::set_var("user", "mininum_password_length", 5); }
static function upgrade($version) { if ($version == 1) { block_manager::add("site.sidebar", "image_block", "random_image"); module::set_version("image_block", 2); } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {hidden_items} (\n `item_id` int(9) NOT NULL,\n PRIMARY KEY (`item_id`))\n DEFAULT CHARSET=utf8;"); module::set_var("hide", "access_permissions", hide::NONE); module::set_version("hide", 1); }
static function install() { module::set_version("gwtorganise", 1); upload_configuration::setResize(false); upload_configuration::setMaxWidth(500); upload_configuration::setMaxHeight(400); }
static function upgrade($version) { if ($version == 1) { module::set_var("date_tag", "template", "F, Y"); } module::set_version("date_tag", $version = 2); }
static function upgrade($version) { log::info("aws_s3", "Commencing module upgrade (" . $version . ")"); switch ($version) { case 0: log::info("aws_s3", "Installing version 1"); @mkdir(VARPATH . "modules/aws_s3"); @mkdir(VARPATH . "modules/aws_s3/log"); // installation's unique identifier - allows multiple g3's pointing to the same s3 bucket. if (!module::get_var("aws_s3", "g3id")) { module::set_var("aws_s3", "g3id", md5(time())); } module::set_var("aws_s3", "synced", false); module::set_var("aws_s3", "enabled", false); module::set_var("aws_s3", "access_key", ""); module::set_var("aws_s3", "secret_key", ""); module::set_var("aws_s3", "bucket_name", ""); module::set_version("aws_s3", 1); case 1: log::info("aws_s3", "Upgrading to version 2"); $db = Database::instance(); $db->query("CREATE TABLE {aws_s3_meta} (\n `item_id` int(9) NOT NULL,\n `item_hash` varchar(32) NOT NULL DEFAULT '',\n `thumb_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `resize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `fullsize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n `local_deleted` smallint(1) NOT NULL DEFAULT 0,\n PRIMARY KEY (`item_id`)\n ) DEFAULT CHARSET=utf8;"); module::set_var("aws_s3", "upload_thumbs", true); module::set_var("aws_s3", "upload_resizes", true); module::set_var("aws_s3", "upload_fullsizes", true); module::set_var("aws_s3", "s3_storage_only", false); if (module::get_var("aws_s3", "synced")) { // v1 has already synced this installation to s3. mark all the items with the relevant meta data $items = ORM::factory("item")->find_all(); foreach ($items as $item) { aws_s3::log("Updating S3 meta for item ID: " . $item->id); $item->s3_thumb_uploaded = true; if (!$item->is_album()) { $item->s3_resize_uploaded = true; $item->s3_fullsize_uploaded = true; } $item->s3_local_deleted = false; $item->s3_item_hash = md5($item->relative_path()); $item->save_s3_meta(); } } else { // check various states after upgrade from v1.. if (module::get_var("aws_s3", "access_key") != "" && module::get_var("aws_s3", "secret_key") != "" && module::get_var("aws_s3", "bucket_name") != "" && aws_s3::validate_access_details(module::get_var("aws_s3", "access_key"), module::get_var("aws_s3", "secret_key"), module::get_var("aws_s3", "bucket_name"))) { // details are correct but hasn't been synced. if (aws_s3::can_schedule()) { // i can schedule this task aws_s3::schedule_full_sync2(); site_status::warning("Your site has been scheduled for full Amazon S3 re-synchronisation. This message will clear when this has been completed.", "aws_s3_not_synced"); } else { // i CAN'T schedule it.. site_status::warning(t('Your site has not been synchronised to Amazon S3. Until it has, your server will continue to serve image content to your visitors.<br />Click <a href="%url" class="g-dialog-link">here</a> to start the synchronisation task.', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::manual_sync?csrf=__CSRF__")))), "aws_s3_not_synced"); } } else { site_status::warning(t('Amazon S3 module needs configuration. Click <a href="%url">here</a> to go to the configuration page.', array("url" => html::mark_clean(url::site("admin/aws_s3")))), "aws_s3_not_configured"); } } module::set_version("aws_s3", 2); } log::info("aws_s3", "Module upgrade complete"); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {tags} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(64) NOT NULL,\n `count` int(10) unsigned NOT NULL DEFAULT 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {items_tags} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `tag_id` int(9) NOT NULL,\n PRIMARY KEY (`id`),\n KEY(`tag_id`, `id`),\n KEY(`item_id`, `id`))\n DEFAULT CHARSET=utf8;"); module::set_version("tag", 1); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE {embedded_videos} (\n\t\t\t\t\t\t`id` int(9) NOT NULL auto_increment,\n\t\t\t\t\t\t`embed_code` varchar(2048) DEFAULT NULL,\n\t\t\t\t\t\t`source` varchar(64) DEFAULT NULL,\n\t\t\t\t\t\t`item_id` int(9) NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\t\t\tKEY (`item_id`, `id`))\n\t\t\t\t\t\tDEFAULT CHARSET=utf8;"); module::set_version("embed_videos", 2); //exec("cd modules/gallery/controllers/; ln -s ../../embed/controllers/embeds.php embeds.php"); }
static function upgrade($version) { if ($version == 2) { access::register_permission("downloadalbum", "Download album"); module::set_version("downloadalbum", 3); } }
static function install() { $defaults = array('jpg' => '1', 'png' => '2', 'gif' => '1'); foreach ($defaults as $type => $optlevel) { // set default path as the pre-compiled versions in the lib module::set_var("image_optimizer", "path_" . $type, MODPATH . "image_optimizer/lib/" . image_optimizer::tool_name($type)); // check config status (also sets configstatus_ variables and ensures that the permissions are set correctly) image_optimizer::tool_status($type); // set default optimization levels module::set_var("image_optimizer", "optlevel_thumb_" . $type, $optlevel); module::set_var("image_optimizer", "optlevel_resize_" . $type, $optlevel); } module::set_var("image_optimizer", "rotate_jpg", true); module::set_var("image_optimizer", "enable_thumb", true); module::set_var("image_optimizer", "enable_resize", true); module::set_var("image_optimizer", "update_mode_thumb", false); module::set_var("image_optimizer", "update_mode_resize", false); module::set_var("image_optimizer", "metastrip_thumb", true); module::set_var("image_optimizer", "convert_thumb_png", "jpg"); module::set_var("image_optimizer", "convert_resize_png", false); module::set_var("image_optimizer", "convert_thumb_gif", "jpg"); module::set_var("image_optimizer", "convert_resize_gif", false); module::set_var("image_optimizer", "metastrip_resize", false); module::set_var("image_optimizer", "progressive_thumb", false); module::set_var("image_optimizer", "progressive_resize", true); module::set_version("image_optimizer", 1); image_optimizer::add_image_optimizer_rule("thumb"); image_optimizer::add_image_optimizer_rule("resize"); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY (`item_id`, `user_id`),\n UNIQUE KEY (`user_id`, `item_id`))\n DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {pending_notifications} (\n `id` int(9) NOT NULL auto_increment,\n `email` varchar(128) NOT NULL,\n `subject` varchar(255) NOT NULL,\n `text` text,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); module::set_version("notification", 1); }
static function install() { $version = module::get_version("info"); if ($version == 0) { module::set_version("info", 1); } }
static function install() { Database::instance()->query("CREATE TABLE {twitter_tweets} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `item_id` int(9) NOT NULL,\n `sent` int(9) NULL,\n `twitter_id` decimal(20,0) NULL,\n `tweet` varchar(255) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); Database::instance()->query("CREATE TABLE {twitter_users} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `oauth_token` varchar(64) NOT NULL,\n `oauth_token_secret` varchar(64) NOT NULL,\n `screen_name` varchar(16) NOT NULL,\n `twitter_user_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); module::set_version("twitter", 1); twitter::reset_default_tweet(); }
static function install() { $db = Database::instance(); $version = module::get_version("user"); if ($version == 0) { $db->query("CREATE TABLE IF NOT EXISTS {users} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `full_name` varchar(255) NOT NULL,\n `password` varchar(64) NOT NULL,\n `login_count` int(10) unsigned NOT NULL DEFAULT 0,\n `last_login` int(10) unsigned NOT NULL DEFAULT 0,\n `email` varchar(64) default NULL,\n `admin` BOOLEAN default 0,\n `guest` BOOLEAN default 0,\n `hash` char(32) default NULL,\n `url` varchar(255) default NULL,\n `locale` char(10) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`hash`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups} (\n `id` int(9) NOT NULL auto_increment,\n `name` char(64) default NULL,\n `special` BOOLEAN default 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (\n `group_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`group_id`, `user_id`),\n UNIQUE KEY(`user_id`, `group_id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $everybody = group::create("Everybody"); $everybody->special = true; $everybody->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(); $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); $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); } }
static function install() { $version = module::get_version("organize"); if ($version == 0) { module::set_version("organize", 1); } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {g2_maps} (\n `id` int(9) NOT NULL auto_increment,\n `g2_id` int(9) NOT NULL,\n `g3_id` int(9) NOT NULL,\n PRIMARY KEY (`id`),\n KEY (`g2_id`))\n DEFAULT CHARSET=utf8;"); module::set_version("g2_import", 1); mkdir(VARPATH . "modules/g2_import"); }
static function upgrade($version) { if ($version == 2) { module::set_var("tagsmap", "restrict_maps", "0"); module::set_version("tagsmap", 3); } }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {watermarks} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `width` int(9) NOT NULL,\n `height` int(9) NOT NULL,\n `active` boolean default 0,\n `position` boolean default 0,\n `mime_type` varchar(64) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;"); @mkdir(VARPATH . "modules/watermark"); module::set_version("watermark", 1); }
static function upgrade($version) { // Set the default value for this module's behavior. module::set_var("albumpassword", "hideonly", true); // Set the module's version number. module::set_version("albumpassword", 2); }
static function install() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {item_links} (\n `id` int(9) NOT NULL auto_increment,\n `item_id` int(9) NOT NULL,\n `url` text default NULL,\n PRIMARY KEY (`id`),\n KEY(`item_id`, `id`))\n DEFAULT CHARSET=utf8;"); // Set the module's version number. module::set_version("item_links", 1); }
static function upgrade($version) { $db = Database::instance(); if ($version == 1) { // fix for allowing decimel place in money $db->query("ALTER TABLE {products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default 0;"); $db->query("ALTER TABLE {item_products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default -1;"); // postage bands $db->query("ALTER TABLE {products} ADD COLUMN `postage_band_id` int(9) default 1"); $db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (\n `id` int(9) NOT NULL auto_increment,\n `name` TEXT NOT NULL,\n `flat_rate` DECIMAL(10,2) default 0,\n `per_item` DECIMAL(10,2) default 0,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); postage_band::create("No Postage", 0, 0); module::set_version("basket", $version = 2); } if ($version == 2) { $db->query("CREATE TABLE IF NOT EXISTS {orders} (\n `id` int(9) NOT NULL auto_increment,\n `text` TEXT NOT NULL,\n PRIMARY KEY (`id`))\n ENGINE=InnoDB DEFAULT CHARSET=utf8;"); basket::setPaymentDetails("<p>Use the following options to pay for this order.</p>\n<p>Send a chequre to..</p>\n<p>Visit the shop..</p>\n<p>By using internet banking..</p>"); basket::setOrderPrefix("ORDER"); basket::setOrderCompletePage("<p>Your order number is %order_number. To pay for this order please either:</p>\n<p> - Send a cheque for %total_cost to with reference %order_number..</p>\n<p> - Visit the shop and quote the order %order_number..</p>\n<p> - Transfer %total_cost using internet banking with reference %order_number..</p>\n<p>Order will be processed as soon as payment is received. You should receive an e-mail with your order details shortly.</p>"); basket::setOrderCompleteEmail("Hi %name,\n\nThank you for your order the order details are below. To pay for this order please either:\n\n- Send a cheque for %total_cost to with reference %order_number..\n- Visit the shop and quote the order %order_number..\n- Transfer %total_cost using internet banking with reference %order_number..\n\nOrder will be processed as soon as payment is received. For order pick-ups please visit..\n\nOrder Details\n-------------\n%order_details\n\nThanks"); basket::setOrderCompleteEmailSubject("Photography Order %order_number"); module::set_version("basket", $version = 3); } if ($version == 3) { $db->query("ALTER TABLE {orders} ADD COLUMN `status` int(9) DEFAULT 0;"); $db->query("CREATE TABLE IF NOT EXISTS {ipn_messages} (\n `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n `date` int(11) NOT NULL,\n `key` varchar(20) NOT NULL,\n `txn_id` varchar(20) NOT NULL,\n `status` varchar(20) NOT NULL,\n `success` bool default false,\n `text` text,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("basket", $version = 4); } if ($version == 4) { $db->query("ALTER TABLE {orders} ADD COLUMN `name` varchar(1024);"); $db->query("ALTER TABLE {orders} ADD COLUMN `email` varchar(1024);"); $db->query("ALTER TABLE {orders} ADD COLUMN `method` int(9) DEFAULT 0;"); $db->query("ALTER TABLE {orders} ADD COLUMN `cost` DECIMAL(10,2) default 0"); module::set_version("basket", $version = 5); } }
static function upgrade($version) { if ($version == 1) { Database::instance()->query("ALTER TABLE `picasa_faces` ADD `user_id` int(9) NOT NULL"); module::set_version("picasa_faces", 2); } }
static function install() { $version = module::get_version("moduleupdates"); if ($version == 0) { module::set_version("moduleupdates", 1); } }
static function upgrade($version) { if ($version == 1) { module::set_var("slideshow", "max_scale", 0); module::set_version("slideshow", $version = 2); } }
static function install() { $version = module::get_version("media_rss"); if ($version == 0) { module::set_version("media_rss", 1); } }