|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Mymodule2; |
|
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
|
|
|
/** |
|
16
|
|
|
* My Module 2 module for xoops |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright 2020 XOOPS Project (https://xooops.org) |
|
19
|
|
|
* @license GPL 2.0 or later |
|
20
|
|
|
* @package mymodule2 |
|
21
|
|
|
* @since 1.0 |
|
22
|
|
|
* @min_xoops 2.5.9 |
|
23
|
|
|
* @author TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org> |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
use XoopsModules\Mymodule2; |
|
27
|
|
|
|
|
28
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Class Object Permissionshandler |
|
32
|
|
|
*/ |
|
33
|
|
|
class Permissionshandler extends \XoopsPersistableObjectHandler |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Constructor |
|
37
|
|
|
* |
|
38
|
|
|
* @param null |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct() |
|
41
|
|
|
{ |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @public function permGlobalApprove |
|
46
|
|
|
* returns right for global approve |
|
47
|
|
|
* |
|
48
|
|
|
* @param null |
|
49
|
|
|
* return bool |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getPermGlobalApprove() |
|
52
|
|
|
{ |
|
53
|
|
|
global $xoopsUser, $xoopsModule; |
|
54
|
|
|
$currentuid = 0; |
|
55
|
|
|
if (isset($xoopsUser) && is_object($xoopsUser)) { |
|
56
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
57
|
|
|
return true; |
|
58
|
|
|
} |
|
59
|
|
|
$currentuid = $xoopsUser->uid(); |
|
60
|
|
|
} |
|
61
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
62
|
|
|
$mid = $xoopsModule->mid(); |
|
63
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
64
|
|
|
if (0 == $currentuid) { |
|
65
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
66
|
|
|
} else { |
|
67
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid);; |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
if ($grouppermHandler->checkRight('mymodule2_ac', 4, $my_group_ids, $mid)) { |
|
|
|
|
|
|
70
|
|
|
return true; |
|
71
|
|
|
} |
|
72
|
|
|
return false; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @public function permGlobalSubmit |
|
77
|
|
|
* returns right for global submit |
|
78
|
|
|
* |
|
79
|
|
|
* @param null |
|
80
|
|
|
* return bool |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getPermGlobalSubmit() |
|
83
|
|
|
{ |
|
84
|
|
|
global $xoopsUser, $xoopsModule; |
|
85
|
|
|
$currentuid = 0; |
|
86
|
|
|
if (isset($xoopsUser) && is_object($xoopsUser)) { |
|
87
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
88
|
|
|
return true; |
|
89
|
|
|
} |
|
90
|
|
|
$currentuid = $xoopsUser->uid(); |
|
91
|
|
|
} |
|
92
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
93
|
|
|
$mid = $xoopsModule->mid(); |
|
94
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
95
|
|
|
if (0 == $currentuid) { |
|
96
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
97
|
|
|
} else { |
|
98
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid);; |
|
99
|
|
|
} |
|
100
|
|
|
if ($this->getGlobalApprove()) { |
|
|
|
|
|
|
101
|
|
|
return true; |
|
102
|
|
|
} |
|
103
|
|
|
if ($grouppermHandler->checkRight('mymodule2_ac', 8, $my_group_ids, $mid)) { |
|
104
|
|
|
return true; |
|
105
|
|
|
} |
|
106
|
|
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @public function permGlobalView |
|
111
|
|
|
* returns right for global view |
|
112
|
|
|
* |
|
113
|
|
|
* @param null |
|
114
|
|
|
* return bool |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getPermGlobalView() |
|
117
|
|
|
{ |
|
118
|
|
|
global $xoopsUser, $xoopsModule; |
|
119
|
|
|
$currentuid = 0; |
|
120
|
|
|
if (isset($xoopsUser) && is_object($xoopsUser)) { |
|
121
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
|
122
|
|
|
return true; |
|
123
|
|
|
} |
|
124
|
|
|
$currentuid = $xoopsUser->uid(); |
|
125
|
|
|
} |
|
126
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
127
|
|
|
$mid = $xoopsModule->mid(); |
|
128
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
129
|
|
|
if (0 == $currentuid) { |
|
130
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
131
|
|
|
} else { |
|
132
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid);; |
|
133
|
|
|
} |
|
134
|
|
|
if ($this->getGlobalApprove()) { |
|
135
|
|
|
return true; |
|
136
|
|
|
} |
|
137
|
|
|
if ($this->getGlobalSubmit()) { |
|
|
|
|
|
|
138
|
|
|
return true; |
|
139
|
|
|
} |
|
140
|
|
|
if ($grouppermHandler->checkRight('mymodule2_ac', 16, $my_group_ids, $mid)) { |
|
141
|
|
|
return true; |
|
142
|
|
|
} |
|
143
|
|
|
return false; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|