Completed
Push — master ( 62af87...249590 )
by Michael
03:02
created

PermissionForumHandler   B

Complexity

Total Complexity 42

Size/Duplication

Total Lines 245
Duplicated Lines 11.02 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 27
loc 245
rs 8.295
c 0
b 0
f 0
wmc 42
lcom 1
cbo 3

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getValidPerms() 0 16 4
D getValidItems() 0 34 9
C getPermissions() 16 46 8
C getPermissionTable() 0 28 8
A deleteByForum() 0 14 2
C applyTemplate() 11 34 8
A getTemplate() 0 5 1
A setTemplate() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like PermissionForumHandler often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use PermissionForumHandler, and based on these observations, apply Extract Interface, too.

1
<?php namespace XoopsModules\Newbb;
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 24 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * NewBB 5.0x,  the forum module for XOOPS project
5
 *
6
 * @copyright      XOOPS Project (https://xoops.org)
7
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
8
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
9
 * @since          4.00
10
 * @package        module::newbb
11
 */
12
13
use XoopsModules\Newbb;
14
15
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
16
17
//defined("NEWBB_HANDLER_PERMISSION") || include __DIR__.'/permission.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
//define("NEWBB_HANDLER_PERMISSION_FORUM", 1);
19
20
if (defined('FORUM_PERM_ITEMS') && class_exists('ForumPermissionHandler')) {
21
    exit('access denied');
22
}
23
// irmtfan add pdf and print permissions.
24
define('FORUM_PERM_ITEMS', 'access,view,post,reply,edit,delete,addpoll,vote,attach,noapprove,type,html,signature,pdf,print');
25
26
/**
27
 * Class PermissionForumHandler
28
 */
29
class PermissionForumHandler extends PermissionHandler
30
{
31
    protected $templateFilename;
32
33
    /**
34
     * @param \XoopsDatabase $db
35
     */
36
    public function __construct(\XoopsDatabase $db)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $db. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
37
    {
38
        //        $this->PermissionHandler($db);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
        parent::__construct($db);
40
        $this->templateFilename = XOOPS_VAR_PATH . '/configs/newbb_permission_template.php';
41
    }
42
43
    /**
44
     * @param  bool $fullname
45
     * @return array
46
     */
47
    public function getValidPerms($fullname = false)
48
    {
49
        static $validPerms = [];
50
        if (isset($validPerms[(int)$fullname])) {
51
            return $validPerms[(int)$fullname];
52
        }
53
        $items = array_filter(array_map('trim', explode(',', FORUM_PERM_ITEMS)));
54
        if (!empty($fullname)) {
55
            foreach (array_keys($items) as $key) {
56
                $items[$key] = 'forum_' . $items[$key];
57
            }
58
        }
59
        $validPerms[(int)$fullname] = $items;
60
61
        return $items;
62
    }
63
64
    /**
65
     * @param        $mid
66
     * @param  int   $id
67
     * @return array
68
     */
69
    public function getValidItems($mid, $id = 0)
0 ignored issues
show
Coding Style introduced by
getValidItems uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
70
    {
71
        static $suspension = [];
72
        $full_items = [];
0 ignored issues
show
Coding Style introduced by
$full_items does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
73
        if (empty($mid)) {
74
            return $full_items;
0 ignored issues
show
Coding Style introduced by
$full_items does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
75
        }
76
77
        include_once __DIR__ . '/../include/functions.user.php';
78
        $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
79
        $ip  = \Xmf\IPAddress::fromRequest()->asReadable();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $ip. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
80
        if (!empty($GLOBALS['xoopsModuleConfig']['enable_usermoderate']) && !isset($suspension[$uid][$id])
81
            && !newbbIsAdmin($id)) {
82
            /** @var Newbb\ModerateHandler $moderateHandler */
83
            $moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate');
84
            if (!$moderateHandler->verifyUser($uid, '', $id)) {
85
                $suspension[$uid][$ip][$id] = 1;
86
            } else {
87
                $suspension[$uid][$ip][$id] = 0;
88
            }
89
        }
90
91
        $items = $this->getValidPerms();
92
        foreach ($items as $item) {
93
            /* skip access for suspended users */
94
            //if ( !empty($suspension[$uid][$ip][$id]) && in_array($item, array("post", "reply", "edit", "delete", "addpoll", "vote", "attach", "noapprove", "type")) ) continue;
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
95
            if (!empty($suspension[$uid][$ip][$id])) {
96
                continue;
97
            }
98
            $full_items[] = "'forum_{$item}'";
0 ignored issues
show
Coding Style introduced by
$full_items does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
99
        }
100
101
        return $full_items;
0 ignored issues
show
Coding Style introduced by
$full_items does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
102
    }
103
104
    /*
105
    * Returns permissions for a certain type
106
    *
107
    * @param int $id id of the item (forum, topic or possibly post) to get permissions for
108
    *
109
    * @return array
110
    */
111
    /**
112
     * @param  int $id
113
     * @return bool|array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use false|array.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
114
     */
115
    public function getPermissions($id = 0)
0 ignored issues
show
Coding Style introduced by
getPermissions uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
116
    {
117
        $permissions = [];
118 View Code Duplication
        if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
            $modid = $GLOBALS['xoopsModule']->getVar('mid');
120
        } else {
121
            /** @var \XoopsModuleHandler $moduleHandler */
122
            $moduleHandler = xoops_getHandler('module');
123
            $xoopsNewBB    = $moduleHandler->getByDirname('newbb');
124
            $modid         = $xoopsNewBB->getVar('mid');
125
            unset($xoopsNewBB);
126
        }
127
128
        // Get user's groups
129
        $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
130
        // Create string of groupid's separated by commas, inserted in a set of brackets
131
        if (count($groups) < 1) {
132
            return false;
133
        }
134
        // Create criteria for getting only the permissions regarding this module and this user's groups
135
        $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $modid));
136
        $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $groups) . ')', 'IN'));
137 View Code Duplication
        if ($id) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
            if (is_array($id)) {
139
                $criteria->add(new \Criteria('gperm_itemid', '(' . implode(',', $id) . ')', 'IN'));
140
            } else {
141
                $criteria->add(new \Criteria('gperm_itemid', (int)$id));
142
            }
143
        }
144
        $gperm_names = implode(', ', $this->getValidItems($modid, $id));
0 ignored issues
show
Coding Style introduced by
$gperm_names does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
145
146
        // Add criteria for gpermnames
147
        $criteria->add(new \Criteria('gperm_name', '(' . $gperm_names . ')', 'IN'));
0 ignored issues
show
Coding Style introduced by
$gperm_names does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
148
        // Get all permission objects in this module and for this user's groups
149
        $userpermissions = $this->getObjects($criteria, true);
150
151
        // Set the granted permissions to 1
152
        foreach ($userpermissions as $gperm_id => $gperm) {
0 ignored issues
show
Coding Style introduced by
$gperm_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
153
            $permissions[$gperm->getVar('gperm_itemid')][$gperm->getVar('gperm_name')] = 1;
154
        }
155
        $userpermissions = null;
156
        unset($userpermissions);
157
158
        // Return the permission array
159
        return $permissions;
160
    }
161
162
    /**
163
     * @param  Forum|int $forum
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $forum a bit more specific; maybe use integer.
Loading history...
164
     * @param  bool      $topic_locked
165
     * @param  bool      $isAdmin
166
     * @return array
167
     */
168
    public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = false)
0 ignored issues
show
Coding Style introduced by
$topic_locked does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
169
    {
170
        $perm = [];
171
172
        $forumId = $forum;
173
        if (is_object($forum)) {
174
            $forumId = $forum->getVar('forum_id');
175
        }
176
177
        $permission_set = $this->getPermissions($forumId);
0 ignored issues
show
Coding Style introduced by
$permission_set does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
178
179
        $permItems = $this->getValidPerms();
180
        foreach ($permItems as $item) {
181
            if ('access' === $item) {
182
                continue;
183
            }
184
            if ($isAdmin
185
                || (isset($permission_set[$forumId]['forum_' . $item])
0 ignored issues
show
Coding Style introduced by
$permission_set does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
186
                    && (!$topic_locked
0 ignored issues
show
Coding Style introduced by
$topic_locked does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
187
                        || 'view' === $item))) {
188
                $perm[] = constant('_MD_NEWBB_CAN_' . strtoupper($item));
189
            } else {
190
                $perm[] = constant('_MD_NEWBB_CANNOT_' . strtoupper($item));
191
            }
192
        }
193
194
        return $perm;
195
    }
196
197
    /**
198
     * @param $forum_id
199
     * @return bool
200
     */
201
    public function deleteByForum($forum_id)
0 ignored issues
show
Coding Style introduced by
function deleteByForum() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
$forum_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
deleteByForum uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
202
    {
203
        $forum_id = (int)$forum_id;
0 ignored issues
show
Coding Style introduced by
$forum_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
204
        if (empty($forum_id)) {
0 ignored issues
show
Coding Style introduced by
$forum_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
205
            return false;
206
        }
207
        $gpermHandler = xoops_getHandler('groupperm');
208
        $criteria     = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
209
        $items        = $this->getValidPerms(true);
210
        $criteria->add(new \Criteria('gperm_name', "('" . implode("', '", $items) . "')", 'IN'));
211
        $criteria->add(new \Criteria('gperm_itemid', $forum_id));
0 ignored issues
show
Coding Style introduced by
$forum_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
212
213
        return $gpermHandler->deleteAll($criteria);
214
    }
215
216
    /**
217
     * @param       $forum
218
     * @param  int  $mid
219
     * @return bool
220
     */
221
    public function applyTemplate($forum, $mid = 0)
0 ignored issues
show
Coding Style introduced by
function applyTemplate() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
applyTemplate uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
222
    {
223
        if (!$perm_template = $this->getTemplate()) {
0 ignored issues
show
Coding Style introduced by
$perm_template does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
224
            return false;
225
        }
226
227 View Code Duplication
        if (empty($mid)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
228
            if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
229
                $mid = $GLOBALS['xoopsModule']->getVar('mid');
230
            } else {
231
                /** @var \XoopsModuleHandler $moduleHandler */
232
                $moduleHandler = xoops_getHandler('module');
233
                $newbb         = $moduleHandler->getByDirname('newbb');
234
                $mid           = $newbb->getVar('mid');
235
                unset($newbb);
236
            }
237
        }
238
239
        /** @var \XoopsMemberHandler $memberHandler */
240
        $memberHandler = xoops_getHandler('member');
241
        $glist         = $memberHandler->getGroupList();
242
        $perms         = $this->getValidPerms(true);
243
        foreach (array_keys($glist) as $group) {
244
            foreach ($perms as $perm) {
245
                if (!empty($perm_template[$group][$perm])) {
0 ignored issues
show
Coding Style introduced by
$perm_template does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
246
                    $this->validateRight($perm, $forum, $group, $mid);
247
                } else {
248
                    $this->deleteRight($perm, $forum, $group, $mid);
249
                }
250
            }
251
        }
252
253
        return true;
254
    }
255
256
    /**
257
     * @return array|false
258
     */
259
    public function getTemplate()
260
    {
261
        $perms = \Xmf\Yaml::readWrapped($this->templateFilename);
262
        return $perms;
263
    }
264
265
    /**
266
     * @param array $perms
267
     * @return bool
268
     */
269
    public function setTemplate($perms)
0 ignored issues
show
Coding Style introduced by
function setTemplate() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
270
    {
271
        return \Xmf\Yaml::saveWrapped($perms, $this->templateFilename);
272
    }
273
}
274