Ejemplo n.º 1
0
 /**
  * Get a list of tasks
  */
 public function getList(array $order = array(), array $filter = array(), array $select = array(), array $parameters = array())
 {
     global $USER;
     $result = array();
     // ID is required
     $select[] = 'ID';
     // restrict navigation
     if (is_numeric($parameters['NAV_PARAMS']['nPageTop'])) {
         $parameters['NAV_PARAMS']['nPageTop'] = min($parameters['NAV_PARAMS']['nPageTop'], \CTaskRestService::TASKS_LIMIT_TOP_COUNT);
     } else {
         if (is_numeric($parameters['NAV_PARAMS']['nPageSize'])) {
             $parameters['NAV_PARAMS']['nPageSize'] = min($parameters['NAV_PARAMS']['nPageSize'], \CTaskRestService::TASKS_LIMIT_PAGE_SIZE);
         } else {
             $parameters['NAV_PARAMS']['nPageSize'] = \CTaskRestService::TASKS_LIMIT_PAGE_SIZE;
         }
     }
     $items = \CTaskItem::fetchList($USER->GetId(), $order, $filter, $parameters, $select);
     if (is_array($items)) {
         foreach ($items as $item) {
             $data = $item->getData(false);
             $id = $item->getId();
             $result['DATA']['TASK'][$id] = $data;
             $result['CAN']['TASK'][$id]['ACTION'] = static::translateAllowedActionNames($item->getAllowedActions());
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 public static function OnGetRatingContentOwner($params)
 {
     if (intval($params['ENTITY_ID']) && $params['ENTITY_TYPE_ID'] == 'TASK') {
         list($oTaskItems, $rsData) = CTaskItem::fetchList(CTasksTools::GetCommanderInChief(), array(), array('=ID' => $params['ENTITY_ID']), array(), array('ID', 'CREATED_BY'));
         unset($rsData);
         if ($oTaskItems[0] instanceof CTaskItem) {
             $data = $oTaskItems[0]->getData(false);
             if (intval($data['CREATED_BY'])) {
                 return intval($data['CREATED_BY']);
             }
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 private function getTaskPosition($taskId, array $order = array(), array $filter = array(), array $navigation = array(), array $select = array())
 {
     global $USER;
     //Navigation Restrictions
     if (isset($navigation["NAV_PARAMS"])) {
         $navigation["NAV_PARAMS"]["NavShowAll"] = false;
         $navigation["NAV_PARAMS"]["bShowAll"] = false;
     }
     $maxPageSize = \Bitrix\Tasks\Manager\Task::LIMIT_PAGE_SIZE;
     if (isset($navigation["NAV_PARAMS"]["nPageTop"])) {
         $navigation["NAV_PARAMS"]["nPageTop"] = min(intval($navigation["NAV_PARAMS"]["nPageTop"]), $maxPageSize);
     }
     if (isset($navigation["NAV_PARAMS"]["nPageSize"])) {
         $navigation["NAV_PARAMS"]["nPageSize"] = min(intval($navigation["NAV_PARAMS"]["nPageSize"]), $maxPageSize);
     }
     list($items) = \CTaskItem::fetchList($USER->GetId(), $order, $filter, $navigation, $select);
     $result = array("found" => false, "prevTaskId" => 0, "nextTaskId" => 0);
     for ($i = 0, $l = count($items); $i < $l; $i++) {
         $id = $items[$i]->getId();
         if ($id == $taskId) {
             $result["found"] = true;
             if (isset($items[$i + 1])) {
                 $result["nextTaskId"] = $items[$i + 1]->getId();
             }
             break;
         }
         $result["prevTaskId"] = $id;
     }
     return $result;
 }
Ejemplo n.º 4
0
    $arSelect = array('ID', 'TITLE', 'PRIORITY', 'STATUS', 'REAL_STATUS', 'MULTITASK', 'DATE_START', 'GROUP_ID', 'DEADLINE', 'ALLOW_TIME_TRACKING', 'TIME_ESTIMATE', 'TIME_SPENT_IN_LOGS', 'COMMENTS_COUNT', 'FILES', 'MARK', 'ADD_IN_REPORT', 'SUBORDINATE', 'CREATED_DATE', 'VIEWED_DATE', 'FORUM_TOPIC_ID', 'END_DATE_PLAN', 'START_DATE_PLAN', 'CLOSED_DATE', 'PARENT_ID', 'ALLOW_CHANGE_DEADLINE', 'ALLOW_TIME_TRACKING', 'CHANGED_DATE', 'CREATED_BY', 'CREATED_BY_NAME', 'CREATED_BY_LAST_NAME', 'CREATED_BY_SECOND_NAME', 'CREATED_BY_LOGIN', 'CREATED_BY_WORK_POSITION', 'CREATED_BY_PHOTO', 'RESPONSIBLE_ID', 'RESPONSIBLE_NAME', 'RESPONSIBLE_LAST_NAME', 'RESPONSIBLE_SECOND_NAME', 'RESPONSIBLE_LOGIN', 'RESPONSIBLE_WORK_POSITION', 'RESPONSIBLE_PHOTO', 'UF_CRM_TASK');
    try {
        list($arTaskItems, $rsItems) = CTaskItem::fetchList($loggedInUserId, $arOrder, $arFilter, $arGetListParams, $arSelect);
    } catch (TasksException $e) {
        // Got SQL error for extended filter? Rollback to default filter preset.
        if ($arParams['USE_FILTER_V2'] && $e->getCode() & TasksException::TE_SQL_ERROR) {
            $bGroupMode = $taskType === 'group';
            $oFilter = CTaskFilterCtrl::GetInstance($arParams['USER_ID'], $bGroupMode);
            // Not default preset? Switch to it.
            if ($oFilter->GetSelectedFilterPresetId() != CTaskFilterCtrl::STD_PRESET_ALIAS_TO_DEFAULT) {
                $oFilter->SwitchFilterPreset(CTaskFilterCtrl::STD_PRESET_ALIAS_TO_DEFAULT);
                $arFilter = $oFilter->GetSelectedFilterPresetCondition();
                $arResult['SELECTED_PRESET_NAME'] = $oFilter->GetSelectedFilterPresetName();
                $arResult['SELECTED_PRESET_ID'] = $oFilter->GetSelectedFilterPresetId();
                // Try again to load data
                list($arTaskItems, $rsItems) = CTaskItem::fetchList($loggedInUserId, $arOrder, $arFilter, $arGetListParams, $arSelect);
            } else {
                throw new TasksException();
            }
        } else {
            throw new TasksException();
        }
    }
} catch (Exception $e) {
    ShowError(GetMessage('TASKS_UNEXPECTED_ERROR'));
    return;
}
$arResult["NAV_STRING"] = $rsItems->GetPageNavString(GetMessage("TASKS_TITLE_TASKS"), $arParams['NAV_TEMPLATE']);
$arResult["NAV_PARAMS"] = $rsItems->getNavParams();
$arResult["TASKS"] = array();
$arTasksIDs = array();