You are here

function advuser_settings in Advanced User 5

Same name and namespace in other branches
  1. 5.2 advuser.module \advuser_settings()
  2. 6.3 forms/advuser_settings.inc \advuser_settings()
  3. 6.2 advuser.module \advuser_settings()
  4. 7.3 forms/advuser_settings.inc \advuser_settings()
1 string reference to 'advuser_settings'
advuser_menu in ./advuser.module
Implementation of hook_menu().

File

./advuser.module, line 644

Code

function advuser_settings() {
  $form['module_banner'] = array(
    '#type' => 'markup',
    '#value' => '<div style="border: solid 1px #eee; margin: .5em; padding: .5em;" <strong>Module maintenance and development sponsored by <a href="http://exodusdev.com">Exodus Development</a></strong><br/>',
  );
  $form['module_id'] = array(
    '#type' => 'markup',
    '#value' => ADVUSER_MODULE_VERSION . '<br/></div>',
  );
  $form['advuser_mail'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mail notifications on user account activity.'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['advuser_mail']['variables'] = array(
    '#type' => 'markup',
    '#value' => '<div class="advuser-inset-panel"><strong>Substitution variables</strong> available in subject and email body<br/><em> %username, %site, %uri, %user_email, %google_user (search google for user email), %yahoo_user (search yahoo for user email)</em></div>',
  );

  //New User Notification
  $form['advuser_mail']['advuser_new_notify'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send notifications on new user registration'),
    '#description' => t('Notify selected roles when new users register.'),
    '#default_value' => variable_get('advuser_new_notify', ADVUSER_DEFAULT_NEW_NOTIFY),
  );
  $form['advuser_mail']['advuser_new_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Mail subject'),
    '#description' => t('The subject of the mail that is going to be sent to the user.  You may insert substitution variables within this item.'),
    '#default_value' => variable_get('advuser_new_subject', ADVUSER_DEFAULT_NEW_SUBJECT),
  );
  $form['advuser_mail']['advuser_new_mail'] = array(
    '#type' => 'textarea',
    '#title' => t('Mail body'),
    '#description' => t('The mail that is going to be sent to the selected roles.  You may insert substitution variables within this item.'),
    '#default_value' => variable_get('advuser_new_mail', ADVUSER_DEFAULT_NEW_MAIL),
  );

  //User change notification
  $form['advuser_mail']['advuser_modify_notify'] = array(
    '#type' => 'checkbox',
    '#title' => t('Send notifications on user profile updates'),
    '#description' => t('Notify selected roles when users update their profiles.'),
    '#default_value' => variable_get('advuser_modify_notify', ADVUSER_DEFAULT_MODIFY_NOTIFY),
  );
  $form['advuser_mail']['advuser_modify_subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Mail subject'),
    '#description' => t('The subject of the mail that is going to be sent when a user modifies their profiles.  You may insert substitution variables within this item.'),
    '#default_value' => variable_get('advuser_modify_subject', ADVUSER_DEFAULT_MODIFY_SUBJECT),
  );
  $form['advuser_mail']['advuser_modify_mail'] = array(
    '#type' => 'textarea',
    '#title' => t('Mail body'),
    '#description' => t('The mail that is going to be sent to the selected roles when a user modifies their account.  You may insert substitution variables within this item.'),
    '#default_value' => variable_get('advuser_modify_mail', ADVUSER_DEFAULT_MODIFY_MAIL),
  );

  //Maximum rows in dataset to display
  $form['advuser_mail']['advuser_listno'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(
      0,
      10,
      25,
      50,
      75,
      100,
      125,
      150,
      175,
      200,
    )),
    '#title' => t('Number of users in listing'),
    '#description' => t('Sets how many users to display in table view'),
    '#default_value' => variable_get('advuser_listno', ADVUSER_DEFAULT_LISTNO),
  );
  $roles = user_roles(1);

  /*$options = array();
    foreach ( $roles as $rid => $role) {
      $options["$rid"] = $role;
    }*/

  //print_r();
  $values = array();
  $options = variable_get('advuser_new_roles', ADVUSER_DEFAULT_NEW_ROLES);
  $sel_roles_count = 0;
  foreach ((array) $options as $opt => $v) {
    if ($v > 0) {
      $values[] = $v;
      $sel_roles_count++;
    }
  }
  $form['advuser_mailonnew']['advuser_new_roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Notification Roles'),
    '#description' => t('Roles that receive email notifications.'),
    '#options' => $roles,
    '#default_value' => $values,
  );
  if ($sel_roles_count == 0) {
    $form['advuser_mailonnew']['no_roles_sel_warning'] = array(
      '#type' => 'markup',
      '#value' => '<div class="advuser-settings-warning"><strong>WARNING: No roles selected!</strong> - no email notifications will be sent.</div>',
    );
  }
  if (module_exists('profile')) {
    $form['advuser_profile'] = array(
      '#type' => 'fieldset',
      '#title' => t('Profile module special settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $fields = array();
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
    while ($row = db_fetch_object($result)) {
      $fields[$row->fid] = $row->title;
    }
    $values = array();
    $options = variable_get('advuser_profile_fields', ADVUSER_DEFAULT_PROFILE_FIELDS);
    foreach ((array) $options as $opt => $v) {
      if ($v > 0) {
        $values[] = $v;
      }
    }
    $form['advuser_profile']['advuser_profile_fields'] = array(
      '#type' => 'checkboxes',
      '#description' => t('Profile fields to be used as filters for the users.'),
      '#title' => t('Profile fields'),
      '#options' => $fields,
      '#default_value' => $values,
    );
  }
  return system_settings_form($form);
}