1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: class LegacyGroup_permissionObject extends XoopsSimpleObject
14: {
15: function LegacyGroup_permissionObject()
16: {
17: static $initVars;
18: if (isset($initVars)) {
19: $this->mVars = $initVars;
20: return;
21: }
22: $this->initVar('gperm_id', XOBJ_DTYPE_INT, '', true);
23: $this->initVar('gperm_groupid', XOBJ_DTYPE_INT, '0', true);
24: $this->initVar('gperm_itemid', XOBJ_DTYPE_INT, '0', true);
25: $this->initVar('gperm_modid', XOBJ_DTYPE_INT, '0', true);
26: $this->initVar('gperm_name', XOBJ_DTYPE_STRING, '', true, 50);
27: $initVars=$this->mVars;
28: }
29: }
30:
31: class LegacyGroup_permissionHandler extends XoopsObjectGenericHandler
32: {
33: var $mTable = "group_permission";
34: var $mPrimary = "gperm_id";
35: var $mClass = "LegacyGroup_permissionObject";
36:
37: 38: 39: 40: 41: 42:
43: function getRolesByModule($mid, $groups)
44: {
45: $retRoles = array();
46:
47: $sql = "SELECT gperm_name FROM " . $this->mTable . " WHERE gperm_modid=" . intval($mid) . " AND gperm_itemid=0 AND ";
48: $groupSql = array();
49:
50: foreach ($groups as $gid) {
51: $groupSql[] = "gperm_groupid=" . intval($gid);
52: }
53:
54: $sql .= "(" . implode(' OR ', $groupSql) . ")";
55:
56: $result = $this->db->query($sql);
57:
58: if (!$result) {
59: return $retRoles;
60: }
61:
62: while ($row = $this->db->fetchArray($result)) {
63: $retRoles[] = $row['gperm_name'];
64: }
65:
66: return $retRoles;
67: }
68: }
69:
70: ?>
71: