You are here

function xmlsitemap_menu_update_1 in XML sitemap 5.2

Implementation of hook_update_N().

1 call to xmlsitemap_menu_update_1()
xmlsitemap_menu_update_2 in xmlsitemap_menu/xmlsitemap_menu.install
Implementation of hook_update_N().

File

xmlsitemap_menu/xmlsitemap_menu.install, line 42
Install file for XML sitemap menu

Code

function xmlsitemap_menu_update_1() {
  $ret = array();
  $mid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')));
  if (($mid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')))) !== FALSE) {
    $result = db_query("SELECT * FROM {xmlsitemap_additional}");
    while ($link = db_fetch_object($result)) {
      $link->priority = isset($link->priority) ? $link->priority : variable_get('xmlsitemap_additional_links_priority', 0.5);
      $item = array(
        'mid' => db_next_id('{menu}_mid'),
        'pid' => $mid,
        'path' => $link->path,
        'title' => $link->path,
        'weight' => $link->priority * 20 - 10,
        'type' => MENU_CUSTOM_ITEM | MENU_MODIFIED_BY_ADMIN,
      );
      db_query("INSERT INTO {menu} (mid, pid, path, title, weight, type) VALUES (%d, %d, '%s', '%s', %d, %d)", $item);
    }
    variable_set('xmlsitemap_menu_custom_menu', $mid);
    $ret[] = array(
      'success' => TRUE,
      'query' => 'ADD MODULE VARIABLE xmlsitemap_menu_custom_menu',
    );
  }
  $ret[] = update_sql("DROP TABLE {xmlsitemap_additional}");
  return $ret;
}