当前位置: 首页>>代码示例>>PHP>>正文


PHP groups_new_group_forum函数代码示例

本文整理汇总了PHP中groups_new_group_forum函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_new_group_forum函数的具体用法?PHP groups_new_group_forum怎么用?PHP groups_new_group_forum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了groups_new_group_forum函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: groups_edit_group_settings

/**
 * Edit the base details for a group.
 *
 * These are the settings that appear on the Settings page of the group's Admin
 * section (privacy settings, "enable forum", invitation status).
 *
 * @param int         $group_id      ID of the group.
 * @param bool        $enable_forum  Whether to enable a forum for the group.
 * @param string      $status        Group status. 'public', 'private', 'hidden'.
 * @param string|bool $invite_status Optional. Who is allowed to send invitations
 *                                   to the group. 'members', 'mods', or 'admins'.
 *
 * @return bool True on success, false on failure.
 */
function groups_edit_group_settings($group_id, $enable_forum, $status, $invite_status = false)
{
    $group = groups_get_group(array('group_id' => $group_id));
    $group->enable_forum = $enable_forum;
    /***
     * Before we potentially switch the group status, if it has been changed to public
     * from private and there are outstanding membership requests, auto-accept those requests.
     */
    if ('private' == $group->status && 'public' == $status) {
        groups_accept_all_pending_membership_requests($group->id);
    }
    // Now update the status
    $group->status = $status;
    if (!$group->save()) {
        return false;
    }
    // If forums have been enabled, and a forum does not yet exist, we need to create one.
    if ($group->enable_forum) {
        if (bp_is_active('forums') && !groups_get_groupmeta($group->id, 'forum_id')) {
            groups_new_group_forum($group->id, $group->name, $group->description);
        }
    }
    // Set the invite status
    if ($invite_status) {
        groups_update_groupmeta($group->id, 'invite_status', $invite_status);
    }
    groups_update_groupmeta($group->id, 'last_activity', bp_core_current_time());
    /**
     * Fires after the update of a groups settings.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group that was updated.
     */
    do_action('groups_settings_updated', $group->id);
    return true;
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:51,代码来源:bp-groups-functions.php

示例2: bpdd_import_groups

function bpdd_import_groups($users = false)
{
    $groups = array();
    $group_ids = array();
    if (empty($users)) {
        $users = get_users();
    }
    require dirname(__FILE__) . '/data/groups.php';
    foreach ($groups as $group) {
        $cur = groups_create_group(array('creator_id' => $users[array_rand($users)]->ID, 'name' => $group['name'], 'description' => $group['description'], 'slug' => groups_check_slug(sanitize_title(esc_attr($group['name']))), 'status' => $group['status'], 'date_created' => bpdd_get_random_date(30, 5), 'enable_forum' => $group['enable_forum']));
        groups_update_groupmeta($cur, 'total_member_count', 1);
        groups_update_groupmeta($cur, 'last_activity', bpdd_get_random_date(10));
        // create forums if Forum Component is active
        if (bp_is_active('forums') && bp_forums_is_installed_correctly()) {
            groups_new_group_forum($cur, $group['name'], $group['description']);
        }
        $group_ids[] = $cur;
    }
    return $group_ids;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:20,代码来源:bp-default-data.php

示例3: groups_action_create_group

/**
 * Catch and process group creation form submissions.
 */
function groups_action_create_group()
{
    global $bp;
    // If we're not at domain.org/groups/create/ then return false
    if (!bp_is_groups_component() || !bp_is_current_action('create')) {
        return false;
    }
    if (!is_user_logged_in()) {
        return false;
    }
    if (!bp_user_can_create_groups()) {
        bp_core_add_message(__('Sorry, you are not allowed to create groups.', 'buddypress'), 'error');
        bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()));
    }
    // Make sure creation steps are in the right order
    groups_action_sort_creation_steps();
    // If no current step is set, reset everything so we can start a fresh group creation
    $bp->groups->current_create_step = bp_action_variable(1);
    if (!bp_get_groups_current_create_step()) {
        unset($bp->groups->current_create_step);
        unset($bp->groups->completed_create_steps);
        setcookie('bp_new_group_id', false, time() - 1000, COOKIEPATH);
        setcookie('bp_completed_create_steps', false, time() - 1000, COOKIEPATH);
        $reset_steps = true;
        $keys = array_keys($bp->groups->group_creation_steps);
        bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . array_shift($keys) . '/');
    }
    // If this is a creation step that is not recognized, just redirect them back to the first screen
    if (bp_get_groups_current_create_step() && empty($bp->groups->group_creation_steps[bp_get_groups_current_create_step()])) {
        bp_core_add_message(__('There was an error saving group details. Please try again.', 'buddypress'), 'error');
        bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/');
    }
    // Fetch the currently completed steps variable
    if (isset($_COOKIE['bp_completed_create_steps']) && !isset($reset_steps)) {
        $bp->groups->completed_create_steps = json_decode(base64_decode(stripslashes($_COOKIE['bp_completed_create_steps'])));
    }
    // Set the ID of the new group, if it has already been created in a previous step
    if (isset($_COOKIE['bp_new_group_id'])) {
        $bp->groups->new_group_id = (int) $_COOKIE['bp_new_group_id'];
        $bp->groups->current_group = groups_get_group(array('group_id' => $bp->groups->new_group_id));
        // Only allow the group creator to continue to edit the new group
        if (!bp_is_group_creator($bp->groups->current_group, bp_loggedin_user_id())) {
            bp_core_add_message(__('Only the group creator may continue editing this group.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/');
        }
    }
    // If the save, upload or skip button is hit, lets calculate what we need to save
    if (isset($_POST['save'])) {
        // Check the nonce
        check_admin_referer('groups_create_save_' . bp_get_groups_current_create_step());
        if ('group-details' == bp_get_groups_current_create_step()) {
            if (empty($_POST['group-name']) || empty($_POST['group-desc']) || !strlen(trim($_POST['group-name'])) || !strlen(trim($_POST['group-desc']))) {
                bp_core_add_message(__('Please fill in all of the required fields', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
            $new_group_id = isset($bp->groups->new_group_id) ? $bp->groups->new_group_id : 0;
            if (!($bp->groups->new_group_id = groups_create_group(array('group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug(sanitize_title(esc_attr($_POST['group-name']))), 'date_created' => bp_core_current_time(), 'status' => 'public')))) {
                bp_core_add_message(__('There was an error saving group details, please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
        }
        if ('group-settings' == bp_get_groups_current_create_step()) {
            $group_status = 'public';
            $group_enable_forum = 1;
            if (!isset($_POST['group-show-forum'])) {
                $group_enable_forum = 0;
            } else {
                // Create the forum if enable_forum = 1
                if (bp_is_active('forums') && !groups_get_groupmeta($bp->groups->new_group_id, 'forum_id')) {
                    groups_new_group_forum();
                }
            }
            if ('private' == $_POST['group-status']) {
                $group_status = 'private';
            } else {
                if ('hidden' == $_POST['group-status']) {
                    $group_status = 'hidden';
                }
            }
            if (!($bp->groups->new_group_id = groups_create_group(array('group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum)))) {
                bp_core_add_message(__('There was an error saving group details, please try again.', 'buddypress'), 'error');
                bp_core_redirect(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/create/step/' . bp_get_groups_current_create_step() . '/');
            }
            // Set the invite status
            // Checked against a whitelist for security
            $allowed_invite_status = apply_filters('groups_allowed_invite_status', array('members', 'mods', 'admins'));
            $invite_status = !empty($_POST['group-invite-status']) && in_array($_POST['group-invite-status'], (array) $allowed_invite_status) ? $_POST['group-invite-status'] : 'members';
            groups_update_groupmeta($bp->groups->new_group_id, 'invite_status', $invite_status);
        }
        if ('group-invites' === bp_get_groups_current_create_step()) {
            if (!empty($_POST['friends'])) {
                foreach ((array) $_POST['friends'] as $friend) {
                    groups_invite_user(array('user_id' => $friend, 'group_id' => $bp->groups->new_group_id));
                }
            }
            groups_send_invites(bp_loggedin_user_id(), $bp->groups->new_group_id);
        }
//.........这里部分代码省略.........
开发者ID:eresyyl,项目名称:mk,代码行数:101,代码来源:bp-groups-actions.php

示例4: bp_group_organizer_import_group

function bp_group_organizer_import_group($group, $args = array())
{
    if (empty($group['name'])) {
        return false;
    }
    if (isset($group['path'])) {
        if (bpgo_is_hierarchy_available()) {
            // Try to place the group in the requested spot, but if the spot doesn't exist (e.g. because of slug conflicts)
            // then place it as far down the tree as possible
            $parent_path = $group['path'];
            do {
                $parent_path = dirname($parent_path);
                $parent_id = BP_Groups_Hierarchy::get_id_from_slug($parent_path);
            } while ($parent_path != '.' && $parent_id == 0);
            $group['parent_id'] = $parent_id ? $parent_id : 0;
        }
        $group['slug'] = basename($group['path']);
        unset($group['path']);
    }
    $group['slug'] = groups_check_slug($group['slug']);
    $group_id = groups_create_group($group);
    if (!$group_id) {
        return false;
    }
    groups_update_groupmeta($group_id, 'total_member_count', 1);
    if (bpgo_is_hierarchy_available()) {
        $obj_group = new BP_Groups_Hierarchy($group_id);
        $obj_group->parent_id = (int) $group['parent_id'];
        $obj_group->save();
    }
    // Create the forum if enable_forum is checked
    if ($group['enable_forum']) {
        // Ensure group forums are activated, and group does not already have a forum
        if (bp_is_active('forums')) {
            // Check for BuddyPress group forums
            if (!groups_get_groupmeta($group_id, 'forum_id')) {
                groups_new_group_forum($group_id, $group['name'], $group['description']);
            }
        } else {
            if (function_exists('bbp_is_group_forums_active') && bbp_is_group_forums_active()) {
                // Check for bbPress group forums
                if (count(bbp_get_group_forum_ids($group_id)) == 0) {
                    // Create the group forum - implementation from BBP_Forums_Group_Extension:create_screen_save
                    // Set the default forum status
                    switch ($group['status']) {
                        case 'hidden':
                            $status = bbp_get_hidden_status_id();
                            break;
                        case 'private':
                            $status = bbp_get_private_status_id();
                            break;
                        case 'public':
                        default:
                            $status = bbp_get_public_status_id();
                            break;
                    }
                    // Create the initial forum
                    $forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => $group['name'], 'post_content' => $group['description'], 'post_status' => $status));
                    bbp_add_forum_id_to_group($group_id, $forum_id);
                    bbp_add_group_id_to_forum($forum_id, $group_id);
                }
            }
        }
    }
    do_action('bp_group_organizer_import_group', $group_id);
    return $group_id;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:67,代码来源:group-organizer-import.php

示例5: groups_edit_group_settings

function groups_edit_group_settings( $group_id, $enable_forum, $status ) {
	global $bp;

	$group = new BP_Groups_Group( $group_id );
	$group->enable_forum = $enable_forum;

	/***
	 * Before we potentially switch the group status, if it has been changed to public
	 * from private and there are outstanding membership requests, auto-accept those requests.
	 */
	if ( 'private' == $group->status && 'public' == $status )
		groups_accept_all_pending_membership_requests( $group->id );

	/* Now update the status */
	$group->status = $status;

	if ( !$group->save() )
		return false;

	/* If forums have been enabled, and a forum does not yet exist, we need to create one. */
	if ( $group->enable_forum ) {
		if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $group->id, 'forum_id' ) ) {
			groups_new_group_forum( $group->id, $group->name, $group->description );
		}
	}

	groups_update_groupmeta( $group->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
	do_action( 'groups_settings_updated', $group->id );

	return true;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:31,代码来源:bp-groups.php

示例6: bp_group_organizer_admin_page

function bp_group_organizer_admin_page()
{
    global $wpdb;
    // Permissions Check
    if (!current_user_can('manage_options')) {
        wp_die(__('Cheatin’ uh?'));
    }
    // Load all the nav menu interface functions
    require_once 'includes/group-meta-boxes.php';
    require_once 'includes/group-organizer-template.php';
    require_once 'includes/group-organizer.php';
    // Container for any messages displayed to the user
    $messages = array();
    // Container that stores the name of the active menu
    $nav_menu_selected_title = '';
    // Allowed actions: add, update, delete
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'edit';
    $errored = false;
    switch ($action) {
        case 'add-group':
            check_admin_referer('add-group', 'group-settings-column-nonce');
            $group['name'] = stripslashes($_POST['group_name']);
            $group['description'] = stripslashes($_POST['group_desc']);
            $group['slug'] = groups_check_slug($_POST['group_slug']);
            $group['status'] = $_POST['group_status'];
            $group['enable_forum'] = isset($_POST['group_forum']) ? true : false;
            $group['date_created'] = date('Y-m-d H:i:s');
            if ($group['slug'] != $_POST['group_slug']) {
                $messages[] = '<div class="updated warning"><p>' . sprintf(__('The group slug you specified was unavailable or invalid. This group was created with the slug: <code>%s</code>.', 'bp-group-organizer'), $group['slug']) . '</p></div>';
            }
            if (empty($group['name'])) {
                $messages[] = '<div class="error"><p>' . __('Group could not be created because one or more required fields were not filled in', 'bp-group-organizer') . '</p></div>';
                $errored = true;
            }
            if (!$errored) {
                $group_id = groups_create_group($group);
                if (!$group_id) {
                    $wpdb->show_errors();
                    $wpdb->print_error();
                    $messages[] = '<div class="error"><p>' . __('Group was not successfully created.', 'bp-group-organizer') . '</p></div>';
                } else {
                    $messages[] = '<div class="updated"><p>' . __('Group was created successfully.', 'bp-group-organizer') . '</p></div>';
                }
            }
            if (!empty($group_id)) {
                groups_update_groupmeta($group_id, 'total_member_count', 1);
                if (bpgo_is_hierarchy_available()) {
                    $obj_group = new BP_Groups_Hierarchy($group_id);
                    $obj_group->parent_id = (int) $_POST['group_parent'];
                    $obj_group->save();
                }
                // Create the forum if enable_forum is checked
                if ($group['enable_forum']) {
                    // Ensure group forums are activated, and group does not already have a forum
                    if (bp_is_active('forums')) {
                        // Check for BuddyPress group forums
                        if (!groups_get_groupmeta($group_id, 'forum_id')) {
                            groups_new_group_forum($group_id, $group['name'], $group['description']);
                        }
                    } else {
                        if (function_exists('bbp_is_group_forums_active') && bbp_is_group_forums_active()) {
                            // Check for bbPress group forums
                            if (count(bbp_get_group_forum_ids($group_id)) == 0) {
                                // Create the group forum - implementation from BBP_Forums_Group_Extension:create_screen_save
                                // Set the default forum status
                                switch ($group['status']) {
                                    case 'hidden':
                                        $status = bbp_get_hidden_status_id();
                                        break;
                                    case 'private':
                                        $status = bbp_get_private_status_id();
                                        break;
                                    case 'public':
                                    default:
                                        $status = bbp_get_public_status_id();
                                        break;
                                }
                                // Create the initial forum
                                $forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => $group['name'], 'post_content' => $group['description'], 'post_status' => $status));
                                bbp_add_forum_id_to_group($group_id, $forum_id);
                                bbp_add_group_id_to_forum($forum_id, $group_id);
                            }
                        }
                    }
                }
                do_action('bp_group_organizer_save_new_group_options', $group_id);
            }
            break;
        case 'delete-group':
            $group_id = (int) $_REQUEST['group_id'];
            check_admin_referer('delete-group_' . $group_id);
            break;
        case 'update':
            check_admin_referer('update-groups', 'update-groups-nonce');
            $groups_order = $_POST['group'];
            $parent_ids = $_POST['menu-item-parent-id'];
            $db_ids = $_POST['menu-item-db-id'];
            foreach ($groups_order as $id => $group) {
                $group_reference = new BP_Groups_Group($id);
                if (defined('BP_GROUP_HIERARCHY_IS_INSTALLED') && method_exists('BP_Groups_Hierarchy', 'get_tree')) {
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:index.php

示例7: groups_edit_group_settings

function groups_edit_group_settings($group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status)
{
    global $bp;
    /* Check the nonce first. */
    if (!check_admin_referer('groups_edit_group_settings')) {
        return false;
    }
    $group = new BP_Groups_Group($group_id, false, false);
    $group->enable_wire = $enable_wire;
    $group->enable_forum = $enable_forum;
    $group->enable_photos = $enable_photos;
    $group->photos_admin_only = $photos_admin_only;
    $group->status = $status;
    if (!$group->save()) {
        return false;
    }
    /* If forums have been enabled, and a forum does not yet exist, we need to create one. */
    if ($group->enable_forum) {
        if (function_exists('bp_forums_setup') && '' == groups_get_groupmeta($group->id, 'forum_id')) {
            groups_new_group_forum($group->id, $group->name, $group->description);
        }
    }
    do_action('groups_settings_updated', $group->id);
    return true;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:25,代码来源:bp-groups.php

示例8: bp_ning_import_get_discussion_groups

function bp_ning_import_get_discussion_groups()
{
    global $wpdb;
    $ning_id_array = get_option('bp_ning_user_array');
    // Get list of Ning groups for cross reference
    $groups = bp_ning_import_prepare_json('groups');
    $ning_group_id_array = get_option('bp_ning_group_array', array());
    // Loop through each discussion. If the topic doesn't have a corresponding group, create one. Then insert the forum items.
    $discussions = bp_ning_import_prepare_json('discussions');
    $counter = 0;
    foreach ((array) $discussions as $discussion_key => $discussion) {
        if (!isset($discussion->category)) {
            continue;
        }
        $ning_group_id = $discussion->category;
        if (isset($ning_group_id_array[$ning_group_id])) {
            continue;
        }
        // todo - what if a topic has no group and no category
        $slug = sanitize_title(esc_attr($discussion->category));
        $ning_group_creator_id = $discussion->contributorName;
        $creator_id = $ning_id_array[$ning_group_creator_id];
        $ndate = strtotime($discussion->createdDate);
        $date_created = date("Y-m-d H:i:s", $ndate);
        if (!($group_id = BP_Groups_Group::group_exists($slug))) {
            $args = array('creator_id' => $creator_id, 'name' => $discussion->category, 'description' => $discussion->category, 'slug' => groups_check_slug($slug), 'status' => 'public', 'enable_forum' => 1, 'date_created' => $date_created);
            if ($group_id = groups_create_group($args)) {
                groups_update_groupmeta($group_id, 'last_activity', $date_created);
                groups_update_groupmeta($group_id, 'total_member_count', 1);
                groups_new_group_forum($group_id, $discussion->category, $discussion->category);
                echo "<strong>Created group: {$discussion->category}</strong><br />";
                $ning_group_id_array[$ning_group_id] = $group_id;
                update_option('bp_ning_group_array', $ning_group_id_array);
            }
        } else {
            echo "<strong>Group already exists: {$discussion->category}</strong><br />";
            $ning_group_id_array[$ning_group_id] = $group_id;
            update_option('bp_ning_group_array', $ning_group_id_array);
        }
    }
}
开发者ID:boonebgorges,项目名称:Import-from-Ning,代码行数:41,代码来源:bp-functions.php


注:本文中的groups_new_group_forum函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。