Exemplo n.º 1
0
/**
 * Add reply link below each post
 *
 * @param $post_links Array of the links
 * @param $args Array of args
 */
function em_reply_link($post_links = array(), $args = array())
{
    global $em_plugopts;
    if ($em_plugopts['reply-link'] == 1 && $em_plugopts['reply-text'] && bb_is_topic() && topic_is_open() && (bb_is_user_logged_in() || function_exists('bb_is_login_required') && !bb_is_login_required())) {
        /* Check if link is needed */
        $text = str_replace("%%POSTLINK%%", get_post_link(), str_replace("%%USERNAME%%", get_post_author(), $em_plugopts['reply-text']));
        $js = "var ema=document.getElementById('post_content');var emb=ema.value;if(emb!='')emb+='\\n\\n';ema.value=emb+'" . $text . "\\n\\n';ema.focus();void(0);";
        $post_links[] = $args['before_each'] . '<a class="reply_link" style="cursor:pointer" onclick="' . $js . '">' . __('Reply', 'easy-mentions') . '</a>' . $args['after_each'];
    }
    return $post_links;
}
Exemplo n.º 2
0
function bb_quote_link($link_text = 'Quote')
{
    global $bb, $page, $topic, $forum, $bb_post;
    $add = topic_pages_add();
    if (!topic_is_open($bb_post->topic_id) || !bb_is_user_logged_in()) {
        return;
    }
    $post_id = get_post_id();
    $last_page = get_page_number($topic->topic_posts + $add);
    echo '<a href="' . get_topic_link(0, $last_page) . '&quote=' . $post_id . '#postform" id="quote_' . $post_id . '">' . __($link_text) . '</a>';
}
Exemplo n.º 3
0
    }
    ?>

</ol>
<div class="clearit"><br style=" clear: both;" /></div>
<p class="rss-link"><a href="<?php 
    topic_rss_link();
    ?>
" class="rss-link"><?php 
    _e('<abbr title="Really Simple Syndication">RSS</abbr> feed for this topic');
    ?>
</a></p>
<?php 
    topic_pages(array('before' => '<div class="nav">', 'after' => '</div>'));
}
if (topic_is_open($bb_post->topic_id)) {
    post_form();
} else {
    ?>
<h2><?php 
    _e('Question Closed');
    ?>
</h2>
<p><?php 
    _e('This topic has been closed to new replies.');
    ?>
</p>
<?php 
}
if (bb_current_user_can('delete_topic', get_topic_id()) || bb_current_user_can('close_topic', get_topic_id()) || bb_current_user_can('stick_topic', get_topic_id()) || bb_current_user_can('move_topic', get_topic_id())) {
    ?>
Exemplo n.º 4
0
<?php

require 'admin-action.php';
$topic_id = (int) $_GET['id'];
$topic = get_topic($topic_id);
if (!$topic) {
    bb_die(__('There is a problem with that topic, pardner.'));
}
if (!bb_current_user_can('close_topic', $topic_id)) {
    nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    exit;
}
bb_check_admin_referer('close-topic_' . $topic_id);
if (topic_is_open($topic_id)) {
    bb_close_topic($topic_id);
    $message = 'closed';
} else {
    bb_open_topic($topic_id);
    $message = 'opened';
}
if ($sendto = nxt_get_referer()) {
    $sendto = remove_query_arg('message', $sendto);
    $sendto = add_query_arg('message', $message, $sendto);
} else {
    $sendto = get_topic_link($topic_id);
}
bb_safe_redirect($sendto);
exit;
function bb_get_topic_close_link($args = '')
{
    $defaults = array('id' => 0, 'before' => '[', 'after' => ']', 'close_text' => false, 'open_text' => false, 'redirect' => true);
    extract(wp_parse_args($args, $defaults), EXTR_SKIP);
    $id = (int) $id;
    $topic = get_topic(get_topic_id($id));
    if (!$topic || !bb_current_user_can('close_topic', $topic->topic_id)) {
        return;
    }
    if (topic_is_open($topic->topic_id)) {
        $display = esc_html($close_text ? $close_text : __('Close topic'));
    } else {
        $display = esc_html($open_text ? $open_text : __('Open topic'));
    }
    if (true === $redirect) {
        $redirect = $_SERVER['REQUEST_URI'];
    }
    $uri = bb_get_uri('bb-admin/topic-toggle.php', array('id' => $topic->topic_id, '_wp_http_referer' => $redirect ? rawurlencode($redirect) : false), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
    $uri = esc_url(bb_nonce_url($uri, 'close-topic_' . $topic->topic_id));
    return $before . '<a href="' . $uri . '">' . $display . '</a>' . $after;
}
Exemplo n.º 6
0
</li>
                    <li class="post-text"><?php 
    post_text();
    ?>
</li>
                </ul>
            </li>
        <?php 
}
?>
        </ul>
        <?php 
topic_pages(array('before' => '<div class="pagination">', 'after' => '</div>'));
?>

        <?php 
if (topic_is_open()) {
    ?>
        <div id="post-form">
            <?php 
    post_form(array('h3' => 'hoge'));
    ?>
        </div>
        <?php 
}
?>
    </div>

</div>
<?php 
bb_get_footer();
/**
 * Map meta capabilities to primitive capabilities.
 *
 * This does not actually compare whether the user ID has the actual capability,
 * just what the capability or capabilities are. Meta capability list value can
 * be 'delete_user', 'edit_user', 'delete_post', 'delete_page', 'edit_post',
 * 'edit_page', 'read_post', or 'read_page'.
 *
 * @since 0.7.2
 *
 * @param array $caps Previously existing capabilities
 * @param string $cap Capability name.
 * @param int $user_id User ID.
 * @return array Actual capabilities for meta capability.
 */
function bb_map_meta_cap($caps, $cap, $user_id, $args)
{
    // Unset the meta cap
    if (false !== ($cap_pos = array_search($cap, $caps))) {
        unset($caps[$cap_pos]);
    }
    switch ($cap) {
        case 'write_post':
            $caps[] = 'write_posts';
            break;
        case 'edit_post':
            // edit_posts, edit_others_posts, edit_deleted, edit_closed, ignore_edit_lock
            if (!($bb_post = bb_get_post($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if ($user_id == $bb_post->poster_id) {
                $caps[] = 'edit_posts';
            } else {
                $caps[] = 'edit_others_posts';
            }
            if ($bb_post->post_status == '1') {
                $caps[] = 'edit_deleted';
            }
            if (!topic_is_open($bb_post->topic_id)) {
                $caps[] = 'edit_closed';
            }
            $post_time = bb_gmtstrtotime($bb_post->post_time);
            $curr_time = time() + 1;
            $edit_lock = bb_get_option('edit_lock');
            if ($edit_lock >= 0 && $curr_time - $post_time > $edit_lock * 60) {
                $caps[] = 'ignore_edit_lock';
            }
            break;
        case 'delete_post':
            // edit_deleted, delete_posts
            if (!($bb_post = bb_get_post($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (0 != $bb_post->post_status) {
                $caps[] = 'edit_deleted';
            }
            // NO BREAK
        // NO BREAK
        case 'manage_posts':
            // back compat
            $caps[] = 'delete_posts';
            break;
        case 'write_topic':
            $caps[] = 'write_topics';
            break;
        case 'edit_topic':
            // edit_closed, edit_deleted, edit_topics, edit_others_topics
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($args[0])) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            if ($user_id == $topic->topic_poster) {
                $caps[] = 'edit_topics';
            } else {
                $caps[] = 'edit_others_topics';
            }
            break;
        case 'move_topic':
            $caps[] = 'move_topics';
            break;
        case 'stick_topic':
            $caps[] = 'stick_topics';
            break;
        case 'close_topic':
            $caps[] = 'close_topics';
            break;
        case 'delete_topic':
            $caps[] = 'delete_topics';
            add_filter('get_topic_where', 'bb_no_where', 9999);
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (0 != $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            remove_filter('get_topic_where', 'bb_no_where', 9999);
            break;
        case 'manage_topics':
            // back compat
            $caps[] = 'move_topics';
            $caps[] = 'stick_topics';
            $caps[] = 'close_topics';
            $caps[] = 'delete_topics';
            break;
        case 'add_tag_to':
            // edit_closed, edit_deleted, edit_tags;
            if (!($topic = get_topic($args[0]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($topic->topic_id)) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            $caps[] = 'edit_tags';
            break;
        case 'edit_tag_by_on':
            // edit_closed, edit_deleted, edit_tags, edit_others_tags
            if (!($topic = get_topic($args[1]))) {
                $caps[] = 'magically_provide_data_given_bad_input';
                return $caps;
            }
            if (!topic_is_open($topic->topic_id)) {
                $caps[] = 'edit_closed';
            }
            if ('1' == $topic->topic_status) {
                $caps[] = 'edit_deleted';
            }
            if ($user_id == $args[0]) {
                $caps[] = 'edit_tags';
            } else {
                $caps[] = 'edit_others_tags';
            }
            break;
        case 'edit_user':
            // edit_profile, edit_users;
            if ($user_id == $args[0]) {
                $caps[] = 'edit_profile';
            } else {
                $caps[] = 'edit_users';
            }
            break;
        case 'edit_favorites_of':
            // edit_favorites, edit_others_favorites;
            if ($user_id == $args[0]) {
                $caps[] = 'edit_favorites';
            } else {
                $caps[] = 'edit_others_favorites';
            }
            break;
        case 'delete_forum':
            $caps[] = 'delete_forums';
            break;
        case 'change_user_password':
            // change_password, edit_users
            $caps[] = 'change_password';
            if ($user_id != $args[0]) {
                $caps[] = 'edit_users';
            }
            break;
        default:
            // If no meta caps match, return the original cap.
            $caps[] = $cap;
    }
    return $caps;
}