Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
permission.php
1<?php
2namespace Bitrix\Rest\APAuth;
3
6
32class PermissionTable extends Main\Entity\DataManager
33{
34 protected static $deniedPermission = array(
35 'rating', 'entity', 'placement', 'landing_cloud', \CRestUtil::GLOBAL_SCOPE
36 );
37
43 public static function getTableName()
44 {
45 return 'b_rest_ap_permission';
46 }
47
53 public static function getMap()
54 {
55 return array(
56 'ID' => array(
57 'data_type' => 'integer',
58 'primary' => true,
59 'autocomplete' => true,
60 ),
61 'PASSWORD_ID' => array(
62 'data_type' => 'integer',
63 'required' => true,
64 ),
65 'PERM' => array(
66 'data_type' => 'string',
67 'required' => true,
68 ),
69 );
70 }
71
72 public static function onPasswordDelete(Main\Entity\Event $event)
73 {
74 $data = $event->getParameter("id");
75 static::deleteByPasswordId($data['ID']);
76 }
77
78 public static function deleteByPasswordId($passwordId)
79 {
80 $dbRes = static::getList(
81 array(
82 'filter' => array
83 (
84 '=PASSWORD_ID' => $passwordId,
85 ),
86 'select' => array('ID')
87 )
88 );
89 while($perm = $dbRes->fetch())
90 {
91 static::delete($perm['ID']);
92 }
93 }
94
95 public static function cleanPermissionList(array $permissionList)
96 {
97 foreach($permissionList as $key => $perm)
98 {
99 if(in_array($perm, static::$deniedPermission))
100 {
101 unset($permissionList[$key]);
102 }
103 }
104
105 return array_values($permissionList);
106 }
107
108 public static function onAfterAdd(Main\Entity\Event $event)
109 {
110 EventController::onAfterAddApPermission($event);
111 }
112}
static onPasswordDelete(Main\Entity\Event $event)
static cleanPermissionList(array $permissionList)
static deleteByPasswordId($passwordId)
static onAfterAdd(Main\Entity\Event $event)