Browse Source

remove abstracted add_to_log function

MOODLE_23_STABLE
Dan Marsden 12 years ago
parent
commit
21afd6e0c4
  1. 42
      locallib.php
  2. 3
      report.php

42
locallib.php

@ -798,8 +798,7 @@ class attendance {
foreach ($sessions as $sess) { foreach ($sessions as $sess) {
$info_array[] = construct_session_full_date_time($sess->sessdate, $sess->duration); $info_array[] = construct_session_full_date_time($sess->sessdate, $sess->duration);
} }
add_to_log($this->course->id, 'attendance', 'sessions added', $this->url_manage(), implode(',', $info_array), $this->cm->id);
$this->log('sessions added', $this->url_manage(), implode(', ', $info_array));
} }
public function update_session_from_form_data($formdata, $sessionid) { 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)); $url = $this->url_sessions(array('sessionid' => $sessionid, 'action' => att_sessions_page_params::ACTION_UPDATE));
$info = construct_session_full_date_time($sess->sessdate, $sess->duration); $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) { public function take_from_form_data($formdata) {
@ -875,7 +874,7 @@ class attendance {
'sessionid' => $this->pageparams->sessionid, 'sessionid' => $this->pageparams->sessionid,
'grouptype' => $this->pageparams->grouptype); 'grouptype' => $this->pageparams->grouptype);
$url = $this->url_take($params); $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')); redirect($this->url_manage(), get_string('attendancesuccess', 'attendance'));
} }
@ -1154,8 +1153,8 @@ class attendance {
list($sql, $params) = $DB->get_in_or_equal($sessionsids); list($sql, $params) = $DB->get_in_or_equal($sessionsids);
$DB->delete_records_select('attendance_log', "sessionid $sql", $params); $DB->delete_records_select('attendance_log', "sessionid $sql", $params);
$DB->delete_records_list('attendance_sessions', 'id', $sessionsids); $DB->delete_records_list('attendance_sessions', 'id', $sessionsids);
add_to_log($this->course->id, 'attendance', 'sessions deleted', $this->url_manage(),
$this->log('sessions deleted', null, get_string('sessionsids', 'attendance').implode(', ', $sessionsids)); get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id);
} }
public function update_sessions_duration($sessionsids, $duration) { public function update_sessions_duration($sessionsids, $duration) {
@ -1168,9 +1167,8 @@ class attendance {
$sess->timemodified = $now; $sess->timemodified = $now;
$DB->update_record('attendance_sessions', $sess); $DB->update_record('attendance_sessions', $sess);
} }
add_to_log($this->course->id, 'attendance', 'sessions duration updated', $this->url_manage(),
$this->log('sessions duration updated', $this->url_manage(), get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id);
get_string('sessionsids', 'attendance').implode(', ', $sessionsids));
} }
public function remove_status($statusid) { public function remove_status($statusid) {
@ -1191,7 +1189,8 @@ class attendance {
$rec->grade = $grade; $rec->grade = $grade;
$DB->insert_record('attendance_statuses', $rec); $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 { } else {
print_error('cantaddstatus', 'attendance', $this->url_preferences()); print_error('cantaddstatus', 'attendance', $this->url_preferences());
} }
@ -1222,27 +1221,8 @@ class attendance {
} }
$DB->update_record('attendance_statuses', $status); $DB->update_record('attendance_statuses', $status);
$this->log('status updated', $this->url_preferences(), implode(' ', $updated)); add_to_log($this->course->id, 'attendance', 'status updated', $this->url_preferences(),
} implode(' ', $updated), $this->cm->id);
/**
* 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);
} }
} }

3
report.php

@ -58,8 +58,7 @@ $tabs = new attendance_tabs($att, attendance_tabs::TAB_REPORT);
$filtercontrols = new attendance_filter_controls($att); $filtercontrols = new attendance_filter_controls($att);
$reportdata = new attendance_report_data($att); $reportdata = new attendance_report_data($att);
global $USER; add_to_log($course->id, 'attendance', 'report viewed', '/mod/attendance/report.php?id='.$id, '', $cm->id);
$att->log('report viewed', null, $USER->firstname.' '.$USER->lastname);
// Output starts here. // Output starts here.

Loading…
Cancel
Save