1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Extgallery; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* ExtGallery Class Manager |
7
|
|
|
* |
8
|
|
|
* You may not change or alter any portion of this comment or credits |
9
|
|
|
* of supporting developers from this source code or any supporting source code |
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14
|
|
|
* |
15
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
16
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
17
|
|
|
* @author Zoullou (http://www.zoullou.net) |
18
|
|
|
* @package ExtGallery |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use XoopsModules\Extgallery; |
22
|
|
|
|
23
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Extgallery\GroupPermForm |
27
|
|
|
*/ |
28
|
|
|
class GroupPermForm extends \XoopsGroupPermForm |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Extgallery\GroupPermForm constructor. |
32
|
|
|
* @param string $title |
33
|
|
|
* @param string $modid |
34
|
|
|
* @param string $permname |
35
|
|
|
* @param string $permdesc |
36
|
|
|
* @param string $url |
37
|
|
|
* @param bool $anonymous |
38
|
|
|
*/ |
39
|
|
|
public function __construct($title, $modid, $permname, $permdesc, $url = '', $anonymous = true) |
40
|
|
|
{ |
41
|
|
|
parent::__construct($title, $modid, $permname, $permdesc, $url, $anonymous); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string|void |
46
|
|
|
*/ |
47
|
|
|
public function render() |
48
|
|
|
{ |
49
|
|
|
// load all child ids for javascript codes |
50
|
|
|
foreach (\array_keys($this->_itemTree) as $item_id) { |
51
|
|
|
$this->_itemTree[$item_id]['allchild'] = []; |
52
|
|
|
$this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
53
|
|
|
} |
54
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
55
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
56
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
57
|
|
|
$memberHandler = \xoops_getHandler('member'); |
58
|
|
|
$glist = $memberHandler->getGroupList(); |
59
|
|
|
foreach (\array_keys($glist) as $i) { |
60
|
|
|
if (XOOPS_GROUP_ANONYMOUS == $i && !$this->_showAnonymous) { |
61
|
|
|
continue; |
62
|
|
|
} |
63
|
|
|
// get selected item id(s) for each group |
64
|
|
|
$selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
65
|
|
|
$ele = new Extgallery\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
66
|
|
|
$ele->setOptionTree($this->_itemTree); |
67
|
|
|
$this->addElement($ele); |
68
|
|
|
unset($ele); |
69
|
|
|
} |
70
|
|
|
$tray = new \XoopsFormElementTray(''); |
71
|
|
|
$tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
72
|
|
|
$tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
73
|
|
|
$this->addElement($tray); |
74
|
|
|
echo '<h4>' . $this->getTitle() . '</h4>'; |
75
|
|
|
if ($this->_permDesc) { |
76
|
|
|
echo $this->_permDesc . '<br><br>'; |
77
|
|
|
} |
78
|
|
|
echo "<form name='" . $this->getName() . '\' id=\'' . $this->getName() . '\' action=\'' . $this->getAction() . '\' method=\'' . $this->getMethod() . '\'' . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
79
|
|
|
$elements = &$this->getElements(); |
80
|
|
|
$hidden = ''; |
81
|
|
|
foreach (\array_keys($elements) as $i) { |
82
|
|
|
if (!\is_object($elements[$i])) { |
83
|
|
|
echo $elements[$i]; |
|
|
|
|
84
|
|
|
} elseif (!$elements[$i]->isHidden()) { |
85
|
|
|
echo "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
86
|
|
|
if ('' != $elements[$i]->getDescription()) { |
87
|
|
|
echo '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
88
|
|
|
} |
89
|
|
|
echo "</td>\n<td class='even'>\n"; |
90
|
|
|
if (\is_a($elements[$i], 'Extgallery\GroupFormCheckBox')) { |
91
|
|
|
$elements[$i]->render(); |
92
|
|
|
} else { |
93
|
|
|
echo $elements[$i]->render(); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
echo "\n</td></tr>\n"; |
96
|
|
|
} else { |
97
|
|
|
$hidden .= $elements[$i]->render(); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
echo "</table>$hidden</form>"; |
101
|
|
|
echo $this->renderValidationJS(true); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|