function questions_init() { elgg_register_library("elgg:questions", dirname(__FILE__) . "/lib/questions.php"); add_subtype("object", 'question', 'ElggQuestion'); update_subtype("object", 'question', 'ElggQuestion'); add_subtype("object", 'answer', 'ElggAnswer'); update_subtype("object", 'answer', 'ElggAnswer'); elgg_extend_view("css/elgg", "questions/css"); elgg_extend_view("js/elgg", "questions/js"); elgg_register_menu_item("site", array("name" => 'questions', "text" => elgg_echo('questions'), "href" => "/questions/all")); elgg_register_entity_type("object", 'questions'); elgg_register_widget_type('questions', elgg_echo("widget:questions:title"), elgg_echo("widget:questions:description")); $actions_base = dirname(__FILE__) . '/actions/object/question'; elgg_register_action("object/question/save", "{$actions_base}/save.php"); elgg_register_action("questions/delete", "{$actions_base}/delete.php"); $actions_base = dirname(__FILE__) . '/actions/object/answer'; elgg_register_action("object/answer/save", "{$actions_base}/save.php"); elgg_register_entity_url_handler('object', 'question', 'questions_url_handler'); $plugin_dir = dirname(__FILE__); elgg_register_entity_url_handler('object', 'answer', 'answers_url'); elgg_register_page_handler('questions', 'questions_page_handler'); elgg_register_page_handler('answers', 'answers_page_handler'); $actions_base = "{$plugin_dir}/actions/object/answer"; elgg_register_action('object/answer/add', "{$actions_base}/save.php"); elgg_register_action('object/answer/edit', "{$actions_base}/save.php"); elgg_register_action('answers/delete', "{$actions_base}/delete.php"); elgg_register_plugin_hook_handler("register", "menu:owner_block", 'questions_owner_block_menu_handler'); elgg_register_plugin_hook_handler("register", "menu:user_hover", 'questions_user_hover_menu_handler'); elgg_register_plugin_hook_handler("register", 'menu:entity', 'questions_entity_menu_handler'); elgg_register_plugin_hook_handler("notify:entity:message", "object", 'questions_notify_message_handler'); add_group_tool_option('questions', elgg_echo("questions:enable"), true); elgg_extend_view("groups/tool_latest", "questions/group_module"); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'questions_container_permissions_check'); }
/** * Set the correct class for the GroupMail subtype * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied object * * @return void */ public static function setGroupMailClassHandler($event, $type, $object) { if (get_subtype_id('object', \GroupMail::SUBTYPE)) { update_subtype('object', \GroupMail::SUBTYPE, 'GroupMail'); } else { add_subtype('object', \GroupMail::SUBTYPE, 'GroupMail'); } }
/** * Listen to the upgrade event to set the correct class handler * * @param string $event the name of the event * @param string $type the type of the event * @param null $object supplied param * * @return void */ public static function setClassHandler($event, $type, $object) { if (get_subtype_id('object', \CSVExport::SUBTYPE)) { update_subtype('object', \CSVExport::SUBTYPE, 'CSVExport'); } else { add_subtype('object', \CSVExport::SUBTYPE, 'CSVExport'); } }
/** * This function adds a class handler to object->faq * Since the old FAQ didn't had a class * * @return bool */ function user_support_faq_class_update() { $class = get_subtype_class("object", UserSupportFAQ::SUBTYPE); if ($class != "UserSupportFAQ") { return update_subtype("object", UserSupportFAQ::SUBTYPE, "UserSupportFAQ"); } return true; }
/** * Update the class for publication subtype * * @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 setClassHandler($event, $type, $object) { // set correct class handler for Publication if (get_subtype_id('object', \Publication::SUBTYPE)) { update_subtype('object', \Publication::SUBTYPE, 'Publication'); } else { add_subtype('object', \Publication::SUBTYPE, 'Publication'); } }
public static function fixClasses($event, $type, $object) { $classes = ['\\ColdTrick\\EventManager\\Event\\Day', '\\ColdTrick\\EventManager\\Event\\Slot']; foreach ($classes as $class) { if (get_subtype_class('object', $class::SUBTYPE) !== $class) { update_subtype('object', $class::SUBTYPE, $class); } } }
/** * Make sure the class handler for QuickLink is correct * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object misc params * * @return void */ public static function setClassHandler($event, $type, $object) { // set correct class handler for QuickLink if (get_subtype_id('object', \QuickLink::SUBTYPE)) { update_subtype('object', \QuickLink::SUBTYPE, 'QuickLink'); } else { add_subtype('object', \QuickLink::SUBTYPE, 'QuickLink'); } }
/** * Performs class upgrade before init as classes are needed during init * * @return void */ function profile_manager_plugins_boot() { $classes = ['\\ColdTrick\\ProfileManager\\CustomProfileField', '\\ColdTrick\\ProfileManager\\CustomGroupField', '\\ColdTrick\\ProfileManager\\CustomProfileType', '\\ColdTrick\\ProfileManager\\CustomFieldCategory']; foreach ($classes as $class) { $current_class = get_subtype_class('object', $class::SUBTYPE); if ($current_class !== $class) { update_subtype('object', $class::SUBTYPE, $class); } } }
function upgrade_1395096061() { $subtypes = array(HYPEGAMEMECHANICS_BADGE_SUBTYPE, HYPEGAMEMECHANICS_BADGERULE_SUBTYPE, HYPEGAMEMECHANICS_SCORE_SUBTYPE); foreach ($subtypes as $subtype) { if (get_subtype_id('object', $subtype)) { update_subtype('object', $subtype); } else { add_subtype('object', $subtype); } } }
/** * Listen to the upgrade event * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied params */ function haarlem_tangram_upgrade($event, $type, $object) { // register correct class for future use if (get_subtype_id('object', TangramVacancy::SUBTYPE)) { update_subtype('object', TangramVacancy::SUBTYPE, 'TangramVacancy'); } else { add_subtype('object', TangramVacancy::SUBTYPE, 'TangramVacancy'); } // reset xml cache haarlem_tangram_clear_cached_xml(); }
/** * 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 */ function wizard_upgrade_system_handler($event, $type, $object) { $id = get_subtype_id('object', Wizard::SUBTYPE); if (empty($id)) { // add subtype registration add_subtype('object', Wizard::SUBTYPE, 'Wizard'); } elseif (get_subtype_class_from_id($id) !== 'Wizard') { // update subtype registration update_subtype('object', Wizard::SUBTYPE, 'Wizard'); } }
/** * Check the class assosiation * * @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 checkClasses($event, $type, $object) { if (get_subtype_id('object', \APIApplication::SUBTYPE)) { update_subtype('object', \APIApplication::SUBTYPE, 'APIApplication'); } else { add_subtype('object', \APIApplication::SUBTYPE, 'APIApplication'); } if (get_subtype_id('object', \APIApplicationUserSetting::SUBTYPE)) { update_subtype('object', \APIApplicationUserSetting::SUBTYPE, 'APIApplicationUserSetting'); } else { add_subtype('object', \APIApplicationUserSetting::SUBTYPE, 'APIApplicationUserSetting'); } }
function widget_manager_init() { // check valid WidgetManagerWidget class if (get_subtype_class("object", "widget") == "ElggWidget") { update_subtype("object", "widget", "WidgetManagerWidget"); } elgg_trigger_event("widgets_init", "widget_manager"); if (elgg_is_active_plugin("groups") && elgg_get_plugin_setting("group_enable", "widget_manager") == "yes") { // add the widget manager tool option $group_option_enabled = false; if (elgg_get_plugin_setting("group_option_default_enabled", "widget_manager") == "yes") { $group_option_enabled = true; } if (elgg_get_plugin_setting("group_option_admin_only", "widget_manager") != "yes") { // add the tool option for group admins add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled); } elseif (elgg_is_admin_logged_in()) { add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled); } elseif ($group_option_enabled) { // register event to make sure newly created groups have the group option enabled elgg_register_event_handler("create", "group", "widget_manager_create_group_event_handler"); elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'widget_manager_group_widgets_default_list'); } } // extend CSS elgg_extend_view("css/elgg", "widget_manager/css/global"); elgg_extend_view("css/admin", "widget_manager/css/global"); elgg_extend_view("js/elgg", "widget_manager/js/site"); elgg_extend_view("js/admin", "widget_manager/js/admin"); // register a widget title url handler elgg_register_entity_url_handler("object", "widget", "widget_manager_widget_url_handler"); // multi dashboard support add_subtype("object", MultiDashboard::SUBTYPE, "MultiDashboard"); if (elgg_is_logged_in() && widget_manager_multi_dashboard_enabled()) { elgg_register_page_handler("multi_dashboard", "widget_manager_multi_dashboard_page_handler"); $options = array("type" => "object", "subtype" => MultiDashboard::SUBTYPE, "owner_guid" => elgg_get_logged_in_user_guid(), "count" => true); $tab_count = elgg_get_entities($options); if ($tab_count < MULTI_DASHBOARD_MAX_TABS) { elgg_register_menu_item("extras", array("name" => "multi_dashboard", "text" => elgg_view_icon("home"), "href" => "multi_dashboard/edit/?internal_url=" . urlencode(current_page_url()), "title" => elgg_echo("widget_manager:multi_dashboard:extras"), "rel" => "nofollow", "id" => "widget-manager-multi_dashboard-extras")); } elgg_extend_view("page/elements/sidebar", "widget_manager/multi_dashboard/sidebar", 400); elgg_register_event_handler("create", "object", "widget_manager_create_object_handler"); elgg_register_plugin_hook_handler("route", "dashboard", "widget_manager_dashboard_route_handler"); elgg_register_plugin_hook_handler("action", "widgets/add", "widget_manager_widgets_add_action_handler"); elgg_register_action("multi_dashboard/edit", dirname(__FILE__) . "/actions/multi_dashboard/edit.php"); elgg_register_action("multi_dashboard/delete", dirname(__FILE__) . "/actions/multi_dashboard/delete.php"); elgg_register_action("multi_dashboard/drop", dirname(__FILE__) . "/actions/multi_dashboard/drop.php"); elgg_register_action("multi_dashboard/reorder", dirname(__FILE__) . "/actions/multi_dashboard/reorder.php"); } }
function hj_forum_1358206168() { $subtypes = array('hjforum' => 'hjForum', 'hjforumcategory' => 'hjForumCategory', 'hjforumtopic' => 'hjForumTopic', 'hjforumpost' => 'hjForumPost'); foreach ($subtypes as $subtype => $class) { if (get_subtype_id('object', $subtype)) { update_subtype('object', $subtype, $class); } else { add_subtype('object', $subtype, $class); } } $subtypeIdForum = get_subtype_id('object', 'hjforum'); $subtypeIdForumTopic = get_subtype_id('object', 'hjforumtopic'); $subtypeIdAnnotation = get_subtype_id('object', 'hjannotation'); $dbprefix = elgg_get_config('dbprefix'); $segments = elgg_get_entities_from_metadata(array('types' => 'object', 'subtypes' => 'hjsegment', 'metadata_name_value_pairs' => array('name' => 'handler', 'value' => 'hjforumtopic'), 'limit' => 0)); /** * Upgrade : * 1. Convert segmented hjForumTopic objects to hjForum objects * 2. Remove segments * 3. Convert widgets to categories */ foreach ($segments as $segment) { $forum = get_entity($segment->container_guid); $query = "UPDATE {$dbprefix}entities SET subtype = {$subtypeIdForum} WHERE subtype = {$subtypeIdForumTopic} AND guid = {$forum->guid}"; update_data($query); $widgets = elgg_get_entities(array('types' => 'object', 'subtypes' => 'widget', 'container_guids' => array($segment->guid, $forum->guid), 'limit' => 0)); if ($widgets) { $forum->enable_subcategories = true; foreach ($widgets as $widget) { $threads = elgg_get_entities_from_metadata(array('types' => 'object', 'subtypes' => 'hjforumtopic', 'metadata_name_value_pairs' => array(array('name' => 'widget', 'value' => $widget->guid)), 'limit' => 0)); $cat = new ElggObject(); $cat->subtype = 'hjforumcategory'; $cat->owner_guid = elgg_get_logged_in_user_guid(); $cat->container_guid = $forum->guid; $cat->title = $widget->title; $cat->description = ''; $cat->access_id = ACCESS_PUBLIC; $cat->save(); foreach ($threads as $thread) { $query = "UPDATE {$dbprefix}entities SET container_guid = {$forum->guid} WHERE guid = {$thread->guid}"; update_data($query); unset($thread->widget); $thread->setCategory($cat->guid, true); } $widget->disable('plugin_version_upgrade'); } } $segment->disable('plugin_version_upgrade'); } }
/** * Do something on the 'upgrade', 'system' event (when running upgrade.php) * * @param string $event which event was triggered * @param string $type what is the type of the event * @param mixed $object On what object was the event triggered * * @return void * * @see elgg_trigger_event() */ function newsletter_upgrade_event_handler($event, $type, $object) { // amke sure the correct classes are set for our own classes if (!update_subtype("object", Newsletter::SUBTYPE, "Newsletter")) { // first time the plugin was activated add_subtype("object", Newsletter::SUBTYPE, "Newsletter"); } if (!update_subtype("object", NewsletterSubscription::SUBTYPE, "NewsletterSubscription")) { // first time the plugin was activated add_subtype("object", NewsletterSubscription::SUBTYPE, "NewsletterSubscription"); } // proccess upgrade scripts $upgrade_scripts = array(); $upgrade_dir = dirname(__FILE__) . "/upgrades/"; $fh = opendir($upgrade_dir); // read all available upgrade scripts if (!empty($fh)) { while (($upgrade_file = readdir($fh)) !== false) { if (!is_dir($upgrade_dir . $upgrade_file)) { $upgrade_scripts[] = $upgrade_file; } } closedir($fh); } if (!empty($upgrade_scripts)) { // get already run scripts $upgrades = datalist_get("processed_upgrades"); $processed_upgrades = unserialize($upgrades); if (!is_array($processed_upgrades)) { $processed_upgrades = array(); } // do we have something left $unprocessed = array_diff($upgrade_scripts, $processed_upgrades); if (!empty($unprocessed)) { // proccess all upgrades foreach ($unprocessed as $script) { include $upgrade_dir . $script; $processed_upgrades[] = $script; } // save new list elgg_set_processed_upgrades($processed_upgrades); } } }
/** * 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 fixClasses($event, $type, $object) { $id = get_subtype_id('object', \Wizard::SUBTYPE); if (empty($id)) { // add subtype registration add_subtype('object', \Wizard::SUBTYPE, 'Wizard'); } elseif (get_subtype_class_from_id($id) !== 'Wizard') { // update subtype registration update_subtype('object', \Wizard::SUBTYPE, 'Wizard'); } $id = get_subtype_id('object', \WizardStep::SUBTYPE); if (empty($id)) { // add subtype registration add_subtype('object', \WizardStep::SUBTYPE, 'WizardStep'); } elseif (get_subtype_class_from_id($id) !== 'WizardStep') { // update subtype registration update_subtype('object', \WizardStep::SUBTYPE, 'WizardStep'); } }
/** * The Wire initialization */ function thewire_init() { global $CONFIG; // this can be removed in favor of activate/deactivate scripts if (!update_subtype('object', 'thewire', 'ElggWire')) { add_subtype('object', 'thewire', 'ElggWire'); } // register the wire's JavaScript $thewire_js = elgg_get_simplecache_url('js', 'thewire'); elgg_register_simplecache_view('js/thewire'); elgg_register_js('elgg.thewire', $thewire_js, 'footer'); elgg_register_ajax_view('thewire/previous'); // add a site navigation item $item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all'); elgg_register_menu_item('site', $item); // owner block menu elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'thewire_owner_block_menu'); // remove edit and access and add thread, reply, view previous elgg_register_plugin_hook_handler('register', 'menu:entity', 'thewire_setup_entity_menu_items'); // Extend system CSS with our own styles, which are defined in the thewire/css view elgg_extend_view('css', 'thewire/css'); //extend views elgg_extend_view('activity/thewire', 'thewire/activity_view'); elgg_extend_view('profile/status', 'thewire/profile_status'); elgg_extend_view('js/initialise_elgg', 'thewire/js/textcounter'); // Register a page handler, so we can have nice URLs elgg_register_page_handler('thewire', 'thewire_page_handler'); // Register a URL handler for thewire posts elgg_register_entity_url_handler('object', 'thewire', 'thewire_url'); elgg_register_widget_type('thewire', elgg_echo('thewire'), elgg_echo("thewire:widget:desc")); // Register for search elgg_register_entity_type('object', 'thewire'); // Register granular notification for this type register_notification_object('object', 'thewire', elgg_echo('thewire:notify:subject')); // Listen to notification events and supply a more useful message elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'thewire_notify_message'); // Register actions $action_base = $CONFIG->pluginspath . 'thewire/actions'; elgg_register_action("thewire/add", "{$action_base}/add.php"); elgg_register_action("thewire/delete", "{$action_base}/delete.php"); elgg_register_plugin_hook_handler('unit_test', 'system', 'thewire_test'); }
<?php /** @todo: remove hjForm & hjField */ $subtypes = array('hjform' => 'hjForm', 'hjfield' => 'hjField', 'hjfile' => 'hjFile', 'hjfilefolder' => 'hjFileFolder', 'hjsegment' => 'hjSegment', 'hjannotation' => 'hjAnnotation', 'hjcategory' => 'hjCategory'); foreach ($subtypes as $subtype => $class) { if (get_subtype_id('object', $subtype)) { update_subtype('object', $subtype, $class); } else { add_subtype('object', $subtype, $class); } }
<?php /** * Elgg 1.9.0-dev upgrade 2013010400 * comments_to_entities * * Convert comment annotations to entities. * * Register comment subtype and add ElggUpgrade for ajax upgrade. * * We do not migrate comments in this upgrade. See the comment * upgrade action in actions/admin/upgrades/upgrade_comments.php for that. */ // Register subtype and class for comments if (get_subtype_id('object', 'comment')) { update_subtype('object', 'comment', 'ElggComment'); } else { add_subtype('object', 'comment', 'ElggComment'); } $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); // add ElggUpgrade object if need to migrate comments $options = array('annotation_names' => 'generic_comment', 'order_by' => 'n_table.id DESC', 'count' => true); if (elgg_get_annotations($options)) { $url = "admin/upgrades/comments"; $upgrade = new ElggUpgrade(); // Create the upgrade if one with the same URL doesn't already exist if (!$upgrade->getUpgradeFromURL($url)) { $upgrade->setURL($url); $upgrade->title = 'Comments Upgrade';
<?php /** * This script is run when the plugin gets deactivated */ // undo class handlers for subtype update_subtype('object', GroupMail::SUBTYPE);
<?php /** * Activate Elggx Userpoints plugin * */ // Register the Userpoint class for the object/userpoint subtype if (get_subtype_id('object', 'userpoint')) { update_subtype('object', 'userpoint', 'Userpoint'); } else { add_subtype('object', 'userpoint', 'Userpoint'); } // Upgrade settings $oldversion = elgg_get_plugin_setting('version', 'userpoints'); $current_version = elgg_get_plugin_setting('version', 'elggx_userpoints'); // Check if we need to run an upgrade if ($oldversion && !$current_version) { // Update plugin settings $plugin = elgg_get_plugin_from_id('userpoints'); elgg_set_plugin_setting('moderate', $plugin->moderate, 'elggx_userpoints'); elgg_set_plugin_setting('subtract', $plugin->subtract, 'elggx_userpoints'); elgg_set_plugin_setting('displaymessage', $plugin->displaymessage, 'elggx_userpoints'); elgg_set_plugin_setting('profile_display', $plugin->profile_display, 'elggx_userpoints'); elgg_set_plugin_setting('delete', $plugin->delete, 'elggx_userpoints'); elgg_set_plugin_setting('expire_after', $plugin->expire_after, 'elggx_userpoints'); // Update point settings $pointssettings = elgg_get_plugin_from_id('userpoints_standard'); elgg_set_plugin_setting('blog', $pointssettings->blog, 'elggx_userpoints'); elgg_set_plugin_setting('group', $pointssettings->group, 'elggx_userpoints'); elgg_set_plugin_setting('profileupdate', $pointssettings->profileupdate, 'elggx_userpoints'); elgg_set_plugin_setting('page_top', $pointssettings->page_top, 'elggx_userpoints');
<?php // Register a class for the object/group_request subtype if (get_subtype_id('object', 'group_request')) { update_subtype('object', 'group_request', '\\Groups\\Requests\\Request'); } else { add_subtype('object', 'group_request', '\\Groups\\Requests\\Request'); } $limited_groups = elgg_get_plugin_setting('limited_groups', 'groups'); // Notify admin if group creation has not been restricted to admins if ($limited_groups !== 'yes') { $group_settings = elgg_view('output/url', array('text' => elgg_echo('group_requests:limited_groups:enable'), 'href' => 'admin/plugin_settings/groups')); elgg_add_admin_notice('limited_groups_disabled', elgg_echo('group_requests:limited_groups:disabled', array($group_settings))); }
<?php /* * This file is part of izap-videos plugin for Elgg. * * izap-videos for Elgg 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. * * izap-videos for Elgg 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 izap-videos for Elgg. If not, see <http://www.gnu.org/licenses/>. */ // add subtype with class if (get_subtype_id('object', 'izap_video')) { update_subtype('object', 'izap_video', 'IzapVideo'); } else { add_subtype('object', 'izap_video', 'IzapVideo'); }
<?php update_subtype('object', 'videos');
<?php /** * Deregister the class */ update_subtype('object', 'site_notification');
<?php /** * Register the Wire class for the object/wire subtype */ if (get_subtype_id('object', 'wire')) { update_subtype('object', 'wire', 'Wire'); } else { add_subtype('object', 'wire', 'Wire'); }
<?php /** * Register classes */ if (!get_subtype_id('object', Wizard::SUBTYPE)) { // new installation add_subtype('object', Wizard::SUBTYPE, 'Wizard'); } else { update_subtype('object', Wizard::SUBTYPE, 'Wizard'); }
/** * Upgrade from 1.7 to 1.8. */ function blog_run_upgrades($event, $type, $details) { $blog_upgrade_version = elgg_get_plugin_setting('upgrade_version', 'blogs'); if (!$blog_upgrade_version) { // When upgrading, check if the ElggBlog class has been registered as this // was added in Elgg 1.8 if (!update_subtype('object', 'blog', 'ElggBlog')) { add_subtype('object', 'blog', 'ElggBlog'); } elgg_set_plugin_setting('upgrade_version', 1, 'blogs'); } }
<?php /** * This file is executed when the plugin is enabled */ // restore class handlers to default update_subtype('object', 'question'); update_subtype('object', 'answer');
<?php /** * Register classes */ if (!get_subtype_id('object', \Wizard::SUBTYPE)) { // new installation add_subtype('object', \Wizard::SUBTYPE, 'Wizard'); } else { update_subtype('object', \Wizard::SUBTYPE, 'Wizard'); } if (!get_subtype_id('object', \WizardStep::SUBTYPE)) { // new installation add_subtype('object', \WizardStep::SUBTYPE, 'WizardStep'); } else { update_subtype('object', \WizardStep::SUBTYPE, 'WizardStep'); }