/**
  * @param CTaskItemInterface $oTaskItem
  * @throws TasksException
  * @return array $arReturn with elements
  * 		<ul>
  * 		<li>$arReturn[0] - array of items
  * 		<li>$arReturn[1] - CDBResult
  * 		</ul>
  */
 public static function fetchList(CTaskItemInterface $oTaskItem, $arOrder = array(), $arFilter = array())
 {
     $arItems = array();
     CTaskAssert::assert($oTaskItem instanceof CTaskItemInterface);
     $taskId = (int) $oTaskItem->getId();
     // Ensure that we have read access for task
     $taskData = $oTaskItem->getData();
     try {
         list($arItemsData, $rsData) = static::fetchListFromDb($taskData, $arOrder, $arFilter);
     } catch (Exception $e) {
         throw new TasksException('Action failed', TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED);
     }
     foreach ($arItemsData as $arItemData) {
         $arItems[] = self::constructWithPreloadedData($oTaskItem, $arItemData['ID'], $arItemData);
     }
     return array($arItems, $rsData);
 }
Example #2
0
 /**
  * @param CTaskItemInterface $oTaskItem
  * @param array $arFields with mandatory elements MINUTES, COMMENT_TEXT
  * @throws TasksException
  * @return CTaskElapsedItem
  */
 public static function add(CTaskItemInterface $oTaskItem, $arFields)
 {
     CTaskAssert::assert(is_array($arFields) && count($arFields) == 2 && isset($arFields['COMMENT_TEXT']) && (isset($arFields['MINUTES']) && CTaskAssert::isLaxIntegers($arFields['MINUTES']) || isset($arFields['SECONDS']) && CTaskAssert::isLaxIntegers($arFields['SECONDS'])) && is_string($arFields['COMMENT_TEXT']));
     if (!$oTaskItem->isActionAllowed(CTaskItem::ACTION_ELAPSED_TIME_ADD)) {
         throw new TasksException('', TasksException::TE_ACTION_NOT_ALLOWED);
     }
     $arFields['USER_ID'] = $oTaskItem->getExecutiveUserId();
     $arFields['TASK_ID'] = $oTaskItem->getId();
     /** @noinspection PhpDeprecationInspection */
     $obElapsed = new CTaskElapsedTime();
     $logId = $obElapsed->Add($arFields);
     // Reset tagged system cache by tag 'tasks_user_' . $userId for each task member
     self::__resetSystemWideTasksCacheByTag($oTaskItem->getData(false));
     if ($logId === false) {
         throw new TasksException('', TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED);
     }
     return new self($oTaskItem, (int) $logId);
 }