示例#1
0
 protected function fetchListFromDb($taskData, $arOrder = array('ID' => 'ASC'), $arFilter = array())
 {
     CTaskAssert::assertLaxIntegers($taskData['ID']);
     if (!isset($arOrder)) {
         $arOrder = array('ID' => 'ASC');
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arFilter['TASK_ID'] = (int) $taskData['ID'];
     $arItemsData = array();
     /** @noinspection PhpDeprecationInspection */
     $rsData = CTaskLog::GetList($arOrder, $arFilter);
     if (!is_object($rsData)) {
         throw new Exception();
     }
     $i = 1;
     while ($arData = $rsData->fetch()) {
         $arData['ID'] = $i;
         // emulate ID field that is required by CTaskSubItemAbstract::constructWithPreloadedData()
         $arItemsData[] = $arData;
         $i++;
     }
     return array($arItemsData, $rsData);
 }
示例#2
0
 /**
  * Create new comment for task
  * 
  * @param integer $taskId
  * @param integet $commentId
  * @param integer $commentEditorId - ID of user who is comment's editor
  * @param string[] $arFields - fields to be updated, including text in BB code
  * 
  * @throws TasksException, CTaskAssertException
  * 
  * @return boolean
  */
 public static function update($taskId, $commentId, $commentEditorId, $arFields)
 {
     CTaskAssert::assertLaxIntegers($taskId, $commentId, $commentEditorId);
     CTaskAssert::assert(is_array($arFields) && !empty($arFields));
     if (!CModule::includeModule('forum')) {
         throw new TasksException('forum module can not be loaded', TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED);
     }
     IncludeModuleLangFile(__FILE__);
     $forumId = CTasksTools::GetForumIdForIntranet();
     $oTask = CTaskItem::getInstance($taskId, $commentEditorId);
     $arTask = $oTask->getData();
     $outForumTopicId = $outStrUrl = null;
     $arErrorCodes = array();
     $arFields = array_merge(array('EDITOR_ID' => $commentEditorId), $arFields);
     $messageId = self::__deprecated_Add($arFields['POST_MESSAGE'], $forumTopicId = $arTask['FORUM_TOPIC_ID'], $forumId, $nameTemplate = CSite::GetNameFormat(false), $arTask = $arTask, $permissions = 'Y', $commentId = $commentId, $givenUserId = $commentEditorId, $imageWidth = 300, $imageHeight = 300, $arSmiles = array(), $arForum = CForumNew::GetByID($forumId), $messagesPerPage = 10, $arUserGroupArray = CUser::GetUserGroup($commentEditorId), $backPage = null, $strMsgAddComment = GetMessage("TASKS_COMMENT_MESSAGE_ADD"), $strMsgEditComment = GetMessage("TASKS_COMMENT_MESSAGE_EDIT"), $strMsgNewTask = GetMessage("TASKS_COMMENT_SONET_NEW_TASK_MESSAGE"), $componentName = null, $outForumTopicId, $arErrorCodes, $outStrUrl, $arFields);
     if (!($messageId >= 1)) {
         throw new TasksException(serialize($arErrorCodes), TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED | TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE);
     }
     return true;
 }
示例#3
0
 public static function setOccurAsUserId($userId = 'get key')
 {
     static $key = null;
     if ($key === null) {
         $key = 'occurAs_key:' . md5(mt_rand(1000, 999999) . '-' . mt_rand(1000, 999999));
         if ($userId !== 'get key') {
             CTasksPerHitOption::set('tasks', $key, false);
         }
     }
     if ($userId !== 'get key') {
         CTaskAssert::assertLaxIntegers($userId);
         $userId = (int) $userId;
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $rs = CUser::getById($userId);
         if (!($rs && $rs->fetch())) {
             throw new TasksException('User not found', TasksException::TE_ITEM_NOT_FOUND_OR_NOT_ACCESSIBLE);
         }
         CTasksPerHitOption::set('tasks', $key, $userId);
     }
     return $key;
 }
示例#4
0
 private function __construct($userId)
 {
     CTaskAssert::assertLaxIntegers($userId);
     CTaskAssert::assert($userId > 0);
     $this->userId = (int) $userId;
 }
示例#5
0
 /**
  * @param integer $fileId
  * @throws TasksException
  * @throws CTaskAssertException
  * 
  * This function is deprecated, it wont work with a new disk-based file attachment mechanism
  * 
  * @deprecated
  */
 public function removeAttachedFile($fileId)
 {
     CTaskAssert::assertLaxIntegers($fileId);
     CTaskAssert::assert($fileId > 0);
     if (!$this->isActionAllowed(self::ACTION_EDIT)) {
         CTaskAssert::log('access denied while trying to remove file: fileId=' . $fileId . ', taskId=' . $this->taskId . ', userId=' . $this->executiveUserId, CTaskAssert::ELL_WARNING);
         throw new TasksException('', TasksException::TE_ACTION_NOT_ALLOWED);
     }
     if (!CTaskFiles::Delete($this->taskId, $fileId)) {
         throw new TasksException('File #' . $fileId . ' not attached to task #' . $this->taskId, TasksException::TE_FILE_NOT_ATTACHED_TO_TASK);
     }
 }
示例#6
0
 public function importFilterDataFromJs($arPresetData, $mode = self::IMPORT_MODE_CREATE, $presetId = null)
 {
     CTaskAssert::assert(in_array($mode, array(self::IMPORT_MODE_CREATE, self::IMPORT_MODE_REPLACE), true) && is_array($arPresetData) && count($arPresetData) === 3 && isset($arPresetData['Name'], $arPresetData['Parent'], $arPresetData['Condition']) && $arPresetData['Parent'] === self::ROOT_PRESET && strlen($arPresetData['Name']) && is_array($arPresetData['Condition']));
     $arPresetData['Condition'] = self::convertItemForImport($arPresetData['Condition']);
     if ($mode === self::IMPORT_MODE_CREATE) {
         $newPresetId = $this->createPreset($arPresetData);
     } else {
         CTaskAssert::assertLaxIntegers($presetId);
         CTaskAssert::assert($presetId > 0);
         $newPresetId = $this->replacePreset($presetId, $arPresetData);
     }
     return $newPresetId;
 }
示例#7
0
 protected final function fetchListFromDb($taskData, $arOrder = array('SORT_INDEX' => 'asc', 'ID' => 'asc'))
 {
     CTaskAssert::assertLaxIntegers($taskData['ID']);
     if (!isset($arOrder)) {
         $arOrder = array('SORT_INDEX' => 'asc', 'ID' => 'asc');
     }
     global $DB;
     if (is_array($arOrder) && !empty($arOrder)) {
         if (!self::checkFieldsForSort($arOrder)) {
             throw new TasksException('', TasksException::TE_WRONG_ARGUMENTS);
         }
         $sqlOrder = array();
         foreach ($arOrder as $fld => $way) {
             $sqlOrder[] = $fld . ' ' . $way;
         }
         $sqlOrder = 'ORDER BY ' . implode(', ', $sqlOrder);
     } else {
         $sqlOrder = '';
     }
     $rc = $DB->Query("SELECT ID, CREATED_BY, TASK_ID, TITLE, IS_COMPLETE, SORT_INDEX, " . $DB->DateToCharFunction("TOGGLED_DATE", "FULL") . " AS TOGGLED_DATE , TOGGLED_BY\n\t\t\t\tFROM b_tasks_checklist_items \n\t\t\t\tWHERE TASK_ID = " . (int) $taskData['ID'] . ' ' . $sqlOrder, $bIgnoreErrors = true);
     if (!$rc) {
         throw new \Bitrix\Main\SystemException();
     }
     $arItemsData = array();
     while ($arItemData = $rc->fetch()) {
         $arItemsData[] = $arItemData;
     }
     return array($arItemsData, $rc);
 }
示例#8
0
 public function setColumns($presetId, $columns)
 {
     global $DB;
     CTaskAssert::assertLaxIntegers($presetId);
     $presetId = (int) $presetId;
     CTaskAssert::assert($presetId > 0);
     self::checkColumns($columns);
     if (empty($columns)) {
         $columns = array(array('ID' => CTaskColumnList::COLUMN_TITLE, 'WIDTH' => 1));
     }
     $arFields = array('SERIALIZED_COLUMNS' => serialize($columns));
     $arBinds = array('SERIALIZED_COLUMNS' => $arFields['SERIALIZED_COLUMNS']);
     $strUpdate = $DB->PrepareUpdate("b_tasks_columns", $arFields, "tasks");
     $strSql = "UPDATE b_tasks_columns SET " . $strUpdate . " WHERE ID=" . $presetId . " AND USER_ID = " . $this->userId . " AND CONTEXT_ID = " . $this->contextId;
     $DB->QueryBind($strSql, $arBinds, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
示例#9
0
         $oTaskTimer->start($taskId);
     } elseif ($arAction['operation'] === 'CTaskTimerManager::stop()') {
         $oTaskTimer->stop($taskId);
     } else {
         CTaskAssert::assert(false);
     }
     $arCurOperationResult = array('returnValue' => null, 'requestedTaskId' => $taskId);
     break;
 case 'CTaskTimerManager::getLastTimer()':
     $oTaskTimer = CTaskTimerManager::getInstance($loggedInUserId);
     $arCurOperationResult = array('returnValue' => $oTaskTimer->getLastTimer());
     break;
 case 'tasks.list::getOriginators()':
 case 'tasks.list::getResponsibles()':
     CTaskAssert::assert(isset($arAction['userId'], $arAction['groupId'], $arAction['rawState']));
     CTaskAssert::assertLaxIntegers($arAction['userId'], $arAction['groupId']);
     CTaskAssert::assert(unserialize($arAction['rawState']) !== false);
     $oListState = CTaskListState::getInstance($loggedInUserId);
     $oListState->setRawState($arAction['rawState']);
     // just update current value of an option
     $oListCtrl = CTaskListCtrl::getInstance($arAction['userId']);
     $oListCtrl->useState($oListState);
     // just saving reference to $oListState inside $oListCtrl
     if ($arAction['groupId'] > 0) {
         $bGroupMode = true;
         $oListCtrl->setFilterByGroupId((int) $arAction['groupId']);
     } else {
         $bGroupMode = false;
         $oListCtrl->setFilterByGroupId(null);
     }
     $oFilter = CTaskFilterCtrl::GetInstance($arAction['userId'], $bGroupMode);
示例#10
0
 protected final function fetchListFromDb($taskData, $arOrder = array('ID' => 'ASC'), $arFilter = array())
 {
     CTaskAssert::assertLaxIntegers($taskData['ID']);
     if (!isset($arOrder)) {
         $arOrder = array('ID' => 'ASC');
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arFilter['TASK_ID'] = (int) $taskData['ID'];
     $arItemsData = array();
     /** @noinspection PhpDeprecationInspection */
     $rsData = CTaskElapsedTime::GetList($arOrder, $arFilter);
     if (!is_object($rsData)) {
         throw new Exception();
     }
     while ($arData = $rsData->fetch()) {
         $arItemsData[] = $arData;
     }
     return array($arItemsData, $rsData);
 }
示例#11
0
 /**
  * prevent creating through "new"
  *
  * @param $userId
  */
 private function __construct($userId)
 {
     global $USER;
     CTaskAssert::assertLaxIntegers($userId);
     CTaskAssert::assert($userId > 0);
     $this->userId = $userId;
     if (isset($GLOBALS['USER']) && is_object($GLOBALS['USER']) && $USER->IsAuthorized()) {
         $this->loggedInUserId = (int) $USER->getId();
     }
     $this->oListState = CTaskListState::getInstance($userId);
 }
示例#12
0
 protected final function fetchDataFromDb($taskId, $itemId)
 {
     CTaskAssert::assertLaxIntegers($taskId, $itemId);
     CTaskAssert::assert(CModule::IncludeModule('forum'));
     /** @noinspection PhpDeprecationInspection */
     $rsData = CForumMessage::GetList(array(), array('ID' => (int) $itemId));
     if (is_object($rsData) && ($arData = $rsData->fetch())) {
         return $arData;
     } else {
         throw new Exception();
     }
 }
示例#13
0
 /**
  * prevent creating through "new"
  *
  * @param $userId
  */
 private function __construct($userId)
 {
     global $USER;
     CTaskAssert::assertLaxIntegers($userId);
     CTaskAssert::assert($userId > 0);
     $this->userId = $userId;
     if (isset($USER) && is_object($USER) && $USER->IsAuthorized()) {
         $this->loggedInUserId = (int) $USER->getId();
         $this->paramName = self::listViewModeParamName . '_by_user_' . $this->loggedInUserId;
     } else {
         $this->paramName = self::listViewModeParamName;
     }
     $rc = CUserOptions::GetOption(self::listCategoryName, $this->paramName, serialize(false), $this->userId);
     $this->state = array(self::TOC_SECTION_SELECTED => self::VIEW_SECTION_ROLES, self::TOC_ROLE_SELECTED => self::VIEW_ROLE_RESPONSIBLE, self::TOC_VIEW_SELECTED => self::VIEW_MODE_LIST, self::TOC_TASK_CATEGORY_SELECTED => array(self::VIEW_ROLE_RESPONSIBLE => self::VIEW_TASK_CATEGORY_IN_PROGRESS, self::VIEW_ROLE_ORIGINATOR => self::VIEW_TASK_CATEGORY_IN_PROGRESS, self::VIEW_ROLE_ACCOMPLICE => self::VIEW_TASK_CATEGORY_IN_PROGRESS, self::VIEW_ROLE_AUDITOR => self::VIEW_TASK_CATEGORY_IN_PROGRESS), self::TOC_SUBMODES => array(self::VIEW_SUBMODE_WITH_GROUPS => array(self::TOC_SELECTED => 'Y'), self::VIEW_SUBMODE_WITH_SUBTASKS => array(self::TOC_SELECTED => 'Y')));
     $state = unserialize($rc);
     if (is_array($state)) {
         $this->state = array_merge($this->state, $state);
     }
 }
示例#14
0
 public static function tasks_extended_meta_setAnyStatus($args)
 {
     $arMessages = array();
     $parsedReturnValue = null;
     $withoutExceptions = false;
     try {
         CTaskAssert::assert(is_array($args) && count($args) == 2);
         $statusId = array_pop($args);
         $taskId = array_pop($args);
         CTaskAssert::assertLaxIntegers($statusId, $taskId);
         $taskId = (int) $taskId;
         $statusId = (int) $statusId;
         if (!in_array($statusId, array(CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS, CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED, CTasks::STATE_DEFERRED), true)) {
             throw new TasksException('Invalid status given', TasksException::TE_WRONG_ARGUMENTS);
         }
         $oTask = CTaskItem::getInstance($taskId, 1);
         // act as Admin
         $oTask->update(array('STATUS' => $statusId));
         $parsedReturnValue = null;
         $withoutExceptions = true;
     } catch (CTaskAssertException $e) {
         $arMessages[] = array('id' => 'TASKS_ERROR_ASSERT_EXCEPTION', 'text' => 'TASKS_ERROR_ASSERT_EXCEPTION');
     } catch (TasksException $e) {
         $errCode = $e->getCode();
         $errMsg = $e->getMessage();
         if ($e->GetCode() & TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE) {
             $arMessages = unserialize($errMsg);
         } else {
             $arMessages[] = array('id' => 'TASKS_ERROR_EXCEPTION_#' . $errCode, 'text' => 'TASKS_ERROR_EXCEPTION_#' . $errCode . '; ' . $errMsg . '; ' . TasksException::renderErrorCode($e));
         }
     } catch (Exception $e) {
         $errMsg = $e->getMessage();
         if ($errMsg !== '') {
             $arMessages[] = array('text' => $errMsg, 'id' => 'TASKS_ERROR');
         }
     }
     if ($withoutExceptions) {
         return $parsedReturnValue;
     } else {
         self::_emitError($arMessages);
         throw new Exception();
     }
 }
示例#15
0
            if ($_POST['action'] === 'replacePreset') {
                CTaskAssert::assert(isset($_POST['presetId']) && CTaskAssert::isLaxIntegers($_POST['presetId']) && $_POST['presetId'] > 0);
                $mode = CTaskFilterCtrl::IMPORT_MODE_REPLACE;
                $presetId = (int) $_POST['presetId'];
            }
            $oFilter = CTaskFilterCtrl::getInstance($loggedInUser);
            $newPresetId = $oFilter->importFilterDataFromJs($_POST['presetData'], $mode, $presetId);
            $arReply['newPresetId'] = $newPresetId;
        } catch (Exception $e) {
            $status = 'fail';
        }
        break;
    case 'removePreset':
        try {
            CTaskAssert::assert(isset($_POST['presetId']) && $_POST['presetId'] > 0);
            CTaskAssert::assertLaxIntegers($_POST['presetId']);
            $oFilter = CTaskFilterCtrl::getInstance($loggedInUser);
            $arPresetDefinition = $oFilter->removePreset($_POST['presetId']);
            if ($arPresetDefinition !== false) {
                $arReply = array('removedPresetId' => (int) $_POST['presetId']);
            } else {
                $status = 'fail';
            }
        } catch (Exception $e) {
            $status = 'fail';
        }
        break;
    default:
        CTaskAssert::assert(false);
        break;
}
示例#16
0
 /**
  * prevent creating through "new"
  *
  * @param $userId
  */
 private function __construct($userId)
 {
     global $USER;
     CTaskAssert::assertLaxIntegers($userId);
     CTaskAssert::assert($userId > 0);
     $this->userId = $userId;
     if (isset($USER) && is_object($USER) && $USER->IsAuthorized()) {
         $this->loggedInUserId = (int) $USER->getId();
         $this->paramName = self::listViewModeParamName . '_by_user_' . $this->loggedInUserId;
     } else {
         $this->paramName = self::listViewModeParamName;
     }
     $rc = CUserOptions::GetOption(self::listCategoryName, $this->paramName, serialize(false), $this->userId);
     $this->resetState();
     $state = unserialize($rc);
     if (is_array($state)) {
         $this->state = array_merge($this->state, $state);
     }
 }