You are here

function xmlsitemap_node_enable in XML sitemap 5

Same name and namespace in other branches
  1. 5.2 xmlsitemap_node/xmlsitemap_node.install \xmlsitemap_node_enable()
  2. 6 xmlsitemap_node/xmlsitemap_node.install \xmlsitemap_node_enable()

Implementation of hook_enable().

File

xmlsitemap_node/xmlsitemap_node.install, line 102

Code

function xmlsitemap_node_enable() {
  $weight = db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'pathauto'"));
  if ($weight !== FALSE) {
    db_query("UPDATE {system} SET weight = %d WHERE type = 'module' AND name = 'xmlsitemap_node'", ++$weight);
  }
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("\n        UPDATE {xmlsitemap_node} xn INNER JOIN {node} n ON xn.nid = n.nid LEFT JOIN {node_comment_statistics} s ON s.nid = xn.nid\n        SET xn.previously_changed = xn.last_changed, xn.last_changed = n.changed, xn.last_comment = s.last_comment_timestamp\n        WHERE xn.nid = n.nid AND (xn.last_changed <> n.changed OR xn.last_comment <> s.last_comment_timestamp)\n      ");
      break;
    case 'pgsql':
      db_query("\n        UPDATE {xmlsitemap_node} SET previously_changed = last_changed, last_changed = {node}.changed, last_comment = {node_comment_statistics}.last_comment_timestamp\n        FROM {node} LEFT JOIN {node_comment_statistics} ON {node_comment_statistics}.nid = {node}.nid\n        WHERE {xmlsitemap_node}.nid = {node}.nid AND (last_changed <> {node}.changed OR last_comment <> {node_comment_statistics}.last_comment_timestamp)\n      ");
      break;
  }
  db_query(_xmlsitemap_node_insert_query());
  db_query(_xmlsitemap_node_updatepid_query());
  xmlsitemap_update_sitemap();
}