Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
department.php
1<?php
9namespace Bitrix\Im\Bot;
10
12
13Loc::loadMessages(__FILE__);
14
16{
17 const XML_ID = "im_bot";
18
19 public static function getId($skipCreate = false)
20 {
21 if (
22 !\Bitrix\Main\Loader::includeModule('intranet')
23 || !\Bitrix\Main\Loader::includeModule('iblock')
24 )
25 {
26 return 0;
27 }
28
29 $departments = \CIntranetUtils::getDeparmentsTree(0, false);
30 if (!is_array($departments) || !isset($departments[0][0]))
31 {
32 return 0;
33 }
34
35 $departmentRootId = \Bitrix\Main\Config\Option::get('intranet', 'iblock_structure', 0);
36 if($departmentRootId <= 0)
37 {
38 return 0;
39 }
40
41 $section = \CIBlockSection::GetList(Array(), Array('ACTIVE' => 'Y', 'IBLOCK_ID' => $departmentRootId, 'XML_ID' => self::XML_ID));
42 if ($row = $section->Fetch())
43 {
44 $sectionId = (int)$row['ID'];
45 }
46 else if ($skipCreate)
47 {
48 return 0;
49 }
50 else
51 {
52 $section = new \CIBlockSection();
53 $sectionId = $section->Add(array(
54 'IBLOCK_ID' => $departmentRootId,
55 'NAME' => Loc::getMessage('BOT_DEPARTMENT_NAME'),
56 'SORT' => 20000,
57 'IBLOCK_SECTION_ID' => intval($departments[0][0]),
58 'XML_ID' => self::XML_ID
59 ));
60 }
61 if (!$sectionId)
62 {
63 $sectionId = (int)$departments[0][0];
64 }
65
66 return $sectionId;
67 }
68}
static getId($skipCreate=false)
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29