function xmlsitemap_term_enable in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap_term/xmlsitemap_term.install \xmlsitemap_term_enable()
Implementation of hook_enable().
File
- xmlsitemap_term/
xmlsitemap_term.install, line 51
Code
function xmlsitemap_term_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_term'", ++$weight);
}
$query = "\n INSERT INTO {xmlsitemap_term} (tid, last_changed)\n SELECT td.tid, %d FROM {term_data} td\n LEFT JOIN {xmlsitemap_term} xt ON xt.tid = td.tid\n WHERE xt.tid IS NULL\n ";
db_query($query, time());
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("\n UPDATE {xmlsitemap_term} xt INNER JOIN {url_alias} ua\n ON ua.src = CONCAT('taxonomy/term/', CAST(xt.tid AS CHAR))\n OR ua.src = CONCAT('forum/', CAST(xt.tid AS CHAR))\n SET xt.pid = ua.pid\n WHERE xt.pid IS NULL\n ");
break;
case 'pgsql':
db_query("\n UPDATE {xmlsitemap_term}\n SET pid = {url_alias}.pid\n FROM {url_alias}\n WHERE {url_alias}.src = CONCAT('taxonomy/term/', CAST(tid AS VARCHAR))\n OR {url_alias}.src = CONCAT('forum/', CAST(tid AS VARCHAR))\n AND {xmlsitemap_term}.pid IS NULL\n ");
break;
}
xmlsitemap_update_sitemap();
}