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 IndexController |
30
|
|
|
*/ |
31
|
|
|
class IndexController extends Controller |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @param string|null $section |
35
|
|
|
* @return int|void |
36
|
|
|
*/ |
37
|
|
|
public function checkPrivilege($section = null) |
38
|
|
|
{ |
39
|
|
|
global $xoopsModuleConfig; |
40
|
|
|
if ('' === \trim($section)) { |
|
|
|
|
41
|
|
|
return -1; |
42
|
|
|
} |
43
|
|
|
$configsectionname = 'enable_' . $section; |
44
|
|
|
if (\array_key_exists($configsectionname, $xoopsModuleConfig)) { |
45
|
|
|
if (0 === $this->helper->getConfig($configsectionname)) { |
46
|
|
|
return -1; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
// if ($section=="Notes" && $xoopsModuleConfig['enable_notes']==0){ |
50
|
|
|
// return false; |
51
|
|
|
// } |
52
|
|
|
// if ($section=="pictures" && $xoopsModuleConfig['enable_pictures']==0){ |
53
|
|
|
// return false; |
54
|
|
|
// } |
55
|
|
|
// |
56
|
|
|
// if ($section=="pictures" && $xoopsModuleConfig['enable_pictures']==0){ |
57
|
|
|
// return false; |
58
|
|
|
// } |
59
|
|
|
$criteria = new Criteria('config_uid', $this->owner->getVar('uid')); |
|
|
|
|
60
|
|
|
if (1 === $this->configsFactory->getCount($criteria)) { |
61
|
|
|
$configs = $this->configsFactory->getObjects($criteria); |
62
|
|
|
$config = $configs[0]->getVar($section); |
63
|
|
|
if (!$this->checkPrivilegeLevel($config)) { |
64
|
|
|
return 0; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return 1; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|