ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilChatController.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 require_once "Modules/Chat/classes/class.ilObjChatGUI.php";
24 
33 {
34  var $gui_obj;
35 
36  var $ref_id;
37  var $cmd;
38 
44  public function __construct($a_ref_id)
45  {
46 
47  $this->ref_id = (int) $a_ref_id;
48  $this->gui_obj =& new ilObjChatGUI(array(),$a_ref_id,true,false);
49  $this->gui_obj->object->chat_room->setRoomId((int) $_REQUEST["room_id"]);
50  $this->gui_obj->object->chat_room->setUserId($_SESSION["AccountId"]);
51 
52  // CHECK HACK
53  if(!$this->gui_obj->object->chat_room->checkAccess())
54  {
55  unset($_REQUEST["room_id"]);
56  unset($_REQUEST["message"]);
57  ilUtil::sendInfo("You are not entitled to view this room",true);
58  }
59  $this->gui_obj->object->server_comm->setRecipientId((int) $_GET["p_id"]);
60  $this->getCommand();
61  }
62 
63  // SET/GET
67  public function setRefId($a_ref_id)
68  {
69  $this->ref_id = $a_ref_id;
70  }
71 
75  public function getRefId()
76  {
77  return $this->ref_id;
78  }
79 
80  public function execute()
81  {
82  $cmd = $this->cmd;
83  $this->gui_obj->$cmd();
84  }
85 
89  private function getCommand()
90  {
91  if($_GET["cmd"] == 'gateway')
92  {
93  if(is_array($_POST["cmd"]))
94  {
95  $_GET["cmd"] = key($_POST["cmd"]);
96  }
97  // Workaround for Internet Explorer (IE). If a user presses
98  // the Enter in the message input field, IE does not send a
99  // "cmd" parameter. We fill in the command "input", because
100  // we can safely assume that the user intended to post the
101  // message.
102  else if (! $_POST["cmd"] && $_POST["message"])
103  {
104  $_GET["cmd"] = 'input';
105  }
106  else
107  {
108  $_GET["cmd"] = 'cancel';
109  }
110  }
111 
112  if($_GET["cmd"])
113  {
114  $this->cmd = $_GET["cmd"];
115  }
116  else
117  {
118  $this->cmd = "showFrames";
119  }
120 
121  if($_GET['vcard'] == 1 && (int)$_GET['user'])
122  {
123  $this->cmd = 'deliverVCard';
124  }
125  }
126 
127 } // END class.ilObjTest
128 ?>