本文整理汇总了PHP中CIntranetUtils::GetAbsenceData方法的典型用法代码示例。如果您正苦于以下问题:PHP CIntranetUtils::GetAbsenceData方法的具体用法?PHP CIntranetUtils::GetAbsenceData怎么用?PHP CIntranetUtils::GetAbsenceData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIntranetUtils
的用法示例。
在下文中一共展示了CIntranetUtils::GetAbsenceData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IsUserAbsent
function IsUserAbsent($USER_ID, $CALENDAR_IBLOCK_ID = null)
{
global $CACHE_ABSENCE, $CACHE_MANAGER;
if (null === $CACHE_ABSENCE) {
$cache_ttl = (24 - date('G')) * 3600;
$cache_uid = 'intranet_absence';
$cache_dir = '/' . SITE_ID . '/intranet/absence';
$obCache = new CPHPCache();
if ($obCache->InitCache($cache_ttl, 'intranet_absence', $cache_dir)) {
$arAbsence = $obCache->GetVars();
} else {
if (null == $CALENDAR_IBLOCK_ID) {
$CALENDAR_IBLOCK_ID = COption::GetOptionInt('intranet', 'iblock_calendar', null);
}
$dt = ConvertTimeStamp(false, 'SHORT');
$arAbsence = CIntranetUtils::GetAbsenceData(array('CALENDAR_IBLOCK_ID' => $CALENDAR_IBLOCK_ID, 'DATE_START' => $dt, 'DATE_FINISH' => $dt, 'PER_USER' => true, 'SELECT' => array('DATE_ACTIVE_FROM', 'DATE_ACTIVE_TO')));
$obCache->StartDataCache();
$CACHE_MANAGER->StartTagCache($cache_dir);
$CACHE_MANAGER->RegisterTag('iblock_id_' . COption::GetOptionInt('intranet', 'iblock_absence'));
if ($CALENDAR_IBLOCK_ID > 0) {
$CACHE_MANAGER->RegisterTag('iblock_id_' . $CALENDAR_IBLOCK_ID);
}
$CACHE_MANAGER->EndTagCache();
$obCache->EndDataCache($arAbsence);
}
$CACHE_ABSENCE = is_array($arAbsence) ? $arAbsence : array();
} else {
$arAbsence = $CACHE_ABSENCE;
}
if (is_array($arAbsence[$USER_ID])) {
$ts = time();
foreach ($arAbsence[$USER_ID] as $arEntry) {
$ts_start = MakeTimeStamp($arEntry['DATE_FROM'], FORMAT_DATETIME);
if ($ts_start < $ts) {
$ts_finish = MakeTimeStamp($arEntry['DATE_TO'], FORMAT_DATETIME);
if ($ts_finish > $ts) {
return true;
}
if (($ts_start + date('Z')) % 86400 == 0 && $ts_start == $ts_finish) {
return true;
}
}
}
}
return false;
}
示例2: GetAccessibilityForUsers
public static function GetAccessibilityForUsers($Params)
{
$res = CCalendarEvent::GetAccessibilityForUsers(array('users' => $Params['users'], 'from' => $Params['from'], 'to' => $Params['to'], 'curEventId' => $Params['curEventId']));
// Fetch absence from intranet
if ($Params['getFromHR'] && CCalendar::IsIntranetEnabled()) {
$resHR = CIntranetUtils::GetAbsenceData(array('DATE_START' => $Params['from'], 'DATE_FINISH' => $Params['to'], 'USERS' => $Params['users'], 'PER_USER' => true, 'SELECT' => array('ID', 'DATE_ACTIVE_FROM', 'DATE_ACTIVE_TO')), BX_INTRANET_ABSENCE_HR);
foreach ($resHR as $userId => $forUser) {
if (!isset($res[$userId]) || !is_array($res[$userId])) {
$res[$userId] = array();
}
foreach ($forUser as $event) {
$res[$userId][] = array('FROM_HR' => true, 'ID' => $event['ID'], 'DT_FROM' => $event['DATE_ACTIVE_FROM'], 'DT_TO' => $event['DATE_ACTIVE_TO'], 'ACCESSIBILITY' => 'absent', 'IMPORTANCE' => 'normal', "FROM" => CCalendar::Timestamp($event['DATE_ACTIVE_FROM']), "TO" => CCalendar::Timestamp($event['DATE_ACTIVE_TO']));
}
}
}
return $res;
}
示例3: date
$date_start = $date_finish = date($format);
break;
case 'tomorrow':
$date_start = $date_finish = date($format, strtotime('+1 day'));
break;
case 'after_tomorrow':
$date_start = $date_finish = date($format, strtotime('+2 day'));
break;
case 'now':
default:
$date_start = $date_finish = date($format);
break;
}
$arFilter = array('CALENDAR_IBLOCK_ID' => $arParams['CALENDAR_IBLOCK_ID'], 'ABSENCE_IBLOCK_ID' => $arParams['IBLOCK_ID'], 'DATE_START' => $date_start, 'DATE_FINISH' => $date_finish, 'USERS' => $USERS, 'PER_USER' => false);
//echo '<pre>'; print_r($arFilter); echo '</pre>';
$arResult['ENTRIES'] = CIntranetUtils::GetAbsenceData($arFilter, BX_INTRANET_ABSENCE_ALL);
$arUserIDs = array();
foreach ($arResult['ENTRIES'] as $key => $arEntry) {
$arUserIDs[] = $arEntry['USER_ID'];
$arResult['ENTRIES'][$key]['DATE_ACTIVE_FROM_TS'] = MakeTimeStamp($arEntry['DATE_FROM'], CSite::GetDateFormat('FULL'));
$arResult['ENTRIES'][$key]['DATE_ACTIVE_TO_TS'] = MakeTimeStamp($arEntry['DATE_TO'], CSite::GetDateFormat('FULL'));
$arResult['ENTRIES'][$key]['DATE_FROM'] = FormatDate($arParams['DATE' . (CIntranetUtils::IsDateTime($arResult['ENTRIES'][$key]['DATE_ACTIVE_FROM_TS']) ? '_TIME' : '') . '_FORMAT'], $arResult['ENTRIES'][$key]['DATE_ACTIVE_FROM_TS']);
$arResult['ENTRIES'][$key]['DATE_TO'] = FormatDate($arParams['DATE' . (CIntranetUtils::IsDateTime($arResult['ENTRIES'][$key]['DATE_ACTIVE_TO_TS']) ? '_TIME' : '') . '_FORMAT'], $arResult['ENTRIES'][$key]['DATE_ACTIVE_TO_TS']);
if ($arParams['mode'] == 'now') {
$test1 = $arResult['ENTRIES'][$key]['DATE_ACTIVE_FROM_TS'];
$test2 = $arResult['ENTRIES'][$key]['DATE_ACTIVE_TO_TS'];
if (0 == ($test2 + date('Z')) % 86400) {
$test2 += 86399;
}
if ($test1 > time() || $test2 < time()) {
unset($arResult['ENTRIES'][$key]);
示例4: tasksTaskEditAjaxHandler
function tasksTaskEditAjaxHandler()
{
global $DB;
if (isset($_POST['NAME_TEMPLATE'])) {
$nameTemplate = $_POST['NAME_TEMPLATE'];
} else {
$nameTemplate = CSite::getNameFormat(false);
}
if (!check_bitrix_sessid()) {
die;
}
switch ($_POST['action']) {
case 'tasks_isUserMemberOfGroup':
if (!CModule::IncludeModule('socialnetwork')) {
throw new Exception($_POST['action'] . ': socialnetwork module failed to load.');
}
if (!isset($_POST['groupId']) || !isset($_POST['userId']) || $_POST['groupId'] < 0 || $_POST['userId'] < 0) {
throw new Exception($_POST['action'] . ': invalid userId or groupId');
}
$rc = CSocNetUserToGroup::GetUserRole((int) $_POST['userId'], (int) $_POST['groupId']);
if ($rc === false || $rc == SONET_ROLES_REQUEST) {
echo 'N';
} else {
echo 'Y';
}
break;
case 'getWarnings':
if (isset($_POST['TASK']['RESPONSIBLE_ID'])) {
$responsibleId = (int) $_POST['TASK']['RESPONSIBLE_ID'];
$responsibleName = '#unknown user#';
$rsUser = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => $responsibleId), array('FIELDS' => array('NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN')));
if ($arUser = $rsUser->fetch()) {
$responsibleName = CUser::FormatName($nameTemplate, array("NAME" => $arUser["NAME"], "LAST_NAME" => $arUser["LAST_NAME"], "SECOND_NAME" => $arUser["SECOND_NAME"], "LOGIN" => $arUser["LOGIN"]), true, false);
}
if (isset($_POST['TASK']['GROUP_ID']) && $_POST['TASK']['GROUP_ID']) {
if (CModule::IncludeModule('socialnetwork')) {
$rc = CSocNetUserToGroup::GetUserRole($responsibleId, (int) $_POST['TASK']['GROUP_ID']);
if ($rc === false || $rc == SONET_ROLES_REQUEST) {
$arGroup = CSocNetGroup::GetByID($_POST['TASK']['GROUP_ID']);
echo '<div>' . htmlspecialcharsbx(str_replace(array('#FORMATTED_USER_NAME#', '#GROUP_NAME#'), array($responsibleName, $arGroup["NAME"]), GetMessage('TASKS_WARNING_RESPONSIBLE_NOT_IN_TASK_GROUP'))) . "</div>\n";
}
}
}
if (CModule::IncludeModule('intranet')) {
$dt = ConvertTimeStamp(false, 'SHORT');
$arAbsenceData = CIntranetUtils::GetAbsenceData(array('USERS' => array($responsibleId), 'DATE_START' => $dt, 'DATE_FINISH' => $dt, 'PER_USER' => false), $MODE = BX_INTRANET_ABSENCE_ALL);
$curTs = MakeTimeStamp(ConvertTimeStamp(false, 'FULL'));
if (isset($arAbsenceData[0])) {
if (array_key_exists('DATE_ACTIVE_FROM', $arAbsenceData[0]) && array_key_exists('DATE_ACTIVE_TO', $arAbsenceData[0])) {
$fromTs = MakeTimeStamp($arAbsenceData[0]['DATE_ACTIVE_FROM']);
$toTs = MakeTimeStamp($arAbsenceData[0]['DATE_ACTIVE_TO']);
} else {
$fromTs = MakeTimeStamp($arAbsenceData[0]['DATE_FROM']);
$toTs = MakeTimeStamp($arAbsenceData[0]['DATE_TO']);
}
if ($toTs > $curTs) {
$from = FormatDate($DB->DateFormatToPhp(CSite::GetDateFormat(CIntranetUtils::IsDateTime($fromTs) ? 'FULL' : 'SHORT')), $fromTs);
$to = FormatDate($DB->DateFormatToPhp(CSite::GetDateFormat(CIntranetUtils::IsDateTime($toTs) ? 'FULL' : 'SHORT')), $toTs);
echo '<div>' . htmlspecialcharsbx(str_replace(array('#FORMATTED_USER_NAME#', '#DATE_FROM#', '#DATE_TO#', '#ABSCENCE_REASON#'), array($responsibleName, $from, $to, $arAbsenceData[0]['NAME']), GetMessage('TASKS_WARNING_RESPONSIBLE_IS_ABSENCE'))) . '</div>';
}
}
}
}
break;
default:
throw new Exception('Requested action is unknown!');
break;
}
}
示例5: foreach
$MODE = 0;
if (count($arParams['TYPES']) <= 0) {
$MODE = BX_INTRANET_ABSENCE_ALL;
} else {
foreach ($arParams['TYPES'] as $type) {
if ($type == 'PERSONAL') {
$MODE |= BX_INTRANET_ABSENCE_PERSONAL;
} else {
$MODE |= BX_INTRANET_ABSENCE_HR;
}
if ($MODE == BX_INTRANET_ABSENCE_ALL) {
break;
}
}
}
$arIBlockElements = CIntranetUtils::GetAbsenceData(array('CALENDAR_IBLOCK_ID' => $arParams['CALENDAR_IBLOCK_ID'], 'ABSENCE_IBLOCK_ID' => $arParams['IBLOCK_ID'], 'DATE_START' => ConvertTimeStamp($arParams['TS_START'], 'FULL'), 'DATE_FINISH' => ConvertTimeStamp($arParams['TS_FINISH'], 'FULL'), 'USERS' => false, 'PER_USER' => true), $MODE);
$arUserIDs = array_keys($arIBlockElements);
$bLoadUsers = count($arUserIDs) > 0 || $arParams['USERS_ALL'] == 'Y';
if ($bLoadUsers) {
$arFilter = array('ACTIVE' => 'Y');
if ($arParams['DEPARTMENT'] > 0) {
$arFilter['UF_DEPARTMENT'] = $arParams['FILTER_SECTION_CURONLY'] == 'N' ? CIntranetUtils::GetIBlockSectionChildren($arParams['DEPARTMENT']) : array($arParams['DEPARTMENT']);
} elseif (!CModule::IncludeModule('extranet') || !CExtranet::IsExtranetSite($arParams['SITE_ID'])) {
$arFilter["!UF_DEPARTMENT"] = false;
}
if ($arParams['USERS_ALL'] == 'N') {
$arFilter['ID'] = implode('|', array_keys($arIBlockElements));
}
$bExtranetInstalled = CModule::IncludeModule('extranet');
$bExtranetSite = false || $bExtranetInstalled && CExtranet::IsExtranetSite($arParams['SITE_ID']);
if ($bExtranetInstalled && !$bExtranetSite && !CExtranet::IsIntranetUser($arParams['SITE_ID'])) {
示例6: intval
<?php
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
}
if (!CModule::IncludeModule('intranet')) {
return false;
}
$arParams['ID'] = intval($arParams['ID']);
if ($arParams['ID'] <= 0) {
$arParams['ID'] = $USER->GetID();
}
if ($arParams['ID'] <= 0) {
return false;
}
$arParams['CALENDAR_IBLOCK_ID'] = intval($arParams['CALENDAR_IBLOCK_ID']);
if ($arParams['CALENDAR_IBLOCK_ID'] <= 0) {
$arParams['CALENDAR_IBLOCK_ID'] = COption::GetOptionInt('intranet', 'iblock_calendar');
}
$arParams['CACHE_TIME'] = 3600;
if ($this->StartResultCache(false, $arParams['ID'])) {
$arResult['ENTRIES'] = CIntranetUtils::GetAbsenceData(array('CALENDAR_IBLOCK_ID' => $arParams['CALENDAR_IBLOCK_ID'], 'USERS' => array($arParams['ID']), 'DATE_START' => date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT"))), 'DATE_FINISH' => false, 'PER_USER' => false));
foreach ($arResult['ENTRIES'] as $key => $arRes) {
$arResult['ENTRIES'][$key]['TITLE'] = $arRes['PROPERTY_STATE_VALUE'] ? $arRes['PROPERTY_STATE_VALUE'] : ($arRes['DETAIL_TEXT'] ? $arRes['DETAIL_TEXT'] : ($arRes['PREVIEW_TEXT'] ? $arRes['PREVIEW_TEXT'] : $arRes['NAME']));
$arResult['ENTRIES'][$key]['DATE_ACTIVE_FROM'] = $arRes['DATE_FROM'];
$arResult['ENTRIES'][$key]['DATE_ACTIVE_TO'] = $arRes['DATE_TO'];
}
$this->IncludeComponentTemplate();
}