function bb_manage_user_fields($edit_user = '') { global $nxt_roles, $nxt_users_object, $bbdb; // Cap checks $user_roles = $nxt_roles->role_names; $can_keep_gate = bb_current_user_can('keep_gate'); if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) { bb_check_admin_referer('user-manage'); // Instantiate required vars $_POST = stripslashes_deep($_POST); $create_user_errors = new nxt_Error(); // User login $trimmed_user_login = str_replace(' ', '', $_POST['user_login']); $user_login = sanitize_user($_POST['user_login'], true); $user_meta['first_name'] = $_POST['first_name']; $user_meta['last_name'] = $_POST['last_name']; $user_display_name = $_POST['display_name']; $user_email = $_POST['user_email']; $user_url = $_POST['user_url']; $user_meta['from'] = $_POST['from']; $user_meta['occ'] = $_POST['occ']; $user_meta['interest'] = $_POST['interest']; $user_role = $_POST['userrole']; $user_meta['throttle'] = $_POST['throttle']; $user_pass1 = $_POST['pass1']; $user_pass2 = $_POST['pass2']; $user_status = 0; $user_pass = false; $user_url = $user_url ? bb_fix_link($user_url) : ''; // Check user_login if (!isset($_GET['action']) && empty($user_login)) { $create_user_errors->add('user_login', __('Username is a required field.')); } else { if ($user_login !== $trimmed_user_login) { $create_user_errors->add('user_login', sprintf(__('%s is an invalid username. How\'s this one?'), esc_html($_POST['user_login']))); $user_login = $trimmed_user_login; } } // Check email if (isset($user_email) && empty($user_email)) { $create_user_errors->add('user_email', __('Email address is a required field.')); } // Password Sanity Check if ((!empty($user_pass1) || !empty($user_pass2)) && $user_pass1 !== $user_pass2) { $create_user_errors->add('pass', __('You must enter the same password twice.')); } elseif (!isset($_GET['action']) && (empty($user_pass1) && empty($user_pass2))) { $create_user_errors->add('pass', __('You must enter a password.')); } elseif (isset($_GET['action']) && (empty($user_pass1) && empty($user_pass2))) { $user_pass = ''; } else { $user_pass = $user_pass1; } // No errors if (!$create_user_errors->get_error_messages()) { // Create or udpate switch ($_POST['action']) { case 'create': $goback = bb_get_uri('bb-admin/users.php', array('created' => 'true'), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); $user = $nxt_users_object->new_user(compact('user_login', 'user_email', 'user_url', 'user_nicename', 'user_status', 'user_pass')); // Error handler if (is_nxt_error($user)) { bb_admin_notice($user); unset($goback); // Update additional user data } else { // Update caps bb_update_usermeta($user['ID'], $bbdb->prefix . 'capabilities', array($user_role => true)); // Update all user meta foreach ($user_meta as $key => $value) { bb_update_usermeta($user['ID'], $key, $value); } // Don't send email if empty if (!empty($user_pass)) { bb_send_pass($user['ID'], $user_pass); } do_action('bb_new_user', $user['ID'], $user_pass); } break; case 'update': $goback = bb_get_uri('bb-admin/users.php', array('updated' => 'true'), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); $user = $nxt_users_object->get_user($_GET['user_id'], array('output' => ARRAY_A)); bb_update_user($user['ID'], $user_email, $user_url, $user_display_name); // Don't change PW if empty if (!empty($user_pass)) { bb_update_user_password($user['ID'], $user_pass); } // Error handler if (is_nxt_error($user)) { bb_admin_notice($user); unset($goback); // Update additional user data } else { // Update caps bb_update_usermeta($user['ID'], $bbdb->prefix . 'capabilities', array($user_role => true)); // Update all user meta foreach ($user_meta as $key => $value) { bb_update_usermeta($user['ID'], $key, $value); } // Don't send email if empty if (!empty($user_pass)) { bb_send_pass($user['ID'], $user_pass); } do_action('bb_update_user', $user['ID'], $user_pass); } break; } // Redirect if (isset($goback) && !empty($goback)) { bb_safe_redirect($goback); } // Error handler } else { bb_admin_notice($create_user_errors); } } elseif (isset($_GET['action']) && $_GET['action'] == 'edit') { if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) { $disabled = true; // Get the user if (empty($edit_user)) { $edit_user = bb_get_user(bb_get_user_id($_GET['user_id'])); } // Instantiate required vars $user_login = $edit_user->user_login; $user_meta['first_name'] = $edit_user->first_name; $user_meta['last_name'] = $edit_user->last_name; $user_display_name = $edit_user->display_name; $user_email = $edit_user->user_email; $user_url = $edit_user->user_url; $user_meta['from'] = $edit_user->from; $user_meta['occ'] = $edit_user->occ; $user_meta['interest'] = $edit_user->interest; $user_role = array_search('true', $edit_user->capabilities); $user_meta['throttle'] = $edit_user->throttle; // Keymasters can't demote themselves if ($edit_user->ID == bb_get_current_user_info('id') && $can_keep_gate || isset($edit_user->capabilities) && is_array($edit_user->capabilities) && array_key_exists('keymaster', $edit_user->capabilities) && !$can_keep_gate) { $user_roles = array('keymaster' => $user_roles['keymaster']); } elseif (!$can_keep_gate) { unset($user_roles['keymaster']); } } } // Load password strength checker nxt_enqueue_script('password-strength-meter'); nxt_enqueue_script('profile-edit'); // Generate a few PW hints $some_pass_hints = ''; for ($l = 3; $l != 0; $l--) { $some_pass_hints .= '<p>' . bb_generate_password() . '</p>'; } // Create the user fields $user_fields = array('user_login' => array('title' => __('Username'), 'note' => __('Required! Unique identifier for new user.'), 'value' => $user_login, 'disabled' => $disabled), 'first_name' => array('title' => __('First Name'), 'value' => $user_meta['first_name']), 'last_name' => array('title' => __('Last Name'), 'value' => $user_meta['last_name']), 'display_name' => array('title' => __('Display Name'), 'value' => $user_display_name), 'user_email' => array('title' => __('Email'), 'note' => __('Required! Will be used for notifications and profile settings changes.'), 'value' => $user_email), 'user_url' => array('title' => __('Website'), 'class' => array('long', 'code'), 'note' => __('The full URL of user\'s homepage or blog.'), 'value' => $user_url), 'from' => array('title' => __('Location'), 'class' => array('long'), 'value' => $user_meta['from']), 'occ' => array('title' => __('Occupation'), 'class' => array('long'), 'value' => $user_meta['occ']), 'interest' => array('title' => __('Interests'), 'class' => array('long'), 'value' => $user_meta['interest']), 'userrole' => array('title' => __('User Role'), 'type' => 'select', 'options' => $user_roles, 'note' => __('Allow user the above privileges.'), 'value' => $user_role), 'pass1' => array('title' => __('New Password'), 'type' => 'password', 'class' => array('short', 'text', 'code'), 'note' => __('Hints: ') . $some_pass_hints, 'value' => $user_pass1), 'pass2' => array('title' => __('Repeat New Password'), 'type' => 'password', 'class' => array('short', 'text', 'code'), 'note' => __('If you ignore hints, remember: the password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'), 'value' => $user_pass2), 'email_pass' => array('title' => '', 'type' => 'checkbox', 'options' => array('1' => array('label' => __('Email the new password.'), 'attributes' => array('checked' => true)))), 'pass-strength-fake-input' => array('title' => __('Password Strength'), 'type' => 'hidden')); return apply_filters('bb_manage_user_fields', $user_fields); }
<?php require_once 'admin.php'; $edit_user = bb_get_user(bb_get_user_id($_GET['user_id'])); $user_fields = bb_manage_user_fields($edit_user); // Let it rip! // Header $bb_admin_body_class = 'bb-admin-user-manage'; bb_get_admin_header(); ?> <div class="wrap"> <h2><?php _e('Add a new user'); ?> </h2> <?php do_action('bb_admin_notices'); ?> <form class="settings" method="post" action=""> <fieldset> <?php foreach ($user_fields as $field => $args) { bb_option_form_element($field, $args); } ?> <noscript> <?php _e('Disabled (requires JavaScript)');
/** * Outputs the post form subscription checkbox. * * Checks if user is subscribed and outputs checkbox based on status. * * @since 1.1 */ function bb_user_subscribe_checkbox($args = null) { if (!bb_is_user_logged_in()) { return false; } $is_current = false; $defaults = array('tab' => false); $args = wp_parse_args($args, $defaults); $tab = $args['tab'] !== false ? ' tabindex="' . $args['tab'] . '"' : ''; $is_current = bb_get_user_id(get_post_author_id()) == bb_get_current_user_info('id'); // Change subscription checkbox message if current or moderating if (bb_is_topic_edit() && !$is_current) { $text = __('This user should be notified of follow-up posts via email'); } else { $text = __('Notify me of follow-up posts via email'); } echo ' <label for="subscription_checkbox"> <input name="subscription_checkbox" id="subscription_checkbox" type="checkbox" value="subscribe" ' . checked(true, bb_is_user_subscribed(), false) . $tab . ' /> ' . apply_filters('bb_user_subscribe_checkbox_label', $text, (bool) $is_current) . ' </label>'; }
function get_favorites_rss_link($id = 0, $context = 0) { $user = bb_get_user(bb_get_user_id($id)); if (!$context || !is_integer($context)) { $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED; } $rewrite = bb_get_option('mod_rewrite'); if ($rewrite) { if ($rewrite === 'slugs') { $column = 'user_nicename'; } else { $column = 'ID'; } $link = bb_get_uri('rss/profile/' . $user->{$column}, null, $context); } else { $link = bb_get_uri('rss.php', array('profile' => $user->ID), $context); } return apply_filters('get_favorites_rss_link', $link, $user->ID, $context); }
function li_foot_script() { //ob_start(); global $bb_current_user; $_linkedin_need_email_form = FALSE; $user =& $bb_current_user->data; if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE && bb_is_user_logged_in() && !li_check_if_email_set(bb_get_user_email($user->ID))) { //if ( li_get_prompt_status_by_userid(bb_get_user_id($user->ID))) { //echo $_SERVER['REQUEST_URI']; //echo $_SERVER['PHP_SELF']; //echo '/forum/profile/'.(get_user_name($user->ID).'/edit'); // make sure not show on profile edit tab as we want users to edit email if (strpos($_SERVER['REQUEST_URI'], '/forum/profile/' . (get_user_name($user->ID) . '/edit')) !== FALSE) { $_linkedin_need_email_form = FALSE; } else { $_linkedin_need_email_form = TRUE; } //} } ?> <div id="li-root"></div> <!-- begin LinkedIn Connect footer --> <?php if ($_linkedin_need_email_form) { /*<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <label for="user_email">Email</label> <input name="user_email" id="user_email" type="text" value=""> </br> <label for="user_email_validate">Enter Email Again</label> <input name="user_email_validate" id="user_email_validate" type="text" value=""> <p class="submit left"> <input type="submit" name="Defer" value="Skip"> </p> <p class="submit right"> <input type="submit" name="Submit" value="Update Email »"> </p> </form>*/ ?> <div id="linkedin_email_form"> <a id="linkedin_email_form_close" style="cursor: pointer">x</a> <br/> <p>LinkedIn won’t give us an email address.</p> <p>Please click <a id="linkedin_email_form_close_button" href="<?php profile_tab_link(bb_get_user_id($user->ID), 'edit'); ?> " style="color:white;">here</a> to update it in your profile.</p> <br/> <p>That allows you to receive answers to comments on your posts by email.</p> </div> <div id="backgroundPopup"></div> <?php } //ob_flush(); ?> <script> <?php if ($_linkedin_need_email_form) { ?> //SETTING UP OUR POPUP //0 means disabled; 1 means enabled; var popupStatus = 0; function loadPopup(){ if(popupStatus==0){ $("#backgroundPopup").css({ "opacity": "0.7" }); $("#backgroundPopup").fadeIn("slow"); $("#linkedin_email_form").fadeIn("slow"); popupStatus = 1; } } function disablePopup(){ if(popupStatus==1){ $("#backgroundPopup").fadeOut("slow"); $("#linkedin_email_form").fadeOut("slow"); popupStatus = 0; } } //centering popup function centerPopup(){ //request data for centering var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = $("#linkedin_email_form").height(); var popupWidth = $("#linkedin_email_form").width(); //centering $("#linkedin_email_form").css({ "position": "absolute", "top": windowHeight/2-popupHeight/2, "left": windowWidth/2-popupWidth/2 }); //only need force for IE6 $("#backgroundPopup").css({ "height": windowHeight }); } $(document).ready(function(){ centerPopup(); loadPopup(); $("#linkedin_email_form_close").click(function(){ disablePopup(); }); $("#linkedin_email_form_close_button").click(function(){ disablePopup(); }); $("#backgroundPopup").click(function(){ disablePopup(); }); }); <?php } ?> var addUrlParam = function(search, key, val){ var newParam = key + '=' + val, params = '?' + newParam; if (search) { params = search.replace(new RegExp('[\?&]' + key + '[^&]*'), '$1' + newParam); if (params === search) { params += '&' + newParam; } } return params; }; function li_login_action(){ document.location = document.location.pathname + addUrlParam(document.location.search, 'li_bb_connect', escape(document.location)); }; function li_revoke_action() { document.location = document.location.pathname + addUrlParam(document.location.search, 'li_bb_revoke', escape(document.location)); }; </script> <!-- end Linkedin Connect footer --> <?php }