19 declare(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 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"]
125 if (!$direct_from_tree || $node_obj->getType() !==
"fold") {
129 $this->
event->failedRemoval(
131 $node_obj->getRefId(),
132 $node_obj->getType(),
133 $node_obj->getTitle(),
142 if (!$direct_from_tree) {
144 $saved_tree->deleteTree($node_data);
147 $this->tree->deleteTree($node_data);
150 $this->
event->afterTreeDeletion(
151 (
int) $node_data[
'tree'],
152 (
int) $node_data[
'child']
157 foreach ($affected_ids as $aid) {
158 $this->
event->afterObjectRemoval(
162 $aid[
"old_parent_ref_id"]
173 bool $a_delete_objects,
174 array &$a_affected_ids
177 foreach ($this->tree->getTrashedSubtrees($a_node_id) as $tree_id) {
180 if (!in_array($tree_id, $a_checked)) {
181 $deleted_tree = $this->tree->getTree($tree_id);
182 $a_checked[] = $tree_id;
186 $del_node_data = $deleted_tree->getNodeData($tree_id);
187 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
191 if ($a_delete_objects) {
192 foreach ($del_subtree_nodes as $node) {
193 $object = $this->
object->getInstanceByRefId($node[
"ref_id"]);
194 if (!is_null($object)) {
195 $a_affected_ids[$node[
"ref_id"]] = [
196 "ref_id" => $node[
"ref_id"],
197 "obj_id" => $object->getId(),
198 "type" => $object->getType(),
199 "old_parent_ref_id" => $node[
"parent"]
201 $this->
event->beforeObjectRemoval(
210 $this->
event->failedRemoval(
222 $trash_tree = $this->tree->getTree((
int) $del_node_data[
'tree']);
223 $trash_tree->deleteTree($del_node_data);
224 $this->
event->afterTreeDeletion(
225 (
int) $del_node_data[
'tree'],
226 (
int) $del_node_data[
'child']
237 $affected_parents = [];
238 foreach ($ids as
$id) {
239 if ($this->tree->isDeleted($id)) {
243 $subnodes = $this->tree->getSubtree($this->tree->getNodeData($id));
245 foreach ($subnodes as $subnode) {
246 $this->permission->revokePermission((
int) $subnode[
"child"]);
248 $affected_ids[$subnode[
"child"]] = $subnode[
"child"];
249 $affected_parents[$subnode[
"child"]] = $subnode[
"parent"];
252 $this->
event->beforeMoveToTrash($id, $subnodes);
254 if (!$this->tree->moveToTrash($id)) {
261 foreach ($affected_ids as $aid) {
262 $this->
event->afterMoveToTrash($aid, $affected_parents[$aid]);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__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 ===...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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.
deleteObjectsByRefIds(array $ids)
Delete: If trash is enabled, objects are moved to the trash.