本文整理汇总了PHP中BP_Groups_Group类的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Group类的具体用法?PHP BP_Groups_Group怎么用?PHP BP_Groups_Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BP_Groups_Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: meta_box_callback
//.........这里部分代码省略.........
$staddress = esc_attr($meta['staddress']);
}
if (isset($meta['city'])) {
$city = esc_attr($meta['city']);
}
if (isset($meta['state'])) {
$state = esc_attr($meta['state']);
}
if (isset($meta['pincode'])) {
$pincode = esc_attr($meta['pincode']);
}
if (isset($meta['country'])) {
$country = esc_attr($meta['country']);
}
}
echo '<div id="mapCanvas"></div>
<div id="infoPanel">
<h4>Current position:</h4>
<div class="markerStatus"></div>
<label style="display:block;width:200px;float:left;">' . __('Latitude', 'vibe-customtypes') . '</label><input type="text" class="text" id="latitude" name="' . $field['id'] . '[latitude] value="' . $lat . '" size="20" />
<label style="display:block;width:200px;float:left;">' . __('Longitude', 'vibe-customtypes') . '</label><input type="text" class="text" id="longitude" name="' . $field['id'] . '[longitude]" value="' . $long . '" size="20" />
<br /><b style="width:200px;float:left;">' . __('Closest Matching Address', 'vibe-customtypes') . '</b>
<div id="address"></div>
<br />
<label style="width:200px;float:left;">' . __('Street Address', 'vibe-customtypes') . '</label><input type="text" class="text" id="staddress" name="' . $field['id'] . '[staddress]" value="' . $staddress . '" size="20" /> <br />
<label style="width:200px;float:left;">' . __('City', 'vibe-customtypes') . '</label><input type="text" class="text" id="city" name="' . $field['id'] . '[city]" value="' . $city . '" size="20" /> <br />
<label style="width:200px;float:left;">' . __('State', 'vibe-customtypes') . '</label><input type="text" class="text" id="state" name="' . $field['id'] . '[state]" value="' . $state . '" size="20" /> <br />
<label style="width:200px;float:left;">' . __('Zip/Pin Code', 'vibe-customtypes') . '</label><input type="text" class="text" id="pincode" name="' . $field['id'] . '[pincode]" value="' . $pincode . '" size="20" /> <br />
<label style="width:200px;float:left;">' . __('Country', 'vibe-customtypes') . '</label><input type="text" class="text" id="country" name="' . $field['id'] . '[country]" value="' . $country . '" size="20" /> <br />
</div>
<br />' . $desc;
break;
case 'groups':
if (class_exists('BP_Groups_Group')) {
echo '<select name="' . $id . '" id="' . $id . '" class="selectgroup">';
if (!empty($meta)) {
$group = groups_get_group(array('group_id' => $meta));
echo '<option value="' . $meta . '" selected="SELECTED">' . $group->name . '</option>';
}
echo '</select>';
} else {
_e('Buddypress Groups is not Active', 'vibe-customtypes');
}
echo '<br />' . $desc;
break;
case 'selectmultigroups':
if (class_exists('BP_Groups_Group')) {
echo '<select name="' . $id . '[]" id="' . $id . '" class="select chzn-select" data-placeholder="' . __('Select groups', 'vibe-customtypes') . '" multiple>';
if ($meta == '' || !isset($meta)) {
$meta = $std;
}
$vgroups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 999, 'show_hidden' => true));
foreach ($vgroups['groups'] as $vgroup) {
if (is_array($meta)) {
echo '<option ' . (in_array($vgroup->id, $meta) ? 'SELECTED' : '') . ' value="' . $vgroup->id . '">' . $vgroup->name . '</option>';
} else {
echo '<option value="' . $vgroup->id . '" ' . selected($vgroup->id, $meta) . '>' . $vgroup->name . '</option>';
}
}
echo '</select>';
} else {
_e('Buddypress Groups is not Active', 'vibe-customtypes');
}
echo '<br />' . $desc;
break;
case 'curriculum':
示例2: update_object
function update_object($group_id, $fields)
{
$group = new BP_Groups_Group($group_id);
foreach ($fields as $field_name => $value) {
if (isset($group->field_name)) {
$group->field_name = $value;
}
}
$group->save();
return $group;
}
示例3: bp_group_organizer_export_csv
/**
* Export groups in CSV format
* @param string|array $format short name of format OR list of columns
* Column lists are based on properties of the Groups object, not columns in the database
*/
function bp_group_organizer_export_csv($format)
{
if (is_array($format)) {
$format = implode(',', $format);
}
// If Group Hierarchy is not installed, path is equivalent to slug
if ($format == 'path' && !bpgo_is_hierarchy_available()) {
$format == 'slug';
}
if (!strpos($format, ',')) {
// Short name was specified
switch ($format) {
case 'slug':
$fields = array('id', 'creator_id', 'name', 'slug', 'description', 'status', 'enable_forum', 'date_created');
if (bpgo_is_hierarchy_available()) {
$fields[] = 'parent_id';
}
break;
case 'path':
$fields = array('creator_id', 'name', 'path', 'description', 'status', 'enable_forum', 'date_created');
break;
default:
$fields = apply_filters('bp_group_organizer_get_csv_fields_format_' . $format, array());
break;
}
} else {
$fields = explode(',', $format);
}
if (!count($fields)) {
return false;
}
if (bpgo_is_hierarchy_available()) {
$groups_list = array('groups' => BP_Groups_Hierarchy::get_tree());
$groups_list['total'] = count($groups_list['groups']);
} else {
$groups_list = BP_Groups_Group::get('alphabetical');
}
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="' . 'bp-group-export.csv' . '";');
// Print header row
echo implode(',', $fields) . "\n";
foreach ($groups_list['groups'] as $group) {
foreach ($fields as $key => $field) {
if ($field == 'path') {
echo BP_Groups_Hierarchy::get_path($group->id);
} else {
if (in_array($field, array('name', 'description'))) {
echo '"' . stripslashes($group->{$field}) . '"';
} else {
echo $group->{$field};
}
}
if ($key < count($fields) - 1) {
echo ',';
}
}
echo "\n";
}
die;
}
示例4: bp_group_management_delete_group
function bp_group_management_delete_group($group_id)
{
global $bp;
$group = new BP_Groups_Group($group_id);
if (!$group->delete()) {
return false;
}
/* Delete all group activity from activity streams */
if (function_exists('bp_activity_delete_by_item_id')) {
bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id));
}
// Remove all outstanding invites for this group
groups_delete_all_group_invites($group_id);
// Remove all notifications for any user belonging to this group
bp_core_delete_all_notifications_by_type($group_id, $bp->groups->slug);
do_action('groups_delete_group', $group_id);
return true;
}
示例5: themefix_buddypress_groups_settings_extension
function themefix_buddypress_groups_settings_extension($args)
{
$groups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 100));
$the_groups = array();
foreach ($groups['groups'] as $key => $group) {
$the_groups[$group->id] = $group->name;
}
$extra = array('buddypress-group' => array('label' => __('Display a BuddyPress Group activity instead of post(s)', 'thememixfc'), 'description' => '', 'type' => 'checkbox'), 'buddypress-group-group' => array('label' => __('BuddyPress Group', 'thememixfc'), 'description' => '', 'type' => 'select', 'options' => $the_groups, 'requires' => array('buddypress-group', '', true)));
$args['col1'][0] = array_slice($args['col1'][0], 0, 1, true) + $extra + array_slice($args['col1'][0], 1, count($args['col1'][0]) - 1, true);
return $args;
}
示例6: themefix_buddypress_groups_settings_extension
function themefix_buddypress_groups_settings_extension($args)
{
if (!class_exists('BP_Groups_Group')) {
return $args;
}
$groups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 100));
$the_groups = array();
foreach ($groups['groups'] as $key => $group) {
$the_groups[$group->id] = $group->name;
}
$extra = array('buddypress-group' => array('label' => __('Display a BuddyPress Group activity instead of post(s)', 'thememix-pro-genesis'), 'description' => '', 'type' => 'checkbox'), 'buddypress-group-group' => array('label' => __('BuddyPress Group', 'thememix-pro-genesis'), 'description' => '', 'type' => 'select', 'options' => $the_groups, 'requires' => array('buddypress-group', '', true)), 'buddypress-group-count' => array('label' => __('Number of activities to show', 'thememix-pro-genesis'), 'description' => '', 'type' => 'select', 'options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 9), 'requires' => array('buddypress-group', '', true)));
$args['col1'][0] = array_slice($args['col1'][0], 0, 1, true) + $extra + array_slice($args['col1'][0], 1, count($args['col1'][0]) - 1, true);
return $args;
}
示例7: get_groups
function get_groups()
{
$user_id = get_current_user_id();
if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security') || !current_user_can('edit_posts')) {
_e('Security check Failed. Contact Administrator.', 'wplms-front-end');
die;
}
$q = $_POST['q'];
if (class_exists('BP_Groups_Group')) {
$vgroups = BP_Groups_Group::get(array('type' => 'alphabetical', 'per_page' => 999, 's' => $q['term']));
$return = array();
foreach ($vgroups['groups'] as $vgroup) {
$return[] = array('id' => $vgroup->id, 'text' => $vgroup->name);
}
}
print_r(json_encode($return));
die;
}
示例8: bp_group_reviews_extension
function bp_group_reviews_extension()
{
global $bp;
$this->group_id = BP_Groups_Group::group_exists($bp->current_item);
$this->name = __('Reviews', 'bpgr');
$this->slug = $bp->group_reviews->slug;
$this->nav_item_position = 22;
$this->enable_create_step = false;
$this->enable_nav_item = BP_Group_Reviews::current_group_is_available();
$this->enable_edit_item = false;
if (isset($_POST['review_submit'])) {
check_admin_referer('review_submit');
$has_posted = '';
if (empty($_POST['review_content']) || !(int) $_POST['rating']) {
// Something has gone wrong. Save the user's submitted data to reinsert into the post box after redirect
$cookie_data = array('review_content' => $_POST['review_content'], 'rating' => $_POST['rating']);
$cookie = json_encode($cookie_data);
setcookie('bpgr-data', $cookie, time() + 60 * 60 * 24, COOKIEPATH);
bp_core_add_message(__("Please make sure you fill in the review, and don't forget to provide a rating!", 'bpgr'), 'error');
} else {
/* Auto join this user if they are not yet a member of this group */
if (!is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
groups_join_group($bp->groups->current_group->id, $bp->loggedin_user->id);
}
if ($rating_id = $this->post_review(array('content' => $_POST['review_content'], 'rating' => (int) $_POST['rating']))) {
bp_core_add_message("Your review was posted successfully!");
$has_posted = groups_get_groupmeta($bp->groups->current_group->id, 'posted_review');
if (!in_array((int) $bp->loggedin_user->id, (array) $has_posted)) {
$has_posted[] = (int) $bp->loggedin_user->id;
}
groups_update_groupmeta($bp->groups->current_group->id, 'posted_review', $has_posted);
if ((int) $_POST['rating'] < 0) {
$_POST['rating'] = 1;
}
if ((int) $_POST['rating'] > 5) {
$_POST['rating'] = 5;
}
} else {
bp_core_add_message("There was a problem posting your review, please try again.", 'error');
}
}
bp_core_redirect(apply_filters('bpgr_after_post_redirect', trailingslashit(bp_get_group_permalink($bp->groups->current_group) . $this->slug, $has_posted)));
}
}
示例9: gtags_get_groups_by_tag
function gtags_get_groups_by_tag($limit = null, $page = null, $user_id = false, $search_terms = false, $group_tag = null)
{
global $wpdb, $bp;
$hidden_sql = $search_sql = $tag_sql = $pag_sql = '';
if ($limit && $page) {
$pag_sql = $wpdb->prepare(" LIMIT %d, %d", intval(($page - 1) * $limit), intval($limit));
}
if (!is_user_logged_in()) {
$hidden_sql = "AND g.status != 'hidden'";
}
if ($search_terms) {
$search_terms = like_escape($wpdb->escape($search_terms));
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
}
if ($group_tag) {
$group_tag = like_escape($wpdb->escape($group_tag));
$group_tag = stripslashes($group_tag);
$tag_sql = " AND ( gm3.meta_value LIKE '%%{$group_tag}%%' )";
}
$paged_groups = $wpdb->get_results("SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity, gm3.meta_value as gtags_group_tags FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND gm3.meta_key = 'gtags_group_tags' {$hidden_sql} {$search_sql} {$tag_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}");
// this is commented out because it doesn't really work due to the over-inclusive issue.
//$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND gm3.meta_key = 'gtags_group_tags' {$hidden_sql} {$search_sql} {$tag_sql}" );
// loop through results and return only exact matches in comma separated list.
$paged_groups2 = array();
foreach ((array) $paged_groups as $group) {
$items = explode(",", $group->gtags_group_tags);
$match = false;
foreach ($items as $item) {
if (trim(strtolower($item)) == strtolower($group_tag)) {
$match = true;
}
}
if ($match == true) {
$paged_groups2[] = $group;
}
}
$total_groups = count($paged_groups2);
// in place of the commented out code above
foreach ((array) $paged_groups2 as $group) {
$group_ids[] = $group->id;
}
$group_ids = $wpdb->escape(join(',', (array) $group_ids));
$paged_groups2 = BP_Groups_Group::get_group_extras(&$paged_groups2, $group_ids, 'popular');
return array('groups' => $paged_groups2, 'total' => $total_groups);
}
示例10: setup_globals
/**
* Set up component global data.
*
* The BP_GROUPS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since 1.5.0
*
* @see BP_Component::setup_globals() for a description of arguments.
*
* @param array $args See BP_Component::setup_globals() for a description.
*/
public function setup_globals($args = array())
{
$bp = buddypress();
// Define a slug, if necessary.
if (!defined('BP_GROUPS_SLUG')) {
define('BP_GROUPS_SLUG', $this->id);
}
// Global tables for groups component.
$global_tables = array('table_name' => $bp->table_prefix . 'bp_groups', 'table_name_members' => $bp->table_prefix . 'bp_groups_members', 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta');
// Metadata tables for groups component.
$meta_tables = array('group' => $bp->table_prefix . 'bp_groups_groupmeta');
// All globals for groups component.
// Note that global_tables is included in this array.
$args = array('slug' => BP_GROUPS_SLUG, 'root_slug' => isset($bp->pages->groups->slug) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 'has_directory' => true, 'directory_title' => _x('Groups', 'component directory title', 'buddypress'), 'notification_callback' => 'groups_format_notifications', 'search_string' => _x('Search Groups...', 'Component directory search', 'buddypress'), 'global_tables' => $global_tables, 'meta_tables' => $meta_tables);
parent::setup_globals($args);
/* Single Group Globals **********************************************/
// Are we viewing a single group?
if (bp_is_groups_component() && ($group_id = BP_Groups_Group::group_exists(bp_current_action()))) {
$bp->is_single_item = true;
/**
* Filters the current PHP Class being used.
*
* @since 1.5.0
*
* @param string $value Name of the class being used.
*/
$current_group_class = apply_filters('bp_groups_current_group_class', 'BP_Groups_Group');
if ($current_group_class == 'BP_Groups_Group') {
$this->current_group = groups_get_group(array('group_id' => $group_id, 'populate_extras' => true));
} else {
/**
* Filters the current group object being instantiated from previous filter.
*
* @since 1.5.0
*
* @param object $value Newly instantiated object for the group.
*/
$this->current_group = apply_filters('bp_groups_current_group_object', new $current_group_class($group_id));
}
// When in a single group, the first action is bumped down one because of the
// group name, so we need to adjust this and set the group name to current_item.
$bp->current_item = bp_current_action();
$bp->current_action = bp_action_variable(0);
array_shift($bp->action_variables);
// Using "item" not "group" for generic support in other components.
if (bp_current_user_can('bp_moderate')) {
bp_update_is_item_admin(true, 'groups');
} else {
bp_update_is_item_admin(groups_is_user_admin(bp_loggedin_user_id(), $this->current_group->id), 'groups');
}
// If the user is not an admin, check if they are a moderator.
if (!bp_is_item_admin()) {
bp_update_is_item_mod(groups_is_user_mod(bp_loggedin_user_id(), $this->current_group->id), 'groups');
}
// Is the logged in user a member of the group?
if (is_user_logged_in() && groups_is_user_member(bp_loggedin_user_id(), $this->current_group->id)) {
$this->current_group->is_user_member = true;
} else {
$this->current_group->is_user_member = false;
}
// Should this group be visible to the logged in user?
if ('public' == $this->current_group->status || $this->current_group->is_user_member) {
$this->current_group->is_visible = true;
} else {
$this->current_group->is_visible = false;
}
// If this is a private or hidden group, does the user have access?
if ('private' == $this->current_group->status || 'hidden' == $this->current_group->status) {
if ($this->current_group->is_user_member && is_user_logged_in() || bp_current_user_can('bp_moderate')) {
$this->current_group->user_has_access = true;
} else {
$this->current_group->user_has_access = false;
}
} else {
$this->current_group->user_has_access = true;
}
// Check once if the current group has a custom front template.
$this->current_group->front_template = bp_groups_get_front_template($this->current_group);
// Set current_group to 0 to prevent debug errors.
} else {
$this->current_group = 0;
}
/**
* Filters the list of illegal groups names/slugs.
*
* @since 1.0.0
*
* @param array $value Array of illegal group names/slugs.
//.........这里部分代码省略.........
示例11: groups_action_redirect_to_random_group
/**
* Catch requests for a random group page (example.com/groups/?random-group) and redirect.
*/
function groups_action_redirect_to_random_group()
{
if (bp_is_groups_component() && isset($_GET['random-group'])) {
$group = BP_Groups_Group::get_random(1, 1);
bp_core_redirect(trailingslashit(bp_get_groups_directory_permalink() . $group['groups'][0]->slug));
}
}
示例12: get_random
function get_random($limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false)
{
global $wpdb, $bp;
$pag_sql = $hidden_sql = $search_sql = $exclude_sql = '';
if (!empty($limit) && !empty($page)) {
$pag_sql = $wpdb->prepare(" LIMIT %d, %d", intval(($page - 1) * $limit), intval($limit));
}
if (!is_user_logged_in() || !bp_current_user_can('bp_moderate') && $user_id != bp_loggedin_user_id()) {
$hidden_sql = "AND g.status != 'hidden'";
}
if (!empty($search_terms)) {
$search_terms = like_escape($wpdb->escape($search_terms));
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
}
if (!empty($exclude)) {
$exclude = $wpdb->escape($exclude);
$exclude_sql = " AND g.id NOT IN ({$exclude})";
}
if (!empty($user_id)) {
$user_id = $wpdb->escape($user_id);
$paged_groups = $wpdb->get_results("SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql} ORDER BY rand() {$pag_sql}");
$total_groups = $wpdb->get_var("SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 {$exclude_sql}");
} else {
$paged_groups = $wpdb->get_results("SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} {$exclude_sql} ORDER BY rand() {$pag_sql}");
$total_groups = $wpdb->get_var("SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} {$exclude_sql}");
}
if (!empty($populate_extras)) {
foreach ((array) $paged_groups as $group) {
$group_ids[] = $group->id;
}
$group_ids = $wpdb->escape(join(',', (array) $group_ids));
$paged_groups = BP_Groups_Group::get_group_extras($paged_groups, $group_ids, 'newest');
}
return array('groups' => $paged_groups, 'total' => $total_groups);
}
示例13: __construct
function __construct($args = array())
{
// Backward compatibility with old method of passing arguments
if (!is_array($args) || func_num_args() > 1) {
_deprecated_argument(__METHOD__, '1.7', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
$old_args_keys = array(0 => 'user_id', 1 => 'type', 2 => 'page', 3 => 'per_page', 4 => 'max', 5 => 'slug', 6 => 'search_terms', 7 => 'populate_extras', 8 => 'include', 9 => 'exclude', 10 => 'show_hidden', 11 => 'page_arg');
$func_args = func_get_args();
$args = bp_core_parse_args_array($old_args_keys, $func_args);
}
$defaults = array('type' => 'active', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => false, 'page_arg' => 'grpage', 'user_id' => 0, 'slug' => false, 'include' => false, 'exclude' => false, 'search_terms' => '', 'meta_query' => false, 'populate_extras' => true, 'update_meta_cache' => true);
$r = wp_parse_args($args, $defaults);
extract($r);
$this->pag_page = isset($_REQUEST[$page_arg]) ? intval($_REQUEST[$page_arg]) : $page;
$this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page;
if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) {
$show_hidden = true;
}
if ('invites' == $type) {
$this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude);
} else {
if ('single-group' == $type) {
$this->single_group = true;
if (groups_get_current_group()) {
$group = groups_get_current_group();
} else {
$group = groups_get_group(array('group_id' => BP_Groups_Group::get_id_from_slug($r['slug']), 'populate_extras' => $r['populate_extras']));
}
// backwards compatibility - the 'group_id' variable is not part of the
// BP_Groups_Group object, but we add it here for devs doing checks against it
//
// @see https://buddypress.trac.wordpress.org/changeset/3540
//
// this is subject to removal in a future release; devs should check against
// $group->id instead
$group->group_id = $group->id;
$this->groups = array($group);
} else {
$this->groups = groups_get_groups(array('type' => $type, 'order' => $order, 'orderby' => $orderby, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'update_meta_cache' => $update_meta_cache, 'show_hidden' => $show_hidden));
}
}
if ('invites' == $type) {
$this->total_group_count = (int) $this->groups['total'];
$this->group_count = (int) $this->groups['total'];
$this->groups = $this->groups['groups'];
} else {
if ('single-group' == $type) {
if (empty($group->id)) {
$this->total_group_count = 0;
$this->group_count = 0;
} else {
$this->total_group_count = 1;
$this->group_count = 1;
}
} else {
if (empty($max) || $max >= (int) $this->groups['total']) {
$this->total_group_count = (int) $this->groups['total'];
} else {
$this->total_group_count = (int) $max;
}
$this->groups = $this->groups['groups'];
if (!empty($max)) {
if ($max >= count($this->groups)) {
$this->group_count = count($this->groups);
} else {
$this->group_count = (int) $max;
}
} else {
$this->group_count = count($this->groups);
}
}
}
// Build pagination links
if ((int) $this->total_group_count && (int) $this->pag_num) {
$this->pag_links = paginate_links(array('base' => add_query_arg(array($page_arg => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1));
}
}
示例14: humcore_deposit_form
/**
* Render the content for deposits/item/new.
*/
function humcore_deposit_form()
{
if (!empty($_POST)) {
$deposit_id = humcore_deposit_file();
if ($deposit_id) {
$review_url = sprintf('/deposits/item/%1$s/review/', $deposit_id);
wp_redirect($review_url);
exit;
}
}
if (!humcore_check_externals()) {
echo '<h3>New <em>CORE</em> Deposit</h3>';
echo "<p>We're so sorry, but one of the components of <em>CORE</em> is currently down and it can't accept deposits just now. We're working on it (and we're delighted that you want to share your work) so please come back and try again later.</p>";
$wp_referer = wp_get_referer();
printf('<a href="%1$s" class="button white" style="line-height: 1.2em;">Go Back</a>', !empty($wp_referer) && !strpos($wp_referer, 'item/new') ? $wp_referer : '/deposits/');
return;
}
$current_group_id = '';
preg_match('~.*?/groups/(.*[^/]?)/deposits/~i', wp_get_referer(), $slug_match);
if (!empty($slug_match)) {
$current_group_id = BP_Groups_Group::get_id_from_slug($slug_match[1]);
}
$user_id = bp_loggedin_user_id();
$user_firstname = get_the_author_meta('first_name', $user_id);
$user_lastname = get_the_author_meta('last_name', $user_id);
?>
<script type="text/javascript">
var MyAjax = {
ajaxurl : '<?php
echo esc_url(admin_url('admin-ajax.php'));
?>
',
flash_swf_url : '<?php
echo esc_url(includes_url('/js/plupload/Moxie.swf'));
?>
',
silverlight_xap_url : '<?php
echo esc_url(includes_url('/js/plupload/Moxie.xap'));
?>
',
_ajax_nonce : '<?php
echo esc_attr(wp_create_nonce('file-upload'));
?>
',
};
</script>
<h3>New CORE Deposit</h3>
<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<div id="progressbar">
<div id="indicator"></div>
</div>
<div id="console">Select the file you wish to upload and deposit. *</div>
<div id="container">
<button id="pickfile">Select File</button>
<!-- <button id="uploadfile">Upload</button> -->
<?php
$wp_referer = wp_get_referer();
printf('<a href="%1$s" class="button white" style="line-height: 1.2em;">Cancel</a>', !empty($wp_referer) && !strpos($wp_referer, 'item/new') ? $wp_referer : '/deposits/');
?>
</div>
<script type='text/javascript' src='/js/retrieveDOI.js'></script>
<form id="deposit-form" class="standard-form" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="action" id="action" value="deposit_file" />
<?php
wp_nonce_field('new_core_deposit', 'new_core_deposit_nonce');
?>
<input type="hidden" name="selected_temp_name" id="selected_temp_name" value="<?php
if (!empty($_POST['selected_temp_name'])) {
echo sanitize_text_field($_POST['selected_temp_name']);
}
?>
" />
<input type="hidden" name="selected_file_name" id="selected_file_name" value="<?php
if (!empty($_POST['selected_file_name'])) {
echo sanitize_text_field($_POST['selected_file_name']);
}
?>
" />
<input type="hidden" name="selected_file_type" id="selected_file_type" value="<?php
if (!empty($_POST['selected_file_type'])) {
echo sanitize_text_field($_POST['selected_file_type']);
}
?>
" />
<input type="hidden" name="selected_file_size" id="selected_file_size" value="<?php
if (!empty($_POST['selected_file_type'])) {
echo sanitize_text_field($_POST['selected_file_size']);
}
?>
" />
//.........这里部分代码省略.........
示例15: bd_docs_get_current_group_id
/**
* figure out the current used buddypress group_id
*
* @since 0.1
* @access public
* @returns int $group_id
*/
public function bd_docs_get_current_group_id()
{
$group_id = false;
if (bp_docs_is_bp_docs_page() && NULL !== bp_docs_get_current_doc()) {
$group_id = bp_docs_get_associated_group_id(get_the_ID());
} else {
$path = $_SERVER['REQUEST_URI'];
$p_arr = explode('/', $path);
if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
$slug = $p_arr[2];
$group_id = BP_Groups_Group::get_id_from_slug($slug);
} else {
$u = parse_url(wp_get_referer());
$path = $u['path'];
$p_arr = explode('/', $path);
if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
$slug = $p_arr[2];
$group_id = BP_Groups_Group::get_id_from_slug($slug);
}
}
}
return $group_id;
}