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


PHP groups_check_slug函数代码示例

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


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

示例1: save

 /**
  * Save the current group to the database.
  *
  * @return bool True on success, false on failure.
  */
 public function save()
 {
     global $wpdb;
     $bp = buddypress();
     $this->creator_id = apply_filters('groups_group_creator_id_before_save', $this->creator_id, $this->id);
     $this->name = apply_filters('groups_group_name_before_save', $this->name, $this->id);
     $this->slug = apply_filters('groups_group_slug_before_save', $this->slug, $this->id);
     $this->description = apply_filters('groups_group_description_before_save', $this->description, $this->id);
     $this->status = apply_filters('groups_group_status_before_save', $this->status, $this->id);
     $this->enable_forum = apply_filters('groups_group_enable_forum_before_save', $this->enable_forum, $this->id);
     $this->date_created = apply_filters('groups_group_date_created_before_save', $this->date_created, $this->id);
     /**
      * Fires before the current group item gets saved.
      *
      * Please use this hook to filter the properties above. Each part will be passed in.
      *
      * @since 1.0.0
      *
      * @param BP_Groups_Group $this Current instance of the group item being saved. Passed by reference.
      */
     do_action_ref_array('groups_group_before_save', array(&$this));
     // Groups need at least a name.
     if (empty($this->name)) {
         return false;
     }
     // Set slug with group title if not passed.
     if (empty($this->slug)) {
         $this->slug = sanitize_title($this->name);
     }
     // Sanity check.
     if (empty($this->slug)) {
         return false;
     }
     // Check for slug conflicts if creating new group.
     if (empty($this->id)) {
         $this->slug = groups_check_slug($this->slug);
     }
     if (!empty($this->id)) {
         $sql = $wpdb->prepare("UPDATE {$bp->groups->table_name} SET\n\t\t\t\t\tcreator_id = %d,\n\t\t\t\t\tname = %s,\n\t\t\t\t\tslug = %s,\n\t\t\t\t\tdescription = %s,\n\t\t\t\t\tstatus = %s,\n\t\t\t\t\tenable_forum = %d,\n\t\t\t\t\tdate_created = %s\n\t\t\t\tWHERE\n\t\t\t\t\tid = %d\n\t\t\t\t", $this->creator_id, $this->name, $this->slug, $this->description, $this->status, $this->enable_forum, $this->date_created, $this->id);
     } else {
         $sql = $wpdb->prepare("INSERT INTO {$bp->groups->table_name} (\n\t\t\t\t\tcreator_id,\n\t\t\t\t\tname,\n\t\t\t\t\tslug,\n\t\t\t\t\tdescription,\n\t\t\t\t\tstatus,\n\t\t\t\t\tenable_forum,\n\t\t\t\t\tdate_created\n\t\t\t\t) VALUES (\n\t\t\t\t\t%d, %s, %s, %s, %s, %d, %s\n\t\t\t\t)", $this->creator_id, $this->name, $this->slug, $this->description, $this->status, $this->enable_forum, $this->date_created);
     }
     if (false === $wpdb->query($sql)) {
         return false;
     }
     if (empty($this->id)) {
         $this->id = $wpdb->insert_id;
     }
     /**
      * Fires after the current group item has been saved.
      *
      * @since 1.0.0
      *
      * @param BP_Groups_Group $this Current instance of the group item that was saved. Passed by reference.
      */
     do_action_ref_array('groups_group_after_save', array(&$this));
     wp_cache_delete($this->id, 'bp_groups');
     return true;
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:64,代码来源:class-bp-groups-group.php

示例2: 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

示例3: groups_create_group

function groups_create_group($args = '')
{
    extract($args);
    /**
     * Possible parameters (pass as assoc array):
     *	'group_id'
     *	'creator_id'
     *	'name'
     *	'description'
     *	'slug'
     *	'status'
     *	'enable_forum'
     *	'date_created'
     */
    if (!empty($group_id)) {
        $group = groups_get_group(array('group_id' => $group_id));
    } else {
        $group = new BP_Groups_Group();
    }
    if (!empty($creator_id)) {
        $group->creator_id = $creator_id;
    } else {
        $group->creator_id = bp_loggedin_user_id();
    }
    if (isset($name)) {
        $group->name = $name;
    }
    if (isset($description)) {
        $group->description = $description;
    }
    if (isset($slug) && groups_check_slug($slug)) {
        $group->slug = $slug;
    }
    if (isset($status)) {
        if (groups_is_valid_status($status)) {
            $group->status = $status;
        }
    }
    if (isset($enable_forum)) {
        $group->enable_forum = $enable_forum;
    } else {
        if (empty($group_id) && !isset($enable_forum)) {
            $group->enable_forum = 1;
        }
    }
    if (isset($date_created)) {
        $group->date_created = $date_created;
    }
    if (!$group->save()) {
        return false;
    }
    // If this is a new group, set up the creator as the first member and admin
    if (empty($group_id)) {
        $member = new BP_Groups_Member();
        $member->group_id = $group->id;
        $member->user_id = $group->creator_id;
        $member->is_admin = 1;
        $member->user_title = __('Group Admin', 'buddypress');
        $member->is_confirmed = 1;
        $member->date_modified = bp_core_current_time();
        $member->save();
        groups_update_groupmeta($group->id, 'last_activity', bp_core_current_time());
        do_action('groups_create_group', $group->id, $member, $group);
    } else {
        do_action('groups_update_group', $group->id, $group);
    }
    do_action('groups_created_group', $group->id, $group);
    return $group->id;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:69,代码来源:bp-groups-functions.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: 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

示例6: save

 /**
  * Save the current group to the database.
  *
  * @return bool True on success, false on failure.
  */
 public function save()
 {
     global $wpdb, $bp;
     $this->creator_id = apply_filters('groups_group_creator_id_before_save', $this->creator_id, $this->id);
     $this->name = apply_filters('groups_group_name_before_save', $this->name, $this->id);
     $this->slug = apply_filters('groups_group_slug_before_save', $this->slug, $this->id);
     $this->description = apply_filters('groups_group_description_before_save', $this->description, $this->id);
     $this->status = apply_filters('groups_group_status_before_save', $this->status, $this->id);
     $this->enable_forum = apply_filters('groups_group_enable_forum_before_save', $this->enable_forum, $this->id);
     $this->date_created = apply_filters('groups_group_date_created_before_save', $this->date_created, $this->id);
     do_action_ref_array('groups_group_before_save', array(&$this));
     // Groups need at least a name
     if (empty($this->name)) {
         return false;
     }
     // Set slug with group title if not passed
     if (empty($this->slug)) {
         $this->slug = sanitize_title($this->name);
     }
     // Sanity check
     if (empty($this->slug)) {
         return false;
     }
     // Check for slug conflicts if creating new group
     if (empty($this->id)) {
         $this->slug = groups_check_slug($this->slug);
     }
     if (!empty($this->id)) {
         $sql = $wpdb->prepare("UPDATE {$bp->groups->table_name} SET\n\t\t\t\t\tcreator_id = %d,\n\t\t\t\t\tname = %s,\n\t\t\t\t\tslug = %s,\n\t\t\t\t\tdescription = %s,\n\t\t\t\t\tstatus = %s,\n\t\t\t\t\tenable_forum = %d,\n\t\t\t\t\tdate_created = %s\n\t\t\t\tWHERE\n\t\t\t\t\tid = %d\n\t\t\t\t", $this->creator_id, $this->name, $this->slug, $this->description, $this->status, $this->enable_forum, $this->date_created, $this->id);
     } else {
         $sql = $wpdb->prepare("INSERT INTO {$bp->groups->table_name} (\n\t\t\t\t\tcreator_id,\n\t\t\t\t\tname,\n\t\t\t\t\tslug,\n\t\t\t\t\tdescription,\n\t\t\t\t\tstatus,\n\t\t\t\t\tenable_forum,\n\t\t\t\t\tdate_created\n\t\t\t\t) VALUES (\n\t\t\t\t\t%d, %s, %s, %s, %s, %d, %s\n\t\t\t\t)", $this->creator_id, $this->name, $this->slug, $this->description, $this->status, $this->enable_forum, $this->date_created);
     }
     if (false === $wpdb->query($sql)) {
         return false;
     }
     if (empty($this->id)) {
         $this->id = $wpdb->insert_id;
     }
     do_action_ref_array('groups_group_after_save', array(&$this));
     wp_cache_delete($this->id, 'bp_groups');
     return true;
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:47,代码来源:bp-groups-classes.php

示例7: groups_create_group

function groups_create_group( $args = '' ) {
	global $bp;

	extract( $args );

	/**
	 * Possible parameters (pass as assoc array):
	 *	'group_id'
	 *	'creator_id'
	 *	'name'
	 *	'description'
	 *	'slug'
	 *	'status'
	 *	'enable_forum'
	 *	'date_created'
	 */

	if ( $group_id )
		$group = new BP_Groups_Group( $group_id );
	else
		$group = new BP_Groups_Group;

	if ( $creator_id )
		$group->creator_id = $creator_id;
	else
		$group->creator_id = $bp->loggedin_user->id;

	if ( isset( $name ) )
		$group->name = $name;

	if ( isset( $description ) )
		$group->description = $description;

	if ( isset( $slug ) && groups_check_slug( $slug ) )
		$group->slug = $slug;

	if ( isset( $status ) ) {
		if ( groups_is_valid_status( $status ) )
			$group->status = $status;
	}

	if ( isset( $enable_forum ) )
		$group->enable_forum = $enable_forum;
	else if ( !$group_id && !isset( $enable_forum ) )
		$group->enable_forum = 1;

	if ( isset( $date_created ) )
		$group->date_created = $date_created;

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

	if ( !$group_id ) {
		// If this is a new group, set up the creator as the first member and admin
		$member = new BP_Groups_Member;
		$member->group_id = $group->id;
		$member->user_id = $group->creator_id;
		$member->is_admin = 1;
		$member->user_title = __( 'Group Admin', 'buddypress' );
		$member->is_confirmed = 1;
		$member->date_modified = gmdate( "Y-m-d H:i:s" );

		$member->save();
		do_action( 'groups_create_group', $group->id, $member, $group );

	} else {
		do_action( 'groups_update_group', $group->id, $group );
	}

	do_action( 'groups_created_group', $group->id );

	return $group->id;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:73,代码来源:bp-groups.php

示例8: 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

示例9: groups_create_group

function groups_create_group($step, $group_id)
{
    global $bp, $create_group_step, $group_obj, $bbpress_live;
    if (is_numeric($step) && (1 == (int) $step || 2 == (int) $step || 3 == (int) $step || 4 == (int) $step)) {
        if (!$group_obj) {
            $group_obj = new BP_Groups_Group($group_id);
        }
        switch ($step) {
            case '1':
                if (!check_admin_referer('groups_step1_save')) {
                    return false;
                }
                if ($_POST['group-name'] != '' && $_POST['group-desc'] != '') {
                    $group_obj->creator_id = $bp->loggedin_user->id;
                    $group_obj->name = stripslashes($_POST['group-name']);
                    $group_obj->description = stripslashes($_POST['group-desc']);
                    $group_obj->news = stripslashes($_POST['group-news']);
                    $slug = groups_check_slug(sanitize_title($_POST['group-name']));
                    $group_obj->slug = $slug;
                    $group_obj->status = 'public';
                    $group_obj->is_invitation_only = 0;
                    $group_obj->enable_wire = 1;
                    $group_obj->enable_forum = 1;
                    $group_obj->enable_photos = 1;
                    $group_obj->photos_admin_only = 0;
                    $group_obj->date_created = time();
                    if (!$group_obj->save()) {
                        return false;
                    }
                    // Save the creator as the group administrator
                    $admin = new BP_Groups_Member($bp->loggedin_user->id, $group_obj->id);
                    $admin->is_admin = 1;
                    $admin->user_title = __('Group Admin', 'buddypress');
                    $admin->date_modified = time();
                    $admin->inviter_id = 0;
                    $admin->is_confirmed = 1;
                    if (!$admin->save()) {
                        return false;
                    }
                    do_action('groups_create_group_step1_save');
                    /* Set groupmeta */
                    groups_update_groupmeta($group_obj->id, 'total_member_count', 1);
                    groups_update_groupmeta($group_obj->id, 'last_activity', time());
                    groups_update_groupmeta($group_obj->id, 'theme', 'buddypress');
                    groups_update_groupmeta($group_obj->id, 'stylesheet', 'buddypress');
                    return $group_obj->id;
                }
                return false;
                break;
            case '2':
                if (!check_admin_referer('groups_step2_save')) {
                    return false;
                }
                $group_obj->status = 'public';
                $group_obj->is_invitation_only = 0;
                $group_obj->enable_wire = 1;
                $group_obj->enable_forum = 1;
                $group_obj->enable_photos = 1;
                $group_obj->photos_admin_only = 0;
                if (!isset($_POST['group-show-wire'])) {
                    $group_obj->enable_wire = 0;
                }
                if (!isset($_POST['group-show-forum'])) {
                    $group_obj->enable_forum = 0;
                } else {
                    /* Create the forum if enable_forum = 1 */
                    if (function_exists('bp_forums_setup') && '' == groups_get_groupmeta($group_obj->id, 'forum_id')) {
                        groups_new_group_forum();
                    }
                }
                if (!isset($_POST['group-show-photos'])) {
                    $group_obj->enable_photos = 0;
                }
                if ($_POST['group-photos-status'] != 'all') {
                    $group_obj->photos_admin_only = 1;
                }
                if ('private' == $_POST['group-status']) {
                    $group_obj->status = 'private';
                } else {
                    if ('hidden' == $_POST['group-status']) {
                        $group_obj->status = 'hidden';
                    }
                }
                if (!$group_obj->save()) {
                    return false;
                }
                /* Record in activity streams */
                groups_record_activity(array('item_id' => $group_obj->id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'is_private' => 0));
                do_action('groups_create_group_step2_save');
                return $group_obj->id;
                break;
            case '3':
                if (!check_admin_referer('groups_step3_save')) {
                    return false;
                }
                if (isset($_POST['skip'])) {
                    return $group_obj->id;
                }
                // Image already cropped and uploaded, lets store a reference in the DB.
                if (!wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !($result = bp_core_avatar_cropstore($_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $group_obj->id))) {
//.........这里部分代码省略.........
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:101,代码来源:bp-groups.php

示例10: bp_ning_import_get_discussions

function bp_ning_import_get_discussions()
{
    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());
    $discussions = bp_ning_import_prepare_json('discussions');
    //delete_option('bp_ning_discussions_imported');
    $imported = get_option('bp_ning_discussions_imported', array());
    $counter = 0;
    foreach ((array) $discussions as $discussion_key => $discussion) {
        unset($topic_id);
        if (isset($imported[$discussion->id])) {
            continue;
        }
        if ($counter >= 10) {
            update_option('bp_ning_discussions_imported', $imported);
            printf(__('%d out of %d discussions done.'), count($imported), count($discussions));
            return false;
        }
        $slug = sanitize_title(esc_attr($discussion->category));
        $ning_group_creator_id = $discussion->contributorName;
        $creator_id = $ning_id_array[$ning_group_creator_id];
        if (!$creator_id) {
            $what++;
            continue;
        }
        $ndate = strtotime($discussion->createdDate);
        $date_created = date("Y-m-d H:i:s", $ndate);
        if (isset($discussion->category)) {
            $ning_group_id = $discussion->category;
            $group_id = $ning_group_id_array[$ning_group_id];
        } else {
            if (isset($discussion->groupId)) {
                $ngroup_id = $discussion->groupId;
                $group_id = $ning_group_id_array[$ngroup_id];
            } else {
                continue;
                // todo fix me!
            }
        }
        $group = new BP_Groups_Group($group_id);
        $args = array('topic_title' => $discussion->title, 'topic_slug' => groups_check_slug(sanitize_title(esc_attr($discussion->title))), 'topic_text' => $discussion->description, 'topic_poster' => $creator_id, 'topic_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_last_poster' => $creator_id, 'topic_last_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_start_time' => $date_created, 'topic_time' => $date_created, 'forum_id' => groups_get_groupmeta($group_id, 'forum_id'));
        $query = "SELECT `topic_id` FROM wp_bb_topics WHERE topic_title = '%s' AND topic_start_time = '%s' LIMIT 1";
        $q = $wpdb->prepare($query, $args['topic_title'], $args['topic_start_time']);
        $topic_exists = $wpdb->get_results($q);
        if (isset($topic_exists[0])) {
            echo "<em>- Topic {$discussion->title} already exists</em><br />";
            $imported[$discussion->id] = true;
            continue;
        }
        if (!$args['forum_id']) {
            echo "No forum id - skipping";
            continue;
        }
        if (!($topic_id = bp_forums_new_topic($args))) {
            // TODO: WTF?
            return false;
            echo "<h2>Refresh to import more discussions</h2>";
            die;
        } else {
            bp_ning_import_process_inline_images_new('discussions', $topic_id, 'topic');
            echo "<strong>- Created topic: {$discussion->title}</strong><br />";
        }
        $activity_content = bp_create_excerpt($discussion->description);
        $skip_activity = get_option('bp_ning_skip_forum_activity');
        if (!$skip_activity) {
            $topic = bp_forums_get_topic_details($topic_id);
            // Activity item
            $activity_action = sprintf(__('%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink($creator_id), '<a href="' . bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/">' . esc_html($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_html($group->name) . '</a>');
            groups_record_activity(array('user_id' => $creator_id, 'action' => apply_filters('groups_activity_new_forum_topic_action', $activity_action, $discussion->description, $topic), 'content' => apply_filters('groups_activity_new_forum_topic_content', $activity_content, $discussion->description, $topic), 'primary_link' => apply_filters('groups_activity_new_forum_topic_primary_link', bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/'), 'type' => 'new_forum_topic', 'item_id' => $group_id, 'secondary_item_id' => $topic->topic_id, 'recorded_time' => $date_created, 'hide_sitewide' => 0));
            do_action('groups_new_forum_topic', $group_id, $topic);
        }
        // Now check for comments
        if (isset($discussion->comments)) {
            foreach ($discussion->comments as $reply) {
                $ning_group_creator_id = $reply->contributorName;
                $creator_id = $ning_id_array[$ning_group_creator_id];
                $ndate = strtotime($reply->createdDate);
                $date_created = date("Y-m-d H:i:s", $ndate);
                $args = array('topic_id' => $topic_id, 'post_text' => $reply->description, 'post_time' => $date_created, 'poster_id' => $creator_id, 'poster_ip' => '192.168.1.1');
                $query = "SELECT * FROM wp_bb_posts WHERE topic_id = '%s' AND post_text = '%s'";
                $q = $wpdb->prepare($query, $args['topic_id'], $args['post_text']);
                $post_exists = $wpdb->get_results($q);
                if ($post_exists) {
                    continue;
                }
                $post_id = bp_forums_insert_post($args);
                if ($post_id) {
                    bp_ning_import_process_inline_images_new('discussions', $post_id, 'topic_reply');
                    $import_summary = esc_html(bp_create_excerpt($reply->description, 100, array('html' => false)));
                    echo "<em>- Imported forum post: {$import_summary}</em><br />";
                }
                if (!groups_is_user_member($creator_id, $group_id)) {
                    if (!$bp->groups->current_group) {
                        $bp->groups->current_group = new BP_Groups_Group($group_id);
                    }
                    $new_member = new BP_Groups_Member();
                    $new_member->group_id = $group_id;
//.........这里部分代码省略.........
开发者ID:boonebgorges,项目名称:Import-from-Ning,代码行数:101,代码来源:bp-functions.php


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