Example #1
0
 public static function OnBeforeProlog()
 {
     if (!$GLOBALS["USER"]->IsAuthorized()) {
         return;
     }
     CUser::SetLastActivityDate($GLOBALS["USER"]->GetID());
 }
Example #2
0
	public static function SetOnline($userId = null, $cache = false)
	{
		global $USER;

		if (is_null($userId))
			$userId = $USER->GetId();

		$userId = intval($userId);
		if ($userId <= 0)
			return false;

		if ($cache && $userId == $USER->GetId())
		{
			if (isset($_SESSION['USER_LAST_ONLINE_'.$userId]) && intval($_SESSION['USER_LAST_ONLINE_'.$userId])+60 > time())
				return false;

			$_SESSION['USER_LAST_ONLINE_'.$userId] = time();
		}

		CUser::SetLastActivityDate($userId);

		return true;
	}
Example #3
0
File: init.php Project: kudin/crm
function CustomSetLastActivityDate()
{
    global $USER;
    CUser::SetLastActivityDate($USER->GetID());
}
Example #4
0
 private function __ReportKernel()
 {
     foreach ($this->arClientsIndex as $clientDomain => $arDomainClientsIndex) {
         if (!CXMPPUtility::SelectDatabase($clientDomain)) {
             continue;
         }
         if (count($arDomainClientsIndex) <= 0) {
             continue;
         }
         foreach ($arDomainClientsIndex as $jid => $arId) {
             foreach ($arId as $id) {
                 if (array_key_exists($id, $this->arClients)) {
                     if ($this->arClients[$id]->IsConnected() && $this->arClients[$id]->IsAuthenticated()) {
                         $idTmp = $this->arClients[$id]->GetId();
                         CUser::SetLastActivityDate($idTmp);
                         CXMPPClient::SetLastActivityDate($idTmp);
                     }
                 }
             }
         }
         $arOnlineOnSiteTmp = array();
         $dbUsers = CUser::GetList($b = "LOGIN", $o = "DESC", array("ACTIVE" => "Y", "LAST_ACTIVITY" => 600, "!UF_DEPARTMENT" => false), array('FIELDS' => array('ID', 'LOGIN')));
         while ($arUser = $dbUsers->Fetch()) {
             $arOnlineOnSiteTmp[] = CXMPPUtility::GetJId($arUser, $clientDomain);
         }
         if (!is_array($this->arOnlineOnSite[$clientDomain])) {
             $this->arOnlineOnSite[$clientDomain] = array();
         }
         $arOffline = array_diff($this->arOnlineOnSite[$clientDomain], $arOnlineOnSiteTmp);
         foreach ($arOffline as $jid) {
             if (!array_key_exists($jid, $this->arClientsIndex[$clientDomain]) || array_key_exists($jid, $this->arClientsIndex[$clientDomain]) && count($this->arClientsIndex[$clientDomain][$jid]) <= 0) {
                 $this->SendAll(array("presence" => array("." => array("type" => "unavailable", "from" => $jid))));
             }
         }
         $arOnline = array_diff($arOnlineOnSiteTmp, $this->arOnlineOnSite[$clientDomain]);
         foreach ($arOnline as $jid) {
             if (!array_key_exists($jid, $this->arClientsIndex[$clientDomain]) || array_key_exists($jid, $this->arClientsIndex[$clientDomain]) && count($this->arClientsIndex[$clientDomain][$jid]) <= 0) {
                 $this->SendAll(array("presence" => array("." => array("from" => $jid))));
             }
         }
         $this->arOnlineOnSite[$clientDomain] = $arOnlineOnSiteTmp;
     }
 }
Example #5
0
 function CustomSetLastActivityDate()
 {
     if ($GLOBALS['USER']->IsAuthorized()) {
         CUser::SetLastActivityDate($GLOBALS['USER']->GetID());
     }
 }
Example #6
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!defined('PUBLIC_AJAX_MODE') && !IsModuleInstalled("im") && $GLOBALS["USER"]->IsAuthorized() && (!isset($_SESSION["USER_LAST_ONLINE"]) || intval($_SESSION["USER_LAST_ONLINE"]) + 60 <= time())) {
    $_SESSION["USER_LAST_ONLINE"] = time();
    CUser::SetLastActivityDate($GLOBALS["USER"]->GetID());
}
Example #7
0
 public function ReceiveMessage($senderJId, array $arMessage, CXMPPClient $senderClient)
 {
     if (!$senderClient->IsAuthenticated()) {
         return false;
     }
     if (strlen($senderJId) <= 0) {
         return false;
     }
     if (!array_key_exists("presence", $arMessage) || !array_key_exists(".", $arMessage["presence"])) {
         return false;
     }
     $type = "available";
     if (array_key_exists("type", $arMessage["presence"]["."])) {
         $type = $arMessage["presence"]["."]["type"];
     }
     if ($type == "error") {
         return false;
     }
     // available (empty) - Signals that the sender is online and available for communication.
     // unavailable - Signals that the sender is no longer available for communication.
     // subscribe - The sender wishes to subscribe to the recipient's presence.
     // subscribed - The sender has allowed the recipient to receive their presence.
     // unsubscribe - The sender is unsubscribing from another entity's presence.
     // unsubscribed - The subscription request has been denied or a previously-granted subscription has been cancelled.
     // probe - A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
     // error - An error has occurred regarding processing or delivery of a previously-sent presence stanza.
     if (!in_array($type, array("available", "unavailable", "subscribe", "subscribed", "unsubscribe", "unsubscribed", "probe"))) {
         return CXMPPUtility::GetErrorArray($senderJId, "presence", "modify", "bad-request", "", "", "", $senderClient->GetClientDomain());
     }
     $to = "";
     if (array_key_exists("to", $arMessage["presence"]["."])) {
         $to = $arMessage["presence"]["."]["to"];
     }
     $server = CXMPPServer::GetServer();
     if (strlen($to) <= 0) {
         $server->SendAll($arMessage, $senderClient->GetClientDomain());
     } else {
         $server->Send($to, $arMessage, $senderClient->GetClientDomain());
     }
     if (!in_array($type, array("available"))) {
         return true;
     }
     $userJId = $senderJId;
     $show = "online";
     if (array_key_exists("show", $arMessage["presence"])) {
         $show = $arMessage["presence"]["show"]["#"];
     }
     $status = "";
     if (array_key_exists("status", $arMessage["presence"])) {
         $status = $arMessage["presence"]["status"]["#"];
     }
     $priority = 0;
     if (array_key_exists("priority", $arMessage["presence"])) {
         $priority = intval($arMessage["presence"]["priority"]["#"]);
     }
     $arUser = CXMPPUtility::GetUserByJId($userJId);
     if (!$arUser) {
         return CXMPPUtility::GetErrorArray($senderJId, "presence", "auth", "forbidden", "", "", "", $senderClient->GetClientDomain());
     }
     CUser::SetLastActivityDate($arUser["ID"]);
     CXMPPFactory::SendUnreadMessages($senderJId, $senderClient->GetClientDomain());
     $senderClient->ChangeWorkPresence("Status", $show);
     return true;
 }