You are here

function ldapdata_form_alter in LDAP integration 6

Implementation of hook_form_alter().

Note: Provides support for avatarcrop module (AC). However, the AC module needs to have the drupal_goto call in the cropUserPic form replaces with a $form_state['redirect'] call and the uid added as a form value. Patch for AC will soon be created.

File

./ldapdata.module, line 978
ldapdata provides data maping against ldap server.

Code

function ldapdata_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'cropUserPic':
      $form['#submit'][] = 'ldapdata_avatarcrop_submit';
      break;

    // Add picture UI options
    case 'ldapauth_admin_settings':
      if (variable_get('user_pictures', '0')) {
        $form['ldap-ui']['ldapdata_disable_picture_change'] = array(
          '#type' => 'checkbox',
          '#title' => t('Remove picture upload and delete fields from user edit form'),
          '#default_value' => LDAPDATA_DISABLE_PICTURE_CHANGE,
          '#description' => t('If checked, LDAP users will not see these change user picture fields. Use this if ldapdata maps the user picture to an ldap attribute and the map type is "read only" since LDAP users will not be able to change pictures via Drupal.'),
        );
        $form['#submit'][] = 'ldapdata_ldapauth_admin_settings_submit';
      }
      break;

    // Remove user picture fields if needed
    case 'user_profile_form':
      $account = $form["_account"]["#value"];
      if ($user->uid != 1 && isset($account->ldap_authentified) && LDAPDATA_DISABLE_PICTURE_CHANGE && isset($form['picture'])) {
        unset($form['picture']);
      }
      break;
  }
}