You are here

function xmlsitemap_user_cron in XML sitemap 5

Same name and namespace in other branches
  1. 6.2 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_cron()
  2. 6 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_cron()
  3. 7.2 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_cron()

Implementation of hook_cron().

Related topics

File

xmlsitemap_user/xmlsitemap_user.module, line 243
Adds user profiles to the site map.

Code

function xmlsitemap_user_cron() {
  if (db_result(db_query_range("SELECT COUNT(*) FROM {users} u LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid WHERE u.uid <> 0 AND xu.uid IS NULL", 0, 1))) {
    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;
    }
    xmlsitemap_update_sitemap();
  }
}