本文整理汇总了PHP中calendar_get_upcoming函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_get_upcoming函数的具体用法?PHP calendar_get_upcoming怎么用?PHP calendar_get_upcoming使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_get_upcoming函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $USER, $CFG, $SESSION, $COURSE;
$cal_m = optional_param('cal_m', 0, PARAM_INT);
$cal_y = optional_param('cal_y', 0, PARAM_INT);
require_once $CFG->dirroot . '/calendar/lib.php';
if ($this->content !== NULL) {
return $this->content;
}
// Reset the session variables
calendar_session_vars($COURSE);
$this->content = new stdClass();
$this->content->text = '';
if (empty($this->instance)) {
// Overrides: use no course at all
$courseshown = false;
$filtercourse = array();
$this->content->footer = '';
} else {
$courseshown = $COURSE->id;
$this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...';
$context = get_context_instance(CONTEXT_COURSE, $courseshown);
if (has_capability('moodle/calendar:manageentries', $context) || has_capability('moodle/calendar:manageownentries', $context)) {
$this->content->footer .= '<br /><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...';
}
if ($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = NULL;
$groupeventsfrom = NULL;
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
calendar_set_referring_course(0);
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => $COURSE);
$groupeventsfrom = array($courseshown => 1);
}
}
// We 'll need this later
calendar_set_referring_course($courseshown);
// Be VERY careful with the format for default courses arguments!
// Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false);
$events = calendar_get_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
if (!empty($this->instance)) {
$this->content->text = calendar_get_sideblock_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&');
}
if (empty($this->content->text)) {
$this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>';
}
return $this->content;
}
示例2: get_content
function get_content()
{
global $USER, $CFG, $SESSION;
$cal_m = optional_param('cal_m', 0, PARAM_INT);
$cal_y = optional_param('cal_y', 0, PARAM_INT);
require_once $CFG->dirroot . '/calendar/lib.php';
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$filtercourse = array();
if (empty($this->instance)) {
// Overrides: use no course at all
$courseshown = false;
$this->content->footer = '';
} else {
$courseshown = $this->page->course->id;
$this->content->footer = '<div class="gotocal"><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...</div>';
$context = context_course::instance($courseshown);
if (has_any_capability(array('moodle/calendar:manageentries', 'moodle/calendar:manageownentries'), $context)) {
$this->content->footer .= '<div class="newevent"><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...</div>';
}
if ($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = calendar_get_default_courses();
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => $this->page->course);
}
}
list($courses, $group, $user) = calendar_set_filters($filtercourse);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
$defaultlookahead = intval($CFG->calendar_lookahead);
}
$lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
$defaultmaxevents = intval($CFG->calendar_maxevents);
}
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents);
if (!empty($this->instance)) {
$this->content->text = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&');
}
if (empty($this->content->text)) {
$this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>';
}
return $this->content;
}
示例3: ical_parse
/**
* This functions parses all the events, and creates one iCal
* (.ics) file per course, storing them in the folder specified in the
* module's configuration.
* ToDo: site's events.
*/
function ical_parse()
{
global $CFG;
// Retrieves all the courses
$courses = get_records_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'course');
// First, we must check if the path to store the iCal files exists...
if (empty($CFG->ical_path)) {
set_config('ical_path', 'webdav');
}
$webdav_dir = $CFG->dirroot . '/' . $CFG->ical_path;
if (is_dir($webdav_dir)) {
// Now, for each course...
foreach ($courses as $course) {
$count = get_record_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'event WHERE courseid=' . $course->id);
if (!empty($count) && $course->id != 0 && ($fp = @fopen($webdav_dir . '/' . $course->shortname . '.ics', "w"))) {
// Write the header
$write = fwrite($fp, "BEGIN:VCALENDAR\nVERSION\n :2.0\nPRODID\n :-//Moodle.org//NONSGML iCal Module v0.1 beta//EN");
// expect creating/modifying the course file
$events = calendar_get_upcoming(array(0 => $course->id), $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
// For all the events in the current course
foreach ($events as $event) {
// If the event is visible
if ($event->visible) {
$write = fwrite($fp, "\nBEGIN:VEVENT\nUID\n :" . $event->id . "-" . $event->timestart . "\nSUMMARY\n :" . $event->name . "\nCATEGORIES\n :" . $course->fullname . "\nSTATUS\n :CONFIRMED\nCLASS\n :PUBLIC\nDESCRIPTION:" . $event->description);
// We check if it has a stablished duration
if ($event->timeduration != 0) {
// It does: we print the event time information, with the duration
$write = fwrite($fp, "\nDTSTART\n :" . gmdate("Ymd\\THis\\Z", $event->timestart) . "\nDTEND\n :" . gmdate("Ymd\\THis\\Z", $event->timestart + $event->timeduration));
} else {
// However, if it doesn't, we assume that the event lasts 24hrs
$write = fwrite($fp, "\nDTSTART\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart) . "\nDTEND\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart + 86400));
}
// And now for the timestamp and we finish this event
$write = fwrite($fp, "\nDTSTAMP\n :" . gmdate("Ymd\\THis\\Z", $event->timemodified) . "\nEND:VEVENT");
}
}
// This calendar file (course file) has ended :)
$write = fwrite($fp, "\nEND:VCALENDAR");
fclose($fp);
}
}
} else {
echo 'The directory ' . $webdav_dir . ' is not valid.';
}
}
示例4: show_upcoming_events
/**
* Displays upcoming events
*
* @param calendar_information $calendar
* @param int $futuredays
* @param int $maxevents
* @return string
*/
public function show_upcoming_events(calendar_information $calendar, $futuredays, $maxevents, moodle_url $returnurl = null)
{
if ($returnurl === null) {
$returnurl = $this->page->url;
}
$events = calendar_get_upcoming($calendar->courses, $calendar->groups, $calendar->users, $futuredays, $maxevents);
$output = html_writer::start_tag('div', array('class' => 'header'));
$output .= $this->course_filter_selector($returnurl, get_string('upcomingeventsfor', 'calendar'));
if (calendar_user_can_add_event($calendar->course)) {
$output .= $this->add_event_button($calendar->course->id);
}
$output .= html_writer::end_tag('div');
if ($events) {
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
foreach ($events as $event) {
// Convert to calendar_event object so that we transform description
// accordingly
$event = new calendar_event($event);
$event->calendarcourseid = $calendar->courseid;
$output .= $this->event($event);
}
$output .= html_writer::end_tag('div');
} else {
$output .= $this->output->heading(get_string('noupcomingevents', 'calendar'));
}
return $output;
}
示例5: calendar_show_upcoming_events
function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents, $courseid)
{
global $USER;
$events = calendar_get_upcoming($courses, $groups, $users, $futuredays, $maxevents);
$text = '';
if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
$text .= '<div class="buttons">';
$text .= '<form action="' . CALENDAR_URL . 'event.php" method="get">';
$text .= '<div>';
$text .= '<input type="hidden" name="action" value="new" />';
$text .= '<input type="hidden" name="course" value="' . $courseid . '" />';
/*
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
$text.= '<input type="hidden" name="cal_y" value="'.$y.'" />';
*/
$text .= '<input type="submit" value="' . get_string('newevent', 'calendar') . '" />';
$text .= '</div></form></div>';
}
$text .= get_string('upcomingevents', 'calendar') . ': ' . calendar_course_filter_selector('from=upcoming');
echo '<div class="header">' . $text . '</div>';
if ($events) {
echo '<div class="eventlist">';
foreach ($events as $event) {
$event->calendarcourseid = $courseid;
calendar_print_event($event);
}
echo '</div>';
} else {
print_heading(get_string('noupcomingevents', 'calendar'));
}
}
示例6: get_upcoming_events
/**
* Returns upcoming events for a course
*
* @param int $id Course identifier
*/
function get_upcoming_events($id, $username = '')
{
global $CFG, $DB;
$id = addslashes($id);
$courseshown = $id;
$coursestoload = array($courseshown => $id);
$groupeventsfrom = array($courseshown => 1);
$filtercourse = $DB->get_records_list('course', 'id', $coursestoload);
$true = true;
if ($CFG->version >= 2011070100) {
list($courses, $group, $user) = calendar_set_filters($filtercourse, $true);
$courses = array($id => $id);
if ($username != '') {
// Show only events for groups where user is a member
$groups = groups_get_all_groups($id);
$gs = array();
foreach ($groups as $group) {
$found = false;
// Check is user is a member of the group
$members = $this->get_group_members($group->id);
foreach ($members as $member) {
if ($member['username'] == $username) {
$found = true;
break;
}
}
if ($found) {
$gs[$group->id] = $group->id;
}
}
}
$events = calendar_get_upcoming($courses, $gs, false, CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD, CALENDAR_DEFAULT_UPCOMING_MAXEVENTS);
} else {
calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, true);
$events = calendar_get_upcoming($courses, $group, $user, CALENDAR_UPCOMING_DAYS, CALENDAR_UPCOMING_MAXEVENTS);
}
$data = array();
foreach ($events as $r) {
$e = array();
$e['name'] = $r->name;
$e['timestart'] = $r->timestart;
$e['courseid'] = $r->courseid;
$data[$i] = $e;
$i++;
}
return $data;
}
示例7: show_upcoming_events
/**
* Displays upcoming events
*
* @param calendar_information $calendar
* @param int $futuredays
* @param int $maxevents
* @return string
*/
public function show_upcoming_events(calendar_information $calendar, $futuredays, $maxevents)
{
$events = calendar_get_upcoming($calendar->courses, $calendar->groups, $calendar->users, $futuredays, $maxevents);
$output = html_writer::start_tag('div', array('class' => 'header'));
if (!isguestuser() && isloggedin() && calendar_user_can_add_event()) {
$output .= $this->add_event_button($calendar->courseid);
}
$output .= html_writer::tag('label', get_string('upcomingevents', 'calendar'), array('for' => 'cal_course_flt_jump'));
$output .= $this->course_filter_selector(array('from' => 'upcoming'));
$output .= html_writer::end_tag('div');
if ($events) {
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
foreach ($events as $event) {
// Convert to calendar_event object so that we transform description
// accordingly
$event = new calendar_event($event);
$event->calendarcourseid = $calendar->courseid;
$output .= $this->event($event);
}
$output .= html_writer::end_tag('div');
} else {
$output .= $this->output->heading(get_string('noupcomingevents', 'calendar'));
}
return $output;
}
示例8: get_upcoming_events
/**
* Returns upcoming events for a course
*
* @param int $id Course identifier
*/
function get_upcoming_events($id)
{
global $CFG;
$id = addslashes($id);
$courseshown = $id;
$filtercourse = array($courseshown => $id);
$groupeventsfrom = array($courseshown => 1);
$true = true;
if ($CFG->version >= 2011070100) {
list($courses, $group, $user) = calendar_set_filters($filtercourse, $true);
$courses = array($id => $id);
$events = calendar_get_upcoming($courses, true, true, CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD, CALENDAR_DEFAULT_UPCOMING_MAXEVENTS);
} else {
calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, true);
$events = calendar_get_upcoming($courses, $group, $user, CALENDAR_UPCOMING_DAYS, CALENDAR_UPCOMING_MAXEVENTS);
}
$data = array();
foreach ($events as $r) {
$e['name'] = $r->name;
$e['timestart'] = $r->timestart;
$e['courseid'] = $r->courseid;
$data[] = $e;
}
return $data;
}
示例9: optional_param
global $USER, $CFG, $SESSION;
$cal_m = optional_param('cal_m', 0, PARAM_INT);
$cal_y = optional_param('cal_y', 0, PARAM_INT);
require_once $CFG->dirroot . '/calendar/lib.php';
$filtercourse = array();
if (empty($this->instance)) {
// Overrides: use no course at all
$courseshown = false;
} else {
$courseshown = $this->page->course->id;
}
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = calendar_get_default_courses();
list($courses, $group, $user) = calendar_set_filters($filtercourse);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
$defaultlookahead = intval($CFG->calendar_lookahead);
}
$lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
$defaultmaxevents = intval($CFG->calendar_maxevents);
}
$maxevents = 3;
$events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents);
$upcomingoutput = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&');
echo $upcomingoutput;
?>