public function executeDefault($method)
 {
     global $tpl, $ilUser, $ilCtrl, $lng, $ilAccess;
     $room = ilChatroom::byObjectId($this->gui->object->getId());
     $chat_user = new ilChatroomUser($ilUser, $room);
     $result = new stdClass();
     $result->users = $room->getConnectedUsers();
     $result->private_rooms = $room->getActivePrivateRooms($ilUser->getId());
     $result->userinfo = array('moderator' => $ilAccess->checkAccess('moderate', '', $_GET['ref_id']), 'userid' => $chat_user->getUserId());
     $smileys = array();
     include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
     $smileys_array = ilChatroomSmilies::_getSmilies();
     foreach ($smileys_array as $smiley_array) {
         foreach ($smiley_array as $key => $value) {
             if ($key == 'smiley_keywords') {
                 $new_keys = explode("\n", $value);
             }
             if ($key == 'smiley_fullpath') {
                 $new_val = $value;
             }
         }
         foreach ($new_keys as $new_key) {
             $smileys[$new_key] = $new_val;
         }
     }
     $result->smileys = $smileys;
     echo json_encode($result);
     exit;
 }
 /**
  * Instantiates ilChatroomSmiliesTableGUI and returns its table's HTML.
  *
  * @global ilLanguage $lng
  * @global ilCtrl2 $ilCtrl
  * @param ilObjChatroomAdminGUI $a_ref
  * @return string
  */
 public static function _getExistingSmiliesTable($a_ref)
 {
     global $lng, $ilCtrl;
     include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesTableGUI.php";
     $table = new ilChatroomSmiliesTableGUI($a_ref, 'smiley');
     include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
     $values = ilChatroomSmilies::_getSmilies();
     $table->setData($values);
     return $table->getHTML();
 }
 /**
  * Uploads and stores a new smiley with keywords from
  * $_REQUEST["chatroom_smiley_keywords"]
  *
  * @global ilRbacSystem $rbacsystem
  * @global ilCtrl2 $ilCtrl
  */
 public function uploadSmileyObject()
 {
     global $rbacsystem, $ilCtrl, $tpl, $lng;
     if (!$rbacsystem->checkAccess('write', $this->gui->ref_id)) {
         $this->ilias->raiseError($lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
     }
     $this->initSmiliesForm();
     include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     //$this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setValuesByPost();
     $keywords = ilChatroomSmilies::_prepareKeywords(ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"]));
     $keywordscheck = count($keywords) > 0;
     if (!$this->form_gui->checkInput()) {
         $tpl->setContent($this->form_gui->getHtml());
         return $this->view();
     }
     $pathinfo = pathinfo($_FILES["chatroom_image_path"]["name"]);
     $target_file = md5(time() + $pathinfo['basename']) . "." . $pathinfo['extension'];
     move_uploaded_file($_FILES["chatroom_image_path"]["tmp_name"], ilChatroomSmilies::_getSmiliesBasePath() . $target_file);
     ilChatroomSmilies::_storeSmiley(join("\n", $keywords), $target_file);
     $ilCtrl->redirect($this->gui, "smiley");
 }
 /**
  * Fill data section
  */
 public function fillDataSection()
 {
     /**
      * @var $tpl	ilTemplate
      * @var $lng	ilLanguage
      * @var $ilCtrl ilCtrl
      */
     global $tpl, $lng, $ilCtrl;
     //@todo: Dirty hack
     if ($ilCtrl->isAsynch()) {
         return $this->getMessages();
     }
     $tpl->addJavascript('./Modules/Chatroom/js/chatviewer.js');
     $tpl->addCss('./Modules/Chatroom/templates/default/style.css');
     $chatblock = new ilChatroomBlock();
     $body_tpl = new ilTemplate('tpl.chatroom_block_message_body.html', true, true, 'Modules/Chatroom');
     $height = 120;
     if ($this->getCurrentDetailLevel() > 0 && $this->getCurrentDetailLevel() <= 3) {
         $height *= $this->getCurrentDetailLevel();
     }
     $body_tpl->setVariable('BLOCK_HEIGHT', $height);
     $body_tpl->setVariable('TXT_ENABLE_AUTOSCROLL', $lng->txt('chat_enable_autoscroll'));
     $ilCtrl->setParameterByClass('ilcolumngui', 'block_id', 'block_' . $this->getBlockType() . '_' . (int) $this->getBlockId());
     $ilCtrl->setParameterByClass('ilcolumngui', 'ref_id', '#__ref_id');
     $body_tpl->setVariable('CHATBLOCK_BASE_URL', $ilCtrl->getLinkTargetByClass('ilcolumngui', 'updateBlock', '', true));
     $ilCtrl->setParameterByClass('ilcolumngui', 'block_id', '');
     $ilCtrl->setParameterByClass('ilcolumngui', 'ref_id', '');
     $smilieys = array();
     $settings = ilChatroomServerSettings::loadDefault();
     if ($settings->getSmiliesEnabled()) {
         $smilies_array = ilChatroomSmilies::_getSmilies();
         foreach ($smilies_array as $smiley_array) {
             foreach ($smiley_array as $key => $value) {
                 if ($key == 'smiley_keywords') {
                     $new_keys = explode("\n", $value);
                 }
                 if ($key == 'smiley_fullpath') {
                     $new_val = $value;
                 }
             }
             foreach ($new_keys as $new_key) {
                 $smilieys[$new_key] = $new_val;
             }
         }
     } else {
         $smilieys = new stdClass();
     }
     $body_tpl->setVariable('SMILIES', json_encode($smilieys));
     $js_translations = array('LBL_CONNECT' => 'chat_connection_established', 'LBL_DISCONNECT' => 'chat_connection_disconnected', 'LBL_TIMEFORMAT' => 'lang_timeformat_no_sec', 'LBL_DATEFORMAT' => 'lang_dateformat');
     foreach ($js_translations as $placeholder => $lng_variable) {
         $body_tpl->setVariable($placeholder, json_encode($lng->txt($lng_variable)));
     }
     $content = $body_tpl->get() . $chatblock->getRoomSelect();
     $this->setDataSection($content);
 }
Ejemplo n.º 5
0
 /**
  * Prepares and displays chatroom and connects user to it.
  * @param ilChatroom     $room
  * @param ilChatroomUser $chat_user
  */
 private function showRoom(ilChatroom $room, ilChatroomUser $chat_user)
 {
     /**
      * @var $tpl                 ilTemplate    $tpl
      * @var $ilUser              ilObjUser
      * @var $ilCtrl              ilCtrl
      * @var $rbacsystem          ilRbacSystem
      * @var $lng                 ilLanguage
      * @var $ilNavigationHistory ilNavigationHistory
      */
     global $tpl, $ilUser, $ilCtrl, $rbacsystem, $lng, $ilNavigationHistory;
     if (!ilChatroom::checkUserPermissions('read', $this->gui->ref_id)) {
         $ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
         $ilCtrl->redirectByClass('ilrepositorygui', '');
     }
     $user_id = $chat_user->getUserId($ilUser);
     $ilNavigationHistory->addItem($_GET['ref_id'], $ilCtrl->getLinkTargetByClass('ilrepositorygui', 'view'), 'chtr');
     if ($room->isUserBanned($user_id)) {
         $this->cancelJoin($lng->txt('banned'));
         return;
     }
     $scope = $room->getRoomId();
     $connector = $this->gui->getConnector();
     $response = @$connector->connect($scope, $user_id);
     if (!$response) {
         ilUtil::sendFailure($lng->txt('unable_to_connect'), true);
         $ilCtrl->redirectByClass('ilinfoscreengui', 'info');
     }
     if (!$room->isSubscribed($chat_user->getUserId()) && $room->connectUser($chat_user)) {
         $messageObject = array('type' => 'connected', 'users' => array(array('login' => $chat_user->getUsername(), 'id' => $user_id)), 'timestamp' => time() * 1000);
         $message = json_encode($messageObject);
         $connector->sendMessage($scope, $message);
         $room->addHistoryEntry($messageObject);
     }
     $connection_info = json_decode($response);
     $settings = $connector->getSettings();
     $known_private_room = $room->getActivePrivateRooms($ilUser->getId());
     $initial = new stdClass();
     $initial->users = $room->getConnectedUsers();
     $initial->private_rooms = array_values($known_private_room);
     $initial->redirect_url = $ilCtrl->getLinkTarget($this->gui, 'view-lostConnection', '', false, false);
     $initial->private_rooms_enabled = (bool) $room->getSetting('private_rooms_enabled');
     $initial->userinfo = array('moderator' => $rbacsystem->checkAccess('moderate', (int) $_GET['ref_id']), 'userid' => $chat_user->getUserId());
     $smileys = array();
     include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
     if ($settings->getSmiliesEnabled()) {
         $smileys_array = ilChatroomSmilies::_getSmilies();
         foreach ($smileys_array as $smiley_array) {
             $new_keys = array();
             $new_val = '';
             foreach ($smiley_array as $key => $value) {
                 if ($key == 'smiley_keywords') {
                     $new_keys = explode("\n", $value);
                 }
                 if ($key == 'smiley_fullpath') {
                     $new_val = $value;
                 }
             }
             if (!$new_keys || !$new_val) {
                 continue;
             }
             foreach ($new_keys as $new_key) {
                 $smileys[$new_key] = $new_val;
             }
         }
         $initial->smileys = $smileys;
     } else {
         $initial->smileys = '{}';
     }
     $initial->messages = array();
     if (isset($_REQUEST['sub'])) {
         if ($known_private_room[$_REQUEST['sub']]) {
             if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $_REQUEST['sub'])) {
                 $initial->messages[] = array('type' => 'error', 'message' => $lng->txt('not_allowed_to_enter'));
             } else {
                 $scope = $room->getRoomId();
                 $params = array();
                 $params['user'] = $chat_user->getUserId();
                 $params['sub'] = $_REQUEST['sub'];
                 $params['message'] = json_encode(array('type' => 'private_room_entered', 'user' => $user_id));
                 $query = http_build_query($params);
                 $connector = $this->gui->getConnector();
                 $response = $connector->enterPrivateRoom($scope, $query);
                 $responseObject = json_decode($response);
                 if ($responseObject->success == true) {
                     $room->subscribeUserToPrivateRoom($params['sub'], $params['user']);
                 }
                 $message = json_encode(array('type' => 'private_room_entered', 'user' => $params['user'], 'sub' => $params['sub']));
                 $connector->sendMessage($room->getRoomId(), $message, array('public' => 1, 'sub' => $params['sub']));
                 $initial->enter_room = $_REQUEST['sub'];
                 $initial->messages[] = array('type' => 'notice', 'user' => $params['user'], 'sub' => $params['sub'], 'entersub' => 1);
             }
             if ($_SESSION['show_invitation_message']) {
                 $initial->messages[] = array('type' => 'notice', 'message' => $lng->txt('user_invited'), 'sub' => $_REQUEST['sub']);
                 unset($_SESSION['show_invitation_message']);
             }
         } else {
             $initial->messages[] = array('type' => 'error', 'message' => $lng->txt('user_invited'));
         }
     }
     if ((int) $room->getSetting('display_past_msgs')) {
         $initial->messages = array_merge($initial->messages, array_reverse($room->getLastMessages($room->getSetting('display_past_msgs'), $chat_user)));
     }
     $roomTpl = new ilTemplate('tpl.chatroom.html', true, true, 'Modules/Chatroom');
     $roomTpl->setVariable('SESSION_ID', $connection_info->{'session-id'});
     $roomTpl->setVariable('BASEURL', $settings->getBaseURL());
     $roomTpl->setVariable('INSTANCE', $settings->getInstance());
     $roomTpl->setVariable('SCOPE', $scope);
     $roomTpl->setVariable('MY_ID', $user_id);
     $roomTpl->setVariable('INITIAL_DATA', json_encode($initial));
     $roomTpl->setVariable('POSTURL', $ilCtrl->getLinkTarget($this->gui, 'postMessage', '', true, true));
     $roomTpl->setVariable('ACTIONS', $lng->txt('actions'));
     $roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $lng->txt('create_private_room_label'));
     $roomTpl->setVariable('LBL_USER', $lng->txt('user'));
     $roomTpl->setVariable('LBL_USER_TEXT', $lng->txt('invite_username'));
     $roomTpl->setVariable('LBL_AUTO_SCROLL', $lng->txt('auto_scroll'));
     $roomTpl->setVariable('INITIAL_USERS', json_encode($room->getConnectedUsers()));
     $this->renderFontSettings($roomTpl, array());
     $this->renderFileUploadForm($roomTpl);
     $this->renderSendMessageBox($roomTpl);
     $this->renderLanguageVariables($roomTpl);
     $roomRightTpl = new ilTemplate('tpl.chatroom_right.html', true, true, 'Modules/Chatroom');
     $this->renderRightUsersBlock($roomRightTpl);
     require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
     $right_content_panel = ilPanelGUI::getInstance();
     $right_content_panel->setHeading($lng->txt('users'));
     $right_content_panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY);
     $right_content_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_BLOCK);
     $right_content_panel->setBody($roomRightTpl->get());
     $tpl->setContent($roomTpl->get());
     $tpl->setRightContent($right_content_panel->getHTML());
 }