当前位置: 首页>>代码示例>>PHP>>正文


PHP ilTree::deleteTree方法代码示例

本文整理汇总了PHP中ilTree::deleteTree方法的典型用法代码示例。如果您正苦于以下问题:PHP ilTree::deleteTree方法的具体用法?PHP ilTree::deleteTree怎么用?PHP ilTree::deleteTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilTree的用法示例。


在下文中一共展示了ilTree::deleteTree方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: confirmedDelete

 /**
  * delete page object or structure objects
  *
  * @param	int		$a_parent_subobj_id		id of parent object (structure object)
  *											of the objects, that should be deleted
  *											(or no parent object id for top level)
  */
 function confirmedDelete($a_parent_subobj_id = 0)
 {
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // check number of objects
     if (!$_POST["id"]) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // delete all selected objects
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setLMId($this->object->getId());
                 include_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($this->object->getId(), "delete_" . $obj->getType(), array(ilLMObject::_lookupTitle($id), $id), $this->object->getType());
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     $this->object->checkTree();
     // feedback
     ilUtil::sendSuccess($this->lng->txt("info_deleted"), true);
     if ($a_parent_subobj_id == 0) {
         $this->ctrl->redirect($this, $_GET["backcmd"]);
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:40,代码来源:class.ilObjContentObjectGUI.php

示例2: confirmedDelete

 /**
  * Delete chapters/scos/pages
  */
 function confirmedDelete($a_redirect = true)
 {
     global $ilCtrl;
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // delete all selected objects
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setSLMId($this->object->getId());
                 /*include_once("./Services/History/classes/class.ilHistory.php");
                 	 ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
                 		array(ilLMObject::_lookupTitle($id), $id),
                 		$this->object->getType());*/
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     //		$this->object->checkTree();
     // feedback
     ilUtil::sendInfo($this->lng->txt("info_deleted"), true);
     if ($a_redirect) {
         $ilCtrl->redirect($this, "showOrganization");
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:36,代码来源:class.ilObjSCORM2004LearningModuleGUI.php

示例3: purge

 /**
  * checks if rolefolder contains any roles. if not the rolefolder is deleted
  * @access	public
  * @return	boolean	true if rolefolder is deleted
  */
 function purge()
 {
     global $rbacreview, $rbacadmin, $tree;
     $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
     if (count($local_roles) == 0) {
         $rbacadmin->revokePermission($this->getRefId());
         if ($tree_id = $this->isDeleted()) {
             $deleted_tree = new ilTree($tree_id, -(int) $tree_id);
             $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
         } else {
             $tree->deleteTree($tree->getNodeData($this->getRefId()));
         }
         $this->delete();
         return true;
     }
     return false;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:22,代码来源:class.ilObjRoleFolder.php

示例4: executeDragDrop

 /**
  * Execute Drag Drop Action
  *
  * @param	string	$source_id		Source element ID
  * @param	string	$target_id		Target element ID
  * @param	string	$first_child	Insert as first child of target
  * @param	string	$movecopy		Position ("move" | "copy")
  */
 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
 {
     $lmtree = new ilTree($this->getId());
     $lmtree->setTableNames('lm_tree', 'lm_data');
     $lmtree->setTreeTablePK("lm_id");
     //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
     $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
     $source_obj->setLMId($this->getId());
     if (!$first_child) {
         $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
         $target_obj->setLMId($this->getId());
         $target_parent = $lmtree->getParentId($target_id);
     }
     // handle pages
     if ($source_obj->getType() == "pg") {
         //echo "1";
         if ($lmtree->isInTree($source_obj->getId())) {
             $node_data = $lmtree->getNodeData($source_obj->getId());
             // cut on move
             if ($movecopy == "move") {
                 $parent_id = $lmtree->getParentId($source_obj->getId());
                 $lmtree->deleteTree($node_data);
                 // write history entry
                 require_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($source_obj->getId(), "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->getType() . ":pg");
                 ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
             } else {
                 // copy page
                 $new_page =& $source_obj->copy();
                 $source_id = $new_page->getId();
                 $source_obj =& $new_page;
             }
             // paste page
             if (!$lmtree->isInTree($source_obj->getId())) {
                 if ($first_child) {
                     $target_pos = IL_FIRST_NODE;
                     $parent = $target_id;
                 } else {
                     if ($as_subitem) {
                         $parent = $target_id;
                         $target_pos = IL_FIRST_NODE;
                         $pg_childs =& $lmtree->getChildsByType($parent, "pg");
                         if (count($pg_childs) != 0) {
                             $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
                         }
                     } else {
                         $target_pos = $target_id;
                         $parent = $target_parent;
                     }
                 }
                 // insert page into tree
                 $lmtree->insertNode($source_obj->getId(), $parent, $target_pos);
                 // write history entry
                 if ($movecopy == "move") {
                     // write history comments
                     include_once "./Services/History/classes/class.ilHistory.php";
                     ilHistory::_createEntry($source_obj->getId(), "paste", array(ilLMObject::_lookupTitle($parent), $parent), $this->getType() . ":pg");
                     ilHistory::_createEntry($parent, "paste_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
                 }
             }
         }
     }
     // handle chapters
     if ($source_obj->getType() == "st") {
         //echo "2";
         $source_node = $lmtree->getNodeData($source_id);
         $subnodes = $lmtree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
             if (count($pg_childs) != 0) {
                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
             }
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs =& $lmtree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // insert into
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilObjContentObject.php

示例5: restoreObjects

 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser, $tree;
         $node_data = $saved_tree->getNodeData($id);
         $saved_tree->deleteTree($node_data);
         // Record undelete event
         $node_data = $tree->getNodeData($id);
         $parent_data = $tree->getParentNodeData($node_data['ref_id']);
         ilChangeEvent::_recordWriteEvent($node_data['obj_id'], $ilUser->getId(), 'undelete', $parent_data['obj_id']);
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:43,代码来源:class.ilRepUtil.php

示例6: cutPage

 /**
  * cut page
  */
 function cutPage()
 {
     $this->cutItems();
     return;
     if (!isset($_POST["id"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) > 1) {
         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE) {
         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
     }
     // SAVE POST VALUES
     ilEditClipboard::storeContentObject("pg", $_POST["id"][0]);
     $tree = new ilTree($this->content_object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // cut selected object
     $cutted = 0;
     foreach ($_POST["id"] as $id) {
         if ($id == -1) {
             continue;
         }
         $obj =& ilLMObjectFactory::getInstance($this->content_object, $id);
         $obj->setLMId($this->content_object->getId());
         $node_data = $tree->getNodeData($id);
         //$obj->delete();
         if ($tree->isInTree($id)) {
             $parent_id = $tree->getParentId($id);
             $tree->deleteTree($node_data);
             // write history entry
             require_once "./Services/History/classes/class.ilHistory.php";
             ilHistory::_createEntry($id, "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->content_object->getType() . ":pg");
             ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($id), $id), $this->content_object->getType() . ":st");
         }
         $cutted++;
     }
     // tree check
     $this->checkTree();
     if ($cutted > 0) {
         ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
     }
     $this->ctrl->redirect($this, "view");
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:48,代码来源:class.ilStructureObjectGUI.php

示例7: restoreObjects

 /**
  * Move objects from trash back to repository
  */
 function restoreObjects($a_cur_ref_id, $a_ref_ids)
 {
     global $rbacsystem, $log, $ilAppEventHandler, $lng, $tree;
     $cur_obj_id = ilObject::_lookupObjId($a_cur_ref_id);
     foreach ($a_ref_ids as $id) {
         $obj_data = ilObjectFactory::getInstanceByRefId($id);
         if (!$rbacsystem->checkAccess('create', $a_cur_ref_id, $obj_data->getType())) {
             $no_create[] = ilObject::_lookupTitle(ilObject::_lookupObjId($id));
         }
     }
     if (count($no_create)) {
         include_once "./Services/Repository/exceptions/class.ilRepositoryException.php";
         throw new ilRepositoryException($lng->txt("msg_no_perm_paste") . " " . implode(',', $no_create));
     }
     $affected_ids = array();
     foreach ($a_ref_ids as $id) {
         $affected_ids[$id] = $id;
         // INSERT AND SET PERMISSIONS
         ilRepUtil::insertSavedNodes($id, $a_cur_ref_id, -(int) $id, $affected_ids);
         // DELETE SAVED TREE
         $saved_tree = new ilTree(-(int) $id);
         $saved_tree->deleteTree($saved_tree->getNodeData($id));
         include_once './Services/Object/classes/class.ilObjectFactory.php';
         $factory = new ilObjectFactory();
         $ref_obj = $factory->getInstanceByRefId($id, FALSE);
         if ($ref_obj instanceof ilObject) {
             $lroles = $GLOBALS['rbacreview']->getRolesOfRoleFolder($id, FALSE);
             foreach ($lroles as $role_id) {
                 include_once './Services/AccessControl/classes/class.ilObjRole.php';
                 $role = new ilObjRole($role_id);
                 $role->setParent($id);
                 $role->delete();
             }
             $parent_ref = $GLOBALS['tree']->getParentId($id);
             if ($parent_ref) {
                 $ref_obj->setPermissions($parent_ref);
             }
         }
         // BEGIN ChangeEvent: Record undelete.
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         ilChangeEvent::_recordWriteEvent(ilObject::_lookupObjId($id), $ilUser->getId(), 'undelete', ilObject::_lookupObjId($tree->getParentId($id)));
         ilChangeEvent::_catchupWriteEvents($cur_obj_id, $ilUser->getId());
         // END PATCH ChangeEvent: Record undelete.
     }
     // send events
     foreach ($affected_ids as $id) {
         // send global event
         $ilAppEventHandler->raise("Services/Object", "undelete", array("obj_id" => ilObject::_lookupObjId($id), "ref_id" => $id));
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:54,代码来源:class.ilRepUtil.php

示例8: testTreeTrash

 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);
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:52,代码来源:ilObjectTest.php


注:本文中的ilTree::deleteTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。