Esempio n. 1
0
 public static function onAfterTimeManagerDayStart($arData)
 {
     if (!(isset($arData['USER_ID'], $arData['MODIFIED_BY']) && $arData['USER_ID'] > 0 && $arData['MODIFIED_BY'] > 0 && $arData['MODIFIED_BY'] == $arData['USER_ID'] && IsModuleInstalled("im") && CModule::IncludeModule("im"))) {
         return;
     }
     $recipientId = (int) $arData['USER_ID'];
     try {
         $tasksCounter = CTaskListCtrl::getMainCounterForUser($recipientId);
         if ($tasksCounter <= 0) {
             return;
         }
         /** @noinspection PhpDeprecationInspection */
         CIMNotify::Add(array('FROM_USER_ID' => 0, 'TO_USER_ID' => $recipientId, 'NOTIFY_MODULE' => 'tasks', 'NOTIFY_EVENT' => 'notice', 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_TAG' => 'TASKS|COUNTERS_NOTICE|' . $recipientId, 'MESSAGE' => CTasksTools::getMessagePlural($tasksCounter, 'TASKS_COUNTERS_NOTICE_CONTENT_V2', array('#TASKS_COUNT#' => $tasksCounter, '#HREF#' => self::getTasksListLink($recipientId))), 'TITLE' => GetMessage('TASKS_COUNTERS_NOTICE_TITLE')));
     } catch (Exception $e) {
         CTaskAssert::logWarning('[0xb83d6845] unexpected exception in CTaskCountersNotifier::onAfterTimeManagerDayStart()' . ', file: ' . $e->getFile() . ', line: ' . $e->getLine() . ', code: ' . $e->getCode() . ', message: ' . $e->getMessage());
     }
 }
Esempio n. 2
0
     $arResult['SHOW_SECTION_MANAGE'] = 'N';
 }
 if ($arResult['SHOW_SECTION_MANAGE'] === 'Y') {
     $arResult['SECTION_MANAGE_COUNTER'] = 0;
     if ($arEmployees = CTaskIntranetTools::getImmediateEmployees($arParams['USER_ID'])) {
         foreach ($arEmployees as $employeeId) {
             $employeeId = (int) $employeeId;
             $arResult['SECTION_MANAGE_COUNTER'] += CTaskListCtrl::getUserRoleCounterForUser($employeeId, CTaskListState::VIEW_ROLE_RESPONSIBLE) + CTaskListCtrl::getUserRoleCounterForUser($employeeId, CTaskListState::VIEW_ROLE_ACCOMPLICE) + CTaskListCtrl::getUserRoleCounterForUser($employeeId, CTaskListState::VIEW_ROLE_ORIGINATOR) + CTaskListCtrl::getUserRoleCounterForUser($employeeId, CTaskListState::VIEW_ROLE_AUDITOR);
         }
     }
 }
 // get states description
 $oListState = CTaskListState::getInstance($loggedInUserId);
 $arResult['VIEW_STATE'] = $oListState->getState();
 $arResult['VIEW_STATE_RAW'] = $oListState->getRawState();
 $oListCtrl = CTaskListCtrl::getInstance($arParams['USER_ID']);
 $oListCtrl->useState($oListState);
 if ($arParams["GROUP_ID"] > 0) {
     $oListCtrl->setFilterByGroupId((int) $arParams["GROUP_ID"]);
 } else {
     $oListCtrl->setFilterByGroupId(null);
 }
 $selectedRoleId = $arResult['VIEW_STATE']['ROLE_SELECTED']['ID'];
 $selectedRoleName = $arResult['VIEW_STATE']['ROLE_SELECTED']['CODENAME'];
 $arResult['F_CREATED_BY'] = $arResult['F_RESPONSIBLE_ID'] = null;
 if ($arResult['VIEW_STATE']['SECTION_SELECTED']['CODENAME'] === 'VIEW_SECTION_ROLES') {
     /*
     if (
     	($selectedRoleName === 'VIEW_ROLE_RESPONSIBLE')
     	|| ($selectedRoleName === 'VIEW_ROLE_ORIGINATOR')
     )
Esempio n. 3
0
     }
     $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);
     $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' ";
Esempio n. 4
0
    foreach ($viewState['ROLES'] as $roleCodename => $arRoleData) {
        if (!isset($arCountsAll[$arRoleData['ID']])) {
            if ($arRoleData['ID'] == CTaskListState::VIEW_ROLE_AUDITOR || $arRoleData['ID'] == CTaskListState::VIEW_ROLE_ACCOMPLICE) {
                $rs = CTasks::GetCount(CTaskListCtrl::getFilterFor($arParams['USER_ID'], $arRoleData['ID'], CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS), array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true, 'bNeedJoinMembersTable' => true));
                if ($arTmp = $rs->fetch()) {
                    $arCountsAll[$arRoleData['ID']] = (int) $arTmp['CNT'];
                } else {
                    $arCountsAll[$arRoleData['ID']] = 0;
                }
            } else {
                $arCountsAll[$arRoleData['ID']] = CTasks::GetCountInt(CTaskListCtrl::getFilterFor($arParams['USER_ID'], $arRoleData['ID'], CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS), array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true));
            }
            $bNeedCacheData = true;
        }
        $arRoleData['CNT_ALL'] = $arCountsAll[$arRoleData['ID']];
        $arRoleData['CNT_NOTIFY'] = CTaskListCtrl::getUserRoleCounterForUser($arParams['USER_ID'], $arRoleData['ID']);
        $arRoleData['HREF'] = $arParams['PATH_TO_TASKS'] . '?F_CANCEL=Y&F_STATE=sR' . base_convert($arRoleData['ID'], 10, 32);
        $arResult["ROLES_LIST"][$roleCodename] = $arRoleData;
    }
    if ($bNeedCacheData && defined('BX_COMP_MANAGED_CACHE') && $obCache->StartDataCache()) {
        global $CACHE_MANAGER;
        $CACHE_MANAGER->StartTagCache($cacheDir);
        $CACHE_MANAGER->RegisterTag("tasks_user_" . $arResult['LOGGED_IN_USER']);
        $CACHE_MANAGER->EndTagCache();
        $obCache->EndDataCache($arCountsAll);
    }
} else {
    $arResult['USE_ROLE_FILTER'] = 'N';
    $arResult["ADVANCED_STATUSES"] = array(array("TITLE" => GetMessage("TASKS_FILTER_ALL"), "FILTER" => array()), array("TITLE" => GetMessage("TASKS_FILTER_ACTIVE"), "FILTER" => array("STATUS" => array(CTasks::METASTATE_VIRGIN_NEW, CTasks::METASTATE_EXPIRED, CTasks::STATE_NEW, CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS))), array("TITLE" => GetMessage("TASKS_FILTER_NEW"), "FILTER" => array("STATUS" => array(CTasks::METASTATE_VIRGIN_NEW, CTasks::STATE_NEW))), array("TITLE" => GetMessage("TASKS_FILTER_IN_CONTROL"), "FILTER" => array("STATUS" => array(CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_DECLINED))), array("TITLE" => GetMessage("TASKS_FILTER_IN_PROGRESS"), "FILTER" => array("STATUS" => CTasks::STATE_IN_PROGRESS)), array("TITLE" => GetMessage("TASKS_FILTER_ACCEPTED"), "FILTER" => array("STATUS" => CTasks::STATE_PENDING)), array("TITLE" => GetMessage("TASKS_FILTER_OVERDUE"), "FILTER" => array("STATUS" => CTasks::METASTATE_EXPIRED)), array("TITLE" => GetMessage("TASKS_FILTER_DELAYED"), "FILTER" => array("STATUS" => CTasks::STATE_DEFERRED)), array("TITLE" => GetMessage("TASKS_FILTER_DECLINED"), "FILTER" => array("STATUS" => CTasks::STATE_DECLINED)), array("TITLE" => GetMessage("TASKS_FILTER_CLOSED"), "FILTER" => array("STATUS" => array(CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED))));
    $bGroupMode = $taskType === 'group';
    $oFilter = CTaskFilterCtrl::GetInstance($arResult['LOGGED_IN_USER'], $bGroupMode);
Esempio n. 5
0
 private static function getCounts($arUsersIds)
 {
     $arUsersIds = array_unique(array_filter($arUsersIds));
     $arCounters = array();
     foreach ($arUsersIds as $userId) {
         $arCounters[$userId] = array();
         $responsiblesNoticedTasks = CTaskListCtrl::getUserRoleCounterForUser($userId, CTaskListState::VIEW_ROLE_RESPONSIBLE);
         $accomplicesNoticedTasks = CTaskListCtrl::getUserRoleCounterForUser($userId, CTaskListState::VIEW_ROLE_ACCOMPLICE);
         $originatorsNoticedTasks = CTaskListCtrl::getUserRoleCounterForUser($userId, CTaskListState::VIEW_ROLE_ORIGINATOR);
         $auditorsNoticedTasks = CTaskListCtrl::getUserRoleCounterForUser($userId, CTaskListState::VIEW_ROLE_AUDITOR);
         if ($responsiblesNoticedTasks < 0) {
             $responsiblesNoticedTasks = 0;
         }
         if ($accomplicesNoticedTasks < 0) {
             $accomplicesNoticedTasks = 0;
         }
         if ($originatorsNoticedTasks < 0) {
             $originatorsNoticedTasks = 0;
         }
         if ($auditorsNoticedTasks < 0) {
             $auditorsNoticedTasks = 0;
         }
         $arCounters[$userId]['RESPONSIBLES_TOTAL_TASKS'] = 0;
         $arCounters[$userId]['RESPONSIBLES_NOTICED_TASKS'] = $responsiblesNoticedTasks;
         $arCounters[$userId]['ACCOMPLICES_TOTAL_TASKS'] = 0;
         $arCounters[$userId]['ACCOMPLICES_NOTICED_TASKS'] = $accomplicesNoticedTasks;
         $arCounters[$userId]['ORIGINATORS_TOTAL_TASKS'] = 0;
         $arCounters[$userId]['ORIGINATORS_NOTICED_TASKS'] = $originatorsNoticedTasks;
         $arCounters[$userId]['AUDITORS_TOTAL_TASKS'] = 0;
         $arCounters[$userId]['AUDITORS_NOTICED_TASKS'] = $auditorsNoticedTasks;
     }
     // Get RESPONSIBLES_TOTAL_TASKS counters
     $arFilterMy = CTaskListCtrl::getFilterFor($arUsersIds, CTaskListState::VIEW_ROLE_RESPONSIBLE, CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS);
     $rs = CTasks::GetCount($arFilterMy, array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true), array('RESPONSIBLE_ID'));
     while ($ar = $rs->fetch()) {
         $userId = (int) $ar['RESPONSIBLE_ID'];
         if ($userId) {
             $arCounters[$userId]['RESPONSIBLES_TOTAL_TASKS'] = (int) $ar['CNT'];
         }
     }
     // Get ORIGINATORS_TOTAL_TASKS counters
     $arFilterOriginator = CTaskListCtrl::getFilterFor($arUsersIds, CTaskListState::VIEW_ROLE_ORIGINATOR, CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS);
     $rs = CTasks::GetCount($arFilterOriginator, array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true), array('CREATED_BY'));
     while ($ar = $rs->fetch()) {
         $userId = (int) $ar['CREATED_BY'];
         if ($userId) {
             $arCounters[$userId]['ORIGINATORS_TOTAL_TASKS'] = (int) $ar['CNT'];
         }
     }
     // Get ACCOMPLICES_TOTAL_TASKS counters
     $arFilterAccomplice = CTaskListCtrl::getFilterFor($arUsersIds, CTaskListState::VIEW_ROLE_ACCOMPLICE, CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS);
     $rs = CTasks::GetCount($arFilterAccomplice, array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true), array('ACCOMPLICE'));
     while ($ar = $rs->fetch()) {
         $userId = (int) $ar['ACCOMPLICE'];
         if ($userId) {
             $arCounters[$userId]['ACCOMPLICES_TOTAL_TASKS'] = (int) $ar['CNT'];
         }
     }
     // Get AUDITORS_TOTAL_TASKS counters
     $arFilterAuditor = CTaskListCtrl::getFilterFor($arUsersIds, CTaskListState::VIEW_ROLE_AUDITOR, CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS);
     $rs = CTasks::GetCount($arFilterAuditor, array('bSkipUserFields' => true, 'bSkipExtraTables' => true, 'bSkipJoinTblViewed' => true), array('AUDITOR'));
     while ($ar = $rs->fetch()) {
         $userId = (int) $ar['AUDITOR'];
         if ($userId) {
             $arCounters[$userId]['AUDITORS_TOTAL_TASKS'] = (int) $ar['CNT'];
         }
     }
     return $arCounters;
 }