ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjChatroomGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./classes/class.ilObjectGUI.php";
6 require_once "./Modules/Chatroom/classes/class.ilObjChatroom.php";
7 require_once "./Modules/Chatroom/classes/class.ilChatroom.php";
8 require_once "./Modules/Chatroom/classes/class.ilObjChatroomAccess.php";
9 require_once 'Modules/Chatroom/lib/DatabayHelper/databayHelperLoader.php';
10 
26 {
27 
35  public function __construct($a_data = null, $a_id = null, $a_call_by_reference = true)
36  {
37  if (in_array($_REQUEST['cmd'], array('getOSDNotifications','removeOSDNotifications'))) {
38  require_once 'Services/Notifications/classes/class.ilNotificationGUI.php';
39  $notifications = new ilNotificationGUI();
40  $notifications->{$_REQUEST['cmd'] . 'Object'}();
41  exit;
42  }
43 
44 
45  if( $a_data == null )
46  {
47  if( $_GET['serverInquiry'] )
48  {
49  require_once dirname( __FILE__ ) . '/class.ilChatroomServerHandler.php';
51  return;
52  }
53  }
54  /*require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
55  var_dump( ilChatroomServerConnector::checkServerConnection());*/
56  $this->type = 'chtr';
57  $this->ilObjectGUI( $a_data, $a_id, $a_call_by_reference, false );
58  $this->lng->loadLanguageModule( 'chatroom' );
59  $this->lng->loadLanguageModule( 'chatroom_adm' );
60  }
61 
68  protected function getObjectDefinition()
69  {
71  }
72 
78  public function _forwards()
79  {
80  return array();
81  }
82 
88  public function executeCommand()
89  {
90  global $ilAccess, $ilNavigationHistory, $ilCtrl;
91 
92  if ('cancel' == $ilCtrl->getCmd() && $this->getCreationMode()) {
93  parent::cancelCreation();
94  return;
95  }
96 
97  // add entry to navigation history
98  if(!$this->getCreationMode() && $ilAccess->checkAccess('read', '', $_GET['ref_id']))
99  {
100  $ilNavigationHistory->addItem($_GET['ref_id'], './goto.php?target=' . $this->type . '_' . $_GET['ref_id'], $this->type);
101  }
102 
103  $next_class = $ilCtrl->getNextClass();
104 
105  require_once 'Modules/Chatroom/classes/class.ilChatroomTabFactory.php';
106  if (!$this->getCreationMode()) {
107  $tabFactory = new ilChatroomTabFactory( $this );
108 
109  if(strtolower($_GET["baseClass"]) == "iladministrationgui") {
110  $tabFactory->getAdminTabsForCommand( $ilCtrl->getCmd() );
111  }
112  else {
113  $tabFactory->getTabsForCommand( $ilCtrl->getCmd() );
114  }
115  }
116 
117  // #8701 - infoscreen actions
118  if($next_class == "ilinfoscreengui" && $ilCtrl->getCmd() != "info")
119  {
120  $ilCtrl->setCmd("info-".$ilCtrl->getCmd());
121  }
122  // repository info call
123  if($ilCtrl->getCmd() == "infoScreen")
124  {
125  $ilCtrl->setCmdClass("ilinfoscreengui");
126  $ilCtrl->setCmd("info");
127  }
128 
129  switch($next_class)
130  {
131  case 'ilpermissiongui':
132  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
133  $this->prepareOutput();
134  $perm_gui = & new ilPermissionGUI( $this );
135  $ret = & $this->ctrl->forwardCommand( $perm_gui );
136  break;
137  case 'ilobjectcopygui':
138  $this->prepareOutput();
139  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
140  $cp = new ilObjectCopyGUI($this);
141  $cp->setType('chtr');
142  $this->ctrl->forwardCommand($cp);
143  break;
144  default:
145  try
146  {
147  $res = split( '-', $ilCtrl->getCmd(), 2 );
148  $this->dispatchCall( $res[0], $res[1] ? $res[1] : '' );
149  }
150  catch (Exception $e)
151  {
152  $error = array(
153  'success' => false,
154  'reason' => $e->getMessage()
155  );
156  echo json_encode($error);
157  exit;
158  }
159 
160  }
161  }
162 
168  public function getConnector()
169  {
170  require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
171  require_once 'Modules/Chatroom/classes/class.ilChatroomServerSettings.php';
172  require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
173  //require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
174  // ilChatroomInstaller::install();
175 
176  //$settings = new ilChatroomServerSettings();
177  $settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
178  $connector = new ilChatroomServerConnector( $settings );
179 
180  return $connector;
181  }
182 
186  public function fallback()
187  {
188  $this->prepareOutput();
189  $this->tpl->setVariable( 'ADM_CONTENT', $this->lng->txt( 'invalid_operation' ) );
190  }
191 
195  public function settings()
196  {
197  $this->prepareOutput();
198  }
199 
212  public function insertObject()
213  {
214  global $rbacsystem, $objDefinition, $rbacreview;
215 
216  $new_type = $this->type;
217 
218  // create permission is already checked in createObject.
219  // This check here is done to prevent hacking attempts
220  if( !$rbacsystem->checkAccess( "create", $_GET["ref_id"], $new_type ) )
221  {
222  $this->ilias->raiseError(
223  $this->lng->txt( "no_create_permission" ),
224  $this->ilias->error_obj->MESSAGE
225  );
226  }
227 
228  $location = $objDefinition->getLocation( $new_type );
229 
230  // create and insert object in objecttree
231  $class_name = "ilObj" . $objDefinition->getClassName( $new_type );
232  include_once($location . "/class." . $class_name . ".php");
233 
234  $newObj = new $class_name();
235  $newObj->setType( $new_type );
236  $newObj->setTitle( ilUtil::stripSlashes( $_POST["title"] ) );
237  $newObj->setDescription( ilUtil::stripSlashes( $_POST["desc"] ) );
238  $newObj->create();
239  $newObj->createReference();
240  $newObj->putInTree( $_GET["ref_id"] );
241  $newObj->setPermissions( $_GET["ref_id"] );
242 
243  $objId = $newObj->getId();
244 
245  $room = new ilChatroom();
246 
247  $room->saveSettings(
248  array(
249  'object_id' => $objId,
250  'autogen_usernames' => 'Autogen #',
251  'display_past_msgs' => 20,
252  'private_rooms_enabled' => 0
253  ));
254 
255  // rbac log
256  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
257  $rbac_log_roles = $rbacreview->getParentRoleIds( $newObj->getRefId(), false );
258  $rbac_log = ilRbacLog::gatherFaPa( $newObj->getRefId(), array_keys( $rbac_log_roles ), true );
259  ilRbacLog::add( ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log );
260 
261  $this->object = $newObj;
262 
263  return $newObj;
264  }
265 
271  public function getRefId()
272  {
273  return $this->object->getRefId();
274  }
275 
283  public static function _goto($params)
284  {
290  global $ilAccess, $ilErr, $lng;
291 
292  $parts = explode('_', $params);
293  $ref_id = $parts[0];
294  $sub = $parts[1];
295 
296  if($ilAccess->checkAccess('read', '', $ref_id))
297  {
298  $_GET['cmd'] = 'view';
299  $_GET['ref_id'] = $ref_id;
300  if($sub)
301  {
302  $_REQUEST['sub'] = $_GET['sub'] = (int)$sub;
303  }
304  require 'repository.php';
305  exit();
306  }
307  else if($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID))
308  {
309  $_GET['target'] = '';
310  $_GET['ref_id'] = ROOT_FOLDER_ID;
311  ilUtil::sendInfo(sprintf($lng->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), true);
312  include 'repository.php';
313  exit();
314  }
315 
316  $ilErr->raiseError(sprintf($lng->txt('msg_no_perm_read_item'), ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id))), $ilErr->FATAL);
317  }
318 
319  protected function initCreationForms($a_new_type)
320  {
321  $forms = parent::initCreationForms($a_new_type);
322 
323  unset($forms[self::CFORM_IMPORT]);
324  //unset($forms[self::CFORM_CLONE]);
325 
326  $forms[self::CFORM_NEW]->clearCommandButtons();
327  $forms[self::CFORM_NEW]->addCommandButton("create-save", $this->lng->txt($a_new_type."_add"));
328  $forms[self::CFORM_NEW]->addCommandButton("cancel", $this->lng->txt("cancel"));
329  return $forms;
330  }
331 
332  function addLocatorItems()
333  {
334  global $ilLocator;
335 
336  if (is_object($this->object))
337  {
338  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "view"), "", $this->getRefId());
339  }
340  }
341 }
342 
343 ?>