ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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().

+ 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().

+ 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 211 of file class.ilSystemCheckTrash.php.

212 {
213 global $ilDB;
214
215 $query = 'SELECT child,tree FROM tree t JOIN object_reference r ON child = r.ref_id '.
216 'JOIN object_data o on r.obj_id = o.obj_id ';
217
218 if($tree_id === null)
219 {
220 $query .= 'WHERE tree < '.$ilDB->quote(0,'integer').' ';
221 }
222 else
223 {
224 $query .= 'WHERE tree = '.$ilDB->quote($tree_id,'integer').' ';
225 }
226 $query .= 'ORDER BY depth desc';
227
228 $res = $ilDB->query($query);
229
230 $deleted = array();
231 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
232 {
233 $deleted[] = array(
234 'tree' => $row->tree,
235 'child' => $row->child
236 );
237 }
238 return $deleted;
239 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

References $ilDB, $query, $res, $row, and DB_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 146 of file class.ilSystemCheckTrash.php.

147 {
148 global $ilDB;
149
150 $and_types = '';
151 ilLoggerFactory::getLogger('sysc')->dump($this->getTypesLimit());
152
153 $types = array();
154 foreach((array) $this->getTypesLimit() as $id => $type)
155 {
156 if($type)
157 {
158 $types[] = $type;
159 }
160 }
161 if(count($types))
162 {
163 $and_types = 'AND '.$ilDB->in('o.type', $this->getTypesLimit(),FALSE,'text').' ';
164 }
165
166 $and_age = '';
167 $age_limit = $this->getAgeLimit()->get(IL_CAL_UNIX);
168 if($age_limit > 0)
169 {
170 $and_age = 'AND r.deleted < '.$ilDB->quote($this->getAgeLimit()->get(IL_CAL_DATETIME)).' ';
171 }
172 $limit = '';
173 if($this->getNumberLimit())
174 {
175 $limit = 'LIMIT '.(int) $this->getNumberLimit();
176 }
177
178 $query = 'SELECT child,tree FROM tree t JOIN object_reference r ON child = r.ref_id '.
179 'JOIN object_data o on r.obj_id = o.obj_id '.
180 'WHERE tree < '.$ilDB->quote(0,'integer').' '.
181 'AND child = -tree ';
182
183 $query .= $and_age;
184 $query .= $and_types;
185 $query .= 'ORDER BY depth desc ';
186 $query .= $limit;
187
188 $GLOBALS['ilLog']->write($query);
189
190 $deleted = array();
191 $res = $ilDB->query($query);
192 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
193 {
194 $deleted[] = array(
195 'tree' => $row->tree,
196 'child' => $row->child
197 );
198 }
199 return $deleted;
200
201 }
const IL_CAL_DATETIME
static getLogger($a_component_id)
Get component logger.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

References $GLOBALS, $ilDB, $query, $res, $row, DB_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 120 of file class.ilSystemCheckTrash.php.

121 {
122 $factory = new ilObjectFactory();
123
124 $deleted = $this->readSelectedDeleted();
125 foreach($deleted as $tmp_num => $deleted_info)
126 {
127 $sub_nodes = $this->readDeleted($deleted_info['tree']);
128
129 foreach($sub_nodes as $tmp_num => $subnode_info)
130 {
131 $ref_obj = $factory->getInstanceByRefId($subnode_info['child'], FALSE);
132 if(!$ref_obj instanceof ilObject)
133 {
134 continue;
135 }
136
137 $ref_obj->delete();
138 ilTree::_removeEntry($subnode_info['tree'],$subnode_info['child']);
139 }
140 }
141 }
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.
_removeEntry($a_tree, $a_child, $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.

References 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 88 of file class.ilSystemCheckTrash.php.

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

References $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())
69 {
71 $GLOBALS['ilLog']->write(__METHOD__.': Restore trash to recovery folder');
72 $this->restore();
73 break;
74
76 $GLOBALS['ilLog']->write(__METHOD__.': Remove selected from system.');
77 $GLOBALS['ilLog']->write(__METHOD__.': Type limit: '. print_r($this->getTypesLimit(),TRUE));
78 $GLOBALS['ilLog']->write(__METHOD__.': Age limit: '. (string) $this->getAgeLimit());
79 $GLOBALS['ilLog']->write(__METHOD__.': Number limit: '. (string) $this->getNumberLimit());
81 return TRUE;
82 }
83 }
restore()
Restore to recovery folder.
removeSelectedFromSystem()
remove (containers) from system

References $GLOBALS, getMode(), 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: