28 lines
795 B
PHP
28 lines
795 B
PHP
<?php
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
|
|
|
if ($_SESSION['id'] && $_POST['channelId'] && $_POST['users']) {
|
|
|
|
$post = clearInputData($_POST);
|
|
|
|
$ids = explode(',', $post['users']);
|
|
|
|
foreach ($ids as $id) {
|
|
$user = new User();
|
|
$user->get($id);
|
|
|
|
$userSettings = RocketChat::getUserChatSettings($id);
|
|
|
|
if (!$userSettings['chat_login']) {
|
|
$result = RocketChat::createChatUser($user);
|
|
}
|
|
|
|
if (!RocketChat::checkUserInChannel($user, $post['channelId'])) {
|
|
//логиним, чтобы получить ИД в чате
|
|
RocketChat::loginUser($user->id);
|
|
//добавляем в канал
|
|
RocketChat::addUserToChannel($user, $post['channelId']);
|
|
}
|
|
}
|
|
} |