Example #1
0
<?php

require_once './bb-load.php';
bb_repermalink();
// The magic happens here.
if ($self) {
    if (strpos($self, '.php') !== false) {
        require $self;
    } else {
        require BB_PATH . 'profile-base.php';
    }
    return;
}
$reg_time = bb_gmtstrtotime($user->user_registered);
$profile_info_keys = bb_get_profile_info_keys();
if (!isset($_GET['updated'])) {
    $updated = false;
} else {
    $updated = true;
}
do_action('bb_profile.php_pre_db', $user_id);
if (isset($user->is_bozo) && $user->is_bozo && $user->ID != bb_get_current_user_info('id') && !bb_current_user_can('moderate')) {
    $profile_info_keys = array();
}
$posts = bb_get_recent_user_replies($user_id);
$topics = get_recent_user_threads($user_id);
bb_load_template('profile.php', array('reg_time', 'profile_info_keys', 'updated', 'threads'), $user_id);
function get_profile_info_keys($context = null)
{
    bb_log_deprecated('function', __FUNCTION__, 'bb_get_profile_info_keys');
    return bb_get_profile_info_keys($context);
}
Example #3
0
    exit;
}
// Store the current user id
$bb_current_id = bb_get_current_user_info('id');
// I don't know how this would ever get triggered
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($bb_current_id, 'edit');
    nxt_redirect($sendto);
    exit;
}
// Set some low capabilities if the current user has none
if (!isset($user->capabilities)) {
    $user->capabilities = array('inactive' => true);
}
// Store the profile info keys
$profile_info_keys = bb_get_profile_info_keys('profile-edit');
// Store additional keys if the current user has access to them
if (bb_current_user_can('edit_users')) {
    $profile_admin_keys = bb_get_profile_admin_keys('profile-edit');
    $assignable_caps = bb_get_assignable_caps();
}
// Instantiate the error object
$errors = new nxt_Error();
if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) {
    $_POST = stripslashes_deep($_POST);
    bb_check_admin_referer('edit-profile_' . $user_id);
    // Fix the URL before sanitizing it
    $user_url = bb_fix_link($_POST['user_url']);
    // Sanitize the profile info keys and check for missing required data
    foreach ($profile_info_keys as $key => $label) {
        ${$key} = apply_filters('sanitize_profile_info', $_POST[$key], $key, $_POST[$key]);
function bb_profile_data_form($id = 0)
{
    global $errors;
    if (!($user = bb_get_user(bb_get_user_id($id)))) {
        return;
    }
    if (!bb_current_user_can('edit_user', $user->ID)) {
        return;
    }
    $error_codes = $errors->get_error_codes();
    $profile_info_keys = bb_get_profile_info_keys();
    $required = false;
    ?>
<table id="userinfo">
<?php 
    if (is_array($profile_info_keys)) {
        $bb_current_id = bb_get_current_user_info('id');
        foreach ($profile_info_keys as $key => $label) {
            if ($label[0]) {
                $class = 'form-field form-required required';
                $required = true;
            } else {
                $class = 'form-field';
            }
            $title = esc_attr($label[1]);
            $name = esc_attr($key);
            $type = isset($label[2]) ? esc_attr($label[2]) : 'text';
            if (!in_array($type, array('checkbox', 'file', 'hidden', 'image', 'password', 'radio', 'text'))) {
                $type = 'text';
            }
            $checked = false;
            if (in_array($key, $error_codes)) {
                $class .= ' form-invalid error';
                $data = $errors->get_error_data($key);
                if ('checkbox' == $type) {
                    if (isset($data['data'])) {
                        $checked = $data['data'];
                    } else {
                        $checked = $_POST[$key];
                    }
                    $value = $label[3];
                    $checked = $checked == $value;
                } else {
                    if (isset($data['data'])) {
                        $value = $data['data'];
                    } else {
                        $value = $_POST[$key];
                    }
                }
                $message = esc_html($errors->get_error_message($key));
                $message = "<em>{$message}</em>";
            } else {
                if ('checkbox' == $type) {
                    $checked = $user->{$key} == $label[3] || $label[4] == $label[3];
                    $value = $label[3];
                } else {
                    $value = isset($user->{$key}) ? $user->{$key} : '';
                }
                $message = '';
            }
            $checked = $checked ? ' checked="checked"' : '';
            $value = esc_attr($value);
            ?>

<tr class="<?php 
            echo $class;
            ?>
">
	<th scope="row">
		<label for="<?php 
            echo $name;
            ?>
"><?php 
            echo $title;
            ?>
</label>
		<?php 
            echo $message;
            ?>
	</th>
	<td>
<?php 
            if ($key == 'display_name') {
                ?>
		<select name="display_name" id="display_name">
<?php 
                $public_display = array();
                $public_display['display_displayname'] = $user->display_name;
                //$public_display['display_nickname'] = $user->nickname;
                $public_display['display_username'] = $user->user_login;
                if (isset($user->first_name)) {
                    $public_display['display_firstname'] = $user->first_name;
                    if (isset($user->last_name)) {
                        $public_display['display_firstlast'] = $user->first_name . ' ' . $user->last_name;
                        $public_display['display_lastfirst'] = $user->last_name . ' ' . $user->first_name;
                    }
                }
                if (isset($user->last_name)) {
                    $public_display['display_lastname'] = $user->last_name;
                }
                $public_display = array_unique(array_filter(array_map('trim', $public_display)));
                foreach ($public_display as $id => $item) {
                    ?>
			<option id="<?php 
                    echo esc_attr($id);
                    ?>
" value="<?php 
                    echo esc_attr($item);
                    ?>
"><?php 
                    echo esc_html($item);
                    ?>
</option>
<?php 
                }
                ?>
		</select>
<?php 
            } else {
                ?>
		<?php 
                if ('checkbox' == $type && isset($label[5])) {
                    echo '<label for="' . $name . '">';
                }
                ?>
		<input name="<?php 
                echo $name;
                ?>
" id="<?php 
                echo $name;
                ?>
" type="<?php 
                echo $type;
                ?>
"<?php 
                echo $checked;
                ?>
 value="<?php 
                echo $value;
                ?>
" />
		<?php 
                if ('checkbox' == $type && isset($label[5])) {
                    echo esc_html($label[5]) . '</label>';
                }
            }
            ?>
	</td>
</tr>

<?php 
        }
    }
    // $profile_info_keys; $profile_info_keys
    ?>

</table>

<?php 
    bb_nonce_field('edit-profile_' . $user->ID);
    if ($required) {
        ?>

<p class="required-message"><?php 
        _e('These items are <span class="required">required</span>.');
        ?>
</p>

<?php 
    }
    do_action('extra_profile_info', $user->ID);
}