ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDBUpdate4963.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9  private static $table_tree;
10  private static $tree_id;
11  private static $gap;
12 
21  public static function renumberBookmarkTree()
22  {
23  global $ilDB;
24 
25  self::$table_tree = "bookmark_tree";
26  self::$gap = 0;
27 
28  $query = 'SELECT tree FROM ' . self::$table_tree .
29  ' GROUP BY tree';
30  $res = $ilDB->query($query);
31 
32  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
33  self::$tree_id = $row->tree;
34  self::__renumber();
35  }
36  }
37 
38  // PRIVATE
48  private static function __renumber($node_id = 1, $i = 1)
49  {
50  global $ilDB;
51 
52  $query = 'UPDATE ' . self::$table_tree . ' SET lft = %s WHERE child = %s AND tree = %s';
53  $res = $ilDB->manipulateF($query, array('integer','integer','integer'), array(
54  $i,
55  $node_id,
56  self::$tree_id));
57 
58  // to much dependencies
59  //$childs = $this->getChilds($node_id);
60  $childs = self::getChildIds($node_id);
61 
62  foreach ($childs as $child) {
63  $i = self::__renumber($child, $i+1);
64  }
65  $i++;
66 
67  // Insert a gap at the end of node, if the node has children
68  if (count($childs) > 0) {
69  $i += self::$gap * 2;
70  }
71 
72 
73  $query = 'UPDATE ' . self::$table_tree . ' SET rgt = %s WHERE child = %s AND tree = %s';
74  $res = $ilDB->manipulateF($query, array('integer','integer', 'integer'), array(
75  $i,
76  $node_id,
77  self::$tree_id));
78  return $i;
79  }
80 
87  private static function getChildIds($a_node)
88  {
89  global $ilDB;
90 
91  $query = 'SELECT * FROM ' . self::$table_tree .
92  ' WHERE parent = ' . $ilDB->quote($a_node, 'integer') . ' ' .
93  'AND tree = ' . $ilDB->quote(self::$tree_id, 'integer');
94  $res = $ilDB->query($query);
95 
96  $childs = array();
97  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
98  $childs[] = $row->child;
99  }
100  return $childs;
101  }
102 }
static renumberBookmarkTree()
Wrapper for renumber.
static getChildIds($a_node)
Get node child ids type $ilDB.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
Class ilDBUpdate4950.
static __renumber($node_id=1, $i=1)
This method is private.