本文整理汇总了PHP中bb_new_forum函数的典型用法代码示例。如果您正苦于以下问题:PHP bb_new_forum函数的具体用法?PHP bb_new_forum怎么用?PHP bb_new_forum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bb_new_forum函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_forums_new_forum
function bp_forums_new_forum($args = '')
{
do_action('bbpress_init');
$r = wp_parse_args($args, array('forum_name' => '', 'forum_desc' => '', 'forum_parent_id' => bp_forums_parent_forum_id(), 'forum_order' => false, 'forum_is_category' => 0));
extract($r, EXTR_SKIP);
return bb_new_forum(array('forum_name' => stripslashes($forum_name), 'forum_desc' => stripslashes($forum_desc), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category));
}
示例2: bb_die
require_once 'admin.php';
if (!bb_current_user_can('manage_forums')) {
bb_die(__("You don't have the authority to mess with the forums."));
}
if (!isset($_POST['action'])) {
nxt_redirect(bb_get_uri('bb-admin/forums.php', null, BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN));
exit;
}
$sent_from = nxt_get_referer();
switch ($_POST['action']) {
case 'add':
if (!isset($_POST['forum_name']) || '' === $_POST['forum_name']) {
bb_die(__('Bad forum name. Go back and try again.'));
}
bb_check_admin_referer('add-forum');
if (false !== bb_new_forum($_POST)) {
bb_safe_redirect($sent_from);
exit;
} else {
bb_die(__('The forum was not added'));
}
break;
case 'update':
bb_check_admin_referer('update-forum');
if (!($forums = bb_get_forums())) {
bb_die(__('No forums to update!'));
}
if ((int) $_POST['forum_id'] && isset($_POST['forum_name']) && '' !== $_POST['forum_name']) {
bb_update_forum($_POST);
}
foreach (array('action', 'id') as $arg) {
示例3: bb_newForum
/**
* Creates a new forum
*
* @since 1.0
* @return array|object The forum data when successfully created or an IXR_Error object on failure
* @param array $args Arguments passed by the XML-RPC call
* @param string $args[0] The username for authentication
* @param string $args[1] The password for authentication
* @param array $args[2] The values for the various settings in the new forum
* @param string $args[2]['name'] The name of the forum
* @param string $args[2]['description'] The description of the forum (optional)
* @param integer|string $args[2]['parent_id'] The unique id of the parent forum for this forum (optional)
* @param integer $args[2]['order'] The position of the forum in the forum list (optional)
* @param integer $args[2]['is_category'] Whether the forum is simply a container category (optional)
*
* XML-RPC request to create a new sub-forum called "A new forum" inside the parent forum with id 2
* <methodCall>
* <methodName>bb.newForum</methodName>
* <params>
* <param><value><string>joeblow</string></value></param>
* <param><value><string>123password</string></value></param>
* <param><value><struct>
* <member>
* <name>name</name>
* <value><string>A new forum</string></value>
* </member>
* <member>
* <name>parent_id</name>
* <value><integer>2</integer></value>
* </member>
* </struct></value></param>
* </params>
* </methodCall>
*/
function bb_newForum($args)
{
do_action('bb_xmlrpc_call', 'bb.newForum');
// Escape args
$this->escape($args);
// Get the login credentials
$username = $args[0];
$password = (string) $args[1];
// Check the user is valid
$user = $this->authenticate($username, $password, 'manage_forums', __('You do not have permission to manage forums.'));
do_action('bb_xmlrpc_call_authenticated', 'bb.newForum');
// If an error was raised by authentication or by an action then return it
if ($this->error) {
return $this->error;
}
// Make sure there is something for us to do
if (!$args[2] || !is_array($args[2]) || !count($args[2])) {
$this->error = new IXR_Error(400, __('The forum data is invalid.'));
return $this->error;
}
$structure = (array) $args[2];
// Minimum requirement is a name for the new forum
if (!isset($structure['name']) || !$structure['name']) {
$this->error = new IXR_Error(400, __('The forum name is invalid.'));
return $this->error;
}
// Inject structure into an array suitable for bb_new_forum()
$bb_new_forum_args = array('forum_name' => (string) $structure['name'], 'forum_desc' => (string) $structure['description'], 'forum_parent' => (int) $structure['parent_id'], 'forum_order' => (int) $structure['order'], 'forum_is_category' => (int) $structure['is_category']);
// Remove empty settings so that changes to the defaults in bb_new_forum() are honoured
$bb_new_forum_args = array_filter($bb_new_forum_args);
// Leave the require until the very end
require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
// Create the forum
if (!($forum_id = (int) bb_new_forum($bb_new_forum_args))) {
$this->error = new IXR_Error(500, __('The forum could not be created.'));
return $this->error;
}
// Only include "safe" data in the array
$forum = $this->prepare_forum(bb_get_forum($forum_id));
do_action('bb_xmlrpc_call_return', 'bb.newForum');
return $forum;
}
示例4: bp_forums_load_bbpress
//.........这里部分代码省略.........
$bp = buddypress();
define('BB_PATH', $bp->plugin_dir . '/bp-forums/bbpress/');
define('BACKPRESS_PATH', $bp->plugin_dir . '/bp-forums/bbpress/bb-includes/backpress/');
define('BB_URL', $bp->plugin_url . 'bp-forums/bbpress/');
define('BB_INC', 'bb-includes/');
require BB_PATH . BB_INC . 'class.bb-query.php';
require BB_PATH . BB_INC . 'class.bb-walker.php';
require BB_PATH . BB_INC . 'functions.bb-core.php';
require BB_PATH . BB_INC . 'functions.bb-forums.php';
require BB_PATH . BB_INC . 'functions.bb-topics.php';
require BB_PATH . BB_INC . 'functions.bb-posts.php';
require BB_PATH . BB_INC . 'functions.bb-topic-tags.php';
require BB_PATH . BB_INC . 'functions.bb-capabilities.php';
require BB_PATH . BB_INC . 'functions.bb-meta.php';
require BB_PATH . BB_INC . 'functions.bb-pluggable.php';
require BB_PATH . BB_INC . 'functions.bb-formatting.php';
require BB_PATH . BB_INC . 'functions.bb-template.php';
require BACKPRESS_PATH . 'class.wp-taxonomy.php';
require BB_PATH . BB_INC . 'class.bb-taxonomy.php';
require BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
$bb = new stdClass();
require bp_get_option('bb-config-location');
// Setup the global database connection
$bbdb = new BPDB(BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST);
// Set the table names
$bbdb->forums = $bb_table_prefix . 'forums';
$bbdb->meta = $bb_table_prefix . 'meta';
$bbdb->posts = $bb_table_prefix . 'posts';
$bbdb->terms = $bb_table_prefix . 'terms';
$bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
$bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
$bbdb->topics = $bb_table_prefix . 'topics';
if (isset($bb->custom_user_table)) {
$bbdb->users = $bb->custom_user_table;
} else {
$bbdb->users = $wpdb->users;
}
if (isset($bb->custom_user_meta_table)) {
$bbdb->usermeta = $bb->custom_user_meta_table;
} else {
$bbdb->usermeta = $wpdb->usermeta;
}
$bbdb->prefix = $bb_table_prefix;
define('BB_INSTALLING', false);
if (is_object($wp_roles)) {
$bb_roles = $wp_roles;
bb_init_roles($bb_roles);
}
/**
* Fires during the bootstrap setup for bbPress 1.x.
*
* @since 1.1.0
*/
do_action('bb_got_roles');
/**
* Fires during the bootstrap setup for bbPress 1.x.
*
* @since 1.1.0
*/
do_action('bb_init');
/**
* Fires during the bootstrap setup for bbPress 1.x.
*
* @since 1.1.0
*/
do_action('init_roles');
$bb_current_user = $current_user;
$wp_users_object = new BP_Forums_BB_Auth();
if (!isset($wp_taxonomy_object)) {
$wp_taxonomy_object = new BB_Taxonomy($bbdb);
}
$wp_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
// Set a site id if there isn't one already
if (!isset($bb->site_id)) {
$bb->site_id = bp_get_root_blog_id();
}
// Check if the tables are installed, if not, install them
if (!($tables_installed = (bool) $bbdb->get_results('DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A))) {
require BB_PATH . 'bb-admin/includes/defaults.bb-schema.php';
// Backticks and "IF NOT EXISTS" break the dbDelta function.
bp_bb_dbDelta(str_replace(' IF NOT EXISTS', '', str_replace('`', '', $bb_queries)));
require BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php';
bb_update_db_version();
// Set the site admins as the keymasters
$site_admins = get_site_option('site_admins', array('admin'));
foreach ((array) $site_admins as $site_admin) {
bp_update_user_meta(bp_core_get_userid($site_admin), $bb_table_prefix . 'capabilities', array('keymaster' => true));
}
// Create the first forum.
bb_new_forum(array('forum_name' => 'Default Forum'));
// Set the site URI
bb_update_option('uri', BB_URL);
}
/**
* Fires inside an anonymous function that is run on bbPress shutdown.
*
* @since 1.1.0
*/
register_shutdown_function(create_function('', 'do_action("bb_shutdown");'));
}
示例5: process_form_finalise_installation
//.........这里部分代码省略.........
if ($keymaster_user = bb_get_user($data3['keymaster_user_login']['value'], array('by' => 'login'))) {
// The keymaster is an existing bbPress or WordPress user
$bb_current_user = bb_set_current_user($keymaster_user->ID);
$bb_current_user->set_role('keymaster');
$data4['keymaster_user_password']['value'] = __('Your existing password');
$installation_log[] = '>>> ' . __('Key master role assigned to existing user');
$installation_log[] = '>>>>>> ' . __('Username:') . ' ' . $data3['keymaster_user_login']['value'];
$installation_log[] = '>>>>>> ' . __('Email address:') . ' ' . $data3['keymaster_user_email']['value'];
$installation_log[] = '>>>>>> ' . __('Password:') . ' ' . $data4['keymaster_user_password']['value'];
$keymaster_created = true;
} else {
$installation_log[] = '>>> ' . __('Key master role could not be assigned to existing user!');
$installation_log[] = '>>>>>> ' . __('Halting installation!');
$error_log[] = __('Key master could not be created!');
$this->step_status[4] = 'incomplete';
$this->strings[4]['h2'] = __('Installation failed!');
$this->strings[4]['messages']['error'][] = __('The key master could not be assigned. You may need to replace bbPress with a fresh copy and start again.');
$data4['installation_log']['value'] = join("\n", $installation_log);
$data4['error_log']['value'] = join("\n", $error_log);
return 'incomplete';
}
break;
}
// Don't create an initial forum if any forums already exist
if (!$bbdb->get_results('SELECT `forum_id` FROM `' . $bbdb->forums . '` LIMIT 1;')) {
if ($this->language != BB_LANG) {
global $locale, $l10n;
$locale = BB_LANG;
unset($l10n['default']);
bb_load_default_textdomain();
}
$description = __('Just another bbPress community');
bb_update_option('description', $description);
if ($this->language != BB_LANG) {
$locale = $this->language;
unset($l10n['default']);
bb_load_default_textdomain();
}
$installation_log[] = '>>> ' . __('Description:') . ' ' . $description;
if ($forum_id = bb_new_forum(array('forum_name' => $data3['forum_name']['value']))) {
$installation_log[] = '>>> ' . __('Forum name:') . ' ' . $data3['forum_name']['value'];
if ($this->language != BB_LANG) {
$locale = BB_LANG;
unset($l10n['default']);
bb_load_default_textdomain();
}
$topic_title = __('Your first topic');
$topic_id = bb_insert_topic(array('topic_title' => $topic_title, 'forum_id' => $forum_id, 'tags' => 'bbPress'));
$post_text = __('First Post! w00t.');
bb_insert_post(array('topic_id' => $topic_id, 'post_text' => $post_text));
if ($this->language != BB_LANG) {
$locale = $this->language;
unset($l10n['default']);
bb_load_default_textdomain();
}
$installation_log[] = '>>>>>> ' . __('Topic:') . ' ' . $topic_title;
$installation_log[] = '>>>>>>>>> ' . __('Post:') . ' ' . $post_text;
} else {
$installation_log[] = '>>> ' . __('Forum could not be created!');
$error_log[] = __('Forum could not be created!');
}
} else {
$installation_log[] = '>>> ' . __('There are existing forums in this database.');
$installation_log[] = '>>>>>> ' . __('No new forum created.');
$error_log[] = __('Forums already exist!');
}
if (defined('BB_PLUGIN_DIR') && BB_PLUGIN_DIR && !file_exists(BB_PLUGIN_DIR)) {
// Just suppress errors as this is not critical
if (@mkdir(BB_PLUGIN_DIR, 0750)) {
$installation_log[] = '>>> ' . sprintf(__('Making plugin directory at %s.'), BB_PLUGIN_DIR);
}
}
if (defined('BB_THEME_DIR') && BB_THEME_DIR && !file_exists(BB_THEME_DIR)) {
// Just suppress errors as this is not critical
if (@mkdir(BB_THEME_DIR, 0750)) {
$installation_log[] = '>>> ' . sprintf(__('Making theme directory at %s.'), BB_THEME_DIR);
}
}
if ($keymaster_created) {
$keymaster_email_message = sprintf(__("Your new bbPress site has been successfully set up at:\n\n%1\$s\n\nYou can log in to the key master account with the following information:\n\nUsername: %2\$s\nPassword: %3\$s\n\nWe hope you enjoy your new forums. Thanks!\n\n--The bbPress Team\nhttp://bbpress.org/"), bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), $data3['keymaster_user_login']['value'], $data4['keymaster_user_password']['value']);
if (bb_mail($data3['keymaster_user_email']['value'], __('New bbPress installation'), $keymaster_email_message)) {
$installation_log[] = '>>> ' . __('Key master email sent');
} else {
$installation_log[] = '>>> ' . __('Key master email not sent!');
$error_log[] = __('Key master email not sent!');
}
}
if (count($error_log)) {
$this->strings[4]['h2'] = __('Installation completed with some errors!');
$this->strings[4]['messages']['error'][] = __('Your installation completed with some minor errors. See the error log below for more specific information.');
$installation_log[] = "\n" . __('There were some errors encountered during installation!');
} else {
$this->strings[4]['messages']['message'][] = __('Your installation completed successfully.');
$installation_log[] = "\n" . __('Installation complete!');
}
$this->step_status[4] = 'complete';
$data4['installation_log']['value'] = join("\n", $installation_log);
$data4['error_log']['value'] = join("\n", $error_log);
return 'complete';
}
示例6: WP_Ajax_Response
ob_end_clean();
endif;
$x = new WP_Ajax_Response( array(
'what' => 'post',
'id' => $post_id,
'data' => is_wp_error($error) ? $error : $data
) );
$x->send();
break;
*/
case 'add-forum':
if (!bb_current_user_can('manage_forums')) {
die('-1');
}
bb_check_ajax_referer($action);
if (!($forum_id = bb_new_forum($_POST))) {
die('0');
}
global $forums_count;
$forums_count = 2;
// Hack
$data = bb_forum_row($forum_id, false, true);
$forum = bb_get_forum($forum_id);
if ($forum->forum_parent) {
$siblings = bb_get_forums($forum->forum_parent);
$last_sibling = array_pop($siblings);
if ($last_sibling->forum_id == $forum_id) {
$last_sibling = array_pop($siblings);
}
if ($last_sibling) {
$position = "forum-{$last_sibling->forum_id}";
示例7: bp_forums_load_bbpress
//.........这里部分代码省略.........
define( 'BB_URL', BP_PLUGIN_URL . '/bp-forums/bbpress/' );
define( 'BB_INC', 'bb-includes/' );
require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-posts.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-capabilities.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-meta.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );
require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );
$bb = new stdClass();
require_once( $bp->forums->bbconfig );
// Setup the global database connection
$bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );
/* Set the table names */
$bbdb->forums = $bb_table_prefix . 'forums';
$bbdb->meta = $bb_table_prefix . 'meta';
$bbdb->posts = $bb_table_prefix . 'posts';
$bbdb->terms = $bb_table_prefix . 'terms';
$bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
$bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
$bbdb->topics = $bb_table_prefix . 'topics';
if ( isset( $bb->custom_user_table ) )
$bbdb->users = $bb->custom_user_table;
else
$bbdb->users = $wpdb->users;
if ( isset( $bb->custom_user_meta_table ) )
$bbdb->usermeta = $bb->custom_user_meta_table;
else
$bbdb->usermeta = $wpdb->usermeta;
$bbdb->prefix = $bb_table_prefix;
define( 'BB_INSTALLING', false );
/* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
if ( is_object( $wp_roles ) ) {
$bb_roles = $wp_roles;
bb_init_roles( $bb_roles );
}
do_action( 'bb_got_roles' );
do_action( 'bb_init' );
do_action( 'init_roles' );
$bb_current_user = $current_user;
$wp_users_object = new BP_Forums_BB_Auth;
if ( !isset( $wp_taxonomy_object ) )
$wp_taxonomy_object = new BB_Taxonomy( $bbdb );
$wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
// Set a site id if there isn't one already
if ( !isset( $bb->site_id ) )
$bb->site_id = BP_ROOT_BLOG;
/* Check if the tables are installed, if not, install them */
if ( !$tables_installed ) {
require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
/* Backticks and "IF NOT EXISTS" break the dbDelta function. */
dbDelta( str_replace( ' IF NOT EXISTS', '', str_replace( '`', '', $bb_queries ) ) );
require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
bb_update_db_version();
/* Set the site admins as the keymasters */
$site_admins = get_site_option( 'site_admins', array('admin') );
foreach ( (array)$site_admins as $site_admin )
update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );
// Create the first forum.
bb_new_forum( array( 'forum_name' => 'Default Forum' ) );
// Set the site URI
bb_update_option( 'uri', BB_URL );
}
register_shutdown_function( create_function( '', 'do_action("bb_shutdown");' ) );
}
示例8: array
echo "<li>Allocated memory is {$all_mem_size}</li>\n";
}
if (defined('W2BC_ALLOW_SYNC') && W2BC_ALLOW_SYNC == true) {
$notposts = array();
}
$last_comment_date = '1970-01-02 00:00:01';
foreach ((array) $posts as $post) {
echo "<li>Processing post #{$post->ID} (<a href='{$post->guid}'>{$post->post_title}</a>)\n<ul>\n";
if (defined('W2BC_CONVERT_FROM_TIME') && W2BC_CONVERT_FROM_TIME !== false && defined('W2BC_DEBUG') && W2BC_DEBUG == true) {
echo "<li>Post date/time is {$post->post_date} (GMT - {$post->post_date_gmt})</li>\n";
}
/* Category <-> Forum */
$cats = get_the_category($post->ID);
$cat = $cats[0];
if (!($forum = bb_get_forum(bb_slug_sanitize($cat->name)))) {
if ($forum_id = bb_new_forum(array('forum_name' => $cat->name, 'forum_desc' => $cat->description))) {
echo "<li>Added category #{$cat->term_id} ({$cat->name}) as forum #{$forum_id}</li>\n";
} else {
echo "<li><em>There was a problem in adding category #{$cat->term_id} ({$cat->name}) as a forum and thus post #{$post->ID} couldn't be added as a topic.</em></li></ul></li>\n";
continue;
}
} else {
$forum_id = $forum->forum_id;
}
if (defined('W2BC_DEBUG') && W2BC_DEBUG == true) {
echo "<li>Topic's forum is <a href=\"" . bb_get_uri('forum.php', array('id' => $forum_id)) . "\">#{$forum_id}</a> ({$cat->name})</li>\n";
}
/* Post Tag <-> Topic Tag */
$tags = '';
if ($posttags = get_the_tags()) {
foreach ($posttags as $tag) {