19declare(strict_types=1);
30 protected bool $trash_enabled
43 if (count($del_ids = $this->tree->getDeletedTreeNodeIds($ids)) > 0) {
48 if (count($miss_ids = $this->permission->getRefIdsWithoutDeletePermission($ids)) > 0) {
52 if ($this->trash_enabled) {
65 bool $direct_from_tree =
false
69 $ref_ids = array_map(
'intval', $ref_ids);
70 foreach ($ref_ids as
$id) {
74 if (!$direct_from_tree) {
76 $saved_tree = $this->tree->getTrashTree(
$id);
77 $node_data = $saved_tree->getNodeData(
$id);
79 $subtree_nodes = $saved_tree->getSubTree($node_data);
82 $node_data = $this->tree->getNodeData(
$id);
84 $subtree_nodes = $this->tree->getSubTree($node_data);
87 $this->
event->beforeSubTreeRemoval(
92 if (!$direct_from_tree) {
100 foreach ($subtree_nodes as $node) {
101 if (!$node_obj = $this->
object->getInstanceByRefId($node[
"ref_id"])) {
108 $this->
event->beforeObjectRemoval(
110 $node_obj->getRefId(),
111 $node_obj->getType(),
112 $node_obj->getTitle()
114 $affected_ids[$node[
"ref_id"]] = [
115 "ref_id" => $node[
"ref_id"],
116 "obj_id" => $node_obj->getId(),
117 "type" => $node_obj->getType(),
118 "old_parent_ref_id" => $node[
"parent"]
123 }
catch (\Exception
$e) {
124 $this->
event->failedRemoval(
126 $node_obj->getRefId(),
127 $node_obj->getType(),
128 $node_obj->getTitle(),
135 if (!$direct_from_tree) {
137 $saved_tree->deleteTree($node_data);
140 $this->tree->deleteTree($node_data);
143 $this->
event->afterTreeDeletion(
144 (
int) $node_data[
'tree'],
145 (
int) $node_data[
'child']
150 foreach ($affected_ids as $aid) {
151 $this->
event->afterObjectRemoval(
155 $aid[
"old_parent_ref_id"]
166 bool $a_delete_objects,
167 array &$a_affected_ids
170 foreach ($this->tree->getTrashedSubtrees($a_node_id) as $tree_id) {
173 if (!in_array($tree_id, $a_checked)) {
174 $deleted_tree = $this->tree->getTree($tree_id);
175 $a_checked[] = $tree_id;
179 $del_node_data = $deleted_tree->getNodeData($tree_id);
180 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
184 if ($a_delete_objects) {
185 foreach ($del_subtree_nodes as $node) {
186 $object = $this->
object->getInstanceByRefId($node[
"ref_id"]);
187 if (!is_null($object)) {
188 $a_affected_ids[$node[
"ref_id"]] = [
189 "ref_id" => $node[
"ref_id"],
190 "obj_id" => $object->getId(),
191 "type" => $object->getType(),
192 "old_parent_ref_id" => $node[
"parent"]
194 $this->
event->beforeObjectRemoval(
202 }
catch (\Exception
$e) {
203 $this->
event->failedRemoval(
215 $trash_tree = $this->tree->getTree((
int) $del_node_data[
'tree']);
216 $trash_tree->deleteTree($del_node_data);
217 $this->
event->afterTreeDeletion(
218 (
int) $del_node_data[
'tree'],
219 (
int) $del_node_data[
'child']
230 $affected_parents = [];
231 foreach ($ids as
$id) {
232 if ($this->tree->isDeleted(
$id)) {
236 $subnodes = $this->tree->getSubtree($this->tree->getNodeData(
$id));
238 foreach ($subnodes as $subnode) {
239 $this->permission->revokePermission((
int) $subnode[
"child"]);
241 $affected_ids[$subnode[
"child"]] = $subnode[
"child"];
242 $affected_parents[$subnode[
"child"]] = $subnode[
"parent"];
245 $this->
event->beforeMoveToTrash($id, $subnodes);
247 if (!$this->tree->moveToTrash(
$id)) {
254 foreach ($affected_ids as $aid) {
255 $this->
event->afterMoveToTrash($aid, $affected_parents[$aid]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(protected TreeInterface $tree, protected PermissionInterface $permission, protected EventInterface $event, protected ObjectInterface $object, protected bool $trash_enabled)
removeObjectsFromSystemByRefIds(array $ref_ids, bool $direct_from_tree=false)
Remove objects from system directly ($direct_from_tree === true) or from trash ($direct_from_tree ===...
deleteObjectsByRefIds(array $ids)
Delete: If trash is enabled, objects are moved to the trash.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...