Пример #1
0
 public static function UpdateMessageOut($id, $messageOut)
 {
     $id = intval($id);
     if ($id <= 0) {
         return false;
     }
     \Bitrix\Im\MessageTable::update($id, array("MESSAGE_OUT" => $messageOut));
     return true;
 }
Пример #2
0
 public static function Delete($id)
 {
     $message = self::CheckPossibilityUpdateMessage($id);
     if (!$message) {
         return false;
     }
     $date = FormatDate("FULL", $message['DATE_CREATE'] + CTimeZone::GetOffset());
     IM\MessageTable::update($message['ID'], array("MESSAGE" => GetMessage('IM_MESSAGE_DELETED'), "MESSAGE_OUT" => GetMessage('IM_MESSAGE_DELETED_OUT', array('#DATE#' => $date))));
     CIMMessageParam::Set($message['ID'], array('IS_DELETED' => 'Y'));
     $arFields = $message;
     $arFields['MESSAGE'] = GetMessage('IM_MESSAGE_DELETED_OUT', array('#DATE#' => $date));
     $arFields['DATE_MODIFY'] = time() + CTimeZone::GetOffset();
     $relations = CIMMessenger::GetRelationById($message['ID']);
     $arPullMessage = array('id' => $arFields['ID'], 'type' => $arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE ? 'private' : 'chat', 'date' => $arFields['DATE_MODIFY'], 'text' => GetMessage('IM_MESSAGE_DELETED'));
     if ($message['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'];
     }
     foreach ($relations as $rel) {
         CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageDelete', 'params' => $arPullMessage));
         $obCache = new CPHPCache();
         $obCache->CleanDir('/bx/imc/recent' . self::GetCachePath($rel['USER_ID']));
     }
     foreach (GetModuleEvents("im", "OnAfterMessagesDelete", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(intval($id), $arFields));
     }
     return true;
 }