示例#1
0
 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 = '';
     $this->content->footer = '';
     // [pj] To me it looks like this if would never be needed, but Penny added it
     // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
     // It definitely needs SOME comment here!
     $courseshown = $COURSE->id;
     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);
     // MDL-9059, set to show this course when admins go into a course, then unset it.
     if ($COURSE->id != SITEID && !isset($SESSION->cal_courses_shown[$COURSE->id]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
         $courseset = true;
         $SESSION->cal_courses_shown[$COURSE->id] = $COURSE;
     }
     // 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);
     if ($courseshown == SITEID) {
         // For the front page
         $this->content->text .= calendar_overlib_html();
         $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         // No filters for now
     } else {
         // For any other course
         $this->content->text .= calendar_overlib_html();
         $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         $this->content->text .= '<h3 class="eventskey">' . get_string('eventskey', 'calendar') . '</h3>';
         $this->content->text .= '<div class="filters">' . calendar_filter_controls('course', '', $COURSE) . '</div>';
     }
     // MDL-9059, unset this so that it doesn't stay in session
     if (!empty($courseset)) {
         unset($SESSION->cal_courses_shown[$COURSE->id]);
     }
     return $this->content;
 }
示例#2
0
 /**
  * Return the content of this block.
  *
  * @return stdClass the content
  */
 public function get_content()
 {
     global $CFG;
     $calm = optional_param('cal_m', 0, PARAM_INT);
     $caly = optional_param('cal_y', 0, PARAM_INT);
     $time = optional_param('time', 0, PARAM_INT);
     require_once $CFG->dirroot . '/calendar/lib.php';
     if ($this->content !== null) {
         return $this->content;
     }
     // If a day, month and year were passed then convert it to a timestamp. If these were passed then we can assume
     // the day, month and year are passed as Gregorian, as no where in core should we be passing these values rather
     // than the time. This is done for BC.
     if (!empty($calm) && !empty($caly)) {
         $time = make_timestamp($caly, $calm, 1);
     } else {
         if (empty($time)) {
             $time = time();
         }
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     // [pj] To me it looks like this if would never be needed, but Penny added it
     // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
     // It definitely needs SOME comment here!
     $courseid = $this->page->course->id;
     $issite = $courseid == SITEID;
     if ($issite) {
         // 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($courseid => $this->page->course);
     }
     list($courses, $group, $user) = calendar_set_filters($filtercourse);
     if ($issite) {
         // For the front page.
         $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
         // No filters for now.
     } else {
         // For any other course.
         $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
         $this->content->text .= '<h3 class="eventskey">' . get_string('eventskey', 'calendar') . '</h3>';
         $this->content->text .= '<div class="filters calendar_filters">' . calendar_filter_controls($this->page->url) . '</div>';
     }
     return $this->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 = '';
     $this->content->footer = '';
     // [pj] To me it looks like this if would never be needed, but Penny added it
     // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
     // It definitely needs SOME comment here!
     $courseid = $this->page->course->id;
     $issite = $courseid == SITEID;
     if ($issite) {
         // 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($courseid => $this->page->course);
     }
     list($courses, $group, $user) = calendar_set_filters($filtercourse);
     if ($issite) {
         // For the front page
         $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         // No filters for now
     } else {
         // For any other course
         $this->content->text .= calendar_top_controls('course', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
         $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
         $this->content->text .= '<h3 class="eventskey">' . get_string('eventskey', 'calendar') . '</h3>';
         $this->content->text .= '<div class="filters">' . calendar_filter_controls($this->page->url) . '</div>';
     }
     return $this->content;
 }
示例#4
0
 /**
  * Produces the content for the three months block (pretend block)
  *
  * This includes the previous month, the current month, and the next month
  *
  * @param calendar_information $calendar
  * @return string
  */
 public function fake_block_threemonths(calendar_information $calendar)
 {
     // Get the calendar type we are using.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     $date = $calendartype->timestamp_to_date_array($calendar->time);
     $prevmonth = calendar_sub_month($date['mon'], $date['year']);
     $prevmonthtime = $calendartype->convert_to_gregorian($prevmonth[1], $prevmonth[0], 1);
     $prevmonthtime = make_timestamp($prevmonthtime['year'], $prevmonthtime['month'], $prevmonthtime['day'], $prevmonthtime['hour'], $prevmonthtime['minute']);
     $nextmonth = calendar_add_month($date['mon'], $date['year']);
     $nextmonthtime = $calendartype->convert_to_gregorian($nextmonth[1], $nextmonth[0], 1);
     $nextmonthtime = make_timestamp($nextmonthtime['year'], $nextmonthtime['month'], $nextmonthtime['day'], $nextmonthtime['hour'], $nextmonthtime['minute']);
     $content = html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $prevmonthtime);
     $content .= html_writer::end_tag('div');
     $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $calendar->time);
     $content .= html_writer::end_tag('div');
     $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $nextmonthtime);
     $content .= html_writer::end_tag('div');
     return $content;
 }
示例#5
0
echo '<div class="header"><h2>' . get_string('eventskey', 'calendar') . '</h2></div>';
echo '<div class="filters">';
echo calendar_filter_controls('event', 'action=' . $action . '&amp;type=' . $eventtype . '&amp;id=' . $eventid);
echo '</div>';
echo '</div>';
echo '<div class="sideblock">';
echo '<div class="header"><h2>' . get_string('monthlyview', 'calendar') . '</h2></div>';
echo '<div class="minicalendarblock minicalendartop">';
echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $prevmon, 'y' => $prevyr));
echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
echo '</div><div class="minicalendarblock">';
echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $mon, 'y' => $yr));
echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
echo '</div><div class="minicalendarblock">';
echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $nextmon, 'y' => $nextyr));
echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
echo '</div>';
echo '</div>';
echo '</td>';
echo '</tr></table>';
print_footer();
function validate_form(&$form, &$err)
{
    $form->name = trim($form->name);
    $form->description = trim($form->description);
    if (empty($form->name)) {
        $err['name'] = get_string('errornoeventname', 'calendar');
    }
    /* Allow events without a description
        if(empty($form->description)) {
            $err['description'] = get_string('errornodescription', 'calendar');
示例#6
0
 /**
  * Produces the content for the three months block (pretend block)
  *
  * This includes the previous month, the current month, and the next month
  *
  * @param calendar_information $calendar
  * @return string
  */
 public function fake_block_threemonths(calendar_information $calendar)
 {
     list($prevmon, $prevyr) = calendar_sub_month($calendar->month, $calendar->year);
     list($nextmon, $nextyr) = calendar_add_month($calendar->month, $calendar->year);
     $content = html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $prevmon, 'y' => $prevyr));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $prevmon, $prevyr);
     $content .= html_writer::end_tag('div');
     $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $calendar->month, 'y' => $calendar->year));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $calendar->month, $calendar->year);
     $content .= html_writer::end_tag('div');
     $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock'));
     $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $nextmon, 'y' => $nextyr));
     $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $nextmon, $nextyr);
     $content .= html_writer::end_tag('div');
     return $content;
 }
}
if (current_language() == 'he_utf8') {
    // nadavkav
    setlocale(LC_TIME, 'he_IL.utf8');
}
if (current_language() == 'en_utf8') {
    setlocale(LC_TIME, 'en_US');
}
// 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);
if ($courseshown == SITEID) {
    // For the front page
    $calendar .= calendar_overlib_html();
    $calendar .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
    $calendar .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
    // No filters for now
} else {
    // For any other course
    //echo '<div id="topcalendar"><div id="calendarview">'.calendar_overlib_html();
    //echo calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
    // Layout the whole page as three big columns.
    echo '<table id="calendartable" style="height:100%;">';
    echo '<tr>';
    // START: Main column
    echo '<td class="maincalendar">';
    //$calendar .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y).'</div>';
    echo calendar_show_month_detailed($cal_m, $cal_y, $courses, $group, $user, $courseshown);
    //$calendar .= '<div id="calendarfilters"><h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
    //$calendar .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div></div></div>';
    //$calendar .= "<div id='newevent'><a href='$CFG->wwwroot/calendar/event.php?action=new&course=2&cal_m=".date('n')."&cal_y=".date('Y')."'>".get_string('newevent','calendar')."</a></div>";