Пример #1
0
 private static function PrepereFields($params)
 {
     $arValues = array();
     $arFields = IM\StatusTable::getMap();
     foreach ($params as $key => $value) {
         if (!isset($arFields[$key])) {
             continue;
         }
         if ($key == 'STATUS') {
             $arValues[$key] = in_array($value, self::$AVAILABLE_STATUSES) ? $value : 'online';
         } else {
             $arValues[$key] = $value;
         }
     }
     return $arValues;
 }
Пример #2
0
 public function handleStatusBindOperation($event, $nodeFrom, $nodeTo)
 {
     if (isset($event["guid"])) {
         $userId = \Bitrix\Replica\Client\User::getId($event["guid"]);
         if ($userId > 0) {
             \Bitrix\Replica\Mapper::getInstance()->add("b_im_status.USER_ID", $userId, $nodeFrom, $event["guid"]);
             $res = \Bitrix\Im\StatusTable::getById($userId);
             if ($res->fetch()) {
                 //Insert operation
                 \Bitrix\Replica\Db\Operation::writeInsert("b_im_status", $this->getPrimary(), array("USER_ID" => $userId));
             }
         }
     }
 }
Пример #3
0
 /**
  * Registers b_im_status record in the replication map
  * and sends the record back as an update operation.
  *
  * @param array $event Event made by OnAfterRecentAdd method.
  * @param string $nodeFrom Source database.
  * @param string $nodeTo Target database.
  *
  * @return void
  * @see \Bitrix\Im\Replica\StatusHandler::OnAfterRecentAdd
  */
 public function handleStatusRebindOperation($event, $nodeFrom, $nodeTo)
 {
     if (!isset($event["guid"])) {
         return;
     }
     list($userGuid, ) = explode('@', $event["guid"]);
     $userId = \Bitrix\Replica\Client\User::getLocalUserId($userGuid);
     if (!$userId) {
         return;
     }
     \Bitrix\Replica\Mapper::getInstance()->add("b_im_status.USER_ID", $userId, $nodeFrom, $event["guid"]);
     $res = \Bitrix\Im\StatusTable::getById($userId);
     if ($res->fetch()) {
         //Update operation
         \Bitrix\Replica\Db\Operation::writeUpdate("b_im_status", $this->getPrimary(), array("USER_ID" => $userId));
     }
 }