XOOPS  2.6.0
group.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
14 
27 {
33  public function __construct(XoopsGroup &$obj)
34  {
36 
37  if ($obj->isNew()) {
38  $s_cat_value = '';
39  $a_mod_value = array();
40  $r_mod_value = array();
41  $r_block_value = array();
42  } else {
43  $sysperm_handler = $xoops->getHandlerGroupperm();
44  $s_cat_value = $sysperm_handler->getItemIds('system_admin', $obj->getVar('groupid'));
45  $member_handler = $xoops->getHandlerMember();
46  $thisgroup = $member_handler->getGroup($obj->getVar('groupid'));
47  $moduleperm_handler = $xoops->getHandlerGroupperm();
48  $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
49  $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
50  $gperm_handler = $xoops->getHandlerGroupperm();
51  $r_block_value = $gperm_handler->getItemIds('block_read', $obj->getVar('groupid'));
52  }
53  include_once $xoops->path('/modules/system/constants.php');
54 
56  parent::__construct($title, "groupform", 'admin.php', "post", true);
57  $this->setExtra('enctype="multipart/form-data"');
58 
59  $name_text = new Xoops\Form\Text(SystemLocale::GROUP_NAME, "name", 4, 50, $obj->getVar('name'));
60  $desc_text = new Xoops\Form\TextArea(SystemLocale::GROUP_DESCRIPTION, "desc", $obj->getVar('description'));
61 
63 
64  $s_cat_checkbox_all = new Xoops\Form\Checkbox('', "catbox", 1);
65  $s_cat_checkbox_all->addOption('allbox', XoopsLocale::ALL);
66  $s_cat_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"catbox\" , \"system_catids[]\");' ");
67  $s_cat_checkbox_all->setClass('xo-checkall');
68  $system_catids->addElement($s_cat_checkbox_all);
69 
70  $s_cat_checkbox = new Xoops\Form\Checkbox('', "system_catids", $s_cat_value);
71  //$s_cat_checkbox->columns = 6;
72  $admin_dir = \XoopsBaseConfig::get('root-path') . '/modules/system/admin/';
73  $dirlist = XoopsLists::getDirListAsArray($admin_dir);
74  foreach ($dirlist as $file) {
75  include \XoopsBaseConfig::get('root-path') . '/modules/system/admin/' . $file . '/xoops_version.php';
76  if (!empty($modversion['category'])) {
77  if ($xoops->getModuleConfig('active_' . $file, 'system') == 1) {
78  $s_cat_checkbox->addOption($modversion['category'], $modversion['name']);
79  }
80  }
81  unset($modversion);
82  }
83  unset($dirlist);
84  $system_catids->addElement($s_cat_checkbox);
85 
87 
88  $s_admin_checkbox_all = new Xoops\Form\Checkbox('', "adminbox", 1);
89  $s_admin_checkbox_all->addOption('allbox', XoopsLocale::ALL);
90  $s_admin_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"adminbox\" , \"admin_mids[]\");' ");
91  $s_admin_checkbox_all->setClass('xo-checkall');
92  $admin_mids->addElement($s_admin_checkbox_all);
93 
94  $a_mod_checkbox = new Xoops\Form\Checkbox('', "admin_mids[]", $a_mod_value);
95  //$a_mod_checkbox->columns = 5;
96  $module_handler = $xoops->getHandlerModule();
97  $criteria = new CriteriaCompo(new Criteria('hasadmin', 1));
98  $criteria->add(new Criteria('isactive', 1));
99  $criteria->add(new Criteria('dirname', 'system', '<>'));
100  $a_mod_checkbox->addOptionArray($module_handler->getNameList($criteria));
101  $admin_mids->addElement($a_mod_checkbox);
102 
104 
105  $s_mod_checkbox_all = new Xoops\Form\Checkbox('', "readbox", 1);
106  $s_mod_checkbox_all->addOption('allbox', XoopsLocale::ALL);
107  $s_mod_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"readbox\" , \"read_mids[]\");' ");
108  $s_mod_checkbox_all->setClass('xo-checkall');
109  $read_mids->addElement($s_mod_checkbox_all);
110 
111  $r_mod_checkbox = new Xoops\Form\Checkbox('', "read_mids[]", $r_mod_value);
112  //$r_mod_checkbox->columns = 5;
113  $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
114  $criteria->add(new Criteria('isactive', 1));
115  $r_mod_checkbox->addOptionArray($module_handler->getNameList($criteria));
116  $read_mids->addElement($r_mod_checkbox);
117 
118  $criteria = new CriteriaCompo(new Criteria('isactive', 1));
119  $criteria->setSort("mid");
120  $criteria->setOrder("ASC");
121  $module_list = $module_handler->getNameList($criteria);
122  $module_list[0] = SystemLocale::CUSTOM_BLOCK;
123 
124  $block_handler = $xoops->getHandlerBlock();
125  $blocks_obj = $block_handler->getDistinctObjects(
126  new Criteria("mid", "('" . implode("', '", array_keys($module_list)) . "')", "IN"),
127  true
128  );
129 
130  $blocks_module = array();
131  foreach (array_keys($blocks_obj) as $bid) {
132  $title = $blocks_obj[$bid]->getVar("title");
133  $blocks_module[$blocks_obj[$bid]->getVar('mid')][$blocks_obj[$bid]->getVar('bid')] =
134  empty($title) ? $blocks_obj[$bid]->getVar("name") : $title;
135  }
136  ksort($blocks_module);
137 
138  $r_block_tray = new Xoops\Form\ElementTray(SystemLocale::BLOCK_ACCESS_RIGHTS, "<br /><br />");
139  $s_checkbox_all = new Xoops\Form\Checkbox('', "blocksbox", 1);
140  $s_checkbox_all->addOption('allbox', XoopsLocale::ALL);
141  $s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' ");
142  $s_checkbox_all->setClass('xo-checkall');
143  $r_block_tray->addElement($s_checkbox_all);
144  foreach (array_keys($blocks_module) as $mid) {
145 
146  $new_blocks_array = array();
147  foreach ($blocks_module[$mid] as $key => $value) {
148  $new_blocks_array[$key] = "<a href='" . \XoopsBaseConfig::get('url')
149  . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid={$key}' "
150  . "title='ID: {$key}' rel='external'>{$value}</a>";
151  }
152  $r_block_checkbox = new Xoops\Form\Checkbox(
153  '<strong>' . $module_list[$mid] . '</strong><br />',
154  "read_bids[]",
155  $r_block_value
156  );
157  //$r_block_checkbox->columns = 5;
158  $r_block_checkbox->addOptionArray($new_blocks_array);
159  $r_block_tray->addElement($r_block_checkbox);
160  unset($r_block_checkbox);
161  }
162  if (!$obj->isNew()) {
163  $this->addElement(new Xoops\Form\Hidden('g_id', $obj->getVar('groupid')));
164  $this->addElement(new Xoops\Form\Hidden("op", "groups_save_update"));
165  } else {
166  $this->addElement(new Xoops\Form\Hidden("op", "groups_save_add"));
167  }
168  $this->addElement(new Xoops\Form\Hidden('fct', 'groups'));
169 
170  $this->addElement($name_text, true);
171  $this->addElement($desc_text);
172  $this->addElement($system_catids);
173  $this->addElement($admin_mids);
174  $this->addElement($read_mids);
175  $this->addElement($r_block_tray);
176  $this->addElement(new Xoops\Form\Button("", "submit", XoopsLocale::A_SUBMIT, "submit"));
177  }
178 }
$mid
Definition: index.php:39
const BLOCK_ACCESS_RIGHTS
Definition: en_US.php:44
const SYSTEM_ADMIN_RIGHTS
Definition: en_US.php:390
setExtra($extra)
Definition: Form.php:374
const A_SUBMIT
Definition: en_US.php:128
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
static getInstance()
Definition: Xoops.php:160
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
addElement(Element $formElement, $required=false)
Definition: Form.php:206
$admin_dir
Definition: menu.php:39
const ADD_NEW_GROUP
Definition: en_US.php:31
$gperm_handler
getVar($key, $format= 's')
$xoops
Definition: admin.php:25
const GROUP_NAME
Definition: en_US.php:322
const GROUP_DESCRIPTION
Definition: en_US.php:321
const MODULE_ADMIN_RIGHTS
Definition: en_US.php:345
static get($name)
const CUSTOM_BLOCK
Definition: en_US.php:248
$modversion
$criteria
$module_handler
Definition: main.php:55
__construct(XoopsGroup &$obj)
Definition: group.php:33
const MODULE_ACCESS_RIGHTS
Definition: en_US.php:344
$moduleperm_handler
Definition: cp_header.php:31
const EDIT_GROUP
Definition: en_US.php:265