diff --git a/calendar/lib.php b/calendar/lib.php index dc56f91fd63..72f5c60e6bc 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1895,7 +1895,7 @@ class calendar_event { * an event */ public function __construct($data=null) { - global $CFG, $USER; + global $CFG, $USER, $DB; // First convert to object if it is not already (should either be object or assoc array) if (!is_object($data)) { @@ -1910,6 +1910,10 @@ class calendar_event { $data->id = null; } + if (!empty($data->subscriptionid)) { + $data->subscription = $DB->get_record('event_subscriptions', array('id' => $data->subscriptionid)); + } + // Default to a user event if (empty($data->eventtype)) { $data->eventtype = 'user'; diff --git a/calendar/renderer.php b/calendar/renderer.php index b7cbd7978c8..522f1946357 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -307,6 +307,11 @@ class core_calendar_renderer extends plugin_renderer_base { if (!empty($event->courselink)) { $table->data[0]->cells[1]->text .= html_writer::tag('div', $event->courselink, array('class'=>'course')); } + if (!empty($event->subscription)) { + $table->data[0]->cells[1]->text .= html_writer::tag('div', + html_writer::link($event->subscription->url, get_string('subsource', 'calendar', + $event->subscription)), array('class' => 'subscription')); + } if (!empty($event->time)) { $table->data[0]->cells[1]->text .= html_writer::tag('span', $event->time, array('class'=>'date')); } else { diff --git a/lang/en/calendar.php b/lang/en/calendar.php index 54ee712bd48..fc84849a1cf 100644 --- a/lang/en/calendar.php +++ b/lang/en/calendar.php @@ -167,6 +167,7 @@ $string['subscriptions'] = 'Subscriptions'; $string['subscriptionname'] = 'Calendar name'; $string['subscriptionremoved'] = 'Calendar subscription {$a} removed'; $string['subscriptionupdated'] = 'Calendar subscription {$a} updated'; +$string['subsource'] = 'Event source: {$a->name}'; $string['sun'] = 'Sun'; $string['sunday'] = 'Sunday'; $string['thu'] = 'Thu'; diff --git a/theme/base/style/calendar.css b/theme/base/style/calendar.css index f6ac3820ff9..c59d76648f9 100644 --- a/theme/base/style/calendar.css +++ b/theme/base/style/calendar.css @@ -32,6 +32,8 @@ .dir-rtl.path-calendar .maincalendar .eventlist .event .topic .name {float:right;} .path-calendar .maincalendar .eventlist .event .topic .date {float:right;} .dir-rtl.path-calendar .maincalendar .eventlist .event .topic .date {float:left;} +.path-calendar .maincalendar .eventlist .event .subscription {float:left;clear:left;} +.dir-rtl.path-calendar .maincalendar .eventlist .event .subscription {float:right;clear:right;} .path-calendar .maincalendar .eventlist .event .course {float:left;clear:left;} .dir-rtl.path-calendar .maincalendar .eventlist .event .course {float:right;clear:right;} .path-calendar .maincalendar .eventlist .event .side {width:32px;}