diff --git a/export.php b/export.php index bbda671..ca5d445 100644 --- a/export.php +++ b/export.php @@ -35,11 +35,10 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUS $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); +require_capability('mod/attendance:export', $PAGE->context); $att = new attendance($att, $cm, $course, $PAGE->context); -$att->perm->require_export_capability(); - $PAGE->set_url($att->url_export()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); diff --git a/locallib.php b/locallib.php index 9f2cb38..7a80373 100644 --- a/locallib.php +++ b/locallib.php @@ -74,10 +74,6 @@ class attendance_permissions { return $this->canviewreports; } - public function require_view_reports_capability() { - require_capability('mod/attendance:viewreports', $this->context); - } - public function can_take() { if (is_null($this->cantake)) { $this->cantake = has_capability('mod/attendance:takeattendances', $this->context); @@ -115,10 +111,6 @@ class attendance_permissions { return $this->canmanage; } - - public function require_manage_capability() { - require_capability('mod/attendance:manageattendances', $this->context); - } // Check to see if the user can manage temporary users. public function can_managetemp() { @@ -128,10 +120,6 @@ class attendance_permissions { return $this->canmanagetemp; } - public function require_managetemp_capability() { - require_capability('mod/attendance:managetemporaryusers', $this->context); - } - public function can_change_preferences() { if (is_null($this->canchangepreferences)) { $this->canchangepreferences = has_capability('mod/attendance:changepreferences', $this->context); @@ -140,10 +128,6 @@ class attendance_permissions { return $this->canchangepreferences; } - public function require_change_preferences_capability() { - require_capability('mod/attendance:changepreferences', $this->context); - } - public function can_export() { if (is_null($this->canexport)) { $this->canexport = has_capability('mod/attendance:export', $this->context); @@ -152,10 +136,6 @@ class attendance_permissions { return $this->canexport; } - public function require_export_capability() { - require_capability('mod/attendance:export', $this->context); - } - public function can_be_listed() { if (is_null($this->canbelisted)) { $this->canbelisted = has_capability('mod/attendance:canbelisted', $this->context, null, false); diff --git a/preferences.php b/preferences.php index 75cc95c..1c4c0dd 100644 --- a/preferences.php +++ b/preferences.php @@ -37,6 +37,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUS $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); +require_capability('mod/attendance:changepreferences', $PAGE->context); // Make sure the statusset is valid. $maxstatusset = attendance_get_max_statusset($att->id); @@ -46,8 +47,6 @@ if ($pageparams->statusset > $maxstatusset + 1) { $att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); -$att->perm->require_change_preferences_capability(); - $PAGE->set_url($att->url_preferences()); $PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('settings', 'attendance')); $PAGE->set_heading($course->fullname); diff --git a/report.php b/report.php index 46bd00c..8ecabe2 100644 --- a/report.php +++ b/report.php @@ -41,12 +41,11 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUS $attrecord = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); +require_capability('mod/attendance:viewreports', $PAGE->context); $pageparams->init($cm); $att = new attendance($attrecord, $cm, $course, $PAGE->context, $pageparams); -$att->perm->require_view_reports_capability(); - $PAGE->set_url($att->url_report()); $PAGE->set_pagelayout('report'); $PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('report', 'attendance')); diff --git a/sessions.php b/sessions.php index d1f537d..e4350d0 100644 --- a/sessions.php +++ b/sessions.php @@ -45,11 +45,10 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUS $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); +require_capability('mod/attendance:manageattendances', $PAGE->context); $att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); -$att->perm->require_manage_capability(); - $PAGE->set_url($att->url_sessions(array('action'=>$pageparams->action))); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); diff --git a/tempedit.php b/tempedit.php index 618e6d1..0422e0c 100644 --- a/tempedit.php +++ b/tempedit.php @@ -46,8 +46,7 @@ if ($action) { $PAGE->set_url($att->url_tempedit($params)); require_login($course, true, $cm); - -$att->perm->require_managetemp_capability(); +require_capability('mod/attendance:managetemporaryusers', $PAGE->context); $PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusersedit', 'attendance')); $PAGE->set_heading($course->fullname); diff --git a/tempusers.php b/tempusers.php index a919fcc..e3dbe49 100644 --- a/tempusers.php +++ b/tempusers.php @@ -37,8 +37,7 @@ $att = new attendance($att, $cm, $course); $PAGE->set_url($att->url_managetemp()); require_login($course, true, $cm); - -$att->perm->require_managetemp_capability(); +require_capability('mod/attendance:managetemporaryusers', $PAGE->context); $PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusers', 'attendance')); $PAGE->set_heading($course->fullname); diff --git a/view.php b/view.php index f776d61..c163555 100644 --- a/view.php +++ b/view.php @@ -39,6 +39,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUS $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); +require_capability('mod/attendance:view', $PAGE->context); $pageparams->init($cm); $att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams); @@ -53,8 +54,6 @@ if (!$pageparams->studentid) { } } -require_capability('mod/attendance:view', $PAGE->context); - $PAGE->set_url($att->url_view()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname);