Permanently hiding/removing global events from course calendars

Permanently hiding/removing global events from course calendars

by William Mair -
Number of replies: 6

Hi,

I have setup a weekly quiz on the front page of our Moodle site and this is filtering down into each of the class calendars and upcoming events (which I don't want it to do).

Is there any way that I can permanently turn off the global events inside a course calendar (I know I can hide it with the hide/show, but this can easily be brought back again).

Anyone any suggestions (I don't mind hacking a bit of code if someone points me in the right direction).

Thanks

Average of ratings: -
In reply to William Mair

Re: Permanently hiding/removing global events from course calendars

by William Mair -

If it helps, I'm using v 1.9 Moodle

In reply to William Mair

Re: Permanently hiding/removing global events from course calendars

by William Mair -

OK,

For those who are interested (and for those who may search in future), I got around the problem as follows.

I edited Moodleroot/Calendar/lib.php

At line 637 I changed

$whereclause .= ' (groupid = 0 AND courseid IN ('.implode(',', $courses).'))';

to

$implodeString = implode(',',$courses);
            if (strstr($implodeString,",1")){
                $extractglobal = str_replace(",1","",($implodeString));
            }
            $whereclause .= ' (groupid = 0 AND courseid IN ('.$extractglobal.'))';

That removed the course from the query string which meant that the global courses were not picked up within the courses, but are still picked up in the front course (the string has the global course in as an array entry twice for some reason).

I also had to comment out lines 822-828 starting

if($SESSION->cal_show_global) {

otherwise clicking on Hide Global would hide the Course events in the calendar.

Hope that makes sense. If anyone has a better suggestion, I'd be happy to hear it.

In reply to William Mair

Re: Permanently hiding/removing global events from course calendars

by William Mair -

Scrap the above, doesn't work properly - although it's the right area, so I'll keep working on it.

In reply to William Mair

Re: Permanently hiding/removing global events from course calendars

by William Mair -

Now changed line 637 onwards to

            $implodeString = implode(' ,',$courses);
        
            if (strstr($implodeString,",1 ")){
                $extractglobalMiddle = str_replace(" ,1 " ,"",($implodeString));
            } else {
                $extractglobalMiddle = $implodeString;                
            }
            
            if ($extractglobalMiddle[strlen($extractglobalMiddle) - 1] === "1"){
                $extractglobalMiddle[strlen($extractglobalMiddle) - 1] = " ";
                $extractglobalMiddle[strlen($extractglobalMiddle) - 2] = " ";
                $extractglobalEnd = rtrim($extractglobalMiddle);
            } else {
                $extractglobalEnd = $extractglobalStart;
            }        
            $extractglobal = str_replace(" ,",",",$extractglobalEnd);
            $whereclause .= ' (groupid = 0 AND courseid IN ('.$extractglobal.'))';

In reply to William Mair

Re: Permanently hiding/removing global events from course calendars

by Paula Jimenez -

Great! Thanks! big grin Worked for 2.5

In reply to Paula Jimenez

Re: Permanently hiding/removing global events from course calendars

by Paula Jimenez -

Sorry, be careful ... I don´t know if it was this code or that I did something wrong but it messed up everything. Couldn´t even log in to moodle ... Keep a backup always when touching code ........!!!