本文整理汇总了PHP中get_course_users函数的典型用法代码示例。如果您正苦于以下问题:PHP get_course_users函数的具体用法?PHP get_course_users怎么用?PHP get_course_users使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_course_users函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $CFG, $COURSE, $USER;
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
// the following 3 lines is need to pass _self_test();
if (empty($this->instance->pageid)) {
return '';
}
$this->content = new object();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
/// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
if (!($currentcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
$this->content = '';
return $this->content;
}
if ($COURSE->id == SITEID) {
if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
$this->content = '';
return $this->content;
}
} else {
if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
$this->content = '';
return $this->content;
}
}
// a nice sample of how to get a data from a table:
$uif = get_field('user_info_field', 'id', 'shortname', 'class');
//echo "uif = $uif<br/>";
$currentuserclass = get_field('user_info_data', 'data', 'userid', $USER->id, 'fieldid', $uif);
//echo "udf data (class) = $udf<br/>";
$courseusers = get_course_users($COURSE->id);
foreach ($courseusers as $cuser) {
$currentclass = get_field('user_info_data', 'data', 'userid', $cuser->id, 'fieldid', $uif);
if ($currentclass == $currentuserclass) {
$this->content->items[] = "<a href=\"{$CFG->wwwroot}/blog/index.php?userid={$cuser->id}&courseid={$COURSE->id}\" >{$cuser->firstname} {$cuser->lastname}</a>";
$this->content->icons[] = "<img src=\"{$CFG->wwwroot}/user/pix.php/{$cuser->id}/f2.jpg\" class=\"icon\" alt=\"\" />";
}
}
return $this->content;
}
示例2: forum_add_instance
/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will create a new instance and return the id number
* of the new instance.
* @param object $forum add forum instance (with magic quotes)
* @return int intance id
*/
function forum_add_instance($forum)
{
global $CFG;
$forum->timemodified = time();
if (empty($forum->assessed)) {
$forum->assessed = 0;
}
if (empty($forum->ratingtime) or empty($forum->assessed)) {
$forum->assesstimestart = 0;
$forum->assesstimefinish = 0;
}
if (!($forum->id = insert_record('forum', $forum))) {
return false;
}
if ($forum->type == 'single') {
// Create related discussion.
$discussion = new object();
$discussion->course = $forum->course;
$discussion->forum = $forum->id;
$discussion->name = $forum->name;
$discussion->intro = $forum->intro;
$discussion->assessed = $forum->assessed;
$discussion->format = $forum->type;
$discussion->mailnow = false;
$discussion->groupid = -1;
if (!forum_add_discussion($discussion, $discussion->intro)) {
error('Could not add the discussion for this forum');
}
}
if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) {
// all users should be subscribed initially
$users = get_course_users($forum->course);
foreach ($users as $user) {
forum_subscribe($user->id, $forum->id);
}
}
$forum = stripslashes_recursive($forum);
forum_grade_item_update($forum);
return $forum->id;
}
示例3: groups_get_users_not_in_group
/**
* Gets the users for a course who are not in a specified group
* @param int $groupid The id of the group
* @return array An array of the userids of the non-group members, or false if
* an error occurred.
*/
function groups_get_users_not_in_group($courseid, $groupid)
{
$users = get_course_users($courseid);
$userids = groups_users_to_userids($users);
$nongroupmembers = array();
foreach ($userids as $userid) {
if (!groups_is_member($groupid, $userid)) {
array_push($nongroupmembers, $userid);
}
}
return $nongroupmembers;
}
示例4: wwassignment_get_participants
/**
* @desc Finds all the participants in the course
* @param string $wwassignmentid The Moodle wwassignment ID.
* @return array An array of course users (IDs).
*/
function wwassignment_get_participants($wwassignmentid)
{
$wwassignment = get_record('wwassignment', 'id', $wwassignmentid);
if (!isset($wwassignment)) {
return array();
}
return get_course_users($wwassignment->course);
}
示例5: error
* This view provides a summary for the teacher
*
* @package mod-poodllflashcard
* @category mod
* @author Valery Fremaux, Gustav Delius
* @contributors
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
// security
if (!defined('MOODLE_INTERNAL')) {
error("Illegal direct access to this screen");
}
if ($action != '') {
include "{$CFG->dirroot}/mod/poodllflashcard/usersummaryview.controller.php";
}
$courseusers = get_course_users($COURSE->id);
$struser = get_string('username');
$strdeckstates = get_string('deckstates', 'poodllflashcard');
$strcounts = get_string('counters', 'poodllflashcard');
$table->head = array("<b>{$struser}</b>", "<b>{$strdeckstates}</b>", "<b>{$strcounts}</b>");
$table->size = array('30%', '50%', '20%');
$table->width = "90%";
if (!empty($courseusers)) {
foreach ($courseusers as $auser) {
$status = poodllflashcard_get_deck_status($flashcard, $auser->id);
// if (has_capability('mod/poodllflashcard:manage', $context, $auser->id)) continue;
$userbox = print_user_picture($auser, $COURSE->id, true, false, true, true, '', true);
$userbox .= fullname($auser);
if ($status) {
$flashcard->cm =& $cm;
$deckbox = poodllflashcard_print_deck_status($flashcard, $auser->id, $status, true);
示例6: wiki_print_groupmode_selection
/**
* This function is the responsable of printing the group mode menu
*
* There are 9 possible combinations of groupmode-studentmode.
*
* Groupmode Studentmode Description
* 0 0 No groups-Users in groups
* 0 1 No groups-Separate Users
* 0 2 No groups-Visible Users
* 1 0 Separate Groups-Users in groups
* 1 1 Separate Groups-Separate Users
* 1 2 Separate Groups-Visible Users
* 2 0 Visible Groups-Users in groups
* 2 1 Visible Groups-Separate Users
* 2 2 Visible Groups-Visible Users
*
*
* @param WikiStorage $WS.
*
* @TODO: this function is filled of bugs. We have to rewrite it.
*
*/
function wiki_print_groupmode_selection(&$WS)
{
global $USER, $CFG, $COURSE;
//this function is the responsable of printing the group mode menu
//Course groups list
$wikimanager = wiki_manager_get_instance();
$listgroups = $wikimanager->get_course_groups($COURSE->id);
$listmembers = $listgroupsmembers = $wikimanager->get_course_members($COURSE->id);
$context = get_context_instance(CONTEXT_MODULE, $WS->cm->id);
$cm->id = isset($WS->dfcourse) ? $COURSE->id : $WS->cm->id;
switch ($WS->cm->groupmode) {
//Without groups:
case '0':
// if no groups then get all the users of the course
$listmembers = get_course_users($COURSE->id, 'u.lastname');
switch ($WS->dfwiki->studentmode) {
//Commune wiki
case '0':
//no menu
break;
//Separate students
//Separate students
case '1':
if (has_capability('mod/wiki:editanywiki', $context)) {
wiki_print_menu_students($listmembers, $WS->member->id, $cm);
}
break;
//Visible students
//Visible students
case '2':
wiki_print_menu_students($listmembers, $WS->member->id, $cm);
break;
default:
break;
}
break;
//Separate groups:
//Separate groups:
case '1':
switch ($WS->dfwiki->studentmode) {
//Students in group
case '0':
wiki_print_menu_groups($listgroups, $WS->groupmember->groupid, $cm, $WS);
break;
//Separate students
//Separate students
case '1':
wiki_print_menu_groups_and_students($listgroups, $listgroupsmembers, $WS);
break;
//Visible students
//Visible students
case '2':
wiki_print_menu_groups_and_students($listgroups, $listgroupsmembers, $WS);
break;
default:
break;
}
break;
//Visible groups:
//Visible groups:
case '2':
switch ($WS->dfwiki->studentmode) {
//Students in group
case '0':
wiki_print_menu_groups($listgroups, $WS->groupmember->groupid, $cm, $WS);
break;
//Separate students
//Separate students
case '1':
wiki_print_menu_groups_and_students($listgroups, $listgroupsmembers, $WS);
break;
//Visible students
//Visible students
case '2':
wiki_print_menu_groups_and_students($listgroups, $listgroupsmembers, $WS);
break;
default:
break;
//.........这里部分代码省略.........
示例7: error
if ($type != "student.png" or $sid != $USER->id) {
error("Sorry, you aren't allowed to see this.");
} else {
if ($groupmode and !ismember($group)) {
error("Sorry, you aren't allowed to see this.");
}
}
}
if (!($survey = get_record("survey", "id", $cm->instance))) {
error("Survey ID was incorrect");
}
/// Check to see if groups are being used in this survey
if ($groupmode and $group) {
$users = get_group_users($group);
} else {
$users = get_course_users($course->id);
$group = false;
}
$stractual = get_string("actual", "survey");
$stractualclass = get_string("actualclass", "survey");
$stractualstudent = get_string("actualstudent", "survey", $course->student);
$strpreferred = get_string("preferred", "survey");
$strpreferredclass = get_string("preferredclass", "survey");
$strpreferredstudent = get_string("preferredstudent", "survey", $course->student);
$virtualscales = false;
//set default value for case clauses
switch ($type) {
case "question.png":
$question = get_record("survey_questions", "id", $qid);
$question->text = get_string($question->text, "survey");
$question->options = get_string($question->options, "survey");
示例8: find_real_names_course
/**
* Lookup the avatar/real name associations for everybody in the current course.
* NOTE: fails if a course is not loaded in the current {@link SloodleSession}
* @return array|bool An associative array of avatar names to (full) real names if successful, or false if a course is not available
*/
function find_real_names_course()
{
// Make sure we have a course loaded
if (!isset($this->_session)) {
return false;
}
if (!$this->_session->course->is_loaded()) {
return false;
}
$user = new SloodleUser($this->_session);
// Get a list of users of the course
$courseusers = get_course_users($this->_session->course->get_course_id());
if (!is_array($courseusers)) {
$courseusers = array();
}
// Go through each user
$output = array();
foreach ($courseusers as $u) {
// Attempt to fetch the avatar data for this Moodle user
$user->load_user($u->id);
if (!$user->load_linked_avatar()) {
continue;
}
// Store the name association
$output[$user->get_avatar_name()] = $u->firstname . ' ' . $u->lastname;
}
return $output;
}
示例9: hotpot_get_report_users
function hotpot_get_report_users($course, $formdata)
{
$users = array();
/// Check to see if groups are being used in this module
$groupmode = groupmode($course, $cm);
//TODO: there is no $cm defined!
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id={$cm->id}&mode=simple");
$sort = "u.lastname ASC";
switch ($formdata['reportusers']) {
case 'students':
if ($currentgroup) {
$users = get_group_students($currentgroup, $sort);
} else {
$users = get_course_students($course->id, $sort);
}
break;
case 'all':
if ($currentgroup) {
$users = get_group_users($currentgroup, $sort);
} else {
$users = get_course_users($course->id, $sort);
}
break;
}
return $users;
}
示例10: print_mnet_log_selector_form
function print_mnet_log_selector_form($hostid, $course, $selecteduser = 0, $selecteddate = 'today', $modname = "", $modid = 0, $modaction = '', $selectedgroup = -1, $showcourses = 0, $showusers = 0)
{
global $USER, $CFG, $SITE;
require_once $CFG->dirroot . '/mnet/peer.php';
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
$sql = "select distinct course, hostid, coursename from {$CFG->prefix}mnet_log";
$courses = get_records_sql($sql);
$remotecoursecount = count($courses);
// first check to see if we can override showcourses and showusers
$numcourses = $remotecoursecount + count_records_select("course", "", "COUNT(id)");
if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
$showcourses = 1;
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
// Context for remote data is always SITE
// Groups for remote data are always OFF
if ($hostid == $CFG->mnet_localhost_id) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
/// Setup for group handling.
if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
$selectedgroup = get_current_group($course->id);
$showgroups = false;
} else {
if ($course->groupmode) {
$selectedgroup = $selectedgroup == -1 ? get_current_group($course->id) : $selectedgroup;
$showgroups = true;
} else {
$selectedgroup = 0;
$showgroups = false;
}
}
} else {
$context = $sitecontext;
}
// Get all the possible users
$users = array();
// If looking at a different host, we're interested in all our site users
if ($hostid == $CFG->mnet_localhost_id && $course->id != SITEID) {
if ($selectedgroup) {
// If using a group, only get users in that group.
$courseusers = get_group_users($selectedgroup, 'u.lastname ASC', '', 'u.id, u.firstname, u.lastname, u.idnumber');
} else {
$courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname, u.idnumber');
}
} else {
$courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
}
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
$showusers = 1;
}
if ($showusers) {
if ($courseusers) {
foreach ($courseusers as $courseuser) {
$users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
}
}
if ($guest = get_guest()) {
$users[$guest->id] = fullname($guest);
}
}
// Get all the hosts that have log records
$sql = "select distinct\n h.id,\n h.name\n from\n {$CFG->prefix}mnet_host h,\n {$CFG->prefix}mnet_log l\n where\n h.id = l.hostid\n order by\n h.name";
$hostarray = array();
$dropdown = array();
if ($hosts = get_records_sql($sql)) {
foreach ($hosts as $host) {
$hostarray[$host->id] = $host->name;
}
}
$hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
asort($hostarray);
// $hostid already exists
foreach ($hostarray as $hostid_ => $name) {
$courses = array();
$sites = array();
if (has_capability('moodle/site:viewreports', $context) && $showcourses) {
if ($CFG->mnet_localhost_id == $hostid_) {
if ($ccc = get_records("course", "", "", "fullname", "id,fullname,category")) {
foreach ($ccc as $cc) {
if ($cc->id == SITEID) {
$sites["{$hostid_}/{$cc->id}"] = format_string($cc->fullname) . ' (' . get_string('site') . ')';
} else {
$courses["{$hostid_}/{$cc->id}"] = format_string($cc->fullname);
}
}
}
} else {
$sql = "select distinct course, coursename from mdl_mnet_log where hostid = '{$hostid_}'";
if ($ccc = get_records_sql($sql)) {
foreach ($ccc as $cc) {
if (1 == $cc->course) {
// TODO: MDL-8187 : this might be wrong - site course may have another id
$sites["{$hostid_}/{$cc->course}"] = $cc->coursename . ' (' . get_string('site') . ')';
} else {
$courses["{$hostid_}/{$cc->course}"] = $cc->coursename;
}
}
}
}
//.........这里部分代码省略.........
示例11: wiki_grade_get_users_info
function wiki_grade_get_users_info($courseid, $wikiid)
{
global $CFG;
$USERS_PER_PAGE = 18;
$group = optional_param('group', -1, PARAM_INT);
if ($group >= 0) {
$users = get_group_students($group);
$groups = groups_get_all_groups($courseid);
$groupname = $groups[$group]->name;
$a->of = 'of group ' . $groupname;
} else {
$users = get_course_users($courseid, 'u.lastname', '', 'u.id, u.firstname, u.lastname, u.idnumber');
$a->of = '';
}
$users = array_values($users);
$num_users = count($users);
$num_pages = wiki_grade_get_num_userpages($num_users, $USERS_PER_PAGE);
$userlistpage = optional_param('userlistpage', 0, PARAM_INT);
if ($userlistpage >= $num_pages) {
$userlistpage = 0;
}
$from = $userlistpage * $USERS_PER_PAGE;
if ($userlistpage == $num_pages - 1) {
$to = $from + $num_users % $USERS_PER_PAGE;
} else {
$to = $from + $USERS_PER_PAGE;
}
$output = print_box_start('generalbox', '', true);
$output .= '<div style="float:left">';
$a->from = $from + 1;
$a->to = $to;
$a->total = $num_users;
$output .= get_string('eval_show_userlist', 'wiki', $a);
$output .= '</div>';
$output .= '<div style="float:right">';
$output .= '<table><tr><td><i>' . get_string('legend', 'wiki') . ': </i></td>';
$output .= '<td class="borderred">' . get_string('eval_legend_user_nograde', 'wiki') . '</td>';
$output .= '<td> </td>';
$output .= '<td class="bordergreen">' . get_string('eval_legend_user_grade', 'wiki') . '</td>';
$output .= '</tr></table>';
$output .= '</div>';
$output .= '<div style="clear:both"> </div>';
if (!$users) {
echo 'grades.lib.php: there is not any user in this course';
} else {
$wikimanager = wiki_manager_get_instance();
$output .= '<ul class="userlist">';
$output .= "\n\n" . '<div class="container"><br/>';
for ($i = $from; $i < $to; $i++) {
$myuser = $users[$i];
$output .= '<li>';
$info = $wikimanager->get_user_info_by_id($myuser->id);
$grade = grade_get_grades($courseid, 'mod', 'wiki', $wikiid, $myuser->id);
if (isset($grade->items[0]->grades[$myuser->id])) {
$grade = $grade->items[0]->grades[$myuser->id]->str_grade;
} else {
$grade = null;
}
$output .= "\n" . wiki_grade_get_user_info($info, $courseid, $grade);
$output .= '</li>';
}
$output .= '</ul>' . "\n\n";
$output .= wiki_grade_get_userpages($num_users, $userlistpage, $courseid, $USERS_PER_PAGE);
$output .= '</tr></td></table>';
$output .= print_box_end(true);
echo $output;
}
}
示例12: count
/// Get all discussions that have had posts since the old post date.
if ($discussions = get_records_select('forum_discussions', 'timemodified > ' . $dateafter, 'course', 'id,course,forum,groupid,userid')) {
$dtotal = count($discussions);
print_heading('Updating forum post read/unread records for ' . $dtotal . ' discussions...' . 'Please keep this window open until it completes', '', 3);
$groups = array();
$currcourse = 0;
$users = 0;
$count = 0;
$dcount = 0;
foreach ($discussions as $discussion) {
$dcount++;
print_progress($dcount, $dtotal);
if ($discussion->course != $currcourse) {
/// Discussions are ordered by course, so we only need to get any course's users once.
$currcourse = $discussion->course;
$users = get_course_users($currcourse, '', '', 'u.id,u.confirmed');
}
/// If this course has users, and posts more than a day old, mark them for each user.
if ($users && ($posts = get_records_select('forum_posts', 'discussion = ' . $discussion->id . ' AND ' . $dateafter . ' < modified AND modified < ' . $onedayago, '', 'id,discussion,modified'))) {
foreach ($users as $user) {
/// If its a group discussion, make sure the user is in the group.
if ($discussion->groupid) {
if (!isset($groups[$discussion->groupid][$user->id])) {
$groups[$discussion->groupid][$user->id] = ismember($discussion->groupid, $user->id);
}
}
if (!$discussion->groupid || !empty($groups[$discussion->groupid][$user->id])) {
foreach ($posts as $post) {
print_progress($dcount, $dtotal);
forum_tp_mark_post_read($user->id, $post, $discussion->forum);
}
示例13: skype_show
function skype_show($skype, $user, $cm, $what = "form")
{
global $USER;
$which_group = user_group($cm->course, $user->id);
if (!$which_group) {
$g_id = 0;
} else {
foreach ($which_group as $www => $xxx) {
$g_id = $xxx->id;
}
}
if ($skype->participants == '0') {
//0 for students, 1 for tutors of course
if ($g_id == 0) {
$call_users = get_course_users($cm->course);
} else {
$call_users = get_group_users($g_id);
}
} else {
$call_users = get_course_teachers($cm->course);
}
$return = "";
if ($call_users) {
foreach ($call_users as $call_user) {
if ($call_user->skype) {
$skypeid = $call_user->skype;
if ($what == "casts") {
$return .= '
<script type="text/javascript" src="https://feedsskypecasts.skype.com/skypecasts/webservice/get.js?limit=100&user=' . $skypeid . '"></script>
<script language="javascript" type="text/javascript">//<![CDATA[
var cast;
var cntx=0;
for(i in Skypecasts) {
cntx=1;
cast = Skypecasts[i];
document.write("<a target=\\"_blank\\" href=\\""+cast.url_info+"\\"><img src=\\"skypecast_icon.gif\\" border=0 width=\\"76\\" height=\\"76\\" alt=\\""+cast.title+"\\" /></a>");
document.write("<p class=\\"skypecast-title\\"><a target=\\"_blank\\" href=\\""+cast.url_info+"\\">"+cast.title+"</a></p>");
document.write("<p class=\\"skypecast-host\\">' . get_string("moderator", "skype") . ': "+cast.host_name+"</p>");
document.write("<p class=\\"skypecast-date\\">"+cast.start_time_hint+"</p>");
}
if(cntx == 0){
document.write("<p class=\\"skypecast-title\\">There are no Skypecasts for you!</p><br><br><br>");
document.write("<p class=\\"skypecast-title\\"><br><br><br><br><br><br><br><br> </p>");
}
//]]></script>
';
} else {
if ($USER->id != $call_user->id) {
$return .= "\n\t\t\t\t\t\t<option value='{$skypeid}'>" . fullname($call_user, true) . "</option>";
}
}
}
}
} else {
$call_users = get_course_users($cm->course);
if ($call_users) {
foreach ($call_users as $call_user) {
if ($call_user->skype) {
$skypeid = $call_user->skype;
if ($what == "casts") {
$return .= '
<script type="text/javascript" src="https://feedsskypecasts.skype.com/skypecasts/webservice/get.js?limit=100&user=' . $skypeid . '"></script>
<script language="javascript" type="text/javascript">//<![CDATA[
var cast;
var cntx=0;
for(i in Skypecasts) {
cntx=1;
cast = Skypecasts[i];
document.write("<a target=\\"_blank\\" href=\\""+cast.url_info+"\\"><img src=\\"skypecast_icon.gif\\" border=0 width=\\"76\\" height=\\"76\\" alt=\\""+cast.title+"\\" /></a>");
document.write("<p class=\\"skypecast-title\\"><a target=\\"_blank\\" href=\\""+cast.url_info+"\\">"+cast.title+"</a></p>");
document.write("<p class=\\"skypecast-host\\">' . get_string("moderator", "skype") . ': "+cast.host_name+"</p>");
document.write("<p class=\\"skypecast-date\\">"+cast.start_time_hint+"</p>");
}
if(cntx == 0){
document.write("<p class=\\"skypecast-title\\">There are no Skypecasts for you!</p><br><br><br>");
document.write("<p class=\\"skypecast-title\\"><br><br><br><br><br><br><br><br> </p>");
}
//]]></script>
';
} else {
if ($USER->id != $call_user->id) {
$return .= "\n\t\t\t\t\t\t\t\t<option value='{$skypeid}'>" . fullname($call_user, true) . "</option>";
}
}
}
}
}
}
return $return;
}
示例14: show_user_group_filter_form
/**
* This function displays a dropdown list that allows the course administrator do view the calendar items of one specific group
* @author: Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function show_user_group_filter_form()
{
echo "<select name=\"select\" onchange=\"javascript: MM_jumpMenu('parent',this,0)\">";
echo "<option value=\"agenda.php?user=none&action=view\">" . get_lang("ShowAll") . "</option>";
// Groups
$group_list = get_course_groups();
$group_available_to_access = array();
$option = '';
if (!empty($group_list)) {
$option = "<optgroup label=\"" . get_lang("Groups") . "\">";
foreach ($group_list as $this_group) {
// echo "<option value=\"agenda.php?isStudentView=true&group=".$this_group['id']."\">".$this_group['name']."</option>";
$has_access = GroupManager::user_has_access(api_get_user_id(), $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR);
$result = GroupManager::get_group_properties($this_group['id']);
if ($result['calendar_state'] != '0') {
$group_available_to_access[] = $this_group['id'];
}
// lastedit
if ($has_access || $result['calendar_state'] == '1') {
$option .= "<option value=\"agenda.php?action=view&group=" . $this_group['id'] . "\" ";
$option .= $this_group['id'] == $_SESSION['group'] ? " selected" : "";
$option .= ">" . $this_group['name'] . "</option>";
}
}
$option .= "</optgroup>";
}
echo $option;
// Users
$user_list = get_course_users();
if (!empty($user_list)) {
echo "<optgroup label=\"" . get_lang("Users") . "\">";
foreach ($user_list as $this_user) {
echo "<option value=\"agenda.php?action=view&user=" . $this_user['uid'] . "\" ";
echo isset($_SESSION['user']) && $this_user['uid'] == $_SESSION['user'] ? " selected" : "";
echo ">" . api_get_person_name($this_user['firstName'], $this_user['lastName']) . "</option>";
}
echo "</optgroup>";
}
echo "</select>";
}
示例15: elluminate_reminder_send
/**
* Sends the reminder message for the specified reminder.
*
* @param int $reminderid ID of the reminder to send a message for.
* @return boolean True on success, False otherwise.
*/
function elluminate_reminder_send($reminderid)
{
// Make sure the reminder exists
if (!($reminder = $DB->get_record('event_reminder', array('id' => intval($reminderid))))) {
return false;
}
// Get the event record that this reminder belongs to
if (!($event = $DB->get_record('event', array('id' => $reminder->event)))) {
return false;
}
// Determine the type of event
$type = elluminate_reminder_event_type($event->id);
// General message information.
$userfrom = get_admin();
$site = get_site();
$subject = get_string('remindersubject', 'event_reminder', $site->fullname);
$message = elluminate_reminder_message($event->id, $type);
// Send the reminders to user(s) based on the type of event.
switch ($type) {
case 'user':
// Send a reminder to the user
if (!empty($CFG->messaging)) {
// use message system
} else {
$user = $DB->get_record('user', array('id' => $event->userid));
email_to_user($user, $userfrom, $subject, $message);
}
break;
case 'course':
// Get all the users in the course and send them the reminder
$users = get_course_users($event->courseid);
foreach ($users as $user) {
if (!empty($CFG->messaging)) {
// use message system
} else {
email_to_user($user, $userfrom, $subject, $message);
}
}
break;
case 'group':
// Get all the users in the group and send them the reminder
$users = get_group_users($event->groupid);
foreach ($users as $user) {
if (!empty($CFG->messaging)) {
// use message system
} else {
email_to_user($user, $userfrom, $subject, $message);
}
}
break;
default:
return false;
break;
}
return true;
}