public static function convertTimestamps($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/convert_timestamps'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:convert_timestamps'); $upgrade->description = elgg_echo('admin:upgrades:convert_timestamps:description'); $upgrade->save(); } elgg_set_ignore_access($ia); }
/** * Listen to the upgrade event to check if there is any old content with unsent tag notifications * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $entity supplied entity/params * * @return void */ public static function markOldTagsAsSent($event, $type, $entity) { $path = 'admin/upgrades/set_tag_notifications_sent'; $upgrade = new \ElggUpgrade(); // ignore acces while checking for existence $ia = elgg_set_ignore_access(true); // already registered? if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->title = elgg_echo('admin:upgrades:set_tag_notifications_sent'); $upgrade->description = elgg_echo('admin:upgrades:set_tag_notifications_sent:description'); $upgrade->setPath($path); $upgrade->save(); } // restore access elgg_set_ignore_access($ia); }
/** * Register an upgrade class to move the blog icons * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied object/params * * @return void */ public static function moveBlogIcons($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/blog_tools_move_icons'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:blog_tools_move_icons'); $upgrade->description = elgg_echo('admin:upgrades:blog_tools_move_icons:description'); $upgrade->save(); // check for blog with icons // eg. if non found, no upgrade needed $count = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'blog', 'metadata_name' => 'icontime', 'count' => true]); if (empty($count)) { $upgrade->setCompleted(); } } // restore access elgg_set_ignore_access($ia); }
/** * Listen to the upgrade event to make sure upgrades can be run * * @param string $event the name of the event * @param string $type the type of the event * @param null $object nothing * * @return void */ function thewire_tools_upgrade_system_event_handler($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array("type" => "user", "plugin_id" => "thewire_tools", "plugin_user_setting_name" => "notify_mention", "count" => true); $count = elgg_get_entities_from_plugin_user_settings($options); if ($count) { $path = "admin/upgrades/thewire_tools_mentions"; $upgrade = new ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = "TheWire Tools mentions upgrade"; $upgrade->description = "The way mention notifications are handled has changed. Run this script to make sure all settings are migrated."; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to the upgrade event * * @param string $event name of the event * @param string $type type of the event * @param null $object supplied object * * @return void */ function content_subscriptions_upgrade_system_handler($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array("type" => "user", "relationship" => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, "inverse_relationship" => true, "count" => true); $count = elgg_get_entities_from_relationship($options); if ($count) { $path = "admin/upgrades/content_subscriptions"; $upgrade = new ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = "Content Subscription upgrade"; $upgrade->description = "The way content subscriptions are handled has changed. Run this script to make sure all content subscriptions are migrated."; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to the upgrade event, to register a script * * @param string $event name of the event * @param string $type type of the event * @param null $object supplied object * * @return void */ public static function registerScript($event, $type, $object) { // Upgrade also possible hidden entities. This feature get run // by an administrator so there's no need to ignore access. $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); // register an upgrade script $options = array('type' => 'user', 'relationship' => CONTENT_SUBSCRIPTIONS_SUBSCRIPTION, 'inverse_relationship' => true, 'count' => true); $count = elgg_get_entities_from_relationship($options); if ($count) { $path = 'admin/upgrades/content_subscriptions'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = 'Content Subscription upgrade'; $upgrade->description = 'The way content subscriptions are handled has changed. Run this script to make sure all content subscriptions are migrated.'; $upgrade->save(); } } access_show_hidden_entities($access_status); }
/** * Listen to upgrade event * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied params * * @return void */ public static function migrateSteps($event, $type, $object) { $path = 'admin/upgrades/migrate_wizard_steps'; $upgrade = new \ElggUpgrade(); // ignore acces while checking for existence $ia = elgg_set_ignore_access(true); // already registered? if ($upgrade->getUpgradeFromPath($path)) { // restore access elgg_set_ignore_access($ia); return; } // find if upgrade is needed $upgrade_needed = false; $batch = new \ElggBatch('elgg_get_entities', ['type' => 'object', 'subtype' => \Wizard::SUBTYPE, 'limit' => false]); foreach ($batch as $entity) { $fa = new \ElggFile(); $fa->owner_guid = $entity->getGUID(); $fa->setFilename('steps.json'); if (!$fa->exists()) { continue; } $upgrade_needed = true; break; } if (!$upgrade_needed) { // restore access elgg_set_ignore_access($ia); return; } $upgrade->title = elgg_echo('admin:upgrades:migrate_wizard_steps'); $upgrade->description = elgg_echo('admin:upgrades:migrate_wizard_steps:description'); $upgrade->setPath($path); $upgrade->save(); // restore access elgg_set_ignore_access($ia); }
* in actions/admin/upgrades/upgrade_discussion_replies.php for that. * * This upgrade must be run even if the groups plugin is disabled because the * script will be removed in Elgg 1.10 and we don't want anyone to get stuck * with old annotation replies just because the groups plugin was not enabled * when site was upgraded from 1.8. */ // Register subtype and class for discussion replies if (get_subtype_id('object', 'discussion_reply')) { update_subtype('object', 'discussion_reply', 'ElggDiscussionReply'); } else { add_subtype('object', 'discussion_reply', 'ElggDiscussionReply'); } $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); $discussion_replies = elgg_get_annotations(array('annotation_names' => 'group_topic_post', 'count' => true)); // Notify administrator only if there are existing discussion replies if ($discussion_replies) { $path = "admin/upgrades/discussion_replies"; $upgrade = new \ElggUpgrade(); // Create the upgrade if one with the same URL doesn't already exist if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = 'Group Discussions Upgrade'; $upgrade->description = 'Group discussions have been improved in Elgg 1.9 and require a migration. Run this upgrade to complete the migration.'; $upgrade->save(); } } elgg_set_ignore_access($ia); access_show_hidden_entities($access_status);
/** * @expectedException UnexpectedValueException * @expectedExceptionMessage ElggUpgrade objects must have a value for the description property. */ public function testThrowsOnSaveWithoutDesc() { $this->obj->setPath('test'); $this->obj->title = 'Test'; $this->obj->save(); }
/** * Migrates static pages to be using 'normal' containers and move parent relationship to parent_guid metadata * The previous migration using static pages as containers backfired in places like search, (write) access, listings * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $entity supplied entity * * @return void * @since 5.0 */ public static function migrateContainers($event, $type, $object) { $ia = elgg_set_ignore_access(true); $path = 'admin/upgrades/static/migrate_containers'; $upgrade = new \ElggUpgrade(); if (!$upgrade->getUpgradeFromPath($path)) { $upgrade->setPath($path); $upgrade->title = elgg_echo('admin:upgrades:static:migrate_containers'); $upgrade->description = elgg_echo('admin:upgrades:static:migrate_containers:description'); $upgrade->save(); } elgg_set_ignore_access($ia); }