ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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.

References IL_CAL_UNIX.

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

Member Function Documentation

◆ getAgeLimit()

ilSystemCheckTrash::getAgeLimit ( )
Returns
ilDateTime

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

References $limit_age.

Referenced by readSelectedDeleted().

41  {
42  return $this->limit_age;
43  }
+ Here is the caller graph for this function:

◆ getMode()

ilSystemCheckTrash::getMode ( )

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

Referenced by start().

61  {
62  return $this->mode;
63  }
+ 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.

References $limit_types, and array.

Referenced by readSelectedDeleted(), and start().

51  {
52  return (array) $this->limit_types;
53  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readDeleted()

ilSystemCheckTrash::readDeleted (   $tree_id = null)
protected

Read deleted objects type $ilDB.

Returns
type

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

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

Referenced by removeSelectedFromSystem(), and restore().

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(ilDBConstants::FETCHMODE_OBJECT))
232  {
233  $deleted[] = array(
234  'tree' => $row->tree,
235  'child' => $row->child
236  );
237  }
238  return $deleted;
239  }
Create styles array
The data for the language used.
global $ilDB
+ 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.

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

Referenced by removeSelectedFromSystem().

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(ilDBConstants::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
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const IL_CAL_UNIX
Create styles array
The data for the language used.
global $ilDB
static getLogger($a_component_id)
Get component logger.
+ 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.

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

Referenced by start().

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  }
readSelectedDeleted()
read deleted according to filter settings
Class ilObjectFactory.
Class ilObject Basic functions for all objects.
static _removeEntry($a_tree, $a_child, $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.
readDeleted($tree_id=null)
Read deleted objects type $ilDB.
+ 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.

References $GLOBALS, and readDeleted().

Referenced by start().

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  }
Class ilObjectFactory.
Class ilObject Basic functions for all objects.
readDeleted($tree_id=null)
Read deleted objects type $ilDB.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ 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.

References array.

46  {
47  $this->limit_types = (array) $a_types;
48  }
Create styles array
The data for the language used.

◆ start()

ilSystemCheckTrash::start ( )

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

References $GLOBALS, getMode(), getTypesLimit(), removeSelectedFromSystem(), and restore().

66  {
67  $GLOBALS['ilLog']->write(__METHOD__.': Handling delete');
68  switch($this->getMode())
69  {
70  case self::MODE_TRASH_RESTORE:
71  $GLOBALS['ilLog']->write(__METHOD__.': Restore trash to recovery folder');
72  $this->restore();
73  break;
74 
75  case self::MODE_TRASH_REMOVE:
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());
80  $this->removeSelectedFromSystem();
81  return TRUE;
82  }
83  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
removeSelectedFromSystem()
remove (containers) from system
restore()
Restore to recovery folder.
+ 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().


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