ILIAS  Release_3_10_x_branch Revision 61812
 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-2001 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  function ilChatController($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
64  function setRefId($a_ref_id)
65  {
66  $this->ref_id = $a_ref_id;
67  }
68  function getRefId()
69  {
70  return $this->ref_id;
71  }
72 
73  function execute()
74  {
75  $cmd = $this->cmd;
76  $this->gui_obj->$cmd();
77  }
78 
79  // PRIVATE
80  function __getCommand()
81  {
82  if($_GET["cmd"] == 'gateway')
83  {
84  if(is_array($_POST["cmd"]))
85  {
86  $_GET["cmd"] = key($_POST["cmd"]);
87  }
88  // Workaround for Internet Explorer (IE). If a user presses
89  // the Enter in the message input field, IE does not send a
90  // "cmd" parameter. We fill in the command "input", because
91  // we can safely assume that the user intended to post the
92  // message.
93  else if (! $_POST["cmd"] && $_POST["message"])
94  {
95  $_GET["cmd"] = 'input';
96  }
97  else
98  {
99  $_GET["cmd"] = 'cancel';
100  }
101  }
102 
103  if($_GET["cmd"])
104  {
105  $this->cmd = $_GET["cmd"];
106  }
107  else
108  {
109  $this->cmd = "showFrames";
110  }
111 
112  if($_GET['vcard'] == 1 && (int)$_GET['user'])
113  {
114  $this->cmd = 'deliverVCard';
115  }
116  }
117 } // END class.ilObjTest
118 ?>