Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userfieldaccesscontroller.php
1<?php
2
4
10
13
15{
16 public static function getAccessibleFields($userId, string $action, $itemId = null, $params = null): array
17 {
18 $userId = (int) $userId;
19 $controller = new static($userId);
20 return $controller->checkByItemsId($action, $itemId, $params);
21 }
22
23 public function checkByItemsId(string $action, iterable $itemId = null, $params = null): array
24 {
25 $items = $this->loadItems($itemId);
26 return $this->massCheck($action, $items, $params);
27 }
28
29 protected function loadItems(iterable $itemsId = null): array
30 {
31 $userFieldModels = [];
32 foreach ($itemsId as $itemId){
33 $userFieldModels[] = UserFieldModel::createFromId($itemId);
34 }
35
36 return $userFieldModels;
37 }
38
39 public function massCheck(string $action, array $items = null, $params = null): array
40 {
41 $ruleName = $this->getRuleName($action);
42
43 if (!$ruleName || !class_exists($ruleName))
44 {
45 throw new UnknownActionException($action);
46 }
47
48 return (new $ruleName($this))->executeMass($items, $params);
49 }
50
51 protected function loadItem(int $itemId = null): AccessibleItem
52 {
53 if ($itemId)
54 {
55 return UserFieldModel::createFromId($itemId);
56 }
57
58 return UserFieldModel::createNew();
59 }
60
61 protected function loadUser(int $userId): AccessibleUser
62 {
63 return UserModel::createFromId($userId);
64 }
65}
checkByItemsId(string $action, iterable $itemId=null, $params=null)
static getAccessibleFields($userId, string $action, $itemId=null, $params=null)
massCheck(string $action, array $items=null, $params=null)