1: <?php defined('_JOOS_CORE') or exit();
2:
3: /**
4: * Упрощённая заглушка для проверки прав
5: */
6: class helperAcl
7: {
8: public static function is_allowed($full_operations_name)
9: {
10: $user_id = joosCore::user()->id;
11:
12: return self::check_access_for_user_id($full_operations_name,$user_id);
13: }
14:
15: public static function is_deny($full_operations_name)
16: {
17: return !self::is_allowed($full_operations_name);
18: }
19:
20: public static function check_access_for_user_id($full_operations_name,$user_id)
21: {
22: static $allowed_rules;
23:
24: if ($allowed_rules===null) {
25: $sql = sprintf("SELECT DISTINCT CONCAT_WS('::',al.acl_group, al.acl_name) AS rule_name, 1 AS value FROM #__users_acl_rules_groups AS aa INNER JOIN #__users_acl_groups AS ag ON ( ag.id=aa.group_id ) INNER JOIN #__users_acl_rules AS al ON ( al.id=aa.task_id ) WHERE ag.id IN ( SELECT group_id FROM #__users_acl_groups_users WHERE user_id = %s )", $user_id );
26: $allowed_rules = joosDatabase::instance()->set_query($sql)->load_row_array('rule_name','value');
27: }
28:
29: return isset( $allowed_rules[$full_operations_name] );
30: }
31:
32: }
33:
34: /**
35: * Class AclGroups
36: *
37: * @package Components\Acls
38: * @subpackage Models\Site
39: * @author JoostinaTeam
40: * @copyright (C) 2007-2012 Joostina Team
41: * @license MIT License http://www.opensource.org/licenses/mit-license.php
42: * @version 1
43: * @created 2011-12-05 12:38:49
44: * Информация об авторах и лицензиях стороннего кода в составе Joostina CMS: docs/copyrights
45: */
46: class modelUsersAclGroups extends joosModel
47: {
48: /**
49: * @field int(11) unsigned
50: * @type int
51: */
52: public $id;
53:
54: /**
55: * @field varchar(20)
56: * @type string
57: */
58: public $title;
59:
60: /**
61: * @field varchar(250)
62: * @type string
63: */
64: public $name;
65:
66: /**
67: * @field datetime
68: * @type datetime
69: */
70: public $created_at;
71:
72: /**
73: * @field datetime
74: * @type datetime
75: */
76: public $modified_at;
77:
78: /*
79: * Constructor
80: */
81:
82: public function __construct()
83: {
84: parent::__construct('#__users_acl_groups', 'id');
85: }
86:
87: public function check()
88: {
89: $this->filter();
90:
91: return true;
92: }
93: }
94:
95: /**
96: * Class AclList
97: *
98: * @package Components\Acls
99: * @subpackage Models\Site
100: * @author JoostinaTeam
101: * @copyright (C) 2007-2012 Joostina Team
102: * @license MIT License http://www.opensource.org/licenses/mit-license.php
103: * @version 1
104: * @created 2011-12-05 12:38:49
105: * Информация об авторах и лицензиях стороннего кода в составе Joostina CMS: docs/copyrights
106: */
107: class modelUsersAclRules extends joosModel
108: {
109: /**
110: * @field int(11) unsigned
111: * @type int
112: */
113: public $id;
114:
115: /**
116: * @field varchar(200)
117: * @type string
118: */
119: public $title;
120:
121: /**
122: * @field varchar(15)
123: * @type string
124: */
125: public $acl_group;
126:
127: /**
128: * @field varchar(15)
129: * @type string
130: */
131: public $acl_name;
132:
133: /**
134: * @field datetime
135: * @type datetime
136: */
137: public $created_at;
138:
139: /**
140: * @field datetime
141: * @type datetime
142: */
143: public $modified_at;
144:
145: /*
146: * Constructor
147: */
148:
149: public function __construct()
150: {
151: parent::__construct('#__users_acl_rules', 'id');
152: }
153:
154: public function check()
155: {
156: $this->filter();
157:
158: return true;
159: }
160: }
161:
162: /**
163: * Class AclUsersGroups
164: *
165: * @package Components\Acls
166: * @subpackage Models\Site
167: * @author JoostinaTeam
168: * @copyright (C) 2007-2012 Joostina Team
169: * @license MIT License http://www.opensource.org/licenses/mit-license.php
170: * @version 1
171: * @created 2011-12-05 12:38:49
172: * Информация об авторах и лицензиях стороннего кода в составе Joostina CMS: docs/copyrights
173: */
174: class modelUsersAclGroupsUsers extends joosModel
175: {
176: /**
177: * @field int(11) unsigned
178: * @type int
179: */
180: public $id;
181:
182: /**
183: * @field int(11) unsigned
184: * @type int
185: */
186: public $user_id;
187:
188: /**
189: * @field tinyint(5) unsigned
190: * @type int
191: */
192: public $group_id;
193:
194: /*
195: * Constructor
196: */
197:
198: public function __construct()
199: {
200: parent::__construct('#__users_acl_groups_users', 'id');
201: }
202:
203: public function check()
204: {
205: $this->filter();
206:
207: return true;
208: }
209: }
210:
211: /**
212: * Class AclAccess
213: *
214: * @package Components\Acls
215: * @subpackage Models\Site
216: * @author JoostinaTeam
217: * @copyright (C) 2007-2012 Joostina Team
218: * @license MIT License http://www.opensource.org/licenses/mit-license.php
219: * @version 1
220: * @created 2011-12-07 14:23:55
221: * Информация об авторах и лицензиях стороннего кода в составе Joostina CMS: docs/copyrights
222: */
223: class modelUsersAclRolesGroups extends joosModel
224: {
225: /**
226: * @field int(11) unsigned
227: * @type int
228: */
229: public $id;
230: /**
231: * @field int(11) unsigned
232: * @type int
233: */
234: public $group_id;
235: /**
236: * @field int(11) unsigned
237: * @type int
238: */
239: public $task_id;
240:
241: /*
242: * Constructor
243: */
244: public function __construct()
245: {
246: parent::__construct( '#__users_acl_rules_groups', 'id' );
247: }
248:
249: public function check()
250: {
251: $this->filter();
252:
253: return true;
254: }
255: }
256: