19declare(strict_types=1);
33 $this->db =
$DIC->database();
34 $this->tree =
$DIC->repositoryTree();
44 $query =
'SELECT child FROM tree first ' .
46 'SELECT child FROM tree second WHERE first.child = second.child ' .
47 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
48 'ORDER BY depth DESC';
52 return (
int) $row->child;
63 $ilDB->addPrimaryKey(
'tree', array(
'child'));
66 public static function getNodeInfo(
int $a_tree_id,
int $a_child): array
72 $query =
'SELECT * FROM tree WHERE child = ' .
$ilDB->quote(
80 $node[
'child'] = (
int) $row->child;
81 $node[
'tree'] = (
int) $row->tree;
82 $node[
'depth'] = (
int) $row->depth;
85 $query =
'SELECT obj_id FROM object_reference WHERE ref_id = ' .
$ilDB->quote(
89 $ref_res =
$ilDB->query($query);
91 $node[
'obj_id'] = (
int) $ref_row->obj_id;
94 $query =
'SELECT title, description, type FROM object_data ' .
96 $obj_res =
$ilDB->query($query);
98 $node[
'title'] = (string) $obj_row->title;
99 $node[
'description'] = (
string) $obj_row->description;
100 $node[
'type'] = (string) $obj_row->type;
107 public static function getChilds(
int $a_tree_id,
int $a_childs): array
113 $query =
'SELECT * FROM tree WHERE tree = ' .
$ilDB->quote(
121 $childs[] = (
int) $row->child;
132 $query =
'SELECT * FROM tree first ' .
134 'SELECT child FROM tree second WHERE first.child = second.child ' .
135 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
137 'ORDER BY depth DESC';
143 $node[
'tree'] = (
int) $row->tree;
144 $node[
'child'] = (
int) $row->child;
145 $node[
'depth'] = (
int) $row->depth;
159 return count(self::findDuplicates($a_child));
165 foreach ($dups as $dup) {
166 if ($a_delete_trash && $dup[
'tree'] < 1) {
169 if (!$a_delete_trash && $dup[
'tree'] == 1) {
182 $query =
'SELECT child FROM tree ' .
191 if (self::hasDuplicate($dup_id)) {
192 $query =
'DELETE FROM tree ' .
195 $ilDB->manipulate($query);
213 if (count($failures)) {
220 return count($failures);
225 return $this->tree->validateParentRelations();
232 if (count($failures)) {
239 return count($failures);
244 $query =
'SELECT child, count(child) num FROM tree ' .
246 'HAVING count(child) > 1';
247 $res = $this->db->query($query);
251 $failures[] = (
int) $row->child;
260 if (count($failures)) {
268 return count($failures);
275 if (count($failures)) {
283 return count($failures);
290 foreach ($failures as
$ref_id) {
298 $query =
'SELECT obj_id FROM object_reference ' .
301 $res = $this->db->query($query);
303 $query =
'SELECT type, title FROM object_data ' .
305 $ores = $this->db->query($query);
312 $ref_obj = $factory->getInstanceByRefId($a_ref_id,
false);
316 } elseif ($ref_obj instanceof
ilObject) {
317 $ref_obj->putInTree($a_parent_ref);
318 $ref_obj->setPermissions($a_parent_ref);
325 $query =
'DELETE FROM object_reference WHERE ref_id = ' . $this->db->quote(
329 $this->db->manipulate($query);
339 $query =
'SELECT ref_id FROM object_reference ' .
340 'LEFT JOIN tree ON ref_id = child ' .
341 'WHERE child IS NULL';
342 $res = $this->db->query($query);
346 $failures[] = (
int) $row->ref_id;
354 foreach ($missing as
$ref_id) {
356 $query =
'SELECT tree, child FROM tree ' .
358 $res = $this->db->query($query);
367 $query =
'SELECT child FROM tree ' .
371 $res = $this->db->query($query);
374 $query =
'SELECT tree, child FROM tree ' .
376 $resd = $this->db->query($query);
385 $ref_obj = $factory->getInstanceByRefId($a_ref_id,
false);
387 if (($ref_obj instanceof
ilObject) && $ref_obj->getType()) {
391 $query =
'DELETE from tree ' .
394 $this->db->manipulate($query);
403 $query =
'SELECT child FROM tree ' .
404 'LEFT JOIN object_reference ON child = ref_id ' .
405 'WHERE ref_id IS NULL';
407 $res = $this->db->query($query);
411 $failures[] = (
int) $row->child;
421 $folder->setTitle(
'__System check recovery: ' . $now->get(
IL_CAL_DATETIME));
423 $folder->createReference();
426 return $folder->getRefId();
@classDescription Date and time handling
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
Class ilObject Basic functions for all objects.
Defines a system check task.
Defines a system check task.
static findDeepestDuplicate()
static findDuplicates(int $a_duplicate_id)
static hasDuplicate(int $a_child)
static deleteDuplicateFromTree(int $a_duplicate_id, bool $a_delete_trash)
repairMissingObject(int $a_parent_ref, int $a_ref_id)
__construct(ilSCTask $task)
repairMissingTreeEntries()
createRecoveryContainer()
static getNodeInfo(int $a_tree_id, int $a_child)
static deleteDuplicate(int $tree_id, int $dup_id)
static getChilds(int $a_tree_id, int $a_childs)
deleteMissingTreeEntry(int $a_tree_id, int $a_ref_id)
readMissingTreeEntries()
Read missing tree entries for referenced objects Entry in tree but no entry in object reference.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...