/**
  * save object
  * @access	public
  */
 function afterSave(ilObject $a_new_object)
 {
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("object_added"), true);
     ilUtil::redirect("ilias.php?ref_id=" . $a_new_object->getRefId() . "&baseClass=ilObjQuestionPoolGUI");
 }
 protected function afterSave(ilObject $a_new_object)
 {
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("fold_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     $this->redirectToRefId($a_new_object->getRefId(), "");
 }
 /**
  * Add object to tree at given position
  *
  * @param ilObject $a_obj
  * @param int $a_parent_node_id
  */
 protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
 {
     global $rbacreview, $ilUser, $objDefinition;
     $this->object_id = $a_obj->getId();
     if (!$a_parent_node_id) {
         $a_parent_node_id = $this->parent_id;
     }
     // add new object to custom parent container
     if ((int) $_REQUEST["crtptrefid"]) {
         $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
     }
     switch ($this->id_type) {
         case self::REPOSITORY_NODE_ID:
         case self::REPOSITORY_OBJECT_ID:
             if (!$this->node_id) {
                 $a_obj->createReference();
                 $this->node_id = $a_obj->getRefId();
             }
             $a_obj->putInTree($a_parent_node_id);
             $a_obj->setPermissions($a_parent_node_id);
             // rbac log
             include_once "Services/AccessControl/classes/class.ilRbacLog.php";
             $rbac_log_roles = $rbacreview->getParentRoleIds($this->node_id, false);
             $rbac_log = ilRbacLog::gatherFaPa($this->node_id, array_keys($rbac_log_roles), true);
             ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->node_id, $rbac_log);
             $this->ctrl->setParameter($this, "ref_id", $this->node_id);
             break;
         case self::WORKSPACE_NODE_ID:
         case self::WORKSPACE_OBJECT_ID:
             if (!$this->node_id) {
                 $this->node_id = $this->tree->insertObject($a_parent_node_id, $this->object_id);
             }
             $this->getAccessHandler()->setPermissions($a_parent_node_id, $this->node_id);
             $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
             break;
         case self::OBJECT_ID:
         case self::PORTFOLIO_OBJECT_ID:
             // do nothing
             break;
     }
     // BEGIN ChangeEvent: Record save object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordWriteEvent($this->object_id, $ilUser->getId(), 'create');
     // END ChangeEvent: Record save object.
     // use forced callback after object creation
     self::handleAfterSaveCallback($a_obj, $_REQUEST["crtcb"]);
 }
 /**
  * Activate rating automatically if parent container setting 
  * 
  * @param ilObject $a_new_obj
  */
 protected function handleAutoRating(ilObject $a_new_obj)
 {
     if (ilObject::hasAutoRating($a_new_obj->getType(), $a_new_obj->getRefId()) && method_exists($a_new_obj, "setRating")) {
         $a_new_obj->setRating(true);
         $a_new_obj->update();
     }
 }
 public function testTreeTrash()
 {
     global $tree;
     $obj = new ilObject();
     $obj->setType("xxx");
     $obj->setTitle("TestObject");
     $obj->setDescription("TestDescription");
     $obj->setImportId("imp_44");
     $obj->create();
     $obj->createReference();
     $id = $obj->getId();
     $ref_id = $obj->getRefId();
     $obj = new ilObject($ref_id);
     $obj->putInTree(ROOT_FOLDER_ID);
     $obj->createRoleFolder();
     $obj->setPermissions(ROOT_FOLDER_ID);
     if ($tree->isInTree($ref_id)) {
         $value .= "tree1-";
     }
     if (ilObject::_hasUntrashedReference($id)) {
         $value .= "tree2-";
     }
     // isSaved() uses internal cache!
     $tree->useCache(false);
     $tree->saveSubTree($ref_id, true);
     if ($tree->isDeleted($ref_id)) {
         $value .= "tree3-";
     }
     if ($tree->isSaved($ref_id)) {
         $value .= "tree4-";
     }
     if (ilObject::_isInTrash($ref_id)) {
         $value .= "tree5-";
     }
     if (!ilObject::_hasUntrashedReference($id)) {
         $value .= "tree6-";
     }
     $saved_tree = new ilTree(-(int) $ref_id);
     $node_data = $saved_tree->getNodeData($ref_id);
     $saved_tree->deleteTree($node_data);
     if (!ilObject::_isInTrash($ref_id)) {
         $value .= "tree7-";
     }
     $obs = ilUtil::_getObjectsByOperations("cat", "read");
     foreach ($obs as $ob) {
         if (ilObject::_lookupType(ilObject::_lookupObjId($ob)) != "cat") {
             $value .= "nocat-";
         }
     }
     $obj->delete();
     $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
 }
 /**
  * Filter roles
  * @param ilObject $object
  */
 protected function filterRoles(ilObject $source)
 {
     global $rbacreview;
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
     $patterns = ilDidacticTemplateFilterPatternFactory::lookupPatternsByParentId($this->getActionId(), self::PATTERN_PARENT_TYPE);
     $filtered = array();
     foreach ($rbacreview->getParentRoleIds($source->getRefId()) as $role_id => $role) {
         foreach ($patterns as $pattern) {
             if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ' Role is valid: ' . ilObject::_lookupTitle($role_id));
                 $filtered[$role_id] = $role;
             }
         }
     }
     return $filtered;
 }
 protected function afterSave(ilObject $a_new_object)
 {
     $a_new_object->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $a_new_object->getRefId());
     $a_new_object->setCleanFrames(true);
     $a_new_object->update();
     // create content object tree
     $a_new_object->createLMTree();
     // create a first chapter
     $a_new_object->addFirstChapterAndPage();
     // always send a message
     ilUtil::sendSuccess($this->lng->txt($this->type . "_added"), true);
     ilUtil::redirect("ilias.php?ref_id=" . $a_new_object->getRefId() . "&baseClass=ilLMEditorGUI");
 }
 protected function afterSave(ilObject $a_new_object)
 {
     $target_obj_id = ilObject::_lookupObjId((int) $_REQUEST['target_id']);
     $a_new_object->setTargetId($target_obj_id);
     $a_new_object->update();
     ilUtil::sendSuccess($this->lng->txt("object_added"), true);
     $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
     $this->ctrl->redirect($this, 'firstEdit');
 }
 protected function afterSave(ilObject $a_new_object)
 {
     global $ilUser, $tree;
     // add default translation
     $a_new_object->addTranslation($a_new_object->getTitle(), $a_new_object->getDescription(), $ilUser->getPref("language"), true);
     // default: sort by title
     include_once 'Services/Container/classes/class.ilContainerSortingSettings.php';
     $settings = new ilContainerSortingSettings($a_new_object->getId());
     $settings->setSortMode(ilContainer::SORT_TITLE);
     $settings->save();
     // inherit parents content style, if not individual
     $parent_ref_id = $tree->getParentId($a_new_object->getRefId());
     $parent_id = ilObject::_lookupObjId($parent_ref_id);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = ilObjStyleSheet::lookupObjectStyle($parent_id);
     if ($style_id > 0) {
         if (ilObjStyleSheet::_lookupStandard($style_id)) {
             ilObjStyleSheet::writeStyleUsage($a_new_object->getId(), $style_id);
         }
     }
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("cat_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     $this->redirectToRefId($a_new_object->getRefId(), "");
 }
 protected function afterSave(ilObject $a_new_object)
 {
     $a_new_object->setOffline(true);
     $a_new_object->setNumberOfSlots(4);
     $a_new_object->update();
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("book_pool_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     $this->ctrl->redirect($this, "edit");
 }
 /**
  * save object
  * @access	public
  */
 protected function afterSave(ilObject $a_new_object)
 {
     global $rbacadmin, $ilUser;
     $a_new_object->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
     $a_new_object->getMemberObject()->updateNotification($ilUser->getId(), 1);
     $a_new_object->update();
     // BEGIN ChangeEvent: Record write event.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     global $ilUser;
     ilChangeEvent::_recordWriteEvent($a_new_object->getId(), $ilUser->getId(), 'create');
     // END ChangeEvent: Record write event.
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("crs_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     ilUtil::redirect($this->getReturnLocation("save", $this->ctrl->getLinkTarget($this, "edit", "", false, false)));
 }
 protected function revertLocalPolicy(ilObject $source, $role)
 {
     global $rbacadmin, $rbacreview, $ilDB;
     $GLOBALS['ilLog']->write(__METHOD__ . ': Reverting policy for role: ' . print_r($role, true));
     // Local policies can only be reverted for auto generated roles. Otherwise the
     // original role settings are unknown
     if (substr($role['title'], 0, 3) != 'il_') {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot revert local policy for role ' . $role['title']);
         return false;
     }
     $role_folder_id = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
     // No role folder found
     if (!$role_folder_id) {
         return false;
     }
     $exploded_title = explode('_', $role['title']);
     $rolt_title = $exploded_title[0] . '_' . $exploded_title[1] . '_' . $exploded_title[2];
     // Lookup role template
     $query = 'SELECT obj_id FROM object_data ' . 'WHERE title = ' . $ilDB->quote($rolt_title, 'text') . ' ' . 'AND type = ' . $ilDB->quote('rolt', 'text');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $rolt_id = $row->obj_id;
     }
     // No template found
     if (!$rolt_id) {
         return false;
     }
     $rbacadmin->copyRoleTemplatePermissions($rolt_id, ROLE_FOLDER_ID, $role_folder_id, $role['obj_id'], true);
     // Change existing object
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role_obj = new ilObjRole($role['obj_id']);
     $role_obj->changeExistingObjects($source->getRefId(), $role['protected'] ? ilObjRole::MODE_PROTECTED_DELETE_LOCAL_POLICIES : ilObjRole::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES, array('all'));
 }
 /**
  * Add object to tree at given position
  *
  * @param ilObject $a_obj
  * @param int $a_parent_node_id
  */
 protected function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
 {
     global $rbacreview, $ilUser, $objDefinition;
     if (!$a_parent_node_id) {
         $a_parent_node_id = $_GET["ref_id"];
     }
     // add new object to custom parent container
     if ((int) $_REQUEST["crtptrefid"]) {
         $a_parent_node_id = (int) $_REQUEST["crtptrefid"];
     }
     $a_obj->createReference();
     $a_obj->putInTree($a_parent_node_id);
     $a_obj->setPermissions($a_parent_node_id);
     $this->obj_id = $a_obj->getId();
     $this->ref_id = $a_obj->getRefId();
     // BEGIN ChangeEvent: Record save object.
     require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
     ilChangeEvent::_recordWriteEvent($this->obj_id, $ilUser->getId(), 'create');
     // END ChangeEvent: Record save object.
     // rbac log
     include_once "Services/AccessControl/classes/class.ilRbacLog.php";
     $rbac_log_roles = $rbacreview->getParentRoleIds($this->ref_id, false);
     $rbac_log = ilRbacLog::gatherFaPa($this->ref_id, array_keys($rbac_log_roles), true);
     ilRbacLog::add(ilRbacLog::CREATE_OBJECT, $this->ref_id, $rbac_log);
     // use forced callback after object creation
     if ($_REQUEST["crtcb"]) {
         $callback_type = ilObject::_lookupType((int) $_REQUEST["crtcb"], true);
         $class_name = "ilObj" . $objDefinition->getClassName($callback_type) . "GUI";
         $location = $objDefinition->getLocation($callback_type);
         include_once $location . "/class." . $class_name . ".php";
         if (in_array(strtolower($class_name), array("ilobjitemgroupgui"))) {
             $callback_obj = new $class_name((int) $_REQUEST["crtcb"]);
         } else {
             // #10368
             $callback_obj = new $class_name(null, (int) $_REQUEST["crtcb"], true, false);
         }
         $callback_obj->afterSaveCallback($a_obj);
     }
 }
 /**	
  * Creates a dav null object as a child of this object.
  * null objects are used for locking names.
  *
  * @param	string		the name of the null object.
  * @return	ilObjectDAV	returns the created object, or null if creation failed.
  */
 function createNull($name)
 {
     global $tree;
     // create and insert Folder in tree
     require_once './Services/Object/classes/class.ilObject.php';
     $newObj = new ilObject(0);
     $newObj->setType('null');
     $newObj->setTitle($name);
     $newObj->create();
     $newObj->createReference();
     $newObj->setPermissions($this->getRefId());
     $newObj->putInTree($this->getRefId());
     require_once 'class.ilObjNullDAV.php';
     $objDAV = new ilObjNullDAV($newObj->getRefId(), $newObj);
     return $objDAV;
 }
 /**
  * save object
  * @access	public
  */
 function afterSave(ilObject $a_new_object)
 {
     $tpl = $this->getDidacticTemplateVar("svytpl");
     if ($tpl) {
         $a_new_object->applySettingsTemplate($tpl);
     }
     $a_new_object->set360Mode((bool) $this->getDidacticTemplateVar("svy360"));
     if ($a_new_object->get360Mode()) {
         // this should rather be ilObjSurvey::ANONYMIZE_ON - see ilObjSurvey::getUserDataFromActiveId()
         $a_new_object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
         $a_new_object->setEvaluationAccess(ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS);
     }
     $a_new_object->saveToDB();
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("object_added"), true);
     ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=" . $a_new_object->getRefId() . "&cmd=properties");
 }
 final function getRefId()
 {
     return parent::getRefId();
 }
 /**
  * Custom callback after object is created (in parent containert
  * 
  * @param ilObject $a_obj 
  */
 public function afterSaveCallback(ilObject $a_obj)
 {
     // add new object to materials
     include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
     $items = new ilItemGroupItems($this->object->getRefId());
     $items->addItem($a_obj->getRefId());
     $items->update();
 }
 protected function afterSave(ilObject $a_new_object)
 {
     // Save link
     $this->link->setLinkResourceId($a_new_object->getId());
     $link_id = $this->link->add();
     $this->link->updateValid(true);
     ilUtil::sendSuccess($this->lng->txt('webr_link_added'));
     // personal workspace
     if ($this->id_type == self::WORKSPACE_NODE_ID) {
         $this->ctrl->redirect($this, "editLinks");
     } else {
         ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $a_new_object->getRefId() . "&cmd=switchViewMode&switch_mode=2");
     }
 }
 /**
  * @param ilObjiLincCourse $a_new_object 
  */
 protected function afterSave(ilObject $a_new_object)
 {
     // save ilinc_id in ILIAS and save data
     $a_new_object->storeiLincId($this->iLincAddCourseResponse->getFirstID());
     $a_new_object->saveActivationStatus(ilUtil::tf2yn((bool) $this->form_gui->getInput('activated')));
     $a_new_object->saveAKClassValues($this->form_gui->getInput('akclassvalue1'), $this->form_gui->getInput('akclassvalue2'));
     // ...finally assign icrsadmin role to creator of icrs object
     $success = $a_new_object->addMember($this->ilias->account, $a_new_object->getDefaultAdminRole(), true);
     if (!$success) {
         ilUtil::sendFailure($a_new_object->getErrorMsg(), true);
         $this->ctrl->returnToParent($this);
     }
     //		$icrsObj->setRegistrationFlag($_POST["enable_registration"]); //0=no registration, 1=registration enabled 2=passwordregistration
     //		$icrsObj->setPassword($_POST["password"]);
     //		$icrsObj->setExpirationDateTime($_POST["expirationdate"]." ".$_POST["expirationtime"].":00");
     $this->ilias->account->addDesktopItem($a_new_object->getRefId(), 'icrs');
     // always send a message
     ilUtil::sendInfo($this->lng->txt('icrs_added'), true);
     $this->redirectToRefId((int) $_GET['ref_id']);
 }
 /**
  * Delete local policy
  *
  * @param int $a_role_id
  * @param ilObject $source
  */
 protected function deleteLocalPolicy($a_role_id, $source)
 {
     global $rbacreview, $rbacadmin;
     // Create role folder if it does not exist
     //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
     if ($rbacreview->getRoleFolderOfRole($a_role_id) == $source->getRefId()) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
         return false;
     }
     $rbacadmin->deleteLocalRole($a_role_id, $source->getRefId());
     // Change existing object
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role = new ilObjRole($a_role_id);
     $role->changeExistingObjects($source->getRefId(), ilObjRole::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES, array('all'));
     return true;
 }
 protected function afterSave(ilObject $a_new_object)
 {
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sort = new ilContainerSortingSettings($a_new_object->getId());
     $sort->setSortMode(ilContainer::SORT_INHERIT);
     $sort->update();
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("fold_added"), true);
     $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
     $this->redirectToRefId($a_new_object->getRefId(), "");
 }
 /**
  * Custom callback after object is created (in parent containert
  * 
  * @param ilObject $a_obj 
  */
 public function afterSaveCallback(ilObject $a_obj)
 {
     // add new object to materials
     include_once './Modules/Session/classes/class.ilEventItems.php';
     $event_items = new ilEventItems($this->object->getId());
     $event_items->addItem($a_obj->getRefId());
     $event_items->update();
     /*
     ilUtil::sendSuccess($this->lng->txt("object_added"), true);
     $this->ctrl->redirect($this, "materials");
     */
 }
 protected function afterSave(ilObject $a_new_object)
 {
     $a_new_object->saveData();
     ilUtil::sendSuccess($this->lng->txt("exc_added"), true);
     ilUtil::redirect("ilias.php?baseClass=ilExerciseHandlerGUI&ref_id=" . $a_new_object->getRefId() . "&cmd=addAssignment");
 }
 /**
  * save object
  * @access	public
  */
 function afterSave(ilObject $a_new_object)
 {
     $tpl = $this->getDidacticTemplateVar("svytpl");
     if ($tpl) {
         $a_new_object->applySettingsTemplate($tpl);
     }
     // always send a message
     ilUtil::sendSuccess($this->lng->txt("object_added"), true);
     ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=" . $a_new_object->getRefId() . "&cmd=properties");
 }