本文整理汇总了PHP中module::set_version方法的典型用法代码示例。如果您正苦于以下问题:PHP module::set_version方法的具体用法?PHP module::set_version怎么用?PHP module::set_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module
的用法示例。
在下文中一共展示了module::set_version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
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");
}
}
示例2: upgrade
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);
}
}
示例3: install
static function install()
{
$version = module::get_version("akismet");
if ($version == 0) {
module::set_version("akismet", 1);
}
}
示例4: initialize
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";
$admin->email = "unknown@unknown.com";
$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);
}
示例5: upgrade
static function upgrade($version)
{
if ($version == 1) {
block_manager::add("site.sidebar", "image_block", "random_image");
module::set_version("image_block", 2);
}
}
示例6: install
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);
}
示例7: install
static function install()
{
module::set_version("gwtorganise", 1);
upload_configuration::setResize(false);
upload_configuration::setMaxWidth(500);
upload_configuration::setMaxHeight(400);
}
示例8: upgrade
static function upgrade($version)
{
if ($version == 1) {
module::set_var("date_tag", "template", "F, Y");
}
module::set_version("date_tag", $version = 2);
}
示例9: upgrade
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");
}
示例10: install
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);
}
示例11: install
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");
}
示例12: upgrade
static function upgrade($version)
{
if ($version == 2) {
access::register_permission("downloadalbum", "Download album");
module::set_version("downloadalbum", 3);
}
}
示例13: install
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");
}
示例14: install
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();
}
示例15: install
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);
}
}