function xmlsitemap_user_xmlsitemap_links in XML sitemap 6
Same name and namespace in other branches
- 5.2 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_xmlsitemap_links()
- 5 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_xmlsitemap_links()
Implementation of hook_xmlsitemap_links().
File
- xmlsitemap_user/
xmlsitemap_user.module, line 196 - Adds user profiles to the sitemap.
Code
function xmlsitemap_user_xmlsitemap_links() {
$anon_account = drupal_anonymous_user();
$user_access = user_access('access user profiles', $anon_account);
$result = db_query("SELECT u.uid, u.access, u.status, xu.changed, xu.previously_changed, xu.priority_override\n FROM {xmlsitemap_user} xu\n INNER JOIN {users} u ON xu.uid = u.uid");
$row = new stdClass();
$row->module = 'xmlsitemap_user';
$row->type = 'user';
while ($user = db_fetch_object($result)) {
$row->loc = 'user/' . $user->uid;
$row->id = $user->uid;
$row->changed = $user->changed;
$row->changefreq = max(REQUEST_TIME - $user->changed, empty($user->previously_changed) ? 0 : $user->changed - $user->previously_changed);
$priority = xmlsitemap_user_get_priority($user);
$row->priority = $priority == -1 ? $priority : min(max(round($priority, 1), 0.0), 1.0);
$row->priority = $user_access ? $row->priority : -1;
$old_row = db_fetch_object(db_query("SELECT lid, type, priority FROM {xmlsitemap} WHERE loc = '%s'", $row->loc));
if ($old_row === FALSE) {
drupal_write_record('xmlsitemap', $row);
}
elseif ($old_row->type == 'user' && ($old_row->priority != $row->priority || $old_row->changed != $row->changed || $old_row->changefreq != $row->changefreq)) {
$row->lid = $old_row->lid;
drupal_write_record('xmlsitemap', $row, 'lid');
}
}
}