20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
71 $this->XoopsForm(
$title,
'groupperm_form', XOOPS_URL .
'/modules/system/admin/groupperm.php',
'post');
72 $this->_modid = intval(
$modid);
73 $this->_permName = $permname;
74 $this->_permDesc = $permdesc;
75 $this->addElement(
new XoopsFormHidden(
'modid', $this->_modid));
76 $this->addElement(
new XoopsFormHiddenToken($permname));
78 $this->addElement(
new XoopsFormHidden(
'redirect_url',
$url));
80 $this->_showAnonymous = $anonymous;
91 function addItem($itemId, $itemName, $itemParent = 0)
93 $this->_itemTree[$itemParent][
'children'][] = $itemId;
94 $this->_itemTree[$itemId][
'parent'] = $itemParent;
95 $this->_itemTree[$itemId][
'name'] = $itemName;
96 $this->_itemTree[$itemId][
'id'] = $itemId;
106 function _loadAllChildItemIds($itemId, &$childIds)
108 if (! empty($this->_itemTree[$itemId][
'children'])) {
109 $first_child = $this->_itemTree[$itemId][
'children'];
110 foreach($first_child as $fcid) {
111 array_push($childIds, $fcid);
112 if (! empty($this->_itemTree[$fcid][
'children'])) {
113 foreach($this->_itemTree[$fcid][
'children'] as $_fcid) {
114 array_push($childIds, $_fcid);
115 $this->_loadAllChildItemIds($_fcid, $childIds);
131 foreach(array_keys($this->_itemTree) as $item_id) {
132 $this->_itemTree[$item_id][
'allchild'] = array();
133 $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id][
'allchild']);
138 foreach(array_keys($glist) as
$i) {
139 if ($i == XOOPS_GROUP_ANONYMOUS && ! $this->_showAnonymous)
142 $selected =
$gperm_handler->getItemIds($this->_permName, $i, $this->_modid);
144 $ele->setOptionTree($this->_itemTree);
145 $this->addElement($ele);
148 $tray =
new XoopsFormElementTray(
'');
149 $tray->addElement(
new XoopsFormButton(
'',
'submit',
_SUBMIT,
'submit'));
150 $tray->addElement(
new XoopsFormButton(
'',
'reset',
_CANCEL,
'reset'));
151 $this->addElement($tray);
153 $ret =
'<h4>' . $this->getTitle() .
'</h4>';
154 if ($this->_permDesc) {
155 $ret .= $this->_permDesc .
'<br /><br />';
157 $ret .=
'<form title="' . str_replace(
'"',
'', $this->getTitle()) .
'" name="' . $this->getName() .
'" id="' . $this->getName() .
'" action="' . $this->getAction() .
'" method="' . $this->getMethod() .
'"' . $this->getExtra() .
'>' .
'<table width="100%" class="outer" cellspacing="1" valign="top">' ;
158 $elements = $this->getElements();
160 foreach(array_keys($elements) as $i) {
161 if (! is_object($elements[$i])) {
163 } elseif (! $elements[$i]->isHidden()) {
164 $ret .=
'<tr valign="top" align="left"><td class="head">' . $elements[
$i]->getCaption();
165 if ($elements[$i]->getDescription() !=
"") {
166 $ret .=
"<br /><br /><span style='font-weight: normal;'>" . $elements[
$i]->getDescription() .
"</span>";
168 $ret .=
'</td>' .
'<td class="even">' . $elements[
$i]->render() .
'</td></tr>' .
'';
170 $hidden .= $elements[
$i]->render();
173 $ret .=
'</table>' . $hidden .
'</form>';
174 $ret .= $this->renderValidationJS(
true);
210 if (isset($values)) {
213 $this->_groupId = $groupId;
224 if (is_array($value)) {
225 foreach($value as $v) {
229 $this->_value[] = $value;
241 $this->_optionTree = &$optionTree;
253 $ret =
'<table class="outer"><tr><td class="odd"><table><tr>';
255 foreach($this->_optionTree[0][
'children'] as $topitem) {
260 $tree =
'<td valign="top">';
263 $ret .= $tree .
'</td>';
266 $ret .=
'</tr></table></td><td class="even" valign="top">';
267 $option_ids = array();
268 foreach(array_keys($this->_optionTree) as $id) {
270 $option_ids[] =
"'" . $ele_name .
'[groups][' . $this->_groupId .
'][' . $id .
']' .
"'";
273 $checkallbtn_id = $ele_name .
'[checkallbtn][' . $this->_groupId .
']';
274 $option_ids_str = implode(
', ', $option_ids);
275 $ret .=
_ALL .
" <input id=\"" . $checkallbtn_id .
"\" type=\"checkbox\" value=\"\" onclick=\"var optionids = new Array(" . $option_ids_str .
"); xoopsCheckAllElements(optionids, '" . $checkallbtn_id .
"');\" />";
276 $ret .=
'</td></tr></table>';
292 $tree .= $prefix .
"<input type=\"checkbox\" name=\"" . $ele_name .
"[groups][" . $this->_groupId .
"][" . $option[
'id'] .
"]\" id=\"" . $ele_name .
"[groups][" . $this->_groupId .
"][" . $option[
'id'] .
"]\" onclick=\"";
296 foreach($parentIds as $pid) {
297 $parent_ele = $ele_name .
'[groups][' . $this->_groupId .
'][' . $pid .
']';
298 $tree .=
"var ele = xoopsGetElementById('" . $parent_ele .
"'); if(ele.checked != true) {ele.checked = this.checked;}";
304 foreach($option[
'allchild'] as $cid) {
305 $child_ele = $ele_name .
'[groups][' . $this->_groupId .
'][' . $cid .
']';
306 $tree .=
"var ele = xoopsGetElementById('" . $child_ele .
"'); if(this.checked != true) {ele.checked = false;}";
308 $tree .=
'" value="1"';
309 if (in_array($option[
'id'], $this->_value)) {
310 $tree .=
' checked="checked"';
312 $tree .=
" />" . $option[
'name'] .
"<input type=\"hidden\" name=\"" . $ele_name .
"[parents][" . $option[
'id'] .
"]\" value=\"" . implode(
':', $parentIds) .
"\" /><input type=\"hidden\" name=\"" . $ele_name .
"[itemname][" . $option[
'id'] .
"]\" value=\"" . htmlspecialchars($option[
'name']) .
"\" /><br />\n";
313 if (isset($option[
'children'])) {
314 foreach($option[
'children'] as $child) {
315 array_push($parentIds, $option[
'id']);
316 $this->
_renderOptionTree($tree, $this->_optionTree[$child], $prefix .
' -', $parentIds);