XOOPS  2.6.0
user.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
14 
26 {
28  if (!$xoops->isUser()) {
29  return false;
30  }
31 
32  $block = array();
33  $block['modules'] = array();
34 
35  $plugins = \Xoops\Module\Plugin::getPlugins('system');
36  $i = 0;
37  /* @var $plugin SystemPluginInterface */
38  foreach ($plugins as $dirname => $plugin) {
39  $menu = $plugin->userMenus();
40 
41  if (is_array($menu) && !empty($menu)) {
42  $block['modules'][$i]['name'] = $menu['name'];
43  $block['modules'][$i]['link'] = $xoops->url('modules/' . $dirname . '/' . $menu['link']);
44  $block['modules'][$i]['image'] = $menu['image'];
45  $block['modules'][$i]['icon'] = 'icon-tags';
46  $block['modules'][$i]['dirname'] = $dirname;
47 
48  //todo, remove this hardcoded call
49  if ($xoops->isModule() && $xoops->module->getVar('dirname') == $dirname && $plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'menus')) {
50  if (method_exists($plugin, 'subMenus')) {
51  $sublinks = $plugin->subMenus();
52  foreach ($sublinks as $sublink) {
53  $block['modules'][$i]['sublinks'][] = array(
54  'name' => $sublink['name'],
55  'url' => \XoopsBaseConfig::get('url') . '/modules/' . $dirname . '/' . $sublink['url']
56  );
57  }
58  }
59  }
60  ++$i;
61  }
62 
63  }
64 
65  // View Account
66  array_unshift($block['modules'], array(
67  'name' => XoopsLocale::VIEW_ACCOUNT,
68  'link' => $xoops->url('userinfo.php?uid=' . $xoops->user->getVar('uid')),
69  'icon' => 'icon-user',
70  ));
71 
72  // Edit Account
73  array_unshift($block['modules'], array(
74  'name' => XoopsLocale::EDIT_ACCOUNT,
75  'link' => $xoops->url('edituser.php'),
76  'icon' => 'icon-user',
77  ));
78 
79  // Administration Menu
80  if ($xoops->isAdmin()) {
81  array_unshift($block['modules'], array(
83  'link' => $xoops->url('admin.php'),
84  'rel' => 'external',
85  'icon' => 'icon-wrench',
86  ));
87  }
88 
89  // Inbox
90  $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
91  $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid')));
92  $pm_handler = $xoops->getHandlerPrivmessage();
93  $xoops->preload()->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
94 
96  $class = '';
97  if ($pm_count = $pm_handler->getCount($criteria)) {
98  $name = XoopsLocale::INBOX . ' <strong>' . $pm_count . '</strong>';
99  $class = 'highlight';
100  }
101 
102  array_push($block['modules'], array(
103  'name' => $name,
104  'link' => $xoops->url('viewpmsg.php'),
105  'icon' => 'icon-envelope',
106  'class' => $class,
107  ));
108 
109  // Logout
110  array_push($block['modules'], array(
111  'name' => XoopsLocale::A_LOGOUT,
112  'link' => $xoops->url('user.php?op=logout'),
113  'icon' => 'icon-off',
114  ));
115 
116  $block['active_url'] = \Xoops\Core\HttpRequest::getInstance()->getUrl();
117  return $block;
118 }
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
const ADMINISTRATION_MENU
Definition: en_US.php:33
const VIEW_ACCOUNT
Definition: en_US.php:1088
$menu
static get($name)
const EDIT_ACCOUNT
Definition: en_US.php:227
$criteria
$dirname
Definition: backend.php:38
$xoops
Definition: user.php:29
b_system_user_show()
Definition: user.php:25
$pm_handler
Definition: readpmsg.php:37
const A_LOGOUT
Definition: en_US.php:103