You are here

function xmlsitemap_user_set_priority in XML sitemap 6

Set the user priority in the sitemap. It doesn't change the priority of a blocked user.

Parameters

$user: The user object, or the user ID.

$priority: The priority for the user.

Return value

The user object, or FALSE.

File

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

Code

function xmlsitemap_user_set_priority($user, $priority) {
  if (!is_numeric($user)) {
    $user = (object) $user;
    $uid = $user->uid;
  }
  else {
    $uid = $user;
    $user = user_load($uid);
  }
  if ($user && $user->status) {
    $result = db_fetch_object(db_query("SELECT uid, changed, previously_changed, priority_override\n      FROM {xmlsitemap_user}\n      WHERE uid = %d", $uid));
    if ($result === FALSE) {
      $row = new stdClass();
      $row->uid = $user->uid;
      $row->changed = $user->access;
      $row->previously_changed = $user->created;
    }
    else {
      $row = $result;
      if ($row->changed < $user->access) {
        $row->previously_changed = $row->changed;
        $row->changed = $user->access;
      }
    }
    $row->priority_override = $priority;
    drupal_write_record('xmlsitemap_user', $row, $result === FALSE ? NULL : 'uid');
    return $user;
  }
  return FALSE;
}