summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlogintoboggan.module142
1 files changed, 112 insertions, 30 deletions
diff --git a/logintoboggan.module b/logintoboggan.module
index 76c43ac..43829af 100755
--- a/logintoboggan.module
+++ b/logintoboggan.module
@@ -58,7 +58,7 @@ function logintoboggan_help($section) {
}
/**
- * Helper function for example user email textfield.
+ * Helper function for example user e-mail textfield.
*/
function logintoboggan_example_help() {
$example = t('
@@ -115,13 +115,14 @@ function logintoboggan_form_alter($form_id, &$form) {
}
break;
- // This will reset the the site 403 variable to the default if the module is disabled and the toboggan redirect on acccess
- // denied is enabled.
+ // This will reset the the site 403 variable to the default if the module is
+ // disabled and the toboggan redirect on access denied is enabled.
case 'system_modules':
if ($_POST && !$_POST['status']['logintoboggan'] && (db_result(db_query("SELECT status FROM {system} WHERE name = 'logintoboggan'")) == 1) && (variable_get('site_403', '') == 'toboggan/denied')) {
variable_set('site_403', '');
}
break;
+
case 'logintoboggan_main_settings':
$form['#submit'] += array('logintoboggan_flip_user_email_verification' => array());
break;
@@ -138,24 +139,27 @@ function logintoboggan_form_alter($form_id, &$form) {
$form['account']['roles']['#description'] = t("The user is assigned LoginToboggan's pre-authorized role, and is not currently receiving authenticated user permissions.");
}
break;
+
case 'user_login':
case 'user_login_block':
- // Grab the message from settings if there is one to display at the top of the login block.
+ // Grab the message from settings for display at the top of the login block.
if ($login_msg = variable_get('toboggan_block_msg', '')) {
$form['message'] = array(
'#value' => filter_xss_admin($login_msg),
'#weight' => -50,
);
}
- $form['name']['#attributes'] = array('tabindex' => '1');
- $form['pass']['#attributes'] = array('tabindex' => '2');
- $form['submit']['#attributes'] = array('tabindex' => '3');
+ $form['name']['#attributes']['tabindex'] = '1';
+ $form['pass']['#attributes']['tabindex'] = '2';
+ $form['submit']['#attributes']['tabindex'] = '3';
if (variable_get('login_with_mail', 0)) {
$form['#validate'] = array('logintoboggan_user_login_validate' => array()) + $form['#validate'];
- $form['name']['#title'] = t('Username or e-mail address');
- if (variable_get('drupal_authentication_service', FALSE) && count(user_auth_help_links()) > 0) {
- $form['name']['#description'] = t('Enter your %s username, e-mail address, or an ID from one of our affiliates: !a.', array('%s' => variable_get('site_name', 'local'), '!a' => implode(', ', user_auth_help_links())));
- }
+ // Use theme functions to print the username field's textual labels.
+ $form['name']['#title'] = theme_lt_username_title($form_id);
+ $form['name']['#description'] = theme_lt_username_description($form_id);
+ // Use theme functions to print the password field's textual labels.
+ $form['pass']['#title'] = theme_lt_password_title($form_id);
+ $form['pass']['#description'] = theme_lt_password_description($form_id);
}
if($GLOBALS['logintoboggan_denied'] == TRUE){
$form['#redirect'] = logintoboggan_destination();
@@ -170,7 +174,6 @@ function logintoboggan_form_alter($form_id, &$form) {
$form = _logintoboggan_toggleboggan($form);
}
}
-
break;
case 'user_register':
@@ -279,7 +282,7 @@ function logintoboggan_user_register_submit($form_id, $form_values) {
$login_url = variable_get('user_register', 1) == 1 ? logintoboggan_eml_validate_url($account) : user_pass_reset_url($account);
$variables = array('!username' => $name, '!site' => variable_get('site_name', 'drupal'), '!password' => $pass, '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen(_logintoboggan_protocol() .'://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '!login_url' => $login_url);
- //compose the appropriate user message--admin approvals don't require a validation email
+ // Compose the appropriate user message--admin approvals don't require a validation e-mail.
if($reg_pass_set && variable_get('user_register', 1) == 1) {
if ($pre_auth) {
$message = t('A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message.');
@@ -515,16 +518,6 @@ function logintoboggan_block($op = 'list', $delta = 0, $edit = array()) {
}
/**
- * Custom theme function for defining what gets displayed for logged in users.
- *
- */
-
-function theme_lt_loggedinblock() {
- global $user;
- return check_plain($user->name) .' | ' . l(t('Log out'), 'logout');
-}
-
-/**
* User login block with JavaScript to expand
*
* this should really be themed
@@ -696,12 +689,7 @@ function logintoboggan_denied() {
return $return;
}
-// Themeable function so that the access denied message can be customized
-function theme_lt_access_denied() {
- return t('You are not authorized to access this page.');
-}
-
-// slight rewrite of drupal_get_destination()
+// Slight rewrite of drupal_get_destination()
// with custom 403, drupal_get_destination() would return toboggan/denied
// which would show 'Access Denied' after login... what good is that!?
function logintoboggan_destination() {
@@ -955,4 +943,98 @@ function _logintoboggan_process_redirect($redirect, $account) {
function logintoboggan_flip_user_email_verification($form_id, $form_values) {
$value = $form_values['user_email_verification'] ? FALSE : TRUE;
variable_set('user_email_verification', $value);
-} \ No newline at end of file
+}
+
+/**
+ *
+ * THEME FUNCTIONS!
+ *
+ * You may override and change any of these custom HTML output functions
+ * by copy/pasting them into your template.php file, at which point you can
+ * customize anything, provided you are using the default phptemplate engine.
+ *
+ * For more info on overriding theme functions, see http://drupal.org/node/55126
+ */
+
+/**
+ * Theme the username title of the user login form
+ * and the user login block.
+ */
+function theme_lt_username_title($form_id) {
+ switch ($form_id) {
+ case 'user_login':
+ // Label text for the username field on the /user/login page.
+ return t('Username OR e-mail address');
+ break;
+
+ case 'user_login_block':
+ // Label text for the username field when shown in a block.
+ return t('Username OR e-mail');
+ break;
+ }
+}
+
+/**
+ * Theme the username description of the user login form
+ * and the user login block.
+ */
+function theme_lt_username_description($form_id) {
+ switch ($form_id) {
+ case 'user_login':
+ if (variable_get('drupal_authentication_service', FALSE) && count(user_auth_help_links()) > 0) {
+ // If drupal_authentication_service is enabled, this is
+ // the username field's description when shown on the /user/login page.
+ return t('Enter your %s username, e-mail address, or an ID from one of our affiliates: !a.', array('%s' => variable_get('site_name', 'local'), '!a' => implode(', ', user_auth_help_links())));
+ }
+ else {
+ // The username field's description when shown on the /user/login page.
+ return t('You may login with EITHER your assigned username OR your e-mail address.');
+ }
+ break;
+ case 'user_login_block':
+ return t('');
+ break;
+ }
+}
+
+/**
+ * Theme the password title of the user login form
+ * and the user login block.
+ */
+function theme_lt_password_title($form_id) {
+ // Label text for the password field.
+ return t('Password');
+}
+
+/**
+ * Theme the password description of the user login form
+ * and the user login block.
+ */
+function theme_lt_password_description($form_id) {
+ switch ($form_id) {
+ case 'user_login':
+ // The password field's description on the /user/login page.
+ return t('The password field is case sensitive.');
+ break;
+
+ case 'user_login_block':
+ // If showing the login form in a block, don't print any descriptive text.
+ return t('');
+ break;
+ }
+}
+
+/**
+ * Theme the Access Denied message.
+ */
+function theme_lt_access_denied() {
+ return t('You are not authorized to access this page.');
+}
+
+/**
+ * Theme the loggedinblock that shows for logged-in users.
+ */
+function theme_lt_loggedinblock(){
+ global $user;
+ return check_plain($user->name) .' | ' . l(t('Log out'), 'logout');
+}