예제 #1
0
 public static function prepareMenu($h, $t, $v, $p)
 {
     $default = new MenuList(elgg_extract('default', $v, []));
     $alt = new MenuList(elgg_extract('alt', $v, []));
     // dump alt items into default
     $default->appendList($alt);
     $avatar = $default->get('profile');
     $account = $default->get('account');
     if ($avatar && $account) {
         $user = elgg_get_logged_in_user_entity();
         // copy account children under avatar
         $children = new MenuList($account->getChildren());
         // copy admin out
         $admin = $children->remove('administration');
         $url = $avatar->getHref();
         $profile = new \ElggMenuItem('view-profile', elgg_echo('profile'), $url);
         $children->move($profile, 0);
         $avatar->setHref(null);
         elgg_push_context('mrclay_aalborg_topbar');
         $avatar->setText(elgg_view_entity_icon($user, 'tiny'));
         elgg_pop_context();
         $default->remove($account);
         $default->push($avatar);
         if ($admin) {
             $admin->setTooltip(elgg_echo('admin'));
             $admin->setText(elgg_view_icon('settings-alt'));
             $default->move($admin, 0);
         }
     }
     return ['default' => $default->getItems()];
 }
예제 #2
0
 public static function prepareMenu($h, $t, $v, $p)
 {
     if (!elgg_in_context('mrclay_aalborg_topbar')) {
         return;
     }
     $action_section = new MenuList(elgg_extract('action', $v, []));
     $action_section->remove('avatar:edit');
     $user = $p['entity'];
     /* @var \ElggUser $user */
     if (elgg_is_active_plugin('notifications')) {
         $item = \ElggMenuItem::factory(array('name' => '2_a_user_notify', 'text' => elgg_echo('notifications:subscriptions:changesettings'), 'href' => "notifications/personal/{$user->username}", 'section' => "notifications"));
         $action_section->push($item);
         if (elgg_is_active_plugin('groups')) {
             $item = \ElggMenuItem::factory(array('name' => '2_group_notify', 'text' => elgg_echo('notifications:subscriptions:changesettings:groups'), 'href' => "notifications/group/{$user->username}", 'section' => "notifications"));
             $action_section->push($item);
         }
     }
     $item = \ElggMenuItem::factory(array('name' => 'logout', 'text' => elgg_view_icon('sign-out') . elgg_echo('logout'), 'href' => elgg_add_action_tokens_to_url("action/logout")));
     $action_section->push($item);
     $v['action'] = $action_section->getItems();
     return $v;
 }
예제 #3
0
파일: hooks.php 프로젝트: Elgg/probation
function hook_register_hover_menu($hook, $type, $items, $params)
{
    $list = new MenuList($items);
    if (is_on_probation()) {
        $list->remove('send');
    }
    if (elgg_is_admin_logged_in()) {
        $user = elgg_extract('entity', $params);
        if (is_on_probation($user)) {
            $item = \ElggMenuItem::factory(['name' => 'probation_remove', 'text' => elgg_echo('probation:remove_probation'), 'href' => elgg_add_action_tokens_to_url("action/probation/approve_user?guid={$user->guid}"), 'section' => 'admin']);
            $list->push($item);
        }
    }
    return $list->getItems();
}