FriendsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkPrivilege() 0 19 3
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Suico;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
use Criteria;
16
17
/**
18
 * @category        Module
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
21
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
22
 */
23
require_once XOOPS_ROOT_PATH . '/kernel/object.php';
24
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
25
require_once XOOPS_ROOT_PATH . '/class/criteria.php';
26
require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
27
28
/**
29
 * Class FriendsController
30
 */
31
class FriendsController extends Controller
32
{
33
    /**
34
     * @return bool|void
35
     */
36
    public function checkPrivilege()
37
    {
38
        if (0 === $this->helper->getConfig('enable_friends')) {
39
            \redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 3, \_MD_SUICO_FRIENDS_ENABLED_NOT);
40
        }
41
        $criteria = new Criteria('config_uid', $this->owner->getVar('uid'));
0 ignored issues
show
Bug introduced by
It seems like $this->owner->getVar('uid') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
        $criteria = new Criteria('config_uid', /** @scrutinizer ignore-type */ $this->owner->getVar('uid'));
Loading history...
42
        if (1 === $this->configsFactory->getCount($criteria)) {
43
            $configs = $this->configsFactory->getObjects($criteria);
44
            $config  = $configs[0]->getVar('friends');
0 ignored issues
show
Unused Code introduced by
The assignment to $config is dead and can be removed.
Loading history...
45
            /*
46
                        if (!$this->checkPrivilegeLevel($config)) {
47
                            //mb temporary fix for self-loop
48
            //                  \redirect_header('index.php?uid=' . $this->owner->getVar('uid'), 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Friends'));
49
                            redirect_header('/', 10, sprintf(_MD_SUICO_NOPRIVILEGE,'Friends'));
50
                        }
51
            */
52
        }
53
54
        return true;
55
    }
56
}
57