ILIAS Data Validator & Recovery Tool. More...
Inheritance diagram for ilValidator:
Collaboration diagram for ilValidator:Public Member Functions | |
| ilValidator ($a_log=false) | |
| Constructor. | |
| setMode ($a_mode, $a_value) | |
| set mode of ilValidator Usage: setMode("restore",true) => enable object restorey setMode("all",true) => enable all features For all possible modes see variables declaration | |
| isModeEnabled ($a_mode) | |
| Is a particular mode enabled? | |
| isLogEnabled () | |
| setModeDependencies () | |
| Sets modes by considering mode dependencies; some modes require other modes to be activated. | |
| validate () | |
| Performs the validation for each enabled mode. | |
| findMissingObjects () | |
| Search database for all object entries with missing reference and/or tree entry and stores result in $this->missing_objects. | |
| findInvalidRolefolders () | |
| Search database for all rolefolder object entries with missing reference entry. | |
| findInvalidRBACEntries () | |
| Search database for all role entries that are linked to invalid ref_ids. | |
| getMissingObjects () | |
| Gets all object entries with missing reference and/or tree entry. | |
| findInvalidReferences () | |
| Search database for all reference entries that are not linked with a valid object id and stores result in $this->invalid_references. | |
| getInvalidReferences () | |
| Gets all reference entries that are not linked with a valid object id. | |
| findInvalidChilds () | |
| Search database for all tree entries without any link to a valid object and stores result in $this->invalid_childs. | |
| getInvalidChilds () | |
| Gets all tree entries without any link to a valid object. | |
| findUnboundObjects () | |
| Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result does not contain childs that are marked as deleted! Deleted childs have a negative number. | |
| findDeletedObjects () | |
| Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result also contains childs that are marked as deleted! Deleted childs has a negative number in ["deleted"] otherwise NULL. | |
| getUnboundObjects () | |
| Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with child => actual entry with broken uplink to its parent parent => parent of child that does not exist grandparent => grandparent of child (where path to root node continues) deleted => containing a negative number (= parent in trash) or NULL (parent does not exist at all). | |
| getDeletedObjects () | |
| Gets all object in trash. | |
| getInvalidRolefolders () | |
| Gets invalid rolefolders (same as missing objects). | |
| removeInvalidReferences ($a_invalid_refs=NULL) | |
| Removes all reference entries that are linked with invalid object IDs. | |
| removeInvalidChilds ($a_invalid_childs=NULL) | |
| Removes all tree entries without any link to a valid object. | |
| removeInvalidRolefolders ($a_invalid_rolefolders=NULL) | |
| Removes invalid rolefolders. | |
| restoreMissingObjects ($a_missing_objects=NULL) | |
| Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Restored object are placed in RecoveryFolder. | |
| restoreReference ($a_obj_id) | |
| restore a reference for an object Creates a new reference entry in DB table object_reference for $a_obj_id | |
| restoreUnboundObjects ($a_unbound_objects=NULL) | |
| Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in the hierarchy because they point to an invalid parent_id. | |
| restoreTrash ($a_deleted_objects=NULL) | |
| Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryFolder regardless of existing hierarchical structure! | |
| restoreDeletedObjects ($a_nodes) | |
| Restore deleted objects (and their subobjects) to RecoveryFolder. | |
| restoreSubTrees ($a_nodes) | |
| Restore objects (and their subobjects) to RecoveryFolder. | |
| purgeTrash ($a_nodes=NULL) | |
| Removes all objects in trash from system. | |
| purgeUnboundObjects ($a_nodes=NULL) | |
| Removes all invalid objects from system. | |
| purgeMissingObjects ($a_nodes=NULL) | |
| Removes all missing objects from system. | |
| purgeObjects ($a_nodes) | |
| removes objects from system | |
| initGapsInTree () | |
| Initializes gaps in lft/rgt values of a tree. | |
| handleErr ($error) | |
| Callback function handles PEAR_error and outputs detailed infos about error TODO: implement that in global errorhandler of ILIAS (via templates). | |
| writeScanLogArray ($a_arr) | |
| writeScanLogLine ($a_msg) | |
| hasScanLog () | |
| Quickly determine if there is a scan log. | |
| deleteScanLog () | |
| Delete scan log. | |
| readScanLog () | |
| get_last_scan ($a_scan_log) | |
| checkTreeStructure ($a_startnode=null) | |
| dumpTree () | |
| Dumps the Tree structure into the scan log. | |
Data Fields | |
| $rbac_object_types = NULL | |
| $object_types_exclude | |
| $mode | |
| $invalid_references = array() | |
| $invalid_childs = array() | |
| $missing_objects = array() | |
| $unbound_objects = array() | |
| $deleted_objects = array() | |
| $invalid_rolefolders = array() | |
| $invalid_objects = array() | |
| $logging = false | |
| $scan_log | |
| $scan_log_file = "scanlog.log" | |
| $scan_log_separator = "<!-- scan log start -->" | |
Protected Member Functions | |
| isMediaFolder ($a_obj_id) | |
Protected Attributes | |
| $media_pool_ids = null | |
ILIAS Data Validator & Recovery Tool.
Definition at line 31 of file class.ilValidator.php.
| ilValidator::checkTreeStructure | ( | $ | a_startnode = null |
) |
Definition at line 2032 of file class.ilValidator.php.
References writeScanLogLine().
Referenced by validate().
{
global $tree;
$this->writeScanLogLine("\nchecking tree structure is disabled");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::deleteScanLog | ( | ) |
Delete scan log.
Definition at line 1996 of file class.ilValidator.php.
Referenced by ilValidator().
{
@unlink(CLIENT_DATA_DIR."/".$this->scan_log_file);
}
Here is the caller graph for this function:| ilValidator::dumpTree | ( | ) |
Dumps the Tree structure into the scan log.
public
Definition at line 2047 of file class.ilValidator.php.
References isMediaFolder(), and writeScanLogLine().
Referenced by validate().
{
$this->writeScanLogLine("BEGIN dumpTree:");
// collect nodes with duplicate child Id's
// (We use this, to mark these nodes later in the output as being
// erroneous.).
$q = 'SELECT child FROM tree GROUP BY child HAVING COUNT(*) > 1';
$r = $this->db->query($q);
$duplicateNodes = array();
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$duplicateNodes[] = $row->child;
}
// dump tree
$q = "SELECT tree.*,ref.ref_id,ref.obj_id AS refobj_id,ref.deleted,dat.*,usr.login "
."FROM tree "
."RIGHT JOIN object_reference AS ref ON tree.child = ref.ref_id "
."RIGHT JOIN object_data AS dat ON ref.obj_id = dat.obj_id "
."LEFT JOIN usr_data AS usr ON usr.usr_id = dat.owner "
."ORDER BY tree, lft, type, title";
$r = $this->db->query($q);
$this->writeScanLogLine(
'<table><tr>'
.'<td>tree, child, parent, lft, rgt, depth</td>'
.'<td>ref_id, ref.obj_id, deleted</td>'
.'<td>obj_id, type, owner, title</td>'
.'</tr>'
);
// We use a stack to represent the path to the current node.
// This allows us to do analyze the tree structure without having
// to implement a recursive algorithm.
$stack = array();
$error_count = 0;
$repository_tree_count = 0;
$trash_trees_count = 0;
$other_trees_count = 0;
$not_in_tree_count = 0;
// The previous number is used for gap checking
$previousNumber = 0;
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
// If there is no entry in table tree for the object, we display it here
if (is_null($row->child))
{
$not_in_tree_count++;
switch ($row->type) {
case 'crsg' :
case 'usr' :
case 'typ' :
case 'lng' :
case 'rolt' :
case 'role' :
case 'mob' :
case 'sty' :
// We are not interested in dumping these object types.
continue 2;
//break; NOT REACHED
case 'file' :
if (is_null($row->ref_id)) {
// File objects can be part of a learning module.
// In this case, they do not have a row in table object_reference.
// We are not interested in dumping these file objects.
continue 2;
} else {
// File objects which have a row in table object_reference, but
// none in table tree are an error.
$error_count++;
$isRowOkay = false;
$isParentOkay = false;
$isLftOkay = false;
$isRgtOkay = false;
$isDepthOkay = false;
}
break;
case 'fold':
// ignore folders on media pools
if($this->isMediaFolder($row->obj_id))
{
continue 2;
}
default :
$error_count++;
$isRowOkay = false;
$isParentOkay = false;
$isLftOkay = false;
$isRgtOkay = false;
$isDepthOkay = false;
break;
}
$this->writeScanLogLine(
'<tr>'
.'<td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.$row->tree.', '
.$row->child.', '
.(($isParentOkay) ? '' : 'parent:<b>')
.$row->parent
.(($isParentOkay) ? '' : '</b>')
.', '
.(($isLftOkay) ? '' : 'lft:<b>')
.$row->lft
.(($isLftOkay) ? '' : '</b>')
.', '
.(($isRgtOkay) ? '' : 'rgt:<b>')
.$row->rgt
.(($isRgtOkay) ? '' : '</b>')
.', '
.(($isDepthOkay) ? '' : 'depth:<b>')
.$row->depth
.(($isDepthOkay) ? '' : '</b>')
.(($isRowOkay) ? '' : '</font>')
.'</td><td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.(($isRefRefOkay && $isChildOkay) ? '' : 'ref.ref_id:<b>')
.$row->ref_id
.(($isRefRefOkay && $isChildOkay) ? '' : '</b>')
.', '
.(($isRefObjOkay) ? '' : 'ref.obj_id:<b>')
.$row->refobj_id
.(($isRefObjOkay) ? '' : '</b>')
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.(($row->deleted != '0000-00-00 00:00:00') ? ', '.$row->deleted : '')
.'</td><td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.$indent
.$row->obj_id.', '
.$row->type.', '
.$row->login.', '
.$row->title
.(($isRowOkay) ? '' : ' <b>*ERROR*</b><font color=#ff0000>')
.'</td>'
.'</tr>'
);
continue;
}
// Update stack
// -------------------
$indent = "";
for ($i = 1; $i < $row->depth; $i++)
{
$indent .= ". ";
}
// Initialize the stack and the previous number if we are in a new tree
if (count($stack) == 0 || $stack[0]->tree != $row->tree)
{
$stack = array();
$previousNumber = $row->lft - 1;
$this->writeScanLogLine('<tr><td> </td></tr>');
}
// Pop old stack entries
while (count($stack) > 0 && $stack[count($stack) - 1]->rgt < $row->lft)
{
$popped = array_pop($stack);
// check for gap
$gap = $popped->rgt - $previousNumber - 1;
if ($gap > 0)
{
$poppedIndent = "";
for ($i = 1; $i < $popped->depth; $i++)
{
$poppedIndent .= ". ";
}
$this->writeScanLogLine(
'<tr>'
.'<td colspan=2><div align="right">'
.'<font color=#00cc00>*gap* for '.($gap/2).' nodes at end of </font>'
.'</div></td>'
.'<td>'
.'<font color=#00cc00>'
.$poppedIndent
.$popped->obj_id.', '
.$popped->type.', '
.$popped->login.', '
.$popped->title
.'</font>'
.'</td>'
.'</tr>'
);
}
$previousNumber = $popped->rgt;
unset($popped);
}
// Check row integrity
// -------------------
$isRowOkay = true;
// Check tree structure
$isChildOkay = true;
$isParentOkay = true;
$isLftOkay = true;
$isRgtOkay = true;
$isDepthOkay = true;
$isGap = false;
if (count($stack) > 0)
{
$parent = $stack[count($stack) - 1];
if ($parent->depth + 1 != $row->depth)
{
$isDepthOkay = false;
$isRowOkay = false;
}
if ($parent->child != $row->parent)
{
$isParentOkay = false;
$isRowOkay = false;
}
if ($parent->lft >= $row->lft)
{
$isLftOkay = false;
$isRowOkay = false;
}
if ($parent->rgt <= $row->rgt)
{
$isRgtOkay = false;
$isRowOkay = false;
}
}
// Check lft rgt
if ($row->lft >= $row->rgt)
{
$isLftOkay = false;
$isRgtOkay = false;
$isRowOkay = false;
}
if (in_array($row->child, $duplicateNodes))
{
$isChildOkay = false;
$isRowOkay = false;
}
// Check object reference
$isRefRefOkay = true;
$isRefObjOkay = true;
if ($row->ref_id == null)
{
$isRefRefOkay = false;
$isRowOkay = false;
}
if ($row->obj_id == null)
{
$isRefObjOkay = false;
$isRowOkay = false;
}
if (! $isRowOkay)
{
$error_count++;
}
// Check for gap between siblings,
// and eventually write a log line
$gap = $row->lft - $previousNumber - 1;
$previousNumber = $row->lft;
if ($gap > 0)
{
$this->writeScanLogLine(
'<tr>'
.'<td colspan=2><div align="right">'
.'<font color=#00cc00>*gap* for '.($gap/2).' nodes between </font>'
.'</div></td>'
.'<td>'
.'<font color=#00cc00>siblings</font>'
.'</td>'
.'</tr>'
);
}
// Write log line
// -------------------
$this->writeScanLogLine(
'<tr>'
.'<td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.$row->tree.', '
.$row->child.', '
.(($isParentOkay) ? '' : 'parent:<b>')
.$row->parent
.(($isParentOkay) ? '' : '</b>')
.', '
.(($isLftOkay) ? '' : 'lft:<b>')
.$row->lft
.(($isLftOkay) ? '' : '</b>')
.', '
.(($isRgtOkay) ? '' : 'rgt:<b>')
.$row->rgt
.(($isRgtOkay) ? '' : '</b>')
.', '
.(($isDepthOkay) ? '' : 'depth:<b>')
.$row->depth
.(($isDepthOkay) ? '' : '</b>')
.(($isRowOkay) ? '' : '</font>')
.'</td><td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.(($isRefRefOkay && $isChildOkay) ? '' : 'ref.ref_id:<b>')
.$row->ref_id
.(($isRefRefOkay && $isChildOkay) ? '' : '</b>')
.', '
.(($isRefObjOkay) ? '' : 'ref.obj_id:<b>')
.$row->refobj_id
.(($isRefObjOkay) ? '' : '</b>')
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.(($row->tree < 0) ? ', '.$row->deleted : '')
.'</td><td>'
.(($isRowOkay) ? '' : '<font color=#ff0000>')
.$indent
.$row->obj_id.', '
.$row->type.', '
.$row->login.', '
.$row->title
.(($isRowOkay) ? '' : ' <b>*ERROR*</b><font color=#ff0000>')
.'</td>'
.'</tr>'
);
// Update stack
// -------------------
// Push node on stack
$stack[] = $row;
// Count nodes
// -----------------
if ($row->tree == 1)
{
$repository_tree_count++;
}
else if ($row->tree < 0)
{
$trash_trees_count++;
}
else
{
$other_trees_count++;
}
}
//
// Pop remaining stack entries
while (count($stack) > 0)
{
$popped = array_pop($stack);
// check for gap
$gap = $popped->rgt - $previousNumber - 1;
if ($gap > 0)
{
$poppedIndent = "";
for ($i = 1; $i < $popped->depth; $i++)
{
$poppedIndent .= ". ";
}
$this->writeScanLogLine(
'<tr>'
.'<td colspan=2><div align="right">'
.'<font color=#00cc00>*gap* for '.($gap/2).' nodes at end of </font>'
.'</div></td>'
.'<td>'
.'<font color=#00cc00>'
.$poppedIndent
.$popped->obj_id.', '
.$popped->type.', '
.$popped->login.', '
.$popped->title
.'</font>'
.'</td>'
.'</tr>'
);
}
$previousNumber = $popped->rgt;
unset($popped);
}
//
$this->writeScanLogLine("</table>");
if ($error_count > 0)
{
$this->writeScanLogLine('<font color=#ff0000>'.$error_count.' errors found while dumping tree.</font>');
}
else
{
$this->writeScanLogLine('No errors found while dumping tree.');
}
$this->writeScanLogLine("$repository_tree_count nodes in repository tree");
$this->writeScanLogLine("$trash_trees_count nodes in trash trees");
$this->writeScanLogLine("$other_trees_count nodes in other trees");
$this->writeScanLogLine("$not_in_tree_count nodes are not in a tree");
$this->writeScanLogLine("END dumpTree");
return $error_count;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findDeletedObjects | ( | ) |
Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result also contains childs that are marked as deleted! Deleted childs has a negative number in ["deleted"] otherwise NULL.
public
Definition at line 991 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by validate().
{
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->deleted_objects = array();
$this->writeScanLogLine("\nfindDeletedObjects:");
// Delete objects, start with the oldest objects first
$q = "SELECT object_data.*,tree.tree,tree.child,tree.parent,deleted,UNIX_TIMESTAMP(deleted) as deleted_timestamp ".
"FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
"LEFT JOIN tree ON tree.child=object_reference.ref_id ".
" WHERE tree !=1 ".
" ORDER BY deleted";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->deleted_objects[] = array(
"child" => $row->child,
"parent" => $row->parent,
"tree" => $row->tree,
"type" => $row->type,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"deleted" => $row->deleted,
"deleted_timestamp" => $row->deleted_timestamp,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
if (count($this->deleted_objects) > 0)
{
$this->writeScanLogArray(array(array_keys($this->deleted_objects[0])));
$this->writeScanLogArray($this->deleted_objects);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findInvalidChilds | ( | ) |
Search database for all tree entries without any link to a valid object and stores result in $this->invalid_childs.
public
Definition at line 872 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by purgeObjects(), restoreSubTrees(), and validate().
{
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->invalid_childs = array();
$this->writeScanLogLine("\nfindInvalidChilds:");
$q = "SELECT tree.*,object_reference.ref_id FROM tree ".
"LEFT JOIN object_reference ON tree.child = object_reference.ref_id ".
"LEFT JOIN object_data ON object_reference.obj_id = object_data.obj_id ".
"WHERE object_reference.ref_id IS NULL or object_data.obj_id IS NULL";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_childs[] = array(
"child" => $row->child,
"ref_id" => $row->ref_id,
"msg" => "No object found"
);
}
if (count($this->invalid_childs) > 0)
{
$this->writeScanLogLine("child\t\tref_id");
$this->writeScanLogArray($this->invalid_childs);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findInvalidRBACEntries | ( | ) |
Search database for all role entries that are linked to invalid ref_ids.
public
Definition at line 713 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
{
global $ilDB;
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->invalid_rbac_entries = array();
$this->writeScanLogLine("\nfindInvalidRBACEntries:");
$q = "SELECT object_data.*, ref_id FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
"LEFT JOIN tree ON object_reference.ref_id = tree.child ".
"WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
"AND object_data.type='rolf'";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_rolefolders[] = array(
"obj_id" => $row->obj_id,
"type" => $row->type,
"ref_id" => $row->ref_id,
"child" => $row->child,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
// find rolfs within RECOVERY FOLDER
$q = "SELECT object_data.*, ref_id FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
"LEFT JOIN tree ON object_reference.ref_id = tree.child ".
"WHERE object_reference.ref_id =".$ilDB->quote(RECOVERY_FOLDER_ID)." ".
"AND object_data.type='rolf'";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_rolefolders[] = array(
"obj_id" => $row->obj_id,
"type" => $row->type,
"ref_id" => $row->ref_id,
"child" => $row->child,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
if (count($this->invalid_rolefolders) > 0)
{
$this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
$this->writeScanLogArray($this->invalid_rolefolders);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:| ilValidator::findInvalidReferences | ( | ) |
Search database for all reference entries that are not linked with a valid object id and stores result in $this->invalid_references.
public
Definition at line 811 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by validate().
{
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->invalid_references = array();
$this->writeScanLogLine("\nfindInvalidReferences:");
$q = "SELECT object_reference.* FROM object_reference ".
"LEFT JOIN object_data ON object_data.obj_id = object_reference.obj_id ".
"WHERE object_data.obj_id IS NULL ".
"OR object_data.type NOT IN (".$this->rbac_object_types.")";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_references[] = array(
"ref_id" => $row->ref_id,
"obj_id" => $row->obj_id,
"msg" => "Object does not exist."
);
}
if (count($this->invalid_references) > 0)
{
$this->writeScanLogLine("ref_id\t\tobj_id");
$this->writeScanLogArray($this->invalid_references);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findInvalidRolefolders | ( | ) |
Search database for all rolefolder object entries with missing reference entry.
Furthermore gets all rolefolders that are placed accidently in RECOVERY_FOLDER from earlier versions of System check. Result is stored in $this->invalid_rolefolders
public
Definition at line 632 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by validate().
{
global $ilDB;
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->invalid_rolefolders = array();
$this->writeScanLogLine("\nfindInvalidRolefolders:");
// find rolfs without reference/tree entry
$q = "SELECT object_data.*, ref_id FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
"LEFT JOIN tree ON object_reference.ref_id = tree.child ".
"WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
"AND object_data.type='rolf'";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_rolefolders[] = array(
"obj_id" => $row->obj_id,
"type" => $row->type,
"ref_id" => $row->ref_id,
"child" => $row->child,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
// find rolfs within RECOVERY FOLDER
$q = "SELECT object_data.*, ref_id FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
"LEFT JOIN tree ON object_reference.ref_id = tree.child ".
"WHERE object_reference.ref_id = ".$ilDB->quote(RECOVERY_FOLDER_ID)." ".
"AND object_data.type='rolf'";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->invalid_rolefolders[] = array(
"obj_id" => $row->obj_id,
"type" => $row->type,
"ref_id" => $row->ref_id,
"child" => $row->child,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
if (count($this->invalid_rolefolders) > 0)
{
$this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
$this->writeScanLogArray($this->invalid_rolefolders);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findMissingObjects | ( | ) |
Search database for all object entries with missing reference and/or tree entry and stores result in $this->missing_objects.
public
Definition at line 564 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by validate().
{
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->missing_objects = array();
$this->writeScanLogLine("\nfindMissingObjects:");
// Repair missing objects.
// We only repair file objects which have an entry in table object_reference.
// XXX - We should check all references to file objects which don't
// have an object_reference. If we can't find any reference to such
// a file object, we should repair it too!
$q = "SELECT object_data.*, ref_id FROM object_data ".
"LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
"LEFT JOIN tree ON object_reference.ref_id = tree.child ".
"WHERE tree.child IS NULL ".
"AND (object_reference.obj_id IS NOT NULL ".
" OR object_data.type <> 'file' AND ".
" object_data.type IN (".$this->rbac_object_types.") ".
")";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
if (!in_array($row->type,$this->object_types_exclude))
{
$this->missing_objects[] = array(
"obj_id" => $row->obj_id,
"type" => $row->type,
"ref_id" => $row->ref_id,
"child" => $row->child,
"title" => $row->title,
"desc" => $row->description,
"owner" => $row->owner,
"create_date" => $row->create_date,
"last_update" => $row->last_update
);
}
}
if (count($this->missing_objects) > 0)
{
$this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
$this->writeScanLogArray($this->missing_objects);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::findUnboundObjects | ( | ) |
Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result does not contain childs that are marked as deleted! Deleted childs have a negative number.
public
Definition at line 935 of file class.ilValidator.php.
References writeScanLogArray(), and writeScanLogLine().
Referenced by validate().
{
// check mode: analyze
if ($this->mode["scan"] !== true)
{
return false;
}
// init
$this->unbound_objects = array();
$this->writeScanLogLine("\nfindUnboundObjects:");
$q = "SELECT T1.tree,T1.child,T1.parent,".
"T2.tree AS deleted,T2.parent AS grandparent ".
"FROM tree AS T1 ".
"LEFT JOIN tree AS T2 ON T2.child=T1.parent ".
"WHERE (T2.tree!=1 OR T2.tree IS NULL) AND T1.parent!=0";
$r = $this->db->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
// exclude deleted nodes
if ($row->deleted === NULL)
{
$this->unbound_objects[] = array(
"child" => $row->child,
"parent" => $row->parent,
"tree" => $row->tree,
"msg" => "No valid parent node found"
);
}
}
if (count($this->unbound_objects) > 0)
{
$this->writeScanLogLine("child\t\tparent\ttree");
$this->writeScanLogArray($this->unbound_objects);
return true;
}
$this->writeScanLogLine("none");
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::get_last_scan | ( | $ | a_scan_log | ) |
Definition at line 2020 of file class.ilValidator.php.
Referenced by readScanLog().
{
$logs = array_keys($a_scan_log,$this->scan_log_separator."\n");
if (count($logs) > 0)
{
return array_slice($a_scan_log,array_pop($logs)+2);
}
return false;
}
Here is the caller graph for this function:| ilValidator::getDeletedObjects | ( | ) |
Gets all object in trash.
public
Definition at line 1066 of file class.ilValidator.php.
Referenced by validate().
{
return $this->deleted_objects;
}
Here is the caller graph for this function:| ilValidator::getInvalidChilds | ( | ) |
Gets all tree entries without any link to a valid object.
public
Definition at line 919 of file class.ilValidator.php.
Referenced by validate().
{
return $this->invalid_childs;
}
Here is the caller graph for this function:| ilValidator::getInvalidReferences | ( | ) |
Gets all reference entries that are not linked with a valid object id.
public
Definition at line 858 of file class.ilValidator.php.
Referenced by validate().
{
return $this->invalid_references;
}
Here is the caller graph for this function:| ilValidator::getInvalidRolefolders | ( | ) |
Gets invalid rolefolders (same as missing objects).
public
Definition at line 1079 of file class.ilValidator.php.
Referenced by validate().
{
return $this->invalid_rolefolders;
}
Here is the caller graph for this function:| ilValidator::getMissingObjects | ( | ) |
Gets all object entries with missing reference and/or tree entry.
Returns array with obj_id => actual object entry with missing reference or tree type => symbolic name of object type ref_id => reference entry of object (or NULL if missing) child => always NULL (only for debugging and verification)
public
Definition at line 797 of file class.ilValidator.php.
Referenced by validate().
{
return $this->missing_objects;
}
Here is the caller graph for this function:| ilValidator::getUnboundObjects | ( | ) |
Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with child => actual entry with broken uplink to its parent parent => parent of child that does not exist grandparent => grandparent of child (where path to root node continues) deleted => containing a negative number (= parent in trash) or NULL (parent does not exist at all).
public
Definition at line 1055 of file class.ilValidator.php.
Referenced by validate().
{
return $this->unbound_objects;
}
Here is the caller graph for this function:| ilValidator::handleErr | ( | $ | error | ) |
Callback function handles PEAR_error and outputs detailed infos about error TODO: implement that in global errorhandler of ILIAS (via templates).
private
| object | PEAR_error |
Definition at line 1896 of file class.ilValidator.php.
References exit.
{
$call_loc = $error->backtrace[count($error->backtrace)-1];
$num_args = count($call_loc["args"]);
if ($num_args > 0)
{
foreach ($call_loc["args"] as $arg)
{
$type = gettype($arg);
switch ($type)
{
case "string":
$value = strlen($arg);
break;
case "array":
$value = count($arg);
break;
case "object":
$value = get_class($arg);
break;
case "boolean":
$value = ($arg) ? "true" : "false";
break;
default:
$value = $arg;
break;
}
$arg_list[] = array(
"type" => $type,
"value" => "(".$value.")"
);
}
foreach ($arg_list as $arg)
{
$arg_str .= implode("",$arg)." ";
}
}
$err_msg = "<br/><b>".$error->getCode().":</b> ".$error->getMessage()." in ".$call_loc["class"].$call_loc["type"].$call_loc["function"]."()".
"<br/>Called from: ".basename($call_loc["file"])." , line ".$call_loc["line"].
"<br/>Passed parameters: [".$num_args."] ".$arg_str."<br/>";
printf($err_msg);
if ($error->getUserInfo())
{
printf("<br/>Parameter details:");
echo "<pre>";
var_dump($call_loc["args"]);
echo "</pre>";
}
if ($error->getCode() == FATAL)
{
exit();
}
}
| ilValidator::hasScanLog | ( | ) |
Quickly determine if there is a scan log.
Definition at line 1987 of file class.ilValidator.php.
Referenced by readScanLog().
{
// file check
return is_file(CLIENT_DATA_DIR."/".$this->scan_log_file);
}
Here is the caller graph for this function:| ilValidator::ilValidator | ( | $ | a_log = false |
) |
Constructor.
public
| integer | mode |
Definition at line 136 of file class.ilValidator.php.
References deleteScanLog(), and writeScanLogLine().
{
global $objDefinition, $ilDB;
$this->PEAR();
$this->db =& $ilDB;
$this->rbac_object_types = "'".implode("','",$objDefinition->getAllRBACObjects())."'";
$this->setErrorHandling(PEAR_ERROR_CALLBACK,array(&$this, 'handleErr'));
if ($a_log === true)
{
$this->logging = true;
// should be available thru inc.header.php
// TODO: move log functionality to new class ilScanLog
include_once "./Services/Logging/classes/class.ilLog.php";
// Delete old scan log
$this->deleteScanLog();
// create scan log
$this->scan_log = new ilLog(CLIENT_DATA_DIR,"scanlog.log");
$this->scan_log->setLogFormat("");
$this->writeScanLogLine($this->scan_log_separator);
$this->writeScanLogLine("\n[Systemscan from ".date("y-m-d H:i]"));
}
}
Here is the call graph for this function:| ilValidator::initGapsInTree | ( | ) |
Initializes gaps in lft/rgt values of a tree.
Depending on the value of the gap property of the tree, this function either closes all gaps in the tree, or equally distributes gaps all over the tree.
Wrapper for ilTree::renumber()
public
Definition at line 1865 of file class.ilValidator.php.
References $ilLog, and writeScanLogLine().
Referenced by validate().
{
global $tree,$ilLog;
$message = sprintf('%s::initGapsInTree(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// check mode: clean
if ($this->mode["clean"] !== true)
{
return false;
}
$this->writeScanLogLine("\nrenumberTree:");
$tree->renumber(ROOT_FOLDER_ID);
$this->writeScanLogLine("done");
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::isLogEnabled | ( | ) |
Definition at line 221 of file class.ilValidator.php.
Referenced by writeScanLogArray(), and writeScanLogLine().
{
return $this->logging;
}
Here is the caller graph for this function:| ilValidator::isMediaFolder | ( | $ | a_obj_id | ) | [protected] |
Definition at line 2453 of file class.ilValidator.php.
References $res.
Referenced by dumpTree().
{
global $ilDB;
if(!is_array($this->media_pool_ids))
{
$this->media_pool_ids = array();
$query = "SELECT child FROM mep_tree ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->media_pool_ids[] = $row->child;
}
}
return in_array($a_obj_id,$this->media_pool_ids) ? true : false;
}
Here is the caller graph for this function:| ilValidator::isModeEnabled | ( | $ | a_mode | ) |
Is a particular mode enabled?
public
| string | mode to query |
Definition at line 210 of file class.ilValidator.php.
Referenced by validate().
{
if (!in_array($a_mode,array_keys($this->mode)))
{
$this->throwError(VALIDATER_UNKNOWN_MODE, WARNING, DEBUG);
return false;
}
return $this->mode[$a_mode];
}
Here is the caller graph for this function:| ilValidator::purgeMissingObjects | ( | $ | a_nodes = NULL |
) |
Removes all missing objects from system.
public
| array | list of nodes to delete |
Definition at line 1733 of file class.ilValidator.php.
References $ilLog, purgeObjects(), and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: purge
if ($this->mode["purge"] !== true)
{
return false;
}
$this->writeScanLogLine("\npurgeMissingObjects:");
if ($a_nodes === NULL and isset($this->missing_objects))
{
$a_nodes = $this->missing_objects;
}
$message = sprintf('%s::purgeMissingObjects(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// start purge process
return $this->purgeObjects($a_nodes);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::purgeObjects | ( | $ | a_nodes | ) |
removes objects from system
private
| array | list of objects |
Definition at line 1765 of file class.ilValidator.php.
References $ilias, $ilLog, $ref_id, ilTree::_removeEntry(), findInvalidChilds(), removeInvalidChilds(), and writeScanLogLine().
Referenced by purgeMissingObjects(), purgeTrash(), and purgeUnboundObjects().
{
global $ilias,$ilLog;
// Get purge limits
$count_limit = $ilias->account->getPref("systemcheck_count_limit");
if (! is_numeric($count_limit) || $count_limit < 0)
{
$count_limit = count($a_nodes);
}
$timestamp_limit = time();
$age_limit = $ilias->account->getPref("systemcheck_age_limit");
if (is_numeric($age_limit) && $age_limit > 0)
{
$timestamp_limit -= $age_limit * 60 * 60 * 24;
}
$type_limit = $ilias->account->getPref("systemcheck_type_limit");
if ($type_limit)
{
$type_limit = trim($type_limit);
if (strlen($type_limit) == 0)
{
$type_limit = null;
}
}
// handle wrong input
if (!is_array($a_nodes))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// start delete process
$this->writeScanLogLine("action\tref_id\tobj_id\ttype\ttitle");
$count = 0;
foreach ($a_nodes as $node)
{
if ($type_limit && $node['type'] != $type_limit)
{
$this->writeScanLogLine("skip type\t".
$node['child']."\t\t".$node['type']."\t".$node['title']
);
continue;
}
$count++;
if ($count > $count_limit)
{
$this->writeScanLogLine("Stopped purging after ".($count - 1)." objects, because count limit was reached: ".$count_limit);
break;
}
if ($node["deleted_timestamp"] > $timestamp_limit)
{
$this->writeScanLogLine("Stopped purging after ".($count - 1)." objects, because timestamp limit was reached: ".date("c", $timestamp_limit));
break;
}
$ref_id = ($node["child"]) ? $node["child"] : $node["ref_id"];
$node_obj =& $ilias->obj_factory->getInstanceByRefId($ref_id,false);
if ($node_obj === false)
{
$this->invalid_objects[] = $node;
continue;
}
$message = sprintf('%s::purgeObjects(): Removing object (id:%s ref:%s)',
get_class($this),
$node['ref_id'],
$node_obj->getId);
$ilLog->write($message,$ilLog->WARNING);
$node_obj->delete();
ilTree::_removeEntry($node["tree"],$ref_id);
$this->writeScanLogLine("purged\t".$ref_id."\t".$node_obj->getId().
"\t".$node['type']."\t".$node['title']);
}
$this->findInvalidChilds();
$this->removeInvalidChilds();
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::purgeTrash | ( | $ | a_nodes = NULL |
) |
Removes all objects in trash from system.
public
| array | list of nodes to delete |
Definition at line 1665 of file class.ilValidator.php.
References $ilLog, purgeObjects(), and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: purge_trash
if ($this->mode["purge_trash"] !== true)
{
return false;
}
$this->writeScanLogLine("\npurgeTrash:");
if ($a_nodes === NULL and isset($this->deleted_objects))
{
$a_nodes = $this->deleted_objects;
}
$message = sprintf('%s::purgeTrash(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// start purge process
return $this->purgeObjects($a_nodes);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::purgeUnboundObjects | ( | $ | a_nodes = NULL |
) |
Removes all invalid objects from system.
public
| array | list of nodes to delete |
Definition at line 1699 of file class.ilValidator.php.
References $ilLog, purgeObjects(), and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: purge
if ($this->mode["purge"] !== true)
{
return false;
}
$this->writeScanLogLine("\npurgeUnboundObjects:");
if ($a_nodes === NULL and isset($this->unbound_objects))
{
$a_nodes = $this->unbound_objects;
}
$message = sprintf('%s::purgeUnboundObjects(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// start purge process
return $this->purgeObjects($a_nodes);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::readScanLog | ( | ) |
Definition at line 2001 of file class.ilValidator.php.
References $scan_log, get_last_scan(), and hasScanLog().
{
// file check
if (! $this->hasScanLog())
{
return false;
}
$scanfile =& file(CLIENT_DATA_DIR."/".$this->scan_log_file);
if (!$scan_log =& $this->get_last_scan($scanfile))
{
return false;
}
// Ensure that memory is freed
unset($scanfile);
return $scan_log;
}
Here is the call graph for this function:| ilValidator::removeInvalidChilds | ( | $ | a_invalid_childs = NULL |
) |
Removes all tree entries without any link to a valid object.
public
| array | invalid IDs in tree (optional) |
Definition at line 1157 of file class.ilValidator.php.
References $ilLog, and writeScanLogLine().
Referenced by purgeObjects(), restoreSubTrees(), and validate().
{
global $ilLog;
// check mode: clean
if ($this->mode["clean"] !== true)
{
return false;
}
$this->writeScanLogLine("\nremoveInvalidChilds:");
if ($a_invalid_childs === NULL and isset($this->invalid_childs))
{
$a_invalid_childs =& $this->invalid_childs;
}
// handle wrong input
if (!is_array($a_invalid_childs))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no unbound childs found. do nothing
if (count($a_invalid_childs) == 0)
{
$this->writeScanLogLine("none");
return false;
}
/*******************
removal starts here
********************/
$message = sprintf('%s::removeInvalidChilds(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
foreach ($a_invalid_childs as $entry)
{
$q = "DELETE FROM tree WHERE child='".$entry["child"]."'";
$this->db->query($q);
$message = sprintf('%s::removeInvalidChilds(): Entry child=%s removed',
get_class($this),
$entry["child"]);
$ilLog->write($message,$ilLog->WARNING);
$this->writeScanLogLine("Entry ".$entry["child"]." removed");
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::removeInvalidReferences | ( | $ | a_invalid_refs = NULL |
) |
Removes all reference entries that are linked with invalid object IDs.
public
| array | invalid IDs in object_reference (optional) |
Definition at line 1093 of file class.ilValidator.php.
References $ilLog, and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: clean
if ($this->mode["clean"] !== true)
{
return false;
}
$this->writeScanLogLine("\nremoveInvalidReferences:");
if ($a_invalid_refs === NULL and isset($this->invalid_references))
{
$a_invalid_refs =& $this->invalid_references;
}
// handle wrong input
if (!is_array($a_invalid_refs))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no unbound references found. do nothing
if (count($a_invalid_refs) == 0)
{
$this->writeScanLogLine("none");
return false;
}
/*******************
removal starts here
********************/
$message = sprintf('%s::removeInvalidReferences(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
foreach ($a_invalid_refs as $entry)
{
$q = "DELETE FROM object_reference WHERE ref_id= ".$this->db->quote($entry["ref_id"]).
" AND obj_id = ".$this->db->quote($entry["obj_id"])." ";
$this->db->query($q);
$message = sprintf('%s::removeInvalidReferences(): Reference %s removed',
get_class($this),
$entry["ref_id"]);
$ilLog->write($message,$ilLog->WARNING);
$this->writeScanLogLine("Entry ".$entry["ref_id"]." removed");
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::removeInvalidRolefolders | ( | $ | a_invalid_rolefolders = NULL |
) |
Removes invalid rolefolders.
public
| array | obj_ids of rolefolder objects (optional) |
Definition at line 1222 of file class.ilValidator.php.
References $ilias, $ilLog, restoreReference(), and writeScanLogLine().
Referenced by validate().
{
global $ilias,$ilLog;
// check mode: clean
if ($this->mode["clean"] !== true)
{
return false;
}
$this->writeScanLogLine("\nremoveInvalidRolefolders:");
if ($a_invalid_rolefolders === NULL and isset($this->invalid_rolefolders))
{
$a_invalid_rolefolders = $this->invalid_rolefolders;
}
// handle wrong input
if (!is_array($a_invalid_rolefolders))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no invalid rolefolders found. do nothing
if (count($a_invalid_rolefolders) == 0)
{
$this->writeScanLogLine("none");
return false;
}
/*******************
removal starts here
********************/
$removed = false;
$message = sprintf('%s::removeInvalidRolefolders(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
foreach ($a_invalid_rolefolders as $rolf)
{
// restore ref_id in case of missing
if ($rolf["ref_id"] === NULL)
{
$rolf["ref_id"] = $this->restoreReference($rolf["obj_id"]);
$this->writeScanLogLine("Created missing reference '".$rolf["ref_id"]."' for rolefolder object '".$rolf["obj_id"]."'");
}
// now delete rolefolder
$obj_data =& $ilias->obj_factory->getInstanceByRefId($rolf["ref_id"]);
$obj_data->delete();
unset($obj_data);
$removed = true;
$this->writeScanLogLine("Removed invalid rolefolder '".$rolf["title"]."' (id=".$rolf["obj_id"].",ref=".$rolf["ref_id"].") from system");
}
return $removed;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::restoreDeletedObjects | ( | $ | a_nodes | ) |
Restore deleted objects (and their subobjects) to RecoveryFolder.
private
| array | list of nodes |
Definition at line 1501 of file class.ilValidator.php.
References $ilias, $ilLog, and writeScanLogLine().
Referenced by restoreTrash().
{
global $tree,$rbacadmin,$ilias,$ilLog;
//vd($a_nodes);exit;
// handle wrong input
if (!is_array($a_nodes))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no invalid parents found. do nothing
if (count($a_nodes) == 0)
{
$this->writeScanLogLine("none");
return false;
}
$message = sprintf('%s::restoreDeletedObjects()): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// first delete all rolefolders
// don't save rolefolders, remove them
// TODO process ROLE_FOLDER_ID
foreach ($a_nodes as $key => $node)
{
if ($node["type"] == "rolf")
{
// delete old tree entries
$tree->deleteTree($node);
$obj_data =& $ilias->obj_factory->getInstanceByRefId($node["child"]);
$obj_data->delete();
unset($a_nodes[$key]);
}
}
// process move
foreach ($a_nodes as $node)
{
// delete old tree entries
$tree->deleteTree($node);
$rbacadmin->revokePermission($node["child"]);
$obj_data =& $ilias->obj_factory->getInstanceByRefId($node["child"]);
$obj_data->putInTree(RECOVERY_FOLDER_ID);
$obj_data->setPermissions(RECOVERY_FOLDER_ID);
$obj_data->initDefaultRoles();
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::restoreMissingObjects | ( | $ | a_missing_objects = NULL |
) |
Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Restored object are placed in RecoveryFolder.
public
| array | obj_ids of missing objects (optional) |
Definition at line 1294 of file class.ilValidator.php.
References $ilias, $ilLog, restoreReference(), and writeScanLogLine().
Referenced by validate().
{
global $ilias,$rbacadmin,$ilLog;
// check mode: restore
if ($this->mode["restore"] !== true)
{
return false;
}
$this->writeScanLogLine("\nrestoreMissingObjects:");
if ($a_missing_objects === NULL and isset($this->missing_objects))
{
$a_missing_objects = $this->missing_objects;
}
// handle wrong input
if (!is_array($a_missing_objects))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no missing objects found. do nothing
if (count($a_missing_objects) == 0)
{
$this->writeScanLogLine("none");
return false;
}
/*******************
restore starts here
********************/
$restored = false;
$message = sprintf('%s::restoreMissingObjects(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
foreach ($a_missing_objects as $missing_obj)
{
// restore ref_id in case of missing
if ($missing_obj["ref_id"] === NULL)
{
$missing_obj["ref_id"] = $this->restoreReference($missing_obj["obj_id"]);
$this->writeScanLogLine("Created missing reference '".$missing_obj["ref_id"]."' for object '".$missing_obj["obj_id"]."'");
}
// put in tree under RecoveryFolder if not on exclude list
if (!in_array($missing_obj["type"],$this->object_types_exclude))
{
$rbacadmin->revokePermission($missing_obj["ref_id"]);
$obj_data =& $ilias->obj_factory->getInstanceByRefId($missing_obj["ref_id"]);
$obj_data->putInTree(RECOVERY_FOLDER_ID);
$obj_data->setPermissions(RECOVERY_FOLDER_ID);
$obj_data->initDefaultRoles();
unset($obj_data);
//$tree->insertNode($missing_obj["ref_id"],RECOVERY_FOLDER_ID);
$restored = true;
$this->writeScanLogLine("Restored object '".$missing_obj["title"]."' (id=".$missing_obj["obj_id"].",ref=".$missing_obj["ref_id"].") in 'Restored objects folder'");
}
// TODO: process rolefolders
}
return $restored;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::restoreReference | ( | $ | a_obj_id | ) |
restore a reference for an object Creates a new reference entry in DB table object_reference for $a_obj_id
| integer | obj_id private |
Definition at line 1374 of file class.ilValidator.php.
References $ilLog.
Referenced by removeInvalidRolefolders(), and restoreMissingObjects().
{
global $ilLog;
if (empty($a_obj_id))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
$q = "INSERT INTO object_reference (ref_id,obj_id) VALUES ('0',".$this->db->quote($a_obj_id)." )";
$this->db->query($q);
$message = sprintf('%s::restoreReference(): new reference %s for obj_id %s created',
get_class($this),
$this->db->getLastInsertId(),
$a_obj_id);
$ilLog->write($message,$ilLog->WARNING);
return $this->db->getLastInsertId();
}
Here is the caller graph for this function:| ilValidator::restoreSubTrees | ( | $ | a_nodes | ) |
Restore objects (and their subobjects) to RecoveryFolder.
private
| array | list of nodes |
Definition at line 1563 of file class.ilValidator.php.
References $ilias, $ilLog, findInvalidChilds(), removeInvalidChilds(), and writeScanLogLine().
Referenced by restoreUnboundObjects().
{
global $tree,$rbacadmin,$ilias,$ilLog;
// handle wrong input
if (!is_array($a_nodes))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
// no invalid parents found. do nothing
if (count($a_nodes) == 0)
{
$this->writeScanLogLine("none");
return false;
}
/*******************
restore starts here
********************/
$subnodes = array();
$topnode = array();
$message = sprintf('%s::restoreSubTrees(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// process move subtree
foreach ($a_nodes as $node)
{
// get node data
$topnode = $tree->getNodeData($node["child"], $node['tree']);
// don't save rolefolders, remove them
// TODO process ROLE_FOLDER_ID
if ($topnode["type"] == "rolf")
{
$rolfObj = $ilias->obj_factory->getInstanceByRefId($topnode["child"]);
$rolfObj->delete();
unset($top_node);
unset($rolfObj);
continue;
}
// get subnodes of top nodes
$subnodes[$node["child"]] = $tree->getSubtree($topnode);
// delete old tree entries
$tree->deleteTree($topnode);
}
// now move all subtrees to new location
// TODO: this whole put in place again stuff needs revision. Permission settings get lost.
foreach ($subnodes as $key => $subnode)
{
// first paste top_node ...
$rbacadmin->revokePermission($key);
$obj_data =& $ilias->obj_factory->getInstanceByRefId($key);
$obj_data->putInTree(RECOVERY_FOLDER_ID);
$obj_data->setPermissions(RECOVERY_FOLDER_ID);
$obj_data->initDefaultRoles();
$this->writeScanLogLine("Object '".$obj_data->getId()."' restored.");
// ... remove top_node from list ...
array_shift($subnode);
// ... insert subtree of top_node if any subnodes exist
if (count($subnode) > 0)
{
foreach ($subnode as $node)
{
$rbacadmin->revokePermission($node["child"]);
$obj_data =& $ilias->obj_factory->getInstanceByRefId($node["child"]);
$obj_data->putInTree($node["parent"]);
$obj_data->setPermissions($node["parent"]);
$obj_data->initDefaultRoles();
$this->writeScanLogLine("Object '".$obj_data->getId()."' restored.");
}
}
}
// final clean up
$this->findInvalidChilds();
$this->removeInvalidChilds();
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::restoreTrash | ( | $ | a_deleted_objects = NULL |
) |
Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryFolder regardless of existing hierarchical structure!
public
| array | list of deleted childs (optional) |
Definition at line 1447 of file class.ilValidator.php.
References $ilLog, restoreDeletedObjects(), and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: restore
if ($this->mode["restore_trash"] !== true)
{
return false;
}
$this->writeScanLogLine("\nrestoreTrash:");
if ($a_deleted_objects === NULL and isset($this->deleted_objects))
{
$a_deleted_objects = $this->deleted_objects;
}
// handle wrong input
if (!is_array($a_deleted_objects))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
$message = sprintf('%s::restoreTrash(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// start restore process
$restored = $this->restoreDeletedObjects($a_deleted_objects);
if ($restored)
{
$q = "DELETE FROM tree WHERE tree!=1";
$this->db->query($q);
$message = sprintf('%s::restoreTrash(): Removed all trees with tree id <> 1',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
$this->writeScanLogLine("Old tree entries removed");
}
return $restored;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::restoreUnboundObjects | ( | $ | a_unbound_objects = NULL |
) |
Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in the hierarchy because they point to an invalid parent_id.
public
| array | list of childs with invalid parents (optional) |
Definition at line 1406 of file class.ilValidator.php.
References $ilLog, restoreSubTrees(), and writeScanLogLine().
Referenced by validate().
{
global $ilLog;
// check mode: restore
if ($this->mode["restore"] !== true)
{
return false;
}
$this->writeScanLogLine("\nrestoreUnboundObjects:");
if ($a_unbound_objects === NULL and isset($this->unbound_objects))
{
$a_unbound_objects = $this->unbound_objects;
}
// handle wrong input
if (!is_array($a_unbound_objects))
{
$this->throwError(INVALID_PARAM, WARNING, DEBUG);
return false;
}
$message = sprintf('%s::restoreUnboundObjects(): Started...',
get_class($this));
$ilLog->write($message,$ilLog->WARNING);
// start restore process
return $this->restoreSubTrees($a_unbound_objects);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::setMode | ( | $ | a_mode, | |
| $ | a_value | |||
| ) |
set mode of ilValidator Usage: setMode("restore",true) => enable object restorey setMode("all",true) => enable all features For all possible modes see variables declaration
public
| string | mode | |
| boolean | value (true=enable/false=disable) |
Definition at line 176 of file class.ilValidator.php.
References $mode, and setModeDependencies().
{
if ((!in_array($a_mode,array_keys($this->mode)) and $a_mode != "all") or !is_bool($a_value))
{
$this->throwError(INVALID_PARAM, FATAL, DEBUG);
return false;
}
if ($a_mode == "all")
{
foreach ($this->mode as $mode => $value)
{
$this->mode[$mode] = $a_value;
}
}
else
{
$this->mode[$a_mode] = $a_value;
}
// consider mode dependencies
$this->setModeDependencies();
return true;
}
Here is the call graph for this function:| ilValidator::setModeDependencies | ( | ) |
Sets modes by considering mode dependencies; some modes require other modes to be activated.
This functions set all modes that are required according to the current setting.
private
Definition at line 234 of file class.ilValidator.php.
Referenced by setMode().
{
// DO NOT change the order
if ($this->mode["restore"] === true)
{
$this->mode["scan"] = true;
$this->mode["purge"] = false;
}
if ($this->mode["purge"] === true)
{
$this->mode["scan"] = true;
$this->mode["restore"] = false;
}
if ($this->mode["restore_trash"] === true)
{
$this->mode["scan"] = true;
$this->mode["purge_trash"] = false;
}
if ($this->mode["purge_trash"] === true)
{
$this->mode["scan"] = true;
$this->mode["restore_trash"] = false;
}
if ($this->mode["clean"] === true)
{
$this->mode["scan"] = true;
}
}
Here is the caller graph for this function:| ilValidator::validate | ( | ) |
Performs the validation for each enabled mode.
Returns a validation summary for display to the user.
Definition at line 276 of file class.ilValidator.php.
References $lng, $mode, checkTreeStructure(), dumpTree(), findDeletedObjects(), findInvalidChilds(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), findUnboundObjects(), getDeletedObjects(), getInvalidChilds(), getInvalidReferences(), getInvalidRolefolders(), getMissingObjects(), getUnboundObjects(), initGapsInTree(), isModeEnabled(), purgeMissingObjects(), purgeTrash(), purgeUnboundObjects(), removeInvalidChilds(), removeInvalidReferences(), removeInvalidRolefolders(), restoreMissingObjects(), restoreTrash(), and restoreUnboundObjects().
{
global $lng;
// The validation summary.
$summary = "";
// STEP 1: Scan
// -------------------
$summary .= $lng->txt("scanning_system");
if (!$this->isModeEnabled("scan"))
{
$summary .= $lng->txt("disabled");
}
else
{
$summary .= "<br/>".$lng->txt("searching_invalid_refs");
if ($this->findInvalidReferences())
{
$summary .= count($this->getInvalidReferences())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/>".$lng->txt("searching_invalid_childs");
if ($this->findInvalidChilds())
{
$summary .= count($this->getInvalidChilds())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/>".$lng->txt("searching_missing_objs");
if ($this->findMissingObjects())
{
$summary .= count($this->getMissingObjects())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/>".$lng->txt("searching_unbound_objs");
if ($this->findUnboundObjects())
{
$summary .= count($this->getUnboundObjects())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/>".$lng->txt("searching_deleted_objs");
if ($this->findDeletedObjects())
{
$summary .= count($this->getDeletedObjects())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/>".$lng->txt("searching_invalid_rolfs");
if ($this->findInvalidRolefolders())
{
$summary .= count($this->getInvalidRolefolders())." ".$lng->txt("found");
}
else
{
$summary .= $lng->txt("found_none");
}
$summary .= "<br/><br/>".$lng->txt("analyzing_tree_structure");
if ($this->checkTreeStructure())
{
$summary .= $lng->txt("tree_corrupt");
}
else
{
$summary .= $lng->txt("disabled");
}
}
// STEP 2: Dump tree
// -------------------
$summary .= "<br /><br />".$lng->txt("dumping_tree");
if (!$this->isModeEnabled("dump_tree"))
{
$summary .= $lng->txt("disabled");
}
else
{
$error_count = $this->dumpTree();
if ($error_count > 0)
{
$summary .= $lng->txt("tree_corrupt");
}
else
{
$summary .= $lng->txt("done");
}
}
// STEP 3: Clean Up
// -------------------
$summary .= "<br /><br />".$lng->txt("cleaning");
if (!$this->isModeEnabled("clean"))
{
$summary .= $lng->txt("disabled");
}
else
{
$summary .= "<br />".$lng->txt("removing_invalid_refs");
if ($this->removeInvalidReferences())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_remove").$lng->txt("skipped");
}
$summary .= "<br />".$lng->txt("removing_invalid_childs");
if ($this->removeInvalidChilds())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_remove").$lng->txt("skipped");
}
$summary .= "<br />".$lng->txt("removing_invalid_rolfs");
if ($this->removeInvalidRolefolders())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_remove").$lng->txt("skipped");
}
// find unbound objects again AFTER cleaning process!
// This updates the array 'unboundobjects' required for the further steps
// There might be other objects unbounded now due to removal of object_data/reference entries.
$this->findUnboundObjects();
}
// STEP 4: Restore objects
$summary .= "<br /><br />".$lng->txt("restoring");
if (!$this->isModeEnabled("restore"))
{
$summary .= $lng->txt("disabled");
}
else
{
$summary .= "<br />".$lng->txt("restoring_missing_objs");
if ($this->restoreMissingObjects())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_restore").$lng->txt("skipped");
}
$summary .= "<br />".$lng->txt("restoring_unbound_objs");
if ($this->restoreUnboundObjects())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_restore").$lng->txt("skipped");
}
}
// STEP 5: Restoring Trash
$summary .= "<br /><br />".$lng->txt("restoring_trash");
if (!$this->isModeEnabled("restore_trash"))
{
$summary .= $lng->txt("disabled");
}
else
{
if ($this->restoreTrash())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_restore").$lng->txt("skipped");
}
}
// STEP 6: Purging...
$summary .= "<br /><br />".$lng->txt("purging");
if (!$this->isModeEnabled("purge"))
{
$summary .= $lng->txt("disabled");
}
else
{
$summary .= "<br />".$lng->txt("purging_missing_objs");
if ($this->purgeMissingObjects())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_purge").$lng->txt("skipped");
}
$summary .= "<br />".$lng->txt("purging_unbound_objs");
if ($this->purgeUnboundObjects())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_purge").$lng->txt("skipped");
}
}
// STEP 7: Purging trash...
$summary .= "<br /><br />".$lng->txt("purging_trash");
if (!$this->isModeEnabled("purge_trash"))
{
$summary .= $lng->txt("disabled");
}
else
{
if ($this->purgeTrash())
{
$summary .= strtolower($lng->txt("done"));
}
else
{
$summary .= $lng->txt("nothing_to_purge").$lng->txt("skipped");
}
}
// STEP 8: Initialize gaps in tree
if ($this->isModeEnabled("clean"))
{
$summary .= "<br /><br />".$lng->txt("cleaning_final");
if ($this->initGapsInTree())
{
$summary .= "<br />".$lng->txt("initializing_gaps")." ".strtolower($lng->txt("done"));
}
}
// check RBAC starts here
// ...
// le fin
foreach ($this->mode as $mode => $value)
{
$arr[] = $mode."[".(int)$value."]";
}
return $summary;
}
Here is the call graph for this function:| ilValidator::writeScanLogArray | ( | $ | a_arr | ) |
Definition at line 1961 of file class.ilValidator.php.
References isLogEnabled().
Referenced by findDeletedObjects(), findInvalidChilds(), findInvalidRBACEntries(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), and findUnboundObjects().
{
if (!$this->isLogEnabled())
{
return false;
}
foreach ($a_arr as $entry)
{
$this->scan_log->write(implode("\t",$entry));
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::writeScanLogLine | ( | $ | a_msg | ) |
Definition at line 1974 of file class.ilValidator.php.
References isLogEnabled().
Referenced by checkTreeStructure(), dumpTree(), findDeletedObjects(), findInvalidChilds(), findInvalidRBACEntries(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), findUnboundObjects(), ilValidator(), initGapsInTree(), purgeMissingObjects(), purgeObjects(), purgeTrash(), purgeUnboundObjects(), removeInvalidChilds(), removeInvalidReferences(), removeInvalidRolefolders(), restoreDeletedObjects(), restoreMissingObjects(), restoreSubTrees(), restoreTrash(), and restoreUnboundObjects().
{
if (!$this->isLogEnabled())
{
return false;
}
$this->scan_log->write($a_msg);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilValidator::$deleted_objects = array() |
Definition at line 98 of file class.ilValidator.php.
| ilValidator::$invalid_childs = array() |
Definition at line 80 of file class.ilValidator.php.
| ilValidator::$invalid_objects = array() |
Definition at line 112 of file class.ilValidator.php.
| ilValidator::$invalid_references = array() |
Definition at line 74 of file class.ilValidator.php.
| ilValidator::$invalid_rolefolders = array() |
Definition at line 106 of file class.ilValidator.php.
| ilValidator::$logging = false |
Definition at line 118 of file class.ilValidator.php.
ilValidator::$media_pool_ids = null [protected] |
Definition at line 33 of file class.ilValidator.php.
| ilValidator::$missing_objects = array() |
Definition at line 86 of file class.ilValidator.php.
| ilValidator::$mode |
array(
"scan" => true,
"dump_tree" => false,
"clean" => false,
"restore" => false,
"purge" => false,
"restore_trash" => false,
"purge_trash" => false
)
Definition at line 60 of file class.ilValidator.php.
Referenced by setMode(), and validate().
| ilValidator::$object_types_exclude |
array("adm","root","mail","usrf","objf","lngf", "trac","taxf","auth","rolf","assf","extt","adve","fold")
Definition at line 53 of file class.ilValidator.php.
| ilValidator::$rbac_object_types = NULL |
Definition at line 39 of file class.ilValidator.php.
| ilValidator::$scan_log |
Definition at line 124 of file class.ilValidator.php.
Referenced by readScanLog().
| ilValidator::$scan_log_file = "scanlog.log" |
Definition at line 126 of file class.ilValidator.php.
| ilValidator::$scan_log_separator = "<!-- scan log start -->" |
Definition at line 128 of file class.ilValidator.php.
| ilValidator::$unbound_objects = array() |
Definition at line 92 of file class.ilValidator.php.
1.7.1