public static function Update($id, $arFields) { global $DB; $id = intval($id); if ($id <= 0) { throw new Exception("id"); } self::ParseFields($arFields, $id); $strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields); $strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); if (is_set($arFields, "USERS")) { $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " "); CUserCounter::ClearByTag($id, 'bp_tasks', '**'); $ar = array(); foreach ($arFields["USERS"] as $userId) { $userId = intval($userId); if (in_array($userId, $ar)) { continue; } $DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ") "); CUserCounter::Increment($userId, 'bp_tasks', '**'); $ar[] = $userId; } } $events = GetModuleEvents("bizproc", "OnTaskUpdate"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array($id, $arFields)); } return $id; }
public static function Update($id, $arFields) { global $DB; $id = intval($id); if ($id <= 0) { throw new Exception("id"); } self::ParseFields($arFields, $id); $strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields); $strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $removedUsers = array(); if (is_set($arFields, "USERS")) { $dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " "); while ($arResUser = $dbResUser->Fetch()) { CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**'); $removedUsers[] = $arResUser["USER_ID"]; } $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " "); $ar = array(); foreach ($arFields["USERS"] as $userId) { $userId = intval($userId); if (in_array($userId, $ar)) { continue; } $DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID, ORIGINAL_USER_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ", " . intval($userId) . ") "); CUserCounter::Increment($userId, 'bp_tasks', '**'); $ar[] = $userId; } } $userStatuses = array(); if (isset($arFields['STATUS']) && $arFields['STATUS'] > CBPTaskStatus::Running) { $dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting); while ($arResUser = $dbResUser->Fetch()) { CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**'); if ($arFields['STATUS'] == CBPTaskStatus::Timeout) { $userStatuses[$arResUser["USER_ID"]] = CBPTaskUserStatus::No; } else { $removedUsers[] = $arResUser["USER_ID"]; } } if ($arFields['STATUS'] == CBPTaskStatus::Timeout) { $DB->Query("UPDATE b_bp_task_user SET STATUS = " . CBPTaskUserStatus::No . ", DATE_UPDATE = " . $DB->CurrentTimeFunction() . " WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting); } else { $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting); } } foreach (GetModuleEvents("bizproc", "OnTaskUpdate", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($id, $arFields)); } if ($removedUsers) { $arFields['USERS_REMOVED'] = $removedUsers; } if ($userStatuses) { $arFields['USERS_STATUSES'] = $userStatuses; } self::onTaskChange($id, $arFields, CBPTaskChangedStatus::Update); return $id; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arResult["urlToOwnBlog"] = ""; $arResult["urlToOwnProfile"] = ""; if (CModule::IncludeModule("blog") && $GLOBALS["USER"]->IsAuthorized()) { $arResult["urlToCreateMessageInBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG_NEW_POST"], array("user_id" => $GLOBALS["USER"]->GetID(), "post_id" => "new")); } if ($GLOBALS["USER"]->IsAuthorized()) { $arResult["urlToOwnProfile"] = CComponentEngine::MakePathFromTemplate($arParams["PROFILE_URL"], array("user_id" => $GLOBALS["USER"]->GetID())); $arCounters = CUserCounter::GetValues($GLOBALS["USER"]->GetID(), SITE_ID); $arResult["LOG_COUNTER"] = isset($arCounters["**"]) ? intval($arCounters["**"]) : 0; }
public static function IncrementWithSelect($sub_select, $sendPull = true) { global $DB, $CACHE_MANAGER, $APPLICATION; if (strlen($sub_select) > 0) { $pullInclude = $sendPull && self::CheckLiveMode(); $strSQL = " INSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE, SENT) (".$sub_select.") ON DUPLICATE KEY UPDATE CNT = CNT + VALUES(CNT), SENT = VALUES(SENT) "; $DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__); self::$counters = false; $CACHE_MANAGER->CleanDir("user_counter"); if ($pullInclude) { $db_lock = $DB->Query("SELECT GET_LOCK('".$APPLICATION->GetServerUniqID()."_pull', 0) as L"); $ar_lock = $db_lock->Fetch(); if($ar_lock["L"] > 0) { $arSites = Array(); $res = CSite::GetList(($b = ""), ($o = ""), Array("ACTIVE" => "Y")); while($row = $res->Fetch()) $arSites[] = $row['ID']; $strSQL = " SELECT distinct pc.CHANNEL_ID, uc1.USER_ID, uc1.SITE_ID, uc1.CODE, uc1.CNT FROM b_user_counter uc INNER JOIN b_user_counter uc1 ON uc1.USER_ID = uc.USER_ID AND uc1.CODE = uc.CODE INNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID WHERE uc.SENT = '0' "; $res = $DB->Query($strSQL, false, "FILE: ".__FILE__."<br> LINE: ".__LINE__); $pullMessage = Array(); while($row = $res->Fetch()) { if ($row['SITE_ID'] == '**') { foreach($arSites as $siteId) { if (isset($pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']])) $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] += intval($row['CNT']); else $pullMessage[$row['CHANNEL_ID']][$siteId][$row['CODE']] = intval($row['CNT']); } } else { if (isset($pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']])) $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] += intval($row['CNT']); else $pullMessage[$row['CHANNEL_ID']][$row['SITE_ID']][$row['CODE']] = intval($row['CNT']); } } $DB->Query("UPDATE b_user_counter SET SENT = '1' WHERE SENT = '0'"); $DB->Query("SELECT RELEASE_LOCK('".$APPLICATION->GetServerUniqID()."_pull')"); foreach ($pullMessage as $channelId => $arMessage) { CPullStack::AddByChannel($channelId, Array( 'module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage, )); } } } } }
} else { $arResult['ID'] = CMailbox::Add($arFields); $res = $arResult['ID'] > 0; } if (!$res) { $arResult['ERRORS'][] = GetMessage('INTR_MAIL_SAVE_ERROR'); } else { CUserCounter::Set($USER->GetID(), 'mail_unseen', $unseen, SITE_ID); CUserOptions::SetOption('global', 'last_mail_check_' . SITE_ID, time()); CUserOptions::SetOption('global', 'last_mail_check_success_' . SITE_ID, $unseen >= 0); LocalRedirect($APPLICATION->GetCurPage() . '?STEP=confirm&ACT=setup'); } } } break; case 'remove': if (check_bitrix_sessid()) { CMailbox::Delete($arResult['ID']); CUserCounter::Clear($USER->GetID(), 'mail_unseen', SITE_ID); CUserOptions::DeleteOption('global', 'last_mail_check_' . SITE_ID); CUserOptions::DeleteOption('global', 'last_mail_check_success_' . SITE_ID); LocalRedirect($APPLICATION->GetCurPage() . '?STEP=confirm&ACT=remove'); } else { LocalRedirect($APPLICATION->GetCurPage() . '?STEP=setup'); } break; case 'confirm': $arResult['ACT'] = isset($_REQUEST['ACT']) ? $_REQUEST['ACT'] : ''; break; } $this->IncludeComponentTemplate();
case 'crdomain': list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2); $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMemberMailbox', array('DOMAIN' => $acc['domain'], 'NAME' => $acc['login'])); if (isset($crCheckMailbox['result'])) { $unseen = intval($crCheckMailbox['result']); } else { $unseen = -1; $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']); } break; case 'domain': $service = \Bitrix\Mail\MailServicesTable::getRowById($acc['SERVICE_ID']); list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2); $result = CMailDomain2::getUnreadMessagesCount($service['TOKEN'], $acc['domain'], $acc['login'], $error); if (is_null($result)) { $unseen = -1; $error = CMail::getErrorMessage($error); } else { $unseen = intval($result); } break; } CUserCounter::Set($userId, 'mail_unseen', $unseen, $siteId); CUserOptions::SetOption('global', 'last_mail_check_' . $siteId, time(), false, $userId); CUserOptions::SetOption('global', 'last_mail_check_success_' . $siteId, $unseen >= 0, false, $userId); } else { $unseen = 0; CUserOptions::SetOption('global', 'last_mail_check_' . $siteId, -1, false, $userId); } header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo json_encode(array('result' => $error === false ? 'ok' : 'error', 'unseen' => $unseen, 'last_check' => CUserOptions::GetOption('global', 'last_mail_check_' . $siteId, false, $userId), 'error' => $error));
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; }
public static function MessageUpdate($REPORT_ID, $arReport = array(), $arFields = array()) { global $DB, $USER; $curUser = $USER->GetID(); if (CModule::IncludeModule("socialnetwork")) { $dbLog = CSocNetLog::GetList(array(), array("SOURCE_ID" => $REPORT_ID, "EVENT_ID" => "report")); if (!($arLog = $dbLog->Fetch())) { $LOG_ID = CReportNotifications::SendMessage($REPORT_ID, false); } else { $LOG_ID = $arLog["ID"]; CSocNetLog::Update($LOG_ID, array("USER_ID" => $curUser, "=LOG_DATE" => $DB->CurrentTimeFunction(), "=LOG_UPDATE" => $DB->CurrentTimeFunction())); CUserCounter::IncrementWithSelect(CSocNetLogCounter::GetSubSelect($LOG_ID, $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $arLog["EVENT_ID"], $arLog["USER_ID"])); } if (CModule::IncludeModule("im") && is_array($arFields) && is_array($arReport) && intval($arReport["USER_ID"]) > 0 && $arReport["USER_ID"] != $curUser) { $date_text = ""; $date_from = FormatDate("j F", MakeTimeStamp($arReport["DATE_FROM"], CSite::GetDateFormat("FULL", SITE_ID))); $date_to = FormatDate("j F", MakeTimeStamp($arReport["DATE_TO"], CSite::GetDateFormat("FULL", SITE_ID))); if ($date_from == $date_to) { $date_text = $date_to; } else { $date_text = $date_from . " - " . $date_to; } $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arReport["USER_ID"], "FROM_USER_ID" => $curUser, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "timeman", "NOTIFY_EVENT" => "report_approve", "NOTIFY_TAG" => "TIMEMAN|REPORT|" . $arReport["ID"] . "_" . $arFields["MARK"]); $gender_suffix = ""; $dbUser = CUser::GetByID($curUser); if ($arUser = $dbUser->Fetch()) { switch ($arUser["PERSONAL_GENDER"]) { case "M": $gender_suffix = "_M"; break; case "F": $gender_suffix = "_F"; break; default: $gender_suffix = ""; } } $reports_page = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php"); $arTmp = CSocNetLogTools::ProcessPath(array("REPORTS_PAGE" => $reports_page), $arReport["USER_ID"]); switch ($arFields["MARK"]) { case "G": $mark = "G"; break; case "B": $mark = "B"; break; case "X": $mark = "X"; break; default: $mark = "N"; } $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("REPORT_FULL_IM_APPROVE" . $gender_suffix . "_" . $mark, array("#period#" => "<a href=\"" . $arTmp["URLS"]["REPORTS_PAGE"] . "#user_id=" . $arReport["USER_ID"] . "&report=" . $REPORT_ID . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($date_text) . "</a>")); $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("REPORT_FULL_IM_APPROVE" . $gender_suffix . "_" . $mark, array("#period#" => htmlspecialcharsbx($date_text))) . " ( " . $arTmp["SERVER_NAME"] . $arTmp["URLS"]["REPORTS_PAGE"] . "#user_id=" . $arReport["USER_ID"] . "&report=" . $REPORT_ID . " )"; CIMNotify::Add($arMessageFields); } $dbLogRights = CSocNetLogRights::GetList(array(), array("LOG_ID" => $LOG_ID)); while ($arRight = $dbLogRights->Fetch()) { $arRights[] = $arRight["GROUP_CODE"]; } if (!in_array("U" . $curUser, $arRights)) { CSocNetLogRights::Add($LOG_ID, "U" . $curUser); } return $LOG_ID; } else { return false; } }
function Delete($ID) { global $DB; $ID = IntVal($ID); $db_msg = CMailMessage::GetList(Array(), Array("MAILBOX_ID"=>$ID)); while($msg = $db_msg->Fetch()) { if(!CMailMessage::Delete($msg["ID"])) return false; } $db_flt = CMailFilter::GetList(Array(), Array("MAILBOX_ID"=>$ID)); while($flt = $db_flt->Fetch()) { if(!CMailFilter::Delete($flt["ID"])) return false; } $db_log = CMailLog::GetList(Array(), Array("MAILBOX_ID"=>$ID)); while($log = $db_log->Fetch()) { if(!CMailLog::Delete($log["ID"])) return false; } $db_mbox = CMailbox::GetList(array('ID' => $ID, 'ACTIVE' => 'Y', '!USER_ID' => 0)); if ($mbox = $db_mbox->fetch()) { CUserCounter::Clear($mbox['USER_ID'], 'mail_unseen', $mbox['LID']); CUserOptions::DeleteOption('global', 'last_mail_check_'.$mbox['LID'], false, $mbox['USER_ID']); CUserOptions::DeleteOption('global', 'last_mail_check_success_'.$mbox['LID'], false, $mbox['USER_ID']); } CAgent::RemoveAgent("CMailbox::CheckMailAgent(".$ID.");", "mail"); $strSql = "DELETE FROM b_mail_message_uid WHERE MAILBOX_ID=".$ID; if(!$DB->Query($strSql, true)) return false; CMailbox::SMTPReload(); $strSql = "DELETE FROM b_mail_mailbox WHERE ID=".$ID; return $DB->Query($strSql, true); }
public static function CounterDecrement($log_id, $event_id = false, $type = "L", $bForAllAccess = false) { if (intval($log_id) <= 0) { return false; } CUserCounter::IncrementWithSelect(CSocNetLogCounter::GetSubSelect2($log_id, array("TYPE" => $type, "DECREMENT" => true, "FOR_ALL_ACCESS" => $bForAllAccess))); if ($event_id == "blog_post_important") { CUserCounter::IncrementWithSelect(CSocNetLogCounter::GetSubSelect2($log_id, array("TYPE" => "L", "CODE" => "'BLOG_POST_IMPORTANT'", "DECREMENT" => true, "FOR_ALL_ACCESS" => $bForAllAccess))); } }
public static function DeleteByCode($code) { global $DB, $APPLICATION, $CACHE_MANAGER; if (strlen($code) <= 0) { return false; } $pullMessage = array(); $bPullEnabled = false; if (self::CheckLiveMode()) { $db_lock = $DB->Query("SELECT GET_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull', 0) as L"); $ar_lock = $db_lock->Fetch(); if ($ar_lock["L"] > 0) { $bPullEnabled = true; $arSites = array(); $res = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y")); while ($row = $res->Fetch()) { $arSites[] = $row['ID']; } $strSQL = "\n\t\t\t\t\tSELECT distinct pc.CHANNEL_ID, uc.USER_ID, uc.SITE_ID, uc.CODE, uc.CNT\n\t\t\t\t\tFROM b_user_counter uc\n\t\t\t\t\tINNER JOIN b_pull_channel pc ON pc.USER_ID = uc.USER_ID\n\t\t\t\t\tWHERE uc.CODE LIKE '**%'\n\t\t\t\t"; $res = $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); while ($row = $res->Fetch()) { if ($row["CODE"] == $code) { continue; } CUserCounter::addValueToPullMessage($row, $arSites, $pullMessage); } } } $DB->Query("DELETE FROM b_user_counter WHERE CODE = '" . $code . "'", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); self::$counters = false; $CACHE_MANAGER->CleanDir("user_counter"); if ($bPullEnabled) { $DB->Query("SELECT RELEASE_LOCK('" . $APPLICATION->GetServerUniqID() . "_pull')"); } foreach ($pullMessage as $channelId => $arMessage) { CPullStack::AddByChannel($channelId, array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arMessage)); } }
if ($arTmpEvent["DATE_FOLLOW"]) { $dateLastPage = ConvertTimeStamp(MakeTimeStamp($arTmpEvent["DATE_FOLLOW"], CSite::GetDateFormat("FULL")), "FULL"); } elseif ($arParams["USE_FOLLOW"] == "N" && $arTmpEvent["LOG_UPDATE"]) { $dateLastPage = ConvertTimeStamp(MakeTimeStamp($arTmpEvent["LOG_UPDATE"], CSite::GetDateFormat("FULL")), "FULL"); } if ($arParams["LOG_ID"] <= 0 && intval($arParams["NEW_LOG_ID"]) <= 0 && $GLOBALS["USER"]->IsAuthorized()) { $arCounters = CUserCounter::GetValues($GLOBALS["USER"]->GetID(), SITE_ID); if (isset($arCounters[$arResult["COUNTER_TYPE"]])) { $arResult["LOG_COUNTER"] = intval($arCounters[$arResult["COUNTER_TYPE"]]); } else { $bEmptyCounter = true; $arResult["LOG_COUNTER"] = 0; } } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y" && (intval($arResult["LOG_COUNTER"]) > 0 || $bEmptyCounter)) { CUserCounter::ClearByUser($GLOBALS["USER"]->GetID(), array(SITE_ID, "**"), $arResult["COUNTER_TYPE"]); } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y" && $dateLastPage && (!$dateLastPageStart || $dateLastPageStart != $dateLastPage || $bNeedSetLogPage)) { CSocNetLogPages::Set($GLOBALS["USER"]->GetID(), $dateLastPage, $arParams["PAGE_SIZE"], $arResult["PAGE_NUMBER"], SITE_ID, strlen($arResult["COUNTER_TYPE"]) > 0 ? $arResult["COUNTER_TYPE"] : "**"); } } else { $rsCurrentUser = CUser::GetByID($GLOBALS["USER"]->GetID()); if ($arCurrentUser = $rsCurrentUser->Fetch()) { $arResult["EmptyComment"] = array("AVATAR_SRC" => CSocNetLogTools::FormatEvent_CreateAvatar($arCurrentUser, $arParams, ""), "AUTHOR_NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arCurrentUser, $bUseLogin)); } } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") { $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $GLOBALS["USER"]->GetID(), "CODE" => "**"), array("TYPE")); if ($arFollow = $rsFollow->Fetch()) { $arResult["FOLLOW_DEFAULT"] = $arFollow["TYPE"]; } else {
define("NOT_CHECK_PERMISSIONS", true); define("PUBLIC_AJAX_MODE", true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/bx_root.php"; $cuid = IntVal($_REQUEST["cuid"]); $site_id = isset($_REQUEST["site"]) && is_string($_REQUEST["site"]) ? trim($_REQUEST["site"]) : ""; if (isset($_REQUEST["is"])) { $ImageSize = intval($_REQUEST["is"]); } else { $ImageSize = 0; } if ($ImageSize <= 0) { $ImageSize = 42; } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; if ($GLOBALS["USER"]->IsAuthorized()) { $log_cnt = CUserCounter::GetValueByUserID($GLOBALS["USER"]->GetID(), $site); } if ($CACHE_MANAGER->Read(86400 * 30, "socnet_cm_" . $cuid) && $CACHE_MANAGER->Read(86400 * 30, "socnet_cf_" . $cuid) && $CACHE_MANAGER->Read(86400 * 30, "socnet_cg_" . $cuid)) { if (intval($log_cnt) > 0) { $arData = array(array("LOG_CNT" => $log_cnt)); echo CUtil::PhpToJSObject($arData); define('PUBLIC_AJAX_MODE', true); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php"; die; } $rsSites = CSite::GetByID($site); if ($arSite = $rsSites->Fetch()) { $DateTimeFormat = $arSite["FORMAT_DATETIME"]; __IncludeLang(dirname(__FILE__) . "/lang/" . $arSite["LANGUAGE_ID"] . "/get_message_2.php"); } else {
return; else define("IM_COMPONENT_INIT", true); if (intval($USER->GetID()) <= 0) return; if (!CModule::IncludeModule('im')) return; $arParams["DESKTOP"] = isset($arParams['DESKTOP']) && $arParams['DESKTOP'] == 'Y'? 'Y': 'N'; $arResult = Array(); // Counters $arResult["COUNTERS"] = CUserCounter::GetValues($USER->GetID(), SITE_ID); CIMContactList::SetOnline(null, true); if ($arParams['DESKTOP'] == 'Y') { $GLOBALS["APPLICATION"]->SetPageProperty("BodyClass", "im-desktop"); CIMMessenger::SetDesktopStatusOnline(); } $arParams["INIT"] = 'Y'; $arParams["DESKTOP_LINK_OPEN"] = 'N'; // Exchange $arResult["PATH_TO_USER_MAIL"] = ""; $arResult["MAIL_COUNTER"] = 0;
} } } } } foreach ($arTmpEventsNew as $arTmpEvent) { if (!is_array($_SESSION["SONET_LOG_ID"]) || !in_array($arTmpEvent["EVENT"]["ID"], $_SESSION["SONET_LOG_ID"])) { $_SESSION["SONET_LOG_ID"][] = $arTmpEvent["EVENT"]["ID"]; } $arResult["EventsNew"][] = $arTmpEvent; } if ($arTmpEvent["EVENT"]["DATE_FOLLOW"]) { $dateLastPage = ConvertTimeStamp(MakeTimeStamp($arTmpEvent["EVENT"]["DATE_FOLLOW"], CSite::GetDateFormat("FULL")), "FULL"); } $arResult["WORKGROUPS_PAGE"] = COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID); if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y") { CUserCounter::ClearByUser($GLOBALS["USER"]->GetID(), SITE_ID, $arResult["COUNTER_TYPE"]); CUserCounter::ClearByUser($GLOBALS["USER"]->GetID(), "**", $arResult["COUNTER_TYPE"]); } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y" && $dateLastPage) { CSocNetLogPages::Set($GLOBALS["USER"]->GetID(), $dateLastPage, $arParams["PAGE_SIZE"], $arResult["PAGE_NUMBER"], SITE_ID); } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") { $rsFollow = CSocNetLogFollow::GetList(array("USER_ID" => $GLOBALS["USER"]->GetID(), "CODE" => "**"), array("TYPE")); if ($arFollow = $rsFollow->Fetch()) { $arResult["FOLLOW_DEFAULT"] = $arFollow["TYPE"]; } else { $arResult["FOLLOW_DEFAULT"] = COption::GetOptionString("socialnetwork", "follow_default_type", "Y"); } } $this->IncludeComponentTemplate();
} $arResult["WORKGROUPS_PAGE"] = $folderWorkgroups; if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y") { $arCounters = CUserCounter::GetValues($user_id, SITE_ID); if (isset($arCounters[$arResult["COUNTER_TYPE"]])) { $arResult["LOG_COUNTER"] = intval($arCounters[$arResult["COUNTER_TYPE"]]); } else { $bEmptyCounter = true; $arResult["LOG_COUNTER"] = 0; } } else { $arParams["SHOW_UNREAD"] = "N"; } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y" && (intval($arResult["LOG_COUNTER"]) > 0 || $bEmptyCounter)) { CUserCounter::ClearByUser($user_id, array(SITE_ID, "**"), $arResult["COUNTER_TYPE"], true); CUserCounter::ClearByUser($user_id, SITE_ID, "BLOG_POST_IMPORTANT"); } if ($GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y" && $dateLastPage && (!$dateLastPageStart || $dateLastPageStart != $dateLastPage || $bNeedSetLogPage)) { $groupCode = strlen($arResult["COUNTER_TYPE"]) > 0 ? $arResult["COUNTER_TYPE"] : "**"; $bNeedSetTraffic = CSocNetLogComponent::isSetTrafficNeeded(array("PAGE_NUMBER" => $arResult["PAGE_NUMBER"], "GROUP_CODE" => $groupCode, "TRAFFIC_LAST_DATE_TS" => $arLastPageStart['TRAFFIC_LAST_DATE_TS'])); CSocNetLogPages::Set($user_id, $dateLastPage, $arParams["PAGE_SIZE"], $arResult["PAGE_NUMBER"], SITE_ID, $groupCode, $bNeedSetTraffic ? ($arLastPageStart['TRAFFIC_AVG'] + $dateFirstPageTS - $arResult["dateLastPageTS"]) / ($arLastPageStart['TRAFFIC_CNT'] + 1) : false, $bNeedSetTraffic ? $arLastPageStart['TRAFFIC_CNT'] + 1 : false); } } else { $arResult["NEED_AUTH"] = "Y"; } if (!isset($arResult["FatalError"]) && $GLOBALS["USER"]->IsAuthorized() && !$arResult["AJAX_CALL"]) { $cache = new CPHPCache(); $cache_id = "log_form_comments" . serialize($arParams["COMMENT_PROPERTY"]); $cache_path = "/sonet/log_form/comments"; if (defined("BX_COMP_MANAGED_CACHE")) { $ttl = 2592000;
$arUnread[$data['senderId']]['USER'] = $arMessage['users'][$data['senderId']]; } foreach ($arUnread as $userId => $data) { $arData[$userId] = $data; } uasort($arData, create_function('$a, $b', 'if($a["MESSAGE"]["date"] < $b["MESSAGE"]["date"] ) return 1; elseif($a["MESSAGE"]["date"] > $b["MESSAGE"]["date"] ) return -1; else return 0;')); $arResult['COUNTER_UNREAD_MESSAGES'] = $arData; } if (CModule::IncludeModule('pull')) { $arChannel = CPullChannel::Get($USER->GetId()); if (is_array($arChannel)) { $arResult['PULL_CONFIG'] = array('CHANNEL_ID' => $arChannel['CHANNEL_ID'], 'LAST_ID' => $arChannel['LAST_ID'], 'PATH' => $arChannel['PATH'], 'PATH_WS' => $arChannel['PATH_WS'], 'METHOD' => $arChannel['METHOD'], 'ERROR' => ''); } } // Counters $arResult["COUNTERS"] = CUserCounter::GetValues($USER->GetID(), $_POST['SITE_ID']); $arResult["ERROR"] = $errorMessage; echo CUtil::PhpToJsObject($arResult); } else { if ($_POST['IM_NOTIFY_LOAD'] == 'Y') { $CIMNotify = new CIMNotify(); $arNotify = $CIMNotify->GetUnreadNotify(array('SPEED_CHECK' => 'N', 'USE_TIME_ZONE' => 'N')); if ($arNotify['result']) { $arSend['NOTIFY'] = $arNotify['notify']; $arSend['UNREAD_NOTIFY'] = $arNotify['unreadNotify']; $arSend['FLASH_NOTIFY'] = CIMNotify::GetFlashNotify($arNotify['unreadNotify']); $arSend['ERROR'] = ''; if ($arNotify['maxNotify'] > 0) { $CIMNotify->MarkNotifyRead($arNotify['maxNotify'], true); } }
$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();
public static function SetUnreadCounter($userId) { return false; global $DB; $userId = intval($userId); if ($userId <= 0) return false; $sqlCounter = "SELECT COUNT(M.ID) as CNT FROM b_im_message M INNER JOIN b_im_relation R1 ON M.ID > R1.LAST_ID AND M.CHAT_ID = R1.CHAT_ID AND R1.USER_ID != M.AUTHOR_ID WHERE R1.USER_ID = ".$userId." AND R1.MESSAGE_TYPE = '".IM_MESSAGE_PRIVATE."' AND R1.STATUS < ".IM_STATUS_READ; $dbRes = $DB->Query($sqlCounter, false, "File: ".__FILE__."<br>Line: ".__LINE__); if ($row = $dbRes->Fetch()) CUserCounter::Set($userId, 'im_message_v2', $row['CNT'], '**', false); else CUserCounter::Set($userId, 'im_message_v2', 0, '**', false); return true; }
public function Synchronize() { $currentDay = time() + CTimeZone::GetOffset(); $currentDayEnd = ConvertTimeStamp(mktime(23, 59, 59, date('n', $currentDay), date('j', $currentDay), date('Y', $currentDay)), 'FULL', SITE_ID); $count = 0; if ($this->typeID === self::CurrentActivies) { //Count of open user activities (start time: before tomorrow) $filter = array('RESPONSIBLE_ID' => $this->userID, 'COMPLETED' => 'N', '<=START_TIME' => $currentDayEnd); $count = CCrmActivity::GetCount($filter); } elseif ($this->typeID === self::CurrentCompanyActivies) { $count = CCrmActivity::GetCurrentQuantity($this->userID, CCrmOwnerType::Company); } elseif ($this->typeID === self::CurrentContactActivies) { $count = CCrmActivity::GetCurrentQuantity($this->userID, CCrmOwnerType::Contact); } elseif ($this->typeID === self::CurrentLeadActivies) { $count = CCrmActivity::GetCurrentQuantity($this->userID, CCrmOwnerType::Lead); if (CCrmUserCounterSettings::GetValue(CCrmUserCounterSettings::ReckonActivitylessItems, true)) { $leadTable = CCrmLead::TABLE_NAME; $activityTable = CCrmActivity::USER_ACTIVITY_TABLE_NAME; $statusStr = "'CONVERTED'"; $statusCount = 1; $statuses = self::GetStatusList('STATUS'); $isFound = false; foreach ($statuses as &$status) { if (!$isFound) { $isFound = $status['STATUS_ID'] === 'CONVERTED'; } else { $statusStr .= ",'{$status['STATUS_ID']}'"; $statusCount++; // Foolproof if ($statusCount === 10) { break; } } } unset($status); global $DBType; $sqlData = array('FROM' => '', 'WHERE' => "l.ASSIGNED_BY_ID = {$this->userID} AND l.STATUS_ID NOT IN({$statusStr}) AND l.ID NOT IN(SELECT a.OWNER_ID FROM {$activityTable} a WHERE a.USER_ID = 0 AND a.OWNER_TYPE_ID = 1)", 'GROUPBY' => ''); $count += CSqlUtil::GetRowCount($sqlData, $leadTable, 'l', $DBType); } } elseif ($this->typeID === self::CurrentDealActivies) { $count = CCrmActivity::GetCurrentQuantity($this->userID, CCrmOwnerType::Deal); if (CCrmUserCounterSettings::GetValue(CCrmUserCounterSettings::ReckonActivitylessItems, true)) { $dealTable = CCrmDeal::TABLE_NAME; $activityTable = CCrmActivity::USER_ACTIVITY_TABLE_NAME; $stageStr = "'WON'"; $stageCount = 1; $stages = self::GetStatusList('DEAL_STAGE'); $isFound = false; foreach ($stages as &$stage) { if (!$isFound) { $isFound = $stage['STATUS_ID'] === 'WON'; } else { $stageStr .= ",'{$stage['STATUS_ID']}'"; $stageCount++; // Foolproof if ($stageCount === 10) { break; } } } unset($stage); global $DB; $dbResult = $DB->Query("SELECT COUNT(d.ID) AS CNT FROM {$dealTable} d WHERE d.ASSIGNED_BY_ID = {$this->userID} AND d.STAGE_ID NOT IN({$stageStr}) AND d.ID NOT IN(SELECT a.OWNER_ID FROM {$activityTable} a WHERE a.USER_ID = 0 AND a.OWNER_TYPE_ID = 2)", false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__); $result = $dbResult->Fetch(); $count += is_array($result) ? intval($result['CNT']) : 0; } } elseif ($this->typeID === self::CurrentQuoteActivies) { $count = 0; if (CCrmUserCounterSettings::GetValue(CCrmUserCounterSettings::ReckonActivitylessItems, true)) { $quoteTable = CCrmQuote::TABLE_NAME; $statusStr = "'APPROVED'"; $statusCount = 1; $statuses = self::GetStatusList('QUOTE_STATUS'); $isFound = false; foreach ($statuses as &$status) { if (!$isFound) { $isFound = $status['STATUS_ID'] === 'APPROVED'; } else { $statusStr .= ",'{$status['STATUS_ID']}'"; $statusCount++; // Foolproof if ($statusCount === 10) { break; } } } unset($status); global $DB; $currentDay = time() + CTimeZone::GetOffset(); $currentDayEnd = ConvertTimeStamp(mktime(23, 59, 59, date('n', $currentDay), date('j', $currentDay), date('Y', $currentDay)), 'FULL', SITE_ID); $currentDayEnd = $DB->CharToDateFunction($DB->ForSql($currentDayEnd), 'FULL'); $dbResult = $DB->Query("SELECT COUNT(q.ID) AS CNT FROM {$quoteTable} q WHERE q.ASSIGNED_BY_ID = {$this->userID} AND q.CLOSEDATE IS NOT NULL AND q.CLOSEDATE <= {$currentDayEnd} AND q.STATUS_ID NOT IN ({$statusStr})", false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__); $result = $dbResult->Fetch(); $count += is_array($result) ? intval($result['CNT']) : 0; } } if ($this->curValue !== $count) { $this->curValue = $count; if ($this->code !== '') { CUserCounter::Set($this->userID, $this->code, $this->curValue, SITE_ID, '', false); } } $this->RefreshLastCalculatedTime(); return $this->curValue; }
public static function IncrementWithSelect($sub_select) { global $DB, $CACHE_MANAGER; if (strlen($sub_select) > 0) { $strSQL = "\n\t\t\t\tINSERT INTO b_user_counter (USER_ID, CNT, SITE_ID, CODE) (" . $sub_select . ")\n\t\t\t\tON DUPLICATE KEY UPDATE CNT = CNT + 1\n\t\t\t"; $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); self::$counters = false; $CACHE_MANAGER->CleanDir("user_counter"); } }
$userId = PULL_USER_ID; } if (check_bitrix_sessid()) { if ($_POST['PULL_GET_CHANNEL'] == 'Y') { session_write_close(); $arConfig = CPullChannel::GetConfig($userId, $_POST['CACHE'] == 'Y', $_POST['CACHE'] == 'Y' ? false : true, $_POST['MOBILE'] == 'Y'); if (is_array($arConfig)) { echo CUtil::PhpToJsObject($arConfig); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'ERROR_OPEN_CHANNEL')); } } elseif ($_POST['PULL_UPDATE_WATCH'] == 'Y') { foreach ($_POST['WATCH'] as $tag) { CPullWatch::Extend($userId, $tag); } echo CUtil::PhpToJsObject(array('ERROR' => '')); } elseif ($_POST['PULL_UPDATE_STATE'] == 'Y') { $arMessage = CPullStack::Get($_POST['CHANNEL_ID'], intval($_POST['CHANNEL_LAST_ID'])); $arResult["COUNTERS"] = CUserCounter::GetAllValues($userId); if (!empty($arResult["COUNTERS"])) { $arMessage[] = array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arResult["COUNTERS"]); } echo CUtil::PhpToJsObject(array('MESSAGE' => $arMessage, 'ERROR' => '')); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR')); } } else { echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR')); } CMain::FinalActions(); die;
public static function SetUnreadCounter($userId) { return false; $userId = intval($userId); if ($userId <= 0) { return false; } global $DB; $sqlCounter = "SELECT COUNT(M.ID) as CNT\n\t\t\t\t\t\tFROM b_im_message M\n\t\t\t\t\t\tINNER JOIN b_im_relation R1 ON M.ID > R1.LAST_ID AND M.CHAT_ID = R1.CHAT_ID AND R1.MESSAGE_TYPE IN ('" . IM_MESSAGE_OPEN . "','" . IM_MESSAGE_CHAT . "') AND R1.STATUS < " . IM_STATUS_READ . "\n\t\t\t\t\t\tWHERE R1.USER_ID = " . $userId; $dbRes = $DB->Query($sqlCounter, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($row = $dbRes->Fetch()) { CUserCounter::Set($userId, 'im_chat_v2', $row['CNT'], '**', false); } else { CUserCounter::Set($userId, 'im_chat_v2', 0, '**', false); } return true; }
public static function CounterIncrement($arLogFields) { CUserCounter::IncrementWithSelect(CCrmLiveFeed::GetSubSelect($arLogFields)); }
function SendEvent($ID, $mailTemplate = "SONET_NEW_EVENT") { $ID = IntVal($ID); if ($ID <= 0) { return false; } $arFilter = array("ID" => $ID); $dbLogComments = CSocNetLogComments::GetList(array(), $arFilter, false, false, array("ID", "LOG_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "EVENT_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "GROUP_NAME", "CREATED_BY_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_LOGIN", "LOG_SITE_ID", "SOURCE_ID", "LOG_SOURCE_ID")); $arLogComment = $dbLogComments->Fetch(); if (!$arLogComment) { return false; } $arLog = array(); if (intval($arLogComment["LOG_ID"]) > 0) { $dbLog = CSocNetLog::GetList(array(), array("ID" => $arLogComment["LOG_ID"])); $arLog = $dbLog->Fetch(); if (!$arLog) { $arLog = array(); } } $arEvent = CSocNetLogTools::FindLogCommentEventByID($arLogComment["EVENT_ID"]); if ($arEvent && array_key_exists("CLASS_FORMAT", $arEvent) && array_key_exists("METHOD_FORMAT", $arEvent) && strlen($arEvent["CLASS_FORMAT"]) > 0 && strlen($arEvent["METHOD_FORMAT"]) > 0) { $dbSiteCurrent = CSite::GetByID(SITE_ID); if ($arSiteCurrent = $dbSiteCurrent->Fetch()) { if ($arSiteCurrent["LANGUAGE_ID"] != LANGUAGE_ID) { $arLogComment["MAIL_LANGUAGE_ID"] = $arSiteCurrent["LANGUAGE_ID"]; } } $arLogComment["FIELDS_FORMATTED"] = call_user_func(array($arEvent["CLASS_FORMAT"], $arEvent["METHOD_FORMAT"]), $arLogComment, array(), true, $arLog); } if (array_key_exists($arLogComment["ENTITY_TYPE"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"]) && array_key_exists("HAS_MY", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["HAS_MY"] == "Y" && array_key_exists("CLASS_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && array_key_exists("METHOD_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]) && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"]) > 0 && strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]) > 0 && method_exists($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"])) { $arOfEntities = call_user_func(array($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLogComment["ENTITY_TYPE"]]["METHOD_OF"]), $arLogComment["ENTITY_ID"]); } $arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => array("M", "X")); $arLogSites = array(); $rsLogSite = CSocNetLog::GetSite($arLog["ID"]); while ($arLogSite = $rsLogSite->Fetch()) { $arLogSites[] = $arLogSite["LID"]; } if (CModule::IncludeModule("extranet")) { if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP) { $arSites = array(); $dbSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($arSite = $dbSite->Fetch()) { $arSites[$arSite["ID"]] = array("DIR" => strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/", "SERVER_NAME" => strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"])); } $intranet_site_id = CSite::GetDefSite(); } $arIntranetUsers = CExtranet::GetIntranetUsers(); $extranet_site_id = CExtranet::GetExtranetSiteID(); } $dbSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_LID", "USER_EMAIL", "TRANSPORT"), $arListParams); $arListParams = array("USE_SUBSCRIBE" => "Y", "ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => $arLogComment["EVENT_ID"], "USER_ID" => $arLogComment["USER_ID"], "OF_ENTITIES" => $arOfEntities, "TRANSPORT" => "N"); $dbUnSubscribers = CSocNetLogEvents::GetList(array("TRANSPORT" => "DESC"), array("USER_ACTIVE" => "Y", "SITE_ID" => array_merge($arLogSites, array(false))), false, false, array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "TRANSPORT", "EVENT_ID"), $arListParams); $arUnSubscribers = array(); while ($arUnSubscriber = $dbUnSubscribers->Fetch()) { $arUnSubscribers[] = $arUnSubscriber["USER_ID"] . "_" . $arUnSubscriber["ENTITY_TYPE"] . "_" . $arUnSubscriber["ENTITY_ID"] . "_" . $arUnSubscriber["ENTITY_MY"] . "_" . $arUnSubscriber["ENTITY_CB"] . "_" . $arUnSubscriber["EVENT_ID"]; } $bHasAccessAll = CSocNetLogRights::CheckForUserAll($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"]); $arSentUserID = array("M" => array(), "X" => array()); while ($arSubscriber = $dbSubscribers->Fetch()) { if (is_array($arIntranetUsers) && !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && !in_array($extranet_site_id, $arLogSites)) { continue; } if (array_key_exists($arSubscriber["TRANSPORT"], $arSentUserID) && in_array($arSubscriber["USER_ID"], $arSentUserID[$arSubscriber["TRANSPORT"]])) { continue; } if (intval($arSubscriber["ENTITY_ID"]) != 0 && $arSubscriber["EVENT_ID"] == "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_N_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arSubscriber["ENTITY_ID"] . "_Y_" . $arSubscriber["ENTITY_CB"] . "_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) { continue; } elseif (intval($arSubscriber["ENTITY_ID"]) == 0 && $arSubscriber["ENTITY_CB"] == "N" && $arSubscriber["EVENT_ID"] != "all" && (in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_all", $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_Y_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers) || in_array($arSubscriber["USER_ID"] . "_" . $arSubscriber["ENTITY_TYPE"] . "_" . $arLogComment["ENTITY_ID"] . "_N_N_" . $arLogComment["EVENT_ID"], $arUnSubscribers))) { continue; } $arSentUserID[$arSubscriber["TRANSPORT"]][] = $arSubscriber["USER_ID"]; if (!$bHasAccessAll) { $bHasAccess = CSocNetLogRights::CheckForUserOnly($arLog["ID"] ? $arLog["ID"] : $arLogComment["LOG_ID"], $arSubscriber["USER_ID"]); if (!$bHasAccess) { continue; } } if ($arLogComment["ENTITY_TYPE"] == SONET_ENTITY_GROUP && is_array($arIntranetUsers) && CModule::IncludeModule("extranet")) { $server_name = $arSites[!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id]["SERVER_NAME"]; $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = str_replace(array("#SERVER_NAME#", "#GROUPS_PATH#"), array($server_name, COption::GetOptionString("socialnetwork", "workgroups_page", false, !in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id ? $extranet_site_id : $intranet_site_id)), $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]); } else { $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]; } switch ($arSubscriber["TRANSPORT"]) { case "X": if (array_key_exists("URL_TO_SEND", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && strlen($arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0) { $link = GetMessage("SONET_GLC_SEND_EVENT_LINK") . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]; } else { $link = ""; } $arMessageFields = array("FROM_USER_ID" => intval($arLogComment["USER_ID"]) > 0 ? $arLogComment["USER_ID"] : 1, "TO_USER_ID" => $arSubscriber["USER_ID"], "MESSAGE" => $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"] . " #BR# " . $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] . (strlen($link) > 0 ? "#BR# " . $link : ""), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "IS_LOG" => "Y"); CSocNetMessages::Add($arMessageFields); break; case "M": $arFields["SUBSCRIBER_ID"] = $arSubscriber["USER_ID"]; $arFields["SUBSCRIBER_NAME"] = $arSubscriber["USER_NAME"]; $arFields["SUBSCRIBER_LAST_NAME"] = $arSubscriber["USER_LAST_NAME"]; $arFields["SUBSCRIBER_LOGIN"] = $arSubscriber["USER_LOGIN"]; $arFields["SUBSCRIBER_EMAIL"] = $arSubscriber["USER_EMAIL"]; $arFields["EMAIL_TO"] = $arSubscriber["USER_EMAIL"]; $arFields["TITLE"] = str_replace("#BR#", "\n", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]); $arFields["MESSAGE"] = str_replace("#BR#", "\n", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]); $arFields["ENTITY"] = $arLogComment["FIELDS_FORMATTED"]["ENTITY"]["FORMATTED"]; $arFields["ENTITY_TYPE"] = $arLogComment["FIELDS_FORMATTED"]["ENTITY"]["TYPE_MAIL"]; if (array_key_exists("URL_TO_SEND", $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && strlen($arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0) { $arFields["URL"] = $arLogComment["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]; } else { $arFields["URL"] = $arLogComment["URL"]; } if (CModule::IncludeModule("extranet")) { $arUserGroup = CUser::GetUserGroup($arSubscriber["USER_ID"]); } foreach ($arLogSites as $site_id_tmp) { if (IsModuleInstalled("extranet")) { if (CExtranet::IsExtranetSite($site_id_tmp) && in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup) || !CExtranet::IsExtranetSite($site_id_tmp) && !in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)) { $siteID = $site_id_tmp; break; } else { continue; } } else { $siteID = $site_id_tmp; break; } } if (!$siteID) { $siteID = defined("SITE_ID") ? SITE_ID : $arSubscriber["SITE_ID"]; } if (StrLen($siteID) <= 0) { $siteID = $arSubscriber["USER_LID"]; } if (StrLen($siteID) <= 0) { continue; } $event = new CEvent(); $event->Send($mailTemplate, $siteID, $arFields, "N"); break; default: } } CUserCounter::IncrementWithSelect(CSocNetLogCounter::GetSubSelect($arLog["ID"], $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $arLogComment["EVENT_ID"], $arLogComment["USER_ID"], $arOfEntities, false, false, "Y", "LC")); return true; }
} else echo CUtil::PhpToJsObject(Array('ERROR' => 'ERROR_OPEN_CHANNEL')); } elseif ($_POST['PULL_UPDATE_WATCH'] == 'Y') { foreach ($_POST['WATCH'] as $tag) CPullWatch::Extend($USER->GetID(), $tag); echo CUtil::PhpToJsObject(Array('ERROR' => '')); } elseif ($_POST['PULL_UPDATE_STATE'] == 'Y') { $arMessage = CPullStack::Get($_POST['CHANNEL_ID'], intval($_POST['CHANNEL_LAST_ID'])); $arResult["COUNTERS"] = CUserCounter::GetAllValues($USER->GetID()); if (!empty($arResult["COUNTERS"])) { $arMessage[] = Array( 'module_id' => 'main', 'command' => 'user_counter', 'params' => $arResult["COUNTERS"] ); } echo CUtil::PhpToJsObject(Array('MESSAGE' => $arMessage, 'ERROR' => '')); } else { echo CUtil::PhpToJsObject(Array('ERROR' => 'UNKNOWN_ERROR')); } }
public static function CounterIncrement($log_id, $event_id = false, $arOfEntities = false, $type = "L") { if (intval($log_id) <= 0) return false; CUserCounter::IncrementWithSelect( CSocNetLogCounter::GetSubSelect( $log_id, false, false, false, false, $arOfEntities, false, false, "Y", $type ) ); if ($event_id == "blog_post_important") { CUserCounter::IncrementWithSelect( CSocNetLogCounter::GetSubSelect( $log_id, false, false, false, false, $arOfEntities, false, false, "Y", "L", array("CODE" => "'BLOG_POST_IMPORTANT'") ) ); } }
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); } } }
/** * 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(); } }
$arParams["SHOW_UNREAD"] = "N"; if ( $GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_COUNTER"] == "Y" && (intval($arResult["LOG_COUNTER"]) > 0 || $bEmptyCounter) ) { CUserCounter::ClearByUser( $GLOBALS["USER"]->GetID(), array(SITE_ID, "**"), $arResult["COUNTER_TYPE"] ); CUserCounter::ClearByUser( $GLOBALS["USER"]->GetID(), SITE_ID, "BLOG_POST_IMPORTANT" ); } if ( $GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y" && $dateLastPage && ( !$dateLastPageStart || $dateLastPageStart != $dateLastPage || $bNeedSetLogPage ) ) {