Skip to content

Commit

Permalink
Fixed all hard-coded SITEID references. Thanks to Eloy for pointing i…
Browse files Browse the repository at this point in the history
…t out!

(In the end there were more than we thought; I just searched for all "1"s)
  • Loading branch information
defacer committed Sep 16, 2004
1 parent 0e71599 commit 9064751
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
}

// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing courseid 1 from $courses, there is only one course left, then clicking on a day in the month
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
// arguments to this function.

Expand Down Expand Up @@ -190,10 +190,10 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$popupicon = $CFG->modpixpath.'/'.$event->modulename.'/icon.gif';
$popupalt = $event->modulename;

} else if ($event->courseid == 1) { // Site event
} else if ($event->courseid == SITEID) { // Site event
$popupicon = $CFG->pixpath.'/c/site.gif';
$popupalt = '';
} else if ($event->courseid > 1 and empty($event->groupid)) { // Course event
} else if ($event->courseid != SITEID && empty($event->groupid)) { // Course event
$popupicon = $CFG->pixpath.'/c/course.gif';
$popupalt = '';
} else if ($event->groupid) { // Group event
Expand Down Expand Up @@ -302,7 +302,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
}

// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing courseid 1 from $courses, there is only one course left, then clicking on a day in the month
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
// arguments to this function.

Expand Down Expand Up @@ -355,28 +355,24 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
$output[$outkey]->cmid = $module->id;



} else if($event->courseid == 1) { // Site event
} else if($event->courseid == SITEID) { // Site event
$output[$outkey]->icon = '<img height="16" width="16" src="'.$CFG->pixpath.'/c/site.gif" alt="" style="vertical-align: middle;" />';
$output[$outkey]->time = $eventtime;



} else if($event->courseid > 1 and !$event->groupid) { // Course event
} else if($event->courseid != SITEID && !$event->groupid) { // Course event
calendar_get_course_cached($coursecache, $event->courseid);

$output[$outkey]->icon = '<img height="16" width="16" src="'.$CFG->pixpath.'/c/course.gif" alt="" style="vertical-align: middle;" />';
$output[$outkey]->time = $eventtime;
$output[$outkey]->courselink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$event->courseid.'">'.$coursecache[$event->courseid]->fullname.'</a>';



} else if ($event->groupid) { // Group event
$output[$outkey]->icon = '<img height="16" width="16" src="'.$CFG->pixpath.'/c/group.gif" alt="" style="vertical-align: middle;" />';
$output[$outkey]->time = $eventtime;



} else if($event->userid) { // User event
$output[$outkey]->icon = '<img height="16" width="16" src="'.$CFG->pixpath.'/c/user.gif" alt="" style="vertical-align: middle;" />';
$output[$outkey]->time = $eventtime;
Expand Down Expand Up @@ -802,10 +798,10 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
$eventsbyday[$eventdaystart][] = $event->id;

// Mark the day as having such an event
if($event->courseid == 1 && $event->groupid == 0) {
if($event->courseid == SITEID && $event->groupid == 0) {
$typesbyday[$eventdaystart]['startglobal'] = true;
}
else if($event->courseid > 1 && $event->groupid == 0) {
else if($event->courseid != SITEID && $event->groupid == 0) {
$typesbyday[$eventdaystart]['startcourse'] = true;
}
else if($event->groupid) {
Expand All @@ -830,10 +826,10 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
// Mark all days between $lowerbound and $upperbound (inclusive) as duration
for($i = $lowerbound + 1; $i <= $upperbound; ++$i) {
$durationbyday[$i][] = $event->id;
if($event->courseid == 1 && $event->groupid == 0) {
if($event->courseid == SITEID && $event->groupid == 0) {
$typesbyday[$i]['durationglobal'] = true;
}
else if($event->courseid > 1 && $event->groupid == 0) {
else if($event->courseid != SITEID && $event->groupid == 0) {
$typesbyday[$i]['durationcourse'] = true;
}
else if($event->groupid) {
Expand Down Expand Up @@ -932,11 +928,11 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU

if(($SESSION->cal_show_course && $SESSION->cal_show_global) || $ignorefilters) {
if(is_int($courseeventsfrom)) {
$courses = array(1, $courseeventsfrom);
$courses = array(SITEID, $courseeventsfrom);
}
else if(is_array($courseeventsfrom)) {
$courses = array_keys($courseeventsfrom);
$courses[] = 1;
$courses[] = SITEID;
}
}
else if($SESSION->cal_show_course) {
Expand Down Expand Up @@ -1007,7 +1003,7 @@ function calendar_edit_event_allowed($event) {

if (isadmin($USER->id)) return true; // Admins are allowed anything

if ($event->courseid > 1) {
if ($event->courseid != SITEID) {
// Course event, only editing teachers may... edit :P
if(isteacheredit($event->courseid)) {
return true;
Expand All @@ -1033,7 +1029,7 @@ function calendar_get_default_courses($ignoreref = false) {
global $USER, $CFG, $SESSION;

if(!empty($SESSION->cal_course_referer) && !$ignoreref) {
return array($SESSION->cal_course_referer => 1);
return array($SESSION->cal_course_referer => SITEID);
}

if(empty($USER)) {
Expand Down

0 comments on commit 9064751

Please sign in to comment.