private static function checkAccessThrowException(\CTaskItem $task) { if (!$task->isActionAllowed(\CTaskItem::ACTION_CHANGE_DEADLINE)) { throw new \Bitrix\Tasks\ActionNotAllowedException(false, array('AUX' => array('MESSAGE' => array('TASK_ID' => $task->getId(), 'USER_ID' => $this->userId)))); } }
/** * This is experimental code, don't rely on it. * It can be removed or changed in future without any notifications. * * Use CTaskItem::getAllowedTaskActions() and CTaskItem::getAllowedTaskActionsAsStrings() instead. * * @deprecated */ public static function GetAllowedActions($arTask, $userId = null) { $arAllowedActions = array(); if ($userId === null) { global $USER; $curUserId = (int) $USER->GetID(); } else { $curUserId = (int) $userId; } // we cannot use cached object here (CTaskItem::getInstanceFromPool($arTask['ID'], $curUserId);) // because of backward compatibility (CTasks::Update() don't mark cache as dirty in pooled CTaskItem objects) $oTask = new CTaskItem($arTask['ID'], $curUserId); if ($oTask->isUserRole(CTaskItem::ROLE_RESPONSIBLE)) { if ($arTask['REAL_STATUS'] == CTasks::STATE_NEW) { $arAllowedActions[] = array('public_name' => 'accept', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_ACCEPT); $arAllowedActions[] = array('public_name' => 'decline', 'system_name' => 'decline', 'id' => CTaskItem::ACTION_DECLINE); } } if ($oTask->isActionAllowed(CTaskItem::ACTION_COMPLETE)) { $arAllowedActions[] = array('public_name' => 'close', 'system_name' => 'close', 'id' => CTaskItem::ACTION_COMPLETE); } if ($oTask->isActionAllowed(CTaskItem::ACTION_START)) { $arAllowedActions[] = array('public_name' => 'start', 'system_name' => 'start', 'id' => CTaskItem::ACTION_START); } if ($oTask->isActionAllowed(CTaskItem::ACTION_DELEGATE)) { $arAllowedActions[] = array('public_name' => 'delegate', 'system_name' => 'delegate', 'id' => CTaskItem::ACTION_DELEGATE); } if ($oTask->isActionAllowed(CTaskItem::ACTION_APPROVE)) { $arAllowedActions[] = array('public_name' => 'approve', 'system_name' => 'close', 'id' => CTaskItem::ACTION_APPROVE); } if ($oTask->isActionAllowed(CTaskItem::ACTION_DISAPPROVE)) { $arAllowedActions[] = array('public_name' => 'redo', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_DISAPPROVE); } if ($oTask->isActionAllowed(CTaskItem::ACTION_REMOVE)) { $arAllowedActions[] = array('public_name' => 'remove', 'system_name' => 'remove', 'id' => CTaskItem::ACTION_REMOVE); } if ($oTask->isActionAllowed(CTaskItem::ACTION_EDIT)) { $arAllowedActions[] = array('public_name' => 'edit', 'system_name' => 'edit', 'id' => CTaskItem::ACTION_EDIT); } if ($oTask->isActionAllowed(CTaskItem::ACTION_DEFER)) { $arAllowedActions[] = array('public_name' => 'pause', 'system_name' => 'defer', 'id' => CTaskItem::ACTION_DEFER); } if ($oTask->isActionAllowed(CTaskItem::ACTION_START)) { $arAllowedActions[] = array('public_name' => 'renew', 'system_name' => 'start', 'id' => CTaskItem::ACTION_START); } elseif ($oTask->isActionAllowed(CTaskItem::ACTION_RENEW)) { $arAllowedActions[] = array('public_name' => 'renew', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_RENEW); } return $arAllowedActions; }
} $loggedInUserId = (int) $USER->getId(); if (!$arResult["USER"]) { $rsUser = CUser::GetByID($loggedInUserId); $arResult["USER"] = $rsUser->GetNext(); } $arResult["bVarsFromForm"] = false; if ($arResult["ACTION"] == "edit") { try { $oTask = new CTaskItem($arParams['TASK_ID'], $loggedInUserId); $arTask = $oTask->getData(); $arResult['ALLOWED_ACTIONS'] = $oTask->getAllowedActions(true); $arTask['~TAGS'] = $arTask['TAGS'] = $oTask->getTags(); $arTask['~FILES'] = $arTask['FILES'] = $oTask->getFiles(); $arTask['~DEPENDS_ON'] = $arTask['DEPENDS_ON'] = $oTask->getDependsOn(); if (!$oTask->isActionAllowed(CTaskItem::ACTION_EDIT)) { throw new TasksException(); } } catch (TasksException $e) { ShowError(GetMessage("TASKS_TASK_NOT_FOUND")); return; } } if (array_key_exists("back_url", $_REQUEST) && strlen($_REQUEST["back_url"]) > 0) { $arResult["RETURN_URL"] = htmlspecialcharsbx(trim($_REQUEST["back_url"])); } // a bundle of parameters considering copying and creating by template $arResult['COPY_PARAMS'] = array('ORIGIN_TASK' => intval($_POST['COPY_PARAMS']['ORIGIN_TASK']), 'COPY_CHILD_TASKS' => isset($_POST['COPY_PARAMS']) ? $_POST['COPY_PARAMS']['COPY_CHILD_TASKS'] == 'Y' : true, 'ORIGIN_TEMPLATE' => intval($_POST['COPY_PARAMS']['ORIGIN_TEMPLATE']), 'COPY_CHILD_TEMPLATES' => isset($_POST['COPY_PARAMS']) ? $_POST['COPY_PARAMS']['COPY_CHILD_TEMPLATES'] == 'Y' : true); $arData = array(); $arResult['TASK'] = null; $arResult['FORM_GUID'] = CTasksTools::genUuid();