? sites/default/modules
? sites/default/settings.php
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.305
diff -r1.305 menu.inc
255d254
<   $placeholders = array();
282d280
<     $placeholders[] = "'%s'";
285c283
<   return array($ancestors, $placeholders);
---
>   return $ancestors;
365,367c363,370
<     list($ancestors, $placeholders) = menu_get_ancestors($parts);
< 
<     if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN (' . implode (',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1))) {
---
>     $ancestors = menu_get_ancestors($parts);
>     $router_item = db_select('menu_router')
>       ->fields('menu_router')
>       ->condition('path', $ancestors, 'IN')
>       ->orderBy('fit', 'DESC')
>       ->range(0, 1)
>       ->execute()->fetchAssoc();
>     if ($router_item) {
849a853,873
>       $query = db_select('menu_links', 'ml');
>       $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
>       $query->fields('ml');
>       $query->fields('m', array(
>         'load_functions',
>         'to_arg_functions',
>         'access_callback',
>         'access_arguments',
>         'page_callback',
>         'page_arguments',
>         'title',
>         'title_callback',
>         'title_arguments',
>         'type',
>         'description',
>       ));
>       for ($i = 1; $i <= 9; $i++) {
>         $query->orderBy('p' . $i, 'ASC');
>       }
>       $query->condition('ml.menu_name', $menu_name);
> 
858,859c882
<         $placeholders = implode(', ', array_fill(0, count($args), '%d'));
<         $where = ' AND ml.plid IN (' . $placeholders . ')';
---
>         $query->condition('ml.plid', $args, 'IN');
865d887
<         $where = '';
869d890
<       array_unshift($args, $menu_name);
873,877c894
<       $data['tree'] = menu_tree_data(db_query("
<         SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
<         FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
<         WHERE ml.menu_name = '%s'" . $where . "
<         ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
---
>       $data['tree'] = menu_tree_data($query->execute(), $parents);
935,936c952
<           $args = array($menu_name, $item['href']);
<           $placeholders = "'%s'";
---
>           $args[] = $item['href'];
939d954
<             $placeholders .= ", '%s'";
941c956,969
<           $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (" . $placeholders . ")", $args));
---
>           $parents = db_select('menu_links')
>             ->fields('menu_links', array(
>               'p1',
>               'p2',
>               'p3',
>               'p4',
>               'p5',
>               'p6',
>               'p7',
>               'p8',
>             ))
>             ->condition('menu_name', $menu_name)
>             ->condition('link_path', $args, 'IN')
>             ->execute()->fetchAssoc();
946c974,987
<             $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));
---
>             $parents = db_select('menu_links')
>               ->fields('menu_links', array(
>                 'p1',
>                 'p2',
>                 'p3',
>                 'p4',
>                 'p5',
>                 'p6',
>                 'p7',
>                 'p8',
>               ))
>               ->condition('menu_name', $menu_name)
>               ->condition('link_path', $item['tab_root'])
>               ->execute()->fetchAssoc();
953d993
<           $placeholders = implode(', ', array_fill(0, count($args), '%d'));
960c1000,1007
<               $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (" . $placeholders . ') AND mlid NOT IN (' . $placeholders . ')', array_merge(array($menu_name), $args, $args));
---
>               $result = db_select('menu_links')
>                 ->fields('menu_links', array('mlid'))
>                 ->condition('menu_name', $menu_name)
>                 ->condition('expanded', 1)
>                 ->condition('has_children', 1)
>                 ->condition('plid', $args, 'IN')
>                 ->condition('mlid', $args, 'NOT IN')
>                 ->execute();
961a1009
>               // @todo: Revamp with DBTNG syntax.
966d1013
<               $placeholders = implode(', ', array_fill(0, count($args), '%d'));
969d1015
<           array_unshift($args, $menu_name);
973,974c1019
<           $args = array($menu_name, '0');
<           $placeholders = '%d';
---
>           $args = array(0);
980,984c1025,1046
<         $data['tree'] = menu_tree_data(db_query("
<           SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
<           FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
<           WHERE ml.menu_name = '%s' AND ml.plid IN (" . $placeholders . ")
<           ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
---
>         $query = db_select('menu_links', 'ml');
>         $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
>         $query->fields('ml');
>         $query->fields('m', array(
>           'load_functions',
>           'to_arg_functions',
>           'access_callback',
>           'access_arguments',
>           'page_callback',
>           'page_arguments',
>           'title',
>           'title_callback',
>           'title_arguments',
>           'type',
>           'description',
>         ));
>         for ($i = 1; $i <= 9; $i++) {
>           $query->orderBy('p' . $i, 'ASC');
>         }
>         $query->condition('ml.menu_name', $menu_name);
>         $query->condition('ml.plid', $args, 'IN');
>         $data['tree'] = menu_tree_data($query->execute(), $parents);
1038a1101
>     // @todo: Revamp with DBTNG syntax.
1039a1103
>     // @todo: Revamp with DBTNG syntax.
1101a1166
>   // @todo: Revamp with DBTNG syntax.
1246,1250c1311,1315
<     $names = array();
<     $result = db_query("SELECT DISTINCT(menu_name) FROM {menu_links} ORDER BY menu_name");
<     while ($name = db_fetch_array($result)) {
<       $names[] = $name['menu_name'];
<     }
---
>     $names = db_select('menu_links')
>       ->distinct()
>       ->fields('menu_links', 'menu_name')
>       ->orderBy('menu_name')
>       ->execute()->fetchAll();
1357c1422,1427
<     $result = db_query("SELECT * FROM {menu_router} WHERE tab_root = '%s' ORDER BY weight, title", $router_item['tab_root']);
---
>     $result = db_select('menu_router')
>       ->fields('menu_router')
>       ->condition('tab_root', $router_item['tab_root'])
>       ->orderBy('weight')
>       ->orderBy('title')
>       ->execute();
1362a1433
>     // @todo: Revamp with DBTNG syntax.
1663,1665c1734,1743
<   if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) {
<     _menu_link_translate($item);
<     return $item;
---
>   if (is_numeric($mlid)) {
>     $query = db_select('menu_links', 'ml');
>     $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
>     $query->fields('ml');
>     $query->fields('m');
>     $query->condition('ml.mlid', $mlid);
>     if ($item = $query->execute()->fetchAssoc()) {
>       _menu_link_translate($item);
>       return $item;
>     }
1788c1866,1877
<       $existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized, has_children, updated FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system'));
---
>       $existing_item = db_select('menu_links')
>         ->fields('menu_links', array(
>           'mlid',
>           'menu_name',
>           'plid',
>           'customized',
>           'has_children',
>           'updated',
>         ))
>         ->condition('link_path', $item['link_path'])
>         ->condition('module', 'system')
>         ->execute()->fetchAssoc();
1804d1892
<   $placeholders = db_placeholders($menu, 'varchar');
1807,1808c1895,1911
<   $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path, ml.updated FROM {menu_links} ml WHERE ml.updated = 1 OR (router_path NOT IN ($placeholders) AND external = 0 AND customized = 1)", $paths);
<   while ($item = db_fetch_array($result)) {
---
>   $result = db_select('menu_links')
>     ->fields('menu_links', array(
>       'link_path',
>       'mlid',
>       'router_path',
>       'updated',
>     ))
>     ->condition(db_or()
>       ->condition('updated', 1)
>       ->condition(db_and()
>         ->condition('router_path', $paths, 'NOT IN')
>         ->condition('external', 0)
>         ->condition('customized', 1)
>       )
>     )
>     ->execute();
>   foreach ($result as $item) {
1814c1917,1923
<       db_query("UPDATE {menu_links} SET router_path = '%s', updated = %d WHERE mlid = %d", $router_path, $updated, $item['mlid']);
---
>       db_update('menu_links')
>         ->fields(array(
>           'router_path' => $router_path,
>           'updated' => $updated,
>         ))
>         ->condition('mlid', $item['mlid'])
>         ->execute();
1818c1927,1934
<   $result = db_query("SELECT * FROM {menu_links} WHERE router_path NOT IN ($placeholders) AND external = 0 AND updated = 0 AND customized = 0 ORDER BY depth DESC", $paths);
---
>   $result = db_select('menu_links')
>     ->fields('menu_links')
>     ->condition('router_path', $paths, 'NOT IN')
>     ->condition('external', 0)
>     ->condition('updated', 0)
>     ->condition('customized', 0)
>     ->orderBy('depth', 'DESC')
>     ->execute();
1821c1937
<   while ($item = db_fetch_array($result)) {
---
>    foreach ($result as $item) {
1836c1952
<     _menu_delete_item(db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $mlid)));
---
>     _menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc());
1839,1840c1955,1956
<     $result = db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $path);
<     while ($link = db_fetch_array($result)) {
---
>     $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path));
>     foreach ($result as $link) {
1858c1974,1975
<       $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']);
---
>       $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = :plid", array(':plid' => $item['mlid']));
>       // @todo: Revamp with DBTNG syntax.
1865c1982
<     db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']);
---
>     db_delete('menu_links')->condition('mlid', $item['mlid'])->execute();
1914c2031
<     if ($existing_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid']))) {
---
>     if ($existing_item = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $item['mlid']))->fetchAssoc()) {
1921c2038
<       $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['plid']));
---
>       $parent = db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $item['plid']))->fetchAssoc();
1929,1931c2046
<     // Find the parent - it must be unique.
<     $parent_path = $item['link_path'];
<     $where = "WHERE link_path = '%s'";
---
>     $query = db_select('menu_links');
1935,1936c2050
<       $where .= " AND module = '%s'";
<       $arg2 = 'system';
---
>       $query->condition('module', 'system');
1940,1941c2054
<       $where .= " AND menu_name = '%s'";
<       $arg2 = $item['menu_name'];
---
>       $query->condition('menu_name', $item['menu_name']);
1942a2056,2057
>     // Find the parent - it must be unique.
>     $parent_path = $item['link_path'];
1946c2061,2062
<       $result = db_query("SELECT COUNT(*) FROM {menu_links} " . $where, $parent_path, $arg2);
---
>       $query->condition('link_path', $parent_path);
>       $query_cnt = $query;
1948,1949c2064,2065
<       if (db_result($result) == 1) {
<         $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} " . $where, $parent_path, $arg2));
---
>       if ($query_cnt->countQuery()->execute()->fetchField() == 1) {
>         $parent = $query->fields('menu_links')->execute()->fetchAssoc();
1967,1982c2083,2099
<     db_query("INSERT INTO {menu_links} (
<        menu_name, plid, link_path,
<       hidden, external, has_children,
<       expanded, weight,
<       module, link_title, options,
<       customized, updated) VALUES (
<       '%s', %d, '%s',
<       %d, %d, %d,
<       %d, %d,
<       '%s', '%s', '%s', %d, %d)",
<       $item['menu_name'], $item['plid'], $item['link_path'],
<       $item['hidden'], $item['external'], $item['has_children'],
<       $item['expanded'], $item['weight'],
<       $item['module'],  $item['link_title'], serialize($item['options']),
<       $item['customized'], $item['updated']);
<     $item['mlid'] = db_last_insert_id('menu_links', 'mlid');
---
>     $item['mlid'] = db_insert('menu_links')
>       ->fields(array(
>         'menu_name' => $item['menu_name'],
>         'plid' => $item['plid'],
>         'link_path' => $item['link_path'],
>         'hidden' => $item['hidden'],
>         'external' => $item['external'],
>         'has_children' => $item['has_children'],
>         'expanded' => $item['expanded'],
>         'weight' => $item['weight'],
>         'module' => $item['module'],
>         'link_title' => $item['link_title'],
>         'options' => serialize($item['options']),
>         'customized' => $item['customized'],
>         'updated' => $item['updated'],
>       ))
>       ->execute();
2027,2036c2144,2171
<     db_query("UPDATE {menu_links} SET menu_name = '%s', plid = %d, link_path = '%s',
<       router_path = '%s', hidden = %d, external = %d, has_children = %d,
<       expanded = %d, weight = %d, depth = %d,
<       p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d, p7 = %d, p8 = %d, p9 = %d,
<       module = '%s', link_title = '%s', options = '%s', customized = %d WHERE mlid = %d",
<       $item['menu_name'], $item['plid'], $item['link_path'],
<       $item['router_path'], $item['hidden'], $item['external'], $item['has_children'],
<       $item['expanded'], $item['weight'],  $item['depth'],
<       $item['p1'], $item['p2'], $item['p3'], $item['p4'], $item['p5'], $item['p6'], $item['p7'], $item['p8'], $item['p9'],
<       $item['module'],  $item['link_title'], serialize($item['options']), $item['customized'], $item['mlid']);
---
>     db_update('menu_links')
>       ->fields(array(
>         'menu_name' => $item['menu_name'],
>         'plid' => $item['plid'],
>         'link_path' => $item['link_path'],
>         'router_path' => $item['router_path'],
>         'hidden' => $item['hidden'],
>         'external' => $item['external'],
>         'has_children' => $item['has_children'],
>         'expanded' => $item['expanded'],
>         'weight' => $item['weight'],
>         'depth' => $item['depth'],
>         'p1' => $item['p1'],
>         'p2' => $item['p2'],
>         'p3' => $item['p3'],
>         'p4' => $item['p4'],
>         'p5' => $item['p5'],
>         'p6' => $item['p6'],
>         'p7' => $item['p7'],
>         'p8' => $item['p8'],
>         'p9' => $item['p9'],
>         'module' => $item['module'],
>         'link_title' => $item['link_title'],
>         'options' => serialize($item['options']),
>         'customized' => $item['customized'],
>       ))
>       ->condition('mlid', $item['mlid'])
>       ->execute();
2076a2212
>   // @todo: Revamp with DBTNG syntax.
2098c2234
<     list($ancestors) = menu_get_ancestors($parts);
---
>     $ancestors = menu_get_ancestors($parts);
2135,2137c2271,2283
<       db_query("UPDATE {menu_links} SET link_title = '%s' WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_title, $link_path, $module);
<       $result = db_query("SELECT menu_name FROM {menu_links} WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_path, $module);
<       while ($item = db_fetch_array($result)) {
---
>       db_update('menu_links')
>         ->fields(array('link_title' => $link_title))
>         ->condition('link_path', $link_path)
>         ->condition('customized', 0)
>         ->condition('module', $module)
>         ->execute();
>       $result = db_select('menu_links')
>         ->fields('menu_links', array('menu_name'))
>         ->condition('link_path', $link_path)
>         ->condition('customized', 0)
>         ->condition('module', $module)
>         ->execute();
>       foreach ($result as $item) {
2159a2306,2311
>   $query = db_select('menu_links');
>   $query->addField('menu_links', 'depth');
>   $query->condition('menu_name', $item['menu_name']);
>   $query->orderBy('depth', 'DESC');
>   $query->range(0, 1);
> 
2161,2162d2312
<   $match = '';
<   $args[] = $item['menu_name'];
2165,2166c2315
<     $match .= " AND $p = %d";
<     $args[] = $item[$p];
---
>     $query->condition($p, $item[$p]);
2170c2319
<   $max_depth = db_result(db_query_range("SELECT depth FROM {menu_links} WHERE menu_name = '%s'" . $match . " ORDER BY depth DESC", $args, 0, 1));
---
>   $max_depth = $query->execute()->fetchField();
2181a2331
>   $query = db_update('menu_links');
2183,2184c2333
<   $args[] = $item['menu_name'];
<   $set[] = "menu_name = '%s'";
---
>   $query->fields(array('menu_name' => $item['menu_name']));
2186,2190c2335,2337
<   $i = 1;
<   while ($i <= $item['depth']) {
<     $p = 'p' . $i++;
<     $set[] = "$p = %d";
<     $args[] = $item[$p];
---
>   $p = 'p1';
>   for ($i = 1; $i <= $item['depth']; $p = 'p' . ++$i) {
>     $query->fields(array($p => $item[$p]));
2194c2341
<     $set[] = 'p' . $i++ . ' = p' . $j++;
---
>     $query->expression('p' . $i++, 'p' . $j++);
2197c2344
<     $set[] = 'p' . $i++ . ' = 0';
---
>     $query->fields(array('p' . $i++ => 0));
2202,2203c2349
<     $args[] = -$shift;
<     $set[] = 'depth = depth - %d';
---
>     $query->expression('depth', 'depth - :depth', array(':depth' => -$shift));
2206,2214c2352
<     // The order of $set must be reversed so the new values don't overwrite the
<     // old ones before they can be used because "Single-table UPDATE
<     // assignments are generally evaluated from left to right"
<     // see: http://dev.mysql.com/doc/refman/5.0/en/update.html
<     $set = array_reverse($set);
<     $args = array_reverse($args);
< 
<     $args[] = $shift;
<     $set[] = 'depth = depth + %d';
---
>     $query->expression('depth', 'depth + :depth', array(':depth' => $shift));
2216,2217c2354,2355
<   $where[] = "menu_name = '%s'";
<   $args[] = $existing_item['menu_name'];
---
> 
>   $query->condition('menu_name', $existing_item['menu_name']);
2220,2221c2358
<     $where[] = "$p = %d";
<     $args[] = $existing_item[$p];
---
>     $query->condition($p, $existing_item[$p]);
2224c2361,2362
<   db_query("UPDATE {menu_links} SET " . implode(', ', $set) . " WHERE " . implode(' AND ', $where), $args);
---
>   $query->execute();
> 
2236,2237c2374,2375
<     $query = db_select('menu_links', 'm');
<     $query->addField('m', 'mlid');
---
>     $query = db_select('menu_links');
>     $query->addField('menu_links', 'mlid');
2242d2379
< 
2244c2381
<       $query->condition('mlid', $item['mlid'], '!=');
---
>       $query->condition('mlid', $item['mlid'], '<>');
2246d2382
< 
2248,2249c2384,2387
<     db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $parent_has_children, $item['plid']);
< 
---
>     db_update('menu_links')
>       ->fields(array('has_children' => $parent_has_children))
>       ->condition('mlid', $item['plid'])
>       ->execute();
2361c2499,2523
<   db_query('DELETE FROM {menu_router}');
---
>   db_delete('menu_router')->execute();
> 
>   // Prepare insert object.
>   $insert = db_insert('menu_router')
>     ->fields(array(
>       'path',
>       'load_functions',
>       'to_arg_functions',
>       'access_callback',
>       'access_arguments',
>       'page_callback',
>       'page_arguments',
>       'fit',
>       'number_parts',
>       'tab_parent',
>       'tab_root',
>       'title',
>       'title_callback',
>       'title_arguments',
>       'type',
>       'block_callback',
>       'description',
>       'position',
>       'weight',
>     ));
2427,2443c2589,2610
<     $title_arguments = $item['title arguments'] ? serialize($item['title arguments']) : '';
<     db_query("INSERT INTO {menu_router}
<       (path, load_functions, to_arg_functions, access_callback,
<       access_arguments, page_callback, page_arguments, fit,
<       number_parts, tab_parent, tab_root,
<       title, title_callback, title_arguments,
<       type, block_callback, description, position, weight)
<       VALUES ('%s', '%s', '%s', '%s',
<       '%s', '%s', '%s', %d,
<       %d, '%s', '%s',
<       '%s', '%s', '%s',
<       %d, '%s', '%s', '%s', %d)",
<       $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'],
<       serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['_fit'],
<       $item['_number_parts'], $item['tab_parent'], $item['tab_root'],
<       $item['title'], $item['title callback'], $title_arguments,
<       $item['type'], $item['block callback'], $item['description'], $item['position'], $item['weight']);
---
>     // Fill in insert object values.
>     $insert->values(array(
>       'path' => $item['path'],
>       'load_functions' => $item['load_functions'],
>       'to_arg_functions' => $item['to_arg_functions'],
>       'access_callback' => $item['access callback'],
>       'access_arguments' => serialize($item['access arguments']),
>       'page_callback' => $item['page callback'],
>       'page_arguments' => serialize($item['page arguments']),
>       'fit' => $item['_fit'],
>       'number_parts' => $item['_number_parts'],
>       'tab_parent' => $item['tab_parent'],
>       'tab_root' => $item['tab_root'],
>       'title' => $item['title'],
>       'title_callback' => $item['title callback'],
>       'title_arguments' => ($item['title arguments'] ? serialize($item['title arguments']) : ''),
>       'type' => $item['type'],
>       'block_callback' => $item['block callback'],
>       'description' => $item['description'],
>       'position' => $item['position'],
>       'weight' => $item['weight'],
>     ));
2444a2612,2614
>   // Execute insert object.
>   $insert->execute();
> 
2515c2685
<     if ($item = db_fetch_array(db_query("SELECT * FROM {menu_router} where path = '%s' ", $path))) {
---
>     if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
