34 $this->db =
$DIC->database();
35 $this->tree =
$DIC->repositoryTree();
52 $DIC->repository()->internal()->domain()->deletion()->deleteObjectsByRefIds($a_ids);
66 bool $a_from_recovery_folder =
false
70 $ilLog =
$DIC[
"ilLog"];
71 $ilAppEventHandler =
$DIC[
"ilAppEventHandler"];
72 $tree =
$DIC->repositoryTree();
73 $logger =
$DIC->logger()->rep();
80 $a_ref_ids = array_map(
'intval', $a_ref_ids);
81 foreach ($a_ref_ids as
$id) {
84 if (!$a_from_recovery_folder) {
86 $tree_id = end($trees);
89 $saved_tree =
new ilTree($tree_id);
90 $node_data = $saved_tree->getNodeData(
$id);
91 $subtree_nodes = $saved_tree->getSubTree($node_data);
93 if (isset($affected_ids[
$id])) {
101 $subtree_nodes = $tree->
getSubTree($node_data);
106 $ilUser =
$DIC->user();
107 $tree =
$DIC->repositoryTree();
110 $node_data[
'obj_id'],
118 if (!$a_from_recovery_folder) {
125 self::removeDeletedNodes(
$id, $checked,
true, $affected_ids);
127 foreach ($subtree_nodes as $node) {
133 'delete obj_id: ' . $node_obj->getId() .
134 ', ref_id: ' . $node_obj->getRefId() .
135 ', type: ' . $node_obj->getType() .
136 ', title: ' . $node_obj->getTitle()
138 $affected_ids[$node[
"ref_id"]] = [
139 "ref_id" => $node[
"ref_id"],
140 "obj_id" => $node_obj->getId(),
141 "type" => $node_obj->getType(),
142 "old_parent_ref_id" => $node[
"parent"]
149 if (!$a_from_recovery_folder) {
151 $saved_tree->deleteTree($node_data);
158 'deleted tree, tree_id: ' . $node_data[
'tree'] .
159 ', child: ' . $node_data[
'child']
164 foreach ($affected_ids as $aid) {
165 $ilAppEventHandler->raise(
166 "components/ILIAS/ILIASObject",
169 "obj_id" => $aid[
"obj_id"],
170 "ref_id" => $aid[
"ref_id"],
171 "type" => $aid[
"type"],
172 "old_parent_ref_id" => $aid[
"old_parent_ref_id"]
184 bool $a_delete_objects,
185 array &$a_affected_ids
189 $ilLog =
$DIC[
"ilLog"];
191 $tree =
$DIC->repositoryTree();
192 $logger =
$DIC->logger()->rep();
199 ' AND tree = -1 * child' ;
203 while ($row =
$ilDB->fetchObject($r)) {
205 if (!in_array($row->tree, $a_checked)) {
206 $deleted_tree =
new ilTree($row->tree);
207 $a_checked[] = $row->tree;
210 $del_node_data = $deleted_tree->getNodeData($row->tree);
211 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
213 self::removeDeletedNodes($row->tree, $a_checked, $a_delete_objects, $a_affected_ids);
215 if ($a_delete_objects) {
216 foreach ($del_subtree_nodes as $node) {
219 'removeDeletedNodes: delete obj_id: ' . $node_obj->getId() .
220 ', ref_id: ' . $node_obj->getRefId() .
221 ', type: ' . $node_obj->getType() .
222 ', title: ' . $node_obj->getTitle()
224 $a_affected_ids[$node[
"ref_id"]] = [
225 "ref_id" => $node[
"ref_id"],
226 "obj_id" => $node_obj->getId(),
227 "type" => $node_obj->getType(),
228 "old_parent_ref_id" => $node[
"parent"]
234 $trash_tree =
new ilTree($del_node_data[
'tree']);
235 $trash_tree->deleteTree($del_node_data);
237 'removeDeltedNodes: deleted tree, tree_id: ' . $del_node_data[
'tree'] .
238 ', child: ' . $del_node_data[
'child']
258 $rbacsystem =
$DIC->rbac()->system();
259 $ilAppEventHandler =
$DIC[
"ilAppEventHandler"];
261 $tree =
$DIC->repositoryTree();
267 foreach ($a_ref_ids as
$id) {
270 if (!$rbacsystem->checkAccess(
'create', $a_cur_ref_id, $obj_data->getType())) {
275 if (count($no_create)) {
281 foreach ($a_ref_ids as
$id) {
287 $tree_id = $tree_ids[0];
288 self::insertSavedNodes(
$id, $a_cur_ref_id, $tree_id, $affected_ids);
289 }
catch (Exception
$e) {
297 $ilUser =
$DIC->user();
310 foreach ($affected_ids as
$id) {
312 $ilAppEventHandler->raise(
313 "components/ILIAS/ILIASObject",
327 array &$a_affected_ids
331 $tree =
$DIC->repositoryTree();
333 ilLoggerFactory::getLogger(
'rep')->debug(
'Restoring from trash: source_id: ' . $a_source_id .
', dest_id: ' . $a_dest_id .
', tree_id:' . $a_tree_id);
337 $saved_tree =
new ilTree($a_tree_id);
338 $childs = $saved_tree->getChilds($a_source_id);
343 }
catch (Exception
$e) {
350 $lroles =
$GLOBALS[
'rbacreview']->getRolesOfRoleFolder($a_source_id,
true);
351 foreach ($lroles as $role_id) {
353 $role->setParent($a_source_id);
357 $ref_obj->setPermissions($a_dest_id);
360 foreach ($childs as $child) {
361 self::insertSavedNodes($child[
"child"], $a_source_id, $a_tree_id, $a_affected_ids);
378 $set =
$ilDB->query(
"SELECT child" .
380 " JOIN object_reference ref ON (tree.child = ref.ref_id)" .
381 " JOIN object_data od ON (od.obj_id = ref.obj_id)" .
382 " WHERE tree.tree < " .
$ilDB->quote(0,
"integer") .
383 " AND od.type = " .
$ilDB->quote($a_type,
"text"));
384 while ($row =
$ilDB->fetchAssoc($set)) {
385 $res[] = $row[
"child"];
396 $set =
$ilDB->query(
"SELECT obj_id" .
397 " FROM object_data " .
398 " WHERE type = " .
$ilDB->quote(
"typ",
"text") .
399 " AND title = " .
$ilDB->quote($a_type,
"text"));
400 $row =
$ilDB->fetchAssoc($set);
401 return (
int) $row[
"obj_id"];
414 if ($ref_ids_in_tree) {
415 self::deleteObjects(0, $ref_ids_in_tree);
419 $ref_ids_in_trash = $this->findTypeInTrash($a_type);
420 if ($ref_ids_in_trash) {
421 self::removeObjectsFromSystem($ref_ids_in_trash);
426 $type_id = $this->getObjectTypeId($a_type);
430 $ilDB->manipulate(
"DELETE FROM object_data" .
431 " WHERE obj_id = " .
$ilDB->quote($type_id,
"integer"));
436 $ilDB->manipulate(
"DELETE FROM rbac_ta" .
437 " WHERE typ_id = " .
$ilDB->quote($type_id,
"integer")
441 $set =
$ilDB->query(
"SELECT ops_id" .
442 " FROM rbac_operations " .
443 " WHERE class = " .
$ilDB->quote(
"create",
"text") .
444 " AND operation = " .
$ilDB->quote(
"create_" . $a_type,
"text"));
445 $row =
$ilDB->fetchAssoc($set);
446 $create_ops_id = $row[
"ops_id"];
447 if ($create_ops_id) {
448 $ilDB->manipulate(
"DELETE FROM rbac_operations" .
449 " WHERE ops_id = " .
$ilDB->quote($create_ops_id,
"integer"));
451 $ilDB->manipulate(
"DELETE FROM rbac_templates" .
452 " WHERE ops_id = " .
$ilDB->quote($create_ops_id,
"integer"));
455 foreach ([
"root",
"cat",
"crs",
"grp",
"fold"] as $parent_type) {
456 $parent_type_id = $this->getObjectTypeId($parent_type);
457 if ($parent_type_id) {
458 $ilDB->manipulate(
"DELETE FROM rbac_ta" .
459 " WHERE typ_id = " .
$ilDB->quote($parent_type_id,
"integer") .
460 " AND ops_id = " .
$ilDB->quote($create_ops_id,
"integer"));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _recordWriteEvent(int $obj_id, int $usr_id, string $action, ?int $parent_obj_id=null)
Records a write event.
static getLogger(string $a_component_id)
Get component logger.
static deleteObjectType(string $a_type)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static insertSavedNodes(int $a_source_id, int $a_dest_id, int $a_tree_id, array &$a_affected_ids)
Recursive method to insert all saved nodes of the clipboard.
static removeDeletedNodes(int $a_node_id, array $a_checked, bool $a_delete_objects, array &$a_affected_ids)
Remove already deleted objects within the objects in trash.
static restoreObjects(int $a_cur_ref_id, array $a_ref_ids)
Move objects from trash back to repository.
static removeObjectsFromSystem(array $a_ref_ids, bool $a_from_recovery_folder=false)
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...
findTypeInTrash(string $a_type)
getObjectTypeId(string $a_type)
static deleteObjects(int $a_cur_ref_id, array $a_ids)
Delete objects.
deleteObjectType(string $a_type)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
insertNodeFromTrash(int $a_source_id, int $a_target_id, int $a_tree_id, int $a_pos=self::POS_LAST_NODE, bool $a_reset_deleted_date=false)
Insert node from trash deletes trash entry.
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
static lookupTreesForNode(int $node_id)
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
deleteTree(array $a_node)
delete node and the whole subtree under this node
getParentId(int $a_node_id)
get parent id of given node