ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjChatroom.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./classes/class.ilObject.php";
6 
15 class ilObjChatroom extends ilObject
16 {
17 
24  public function __construct($a_id = 0, $a_call_by_reference = true)
25  {
26  $this->type = 'chtr';
27  $this->ilObject($a_id, $a_call_by_reference);
28  }
29 
36  public function getPersonalInformation(ilChatroomUser $user)
37  {
38  $userInfo = new stdClass();
39  $userInfo->username = $user->getUsername();
40  $userInfo->id = $user->getUserId();
41 
42  return $userInfo;
43  }
44 
45 
46  public static function _getPublicRefId() {
47  $settings = new ilSetting('chatroom');
48  return $settings->get('public_room_ref', 0);
49  }
50 
51  public static function _getPublicObjId() {
52  global $ilDB;
53 
54  $rset = $ilDB->query('SELECT object_id FROM chatroom_settings WHERE room_type=' . $ilDB->quote( 'default' ,'text'));
55  if ($row = $ilDB->fetchAssoc($rset)) {
56  return $row['object_id'];
57  }
58  return 0;
59  }
67  function initDefaultRoles()
68  {
69  global $rbacadmin,$rbacreview,$ilDB;
70 
71  // Create a local role folder
72  $rolf_obj = $this->createRoleFolder();
73 
74  // CREATE Moderator role
75  $role_obj = $rolf_obj->createRole("il_chat_moderator_".$this->getRefId(), "Moderator of chat obj_no.".$this->getId());
76  $roles[] = $role_obj->getId();
77 
78  // SET PERMISSION TEMPLATE OF NEW LOCAL ADMIN ROLE
79  $statement = $ilDB->queryF('
80  SELECT obj_id FROM object_data
81  WHERE type = %s
82  AND title = %s',
83  array('text', 'text'),
84  array('rolt', 'il_chat_moderator'));
85 
86  //$res = $statement->fetchRow(DB_FETCHMODE_OBJECT);
87  $res = $ilDB->fetchAssoc($statement);
88 
89  if ($res) {
90  $rbacadmin->copyRoleTemplatePermissions($res['obj_id'],ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
91 
92  // SET OBJECT PERMISSIONS OF COURSE OBJECT
93  $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"chtr",$rolf_obj->getRefId());
94  $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
95  }
96 
97  return $roles ? $roles : array();
98  }
99 
100  public function cloneObject($a_target_id,$a_copy_id = 0,$a_omit_tree = false) {
101  global $rbacreview;
102  require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
103  $original_room = ilChatroom::byObjectId($this->getId());
104 
105  $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
106 
107 
108 
109  $objId = $newObj->getId();
110 
111 
112 
113  $original_settings = $original_room->getSettings();
114  $room = new ilChatroom();
115 
116  $original_settings['object_id'] = $objId;
117 
118  $room->saveSettings($original_settings);
119 
120  // rbac log
121  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
122  $rbac_log_roles = $rbacreview->getParentRoleIds( $newObj->getRefId(), false );
123  $rbac_log = ilRbacLog::gatherFaPa( $newObj->getRefId(), array_keys( $rbac_log_roles ), true );
124  ilRbacLog::add( ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log );
125 
126  return $newObj;
127  }
128 }
129 
130 ?>