ILIAS  release_7 Revision v7.30-3-g800a261c036
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 199 of file class.ilSystemCheckTrash.php.

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

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

References $DIC, $GLOBALS, $ilDB, $query, $res, $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 }
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
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.
$factory
Definition: metadata.php:58

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['DIC']['ilLog']->info('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['DIC']['tree']->deleteNode($deleted_info['tree'], $deleted_info['child']);
102 $GLOBALS['DIC']['ilLog']->info('Object tree entry deleted');
103
104 if ($ref_obj->getType() != 'rolf') {
105 $GLOBALS['DIC']['rbacadmin']->revokePermission($deleted_info['child']);
106 $ref_obj->putInTree(RECOVERY_FOLDER_ID);
107 $ref_obj->setPermissions(RECOVERY_FOLDER_ID);
108 $GLOBALS['DIC']['ilLog']->info('Object moved to recovery folder');
109 }
110 }
111 }
const RECOVERY_FOLDER_ID
Definition: constants.php:35

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

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['DIC']['ilLog']->info('Handling delete');
68 switch ($this->getMode()) {
70 $GLOBALS['DIC']['ilLog']->info('Restore trash to recovery folder');
71 $this->restore();
72 break;
73
75 $GLOBALS['DIC']['ilLog']->info('Remove selected from system.');
76 $GLOBALS['DIC']['ilLog']->info('Type limit: ' . print_r($this->getTypesLimit(), true));
77 $GLOBALS['DIC']['ilLog']->info('Age limit: ' . (string) $this->getAgeLimit());
78 $GLOBALS['DIC']['ilLog']->info('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: