1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Wggithub; |
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
|
|
|
* wgGitHub module for xoops |
17
|
|
|
* |
18
|
|
|
* @copyright 2020 XOOPS Project (https://xooops.org) |
19
|
|
|
* @license GPL 2.0 or later |
20
|
|
|
* @package wggithub |
21
|
|
|
* @since 1.0 |
22
|
|
|
* @min_xoops 2.5.10 |
23
|
|
|
* @author Goffy - XOOPS Development Team - Email:<[email protected]> - Website:<https://wedega.com> |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
use XoopsModules\Wggithub; |
27
|
|
|
use XoopsModules\Wggithub\Constants; |
28
|
|
|
|
29
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class Object PermissionsHandler |
33
|
|
|
*/ |
34
|
|
|
class PermissionsHandler extends \XoopsPersistableObjectHandler |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* Constructor |
38
|
|
|
* |
39
|
|
|
* @param null |
40
|
|
|
*/ |
41
|
|
|
public function __construct() |
42
|
|
|
{ |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @public function getPermGlobalRead |
47
|
|
|
* returns global right for reading from github |
48
|
|
|
* |
49
|
|
|
* @param null |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
|
|
public function getPermGlobalRead() |
53
|
|
|
{ |
54
|
|
|
global $xoopsUser, $xoopsModule; |
55
|
|
|
$currentuid = 0; |
56
|
|
|
if (isset($xoopsUser) && \is_object($xoopsUser)) { |
57
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
58
|
|
|
return true; |
59
|
|
|
} |
60
|
|
|
$currentuid = $xoopsUser->uid(); |
61
|
|
|
} |
62
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
|
|
|
63
|
|
|
$mid = $xoopsModule->mid(); |
64
|
|
|
$memberHandler = \xoops_getHandler('member'); |
65
|
|
|
if (0 == $currentuid) { |
66
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
|
|
|
67
|
|
|
} else { |
68
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
69
|
|
|
} |
70
|
|
|
if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_READ, $my_group_ids, $mid)) { |
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
return false; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @public function permGlobalSubmit |
78
|
|
|
* returns right for global view |
79
|
|
|
* |
80
|
|
|
* @param null |
81
|
|
|
* @return bool |
82
|
|
|
*/ |
83
|
|
|
public function getPermGlobalView() |
84
|
|
|
{ |
85
|
|
|
global $xoopsUser, $xoopsModule; |
86
|
|
|
|
87
|
|
|
if ($this->getPermGlobalRead()) { |
88
|
|
|
return true; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$currentuid = 0; |
92
|
|
|
if (isset($xoopsUser) && \is_object($xoopsUser)) { |
93
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
94
|
|
|
return true; |
95
|
|
|
} |
96
|
|
|
$currentuid = $xoopsUser->uid(); |
97
|
|
|
} |
98
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
|
|
|
99
|
|
|
$mid = $xoopsModule->mid(); |
100
|
|
|
$memberHandler = \xoops_getHandler('member'); |
101
|
|
|
if (0 == $currentuid) { |
102
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
|
|
|
103
|
|
|
} else { |
104
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
105
|
|
|
} |
106
|
|
|
if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_GLOBAL_VIEW, $my_group_ids, $mid)) { |
107
|
|
|
return true; |
108
|
|
|
} |
109
|
|
|
return false; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @public function getPermReadmeUpdate |
114
|
|
|
* returns right for updating existing readme |
115
|
|
|
* |
116
|
|
|
* @param null |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
|
|
public function getPermReadmeUpdate() |
120
|
|
|
{ |
121
|
|
|
global $xoopsUser, $xoopsModule; |
122
|
|
|
$currentuid = 0; |
123
|
|
|
if (isset($xoopsUser) && \is_object($xoopsUser)) { |
124
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
125
|
|
|
return true; |
126
|
|
|
} |
127
|
|
|
$currentuid = $xoopsUser->uid(); |
128
|
|
|
} |
129
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
|
|
|
130
|
|
|
$mid = $xoopsModule->mid(); |
131
|
|
|
$memberHandler = \xoops_getHandler('member'); |
132
|
|
|
if (0 == $currentuid) { |
133
|
|
|
$my_group_ids = [XOOPS_GROUP_ANONYMOUS]; |
|
|
|
|
134
|
|
|
} else { |
135
|
|
|
$my_group_ids = $memberHandler->getGroupsByUser($currentuid); |
136
|
|
|
} |
137
|
|
|
if ($grouppermHandler->checkRight('wggithub_ac', Constants::PERM_README_UPDATE, $my_group_ids, $mid)) { |
138
|
|
|
return true; |
139
|
|
|
} |
140
|
|
|
return false; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths