18 global $CACHE_MANAGER;
22 $cacheTTL = 3600 * 24 * 30;
23 $cacheDir =
'/sonet/user_absence';
25 $cache = new \CPHPCache();
26 if ($cache->initCache($cacheTTL,
'intranet_absence', $cacheDir))
28 $result = $cache->getVars();
32 $cache->startDataCache();
33 $CACHE_MANAGER->startTagCache($cacheDir);
36 ModuleManager::isModuleInstalled(
'intranet')
37 && Loader::includeModule(
'iblock')
38 && ($absenceIblockId = (
int)Option::get(
'intranet',
'iblock_absence'))
41 $CACHE_MANAGER->registerTag(
'iblock_id_'.$absenceIblockId);
43 $res = \CIBlockProperty::getList(
46 'IBLOCK_ID' => $absenceIblockId,
48 'CODE' =>
'ABSENCE_TYPE',
53 ($property = $res->fetch())
54 && ($absenceTypePropertyId = (
int)$property[
'ID'])
57 $vacationXMLIdList = [];
58 $res = \CIBlockPropertyEnum::getList(
61 'PROPERTY_ID' => $absenceTypePropertyId,
62 'XML_ID' => [
'VACATION',
'LEAVEMATERINITY' ],
66 while ($enum = $res->fetch())
68 $vacationXMLIdList[$enum[
'XML_ID']] = (int)$enum[
'ID'];
71 if (isset($vacationXMLIdList[
'LEAVEMATERINITY']))
73 $result = array_merge($result, self::getVacationListOfType([
74 'absenceIblockId' => $absenceIblockId,
75 'absenceTypeId' => $vacationXMLIdList[
'LEAVEMATERINITY'],
79 if (isset($vacationXMLIdList[
'VACATION']))
81 $result = array_merge($result, self::getVacationListOfType([
82 'absenceIblockId' => $absenceIblockId,
83 'absenceTypeId' => $vacationXMLIdList[
'VACATION'],
84 'fromTimestamp' => time() - (3600 * 24 * 120),
90 $CACHE_MANAGER->endTagCache();
91 $cache->endDataCache($result);
150 $userList = (isset($params[
'userList']) && is_array($params[
'userList']) ? $params[
'userList'] : []);
153 if (empty($vacationList))
160 foreach ($vacationList as $vacation)
164 && !in_array($vacation[
'USER_ID'], $userList)
170 $vacationTSStart = makeTimeStamp($vacation[
'DATE_FROM'], FORMAT_DATETIME);
172 if ($vacationTSStart < $ts)
174 $vacationTSFinish = makeTimeStamp($vacation[
'DATE_TO'], FORMAT_DATETIME) + 86400;
176 if ($vacationTSFinish > $ts)
178 $result[$vacation[
'USER_ID']] = $vacation[
'ABSENCE_TYPE'];