Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
department.php
1
<?php
9
namespace
Bitrix\Im\Bot
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
13
Loc::loadMessages
(__FILE__);
14
15
class
Department
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
}
Bitrix\Im\Bot\Department
Definition
department.php:16
Bitrix\Im\Bot\Department\getId
static getId($skipCreate=false)
Definition
department.php:19
Bitrix\Im\Bot\Department\XML_ID
const XML_ID
Definition
department.php:17
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Im\Bot
Definition
contextmenu.php:9
Bitrix
modules
im
lib
bot
department.php
Создано системой
1.10.0