33 $ownerChats = ChatTable::getList([
35 'AUTHOR_ID' => $ownerId,
40 foreach ($ownerChats as $ownerChat)
42 $chat = Chat\ChatFactory::getInstance()->getChat($ownerChat[
'ID']);
44 $ownerRelation = $chat->getRelations([
50 if ($ownerRelation->getIterator()->current())
52 $ownerRelation->getIterator()->current()->setManager(
false);
53 $ownerRelation->getIterator()->current()->save();
56 $relations = $chat->getRelations([
58 '!USER_ID' => $ownerId
61 if ($relations->count())
63 foreach ($relations as $relation)
65 $user = $relation->getUser();
70 && !$user->isExtranet()
71 && !$user->isConnector()
74 $chat->setAuthorId($relation->getUserId());
77 $relation->setManager(
true);
91 $firedUsers = UserTable::getList([
100 foreach ($firedUsers as $key => $user)
103 __CLASS__.
'::changeChatsOwnerAfterUserFiredAgent(' . (
int)$user[
'ID'] .
');',
106 self::DELAY_AFTER_USER_FIRED,
109 ConvertTimeStamp(time() + \CTimeZone::GetOffset() + self::DELAY_AFTER_USER_FIRED * $key,
"FULL")
118 $generalChatId = \COption::GetOptionInt(
'im',
'general_chat_id');
124 $oldChat = Chat\ChatFactory::getInstance()->getChatById($generalChatId);
135 $generalChat = Chat\ChatFactory::getInstance()->getGeneralChat();
136 if (!$generalChat || $generalChat instanceof
Chat\
NullChat)
141 $canPostAll = (\COption::GetOptionString(
'im',
'allow_send_to_general_chat_all',
'Y') ===
'Y');
151 $chatRights = \COption::GetOptionString(
'im',
'allow_send_to_general_chat_rights');
157 $users = UserAccessTable::getList([
162 '=ACCESS_CODE' => explode(
',', $chatRights)
174 $userIds = array_column($users,
'USER_ID');
176 $relations = $generalChat->getRelations();
177 foreach ($relations as $relation)
179 if (in_array($relation->getUserId(), $userIds))
181 $relation->setManager(
true);