本文整理汇总了PHP中groups_get_all_groups函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_get_all_groups函数的具体用法?PHP groups_get_all_groups怎么用?PHP groups_get_all_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_get_all_groups函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $CFG, $DB;
$mform = $this->_form;
list($instance, $plugin, $course) = $this->_customdata;
$coursecontext = context_course::instance($course->id);
$enrol = enrol_get_plugin('cohort');
$groups = array(0 => get_string('none'));
foreach (groups_get_all_groups($course->id) as $group) {
$groups[$group->id] = format_string($group->name, true, array('context' => $coursecontext));
}
$mform->addElement('header', 'general', get_string('pluginname', 'enrol_cohort'));
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
$mform->setType('name', PARAM_TEXT);
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
$mform->addElement('select', 'status', get_string('status', 'enrol_cohort'), $options);
if ($instance->id) {
if ($cohort = $DB->get_record('cohort', array('id' => $instance->customint1))) {
$cohorts = array($instance->customint1 => format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid))));
} else {
$cohorts = array($instance->customint1 => get_string('error'));
}
$mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
$mform->setConstant('customint1', $instance->customint1);
$mform->hardFreeze('customint1', $instance->customint1);
} else {
$cohorts = array('' => get_string('choosedots'));
$allcohorts = cohort_get_available_cohorts($coursecontext, 0, 0, 0);
foreach ($allcohorts as $c) {
$cohorts[$c->id] = format_string($c->name);
}
$mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
$mform->addRule('customint1', get_string('required'), 'required', null, 'client');
}
$roles = get_assignable_roles($coursecontext);
$roles[0] = get_string('none');
$roles = array_reverse($roles, true);
// Descending default sortorder.
$mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles);
$mform->setDefault('roleid', $enrol->get_config('roleid'));
if ($instance->id and !isset($roles[$instance->roleid])) {
if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
$roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS, true);
$roles[$instance->roleid] = role_get_name($role, $coursecontext);
} else {
$roles[$instance->roleid] = get_string('error');
}
}
$mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_cohort'), $groups);
$mform->addElement('hidden', 'courseid', null);
$mform->setType('courseid', PARAM_INT);
$mform->addElement('hidden', 'id', null);
$mform->setType('id', PARAM_INT);
if ($instance->id) {
$this->add_action_buttons(true);
} else {
$this->add_action_buttons(true, get_string('addinstance', 'enrol'));
}
$this->set_data($instance);
}
示例2: definition
public function definition()
{
global $COURSE;
$mform = $this->_form;
// Adding the "general" fieldset, where all the common settings are showed.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('name', 'teambuilder'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the required "intro" field to hold the description of the instance.
$this->add_intro_editor(false, get_string('intro', 'teambuilder'));
$mform->addHelpButton('introeditor', 'intro', 'teambuilder');
// Adding the rest of teambuilder settings, spreeading all them into this fieldset
// or adding more fieldsets ('header' elements) if needed for better logic.
$groups = groups_get_all_groups($COURSE->id);
$options[0] = 'All Students';
foreach ($groups as $group) {
$options[$group->id] = $group->name;
}
$mform->addElement('select', 'groupid', 'Group', $options);
$mform->addElement('date_time_selector', 'open', 'Open Date');
$mform->addElement('static', 'openInfo', '', 'You will not be able to modify your questionnaire after this date.');
$mform->addElement('date_time_selector', 'close', 'Close Date');
$mform->addElement('checkbox', 'allowupdate', 'Allow updating of answers');
// Add standard elements, common to all modules.
$features = new stdClass();
$features->groups = false;
$features->groupings = true;
$features->groupmembersonly = true;
$this->standard_coursemodule_elements($features);
// Add standard buttons, common to all modules.
$this->add_action_buttons();
}
示例3: __construct
/**
* Constructor
*
* @param \mod_grouptool\output\sortlist $sortlist Sortlist to be used without
*/
public function __construct(sortlist &$sortlist)
{
global $SESSION;
$this->sortlist = $sortlist;
$classes = optional_param_array('classes', array(0), \PARAM_INT);
$action = optional_param('class_action', 0, \PARAM_ALPHA);
$gobutton = optional_param('do_class_action', 0, \PARAM_BOOL);
if (!empty($gobutton) && $classes != null && count($classes) != 0 && !empty($action)) {
$keys = array();
$groups = array();
foreach ($classes as $groupingid) {
$groups = array_merge($groups, groups_get_all_groups($this->sortlist->cm->course, 0, $groupingid));
}
foreach ($groups as $current) {
switch ($action) {
case 'select':
$this->sortlist->selected[$current->id] = 1;
break;
case 'deselect':
$this->sortlist->selected[$current->id] = 0;
break;
case 'toggle':
$next = empty($this->sortlist->selected[$current->id]) ? 1 : 0;
$this->sortlist->selected[$current->id] = $next;
break;
}
}
// Update SESSION!
$SESSION->sortlist->selected = $this->sortlist->selected;
}
}
示例4: _getAllCourseGroups
private function _getAllCourseGroups($courseId)
{
global $CFG;
require_once $CFG->libdir . '/grouplib.php';
return groups_get_all_groups($courseId);
/* lib/grouplib.php */
}
示例5: destination_courses_selector
public function destination_courses_selector(moodle_url $nextstageurl, destination_courses_search $courses = null, $courseid)
{
$html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore'));
$html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring()));
foreach ($nextstageurl->params() as $key => $value) {
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-group backup-section'));
$html .= $this->output->heading(get_string('selectgroups', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= html_writer::start_tag('ul');
$groups = groups_get_all_groups($courseid, 0, 0, 'g.id, g.name');
foreach ($groups as $group) {
$html .= html_writer::start_tag('li') . html_writer::checkbox('groups[]', $group->id, false, $group->name) . html_writer::end_tag('li');
}
$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
// We only allow import adding for now. Enforce it here.
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section'));
$html .= $this->output->heading(get_string('syncgroupsto', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
$html .= html_writer::end_tag('div');
return $html;
}
示例6: report_roster_get_group_options
function report_roster_get_group_options($id)
{
$groupsfromdb = groups_get_all_groups($id);
$groups = array();
foreach ($groupsfromdb as $key => $value) {
$groups[$key] = $value->name;
}
return $groups;
}
示例7: get_all_groups
/**
* Gets all groups for the given course.
*
* @param int $courseid Course id
* @return array Array of all the group objects
*/
protected function get_all_groups($courseid)
{
global $CFG;
require_once $CFG->libdir . '/grouplib.php';
if ($courseid != $this->allgroupscourseid) {
$this->allgroups = groups_get_all_groups($courseid, 0, 0, 'g.id, g.name');
$this->allgroupscourseid = $courseid;
}
return $this->allgroups;
}
示例8: booking_get_groupmembers
/**
* get all group members of $USER (of all groups $USER belongs to)
*
* @param int $courseid
* @return array: all members of all groups $USER belongs to
*/
public static function booking_get_groupmembers($courseid)
{
global $USER, $DB;
$groupmembers = array();
$usergroups = groups_get_all_groups($courseid, $USER->id);
if (!empty($usergroups)) {
$groupsparam = implode(',', array_keys($usergroups));
$groupmembers = $DB->get_records_sql("SELECT u.id\n FROM {user} u, {groups_members} gm\n WHERE u.id = gm.userid AND gm.groupid IN (?)\n ORDER BY lastname ASC", array($groupsparam));
}
return $groupmembers;
}
示例9: __construct
public function __construct($recordorid, $options = array())
{
global $USER;
parent::__construct($recordorid, $options);
$this->cm = get_coursemodule_from_instance('mediagallery', $this->record->id);
if (!empty($this->cm)) {
$this->context = \context_module::instance($this->cm->id);
$this->options['currentgroup'] = groups_get_activity_group($this->cm, true);
$this->options['groupmode'] = groups_get_activity_groupmode($this->cm);
$this->options['groups'] = groups_get_all_groups($this->cm->course, $USER->id, $this->cm->groupingid);
}
}
示例10: get_user_groups
/**
*
*
* @param int|null $userid
*
* @return array An array of group objects keyed by groupid
*/
public function get_user_groups($userid = null)
{
global $USER;
// assume current user when none specified
if (empty($userid)) {
$userid = $USER->id;
}
if (!empty($this->rtq->getRTQ()->grouping)) {
return groups_get_all_groups($this->rtq->getCourse()->id, $userid, $this->rtq->getRTQ()->grouping);
} else {
return array();
// return empty array when there is no grouping
}
}
示例11: __construct
public function __construct()
{
global $DB;
parent::__construct(get_string('gradedistributionbar', 'gradereport_visual'));
$this->layout = visualization::LAYOUT_AXIS;
$this->layoutsettings = null;
//array('false', 'true');
$this->nodeshape = visualization::SHAPE_VERTICAL_BAR;
$this->xaxis = 'grade';
$this->yaxis = 'students';
$this->xaxislabelformat = '0\\%';
//$this->xaxismax = 100 + grade_distribution::RANGE;
//$this->xaxismin = grade_distribution::RANGE;
$this->xaxisxoffset = -27;
$this->xaxislabel = get_string('grade', 'gradereport_visual');
if ($this->percent) {
$this->yaxislabelformat = '0\\%';
$this->yaxislabel = get_string('percentstudents', 'gradereport_visual');
} else {
$this->yaxislabel = get_string('numberstudents', 'gradereport_visual');
}
$this->title = get_string('gradedistribution:title', 'gradereport_visual');
$this->capability = 'gradereport/visual:vis:grade_distribution_bar';
$this->usegroups = true;
$options = array();
foreach (groups_get_all_groups(required_param('id')) as $groupkey => $group) {
$options[$groupkey] = grade_report_visual::truncate($group->name);
}
$options[0] = 'All Groups';
if (isset($DB) && !is_null($DB)) {
$course = $DB->get_record('course', array('id' => required_param('id')));
} else {
$course = get_record('course', 'id', required_param('id'));
}
if (!$course) {
print_error('nocourseid');
}
$active = groups_get_course_group($course, true);
if (!$active) {
$active = 0;
}
$this->selector = new selector('group', $options, $active);
$this->selectors = array($this->selector);
$this->colorencoder = new encoder(encoder::ENCODER_COLOR, 'item');
$this->encoders = array($this->colorencoder);
$this->itemlegend = new legend($this->colorencoder, array(get_string('coursetotal', 'grades')));
$this->legends = array($this->itemlegend);
}
示例12: definition
protected function definition()
{
global $CFG, $DB;
$collection = $this->_customdata['collection'];
$context = $this->_customdata['context'];
$mform = $this->_form;
// Text search box.
$mform->addElement('text', 'search', get_string('search'));
$mform->setType('search', PARAM_TEXT);
$options = array(\mod_mediagallery\base::TYPE_ALL => get_string('typeall', 'mediagallery'), \mod_mediagallery\base::TYPE_IMAGE => get_string('typeimage', 'mediagallery'), \mod_mediagallery\base::TYPE_VIDEO => get_string('typevideo', 'mediagallery'), \mod_mediagallery\base::TYPE_AUDIO => get_string('typeaudio', 'mediagallery'));
$mform->addElement('select', 'type', get_string('mediatype', 'mediagallery'), $options);
// Role select dropdown includes all roles, but using course-specific
// names if applied. The reason for not restricting to roles that can
// be assigned at course level is that upper-level roles display in the
// enrolments table so it makes sense to let users filter by them.
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
if (!empty($CFG->showenrolledusersrolesonly)) {
$rolenames = role_fix_names(get_roles_used_in_context($context));
}
$mform->addElement('select', 'role', get_string('role'), array(0 => get_string('all')) + $rolenames);
// Filter by group.
$allgroups = groups_get_all_groups($collection->course);
$groupsmenu[0] = get_string('allparticipants');
foreach ($allgroups as $gid => $unused) {
$groupsmenu[$gid] = $allgroups[$gid]->name;
}
if (count($groupsmenu) > 1) {
$mform->addElement('select', 'group', get_string('group'), $groupsmenu);
}
// Submit button does not use add_action_buttons because that adds
// another fieldset which causes the CSS style to break in an unfixable
// way due to fieldset quirks.
$group = array();
$group[] = $mform->createElement('submit', 'submitbutton', get_string('filter'));
$group[] = $mform->createElement('submit', 'resetbutton', get_string('reset'));
$group[] = $mform->createElement('submit', 'exportbutton', get_string('exportascsv', 'mediagallery'));
$mform->addGroup($group, 'buttons', '', ' ', false);
$mform->addElement('hidden', 'id', $context->instanceid);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', 'search');
$mform->setType('action', PARAM_ALPHA);
}
示例13: fn_sg_get_all_groups
/**
* Get all FN Site Groups. If a course is specified, and the course is using the FN Site
* Groups enrolment plug-in, then return the groups currently in use in the course.
*
* @param int $courseid The id of the requested course
* @param int $userid The id of the requested user or all.
* @param int $groupingid The id of the requested grouping or all.
* @param string $fields The fields to return or all.
* @return array
*/
function fn_sg_get_all_groups($courseid = SITEID, $userid = 0, $groupingid = 0, $fields = 'g.*')
{
global $CFG;
if (!($course = get_record('course', 'id', $courseid, null, null, null, null, 'id,enrol'))) {
return false;
}
if ($courseid != SITEID && fn_sg_course_uses_sgenrol($course)) {
/// Get site groups used in course.
$agroups = false;
} else {
$agroups = groups_get_all_groups(SITEID, $userid, $groupingid, $fields);
}
if (!is_array($agroups)) {
$agroups = array();
}
if (!($groupings = groups_get_all_groupings(SITEID))) {
$groupings = array();
}
$groups = array();
foreach ($groupings as $groupingid => $grouping) {
$groups['g_' . $groupingid] = $grouping;
if ($ggroups = groups_get_all_groups(SITEID, $userid, $groupingid, $fields)) {
foreach ($ggroups as $ggroupid => $ggroup) {
$ggroup->name = ' - ' . $ggroup->name;
$groups[$ggroupid] = $ggroup;
unset($agroups[$ggroupid]);
}
}
}
$nogrouping = new Object();
$nogrouping->id = 0;
$nogrouping->name = 'NOT IN GROUPING';
foreach ($agroups as $agroup) {
$agroup->name = ' - ' . $agroup->name;
}
if (!empty($agroups)) {
$groups = $groups + array('g_0' => $nogrouping) + $agroups;
}
return $groups;
}
示例14: should_display
public function should_display($discussion)
{
// Check the forum isn't shared (this breaks things because we dunno
// which groups to use)
if ($discussion->get_forum()->is_shared()) {
return false;
}
// Check the discussion's within time period
if (!$discussion->has_unread_data()) {
return false;
}
// Check they have actual permission
$context = $discussion->get_forum()->get_context();
if (!has_capability('mod/forumng:viewreadinfo', $context) || $discussion->is_deleted()) {
return false;
}
// For group forum, check they have group access
if ($groupid = $discussion->get_group_id()) {
// This requires 'write' access i.e. you don't get it just from
// visible groups
if (!$discussion->get_forum()->can_access_group($groupid, true)) {
return false;
}
} else {
// If the forum is NOT grouped, but the course IS, then you must
// be in a group or have access all groups (because we will only
// show read data for students in groups you're in)
$course = $discussion->get_forum()->get_course();
if ($course->groupmode && !has_capability('moodle/site:accessallgroups', $context)) {
// Check they are in at least one group
global $USER;
$groups = groups_get_all_groups($course->id, $USER->id, $course->defaultgroupingid);
if (!$groups || count($groups) == 0) {
return false;
}
}
}
// OK...
return true;
}
示例15: get_target_group
function get_target_group($discussion, $targetforum, $aag = true)
{
// Work out target group for move.
$targetgroup = $discussion->get_group_id();
if ($targetforum->get_group_mode() == 0) {
// Target forum doesn't have groups.
$targetgroup = null;
} else {
if (!$targetgroup && $aag && $discussion->get_forum()->get_group_mode() != 0) {
$targetgroup = null;
} else {
if ($targetgroup && $targetforum->get_grouping() != $discussion->get_forum()->get_grouping()) {
// Target forum has groups :( Need to decide a group.
// Had source group, but grouping has changed.
// See if old group belongs to new grouping.
$allowedgroups = groups_get_all_groups($targetforum->get_course_id(), 0, $targetforum->get_grouping(), 'g.id');
if (count($allowedgroups) == 1) {
$targetgroup = key($allowedgroups);
} else {
if (!array_key_exists($targetgroup, $allowedgroups)) {
// Old group not in new grouping, so don't know where to put it.
$targetgroup = null;
}
}
} else {
// Check to see whether a single or multigroup forum.
$groupids = get_allowed_groupids($targetforum, $aag);
if (count($groupids) == 1) {
$targetgroup = key($groupids);
} else {
if (!array_key_exists($targetgroup, $groupids)) {
$targetgroup = null;
}
}
}
}
}
return $targetgroup;
}