Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
accessauthprovider.php
1<?php
2
4
7
8class AccessAuthProvider extends \CAuthProvider
9{
10 protected const PROVIDER_ID = 'access';
11
12 public static function GetProviders()
13 {
14 return [
15 [
16 "ID" => self::PROVIDER_ID,
17 "CLASS" => self::class,
18 ]
19 ];
20 }
21
22 public function __construct()
23 {
24 $this->id = self::PROVIDER_ID;
25 }
26
27 public function UpdateCodes($userId)
28 {
29 global $DB;
30
31 $iblockId = \COption::GetOptionInt('intranet', 'iblock_structure');
32 if ($iblockId > 0)
33 {
34 $tableName = "b_uts_iblock_". $iblockId ."_section";
35
36 if (!$DB->TableExists($tableName))
37 {
38 return null;
39 }
40
41 $res = $DB->query("
42 SELECT VALUE_ID
43 FROM ". $tableName ."
44 WHERE UF_HEAD = " . $userId
45 );
46
47 $connection = Application::getConnection();
48 $helper = $connection->getSqlHelper();
49
50 while ($row = $res->fetch())
51 {
52 $id = (int) $row['VALUE_ID'];
53
54 $sql = $helper->getInsertIgnore(
55 'b_user_access',
56 '(USER_ID, PROVIDER_ID, ACCESS_CODE)',
57 'VALUES
58 ('.$userId.',"'.$this->id.'","'.AccessCode::ACCESS_DIRECTOR.'0"),
59 ('.$userId.',"'.$this->id.'","'.AccessCode::ACCESS_DIRECTOR.$id.'")'
60 );
61 $DB->query($sql);
62 }
63 }
64 }
65}
static getConnection($name="")