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
|
|
|
* Publisher class |
14
|
|
|
* |
15
|
|
|
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
16
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
17
|
|
|
* @package Publisher |
18
|
|
|
* @since 1.0 |
19
|
|
|
* @author trabis <[email protected]> |
20
|
|
|
* @version $Id: groupperm.php 10374 2012-12-12 23:39:48Z trabis $ |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
|
|
|
24
|
|
|
|
25
|
|
|
include_once $GLOBALS['xoops']->path('kernel/groupperm.php'); |
26
|
|
|
|
27
|
|
|
include_once dirname(__DIR__) . '/include/common.php'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class PublisherGroupPermHandler |
31
|
|
|
*/ |
32
|
|
|
class PublisherGroupPermHandler extends XoopsGroupPermHandler |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Check permission |
36
|
|
|
* |
37
|
|
|
* @param string $gpermName Name of permission |
38
|
|
|
* @param int $gpermItemId ID of an item |
39
|
|
|
* @param int /array $gpermGroupId A group ID or an array of group IDs |
40
|
|
|
* @param int $gpermModId ID of a module |
41
|
|
|
* |
42
|
|
|
* @return bool TRUE if permission is enabled |
43
|
|
|
*/ |
44
|
|
|
public function checkRight($gpermName, $gpermItemId, $gpermGroupId, $gpermModId = 1) |
45
|
|
|
{ |
46
|
|
|
$criteria = new CriteriaCompo(new Criteria('gperm_modid', $gpermModId)); |
47
|
|
|
$criteria->add(new Criteria('gperm_name', $gpermName)); |
48
|
|
|
$gpermItemId = (int)$gpermItemId; |
49
|
|
|
if ($gpermItemId > 0) { |
50
|
|
|
$criteria->add(new Criteria('gperm_itemid', $gpermItemId)); |
51
|
|
|
} |
52
|
|
|
if (is_array($gpermGroupId)) { |
53
|
|
|
$criteria2 = new CriteriaCompo(); |
54
|
|
|
foreach ($gpermGroupId as $gid) { |
55
|
|
|
$criteria2->add(new Criteria('gperm_groupid', $gid), 'OR'); |
56
|
|
|
} |
57
|
|
|
$criteria->add($criteria2); |
58
|
|
|
} else { |
59
|
|
|
$criteria->add(new Criteria('gperm_groupid', $gpermGroupId)); |
60
|
|
|
} |
61
|
|
|
return $this->getCount($criteria) > 0; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
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.