MDL-10048, revert some changes in courses regaring coloring of courses

This commit is contained in:
toyomoyo
2007-10-09 04:02:43 +00:00
parent 4b3f69957e
commit e3bb6401e1
4 changed files with 88 additions and 145 deletions
+30 -103
View File
@@ -62,8 +62,6 @@ define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
define ('CALENDAR_TF_24', '%H:%M');
define ('CALENDAR_TF_12', '%I:%M %p');
define ('CALENDAR_MAXCOURSES', 3);
$CALENDARDAYS = array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
@@ -153,9 +151,6 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
// Set event course class for course events
if (!empty($events)) {
foreach ($events as $eventid => $event) {
if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
}
if (!empty($event->modulename)) {
$cm = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($cm)) {
@@ -519,20 +514,7 @@ function calendar_print_event($event) {
echo '</td></tr>';
echo '<tr><td class="side">&nbsp;</td>';
// If event has a class set then add it to the event <td> tag
$eventclass='';
if (!empty($event->class)) {
$eventclass = ' '.$event->class;
}
if (isset($event->cssclass)) {
$eclass = $event->cssclass.$eventclass;
} else {
$eclass = $eventclass;
}
echo '<td class="description '.$eclass.'">';
echo '<td class="description '.$event->cssclass.'">';
echo format_text($event->description, FORMAT_HTML);
if (calendar_edit_event_allowed($event)) {
echo '<div class="commands">';
@@ -793,101 +775,46 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL, $courses
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" title="'.get_string('tt_showglobal', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showglobal'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showglobal'.$getvars.'" title="'.get_string('tt_showglobal', 'calendar').'">'.get_string('global', 'calendar').'</a></td>'."\n";
}
$tr = '';
if($SESSION->cal_show_course) {
$content .= '<td class="event_course" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_hidecourse', 'calendar').'">'.get_string('courseevents', 'calendar').'</a></td>'."\n";
}
else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('hide').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_showcourse', 'calendar').'">'.get_string('courseevents', 'calendar').'</a></td>'."\n";
}
if(!empty($USER->id) && !isguest()) {
$content .= $tr;
$tr = $tr ? '' : "</tr>\n<tr>";
$content .= "</tr>\n<tr>";
if($groupevents) {
// This course MIGHT have group events defined, so show the filter
if($SESSION->cal_show_groups) {
$content .= '<td class="eventskey event_group" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_hidegroups', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showgroups'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showgroups'.$getvars.'" title="'.get_string('tt_hidegroups', 'calendar').'">'.get_string('group', 'calendar').'</a></td>'."\n";
$content .= '<td class="event_group" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showgroups'.$getvars.'" title="'.get_string('tt_hidegroups', 'calendar').'">'.get_string('groupevents', 'calendar').'</a></td>'."\n";
} else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" title="'.get_string('tt_showgroups', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showgroups'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showgroups'.$getvars.'" title="'.get_string('tt_showgroups', 'calendar').'">'.get_string('group', 'calendar').'</a></td>'."\n";
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showgroups'.$getvars.'" title="'.get_string('tt_showgroups', 'calendar').'">'.get_string('groupevents', 'calendar').'</a></td>'."\n";
}
if ($SESSION->cal_show_user) {
$content .= '<td class="event_user" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_hideuser', 'calendar').'">'.get_string('userevents', 'calendar').'</a></td>'."\n";
} else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_showuser', 'calendar').'">'.get_string('userevents', 'calendar').'</a></td>'."\n";
}
} else {
} else {
// This course CANNOT have group events, so lose the filter
$content .= '<td style="width: 11px;"></td><td>&nbsp;</td>'."\n";
}
$content .= $tr;
$tr = $tr ? '' : "</tr>\n<tr>";
if ($SESSION->cal_show_user) {
$content .= '<td class="eventskey event_user" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_hideuser', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showuser'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_hideuser', 'calendar').'">'.get_string('user', 'calendar').'</a></td>'."\n";
} else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" title="'.get_string('tt_showuser', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showuser'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_showuser', 'calendar').'">'.get_string('user', 'calendar').'</a></td>'."\n";
}
}
// Remove global SITE ID from courses array as do not want to display this
if (!empty($courses)) {
$key = array_search(SITEID, $courses);
if ($key !== false) {
unset($courses[$key]);
}
}
if (empty($courses) || count($courses) == 1) {
// If not multiple courses then just display default single course colour highlighting
$content .= $tr;
$tr = $tr ? '' : "</tr>\n<tr>";
if($SESSION->cal_show_course) {
$content .= '<td class="eventskey event_course" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_hidecourse', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showcourses'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_hidecourse', 'calendar').'">'.get_string('course', 'calendar').'</a></td>'."\n";
}
else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_showcourse', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showcourses'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_showcourse', 'calendar').'">'.get_string('course', 'calendar').'</a></td>'."\n";
}
} else {
// Otherwise display list of course shortnames and relevant colours
// Get list of course shortnames (Limit to 12 for now - who would have more than that?)
$select = 'id in ('.implode(',', $courses).')';
$sort = 'id';
$fields = 'id, shortname';
$courseshortnames = get_records_select('course', $select, $sort, $fields, 0, 12);
for ($i = 0; $i < CALENDAR_MAXCOURSES; $i++) {
// Concatenate shortnames if there are more than 3 courses
$strshortnames = '';
$n = 0;
for ($j = $i; $j < count($courses); $j += CALENDAR_MAXCOURSES) {
$strshortnames .= ', <a title="" href="'.$CFG->wwwroot.'/course/view.php?id='.$courses[$j].'">'.(!empty($courseshortnames[$courses[$j]]->shortname) ? $courseshortnames[$courses[$j]]->shortname : $courses[$j]).'</a>';
$n++;
}
if ($n) {
$content .= $tr;
$tr = $tr ? '' : "</tr>\n<tr>";
if ($n < 2) {
$strcourse = get_string('course', 'calendar');
} else {
$strcourse = get_string('courses', 'calendar');
}
if($SESSION->cal_show_course) {
$content .= '<td class="eventskey event_course'.$i.'" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_hidecourse', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showcourses'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_hidecourse', 'calendar').'">'.$strcourse.'</a>: '.substr($strshortnames, 2).'</td>'."\n";
}
else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('hide').'" title="'.get_string('tt_showcourse', 'calendar').'" style="cursor:pointer" onclick="location.href='."'".CALENDAR_URL.'set.php?var=showcourses'.$getvars."'".'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_showcourse', 'calendar').'">'.$strcourse.'</a>: '.substr($strshortnames, 2).'</td>'."\n";
}
if($SESSION->cal_show_user) {
$content .= '<td class="event_user" style="width: 11px;"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.get_string('hide').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_hideuser', 'calendar').'">'.get_string('userevents', 'calendar').'</a></td>'."\n";
} else {
$content .= '<td style="width: 11px;"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.get_string('show').'" /></td>';
$content .= '<td><a href="'.CALENDAR_URL.'set.php?var=showuser'.$getvars.'" title="'.get_string('tt_showuser', 'calendar').'">'.get_string('userevents', 'calendar').'</a></td>'."\n";
}
}
}
@@ -1103,7 +1030,7 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$typesbyday[$eventdaystart]['startcourse'] = true;
// Set event class for course event
$events[$event->id]->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
//$events[$event->id]->class = 'event_course';
}
else if($event->groupid) {
$typesbyday[$eventdaystart]['startgroup'] = true;
+58 -10
View File
@@ -268,10 +268,6 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users, $courseid) {
// First, print details about events that start today
foreach ($events as $event) {
// Set event course class if a course event
if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
}
$event->calendarcourseid = $courseid;
if ($event->timestart >= $starttime && $event->timestart <= $endtime) { // Print it now
@@ -451,6 +447,15 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
// Special visual fx if an event is defined
if(isset($eventsbyday[$day])) {
if(isset($typesbyday[$day]['startglobal'])) {
$class .= ' event_global';
} else if(isset($typesbyday[$day]['startcourse'])) {
$class .= ' event_course';
} else if(isset($typesbyday[$day]['startgroup'])) {
$class .= ' event_group';
} else if(isset($typesbyday[$day]['startuser'])) {
$class .= ' event_user';
}
if(count($eventsbyday[$day]) == 1) {
$title = get_string('oneevent', 'calendar');
}
@@ -522,6 +527,55 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
echo "</table>\n"; // Tabular display of days ends
// OK, now for the filtering display
echo '<div class="filters"><table><tr>';
// Global events
if($SESSION->cal_show_global) {
echo '<td class="event_global" style="width: 8px;"></td><td><strong>'.get_string('globalevents', 'calendar').':</strong> ';
echo get_string('shown', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showglobal&amp;'.$getvars.'">'.get_string('clickhide', 'calendar').'</a>)</td>'."\n";
}
else {
echo '<td style="width: 8px;"></td><td><strong>'.get_string('globalevents', 'calendar').':</strong> ';
echo get_string('hidden', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showglobal&amp;'.$getvars.'">'.get_string('clickshow', 'calendar').'</a>)</td>'."\n";
}
// Course events
if(!empty($SESSION->cal_show_course)) {
echo '<td class="event_course" style="width: 8px;"></td><td><strong>'.get_string('courseevents', 'calendar').':</strong> ';
echo get_string('shown', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showcourses&amp;'.$getvars.'">'.get_string('clickhide', 'calendar').'</a>)</td>'."\n";
}
else {
echo '<td style="width: 8px;"></td><td><strong>'.get_string('courseevents', 'calendar').':</strong> ';
echo get_string('hidden', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showcourses&amp;'.$getvars.'">'.get_string('clickshow', 'calendar').'</a>)</td>'."\n";
}
echo "</tr>\n";
if(!empty($USER->id) && !isguest()) {
echo '<tr>';
// Group events
if($SESSION->cal_show_groups) {
echo '<td class="event_group" style="width: 8px;"></td><td><strong>'.get_string('groupevents', 'calendar').':</strong> ';
echo get_string('shown', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showgroups&amp;'.$getvars.'">'.get_string('clickhide', 'calendar').'</a>)</td>'."\n";
}
else {
echo '<td style="width: 8px;"></td><td><strong>'.get_string('groupevents', 'calendar').':</strong> ';
echo get_string('hidden', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showgroups&amp;'.$getvars.'">'.get_string('clickshow', 'calendar').'</a>)</td>'."\n";
}
// User events
if($SESSION->cal_show_user) {
echo '<td class="event_user" style="width: 8px;"></td><td><strong>'.get_string('userevents', 'calendar').':</strong> ';
echo get_string('shown', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showuser&amp;'.$getvars.'">'.get_string('clickhide', 'calendar').'</a>)</td>'."\n";
}
else {
echo '<td style="width: 8px;"></td><td><strong>'.get_string('userevents', 'calendar').':</strong> ';
echo get_string('hidden', 'calendar').' (<a href="'.CALENDAR_URL.'set.php?var=showuser&amp;'.$getvars.'">'.get_string('clickshow', 'calendar').'</a>)</td>'."\n";
}
echo "</tr>\n";
}
echo '</table></div>';
}
function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents, $courseid) {
@@ -553,12 +607,6 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
echo '<div class="eventlist">';
foreach ($events as $event) {
// Set event course class if a course event
if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
}
calendar_print_event($event);
}
echo '</div>';
-20
View File
@@ -479,26 +479,6 @@ table.minicalendar {
background-color:#FFD3BD;
}
#calendar .event_course0,
.minicalendar .event_course0,
.block_calendar_month .event_course0 {
border-color:#FFD3BD !important; /* #EEC2AC */
background-color:#FFD3BD;
}
#calendar .event_course1,
.minicalendar .event_course1,
.block_calendar_month .event_course1 {
border-color:#99CCFF !important; /* #EEC2AC */
background-color:#99CCFF;
}
#calendar .event_course2,
.minicalendar .event_course2,
.block_calendar_month .event_course2 {
border-color:#FFFFCC !important; /* #EEC2AC */
background-color:#FFFFCC;
}
#calendar .event_group,
.minicalendar .event_group,
-12
View File
@@ -1621,16 +1621,10 @@ table.minicalendar th {
#calendar .event_global,
#calendar .event_course,
#calendar .event_course0,
#calendar .event_course1,
#calendar .event_course2,
#calendar .event_group,
#calendar .event_user,
.minicalendar .event_global,
.minicalendar .event_course,
.minicalendar .event_course0,
.minicalendar .event_course1,
.minicalendar .event_course2,
.minicalendar .event_group,
.minicalendar .event_user {
border:2px solid !important;
@@ -1638,16 +1632,10 @@ table.minicalendar th {
#calendar .duration_global,
#calendar .duration_course,
#calendar .duration_course0,
#calendar .duration_course1,
#calendar .duration_course2,
#calendar .duration_group,
#calendar .duration_user,
.minicalendar .duration_global,
.minicalendar .duration_course,
.minicalendar .duration_course0,
.minicalendar .duration_course1,
.minicalendar .duration_course2,
.minicalendar .duration_group,
.minicalendar .duration_user
{