function __construct($course_id) { global $CFG, $DB; $global_config = get_config('block_notifications'); $Course = new Course(); if (!$Course->is_registered($course_id) or !$Course->uses_notifications_block($course_id)) { echo get_string('rss_not_enabled', 'block_notifications'); return; } $User = new User(); $teacher = $User->get_professor($course_id); // if no teacher then add a dummy mail address if (empty($teacher)) { $teacher = new \stdClass(); $teacher->firstname = "No"; $teacher->lastname = "Teacher"; $teacher->email = "*****@*****.**"; } $course_info = $Course->get_course_info($course_id); $course_registration = $Course->get_registration($course_id); if ($course_registration->notify_by_rss != 1) { return; // the rss is not active in the course } $now = date('r'); $course_name = $this->standardize($course_info->fullname); $course_summary = $this->standardize($course_info->summary); $output = "<?xml version=\"1.0\"?>\n\t\t\t\t\t<rss version=\"2.0\">\n\t\t\t\t\t<channel>\n\t\t\t\t\t<title>{$course_name}</title>\n\t\t\t\t\t<link>{$CFG->wwwroot}/course/view.php?id={$course_id}</link>\n\t\t\t\t\t<description>{$course_summary}</description>\n\t\t\t\t\t<language>en-us</language>\n\t\t\t\t\t<pubDate>{$now}</pubDate>\n\t\t\t\t\t<lastBuildDate>{$now}</lastBuildDate>\n\t\t\t\t\t<docs>{$CFG->wwwroot}/course/view.php?id={$course_id}</docs>\n\t\t\t\t\t<managingEditor>{$teacher->email} ({$teacher->firstname} {$teacher->lastname})</managingEditor>\n\t\t\t\t\t<webMaster>helpdesk@elearninglab.org (Helpdesk eLab)</webMaster>"; $logs = $Course->get_logs($course_id, $global_config->history_length); $events = report_eventlist_list_generator::get_all_events_list(); if (!isset($logs) or !is_array($logs) or count($logs) == 0) { $output .= "<item>"; $output .= '<title>' . get_string('rss_empty_title', 'block_notifications') . '</title>'; $output .= '<description>' . get_string('rss_empty_description', 'block_notifications') . '</description>'; $output .= "</item>"; } else { $separator = ' - '; foreach ($logs as $log) { $output .= "<item>"; $output .= '<title>' . get_string($log->module, 'block_notifications') . ': ' . $this->standardize($log->name) . '</title>'; if (preg_match('/deleted/', $log->event)) { $output .= "<link></link>"; } else { $output .= "<link>" . $this->extract_url($log) . "</link>"; } $output .= "<description>"; $output .= $this->standardize(preg_replace('/\\\\.*$/', '', $events[$log->event]['raweventname']) . ' on ' . date("r", $log->time_created)); $output .= "</description>"; $output .= "</item>"; } } $output .= "</channel></rss>"; header("Content-Type: application/rss+xml"); echo $output; }