ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSystemCheckTrash Class Reference
+ Collaboration diagram for ilSystemCheckTrash:

Public Member Functions

 __construct ()
 
 setNumberLimit ($a_limit)
 
 getNumberLimit ()
 
 setAgeLimit (ilDateTime $dt)
 
 getAgeLimit ()
 
 setTypesLimit ($a_types)
 
 getTypesLimit ()
 
 setMode ($a_mode)
 
 getMode ()
 
 start ()
 

Data Fields

const MODE_TRASH_RESTORE = 1
 
const MODE_TRASH_REMOVE = 2
 

Protected Member Functions

 restore ()
 Restore to recovery folder. More...
 
 removeSelectedFromSystem ()
 remove (containers) from system More...
 
 readSelectedDeleted ()
 read deleted according to filter settings More...
 
 readDeleted ($tree_id=null)
 Read deleted objects @global type $ilDB. More...
 

Private Attributes

 $limit_number = 0
 
 $limit_age = null
 
 $limit_types = array()
 

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 6 of file class.ilSystemCheckTrash.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemCheckTrash::__construct ( )

Definition at line 16 of file class.ilSystemCheckTrash.php.

17 {
18 $this->limit_age = new ilDate(0, IL_CAL_UNIX);
19 }
const IL_CAL_UNIX
Class for single dates.

References IL_CAL_UNIX.

Member Function Documentation

◆ getAgeLimit()

ilSystemCheckTrash::getAgeLimit ( )
Returns
ilDateTime

Definition at line 40 of file class.ilSystemCheckTrash.php.

References $limit_age.

Referenced by readSelectedDeleted(), and start().

+ Here is the caller graph for this function:

◆ getMode()

ilSystemCheckTrash::getMode ( )

Definition at line 60 of file class.ilSystemCheckTrash.php.

61 {
62 return $this->mode;
63 }

Referenced by start().

+ Here is the caller graph for this function:

◆ getNumberLimit()

ilSystemCheckTrash::getNumberLimit ( )

Definition at line 26 of file class.ilSystemCheckTrash.php.

References $limit_number.

Referenced by readSelectedDeleted(), and start().

+ Here is the caller graph for this function:

◆ getTypesLimit()

ilSystemCheckTrash::getTypesLimit ( )

Definition at line 50 of file class.ilSystemCheckTrash.php.

51 {
52 return (array) $this->limit_types;
53 }

References $limit_types.

Referenced by readSelectedDeleted(), and start().

+ Here is the caller graph for this function:

◆ readDeleted()

ilSystemCheckTrash::readDeleted (   $tree_id = null)
protected

Read deleted objects @global type $ilDB.

Returns
type

Definition at line 197 of file class.ilSystemCheckTrash.php.

198 {
199 global $ilDB;
200
201 $query = 'SELECT child,tree FROM tree t JOIN object_reference r ON child = r.ref_id ' .
202 'JOIN object_data o on r.obj_id = o.obj_id ';
203
204 if ($tree_id === null) {
205 $query .= 'WHERE tree < ' . $ilDB->quote(0, 'integer') . ' ';
206 } else {
207 $query .= 'WHERE tree = ' . $ilDB->quote($tree_id, 'integer') . ' ';
208 }
209 $query .= 'ORDER BY depth desc';
210
211 $res = $ilDB->query($query);
212
213 $deleted = array();
214 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
215 $deleted[] = array(
216 'tree' => $row->tree,
217 'child' => $row->child
218 );
219 }
220 return $deleted;
221 }
$query
foreach($_POST as $key=> $value) $res
global $ilDB

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by removeSelectedFromSystem(), and restore().

+ Here is the caller graph for this function:

◆ readSelectedDeleted()

ilSystemCheckTrash::readSelectedDeleted ( )
protected

read deleted according to filter settings

Definition at line 139 of file class.ilSystemCheckTrash.php.

140 {
141 global $ilDB;
142
143 $and_types = '';
144 ilLoggerFactory::getLogger('sysc')->dump($this->getTypesLimit());
145
146 $types = array();
147 foreach ((array) $this->getTypesLimit() as $id => $type) {
148 if ($type) {
149 $types[] = $type;
150 }
151 }
152 if (count($types)) {
153 $and_types = 'AND ' . $ilDB->in('o.type', $this->getTypesLimit(), false, 'text') . ' ';
154 }
155
156 $and_age = '';
157 $age_limit = $this->getAgeLimit()->get(IL_CAL_UNIX);
158 if ($age_limit > 0) {
159 $and_age = 'AND r.deleted < ' . $ilDB->quote($this->getAgeLimit()->get(IL_CAL_DATETIME)) . ' ';
160 }
161 $limit = '';
162 if ($this->getNumberLimit()) {
163 $limit = 'LIMIT ' . (int) $this->getNumberLimit();
164 }
165
166 $query = 'SELECT child,tree FROM tree t JOIN object_reference r ON child = r.ref_id ' .
167 'JOIN object_data o on r.obj_id = o.obj_id ' .
168 'WHERE tree < ' . $ilDB->quote(0, 'integer') . ' ' .
169 'AND child = -tree ';
170
171 $query .= $and_age;
172 $query .= $and_types;
173 $query .= 'ORDER BY depth desc ';
174 $query .= $limit;
175
176 $GLOBALS['ilLog']->write($query);
177
178 $deleted = array();
179 $res = $ilDB->query($query);
180 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
181 $deleted[] = array(
182 'tree' => $row->tree,
183 'child' => $row->child
184 );
185 }
186 return $deleted;
187 }
const IL_CAL_DATETIME
static getLogger($a_component_id)
Get component logger.
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$type

References $GLOBALS, $id, $ilDB, $query, $res, $row, $type, ilDBConstants\FETCHMODE_OBJECT, getAgeLimit(), ilLoggerFactory\getLogger(), getNumberLimit(), getTypesLimit(), IL_CAL_DATETIME, and IL_CAL_UNIX.

Referenced by removeSelectedFromSystem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSelectedFromSystem()

ilSystemCheckTrash::removeSelectedFromSystem ( )
protected

remove (containers) from system

Definition at line 116 of file class.ilSystemCheckTrash.php.

117 {
119
120 $deleted = $this->readSelectedDeleted();
121 foreach ($deleted as $tmp_num => $deleted_info) {
122 $sub_nodes = $this->readDeleted($deleted_info['tree']);
123
124 foreach ($sub_nodes as $tmp_num => $subnode_info) {
125 $ref_obj = $factory->getInstanceByRefId($subnode_info['child'], false);
126 if (!$ref_obj instanceof ilObject) {
127 continue;
128 }
129
130 $ref_obj->delete();
131 ilTree::_removeEntry($subnode_info['tree'], $subnode_info['child']);
132 }
133 }
134 }
$factory
Definition: metadata.php:47
Class ilObjectFactory.
Class ilObject Basic functions for all objects.
readSelectedDeleted()
read deleted according to filter settings
readDeleted($tree_id=null)
Read deleted objects @global type $ilDB.
static _removeEntry($a_tree, $a_child, $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.

References $factory, ilTree\_removeEntry(), readDeleted(), and readSelectedDeleted().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restore()

ilSystemCheckTrash::restore ( )
protected

Restore to recovery folder.

Definition at line 87 of file class.ilSystemCheckTrash.php.

88 {
89 $deleted = $this->readDeleted();
90
91 $GLOBALS['ilLog']->write(__METHOD__ . ': Found deleted : ' . print_r($deleted, true));
92
94
95 foreach ($deleted as $tmp_num => $deleted_info) {
96 $ref_obj = $factory->getInstanceByRefId($deleted_info['child'], false);
97 if (!$ref_obj instanceof ilObject) {
98 continue;
99 }
100
101 $GLOBALS['tree']->deleteNode($deleted_info['tree'], $deleted_info['child']);
102 $GLOBALS['ilLog']->write(__METHOD__ . ': Object tree entry deleted');
103
104 if ($ref_obj->getType() != 'rolf') {
105 $GLOBALS['rbacadmin']->revokePermission($deleted_info['child']);
106 $ref_obj->putInTree(RECOVERY_FOLDER_ID);
107 $ref_obj->setPermissions(RECOVERY_FOLDER_ID);
108 $GLOBALS['ilLog']->write(__METHOD__ . ': Object moved to recovery folder');
109 }
110 }
111 }

References $factory, $GLOBALS, and readDeleted().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAgeLimit()

ilSystemCheckTrash::setAgeLimit ( ilDateTime  $dt)

Definition at line 31 of file class.ilSystemCheckTrash.php.

32 {
33 $this->limit_age = $dt;
34 }

◆ setMode()

ilSystemCheckTrash::setMode (   $a_mode)

Definition at line 55 of file class.ilSystemCheckTrash.php.

56 {
57 $this->mode = $a_mode;
58 }

◆ setNumberLimit()

ilSystemCheckTrash::setNumberLimit (   $a_limit)

Definition at line 21 of file class.ilSystemCheckTrash.php.

22 {
23 $this->limit_number = $a_limit;
24 }

◆ setTypesLimit()

ilSystemCheckTrash::setTypesLimit (   $a_types)

Definition at line 45 of file class.ilSystemCheckTrash.php.

46 {
47 $this->limit_types = (array) $a_types;
48 }

◆ start()

ilSystemCheckTrash::start ( )

Definition at line 65 of file class.ilSystemCheckTrash.php.

66 {
67 $GLOBALS['ilLog']->write(__METHOD__ . ': Handling delete');
68 switch ($this->getMode()) {
70 $GLOBALS['ilLog']->write(__METHOD__ . ': Restore trash to recovery folder');
71 $this->restore();
72 break;
73
75 $GLOBALS['ilLog']->write(__METHOD__ . ': Remove selected from system.');
76 $GLOBALS['ilLog']->write(__METHOD__ . ': Type limit: ' . print_r($this->getTypesLimit(), true));
77 $GLOBALS['ilLog']->write(__METHOD__ . ': Age limit: ' . (string) $this->getAgeLimit());
78 $GLOBALS['ilLog']->write(__METHOD__ . ': Number limit: ' . (string) $this->getNumberLimit());
80 return true;
81 }
82 }
restore()
Restore to recovery folder.
removeSelectedFromSystem()
remove (containers) from system

References $GLOBALS, getAgeLimit(), getMode(), getNumberLimit(), getTypesLimit(), MODE_TRASH_REMOVE, MODE_TRASH_RESTORE, removeSelectedFromSystem(), and restore().

+ Here is the call graph for this function:

Field Documentation

◆ $limit_age

ilSystemCheckTrash::$limit_age = null
private

Definition at line 12 of file class.ilSystemCheckTrash.php.

Referenced by getAgeLimit().

◆ $limit_number

ilSystemCheckTrash::$limit_number = 0
private

Definition at line 11 of file class.ilSystemCheckTrash.php.

Referenced by getNumberLimit().

◆ $limit_types

ilSystemCheckTrash::$limit_types = array()
private

Definition at line 13 of file class.ilSystemCheckTrash.php.

Referenced by getTypesLimit().

◆ MODE_TRASH_REMOVE

const ilSystemCheckTrash::MODE_TRASH_REMOVE = 2

◆ MODE_TRASH_RESTORE

const ilSystemCheckTrash::MODE_TRASH_RESTORE = 1

Definition at line 8 of file class.ilSystemCheckTrash.php.

Referenced by ilObjSystemCheckGUI\initFormTrash(), and start().


The documentation for this class was generated from the following file: