예제 #1
0
 /**
  * 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 database reference id for the object (saves the object 
 * to the database and creates a reference id in the database)
 *
 * @access public
 */
 function createReference()
 {
     $result = parent::createReference();
     $this->saveToDb();
     return $result;
 }
예제 #3
0
 /**
  * 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"]);
 }
예제 #4
0
 final function createReference()
 {
     return parent::createReference();
 }
예제 #5
0
 /**	
  * 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;
 }
예제 #6
0
 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);
 }