XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
group.php
Go to the documentation of this file.
1 <?php
22 defined('XOOPS_ROOT_PATH') or die('Restricted access');
23 
24 include_once XOOPS_ROOT_PATH . '/kernel/group.php';
25 
32 class SystemGroup extends XoopsGroup
33 {
34 
35  function __construct()
36  {
37  parent::__construct();
38  }
39 
40  function getForm($action = false)
41  {
42  if ($action === false) {
43  $action = $_SERVER["REQUEST_URI"];
44  }
45 
46  if ($this->isNew()) {
47  $s_cat_value = '';
48  $a_mod_value = array();
49  $r_mod_value = array();
50  $r_block_value = array();
51  } else {
52  $sysperm_handler = &xoops_gethandler('groupperm');
53  $s_cat_value = $sysperm_handler->getItemIds('system_admin', $this->getVar('groupid'));
54  $member_handler = &xoops_gethandler('member');
55  $thisgroup = $member_handler->getGroup($this->getVar('groupid'));
56  $moduleperm_handler = &xoops_gethandler('groupperm');
57  $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
58  $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
59  $gperm_handler = &xoops_gethandler('groupperm');
60  $r_block_value = $gperm_handler->getItemIds('block_read', $this->getVar('groupid'));
61  }
62  xoops_load('XoopsFormLoader');
63  xoops_load('XoopsLists');
64  include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
65 
66  $title = $this->isNew() ? sprintf(_AM_SYSTEM_GROUPS_ADD) : sprintf(_AM_SYSTEM_GROUPS_EDIT);
67  $form = new XoopsThemeForm($title, "groupform", $action, "post", true);
68  $form->setExtra('enctype="multipart/form-data"');
69 
70  $name_text = new XoopsFormText(_AM_SYSTEM_GROUPS_NAME, "name", 30, 50, $this->getVar('name'));
71  $desc_text = new XoopsFormTextArea(_AM_SYSTEM_GROUPS_DESCRIPTION, "desc", $this->getVar('description'));
72 
73  $system_catids = new XoopsFormElementTray( _AM_SYSTEM_GROUPS_SYSTEMRIGHTS, '' );
74 
75  $s_cat_checkbox_all = new XoopsFormCheckBox('', "catbox", 1);
76  $s_cat_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL );
77  $s_cat_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"catbox\" , \"system_catids[]\");' ");
78  $s_cat_checkbox_all->setClass('xo-checkall');
79  $system_catids->addElement($s_cat_checkbox_all);
80 
81  $s_cat_checkbox = new XoopsFormCheckBox( '', "system_catids", $s_cat_value);
82  $s_cat_checkbox->columns = 6;
83  $admin_dir = XOOPS_ROOT_PATH . '/modules/system/admin/';
84  $dirlist = XoopsLists::getDirListAsArray($admin_dir);
85  foreach ($dirlist as $file) {
86  include XOOPS_ROOT_PATH . '/modules/system/admin/' . $file . '/xoops_version.php';
87  if (!empty($modversion['category'])) {
88  if (xoops_getModuleOption('active_' . $file, 'system') == 1){
89  $s_cat_checkbox->addOption($modversion['category'], $modversion['name']);
90  }
91  }
92  unset($modversion);
93  }
94  unset($dirlist);
95  $system_catids->addElement($s_cat_checkbox);
96 
98 
99  $s_admin_checkbox_all = new XoopsFormCheckBox('', "adminbox", 1);
100  $s_admin_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL );
101  $s_admin_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"adminbox\" , \"admin_mids[]\");' ");
102  $s_admin_checkbox_all->setClass('xo-checkall');
103  $admin_mids->addElement($s_admin_checkbox_all);
104 
105  $a_mod_checkbox = new XoopsFormCheckBox( '', "admin_mids[]", $a_mod_value);
106  $a_mod_checkbox->columns = 5;
107  $module_handler =& xoops_gethandler('module');
108  $criteria = new CriteriaCompo(new Criteria('hasadmin', 1));
109  $criteria->add(new Criteria('isactive', 1));
110  $criteria->add(new Criteria('dirname', 'system', '<>'));
111  $a_mod_checkbox->addOptionArray($module_handler->getList($criteria));
112  $admin_mids->addElement($a_mod_checkbox);
113 
115 
116  $s_mod_checkbox_all = new XoopsFormCheckBox('', "readbox", 1);
117  $s_mod_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL );
118  $s_mod_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"readbox\" , \"read_mids[]\");' ");
119  $s_mod_checkbox_all->setClass('xo-checkall');
120  $read_mids->addElement($s_mod_checkbox_all);
121 
122  $r_mod_checkbox = new XoopsFormCheckBox( '', "read_mids[]", $r_mod_value);
123  $r_mod_checkbox->columns = 5;
124  $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
125  $criteria->add(new Criteria('isactive', 1));
126  $r_mod_checkbox->addOptionArray($module_handler->getList($criteria));
127  $read_mids->addElement($r_mod_checkbox);
128 
129 
130  $criteria = new CriteriaCompo(new Criteria('isactive', 1));
131  $criteria->setSort("mid");
132  $criteria->setOrder("ASC");
133  $module_list = $module_handler->getList($criteria);
134  $module_list[0] = _AM_SYSTEM_GROUPS_CUSTOMBLOCK;
135 
136  $block_handler = xoops_getHandler("block");
137  $blocks_obj = $block_handler->getObjects(new Criteria("mid", "('" . implode("', '", array_keys($module_list)) . "')", "IN"), true);
138 
139  $blocks_module = array();
140  foreach (array_keys($blocks_obj) as $bid) {
141  $title = $blocks_obj[$bid]->getVar("title");
142  $blocks_module[$blocks_obj[$bid]->getVar('mid')][$blocks_obj[$bid]->getVar('bid')] = empty($title) ? $blocks_obj[$bid]->getVar("name") : $title;
143  }
144  ksort($blocks_module);
145 
146  $r_block_tray = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_BLOCKRIGHTS, "<br /><br />");
147  $s_checkbox_all = new XoopsFormCheckBox('', "blocksbox", 1);
148  $s_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL );
149  $s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' ");
150  $s_checkbox_all->setClass('xo-checkall');
151  $r_block_tray->addElement($s_checkbox_all);
152  foreach (array_keys($blocks_module) as $mid) {
153 
154  $new_blocks_array = array();
155  foreach ($blocks_module[$mid] as $key => $value) {
156  $new_blocks_array[$key] = "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid={$key}' title='ID: {$key}' rel='external'>{$value}</a>";
157  }
158  $r_block_checkbox = new XoopsFormCheckBox('<strong>' . $module_list[$mid] . '</strong><br />', "read_bids[]", $r_block_value);
159  $r_block_checkbox->columns = 5;
160  $r_block_checkbox->addOptionArray($new_blocks_array);
161  $r_block_tray->addElement($r_block_checkbox);
162  unset($r_block_checkbox);
163  }
164  if (!$this->isNew()) {
165  $form->addElement(new XoopsFormHidden('g_id', $this->getVar('groupid')));
166  $form->addElement(new XoopsFormHidden("op", "groups_save_update"));
167  }else{
168  $form->addElement(new XoopsFormHidden("op", "groups_save_add"));
169  }
170  $form->addElement($name_text, true);
171  $form->addElement($desc_text);
172  $form->addElement($system_catids);
173  $form->addElement($admin_mids);
174  $form->addElement($read_mids);
175  $form->addElement($r_block_tray);
176  $form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
177  return $form;
178  }
179 
180 }
181 
193 {
194  function __construct($db) {
195  parent::__construct($db, 'groups', 'SystemGroup', 'groupid', 'name');
196  }
197 }
198 
199 ?>