1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14:
15: 16: 17:
18: class cLinkcheckerCategoryHelper
19: {
20: 21: 22: 23: 24: 25: 26:
27: public static function checkPermission($widcat, $db = null)
28: {
29: global $cfg, $sess, $auth, $group_id, $_arrCatIDs_cCP;
30:
31: if (cString::findFirstPos($auth->auth['perm'], 'admin') !== false) {
32: return true;
33: }
34:
35: if (is_null($db) || !is_object($db)) {
36: $db = cRegistry::getDb();
37: }
38:
39: $group_ids = self::_getGroupIDs($db);
40: $group_ids[] = $db->escape($auth->auth['uid']);
41:
42: if (!is_array($_arrCatIDs_cCP)) {
43: $sql_inc = " user_id='" . implode("' OR user_id='", $group_ids) . "' ";
44:
45: $sql = "SELECT idcat
46: FROM " . $cfg['tab']['rights'] . "
47: WHERE idarea = 6
48: AND idaction = 359
49: AND ($sql_inc)";
50:
51: $db->query($sql);
52:
53: $_arrCatIDs_cCP = [];
54: while ($db->nextRecord()) {
55: $_arrCatIDs_cCP[$db->f('idcat')] = '';
56: }
57: }
58:
59: return array_key_exists($widcat, $_arrCatIDs_cCP);
60: }
61:
62: 63: 64: 65: 66: 67:
68: private static function _getGroupIDs(cDb &$db)
69: {
70: global $cfg, $sess, $auth, $group_id, $_arrGroupIDs_gGI;
71:
72: if (is_array($_arrGroupIDs_gGI)) {
73: return $_arrGroupIDs_gGI;
74: }
75:
76: $sql = "SELECT group_id
77: FROM " . $cfg["tab"]["groupmembers"] . "
78: WHERE user_id='" . $db->escape($auth->auth["uid"]) . "'";
79: $db->query($sql);
80:
81: $_arrGroupIDs_gGI = [];
82: while ($db->nextRecord()) {
83: $_arrGroupIDs_gGI[] = $db->f('group_id');
84: }
85:
86: return $_arrGroupIDs_gGI;
87: }
88: }
89: