19 declare(strict_types=1);
44 $this->db = $DIC->database();
45 $this->
logger = $DIC->logger()->tree();
46 $this->tree = $DIC->repositoryTree();
55 $query =
'select tree,child,parent from tree ' .
58 $trashed_trash =
false;
60 if ((
int) $row->child != ((
int) $row->tree * -1)) {
61 $trashed_trash =
true;
63 if ($this->tree->isDeleted((
int) $row->parent)) {
64 $trashed_trash =
true;
67 return $trashed_trash;
77 $query =
'select parent from tree ' .
83 return (
int) $row->parent;
85 $this->
logger->warning(
'Invalid node given for restoring to original location: deleted node id: ' . $deleted_node);
86 throw new \ilRepositoryException(
'Invalid node given for restoring to original location');
95 $subtreequery = $this->tree->getTrashSubTreeQuery($ref_id, [
'child']);
96 $query =
'select distinct(type) obj_type from object_data obd ' .
97 'join object_reference obr on obd.obj_id = obr.obj_id ' .
105 $obj_types[] = (string) $row->obj_type;
116 $res = $this->db->query($this->tree->getTrashSubTreeQuery($ref_id, [
'child']));
117 return $res->numRows();
130 string $order_direction,
131 int $limit = self::QUERY_LIMIT,
134 $subtreequery = $this->tree->getTrashSubTreeQuery($ref_id, [
'child']);
136 $select =
'SELECT ref_id, obd.obj_id, type, title, description, deleted, deleted_by ';
137 $select_count =
'SELECT COUNT(ref_id) max_entries ';
139 $from =
'FROM object_data obd ' .
140 'JOIN object_reference obr ON obd.obj_id = obr.obj_id ' .
141 'WHERE ref_id IN (' .
142 $subtreequery .
' ' .
147 $order =
'ORDER BY ' . $order_field .
' ' . $order_direction;
156 $res_max_entries = $this->db->query($query_count);
158 $max_entries = (
int) $max_entries_row->max_entries;
161 $this->db->setLimit($limit, $offset);
166 $item = new \ilTreeTrashItem();
167 $item->setObjId((
int) $row->obj_id);
168 $item->setRefId((
int) $row->ref_id);
169 $item->setTitle((
string) $row->title);
170 $item->setDescription((
string) $row->description);
171 $item->setType((
string) $row->type);
172 $item->setDeleted((
string) $row->deleted);
173 $item->setDeletedBy((
int) $row->deleted_by);
188 $query =
'WITH RECURSIVE trash (child,tree) AS ' .
189 '( SELECT child, tree FROM tree WHERE child = ' . $this->db->quote(
193 'UNION SELECT tc.child,tc.tree FROM tree tc JOIN tree tp ON tp.child = tc.parent ) ' .
194 'SELECT * FROM trash WHERE tree < 1 ';
200 $trash_ids[] = (
int) $row->child;
215 if (isset($filter[
'type'])) {
216 $query .=
'and ' . $this->db->like(
222 if (isset($filter[
'title'])) {
223 $query .=
'and ' . $this->db->like(
226 '%' . $filter[
'title'] .
'%' 232 $filter[
'deleted'][
'from'] instanceof \
ilDate &&
233 $filter[
'deleted'][
'to'] instanceof \
ilDate) {
234 $query .= (
'AND deleted BETWEEN ' .
237 } elseif ($filter[
'deleted'][
'from'] instanceof \ilDate) {
238 $query .=
'AND deleted >= ' . $this->db->quote(
242 } elseif ($filter[
'deleted'][
'to'] instanceof \ilDate) {
243 $query .=
'AND deleted <= ' . $this->db->quote(
244 $filter[
'deleted'][
'to']->
get(
IL_CAL_DATE) .
" 23:59:59",
249 if (isset($filter[
'deleted_by']) && !empty($filter[
'deleted_by'])) {
getTrashNodeForContainer(int $ref_id, array $filter, int &$max_entries, string $order_field, string $order_direction, int $limit=self::QUERY_LIMIT, int $offset=0)
Get trashed nodes.
appendTrashNodeForContainerQueryFilter(array $filter)
getTrashedNodeTypesForContainer(int $ref_id)
getTrashedNodesForContainerUsingRecursion(int $ref_id)
Unfortunately not supported by mysql 5.
static _lookupId($a_user_str)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct()
ilTreeTrash constructor.
findRepositoryLocationForDeletedNode(int $deleted_node)
getNumberOfTrashedNodesForTrashedContainer(int $ref_id)
isTrashedTrash(array $ref_ids)