- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
- Класс: CEventCalendar
- Вызов: CEventCalendar::GetGroupsSPCalendars
function GetGroupsSPCalendars()
{
if (!class_exists('CSocNetUserToGroup') || !class_exists('CSocNetFeatures'))
return;
$uid = $this->userId;
$bCache = $this->bCache;
if ($bCache)
{
$cache = new CPHPCache;
$cachePath = $this->cachePath.'sp_groups/';
}
$arGroupFilter = array(
"USER_ID" => $uid,
"<=ROLE" => SONET_ROLES_USER,
"GROUP_SITE_ID" => SITE_ID,
"GROUP_ACTIVE" => "Y"
);
$dbGroups = CSocNetUserToGroup::GetList(
array("GROUP_NAME" => "ASC"),
$arGroupFilter,
false,
false,
array("GROUP_ID", "GROUP_NAME")
);
if ($dbGroups)
{
$arIds = array();
$arGroups = array();
while ($g = $dbGroups->GetNext())
{
$arGroups[] = $g;
$arIds[] = $g['GROUP_ID'];
}
if (count($arIds) > 0)
{
$arSectId = $this->GetSectionsForOwners($arIds, 'GROUP');
$arFeaturesActive = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arIds, "calendar");
$arView = CSocNetFeaturesPerms::CanPerformOperation($uid, SONET_ENTITY_GROUP, $arIds, "calendar", 'view');
$arWrite = CSocNetFeaturesPerms::CanPerformOperation($uid, SONET_ENTITY_GROUP, $arIds, "calendar", 'write');
for($i = 0, $l = count($arGroups); $i < $l; $i++)
{
$groupId = $arGroups[$i]['GROUP_ID'];
$groupName = $arGroups[$i]['GROUP_NAME'];
// Check section
if(!array_key_exists($groupId, $arSectId) || intval($arSectId[$groupId]) <= 0)
continue;
$sectionId = $arSectId[$groupId];
// Can't view
if (!$arFeaturesActive[$groupId] || !$arView[$groupId])
continue;
// Can't write
$bReadOnly = !$arWrite[$groupId];
$res = null;
if ($bCache)
{
$cacheId = serialize(array($sectionId, $groupId, $GLOBALS['USER']->GetUserGroupArray(), $this->spGroupsIblId));
if ($cache->InitCache($this->cacheTime, $cacheId, $cachePath))
{
$res = $cache->GetVars();
$arCals = $res['arCals'];
}
}
if (!$bCache || empty($res['arCals']))
{
$arCals = array();
// Get calendars
$arCals_ = $this->GetCalendars(array(
'bOwner' => true,
'ownerType' => 'GROUP',
'ownerId' => $groupId,
'iblockId' => $this->spGroupsIblId,
'sectionId' => $sectionId,
'bSuperposed' => true
));
// Save SP section calendars
$arCals = Array(
'ID' => $this->spGroupsIblId,
'NAME' => $groupName,
'GROUP_TITLE' => GetMessage('EC_SUPERPOSE_GR_GROUP'),
'GROUP' => 'SOCNET_GROUPS',
'READONLY' => $bReadOnly,
'READONLY' => 'Y',
'ITEMS' => $this->ExtendCalArray($arCals_, array('GROUP_TITLE' => GetMessage('EC_SUPERPOSE_GR_GROUP'), "NAME" => $arGroups[$i]['GROUP_NAME']))
);
if ($bCache)
{
$cache->StartDataCache($this->cacheTime, $cacheId, $cachePath);
$cache->EndDataCache(array("arCals" => $arCals));
}
}
$this->arSPCal[] = $arCals;
if ($groupId == $this->ownerId)
$this->_sp_par_name = $groupName;
if (!$this->bSuperpose && count($arCals['ITEMS']) > 0)
$this->bSuperpose = true;
if ($this->ownerType == 'GROUP' && $groupId == $this->ownerId)
$this->allowAdd2SP = true;
}
}
}
}