--- pubcookie.module 2006-12-18 13:22:19.000000000 -0800 +++ pubcookie.module 2006-12-18 15:16:44.000000000 -0800 @@ -170,6 +170,34 @@ function pubcookie_auth($username, $pass } /** + * Implementation of hook_form_alter(). + * + * Modify user_login form to suggest pubcookie. + */ +function pubcookie_form_alter($form_id, &$form) { + if ($form_id == 'user_login' && variable_get('pubcookie_alter_login_form', 1)) { + foreach (array_keys($form) as $key) { + if (substr($key, 0, 1) != '#') { + $form['local'][$key] = $form[$key]; + unset($form[$key]); + } + } + $form['local']['#title'] = t('Local users'); + $form['local']['#type'] = 'fieldset'; + $form['local']['#collapsible'] = true; + $form['local']['#collapsed'] = true; + $form['pubcookie'] = array( + '#title' => variable_get('pubcookie_authname', 'pubcookie') . t(' users'), + '#type' => 'fieldset', + '#weight' => -10, + ); + $form['pubcookie']['link'] = array( + '#value' => l(t('Log in...'), pubcookie_login_link()), + ); + } +} + +/** * Implementation of hook_user(). * * Fill in profile field(s) from LDAP for pubcookie-authenticated users. @@ -347,6 +375,20 @@ function pubcookie_settings() { '#size' => '40', '#maxlength' => '255' ); + $form['pubcookie_alter_login_form'] = array( + '#type' => 'checkbox', + '#title' => t('Alter primary login form'), + '#default_value' => variable_get('pubcookie_alter_login_form', 0), + '#description' => t("Suggest pubcookie auth on primary login page.") + ); + $form['pubcookie_authname'] = array( + '#type' => 'textfield', + '#title' => t('Label for authentication method'), + '#default_value' => variable_get('pubcookie_authname', 'pubcookie'), + '#description' => t("This will be used when identifying the pubcookie authentication service to the user."), + '#size' => '40', + '#maxlength' => '255', + ); return system_settings_form($form); }