- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
- Класс: CEventCalendar
- Вызов: CEventCalendar::GetUserSPCalendars
function GetUserSPCalendars($uid, $bCurUser = false)
{
$bCache = $this->bCache;
if ($bCache)
{
$cache = new CPHPCache;
$cachePath = $this->cachePath.'sp_user/';
$cacheId = 'ec_sp_'.$uid.'ug'.implode('_', $GLOBALS['USER']->GetUserGroupArray());
if ($cache->InitCache($this->cacheTime, $cacheId, $cachePath))
{
$res = $cache->GetVars();
$arCals = $res['arCals'];
}
}
if (!$bCache || empty($arCals))
{
$arCals = array();
$sectionId = intval($this->GetSectionIDByOwnerId($uid, 'USER', $this->userIblockId));
// Get calendars
if ($sectionId > 0)
{
$arCals_ = $this->GetCalendars(array(
'bOwner' => true,
'ownerType' => 'USER',
'ownerId' => $uid,
'iblockId' => $this->userIblockId,
'sectionId' => $sectionId,
'bSuperposed' => true
));
}
else
{
$arCals_ = array();
}
$grTitle = GetMessage('EC_SUPERPOSE_GR_USER');
if ($bCurUser)
{
$name = GetMessage('EC_SUPERPOSE_GR_CUR_USER');
}
else
{
$r = CUser::GetByID($uid);
if (!$arUser = $r->Fetch())
return;
$name = trim($arUser['NAME'].' '.$arUser['LAST_NAME']);
if ($name == '')
$name = trim($arUser['LOGIN']);
$name .= ' <'.$arUser['EMAIL'].'> ['.$uid.']';
}
if (count($arCals_) > 0)
$arCals_ = $this->ExtendCalArray($arCals_, array('GROUP_TITLE' => $grTitle, "NAME" => $name));
$arCals[] = Array(
'ID' => $this->userIblockId,
'NAME' => $name,
'GROUP_TITLE' => $grTitle,
'GROUP' => 'SOCNET_USERS',
'READONLY' => true,
'ITEMS' => $arCals_,
'bDeletable' => !$bCurUser,
'USER_ID' => $uid
);
if ($bCache)
{
$cache->StartDataCache($this->cacheTime, $cacheId, $cachePath);
$cache->EndDataCache(array('arCals' => $arCals));
}
}
for($i = 0, $l = count($arCals); $i < $l; $i++)
{
if ($this->addCurUserCalDispByDef && $arCals[$i]['USER_ID'] == $this->userId)
for($j = 0; $j < count($arCals[$i]['ITEMS']); $j++)
$this->arSPCalsDisplayedDef[] = $arCals[$i]['ITEMS'][$j]['ID'];
$this->arSPCal[] = $arCals[$i];
}
if (!$this->bSuperpose)
$this->bSuperpose = true;
}