本文整理汇总了PHP中bb_current_user_can函数的典型用法代码示例。如果您正苦于以下问题:PHP bb_current_user_can函数的具体用法?PHP bb_current_user_can怎么用?PHP bb_current_user_can使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bb_current_user_can函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bb_language_switcher_debug
function bb_language_switcher_debug()
{
if (!bb_current_user_can('administrate')) {
return;
}
bb_language_switcher_update();
$bb_language_switcher = bb_get_option('bb_language_switcher');
$url = bb_get_option('uri') . trim(str_replace(array(trim(BBPATH, "/\\"), "\\"), array("", "/"), BB_LANG_DIR), ' /\\') . '/';
$count = 0;
echo "<html><table border='0' cellpadding='1' cellspacing='1' style='font-family:monospace;'>";
foreach ($bb_language_switcher as $value => $description) {
if ($value) {
$count++;
echo "<tr><td>{$description}</td><td><a href='{$url}{$value}.mo'>{$value}.mo</a></td></tr>";
}
}
echo "</table>\n<br />{$count} language files total";
exit;
}
示例2: add_twitter_to_profile_edit
function add_twitter_to_profile_edit()
{
global $user_id, $bb_current_user, $bb_twitter;
if (bb_current_user_can('edit_profile', $user->ID) && bb_is_user_logged_in()) {
$twitter = fetch_user_twitter($user_id);
$user = bb_get_user($user_id);
$tweets_on = $user->twitter_on;
$tweets_on_post = $user->twitter_on_post;
?>
<fieldset>
<legend><?php
_e('Twitter');
?>
</legend>
<table border=0>
<tr>
<th>Twitter username : </th><td><input type="text" name="twitter" value="<?php
echo $twitter;
?>
" size="25"/></td>
</tr>
<?php
if (false) {
?>
<tr>
<td>Show your latest <em>tweet</em> in your profile?</td><td>
<input name="show_tweets" value="tweets_on" type="checkbox" checked="checked"/></td>
<input name="show_tweets" value="tweets_on" type="checkbox"/></td>
</tr>
<tr>
<td>Show your latest <em>tweet</em> under each post?</td><td>
<input name="show_tweets_post" value="tweets_on_post" type="checkbox" checked="checked"/></td>
<input name="show_tweets_post" value="tweets_on_post" type="checkbox"/></td>
<?php
}
?>
</tr>
</table>
</fieldset>
<?php
}
}
示例3: blocklist_process_post
function blocklist_process_post()
{
if (!bb_current_user_can('administrate')) {
return;
}
global $blocklist;
if (isset($_POST['submit']) && isset($_POST['blocklist'])) {
$options = array('data', 'email');
foreach ($options as $option) {
if (!empty($_POST[$option])) {
(array) ($data = explode("\n", trim($_POST[$option])));
array_walk($data, create_function('&$arr', '$arr=trim($arr);'));
$blocklist[$option] = implode("\r\n", $data) . "\r\n";
} else {
$blocklist[$option] = "";
}
}
bb_update_option('blocklist', $blocklist);
}
}
示例4: elseif
} 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’ <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
}
}
?>
<?php
bb_profile_data();
?>
</div>
示例5: bb_repermalink
<?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);
示例6: bb_forum_row
function bb_forum_row($forum_id = 0, $echo = true, $close = false)
{
global $forum, $forums_count;
if ($forum_id) {
$_forum = bb_get_forum($forum_id);
} else {
$_forum =& $forum;
}
if (!$_forum) {
return;
}
$description = get_forum_description($_forum->forum_id);
$r = '';
if ($close) {
$r .= "\t<li id='forum-{$_forum->forum_id}'" . get_alt_class('forum', 'forum clear list-block') . ">\n";
}
$r .= "\t\t<div class='list-block posrel'>\n";
$r .= "\t\t\t<div class=\"row-title\">" . get_forum_name($_forum->forum_id) . "</div>\n";
if ($description) {
$r .= "\t\t\t<p class=\"row-description\">" . get_forum_description($_forum->forum_id) . "</p>\n";
}
$r .= "\t\t\t<div class=\"row-actions\"><span>\n";
$r .= "\t\t\t\t<a class='edit' href='" . get_forum_link() . "'>" . __('View') . "</a>\n";
if (bb_current_user_can('manage_forums')) {
$r .= "\t\t\t\t| <a class='edit' href='" . esc_attr(bb_get_uri('bb-admin/forums.php', array('action' => 'edit', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)) . "'>" . __('Edit') . "</a>\n";
}
if (bb_current_user_can('delete_forum', $_forum->forum_id) && 1 < $forums_count) {
$r .= "\t\t\t\t| <a class='delete' href='" . esc_attr(bb_get_uri('bb-admin/forums.php', array('action' => 'delete', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)) . "'>" . __('Delete') . "</a>\n";
}
$r .= "\t\t\t</span> </div>\n";
$r .= "\t\t</div>\n";
if ($close) {
$r .= "\t</li>\n";
}
if ($echo) {
echo $r;
}
return $r;
}
示例7: elseif
} 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'));
示例8: BB_User_Search
<?php
require_once 'admin.php';
// Query the users
$bb_user_search = new BB_User_Search(@$_GET['usersearch'], @$_GET['page'], @$_GET['userrole']);
$bb_admin_body_class = ' bb-admin-users';
bb_get_admin_header();
?>
<div class="wrap">
<?php
$bb_user_search->display(true, bb_current_user_can('edit_users'));
?>
</div>
<?php
bb_get_admin_footer();
示例9: socialit_hide_show_do
function socialit_hide_show_do()
{
if (bb_is_topic() && $_GET['socialit_hide_show'] == "1" && isset($_GET['shs_opt']) && isset($_GET['tid']) && bb_current_user_can('moderate')) {
$topic = get_topic($_GET['tid']);
if (bb_verify_nonce($_GET['_wpnonce'], 'socialit_hide_show_' . $topic->topic_id)) {
if ($_GET['shs_opt'] == "2") {
bb_update_topicmeta($topic->topic_id, 'hide_socialit', 'true');
} else {
bb_delete_topicmeta($topic->topic_id, 'hide_socialit');
}
} else {
_e('Sorry, but that could not be done.', 'socialit');
exit;
}
wp_redirect(get_topic_link($topic->topic_id));
}
}
示例10: absint
<?php
require_once 'admin-action.php';
$topic_id = absint($_POST['topic_id']);
$forum_id = absint($_POST['forum_id']);
if (!is_numeric($topic_id) || !is_numeric($forum_id)) {
bb_die(__('Invalid topic or forum.'));
}
if (!bb_current_user_can('move_topic', $topic_id, $forum_id)) {
nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
exit;
}
bb_check_admin_referer('move-topic_' . $topic_id);
$topic = get_topic($topic_id);
$forum = bb_get_forum($forum_id);
if (!$topic || !$forum) {
bb_die(__('Your topic or forum caused all manner of confusion'));
}
bb_move_topic($topic_id, $forum_id);
if (!($redirect = nxt_get_referer())) {
$redirect = get_topic_link($topic_id);
}
bb_safe_redirect($redirect);
exit;
示例11: switch
<?php
require 'admin-action.php';
$topic_id = (int) $_GET['id'];
if (!bb_current_user_can('delete_topic', $topic_id)) {
wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
exit;
}
bb_check_admin_referer('delete-topic_' . $topic_id);
$topic = get_topic($topic_id);
$old_status = (int) $topic->topic_status;
if (!$topic) {
bb_die(__('There is a problem with that topic, pardner.'));
}
$status = $topic->topic_status ? 0 : 1;
bb_delete_topic($topic->topic_id, $status);
$message = '';
switch ($old_status) {
case 0:
switch ($status) {
case 0:
break;
case 1:
$message = 'deleted';
break;
}
break;
case 1:
switch ($status) {
case 0:
$message = 'undeleted';
示例12: bb_get_forums
<?php
require_once 'admin.php';
$forums = bb_get_forums();
$forums_count = $forums ? count($forums) : 0;
if (isset($_GET['action']) && 'delete' == $_GET['action']) {
$forum_to_delete = (int) $_GET['id'];
$deleted_forum = bb_get_forum($forum_to_delete);
if (!$deleted_forum || $forums_count < 2 || !bb_current_user_can('delete_forum', $forum_to_delete)) {
bb_safe_redirect(add_query_arg(array('action' => false, 'id' => false)));
exit;
}
}
if (isset($_GET['message'])) {
switch ($_GET['message']) {
case 'updated':
bb_admin_notice(__('<strong>Forum Updated.</strong>'));
break;
case 'deleted':
bb_admin_notice(sprintf(__('<strong>Forum deleted.</strong> You should <a href="%s">recount your site information</a>.'), bb_get_uri('bb-admin/tools-recount.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)));
break;
}
}
if (!isset($_GET['action'])) {
nxt_enqueue_script('admin-forums');
} elseif ('delete' == @$_GET['action']) {
bb_admin_notice(sprintf(__('Are you sure you want to delete the "<strong>%s</strong>" forum?'), $deleted_forum->forum_name));
}
$bb_admin_body_class = ' bb-admin-forums';
bb_get_admin_header();
?>
示例13: define
<?php
require_once '../bb-load.php';
require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
define('BB_EXPORT_USERS', 1);
define('BB_EXPORT_FORUMS', 2);
define('BB_EXPORT_TOPICS', 4);
// Some example usage of the bitwise export levels (can be defined in bb-config.php)
//define('BB_EXPORT_LEVEL', BB_EXPORT_USERS);
//define('BB_EXPORT_LEVEL', BB_EXPORT_USERS + BB_EXPORT_FORUMS);
//define('BB_EXPORT_LEVEL', BB_EXPORT_USERS + BB_EXPORT_FORUMS + BB_EXPORT_TOPICS);
if (!defined('BB_EXPORT_LEVEL')) {
define('BB_EXPORT_LEVEL', 0);
}
if (!BB_EXPORT_LEVEL || !bb_current_user_can('import_export')) {
bb_die(__('Either export is disabled or you are not allowed to export.'));
}
// See bb_export_user for syntax
function _bb_export_object($object, $properties = null, $tabs = 1)
{
$r = '';
if (!($type = $object['type'])) {
return;
}
unset($object['type']);
$atts = '';
$id = 0;
foreach ($object as $att => $v) {
if ('id' == $att) {
$id = $v;
$v = $type . '_' . $v;
示例14: blocklist_check
function blocklist_check($post_id = 0, $wall = false)
{
if (bb_current_user_can('moderate') || bb_current_user_can('throttle')) {
return;
}
if ($wall) {
$bb_post = user_wall_get_post($post_id);
} else {
$bb_post = bb_get_post($post_id);
}
if (empty($post_id) || empty($bb_post) || !empty($bb_post->post_status)) {
return;
}
global $blocklist, $bbdb;
blocklist_initialize();
if (empty($blocklist['data'])) {
return;
}
(array) ($data = explode("\r\n", $blocklist['data']));
$user = bb_get_user($bb_post->poster_id);
foreach ($data as $item) {
if (empty($item) || strlen($item) < 4 || ord($item) == 35) {
continue;
}
if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $item)) {
// is IP
if (strpos($bb_post->poster_ip, $item) === 0) {
$found = "IP address";
$bad = $item;
break;
}
} else {
// is word
$qitem = preg_quote($item);
if (preg_match('/\\b' . $qitem . '/simU', $user->user_email)) {
$found = "email";
$bad = $item;
break;
}
if (preg_match('/\\b' . $qitem . '/simU', $user->user_login)) {
$found = "username";
$bad = $item;
break;
}
if (preg_match('/\\b' . $qitem . '/simU', $bb_post->post_text)) {
$found = "post text";
$bad = $item;
break;
} elseif (!$wall && $bb_post->post_position == 1) {
if (empty($topic)) {
$topic = get_topic($bb_post->topic_id);
}
if (!empty($topic->topic_title) && preg_match('/\\b' . $qitem . '/simU', $topic->topic_title)) {
$found = "topic title";
$bad = $item;
break;
}
}
}
if (!empty($bad)) {
break;
}
}
if (!empty($bad)) {
if ($wall) {
user_wall_delete_post($post_id, 2);
$uri = bb_get_option('uri') . "bb-admin/admin-base.php?post_status=2&plugin=user_wall_admin&user-wall-recent=1";
} else {
bb_delete_post($post_id, 2);
if (empty($topic)) {
$topic = get_topic($bb_post->topic_id);
}
if (empty($topic->topic_posts)) {
bb_delete_topic($topic->topic_id, 2);
}
// if no posts in topic, also set topic to spam
$uri = bb_get_option('uri') . 'bb-admin/' . (defined('BACKPRESS_PATH') ? '' : 'content-') . 'posts.php?post_status=2';
}
if (empty($blocklist['email'])) {
return;
}
(array) ($email = explode("\r\n", $blocklist['email']));
$message = "The blocklist has been triggered... \r\n\r\n";
$message .= "Matching entry " . '"' . $bad . '"' . " found in {$found}.\r\n";
$message .= "{$uri}\r\n\r\n";
$message .= sprintf(__('Username: %s'), stripslashes($user->user_login)) . "\r\n";
$message .= sprintf(__('Profile: %s'), get_user_profile_link($user->ID)) . "\r\n";
$message .= sprintf(__('Email: %s'), stripslashes($user->user_email)) . "\r\n";
$message .= sprintf(__('IP address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n";
$message .= sprintf(__('Agent: %s'), substr(stripslashes($_SERVER["HTTP_USER_AGENT"]), 0, 255)) . "\r\n\r\n";
foreach ($email as $to) {
if (empty($to) || strlen($to) < 8) {
continue;
}
@bb_mail($to, "[" . bb_get_option('name') . "] blocklist triggered", $message);
}
}
}
示例15: bb_insert_post
function bb_insert_post($args = null)
{
global $bbdb, $bb_current_user, $bb;
if (!($args = nxt_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(nxt_parse_args($args, $defaults));
// If the user is not logged in and loginless posting is ON, then this function expects $post_author, $post_email and $post_url to be sanitized (check bb-post.php for example)
if (!($topic = get_topic($topic_id))) {
return false;
}
if (bb_is_login_required() && !($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'));
nxt_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 = !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->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) {
$topics_replied_key = $bbdb->prefix . 'topics_replied';
bb_update_usermeta($poster_id, $topics_replied_key, $user->{$topics_replied_key} + 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 user not logged in, save user data as meta data
if (!$user) {
bb_update_meta($post_id, 'post_author', $post_author, 'post');
bb_update_meta($post_id, 'post_email', $post_email, 'post');
bb_update_meta($post_id, 'post_url', $post_url, 'post');
}
if ($throttle && !bb_current_user_can('throttle')) {
if ($user) {
bb_update_usermeta($poster_id, 'last_posted', time());
} else {
bb_set_transient($_SERVER['REMOTE_ADDR'] . '_last_posted', time());
}
}
if (!bb_is_login_required() && !($user = bb_get_user($poster_id))) {
$post_cookie_lifetime = apply_filters('bb_post_cookie_lifetime', 30000000);
setcookie('post_author_' . BB_HASH, $post_author, time() + $post_cookie_lifetime, $bb->cookiepath, $bb->cookiedomain);
setcookie('post_author_email_' . BB_HASH, $post_email, time() + $post_cookie_lifetime, $bb->cookiepath, $bb->cookiedomain);
//.........这里部分代码省略.........