From 9078c2842f6f5c7c849847c995c80d646d5a71e9 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 15 Jul 2013 14:42:13 +1200 Subject: [PATCH] remove abstracted add_to_log function --- locallib.php | 42 +++++++++++------------------------------- report.php | 3 +-- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/locallib.php b/locallib.php index d7a1766..403bebc 100644 --- a/locallib.php +++ b/locallib.php @@ -798,8 +798,7 @@ class attendance { foreach ($sessions as $sess) { $info_array[] = construct_session_full_date_time($sess->sessdate, $sess->duration); } - - $this->log('sessions added', $this->url_manage(), implode(', ', $info_array)); + add_to_log($this->course->id, 'attendance', 'sessions added', $this->url_manage(), implode(',', $info_array), $this->cm->id); } public function update_session_from_form_data($formdata, $sessionid) { @@ -821,7 +820,7 @@ class attendance { $url = $this->url_sessions(array('sessionid' => $sessionid, 'action' => att_sessions_page_params::ACTION_UPDATE)); $info = construct_session_full_date_time($sess->sessdate, $sess->duration); - $this->log('session updated', $url, $info); + add_to_log($this->course->id, 'attendance', 'session updated', $url, $info, $this->cm->id); } public function take_from_form_data($formdata) { @@ -875,7 +874,7 @@ class attendance { 'sessionid' => $this->pageparams->sessionid, 'grouptype' => $this->pageparams->grouptype); $url = $this->url_take($params); - $this->log('attendance taked', $url, $USER->firstname.' '.$USER->lastname); + add_to_log($this->course->id, 'attendance', 'taken', $url, '', $this->cm->id); redirect($this->url_manage(), get_string('attendancesuccess', 'attendance')); } @@ -1154,8 +1153,8 @@ class attendance { list($sql, $params) = $DB->get_in_or_equal($sessionsids); $DB->delete_records_select('attendance_log', "sessionid $sql", $params); $DB->delete_records_list('attendance_sessions', 'id', $sessionsids); - - $this->log('sessions deleted', null, get_string('sessionsids', 'attendance').implode(', ', $sessionsids)); + add_to_log($this->course->id, 'attendance', 'sessions deleted', $this->url_manage(), + get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id); } public function update_sessions_duration($sessionsids, $duration) { @@ -1168,9 +1167,8 @@ class attendance { $sess->timemodified = $now; $DB->update_record('attendance_sessions', $sess); } - - $this->log('sessions duration updated', $this->url_manage(), - get_string('sessionsids', 'attendance').implode(', ', $sessionsids)); + add_to_log($this->course->id, 'attendance', 'sessions duration updated', $this->url_manage(), + get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id); } public function remove_status($statusid) { @@ -1191,7 +1189,8 @@ class attendance { $rec->grade = $grade; $DB->insert_record('attendance_statuses', $rec); - $this->log('status added', $this->url_preferences(), $acronym.': '.$description.' ('.$grade.')'); + add_to_log($this->course->id, 'attendance', 'status added', $this->url_preferences(), + $acronym.': '.$description.' ('.$grade.')', $this->cm->id); } else { print_error('cantaddstatus', 'attendance', $this->url_preferences()); } @@ -1222,27 +1221,8 @@ class attendance { } $DB->update_record('attendance_statuses', $status); - $this->log('status updated', $this->url_preferences(), implode(' ', $updated)); - } - - /** - * wrapper around {@see add_to_log()} - * - * @param string $action to be logged - * @param moodle_url $url absolute url, if null will be used $this->url_manage() - * @param mixed $info additional info, usually id in a table - */ - public function log($action, moodle_url $url = null, $info = null) { - if (is_null($url)) { - $url = $this->url_manage(); - } - - if (is_null($info)) { - $info = $this->id; - } - - $logurl = att_log_convert_url($url); - add_to_log($this->course->id, 'attendance', $action, $logurl, $info, $this->cm->id); + add_to_log($this->course->id, 'attendance', 'status updated', $this->url_preferences(), + implode(' ', $updated), $this->cm->id); } } diff --git a/report.php b/report.php index d46d38a..032c4fd 100644 --- a/report.php +++ b/report.php @@ -58,8 +58,7 @@ $tabs = new attendance_tabs($att, attendance_tabs::TAB_REPORT); $filtercontrols = new attendance_filter_controls($att); $reportdata = new attendance_report_data($att); -global $USER; -$att->log('report viewed', null, $USER->firstname.' '.$USER->lastname); +add_to_log($course->id, 'attendance', 'report viewed', '/mod/attendance/report.php?id='.$id, '', $cm->id); // Output starts here.