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');
49 $GLOBALS[
'ilDB']->addPrimaryKey(
'tree', array(
'child'));
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');
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);
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));
146 foreach($dups as $dup)
148 if($a_delete_trash and $dup[
'tree'] < 1)
152 if(!$a_delete_trash and $dup[
'tree'] == 1)
164 $query =
'SELECT child FROM tree '.
165 'WHERE parent = '.$ilDB->quote($dup_id,
'integer').
' '.
166 'AND tree = '.$ilDB->quote($tree_id,
'integer');
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');
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');
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');
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);
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);
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);
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();
const DB_FETCHMODE_OBJECT
@classDescription Date and time handling
Class ilObject Basic functions for all objects.
Defines a system check task.
Defines a system check task.
static findDeepestDuplicate()
find duplicates @global type $ilDB
static findDuplicates($a_duplicate_id)
find duplicates @global type $ilDB
validateStructure()
validate tree structure base on parent relation
deleteMissingTreeEntry($a_tree_id, $a_ref_id)
Delete missing tree entries from tree table.
static deleteDuplicateFromTree($a_duplicate_id, $a_delete_trash)
findMissing()
Find missing objects.
__construct(ilSCTask $task)
repairMissingTreeEntries()
repair missing tree entries @global type $ilDB
checkDuplicates()
Check for duplicates.
static hasDuplicate($a_child)
static getNodeInfo($a_tree_id, $a_child)
readMissing()
Read missing objects in tree Entry in oject_reference but no entry in tree @global type $ilDB.
createRecoveryContainer()
Create a reccovery folder.
repairMissing()
Repair missing objects.
static getChilds($a_tree_id, $a_childs)
static deleteDuplicate($tree_id, $dup_id)
readMissingTreeEntries()
Read missing tree entries for referenced objects Entry in tree but no entry in object reference @glob...
repairMissingObject($a_parent_ref, $a_ref_id)
Repair missing object.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.