3 declare(strict_types=1);
19 $this->db = $DIC->database();
20 $this->tree = $DIC->repositoryTree();
28 $ilDB = $DIC->database();
30 $query =
'SELECT child FROM tree first ' .
32 'SELECT child FROM tree second WHERE first.child = second.child ' .
33 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
34 'ORDER BY depth DESC';
38 return (
int) $row->child;
47 $ilDB = $DIC->database();
49 $ilDB->addPrimaryKey(
'tree', array(
'child'));
52 public static function getNodeInfo(
int $a_tree_id,
int $a_child): array
56 $ilDB = $DIC->database();
58 $query =
'SELECT * FROM tree WHERE child = ' .
$ilDB->quote(
66 $node[
'child'] = (
int) $row->child;
67 $node[
'tree'] = (
int) $row->tree;
68 $node[
'depth'] = (
int) $row->depth;
71 $query =
'SELECT obj_id FROM object_reference WHERE ref_id = ' .
$ilDB->quote(
77 $node[
'obj_id'] = (
int) $ref_row->obj_id;
80 $query =
'SELECT title, description, type FROM object_data ' .
84 $node[
'title'] = (string) $obj_row->title;
85 $node[
'description'] = (
string) $obj_row->description;
86 $node[
'type'] = (string) $obj_row->type;
93 public static function getChilds(
int $a_tree_id,
int $a_childs): array
97 $ilDB = $DIC->database();
99 $query =
'SELECT * FROM tree WHERE tree = ' .
$ilDB->quote(
107 $childs[] = (
int) $row->child;
116 $ilDB = $DIC->database();
118 $query =
'SELECT * FROM tree first ' .
120 'SELECT child FROM tree second WHERE first.child = second.child ' .
121 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
123 'ORDER BY depth DESC';
129 $node[
'tree'] = (
int) $row->tree;
130 $node[
'child'] = (
int) $row->child;
131 $node[
'depth'] = (
int) $row->depth;
143 $ilDB = $DIC->database();
145 return count(self::findDuplicates($a_child));
150 $dups = self::findDuplicates($a_duplicate_id);
151 foreach ($dups as $dup) {
152 if ($a_delete_trash && $dup[
'tree'] < 1) {
153 self::deleteDuplicate($dup[
'tree'], $dup[
'child']);
155 if (!$a_delete_trash && $dup[
'tree'] == 1) {
156 self::deleteDuplicate($dup[
'tree'], $dup[
'child']);
166 $ilDB = $DIC->database();
168 $query =
'SELECT child FROM tree ' .
174 self::deleteDuplicate($tree_id, (
int) $row->child);
177 if (self::hasDuplicate($dup_id)) {
178 $query =
'DELETE FROM tree ' .
199 if (count($failures)) {
206 return count($failures);
211 return $this->tree->validateParentRelations();
218 if (count($failures)) {
225 return count($failures);
230 $query =
'SELECT child, count(child) num FROM tree ' .
232 'HAVING count(child) > 1';
237 $failures[] = (
int) $row->child;
246 if (count($failures)) {
254 return count($failures);
261 if (count($failures)) {
269 return count($failures);
276 foreach ($failures as
$ref_id) {
285 $query =
'SELECT obj_id FROM object_reference ' .
290 $query =
'SELECT type, title FROM object_data ' .
292 $ores = $this->db->query(
$query);
299 $ref_obj =
$factory->getInstanceByRefId($a_ref_id,
false);
303 } elseif ($ref_obj instanceof
ilObject) {
304 $ref_obj->putInTree($a_parent_ref);
305 $ref_obj->setPermissions($a_parent_ref);
312 $query =
'DELETE FROM object_reference WHERE ref_id = ' . $this->db->quote(
316 $this->db->manipulate(
$query);
326 $query =
'SELECT ref_id FROM object_reference ' .
327 'LEFT JOIN tree ON ref_id = child ' .
328 'WHERE child IS NULL';
333 $failures[] = (
int) $row->ref_id;
341 foreach ($missing as
$ref_id) {
343 $query =
'SELECT tree, child FROM tree ' .
354 $query =
'SELECT child FROM tree ' .
361 $query =
'SELECT tree, child FROM tree ' .
363 $resd = $this->db->query(
$query);
372 $ref_obj =
$factory->getInstanceByRefId($a_ref_id,
false);
374 if (($ref_obj instanceof
ilObject) && $ref_obj->getType()) {
378 $query =
'DELETE from tree ' .
381 $this->db->manipulate(
$query);
390 $query =
'SELECT child FROM tree ' .
391 'LEFT JOIN object_reference ON child = ref_id ' .
392 'WHERE ref_id IS NULL';
398 $failures[] = (
int) $row->child;
408 $folder->setTitle(
'__System check recovery: ' . $now->get(
IL_CAL_DATETIME));
410 $folder->createReference();
413 return $folder->getRefId();
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilSCTask $task)
static deleteDuplicateFromTree(int $a_duplicate_id, bool $a_delete_trash)
readMissingTreeEntries()
Read missing tree entries for referenced objects Entry in tree but no entry in object reference...
static findDeepestDuplicate()
deleteMissingTreeEntry(int $a_tree_id, int $a_ref_id)
repairMissingTreeEntries()
static hasDuplicate(int $a_child)
static deleteDuplicate(int $tree_id, int $dup_id)
repairMissingObject(int $a_parent_ref, int $a_ref_id)
static findDuplicates(int $a_duplicate_id)
static getNodeInfo(int $a_tree_id, int $a_child)
Defines a system check task.
createRecoveryContainer()
static getChilds(int $a_tree_id, int $a_childs)