19 declare(strict_types=1);
43 $this->db = $DIC->database();
44 $this->
logger = $DIC->logger()->tree();
45 $this->tree = $DIC->repositoryTree();
54 $query =
'select tree,child,parent from tree ' .
56 $res = $this->db->query($query);
57 $trashed_trash =
false;
59 if ((
int) $row->child != ((
int) $row->tree * -1)) {
60 $trashed_trash =
true;
62 if ($this->tree->isDeleted((
int) $row->parent)) {
63 $trashed_trash =
true;
66 return $trashed_trash;
76 $query =
'select parent from tree ' .
79 $this->
logger->debug($query);
80 $res = $this->db->query($query);
82 return (
int) $row->parent;
84 $this->
logger->warning(
'Invalid node given for restoring to original location: deleted node id: ' . $deleted_node);
85 throw new \ilRepositoryException(
'Invalid node given for restoring to original location');
94 $subtreequery = $this->tree->getTrashSubTreeQuery($ref_id, [
'child']);
95 $query =
'select distinct(type) obj_type from object_data obd ' .
96 'join object_reference obr on obd.obj_id = obr.obj_id ' .
102 $res = $this->db->query($query);
104 $obj_types[] = (string) $row->obj_type;
115 $res = $this->db->query($this->tree->getTrashSubTreeQuery($ref_id, [
'child']));
116 return $res->numRows();
129 string $order_direction,
130 int $limit = self::QUERY_LIMIT,
133 $subtreequery = $this->tree->getTrashSubTreeQuery($ref_id, [
'child']);
135 $select =
'SELECT ref_id, obd.obj_id, type, title, description, deleted, deleted_by ';
136 $select_count =
'SELECT COUNT(ref_id) max_entries ';
138 $from =
'FROM object_data obd ' .
139 'JOIN object_reference obr ON obd.obj_id = obr.obj_id ' .
140 'WHERE ref_id IN (' .
141 $subtreequery .
' ' .
146 $order =
'ORDER BY ' . $order_field .
' ' . $order_direction;
155 $res_max_entries = $this->db->query($query_count);
157 $max_entries = (
int) $max_entries_row->max_entries;
160 $this->db->setLimit($limit, $offset);
161 $res = $this->db->query($query);
165 $item = new \ilTreeTrashItem();
166 $item->setObjId((
int) $row->obj_id);
167 $item->setRefId((
int) $row->ref_id);
168 $item->setTitle((
string) $row->title);
169 $item->setDescription((
string) $row->description);
170 $item->setType((
string) $row->type);
171 $item->setDeleted((
string) $row->deleted);
172 $item->setDeletedBy((
int) $row->deleted_by);
187 $query =
'WITH RECURSIVE trash (child,tree) AS ' .
188 '( SELECT child, tree FROM tree WHERE child = ' . $this->db->quote(
192 'UNION SELECT tc.child,tc.tree FROM tree tc JOIN tree tp ON tp.child = tc.parent ) ' .
193 'SELECT * FROM trash WHERE tree < 1 ';
197 $res = $this->db->query($query);
199 $trash_ids[] = (
int) $row->child;
202 $this->
logger->warning($query .
' is not supported');
214 if (isset($filter[
'type'])) {
215 $query .=
'and ' . $this->db->like(
221 if (isset($filter[
'title'])) {
222 $query .=
'and ' . $this->db->like(
225 '%' . $filter[
'title'] .
'%' 231 $filter[
'deleted'][
'from'] instanceof \
ilDate &&
232 $filter[
'deleted'][
'to'] instanceof \
ilDate) {
233 $query .= (
'AND deleted BETWEEN ' .
236 } elseif ($filter[
'deleted'][
'from'] instanceof \ilDate) {
237 $query .=
'AND deleted >= ' . $this->db->quote(
241 } elseif ($filter[
'deleted'][
'to'] instanceof \ilDate) {
242 $query .=
'AND deleted <= ' . $this->db->quote(
243 $filter[
'deleted'][
'to']->
get(
IL_CAL_DATE) .
" 23:59:59",
248 if (isset($filter[
'deleted_by']) && !empty($filter[
'deleted_by'])) {
253 $query .=
'AND 1=2 ';
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)
__construct()
ilTreeTrash constructor.
findRepositoryLocationForDeletedNode(int $deleted_node)
getNumberOfTrashedNodesForTrashedContainer(int $ref_id)
isTrashedTrash(array $ref_ids)