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';
48 #$GLOBALS['ilDB']->dropPrimaryKey('tree'); 56 $query =
'SELECT * FROM tree WHERE child = '.$ilDB->quote($a_child,
'integer').
' AND tree = '. $ilDB->quote($a_tree_id,
'integer');
62 $node[
'child'] =
$row->child;
63 $node[
'tree'] =
$row->tree;
64 $node[
'depth'] =
$row->depth;
67 $query =
'SELECT obj_id FROM object_reference WHERE ref_id = '.$ilDB->quote($a_child,
'integer');
68 $ref_res = $ilDB->query(
$query);
71 $node[
'obj_id'] = $ref_row->obj_id;
74 $query =
'SELECT title, description, type FROM object_data '.
75 'WHERE obj_id = '.$ilDB->quote($ref_row->obj_id);
76 $obj_res = $ilDB->query(
$query);
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)
92 $query =
'SELECT * FROM tree WHERE tree = '.$ilDB->quote($a_tree_id,
'integer').
' '.
'AND child = '.$ilDB->quote($a_childs,
'integer');
98 $childs[] =
$row->child;
112 $query =
'SELECT * FROM tree first '.
114 'SELECT child FROM tree second WHERE first.child = second.child '.
115 'GROUP BY child HAVING COUNT(child) > 1 ) '.
116 'AND child = '.$ilDB->quote($a_duplicate_id,
'integer').
' '.
117 'ORDER BY depth DESC';
126 $node[
'tree'] =
$row->tree;
127 $node[
'child'] =
$row->child;
128 $node[
'depth'] =
$row->depth;
140 return count(self::findDuplicates($a_child));
145 $dups = self::findDuplicates($a_duplicate_id);
146 foreach($dups as $dup)
148 if($a_delete_trash
and $dup[
'tree'] < 1)
150 self::deleteDuplicate($dup[
'tree'],$dup[
'child']);
152 if(!$a_delete_trash
and $dup[
'tree'] == 1)
154 self::deleteDuplicate($dup[
'tree'],$dup[
'child']);
164 $query =
'SELECT child FROM tree '.
165 'WHERE parent = '.$ilDB->quote($dup_id,
'integer').
' '.
166 'AND tree = '.$ilDB->quote($tree_id,
'integer');
171 self::deleteDuplicate($tree_id,
$row->child);
174 if(self::hasDuplicate($dup_id))
176 $query =
'DELETE FROM tree '.
177 'WHERE child = '.$ilDB->quote($dup_id,
'integer').
' '.
178 'AND tree = '.$ilDB->quote($tree_id,
'integer');
179 $ilDB->manipulate(
$query);
221 return count($failures);
227 return $GLOBALS[
'tree']->validateParentRelations();
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';
240 $failures[] =
$row->child;
264 return count($failures);
272 $query =
'SELECT child, count(child) num FROM tree '.
274 'HAVING count(child) > 1';
282 $failures[] =
$row->child;
304 return count($failures);
328 return count($failures);
355 $query =
'SELECT obj_id FROM object_reference '.
356 'WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer');
361 $query =
'SELECT type, title FROM object_data '.
362 'WHERE obj_id = '.$ilDB->quote(
$row->obj_id,
'integer');
363 $ores = $ilDB->query(
$query);
368 $GLOBALS[
'ilLog']->write(__METHOD__.
': Moving to recovery folder: '.$orow->type.
': '.$orow->title);
371 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
373 $ref_obj = $factory->getInstanceByRefId($a_ref_id,FALSE);
379 elseif($ref_obj instanceof
ilObject)
381 $ref_obj->putInTree($a_parent_ref);
382 $ref_obj->setPermissions($a_parent_ref);
383 $GLOBALS[
'ilLog']->write(__METHOD__.
': Moving finished');
390 $query =
'DELETE FROM object_reference WHERE ref_id = '.$ilDB->quote($a_ref_id,
'integer');
391 $ilDB->manipulate(
$query);
392 $GLOBALS[
'ilLog']->write(__METHOD__.
': Delete reference for "object" without tree and object_data entry: ref_id= '.$a_ref_id );
408 $query =
'SELECT ref_id FROM object_reference '.
409 'LEFT JOIN tree ON ref_id = child '.
410 'WHERE child IS NULL';
416 $failures[] =
$row->ref_id;
430 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.print_r($missing,TRUE));
435 $query =
'SELECT tree, child FROM tree '.
436 'WHERE child = '.$ilDB->quote($ref_id);
440 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.
$row->tree.
': '.$ref_id);
454 $query =
'SELECT child FROM tree '.
455 'WHERE parent = '.$ilDB->quote($a_ref_id,
'integer').
' '.
456 'AND tree = '.$ilDB->quote($a_tree_id,
'integer');
462 $query =
'SELECT tree, child FROM tree '.
463 'WHERE child = '.$ilDB->quote(
$row->child);
464 $resd = $ilDB->query(
$query);
472 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
474 $ref_obj = $factory->getInstanceByRefId($a_ref_id,FALSE);
476 if(($ref_obj instanceof
ilObject)
and $ref_obj->getType())
481 $query =
'DELETE from tree '.
482 'WHERE tree = '.$ilDB->quote($a_tree_id).
' '.
483 'AND child = '.$ilDB->quote($a_ref_id);
484 $ilDB->manipulate(
$query);
498 $query =
'SELECT child FROM tree '.
499 'LEFT JOIN object_reference ON child = ref_id '.
500 'WHERE ref_id IS NULL';
507 $failures[] =
$row->child;
520 include_once
'./Modules/Folder/classes/class.ilObjFolder.php';
522 $folder->setTitle(
'__System check recovery: '.$now->get(
IL_CAL_DATETIME));
524 $folder->createReference();
525 $folder->putInTree(RECOVERY_FOLDER_ID);
527 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
Class ilObject Basic functions for all objects.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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)
static deleteDuplicateFromTree($a_duplicate_id, $a_delete_trash)
deleteMissingTreeEntry($a_tree_id, $a_ref_id)
Delete missing tree entries from tree table.
Create styles array
The data for the language used.
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.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
checkDuplicates()
Check for duplicates.
validateStructure()
validate tree structure base on parent relation
static getNodeInfo($a_tree_id, $a_child)