コード例 #1
0
ファイル: user_counter.php プロジェクト: DarneoStudio/bitrix
 public function GetValue($forceSync = false)
 {
     if ($this->curValue !== null) {
         return $this->curValue;
     }
     if ($this->code === '') {
         return 0;
     }
     $this->curValue = CUserCounter::GetValue($this->userID, $this->code, SITE_ID);
     if (!$this->CheckLastCalculatedTime() || $forceSync) {
         $this->Synchronize();
     }
     return $this->curValue;
 }
コード例 #2
0
 /**
  * Checks for broken counters.
  * Expirity counter is broken if it is < 0, or if it is more than tasks count in list of expired tasks
  * Other counters is broken if it is < 0, or if it is != tasks count in list of respective tasks
  *
  * Method is called inside CTask::GetList() to perform recounting of broken counters.
  * 
  * @param $arFilter Filter was used in GetList() call
  * @param $tasksCountInList Number of records returned by GetList() call
  */
 public static function onTaskGetList($arFilter, $tasksCountInList)
 {
     if (!CTaskCountersProcessorInstaller::isInstallComplete()) {
         return;
     }
     // Is there our marker?
     if (!(array_key_exists('::MARKERS', $arFilter) && array_key_exists(self::MARKER_ID, $arFilter['::MARKERS']) && $tasksCountInList !== null)) {
         return;
     }
     $tasksCountInList = (int) $tasksCountInList;
     $counterOwnerUserId = $arFilter['::MARKERS'][self::MARKER_ID]['userId'];
     $counterId = $arFilter['::MARKERS'][self::MARKER_ID]['counterId'];
     $counterValue = (int) CUserCounter::GetValue($counterOwnerUserId, $counterId, $site_id = '**');
     if (in_array($counterId, array(CTaskCountersProcessor::COUNTER_TASKS_MY_EXPIRED, CTaskCountersProcessor::COUNTER_TASKS_ACCOMPLICE_EXPIRED, CTaskCountersProcessor::COUNTER_TASKS_AUDITOR_EXPIRED, CTaskCountersProcessor::COUNTER_TASKS_ORIGINATOR_EXPIRED, CTaskCountersProcessor::COUNTER_TASKS_MY_EXPIRED_CANDIDATES, CTaskCountersProcessor::COUNTER_TASKS_ACCOMPLICE_EXPIRED_CANDIDATES), true)) {
         $isExpirityCounter = true;
     } else {
         $isExpirityCounter = false;
     }
     $isCounterBrokeDetected = false;
     $realTasksCount = null;
     // Is checksum correct?
     $filterCheksum = $arFilter['::MARKERS'][self::MARKER_ID]['filterCheksum'];
     $realCheksum = self::calcFilterChecksum($arFilter);
     // break detection part
     if ($filterCheksum === $realCheksum) {
         $realTasksCount = $tasksCountInList;
         if ($counterValue < 0 || $tasksCountInList != $counterValue) {
             $isCounterBrokeDetected = true;
         }
     } else {
         if (isset($arFilter['SAME_GROUP_PARENT'], $arFilter['ONLY_ROOT_TASKS']) && $arFilter['SAME_GROUP_PARENT'] === 'Y' && $arFilter['ONLY_ROOT_TASKS'] === 'Y') {
             // unset the corresponding fields and try to compare checksums again
             unset($arFilter['SAME_GROUP_PARENT']);
             unset($arFilter['ONLY_ROOT_TASKS']);
             $realCheksum = self::calcFilterChecksum($arFilter);
             if ($filterCheksum === $realCheksum) {
                 // tasks count in list shouldn't be more than registered in counter
                 // and counter shouldn't be less than zero
                 if ($counterValue < 0 || $tasksCountInList > $counterValue) {
                     $isCounterBrokeDetected = true;
                 } else {
                     if (static::getCountersRecheckForSubTasksNeed()) {
                         $rsTasksCount = CTasks::getCount($arFilter, array('bIgnoreDbErrors' => true, 'bSkipUserFields' => true, 'bSkipExtraTables' => true));
                         if ($rsTasksCount && ($arTasksCount = $rsTasksCount->fetch()) && isset($arTasksCount['CNT'])) {
                             $realTasksCount = (int) $arTasksCount['CNT'];
                             if ($realTasksCount != $counterValue) {
                                 // and finally check
                                 $isCounterBrokeDetected = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     /*
     if ( ! $isCounterBrokeDetected )
     {
     	if ($counterValue < 0)
     	{
     		$isCounterBrokeDetected = true;
     	}
     	else if ($realTasksCount !== null)
     	{
     		if ($isExpirityCounter)
     		{
     			if ($realTasksCount < $counterValue)
     				$isCounterBrokeDetected = true;
     		}
     		else
     		{
     			if ($realTasksCount !== $counterValue)
     				$isCounterBrokeDetected = true;
     		}
     	}
     }
     */
     if ($isCounterBrokeDetected) {
         ob_start();
         // a special way for correction of 'deadline expired' counters
         if ($isExpirityCounter) {
             // pend counters reinstalling (agent is used)
             self::pendCountersRecalculation();
         } else {
             if ($realTasksCount !== null) {
                 $delta = $realTasksCount - $counterValue;
                 CTaskCountersQueue::push($counterId, CTaskCountersQueue::OP_INCREMENT, array($counterOwnerUserId), $delta);
                 CTaskCountersQueue::execute();
             } else {
                 CTaskAssert::logError('[0x97e63b37] counter "' . $counterId . '" was mistimed for user ' . $counterOwnerUserId . '. But no correct data available for recount.');
             }
         }
         ob_end_clean();
     }
 }
コード例 #3
0
	public static function GetBadge($userId)
	{
		return 0;
		$count = 0;
		$count += CUserCounter::GetValue($userId, 'im_notify_v2', '**');
		$count += CUserCounter::GetValue($userId, 'im_chat_v2', '**');
		$count += CUserCounter::GetValue($userId, 'im_message_v2', '**');

		return $count;
	}
コード例 #4
0
ファイル: taskservice.php プロジェクト: mrdeadmouse/u136006
 public static function OnAdminInformerInsertItems()
 {
     global $USER;
     if (!defined("BX_AUTH_FORM")) {
         $tasksCount = CUserCounter::GetValue($USER->GetID(), 'bp_tasks');
         if ($tasksCount > 0) {
             $bpAIParams = array("TITLE" => GetMessage("BPTS_AI_BIZ_PROC"), "HTML" => '<span class="adm-informer-strong-text">' . GetMessage("BPTS_AI_EX_TASKS") . '</span><br>' . GetMessage("BPTS_AI_TASKS_NUM") . ' ' . $tasksCount, "FOOTER" => '<a href="/bitrix/admin/bizproc_task_list.php?lang=' . LANGUAGE_ID . '">' . GetMessage("BPTS_AI_TASKS_PERF") . '</a>', "COLOR" => "red", "ALERT" => true);
             CAdminInformer::AddItem($bpAIParams);
         }
     }
 }
コード例 #5
0
ファイル: component.php プロジェクト: k-kalashnikov/geekcon
    $arResult["H_NAV_STRING"] = $dbRecordsList->GetPageNavStringEx($navComponentObject, GetMessage("INTS_TASKS_NAV"), "", false);
    $arResult["H_NAV_CACHED_DATA"] = $navComponentObject->GetTemplateCachedData();
    $arResult["H_NAV_RESULT"] = $dbRecordsList;
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    if (!$arParams['COUNTERS_ONLY']) {
        if ($arParams["SET_TITLE"] == "Y") {
            $APPLICATION->SetTitle(GetMessage("BPABS_TITLE"));
        }
        if ($arParams["SET_NAV_CHAIN"] == "Y") {
            $APPLICATION->AddChainItem(GetMessage("BPABS_TITLE"));
        }
    }
    $arResult['COUNTERS'] = CBPTaskService::getCounters($targetUserId);
    if ($arParams['COUNTERS_ONLY']) {
        $arResult['COUNTERS_RUNNING'] = CBPStateService::getRunningCounters($targetUserId);
    }
    //counter autofixer
    $currentCounter = (int) CUserCounter::GetValue($targetUserId, 'bp_tasks', '**');
    if (isset($arResult['COUNTERS']['*']) && $currentCounter != $arResult['COUNTERS']['*']) {
        CUserCounter::Set($targetUserId, 'bp_tasks', $arResult['COUNTERS']['*'], '**');
    }
} elseif (!$arParams['COUNTERS_ONLY']) {
    if ($arParams["SET_TITLE"] == "Y") {
        $APPLICATION->SetTitle(GetMessage("BPWC_WLC_ERROR"));
    }
    if ($arParams["SET_NAV_CHAIN"] == "Y") {
        $APPLICATION->AddChainItem(GetMessage("BPWC_WLC_ERROR"));
    }
}
$this->IncludeComponentTemplate();
コード例 #6
0
ファイル: tasklistctrl.php プロジェクト: mrdeadmouse/u136006
 private static function getCounterForUser($userRoleId, $taskCategoryId, $userId)
 {
     $counterId = self::resolveCounterIdByRoleAndCategory($userRoleId, $taskCategoryId);
     if ($counterId !== null) {
         $rc = CUserCounter::GetValue($userId, $counterId, $site_id = '**');
     } else {
         CTaskAssert::logError('[0x0de6c535] unknown counter for $userRole: ' . $userRoleId . '; $taskCategoryId: ' . $taskCategoryId);
         $rc = false;
     }
     return $rc;
 }
コード例 #7
0
ファイル: global_counter.php プロジェクト: Satariall/izurit
 public static function GetValue($code, $site_id = SITE_ID)
 {
     return CUserCounter::GetValue(CUserCounter::SYSTEM_USER_ID, $code, $site_id);
 }
コード例 #8
0
ファイル: exchangemail.php プロジェクト: DarneoStudio/bitrix
 public static function GetTicker($user)
 {
     $userId = null;
     $numberOfUnreadMessages = null;
     if (!self::IsExchangeEnabled()) {
         return null;
     }
     if (is_object($user)) {
         if ($user->IsAuthorized()) {
             $userId = intval($user->GetID());
         }
     } elseif (is_array($user)) {
         if (array_key_exists("UF_UNREAD_MAIL_COUNT", $user)) {
             $numberOfUnreadMessages = $user["UF_UNREAD_MAIL_COUNT"];
         } elseif (array_key_exists("ID", $user)) {
             $userId = intval($user["ID"]);
         }
     } elseif (intval($user) . "!" == $user . "!" && intval($user) > 0) {
         $userId = intval($user);
     }
     if (is_null($numberOfUnreadMessages) && !is_null($userId)) {
         $numberOfUnreadMessages = CUserCounter::GetValue($userId, 'dav_unread_mail');
     }
     if (is_null($numberOfUnreadMessages) || empty($numberOfUnreadMessages)) {
         return null;
     }
     $exchangeMailboxPath = COption::GetOptionString("dav", "exchange_mailbox_path", "");
     return array("numberOfUnreadMessages" => $numberOfUnreadMessages, "exchangeMailboxPath" => $exchangeMailboxPath);
 }