1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Kernel\Criteria;
13: use Xoops\Core\Kernel\CriteriaCompo;
14:
15: 16: 17: 18: 19: 20: 21: 22: 23:
24:
25: function b_system_user_show()
26: {
27: $xoops = Xoops::getInstance();
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:
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:
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:
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:
73: array_unshift($block['modules'], array(
74: 'name' => XoopsLocale::EDIT_ACCOUNT,
75: 'link' => $xoops->url('edituser.php'),
76: 'icon' => 'icon-user',
77: ));
78:
79:
80: if ($xoops->isAdmin()) {
81: array_unshift($block['modules'], array(
82: 'name' => SystemLocale::ADMINISTRATION_MENU,
83: 'link' => $xoops->url('admin.php'),
84: 'rel' => 'external',
85: 'icon' => 'icon-wrench',
86: ));
87: }
88:
89:
90: $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
91: $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid')));
92: $pm_handler = $xoops->getHandlerPrivateMessage();
93: $xoops->events()->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
94:
95: $name = XoopsLocale::INBOX;
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:
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: }
119: