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 $this->scan_log =
new ilLog(CLIENT_DATA_DIR,
"scanlog.log");
140 $this->scan_log->setLogFormat(
"");
153 return array_keys($this->mode);
169 if ((!in_array($a_mode,array_keys($this->mode)) and $a_mode !=
"all") or !is_bool($a_value))
171 $this->
throwError(INVALID_PARAM, FATAL, DEBUG);
175 if ($a_mode ==
"all")
177 foreach ($this->mode as
$mode => $value)
179 $this->mode[
$mode] = $a_value;
184 $this->mode[$a_mode] = $a_value;
203 if (!in_array($a_mode,array_keys($this->mode)))
205 $this->
throwError(VALIDATER_UNKNOWN_MODE, WARNING, DEBUG);
209 return $this->mode[$a_mode];
229 if ($this->mode[
"restore"] ===
true)
231 $this->mode[
"scan"] =
true;
232 $this->mode[
"purge"] =
false;
235 if ($this->mode[
"purge"] ===
true)
237 $this->mode[
"scan"] =
true;
238 $this->mode[
"restore"] =
false;
241 if ($this->mode[
"restore_trash"] ===
true)
243 $this->mode[
"scan"] =
true;
244 $this->mode[
"purge_trash"] =
false;
247 if ($this->mode[
"purge_trash"] ===
true)
249 $this->mode[
"scan"] =
true;
250 $this->mode[
"restore_trash"] =
false;
253 if ($this->mode[
"clean"] ===
true)
255 $this->mode[
"scan"] =
true;
277 $summary .= $lng->txt(
"scanning_system");
280 $summary .= $lng->txt(
"disabled");
284 $summary .=
"<br/>".$lng->txt(
"searching_invalid_refs");
291 $summary .= $lng->txt(
"found_none");
294 $summary .=
"<br/>".$lng->txt(
"searching_invalid_childs");
302 $summary .= $lng->txt(
"found_none");
305 $summary .=
"<br/>".$lng->txt(
"searching_missing_objs");
313 $summary .= $lng->txt(
"found_none");
316 $summary .=
"<br/>".$lng->txt(
"searching_unbound_objs");
324 $summary .= $lng->txt(
"found_none");
327 $summary .=
"<br/>".$lng->txt(
"searching_deleted_objs");
335 $summary .= $lng->txt(
"found_none");
338 $summary .=
"<br/>".$lng->txt(
"searching_invalid_rolfs");
346 $summary .= $lng->txt(
"found_none");
349 $summary .=
"<br/><br/>".$lng->txt(
"analyzing_tree_structure");
352 $summary .= $lng->txt(
"tree_corrupt");
356 $summary .= $lng->txt(
"done");
362 $summary .=
"<br /><br />".$lng->txt(
"dumping_tree");
365 $summary .= $lng->txt(
"disabled");
370 if ($error_count > 0)
372 $summary .= $lng->txt(
"tree_corrupt");
376 $summary .= $lng->txt(
"done");
382 $summary .=
"<br /><br />".$lng->txt(
"cleaning");
385 $summary .= $lng->txt(
"disabled");
389 $summary .=
"<br />".$lng->txt(
"removing_invalid_refs");
392 $summary .= strtolower($lng->txt(
"done"));
396 $summary .= $lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
399 $summary .=
"<br />".$lng->txt(
"removing_invalid_childs");
402 $summary .= strtolower($lng->txt(
"done"));
406 $summary .= $lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
409 $summary .=
"<br />".$lng->txt(
"removing_invalid_rolfs");
412 $summary .= strtolower($lng->txt(
"done"));
416 $summary .= $lng->txt(
"nothing_to_remove").$lng->txt(
"skipped");
426 $summary .=
"<br /><br />".$lng->txt(
"restoring");
430 $summary .= $lng->txt(
"disabled");
434 $summary .=
"<br />".$lng->txt(
"restoring_missing_objs");
437 $summary .= strtolower($lng->txt(
"done"));
441 $summary .= $lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
444 $summary .=
"<br />".$lng->txt(
"restoring_unbound_objs");
447 $summary .= strtolower($lng->txt(
"done"));
451 $summary .= $lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
456 $summary .=
"<br /><br />".$lng->txt(
"restoring_trash");
460 $summary .= $lng->txt(
"disabled");
466 $summary .= strtolower($lng->txt(
"done"));
470 $summary .= $lng->txt(
"nothing_to_restore").$lng->txt(
"skipped");
475 $summary .=
"<br /><br />".$lng->txt(
"purging");
479 $summary .= $lng->txt(
"disabled");
483 $summary .=
"<br />".$lng->txt(
"purging_missing_objs");
486 $summary .= strtolower($lng->txt(
"done"));
490 $summary .= $lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
493 $summary .=
"<br />".$lng->txt(
"purging_unbound_objs");
496 $summary .= strtolower($lng->txt(
"done"));
500 $summary .= $lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
505 $summary .=
"<br /><br />".$lng->txt(
"purging_trash");
509 $summary .= $lng->txt(
"disabled");
515 $summary .= strtolower($lng->txt(
"done"));
519 $summary .= $lng->txt(
"nothing_to_purge").$lng->txt(
"skipped");
526 $summary .=
"<br /><br />".$lng->txt(
"cleaning_final");
529 $summary .=
"<br />".$lng->txt(
"initializing_gaps").
" ".strtolower($lng->txt(
"done"));
537 foreach ($this->mode as
$mode => $value)
539 $arr[] =
$mode.
"[".(int)$value.
"]";
560 if ($this->mode[
"scan"] !==
true)
566 $this->missing_objects = array();
575 $q =
"SELECT object_data.*, ref_id FROM object_data ".
576 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
577 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
578 "WHERE tree.child IS NULL ".
579 "AND (object_reference.obj_id IS NOT NULL ".
580 " OR object_data.type <> 'file' AND ".
581 $ilDB->in(
'object_data.type',$this->rbac_object_types,
false,
'text').
583 $r = $this->db->query($q);
587 #if (!in_array($row->type,$this->object_types_exclude))
590 $this->missing_objects[] = array(
591 "obj_id" =>
$row->obj_id,
592 "type" =>
$row->type,
593 "ref_id" =>
$row->ref_id,
594 "child" =>
$row->child,
595 "title" =>
$row->title,
596 "desc" =>
$row->description,
597 "owner" =>
$row->owner,
598 "create_date" =>
$row->create_date,
599 "last_update" =>
$row->last_update
604 if (count($this->missing_objects) > 0)
606 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
631 if ($this->mode[
"scan"] !==
true)
637 $this->invalid_rolefolders = array();
642 $q =
"SELECT object_data.*, ref_id FROM object_data ".
643 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
644 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
645 "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
646 "AND object_data.type='rolf'";
647 $r = $this->db->query($q);
651 $this->invalid_rolefolders[] = array(
652 "obj_id" =>
$row->obj_id,
653 "type" =>
$row->type,
654 "ref_id" =>
$row->ref_id,
655 "child" =>
$row->child,
656 "title" =>
$row->title,
657 "desc" =>
$row->description,
658 "owner" =>
$row->owner,
659 "create_date" =>
$row->create_date,
660 "last_update" =>
$row->last_update
665 $q =
"SELECT object_data.*, ref_id FROM object_data ".
666 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
667 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
668 "WHERE object_reference.ref_id = ".$ilDB->quote(RECOVERY_FOLDER_ID,
'integer').
" ".
669 "AND object_data.type='rolf'";
670 $r = $this->db->query($q);
674 $this->invalid_rolefolders[] = array(
675 "obj_id" =>
$row->obj_id,
676 "type" =>
$row->type,
677 "ref_id" =>
$row->ref_id,
678 "child" =>
$row->child,
679 "title" =>
$row->title,
680 "desc" =>
$row->description,
681 "owner" =>
$row->owner,
682 "create_date" =>
$row->create_date,
683 "last_update" =>
$row->last_update
687 if (count($this->invalid_rolefolders) > 0)
689 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
712 if ($this->mode[
"scan"] !==
true)
718 $this->invalid_rbac_entries = array();
722 $q =
"SELECT object_data.*, ref_id FROM object_data ".
723 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
724 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
725 "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) ".
726 "AND object_data.type='rolf'";
727 $r = $this->db->query($q);
731 $this->invalid_rolefolders[] = array(
732 "obj_id" =>
$row->obj_id,
733 "type" =>
$row->type,
734 "ref_id" =>
$row->ref_id,
735 "child" =>
$row->child,
736 "title" =>
$row->title,
737 "desc" =>
$row->description,
738 "owner" =>
$row->owner,
739 "create_date" =>
$row->create_date,
740 "last_update" =>
$row->last_update
745 $q =
"SELECT object_data.*, ref_id FROM object_data ".
746 "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id ".
747 "LEFT JOIN tree ON object_reference.ref_id = tree.child ".
748 "WHERE object_reference.ref_id =".$ilDB->quote(RECOVERY_FOLDER_ID).
" ".
749 "AND object_data.type='rolf'";
750 $r = $this->db->query($q);
754 $this->invalid_rolefolders[] = array(
755 "obj_id" =>
$row->obj_id,
756 "type" =>
$row->type,
757 "ref_id" =>
$row->ref_id,
758 "child" =>
$row->child,
759 "title" =>
$row->title,
760 "desc" =>
$row->description,
761 "owner" =>
$row->owner,
762 "create_date" =>
$row->create_date,
763 "last_update" =>
$row->last_update
767 if (count($this->invalid_rolefolders) > 0)
769 $this->
writeScanLogLine(
"obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
810 if ($this->mode[
"scan"] !==
true)
816 $this->invalid_references = array();
819 $q =
"SELECT object_reference.* FROM object_reference ".
820 "LEFT JOIN object_data ON object_data.obj_id = object_reference.obj_id ".
821 "WHERE object_data.obj_id IS NULL ".
822 "OR ".$ilDB->in(
'object_data.type',$this->rbac_object_types,
true,
'text');
823 $r = $this->db->query($q);
827 $this->invalid_references[] = array(
828 "ref_id" =>
$row->ref_id,
829 "obj_id" =>
$row->obj_id,
830 "msg" =>
"Object does not exist."
834 if (count($this->invalid_references) > 0)
872 if ($this->mode[
"scan"] !==
true)
878 $this->invalid_childs = array();
882 $q =
"SELECT tree.*,object_reference.ref_id FROM tree ".
883 "LEFT JOIN object_reference ON tree.child = object_reference.ref_id ".
884 "LEFT JOIN object_data ON object_reference.obj_id = object_data.obj_id ".
885 "WHERE object_reference.ref_id IS NULL or object_data.obj_id IS NULL";
886 $r = $this->db->query($q);
890 $this->invalid_childs[] = array(
891 "child" =>
$row->child,
892 "ref_id" =>
$row->ref_id,
893 "msg" =>
"No object found"
897 if (count($this->invalid_childs) > 0)
935 if ($this->mode[
"scan"] !==
true)
941 $this->unbound_objects = array();
945 $q =
"SELECT T1.tree,T1.child,T1.parent,".
946 "T2.tree deleted,T2.parent grandparent ".
948 "LEFT JOIN tree T2 ON T2.child=T1.parent ".
949 "WHERE (T2.tree!=1 OR T2.tree IS NULL) AND T1.parent!=0";
950 $r = $this->db->query($q);
955 if (
$row->deleted === NULL)
957 $this->unbound_objects[] = array(
958 "child" =>
$row->child,
959 "parent" =>
$row->parent,
960 "tree" =>
$row->tree,
961 "msg" =>
"No valid parent node found"
966 if (count($this->unbound_objects) > 0)
991 if ($this->mode[
"scan"] !==
true)
997 $this->deleted_objects = array();
1002 $query =
"SELECT object_data.*,tree.tree,tree.child,tree.parent,deleted ".
1003 "FROM object_data ".
1004 "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
1005 "LEFT JOIN tree ON tree.child=object_reference.ref_id ".
1006 " WHERE tree != 1 ".
1007 " ORDER BY deleted";
1008 $r = $this->db->query(
$query);
1010 include_once
'./Services/Calendar/classes/class.ilDateTime.php';
1015 $this->deleted_objects[] = array(
1016 "child" =>
$row->child,
1017 "parent" =>
$row->parent,
1018 "tree" =>
$row->tree,
1019 "type" =>
$row->type,
1020 "title" =>
$row->title,
1021 "desc" =>
$row->description,
1022 "owner" =>
$row->owner,
1023 "deleted" =>
$row->deleted,
1024 "deleted_timestamp" => $tmp_date->get(
IL_CAL_UNIX),
1025 "create_date" =>
$row->create_date,
1026 "last_update" =>
$row->last_update
1030 if (count($this->deleted_objects) > 0)
1099 if ($this->mode[
"clean"] !==
true)
1106 if ($a_invalid_refs === NULL and isset($this->invalid_references))
1112 if (!is_array($a_invalid_refs))
1114 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1118 if (count($a_invalid_refs) == 0)
1128 $message = sprintf(
'%s::removeInvalidReferences(): Started...',
1130 $ilLog->write($message,$ilLog->WARNING);
1132 foreach ($a_invalid_refs as $entry)
1134 $query =
"DELETE FROM object_reference WHERE ref_id= ".$this->db->quote($entry[
"ref_id"],
'integer').
1135 " AND obj_id = ".$this->db->quote($entry[
"obj_id"],
'integer').
" ";
1138 $message = sprintf(
'%s::removeInvalidReferences(): Reference %s removed',
1141 $ilLog->write($message,$ilLog->WARNING);
1163 if ($this->mode[
"clean"] !==
true)
1170 if ($a_invalid_childs === NULL and isset($this->invalid_childs))
1176 if (!is_array($a_invalid_childs))
1178 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1183 if (count($a_invalid_childs) == 0)
1193 $message = sprintf(
'%s::removeInvalidChilds(): Started...',
1195 $ilLog->write($message,$ilLog->WARNING);
1197 foreach ($a_invalid_childs as $entry)
1199 $q =
"DELETE FROM tree WHERE child='".$entry[
"child"].
"'";
1200 $this->db->query($q);
1202 $message = sprintf(
'%s::removeInvalidChilds(): Entry child=%s removed',
1205 $ilLog->write($message,$ilLog->WARNING);
1228 if ($this->mode[
"clean"] !==
true)
1235 if ($a_invalid_rolefolders === NULL and isset($this->invalid_rolefolders))
1241 if (!is_array($a_invalid_rolefolders))
1243 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1248 if (count($a_invalid_rolefolders) == 0)
1260 $message = sprintf(
'%s::removeInvalidRolefolders(): Started...',
1262 $ilLog->write($message,$ilLog->WARNING);
1264 foreach ($a_invalid_rolefolders as $rolf)
1267 if ($rolf[
"ref_id"] === NULL)
1271 $this->
writeScanLogLine(
"Created missing reference '".$rolf[
"ref_id"].
"' for rolefolder object '".$rolf[
"obj_id"].
"'");
1275 $obj_data =& $ilias->obj_factory->getInstanceByRefId($rolf[
"ref_id"]);
1276 $obj_data->delete();
1279 $this->
writeScanLogLine(
"Removed invalid rolefolder '".$rolf[
"title"].
"' (id=".$rolf[
"obj_id"].
",ref=".$rolf[
"ref_id"].
") from system");
1297 global $ilias,$rbacadmin,
$ilLog;
1300 if ($this->mode[
"restore"] !==
true)
1307 if ($a_missing_objects === NULL and isset($this->missing_objects))
1313 if (!is_array($a_missing_objects))
1315 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1320 if (count($a_missing_objects) == 0)
1332 $message = sprintf(
'%s::restoreMissingObjects(): Started...',
1334 $ilLog->write($message,$ilLog->WARNING);
1336 foreach ($a_missing_objects as $missing_obj)
1339 if ($missing_obj[
"ref_id"] === NULL)
1343 $this->
writeScanLogLine(
"Created missing reference '".$missing_obj[
"ref_id"].
"' for object '".$missing_obj[
"obj_id"].
"'");
1347 #if (!in_array($missing_obj["type"],$this->object_types_exclude))
1350 $rbacadmin->revokePermission($missing_obj[
"ref_id"]);
1351 $obj_data =& $ilias->obj_factory->getInstanceByRefId($missing_obj[
"ref_id"]);
1352 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1353 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1357 $this->
writeScanLogLine(
"Restored object '".$missing_obj[
"title"].
"' (id=".$missing_obj[
"obj_id"].
",ref=".$missing_obj[
"ref_id"].
") in 'Restored objects folder'");
1380 if (empty($a_obj_id))
1382 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1386 $query =
"INSERT INTO object_reference (ref_id,obj_id) ".
1387 "VALUES (".$next_id = $ilDB->nextId(
'object_reference').
",".$this->db->quote($a_obj_id,
'integer').
" )";
1390 $message = sprintf(
'%s::restoreReference(): new reference %s for obj_id %s created',
1394 $ilLog->write($message,$ilLog->WARNING);
1414 if ($this->mode[
"restore"] !==
true)
1421 if ($a_unbound_objects === NULL and isset($this->unbound_objects))
1427 if (!is_array($a_unbound_objects))
1429 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1433 $message = sprintf(
'%s::restoreUnboundObjects(): Started...',
1435 $ilLog->write($message,$ilLog->WARNING);
1455 if ($this->mode[
"restore_trash"] !==
true)
1462 if ($a_deleted_objects === NULL and isset($this->deleted_objects))
1468 if (!is_array($a_deleted_objects))
1470 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1474 $message = sprintf(
'%s::restoreTrash(): Started...',
1476 $ilLog->write($message,$ilLog->WARNING);
1483 $q =
"DELETE FROM tree WHERE tree!=1";
1484 $this->db->query($q);
1486 $message = sprintf(
'%s::restoreTrash(): Removed all trees with tree id <> 1',
1488 $ilLog->write($message,$ilLog->WARNING);
1506 global $tree,$rbacadmin,$ilias,
$ilLog;
1509 if (!is_array($a_nodes))
1511 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1516 if (count($a_nodes) == 0)
1522 $message = sprintf(
'%s::restoreDeletedObjects()): Started...',
1524 $ilLog->write($message,$ilLog->WARNING);
1529 foreach ($a_nodes as $key => $node)
1531 if ($node[
"type"] ==
"rolf")
1534 $tree->deleteTree($node);
1536 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1537 $obj_data->delete();
1538 unset($a_nodes[$key]);
1543 foreach ($a_nodes as $node)
1546 $tree->deleteTree($node);
1548 $rbacadmin->revokePermission($node[
"child"]);
1549 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1550 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1551 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1567 global $tree,$rbacadmin,$ilias,
$ilLog;
1570 if (!is_array($a_nodes))
1572 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1577 if (count($a_nodes) == 0)
1587 $subnodes = array();
1590 $message = sprintf(
'%s::restoreSubTrees(): Started...',
1592 $ilLog->write($message,$ilLog->WARNING);
1595 foreach ($a_nodes as $node)
1598 $topnode = $tree->getNodeData($node[
"child"], $node[
'tree']);
1602 if ($topnode[
"type"] ==
"rolf")
1604 $rolfObj = $ilias->obj_factory->getInstanceByRefId($topnode[
"child"]);
1612 $subnodes[$node[
"child"]] = $tree->getSubtree($topnode);
1615 $tree->deleteTree($topnode);
1620 foreach ($subnodes as $key => $subnode)
1624 $rbacadmin->revokePermission($key);
1625 $obj_data =& $ilias->obj_factory->getInstanceByRefId($key);
1626 $obj_data->putInTree(RECOVERY_FOLDER_ID);
1627 $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1632 array_shift($subnode);
1635 if (count($subnode) > 0)
1637 foreach ($subnode as $node)
1639 $rbacadmin->revokePermission($node[
"child"]);
1640 $obj_data =& $ilias->obj_factory->getInstanceByRefId($node[
"child"]);
1641 $obj_data->putInTree($node[
"parent"]);
1642 $obj_data->setPermissions($node[
"parent"]);
1670 if ($this->mode[
"purge_trash"] !==
true)
1677 if ($a_nodes === NULL and isset($this->deleted_objects))
1682 $message = sprintf(
'%s::purgeTrash(): Started...',
1684 $ilLog->write($message,$ilLog->WARNING);
1704 if ($this->mode[
"purge"] !==
true)
1711 if ($a_nodes === NULL and isset($this->unbound_objects))
1716 $message = sprintf(
'%s::purgeUnboundObjects(): Started...',
1718 $ilLog->write($message,$ilLog->WARNING);
1738 if ($this->mode[
"purge"] !==
true)
1745 if ($a_nodes === NULL and isset($this->missing_objects))
1750 $message = sprintf(
'%s::purgeMissingObjects(): Started...',
1752 $ilLog->write($message,$ilLog->WARNING);
1770 $count_limit = $ilias->account->getPref(
"systemcheck_count_limit");
1771 if (! is_numeric($count_limit) || $count_limit < 0)
1773 $count_limit = count($a_nodes);
1775 $timestamp_limit = time();
1776 $age_limit = $ilias->account->getPref(
"systemcheck_age_limit");
1777 if (is_numeric($age_limit) && $age_limit > 0)
1779 $timestamp_limit -= $age_limit * 60 * 60 * 24;
1783 $timestamp_limit = 0;
1785 $type_limit = $ilias->account->getPref(
"systemcheck_type_limit");
1788 $type_limit = trim($type_limit);
1789 if (strlen($type_limit) == 0)
1796 if (!is_array($a_nodes))
1798 $this->
throwError(INVALID_PARAM, WARNING, DEBUG);
1805 foreach ($a_nodes as $node)
1807 if ($type_limit && $node[
'type'] != $type_limit)
1810 $node[
'child'].
"\t\t".$node[
'type'].
"\t\t".$node[
'title']
1817 if ($count > $count_limit)
1819 $this->
writeScanLogLine(
"Stopped purging after ".($count - 1).
" objects, because count limit was reached: ".$count_limit);
1822 if ($node[
"deleted_timestamp"] > $timestamp_limit)
1824 $this->
writeScanLogLine(
"Stopped purging after ".($count - 1).
" objects, because timestamp limit was reached: ".date(
"c", $timestamp_limit));
1828 $ref_id = ($node[
"child"]) ? $node[
"child"] : $node[
"ref_id"];
1829 $node_obj =& $ilias->obj_factory->getInstanceByRefId(
$ref_id,
false);
1831 if ($node_obj ===
false)
1833 $this->invalid_objects[] = $node;
1837 $message = sprintf(
'%s::purgeObjects(): Removing object (id:%s ref:%s)',
1840 $node_obj->getId());
1841 $ilLog->write($message,$ilLog->WARNING);
1843 $startTime = microtime(
true);
1844 $node_obj->delete();
1846 $endTime = microtime(
true);
1849 "\t".$node[
'type'].
"\t".round($endTime-$startTime,1).
"\t".$node[
'title']);
1875 $message = sprintf(
'%s::initGapsInTree(): Started...',
1877 $ilLog->write($message,$ilLog->WARNING);
1880 if ($this->mode[
"clean"] !==
true)
1886 $tree->renumber(ROOT_FOLDER_ID);
1904 $call_loc =
$error->backtrace[count(
$error->backtrace)-1];
1905 $num_args = count($call_loc[
"args"]);
1909 foreach ($call_loc[
"args"] as
$arg)
1911 $type = gettype($arg);
1916 $value = strlen($arg);
1920 $value = count($arg);
1924 $value = get_class($arg);
1928 $value = (
$arg) ?
"true" :
"false";
1936 $arg_list[] = array(
1938 "value" =>
"(".$value.
")"
1942 foreach ($arg_list as $arg)
1944 $arg_str .= implode(
"",$arg).
" ";
1948 $err_msg =
"<br/><b>".$error->getCode().
":</b> ".
$error->getMessage().
" in ".$call_loc[
"class"].$call_loc[
"type"].$call_loc[
"function"].
"()".
1949 "<br/>Called from: ".basename($call_loc[
"file"]).
" , line ".$call_loc[
"line"].
1950 "<br/>Passed parameters: [".$num_args.
"] ".$arg_str.
"<br/>";
1953 if (
$error->getUserInfo())
1955 printf(
"<br/>Parameter details:");
1957 var_dump($call_loc[
"args"]);
1961 if (
$error->getCode() == FATAL)
1974 foreach ($a_arr as $entry)
1976 $this->scan_log->write(implode(
"\t",$entry));
1987 $this->scan_log->write($a_msg);
1996 return is_file(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2004 @unlink(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2015 $scanfile =& file(CLIENT_DATA_DIR.
"/".$this->scan_log_file);
2028 $logs = array_keys($a_scan_log,$this->scan_log_separator.
"\n");
2030 if (count($logs) > 0)
2032 return array_slice($a_scan_log,array_pop($logs)+2);
2062 $q =
'SELECT child FROM tree GROUP BY child HAVING COUNT(*) > 1';
2063 $r = $this->db->query($q);
2064 $duplicateNodes = array();
2067 $duplicateNodes[] =
$row->child;
2071 $q =
"SELECT tree.*,ref.ref_id,ref.obj_id refobj_id,ref.deleted,dat.*,usr.login "
2073 .
"RIGHT JOIN object_reference ref ON tree.child = ref.ref_id "
2074 .
"RIGHT JOIN object_data dat ON ref.obj_id = dat.obj_id "
2075 .
"LEFT JOIN usr_data usr ON usr.usr_id = dat.owner "
2076 .
"ORDER BY tree, lft, type, dat.title";
2077 $r = $this->db->query($q);
2081 .
'<td>tree, child, parent, lft, rgt, depth</td>'
2082 .
'<td>ref_id, ref.obj_id, deleted</td>'
2083 .
'<td>obj_id, type, owner, title</td>'
2092 $repository_tree_count = 0;
2093 $trash_trees_count = 0;
2094 $other_trees_count = 0;
2095 $not_in_tree_count = 0;
2098 $previousNumber = 0;
2103 if (is_null(
$row->child))
2105 $not_in_tree_count++;
2106 switch (
$row->type) {
2119 if (is_null(
$row->ref_id)) {
2129 $isParentOkay =
false;
2132 $isDepthOkay =
false;
2146 $isParentOkay =
false;
2149 $isDepthOkay =
false;
2156 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2159 .(($isParentOkay) ?
'' :
'parent:<b>')
2161 .(($isParentOkay) ?
'' :
'</b>')
2163 .(($isLftOkay) ?
'' :
'lft:<b>')
2165 .(($isLftOkay) ?
'' :
'</b>')
2167 .(($isRgtOkay) ?
'' :
'rgt:<b>')
2169 .(($isRgtOkay) ?
'' :
'</b>')
2171 .(($isDepthOkay) ?
'' :
'depth:<b>')
2173 .(($isDepthOkay) ?
'' :
'</b>')
2174 .(($isRowOkay) ?
'' :
'</font>')
2176 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2177 .(($isRefRefOkay && $isChildOkay) ?
'' :
'ref.ref_id:<b>')
2179 .(($isRefRefOkay && $isChildOkay) ?
'' :
'</b>')
2181 .(($isRefObjOkay) ?
'' :
'ref.obj_id:<b>')
2183 .(($isRefObjOkay) ?
'' :
'</b>')
2184 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2185 .((
$row->deleted != null) ?
', '.$row->deleted :
'')
2187 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2193 .(($isRowOkay) ?
'' :
' <b>*ERROR*</b><font color=#ff0000>')
2203 for ($i = 1; $i <
$row->depth; $i++)
2209 if (count($stack) == 0 || $stack[0]->tree !=
$row->tree)
2212 $previousNumber =
$row->lft - 1;
2216 while (count($stack) > 0 && $stack[count($stack) - 1]->rgt < $row->lft)
2218 $popped = array_pop($stack);
2221 $gap = $popped->rgt - $previousNumber - 1;
2225 for ($i = 1; $i < $popped->depth; $i++)
2227 $poppedIndent .=
". ";
2231 .
'<td colspan=2><div align="right">'
2232 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes at end of </font>'
2235 .
'<font color=#00cc00>'
2237 .$popped->obj_id.
', '
2239 .$popped->login.
', '
2246 $previousNumber = $popped->rgt;
2255 $isChildOkay =
true;
2256 $isParentOkay =
true;
2259 $isDepthOkay =
true;
2262 if (count($stack) > 0)
2264 $parent = $stack[count($stack) - 1];
2265 if ($parent->depth + 1 !=
$row->depth)
2267 $isDepthOkay =
false;
2270 if ($parent->child !=
$row->parent)
2272 $isParentOkay =
false;
2275 if ($parent->lft >=
$row->lft)
2280 if ($parent->rgt <=
$row->rgt)
2294 if (in_array(
$row->child, $duplicateNodes))
2296 $isChildOkay =
false;
2301 $isRefRefOkay =
true;
2302 $isRefObjOkay =
true;
2303 if (
$row->ref_id == null)
2305 $isRefRefOkay =
false;
2308 if (
$row->obj_id == null)
2310 $isRefObjOkay =
false;
2321 $gap =
$row->lft - $previousNumber - 1;
2322 $previousNumber =
$row->lft;
2327 .
'<td colspan=2><div align="right">'
2328 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes between </font>'
2331 .
'<font color=#00cc00>siblings</font>'
2342 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2345 .(($isParentOkay) ?
'' :
'parent:<b>')
2347 .(($isParentOkay) ?
'' :
'</b>')
2349 .(($isLftOkay) ?
'' :
'lft:<b>')
2351 .(($isLftOkay) ?
'' :
'</b>')
2353 .(($isRgtOkay) ?
'' :
'rgt:<b>')
2355 .(($isRgtOkay) ?
'' :
'</b>')
2357 .(($isDepthOkay) ?
'' :
'depth:<b>')
2359 .(($isDepthOkay) ?
'' :
'</b>')
2360 .(($isRowOkay) ?
'' :
'</font>')
2362 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2363 .(($isRefRefOkay && $isChildOkay) ?
'' :
'ref.ref_id:<b>')
2365 .(($isRefRefOkay && $isChildOkay) ?
'' :
'</b>')
2367 .(($isRefObjOkay) ?
'' :
'ref.obj_id:<b>')
2369 .(($isRefObjOkay) ?
'' :
'</b>')
2370 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2371 .((
$row->tree < 0) ?
', '.$row->deleted :
'')
2373 .(($isRowOkay) ?
'' :
'<font color=#ff0000>')
2379 .(($isRowOkay) ?
'' :
' <b>*ERROR*</b><font color=#ff0000>')
2391 if (
$row->tree == 1)
2393 $repository_tree_count++;
2395 else if (
$row->tree < 0)
2397 $trash_trees_count++;
2401 $other_trees_count++;
2407 while (count($stack) > 0)
2409 $popped = array_pop($stack);
2412 $gap = $popped->rgt - $previousNumber - 1;
2416 for ($i = 1; $i < $popped->depth; $i++)
2418 $poppedIndent .=
". ";
2422 .
'<td colspan=2><div align="right">'
2423 .
'<font color=#00cc00>*gap* for '.($gap/2).
' nodes at end of </font>'
2426 .
'<font color=#00cc00>'
2428 .$popped->obj_id.
', '
2430 .$popped->login.
', '
2437 $previousNumber = $popped->rgt;
2444 if ($error_count > 0)
2446 $this->
writeScanLogLine(
'<font color=#ff0000>'.$error_count.
' errors found while dumping tree.</font>');
2452 $this->
writeScanLogLine(
"$repository_tree_count nodes in repository tree");
2458 return $error_count;
2465 if(!is_array($this->media_pool_ids))
2467 $this->media_pool_ids = array();
2468 $query =
"SELECT child FROM mep_tree ";
2470 while(
$row = $ilDB->fetchObject(
$res))
2472 $this->media_pool_ids[] =
$row->child;
2476 return in_array($a_obj_id,$this->media_pool_ids) ?
true :
false;
2495 return in_array($a_type,$this->object_types_exclude);