- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/bizproc/document/task.php
- Класс: BitrixTasksIntegrationBizprocDocumentTask
- Вызов: Task::canUserOperateDocumentType
static function canUserOperateDocumentType($operation, $userId, $documentType, $arParameters = array())
{
$userId = (int) $userId;
$user = new CBPWorkflowTemplateUser($userId);
if ($user->isAdmin())
{
return true; //Admin is the Lord of the Automation
}
if (BitrixTasksUtilUser::isExternalUser($userId))
{
return false;
}
// if ($operation === CBPCanUserOperateOperation::CreateAutomation)
{
if (static::isProjectTask($documentType))
{
$projectId = static::resolveProjectId($documentType);
if ($projectId > 0 && MainLoader::includeModule('socialnetwork'))
{
$activeFeatures = CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_GROUP, $projectId);
if (!is_array($activeFeatures) || !array_key_exists('tasks', $activeFeatures))
{
return false;
}
return (CSocNetUserToGroup::GetUserRole($userId, $projectId) === SONET_ROLES_OWNER);
}
}
elseif (static::isScrumProjectTask($documentType))
{
$projectId = static::resolveScrumProjectId($documentType);
if ($projectId > 0 && MainLoader::includeModule('socialnetwork'))
{
$activeFeatures = CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_GROUP, $projectId);
if (!is_array($activeFeatures) || !array_key_exists('tasks', $activeFeatures))
{
return false;
}
return (
CSocNetUserToGroup::GetUserRole($userId, $projectId) === SONET_ROLES_OWNER
|| CSocNetUserToGroup::GetUserRole($userId, $projectId) === SONET_ROLES_MODERATOR
);
}
}
elseif (static::isPlanTask($documentType))
{
$ownerId = static::resolvePlanId($documentType);
return ($ownerId === $userId);
}
elseif (static::isPersonalTask($documentType))
{
$ownerId = static::resolvePersonId($documentType);
return ($ownerId === $userId);
}
}
return false;
}