Esempio n. 1
0
/**
 * bb_add_topic_tag() - Adds a multiple tags to a topic.
 *
 * @param int $topic_id
 * @param array|string $tags The (unsanitized) full names of the tag to be added.  CSV or array.
 * @return array|bool The TT_IDs of the new bb_topic_tags or false on failure
 */
function bb_add_topic_tags($topic_id, $tags)
{
    global $wp_taxonomy_object;
    $topic_id = (int) $topic_id;
    if (!($topic = get_topic($topic_id))) {
        return false;
    }
    if (!bb_current_user_can('add_tag_to', $topic_id)) {
        return false;
    }
    $user_id = bb_get_current_user_info('id');
    $tags = apply_filters('bb_add_topic_tags', $tags, $topic_id);
    if (!is_array($tags)) {
        $tags = explode(',', (string) $tags);
    }
    $tt_ids = $wp_taxonomy_object->set_object_terms($topic->topic_id, $tags, 'bb_topic_tag', array('append' => true, 'user_id' => $user_id));
    if (is_array($tt_ids)) {
        global $bbdb;
        $bbdb->query($bbdb->prepare("UPDATE {$bbdb->topics} SET tag_count = tag_count + %d WHERE topic_id = %d", count($tt_ids), $topic->topic_id));
        wp_cache_delete($topic->topic_id, 'bb_topic');
        foreach ($tt_ids as $tt_id) {
            do_action('bb_tag_added', $tt_id, $user_id, $topic_id);
        }
        return $tt_ids;
    }
    return false;
}
 function is_current_user($user)
 {
     $id = bb_get_current_user_info('id');
     if ($id == $user['id']) {
         return TRUE;
     }
     return FALSE;
 }
Esempio n. 3
0
function bb_block_current_user()
{
    global $bbdb;
    if ($id = bb_get_current_user_info('id')) {
        bb_update_usermeta($id, $bbdb->prefix . 'been_blocked', 1);
    }
    // Just for logging.
    bb_die(__("You've been blocked.  If you think a mistake has been made, contact this site's administrator."));
}
Esempio n. 4
0
function rdd_check_params()
{
    $result['ok'] = true;
    $result['error_msg'] = '';
    // Comprobar que tenemos todos los parámetros
    if (isset($_GET['uid']) && is_numeric($_GET['uid'])) {
        $uid = (int) $_GET['uid'];
        $result['uid'] = $uid;
    } else {
        $result['ok'] = false;
        $result['error_msg'] = 'No se ha indicado el usuario';
        return $result;
    }
    if (isset($_GET['lat']) && is_numeric($_GET['lat'])) {
        $lat = (double) $_GET['lat'];
        $result['lat'] = $lat;
    } else {
        $result['ok'] = false;
        $result['error_msg'] = 'No se ha indicado la latitud';
        return $result;
    }
    if (isset($_GET['lon']) && is_numeric($_GET['lon'])) {
        $lon = (double) $_GET['lon'];
        $result['lon'] = $lon;
    } else {
        $result['ok'] = false;
        $result['error_msg'] = 'No se ha indicado la longitud';
        return $result;
    }
    // Comprobar que el usuario logueado en bbpress es el mismo que queremos
    // modificar
    $user_id = bb_get_current_user_info('id');
    if ($user_id != $uid) {
        $result['ok'] = false;
        $result['error_msg'] = 'Sólo se puede modificar la información del usuario actual';
        return $result;
    }
    return $result;
}
function bb_insert_topic($args = null)
{
    global $bbdb;
    if (!($args = wp_parse_args($args))) {
        return false;
    }
    $fields = array_keys($args);
    if (isset($args['topic_id']) && false !== $args['topic_id']) {
        $update = true;
        if (!($topic_id = (int) get_topic_id($args['topic_id']))) {
            return false;
        }
        // Get from db, not cache.  Good idea?  Prevents trying to update meta_key names in the topic table (get_topic() returns appended topic obj)
        $topic = $bbdb->get_row($bbdb->prepare("SELECT * FROM {$bbdb->topics} WHERE topic_id = %d", $topic_id));
        $defaults = get_object_vars($topic);
        unset($defaults['topic_id']);
        // Only update the args we passed
        $fields = array_intersect($fields, array_keys($defaults));
        if (in_array('topic_poster', $fields)) {
            $fields[] = 'topic_poster_name';
        }
        if (in_array('topic_last_poster', $fields)) {
            $fields[] = 'topic_last_poster_name';
        }
    } else {
        $topic_id = false;
        $update = false;
        $now = bb_current_time('mysql');
        $current_user_id = bb_get_current_user_info('id');
        $defaults = array('topic_title' => '', 'topic_slug' => '', 'topic_poster' => $current_user_id, 'topic_poster_name' => '', 'topic_last_poster' => $current_user_id, 'topic_last_poster_name' => '', 'topic_start_time' => $now, 'topic_time' => $now, 'topic_open' => 1, 'forum_id' => 0);
        // Insert all args
        $fields = array_keys($defaults);
    }
    $defaults['tags'] = false;
    // accepts array or comma delimited string
    extract(wp_parse_args($args, $defaults));
    unset($defaults['tags']);
    if (!($forum = bb_get_forum($forum_id))) {
        return false;
    }
    $forum_id = (int) $forum->forum_id;
    if (!($user = bb_get_user($topic_poster))) {
        $user = bb_get_user($topic_poster_name, array('by' => 'login'));
    }
    if (!empty($user)) {
        $topic_poster = $user->ID;
        $topic_poster_name = $user->user_login;
    }
    if (!($last_user = bb_get_user($topic_last_poster))) {
        $last_user = bb_get_user($topic_last_poster_name, array('by' => 'login'));
    }
    if (!empty($last_user)) {
        $topic_last_poster = $last_user->ID;
        $topic_last_poster_name = $last_user->user_login;
    }
    if (in_array('topic_title', $fields)) {
        $topic_title = apply_filters('pre_topic_title', $topic_title, $topic_id);
        if (strlen($topic_title) < 1) {
            return false;
        }
    }
    if (in_array('topic_slug', $fields)) {
        $slug_sql = $update ? "SELECT topic_slug FROM {$bbdb->topics} WHERE topic_slug = %s AND topic_id != %d" : "SELECT topic_slug FROM {$bbdb->topics} WHERE topic_slug = %s";
        $topic_slug = $_topic_slug = bb_slug_sanitize($topic_slug ? $topic_slug : wp_specialchars_decode($topic_title, ENT_QUOTES));
        if (strlen($_topic_slug) < 1) {
            $topic_slug = $_topic_slug = '0';
        }
        while (is_numeric($topic_slug) || ($existing_slug = $bbdb->get_var($bbdb->prepare($slug_sql, $topic_slug, $topic_id)))) {
            $topic_slug = bb_slug_increment($_topic_slug, $existing_slug);
        }
    }
    if ($update) {
        $bbdb->update($bbdb->topics, compact($fields), compact('topic_id'));
        wp_cache_delete($topic_id, 'bb_topic');
        if (in_array('topic_slug', $fields)) {
            wp_cache_delete($topic->topic_slug, 'bb_topic_slug');
        }
        wp_cache_flush('bb_query');
        wp_cache_flush('bb_cache_posts_post_ids');
        do_action('bb_update_topic', $topic_id);
    } else {
        $bbdb->insert($bbdb->topics, compact($fields));
        $topic_id = $bbdb->insert_id;
        $bbdb->query($bbdb->prepare("UPDATE {$bbdb->forums} SET topics = topics + 1 WHERE forum_id = %d", $forum_id));
        wp_cache_delete($forum_id, 'bb_forum');
        wp_cache_flush('bb_forums');
        wp_cache_flush('bb_query');
        wp_cache_flush('bb_cache_posts_post_ids');
        do_action('bb_new_topic', $topic_id);
    }
    if (!empty($tags)) {
        bb_add_topic_tags($topic_id, $tags);
    }
    do_action('bb_insert_topic', $topic_id, $args, compact(array_keys($args)));
    // topic_id, what was passed, what was used
    return $topic_id;
}
Esempio n. 6
0
<p class="login">
	<?php 
printf(__('Welcome, %1$s'), bb_get_profile_link(bb_get_current_user_info('name')));
?>
	<?php 
bb_admin_link('before= | ');
?>
	| <?php 
bb_logout_link();
?>
</p>
Esempio n. 7
0
<ul class="topicmeta">
	<li><?php 
    printf(__('Started %1$s ago by %2$s'), get_topic_start_time(), get_topic_author());
    ?>
</li>
<?php 
    if (1 < get_topic_posts()) {
        ?>
	<li><?php 
        printf(__('<a href="%1$s">Latest reply</a> from %2$s'), attribute_escape(get_topic_last_post_link()), get_topic_last_poster());
        ?>
</li>
<?php 
    }
    if (bb_is_user_logged_in()) {
        $class = 0 === is_user_favorite(bb_get_current_user_info('id')) ? ' class="is-not-favorite"' : '';
        ?>
	<li<?php 
        echo $class;
        ?>
 id="favorite-toggle"><?php 
        user_favorites_link();
        ?>
</li>
<?php 
    }
    do_action('topicmeta');
    ?>
</ul>
</div>
Esempio n. 8
0
function bb_can_access_tab($profile_tab, $viewer_id, $owner_id)
{
    global $bb_current_user;
    $viewer_id = (int) $viewer_id;
    $owner_id = (int) $owner_id;
    if ($viewer_id == bb_get_current_user_info('id')) {
        $viewer =& $bb_current_user;
    } else {
        $viewer = new BP_User($viewer_id);
    }
    if (!$viewer) {
        return '' === $profile_tab[2];
    }
    if ($owner_id == $viewer_id) {
        if ('' === $profile_tab[1]) {
            return true;
        } else {
            return $viewer->has_cap($profile_tab[1]);
        }
    } else {
        if ('' === $profile_tab[2]) {
            return true;
        } else {
            return $viewer->has_cap($profile_tab[2]);
        }
    }
}
/**
 * Load localized script just in time for MCE.
 *
 * These localizations require information that may not be loaded even by init.
 */
function bb_just_in_time_script_localization()
{
    wp_localize_script('topic', 'bbTopicJS', array('currentUserId' => bb_get_current_user_info('id'), 'topicId' => get_topic_id(), 'favoritesLink' => get_favorites_link(), 'isFav' => (int) is_user_favorite(bb_get_current_user_info('id')), 'confirmPostDelete' => __("Are you sure you want to delete this post?"), 'confirmPostUnDelete' => __("Are you sure you want to undelete this post?"), 'favLinkYes' => __('favorites'), 'favLinkNo' => __('?'), 'favYes' => __('This topic is one of your %favLinkYes% [%favDel%]'), 'favNo' => __('%favAdd% (%favLinkNo%)'), 'favDel' => __('&times;'), 'favAdd' => __('Add this topic to your favorites')));
}
Esempio n. 10
0
}
bb_repermalink();
if (!$topic) {
    bb_die(__('Topic not found.'));
}
if ($view_deleted) {
    add_filter('get_thread_where', create_function('', 'return "p.topic_id = ' . $topic_id . '";'));
    add_filter('get_thread_post_ids', create_function('', 'return "p.topic_id = ' . $topic_id . '";'));
    add_filter('post_edit_uri', 'bb_make_link_view_all');
}
$bb_db_override = false;
do_action('bb_topic.php_pre_db', $topic_id);
if (!$bb_db_override) {
    $posts = get_thread($topic_id, $page);
    $forum = bb_get_forum($topic->forum_id);
    $tags = bb_get_topic_tags($topic_id);
    if ($tags && ($bb_current_id = bb_get_current_user_info('id'))) {
        $user_tags = bb_get_user_tags($topic_id, $bb_current_id);
        $other_tags = bb_get_other_tags($topic_id, $bb_current_id);
        $public_tags = bb_get_public_tags($topic_id);
    } elseif (is_array($tags)) {
        $user_tags = false;
        $other_tags = bb_get_public_tags($topic_id);
        $public_tags =& $other_tags;
    } else {
        $user_tags = $other_tags = $public_tags = false;
    }
    $list_start = ($page - 1) * bb_get_option('page_topics') + 1;
    bb_post_author_cache($posts);
}
bb_load_template('topic.php', array('bb_db_override', 'user_tags', 'other_tags', 'list_start'), $topic_id);
function bb_insert_post($args = null)
{
    global $bbdb, $bb_current_user;
    if (!($args = wp_parse_args($args))) {
        return false;
    }
    $fields = array_keys($args);
    if (isset($args['post_id']) && false !== $args['post_id']) {
        $update = true;
        if (!($post_id = (int) get_post_id($args['post_id']))) {
            return false;
        }
        // Get from db, not cache.  Good idea?
        $post = $bbdb->get_row($bbdb->prepare("SELECT * FROM {$bbdb->posts} WHERE post_id = %d", $post_id));
        $defaults = get_object_vars($post);
        unset($defaults['post_id']);
        // Only update the args we passed
        $fields = array_intersect($fields, array_keys($defaults));
        if (in_array('topic_id', $fields)) {
            $fields[] = 'forum_id';
        }
        // No need to run filters if these aren't changing
        // bb_new_post() and bb_update_post() will always run filters
        $run_filters = (bool) array_intersect(array('post_status', 'post_text'), $fields);
    } else {
        $post_id = false;
        $update = false;
        $now = bb_current_time('mysql');
        $current_user_id = bb_get_current_user_info('id');
        $ip_address = $_SERVER['REMOTE_ADDR'];
        $defaults = array('topic_id' => 0, 'post_text' => '', 'post_time' => $now, 'poster_id' => $current_user_id, 'poster_ip' => $ip_address, 'post_status' => 0, 'post_position' => false);
        // Insert all args
        $fields = array_keys($defaults);
        $fields[] = 'forum_id';
        $run_filters = true;
    }
    $defaults['throttle'] = true;
    extract(wp_parse_args($args, $defaults));
    if (!($topic = get_topic($topic_id))) {
        return false;
    }
    if (!($user = bb_get_user($poster_id))) {
        return false;
    }
    $topic_id = (int) $topic->topic_id;
    $forum_id = (int) $topic->forum_id;
    if ($run_filters && !($post_text = apply_filters('pre_post', $post_text, $post_id, $topic_id))) {
        return false;
    }
    if ($update) {
        // Don't change post_status with this function.  Use bb_delete_post().
        $post_status = $post->post_status;
    }
    if ($run_filters) {
        $post_status = (int) apply_filters('pre_post_status', $post_status, $post_id, $topic_id);
    }
    if (false === $post_position) {
        $post_position = $topic_posts = intval(0 == $post_status ? $topic->topic_posts + 1 : $topic->topic_posts);
    }
    unset($defaults['throttle']);
    if ($update) {
        $bbdb->update($bbdb->posts, compact($fields), compact('post_id'));
        wp_cache_delete($post_id, 'bb_post');
    } else {
        $bbdb->insert($bbdb->posts, compact($fields));
        $post_id = $topic_last_post_id = (int) $bbdb->insert_id;
        if (0 == $post_status) {
            $topic_time = $post_time;
            $topic_last_poster = $poster_id;
            $topic_last_poster_name = $user->user_login;
            $bbdb->query($bbdb->prepare("UPDATE {$bbdb->forums} SET posts = posts + 1 WHERE forum_id = %d;", $topic->forum_id));
            $bbdb->update($bbdb->topics, compact('topic_time', 'topic_last_poster', 'topic_last_poster_name', 'topic_last_post_id', 'topic_posts'), compact('topic_id'));
            $query = new BB_Query('post', array('post_author_id' => $poster_id, 'topic_id' => $topic_id, 'post_id' => "-{$post_id}"));
            if (!$query->results) {
                bb_update_usermeta($poster_id, $bbdb->prefix . 'topics_replied', $user->topics_replied + 1);
            }
        } else {
            bb_update_topicmeta($topic->topic_id, 'deleted_posts', isset($topic->deleted_posts) ? $topic->deleted_posts + 1 : 1);
        }
    }
    bb_update_topic_voices($topic_id);
    if ($throttle && !bb_current_user_can('throttle')) {
        bb_update_usermeta($poster_id, 'last_posted', time());
    }
    wp_cache_delete($topic_id, 'bb_topic');
    wp_cache_delete($topic_id, 'bb_thread');
    wp_cache_delete($forum_id, 'bb_forum');
    wp_cache_flush('bb_forums');
    wp_cache_flush('bb_query');
    wp_cache_flush('bb_cache_posts_post_ids');
    if ($update) {
        // fire actions after cache is flushed
        do_action('bb_update_post', $post_id);
    } else {
        do_action('bb_new_post', $post_id);
    }
    do_action('bb_insert_post', $post_id, $args, compact(array_keys($args)));
    // post_id, what was passed, what was used
    if (bb_get_option('enable_pingback')) {
        bb_update_postmeta($post_id, 'pingback_queued', '');
        wp_schedule_single_event(time(), 'do_pingbacks');
    }
    return $post_id;
}
Esempio n. 12
0
<div id="header">
    <h1><a href="<?php 
bb_uri();
?>
"><?php 
bb_option('name');
?>
</a></h1>
</div>

<div id="content">

<ul id="greeting">
<?php 
if (bb_is_user_logged_in()) {
    if ($user = bb_get_current_user_info()) {
        if ($avatar = bb_get_avatar($user->ID, '48')) {
            ?>
<li id="avatar"><?php 
            echo $avatar;
            ?>
</li>
<?php 
        }
        ?>
<li id="message"><?php 
        printf(__("Hello, %s!"), $user->display_name);
        ?>
</li>
<li id="logout"><?php 
        bb_logout_link();
Esempio n. 13
0
    ?>
;
		var uriBase = '<?php 
    bb_option('uri');
    ?>
';
		var tagLinkBase = '<?php 
    bb_tag_link_base();
    ?>
';
		var favoritesLink = '<?php 
    favorites_link();
    ?>
'; 
		var isFav = <?php 
    if (false === ($is_fav = is_user_favorite(bb_get_current_user_info('id')))) {
        echo "'no'";
    } else {
        echo $is_fav;
    }
    ?>
;
	</script>
	
	<?php 
    wp_enqueue_script('topic');
}
?>

	<?php 
bb_head();
Esempio n. 14
0
function li_add_extra_profile_field()
{
    global $li_attr;
    if (bb_is_user_logged_in() && $_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
        $me = get_li_profile();
        if (!$me) {
            bb_die("Linkedin Connect failed");
            exit;
        }
        $li_id = trim($me->{$li_attr}['id']);
        if (!$li_id) {
            bb_die("LinkedIn Connect failed, no user id found.");
            exit;
        }
        $bb_current_id = bb_get_current_user_info('id');
        if (li_get_userid_by_linkedin_id($li_id) == $bb_current_id) {
            ?>
			<div style="margin:10px;padding:10px;background-color:#E6FFFF;">
			<div>Please update your email address above so you can receive forum comments and answers.  </div>
			<div>You can revoke your LinkedIn authorisation by clicking <a href="#" onclick="javascript: li_revoke_action(); return false;">Revoke</a></div>
			<div>You can log in with LinkedIn to re-authorise this account.</div>

			</div>
		<?php 
        }
    }
}
Esempio n. 15
0
function nospamuser_maybe_set_user_ip_field()
{
    if (bb_is_user_logged_in() && !bb_get_usermeta(bb_get_current_user_info('ID'), 'nospamuser_ip')) {
        nospamuser_set_user_ip_field(bb_get_current_user_info('ID'));
    }
}
/**
 * Custom insert post function so that we could do what we need
 *
 * All counting functions have been removed from here, recount should be done
 * after running this script.
 *
 * @param mixed $args
 * @return int|bool New post ID if post was created, otherwise false
 */
function w2bc_insert_post($args = null)
{
    global $bbdb, $bb_current_user, $bb;
    if (!($args = wp_parse_args($args))) {
        return false;
    }
    $fields = array_keys($args);
    $defaults = array('topic_id' => 0, 'post_text' => '', 'post_time' => bb_current_time('mysql'), 'poster_id' => bb_get_current_user_info('id'), 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, 'post_position' => false);
    // Insert all args
    $fields = array_keys($defaults);
    $fields[] = 'forum_id';
    extract(wp_parse_args($args, $defaults));
    if (!($topic = get_topic($topic_id))) {
        return false;
    }
    $topic_id = (int) $topic->topic_id;
    $forum_id = (int) $topic->forum_id;
    if (false === $post_position) {
        $post_position = $topic_posts = intval(0 == $post_status ? $topic->topic_posts + 1 : $topic->topic_posts);
    }
    $bbdb->insert($bbdb->posts, compact($fields));
    $post_id = $topic_last_post_id = (int) $bbdb->insert_id;
    // if anonymous posting, save user data as meta data
    if (!$user) {
        if ($post_author) {
            bb_update_meta($post_id, 'post_author', $post_author, 'post');
        }
        // Atleast this should be there
        if ($post_email) {
            bb_update_meta($post_id, 'post_email', $post_email, 'post');
        }
        if ($post_url) {
            bb_update_meta($post_id, 'post_url', $post_url, 'post');
        }
    }
    $topic_time = $post_time;
    $topic_last_poster = !bb_is_user_logged_in() && !bb_is_login_required() ? -1 : $poster_id;
    $topic_last_poster_name = !bb_is_user_logged_in() && !bb_is_login_required() ? $post_author : $user->user_login;
    $bbdb->update($bbdb->topics, compact('topic_time', 'topic_last_poster', 'topic_last_poster_name', 'topic_last_post_id', 'topic_posts'), compact('topic_id'));
    wp_cache_delete($topic_id, 'bb_topic');
    wp_cache_delete($topic_id, 'bb_thread');
    wp_cache_delete($forum_id, 'bb_forum');
    wp_cache_flush('bb_forums');
    wp_cache_flush('bb_query');
    wp_cache_flush('bb_cache_posts_post_ids');
    if (bb_get_option('enable_pingback')) {
        bb_update_postmeta($post_id, 'pingback_queued', '');
        wp_schedule_single_event(time(), 'do_pingbacks');
    }
    return $post_id;
}
Esempio n. 17
0
function bb_bozo_get_topic_posts($topic_posts)
{
    global $topic;
    if (bb_current_user_is_bozo($topic->topic_id)) {
        $topic_posts += $topic->bozos[bb_get_current_user_info('id')];
    }
    return $topic_posts;
}
Esempio n. 18
0
  })();

</script>

</head>
<body id="<?php 
bb_location();
?>
">
	<div class="container prepend-top append-bottom">
		<div id="util-login">
		<?php 
if (!bb_is_user_logged_in()) {
    printf(__('<a href="%2$s">Log in</a> | <a href="%1$s">Register</a>'), bb_get_uri('register.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS), bb_get_uri('bb-login.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS));
} else {
    printf(__('Logged in as %1$s'), bb_get_profile_link(bb_get_current_user_info('name')));
    echo ' | ';
    if ($bb_current_user->has_cap('administrate') || $bb_current_user->has_cap('moderate')) {
        bb_admin_link();
        echo ' | ';
    }
    bb_logout_link();
}
?>
		</div>
		<div id="header" class="prepend-6 span-18">
			<a id="ach-logo" href="http://www.ach.org">ACH</a>
			<h1><a href="<?php 
bb_uri();
?>
"><?php 
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);
}
Esempio n. 20
0
/**
 * Updates user's subscription status in database.
 *
 * Gets user's new subscription status for topic and
 * adds new status to database.
 *
 * @since 1.1
 *
 * @param int $topic_id ID of topic for subscription
 * @param string $new_status New subscription status
 * @param int $user_id Optional. ID of user for subscription
 */
function bb_subscription_management($topic_id, $new_status, $user_id = '')
{
    global $bbdb, $nxt_taxonomy_object;
    $topic = get_topic($topic_id);
    if (!$user_id) {
        $user_id = bb_get_current_user_info('id');
    }
    do_action('bb_subscripton_management', $topic_id, $new_status, $user_id);
    switch ($new_status) {
        case 'add':
            $tt_ids = $nxt_taxonomy_object->set_object_terms($user_id, 'topic-' . $topic->topic_id, 'bb_subscribe', array('append' => true, 'user_id' => $user_id));
            break;
        case 'remove':
            // I hate this with the passion of a thousand suns
            $term_id = $bbdb->get_var("SELECT term_id FROM {$bbdb->terms} WHERE slug = 'topic-{$topic->topic_id}'");
            $term_taxonomy_id = $bbdb->get_var("SELECT term_taxonomy_id FROM {$bbdb->term_taxonomy} WHERE term_id = {$term_id} AND taxonomy = 'bb_subscribe'");
            $bbdb->query("DELETE FROM {$bbdb->term_relationships} WHERE object_id = {$user_id} AND term_taxonomy_id = {$term_taxonomy_id}");
            $bbdb->query("DELETE FROM {$bbdb->term_taxonomy} WHERE term_id = {$term_id} AND taxonomy = 'bb_subscribe'");
            break;
    }
}
Esempio n. 21
0
function bb_ksd_check_profile($user_id)
{
    global $bb_current_user, $user_obj;
    $bb_current_id = bb_get_current_user_info('id');
    bb_set_current_user($user_id);
    if ($bb_current_id && $bb_current_id != $user_id) {
        if ($user_obj->data->is_bozo && !$bb_current_user->data->is_bozo) {
            bb_ksd_submit($user_id, 'hammer');
        }
        if (!$user_obj->data->is_bozo && $bb_current_user->data->is_bozo) {
            bb_ksd_submit($user_id, 'spammer');
        }
    } else {
        $response = bb_ksd_submit($bb_current_user->data->occ . ' ' . $bb_current_user->data->interests);
        if ('true' == $response[1] && function_exists('bb_bozon')) {
            bb_bozon(bb_get_current_user_info('id'));
        }
    }
    bb_set_current_user((int) $bb_current_id);
}
Esempio n. 22
0
		//]]>
	</script>
	<div id="bbWrap">
		<div id="bbContent">
			<div id="bbHead">
				<h1><a href="<?php 
bb_uri();
?>
"><span><?php 
bb_option('name');
?>
</span> <em><?php 
_e('Visit Site');
?>
</em></a></h1>
				<div id="bbUserInfo">
					<p>
						<?php 
printf(__('Howdy, %1$s'), bb_get_profile_link(array('text' => bb_get_current_user_info('name'))));
?>
						| <?php 
bb_logout_link(array('redirect' => bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)));
?>
					</p>
				</div>
			</div>

			<div id="bbBody">

<?php 
bb_admin_menu();
Esempio n. 23
0
                } elseif ('blocked' != $role && array_key_exists('blocked', $user->capabilities)) {
                    bb_fix_password($user->ID);
                }
            }
            foreach ($profile_admin_keys as $key => $label) {
                if (${$key} != '' || isset($user->{$key})) {
                    bb_update_usermeta($user->ID, $key, ${$key});
                }
            }
            foreach ($assignable_caps as $cap => $label) {
                if (!($already = array_key_exists($cap, $user->capabilities)) && ${$cap}) {
                    $user_obj->add_cap($cap);
                } elseif (!${$cap} && $already) {
                    $user_obj->remove_cap($cap);
                }
            }
        }
        if (bb_current_user_can('change_user_password', $user->ID) && !empty($_POST['pass1'])) {
            $_POST['pass1'] = addslashes($_POST['pass1']);
            bb_update_user_password($user->ID, $_POST['pass1']);
            if (bb_get_current_user_info('ID') == $user->ID) {
                bb_clear_auth_cookie();
                bb_set_auth_cookie($user->ID);
            }
        }
        do_action('profile_edited', $user->ID);
        nxt_redirect(add_query_arg('updated', 'true', get_user_profile_link($user->ID)));
        exit;
    }
}
bb_load_template('profile-edit.php', array('profile_info_keys', 'profile_admin_keys', 'assignable_caps', 'user_email', 'bb_roles', 'errors', 'self'));
Esempio n. 24
0
/**
 * 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 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 ! " ? $ % ^ &amp; ).'), '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);
}
Esempio n. 26
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;
Esempio n. 27
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);
Esempio n. 28
0
function bb_attachments_upload_form($post_id = 0)
{
    global $bb_attachments;
    if (!$post_id) {
        $post_id = intval($_GET['bb_attachments']);
    }
    // only can upload if user is allowed to edit post
    $user_id = bb_get_current_user_info('id');
    if (!$user_id || $post_id && !bb_current_user_can('edit_post', $post_id) || !bb_current_user_can($bb_attachments['role']['upload'])) {
        return;
    }
    $count = 0;
    $allowed = __('allowed uploads:') . " ";
    $exts = bb_attachments_lookup($bb_attachments['allowed']['extensions']);
    $tcount = count($exts);
    foreach ($exts as $ext) {
        $allowed .= $ext . ' <span class="num">(' . round(bb_attachments_lookup($bb_attachments['max']['size'], $ext) / 1024, 1) . ' KB)</span>, ';
        $count++;
        if ($count == 5 && $tcount > 7) {
            $allowed .= "<br />";
        }
    }
    $allowed = rtrim($allowed, " ,");
    if ($post_id) {
        echo '<form class="bb_attachments_upload_form" enctype="multipart/form-data" method="post" action="' . attribute_escape(add_query_arg('bb_attachments', $post_id, remove_query_arg(array('bb_attachments', 'bbat', 'bbat_delete')))) . '">';
    } else {
        echo '<input  type="hidden" name="bb_attachments" value="0" />';
    }
    echo '<h3>' . __("Upload Files from your Computer") . '</h3>		
	<input  type="hidden" name="MAX_FILE_SIZE" value="' . $bb_attachments['max']['php_upload_limit'] . '" />			
	<span id="bb_attachments_file_sample">
	<input type="file" name="bb_attachments[]" size="50" /><br />
	<input type="file" name="bb_attachments[]" size="50" /><br />
	</span>		
	<div id="bb_attachments_file_input_4"></div>	
	<script type="text/javascript" defer="defer">
	bb_attachment_input_count=2;
	function bb_attachment_inputs() {		
		bb_attachment_input_count=bb_attachment_input_count+2; if (bb_attachment_input_count<=' . bb_attachments_lookup($bb_attachments['max']['uploads']) . ') {			
		document.getElementById(' . "'bb_attachments_file_input_'" . '+bb_attachment_input_count).innerHTML+=document.getElementById(' . "'bb_attachments_file_sample'" . ').innerHTML+"<div id=bb_attachments_file_input_"+(bb_attachment_input_count+2)+"></div>";
		}					
	}
	</script>
	' . $allowed . '<br />
	<div style="margin:1em 0 0 0;">';
    if ($post_id) {
        echo '<a style="margin-right:12em;" href="' . get_post_link($post_id) . '">' . __("&laquo; return to post") . '</a>';
    } else {
        echo '<span style="margin-right:20em;">&nbsp;</span>';
    }
    echo '<a href="javascript:void(0)" onClick="bb_attachment_inputs();">[+] ' . __('more') . '</a> &nbsp; 
	<input style="font-weight:bold;" type="submit" class="submit" name="upload" value="' . __('Upload') . '" />
	</div>';
    if ($post_id) {
        echo '</form>';
    }
}
Esempio n. 29
0
    foreach ($posts as $bb_post) {
        $topic = get_topic($bb_post->topic_id);
        ?>
<li<?php 
        alt_class('replies');
        ?>
>
	<a href="<?php 
        topic_link();
        ?>
"><?php 
        topic_title();
        ?>
</a> -
	<?php 
        if ($user->ID == bb_get_current_user_info('id')) {
            printf(__('You last replied: %s ago'), bb_get_post_time());
        } else {
            printf(__('User last replied: %s ago'), bb_get_post_time());
        }
        ?>
 |

	<span class="freshness"><?php 
        if (bb_get_post_time('timestamp') < get_topic_time('timestamp')) {
            printf(__('Most recent reply: %s ago'), get_topic_time());
        } else {
            _e('No replies since');
        }
        ?>
</span>
Esempio n. 30
0
    function tag_form($args = null)
    {
        $defaults = array('topic' => 0, 'submit' => __('Add'), 'list_id' => 'tags-list');
        $args = wp_parse_args($args, $defaults);
        extract($args, EXTR_SKIP);
        if (!($topic = get_topic(get_topic_id($topic)))) {
            return false;
        }
        if (!bb_current_user_can('edit_tag_by_on', bb_get_current_user_info('id'), $topic->topic_id)) {
            return false;
        }
        ?>

	<form id="tag-form" method="post" action="<?php 
        bb_uri('tag-add.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN);
        ?>
" class="add:<?php 
        echo attribute_escape($list_id);
        ?>
:">
		<p>
			<input name="tag" class="text" type="text" id="tag" />
			<input type="hidden" name="id" value="<?php 
        echo $topic->topic_id;
        ?>
" />
			<?php 
        bb_nonce_field('add-tag_' . $topic->topic_id);
        ?>
			<input type="submit" class="button-secondary" name="submit" id="tagformsub" value="<?php 
        echo attribute_escape($submit);
        ?>
" />
		</p>
	</form>

	<?php 
    }