~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to blocks/calendar_month/block_calendar_month.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?PHP //$Id: block_calendar_month.php,v 1.11.2.3 2004/09/19 22:18:33 defacer Exp $
 
1
<?PHP //$Id: block_calendar_month.php,v 1.22 2005/03/03 23:11:13 mjollnir_ Exp $
2
2
 
3
 
class CourseBlock_calendar_month extends MoodleBlock {
4
 
    function CourseBlock_calendar_month($course) {
 
3
class block_calendar_month extends block_base {
 
4
    function init() {
5
5
        $this->title = get_string('calendar', 'calendar');
6
 
        $this->content_type = BLOCK_TYPE_TEXT;
7
 
        $this->course = $course;
8
6
        $this->version = 2004081200;
9
7
    }
10
8
 
 
9
    function preferred_width() {
 
10
        return 200;
 
11
    }
 
12
 
11
13
    function get_content() {
12
14
        global $USER, $CFG, $SESSION;
13
15
        optional_variable($_GET['cal_m']);
14
16
        optional_variable($_GET['cal_y']);
15
17
 
16
18
        require_once($CFG->dirroot.'/calendar/lib.php');
17
 
 
 
19
        
18
20
        if ($this->content !== NULL) {
19
21
            return $this->content;
20
22
        }
21
23
 
22
 
        $this->content = New object;
 
24
        $this->content = new stdClass;
23
25
        $this->content->text = '';
24
26
        $this->content->footer = '';
25
27
 
26
 
        if (empty($this->course)) { // Overrides: use no course at all
 
28
        if (empty($this->instance)) { // Overrides: use no course at all
27
29
 
28
30
            $courseshown = false;
29
31
            $filtercourse = array();
30
32
 
31
33
        } else {
32
34
 
33
 
            $courseshown = $this->course->id;
 
35
            $courseshown = $this->instance->pageid;
34
36
 
35
 
            if($this->course->id == SITEID) {
 
37
            if($courseshown == SITEID) {
36
38
                // Being displayed at site level. This will cause the filter to fall back to auto-detecting
37
39
                // the list of courses it will be grabbing events from.
38
40
                $filtercourse = NULL;
48
50
 
49
51
        // Be VERY careful with the format for default courses arguments!
50
52
        // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
51
 
 
52
53
        calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
53
 
 
54
 
        if ($courseshown == 1) {
 
54
        if ($courseshown == SITEID) {
55
55
            // For the front page
56
56
            $this->content->text .= calendar_overlib_html();
57
57
            $this->content->text .= calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
58
58
            $this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
59
59
            // No filters for now
60
60
 
61
 
        } else {
 
61
        } elseif (!empty($courseshown)) {
62
62
            // For any other course
63
63
            $this->content->text .= calendar_overlib_html();
64
64
            $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
65
65
            $this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
66
 
            $this->content->text .= calendar_filter_controls('course', '', $this->course);
 
66
            $course = get_record('course', 'id', $this->instance->pageid);
 
67
            $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $course).'</div>';
 
68
            
67
69
        }
68
70
 
69
71
        return $this->content;