4 include_once(
"./Services/Object/classes/class.ilObjectFactory.php");
24 global $ilAppEventHandler, $rbacsystem, $rbacadmin,
$log,
$ilUser, $tree,
$lng,
27 include_once(
"./Services/Repository/exceptions/class.ilRepositoryException.php");
30 $a_ids = array_unique((
array) $a_ids);
33 foreach ($a_ids as $id)
35 if ($tree->isDeleted($id))
37 $log->write(__METHOD__.
': Object with ref_id: '.$id.
' already deleted.');
42 $node_data = $tree->getNodeData($id);
43 $subtree_nodes = $tree->getSubTree($node_data);
45 $all_node_data[] = $node_data;
46 $all_subtree_nodes[] = $subtree_nodes;
49 foreach ($subtree_nodes as $node)
51 if($node[
'type'] ==
'rolf')
55 if (!$rbacsystem->checkAccess(
'delete',$node[
"child"]))
57 $not_deletable[] = $node[
"child"];
58 $perform_delete =
false;
64 if (count($not_deletable))
66 $not_deletable_titles =
array();
67 foreach ($not_deletable as $key =>
$ref_id) {
74 $lng->txt(
"msg_no_perm_delete").
" ".implode(
', ',$not_deletable_titles).
"<br/>".$lng->txt(
"msg_cancel"));
78 if (!$all_node_data[0][
"type"])
84 if ($rbacsystem->checkAccess(
'delete', $a_cur_ref_id))
86 foreach($a_ids as $id)
92 $log->write(
"ilObjectGUI::confirmedDeleteObject(), deleted obj_id ".$obj->getId().
93 ", type: ".$obj->getType().
", title: ".$obj->getTitle());
99 $lng->txt(
"no_perm_delete").
"<br/>".$lng->txt(
"msg_cancel"));
105 $affected_ids =
array();
106 $affected_parents =
array();
107 foreach ($a_ids as $id)
109 if($tree->isDeleted($id))
111 $log->write(__METHOD__.
': Object with ref_id: '.$id.
' already deleted.');
116 $subnodes = $tree->getSubtree($tree->getNodeData($id));
118 foreach ($subnodes as $subnode)
120 $rbacadmin->revokePermission($subnode[
"child"]);
124 $affected_ids[$subnode[
"child"]] = $subnode[
"child"];
125 $affected_parents[$subnode[
"child"]] = $subnode[
"parent"];
134 include_once(
'./Services/WebServices/ECS/classes/class.ilECSObjectSettings.php');
137 if(!$tree->saveSubTree($id,
true))
139 $log->write(__METHOD__.
': Object with ref_id: '.$id.
' already deleted.');
144 $log->write(
"ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$id.
150 $affected_ids[$id] = $id;
157 foreach ($affected_ids as $aid)
159 $ilAppEventHandler->raise(
"Services/Object",
"toTrash",
162 "old_parent_ref_id" => $affected_parents[$aid]
167 if (!$ilSetting->get(
'enable_trash'))
180 global $rbacsystem,
$log, $ilAppEventHandler, $tree;
182 $affected_ids =
array();
185 foreach ($a_ref_ids as $id)
188 if (!$a_from_recovery_folder)
190 $saved_tree =
new ilTree(-(
int)$id);
191 $node_data = $saved_tree->getNodeData($id);
192 $subtree_nodes = $saved_tree->getSubTree($node_data);
196 $node_data = $tree->getNodeData($id);
197 $subtree_nodes = $tree->getSubTree($node_data);
201 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
204 $parent_data = $tree->getParentNodeData($node_data[
'ref_id']);
206 $parent_data[
'obj_id']);
210 if (!$a_from_recovery_folder)
212 $checked[] = -(int) $id;
222 foreach ($subtree_nodes as $node)
230 $log->write(
"ilObjectGUI::removeFromSystemObject(), delete obj_id: ".$node_obj->getId().
231 ", ref_id: ".$node_obj->getRefId().
", type: ".$node_obj->getType().
", ".
232 "title: ".$node_obj->getTitle());
233 $affected_ids[$node[
"ref_id"]] =
array(
234 "ref_id" => $node[
"ref_id"],
235 "obj_id" => $node_obj->getId(),
236 "type" => $node_obj->getType(),
237 "old_parent_ref_id" => $node[
"parent"]);
243 if (!$a_from_recovery_folder || $node_obj->getType() !=
"fold")
250 if (!$a_from_recovery_folder)
252 $saved_tree->deleteTree($node_data);
256 $tree->deleteTree($node_data);
260 $log->write(
"ilObjectGUI::removeFromSystemObject(), deleted tree, tree_id: ".$node_data[
"tree"].
261 ", child: ".$node_data[
"child"]);
266 foreach ($affected_ids as $aid)
268 $ilAppEventHandler->raise(
"Services/Object",
"delete",
269 array(
"obj_id" => $aid[
"obj_id"],
270 "ref_id" => $aid[
"ref_id"],
271 "type" => $aid[
"type"],
272 "old_parent_ref_id" => $aid[
"old_parent_ref_id"]));
284 $q =
"SELECT tree FROM tree WHERE parent= ".
285 $ilDB->quote($a_node_id,
"integer").
" AND tree < 0";
287 $r = $ilDB->query($q);
289 while(
$row = $ilDB->fetchObject(
$r))
292 if (!in_array(
$row->tree,$a_checked))
295 $a_checked[] =
$row->tree;
298 $del_node_data = $deleted_tree->getNodeData(
$row->tree);
299 $del_subtree_nodes = $deleted_tree->getSubTree($del_node_data);
303 if ($a_delete_objects)
305 foreach ($del_subtree_nodes as $node)
310 $log->write(
"ilObjectGUI::removeDeletedNodes(), delete obj_id: ".$node_obj->getId().
311 ", ref_id: ".$node_obj->getRefId().
", type: ".$node_obj->getType().
", ".
312 "title: ".$node_obj->getTitle());
313 $a_affected_ids[$node[
"ref_id"]] =
array(
314 "ref_id" => $node[
"ref_id"],
315 "obj_id" => $node_obj->getId(),
316 "type" => $node_obj->getType(),
317 "old_parent_ref_id" => $node[
"parent"]);
324 $tree->deleteTree($del_node_data);
327 $log->write(
"ilObjectGUI::removeDeletedNodes(), deleted tree, tree_id: ".$del_node_data[
"tree"].
328 ", child: ".$del_node_data[
"child"]);
340 global $rbacsystem,
$log, $ilAppEventHandler,
$lng, $tree;
344 foreach ($a_ref_ids as $id)
348 if (!$rbacsystem->checkAccess(
'create', $a_cur_ref_id, $obj_data->getType()))
354 if (count($no_create))
356 include_once(
"./Services/Repository/exceptions/class.ilRepositoryException.php");
360 $affected_ids =
array();
362 foreach ($a_ref_ids as $id)
364 $affected_ids[$id] = $id;
371 include_once(
"./Services/Repository/exceptions/class.ilRepositoryException.php");
377 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
395 foreach ($affected_ids as $id)
398 $ilAppEventHandler->raise(
"Services/Object",
"undelete",
406 private static function insertSavedNodes($a_source_id, $a_dest_id, $a_tree_id, &$a_affected_ids)
408 global $rbacadmin, $rbacreview,
$log, $tree;
410 ilLoggerFactory::getLogger(
'rep')->debug(
'Restoring from trash: source_id: '. $a_source_id.
', dest_id: '. $a_dest_id.
', tree_id:'. $a_tree_id);
414 $saved_tree =
new ilTree($a_tree_id);
415 $childs = $saved_tree->getChilds($a_source_id);
419 $tree->insertNodeFromTrash($a_source_id, $a_dest_id, $a_tree_id,
IL_LAST_NODE,
true);
426 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
428 $ref_obj = $factory->getInstanceByRefId($a_source_id,FALSE);
431 $lroles =
$GLOBALS[
'rbacreview']->getRolesOfRoleFolder($a_source_id,
true);
432 foreach($lroles as $role_id)
434 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
436 $role->setParent($a_source_id);
441 $ref_obj->setPermissions($a_dest_id);
444 foreach ($childs as $child)
462 $set = $ilDB->query(
"SELECT child".
464 " JOIN object_reference ref ON (tree.child = ref.ref_id)".
465 " JOIN object_data od ON (od.obj_id = ref.obj_id)".
466 " WHERE tree.tree < ".$ilDB->quote(0,
"integer").
467 " AND od.type = ".$ilDB->quote(
$a_type,
"text"));
468 while(
$row = $ilDB->fetchAssoc($set))
480 $set = $ilDB->query(
"SELECT obj_id".
481 " FROM object_data ".
482 " WHERE type = ".$ilDB->quote(
"typ",
"text").
483 " AND title = ".$ilDB->quote(
$a_type,
"text"));
484 $row = $ilDB->fetchAssoc($set);
485 return $row[
"obj_id"];
494 $ref_ids_in_tree = $tree->getSubTree($tree->getNodeData(ROOT_FOLDER_ID),
false,
$a_type);
500 if($ilSetting->get(
'enable_trash'))
503 if($ref_ids_in_trash)
505 self::removeObjectsFromSystem($ref_ids_in_trash);
515 $ilDB->manipulate(
"DELETE FROM object_data".
516 " WHERE obj_id = ".$ilDB->quote($type_id,
"integer"));
521 $ilDB->manipulate(
"DELETE FROM rbac_ta".
522 " WHERE typ_id = ".$ilDB->quote($type_id,
"integer")
526 $set = $ilDB->query(
"SELECT ops_id".
527 " FROM rbac_operations ".
528 " WHERE class = ".$ilDB->quote(
"create",
"text").
529 " AND operation = ".$ilDB->quote(
"create_".
$a_type,
"text"));
530 $row = $ilDB->fetchAssoc($set);
531 $create_ops_id =
$row[
"ops_id"];
534 $ilDB->manipulate(
"DELETE FROM rbac_operations".
535 " WHERE ops_id = ".$ilDB->quote($create_ops_id,
"integer"));
537 $ilDB->manipulate(
"DELETE FROM rbac_templates".
538 " WHERE ops_id = ".$ilDB->quote($create_ops_id,
"integer"));
541 foreach(
array(
"root",
"cat",
"crs",
"grp",
"fold") as $parent_type)
546 $ilDB->manipulate(
"DELETE FROM rbac_ta".
547 " WHERE typ_id = ".$ilDB->quote($parent_type_id,
"integer").
548 " AND ops_id = ".$ilDB->quote($create_ops_id,
"integer"));
555 include_once
"Services/Repository/classes/class.ilObjRepositorySettings.php";
static removeItemFromDesktops($a_id)
removes object from all user's desktops public
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI) ...
static _handleDelete(array $a_subbtree_nodes)
handle delete Objects that are moved to the trash call ECS-Remove
Class ilObject Basic functions for all objects.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _lookupTitle($a_id)
lookup object title
static removeDeletedNodes($a_node_id, $a_checked, $a_delete_objects, &$a_affected_ids)
Remove already deleted objects within the objects in trash.
static restoreObjects($a_cur_ref_id, $a_ref_ids)
Move objects from trash back to repository.
deleteObjectType($a_type)
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
static insertSavedNodes($a_source_id, $a_dest_id, $a_tree_id, &$a_affected_ids)
Recursive method to insert all saved nodes of the clipboard.
static _lookupObjId($a_id)
static deleteObjectType($a_type)
static clear($a_var)
Unset a value.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
static removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder=false)
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...