You are here

function xmlsitemap_user_cron in XML sitemap 6

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

Implementation of hook_cron().

File

xmlsitemap_user/xmlsitemap_user.module, line 20
Adds user profiles to the sitemap.

Code

function xmlsitemap_user_cron() {
  if (($limit = variable_get('xmlsitemap_cron_limit', 100)) != -1) {
    $sql = "SELECT u.* FROM {users} u\n      LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid\n      WHERE xu.uid IS NULL\n        AND u.uid <> 0\n        AND u.status <> 0";
    $result = db_query_range($sql, 0, $limit);
    $sitemap_changed = FALSE;
    while ($account = db_fetch_object($result)) {
      $row = new stdClass();
      $row->uid = $account->uid;
      $row->changed = !empty($account->access) ? $account->access : REQUEST_TIME;
      $row->previously_changed = $account->created;
      drupal_write_record('xmlsitemap_user', $row);
      $sitemap_changed = TRUE;
    }
    if ($sitemap_changed) {
      xmlsitemap_flag_sitemap();
    }
  }
}