public static function createDefaultPublicRoom($force = false)
 {
     /**
      * @var $ilDB ilDB
      */
     global $ilDB;
     if ($force) {
         $query = 'DELETE FROM chatroom_settings WHERE room_type = ' . $ilDB->quote('default', 'text');
         $ilDB->manipulate($query);
         $create = true;
     } else {
         $query = 'SELECT * FROM chatroom_settings WHERE room_type = ' . $ilDB->quote('default', 'text');
         $rset = $ilDB->query($query);
         $create = !$ilDB->fetchAssoc($rset);
     }
     if ($create) {
         require_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
         $newObj = new ilObjChatroom();
         $newObj->setType('chtr');
         $newObj->setTitle('Public Chat');
         $newObj->setDescription('');
         $newObj->create();
         // true for upload
         $newObj->createReference();
         $newObj->putInTree(1);
         $newObj->setPermissions(1);
         $obj_id = $newObj->getId();
         $ref_id = $newObj->getRefId();
         $id = $ilDB->nextId('chatroom_settings');
         $ilDB->insert('chatroom_settings', array('room_id' => array('integer', $id), 'object_id' => array('integer', $obj_id), 'room_type' => array('text', 'default'), 'allow_anonymous' => array('integer', 0), 'allow_custom_usernames' => array('integer', 0), 'enable_history' => array('integer', 0), 'restrict_history' => array('integer', 0), 'autogen_usernames' => array('text', 'Anonymous #'), 'allow_private_rooms' => array('integer', 1)));
         $settings = new ilSetting('chatroom');
         $settings->set('public_room_ref', $ref_id);
     }
 }
 /**
  * Constructor
  *
  * Calls $this->ilObjectListGUI method.
  */
 public function __construct()
 {
     $this->ilObjectListGUI();
     require_once 'Modules/Chatroom/classes/class.ilObjChatroom.php';
     self::$publicRoomObjId = ilObjChatroom::_getPublicObjId();
 }
 /**
  *
  */
 public function forcePublicRoom()
 {
     $ref_id = ilObjChatroom::_getPublicRefId();
     if (!$ref_id) {
         $this->createPublicRoom();
         return;
     }
     $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
     if (!$instance) {
         $this->createPublicRoom();
         return;
     }
     $obj_id = ilObject::_lookupObjId($ref_id);
     if (!$obj_id) {
         $this->createPublicRoom();
         return;
     }
     if (!ilObject::_hasUntrashedReference($obj_id)) {
         $this->createPublicRoom();
         return;
     }
     require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
     ilChatroomInstaller::ensureCorrectPublicChatroomTreeLocation($ref_id);
 }
 function __showChatInvitation($a_usr_id)
 {
     global $rbacsystem, $ilUser, $lng;
     include_once './Modules/Chatroom/classes/class.ilObjChatroom.php';
     if ($a_usr_id == $ilUser->getId()) {
         return false;
     }
     //if($rbacsystem->checkAccess('read',ilObjChat::_getPublicChatRefId())
     //and $rbacsystem->checkAccessOfUser($a_usr_id,'read',ilObjChat::_getPublicChatRefId()))
     if ($rbacsystem->checkAccess('read', ilObjChatroom::_getPublicRefId()) and $rbacsystem->checkAccessOfUser($a_usr_id, 'read', ilObjChatroom::_getPublicRefId())) {
         $this->tpl->setCurrentBlock("chat_link");
         $this->tpl->setVariable("TXT_CHAT_INVITE", $lng->txt('chat_invite_public_room'));
         //$this->tpl->setVariable("CHAT_LINK",'./ilias.php?baseClass=ilChatPresentationGUI&ref_id='.ilObjChat::_getPublicChatRefId().
         //'&usr_id='.$a_usr_id.'&cmd=invitePD');
         $this->tpl->setVariable("CHAT_LINK", './ilias.php?baseClass=ilRepositoryGUI&ref_id=' . ilObjChatroom::_getPublicRefId() . '&usr_id=' . $a_usr_id . '&cmd=view-invitePD');
         $this->tpl->setVariable('TXT_CHAT_INVITE_TOOLTIP', $lng->txt('chat_invite_public_room_tooltip'));
         $this->tpl->parseCurrentBlock();
         return true;
     }
     return false;
 }
 public function forcePublicRoom()
 {
     $ref_id = ilObjChatroom::_getPublicRefId();
     if (!$ref_id) {
         $this->createPublicRoom();
         return;
     }
     $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
     if (!$instance) {
         $this->createPublicRoom();
         return;
     }
     $obj_id = ilObject::_lookupObjId($ref_id);
     if (!$obj_id) {
         $this->createPublicRoom();
         return;
     }
     if (!ilObject::_hasUntrashedReference($obj_id)) {
         $this->createPublicRoom();
         return;
     }
 }