Пример #1
0
 protected function getOptions()
 {
     $options = parent::getOptions();
     if ($this->banned === true) {
         $options['wheres'][] = "u.banned = 'yes'";
     } elseif ($this->banned === false) {
         $options['wheres'][] = "u.banned = 'no'";
     }
     if ($this->admin === true) {
         $options['wheres'][] = "u.admin = 'yes'";
     } elseif ($this->admin === false) {
         $options['wheres'][] = "u.admin = 'no'";
     }
     if ($this->search) {
         $q = sanitize_string($this->search);
         $where = "u.name LIKE \"%{$q}%\" OR u.username LIKE \"%{$q}%\"";
         if (\elgg_is_admin_logged_in()) {
             $where .= " u.email LIKE \"%{$q}%\"";
         }
         $options['wheres'][] = "({$where})";
     }
     /*
      * "Unvalidated" means metadata of validated is not set or not truthy.
      * We can't use elgg_get_entities_from_metadata() because you can't say
      * "where the entity has metadata set OR it's not equal to 1".
      */
     if ($this->validated === false) {
         $validated_id = \elgg_get_metastring_id('validated');
         $one_id = \elgg_get_metastring_id('1');
         $options['wheres'][] = "NOT EXISTS (\n\t\t\t\tSELECT 1 FROM {$this->getDB()->getPrefix()}metadata validated_md\n\t\t\t\tWHERE validated_md.entity_guid = e.guid\n\t\t\t\t\tAND validated_md.name_id = {$validated_id}\n\t\t\t\t\tAND validated_md.value_id = {$one_id})";
     }
     return $options;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getFilterOptions()
 {
     $options = $this->getOptions();
     $filter_options = array('', 'open', 'closed', 'featured');
     if (elgg_is_logged_in()) {
         $filter_options[] = 'member';
         if (elgg_get_plugin_setting('limited_groups', 'groups') != 'yes' || elgg_is_admin_logged_in()) {
             $filter_options[] = 'admin';
         }
         $filter_options[] = 'invited';
         $filter_options[] = 'membership_request';
     }
     $params = ['list' => $this];
     $filter_options = elgg_trigger_plugin_hook('sort_relationships', 'group', $params, $filter_options);
     $subtypes = elgg_extract('subtype', $options);
     if (!$subtypes) {
         $subtypes = elgg_extract('subtypes', $options);
     }
     if (!empty($subtypes)) {
         $subtypes = (array) $subtypes;
         $subtype = $subtypes[0];
         $filter_options = elgg_trigger_plugin_hook('sort_relationships', "group:{$subtype}", $params, $filter_options);
     }
     return $filter_options;
 }
Пример #3
0
/**
 * External pages page handler
 *
 * @param array  $page    URL segements
 * @param string $handler Handler identifier
 * @return bool
 */
function expages_page_handler($page, $handler)
{
    if ($handler == 'expages') {
        expages_url_forwarder($page[1]);
    }
    $type = strtolower($handler);
    $title = elgg_echo("expages:{$type}");
    $header = elgg_view_title($title);
    $object = elgg_get_entities(array('type' => 'object', 'subtype' => $type, 'limit' => 1));
    if ($object) {
        $content .= elgg_view('output/longtext', array('value' => $object[0]->description));
    } else {
        $content .= elgg_echo("expages:notset");
    }
    $content = elgg_view('expages/wrapper', array('content' => $content));
    if (elgg_is_admin_logged_in()) {
        elgg_register_menu_item('title', array('name' => 'edit', 'text' => elgg_echo('edit'), 'href' => "admin/appearance/expages?type={$type}", 'link_class' => 'elgg-button elgg-button-action'));
    }
    if (elgg_is_logged_in() || !elgg_get_config('walled_garden')) {
        $body = elgg_view_layout('one_column', array('title' => $title, 'content' => $content));
        echo elgg_view_page($title, $body);
    } else {
        elgg_load_css('elgg.walled_garden');
        $body = elgg_view_layout('walled_garden', array('content' => $header . $content));
        echo elgg_view_page($title, $body, 'walled_garden');
    }
    return true;
}
Пример #4
0
/**
 * Set up entity menu for pool objects
 *
 * @param string $hook 'register'
 * @param string $type 'menu:entity'
 * @param ElggMenuItem[] $return
 * @param array $params
 * @return ElggMenuItem[]
 */
function pool_entity_menu($hook, $type, $return, $params)
{
    $handler = elgg_extract('handler', $params, false);
    if ($handler != 'task_pool') {
        return $return;
    }
    if (elgg_is_logged_in()) {
        $entity = $params['entity'];
        $user_guid = elgg_get_logged_in_user_guid();
        if ($entity->isMember($user_guid)) {
            $text = elgg_echo('pool:leave');
        } else {
            $text = elgg_echo('pool:join');
        }
        $return[] = ElggMenuItem::factory(array('name' => 'test', 'text' => "<span>{$text}</span>", 'href' => "action/pool/toggle_membership?pool_guid={$entity->guid}&user_guid={$user_guid}", 'priority' => 150, 'is_action' => true));
        if (elgg_is_admin_logged_in()) {
            $return[] = ElggMenuItem::factory(array('name' => 'edit', 'text' => elgg_echo('edit'), 'href' => "admin/pool/save?guid={$entity->guid}"));
            $return[] = ElggMenuItem::factory(array('name' => 'delete', 'text' => elgg_view_icon('delete'), 'href' => "action/pool/admin/delete?guid={$entity->guid}", 'is_action' => true, 'confirm' => elgg_echo('question:areyousure'), 'priority' => 200));
            if ($entity->countMembers()) {
                $return[] = ElggMenuItem::factory(array('name' => 'shift', 'text' => elgg_echo('pool:shift'), 'href' => "action/pool/shift?guid={$entity->guid}", 'priority' => 150, 'is_action' => true, 'confirm' => elgg_echo('question:areyousure')));
            }
        }
    }
    return $return;
}
Пример #5
0
function au_staff_options($pageowner)
{
    $user = elgg_get_logged_in_user_entity();
    $group = elgg_get_page_owner_entity();
    if (elgg_instanceof($group, 'group')) {
        //check group attributes - ignore if au staff
        if ($group->staff_only_enable == 'yes') {
            elgg_extend_view('group/default', 'groups/sidebar/staff_only', 502);
            //do stuff if this is a staff-only group
            //system_message("AU staff-only group: only AU staff members can join this group");
            if (elgg_is_logged_in()) {
                $invited = check_entity_relationship($group->getGUID(), "invited", $user->getGUID());
                //allow invited users in
                if (is_au_staff_member($user) || elgg_is_admin_logged_in() || $group->canEdit() || $invited) {
                    //do other stuff - welcome here
                } else {
                    //remove buttons for non staff members who are not members of the group and not invited
                    if (!$group->isMember($user)) {
                        elgg_register_plugin_hook_handler('register', 'menu:title', 'au_landing_remove_group_join_button', 9999);
                        //remove the link we added in groups_ux to allow joining from discussion forum
                        elgg_unextend_view('discussion/replies', 'discussion/replies/join');
                    }
                }
            }
        } else {
            //this is a normal group
        }
    } else {
        //not a group, do nothing
    }
}
Пример #6
0
 /**
  * Add some menu items to the entity menu
  *
  * @param string         $hook        "register"
  * @param string         $entity_type "menu:entity"
  * @param ElggMenuItem[] $returnvalue the current menu items
  * @param array          $params      supplied params
  *
  * @return ElggMenuItem[]
  */
 public static function register($hook, $entity_type, $returnvalue, $params)
 {
     if (empty($params) || !is_array($params)) {
         return $returnvalue;
     }
     $entity = elgg_extract("entity", $params);
     if (empty($entity) || !elgg_instanceof($entity, "object", "blog")) {
         return $returnvalue;
     }
     // only published blogs
     if ($entity->status == "draft") {
         return $returnvalue;
     }
     if (!elgg_in_context("widgets") && elgg_is_admin_logged_in()) {
         $returnvalue[] = \ElggMenuItem::factory(array("name" => "blog-feature", "text" => elgg_echo("blog_tools:toggle:feature"), "href" => "action/blog_tools/toggle_metadata?guid=" . $entity->getGUID() . "&metadata=featured", "item_class" => empty($entity->featured) ? "" : "hidden", "is_action" => true, "priority" => 175));
         $returnvalue[] = \ElggMenuItem::factory(array("name" => "blog-unfeature", "text" => elgg_echo("blog_tools:toggle:unfeature"), "href" => "action/blog_tools/toggle_metadata?guid=" . $entity->getGUID() . "&metadata=featured", "item_class" => empty($entity->featured) ? "hidden" : "", "is_action" => true, "priority" => 176));
     }
     if ($entity->canComment()) {
         $returnvalue[] = \ElggMenuItem::factory(array("name" => "comments", "text" => elgg_view_icon("speech-bubble"), "title" => elgg_echo("comment:this"), "href" => $entity->getURL() . "#comments"));
         $comment_count = $entity->countComments();
         if ($comment_count) {
             $returnvalue[] = \ElggMenuItem::factory(array("name" => "comments_count", "text" => $comment_count, "title" => elgg_echo("comments"), "href" => false));
         }
     }
     return $returnvalue;
 }
Пример #7
0
function language_selector_get_allowed_translations()
{
    $configured_allowed = elgg_get_plugin_setting("allowed_languages", "language_selector");
    if (empty($configured_allowed)) {
        $allowed = array("en");
        $installed_languages = get_installed_translations();
        $min_completeness = (int) elgg_get_plugin_setting("min_completeness", "language_selector");
        if ($min_completeness > 0) {
            $update_completeness = false;
            if (elgg_is_active_plugin("translation_editor")) {
                if (elgg_is_admin_logged_in()) {
                    $update_completeness = true;
                }
                $completeness_function = "translation_editor_get_language_completeness";
            } else {
                $completeness_function = "get_language_completeness";
            }
            foreach ($installed_languages as $lang_id => $lang_description) {
                if ($lang_id != "en") {
                    if (($completeness = $completeness_function($lang_id)) >= $min_completeness) {
                        $allowed[] = $lang_id;
                    }
                }
            }
        }
        elgg_set_plugin_setting("allowed_languages", implode(",", $allowed), "language_selector");
    } else {
        $allowed = string_to_tag_array($configured_allowed);
    }
    return $allowed;
}
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function delete(ParameterBag $params)
 {
     if (!elgg_is_admin_logged_in()) {
         throw new GraphException("You are not permitted to delete river items", 403);
     }
     return elgg_delete_river(array('ids' => sanitize_int($params->id)));
 }
Пример #9
0
function zelev_template_init()
{
    // Extend system CSS with our own styles
    //elgg_extend_view('page/elements/elgg','page/elements/header_logo');
    //elgg_extend_view('page/elements/elgg','page/elements/sidebar');
    //elgg_extend_view('css/elements/elgg','css/elements/layout');
    elgg_unregister_menu_item('topbar', 'elgg_logo');
    $logo_url = elgg_get_site_url() . "mod/zelev/zelev_files/logo.png";
    elgg_register_menu_item('topbar', array('name' => 'my_logo', 'href' => '/', 'text' => "<img src=\"{$logo_url}\" alt=\"My logo\" width=\"275\" height=\"45\" />", 'priority' => 1, 'link_class' => 'elgg-topbar-logo'));
    //
    if (!elgg_is_admin_logged_in()) {
        elgg_unregister_page_handler('activity');
    }
    // Replace the default index page
    register_plugin_hook('index', 'system', 'zelev_index');
    elgg_unregister_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
    elgg_unregister_menu_item('site', 'file');
    elgg_unregister_menu_item('site', 'bookmarks');
    elgg_unregister_menu_item('site', 'reportedcontent');
    elgg_unregister_menu_item('site', 'izap-contest');
    elgg_unregister_menu_item('site', 'activity');
    elgg_unregister_menu_item('site', 'groups');
    $item_1 = new ElggMenuItem('homw', elgg_echo('Inicio'), '/');
    elgg_register_menu_item('site', $item_1);
    $user = elgg_get_logged_in_user_entity();
    if ($user) {
        $url = "groups/member/{$user->username}";
        $item = new ElggMenuItem('groups:member', elgg_echo('groups:yours'), $url);
        elgg_register_menu_item('site', $item);
    }
}
Пример #10
0
Файл: start.php Проект: n8b/VMN
function upgrades()
{
    if (elgg_is_admin_logged_in()) {
        elgg_load_library(PLUGIN_ID . ':upgrades');
        run_function_once(__NAMESPACE__ . '\\upgrade_20150321');
    }
}
Пример #11
0
/**
 * Set some views_counter links on elgg system
 */
function views_counter_pagesetup()
{
    if (elgg_is_admin_logged_in() && elgg_get_context() == 'admin' || elgg_get_context() == 'views_counter') {
        $item = new ElggMenuItem('views_counter_admin', elgg_echo('views_counter:admin_page'), elgg_get_site_url() . 'views_counter/list_entities/user');
        elgg_register_menu_item('page', $item);
    }
}
Пример #12
0
function aalborg_theme_pagesetup()
{
    elgg_unextend_view('page/elements/header', 'search/header');
    if (elgg_is_logged_in()) {
        elgg_extend_view('page/elements/sidebar', 'search/header', 0);
    }
    elgg_unregister_menu_item('topbar', 'dashboard');
    if (elgg_is_active_plugin('dashboard')) {
        elgg_register_menu_item('site', array('name' => 'dashboard', 'href' => 'dashboard', 'text' => elgg_echo('dashboard')));
    }
    if (elgg_is_logged_in()) {
        $user = elgg_get_logged_in_user_entity();
        elgg_register_menu_item('topbar', array('name' => 'account', 'text' => elgg_echo('account'), 'href' => "#", 'priority' => 100, 'section' => 'alt', 'link_class' => 'elgg-topbar-dropdown'));
        elgg_unregister_menu_item('topbar', 'usersettings');
        elgg_register_menu_item('topbar', array('name' => 'usersettings', 'parent_name' => 'account', 'href' => "/settings/user/{$user->username}", 'text' => elgg_echo('settings'), 'priority' => 103, 'section' => 'alt'));
        elgg_unregister_menu_item('topbar', 'logout');
        elgg_register_menu_item('topbar', array('name' => 'logout', 'parent_name' => 'account', 'href' => '/action/logout', 'is_action' => TRUE, 'text' => elgg_echo('logout'), 'priority' => 104, 'section' => 'alt'));
        elgg_unregister_menu_item('topbar', 'administration');
        if (elgg_is_admin_logged_in()) {
            elgg_register_menu_item('topbar', array('name' => 'administration', 'parent_name' => 'account', 'href' => 'admin', 'text' => elgg_echo('admin'), 'priority' => 101, 'section' => 'alt'));
        }
        elgg_unregister_menu_item('footer', 'report_this');
        if (elgg_is_active_plugin('reportedcontent')) {
            $href = "javascript:elgg.forward('reportedcontent/add'";
            $href .= "+'?address='+encodeURIComponent(location.href)";
            $href .= "+'&title='+encodeURIComponent(document.title));";
            elgg_register_menu_item('extras', array('name' => 'report_this', 'href' => $href, 'title' => elgg_echo('reportedcontent:this:tooltip'), 'text' => elgg_view_icon('report-this'), 'priority' => 500));
        }
    }
}
Пример #13
0
function widget_manager_pagesetup()
{
    $context = elgg_get_context();
    if (elgg_is_admin_logged_in() && $context == "admin") {
        // move defaultwidgets menu item
        elgg_unregister_menu_item("page", "appearance:default_widgets");
        elgg_register_menu_item('page', array('name' => "appearance:default_widgets", 'href' => "admin/appearance/default_widgets", 'text' => elgg_echo("admin:appearance:default_widgets"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
        // add own menu items
        elgg_register_admin_menu_item('configure', 'manage', 'widgets');
        if (elgg_get_plugin_setting("custom_index", "widget_manager") == "1|0") {
            // a special link to manage homepages that are only available if logged out
            elgg_register_menu_item('page', array('name' => "admin:widgets:manage:index", 'href' => elgg_get_site_url() . "?override=true", 'text' => elgg_echo("admin:widgets:manage:index"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
        }
    }
    // update fixed widgets if needed
    if (in_array($context, array("profile", "dashboard")) && ($page_owner_guid = elgg_get_page_owner_guid())) {
        // only check things if you are viewing a profile or dashboard page
        $fixed_ts = elgg_get_plugin_setting($context . "_fixed_ts", "widget_manager");
        if (empty($fixed_ts)) {
            // there should always be a fixed ts, so fix it now. This situation only occurs after activating widget_manager the first time.
            $fixed_ts = time();
            elgg_set_plugin_setting($context . "_fixed_ts", $fixed_ts, "widget_manager");
        }
        // get the ts of the profile/dashboard you are viewing
        $user_fixed_ts = elgg_get_plugin_user_setting($context . "_fixed_ts", $page_owner_guid, "widget_manager");
        if ($user_fixed_ts < $fixed_ts) {
            widget_manager_update_fixed_widgets($context, $page_owner_guid);
        }
    }
    if (widget_manager_multi_dashboard_enabled()) {
        if (get_input("internal_dashboard") == "yes") {
            elgg_set_view_location("page/default", dirname(__FILE__) . "/views_alt/");
        }
    }
}
Пример #14
0
/**
 * Returns toolbar settings
 *
 * @param string $type User type 'admin'|'user'
 * @return array
 */
function ckeditor_addons_get_toolbar($type = null)
{
    $toolbar_config = elgg_get_plugin_setting('toolbar_config', 'ckeditor_addons');
    if ($toolbar_config) {
        $toolbar_config = unserialize($toolbar_config);
    } else {
        $toolbar_config = array();
    }
    if (!$type) {
        $type = elgg_is_admin_logged_in() ? 'admin' : 'user';
    }
    $toolbar = elgg_extract($type, $toolbar_config, ckeditor_addons_get_toolbar_defaults());
    $options = ckeditor_addons_get_toolbar_options();
    foreach ($options as $group => $buttons) {
        foreach ($buttons as $key => $button) {
            if (!in_array($button, $toolbar)) {
                unset($options[$group][$key]);
            }
        }
        if (empty($options[$group])) {
            unset($options[$group]);
        } else {
            $options[$group] = array_values($options[$group]);
        }
    }
    return array_values($options);
}
Пример #15
0
/**
 * Profile page handler
 *
 * @param array $page Array of URL segments passed by the page handling mechanism
 * @return bool
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    } elseif (elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return true;
    }
    $content = elgg_view('profile/layout', array('entity' => $user));
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($user->name, $body);
    return true;
}
Пример #16
0
 public function canPost()
 {
     // check for if antispam is enabled in settings, send true if it is disabled
     if (!$this->isEnabled()) {
         return TRUE;
     }
     // if already marked as sapammer
     if ($this->isSpammer()) {
         register_error(elgg_echo('izap-antispam:spammer_notice'));
         return FALSE;
     }
     // check for the admins
     if (elgg_is_admin_logged_in()) {
         return TRUE;
     }
     // low level
     if ($this->lastAction() < $this->consicutive_post_time) {
         return $this->firstCheck();
     } else {
         // reset the consicutive tries
         $this->user->izap_consicutive_try = 0;
     }
     // moderate level
     if ($this->isBetweenAvgInterval()) {
         return $this->secondCheck();
     }
     return TRUE;
 }
Пример #17
0
/**
 * initialization of plugin
 *
 * @return void
 */
function advanced_statistics_init()
{
    // register page handler for nice URLs
    elgg_register_page_handler("advanced_statistics", "advanced_statistics_page_handler");
    if (elgg_is_admin_logged_in()) {
        elgg_register_admin_menu_item('administer', 'users', 'advanced_statistics');
        elgg_register_admin_menu_item('administer', 'groups', 'advanced_statistics');
        elgg_register_admin_menu_item('administer', 'content', 'advanced_statistics');
        elgg_register_admin_menu_item('administer', 'activity', 'advanced_statistics');
        elgg_register_admin_menu_item('administer', 'widgets', 'advanced_statistics');
        elgg_register_admin_menu_item('administer', 'system', 'advanced_statistics');
        elgg_extend_view("js/admin", "js/advanced_statistics/admin");
        $vendors = elgg_get_site_url() . "mod/advanced_statistics/vendors/";
        elgg_register_js("excanvas", $vendors . "jqplot/excanvas.min.js");
        // only for IE < 9
        // jqplot base library
        elgg_register_js("jquery.jqplot", $vendors . "jqplot/jquery.jqplot.js");
        // jqplot plugins
        elgg_register_js("jquery.jqplot.barRenderer", $vendors . "jqplot/plugins/jqplot.barRenderer.js");
        elgg_register_js("jquery.jqplot.pieRenderer", $vendors . "jqplot/plugins/jqplot.pieRenderer.js");
        elgg_register_js("jquery.jqplot.canvasAxisTickRenderer", $vendors . "jqplot/plugins/jqplot.canvasAxisTickRenderer.js");
        elgg_register_js("jquery.jqplot.canvasTextRenderer", $vendors . "jqplot/plugins/jqplot.canvasTextRenderer.js");
        elgg_register_js("jquery.jqplot.categoryAxisRenderer", $vendors . "jqplot/plugins/jqplot.categoryAxisRenderer.js");
        elgg_register_js("jquery.jqplot.dateAxisRenderer", $vendors . "jqplot/plugins/jqplot.dateAxisRenderer.js");
        elgg_register_js("jquery.jqplot.pointLabels", $vendors . "jqplot/plugins/jqplot.pointLabels.js");
        elgg_register_js("jquery.jqplot.highlighter", $vendors . "jqplot/plugins/jqplot.highlighter.js");
        elgg_register_simplecache_view("css/advanced_statistics/jqplot");
        elgg_register_css("jquery.jqplot", elgg_get_simplecache_url("css", "advanced_statistics/jqplot"));
        // register admin widgets
        elgg_register_widget_type("advanced_statistics", elgg_echo("advanced_statistics:widgets:advanced_statistics:title"), elgg_echo("advanced_statistics:widgets:advanced_statistics:description"), array("admin"), true);
        elgg_register_widget_type("online_user_count", elgg_echo("advanced_statistics:widgets:online_user_count:title"), elgg_echo("advanced_statistics:widgets:online_user_count:description"), array("admin"));
        elgg_register_ajax_view("widgets/online_user_count/content");
    }
}
Пример #18
0
function faq_init()
{
    // Extend CSS
    elgg_extend_view("css/elgg", "faq/css");
    if (elgg_get_plugin_setting("publicAvailable", "faq") == "yes" || elgg_is_admin_logged_in()) {
        // Register a page handler, so we can have nice URLs
        elgg_register_page_handler('faq', 'faq_page_handler');
        if (elgg_get_plugin_setting("publicAvailable_sitemenu", "faq") == "yes" || elgg_is_logged_in()) {
            // Add menu item
            elgg_register_menu_item('site', array('name' => elgg_echo("faq:shorttitle"), 'text' => elgg_echo("faq:shorttitle"), 'href' => elgg_get_site_url() . "faq/"));
        }
        if (elgg_get_plugin_setting("publicAvailable_footerlink", "faq") == "yes" || elgg_is_logged_in()) {
            // Add footer link
            faq_setup_footer_menu();
        }
        // Register faq pages as public pages for walled-garden
        elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'faq_public');
        // Register Actions
        $base_dir = elgg_get_plugins_path() . 'faq/actions/faq/';
        elgg_register_action("faq/add", $base_dir . "add.php", "admin");
        elgg_register_action("faq/delete", $base_dir . "delete.php", "admin");
        elgg_register_action("faq/edit", $base_dir . "edit.php", "admin");
        elgg_register_action("faq/search", $base_dir . "search.php", "public");
        elgg_register_action("faq/changeCategory", $base_dir . "changeCategory.php", "admin");
        if (elgg_get_plugin_setting("userQuestions", "faq") == "yes") {
            elgg_register_action("faq/ask", $base_dir . "ask.php", "logged_in");
            elgg_register_action("faq/answer", $base_dir . "answer.php", "admin");
        }
        // Register FAQs for site search
        elgg_register_entity_type("object", "faq");
        elgg_register_plugin_hook_handler('search', 'object:faq', 'faq_search_hook');
    }
}
Пример #19
0
function init()
{
    if (is_on_probation()) {
        // don't allow sending messages
        elgg_unregister_action('messages/send');
        elgg_register_plugin_hook_handler('register', 'menu:topbar', __NAMESPACE__ . '\\hook_register_menu_topbar', 999);
        // don't allow group creation
        elgg_unregister_action('groups/edit');
        elgg_register_plugin_hook_handler('register', 'menu:title', __NAMESPACE__ . '\\hook_register_title_menu', 999);
        // mark content as probationary and make it private.
        if (elgg_get_plugin_setting(QUARANTINE_CONTENT, PLUGIN_ID)) {
            elgg_register_event_handler('create', 'object', __NAMESPACE__ . '\\event_create_object');
            elgg_register_event_handler('update', 'object', __NAMESPACE__ . '\\event_update_object');
        }
    }
    if (elgg_is_admin_logged_in()) {
        elgg_register_admin_menu_item('administer', 'probation', 'users');
        // Add approval links to entity menus
        elgg_register_plugin_hook_handler('prepare', 'menu:entity', __NAMESPACE__ . '\\hook_prepare_entity_menu', 999);
    }
    // show message above user profile
    elgg_extend_view('profile/details', 'probation/profile_details_400', 400);
    elgg_register_action('probation/approve_content', __DIR__ . '/actions/probation/approve_content.php', 'admin');
    elgg_register_action('probation/approve_user', __DIR__ . '/actions/probation/approve_user.php', 'admin');
    // hiding "Send message" or adding "Remove probation"
    elgg_register_plugin_hook_handler('register', 'menu:user_hover', __NAMESPACE__ . '\\hook_register_hover_menu', 999);
    // put all newly-enabled users on probation
    elgg_register_event_handler('enable', 'user', __NAMESPACE__ . '\\event_enable_user');
    // we don't enqueue notification events for probationary content
    elgg_register_plugin_hook_handler('enqueue', 'notification', __NAMESPACE__ . '\\hook_enqueue_notification');
    // nor do we allow notify_user() for comments/replies
    elgg_register_plugin_hook_handler('email', 'system', __NAMESPACE__ . '\\hook_email_system', 1);
    elgg_register_event_handler('shutdown', 'system', __NAMESPACE__ . '\\event_shutdown');
}
Пример #20
0
/**
 * river_comments
 *
 * @author Pedro Prez (modificado por mariano tomasini forosdroid.com)
 * @link http://community.elgg.org/pg/profile/pedroprez
 * @copyright (c) Keetup 2010
 * @link http://www.keetup.com/
 * @license GNU General Public License (GPL) version 2
 */
function river_comments_init()
{
    global $CONFIG;
    elgg_register_js('ui.widgets', $CONFIG->wwwroot . "mod/river_comments/js/lib/ui.widgets.js");
    //Page Handler
    elgg_register_page_handler('river_comments', 'river_comments_page_handler');
    //Extend css view
    elgg_extend_view('css/elgg', 'river_comments/css');
    //Elastic Plugin
    elgg_extend_view('page/elements/footer', 'river_comments/footer', 400);
    //Extend js view on riverdashboard
    elgg_extend_view('page/elements/footer', 'river_comments/js', 450);
    elgg_extend_view('riverdashboard/js', 'river_comments/riverdashboardjs');
    elgg_extend_view('page/elements/comments', 'river_comments/comments');
    //View for river actions
    elgg_extend_view('river/item/actions', 'river_comments/item_action');
    elgg_extend_view('river/elements/responses', 'river/responses');
    //Print the plugin version
    elgg_extend_view('head', 'river_comments/version');
    if (elgg_is_admin_logged_in()) {
        elgg_extend_view('page_elements/header_contents', 'river_comments/comments');
    }
    //Actions
    $actions_path = elgg_get_plugins_path() . "river_comments/actions/river_comments";
    elgg_register_action("river_comments/add", "{$actions_path}/add.php");
    elgg_register_action("river_comments/delete", "{$actions_path}/delete.php");
}
Пример #21
0
 /**
  * Add a menu item to the user hover dropdown
  *
  * @param string          $hook         the name of the hook
  * @param string          $type         the type of the hook
  * @param \ElggMenuItem[] $return_value current menu items
  * @param array           $params       supplied params
  *
  * @return void|\ElggMenuItem[]
  */
 public static function register($hook, $type, $return_value, $params)
 {
     static $user_dirs;
     if (!elgg_is_admin_logged_in()) {
         return;
     }
     if (empty($params) || !is_array($params)) {
         return;
     }
     $user = elgg_extract('entity', $params);
     if (!$user instanceof \ElggUser) {
         return;
     }
     if (!isset($user_dirs)) {
         $user_dirs = [];
     }
     // save in a static for performance when viewing user listings
     if (!isset($user_dirs[$user->getGUID()])) {
         $user_dirs[$user->getGUID()] = false;
         $edl = new \Elgg\EntityDirLocator($user->getGUID());
         $path = $edl->getPath();
         if (is_dir(elgg_get_data_path() . $path)) {
             $path = substr($path, 0, -1);
             $user_dirs[$user->getGUID()] = \ElggMenuItem::factory(['name' => 'dataroot-browser', 'text' => elgg_echo('dataroot_browser:menu:user_hover'), 'href' => elgg_http_add_url_query_elements('admin/administer_utilities/dataroot_browser', ['dir' => $path]), 'is_trusted' => true, 'section' => 'admin']);
         }
     }
     if (empty($user_dirs[$user->getGUID()])) {
         return;
     }
     $return_value[] = $user_dirs[$user->getGUID()];
     return $return_value;
 }
Пример #22
0
/**
 * Profile page handler
 *
 * @param array $page Array of page elements, forwarded by the page handling mechanism
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        $base_dir = elgg_get_root_path();
        require "{$base_dir}pages/profile/edit.php";
        return;
    }
    // main profile page
    $params = array('content' => elgg_view('profile/wrapper'), 'num_columns' => 3);
    $content = elgg_view_layout('widgets', $params);
    $body = elgg_view_layout('one_column', array('content' => $content));
    echo elgg_view_page($title, $body);
}
Пример #23
0
/**
 *
 * Initializes the Roles plugin
 */
function roles_init($event, $type, $object)
{
    elgg_register_library('roles', elgg_get_plugins_path() . 'roles/lib/roles.php');
    elgg_register_library('roles_config', elgg_get_plugins_path() . 'roles/lib/config.php');
    elgg_load_library('roles');
    elgg_load_library('roles_config');
    // Provides default roles by own handler. This should be extended by site specific handlers
    elgg_register_plugin_hook_handler('roles:config', 'role', 'roles_get_roles_config');
    // Catch all actions and page route requests
    elgg_register_plugin_hook_handler('action', 'all', 'roles_actions_permissions');
    elgg_register_plugin_hook_handler('route', 'all', 'roles_pages_permissions');
    // Due to dynamically created (or extended) menus, we need to catch all 'register' hooks _after_ other modules added/removed their menu items
    elgg_register_plugin_hook_handler('register', 'all', 'roles_menus_permissions', 9999);
    // Set up roles based hooks and event listener, after all plugin is initialized
    elgg_register_event_handler('ready', 'system', 'roles_hooks_permissions');
    elgg_register_event_handler('ready', 'system', 'roles_events_permissions');
    // Check for role configuration updates
    if (elgg_is_admin_logged_in()) {
        // @TODO think through if this should rather be a role-based permission
        run_function_once('roles_update_100_to_101');
        elgg_register_event_handler('ready', 'system', 'roles_check_update');
    }
    // Set up roles based view management
    elgg_register_event_handler('ready', 'system', 'roles_register_views');
}
Пример #24
0
/**
 * Profile page handler
 *
 * @param array $page Array of URL segments passed by the page handling mechanism
 * @return bool
 */
function profile_page_handler($page)
{
    if (isset($page[0])) {
        $username = $page[0];
        $user = get_user_by_username($username);
        elgg_set_page_owner_guid($user->guid);
    } elseif (elgg_is_logged_in()) {
        forward(elgg_get_logged_in_user_entity()->getURL());
    }
    // short circuit if invalid or banned username
    if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) {
        register_error(elgg_echo('profile:notfound'));
        forward();
    }
    $action = NULL;
    if (isset($page[1])) {
        $action = $page[1];
    }
    if ($action == 'edit') {
        // use the core profile edit page
        echo elgg_view_resource('profile/edit');
        return true;
    }
    echo elgg_view_resource('profile/view', ['username' => $page[0]]);
    return true;
}
Пример #25
0
function theme_ffd_entity_hook($hook_name, $entity_type, $return_value, $params)
{
    $entity = elgg_extract("entity", $params);
    if (elgg_instanceof($entity, 'object', 'question') | elgg_instanceof($entity, 'object', 'cafe')) {
        if (elgg_is_logged_in() && elgg_is_active_plugin("content_subscriptions")) {
            if (!content_subscriptions_check_subscription($entity->guid)) {
                $url = "action/content_subscriptions/subscribe?entity_guid=" . $entity->getGUID();
                $text = elgg_view_icon('clip', 'mrs') . elgg_echo('theme_ffd:questions:menu:subscribe');
            } else {
                $url = "action/content_subscriptions/subscribe?entity_guid=" . $entity->getGUID();
                $text = elgg_view_icon('clip', 'mrs') . elgg_echo('theme_ffd:questions:menu:unsubscribe');
            }
            $return_value[] = ElggMenuItem::factory(array("name" => "content_subscription", "text" => $text, "href" => $url, 'is_action' => true, "priority" => 90));
        }
    }
    if (elgg_instanceof($entity, 'object', 'page_top')) {
        foreach ($return_value as $key => $item) {
            $name = $item->getName();
            if ($name == "history" && !elgg_is_admin_logged_in()) {
                unset($return_value[$key]);
            }
            if ($name == "export" && !elgg_is_admin_logged_in()) {
                unset($return_value[$key]);
            }
        }
    }
    return $return_value;
}
Пример #26
0
/**
 * Clean up operations on calendar delete
 *
 * @param string     $event  "delete"
 * @param string     $type   "object"
 * @param ElggEntity $entity Entity being deleted
 */
function delete_event_handler($event, $type, $entity)
{
    if ($entity instanceof Calendar) {
        // Do not allow users to delete publi calendars
        if ($entity->isPublicCalendar() && !elgg_is_admin_logged_in()) {
            register_error(elgg_echo('events:error:public_calendar_delete'));
            return false;
        }
        // Move all orphaned events to the public calendar
        $owner = $entity->getContainerEntity();
        $public_calendar = Calendar::getPublicCalendar($owner);
        if (!$public_calendar) {
            register_error(elgg_echo('events:error:no_public_for_orphans'));
            return false;
        }
        $dbprefix = elgg_get_config('dbprefix');
        $relationship_name = sanitize_string(Calendar::EVENT_CALENDAR_RELATIONSHIP);
        $calendar_subtype_id = (int) get_subtype_id('object', Calendar::SUBTYPE);
        // Get all events that do not appear on container's other calendars
        $events = new ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => Event::SUBTYPE, 'relationship' => Calendar::EVENT_CALENDAR_RELATIONSHIP, 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => 0, 'wheres' => array("NOT EXISTS(SELECT * FROM {$dbprefix}entity_relationships er2\n\t\t\t\t\tJOIN {$dbprefix}entities e2 ON er2.guid_two = e2.guid\n\t\t\t\t\tWHERE er2.relationship = '{$relationship_name}'\n\t\t\t\t\t\tAND er2.guid_one = e.guid\n\t\t\t\t\t\tAND er2.guid_two != {$entity->guid}\n\t\t\t\t\t\tAND e2.container_guid = {$entity->container_guid}\n\t\t\t\t\t\tAND e2.type = 'object' AND e2.subtype = {$calendar_subtype_id})")));
        foreach ($events as $event) {
            /* @var Event $event */
            $public_calendar->addEvent($event);
        }
    }
    return true;
}
Пример #27
0
Файл: start.php Проект: n8b/VMN
/**
 * Init function for Menu Builder
 *
 * @return void
 */
function menu_builder_init()
{
    elgg_extend_view("navigation/menu/site", "menu_builder/site_menu_extend");
    elgg_extend_view("css/elgg", "menu_builder/css/site");
    // register pagehandler for nice URL's
    elgg_register_page_handler("menu_builder", "menu_builder_page_handler");
    // switch mode
    if (elgg_is_admin_logged_in()) {
        elgg_register_plugin_hook_handler("access:collections:write", "user", "menu_builder_write_access_hook");
        if (get_input("menu_builder_edit_mode") == "on") {
            $_SESSION["menu_builder_edit_mode"] = true;
        } elseif (get_input("menu_builder_edit_mode") == "off") {
            unset($_SESSION["menu_builder_edit_mode"]);
            unset($_SESSION["menu_builder_logged_out"]);
        }
        if (get_input("menu_builder_logged_out") == "on") {
            $_SESSION["menu_builder_logged_out"] = true;
        } elseif (get_input("menu_builder_logged_out") == "off") {
            unset($_SESSION["menu_builder_logged_out"]);
        }
    } else {
        unset($_SESSION["menu_builder_edit_mode"]);
        unset($_SESSION["menu_builder_logged_out"]);
    }
    // register url handler for menu_builder objects
    elgg_register_entity_url_handler("object", MENU_BUILDER_SUBTYPE, "menu_builder_menu_item_url_handler");
    // take control of menu setup
    elgg_unregister_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
    elgg_register_plugin_hook_handler('prepare', 'menu:site', 'menu_builder_site_menu_prepare');
    elgg_register_plugin_hook_handler('register', 'menu:site', 'menu_builder_site_menu_register');
}
Пример #28
0
/**
 * Set a user's password
 * 
 * @return bool
 * @since 1.8.0
 * @access private
 */
function elgg_set_user_password()
{
    $current_password = get_input('current_password', null, false);
    $password = get_input('password', null, false);
    $password2 = get_input('password2', null, false);
    $user_guid = get_input('guid');
    if (!$user_guid) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_guid);
    }
    if ($user && $password) {
        // let admin user change anyone's password without knowing it except his own.
        if (!elgg_is_admin_logged_in() || elgg_is_admin_logged_in() && $user->guid == elgg_get_logged_in_user_guid()) {
            $credentials = array('username' => $user->username, 'password' => $current_password);
            try {
                pam_auth_userpass($credentials);
            } catch (LoginException $e) {
                register_error(elgg_echo('LoginException:ChangePasswordFailure'));
                return false;
            }
        }
        try {
            $result = validate_password($password);
        } catch (RegistrationException $e) {
            register_error($e->getMessage());
            return false;
        }
        if ($result) {
            if ($password == $password2) {
                $user->salt = _elgg_generate_password_salt();
                $user->password = generate_user_password($user, $password);
                $user->code = '';
                if ($user->guid == elgg_get_logged_in_user_guid() && !empty($_COOKIE['elggperm'])) {
                    // regenerate remember me code so no other user could
                    // use it to authenticate later
                    $code = _elgg_generate_remember_me_token();
                    $_SESSION['code'] = $code;
                    $user->code = md5($code);
                    setcookie("elggperm", $code, time() + 86400 * 30, "/");
                }
                if ($user->save()) {
                    system_message(elgg_echo('user:password:success'));
                    return true;
                } else {
                    register_error(elgg_echo('user:password:fail'));
                }
            } else {
                register_error(elgg_echo('user:password:fail:notsame'));
            }
        } else {
            register_error(elgg_echo('user:password:fail:tooshort'));
        }
    } else {
        // no change
        return null;
    }
    return false;
}
Пример #29
0
function upgrades()
{
    if (!elgg_is_admin_logged_in()) {
        return true;
    }
    elgg_load_library(__NAMESPACE__ . '\\upgrades');
    run_function_once(__NAMESPACE__ . '\\upgrade_20141130');
}
Пример #30
0
 /**
  * Returns a form element object
  *
  * @param mixed  $entity ElggEntity or an array of entity attributes
  * @param string $action Action name (used as a plugin hook type)
  * @param array  $params Additional context params to pass to the hook
  * @return Elements\Profile
  */
 public function with($entity = array(), $action = 'all', array $params = array())
 {
     $entity = $this->entityFactory->build($entity);
     $fields = $this->prototype->fields($entity, $action, $params)->filter(function (Elements\Field $field) {
         return !$field->isAdminOnly() || elgg_is_admin_logged_in();
     })->sort();
     return new Elements\Profile($entity, $action, $fields);
 }