34 "trac",
"taxf",
"auth",
"rolf",
"assf",
"svyf",
"extt",
"adve",
"fold");
46 "restore_trash" =>
false,
47 "purge_trash" =>
false
118 global $objDefinition,
$ilDB;
122 $this->rbac_object_types =
"'".implode(
"','",$objDefinition->getAllRBACObjects()).
"'";
123 $this->rbac_object_types = $objDefinition->getAllRBACObjects();
129 $this->logging =
true;
133 include_once
"./Services/Logging/classes/class.ilLog.php";
139 include_once
'./Services/Logging/classes/class.ilLog.php';
140 $this->scan_log =
new ilLog(CLIENT_DATA_DIR,
"scanlog.log");
141 $this->scan_log->setLogFormat(
"");
154 return array_keys($this->mode);
170 if ((!in_array($a_mode,array_keys($this->mode)) and $a_mode !=
"all") or !is_bool($a_value))
176 if ($a_mode ==
"all")
178 foreach ($this->mode as
$mode => $value)
180 $this->mode[
$mode] = $a_value;
185 $this->mode[$a_mode] = $a_value;
204 if (!in_array($a_mode,array_keys($this->mode)))
210 return $this->mode[$a_mode];
230 if ($this->mode[
"restore"] ===
true)
232 $this->mode[
"scan"] =
true;
233 $this->mode[
"purge"] =
false;
236 if ($this->mode[
"purge"] ===
true)
238 $this->mode[
"scan"] =
true;
239 $this->mode[
"restore"] =
false;
242 if ($this->mode[
"restore_trash"] ===
true)
244 $this->mode[
"scan"] =
true;
245 $this->mode[
"purge_trash"] =
false;
248 if ($this->mode[
"purge_trash"] ===
true)
250 $this->mode[
"scan"] =
true;
251 $this->mode[
"restore_trash"] =
false;
254 if ($this->mode[
"clean"] ===
true)
256 $this->mode[
"scan"] =
true;
278 $summary .=
$lng->txt(
"scanning_system");
281 $summary .=
$lng->txt(
"disabled");
285 $summary .=
"<br/>".$lng->txt(
"searching_invalid_refs");
292 $summary .=
$lng->txt(
"found_none");
295 $summary .=
"<br/>".$lng->txt(
"searching_invalid_childs");
303 $summary .=
$lng->txt(
"found_none");
306 $summary .=
"<br/>".$lng->txt(
"searching_missing_objs");
314 $summary .=
$lng->txt(
"found_none");
317 $summary .=
"<br/>".$lng->txt(
"searching_unbound_objs");
325 $summary .=
$lng->txt(
"found_none");
328 $summary .=
"<br/>".$lng->txt(
"searching_deleted_objs");
336 $summary .=
$lng->txt(
"found_none");
339 $summary .=
"<br/>".$lng->txt(
"searching_invalid_rolfs");
347 $summary .=
$lng->txt(
"found_none");
350 $summary .=
"<br/><br/>".$lng->txt(
"analyzing_tree_structure");
353 $summary .=
$lng->txt(
"tree_corrupt");
357 $summary .=
$lng->txt(
"done");
363 $summary .=
"<br /><br />".$lng->txt(
"dumping_tree");
366 $summary .=
$lng->txt(
"disabled");
371 if ($error_count > 0)
373 $summary .=
$lng->txt(
"tree_corrupt");
377 $summary .=
$lng->txt(
"done");
383 $summary .=
"<br /><br />".$lng->txt(
"cleaning");
386 $summary .=
$lng->txt(
"disabled");
390 $summary .=
"<br />".$lng->txt(
"removing_invalid_refs");
393 $summary .= strtolower(
$lng->txt(
"done"));
397 $summary .=
$lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
400 $summary .=
"<br />".$lng->txt(
"removing_invalid_childs");
403 $summary .= strtolower(
$lng->txt(
"done"));
407 $summary .=
$lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
410 $summary .=
"<br />".$lng->txt(
"removing_invalid_rolfs");
413 $summary .= strtolower(
$lng->txt(
"done"));
417 $summary .=
$lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
427 $summary .=
"<br /><br />".$lng->txt(
"restoring");
431 $summary .=
$lng->txt(
"disabled");
435 $summary .=
"<br />".$lng->txt(
"restoring_missing_objs");
438 $summary .= strtolower(
$lng->txt(
"done"));
442 $summary .=
$lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
445 $summary .=
"<br />".$lng->txt(
"restoring_unbound_objs");
448 $summary .= strtolower(
$lng->txt(
"done"));
452 $summary .=
$lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
457 $summary .=
"<br /><br />".$lng->txt(
"restoring_trash");
461 $summary .=
$lng->txt(
"disabled");
467 $summary .= strtolower(
$lng->txt(
"done"));
471 $summary .=
$lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
476 $summary .=
"<br /><br />".$lng->txt(
"purging");
480 $summary .=
$lng->txt(
"disabled");
484 $summary .=
"<br />".$lng->txt(
"purging_missing_objs");
487 $summary .= strtolower(
$lng->txt(
"done"));
491 $summary .=
$lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
494 $summary .=
"<br />".$lng->txt(
"purging_unbound_objs");
497 $summary .= strtolower(
$lng->txt(
"done"));
501 $summary .=
$lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
506 $summary .=
"<br /><br />".$lng->txt(
"purging_trash");
510 $summary .=
$lng->txt(
"disabled");
516 $summary .= strtolower(
$lng->txt(
"done"));
520 $summary .=
$lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
527 $summary .=
"<br /><br />".$lng->txt(
"cleaning_final");
530 $summary .=
"<br />".$lng->txt(
"initializing_gaps").
" ".strtolower(
$lng->txt(
"done"));
538 foreach ($this->mode as
$mode => $value)
540 $arr[] =
$mode.
"[".(int)$value.
"]";
561 if ($this->mode[
"scan"] !==
true)
567 $this->missing_objects = array();
576 $q =
"SELECT object_data.*, ref_id FROM object_data ".
577 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
578 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
579 "WHERE tree.child IS NULL ".
580 "AND (object_reference.obj_id IS NOT NULL ".
581 " OR object_data.type <> 'file' AND ".
582 $ilDB->in(
'object_data.type',$this->rbac_object_types,
false,
'text').
584 $r = $this->db->query($q);
588 #if (!in_array($row->type,$this->object_types_exclude))
591 $this->missing_objects[] = array(
592 "obj_id" =>
$row->obj_id,
593 "type" =>
$row->type,
594 "ref_id" =>
$row->ref_id,
595 "child" =>
$row->child,
596 "title" =>
$row->title,
597 "desc" =>
$row->description,
598 "owner" =>
$row->owner,
599 "create_date" =>
$row->create_date,
600 "last_update" =>
$row->last_update
606 if (count($this->missing_objects) > 0)
608 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
633 if ($this->mode[
"scan"] !==
true)
639 $this->invalid_rolefolders = array();
644 $q =
"SELECT object_data.*, ref_id FROM object_data ".
645 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
646 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
647 "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
648 "AND object_data.type='rolf'";
649 $r = $this->db->query($q);
653 $this->invalid_rolefolders[] = array(
654 "obj_id" =>
$row->obj_id,
655 "type" =>
$row->type,
656 "ref_id" =>
$row->ref_id,
657 "child" =>
$row->child,
658 "title" =>
$row->title,
659 "desc" =>
$row->description,
660 "owner" =>
$row->owner,
661 "create_date" =>
$row->create_date,
662 "last_update" =>
$row->last_update
667 $q =
"SELECT object_data.*, ref_id FROM object_data ".
668 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
669 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
670 "WHERE object_reference.ref_id = ".$ilDB->quote(RECOVERY_FOLDER_ID,
'integer').
" ".
671 "AND object_data.type='rolf'";
672 $r = $this->db->query($q);
676 $this->invalid_rolefolders[] = array(
677 "obj_id" =>
$row->obj_id,
678 "type" =>
$row->type,
679 "ref_id" =>
$row->ref_id,
680 "child" =>
$row->child,
681 "title" =>
$row->title,
682 "desc" =>
$row->description,
683 "owner" =>
$row->owner,
684 "create_date" =>
$row->create_date,
685 "last_update" =>
$row->last_update
690 if (count($this->invalid_rolefolders) > 0)
692 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
715 if ($this->mode[
"scan"] !==
true)
721 $this->invalid_rbac_entries = array();
725 $q =
"SELECT object_data.*, ref_id FROM object_data ".
726 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
727 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
728 "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
729 "AND object_data.type='rolf'";
730 $r = $this->db->query($q);
734 $this->invalid_rolefolders[] = array(
735 "obj_id" =>
$row->obj_id,
736 "type" =>
$row->type,
737 "ref_id" =>
$row->ref_id,
738 "child" =>
$row->child,
739 "title" =>
$row->title,
740 "desc" =>
$row->description,
741 "owner" =>
$row->owner,
742 "create_date" =>
$row->create_date,
743 "last_update" =>
$row->last_update
748 $q =
"SELECT object_data.*, ref_id FROM object_data ".
749 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
750 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
751 "WHERE object_reference.ref_id =".$ilDB->quote(RECOVERY_FOLDER_ID).
" ".
752 "AND object_data.type='rolf'";
753 $r = $this->db->query($q);
757 $this->invalid_rolefolders[] = array(
758 "obj_id" =>
$row->obj_id,
759 "type" =>
$row->type,
760 "ref_id" =>
$row->ref_id,
761 "child" =>
$row->child,
762 "title" =>
$row->title,
763 "desc" =>
$row->description,
764 "owner" =>
$row->owner,
765 "create_date" =>
$row->create_date,
766 "last_update" =>
$row->last_update
771 if (count($this->invalid_rolefolders) > 0)
773 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
814 if ($this->mode[
"scan"] !==
true)
820 $this->invalid_references = array();
823 $q =
"SELECT object_reference.* FROM object_reference ".
824 "LEFT JOIN object_data ON object_data.obj_id = object_reference.obj_id ".
825 "WHERE object_data.obj_id IS NULL ".
826 "OR ".$ilDB->in(
'object_data.type',$this->rbac_object_types,
true,
'text');
827 $r = $this->db->query($q);
831 $this->invalid_references[] = array(
832 "ref_id" =>
$row->ref_id,
833 "obj_id" =>
$row->obj_id,
834 "msg" =>
"Object does not exist."
839 if (count($this->invalid_references) > 0)
877 if ($this->mode[
"scan"] !==
true)
883 $this->invalid_childs = array();
887 $q =
"SELECT tree.*,object_reference.ref_id FROM tree ".
888 "LEFT JOIN object_reference ON tree.child = object_reference.ref_id ".
889 "LEFT JOIN object_data ON object_reference.obj_id = object_data.obj_id ".
890 "WHERE object_reference.ref_id IS NULL or object_data.obj_id IS NULL";
891 $r = $this->db->query($q);
894 $this->invalid_childs[] = array(
895 "child" =>
$row->child,
896 "ref_id" =>
$row->ref_id,
897 "msg" =>
"No object found"
901 if (count($this->invalid_childs) > 0)
939 if ($this->mode[
"scan"] !==
true)
945 $this->unbound_objects = array();
949 $q =
"SELECT T1.tree,T1.child,T1.parent,".
950 "T2.tree deleted,T2.parent grandparent ".
952 "LEFT JOIN tree T2 ON T2.child=T1.parent ".
953 "WHERE (T2.tree!=1 OR T2.tree IS NULL) AND T1.parent!=0";
954 $r = $this->db->query($q);
959 if (
$row->deleted === NULL)
961 $this->unbound_objects[] = array(
962 "child" =>
$row->child,
963 "parent" =>
$row->parent,
964 "tree" =>
$row->tree,
965 "msg" =>
"No valid parent node found"
970 if (count($this->unbound_objects) > 0)
995 if ($this->mode[
"scan"] !==
true)
1001 $this->deleted_objects = array();
1006 $query =
"SELECT object_data.*,tree.tree,tree.child,tree.parent,deleted ".
1007 "FROM object_data ".
1008 "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
1009 "LEFT JOIN tree ON tree.child=object_reference.ref_id ".
1010 " WHERE tree != 1 ".
1011 " ORDER BY deleted";
1014 include_once
'./Services/Calendar/classes/class.ilDateTime.php';
1019 $this->deleted_objects[] = array(
1020 "child" =>
$row->child,
1021 "parent" =>
$row->parent,
1022 "tree" =>
$row->tree,
1023 "type" =>
$row->type,
1024 "title" =>
$row->title,
1025 "desc" =>
$row->description,
1026 "owner" =>
$row->owner,
1027 "deleted" =>
$row->deleted,
1028 "deleted_timestamp" => $tmp_date->get(
IL_CAL_UNIX),
1029 "create_date" =>
$row->create_date,
1030 "last_update" =>
$row->last_update
1034 if (count($this->deleted_objects) > 0)
1102 if ($this->mode[
"clean"] !==
true)
1109 if ($a_invalid_refs === NULL and isset($this->invalid_references))
1115 if (!is_array($a_invalid_refs))
1121 if (count($a_invalid_refs) == 0)
1131 $message = sprintf(
'%s::removeInvalidReferences(): Started...',
1138 foreach ($a_invalid_refs as $entry)
1140 $query =
"DELETE FROM object_reference WHERE ref_id= ".$this->db->quote($entry[
"ref_id"],
'integer').
1141 " AND obj_id = ".$this->db->quote($entry[
"obj_id"],
'integer').
" ";
1144 $message = sprintf(
'%s::removeInvalidReferences(): Reference %s removed',
1169 if ($this->mode[
"clean"] !==
true)
1176 if ($a_invalid_childs === NULL and isset($this->invalid_childs))
1182 if (!is_array($a_invalid_childs))
1189 if (count($a_invalid_childs) == 0)
1199 $message = sprintf(
'%s::removeInvalidChilds(): Started...',
1203 foreach ($a_invalid_childs as $entry)
1205 $q =
"DELETE FROM tree WHERE child='".$entry[
"child"].
"'";
1206 $this->db->query($q);
1208 $message = sprintf(
'%s::removeInvalidChilds(): Entry child=%s removed',
1234 if ($this->mode[
"clean"] !==
true)
1241 if ($a_invalid_rolefolders === NULL and isset($this->invalid_rolefolders))
1247 if (!is_array($a_invalid_rolefolders))
1254 if (count($a_invalid_rolefolders) == 0)
1266 $message = sprintf(
'%s::removeInvalidRolefolders(): Started...',
1273 foreach ($a_invalid_rolefolders as $rolf)
1276 if ($rolf[
"ref_id"] === NULL)
1280 $this->
writeScanLogLine(
"Created missing reference '".$rolf[
"ref_id"].
"' for rolefolder object '".$rolf[
"obj_id"].
"'");
1284 $obj_data =& $ilias->obj_factory->getInstanceByRefId($rolf[
"ref_id"]);
1285 $obj_data->delete();
1288 $this->
writeScanLogLine(
"Removed invalid rolefolder '".$rolf[
"title"].
"' (id=".$rolf[
"obj_id"].
",ref=".$rolf[
"ref_id"].
") from system");
1306 global $ilias,$rbacadmin,
$ilLog;
1309 if ($this->mode[
"restore"] !==
true)
1316 if ($a_missing_objects === NULL and isset($this->missing_objects))
1322 if (!is_array($a_missing_objects))
1329 if (count($a_missing_objects) == 0)
1341 $message = sprintf(
'%s::restoreMissingObjects(): Started...',
1348 foreach ($a_missing_objects as $missing_obj)
1351 if ($missing_obj[
"ref_id"] === NULL)
1355 $this->
writeScanLogLine(
"Created missing reference '".$missing_obj[
"ref_id"].
"' for object '".$missing_obj[
"obj_id"].
"'");
1359 #if (!in_array($missing_obj["type"],$this->object_types_exclude))
1362 $rbacadmin->revokePermission($missing_obj[
"ref_id"]);
1363 $obj_data =& $ilias->obj_factory->getInstanceByRefId($missing_obj[
"ref_id"]);
1364 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1365 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1369 $this->
writeScanLogLine(
"Restored object '".$missing_obj[
"title"].
"' (id=".$missing_obj[
"obj_id"].
",ref=".$missing_obj[
"ref_id"].
") in 'Restored objects folder'");
1392 if (empty($a_obj_id))
1398 $query =
"INSERT INTO object_reference (ref_id,obj_id) ".
1399 "VALUES (".$next_id =
$ilDB->nextId(
'object_reference').
",".$this->db->quote($a_obj_id,
'integer').
" )";
1402 $message = sprintf(
'%s::restoreReference(): new reference %s for obj_id %s created',
1426 if ($this->mode[
"restore"] !==
true)
1433 if ($a_unbound_objects === NULL and isset($this->unbound_objects))
1439 if (!is_array($a_unbound_objects))
1445 $message = sprintf(
'%s::restoreUnboundObjects(): Started...',
1467 if ($this->mode[
"restore_trash"] !==
true)
1474 if ($a_deleted_objects === NULL and isset($this->deleted_objects))
1480 if (!is_array($a_deleted_objects))
1486 $message = sprintf(
'%s::restoreTrash(): Started...',
1495 $q =
"DELETE FROM tree WHERE tree!=1";
1496 $this->db->query($q);
1498 $message = sprintf(
'%s::restoreTrash(): Removed all trees with tree id <> 1',
1518 global $tree,$rbacadmin,$ilias,
$ilLog;
1521 if (!is_array($a_nodes))
1528 if (count($a_nodes) == 0)
1534 $message = sprintf(
'%s::restoreDeletedObjects()): Started...',
1541 foreach ($a_nodes as $key => $node)
1543 if ($node[
"type"] ==
"rolf")
1546 $tree->deleteTree($node);
1548 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1549 $obj_data->delete();
1550 unset($a_nodes[$key]);
1555 foreach ($a_nodes as $node)
1558 $tree->deleteTree($node);
1560 $rbacadmin->revokePermission($node[
"child"]);
1561 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1562 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1563 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1579 global $tree,$rbacadmin,$ilias,
$ilLog;
1582 if (!is_array($a_nodes))
1589 if (count($a_nodes) == 0)
1599 $subnodes = array();
1602 $message = sprintf(
'%s::restoreSubTrees(): Started...',
1607 foreach ($a_nodes as $node)
1610 $topnode = $tree->getNodeData($node[
"child"], $node[
'tree']);
1614 if ($topnode[
"type"] ==
"rolf")
1616 $rolfObj = $ilias->obj_factory->getInstanceByRefId($topnode[
"child"]);
1624 $subnodes[$node[
"child"]] = $tree->getSubtree($topnode);
1627 $tree->deleteTree($topnode);
1632 foreach ($subnodes as $key => $subnode)
1636 $rbacadmin->revokePermission($key);
1637 $obj_data =& $ilias->obj_factory->getInstanceByRefId($key);
1638 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1639 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1644 array_shift($subnode);
1647 if (count($subnode) > 0)
1649 foreach ($subnode as $node)
1651 $rbacadmin->revokePermission($node[
"child"]);
1652 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1653 $obj_data->putInTree($node[
"parent"]);
1654 $obj_data->setPermissions($node[
"parent"]);
1682 if ($this->mode[
"purge_trash"] !==
true)
1689 if ($a_nodes === NULL and isset($this->deleted_objects))
1695 $message = sprintf(
'%s::purgeTrash(): Started...',
1717 if ($this->mode[
"purge"] !==
true)
1724 if ($a_nodes === NULL and isset($this->unbound_objects))
1729 $message = sprintf(
'%s::purgeUnboundObjects(): Started...',
1751 if ($this->mode[
"purge"] !==
true)
1758 if ($a_nodes === NULL and isset($this->missing_objects))
1763 $message = sprintf(
'%s::purgeMissingObjects(): Started...',
1783 $count_limit = $ilias->account->getPref(
"systemcheck_count_limit");
1784 if (! is_numeric($count_limit) || $count_limit < 0)
1786 $count_limit = count($a_nodes);
1788 $timestamp_limit = time();
1789 $age_limit = $ilias->account->getPref(
"systemcheck_age_limit");
1790 if (is_numeric($age_limit) && $age_limit > 0)
1792 $timestamp_limit -= $age_limit * 60 * 60 * 24;
1794 $type_limit = $ilias->account->getPref(
"systemcheck_type_limit");
1797 $type_limit = trim($type_limit);
1798 if (strlen($type_limit) == 0)
1805 if (!is_array($a_nodes))
1814 foreach ($a_nodes as $node)
1816 if ($type_limit && $node[
'type'] != $type_limit)
1819 $node[
'child'].
"\t\t".$node[
'type'].
"\t\t".$node[
'title']
1826 if ($count > $count_limit)
1828 $this->
writeScanLogLine(
"Stopped purging after ".($count - 1).
" objects, because count limit was reached: ".$count_limit);
1831 if ($node[
"deleted_timestamp"] > $timestamp_limit)
1833 $this->
writeScanLogLine(
"Stopped purging after ".($count - 1).
" objects, because timestamp limit was reached: ".date(
"c", $timestamp_limit));
1837 $ref_id = ($node[
"child"]) ? $node[
"child"] : $node[
"ref_id"];
1838 $node_obj =& $ilias->obj_factory->getInstanceByRefId(
$ref_id,
false);
1840 if ($node_obj ===
false)
1842 $this->invalid_objects[] = $node;
1846 $message = sprintf(
'%s::purgeObjects(): Removing object (id:%s ref:%s)',
1849 $node_obj->getId());
1852 $startTime = microtime(
true);
1853 $node_obj->delete();
1855 $endTime = microtime(
true);
1858 "\t".$node[
'type'].
"\t".round($endTime-$startTime,1).
"\t".$node[
'title']);
1884 $message = sprintf(
'%s::initGapsInTree(): Started...',
1889 if ($this->mode[
"clean"] !==
true)
1895 $tree->renumber(ROOT_FOLDER_ID);
1913 $call_loc = $error->backtrace[count($error->backtrace)-1];
1914 $num_args = count($call_loc[
"args"]);
1918 foreach ($call_loc[
"args"] as $arg)
1920 $type = gettype($arg);
1925 $value = strlen($arg);
1929 $value = count($arg);
1933 $value = get_class($arg);
1937 $value = ($arg) ?
"true" :
"false";
1945 $arg_list[] = array(
1947 "value" =>
"(".$value.
")"
1951 foreach ($arg_list as $arg)
1953 $arg_str .= implode(
"",$arg).
" ";
1957 $err_msg =
"<br/><b>".$error->getCode().
":</b> ".$error->getMessage().
" in ".$call_loc[
"class"].$call_loc[
"type"].$call_loc[
"function"].
"()".
1958 "<br/>Called from: ".basename($call_loc[
"file"]).
" , line ".$call_loc[
"line"].
1959 "<br/>Passed parameters: [".$num_args.
"] ".$arg_str.
"<br/>";
1962 if ($error->getUserInfo())
1964 printf(
"<br/>Parameter details:");
1966 var_dump($call_loc[
"args"]);
1970 if ($error->getCode() == FATAL)
1983 foreach ($a_arr as $entry)
1985 $this->scan_log->write(implode(
"\t",$entry));
1996 $this->scan_log->write($a_msg);
2005 return is_file(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2013 @unlink(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2024 $scanfile =& file(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2037 $logs = array_keys($a_scan_log,$this->scan_log_separator.
"\n");
2039 if (count($logs) > 0)
2041 return array_slice($a_scan_log,array_pop($logs)+2);
2071 $q =
'SELECT child FROM tree GROUP BY child HAVING COUNT(*) > 1';
2072 $r = $this->db->query($q);
2073 $duplicateNodes = array();
2076 $duplicateNodes[] =
$row->child;
2080 $q =
"SELECT tree.*,ref.ref_id,dat.obj_id objobj_id,ref.obj_id refobj_id,ref.deleted,dat.* "
2082 .
"RIGHT JOIN object_reference ref ON tree.child = ref.ref_id "
2083 .
"RIGHT JOIN object_data dat ON ref.obj_id = dat.obj_id "
2085 .
"ORDER BY tree, lft, type, dat.title";
2086 $r = $this->db->query($q);
2090 .
'<td>tree, child, parent, lft, rgt, depth</td>'
2091 .
'<td>ref_id, ref.obj_id, deleted</td>'
2092 .
'<td>obj_id, type, owner, title</td>'
2101 $repository_tree_count = 0;
2102 $trash_trees_count = 0;
2103 $other_trees_count = 0;
2104 $not_in_tree_count = 0;
2107 $previousNumber = 0;
2114 if($this->workspace_object_ids &&
2115 in_array(
$row->objobj_id, $this->workspace_object_ids))
2121 if (is_null(
$row->child))
2123 switch (
$row->type) {
2137 if (is_null(
$row->ref_id)) {
2147 $isParentOkay =
false;
2150 $isDepthOkay =
false;
2164 $isParentOkay =
false;
2167 $isDepthOkay =
false;
2172 $not_in_tree_count++;
2177 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2180 .(($isParentOkay) ?
'' :
'parent:<b>')
2182 .(($isParentOkay) ?
'' :
'</b>')
2184 .(($isLftOkay) ?
'' :
'lft:<b>')
2186 .(($isLftOkay) ?
'' :
'</b>')
2188 .(($isRgtOkay) ?
'' :
'rgt:<b>')
2190 .(($isRgtOkay) ?
'' :
'</b>')
2192 .(($isDepthOkay) ?
'' :
'depth:<b>')
2194 .(($isDepthOkay) ?
'' :
'</b>')
2195 .(($isRowOkay) ?
'' :
'</font>')
2197 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2198 .(($isRefRefOkay && $isChildOkay) ?
'' :
'ref.ref_id:<b>')
2200 .(($isRefRefOkay && $isChildOkay) ?
'' :
'</b>')
2202 .(($isRefObjOkay) ?
'' :
'ref.obj_id:<b>')
2204 .(($isRefObjOkay) ?
'' :
'</b>')
2205 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2206 .((
$row->deleted !=
null) ?
', '.$row->deleted :
'')
2208 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2214 .(($isRowOkay) ?
'' :
' <b>*ERROR*</b><font color=#ff0000>')
2224 for ($i = 1; $i <
$row->depth; $i++)
2230 if (count($stack) == 0 || $stack[0]->tree !=
$row->tree)
2233 $previousNumber =
$row->lft - 1;
2239 while (count($stack) > 0 && $stack[count($stack) - 1]->rgt < $row->lft)
2241 $popped = array_pop($stack);
2244 $gap = $popped->rgt - $previousNumber - 1;
2248 for ($i = 1; $i < $popped->depth; $i++)
2250 $poppedIndent .=
". ";
2254 .
'<td colspan=2><div align="right">'
2255 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes at end of </font>'
2258 .
'<font color=#00cc00>'
2260 .$popped->obj_id.
', '
2262 .$popped->login.
', '
2269 $previousNumber = $popped->rgt;
2278 $isChildOkay =
true;
2279 $isParentOkay =
true;
2282 $isDepthOkay =
true;
2285 if (count($stack) > 0)
2287 $parent = $stack[count($stack) - 1];
2288 if ($parent->depth + 1 !=
$row->depth)
2290 $isDepthOkay =
false;
2293 if ($parent->child !=
$row->parent)
2295 $isParentOkay =
false;
2298 if(
$GLOBALS[
'ilSetting']->
get(
'main_tree_impl',
'ns') ==
'ns')
2300 if ($parent->lft >=
$row->lft)
2305 if ($parent->rgt <=
$row->rgt)
2314 if(
$GLOBALS[
'ilSetting']->
get(
'main_tree_impl',
'ns') ==
'ns')
2323 if (in_array(
$row->child, $duplicateNodes))
2325 $isChildOkay =
false;
2330 $isRefRefOkay =
true;
2331 $isRefObjOkay =
true;
2332 if (
$row->ref_id ==
null)
2334 $isRefRefOkay =
false;
2337 if (
$row->obj_id ==
null)
2339 $isRefObjOkay =
false;
2350 if(
$GLOBALS[
'ilSetting']->
get(
'main_tree_impl',
'ns') ==
'ns')
2352 $gap =
$row->lft - $previousNumber - 1;
2353 $previousNumber =
$row->lft;
2358 .
'<td colspan=2><div align="right">'
2359 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes between </font>'
2362 .
'<font color=#00cc00>siblings</font>'
2374 . (($isRowOkay) ?
'' :
'<font color=#ff0000>')
2376 .
$row->child .
', '
2377 . (($isParentOkay) ?
'' :
'parent:<b>')
2379 . (($isParentOkay) ?
'' :
'</b>')
2381 . (($isLftOkay) ?
'' :
'lft:<b>')
2383 . (($isLftOkay) ?
'' :
'</b>')
2385 . (($isRgtOkay) ?
'' :
'rgt:<b>')
2387 . (($isRgtOkay) ?
'' :
'</b>')
2389 . (($isDepthOkay) ?
'' :
'depth:<b>')
2391 . (($isDepthOkay) ?
'' :
'</b>')
2392 . (($isRowOkay) ?
'' :
'</font>')
2394 . (($isRowOkay) ?
'' :
'<font color=#ff0000>')
2395 . (($isRefRefOkay && $isChildOkay) ?
'' :
'ref.ref_id:<b>')
2397 . (($isRefRefOkay && $isChildOkay) ?
'' :
'</b>')
2399 . (($isRefObjOkay) ?
'' :
'ref.obj_id:<b>')
2401 . (($isRefObjOkay) ?
'' :
'</b>')
2402 . (($isRowOkay) ?
'' :
'<font color=#ff0000>')
2403 . ((
$row->tree < 0) ?
', ' .
$row->deleted :
'')
2405 . (($isRowOkay) ?
'' :
'<font color=#ff0000>')
2407 .
$row->obj_id .
', '
2409 .
$row->login .
', '
2411 . (($isRowOkay) ?
'' :
' <b>*ERROR*</b><font color=#ff0000>')
2423 if (
$row->tree == 1)
2425 $repository_tree_count++;
2427 else if (
$row->tree < 0)
2429 $trash_trees_count++;
2433 $other_trees_count++;
2439 while (count($stack) > 0)
2441 $popped = array_pop($stack);
2444 $gap = $popped->rgt - $previousNumber - 1;
2448 for ($i = 1; $i < $popped->depth; $i++)
2450 $poppedIndent .=
". ";
2454 .
'<td colspan=2><div align="right">'
2455 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes at end of </font>'
2458 .
'<font color=#00cc00>'
2460 .$popped->obj_id.
', '
2462 .$popped->login.
', '
2469 $previousNumber = $popped->rgt;
2476 if ($error_count > 0)
2478 $this->
writeScanLogLine(
'<font color=#ff0000>'.$error_count.
' errors found while dumping tree.</font>');
2484 $this->
writeScanLogLine(
"$repository_tree_count nodes in repository tree");
2490 return $error_count;
2497 if(!is_array($this->media_pool_ids))
2499 $this->media_pool_ids = array();
2500 $query =
"SELECT child FROM mep_tree ";
2504 $this->media_pool_ids[] =
$row->child;
2508 return in_array($a_obj_id,$this->media_pool_ids) ? true :
false;
2527 return in_array($a_type,$this->object_types_exclude);
2534 if($this->workspace_object_ids ===
null)
2536 $this->workspace_object_ids = array();
2539 $set =
$ilDB->query(
"SELECT DISTINCT(obj_id) FROM object_reference_ws");
2542 $this->workspace_object_ids[] =
$row[
"obj_id"];
2546 $set =
$ilDB->query(
"SELECT id FROM usr_portfolio");
2549 $this->workspace_object_ids[] =
$row[
"id"];
2561 if(is_array($this->workspace_object_ids))
2563 foreach($a_data as $idx => $item)
2565 if(in_array($item[$a_index], $this->workspace_object_ids))
2567 unset($a_data[$idx]);
const PEAR_ERROR_CALLBACK
& throwError($message=null, $code=null, $userinfo=null)
Simpler form of raiseError with fewer options.
PEAR($error_class=null)
Constructor.
setErrorHandling($mode=null, $options=null)
Sets how errors generated by this object should be handled.
const DB_FETCHMODE_OBJECT
@classDescription Date and time handling
_removeEntry($a_tree, $a_child, $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.
ILIAS Data Validator & Recovery Tool.
restoreUnboundObjects($a_unbound_objects=NULL)
Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in t...
deleteScanLog()
Delete scan log.
findUnboundObjects()
Search database for all tree entries having no valid parent (=> no valid path to root node) and store...
handleErr($error)
Callback function handles PEAR_error and outputs detailed infos about error TODO: implement that in g...
isExcludedFromRecovery($a_type, $a_obj_id)
Check if type is excluded from recovery.
restoreReference($a_obj_id)
restore a reference for an object Creates a new reference entry in DB table object_reference for $a_o...
getInvalidChilds()
Gets all tree entries without any link to a valid object.
getDeletedObjects()
Gets all object in trash.
getInvalidReferences()
Gets all reference entries that are not linked with a valid object id.
purgeTrash($a_nodes=NULL)
Removes all objects in trash from system.
writeScanLogArray($a_arr)
filterWorkspaceObjects(array &$a_data, $a_index="obj_id")
getInvalidRolefolders()
Gets invalid rolefolders (same as missing objects)
removeInvalidRolefolders($a_invalid_rolefolders=NULL)
Removes invalid rolefolders.
restoreTrash($a_deleted_objects=NULL)
Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryF...
purgeObjects($a_nodes)
removes objects from system
removeInvalidChilds($a_invalid_childs=NULL)
Removes all tree entries without any link to a valid object.
checkTreeStructure($a_startnode=null)
restoreSubTrees($a_nodes)
Restore objects (and their subobjects) to RecoveryFolder.
purgeUnboundObjects($a_nodes=NULL)
Removes all invalid objects from system.
setModeDependencies()
Sets modes by considering mode dependencies; some modes require other modes to be activated.
getUnboundObjects()
Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with ch...
restoreDeletedObjects($a_nodes)
Restore deleted objects (and their subobjects) to RecoveryFolder.
isModeEnabled($a_mode)
Is a particular mode enabled?
get_last_scan($a_scan_log)
getPossibleModes()
get possible ilValidator modes @access public
findDeletedObjects()
Search database for all tree entries having no valid parent (=> no valid path to root node) and store...
hasScanLog()
Quickly determine if there is a scan log.
dumpTree()
Dumps the Tree structure into the scan log.
findInvalidChilds()
Search database for all tree entries without any link to a valid object and stores result in $this->i...
restoreMissingObjects($a_missing_objects=NULL)
Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Resto...
setMode($a_mode, $a_value)
set mode of ilValidator Usage: setMode("restore",true) => enable object restorey setMode("all",...
findMissingObjects()
Search database for all object entries with missing reference and/or tree entry and stores result in ...
findInvalidRBACEntries()
Search database for all role entries that are linked to invalid ref_ids.
purgeMissingObjects($a_nodes=NULL)
Removes all missing objects from system.
removeInvalidReferences($a_invalid_refs=NULL)
Removes all reference entries that are linked with invalid object IDs.
findInvalidReferences()
Search database for all reference entries that are not linked with a valid object id and stores resul...
findInvalidRolefolders()
Search database for all rolefolder object entries with missing reference entry.
validate()
Performs the validation for each enabled mode.
getMissingObjects()
Gets all object entries with missing reference and/or tree entry.
ilValidator($a_log=false)
Constructor.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.