'fieldset', '#title' => t('sitemap'), ); $default = variable_get('xmlsitemap_user_default_priority', 0.5); $form['xmlsitemap']['xmlsitemap_user_old_default_priority'] = array( '#type' => 'value', '#value' => $default ); $form['xmlsitemap']['xmlsitemap_user_default_priority'] = array( '#type' => 'select', '#title' => t('Default user priority'), '#default_value' => $default, '#options' => xmlsitemap_priority_options('exclude'), '#description' => t('Choose the default priority for users who have only the authenticated user role.'), ); $form['buttons']['#weight'] = 1; $form['#submit']['_xmlsitemap_user_submit'] = array(); break; case 'user_admin_role': $options = xmlsitemap_priority_options('both'); $priority = db_result(db_query("SELECT priority FROM {xmlsitemap_user_role} WHERE rid = %d", $form['rid']['#value'])); $priority = $priority === FALSE ? 'NULL' : $priority; $form['xmlsitemap_user_role_priority'] = array( '#type' => 'select', '#title' => t('Default sitemap priority'), '#default_value' => $priority, '#options' => $options, '#description' => t("The priority of all a user's roles will be added together to set the user's default priority. If all role priorities are left at default, the user's default priority will be %priority.", array('%priority' => $options[variable_get('xmlsitemap_user_default_priority', '0.5')])), ); $form['submit']['#weight'] = 1; $form['delete']['#weight'] = 1; $form['#submit']['_xmlsitemap_user_submit'] = array(); break; } } /** * Implementation of hook_user(). */ function xmlsitemap_user_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case 'form': if ($category != 'account') { return array(); } case 'register': $priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_user} WHERE uid = %d", $account->uid)); if (isset($account->roles)) { $roles = array_keys($account->roles); $default = db_fetch_object( db_query("SELECT MIN(priority) AS min, SUM(priority) AS sum FROM {xmlsitemap_user_role} WHERE rid IN (". xmlsitemap_placeholders($roles, 'int') .")", $roles ) ); } if (isset($default->min) && isset($default->sum)) { $default_priority = $default->min < 0 ? -1 : round(min($default->sum, 1), 1); } else { $default_priority = variable_get('xmlsitemap_user_default_priority', '0.5'); } $disabled = !user_access('administer users'); $form = array(); if (user_access('override profile settings')) { $form['xmlsitemap_user'] = array( '#type' => 'fieldset', '#title' => t('sitemap settings'), '#collapsible' => TRUE, '#weight' => 7, ); $options = xmlsitemap_priority_options('both'); $form['xmlsitemap']['xmlsitemap_user_priority'] = array( '#type' => 'select', '#title' => t('Priority'), '#default_value' => $priority !== FALSE ? $priority : 'NULL', '#options' => $options, '#disabled' => $disabled, '#description' => t('The default priority is %priority.', array('%priority' => $options[(string)$default_priority])), ); $form['xmlsitemap_user']['xmlsitemap_user_priority'] = array( '#type' => 'select', '#title' => t('sitemap 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': 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)); } db_query("INSERT INTO {xmlsitemap_user} (uid, last_changed, priority_override) VALUES (%d, %d, %s)", $account->uid, REQUEST_TIME, isset($priority) && $priority !== FALSE ? $priority : 'NULL' ); xmlsitemap_flag_sitemap(); break; case 'update': 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)); } db_query("UPDATE {xmlsitemap_user} SET previously_changed = last_changed, last_changed = %d, priority_override = %s WHERE uid = %d", REQUEST_TIME, $priority !== FALSE ? $priority : 'NULL', $account->uid ); xmlsitemap_flag_sitemap(); break; case 'delete': db_query("DELETE FROM {xmlsitemap_user} WHERE uid = %d", $account->uid); xmlsitemap_flag_sitemap(); break; } } /** * Implementation of hook_xmlsitemap_description(). */ function xmlsitemap_user_xmlsitemap_description() { return '