function user_user_settings_form

7.x user.module user_user_settings_form()
6.x user.module user_user_settings_form()

This is the main settings form for a user.

1 string reference to 'user_user_settings_form'
user_menu in modules/user/user.module
Implementation of hook_menu

File

modules/user/user.module, line 932

Code

function user_user_settings_form() {
  global $user;
  $form = array();

  fp_add_css(fp_get_module_path("user") . "/css/user.css");

  fp_set_title($user->f_name . " " . $user->l_name . " (" . $user->cwid . ")");

  $html = "";

  $image_url = @$user->settings ['image_url'];

  // if faculty, display things like email and such which we have in the database.  
  if ($user->is_faculty) {
    $html .= "<div class='user-profile-markup-faculty'>";
    if ($image_url) {
      $html .= "<span class='small-profile-image'>
                  <img src='$image_url'> 
                </span>";
    }
    $html .= "  <div class='profile-item'><strong>" . t("Email:") . "</strong> $user->email</div>
                <div class='profile-item'><strong>" . t("Roles:") . "</strong>
                    ";
    foreach ($user->roles as $role) {
      $html .= "" . $role . ", ";
    }
    $html = rtrim($html, ', ');
    $html .= "</div>";

    $html .= "</div>"; // user-profile-markup-faculty
  }



  $form ['mark_top'] = array(
    'type' => 'markup',
    'value' => $html,
  );

  $form ['mark_clear'] = array(
    'type' => 'markup',
    'value' => "<div class='clear'></div>",
  );

  // Are we allowed to change our password?
  if (user_has_permission('change_own_password')) {

    if (!isset($_SESSION ['fp_logged_in_external']) || $_SESSION ['fp_logged_in_external'] === FALSE) {
      $form ['current_password'] = array(
        'label' => t("Current password"),
        'type' => 'password',
        'description' => t('If you wish to change your password, enter your current password here, then your new password below.'),
      );
      $form ['new_password1'] = array(
        'label' => t("New password"),
        'type' => 'password',
      );
      $form ['new_password2'] = array(
        'label' => t("New password (re-enter)"),
        'type' => 'password',
        'suffix' => '<hr>',
      );
    }
    else if (isset($_SESSION ['fp_logged_in_external']) && $_SESSION ['fp_logged_in_external'] === TRUE) {
      $form ['mark_external_login'] = array(
        'type' => 'markup',
        'value' => "<fieldset><legend>" . t("Password Change") . "</legend>" . t("<b>Note:</b> You logged in using an external service.  Therefore, you cannot change your FlightPath password from here.
                      Please inquire with your IT department on how to change your password.") . "</strong></fieldset>",
      );
    }
  } // user has perm change_own_password

  if (user_has_permission('change_own_image')) {
    $form ['image_url'] = array(
      'label' => t('Image URL'),
      'type' => 'textfield',
      'value' => @$user->settings ['image_url'],
      'description' => t('Enter the full URL/URI to your profile image.  Make sure your
                          image is in "portrait" orientation, and generally no larger than 20 or 30kb in filesize.
                          Also make sure that the originating server is HTTPS and not HTTP.'),
      'suffix' => '<hr>',
    );
  } // user has permission to change their image



  $system_timezone = variable_get('system_timezone', 'America/Chicago');


  $form ['timezone'] = array(
    'label' => t('Your timezone (if not %tz)', array('%tz' => $system_timezone)),
    'type' => 'select',
    'options' => get_timezones(),
    'value' => @$user->settings ['timezone'],
    'description' => t("By default, times will be displayed based on the system timezone of %tz.  If you wish to override
                        with your own timezone, please select it here.", array("%tz" => $system_timezone)),
  );


  $form ['hide_charts'] = array(
    'label' => t('Should student pie charts be displayed?'),
    'type' => 'select',
    'options' => array('show' => t('Yes (default)'), 'hide' => t('No, hide pie charts on Degree page')),
    'value' => @$user->settings ['hide_charts'],
    'description' => t('If set to No, pie charts will not be visible on student Degree tabs.  If you
                        are unsure what to select, choose "Yes".'),
  );




  if (user_has_permission('view_any_advising_session')) {

    $value = @$user->settings ['default_student_load_tab'];
    if (!$value || $value == "") {
      // No specific setting, so use the system's default setting.
      $value = variable_get('system_default_student_load_tab', 'profile');
    }

    $form ['default_student_load_tab'] = array(
      'label' => t('What is the default tab you want to see when you load a new student?'),
      'type' => 'select',
      'hide_please_select' => TRUE,
      'options' => array('profile' => t('Student Profile'), 'engagements' => t("Engagements"), 'degree' => t('Degree')),
      'value' => $value,
      'description' => t('If you are unsure what to select, choose "Student Profile" or leave set to its current setting.'),
    );
  }


  $options = array('email' => t("Email"));
  $phone_number = user_get_attribute($user->id, 'mobile_phone', '');
  if (variable_get('sms_project_id', '') != '' && $phone_number != "") {
    $options ['txt'] = t("Text Message");
    $options ['email_txt'] = t("Both email and text message");
  }

  $form ['default_notification_method'] = array(
    'label' => t('Default notification method for important events'),
    'type' => 'select',
    'hide_please_select' => TRUE,
    'options' => $options,
    'value' => @$user->settings ['default_notification_method'],
    'description' => t('These would be notifications sent out by FlightPath.  For example, when you schedule an appointment or to send out a reminder.
                        If you are unsure what to select, choose "Email".'),
  );


  if ($phone_number) {
    $phone_number = engagements_convert_to_valid_phone_number($phone_number);
    $form ['sms_opt_out__' . $phone_number] = array(
      'label' => t('Opt-out of receiving text messages at %num?', array("%num" => engagements_convert_to_pretty_phone_number($phone_number))),
      'type' => 'select',
      'hide_please_select' => TRUE,
      'options' => array('no' => t('No - Receive text messages normally (default)'), 'yes' => t('Yes - Opt-out, and do not receive text messages from @flightpath', array("@flightpath", variable_get("system_name", "FlightPath")))),
      'value' => @$user->settings ['sms_opt_out__' . $phone_number],
      'description' => t('This setting controls whether you wish to completely opt-out of receiving text messages on your phone.  If set to "Yes", then your default notification method
                          above will automatically be set to "Email" only.  If unsure what to select, choose "No".'),
    );

  }







  $form ['submit_btn'] = array(
    'type' => 'submit',
    'value' => 'Save',
  );

  return $form;
}