32 $query =
'SELECT child FROM tree first ' .
34 'SELECT child FROM tree second WHERE first.child = second.child ' .
35 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
36 'ORDER BY depth DESC';
49 #$GLOBALS['DIC']['ilDB']->dropPrimaryKey('tree'); 50 $GLOBALS[
'DIC'][
'ilDB']->addPrimaryKey(
'tree', array(
'child'));
59 $query =
'SELECT * FROM tree WHERE child = ' .
$ilDB->quote($a_child,
'integer') .
' AND tree = ' .
$ilDB->quote($a_tree_id,
'integer');
64 $node[
'child'] =
$row->child;
65 $node[
'tree'] =
$row->tree;
66 $node[
'depth'] =
$row->depth;
69 $query =
'SELECT obj_id FROM object_reference WHERE ref_id = ' .
$ilDB->quote($a_child,
'integer');
72 $node[
'obj_id'] = $ref_row->obj_id;
75 $query =
'SELECT title, description, type FROM object_data ' .
76 'WHERE obj_id = ' .
$ilDB->quote($ref_row->obj_id);
79 $node[
'title'] = $obj_row->title;
80 $node[
'description'] = $obj_row->description;
81 $node[
'type'] = $obj_row->type;
88 public static function getChilds($a_tree_id, $a_childs)
94 $query =
'SELECT * FROM tree WHERE tree = ' .
$ilDB->quote($a_tree_id,
'integer') .
' ' .
'AND child = ' .
$ilDB->quote($a_childs,
'integer');
99 $childs[] =
$row->child;
113 $ilDB = $DIC[
'ilDB'];
115 $query =
'SELECT * FROM tree first ' .
117 'SELECT child FROM tree second WHERE first.child = second.child ' .
118 'GROUP BY child HAVING COUNT(child) > 1 ) ' .
119 'AND child = ' .
$ilDB->quote($a_duplicate_id,
'integer') .
' ' .
120 'ORDER BY depth DESC';
128 $node[
'tree'] =
$row->tree;
129 $node[
'child'] =
$row->child;
130 $node[
'depth'] =
$row->depth;
142 $ilDB = $DIC[
'ilDB'];
144 return count(self::findDuplicates($a_child));
149 $dups = self::findDuplicates($a_duplicate_id);
150 foreach ($dups as $dup) {
151 if ($a_delete_trash
and $dup[
'tree'] < 1) {
152 self::deleteDuplicate($dup[
'tree'], $dup[
'child']);
154 if (!$a_delete_trash
and $dup[
'tree'] == 1) {
155 self::deleteDuplicate($dup[
'tree'], $dup[
'child']);
165 $ilDB = $DIC[
'ilDB'];
167 $query =
'SELECT child FROM tree ' .
168 'WHERE parent = ' .
$ilDB->quote($dup_id,
'integer') .
' ' .
169 'AND tree = ' .
$ilDB->quote($tree_id,
'integer');
173 self::deleteDuplicate($tree_id,
$row->child);
176 if (self::hasDuplicate($dup_id)) {
177 $query =
'DELETE FROM tree ' .
178 'WHERE child = ' .
$ilDB->quote($dup_id,
'integer') .
' ' .
179 'AND tree = ' .
$ilDB->quote($tree_id,
'integer');
212 if (count($failures)) {
219 return count($failures);
225 return $GLOBALS[
'DIC'][
'tree']->validateParentRelations();
228 $ilDB = $DIC[
'ilDB'];
230 $query =
'select child from tree child where not exists ' .
232 'select child from tree parent where child.parent = parent.child and (parent.lft < child.lft) and (parent.rgt > child.rgt) ' .
234 'and tree = 1 and child <> 1';
239 $failures[] =
$row->child;
253 if (count($failures)) {
260 return count($failures);
268 $query =
'SELECT child, count(child) num FROM tree ' .
270 'HAVING count(child) > 1';
277 $failures[] =
$row->child;
286 $ilDB = $DIC[
'ilDB'];
290 if (count($failures)) {
298 return count($failures);
309 $ilDB = $DIC[
'ilDB'];
313 if (count($failures)) {
321 return count($failures);
331 foreach ($failures as $ref_id) {
344 $ilDB = $DIC[
'ilDB'];
347 $query =
'SELECT obj_id FROM object_reference ' .
348 'WHERE ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
352 $query =
'SELECT type, title FROM object_data ' .
353 'WHERE obj_id = ' .
$ilDB->quote(
$row->obj_id,
'integer');
358 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Moving to recovery folder: ' . $orow->type .
': ' . $orow->title);
361 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
363 $ref_obj =
$factory->getInstanceByRefId($a_ref_id,
false);
367 } elseif ($ref_obj instanceof
ilObject) {
368 $ref_obj->putInTree($a_parent_ref);
369 $ref_obj->setPermissions($a_parent_ref);
370 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Moving finished');
376 $query =
'DELETE FROM object_reference WHERE ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
378 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Delete reference for "object" without tree and object_data entry: ref_id= ' . $a_ref_id);
393 $ilDB = $DIC[
'ilDB'];
395 $query =
'SELECT ref_id FROM object_reference ' .
396 'LEFT JOIN tree ON ref_id = child ' .
397 'WHERE child IS NULL';
402 $failures[] =
$row->ref_id;
415 $ilDB = $DIC[
'ilDB'];
418 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': ' . print_r($missing,
true));
420 foreach ($missing as $ref_id) {
422 $query =
'SELECT tree, child FROM tree ' .
423 'WHERE child = ' .
$ilDB->quote($ref_id);
426 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': ' .
$row->tree .
': ' . $ref_id);
440 $ilDB = $DIC[
'ilDB'];
442 $query =
'SELECT child FROM tree ' .
443 'WHERE parent = ' .
$ilDB->quote($a_ref_id,
'integer') .
' ' .
444 'AND tree = ' .
$ilDB->quote($a_tree_id,
'integer');
449 $query =
'SELECT tree, child FROM tree ' .
450 'WHERE child = ' .
$ilDB->quote(
$row->child);
458 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
460 $ref_obj =
$factory->getInstanceByRefId($a_ref_id,
false);
462 if (($ref_obj instanceof
ilObject)
and $ref_obj->getType()) {
466 $query =
'DELETE from tree ' .
467 'WHERE tree = ' .
$ilDB->quote($a_tree_id) .
' ' .
468 'AND child = ' .
$ilDB->quote($a_ref_id);
483 $ilDB = $DIC[
'ilDB'];
485 $query =
'SELECT child FROM tree ' .
486 'LEFT JOIN object_reference ON child = ref_id ' .
487 'WHERE ref_id IS NULL';
493 $failures[] =
$row->child;
506 include_once
'./Modules/Folder/classes/class.ilObjFolder.php';
508 $folder->setTitle(
'__System check recovery: ' . $now->get(
IL_CAL_DATETIME));
510 $folder->createReference();
511 $folder->putInTree(RECOVERY_FOLDER_ID);
513 return $folder->getRefId();
Defines a system check task.
findMissing()
Find missing objects.
static findDuplicates($a_duplicate_id)
find duplicates type $ilDB
__construct(ilSCTask $task)
readMissingTreeEntries()
Read missing tree entries for referenced objects Entry in tree but no entry in object reference type...
static deleteDuplicate($tree_id, $dup_id)
static findDeepestDuplicate()
find duplicates type $ilDB
repairMissingTreeEntries()
repair missing tree entries type $ilDB
static getChilds($a_tree_id, $a_childs)
repairMissingObject($a_parent_ref, $a_ref_id)
Repair missing object.
static hasDuplicate($a_child)
foreach($_POST as $key=> $value) $res
static deleteDuplicateFromTree($a_duplicate_id, $a_delete_trash)
deleteMissingTreeEntry($a_tree_id, $a_ref_id)
Delete missing tree entries from tree table.
repairMissing()
Repair missing objects.
Defines a system check task.
createRecoveryContainer()
Create a reccovery folder.
readMissing()
Read missing objects in tree Entry in oject_reference but no entry in tree type $ilDB.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
checkDuplicates()
Check for duplicates.
validateStructure()
validate tree structure base on parent relation
static getNodeInfo($a_tree_id, $a_child)