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(
75 $ref_res =
$ilDB->query($query);
77 $node[
'obj_id'] = (
int) $ref_row->obj_id;
80 $query =
'SELECT title, description, type FROM object_data ' .
82 $obj_res =
$ilDB->query($query);
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 ' .
181 $ilDB->manipulate($query);
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';
233 $res = $this->db->query($query);
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) {
284 $query =
'SELECT obj_id FROM object_reference ' .
287 $res = $this->db->query($query);
289 $query =
'SELECT type, title FROM object_data ' .
291 $ores = $this->db->query($query);
298 $ref_obj = $factory->getInstanceByRefId($a_ref_id,
false);
302 } elseif ($ref_obj instanceof
ilObject) {
303 $ref_obj->putInTree($a_parent_ref);
304 $ref_obj->setPermissions($a_parent_ref);
311 $query =
'DELETE FROM object_reference WHERE ref_id = ' . $this->db->quote(
315 $this->db->manipulate($query);
325 $query =
'SELECT ref_id FROM object_reference ' .
326 'LEFT JOIN tree ON ref_id = child ' .
327 'WHERE child IS NULL';
328 $res = $this->db->query($query);
332 $failures[] = (
int) $row->ref_id;
340 foreach ($missing as
$ref_id) {
342 $query =
'SELECT tree, child FROM tree ' .
344 $res = $this->db->query($query);
353 $query =
'SELECT child FROM tree ' .
357 $res = $this->db->query($query);
360 $query =
'SELECT tree, child FROM tree ' .
362 $resd = $this->db->query($query);
371 $ref_obj = $factory->getInstanceByRefId($a_ref_id,
false);
373 if (($ref_obj instanceof
ilObject) && $ref_obj->getType()) {
377 $query =
'DELETE from tree ' .
380 $this->db->manipulate($query);
389 $query =
'SELECT child FROM tree ' .
390 'LEFT JOIN object_reference ON child = ref_id ' .
391 'WHERE ref_id IS NULL';
393 $res = $this->db->query($query);
397 $failures[] = (
int) $row->child;
407 $folder->setTitle(
'__System check recovery: ' . $now->get(
IL_CAL_DATETIME));
409 $folder->createReference();
412 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)