Esempio n. 1
0
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');
}
Esempio n. 2
0
function subsite_manager_runonce()
{
    // register a new substype in the database and link it to the right classname
    add_subtype("site", Subsite::SUBTYPE, "Subsite");
    // Update the database with extra columns for multisite
    run_sql_script(dirname(dirname(__FILE__)) . "/scripts/add_columns.sql");
}
Esempio n. 3
0
function upgrade_change_subtype($entity, $subtype)
{
    $dbprefix = elgg_get_config('dbprefix');
    $subtype_id = add_subtype('object', $subtype);
    update_data("UPDATE {$dbprefix}entities set subtype={$subtype_id} WHERE guid={$entity->guid}");
    return true;
}
Esempio n. 4
0
 /**
  * @group current
  */
 public function testCanSaveNewObject()
 {
     $subtype = 'test_subtype';
     $subtype_id = add_subtype('object', $subtype);
     $user = $this->mocks()->getUser();
     _elgg_services()->session->setLoggedInUser($user);
     $object = new \ElggObject();
     $object->subtype = $subtype;
     $object->title = 'Foo';
     $object->description = 'Bar';
     $object->owner_guid = $user->guid;
     $object->container_guid = $user->guid;
     $object->access_id = ACCESS_LOGGED_IN;
     $object->time_created = time();
     $object->setCurrentTime();
     // We should be able to match timestamps
     $now = $object->getCurrentTime()->getTimestamp();
     $guid = $object->save();
     $this->assertNotFalse($guid);
     $object = get_entity($guid);
     $this->assertEquals('object', $object->type);
     $this->assertEquals($subtype_id, $object->subtype);
     $this->assertEquals('Foo', $object->title);
     $this->assertEquals('Foo', $object->getDisplayName());
     $this->assertEquals('Bar', $object->description);
     $this->assertEquals($user->guid, $object->getOwnerGUID());
     $this->assertEquals($user, $object->getOwnerEntity());
     $this->assertEquals($user->guid, $object->getContainerGUID());
     $this->assertEquals($user, $object->getContainerEntity());
     $this->assertEquals(ACCESS_LOGGED_IN, $object->access_id);
     _elgg_services()->session->removeLoggedInUser();
 }
function profile_manager_run_once()
{
    global $CONFIG;
    // upgrade
    $profile_field_class_name = "ProfileManagerCustomProfileField";
    $group_field_class_name = "ProfileManagerCustomGroupField";
    $field_type_class_name = "ProfileManagerCustomProfileType";
    $field_category_class_name = "ProfileManagerCustomFieldCategory";
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileField::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$profile_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileField::SUBTYPE, $profile_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomGroupField::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$group_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomGroupField::SUBTYPE, $group_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileType::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_type_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileType::SUBTYPE, $field_type_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomFieldCategory::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_category_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomFieldCategory::SUBTYPE, $field_category_class_name);
    }
}
Esempio n. 6
0
 /**
  * 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');
     }
 }
Esempio n. 7
0
 /**
  * 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');
     }
 }
Esempio n. 8
0
 /**
  * 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');
     }
 }
Esempio n. 9
0
 /**
  * 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');
     }
 }
Esempio n. 10
0
function event_manager_run_once_subtypes()
{
    add_subtype('object', Event::SUBTYPE, "Event");
    add_subtype('object', EventDay::SUBTYPE, "EventDay");
    add_subtype('object', EventSlot::SUBTYPE, "EventSlot");
    add_subtype('object', EventRegistrationForm::SUBTYPE, "EventRegistrationForm");
    add_subtype('object', EventRegistrationQuestion::SUBTYPE, "EventRegistrationQuestion");
    add_subtype('object', EventRegistration::SUBTYPE, "EventRegistration");
}
Esempio n. 11
0
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);
        }
    }
}
Esempio n. 12
0
/**
 * 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();
}
Esempio n. 13
0
/**
 * 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');
    }
}
Esempio n. 14
0
 /**
  * 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');
     }
 }
Esempio n. 15
0
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");
    }
}
Esempio n. 16
0
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');
    }
}
Esempio n. 17
0
 /**
  * Setup a mock entity
  *
  * @param int    $guid       GUID of the mock entity
  * @param string $type       Type of the mock entity
  * @param string $subtype    Subtype of the mock entity
  * @param array  $attributes Attributes of the mock entity
  * @return ElggEntity
  */
 public function setup($guid, $type, $subtype, array $attributes = [])
 {
     while (!isset($guid)) {
         $this->iterator++;
         if (!isset($this->row[$this->iterator])) {
             $guid = $this->iterator;
         }
     }
     if ($subtype) {
         $subtype_id = get_subtype_id($type, $subtype);
         if (!$subtype_id) {
             $subtype_id = add_subtype($type, $subtype);
         }
     } else {
         if (isset($attributes['subtype_id'])) {
             $subtype_id = $attributes['subtype_id'];
             $subtype = get_subtype_from_id($subtype_id);
         }
     }
     $attributes['guid'] = $guid;
     $attributes['type'] = $type;
     $attributes['subtype'] = $subtype_id;
     $time = $this->getCurrentTime()->getTimestamp();
     $primary_attributes = array('owner_guid' => 0, 'container_guid' => 0, 'access_id' => ACCESS_PUBLIC, 'time_created' => $time, 'time_updated' => $time, 'last_action' => $time, 'enabled' => 'yes');
     switch ($type) {
         case 'object':
             $external_attributes = ['title' => null, 'description' => null];
             break;
         case 'user':
             $external_attributes = ['name' => "John Doe {$guid}", 'username' => "john_doe_{$guid}", 'password_hash' => null, 'email' => "john_doe_{$guid}@example.com", 'language' => 'en', 'banned' => "no", 'admin' => 'no', 'prev_last_action' => null, 'last_login' => null, 'prev_last_login' => null];
             break;
         case 'group':
             $external_attributes = ['name' => null, 'description' => null];
             break;
     }
     $map = array_merge($primary_attributes, $external_attributes, $attributes);
     $attrs = (object) $map;
     $this->rows[$guid] = $attrs;
     $this->addQuerySpecs($attrs);
     $entity = $this->rowToElggStar($this->rows[$guid]);
     foreach ($attrs as $name => $value) {
         if (!isset($entity->{$name}) || $entity->{$name} != $value) {
             // not an attribute, so needs to be set again
             $entity->{$name} = $value;
         }
     }
     return $entity;
 }
Esempio n. 18
0
/**
 * 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);
        }
    }
}
Esempio n. 19
0
 /**
  * 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');
}
Esempio n. 21
0
function oauth_upgrade_201004()
{
    add_subtype('object', 'oauthnonce');
    elgg_set_ignore_access(true);
    // grab all the consumers and update their types to the new keys
    $consumers = elgg_get_entities(array('type' => 'object', 'subtype' => 'oauthconsumer', 'limit' => 0));
    foreach ($consumers as $cons) {
        if ($cons->consumer_type == 'client') {
            $cons->consumer_type = 'inbound';
        } else {
            if ($cons->consumer_type == 'server') {
                $cons->consumer_type = 'outbound';
            } else {
                // might as well clean up invalid ones while we're here
                $cons->delete();
            }
        }
    }
    elgg_set_ignore_access(false);
}
Esempio n. 22
0
function stickywidgets_init()
{
    global $CONFIG;
    add_subtype("object", "sticky_widget", "StickyElggWidget");
    // Register a page handler, so we can have nice URLs
    register_page_handler('sticky_widgets', 'sw_page_handler');
    // Register page handler for the dashboard
    register_page_handler('dashboard', 'sw_dashboard');
    // Register page handler for profile
    register_page_handler('profile', 'sw_profile_page_handler');
    register_action('sticky_widgets/getWidgets', false, $CONFIG->pluginspath . "sticky_widgets/actions/getWidgets.php", true);
    register_action('sticky_widgets/reorder', false, $CONFIG->pluginspath . "sticky_widgets/actions/reorder.php", true);
    register_action('sticky_widgets/uninstall', false, $CONFIG->pluginspath . "sticky_widgets/actions/uninstall.php", true);
    register_action('sticky_widgets/save', false, $CONFIG->pluginspath . "sticky_widgets/actions/save.php", true);
    // Extend system CSS with our own styles, which are defined in the messageboard/css view
    extend_view('css', 'sticky_widgets/css');
    //	extend_view("metatags","sticky_widgets/js");
    register_plugin_hook('container_permissions_check', 'object', 'sticky_widgets_container_permission_check');
    register_plugin_hook('permissions_check', 'object', 'sticky_widgets_container_permission_check');
}
Esempio n. 23
0
/**
 * Initialize Elgg, prepare some libraries
 *
 * @return void
 */
function ws_pack_init()
{
    // register libraries
    elgg_register_library("ws_pack.auth", dirname(__FILE__) . "/lib/webservices/auth.php");
    elgg_register_library("ws_pack.river", dirname(__FILE__) . "/lib/webservices/river.php");
    elgg_register_library("ws_pack.groups", dirname(__FILE__) . "/lib/webservices/groups.php");
    elgg_register_library("ws_pack.users", dirname(__FILE__) . "/lib/webservices/users.php");
    elgg_register_library("ws_pack.system", dirname(__FILE__) . "/lib/webservices/system.php");
    elgg_register_library("ws_pack.thewire", dirname(__FILE__) . "/lib/webservices/thewire.php");
    elgg_register_library("ws_pack.settings", dirname(__FILE__) . "/lib/webservices/settings.php");
    elgg_register_library("ws_pack.members", dirname(__FILE__) . "/lib/webservices/members.php");
    elgg_register_library("ws_pack.languages", dirname(__FILE__) . "/lib/webservices/languages.php");
    elgg_register_library("ws_pack.messages", dirname(__FILE__) . "/lib/webservices/messages.php");
    elgg_register_library("ws_pack.entities", dirname(__FILE__) . "/lib/webservices/entities.php");
    elgg_register_library("ws_pack.discussions", dirname(__FILE__) . "/lib/webservices/discussions.php");
    elgg_register_library("ws_pack.notifications", dirname(__FILE__) . "/lib/webservices/notifications.php");
    elgg_register_library("ws_pack.community", dirname(__FILE__) . "/lib/webservices/community.php");
    elgg_register_library("simple_html_dom", dirname(__FILE__) . "/vendors/simplehtmldom/simple_html_dom.php");
    // add subtype class
    add_subtype("object", APIApplication::SUBTYPE, "APIApplication");
    add_subtype("object", APIApplicationUserSetting::SUBTYPE, "APIApplicationUserSetting");
    // register plugin hooks
    elgg_register_plugin_hook_handler("register", "menu:ws_pack:applications", "ws_pack_applications_menu_hook_handler");
    elgg_register_plugin_hook_handler("register", "menu:entity", "ws_pack_entity_menu_hook_handler");
    elgg_register_plugin_hook_handler("register", "menu:annotation", "ws_pack_annotation_menu_hook_handler");
    elgg_register_plugin_hook_handler("rest", "init", "ws_pack_rest_init_hook_handler");
    elgg_register_plugin_hook_handler("api_key", "use", "ws_pack_api_key_use_hook_handler");
    elgg_register_plugin_hook_handler("container_permissions_check", "object", "ws_pack_container_write_hook_handler");
    // register event handlers
    elgg_register_event_handler("created", "river", "ws_pack_created_river_event_handler");
    // register actions
    elgg_register_action("ws_pack/application/activate", dirname(__FILE__) . "/actions/application/activate.php", "admin");
    elgg_register_action("ws_pack/application/deactivate", dirname(__FILE__) . "/actions/application/deactivate.php", "admin");
    elgg_register_action("ws_pack/application/disable", dirname(__FILE__) . "/actions/application/disable.php", "admin");
    elgg_register_action("ws_pack/application/delete", dirname(__FILE__) . "/actions/application/delete.php", "admin");
    elgg_register_action("ws_pack/push_service/delete", dirname(__FILE__) . "/actions/push_service/delete.php", "admin");
    elgg_register_action("ws_pack/push_service/delete_user", dirname(__FILE__) . "/actions/push_service/delete_user.php");
    // register shutdown function
    register_shutdown_function("ws_pack_shutdown_user_counter");
}
Esempio n. 24
0
/**
 * Run once function
 *
 * @return void
 */
function profiles_go_run_once()
{
    $dbprefix = elgg_get_config("dbprefix");
    // upgrade class names for subtypes
    $profile_field_class_name = "ProfileManagerCustomProfileField";
    $trip_field_class_name = "ProfileManagerCustomTripField";
    $field_type_class_name = "ProfileManagerCustomProfileType";
    $field_category_class_name = "ProfileManagerCustomFieldCategory";
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileField::SUBTYPE)) {
        update_data("UPDATE {$dbprefix}entity_subtypes set class='{$profile_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileField::SUBTYPE, $profile_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomTripField::SUBTYPE)) {
        update_data("UPDATE {$dbprefix}entity_subtypes set class='{$trip_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomTripField::SUBTYPE, $trip_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileType::SUBTYPE)) {
        update_data("UPDATE {$dbprefix}entity_subtypes set class='{$field_type_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileType::SUBTYPE, $field_type_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomFieldCategory::SUBTYPE)) {
        update_data("UPDATE {$dbprefix}entity_subtypes set class='{$field_category_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomFieldCategory::SUBTYPE, $field_category_class_name);
    }
    // update ownerships of profile manager field configuration
    // owner should be site instead of a user (prevents problems when upgrading)
    // Added in Profile Manager v5.6
    $options = array("type" => "object", "subtypes" => array(ProfileManagerCustomProfileField::SUBTYPE, ProfileManagerCustomTripField::SUBTYPE, ProfileManagerCustomProfileType::SUBTYPE, ProfileManagerCustomFieldCategory::SUBTYPE), "limit" => false);
    $entities = elgg_get_entities($options);
    foreach ($entities as $entity) {
        $entity->owner_guid = $entity->site_guid;
        $entity->container_guid = $entity->site_guid;
        $entity->save();
    }
}
/**
 * Form initialisation
 *
 * These parameters are required for the event API, but we won't use them:
 * 
 * @param unknown_type $event
 * @param unknown_type $object_type
 * @param unknown_type $object
 */
function form_init()
{
    // Load system configuration
    global $CONFIG;
    // Load the language files
    register_translations($CONFIG->pluginspath . "form/languages/");
    register_translations($CONFIG->pluginspath . "form/languages/formtrans/");
    // Register entity type
    register_entity_type('object', 'form_data');
    // Register a page handler, so we can have nice URLs
    register_page_handler('form', 'form_page_handler');
    register_plugin_hook('usersettings:save', 'user', 'form_user_settings_save');
    // Register a URL handler for form data
    register_entity_url_handler('form_data_url', 'object', 'form_data');
    extend_view('css', 'form/css');
    add_subtype('object', 'form:form');
    add_subtype('object', 'form:config');
    add_subtype('object', 'form:field');
    add_subtype('object', 'form:field_map');
    add_subtype('object', 'form:field_choice');
    add_subtype('object', 'form:search_definition');
    add_subtype('object', 'form_data');
}
Esempio n. 26
0
<?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');
}
Esempio n. 27
0
<?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');
}
Esempio n. 28
0
<?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);
    }
}
/**
 * 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';
        $upgrade->description = 'Comments have been improved in Elgg 1.9 and require a migration. Run this upgrade to complete the migration.';
        $upgrade->save();
Esempio n. 30
0
 /**
  * Create a new entry in the entities table.
  *
  * Saves the base information in the entities table for the entity.  Saving
  * the type-specific information is handled in the calling class method.
  *
  * @warning Entities must have an entry in both the entities table and their type table
  * or they will throw an exception when loaded.
  *
  * @return int The new entity's GUID
  * @throws InvalidParameterException If the entity's type has not been set.
  * @throws IOException If the new row fails to write to the DB.
  */
 protected function create()
 {
     $allowed_types = elgg_get_config('entity_types');
     $type = $this->getDatabase()->sanitizeString($this->attributes['type']);
     if (!in_array($type, $allowed_types)) {
         throw new \InvalidParameterException('Entity type must be one of the allowed types: ' . implode(', ', $allowed_types));
     }
     $subtype = $this->attributes['subtype'];
     $subtype_id = add_subtype($type, $subtype);
     $owner_guid = (int) $this->attributes['owner_guid'];
     $access_id = (int) $this->attributes['access_id'];
     $now = $this->getCurrentTime()->getTimestamp();
     $time_created = isset($this->attributes['time_created']) ? (int) $this->attributes['time_created'] : $now;
     $container_guid = $this->attributes['container_guid'];
     if ($container_guid == 0) {
         $container_guid = $owner_guid;
         $this->attributes['container_guid'] = $container_guid;
     }
     $container_guid = (int) $container_guid;
     if ($access_id == ACCESS_DEFAULT) {
         throw new \InvalidParameterException('ACCESS_DEFAULT is not a valid access level. See its documentation in elgglib.h');
     }
     $user_guid = elgg_get_logged_in_user_guid();
     // If given an owner, verify it can be loaded
     if ($owner_guid) {
         $owner = $this->getOwnerEntity();
         if (!$owner) {
             _elgg_services()->logger->error("User {$user_guid} tried to create a ({$type}, {$subtype}), but the given" . " owner {$owner_guid} could not be loaded.");
             return false;
         }
         // If different owner than logged in, verify can write to container.
         if ($user_guid != $owner_guid && !$owner->canWriteToContainer(0, $type, $subtype)) {
             _elgg_services()->logger->error("User {$user_guid} tried to create a ({$type}, {$subtype}) with owner" . " {$owner_guid}, but the user wasn't permitted to write to the owner's container.");
             return false;
         }
     }
     // If given a container, verify it can be loaded and that the current user can write to it
     if ($container_guid) {
         $container = $this->getContainerEntity();
         if (!$container) {
             _elgg_services()->logger->error("User {$user_guid} tried to create a ({$type}, {$subtype}), but the given" . " container {$container_guid} could not be loaded.");
             return false;
         }
         if (!$container->canWriteToContainer(0, $type, $subtype)) {
             _elgg_services()->logger->error("User {$user_guid} tried to create a ({$type}, {$subtype}), but was not" . " permitted to write to container {$container_guid}.");
             return false;
         }
     }
     $result = _elgg_services()->entityTable->insertRow((object) ['type' => $type, 'subtype_id' => $subtype_id, 'owner_guid' => $owner_guid, 'container_guid' => $container_guid, 'access_id' => $access_id, 'time_created' => $time_created, 'time_updated' => $now, 'last_action' => $now], $this->attributes);
     if (!$result) {
         throw new \IOException("Unable to save new object's base entity information!");
     }
     // for BC with 1.8, ->subtype always returns ID, ->getSubtype() the string
     $this->attributes['subtype'] = (int) $subtype_id;
     $this->attributes['guid'] = (int) $result;
     $this->attributes['time_created'] = (int) $time_created;
     $this->attributes['time_updated'] = (int) $now;
     $this->attributes['last_action'] = (int) $now;
     $this->attributes['container_guid'] = (int) $container_guid;
     // Save any unsaved metadata
     if (sizeof($this->temp_metadata) > 0) {
         foreach ($this->temp_metadata as $name => $value) {
             $this->{$name} = $value;
         }
         $this->temp_metadata = array();
     }
     // Save any unsaved annotations.
     if (sizeof($this->temp_annotations) > 0) {
         foreach ($this->temp_annotations as $name => $value) {
             $this->annotate($name, $value);
         }
         $this->temp_annotations = array();
     }
     // Save any unsaved private settings.
     if (sizeof($this->temp_private_settings) > 0) {
         foreach ($this->temp_private_settings as $name => $value) {
             $this->setPrivateSetting($name, $value);
         }
         $this->temp_private_settings = array();
     }
     return $result;
 }