XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
group_permission.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15class LegacyGroup_permissionObject extends XoopsSimpleObject
16{
17 public function LegacyGroup_permissionObject()
18 {
19 self::__construct();
20 }
21
22 public function __construct()
23 {
24 static $initVars;
25 if (isset($initVars)) {
26 $this->mVars = $initVars;
27 return;
28 }
29 $this->initVar('gperm_id', XOBJ_DTYPE_INT, '', true);
30 $this->initVar('gperm_groupid', XOBJ_DTYPE_INT, '0', true);
31 $this->initVar('gperm_itemid', XOBJ_DTYPE_INT, '0', true);
32 $this->initVar('gperm_modid', XOBJ_DTYPE_INT, '0', true);
33 $this->initVar('gperm_name', XOBJ_DTYPE_STRING, '', true, 50);
34 $initVars=$this->mVars;
35 }
36}
37
39{
40 public $mTable = 'group_permission';
41 public $mPrimary = 'gperm_id';
42 public $mClass = 'LegacyGroup_permissionObject';
43
50 public function getRolesByModule($mid, $groups)
51 {
52 $retRoles = [];
53
54 $sql = 'SELECT gperm_name FROM ' . $this->mTable . ' WHERE gperm_modid=' . (int)$mid . ' AND gperm_itemid=0 AND ';
55 $groupSql = [];
56
57 foreach ($groups as $gid) {
58 $groupSql[] = 'gperm_groupid=' . (int)$gid;
59 }
60
61 $sql .= '(' . implode(' OR ', $groupSql) . ')';
62
63 $result = $this->db->query($sql);
64
65 if (!$result) {
66 return $retRoles;
67 }
68
69 while ($row = $this->db->fetchArray($result)) {
70 $retRoles[] = $row['gperm_name'];
71 }
72
73 return $retRoles;
74 }
75}