Пример #1
0
/**
 * Add menu items to the (theme)personal 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 ElggMenuItem[]
 */
function theme_haarlem_intranet_personal_menu($hook, $type, $return_value, $params)
{
    $user = elgg_get_logged_in_user_entity();
    if (empty($user)) {
        return $return_value;
    }
    $return_value[] = ElggMenuItem::factory(array('name' => 'dashboard', 'text' => elgg_echo('theme_haarlem_intranet:menu:site:dashboard'), 'href' => 'dashboard', 'section' => 'personal', 'is_trusted' => true, 'priority' => 100));
    if (elgg_is_active_plugin('content_redirector')) {
        $return_value[] = ElggMenuItem::factory(array('name' => 'content_redirector', 'text' => elgg_view_icon('plus'), 'title' => elgg_echo('content_redirector:selector:add'), 'href' => 'add', 'section' => 'personal', 'is_trusted' => true, 'priority' => 150));
    }
    if (elgg_is_active_plugin('groups')) {
        $invited_groups = groups_get_invited_groups($user->getGUID(), true);
        $invite_count = count($invited_groups);
        $postfix = '';
        if ($invite_count) {
            $postfix = "<span class='theme-haarlem-intranet-counter'>{$invite_count}</span>";
        }
        $return_value[] = ElggMenuItem::factory(array('name' => 'groups', 'text' => elgg_view_icon('group') . $postfix, 'title' => elgg_echo('groups:yours'), 'href' => "#", 'section' => 'personal', 'is_trusted' => true, 'priority' => 150));
        // add my groups
        $dbprefix = elgg_get_config('dbprefix');
        $group_options = array('type' => 'group', 'limit' => false, 'relationship' => 'member', 'relationship_guid' => $user->getGUID(), 'joins' => array("JOIN {$dbprefix}groups_entity ge ON e.guid = ge.guid"), 'order_by' => 'ge.name ASC');
        $groups = new ElggBatch('elgg_get_entities_from_relationship', $group_options);
        $groups_found = false;
        foreach ($groups as $index => $group) {
            $groups_found = true;
            $return_value[] = ElggMenuItem::factory(array('name' => "group_{$group->getGUID()}", 'text' => $group->name, 'href' => $group->getURL(), 'section' => 'personal', 'is_trusted' => true, 'priority' => $index, 'parent_name' => 'groups_member_of'));
        }
        if ($groups_found) {
            $return_value[] = ElggMenuItem::factory(array('name' => 'groups_member_of', 'text' => false, 'href' => false, 'section' => 'personal', 'is_trusted' => true, 'priority' => 8888888, 'parent_name' => 'groups'));
        }
        $return_value[] = ElggMenuItem::factory(array('name' => 'my_groups', 'text' => elgg_echo('groups:yours'), 'href' => "groups/member/{$user->username}", 'section' => 'personal', 'is_trusted' => true, 'priority' => 9999999, 'parent_name' => 'groups'));
    }
    if (elgg_is_active_plugin('messages')) {
        $message_count = messages_count_unread();
        $postfix = '';
        if ($message_count) {
            $postfix = "<span class='theme-haarlem-intranet-counter'>{$message_count}</span>";
        }
        $return_value[] = ElggMenuItem::factory(array('name' => 'messages', 'text' => elgg_view_icon('envelope') . $postfix, 'title' => elgg_echo('messages'), 'href' => "messages/inbox/{$user->username}", 'section' => 'personal', 'is_trusted' => true, 'priority' => 200));
    }
    if (elgg_is_active_plugin('quicklinks')) {
        $return_value[] = ElggMenuItem::factory(array('name' => 'quicklinks', 'text' => elgg_view('page/elements/topbar/quicklinks'), 'href' => false, 'section' => 'personal', 'is_trusted' => true, 'priority' => 250));
    }
    $return_value[] = ElggMenuItem::factory(array('name' => 'profile', 'text' => elgg_view('output/img', array('src' => $user->getIconURL('tiny'))), 'title' => $user->name, 'href' => '#', 'section' => 'personal', 'is_trusted' => true, 'priority' => 300));
    $return_value[] = ElggMenuItem::factory(array('name' => 'profile_mine', 'text' => elgg_echo('theme_haarlem_intranet:menu:site:profile:mine'), 'href' => $user->getURL(), 'section' => 'personal', 'parent_name' => 'profile', 'is_trusted' => true, 'priority' => 100));
    $return_value[] = ElggMenuItem::factory(array('name' => 'profile_settings', 'text' => elgg_echo('theme_haarlem_intranet:menu:site:profile:settings'), 'href' => "settings/user/{$user->username}", 'section' => 'personal', 'parent_name' => 'profile', 'is_trusted' => true, 'priority' => 200));
    $return_value[] = ElggMenuItem::factory(array('name' => 'profile_logout', 'text' => elgg_echo('logout'), 'href' => 'action/logout', 'section' => 'personal', 'parent_name' => 'profile', 'is_trusted' => true, 'is_action' => true, 'priority' => 300));
    return $return_value;
}
Пример #2
0
/**
 * Return the site menu
 *
 * @param string $hook        name of the hook
 * @param string $entity_type type of the hook
 * @param array  $returnvalue current return value
 * @param array  $params      extra params
 */
function theme_eersel_register_topbar_menu_handler($hook, $entity_type, $returnvalue, $params)
{
    // we will make our own menu
    $menu_items = array();
    $user = elgg_get_logged_in_user_entity();
    if (!$user) {
        return;
    }
    $groups_count = "";
    $invitation_count = (int) groups_get_invited_groups($user->getGUID(), false, array('count' => true));
    if ($invitation_count) {
        $groups_count = "<span title='" . elgg_echo('groups:invitations:pending', array($invitation_count)) . "' class='theme-eersel-topbar-status-new'>{$invitation_count}</span>";
    }
    // get unread messages
    $message_count = "";
    $num_messages = (int) messages_count_unread();
    if ($num_messages) {
        $message_count = "<span title='" . elgg_echo('messages:unreadcount', array($num_messages)) . "' class='theme-eersel-topbar-status-new'>{$num_messages}</span>";
    }
    // main menu
    $wiki_group = get_entity("32599992");
    $menu_items[] = ElggMenuItem::factory(array("name" => "home", "title" => elgg_echo("theme_eersel:menu:home"), "href" => elgg_get_site_url(), "text" => "<i class='fa fa-home'></i>"));
    $menu_items[] = ElggMenuItem::factory(array("name" => "groups", "title" => elgg_echo("theme_eersel:menu:groups:all"), "href" => "groups/all", "text" => "<i class='fa fa-group'></i>"));
    if ($wiki_group) {
        $menu_items[] = ElggMenuItem::factory(array("name" => "wiki", "title" => $wiki_group->name, "href" => $wiki_group->getURL(), "text" => "<i class='fa fa-stack-overflow'></i>"));
    }
    $menu_items[] = ElggMenuItem::factory(array("name" => "members", "title" => elgg_echo("members"), "href" => "members/all", "text" => "<i class='fa fa-user'></i>"));
    $menu_items[] = ElggMenuItem::factory(array("name" => "add", "title" => elgg_echo("theme_eersel:menu:add"), "href" => "/add", "text" => "<i class='fa fa-plus'></i>", "section" => "alt"));
    $menu_items[] = ElggMenuItem::factory(array("name" => "my-groups", "title" => elgg_echo("theme_eersel:menu:groups:mine"), "href" => "groups/member/" . $user->username, "text" => $groups_count . "<i class='fa fa-group'></i>", "section" => "alt"));
    $menu_items[] = ElggMenuItem::factory(array("name" => "messages", "title" => elgg_echo("messages"), "href" => "messages/inbox/" . $user->username, "text" => $message_count . "<i class='fa fa-envelope'></i>", "section" => "alt"));
    $menu_items[] = ElggMenuItem::factory(array("name" => "settings", "title" => elgg_echo("settings"), "href" => "settings", "text" => "<i class='fa fa-cog'></i>", "section" => "alt"));
    if (elgg_is_admin_logged_in()) {
        $menu_items[] = ElggMenuItem::factory(array("name" => "admin", "title" => elgg_echo("admin"), "href" => "admin", "text" => "<i class='fa fa-gears'></i>", "section" => "alt"));
    }
    $menu_items[] = ElggMenuItem::factory(array("name" => "profile", "title" => elgg_echo("profile"), "href" => $user->getURL(), "text" => elgg_view("output/img", array("src" => $user->getIconURL('small'))), "section" => "alt"));
    return $menu_items;
}
Пример #3
0
/**
 * Configure the groups sidebar menu. Triggered on page setup
 *
 */
function groups_setup_sidebar_menus()
{
    // Get the page owner entity
    $page_owner = elgg_get_page_owner_entity();
    if (elgg_in_context('group_profile')) {
        if (!elgg_instanceof($page_owner, 'group')) {
            forward('', '404');
        }
        if (elgg_is_logged_in() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
            $url = elgg_get_site_url() . "groups/requests/{$page_owner->getGUID()}";
            $count = elgg_get_entities_from_relationship(array('type' => 'user', 'relationship' => 'membership_request', 'relationship_guid' => $page_owner->getGUID(), 'inverse_relationship' => true, 'count' => true));
            if ($count) {
                $text = elgg_echo('groups:membershiprequests:pending', array($count));
            } else {
                $text = elgg_echo('groups:membershiprequests');
            }
            elgg_register_menu_item('page', array('name' => 'membership_requests', 'text' => $text, 'href' => $url));
        }
    }
    if (elgg_get_context() == 'groups' && !elgg_instanceof($page_owner, 'group')) {
        elgg_register_menu_item('page', array('name' => 'groups:all', 'text' => elgg_echo('groups:all'), 'href' => 'groups/all'));
        $user = elgg_get_logged_in_user_entity();
        if ($user) {
            $url = "groups/owner/{$user->username}";
            $item = new ElggMenuItem('groups:owned', elgg_echo('groups:owned'), $url);
            elgg_register_menu_item('page', $item);
            $url = "groups/member/{$user->username}";
            $item = new ElggMenuItem('groups:member', elgg_echo('groups:yours'), $url);
            elgg_register_menu_item('page', $item);
            $url = "groups/invitations/{$user->username}";
            $invitation_count = groups_get_invited_groups($user->getGUID(), false, array('count' => true));
            if ($invitation_count) {
                $text = elgg_echo('groups:invitations:pending', array($invitation_count));
            } else {
                $text = elgg_echo('groups:invitations');
            }
            $item = new ElggMenuItem('groups:user:invites', $text, $url);
            elgg_register_menu_item('page', $item);
        }
    }
}
Пример #4
0
/**
 * Group invitations for a user
 */
function groups_handle_invitations_page()
{
    gatekeeper();
    $user = elgg_get_page_owner_entity();
    $title = elgg_echo('groups:invitations');
    elgg_push_breadcrumb($title);
    // @todo temporary workaround for exts #287.
    $invitations = groups_get_invited_groups($user->getGUID());
    $content = elgg_view('groups/invitationrequests', array('invitations' => $invitations));
    $params = array('content' => $content, 'title' => $title, 'filter' => '');
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page($title, $body);
}
Пример #5
0
<?php

/**
 * Manage group invitation requests.
 *
 * @package ElggGroups
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.com/
 */
require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php";
gatekeeper();
$user = get_loggedin_user();
$title = elgg_echo('groups:invitations');
$area2 = elgg_view_title($title);
if ($user) {
    // @todo temporary workaround for exts #287.
    $invitations = groups_get_invited_groups($user->getGUID());
    $area2 .= elgg_view('groups/invitationrequests', array('invitations' => $invitations));
    elgg_set_ignore_access($ia);
} else {
    $area2 .= elgg_echo("groups:noaccess");
}
$body = elgg_view_layout('one_column_with_sidebar', $area2);
page_draw($title, $body);
 * Join a group action.
 *
 * @package ElggGroups
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.com/
 */
// Load configuration
global $CONFIG;
gatekeeper();
$user_guid = get_input('user_guid', get_loggedin_userid());
$group_guid = get_input('group_guid');
// @todo fix for #287
// disable access to get entity.
$invitations = groups_get_invited_groups($user_guid, TRUE);
if (in_array($group_guid, $invitations)) {
    $ia = elgg_set_ignore_access(TRUE);
}
$user = get_entity($user_guid);
$group = get_entity($group_guid);
if ($user instanceof ElggUser && $group instanceof ElggGroup) {
    if ($group->isPublicMembership()) {
        if ($group->join($user)) {
            system_message(elgg_echo("groups:joined"));
            // Remove any invite or join request flags
            remove_entity_relationship($group->guid, 'invited', $user->guid);
            remove_entity_relationship($user->guid, 'membership_request', $group->guid);
            // add to river
            add_to_river('river/group/create', 'join', $user->guid, $group->guid);
            forward($group->getURL());
Пример #7
0
/**
 * A user's group invitations
 *
 * @uses $vars['invitations'] Array of ElggGroups
 */
$user = elgg_get_page_owner_entity();
if (!elgg_instanceof($user, 'user') || !$user->canEdit()) {
    return true;
}
if (isset($vars['invitations'])) {
    $invitations = $vars['invitations'];
} else {
    $limit = get_input('limit', elgg_get_config('default_limit'));
    $offset = get_input('offset', 0);
    $count = groups_get_invited_groups($user->guid, false, array('count' => true));
    $invitations = groups_get_invited_groups($user->guid, false, array('limit' => $limit, 'offset' => $offset));
}
if (is_array($invitations) && count($invitations) > 0) {
    $user = elgg_get_logged_in_user_entity();
    echo '<ul class="elgg-list">';
    foreach ($invitations as $group) {
        if ($group instanceof ElggGroup) {
            $icon = elgg_view_entity_icon($group, 'tiny', array('use_hover' => 'true'));
            $group_title = elgg_view('output/url', array('href' => $group->getURL(), 'text' => $group->name, 'is_trusted' => true));
            $url = elgg_add_action_tokens_to_url(elgg_get_site_url() . "action/groups/join?user_guid={$user->guid}&group_guid={$group->guid}");
            $accept_button = elgg_view('output/url', array('href' => $url, 'text' => elgg_echo('accept'), 'class' => 'elgg-button elgg-button-submit', 'is_trusted' => true));
            $url = "action/groups/killinvitation?user_guid={$user->getGUID()}&group_guid={$group->getGUID()}";
            $delete_button = elgg_view('output/url', array('href' => $url, 'confirm' => elgg_echo('groups:invite:remove:check'), 'text' => elgg_echo('delete'), 'class' => 'elgg-button elgg-button-delete mlm'));
            $body = <<<HTML
<h4>{$group_title}</h4>
<p class="elgg-subtext">{$group->briefdescription}</p>
Пример #8
0
/**
 * Group invitations for a user
 */
function groups_handle_invitations_page()
{
    gatekeeper();
    $username = get_input('username');
    if ($username) {
        $user = get_user_by_username($username);
    }
    if (!$username || !$user) {
        $user = elgg_get_logged_in_user_entity();
    }
    $title = elgg_echo('groups:invitations');
    elgg_push_breadcrumb($title);
    $invitations = groups_get_invited_groups($user->guid);
    $content = elgg_view('groups/invitationrequests', array('invitations' => $invitations));
    $params = array('content' => $content, 'title' => $title, 'filter' => '');
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page($title, $body);
}
Пример #9
0
<?php

/**
 * content for the open group invitations widget
 */
$invitations = groups_get_invited_groups(elgg_get_logged_in_user_guid());
echo elgg_view("groups/invitationrequests", array("invitations" => $invitations));
Пример #10
0
/**
 * Register menu items for the page menu
 *
 * @param string $hook
 * @param string $type
 * @param array  $return
 * @param array  $params
 * @return array
 *
 * @access private
 *
 * @since 3.0
 */
function _groups_page_menu($hook, $type, $return, $params)
{
    if (elgg_get_context() !== 'groups') {
        return;
    }
    // Get the page owner entity
    $page_owner = elgg_get_page_owner_entity();
    if ($page_owner instanceof ElggGroup) {
        return;
    }
    $return[] = \ElggMenuItem::factory(['name' => 'groups:all', 'text' => elgg_echo('groups:all'), 'href' => 'groups/all']);
    $user = elgg_get_logged_in_user_entity();
    if (!$user) {
        return $return;
    }
    $return[] = \ElggMenuItem::factory(['name' => 'groups:owned', 'text' => elgg_echo('groups:owned'), 'href' => "groups/owner/{$user->username}"]);
    $return[] = \ElggMenuItem::factory(['name' => 'groups:member', 'text' => elgg_echo('groups:yours'), 'href' => "groups/member/{$user->username}"]);
    $invitation_count = groups_get_invited_groups($user->guid, false, ['count' => true]);
    // Invitations
    $text = elgg_echo('groups:invitations');
    $title = $text;
    if ($invitation_count) {
        $title = elgg_echo('groups:invitations:pending', array($invitation_count));
    }
    $return[] = \ElggMenuItem::factory(['name' => 'groups:user:invites', 'text' => $text, 'badge' => $invitation_count ? $invitation_count : null, 'title' => $title, 'href' => "groups/invitations/{$user->username}"]);
    return $return;
}