Completed
Push — master ( c622f7...33a06a )
by Richard
09:52 queued 02:32
created

PmUsermenuPlugin::usermenu()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 14

Duplication

Lines 3
Ratio 13.04 %

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 2
nop 0
dl 3
loc 23
rs 9.0856
c 0
b 0
f 0
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
12
/**
13
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
14
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @author          trabis <[email protected]>
16
 */
17
class PmUsermenuPlugin implements UsermenuPluginInterface
18
{
19
20
    /**
21
     * @return array
22
     */
23
    public function usermenu()
24
    {
25
        $xoops = \Xoops::getInstance();
26
        $helper = \Xoops::getModuleHelper('pm');
27
        $ret = array();
28
29
        $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
30
        $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid')));
31
        $pm_handler = $helper->getHandler('message');
32
33
        $name = XoopsLocale::INBOX;
34 View Code Duplication
        if ($pm_count = $pm_handler->getCount($criteria)) {
35
            $name = XoopsLocale::INBOX . ' <span class="badge">' . $pm_count . '</span>';
36
        }
37
38
        $ret[] = [
39
            'name' => $name,
40
            'link' => $helper->url('viewpmsg.php'),
41
        ];
42
43
44
        return $ret;
45
    }
46
}