Ejemplo n.º 1
0
 /**
  * Get instance of multiton tasks' list controller
  */
 public static function getInstance()
 {
     if (self::$instanceOfSelf === null) {
         self::$instanceOfSelf = new self();
     }
     return self::$instanceOfSelf;
 }
 public static function pendCountersRecalculation()
 {
     $optionCountersBrokeDetected = (int) COption::GetOptionString('tasks', '~counters_broke_detected', -1, $siteId = '');
     // check if the agent event exists
     CTaskCountersProcessor::ensureAgentExists();
     if ($optionCountersBrokeDetected !== 1) {
         COption::SetOptionString('tasks', '~counters_broke_detected', 1, $description = '', $siteId = '');
     }
 }
Ejemplo n.º 3
0
        foreach ($arSites as $site) {
            foreach ($arDefaultValues as $key => $value) {
                if (isset($_POST[$key . "_" . $site["LID"]])) {
                    COption::SetOptionString("tasks", $key, $_POST[$key . "_" . $site["LID"]], false, $site["LID"]);
                }
            }
        }
        if (strlen($Update) > 0 && strlen($_REQUEST["back_url_settings"]) > 0) {
            LocalRedirect($_REQUEST["back_url_settings"]);
        } else {
            LocalRedirect($APPLICATION->GetCurPage() . "?mid=" . urlencode($mid) . "&lang=" . urlencode(LANGUAGE_ID) . "&back_url_settings=" . urlencode($_REQUEST["back_url_settings"]) . "&" . $tabControl->ActiveTabParam());
        }
    }
}
// check and restore CTaskCountersProcessor::agent();, if there is no one
CTaskCountersProcessor::ensureAgentExists();
?>
<form method="post" action="<?php 
echo $APPLICATION->GetCurPage();
?>
?mid=<?php 
echo htmlspecialcharsbx($mid);
?>
&amp;lang=<?php 
echo LANG;
?>
">
<?php 
echo bitrix_sessid_post();
$tabControl->Begin();
$tabControl->BeginNextTab();
Ejemplo n.º 4
0
 /**
  * $userId can be integer or array of integers
  */
 public static function getFilterFor($userId, $userRoleId, $taskCategoryId)
 {
     $subfilterIndex = 0;
     $arFilter = array('::LOGIC' => 'AND');
     switch ($userRoleId) {
         case CTaskListState::VIEW_ROLE_RESPONSIBLE:
             $arFilter['RESPONSIBLE_ID'] = $userId;
             break;
         case CTaskListState::VIEW_ROLE_ACCOMPLICE:
             $arFilter['ACCOMPLICE'] = $userId;
             break;
         case CTaskListState::VIEW_ROLE_AUDITOR:
             $arFilter['AUDITOR'] = $userId;
             break;
         case CTaskListState::VIEW_ROLE_ORIGINATOR:
             $arFilter['CREATED_BY'] = $userId;
             $arFilter['!REFERENCE:RESPONSIBLE_ID'] = 'CREATED_BY';
             break;
     }
     switch ($taskCategoryId) {
         case CTaskListState::VIEW_TASK_CATEGORY_COMPLETED:
             $arFilter['REAL_STATUS'] = array(CTasks::STATE_COMPLETED, CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_DECLINED);
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_WAIT_CTRL:
             $arFilter['REAL_STATUS'] = CTasks::STATE_SUPPOSEDLY_COMPLETED;
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_NEW:
             $arFilter['VIEWED'] = 0;
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_ALL:
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_IN_PROGRESS:
             $arFilter['REAL_STATUS'] = array(CTasks::STATE_NEW, CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS);
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_EXPIRED:
             $arFilter['STATUS'] = CTasks::METASTATE_EXPIRED;
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_EXPIRED_CANDIDATES:
             $obj = CTaskCountersProcessor::getInstance();
             $arFilter['>=DEADLINE'] = $obj->getNowDateTime();
             $arFilter['<DEADLINE'] = $obj->getExpiredSoonEdgeDateTime();
             $arFilter['!REAL_STATUS'] = array(CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED, CTasks::STATE_DECLINED);
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_DEFERRED:
             $arFilter['REAL_STATUS'] = CTasks::STATE_DEFERRED;
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_ATTENTION:
             switch ($userRoleId) {
                 case CTaskListState::VIEW_ROLE_RESPONSIBLE:
                 case CTaskListState::VIEW_ROLE_ACCOMPLICE:
                     // selects not viewed tasks, expired and to be expired soon
                     $arFilter['!REAL_STATUS'] = array(CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED, CTasks::STATE_DECLINED);
                     $obj = CTaskCountersProcessor::getInstance();
                     $arFilter['::SUBFILTER-' . ++$subfilterIndex] = array('::LOGIC' => 'OR', 'VIEWED' => 0, '<DEADLINE' => $obj->getExpiredSoonEdgeDateTime());
                     break;
                 case CTaskListState::VIEW_ROLE_AUDITOR:
                 case CTaskListState::VIEW_ROLE_ORIGINATOR:
                     // selects only expired tasks
                     $arFilter['STATUS'] = CTasks::METASTATE_EXPIRED;
                     break;
             }
             break;
         case CTaskListState::VIEW_TASK_CATEGORY_WO_DEADLINE:
             $arFilter['!REAL_STATUS'] = array(CTasks::STATE_DECLINED, CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED);
             $arFilter['DEADLINE'] = '';
             if ($userRoleId == CTaskListState::VIEW_ROLE_RESPONSIBLE) {
                 $arFilter['!CREATED_BY'] = $userId;
             }
             break;
         default:
             CTaskAssert::logError('[0x9a0abea0] Unknown $taskCategoryId = ' . $taskCategoryId);
             break;
     }
     return $arFilter;
 }
Ejemplo n.º 5
0
 public static function __updateViewed($TASK_ID, $USER_ID, $onTaskAdd = false)
 {
     global $DB;
     $USER_ID = (int) $USER_ID;
     $TASK_ID = (int) $TASK_ID;
     $rsViewed = $DB->Query("SELECT 'x' FROM b_tasks_viewed WHERE TASK_ID = " . $TASK_ID . " AND USER_ID = " . $USER_ID, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($rsViewed->Fetch()) {
         $DB->Query("UPDATE b_tasks_viewed SET VIEWED_DATE = " . $DB->CurrentTimeFunction() . " WHERE TASK_ID = " . $TASK_ID . " AND USER_ID = " . $USER_ID, $bIgnoreErrors = true);
     } else {
         CTaskCountersProcessor::onBeforeTaskViewedFirstTime($TASK_ID, $USER_ID, $onTaskAdd);
         $DB->Add("b_tasks_viewed", array("ID" => 1, "TASK_ID" => $TASK_ID, "USER_ID" => $USER_ID), array(), "tasks", $bIgnoreErrors = true);
     }
 }
 private static function reset()
 {
     global $DB, $CACHE_MANAGER;
     // Reset tasks marked as processed by CTaskCountersProcessor::agent()
     $DB->Query("UPDATE b_tasks SET DEADLINE_COUNTED = 0 WHERE 1=1");
     $arCountersIds = CTaskCountersProcessor::enumCountersIds();
     if (count($arCountersIds)) {
         // Reset all tasks' counters of users
         $DB->Query("UPDATE b_user_counter \n\t\t\t\tSET CNT = 0\n\t\t\t\tWHERE SITE_ID = '**' \n\t\t\t\t\tAND CODE IN ('" . implode("', '", $arCountersIds) . "')", $bIgnoreErrors = true);
         /** @var $CACHE_MANAGER CCacheManager */
         $CACHE_MANAGER->CleanDir('user_counter');
     }
 }