Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
role.php
1<?php
3
4use \Bitrix\Main\Localization\Loc;
5use \Bitrix\Landing\Manager;
6use \Bitrix\Landing\Rights;
7use \Bitrix\Landing\Role as RoleCore;
8use \Bitrix\Landing\PublicActionResult;
9
10Loc::loadMessages(__FILE__);
11
12class Role
13{
18 public static function init()
19 {
20 static $internal = true;
21
22 $result = new PublicActionResult();
23 $error = new \Bitrix\Landing\Error;
24
25 if (!Rights::isAdmin())
26 {
27 $error->addError(
28 'IS_NOT_ADMIN',
29 Loc::getMessage('LANDING_IS_NOT_ADMIN_ERROR')
30 );
31 $result->setError($error);
32 }
34 {
35 $error->addError(
36 'FEATURE_NOT_AVAIL',
37 \Bitrix\Landing\Restriction\Manager::getSystemErrorMessage(
38 'limit_sites_access_permissions'
39 )
40 );
41 $result->setError($error);
42 }
43
44 return $result;
45 }
46
51 public static function getList()
52 {
53 $result = new PublicActionResult();
54
55 $roles = [];
56 foreach (RoleCore::fetchAll() as $item)
57 {
58 $roles[] = [
59 'ID' => $item['ID'],
60 'TITLE' => $item['TITLE'],
61 'XML_ID' => $item['XML_ID']
62 ];
63 }
64
65 $result->setResult($roles);
66
67 return $result;
68 }
69
75 public static function getRights($id)
76 {
77 $id = (int)$id;
78 $result = new PublicActionResult();
79 $result->setResult(
81 );
82 return $result;
83 }
84
92 public static function setRights($id, array $rights, $additional = null)
93 {
94 static $mixedParams = ['additional'];
95
96 $id = (int)$id;
97 $result = new PublicActionResult();
98 $result->setResult(true);
100 $id,
101 $rights,
102 ($additional !== null) ? $additional : null
103 );
104
105 return $result;
106 }
107
114 public static function setAccessCodes($id, array $codes = array())
115 {
116 $result = new PublicActionResult();
117 $result->setResult(true);
118 RoleCore::setAccessCodes((int)$id, $codes);
119 return $result;
120 }
121
126 public static function isEnabled()
127 {
128 $result = new PublicActionResult();
129 $result->setResult(
131 );
132 return $result;
133 }
134
140 public static function enable($mode)
141 {
142 $result = new PublicActionResult();
143 $extended = Rights::isExtendedMode();
144 if (
145 $mode && $extended ||
146 !$mode && !$extended
147 )
148 {
150 }
151 $result->setResult(true);
152 return $result;
153 }
154}
const FEATURE_PERMISSIONS_AVAILABLE
Definition manager.php:42
static checkFeature(string $feature, array $params=array())
Definition manager.php:831
static setRights($id, array $rights, $additional=null)
Definition role.php:92
static setAccessCodes($id, array $codes=array())
Definition role.php:114
static isExtendedMode()
Definition rights.php:781
static setRights($roleId, $rights=[], $additionalRights=null)
Definition role.php:406
static setAccessCodes($roleId, array $codes=array())
Definition role.php:336
static fetchAll()
Definition role.php:114
static getRights($roleId)
Definition role.php:362
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29