/** * @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); }
/** * DEPRECATED! Migrated to tasks module. * * @deprecated */ public static function SetTaskTime($arParams) { if (!self::$arWasElapedCache[$arParams['TASK_ID']]) { $ob = new CTaskElapsedTime(); $ob->Add(array('USER_ID' => $arParams['USER_ID'], 'TASK_ID' => $arParams['TASK_ID'], 'MINUTES' => intval($arParams['TIME'] / 60), 'COMMENT_TEXT' => GetMessage('TIMEMAN_MODULE_NAME'))); } }