当前位置: 首页>>代码示例>>PHP>>正文


PHP CPullStack::AddByUsers方法代码示例

本文整理汇总了PHP中CPullStack::AddByUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP CPullStack::AddByUsers方法的具体用法?PHP CPullStack::AddByUsers怎么用?PHP CPullStack::AddByUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPullStack的用法示例。


在下文中一共展示了CPullStack::AddByUsers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onExecuteStartWriting

 function onExecuteStartWriting(\Bitrix\Main\Event $event)
 {
     $parameters = $event->getParameters();
     $userId = $parameters[0];
     $dialogId = $parameters[1] . $parameters[2];
     if ($userId > 0) {
         if (!\Bitrix\Main\Loader::includeModule('pull')) {
             return;
         }
         \CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
         if (intval($dialogId) > 0) {
             \CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
         } elseif (substr($dialogId, 0, 4) == 'chat') {
             $chatId = substr($dialogId, 4);
             $arRelation = \CIMChat::GetRelationById($chatId);
             unset($arRelation[$userId]);
             $pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId));
             \CPullStack::AddByUsers(array_keys($arRelation), $pullMessage);
             $orm = \Bitrix\Im\ChatTable::getById($chatId);
             $chat = $orm->fetch();
             if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
                 \CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage);
             }
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:26,代码来源:startwritinghandler.php

示例2: afterUpdateTrigger

 /**
  * Method will be invoked after an database record updated.
  *
  * @param array $oldRecord All fields before update.
  * @param array $newRecord All fields after update.
  *
  * @return void
  */
 public function afterUpdateTrigger(array $oldRecord, array $newRecord)
 {
     if (!\Bitrix\Main\Loader::includeModule('pull')) {
         return;
     }
     $arFields = \CIMMessenger::GetById($newRecord['ID'], array('WITH_FILES' => 'Y'));
     if (!$arFields) {
         return;
     }
     $arFields['DATE_MODIFY'] = time() + \CTimeZone::GetOffset();
     $CCTP = new \CTextParser();
     $CCTP->MaxStringLen = 200;
     $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
     $pullMessage = $CCTP->convertText(htmlspecialcharsbx($arFields['MESSAGE']));
     $relations = \CIMChat::GetRelationById($arFields['CHAT_ID']);
     $arPullMessage = array('id' => $arFields['ID'], 'type' => $arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE ? 'private' : 'chat', 'text' => $pullMessage, 'date' => $arFields['DATE_MODIFY']);
     if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) {
         $arFields['FROM_USER_ID'] = $arFields['AUTHOR_ID'];
         foreach ($relations as $rel) {
             if ($rel['USER_ID'] != $arFields['AUTHOR_ID']) {
                 $arFields['TO_USER_ID'] = $rel['USER_ID'];
             }
         }
         $arPullMessage['fromUserId'] = $arFields['FROM_USER_ID'];
         $arPullMessage['toUserId'] = $arFields['TO_USER_ID'];
     } else {
         $arPullMessage['chatId'] = $arFields['CHAT_ID'];
         $arPullMessage['senderId'] = $arFields['AUTHOR_ID'];
     }
     \CPullStack::AddByUsers(array_keys($relations), $p = array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     foreach ($relations as $rel) {
         $obCache = new \CPHPCache();
         $obCache->CleanDir('/bx/imc/recent' . \CIMMessenger::GetCachePath($rel['USER_ID']));
     }
     if ($newRecord['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) {
         \CPullWatch::AddToStack('IM_PUBLIC_' . $arFields['CHAT_ID'], array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     }
     foreach (\GetModuleEvents("im", "OnAfterMessagesUpdate", true) as $arEvent) {
         \ExecuteModuleEventEx($arEvent, array(intval($newRecord['ID']), $arFields));
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:49,代码来源:messagehandler.php

示例3: UploadAvatar

 public static function UploadAvatar($hash, &$file, &$package, &$upload, &$error)
 {
     $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray();
     $chatId = intval($post['CHAT_ID']);
     if ($chatId <= 0) {
         return false;
     }
     $chat = IM\ChatTable::getById($chatId)->fetch();
     if (!$chat) {
         return false;
     }
     $relationError = true;
     $chatRelation = CIMChat::GetRelationById($chatId);
     foreach ($chatRelation as $relation) {
         if ($relation['USER_ID'] == self::GetUserId()) {
             $relationError = false;
             break;
         }
     }
     if ($relationError) {
         $error = GetMessage('IM_DISK_ERR_AVATAR_1');
         return false;
     }
     $fileId = CFile::saveFile($file["files"]["default"], self::MODULE_ID);
     if ($fileId > 0) {
         if ($chat['AVATAR'] > 0) {
             CFile::DeLete($chat['AVATAR']);
         }
         IM\ChatTable::update($chatId, array('AVATAR' => $fileId));
         $file['chatId'] = $chatId;
         $file['chatAvatar'] = CIMChat::GetAvatarImage($fileId);
         if ($chat["ENTITY_TYPE"] != 'CALL') {
             CIMChat::AddSystemMessage(array('CHAT_ID' => $chatId, 'USER_ID' => self::GetUserId(), 'MESSAGE_CODE' => 'IM_DISK_AVATAR_CHANGE_'));
         }
         if (CModule::IncludeModule('pull')) {
             $pullMessage = array('module_id' => 'im', 'command' => 'chatAvatar', 'params' => array('chatId' => $chatId, 'chatAvatar' => $file['chatAvatar']));
             CPullStack::AddByUsers(array_keys($chatRelation), $pullMessage);
             $orm = \Bitrix\Im\ChatTable::getById($chatId);
             $chat = $orm->fetch();
             if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
                 CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage);
             }
         }
     } else {
         return false;
     }
     return true;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:48,代码来源:im_disk.php

示例4: DeleteUser

 public function DeleteUser($chatId, $userId, $checkPermission = true)
 {
     global $DB;
     $chatId = intval($chatId);
     $userId = intval($userId);
     if ($chatId <= 0 || $userId <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_USER_OR_CHAT"), "EMPTY_USER_OR_CHAT");
         return false;
     }
     $strSql = "\n\t\t\tSELECT R.CHAT_ID, C.TITLE CHAT_TITLE, C.AUTHOR_ID CHAT_AUTHOR_ID, C.EXTRANET CHAT_EXTRANET, C.TYPE CHAT_TYPE\n\t\t\tFROM b_im_relation R LEFT JOIN b_im_chat C ON R.CHAT_ID = C.ID\n\t\t\tWHERE R.USER_ID = " . $userId . " AND R.MESSAGE_TYPE IN ('" . IM_MESSAGE_OPEN . "','" . IM_MESSAGE_CHAT . "') AND R.CHAT_ID = " . $chatId;
     $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($arRes = $dbRes->Fetch()) {
         $arRes['CHAT_TYPE'] = trim($arRes['CHAT_TYPE']);
         $extranetFlag = $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false);
         $chatTitle = $arRes['CHAT_TITLE'];
         $chatType = $arRes['CHAT_TYPE'];
         $chatAuthorId = intval($arRes['CHAT_AUTHOR_ID']);
         if ($chatAuthorId == $userId) {
             $strSql = "\n\t\t\t\t\tSELECT R.USER_ID\n\t\t\t\t\tFROM b_im_relation R\n\t\t\t\t\tWHERE R.CHAT_ID = " . $chatId . " AND R.USER_ID <> " . $chatAuthorId;
             $strSql = $DB->TopSql($strSql, 1);
             $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             if ($arRes = $dbRes->Fetch()) {
                 $strSql = "UPDATE b_im_chat SET AUTHOR_ID = " . $arRes['USER_ID'] . " WHERE ID = " . $chatId;
                 $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             }
         }
         $bSelf = true;
         $arUsers = array($userId);
         if ($this->user_id != $userId) {
             if ($checkPermission && $chatAuthorId != $this->user_id) {
                 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_KICK"), "IM_ERROR_KICK");
                 return false;
             }
             $bSelf = false;
             $arUsers[] = $this->user_id;
         }
         $arOldRelation = CIMChat::GetRelationById($chatId);
         $arUsers = CIMContactList::GetUserData(array('ID' => array_keys($arOldRelation), 'DEPARTMENT' => 'N', 'USE_CACHE' => 'N'));
         $arUsers = $arUsers['users'];
         if ($bSelf) {
             $message = GetMessage("IM_CHAT_LEAVE_" . $arUsers[$userId]['gender'], array('#USER_NAME#' => htmlspecialcharsback($arUsers[$userId]['name'])));
         } else {
             $message = GetMessage("IM_CHAT_KICK_" . $arUsers[$GLOBALS["USER"]->GetId()]['gender'], array('#USER_1_NAME#' => htmlspecialcharsback($arUsers[$GLOBALS["USER"]->GetId()]['name']), '#USER_2_NAME#' => htmlspecialcharsback($arUsers[$userId]['name'])));
         }
         $CIMChat = new CIMChat($userId);
         $CIMChat->SetReadMessage($chatId);
         if ($chatType == IM_MESSAGE_OPEN) {
             CIMContactList::CleanAllChatCache();
         } else {
             CIMContactList::CleanChatCache($userId);
         }
         $publicPullWatch = false;
         if ($chatType == IM_MESSAGE_OPEN && CModule::IncludeModule("pull")) {
             $publicPullWatch = true;
         }
         $relationList = IM\RelationTable::getList(array("select" => array("ID", "USER_ID"), "filter" => array("=CHAT_ID" => $chatId, "=USER_ID" => $userId)));
         while ($relation = $relationList->fetch()) {
             if ($publicPullWatch && !$arUsers[$relation["USER_ID"]]['extranet']) {
                 CPullWatch::Add($relation["USER_ID"], 'IM_PUBLIC_' . $chatId, true);
             }
             Im\RelationTable::delete($relation["ID"]);
             CIMContactList::DeleteRecent($chatId, true, $relation["USER_ID"]);
             if ($extranetFlag !== false) {
                 $isExtranet = false;
                 foreach ($arUsers as $userData) {
                     if ($userData['id'] == $userId) {
                         continue;
                     }
                     if ($userData['extranet']) {
                         $isExtranet = true;
                         break;
                     }
                 }
                 if (!$isExtranet || $extranetFlag === "") {
                     IM\ChatTable::update($chatId, array('EXTRANET' => $isExtranet ? "Y" : "N"));
                 }
                 $extranetFlag = $isExtranet;
             }
         }
         CIMDisk::ChangeFolderMembers($chatId, $userId, false);
         self::AddMessage(array("TO_CHAT_ID" => $chatId, "MESSAGE" => $message, "FROM_USER_ID" => $this->user_id, "SYSTEM" => 'Y'));
         $pushMessage = array('module_id' => 'im', 'command' => 'chatUserLeave', 'params' => array('chatId' => $chatId, 'chatTitle' => $chatTitle, 'userId' => $userId, 'message' => $bSelf ? '' : htmlspecialcharsbx($message)));
         CPullStack::AddByUsers(array_keys($arOldRelation), $pushMessage);
         if ($chatType == IM_MESSAGE_OPEN) {
             CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pushMessage);
         }
         return true;
     }
     $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_USER_NOT_FOUND"), "USER_NOT_FOUND");
     return false;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:91,代码来源:im_chat.php

示例5: DeleteBySubTag

 public static function DeleteBySubTag($notifySubTag, $authorId = false)
 {
     global $DB;
     if (strlen($notifySubTag) <= 0) {
         return false;
     }
     $sqlUser = "";
     $sqlUser2 = "";
     if ($authorId !== false) {
         $sqlUser = " AND M.AUTHOR_ID = " . intval($authorId);
         $sqlUser2 = " AND AUTHOR_ID = " . intval($authorId);
     }
     $dbRes = $DB->Query("SELECT M.ID, M.NOTIFY_TYPE, R.USER_ID, R.STATUS FROM b_im_relation R, b_im_message M WHERE M.CHAT_ID = R.CHAT_ID AND M.NOTIFY_SUB_TAG = '" . $DB->ForSQL($notifySubTag) . "'" . $sqlUser, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $arUsers = array();
     $messages = array();
     while ($row = $dbRes->Fetch()) {
         $messages[$row['ID']] = $row['NOTIFY_TYPE'];
         $count = $row['STATUS'] < IM_STATUS_READ ? 1 : 0;
         if (isset($arUsers[$row['USER_ID']])) {
             $arUsers[$row['USER_ID']] += $count;
         } else {
             $arUsers[$row['USER_ID']] = $count;
         }
     }
     $pullActive = false;
     if (CModule::IncludeModule("pull")) {
         $pullActive = true;
     }
     $arUsersSend = array();
     foreach ($arUsers as $userId => $count) {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_NOTIFY);
         if ($count > 0) {
             $arUsersSend[] = $userId;
             //CUserCounter::Decrement($userId, 'im_notify_v2', '**', false);
         }
         if ($pullActive) {
             CPushManager::DeleteFromQueueBySubTag($userId, $notifySubTag);
         }
     }
     if ($pullActive) {
         CPullStack::AddByUsers(array_keys($arUsers), array('module_id' => 'im', 'command' => 'massDeleteMessage', 'params' => array('MESSAGE' => $messages)));
     }
     if (count($messages) > 0) {
         $messageParameters = IM\MessageParamTable::getList(array('select' => array('ID'), 'filter' => array('=MESSAGE_ID' => array_keys($messages))));
         while ($ar = $messageParameters->fetch()) {
             IM\MessageParamTable::delete($ar['ID']);
         }
         $strSql = "DELETE FROM b_im_message WHERE NOTIFY_SUB_TAG = '" . $DB->ForSQL($notifySubTag) . "'" . $sqlUser2;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     CIMMessenger::SendBadges($arUsersSend);
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:53,代码来源:im_notify.php

示例6: StartWriting

 public static function StartWriting($dialogId)
 {
     global $USER;
     if (substr($dialogId, 0, 4) == 'chat') {
         $arRelation = CIMChat::GetRelationById(substr($dialogId, 4));
         if (!isset($arRelation[$USER->GetID()])) {
             return false;
         }
     }
     foreach (\Bitrix\Main\EventManager::getInstance()->findEventHandlers("im", "OnStartWriting") as $event) {
         $result = ExecuteModuleEventEx($event, array($USER->GetID(), $dialogId));
     }
     if ($USER->GetID() > 0 && strlen($dialogId) > 0 && CModule::IncludeModule("pull")) {
         CPushManager::DeleteFromQueueBySubTag($USER->GetID(), 'IM_MESS');
         if (intval($dialogId) > 0) {
             CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $USER->GetID(), 'dialogId' => $dialogId)));
         } elseif (substr($dialogId, 0, 4) == 'chat') {
             unset($arRelation[$USER->GetID()]);
             $pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $USER->GetID(), 'dialogId' => $dialogId));
             CPullStack::AddByUsers(array_keys($arRelation), $pullMessage);
             $orm = \Bitrix\Im\ChatTable::getById(substr($dialogId, 4));
             $chat = $orm->fetch();
             if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
                 CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:im_messenger.php


注:本文中的CPullStack::AddByUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。