/** * Handles the logic to display the pseudonym admin page to a student. * * @access private * @since 0.1 */ public function _admin_page() { // Get information on the user and their blog URL $current_user = nxt_get_current_user(); $username = $current_user->user_login; $blog_url = home_url(); // Validate the pseudonym $username_valid = true; if ($_POST) { // Apply the pseudonym to the user and their blog if the username // does not conflict with an existing user or blog check_admin_referer($this->get_uid()); $username = ClassBlogs_Utils::sanitize_user_input($_POST['new_username']); $username_valid = $this->_validate_username($username); if ($username_valid) { global $blog_id; $current_user = nxt_get_current_user(); $this->_apply_pseudonym($current_user->ID, $blog_id, $username); // Display the updated information to the user $blog_url = home_url(); $message = array(__('You successfully changed your username. Your new user information is as follows.', 'classblogs'), '<p>'); $message[] = sprintf('<strong>%s</strong><br />%s<br /><br />', __('Username', 'classblogs'), esc_html($username)); if (ClassBlogs_Utils::is_multisite()) { $message[] = sprintf('<strong>%s</strong><br />%s<br /><br />', __('Blog URL', 'classblogs'), sprintf('<a href="%1$s">%1$s</a>', esc_url($blog_url))); } $message[] = '</p>'; ClassBlogs_Admin::show_admin_message(implode("\n", $message)); } else { if (!$username) { $error = __('You cannot have a blank username.', 'classblogs'); } else { $error = sprintf(__('The username %s is invalid or conflicts with another user or blog. Please choose a different username.', 'classblogs'), '<strong>' . esc_html($username) . '</strong>'); } ClassBlogs_Admin::show_admin_error($error); } } ?> <div class="wrap"> <div id="icon-users" class="icon32"></div> <h2><?php _e('Change Username', 'classblogs'); ?> </h2> <p id="student-pseudonym-instructions"> <?php _e('If you have already changed your display name but still wish for there to be no trace of your actual identity on the blog, you can use this page to change the username that you use to log in to the blog.', 'classblogs'); ?> </p> <form method="post" action="" id="cb-username-form"> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('New Username', 'classblogs'); ?> </th> <td> <input type="text" name="new_username" id="new-username" /><br /> <label for="new-username"><?php _e('Changing this will change the username that you use to access your blog and the URL at which it can be found.', 'classblogs'); ?> </label> <hr /> <label for="new-username"> <?php printf(__('Your current username is %s', 'classblogs'), '<strong>' . esc_html($current_user->user_login) . '</strong>'); ?> </label><br /> <?php if (ClassBlogs_Utils::is_multisite()) { ?> <label for="new-username"> <?php printf(__('Your current blog URL is %s', 'classblogs'), sprintf('<a href="%1$s">%1$s</a>', esc_url($blog_url))); ?> </label> <?php } ?> </td> </tr> </table> <?php nxt_nonce_field($this->get_uid()); ?> <p class="submit"><input class="button-primary" type="submit" name="Submit" value="<?php _e('Change Username', 'classblogs'); ?> " /></p> <strong style="color: #a00">You will only be able to change your username once</strong> </form> <script type="text/javascript"> jQuery("#cb-username-form").submit(function() { return confirm( "<?php _e('You can only change your username once. Are you sure that you wish to change it now?', 'classblogs'); ?> " ); }); </script> </div> <?php }