1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
department.php
См. документацию.
1
<?php
2
namespace
Bitrix\Im\Integration\Intranet
;
3
4
use
Bitrix\Main\Loader
;
5
use
Bitrix\Main\Localization\Loc
;
6
7
class
Department
8
{
9
const
CACHE_TOKEN_TTL
= 2592000;
// 1 month
10
11
public
static
function
checkModules
()
12
{
13
return
14
Loader::includeModule(
'intranet'
)
15
&& Loader::includeModule(
"socialnetwork"
)
16
;
17
}
18
19
public
static
function
getList
(?
array
$ids =
null
)
20
{
21
if
(!self::checkModules())
22
{
23
return
false
;
24
}
25
26
if
(\
Bitrix
\
Im
\
User::getInstance
()->isExtranet())
27
{
28
return
[];
29
}
30
31
if
(!empty($ids))
32
{
33
$departments =
\Bitrix\Im\V2\Integration\HumanResources\Department\Department::getInstance
()->getListByIds($ids);
34
}
35
else
36
{
37
$departments =
\Bitrix\Im\V2\Integration\HumanResources\Department\Department::getInstance
()->getList();
38
}
39
40
$result
= [];
41
foreach
($departments as $department)
42
{
43
$result
[$department->id] = [
44
'ID'
=> $department->id,
45
'NAME'
=> $department->name,
46
'FULL_NAME'
=> $department->name,
47
'MANAGER_USER_ID'
=> $department->headUserID,
48
];
49
50
if
(
51
$department->depthLevel > 0
52
&& isset(
$result
[$department->parent][
'FULL_NAME'
])
53
)
54
{
55
$result
[$department->id][
'FULL_NAME'
] = $department->name .
' / '
.
$result
[$department->parent][
'FULL_NAME'
];
56
}
57
}
58
59
return
$result
;
60
}
61
62
public
static
function
getGroup
(
$params
)
63
{
64
if
(!self::checkModules())
65
return
false
;
66
67
$params
= is_array(
$params
)?
$params
: Array();
68
69
if
(!isset(
$params
[
'CURRENT_USER'
]) && is_object(
$GLOBALS
[
'USER'
]))
70
{
71
$params
[
'CURRENT_USER'
] =
$GLOBALS
[
'USER'
]->GetID();
72
}
73
74
$userId
= intval(
$params
[
'CURRENT_USER'
]);
75
if
(
$userId
<= 0)
76
{
77
return
false
;
78
}
79
80
$cacheId =
'im_sonet_extranet_v3_'
.$userId;
81
$cachePath =
'/bx/imc/sonet/extranet'
.\Bitrix\Im\Common::getCacheUserPostfix(
$userId
);
82
83
$cache =
\Bitrix\Main\Application::getInstance
()->getCache();
84
$taggedCache =
\Bitrix\Main\Application::getInstance
()->getTaggedCache();
85
86
if
($cache->initCache(self::CACHE_TOKEN_TTL, $cacheId, $cachePath))
87
{
88
return
$cache->getVars();
89
}
90
91
$taggedCache->startTagCache($cachePath);
92
93
$db = \CSocNetUserToGroup::GetList(
94
array
(),
95
array
(
96
"USER_ID"
=>
$userId
,
97
"<=ROLE"
=>
SONET_ROLES_USER
,
98
"GROUP_SITE_ID"
=> \CExtranet::GetExtranetSiteID(),
99
"GROUP_ACTIVE"
=>
"Y"
,
100
"GROUP_CLOSED"
=>
"N"
101
),
102
false
,
103
false
,
104
array
(
"ID"
,
"GROUP_ID"
,
"GROUP_NAME"
)
105
);
106
107
$groups
= Array();
108
$groupIds = Array();
109
while
($row = $db->GetNext(
true
,
false
))
110
{
111
$groupIds[] = $row[
"GROUP_ID"
];
112
$groups
[
'SG'
.$row[
'GROUP_ID'
]] =
array
(
113
'ID'
=>
'SG'
.$row[
'GROUP_ID'
],
114
'NAME'
=> Loc::getMessage(
'IM_INT_SN_GROUP_EXTRANET'
, Array(
'#GROUP_NAME#'
=> $row[
'GROUP_NAME'
])),
115
'USERS'
=> Array()
116
);
117
118
$taggedCache->registerTag(
'sonet_group_'
.$row[
'GROUP_ID'
]);
119
$taggedCache->registerTag(
'sonet_user2group_G'
.$row[
'GROUP_ID'
]);
120
}
121
122
if
(
count
(
$groups
) <= 0)
123
{
124
return
false
;
125
}
126
127
$taggedCache->endTagCache();
128
129
$db = \CSocNetUserToGroup::GetList(
130
array
(),
131
array
(
132
"GROUP_ID"
=> $groupIds,
133
"<=ROLE"
=>
SONET_ROLES_USER
,
134
"USER_ACTIVE"
=>
"Y"
,
135
"USER_CONFIRM_CODE"
=>
false
136
),
137
false
,
138
false
,
139
array
(
"ID"
,
"USER_ID"
,
"GROUP_ID"
)
140
);
141
while
(
$ar
= $db->GetNext(
true
,
false
))
142
{
143
if
(
$ar
[
"USER_ID"
] ==
$userId
)
144
continue
;
145
146
$groups
[
'SG'
.$row[
'GROUP_ID'
]][
'USERS'
][] =
$ar
[
"USER_ID"
];
147
}
148
149
$cache->startDataCache();
150
$cache->endDataCache(
$groups
);
151
152
return
$groups
;
153
}
154
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Im\Integration\Intranet\Department
Определения
department.php:8
Bitrix\Im\Integration\Intranet\Department\checkModules
static checkModules()
Определения
department.php:11
Bitrix\Im\Integration\Intranet\Department\getList
static getList(?array $ids=null)
Определения
department.php:19
Bitrix\Im\Integration\Intranet\Department\CACHE_TOKEN_TTL
const CACHE_TOKEN_TTL
Определения
department.php:9
Bitrix\Im\Integration\Intranet\Department\getGroup
static getGroup($params)
Определения
department.php:62
Bitrix\Im\User\getInstance
static getInstance($userId=null)
Определения
user.php:45
Bitrix\Im\V2\Integration\HumanResources\Department\Department\getInstance
static getInstance()
Определения
Department.php:36
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Localization\Loc
Определения
loc.php:12
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$groups
$groups
Определения
options.php:30
Bitrix\Im\Integration\Intranet
Определения
department.php:2
Bitrix\Im
Bitrix\Main\$GLOBALS
$GLOBALS['____1690880296']
Определения
license.php:1
Bitrix
$ar
$ar
Определения
options.php:199
count
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения
waybill.php:936
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
SONET_ROLES_USER
const SONET_ROLES_USER
Определения
include.php:31
bitrix
modules
im
lib
integration
intranet
department.php
Создано системой
1.14.0