function xmlsitemap_user_enable in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap_user/xmlsitemap_user.install \xmlsitemap_user_enable()
- 6 xmlsitemap_user/xmlsitemap_user.install \xmlsitemap_user_enable()
Implementation of hook_enable().
File
- xmlsitemap_user/
xmlsitemap_user.install, line 61
Code
function xmlsitemap_user_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_user'", ++$weight);
}
db_query("\n INSERT INTO {xmlsitemap_user} (uid, last_changed)\n SELECT u.uid, u.created FROM {users} u\n LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid\n WHERE u.uid <> 0 AND xu.uid IS NULL\n ");
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("\n UPDATE {xmlsitemap_user} xu INNER JOIN {url_alias} ua\n ON ua.src = CONCAT('user/', CAST(xu.uid AS CHAR))\n SET xu.pid = ua.pid\n WHERE xu.pid IS NULL\n ");
break;
case 'pgsql':
db_query("\n UPDATE {xmlsitemap_user}\n SET pid = {url_alias}.pid\n FROM {url_alias}\n WHERE {url_alias}.src = CONCAT('user/', CAST(uid AS VARCHAR)) AND {xmlsitemap_user}.pid IS NULL\n ");
break;
}
db_query("\n INSERT INTO {xmlsitemap_user_role} (rid)\n SELECT r.rid FROM {role} r\n LEFT JOIN {xmlsitemap_user_role} xur ON xur.rid = r.rid\n WHERE r.rid > 2 AND xur.rid IS NULL\n ");
xmlsitemap_update_sitemap();
}