Exemplo n.º 1
0
 /**
  * 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;
 }