Пример #1
0
/**
 * Adds the filter menu for todos
 *
 * @param string         $hook   name of the hook
 * @param string         $type   type of the hook
 * @param ElggMenuItem[] $return return value
 * @param array          $params hook parameters
 *
 * @return ElggMenuItem[]
 */
function todos_filter_menu_register($hook, $type, $return, $params)
{
    if (elgg_get_context() !== 'todos') {
        return $return;
    }
    $page_owner = elgg_get_page_owner_entity();
    if (todos_enabled_for_container($page_owner)) {
        $base_url = 'todos';
        if (elgg_instanceof($page_owner, 'group')) {
            $base_url .= "/group/{$page_owner->getGUID()}/all";
        }
        $return[] = ElggMenuItem::factory(array('name' => 'active', 'text' => elgg_echo('todos:filter:active'), 'href' => $base_url));
        $return[] = ElggMenuItem::factory(array('name' => 'completed', 'text' => elgg_echo('todos:filter:completed'), 'href' => "{$base_url}?filter=completed"));
        if ($page_owner instanceof ElggGroup) {
            $return[] = ElggMenuItem::factory(array('name' => 'assigned_per_user', 'text' => elgg_echo('todos:filter:assigned_per_user'), 'href' => "todos/assigned_per_user/{$page_owner->getGUID()}"));
        }
        $return[] = ElggMenuItem::factory(array('name' => 'overdue', 'text' => elgg_echo('todos:filter:overdue'), 'href' => "{$base_url}?filter=overdue"));
    }
    $user = elgg_get_logged_in_user_entity();
    if (!empty($user)) {
        $href = "todos/assigned/{$user->username}";
        if (elgg_instanceof($page_owner, 'group')) {
            $href .= "/{$page_owner->getGUID()}";
        }
        $return[] = ElggMenuItem::factory(array('name' => 'assigned', 'text' => elgg_echo('todos:filter:assigned'), 'href' => $href));
    }
    return $return;
}
Пример #2
0
function friend_request_pagesetup()
{
    $context = elgg_get_context();
    $page_owner = elgg_get_page_owner_entity();
    // Remove link to friendsof
    elgg_unregister_menu_item("page", "friends:of");
    if ($user = elgg_get_logged_in_user_entity()) {
        $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
        if ($count = elgg_get_entities_from_relationship($options)) {
            $params = array("name" => "friend_request", "href" => "friend_request/" . $user->username, "text" => elgg_view_icon("user") . "<span class='friend-request-new'>" . $count . "</span>", "title" => elgg_echo("friend_request:menu"), "priority" => 301);
            elgg_register_menu_item("topbar", $params);
        }
    }
    // Show menu link in the correct context
    if (in_array($context, array("friends", "friendsof", "collections", "messages")) && !empty($page_owner) && $page_owner->canEdit()) {
        $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
        if ($count = elgg_get_entities_from_relationship($options)) {
            $extra = " [" . $count . "]";
        } else {
            $extra = "";
        }
        // add menu item
        $menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections", "messages"), "section" => "friend_request");
        elgg_register_menu_item("page", $menu_item);
    }
}
Пример #3
0
/**
 * Sets up submenus. Triggered on pagesetup.
 *
 */
function add_submenus()
{
    $plugins_base = elgg_get_site_url() . "plugins";
    if (elgg_get_context() == 'admin') {
        elgg_register_admin_menu_item('administer', 'statistics', 'community_plugins');
        elgg_register_admin_menu_item('administer', 'utilities', 'community_plugins');
        elgg_register_admin_menu_item('configure', 'community_plugins', 'settings');
        return;
    }
    if (elgg_get_context() != "plugins") {
        return;
    }
    $page_owner = elgg_get_page_owner_entity();
    if (elgg_is_logged_in() && elgg_get_page_owner_guid() == elgg_get_logged_in_user_guid()) {
        elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:yours', 'text' => elgg_echo("plugins:yours", array(elgg_echo('plugins:types:')))));
    } else {
        if (elgg_get_page_owner_guid()) {
            $title = elgg_echo("plugins:user", array($page_owner->name, elgg_echo('plugins:types:')));
            elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:user', 'text' => $title));
        }
    }
    elgg_register_menu_item('page', array('href' => '/plugins', 'name' => 'plugins:all', 'text' => elgg_echo('plugins:all')));
    // add upload link when viewing own plugin page
    if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
        elgg_register_menu_item('page', array('href' => "{$plugins_base}/new/project/{$page_owner->username}", 'name' => 'plugins:upload', 'text' => elgg_echo('plugins:upload')));
    }
}
Пример #4
0
function pleiofile_pagesetup()
{
    $page_owner = elgg_get_page_owner_entity();
    if ($page_owner->file_enable == "no") {
        elgg_unregister_widget_type("group_files");
    }
}
Пример #5
0
 /**
  * https://github.com/Elgg/Elgg/pull/6393
  * Hook handlers for 'access:collections:write','all' hook should respect
  * group's content access mode and container write permissions
  */
 public function testWriteAccessArray()
 {
     $membersonly = ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY;
     $unrestricted = ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
     $original_page_owner = elgg_get_page_owner_entity();
     elgg_set_page_owner_guid($this->group->guid);
     $ia = elgg_set_ignore_access(false);
     // User is not a member of the group
     // Member-only group
     $this->group->setContentAccessMode($membersonly);
     $write_access = get_write_access_array($this->user->guid, true);
     $this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
     // Unrestricted group
     $this->group->setContentAccessMode($unrestricted);
     $write_access = get_write_access_array($this->user->guid, true);
     $this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
     // User is a member (can write to container)
     $this->group->join($this->user);
     // Member-only group
     $this->group->setContentAccessMode($membersonly);
     $write_access = get_write_access_array($this->user->guid, true);
     $this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
     // Unrestricted group
     $this->group->setContentAccessMode($unrestricted);
     $write_access = get_write_access_array($this->user->guid, true);
     $this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
     elgg_set_ignore_access($ia);
     $this->group->leave($this->user);
     $original_page_owner_guid = elgg_instanceof($original_page_owner) ? $original_page_owner->guid : 0;
     elgg_set_page_owner_guid($original_page_owner_guid);
 }
Пример #6
0
function hflts_page_handler($page)
{
    if (elgg_extract(0, $page) === 'collective') {
        $content = elgg_view('hflts/collective', array('nAlternativas' => $page[1], 'nCriterios' => $page[2], 'nExpertos' => $page[3], 'G' => $page[4], 'import_file' => $page[5], 'weight_file' => $page[6]));
        $params = array('title' => 'DM con datos de samples/set_' . $page[5] . '.csv (' . $page[6] . ')', 'content' => $content, 'filter' => '');
        $body = elgg_view_layout('content', $params);
        echo elgg_view_page('hflts', $body);
        return true;
    }
    set_input('username', $page[0]);
    //necesario
    $user = elgg_get_page_owner_entity();
    // ej strem
    $guid = elgg_get_page_owner_guid();
    // id de strem
    //aqui es donde tengo que filtrar por guid como en https://elgg.org/discussion/view/2268999/doubt-in-elgg-get-entities-from-metadata
    $valorations = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'evaluation_content', 'metadata_name_value_pairs' => array('name' => 'user_guid', 'value' => $guid), 'limit' => $vars['entity']->num_display, 'pagination' => false, 'order_by_metadata' => ['name' => 'state', 'direction' => 'ASC', 'as' => 'text']]);
    if (!$valorations) {
        $valorations = '<p class="mtm">' . elgg_echo('evaluationcontent:none') . '</p>';
    }
    $content = elgg_view('hflts/driver', array('valorations' => $valorations));
    $params = array('title' => 'Valoraciones de ' . $user->name, 'content' => $content, 'filter' => '');
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page('hflts', $body);
}
Пример #7
0
/**
 * Register some menu items for friends UI
 * @access private
 */
function _elgg_friends_page_setup() {
	$owner = elgg_get_page_owner_entity();
	$viewer = elgg_get_logged_in_user_entity();

	if ($owner) {
		$params = array(
			'name' => 'friends',
			'text' => elgg_echo('friends'),
			'href' => 'friends/' . $owner->username,
			'contexts' => array('friends')
		);
		elgg_register_menu_item('page', $params);

		$params = array(
			'name' => 'friends:of',
			'text' => elgg_echo('friends:of'),
			'href' => 'friendsof/' . $owner->username,
			'contexts' => array('friends')
		);
		elgg_register_menu_item('page', $params);
	}

	// topbar
	if ($viewer) {
		elgg_register_menu_item('topbar', array(
			'name' => 'friends',
			'href' => "friends/{$viewer->username}",
			'text' => elgg_view_icon('users'),
			'title' => elgg_echo('friends'),
			'priority' => 300,
		));
	}
}
Пример #8
0
/**
 * Page setup event
 */
function pagesetup()
{
    $group = elgg_get_page_owner_entity();
    if (!$group instanceof \ElggGroup) {
        return true;
    }
    $position = $group->au_group_notice_position;
    switch ($position) {
        case 'top':
            elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 499);
            break;
        case 'bottom':
            elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 501);
            break;
        case 'sidebottom':
            elgg_extend_view('page/elements/sidebar', 'au_group_notices/au_group_notices_show', 600);
            break;
        case 'sidetop':
            elgg_extend_view('group/default', 'au_group_notices/au_group_notices_show', 100);
            break;
        default:
            // do nothing - if position not set, no settings provided
            break;
    }
}
Пример #9
0
/**
 * Returns a ACL for use in widgets
 *
 * @param string $hook_name    name of the hook
 * @param string $entity_type  type of the hook
 * @param string $return_value current return value
 * @param array  $params       hook parameters
 *
 * @return array
 */
function widget_manager_write_access_hook($hook_name, $entity_type, $return_value, $params)
{
    if (!elgg_in_context('widget_access')) {
        return $return_value;
    }
    $widget = elgg_extract('entity', $params['input_params']);
    if ($widget instanceof ElggWidget) {
        $widget_context = $widget->context;
        if ($widget_context == 'groups') {
            $group = $widget->getContainerEntity();
            if (!empty($group->group_acl)) {
                $return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            }
        } elseif ($widget->getContainerGUID() === elgg_get_site_entity()->getGUID()) {
            // admins only have the following options for index widgets
            if (elgg_is_admin_logged_in()) {
                $return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            } elseif (elgg_can_edit_widget_layout($widget_context)) {
                // for non admins that can manage this widget context
                $return_value = [ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
            }
        }
    } elseif (elgg_in_context('index') && elgg_is_admin_logged_in()) {
        // admins only have the following options for index widgets
        $return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
    } elseif (elgg_in_context('groups')) {
        $group = elgg_get_page_owner_entity();
        if (!empty($group->group_acl)) {
            $return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
        }
    }
    return $return_value;
}
Пример #10
0
/**
 * Get the context for a page, for the help system
 *
 * @param string $url the (optional) url to get the context for
 *
 * @return bool|string
 */
function user_support_get_help_context($url = "")
{
    if (empty($url)) {
        $url = current_page_url();
    }
    if (empty($url)) {
        return false;
    }
    $path = parse_url($url, PHP_URL_PATH);
    if (empty($path)) {
        return false;
    }
    $parts = explode("/", $path);
    $page_owner = elgg_get_page_owner_entity();
    if (empty($page_owner)) {
        $page_owner = elgg_get_logged_in_user_entity();
    }
    $new_parts = array();
    foreach ($parts as $index => $part) {
        if (empty($part)) {
            continue;
        } elseif (is_numeric($part) || !empty($page_owner) && $page_owner->username == $part) {
            break;
        } else {
            $new_parts[] = $part;
        }
    }
    if (empty($new_parts)) {
        return false;
    }
    return implode("/", $new_parts);
}
Пример #11
0
function group_member_entity_menu_handler($hook, $type, $returnvalue, $params)
{
    $page_owner = elgg_get_page_owner_entity();
    $user = elgg_get_logged_in_user_entity();
    if (!$page_owner instanceof ElggGroup || empty($user) || $page_owner->owner_guid != $user->getGUID()) {
        return $returnvalue;
    }
    $result = $returnvalue;
    if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
        $entity = elgg_extract("entity", $params);
        if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
            if (!empty($result) && !is_array($result)) {
                $result = array($result);
            } elseif (empty($result)) {
                $result = array();
            }
            if (check_entity_relationship($page_owner->getGUID(), "manager", $entity->getGUID())) {
                // pending request
                $result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:setmanager"), "href" => "groups/setmanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
            } else {
                // add as friend
                $result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:removemanager"), "href" => "groups/removemanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
            }
        }
    }
    return $result;
}
Пример #12
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
    }
}
Пример #13
0
 /**
  * Set folder breadcrumb menu
  *
  * @param string         $hook        the name of the hook
  * @param string         $type        the type of the hook
  * @param ElggMenuItem[] $return_value current return value
  * @param array          $params      supplied params
  *
  * @return void|ElggMenuItem[]
  */
 public static function register($hook, $type, $return_value, $params)
 {
     if (empty($params) || !is_array($params)) {
         return;
     }
     $container = elgg_get_page_owner_entity();
     /* @var $folder \ElggObject */
     $folder = elgg_extract('entity', $params);
     if (elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
         $container = $folder->getContainerEntity();
         $priority = 9999999;
         $return_value[] = \ElggMenuItem::factory(['name' => "folder_{$folder->getGUID()}", 'text' => $folder->getDisplayName(), 'href' => false, 'priority' => $priority]);
         $parent_guid = (int) $folder->parent_guid;
         while (!empty($parent_guid)) {
             $parent = get_entity($parent_guid);
             if (!elgg_instanceof($parent, 'object', FILE_TOOLS_SUBTYPE)) {
                 break;
             }
             $priority--;
             $return_value[] = \ElggMenuItem::factory(['name' => "folder_{$parent->getGUID()}", 'text' => $parent->getDisplayName(), 'href' => $parent->getURL(), 'priority' => $priority]);
             $parent_guid = (int) $parent->parent_guid;
         }
     }
     // make main folder item
     $main_folder_options = ['name' => 'main_folder', 'text' => elgg_echo('file_tools:list:folder:main'), 'priority' => 0];
     if ($container instanceof \ElggGroup) {
         $main_folder_options['href'] = "file/group/{$container->getGUID()}/all#";
     } else {
         $main_folder_options['href'] = "file/owner/{$container->username}/all#";
     }
     $return_value[] = \ElggMenuItem::factory($main_folder_options);
     return $return_value;
 }
Пример #14
0
 /**
  * Set the title URL for the discussions_tools widgets
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param string $return_value current return value
  * @param array  $params       supplied params
  *
  * @return void|string
  */
 public static function widgetURL($hook, $type, $return_value, $params)
 {
     if (!empty($return_value)) {
         // someone already set an url
         return;
     }
     $widget = elgg_extract('entity', $params);
     if (!$widget instanceof \ElggWidget) {
         return;
     }
     switch ($widget->handler) {
         case 'start_discussion':
             $owner = $widget->getOwnerEntity();
             if ($owner instanceof \ElggGroup) {
                 $return_value = "discussion/add/{$owner->getGUID()}";
             }
             break;
         case 'discussion':
             $return_value = 'discussion/all';
             break;
         case 'group_forum_topics':
             $page_owner = elgg_get_page_owner_entity();
             if ($page_owner instanceof \ElggGroup) {
                 $return_value = "discussion/owner/{$page_owner->getGUID()}";
             }
             break;
     }
     return $return_value;
 }
Пример #15
0
function gvfriendrequest_pagesetup()
{
    $context = elgg_get_context();
    $page_owner = elgg_get_page_owner_entity();
    // Remove link to friendsof
    elgg_unregister_menu_item("page", "friends:of");
    if ($user = elgg_get_logged_in_user_entity()) {
        $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
        if ($count = elgg_get_entities_from_relationship($options)) {
            $class = "elgg-icon elgg-icon-users";
            $text = "<span class='{$class}'></span>";
            $tooltip = elgg_echo('gvtheme:myfriends');
            if ($count > 0) {
                $text .= "<span class=\"messages-new\">{$count}</span>";
                $tooltip = elgg_echo("friend_request:unreadcount", array($count));
            }
            $params = array("name" => "friends", "href" => "friend_request/" . $user->username, "text" => $text, "section" => 'alt', "title" => $tooltip);
            elgg_register_menu_item("topbar", $params);
        }
    }
    // Show menu link in the correct context
    if (in_array($context, array("friends", "friendsof", "collections")) && !empty($page_owner) && $page_owner->canEdit()) {
        $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
        if ($count = elgg_get_entities_from_relationship($options)) {
            $extra = " (" . $count . ")";
        } else {
            $extra = "";
        }
        // add menu item
        $menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections"), "section" => "friend_request");
        elgg_register_menu_item("page", $menu_item);
    }
}
Пример #16
0
 /**
  * Return user info
  *
  * Returns info about the given user needs to contain
  * at least these fields:
  *
  * name string  full name of the user
  * mail string  email addres of the user
  * grps array   list of groups the user is in
  *
  * @author  Andreas Gohr <*****@*****.**>
  */
 function getUserData($username)
 {
     $user = get_user_by_username($username);
     //error_log("getUserData:".$username);
     if (!$user) {
         return false;
     }
     //error_log("getUserData:".$username);
     $page_owner = elgg_get_page_owner_entity();
     $grps = array();
     if ($page_owner instanceof ElggGroup) {
         if ($page_owner->canEdit($user->getGUID())) {
             $grps[] = "admin";
             $grps[] = "root";
             //error_log('operator');
         } elseif ($page_owner->isMember($user)) {
             $grps[] = "member";
         }
     } elseif ($page_owner instanceof ElggUser) {
         if ($page_owner == $user) {
             $grps[] = "admin";
         } elseif ($page_owner->isFriendsWith($user->getGUID())) {
             $grps[] = "member";
         }
     }
     if ($user->isAdmin()) {
         $grps[] = "root";
         $grps[] = "admin";
     }
     $groups = elgg_get_entities_from_relationship(array('relationship' => 'member', 'relationship_guid' => $user->getGUID(), 'inverse_relationship' => FALSE, 'limit' => 0));
     foreach ($groups as $group) {
         $grps[] = $this->cleanUser($group->name);
     }
     return array('name' => $user->name, 'mail' => $user->email, 'grps' => $grps);
 }
Пример #17
0
function group_tools_pagesetup()
{
    $user = elgg_get_logged_in_user_entity();
    $page_owner = elgg_get_page_owner_entity();
    if (elgg_in_context("groups") && $page_owner instanceof ElggGroup) {
        if ($page_owner->forum_enable == "no") {
            // unset if not enabled for this plugin
            elgg_unregister_widget_type("group_forum_topics");
        }
        if (!empty($user)) {
            // check for admin transfer
            $admin_transfer = elgg_get_plugin_setting("admin_transfer", "group_tools");
            if ($admin_transfer == "admin" && $user->isAdmin()) {
                elgg_extend_view("groups/edit", "group_tools/forms/admin_transfer", 400);
            } elseif ($admin_transfer == "owner" && ($page_owner->getOwnerGUID() == $user->getGUID() || $user->isAdmin())) {
                elgg_extend_view("groups/edit", "group_tools/forms/admin_transfer", 400);
            }
            // check multiple admin
            if (elgg_get_plugin_setting("multiple_admin", "group_tools") == "yes") {
                // extend group members sidebar list
                elgg_extend_view("groups/sidebar/members", "group_tools/group_admins", 400);
                // remove group tool options for group admins
                if ($page_owner->getOwnerGUID() != $user->getGUID() && !$user->isAdmin()) {
                    remove_group_tool_option("group_multiple_admin_allow");
                }
            }
            // invitation management
            if ($page_owner->canEdit()) {
                $request_options = array("type" => "user", "relationship" => "membership_request", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true, "count" => true);
                $invite_options = array("type" => "user", "relationship" => "invited", "relationship_guid" => $page_owner->getGUID(), "count" => true);
                $postfix = "";
                if ($requests = elgg_get_entities_from_relationship($request_options)) {
                    $postfix = " [" . $requests . "]";
                } elseif ($invited = elgg_get_entities_from_relationship($invite_options)) {
                    $postfix = " [" . $invited . "]";
                }
                if (!$page_owner->isPublicMembership() || !empty($requests)) {
                    elgg_register_menu_item('page', array('name' => 'membership_requests', 'text' => elgg_echo('groups:membershiprequests') . $postfix, 'href' => "groups/requests/" . $page_owner->getGUID()));
                } elseif (!empty($invited)) {
                    elgg_register_menu_item('page', array('name' => 'membership_requests', 'text' => elgg_echo('group_tools:menu:invitations') . $postfix, 'href' => "groups/requests/" . $page_owner->getGUID()));
                }
            }
            // group mail options
            if ($page_owner->canEdit() && elgg_get_plugin_setting("mail", "group_tools") == "yes") {
                elgg_register_menu_item('page', array('name' => 'mail', 'text' => elgg_echo('group_tools:menu:mail'), 'href' => "groups/mail/" . $page_owner->getGUID()));
            }
        }
    }
    if ($page_owner instanceof ElggGroup) {
        if (!$page_owner->isPublicMembership()) {
            if (elgg_get_plugin_setting("search_index", "group_tools") != "yes") {
                // closed groups should be indexed by search engines
                elgg_extend_view("page/elements/head", "metatags/noindex");
            }
        }
        // cleanup sidebar
        elgg_extend_view("page/elements/sidebar", "group_tools/sidebar/cleanup");
    }
}
Пример #18
0
function hj_forum_init_plugin_user_settings_form($hook, $type, $return, $params)
{
    $entity = elgg_extract('entity', $params);
    $user = elgg_get_page_owner_entity();
    $config['fields'] = array('params[hypeforum_signature]' => HYPEFORUM_USER_SIGNATURE ? array('input_type' => 'longtext', 'class' => 'elgg-input-longtext', 'value' => $entity->getUserSetting('hypeforum_signature', $user->guid)) : null);
    $config['buttons'] = false;
    return $config;
}
Пример #19
0
function friendsgallery_pagesetup()
{
    $owner = elgg_get_page_owner_entity();
    if ($owner) {
        $params = array('name' => 'friends:gallery', 'text' => elgg_echo('friends:gallery'), 'href' => 'friendsgallery/' . $owner->username, 'contexts' => array('friends'));
        elgg_register_menu_item('page', $params);
    }
}
Пример #20
0
 /**
  * Remove discussions widget from group context if discussions are not enabled
  *
  * @param string $hook   "view_vars"
  * @param string $type   "page/layouts/widgets"
  * @param array  $return View vars
  * @param array  $params Hook params
  * @return void
  */
 public static function filterWidgetLayoutVars($hook, $type, $return, $params)
 {
     //$owner_guid = elgg_extract('owner_guid', $return, elgg_get_page_owner_guid()); // not yet supported
     $owner = elgg_get_page_owner_entity();
     if ($owner instanceof ElggGroup && $owner->forum_enable != 'yes') {
         elgg_unregister_widget_type('group_discussions');
     }
 }
Пример #21
0
/**
 * Setup menus at page setup
 */
function stripe_pagesetup()
{
    elgg_register_menu_item('page', array('name' => 'stripe:customers', 'href' => 'admin/stripe/customers', 'text' => elgg_echo('admin:stripe:customers'), 'context' => 'admin', 'section' => 'stripe'));
    $user = elgg_get_page_owner_entity();
    elgg_register_menu_item('page', array('name' => 'stripe:cards', 'href' => "billing/{$user->username}/cards/all", 'text' => elgg_echo('stripe:cards:all'), 'selected' => substr_count(current_page_url(), 'cards/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:charges', 'href' => "billing/{$user->username}/charges/all", 'text' => elgg_echo('stripe:charges:all'), 'selected' => substr_count(current_page_url(), 'charges/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:invoices', 'href' => "billing/{$user->username}/invoices/all", 'text' => elgg_echo('stripe:invoices:all'), 'selected' => substr_count(current_page_url(), 'invoices/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:subscriptions', 'href' => "billing/{$user->username}/subscriptions/all", 'text' => elgg_echo('stripe:subscriptions:all'), 'selected' => substr_count(current_page_url(), 'subscriptions/all'), 'context' => 'settings', 'section' => 'stripe'));
}
Пример #22
0
function discussions_tools_pagesetup()
{
    $page_owner = elgg_get_page_owner_entity();
    if ($page_owner instanceof ElggGroup) {
        if ($page_owner->forum_enable === 'no') {
            // unregister widget because the tool option is disabled
            elgg_unregister_widget_type('group_forum_topics');
        }
    }
}
Пример #23
0
 /**
  * Returns normalized category URL
  * 
  * @param Category $entity Category
  * @return string
  */
 public function getEntityUrl(Category $entity)
 {
     $friendly = elgg_get_friendly_title($entity->getDisplayName());
     $query = array();
     $page_owner = elgg_get_page_owner_entity();
     if ($page_owner instanceof \ElggGroup) {
         $query['container_guid'] = $page_owner->guid;
     }
     return $this->normalize(array('view', $entity->guid, $friendly), $query);
 }
Пример #24
0
function widget_group_files_url($hook_name, $entity_type, $return_value, $params)
{
    $result = $return_value;
    $widget = $params["entity"];
    if (empty($result) && $widget instanceof ElggWidget && $widget->handler == "group_files") {
        if (($page_owner = elgg_get_page_owner_entity()) && $page_owner instanceof ElggGroup) {
            $result = "/file/group/" . $page_owner->getGUID() . "/all";
        }
    }
    return $result;
}
Пример #25
0
/**
 * gets called just before the first output is generated
 *
 * @return void
 */
function digest_pagesetup()
{
    if (elgg_is_logged_in()) {
        $page_owner = elgg_get_page_owner_entity();
        if (elgg_instanceof($page_owner, "user")) {
            elgg_register_menu_item("page", array("name" => "digest", "text" => elgg_echo("digest:page_menu:settings"), "href" => "digest/user/" . $page_owner->username, "context" => "settings"));
        }
        elgg_register_menu_item("page", array("name" => "digest", "text" => elgg_echo("digest:page_menu:theme_preview"), "href" => "digest/test", "context" => "theme_preview"));
        elgg_register_admin_menu_item("administer", "digest", "statistics");
    }
}
Пример #26
0
/**
 * page setup - protect anon user owned pages
 */
function pagesetup()
{
    $user = get_anon_user();
    $page_owner = elgg_get_page_owner_entity();
    if ($user->guid == $page_owner->guid) {
        // admin could log in as the anon user to set some things
        if ($user->guid != elgg_get_logged_in_user_guid()) {
            admin_gatekeeper();
        }
    }
}
Пример #27
0
/**
 * Live Notifications settings sidebar menu
 *
 */
function live_notifications_plugin_pagesetup()
{
    if (elgg_in_context("settings") && elgg_get_logged_in_user_guid()) {
        $user = elgg_get_page_owner_entity();
        if (!$user) {
            $user = elgg_get_logged_in_user_entity();
        }
        $params = array('name' => '2_a_user_live_notification', 'text' => elgg_echo('live_notifications:all'), 'href' => "live_notifications/all", 'section' => "notifications");
        elgg_register_menu_item('page', $params);
    }
}
Пример #28
0
 /**
  * Add a menu item to the page menu
  *
  * @param string          $hook         the name of the hook
  * @param string          $type         the type of the hook
  * @param \ElggMenuItem[] $return_value current return value
  * @param mixed           $params       supplied params
  *
  * @return void|\ElggMenuItem[]
  */
 public static function registerSettingsMenuItem($hook, $type, $return_value, $params)
 {
     if (!elgg_is_logged_in() || !elgg_in_context('settings')) {
         return;
     }
     $user = elgg_get_page_owner_entity();
     if (!$user instanceof \ElggUser) {
         $user = elgg_get_logged_in_user_entity();
     }
     $return_value[] = \ElggMenuItem::factory(['name' => 'tag_notifications', 'text' => elgg_echo('tag_tools:notifications:menu'), 'href' => "notifications/tag/{$user->username}", 'section' => 'notifications']);
     return $return_value;
 }
Пример #29
0
function file_tools_pagesetup()
{
    $page_owner = elgg_get_page_owner_entity();
    if (elgg_instanceof($page_owner, "group")) {
        // check if the group hase files enabled
        if ($page_owner->files_enable == "no") {
            // no, so remove the widgets
            elgg_unregister_widget_type("file_tree");
            elgg_unregister_widget_type("group_files");
        }
    }
}
Пример #30
0
 /**
  * displays the list of accepted challenges
  */
 public function actionAccepted()
 {
     $page_owner = elgg_get_page_owner_entity();
     $this->page_elements['title'] = $page_owner->name . '\'s ' . elgg_echo('izap-contest:challenge:accepted');
     $list = elgg_list_entities_from_metadata(array('type' => 'object', 'subtype' => GLOBAL_IZAP_CONTEST_CHALLENGE_SUBTYPE, 'metadata_name' => 'accepted_by', 'metadata_value' => $page_owner->guid));
     if (empty($list) || $list == '') {
         $this->page_elements['content'] = '<div class="contentWrapper">' . elgg_echo('izap-contest:notfound') . '</div>';
     } else {
         $this->page_elements['content'] = $list;
     }
     $this->drawpage();
 }