Ejemplo n.º 1
0
     $bLoadCommentsData = true;
 } elseif ($_POST['subject'] === 'DETAIL_AND_COMMENTS') {
     $bLoadDetailData = true;
     $bLoadCommentsData = true;
 } elseif ($_POST['subject'] === 'DETAIL') {
     $bLoadDetailData = true;
 } elseif ($_POST['subject'] === 'COMMENTS') {
     $bLoadCommentsData = true;
 }
 $arParams = array('USER_ID' => $userId, 'TASK_ID' => $taskId, 'DATE_TIME_FORMAT' => $_POST['DATE_TIME_FORMAT'], 'SHOW_TEMPLATE' => 'N', 'PATH_TO_USER_TASKS_EDIT' => '...');
 $arRes = $APPLICATION->IncludeComponent('bitrix:mobile.tasks.detail', '.default', $arParams, false);
 $filterCheckResult = 'not checked';
 // We must check filter condition for this task?
 if (isset($_POST['CHECK_FILTER_ID'])) {
     $filterPresetId = (int) $_POST['CHECK_FILTER_ID'];
     $oFilter = CTaskFilterCtrl::GetInstance($userId);
     $arFilter = $oFilter->GetFilterPresetConditionById($filterPresetId);
     if ($arFilter !== false) {
         $arFilter['ID'] = (int) $taskId;
         $rsTasks = CTasks::GetList($arOrder = array(), $arFilter, $arSelect = array('ID'));
         if ($rsTasks->Fetch()) {
             $filterCheckResult = 'match filter';
         } else {
             $filterCheckResult = 'dismatch filter';
         }
     }
 }
 $arTaskData = array('task_id' => $task_id, 'filter_check_result' => $filterCheckResult);
 if ($bLoadBaseData) {
     $arTaskData['baseData'] = MBTasksCptDetailAjax::PrepareBaseData($task_id, $arRes);
 }
Ejemplo n.º 2
0
	oEngine.loggedInUserId     = <?php 
echo (int) $loggedInUserId;
?>
;
	oEngine.formattedGroupsNames = {};	// cache of groups names
	oEngine.formattedUserNames = {};	// cache of user names
	oEngine.formattedUserNames['u' + <?php 
echo (int) $loggedInUserId;
?>
] = '<?php 
echo CUtil::JSEscape($loggedInUserFormattedName);
?>
';

	oEngine.manifest = <?php 
echo CUtil::PhpToJsObject(CTaskFilterCtrl::getManifest());
?>
;

	oEngine.objForm = BX.Tasks.lwPopup.registerForm({
		callbacks: {
			onAfterPopupCreated : function(){},
			onBeforePopupShow   : function(){},
			onAfterPopupShow    : function(){},
			onAfterEditorInited : function(){},
			onPopupClose        : (function(objEngine){
				return function(){
					if (objEngine.renderer.bFormShowed)
						objEngine.renderer.bFormShowed = false;
				}
			})(oEngine)
Ejemplo n.º 3
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.º 4
0
    $arParams['PATH_TO_TASKS_FILTER'] = str_replace(array('#user_id#', '#USER_ID#'), $arParams['USER_ID'], $arParams['PATH_TO_USER_TASKS_FILTER']);
}
$paramsCheck = ($arParams['SHOW_TEMPLATE'] === 'Y' || $arParams['SHOW_TEMPLATE'] === 'N') && $arParams['RENDER_FORMAT'] === 'HTML' && is_int($arParams['TASKS_PER_PAGE']) && $arParams['TASKS_PER_PAGE'] > 0 && is_int($arParams['USER_ID']) && (is_int($arParams['GROUP_ID']) || $arParams['GROUP_ID'] === false) && is_string($arParams['NAME_TEMPLATE']) && strlen($arParams['NAME_TEMPLATE']) > 0 && is_string($arParams['DATE_TIME_FORMAT']) && strlen($arParams['DATE_TIME_FORMAT']) && is_string($arParams['PATH_TEMPLATE_TO_USER_PROFILE']) && is_string($arParams['PATH_TO_USER_TASKS']) && is_string($arParams['PATH_TO_USER_TASKS_TASK']) && is_string($arParams['PATH_TO_TASKS']) && is_string($arParams['PATH_TO_TASKS_EDIT']) && is_string($arParams['PATH_TO_TASKS_TASK']) && is_string($arParams['PATH_TO_TASKS_FILTER']) && in_array($arParams['OPTIMIZATION_MODE'], array('NONE', 'SELECT_ONLY_FILES_COUNT', 'SELECT_FULL_DATA_EXCEPT_FILES'), true);
if (!$paramsCheck) {
    return false;
}
unset($paramsCheck);
if (!CBXFeatures::IsFeatureEnabled('Tasks')) {
    if ($arParams['SHOW_TEMPLATE'] === 'Y' && $arParams['RENDER_FORMAT'] === 'HTML') {
        ShowError(GetMessage('TASKS_MODULE_NOT_AVAILABLE_IN_THIS_EDITION'));
    }
    return false;
}
require_once dirname(__FILE__) . '/functions.php';
// Init filter controller
$oFilter = CTaskFilterCtrl::GetInstance($arParams['USER_ID']);
$curFilterId = $oFilter->GetSelectedFilterPresetId();
// Switch filter, if need
if (isset($_GET['SWITCH_TO_FILTER_PRESET_ID'])) {
    $newFilterId = (int) $_GET['SWITCH_TO_FILTER_PRESET_ID'];
    // prevent idle action
    if ($newFilterId !== $curFilterId) {
        try {
            $oFilter->SwitchFilterPreset($newFilterId);
        } catch (Exception $e) {
            $oFilter->SwitchFilterPreset(CTaskFilterCtrl::STD_PRESET_ACTIVE_MY_TASKS);
        }
    }
}
// Set filter params for CTasks::GetList();
$arResult['FILTER'] = $oFilter->GetSelectedFilterPresetCondition();
Ejemplo n.º 5
0
 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);
 $oListCtrl->useAdvancedFilterObject($oFilter);
 // just saving reference to $oFilter inside $oListCtrl
 $arFilter = array_merge($oListCtrl->getFilter(), $oListCtrl->getCommonFilter());
 $arSqlSearch = CTasks::GetFilter($arFilter, '', array('USER_ID' => $loggedInUserId));
 $arSqlSearch[] = " T.ZOMBIE = 'N' ";
 if ($arAction['operation'] === 'tasks.list::getOriginators()') {
     $sql = "SELECT T.CREATED_BY AS USER_ID, COUNT(T.ID) AS TASKS_CNT \n\t\t\t\t\t\tFROM b_tasks T \n\t\t\t\t\t\tLEFT JOIN b_tasks_viewed TV ON TV.TASK_ID = T.ID AND TV.USER_ID = " . $loggedInUserId . "\n\t\t\t\t\t\tWHERE " . implode('AND', $arSqlSearch) . " GROUP BY T.CREATED_BY";
 } else {
     if ($arAction['operation'] === 'tasks.list::getResponsibles()') {
         $sql = "SELECT T.RESPONSIBLE_ID AS USER_ID, COUNT(T.ID) AS TASKS_CNT \n\t\t\t\t\t\tFROM b_tasks T \n\t\t\t\t\t\tLEFT JOIN b_tasks_viewed TV ON TV.TASK_ID = T.ID AND TV.USER_ID = " . $loggedInUserId . "\n\t\t\t\t\t\tWHERE " . implode('AND', $arSqlSearch) . " GROUP BY T.RESPONSIBLE_ID";
     } else {
         throw new Exception('unknown operation: ' . $arAction['operation']);
     }
 }
 global $DB;
Ejemplo n.º 6
0
		pulltext: '<?php 
echo GetMessageJS('MB_TASKS_TASKS_FILTER_PULLDOWN_PULL');
?>
',
		downtext: '<?php 
echo GetMessageJS('MB_TASKS_TASKS_FILTER_PULLDOWN_DOWN');
?>
',
		loadtext: '<?php 
echo GetMessageJS('MB_TASKS_TASKS_FILTER_PULLDOWN_LOADING');
?>
',
		action:   'RELOAD',
		callback: function() { app.reload(); }
	});
</script>
<?php 
$arResult = array();
$environmentCheck = isset($GLOBALS['APPLICATION']) && is_object($GLOBALS['APPLICATION']) && isset($GLOBALS['USER']) && is_object($GLOBALS['USER']) && isset($arParams) && is_array($arParams) && CModule::IncludeModule('tasks');
try {
    CTaskAssert::assert($environmentCheck);
    unset($environmentCheck);
    $arResult['USER_ID'] = (int) $_GET['USER_ID'];
    $oFilter = CTaskFilterCtrl::GetInstance($arResult['USER_ID']);
    $arResult['PRESETS_TREE'] = $oFilter->ListFilterPresets($bTreeMode = true);
    $arResult['CURRENT_PRESET_ID'] = $oFilter->GetSelectedFilterPresetId();
} catch (Exception $e) {
    return false;
}
$this->IncludeComponentTemplate();
return $arResult;
Ejemplo n.º 7
0
 public function getFilter()
 {
     $curSection = $this->oListState->getSection();
     if ($curSection === CTaskListState::VIEW_SECTION_ADVANCED_FILTER) {
         // we are in "advanced-mode" (section "all" and user-defined filters)
         $bGroupMode = false;
         if ($this->filterByGroupId !== null) {
             $bGroupMode = true;
         }
         if ($this->oFilter) {
             $oFilter = $this->oFilter;
         } else {
             $oFilter = CTaskFilterCtrl::GetInstance($this->userId, $bGroupMode);
         }
         $arFilter = $oFilter->GetSelectedFilterPresetCondition();
     } elseif ($curSection === CTaskListState::VIEW_SECTION_ROLES) {
         // we are in "role-mode" (four pre-defined filters at the top of the list)
         $arFilter = $this->__getFilterFor($this->oListState->getUserRole(), $this->oListState->getTaskCategory());
     }
     $counterId = self::resolveCounterIdByRoleAndCategory($this->oListState->getUserRole(), $this->oListState->getTaskCategory());
     $arFilter['CHECK_PERMISSIONS'] = 'Y';
     // Mark filter. So when it will be used by CTasks::GetList(),
     // CTaskCountersProcessorHomeostasis will check if counter is right
     // or not.
     // This will work out only when resolved counter is not null and we are in "role-mode"
     $arFilter = CTaskCountersProcessorHomeostasis::injectMarker($arFilter, $curSection, $counterId, $this->userId);
     return $arFilter;
 }
Ejemplo n.º 8
0
        // This will be interpreted by CTasks::GetList as nPageTop
        $arGetListParams = array('nPageTop' => $itemsCount);
    }
}
$arResult["ORIGINAL_FILTER"] = $arFilter;
$arResult["FILTER"] = $arFilter;
unset($arResult["FILTER"]["ONLY_ROOT_TASKS"]);
try {
    $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();
        }
    }
Ejemplo n.º 9
0
 public static function MkOperationFilter($key)
 {
     static $arOperationsMap = null;
     // will be loaded on demand
     $key = ltrim($key);
     $firstSymbol = substr($key, 0, 1);
     $twoSymbols = substr($key, 0, 2);
     if ($firstSymbol == "=") {
         $key = substr($key, 1);
         $cOperationType = "I";
     } elseif ($twoSymbols == "!=") {
         $key = substr($key, 2);
         $cOperationType = "NI";
     } elseif ($firstSymbol == "%") {
         $key = substr($key, 1);
         $cOperationType = "S";
     } elseif ($twoSymbols == "!%") {
         $key = substr($key, 2);
         $cOperationType = "NS";
     } elseif ($firstSymbol == "?") {
         $key = substr($key, 1);
         $cOperationType = "?";
     } elseif ($twoSymbols == "><") {
         $key = substr($key, 2);
         $cOperationType = "B";
     } elseif (substr($key, 0, 3) == "!><") {
         $key = substr($key, 3);
         $cOperationType = "NB";
     } elseif ($twoSymbols == ">=") {
         $key = substr($key, 2);
         $cOperationType = "GE";
     } elseif ($firstSymbol == ">") {
         $key = substr($key, 1);
         $cOperationType = "G";
     } elseif ($twoSymbols == "<=") {
         $key = substr($key, 2);
         $cOperationType = "LE";
     } elseif ($firstSymbol == "<") {
         $key = substr($key, 1);
         $cOperationType = "L";
     } elseif ($firstSymbol == "!") {
         $key = substr($key, 1);
         $cOperationType = "N";
     } elseif ($firstSymbol === '#') {
         // Preload and cache in static variable
         if ($arOperationsMap === null) {
             $arManifest = CTaskFilterCtrl::getManifest();
             $arOperationsMap = $arManifest['Operations map'];
         }
         // Resolve operation code and cutoff operation prefix from item name
         $operation = null;
         foreach ($arOperationsMap as $operationCode => $operationPrefix) {
             $pattern = '/^' . preg_quote($operationPrefix) . '[A-Za-z]/';
             if (preg_match($pattern, $key)) {
                 $operation = $operationCode;
                 $key = substr($key, strlen($operationPrefix));
                 break;
             }
         }
         CTaskAssert::assert($operation !== null);
         $cOperationType = "#" . $operation;
     } else {
         $cOperationType = "E";
     }
     // field LIKE val
     return array("FIELD" => $key, "OPERATION" => $cOperationType);
 }
Ejemplo n.º 10
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.º 11
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;
 }