- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/task.php
- Класс: CTasks
- Вызов: CTasks::GetAllowedGroups
static function GetAllowedGroups($arParams = [])
{
global $DB;
static $ALLOWED_GROUPS = [];
$userId = null;
if (is_array($arParams) && isset($arParams['USER_ID']))
{
$userId = $arParams['USER_ID'];
}
else
{
$userId = User::getId();
}
if (!($userId >= 1))
{
$userId = 0;
}
if (!isset($ALLOWED_GROUPS[$userId]) && CModule::IncludeModule("socialnetwork"))
{
// bottleneck
$strSql = "SELECT DISTINCT(T.GROUP_ID) FROM b_tasks T WHERE T.GROUP_ID IS NOT NULL";
$rsGroups = $DB->Query($strSql, false, "File: " . __FILE__ . "
Line: " . __LINE__);
$ALLOWED_GROUPS[$userId] = $arGroupsWithTasks = [];
while ($arGroup = $rsGroups->Fetch())
{
$arGroupsWithTasks[] = $arGroup["GROUP_ID"];
}
if (is_array($arGroupsWithTasks) && sizeof($arGroupsWithTasks))
{
if ($userId === 0)
{
$featurePerms = CSocNetFeaturesPerms::CurrentUserCanPerformOperation(
SONET_ENTITY_GROUP,
$arGroupsWithTasks,
"tasks",
"view_all"
);
}
else
{
$featurePerms = CSocNetFeaturesPerms::CanPerformOperation(
$userId,
SONET_ENTITY_GROUP,
$arGroupsWithTasks,
"tasks",
"view_all"
);
}
if (is_array($featurePerms))
{
$ALLOWED_GROUPS[$userId] = array_keys(array_filter($featurePerms));
}
}
}
return $ALLOWED_GROUPS[$userId];
}