public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false) { global $rbacreview; require_once 'Modules/Chatroom/classes/class.ilChatroom.php'; $original_room = ilChatroom::byObjectId($this->getId()); $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree); $objId = $newObj->getId(); $original_settings = $original_room->getSettings(); $room = new ilChatroom(); $original_settings['object_id'] = $objId; $room->saveSettings($original_settings); // rbac log include_once "Services/AccessControl/classes/class.ilRbacLog.php"; $rbac_log_roles = $rbacreview->getParentRoleIds($newObj->getRefId(), false); $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true); ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log); return $newObj; }
/** * Sets autogen_usernames default option for chatrooms * @param array $obj_ids */ public static function setChatroomSettings($obj_ids) { if (is_array($obj_ids)) { foreach ($obj_ids as $obj_id) { $room = new ilChatroom(); $room->saveSettings(array('object_id' => $obj_id, 'autogen_usernames' => 'Autogen #', 'room_type' => 'repository')); } } }
/** * Instantiates, prepares and returns object. * $class_name = 'ilObj' . $objDefinition->getClassName( $new_type ). * Fetches title from $_POST['title'], description from $_POST['desc'] * and RefID from $_GET['ref_id']. * @return ilObject */ public function insertObject() { /** * @var $rbacsystem ilRbacSystem * @var $objDefinition ilObjectDefinition * @var $rbacreview ilRbacReview */ global $rbacsystem, $objDefinition, $rbacreview; $new_type = $this->type; // create permission is already checked in createObject. // This check here is done to prevent hacking attempts if (!$rbacsystem->checkAccess('create', $_GET['ref_id'], $new_type)) { $this->ilias->raiseError($this->lng->txt('no_create_permission'), $this->ilias->error_obj->MESSAGE); } $location = $objDefinition->getLocation($new_type); // create and insert object in objecttree $class_name = 'ilObj' . $objDefinition->getClassName($new_type); include_once $location . '/class.' . $class_name . '.php'; /** * @var $newObj ilObjChatroom */ $newObj = new $class_name(); $newObj->setType($new_type); $newObj->setTitle(ilUtil::stripSlashes($_POST['title'])); $newObj->setDescription(ilUtil::stripSlashes($_POST['desc'])); $newObj->create(); $newObj->createReference(); $newObj->putInTree($_GET['ref_id']); $newObj->setPermissions($_GET['ref_id']); $objId = $newObj->getId(); $room = new ilChatroom(); $room->saveSettings(array('object_id' => $objId, 'autogen_usernames' => 'Autogen #', 'display_past_msgs' => 20, 'private_rooms_enabled' => 0)); // rbac log include_once 'Services/AccessControl/classes/class.ilRbacLog.php'; $rbac_log_roles = $rbacreview->getParentRoleIds($newObj->getRefId(), false); $rbac_log = ilRbacLog::gatherFaPa($newObj->getRefId(), array_keys($rbac_log_roles), true); ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $newObj->getRefId(), $rbac_log); $this->object = $newObj; return $newObj; }