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


PHP groups_get_groups函数代码示例

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


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

示例1: _wds_get_buddypress_fields

/**
 * BuddyPress settings fields helper.
 */
function _wds_get_buddypress_fields()
{
    // BuddyPress Groups
    if (function_exists('groups_get_groups')) {
        // We have BuddyPress groups, so let's get some settings
        $opts = array('title' => __('BuddyPress', 'wds'), 'intro' => __('BuddyPress sitemaps integration.', 'wds'), 'options' => array(array('type' => 'radio', 'name' => 'sitemap-buddypress-groups', 'title' => __('Include BuddyPress groups in my sitemaps', 'wds'), 'description' => __('Enabling this option will add all your BuddyPress groups to your sitemap.', 'wds'), 'items' => array(__('No', 'wds'), __('Yes', 'wds')))));
        $groups = groups_get_groups(array('per_page' => WDS_BP_GROUPS_LIMIT));
        $groups = @$groups['groups'] ? $groups['groups'] : array();
        $exclude = array();
        foreach ($groups as $group) {
            $exclude["exclude-buddypress-group-{$group->slug}"] = $group->name;
        }
        if ($exclude) {
            $opts['options'][] = array('type' => 'checkbox', 'name' => 'sitemap-buddypress', 'title' => __('Exclude these groups from my sitemap', 'wds'), 'items' => $exclude);
        }
    }
    // BuddyPress profiles
    $opts['options'][] = array('type' => 'radio', 'name' => 'sitemap-buddypress-profiles', 'title' => __('Include BuddyPress profiles in my sitemaps', 'wds'), 'description' => __('Enabling this option will add all your BuddyPress profiles to your sitemap.', 'wds'), 'items' => array(__('No', 'wds'), __('Yes', 'wds')));
    $wp_roles = new WP_Roles();
    $wp_roles = $wp_roles->get_names();
    $wp_roles = $wp_roles ? $wp_roles : array();
    $exclude = array();
    foreach ($wp_roles as $key => $label) {
        $exclude["exclude-profile-role-{$key}"] = $label;
    }
    if ($exclude) {
        $opts['options'][] = array('type' => 'checkbox', 'name' => 'sitemap-buddypress-roles', 'title' => __('Exclude profiles with these roles from my sitemap', 'wds'), 'items' => $exclude);
    }
    return $opts;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:33,代码来源:wds-sitemaps-settings.php

示例2: groups_cleanup_groups

/**
 * Cleans up all the groups and groupings in a course (it does this best-effort 
 * i.e. if one deletion fails, it still attempts further deletions).
 * IMPORTANT: Note that if the groups and groupings are used by other courses 
 * somehow, they will still be deleted - it doesn't protect against this. 
 * @param int $courseid The id of the course
 * @return boolean True if the clean up was successful, false otherwise. 
 */
function groups_cleanup_groups($courseid)
{
    $success = true;
    // Delete all the groupings
    $groupings = groups_get_groupings($courseid);
    if ($groupings != false) {
        foreach ($groupings as $groupingid) {
            $groupingdeleted = groups_delete_grouping($groupingid);
            if (!$groupingdeleted) {
                $success = false;
            }
        }
    }
    // Delete all the groups
    $groupids = groups_get_groups($courseid);
    if ($groupids != false) {
        foreach ($groupids as $groupid) {
            $groupdeleted = groups_delete_group($groupid);
            if (!$groupdeleted) {
                $success = false;
            }
        }
    }
    return $success;
}
开发者ID:veritech,项目名称:pare-project,代码行数:33,代码来源:dbcleanup.php

示例3: process_groups_shortcode

 function process_groups_shortcode($args = array(), $content = false)
 {
     $groups_args = wp_parse_args($args, array('exclude' => false, 'show_members' => false, 'group_marker' => 'icon'));
     $exclude = !empty($groups_args['exclude']) ? array_filter(array_map('intval', array_map('trim', explode(',', $groups_args['exclude'])))) : array();
     $rpl = new AgmMarkerReplacer();
     $overrides = $rpl->arguments_to_overrides($args);
     $raw = groups_get_groups(array('user_id' => false, 'exclude' => $exclude));
     if (empty($raw['groups'])) {
         return $content;
     }
     $maps = array();
     foreach ($raw['groups'] as $group) {
         if (empty($group->id)) {
             continue;
         }
         $map = $this->_get_group_map($group->id, array('show_members' => $groups_args['show_members'], 'group_marker' => $groups_args['group_marker']));
         if (!$map) {
             continue;
         }
         $maps[] = $map;
     }
     if (empty($maps)) {
         return $content;
     }
     return $rpl->create_overlay_tag($maps, $overrides);
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:26,代码来源:agm-bp-group_maps.php

示例4: bp_groups_template

	function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) {
		global $bp;

		$this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
		$this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;

		if ( 'invites' == $type ) {
			$this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
		} else if ( 'single-group' == $type ) {
			$group = new stdClass;
			$group->group_id = BP_Groups_Group::get_id_from_slug($slug);
			$this->groups    = array( $group );
		} else {
			$this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
		}

		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 ) {
			$this->single_group      = true;
			$this->total_group_count = 1;
			$this->group_count       = 1;
		} else {
			if ( !$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 ( $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( 'grpage' => '%#%', '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' => '←',
				'next_text' => '→',
				'mid_size'  => 1
			) );
		}
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:57,代码来源:bp-groups-templatetags.php

示例5: get_groups

/**
 * Returns an array of group objects that the user is a member of
 * in the given course.  If userid isn't specified, then return a
 * list of all groups in the course.
 *
 * @uses $CFG
 * @param int $courseid The id of the course in question.
 * @param int $userid The id of the user in question as found in the 'user' 
 * table 'id' field.
 * @return object
 */
function get_groups($courseid, $userid = 0)
{
    if ($userid) {
        $groupids = groups_get_groups_for_user($userid, $courseid);
    } else {
        $groupids = groups_get_groups($courseid);
    }
    return groups_groupids_to_groups($groupids, $courseid, $alldata = true);
}
开发者ID:veritech,项目名称:pare-project,代码行数:20,代码来源:legacylib.php

示例6: sp_assignments_dashboard_widget_configuration

function sp_assignments_dashboard_widget_configuration()
{
    //get old settings or default to empty array
    $options = get_option("assignments_dashboard_widget_options", array());
    //saving options?
    if (isset($_POST['assignments_dashboard_options_save'])) {
        //get course_id
        $options['course_id'] = intval($_POST['assignments_dashboard_course_id']);
        //save it
        update_option("assignments_dashboard_widget_options", $options);
    }
    //show options form
    $groups = groups_get_groups(array('orderby' => 'name', 'order' => 'ASC'));
    ?>
	<p>Choose a class/group to show assignments from.</p>
	<div class="feature_post_class_wrap">
		<label>Class</label>
		<select name="assignments_dashboard_course_id">
		<option value="" <?php 
    selected($options['course_id'], "");
    ?>
>
			All Classes
		</option>
		<?php 
    $groups = groups_get_groups(array('orderby' => 'name', 'order' => 'ASC'));
    if (!empty($groups) && !empty($groups['groups'])) {
        foreach ($groups['groups'] as $group) {
            ?>
			<option value="<?php 
            echo intval($group->id);
            ?>
" 
			<?php 
            selected($options['course_id'], $group->id);
            ?>
>
			<?php 
            echo $group->name;
            ?>
			</option>
			<?php 
        }
    }
    ?>
		</select>
	</div>
	<input type="hidden" name="assignments_dashboard_options_save" value="1" />
	<?php 
}
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:50,代码来源:dashboard-04.php

示例7: test_create_group

 function test_create_group()
 {
     $this->assertTrue($this->groupid = groups_create_group($this->courseid));
     $this->assertTrue(groups_group_exists($this->groupid));
     $this->assertTrue(groups_group_belongs_to_course($this->groupid, $this->courseid));
     $this->assertTrue($groupids = groups_get_groups($this->courseid));
     //array...
     $this->assertTrue($groupinfo = groups_set_default_group_settings());
     $groupinfo->name = 'Group ' . $this->getLabel();
     //'Temporary Group Name'
     $this->assertTrue(groups_set_group_settings($this->groupid, $groupinfo));
     $this->assertTrue($groupinfo->name == groups_get_group_name($this->groupid));
     $this->assertTrue($this->courseid == groups_get_course($this->groupid));
 }
开发者ID:veritech,项目名称:pare-project,代码行数:14,代码来源:test_basicgrouplib.php

示例8: is_comment_visible

 public function is_comment_visible($comment)
 {
     if ($this->ace_role == self::CORE_TEACHER) {
         return TRUE;
     }
     $comment_user_id = is_array($comment) ? $comment['user_id'] : $comment->user_id;
     if ($this->user->ID == $comment_user_id) {
         return TRUE;
         // own comment
     }
     if ($this->is_teacher()) {
         if (function_exists("groups_get_groups")) {
             // Check if teacher shares one or more groups with comment owner.
             $common_bp_groups = groups_get_groups(array('user_id' => $comment_user_id, 'include' => $this->get_bp_group_ids(), 'show_hidden' => TRUE, 'populate_extras' => FALSE, 'update_meta_cache' => FALSE));
             return $common_bp_groups['total'] > 0;
         } else {
             return TRUE;
             // BuddyPress not installed
         }
     }
     return FALSE;
 }
开发者ID:RobBosman,项目名称:vanace.AceCourse,代码行数:22,代码来源:AceCourseUser.class.php

示例9: _load_buddypress_group_items

 /**
  * Loads BuddyPress Group items.
  */
 private function _load_buddypress_group_items()
 {
     if (!function_exists('groups_get_groups')) {
         return false;
     }
     // No BuddyPress Groups, bail out.
     global $wds_options;
     if (!defined('BP_VERSION')) {
         return false;
     }
     // Nothing to do
     if (!(int) @$wds_options['sitemap-buddypress-groups']) {
         return false;
     }
     // Nothing to do
     $groups = groups_get_groups(array('per_page' => WDS_BP_GROUPS_LIMIT));
     $groups = @$groups['groups'] ? $groups['groups'] : array();
     //$total_users = (int)count_users();
     //$total_users = $total_users ? $total_users : 1;
     foreach ($groups as $group) {
         if (@$wds_options["exclude-buddypress-group-{$group->slug}"]) {
             continue;
         }
         //$priority = sprintf("%.1f", ($group->total_member_count / $total_users));
         $link = bp_get_group_permalink($group);
         $this->_add_item($link, 0.2, 'weekly', strtotime($group->last_activity), $group->description);
     }
     return true;
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:32,代码来源:wds-sitemaps.php

示例10: bp_groups_admin_delete

/**
 * Display the Group delete confirmation screen.
 *
 * We include a separate confirmation because group deletion is truly
 * irreversible.
 *
 * @since 1.7.0
 */
function bp_groups_admin_delete()
{
    if (!bp_current_user_can('bp_moderate')) {
        die('-1');
    }
    $group_ids = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : 0;
    if (!is_array($group_ids)) {
        $group_ids = explode(',', $group_ids);
    }
    $group_ids = wp_parse_id_list($group_ids);
    $groups = groups_get_groups(array('include' => $group_ids, 'show_hidden' => true, 'per_page' => null));
    // Create a new list of group ids, based on those that actually exist
    $gids = array();
    foreach ($groups['groups'] as $group) {
        $gids[] = $group->id;
    }
    $base_url = remove_query_arg(array('action', 'action2', 'paged', 's', '_wpnonce', 'gid'), $_SERVER['REQUEST_URI']);
    ?>

	<div class="wrap">
		<?php 
    screen_icon('buddypress-groups');
    ?>
		<h2><?php 
    _e('Delete Groups', 'buddypress');
    ?>
</h2>
		<p><?php 
    _e('You are about to delete the following groups:', 'buddypress');
    ?>
</p>

		<ul class="bp-group-delete-list">
		<?php 
    foreach ($groups['groups'] as $group) {
        ?>
			<li><?php 
        echo esc_html($group->name);
        ?>
</li>
		<?php 
    }
    ?>
		</ul>

		<p><strong><?php 
    _e('This action cannot be undone.', 'buddypress');
    ?>
</strong></p>

		<a class="button-primary" href="<?php 
    echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'do_delete', 'gid' => implode(',', $gids)), $base_url), 'bp-groups-delete'));
    ?>
"><?php 
    _e('Delete Permanently', 'buddypress');
    ?>
</a>
		<a class="button" href="<?php 
    echo esc_attr($base_url);
    ?>
"><?php 
    _e('Cancel', 'buddypress');
    ?>
</a>
	</div>

	<?php 
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:76,代码来源:bp-groups-admin.php

示例11: __construct

 function __construct($user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false)
 {
     global $bp;
     $this->pag_page = isset($_REQUEST['grpage']) ? intval($_REQUEST['grpage']) : $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) {
             $group = new stdClass();
             $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
             $this->groups = array($group);
         } else {
             $this->groups = groups_get_groups(array('type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, '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) {
             $this->single_group = true;
             $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('grpage' => '%#%', '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('&larr;', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('&rarr;', 'Group pagination next text', 'buddypress'), 'mid_size' => 1));
     }
 }
开发者ID:newington,项目名称:buddypress,代码行数:51,代码来源:bp-groups-template.php

示例12: buddydrive_get_select_user_group

/**
 * Builds the select box to choose the group to attach the BuddyDrive Item to
 * @param  int $user_id  the user id
 * @param  int $selected the group id in case of edit form
 * @param  string $name  the name of the select box
 * @uses bp_loggedin_user_id() to get current user id
 * @uses groups_get_groups() to list the groups of the user
 * @uses groups_get_groupmeta() to check group enabled BuddyDrive
 * @uses selected() to eventually activate a group
 * @return string the select box
 */
function buddydrive_get_select_user_group($user_id = false, $selected = false, $name = false)
{
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    $name = !empty($name) ? ' name="' . $name . '"' : false;
    $output = __('No group available for BuddyDrive', 'buddydrive');
    if (!bp_is_active('groups')) {
        return $output;
    }
    $user_groups = groups_get_groups(array('user_id' => $user_id, 'show_hidden' => true, 'per_page' => false));
    $buddydrive_groups = false;
    // checking for available buddydrive groups
    if (!empty($user_groups['groups'])) {
        foreach ($user_groups['groups'] as $group) {
            if (1 == groups_get_groupmeta($group->id, '_buddydrive_enabled')) {
                $buddydrive_groups[] = array('group_id' => $group->id, 'group_name' => $group->name);
            }
        }
    }
    // building the select box
    if (!empty($buddydrive_groups) && is_array($buddydrive_groups)) {
        $output = '<select id="buddygroup"' . $name . '>';
        foreach ($buddydrive_groups as $buddydrive_group) {
            $output .= '<option value="' . $buddydrive_group['group_id'] . '" ' . selected($selected, $buddydrive_group['group_id'], false) . '>' . $buddydrive_group['group_name'] . '</option>';
        }
        $output .= '</select>';
    }
    return apply_filters('buddydrive_get_select_user_group', $output);
}
开发者ID:MrVibe,项目名称:buddydrive,代码行数:41,代码来源:buddydrive-item-template.php

示例13: admin_main

    function admin_main($data)
    {
        if (!$data) {
            $data = array();
        }
        ?>
		<div class='level-operation' id='main-bpgroups'>
			<h2 class='sidebar-name'><?php 
        _e('Groups', 'membership');
        ?>
<span><a href='#remove' id='remove-bpgroups' class='removelink' title='<?php 
        _e("Remove Groups from this rules area.", 'membership');
        ?>
'><?php 
        _e('Remove', 'membership');
        ?>
</a></span></h2>
			<div class='inner-operation'>
				<p><?php 
        _e('Select the groups to be covered by this rule by checking the box next to the relevant groups title.', 'membership');
        ?>
</p>
				<?php 
        if (function_exists('groups_get_groups')) {
            $groups = groups_get_groups(array('per_page' => MEMBERSHIP_GROUP_COUNT));
        }
        if ($groups) {
            ?>
						<table cellspacing="0" class="widefat fixed">
							<thead>
							<tr>
								<th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th>
								<th style="" class="manage-column column-name" id="name" scope="col"><?php 
            _e('Group title', 'membership');
            ?>
</th>
								<th style="" class="manage-column column-date" id="date" scope="col"><?php 
            _e('Group created', 'membership');
            ?>
</th>
							</tr>
							</thead>

							<tfoot>
							<tr>
								<th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th>
								<th style="" class="manage-column column-name" id="name" scope="col"><?php 
            _e('Group title', 'membership');
            ?>
</th>
								<th style="" class="manage-column column-date" id="date" scope="col"><?php 
            _e('Group created', 'membership');
            ?>
</th>
							</tr>
							</tfoot>

							<tbody>
						<?php 
            foreach ($groups['groups'] as $key => $group) {
                ?>
							<tr valign="middle" class="alternate" id="bpgroup-<?php 
                echo $group->id;
                ?>
">
								<th class="check-column" scope="row">
									<input type="checkbox" value="<?php 
                echo $group->id;
                ?>
" name="bpgroups[]" <?php 
                if (in_array($group->id, $data)) {
                    echo 'checked="checked"';
                }
                ?>
>
								</th>
								<td class="column-name">
									<strong><?php 
                echo esc_html($group->name);
                ?>
</strong>
								</td>
								<td class="column-date">
									<?php 
                echo date("Y/m/d", strtotime($group->date_created));
                ?>
								</td>
						    </tr>
							<?php 
            }
            ?>
							</tbody>
						</table>
						<?php 
        }
        if ($groups['total'] > MEMBERSHIP_GROUP_COUNT) {
            ?>
						<p class='description'><?php 
            echo __("Only the most recent ", 'membership') . MEMBERSHIP_GROUP_COUNT . __(" groups are shown above.", 'membership');
            ?>
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:default.bprules.php

示例14: process_group_archives_shortcode

 function process_group_archives_shortcode($args = array(), $content = false)
 {
     $args = $this->_preparse_arguments($args, array('date' => false, 'lookahead' => false, 'weeks' => false, 'category' => false, 'limit' => false, 'order' => false, 'groups' => false, 'user' => false, 'class' => 'eab-group_events', 'template' => 'get_shortcode_archive_output', 'override_styles' => false, 'override_scripts' => false));
     if (is_numeric($args['user'])) {
         $args['user'] = $this->_arg_to_int($args['user']);
     } else {
         if ('current' == trim($args['user'])) {
             $user = wp_get_current_user();
             $args['user'] = $user->ID;
         } else {
             $args['user'] = false;
         }
     }
     if (is_numeric($args['groups'])) {
         // Single group ID
         $args['groups'] = $this->_arg_to_int($args['groups']);
     } else {
         if (strstr($args['groups'], ',')) {
             // Comma-separated list of group IDs
             $ids = array_map('intval', array_map('trim', explode(',', $args['groups'])));
             if (!empty($ids)) {
                 $args['groups'] = $ids;
             }
         } else {
             // Keyword
             if (in_array(trim($args['groups']), array('my', 'my-groups', 'my_groups')) && $args['user']) {
                 if (!function_exists('groups_get_groups')) {
                     return $content;
                 }
                 $groups = groups_get_groups(array('user_id' => $args['user']));
                 $args['groups'] = array_map('intval', wp_list_pluck($groups['groups'], 'id'));
             } else {
                 if ('all' == trim($args['groups'])) {
                     if (!function_exists('groups_get_groups')) {
                         return $content;
                     }
                     $groups = groups_get_groups();
                     $args['groups'] = array_map('intval', wp_list_pluck($groups['groups'], 'id'));
                 } else {
                     $args['groups'] = false;
                 }
             }
         }
     }
     if (!$args['groups']) {
         return $content;
     }
     $events = array();
     $query = $this->_to_query_args($args);
     $query['meta_query'][] = array('key' => 'eab_event-bp-group_event', 'value' => $args['groups'], 'compare' => is_array($args['groups']) ? 'IN' : '=');
     $order_method = $args['order'] ? create_function('', 'return "' . $args['order'] . '";') : false;
     if ($order_method) {
         add_filter('eab-collection-date_ordering_direction', $order_method);
     }
     // Lookahead - depending on presence, use regular upcoming query, or poll week count
     if ($args['lookahead']) {
         $method = $args['weeks'] ? create_function('', 'return ' . $args['weeks'] . ';') : false;
         if ($method) {
             add_filter('eab-collection-upcoming_weeks-week_number', $method);
         }
         $collection = new Eab_BuddyPress_GroupEventsWeeksCollection($args['groups'], $args['date'], $query);
         if ($method) {
             remove_filter('eab-collection-upcoming_weeks-week_number', $method);
         }
     } else {
         // No lookahead, get the full month only
         $collection = new Eab_BuddyPress_GroupEventsCollection($args['groups'], $args['date'], $query);
     }
     if ($order_method) {
         remove_filter('eab-collection-date_ordering_direction', $order_method);
     }
     $events = $collection->to_collection();
     $output = eab_call_template('util_apply_shortcode_template', $events, $args);
     $output = $output ? $output : $content;
     if (!$args['override_styles']) {
         wp_enqueue_style('eab_front');
     }
     if (!$args['override_scripts']) {
         wp_enqueue_script('eab_event_js');
     }
     return $output;
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:82,代码来源:eab-buddypress-group_events.php

示例15: reset_course_userdata

/**
* This function will empty a course of USER data as much as
/// possible. It will retain the activities and the structure
/// of the course.
*
* @uses $USER
* @uses $SESSION
* @uses $CFG
* @param object $data an object containing all the boolean settings and courseid
* @param bool $showfeedback  if false then do it all silently
* @return bool
* @todo Finish documenting this function
*/
function reset_course_userdata($data, $showfeedback = true)
{
    global $CFG, $USER, $SESSION;
    $result = true;
    $strdeleted = get_string('deleted');
    // Look in every instance of every module for data to delete
    if ($allmods = get_records('modules')) {
        foreach ($allmods as $mod) {
            $modname = $mod->name;
            $modfile = $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $moddeleteuserdata = $modname . '_delete_userdata';
            // Function to delete user data
            if (file_exists($modfile)) {
                @(include_once $modfile);
                if (function_exists($moddeleteuserdata)) {
                    $moddeleteuserdata($data, $showfeedback);
                }
            }
        }
    } else {
        error('No modules are installed!');
    }
    // Delete other stuff
    $coursecontext = get_context_instance(CONTEXT_COURSE, $data->courseid);
    if (!empty($data->reset_students) or !empty($data->reset_teachers)) {
        $teachers = array_keys(get_users_by_capability($coursecontext, 'moodle/course:update'));
        $participants = array_keys(get_users_by_capability($coursecontext, 'moodle/course:view'));
        $students = array_diff($participants, $teachers);
        if (!empty($data->reset_students)) {
            foreach ($students as $studentid) {
                role_unassign(0, $studentid, 0, $coursecontext->id);
            }
            if ($showfeedback) {
                notify($strdeleted . ' ' . get_string('students'), 'notifysuccess');
            }
            /// Delete group members (but keep the groups) TODO:check.
            if ($groupids = groups_get_groups($data->courseid)) {
                foreach ($groupids as $groupid) {
                    if (groups_remove_all_group_members($groupid)) {
                        if ($showfeedback) {
                            notify($strdeleted . ' groups_members', 'notifysuccess');
                        }
                    } else {
                        $result = false;
                    }
                }
            }
        }
        if (!empty($data->reset_teachers)) {
            foreach ($teachers as $teacherid) {
                role_unassign(0, $teacherid, 0, $coursecontext->id);
            }
            if ($showfeedback) {
                notify($strdeleted . ' ' . get_string('teachers'), 'notifysuccess');
            }
        }
    }
    if (!empty($data->reset_groups)) {
        if ($groupids = groups_get_groups($data->courseid)) {
            foreach ($groupids as $groupid) {
                if (groups_delete_group($groupid)) {
                    if ($showfeedback) {
                        notify($strdeleted . ' groups', 'notifysuccess');
                    }
                } else {
                    $result = false;
                }
            }
        }
    }
    if (!empty($data->reset_events)) {
        if (delete_records('event', 'courseid', $data->courseid)) {
            if ($showfeedback) {
                notify($strdeleted . ' event', 'notifysuccess');
            }
        } else {
            $result = false;
        }
    }
    if (!empty($data->reset_logs)) {
        if (delete_records('log', 'course', $data->courseid)) {
            if ($showfeedback) {
                notify($strdeleted . ' log', 'notifysuccess');
            }
        } else {
            $result = false;
        }
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:moodlelib.php


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