/** * Send chat invitations to selected Users */ public function inviteToChat() { /** * @var $ilUser ilObjUser * @var $lng ilLanguage * @var $ilCtrl ilCtrl * @var $tpl ilTemplate */ global $ilUser, $lng, $ilCtrl, $tpl; $lng->loadLanguageModule('chatroom'); $addr_ids = (int) $_GET['addr_id'] ? array((int) $_GET['addr_id']) : $_POST['addr_id']; if (!$addr_ids) { ilUtil::sendFailure($lng->txt('select_one'), true); $ilCtrl->redirect($this, 'showAddressbook'); } $no_login = array(); foreach ($addr_ids as $id) { $entry = $this->abook->getEntry($id); if (!$entry['login']) { $no_login[] = $id; } } if (count($no_login)) { $message = $lng->txt('chat_users_without_login') . ':<br>'; $list = ''; foreach ($no_login as $e) { $list .= '<li>' . $this->abook->entryToString($e) . '</li>'; } $message .= '<ul>'; $message .= $list; $message .= '</ul>'; ilUtil::sendFailure($message, true); $ilCtrl->redirect($this, 'showAddressbook'); } include_once 'Modules/Chatroom/classes/class.ilChatroom.php'; $ilChatroom = new ilChatroom(); $chat_rooms = $ilChatroom->getAllRooms($ilUser->getId()); $subrooms = array(); foreach ($chat_rooms as $room_id => $title) { $subrooms[] = $ilChatroom->getPrivateSubRooms($room_id, $ilUser->getId()); } include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setTitle($lng->txt('mail_invite_users_to_chat')); $psel = new ilSelectInputGUI($lng->txt('chat_select_room'), 'room_id'); $options = array(); foreach ($chat_rooms as $room_id => $room) { $ref_id = $room_id; if ($ilChatroom->isUserBanned($ilUser->getId())) { continue; } $options[$ref_id] = $room; foreach ($subrooms as $subroom) { foreach ($subroom as $sub_id => $parent_id) { if ($parent_id == $ref_id) { $title = ilChatroom::lookupPrivateRoomTitle($sub_id); $options[$ref_id . ',' . $sub_id] = '+ ' . $title; } } } } $psel->setOptions($options); $form->addItem($psel); $phidden = new ilHiddenInputGUI('addr_ids'); $phidden->setValue(implode(',', $addr_ids)); $form->addItem($phidden); $form->addCommandButton('submitInvitation', $this->lng->txt('submit')); $form->addCommandButton('cancel', $this->lng->txt('cancel')); $form->setFormAction($ilCtrl->getFormAction($this)); $tpl->setTitle($lng->txt('mail_invite_users_to_chat')); $tpl->setContent($form->getHtml()); $tpl->show(); }