本文整理汇总了PHP中groups_get_activity_allowed_groups函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_get_activity_allowed_groups函数的具体用法?PHP groups_get_activity_allowed_groups怎么用?PHP groups_get_activity_allowed_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了groups_get_activity_allowed_groups函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext'];
$mform->addElement('header', 'general', get_string('export', 'quiz'));
$mform->setHelpButton('general', array('export', get_string('export', 'quiz'), 'attforblock'));
$groupmode = groups_get_activity_groupmode($cm);
$groups = groups_get_activity_allowed_groups($cm, $USER->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
$grouplist[0] = get_string('allparticipants');
}
if ($groups) {
foreach ($groups as $group) {
$grouplist[$group->id] = $group->name;
}
}
$mform->addElement('select', 'group', get_string('group'), $grouplist);
$ident = array();
$ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock'));
$ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username'));
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('<br />'), true);
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes'));
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock'));
$mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked');
$mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attforblock'), 'ooo' => get_string('downloadooo', 'attforblock'), 'text' => get_string('downloadtext', 'attforblock')));
// buttons
$submit_string = get_string('ok');
$this->add_action_buttons(false, $submit_string);
$mform->addElement('hidden', 'id', $cm->id);
// $mform->addElement('hidden', 'action', 'add');
}
示例2: should_display
public function should_display($discussion)
{
global $USER;
if (is_a($discussion, 'mod_forumng_discussion')) {
return true;
}
// This is a forum.
if (!$discussion->get_tags_enabled()) {
return false;
} else {
// Need to check for capabilities.
if (has_capability('forumngfeature/edittags:managesettags', $discussion->get_context())) {
return true;
} else {
$cm = $discussion->get_course_module();
if ($discussion->get_group_mode()) {
$allowedgroups = groups_get_activity_allowed_groups($cm);
if (!empty($allowedgroups) && has_capability('forumngfeature/edittags:editsettags', $discussion->get_context())) {
return true;
}
}
}
}
return false;
}
示例3: definition
/**
* Called to define this moodle form
*
* @return void
*/
public function definition()
{
global $USER;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext'];
$mform->addElement('header', 'general', get_string('export', 'attendance'));
$groupmode = groups_get_activity_groupmode($cm, $course);
$groups = groups_get_activity_allowed_groups($cm, $USER->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
$grouplist[0] = get_string('allparticipants');
}
if ($groups) {
foreach ($groups as $group) {
$grouplist[$group->id] = $group->name;
}
}
$mform->addElement('select', 'group', get_string('group'), $grouplist);
$ident = array();
$ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
$ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username'));
$optional = array('idnumber', 'institution', 'department');
foreach ($optional as $opt) {
$ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt));
$mform->setType($opt, PARAM_NOTAGS);
}
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('<br />'), true);
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
$mform->setType('id', PARAM_INT);
$mform->setType('uname', PARAM_INT);
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->setDefault('includeallsessions', true);
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes'));
$mform->addElement('checkbox', 'includeremarks', get_string('includeremarks', 'attendance'), get_string('yes'));
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attendance'));
$mform->setDefault('sessionstartdate', $course->startdate);
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked');
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attendance'));
$mform->disabledIf('sessionenddate', 'includeallsessions', 'checked');
$mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attendance'), 'ooo' => get_string('downloadooo', 'attendance'), 'text' => get_string('downloadtext', 'attendance')));
$submit_string = get_string('ok');
$this->add_action_buttons(false, $submit_string);
$mform->addElement('hidden', 'id', $cm->id);
}
示例4: bigbluebuttonbn_view_joining
function bigbluebuttonbn_view_joining($bbbsession, $context, $streamline)
{
global $CFG, $DB;
$joining = false;
// If user is administrator, moderator or if is viewer and no waiting is required
if ($bbbsession['flag']['administrator'] || $bbbsession['flag']['moderator'] || !$bbbsession['flag']['wait']) {
//
// Join directly
//
$metadata = array("meta_origin" => $bbbsession['origin'], "meta_originVersion" => $bbbsession['originVersion'], "meta_originServerName" => $bbbsession['originServerName'], "meta_originServerCommonName" => $bbbsession['originServerCommonName'], "meta_originTag" => $bbbsession['originTag'], "meta_context" => $bbbsession['context'], "meta_contextActivity" => $bbbsession['contextActivity'], "meta_contextActivityDescription" => $bbbsession['contextActivityDescription'], "meta_recording" => $bbbsession['textflag']['record']);
$response = bigbluebuttonbn_getCreateMeetingArray($bbbsession['meetingname'], $bbbsession['meetingid'], $bbbsession['welcome'], $bbbsession['modPW'], $bbbsession['viewerPW'], $bbbsession['salt'], $bbbsession['url'], $bbbsession['logoutURL'], $bbbsession['textflag']['record'], $bbbsession['timeduration'], $bbbsession['voicebridge'], $metadata);
if (!$response) {
// If the server is unreachable, then prompts the user of the necessary action
if ($bbbsession['flag']['administrator']) {
print_error('view_error_unable_join', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
} else {
if ($bbbsession['flag']['moderator']) {
print_error('view_error_unable_join_teacher', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
} else {
print_error('view_error_unable_join_student', 'streamline', $CFG->wwwroot . '/admin/settings.php?section=modsettingbigbluebuttonbn');
}
}
} else {
if ($response['returncode'] == "FAILED") {
// The meeting was not created
$error_key = bigbluebuttonbn_get_error_key($response['messageKey'], 'view_error_create');
if (!$error_key) {
print_error($response['message'], 'streamline');
} else {
print_error($error_key, 'streamline');
}
} else {
if ($response['hasBeenForciblyEnded'] == "true") {
print_error(get_string('index_error_forciblyended', 'streamline'));
} else {
///////////////Everything is ok /////////////////////
/// Moodle event logger: Create an event for meeting created
if ($CFG->version < '2014051200') {
//This is valid before v2.7
add_to_log($bbbsession['courseid'], 'streamline', 'meeting created', '', $streamline->name, $bbbsession['cm']->id);
} else {
//This is valid after v2.7
$event = \mod_streamline\event\bigbluebuttonbn_meeting_created::create(array('context' => $context, 'objectid' => $streamline->id));
$event->trigger();
}
/// Internal logger: Instert a record with the meeting created
bigbluebuttonbn_log($bbbsession, 'Create');
if (groups_get_activity_groupmode($bbbsession['cm']) > 0 && count(groups_get_activity_allowed_groups($bbbsession['cm'])) > 1) {
print "<br>" . get_string('view_groups_selection', 'streamline') . " <input type='button' onClick='M.mod_streamline.joinURL()' value='" . get_string('view_groups_selection_join', 'streamline') . "'>";
} else {
$joining = true;
if ($bbbsession['flag']['administrator'] || $bbbsession['flag']['moderator']) {
print "<br />" . get_string('view_login_moderator', 'streamline') . "<br /><br />";
} else {
print "<br />" . get_string('view_login_viewer', 'streamline') . "<br /><br />";
}
print "<center><img src='pix/loading.gif' /></center>";
}
/// Moodle event logger: Create an event for meeting joined
if ($CFG->version < '2014051200') {
//This is valid before v2.7
add_to_log($bbbsession['courseid'], 'streamline', 'meeting joined', '', $streamline->name, $bbbsession['cm']->id);
} else {
//This is valid after v2.7
$event = \mod_streamline\event\bigbluebuttonbn_meeting_joined::create(array('context' => $context, 'objectid' => $streamline->id));
$event->trigger();
}
}
}
}
} else {
//
// "Viewer" && Waiting for moderator is required;
//
$joining = true;
print "<div align='center'>";
if (bigbluebuttonbn_wrap_simplexml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($bbbsession['meetingid'], $bbbsession['url'], $bbbsession['salt'])) == "true") {
/// Since the meeting is already running, we just join the session
print "<br />" . get_string('view_login_viewer', 'streamline') . "<br /><br />";
print "<center><img src='pix/loading.gif' /></center>";
/// Moodle event logger: Create an event for meeting joined
if ($CFG->version < '2014051200') {
//This is valid before v2.7
add_to_log($bbbsession['courseid'], 'streamline', 'meeting joined', '', $streamline->name, $bbbsession['cm']->id);
} else {
//This is valid after v2.7
$event = \mod_streamline\event\bigbluebuttonbn_meeting_joined::create(array('context' => $context, 'objectid' => $streamline->id));
$event->trigger();
}
} else {
/// Since the meeting is not running, the spining wheel is shown
print "<br />" . get_string('view_wait', 'streamline') . "<br /><br />";
print '<center><img src="pix/polling.gif"></center>';
}
print "</div>";
}
return $joining;
}
示例5: definition
/**
* Form definition
*
* @return void
*/
function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
//var_dump($this->_customdata);die;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$coursecontext = $this->_customdata['coursecontext'];
$modcontext = $this->_customdata['modcontext'];
$twf = $this->_customdata['twf'];
$post = $this->_customdata['post'];
$subscribe = $this->_customdata['subscribe'];
$edit = $this->_customdata['edit'];
$thresholdwarning = $this->_customdata['thresholdwarning'];
$syx_newdiscussion = $this->_customdata['syx_newdiscussion'];
$syx_phase = $this->_customdata['syx_phase'];
$syx_instance = $this->_customdata['syx_instance'];
$syx_teamwork = $this->_customdata['syx_teamwork'];
$mform->addElement('header', 'general', '');
//fill in the data depending on page params later using set_data
// If there is a warning message and we are not editing a post we need to handle the warning.
if (!empty($thresholdwarning) && !$edit) {
// Here we want to display a warning if they can still post but have reached the warning threshold.
if ($thresholdwarning->canpost) {
$message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
$mform->addElement('html', $OUTPUT->notification($message));
}
}
$mform->addElement('text', 'subject', get_string('subject', 'twf'), 'size="48"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
if ($syx_newdiscussion) {
$mform->addElement('text', 'score', get_string('score', 'twf'));
$mform->setType('score', PARAM_INT);
$mform->addRule('score', get_string('required'), 'required', null, 'client');
$mform->addHelpButton('score', 'score_rules', 'twf');
}
$mform->addElement('editor', 'message', get_string('message', 'twf'), null, self::editor_options($modcontext, empty($post->id) ? null : $post->id));
$mform->setType('message', PARAM_RAW);
$mform->addRule('message', get_string('required'), 'required', null, 'client');
$manageactivities = has_capability('moodle/course:manageactivities', $coursecontext);
if (\mod_twf\subscriptions::is_forcesubscribed($twf)) {
$mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'twf'));
$mform->freeze('discussionsubscribe');
$mform->setDefaults('discussionsubscribe', 0);
$mform->addHelpButton('discussionsubscribe', 'forcesubscribed', 'twf');
} else {
if (\mod_twf\subscriptions::subscription_disabled($twf) && !$manageactivities) {
$mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'twf'));
$mform->freeze('discussionsubscribe');
$mform->setDefaults('discussionsubscribe', 0);
$mform->addHelpButton('discussionsubscribe', 'disallowsubscription', 'twf');
} else {
$mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'twf'));
$mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'twf');
}
}
if (!empty($twf->maxattachments) && $twf->maxbytes != 1 && has_capability('mod/twf:createattachment', $modcontext)) {
// 1 = No attachments at all
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'twf'), null, self::attachment_options($twf));
$mform->addHelpButton('attachments', 'attachment', 'twf');
}
if (empty($post->id) && $manageactivities) {
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'twf'));
}
if (!empty($CFG->twf_enabletimedposts) && !$post->parent && has_capability('mod/twf:viewhiddentimedposts', $coursecontext)) {
// hack alert
$mform->addElement('header', 'displayperiod', get_string('displayperiod', 'twf'));
$mform->addElement('date_selector', 'timestart', get_string('displaystart', 'twf'), array('optional' => true));
$mform->addHelpButton('timestart', 'displaystart', 'twf');
$mform->addElement('date_selector', 'timeend', get_string('displayend', 'twf'), array('optional' => true));
$mform->addHelpButton('timeend', 'displayend', 'twf');
} else {
$mform->addElement('hidden', 'timestart');
$mform->setType('timestart', PARAM_INT);
$mform->addElement('hidden', 'timeend');
$mform->setType('timeend', PARAM_INT);
$mform->setConstants(array('timestart' => 0, 'timeend' => 0));
}
if ($groupmode = groups_get_activity_groupmode($cm, $course)) {
$groupdata = groups_get_activity_allowed_groups($cm);
$groupinfo = array();
foreach ($groupdata as $groupid => $group) {
// Check whether this user can post in this group.
// We must make this check because all groups are returned for a visible grouped activity.
if (twf_user_can_post_discussion($twf, $groupid, null, $cm, $modcontext)) {
// Build the data for the groupinfo select.
$groupinfo[$groupid] = $group->name;
} else {
unset($groupdata[$groupid]);
}
}
$groupcount = count($groupinfo);
// Check whether a user can post to all of their own groups.
//.........这里部分代码省略.........
示例6: simple_edit_discussion
/**
* Get the simple edit discussion form
*
* @param object $cm
* @param int $postid
* @param array $data Template data
* @return string
*/
public function simple_edit_discussion($cm, $postid = 0, array $data = array())
{
global $DB, $USER, $OUTPUT;
$context = context_module::instance($cm->id);
$forum = hsuforum_get_cm_forum($cm);
if (!empty($postid)) {
$params = array('edit' => $postid);
$legend = get_string('editingpost', 'hsuforum');
$post = $DB->get_record('hsuforum_posts', ['id' => $postid]);
if ($post->userid != $USER->id) {
$user = $DB->get_record('user', ['id' => $post->userid]);
$user = hsuforum_anonymize_user($user, $forum, $post);
$data['userpicture'] = $this->output->user_picture($user, array('link' => false, 'size' => 100));
}
} else {
$params = array('forum' => $cm->instance);
$legend = get_string('addyourdiscussion', 'hsuforum');
$thresholdwarning = hsuforum_check_throttling($forum, $cm);
if (!empty($thresholdwarning)) {
$message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
$data['thresholdwarning'] = $OUTPUT->notification($message);
if ($thresholdwarning->canpost === false) {
$data['thresholdblocked'] = " hsuforum-threshold-blocked ";
}
}
}
$data += array('itemid' => 0, 'groupid' => 0, 'messageformat' => FORMAT_HTML);
$actionurl = new moodle_url('/mod/hsuforum/route.php', array('action' => empty($postid) ? 'add_discussion' : 'update_post', 'sesskey' => sesskey(), 'edit' => $postid, 'contextid' => $context->id, 'itemid' => $data['itemid'], 'messageformat' => $data['messageformat']));
$extrahtml = '';
if (groups_get_activity_groupmode($cm)) {
$groupdata = groups_get_activity_allowed_groups($cm);
if (count($groupdata) > 1) {
if (has_capability('moodle/site:accessallgroups', $context)) {
$groupinfo[0] = get_string('allparticipants');
}
foreach ($groupdata as $grouptemp) {
$groupinfo[$grouptemp->id] = $grouptemp->name;
}
$extrahtml = html_writer::tag('span', get_string('group'));
$extrahtml .= html_writer::select($groupinfo, 'groupinfo', $data['groupid'], false);
$extrahtml = html_writer::tag('label', $extrahtml);
} else {
$actionurl->param('groupinfo', groups_get_activity_group($cm));
}
}
if ($forum->anonymous) {
$extrahtml .= html_writer::tag('label', html_writer::checkbox('reveal', 1, !empty($data['reveal'])) . get_string('reveal', 'hsuforum'));
}
$data += array('postid' => $postid, 'context' => $context, 'forum' => $forum, 'actionurl' => $actionurl, 'class' => 'hsuforum-discussion', 'legend' => $legend, 'extrahtml' => $extrahtml, 'advancedurl' => new moodle_url('/mod/hsuforum/post.php', $params));
return $this->simple_edit_template($data);
}
示例7: groups_group_visible
/**
* Determine if a given group is visible to user or not in a given context.
*
* @since Moodle 2.6
* @param int $groupid Group id to test. 0 for all groups.
* @param stdClass $course Course object.
* @param stdClass $cm Course module object.
* @param int $userid user id to test against. Defaults to $USER.
* @return boolean true if visible, false otherwise
*/
function groups_group_visible($groupid, $course, $cm = null, $userid = null)
{
global $USER;
if (empty($userid)) {
$userid = $USER->id;
}
$groupmode = empty($cm) ? groups_get_course_groupmode($course) : groups_get_activity_groupmode($cm, $course);
if ($groupmode == NOGROUPS || $groupmode == VISIBLEGROUPS) {
// Groups are not used, or everything is visible, no need to go any further.
return true;
}
$context = empty($cm) ? context_course::instance($course->id) : context_module::instance($cm->id);
if (has_capability('moodle/site:accessallgroups', $context, $userid)) {
// User can see everything. Groupid = 0 is handled here as well.
return true;
} else {
if ($groupid != 0) {
// Group mode is separate, and user doesn't have access all groups capability. Check if user can see requested group.
$groups = empty($cm) ? groups_get_all_groups($course->id, $userid) : groups_get_activity_allowed_groups($cm, $userid);
if (array_key_exists($groupid, $groups)) {
// User can see the group.
return true;
}
}
}
return false;
}
示例8: can_take_session
public function can_take_session($groupid)
{
if (!$this->can_take()) {
return false;
}
if ($groupid == attendance::SESSION_COMMON || $this->can_access_all_groups() || array_key_exists($groupid, groups_get_activity_allowed_groups($this->cm))) {
return true;
}
return false;
}
示例9: definition
/**
* Called to define this moodle form
*
* @return void
*/
public function definition()
{
global $USER, $DB, $PAGE;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext'];
$mform->addElement('header', 'general', get_string('export', 'attendance'));
$groupmode = groups_get_activity_groupmode($cm, $course);
$groups = groups_get_activity_allowed_groups($cm, $USER->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
$grouplist[0] = get_string('allparticipants');
}
if ($groups) {
foreach ($groups as $group) {
$grouplist[$group->id] = $group->name;
}
}
$mform->addElement('select', 'group', get_string('group'), $grouplist);
// Restrict the export to the selected users.
$namefields = get_all_user_name_fields(true, 'u');
$allusers = get_enrolled_users($modcontext, 'mod/attendance:canbelisted', 0, 'u.id,' . $namefields);
$userlist = array();
foreach ($allusers as $user) {
$userlist[$user->id] = fullname($user);
}
unset($allusers);
$tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $course->id), 'studentid, fullname');
foreach ($tempusers as $user) {
$userlist[$user->studentid] = $user->fullname;
}
list($gsql, $gparams) = $DB->get_in_or_equal(array_keys($grouplist), SQL_PARAMS_NAMED);
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($userlist), SQL_PARAMS_NAMED);
$params = array_merge($gparams, $uparams);
$groupmembers = $DB->get_recordset_select('groups_members', "groupid {$gsql} AND userid {$usql}", $params, '', 'groupid, userid');
$groupmappings = array();
foreach ($groupmembers as $groupmember) {
if (!isset($groupmappings[$groupmember->groupid])) {
$groupmappings[$groupmember->groupid] = array();
}
$groupmappings[$groupmember->groupid][$groupmember->userid] = $userlist[$groupmember->userid];
}
if (isset($grouplist[0])) {
$groupmappings[0] = $userlist;
}
$mform->addElement('selectyesno', 'selectedusers', get_string('onlyselectedusers', 'mod_attendance'));
$sel = $mform->addElement('select', 'users', get_string('users', 'mod_attendance'), $userlist, array('size' => 12));
$sel->setMultiple(true);
$mform->disabledIf('users', 'selectedusers', 'eq', 0);
$opts = array('groupmappings' => $groupmappings);
$PAGE->requires->yui_module('moodle-mod_attendance-groupfilter', 'M.mod_attendance.groupfilter.init', array($opts));
$ident = array();
$ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
$ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username'));
$optional = array('idnumber', 'institution', 'department');
foreach ($optional as $opt) {
$ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt));
$mform->setType($opt, PARAM_NOTAGS);
}
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('<br />'), true);
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
$mform->setType('id', PARAM_INT);
$mform->setType('uname', PARAM_INT);
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->setDefault('includeallsessions', true);
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes'));
$mform->addElement('checkbox', 'includeremarks', get_string('includeremarks', 'attendance'), get_string('yes'));
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attendance'));
$mform->setDefault('sessionstartdate', $course->startdate);
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked');
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attendance'));
$mform->disabledIf('sessionenddate', 'includeallsessions', 'checked');
$mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attendance'), 'ooo' => get_string('downloadooo', 'attendance'), 'text' => get_string('downloadtext', 'attendance')));
$submitstring = get_string('ok');
$this->add_action_buttons(false, $submitstring);
$mform->addElement('hidden', 'id', $cm->id);
}
示例10: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$coursecontext = $this->_customdata['coursecontext'];
$modcontext = $this->_customdata['modcontext'];
$forum = $this->_customdata['forum'];
$post = $this->_customdata['post'];
// if $forum->maxbytes == '0' means we should use $course->maxbytes
if ($forum->maxbytes == '0') {
$forum->maxbytes = $course->maxbytes;
}
// TODO: add max files and max size support
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'trusttext' => true, 'context' => $modcontext);
$mform->addElement('header', 'general', '');
//fill in the data depending on page params later using set_data
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('editor', 'message', get_string('message', 'forum'), null, $editoroptions);
$mform->setType('message', PARAM_RAW);
$mform->addRule('message', get_string('required'), 'required', null, 'client');
if (isset($forum->id) && forum_is_forcesubscribed($forum)) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'forum');
} else {
if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
$options = array();
$options[0] = get_string('subscribestop', 'forum');
$options[1] = get_string('subscribestart', 'forum');
$mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
$mform->addHelpButton('subscribe', 'subscription', 'forum');
} else {
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'forum');
}
}
}
if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
// 1 = No attachments at all
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, array('subdirs' => 0, 'maxbytes' => $forum->maxbytes, 'maxfiles' => $forum->maxattachments, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL));
$mform->addHelpButton('attachments', 'attachment', 'forum');
}
if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
// hack alert
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
}
if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) {
// hack alert
$mform->addElement('header', '', get_string('displayperiod', 'forum'));
$mform->addElement('date_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
$mform->addHelpButton('timestart', 'displaystart', 'forum');
$mform->addElement('date_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
$mform->addHelpButton('timeend', 'displayend', 'forum');
} else {
$mform->addElement('hidden', 'timestart');
$mform->setType('timestart', PARAM_INT);
$mform->addElement('hidden', 'timeend');
$mform->setType('timeend', PARAM_INT);
$mform->setConstants(array('timestart' => 0, 'timeend' => 0));
}
if (groups_get_activity_groupmode($cm, $course)) {
// hack alert
$groupdata = groups_get_activity_allowed_groups($cm);
$groupcount = count($groupdata);
$modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
if ($contextcheck) {
$groupinfo = array('0' => get_string('allparticipants'));
foreach ($groupdata as $grouptemp) {
$groupinfo[$grouptemp->id] = $grouptemp->name;
}
$mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
$mform->setDefault('groupinfo', $post->groupid);
} else {
if (empty($post->groupid)) {
$groupname = get_string('allparticipants');
} else {
$groupname = format_string($groupdata[$post->groupid]->name);
}
$mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
}
}
//-------------------------------------------------------------------------------
// buttons
if (isset($post->edit)) {
// hack alert
$submit_string = get_string('savechanges');
} else {
$submit_string = get_string('posttoforum', 'forum');
}
$this->add_action_buttons(false, $submit_string);
//.........这里部分代码省略.........
示例11: groups_user_groups_visible
/**
* Determine if the current user can see at least one of the groups of the specified user.
*
* @param stdClass $course Course object.
* @param int $userid user id to check against.
* @param stdClass $cm Course module object. Optional, just for checking at activity level instead course one.
* @return boolean true if visible, false otherwise
* @since Moodle 2.9
*/
function groups_user_groups_visible($course, $userid, $cm = null)
{
global $USER;
$groupmode = empty($cm) ? groups_get_course_groupmode($course) : groups_get_activity_groupmode($cm, $course);
if ($groupmode == NOGROUPS || $groupmode == VISIBLEGROUPS) {
// Groups are not used, or everything is visible, no need to go any further.
return true;
}
$context = empty($cm) ? context_course::instance($course->id) : context_module::instance($cm->id);
if (has_capability('moodle/site:accessallgroups', $context)) {
// User can see everything.
return true;
} else {
// Group mode is separate, and user doesn't have access all groups capability.
if (empty($cm)) {
$usergroups = groups_get_all_groups($course->id, $userid);
$currentusergroups = groups_get_all_groups($course->id, $USER->id);
} else {
$usergroups = groups_get_activity_allowed_groups($cm, $userid);
$currentusergroups = groups_get_activity_allowed_groups($cm, $USER->id);
}
$samegroups = array_intersect_key($currentusergroups, $usergroups);
if (!empty($samegroups)) {
// We share groups!
return true;
}
}
return false;
}
示例12: ouwiki_display_subwiki_selector
/**
* Prints the subwiki selector if user has access to more than one subwiki.
* Also displays the currently-viewing subwiki.
*
* @param object $subwiki Current subwiki object
* @param object $ouwiki Wiki object
* @param object $cm Course-module object
* @param object $context Context for permissions
* @param object $course Course object
*/
function ouwiki_display_subwiki_selector($subwiki, $ouwiki, $cm, $context, $course, $actionurl = 'view.php')
{
global $USER, $DB;
if ($ouwiki->subwikis == OUWIKI_SUBWIKIS_SINGLE) {
return '';
}
$choicefield = '';
switch ($ouwiki->subwikis) {
case OUWIKI_SUBWIKIS_GROUPS:
$groups = groups_get_activity_allowed_groups($cm);
uasort($groups, create_function('$a,$b', 'return strcasecmp($a->name,$b->name);'));
$wikifor = htmlspecialchars($groups[$subwiki->groupid]->name);
// Do they have more than one?
if (count($groups) > 1) {
$choicefield = 'group';
$choices = $groups;
}
break;
case OUWIKI_SUBWIKIS_INDIVIDUAL:
$user = $DB->get_record('user', array('id' => $subwiki->userid), 'id, firstname, lastname, username');
$wikifor = ouwiki_display_user($user, $cm->course);
if (has_capability('mod/ouwiki:viewallindividuals', $context)) {
// Get list of everybody...
$choicefield = 'user';
try {
$choices = $DB->get_records_sql('SELECT u.id, u.firstname, u.lastname
FROM {ouwiki_subwikis} sw
INNER JOIN {user} u ON sw.userid = u.id
WHERE sw.wikiid = ?
ORDER BY u.lastname, u.firstname', array($ouwiki->id));
} catch (Exception $e) {
ouwiki_dberror($e);
}
foreach ($choices as $choice) {
$choice->name = fullname($choice);
}
} else {
if (has_capability('mod/ouwiki:viewgroupindividuals', $context)) {
$choicefield = 'user';
$choices = array();
// User allowed to view people in same group
$theirgroups = groups_get_all_groups($cm->course, $USER->id, $course->defaultgroupingid);
if (!$theirgroups) {
$theirgroups = array();
}
foreach ($theirgroups as $group) {
$members = groups_get_members($group->id, 'u.id, u.firstname, u.lastname');
foreach ($members as $member) {
$member->name = fullname($member);
$choices[$member->id] = $member;
}
}
} else {
// Nope, only yours
}
}
break;
default:
ouwiki_error("Unexpected subwikis value: {$ouwiki->subwikis}");
}
$out = '<div class="ouw_subwiki"><label for="wikiselect">' . get_string('wikifor', 'ouwiki') . '</label>';
if ($choicefield && count($choices) > 1) {
$selectedid = $choicefield == 'user' ? $subwiki->userid : $subwiki->groupid;
$out .= '<form method="get" action="' . $actionurl . '" class="ouwiki_otherwikis">
<div><input type="hidden" name="id" value="' . $cm->id . '"/>
<select name="' . $choicefield . '" id="wikiselect">';
foreach ($choices as $choice) {
$selected = $choice->id == $selectedid ? ' selected="selected"' : '';
$out .= '<option value="' . $choice->id . '"' . $selected . '>' . htmlspecialchars($choice->name) . '</option>';
}
$out .= '</select> <input type="submit" value="' . get_string('changebutton', 'ouwiki') . '" /></div></form>';
} else {
$out .= $wikifor;
}
$out .= '</div>';
return $out;
}
示例13: definition
/**
* Form definition
*
* @return void
*/
function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$coursecontext = $this->_customdata['coursecontext'];
$modcontext = $this->_customdata['modcontext'];
$forum = $this->_customdata['forum'];
$post = $this->_customdata['post'];
$edit = $this->_customdata['edit'];
$thresholdwarning = $this->_customdata['thresholdwarning'];
$mform->addElement('header', 'general', '');
//fill in the data depending on page params later using set_data
// If there is a warning message and we are not editing a post we need to handle the warning.
if (!empty($thresholdwarning) && !$edit) {
// Here we want to display a warning if they can still post but have reached the warning threshold.
if ($thresholdwarning->canpost) {
$message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
$mform->addElement('html', $OUTPUT->notification($message));
}
}
$mform->addElement('text', 'subject', get_string('subject', 'forum'), 'size="48"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('editor', 'message', get_string('message', 'forum'), null, self::editor_options($modcontext, empty($post->id) ? null : $post->id));
$mform->setType('message', PARAM_RAW);
$mform->addRule('message', get_string('required'), 'required', null, 'client');
if (isset($forum->id) && forum_is_forcesubscribed($forum)) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('everyoneissubscribed', 'forum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'forum');
} else {
if (isset($forum->forcesubscribe) && $forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
$options = array();
$options[0] = get_string('subscribestop', 'forum');
$options[1] = get_string('subscribestart', 'forum');
$mform->addElement('select', 'subscribe', get_string('subscription', 'forum'), $options);
$mform->addHelpButton('subscribe', 'subscription', 'forum');
} else {
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'forum'), get_string('disallowsubscribe', 'forum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'forum');
}
}
}
if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) {
// 1 = No attachments at all
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, self::attachment_options($forum));
$mform->addHelpButton('attachments', 'attachment', 'forum');
}
if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
// hack alert
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum'));
}
if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) {
// hack alert
$mform->addElement('header', 'displayperiod', get_string('displayperiod', 'forum'));
$mform->addElement('date_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true));
$mform->addHelpButton('timestart', 'displaystart', 'forum');
$mform->addElement('date_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true));
$mform->addHelpButton('timeend', 'displayend', 'forum');
} else {
$mform->addElement('hidden', 'timestart');
$mform->setType('timestart', PARAM_INT);
$mform->addElement('hidden', 'timeend');
$mform->setType('timeend', PARAM_INT);
$mform->setConstants(array('timestart' => 0, 'timeend' => 0));
}
if (groups_get_activity_groupmode($cm, $course)) {
// hack alert
$groupdata = groups_get_activity_allowed_groups($cm);
$groupcount = count($groupdata);
$modulecontext = context_module::instance($cm->id);
$contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount;
if ($contextcheck) {
$groupinfo = array('0' => get_string('allparticipants'));
foreach ($groupdata as $grouptemp) {
$groupinfo[$grouptemp->id] = $grouptemp->name;
}
$mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
$mform->setDefault('groupinfo', $post->groupid);
$mform->setType('groupinfo', PARAM_INT);
} else {
if (empty($post->groupid)) {
$groupname = get_string('allparticipants');
} else {
$groupname = format_string($groupdata[$post->groupid]->name);
}
$mform->addElement('static', 'groupinfo', get_string('group'), $groupname);
}
//.........这里部分代码省略.........
示例14: display_edit
/**
*
*/
public function display_edit(&$mform, $entry, array $options = null)
{
$field = $this->_field;
$fieldid = $field->id;
$entryid = $entry->id;
$fieldname = "entry_{$entryid}_groupid";
$selected = $entry->groupid;
static $groupsmenu = null;
if (is_null($groupsmenu)) {
$groupsmenu = array(0 => get_string('choosedots'));
if ($groups = groups_get_activity_allowed_groups($field->df->cm)) {
foreach ($groups as $groupid => $group) {
$groupsmenu[$groupid] = $group->name;
}
}
}
$mform->addElement('select', $fieldname, null, $groupsmenu);
$mform->setDefault($fieldname, $selected);
}
示例15: definition
/**
* Form definition
*
* @return void
*/
function definition()
{
global $OUTPUT, $USER, $DB;
$config = get_config('hsuforum');
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$coursecontext = $this->_customdata['coursecontext'];
$modcontext = $this->_customdata['modcontext'];
$forum = $this->_customdata['forum'];
$post = $this->_customdata['post'];
$edit = $this->_customdata['edit'];
$thresholdwarning = $this->_customdata['thresholdwarning'];
$mform->addElement('html', '<div class="fcontainer">');
// If there is a warning message and we are not editing a post we need to handle the warning.
if (!empty($thresholdwarning) && !$edit) {
// Here we want to display a warning if they can still post but have reached the warning threshold.
if ($thresholdwarning->canpost) {
$message = get_string($thresholdwarning->errorcode, $thresholdwarning->module, $thresholdwarning->additional);
$mform->addElement('html', $OUTPUT->notification($message));
}
}
$mform->addElement('text', 'subject', get_string('subject', 'hsuforum'), 'size="48"');
$mform->setType('subject', PARAM_TEXT);
$mform->addRule('subject', get_string('required'), 'required', null, 'client');
$mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('editor', 'message', get_string('message', 'hsuforum'), null, self::editor_options($modcontext, empty($post->id) ? null : $post->id));
$mform->setType('message', PARAM_RAW);
$mform->addRule('message', get_string('required'), 'required', null, 'client');
if (isset($forum->id) && hsuforum_is_forcesubscribed($forum)) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'hsuforum'), get_string('everyoneissubscribed', 'hsuforum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'hsuforum');
} else {
if (isset($forum->forcesubscribe) && $forum->forcesubscribe != HSUFORUM_DISALLOWSUBSCRIBE || has_capability('moodle/course:manageactivities', $coursecontext)) {
$options = array();
$options[0] = get_string('subscribestop', 'hsuforum');
$options[1] = get_string('subscribestart', 'hsuforum');
$mform->addElement('select', 'subscribe', get_string('subscription', 'hsuforum'), $options);
$mform->addHelpButton('subscribe', 'subscription', 'hsuforum');
} else {
if ($forum->forcesubscribe == HSUFORUM_DISALLOWSUBSCRIBE) {
$mform->addElement('static', 'subscribemessage', get_string('subscription', 'hsuforum'), get_string('disallowsubscribe', 'hsuforum'));
$mform->addElement('hidden', 'subscribe');
$mform->setType('subscribe', PARAM_INT);
$mform->addHelpButton('subscribemessage', 'subscription', 'hsuforum');
}
}
}
if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/hsuforum:createattachment', $modcontext)) {
// 1 = No attachments at all
$mform->addElement('filemanager', 'attachments', get_string('attachment', 'hsuforum'), null, self::attachment_options($forum));
$mform->addHelpButton('attachments', 'attachment', 'hsuforum');
}
if (empty($post->id) && has_capability('moodle/course:manageactivities', $coursecontext)) {
// hack alert
$mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'hsuforum'));
}
if (!empty($config->enabletimedposts) && !$post->parent && has_capability('mod/hsuforum:viewhiddentimedposts', $coursecontext)) {
// hack alert
$mform->addElement('header', 'displayperiod', get_string('displayperiod', 'hsuforum'));
$mform->addElement('date_selector', 'timestart', get_string('displaystart', 'hsuforum'), array('optional' => true));
$mform->addHelpButton('timestart', 'displaystart', 'hsuforum');
$mform->addElement('date_selector', 'timeend', get_string('displayend', 'hsuforum'), array('optional' => true));
$mform->addHelpButton('timeend', 'displayend', 'hsuforum');
} else {
$mform->addElement('hidden', 'timestart');
$mform->setType('timestart', PARAM_INT);
$mform->addElement('hidden', 'timeend');
$mform->setType('timeend', PARAM_INT);
$mform->setConstants(array('timestart' => 0, 'timeend' => 0));
}
if ($groupmode = groups_get_activity_groupmode($cm, $course)) {
// hack alert
$groupdata = groups_get_activity_allowed_groups($cm);
$groupcount = count($groupdata);
$groupinfo = array();
$modulecontext = context_module::instance($cm->id);
// Check whether the user has access to all groups in this forum from the accessallgroups cap.
if ($groupmode == VISIBLEGROUPS || has_capability('moodle/site:accessallgroups', $modulecontext)) {
// Only allow posting to all groups if the user has access to all groups.
$groupinfo = array('0' => get_string('allparticipants'));
$groupcount++;
}
$contextcheck = has_capability('mod/hsuforum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
if ($contextcheck) {
foreach ($groupdata as $grouptemp) {
$groupinfo[$grouptemp->id] = $grouptemp->name;
}
$mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo);
$mform->setDefault('groupinfo', $post->groupid);
$mform->setType('groupinfo', PARAM_INT);
} else {
if (empty($post->groupid)) {
//.........这里部分代码省略.........