You are here

function xmlsitemap_user_form_alter in XML sitemap 5.2

Same name and namespace in other branches
  1. 5 xmlsitemap_user/xmlsitemap_user.module \xmlsitemap_user_form_alter()

Implementation of hook_form_alter().

File

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

Code

function xmlsitemap_user_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'user_admin_settings':
      $form['xmlsitemap'] = array(
        '#type' => '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;
  }
}