19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
50 function id($format =
'N')
52 return $this->getVar(
'gperm_id', $format);
58 function gperm_id($format =
'')
60 return $this->getVar(
'gperm_id', $format);
66 function gperm_groupid($format =
'')
68 return $this->getVar(
'gperm_groupid', $format);
74 function gperm_itemid($format =
'')
76 return $this->getVar(
'gperm_itemid', $format);
82 function gperm_modid($format =
'')
84 return $this->getVar(
'gperm_modid', $format);
90 function gperm_name($format =
'')
92 return $this->getVar(
'gperm_name', $format);
136 $sql = sprintf(
"SELECT * FROM %s WHERE gperm_id = %u", $this->db->prefix(
'group_permission'), $id);
140 $numrows = $this->db->getRowsNum(
$result);
143 $perm->assignVars($this->db->fetchArray(
$result));
161 if (!is_a($perm,
'xoopsgroupperm')) {
164 if (!$perm->isDirty()) {
167 if (!$perm->cleanVars()) {
170 foreach ($perm->cleanVars as $k => $v) {
173 if ($perm->isNew()) {
174 $gperm_id = $this->db->genId(
'group_permission_gperm_id_seq');
175 $sql = sprintf(
"INSERT INTO %s (gperm_id, gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, %u, %u, %s)", $this->db->prefix(
'group_permission'), $gperm_id, $gperm_groupid, $gperm_itemid, $gperm_modid, $this->db->quoteString($gperm_name));
177 $sql = sprintf(
"UPDATE %s SET gperm_groupid = %u, gperm_itemid = %u, gperm_modid = %u WHERE gperm_id = %u", $this->db->prefix(
'group_permission'), $gperm_groupid, $gperm_itemid, $gperm_modid, $gperm_id);
182 if (empty($gperm_id)) {
183 $gperm_id = $this->db->getInsertId();
185 $perm->assignVar(
'gperm_id', $gperm_id);
196 function delete(&$perm)
201 if (!is_a($perm,
'xoopsgroupperm')) {
204 $sql = sprintf(
"DELETE FROM %s WHERE gperm_id = %u", $this->db->prefix(
'group_permission'), $perm->getVar(
'gperm_id'));
223 $sql =
'SELECT * FROM ' . $this->db->prefix(
'group_permission');
233 while ($myrow = $this->db->fetchArray(
$result)) {
235 $perm->assignVars($myrow);
239 $ret[$myrow[
'gperm_id']] =& $perm;
255 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix(
'group_permission');
263 list ($count) = $this->db->fetchRow(
$result);
276 $sql = sprintf(
"DELETE FROM %s", $this->db->prefix(
'group_permission'));
297 if (isset($gperm_modid)) {
315 if (isset($gperm_name)) {
317 if (isset($gperm_itemid)) {
335 function checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid = 1, $trueifadmin =
true)
337 if (empty($gperm_groupid)) {
339 }
else if (is_array($gperm_groupid)) {
340 if (in_array(XOOPS_GROUP_ADMIN, $gperm_groupid) && $trueifadmin) {
344 foreach ($gperm_groupid as $gid) {
345 $criteria_group->add(
new Criteria(
'gperm_groupid', $gid),
'OR');
348 if (XOOPS_GROUP_ADMIN == $gperm_groupid && $trueifadmin) {
356 $gperm_itemid = intval($gperm_itemid);
357 if ($gperm_itemid > 0) {
376 function addRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid = 1)
379 $perm->setVar(
'gperm_name', $gperm_name);
380 $perm->setVar(
'gperm_groupid', $gperm_groupid);
381 $perm->setVar(
'gperm_itemid', $gperm_itemid);
382 $perm->setVar(
'gperm_modid', $gperm_modid);
383 return $this->
insert($perm);
395 function getItemIds($gperm_name, $gperm_groupid, $gperm_modid = 1)
400 if (is_array($gperm_groupid)) {
402 foreach($gperm_groupid as $gid) {
410 foreach (array_keys($perms) as
$i) {
411 $ret[] = $perms[
$i]->getVar(
'gperm_itemid');
413 return array_unique(
$ret);
425 function getGroupIds($gperm_name, $gperm_itemid, $gperm_modid = 1)
432 foreach(array_keys($perms) as
$i) {
433 $ret[] = $perms[
$i]->getVar(
'gperm_groupid');