# HG changeset patch # User Dan # Date 1189278388 14400 # Node ID a2b20a8324479d6f8347b8e7fa552b0924ead27b # Parent cfa4ae0830cff15f6c52920fa63ebf219e490fff Vastly improved UX for a login to an inactive account diff -r cfa4ae0830cf -r a2b20a832447 includes/sessions.php --- a/includes/sessions.php Sat Sep 08 14:04:15 2007 -0400 +++ b/includes/sessions.php Sat Sep 08 15:06:28 2007 -0400 @@ -392,10 +392,57 @@ $solution = 'Please check your e-mail; you should have been sent a message with instructions on how to activate your account. If you do not receive an e-mail from this site within 24 hours, please contact the site administration for further assistance.'; break; case 'admin': - $solution = 'This website has been configured so that all user accounts must be activated by the administrator before they can be used, so your account will most likely be activated the next time the one of the administrators visits the site.'; + $solution = 'This website has been configured so that all user accounts must be activated by the administrator before they can be used, so your account will most likely be activated the next time an administrator visits the site.'; break; } - die_semicritical('Account error', '
It appears that your user account has not yet been activated. '.$solution.'
'); + + // admin activation request opportunity + $q = $db->sql_query('SELECT 1 FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\' AND edit_summary=\'' . $db->escape($userdata['username']) . '\';'); + if ( !$q ) + $db->_die(); + + $can_request = ( $db->numrows() < 1 ); + $db->free_result(); + + if ( isset($_POST['logout']) ) + { + $this->sid = $_COOKIE['sid']; + $this->user_logged_in = true; + $this->user_id = intval($userdata['user_id']); + $this->username = $userdata['username']; + $this->auth_level = USER_LEVEL_MEMBER; + $this->user_level = USER_LEVEL_MEMBER; + $this->logout(); + redirect(scriptPath . '/', 'Logged out', 'You have successfully been logged out. All cookies cleared.', 4); + } + + if ( $can_request && !isset($_POST['activation_request']) ) + { + $form = 'If you are having trouble or did not receive the e-mail, you can request account activation from the administrators of this site.
+ '; + } + else + { + if ( $can_request && isset($_POST['activation_request']) ) + { + $this->admin_activation_request($userdata['username']); + $form = 'A request has just been sent to the administrators of this site. They will be able to activate your account or send you another activation e-mail if needed.
+ '; + } + else + { + $form = 'There is an active request in the administrators\' control panel for your account to be activated.
+ '; + } + } + + die_semicritical('Account error', 'It appears that your user account has not yet been activated. '.$solution.'
' . $form); } $this->sid = $_COOKIE['sid'];