Ejemplo n.º 1
0
                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;
}
$APPLICATION->RestartBuffer();
Ejemplo n.º 2
0
 private function getCounts($arGroupsIds)
 {
     $arCounters = array();
     if (empty($arGroupsIds)) {
         return;
     }
     foreach ($arGroupsIds as $groupId) {
         $arCounters[$groupId] = array('ALL' => 0, 'IN_WORK' => 0, 'COMPLETE' => 0);
     }
     $oFilter = CTaskFilterCtrl::getInstance($this->arParams['USER_ID'], true);
     $arFilterAll = $oFilter->getFilterPresetConditionById(CTaskFilterCtrl::STD_PRESET_ALL_MY_TASKS);
     $arFilterInWork = $oFilter->getFilterPresetConditionById(CTaskFilterCtrl::STD_PRESET_ACTIVE_MY_TASKS);
     $arFilterComplete = $oFilter->getFilterPresetConditionById(CTaskFilterCtrl::STD_PRESET_COMPLETED_MY_TASKS);
     $arFilterInWorkExpired = $arFilterInWork;
     $arFilterInWorkExpired['<DEADLINE'] = ConvertTimeStamp(time() + CTasksTools::getTimeZoneOffset(), 'FULL');
     $arFilterAll['GROUP_ID'] = $arGroupsIds;
     $arFilterInWork['GROUP_ID'] = $arGroupsIds;
     $arFilterComplete['GROUP_ID'] = $arGroupsIds;
     $arFilterInWorkExpired['GROUP_ID'] = $arGroupsIds;
     $arMap = array('ALL' => &$arFilterAll, 'IN_WORK' => &$arFilterInWork, 'COMPLETE' => &$arFilterComplete, 'EXPIRED' => &$arFilterInWorkExpired);
     foreach ($arMap as $key => &$arFilter) {
         $rs = CTasks::GetCount($arFilter, array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => false), array('GROUP_ID'));
         while ($ar = $rs->fetch()) {
             $groupId = (int) $ar['GROUP_ID'];
             if ($groupId) {
                 $arCounters[$groupId][$key] = (int) $ar['CNT'];
             }
         }
     }
     unset($arFilter);
     return $arCounters;
 }
Ejemplo n.º 3
0
 public function getState()
 {
     $arRoles = self::getKnownRoles();
     $arViews = $this->getAllowedViewModes();
     $arSubmodes = self::getKnownSubmodes();
     $arTaskCategories = $this->getAllowedTaskCategories();
     $selectedSectionId = $this->getSection();
     $selectedRoleId = $this->getUserRole();
     $selectedViewId = $this->getViewMode();
     $taskCategoryId = $this->getTaskCategory();
     $filterCtrl = CTaskFilterCtrl::getInstance($this->userId);
     $arViewState = array('SECTION_SELECTED' => array('ID' => $selectedSectionId, 'CODENAME' => self::resolveConstantCodename($selectedSectionId)), 'ROLES' => array(), 'ROLE_SELECTED' => array('ID' => $selectedRoleId, 'CODENAME' => self::resolveConstantCodename($selectedRoleId)), 'VIEWS' => array(), 'VIEW_SELECTED' => array('ID' => $selectedViewId, 'CODENAME' => self::resolveConstantCodename($selectedViewId)), 'VIEW_PARAMETERS' => $this->getViewParameters(), 'TASK_CATEGORIES' => array(), 'TASK_CATEGORY_SELECTED' => array('ID' => $taskCategoryId, 'CODENAME' => self::resolveConstantCodename($taskCategoryId)), 'SPECIAL_PRESETS' => array(), 'PRESET_SELECTED' => array('ID' => $filterCtrl->getSelectedFilterPresetId()), 'SPECIAL_PRESET_SELECTED' => array(), 'SUBMODES' => array());
     foreach ($arRoles as $roleId) {
         $codeName = self::resolveConstantCodename($roleId);
         $arViewState['ROLES'][$codeName] = array('ID' => $roleId, 'SELECTED' => $selectedRoleId === $roleId ? 'Y' : 'N', 'TITLE' => self::resolveRoleName($roleId), 'TITLE_ALT' => self::resolveRoleName($roleId, $bAltName = true));
     }
     foreach ($arViews as $viewId) {
         $codeName = self::resolveConstantCodename($viewId);
         $arViewState['VIEWS'][$codeName] = array('ID' => $viewId, 'SELECTED' => $selectedViewId === $viewId ? 'Y' : 'N', 'TITLE' => self::resolveViewName($viewId), 'SHORT_TITLE' => self::resolveViewName($viewId, $shortName = true));
     }
     foreach ($arTaskCategories as $categoryId) {
         $codeName = self::resolveConstantCodename($categoryId);
         $arViewState['TASK_CATEGORIES'][$codeName] = array('ID' => $categoryId, 'SELECTED' => $taskCategoryId === $categoryId ? 'Y' : 'N', 'TITLE' => self::resolveTaskCategoryName($categoryId));
     }
     foreach ($arSubmodes as $submodeId) {
         $codeName = self::resolveConstantCodename($submodeId);
         $isSubmodeSelected = $this->isSubmode($submodeId);
         $arViewState['SUBMODES'][$codeName] = array('ID' => $submodeId, 'SELECTED' => $isSubmodeSelected ? 'Y' : 'N', 'TITLE' => self::resolveSubmodeName($submodeId));
     }
     $selectedPreset = $filterCtrl->getSelectedFilterPresetId();
     foreach ($filterCtrl->listFilterSpecialPresets() as $id => $preset) {
         $preset['ID'] = $id;
         $arViewState['SPECIAL_PRESETS'][$id] = array('ID' => $id, 'TITLE' => $preset['Name'], 'SELECTED' => $selectedPreset == $id ? 'Y' : 'N', 'CODE' => $preset['Code']);
         if ($selectedPreset == $id) {
             $arViewState['SPECIAL_PRESET_SELECTED'] = array('ID' => $id, 'CODENAME' => $preset['Code']);
         }
     }
     return $arViewState;
 }