function xmlsitemap_user_user in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_user()
- 6.2 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_user()
- 6 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_user()
Implementation of hook_user().
Related topics
File
- xmlsitemap_user/
xmlsitemap_user.module, line 169 - Adds user profiles to the site map.
Code
function xmlsitemap_user_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'form':
$priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid));
if (user_access('override profile priority')) {
$form['xmlsitemap_user'] = array(
'#type' => 'fieldset',
'#title' => t('Site map settings'),
'#collapsible' => TRUE,
'#weight' => 7,
);
$options = xmlsitemap_priority_options('both');
$default = db_fetch_object(db_query("\n SELECT MIN(priority) AS min, SUM(priority) AS sum FROM {xmlsitemap_user_role}\n WHERE rid IN (" . implode(', ', array_keys($account->roles)) . ")\n "));
$default = $default->min < 0 ? -1 : min($default->sum, 0.9);
$default = isset($default) ? (string) $default : variable_get('xmlsitemap_user_default_priority', '0.5');
$form['xmlsitemap_user']['xmlsitemap_user_priority'] = array(
'#type' => 'select',
'#title' => t('Site map priority'),
'#default_value' => isset($priority) ? $priority : 'NULL',
'#options' => $options,
'#description' => t('The default priority is %priority.', array(
'%priority' => $options[$default],
)),
);
}
else {
$form['xmlsitemap_user_priority'] = array(
'#type' => 'value',
'#value' => isset($priority) ? $priority : 'NULL',
);
}
return $form;
case 'insert':
$pid = db_result(db_query("SELECT pid FROM {url_alias} WHERE src = '%s'", "user/{$account->uid}"));
$pid = empty($pid) ? 'NULL' : $pid;
if (isset($edit['xmlsitemap_user_priority'])) {
$priority = $edit['xmlsitemap_user_priority'];
}
else {
$priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid));
$priority = isset($priority) && $priority !== FALSE ? $priority : 'NULL';
}
db_query("\n INSERT INTO {xmlsitemap_user} (uid, pid, last_changed, priority_override) VALUES (%d, %s, %d, %s)\n ", $account->uid, $pid, time(), $priority);
$edit['xmlsitemap_user_priority'] = NULL;
xmlsitemap_update_sitemap();
break;
case 'update':
$pid = db_result(db_query("SELECT pid FROM {url_alias} WHERE src = '%s'", "user/{$account->uid}"));
$pid = empty($pid) ? 'NULL' : $pid;
if (isset($edit['xmlsitemap_user_priority'])) {
$priority = $edit['xmlsitemap_user_priority'];
}
else {
$priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid));
$priority = isset($priority) && $priority !== FALSE ? $priority : 'NULL';
}
db_query("\n UPDATE {xmlsitemap_user}\n SET pid = %s, last_changed = %d, previously_changed = last_changed, priority_override = %s\n WHERE uid = %d\n ", $pid, time(), $priority, $account->uid);
$edit['xmlsitemap_user_priority'] = NULL;
xmlsitemap_update_sitemap();
break;
case 'delete':
db_query("DELETE FROM {xmlsitemap_user} WHERE uid = %d", $account->uid);
xmlsitemap_update_sitemap();
break;
}
}