Пример #1
0
function post_form_auto_add_checkbox()
{
    global $topic_id, $bb_current_user;
    if (is_user_favorite($bb_current_user->ID, $topic_id)) {
        return;
    } else {
        $checked = !empty($bb_current_user->data->auto_add_favorit) ? ' checked="checked"' : '';
        echo '
		<p>
			<input type="checkbox" name="add_to_my_favorites" id="add_to_my_favorites" value="1"' . $checked . ' />
			<label for="add_to_my_favorites" style="display:inline;">Add this question to my favorites </label>
			<span> (change your default <a href="' . attribute_escape(get_profile_tab_link($bb_current_user->ID, 'edit')) . '">here</a>)</span>
		</p>';
    }
}
Пример #2
0
"><?php 
    _e('Edit again &raquo;');
    ?>
</a></p>
</div>
<?php 
} elseif ($user_id == bb_get_current_user_info('id')) {
    ?>
<p>
<?php 
    _e('This is how your profile appears to a logged in member.');
    ?>

<?php 
    if (bb_current_user_can('edit_user', $user->ID)) {
        printf(__('You may <a href="%1$s">edit this information</a>.'), esc_attr(get_profile_tab_link($user_id, 'edit')));
    }
    ?>
</p>

<?php 
    if (bb_current_user_can('edit_favorites_of', $user->ID)) {
        ?>
<p><?php 
        printf(__('You can also <a href="%1$s">manage your favorites</a> and subscribe to your favorites&#8217; <a href="%2$s"><abbr title="Really Simple Syndication">RSS</abbr> feed</a>.'), esc_attr(get_favorites_link()), esc_attr(get_favorites_rss_link()));
        ?>
</p>
<?php 
    }
}
?>
Пример #3
0
require_once './bb-load.php';
// Redirect if we require SSL and it isn't
bb_ssl_redirect();
// Authenticate against the "logged_in" cookie
bb_auth('logged_in');
// Check that the current user can do this, if not kick them to the front page
if (!bb_current_user_can('edit_user', $user_id)) {
    $sendto = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
    nxt_redirect($sendto);
    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
Пример #4
0
function bb_repermalink()
{
    global $page;
    $location = bb_get_location();
    $uri = $_SERVER['REQUEST_URI'];
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    } else {
        $id = bb_get_path();
    }
    $_original_id = $id;
    do_action('pre_permalink', $id);
    $id = apply_filters('bb_repermalink', $id);
    switch ($location) {
        case 'front-page':
            $path = null;
            $querystring = null;
            if ($page > 1) {
                if (bb_get_option('mod_rewrite')) {
                    $path = 'page/' . $page;
                } else {
                    $querystring = array('page' => $page);
                }
            }
            $permalink = bb_get_uri($path, $querystring, BB_URI_CONTEXT_HEADER);
            $issue_404 = true;
            break;
        case 'forum-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $forum_id, $forum;
            $forum = bb_get_forum($id);
            $forum_id = $forum->forum_id;
            $permalink = get_forum_link($forum->forum_id, $page);
            break;
        case 'topic-edit-page':
        case 'topic-page':
            if (empty($id)) {
                $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
                break;
            }
            global $topic_id, $topic;
            $topic = get_topic($id);
            $topic_id = $topic->topic_id;
            $permalink = get_topic_link($topic->topic_id, $page);
            break;
        case 'profile-page':
            // This handles the admin side of the profile as well.
            global $user_id, $user, $profile_hooks, $self;
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
            } elseif (isset($_GET['username'])) {
                $id = $_GET['username'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            if (!$id) {
                $user = bb_get_current_user();
                // Attempt to go to the current users profile
            } else {
                if (bb_get_option('mod_rewrite') === 'slugs') {
                    if (!($user = bb_get_user_by_nicename($id))) {
                        $user = bb_get_user($id);
                    }
                } else {
                    if (!($user = bb_get_user($id))) {
                        $user = bb_get_user_by_nicename($id);
                    }
                }
            }
            if (!$user || 1 == $user->user_status && !bb_current_user_can('moderate')) {
                bb_die(__('User not found.'), '', 404);
            }
            $user_id = $user->ID;
            bb_global_profile_menu_structure();
            $valid = false;
            if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) {
                foreach ($profile_hooks as $valid_tab => $valid_file) {
                    if ($tab == $valid_tab) {
                        $valid = true;
                        $self = $valid_file;
                    }
                }
            }
            if ($valid) {
                $permalink = get_profile_tab_link($user->ID, $tab, $page);
            } else {
                $permalink = get_user_profile_link($user->ID, $page);
                unset($self, $tab);
            }
            break;
        case 'favorites-page':
            $permalink = get_favorites_link();
            break;
        case 'tag-page':
            // It's not an integer and tags.php pulls double duty.
            $id = isset($_GET['tag']) ? $_GET['tag'] : false;
            if (!$id || !bb_get_tag((string) $id)) {
                $permalink = bb_get_tag_page_link();
            } else {
                global $tag, $tag_name;
                $tag_name = $id;
                $tag = bb_get_tag((string) $id);
                $permalink = bb_get_tag_link(0, $page);
                // 0 => grabs $tag from global.
            }
            break;
        case 'view-page':
            // Not an integer
            if (isset($_GET['view'])) {
                $id = $_GET['view'];
            } else {
                $id = bb_get_path();
            }
            $_original_id = $id;
            global $view;
            $view = $id;
            $permalink = get_view_link($view, $page);
            break;
        default:
            return;
            break;
    }
    nxt_parse_str($_SERVER['QUERY_STRING'], $args);
    $args = urlencode_deep($args);
    if ($args) {
        $permalink = add_query_arg($args, $permalink);
        if (bb_get_option('mod_rewrite')) {
            $pretty_args = array('id', 'page', 'tag', 'tab', 'username');
            // these are already specified in the path
            if ($location == 'view-page') {
                $pretty_args[] = 'view';
            }
            foreach ($pretty_args as $pretty_arg) {
                $permalink = remove_query_arg($pretty_arg, $permalink);
            }
        }
    }
    $permalink = apply_filters('bb_repermalink_result', $permalink, $location);
    $domain = bb_get_option('domain');
    $domain = preg_replace('/^https?/', '', $domain);
    $check = preg_replace('|^.*' . trim($domain, ' /') . '|', '', $permalink, 1);
    $uri = rtrim($uri, " \t\n\r\v?");
    $uri = str_replace('/index.php', '/', $uri);
    global $bb_log;
    $bb_log->debug($uri, 'bb_repermalink() ' . __('REQUEST_URI'));
    $bb_log->debug($check, 'bb_repermalink() ' . __('should be'));
    $bb_log->debug($permalink, 'bb_repermalink() ' . __('full permalink'));
    $bb_log->debug(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null, 'bb_repermalink() ' . __('PATH_INFO'));
    if ($check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri)) {
        if ($issue_404 && rtrim($check, " \t\n\r\v/") !== rtrim($uri, " \t\n\r\v/")) {
            status_header(404);
            bb_load_template('404.php');
        } else {
            nxt_redirect($permalink);
        }
        exit;
    }
    do_action('post_permalink', $permalink);
}
function get_favorites_link($user_id = 0)
{
    if (!$user_id) {
        $user_id = bb_get_current_user_info('id');
    }
    return apply_filters('get_favorites_link', get_profile_tab_link($user_id, 'favorites'), $user_id);
}
Пример #6
0
    ?>
<div class="notice">
<p>Профиль обновлен. <a href="<?php 
    profile_tab_link($user_id, 'edit');
    ?>
">Редактировать снова &raquo;</a></p>
</div>
<?php 
} elseif ($user_id == bb_get_current_user_info('id')) {
    ?>
<p>
Это то, каким видит Ваш профиль пользователь, вошедший в систему.

<?php 
    if (bb_current_user_can('edit_user', $user->ID)) {
        printf('Вы можете <a href=\\"%1$s\\">редактировать эту информацию</a>.', attribute_escape(get_profile_tab_link($user_id, 'edit')));
    }
    ?>
</p>

<?php 
    if (bb_current_user_can('edit_favorites_of', $user->ID)) {
        ?>
<p><?php 
        printf('Вы также можете <a href="%1$s">управлять вашими закладками</a> и подписаться на ваши закладки по <a href="%2$s"><abbr title="Really Simple Syndication">RSS</abbr></a>.', attribute_escape(get_favorites_link()), attribute_escape(get_favorites_rss_link()));
        ?>
</p>
<?php 
    }
    ?>
<hr />
Пример #7
0
<?php

require_once './bb-load.php';
$user_id = bb_get_current_user_info('id');
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($user_id, 'edit');
    nxt_redirect($sendto);
    exit;
}
do_action($self . '_pre_head');
if (is_callable($self)) {
    bb_load_template('profile-base.php', array('self'), $user_id);
}
exit;
Пример #8
0
			<p><?php 
    _e('Profile updated');
    ?>
. <a href="<?php 
    profile_tab_link($user_id, 'edit');
    ?>
"><?php 
    _e('Edit again &raquo;');
    ?>
</a></p>
			</div>
			<?php 
} elseif ($user_id == bb_get_current_user_info('id')) {
    ?>
			<p><?php 
    printf(__('This is how your profile appears to a fellow logged in member, you may <a href="%1$s">edit this information</a>. You can also <a href="%2$s">manage your favorites</a> and subscribe to your favorites&#8217; <a href="%3$s"><abbr title="Really Simple Syndication">RSS</abbr> feed</a>'), attribute_escape(get_profile_tab_link($user_id, 'edit')), attribute_escape(get_favorites_link()), attribute_escape(get_favorites_rss_link()));
    ?>
</p>
			<?php 
}
?>

			<div class="post"><h4><?php 
_e('Recent Replies');
?>
</h4>
			<?php 
if ($posts) {
    ?>
			<ol>
			<?php 
Пример #9
0
function bb_user_row($user, $role = '', $email = false)
{
    $actions = "<a href='" . esc_attr(get_user_profile_link($user->ID)) . "'>" . __('View') . "</a>";
    $title = '';
    if (bb_current_user_can('edit_user', $user_id)) {
        $actions .= " | <a href='" . esc_attr(get_profile_tab_link($user->ID, 'edit')) . "'>" . __('Edit') . "</a>";
        $title = " title='" . esc_attr(sprintf(__('User ID: %d'), $user->ID)) . "'";
    }
    $r = "\t<tr id='user-{$user->ID}'" . get_alt_class("user-{$role}") . ">\n";
    $r .= "\t\t<td class=\"user\">" . bb_get_avatar($user->ID, 32) . "<span class=\"row-title\"><a href='" . get_user_profile_link($user->ID) . "'" . $title . ">" . get_user_name($user->ID) . "</a></span><div><span class=\"row-actions\">{$actions}</span>&nbsp;</div></td>\n";
    $r .= "\t\t<td><a href='" . get_user_profile_link($user->ID) . "'>" . get_user_display_name($user->ID) . "</a></td>\n";
    if ($email) {
        $email = bb_get_user_email($user->ID);
        $r .= "\t\t<td><a href='mailto:{$email}'>{$email}</a></td>\n";
    }
    $registered_time = bb_gmtstrtotime($user->user_registered);
    if ($registered_time < time() - 86400) {
        $time = date('Y/m/d\\<\\b\\r \\/\\>H:i:s', bb_offset_time($registered_time));
    } else {
        $time = sprintf(__('%s ago'), bb_since($registered_time));
    }
    $r .= "\t\t<td>" . $time . "</td>\n";
    if (!isset($user->capabilities) || !is_array($user->capabilities) || empty($user->capabilities)) {
        $role = array(__('Inactive (no role)'));
    } else {
        global $wp_roles;
        $_roles = $wp_roles->get_names();
        $role = array();
        foreach ($user->capabilities as $cap => $cap_set) {
            if (!$cap_set) {
                continue;
            }
            $role[] = $_roles[$cap];
        }
        if (!count($role)) {
            $role[] = __('None');
        }
    }
    $r .= "\t\t<td>" . join(', ', $role) . "</td>\n\t</tr>";
    return $r;
}
Пример #10
0
    }
    $fav = (int) $_GET['fav'];
    $topic_id = (int) $_GET['topic_id'];
    bb_check_admin_referer('toggle-favorite_' . $topic_id);
    $topic = get_topic($topic_id);
    if (!$topic || 0 != $topic->topic_status) {
        exit;
    }
    if ($fav) {
        bb_add_user_favorite($user_id, $topic_id);
    } else {
        bb_remove_user_favorite($user_id, $topic_id);
    }
    $ref = wp_get_referer();
    if (false !== strpos($ref, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))) {
        bb_safe_redirect($ref);
    } else {
        wp_redirect(get_topic_link($topic_id));
    }
    exit;
}
if (!bb_is_profile()) {
    $sendto = get_profile_tab_link($user->ID, 'favorites');
    wp_redirect($sendto);
    exit;
}
if ($topics = get_user_favorites($user->ID, true)) {
    bb_cache_last_posts($topics);
}
$favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
bb_load_template('favorites.php', array('favorites_total', 'self'));