Browse Source

Don't hide capability checks.

MOODLE_29_STABLE
Dan Marsden 10 years ago
parent
commit
91c0b611e0
  1. 3
      export.php
  2. 20
      locallib.php
  3. 3
      preferences.php
  4. 3
      report.php
  5. 3
      sessions.php
  6. 3
      tempedit.php
  7. 3
      tempusers.php
  8. 3
      view.php

3
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); $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:export', $PAGE->context);
$att = new attendance($att, $cm, $course, $PAGE->context); $att = new attendance($att, $cm, $course, $PAGE->context);
$att->perm->require_export_capability();
$PAGE->set_url($att->url_export()); $PAGE->set_url($att->url_export());
$PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_title($course->shortname. ": ".$att->name);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

20
locallib.php

@ -74,10 +74,6 @@ class attendance_permissions {
return $this->canviewreports; return $this->canviewreports;
} }
public function require_view_reports_capability() {
require_capability('mod/attendance:viewreports', $this->context);
}
public function can_take() { public function can_take() {
if (is_null($this->cantake)) { if (is_null($this->cantake)) {
$this->cantake = has_capability('mod/attendance:takeattendances', $this->context); $this->cantake = has_capability('mod/attendance:takeattendances', $this->context);
@ -116,10 +112,6 @@ class attendance_permissions {
return $this->canmanage; 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. // Check to see if the user can manage temporary users.
public function can_managetemp() { public function can_managetemp() {
if (is_null($this->canmanagetemp)) { if (is_null($this->canmanagetemp)) {
@ -128,10 +120,6 @@ class attendance_permissions {
return $this->canmanagetemp; return $this->canmanagetemp;
} }
public function require_managetemp_capability() {
require_capability('mod/attendance:managetemporaryusers', $this->context);
}
public function can_change_preferences() { public function can_change_preferences() {
if (is_null($this->canchangepreferences)) { if (is_null($this->canchangepreferences)) {
$this->canchangepreferences = has_capability('mod/attendance:changepreferences', $this->context); $this->canchangepreferences = has_capability('mod/attendance:changepreferences', $this->context);
@ -140,10 +128,6 @@ class attendance_permissions {
return $this->canchangepreferences; return $this->canchangepreferences;
} }
public function require_change_preferences_capability() {
require_capability('mod/attendance:changepreferences', $this->context);
}
public function can_export() { public function can_export() {
if (is_null($this->canexport)) { if (is_null($this->canexport)) {
$this->canexport = has_capability('mod/attendance:export', $this->context); $this->canexport = has_capability('mod/attendance:export', $this->context);
@ -152,10 +136,6 @@ class attendance_permissions {
return $this->canexport; return $this->canexport;
} }
public function require_export_capability() {
require_capability('mod/attendance:export', $this->context);
}
public function can_be_listed() { public function can_be_listed() {
if (is_null($this->canbelisted)) { if (is_null($this->canbelisted)) {
$this->canbelisted = has_capability('mod/attendance:canbelisted', $this->context, null, false); $this->canbelisted = has_capability('mod/attendance:canbelisted', $this->context, null, false);

3
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); $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:changepreferences', $PAGE->context);
// Make sure the statusset is valid. // Make sure the statusset is valid.
$maxstatusset = attendance_get_max_statusset($att->id); $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 = new attendance($att, $cm, $course, $PAGE->context, $pageparams);
$att->perm->require_change_preferences_capability();
$PAGE->set_url($att->url_preferences()); $PAGE->set_url($att->url_preferences());
$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('settings', 'attendance')); $PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('settings', 'attendance'));
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

3
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); $attrecord = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:viewreports', $PAGE->context);
$pageparams->init($cm); $pageparams->init($cm);
$att = new attendance($attrecord, $cm, $course, $PAGE->context, $pageparams); $att = new attendance($attrecord, $cm, $course, $PAGE->context, $pageparams);
$att->perm->require_view_reports_capability();
$PAGE->set_url($att->url_report()); $PAGE->set_url($att->url_report());
$PAGE->set_pagelayout('report'); $PAGE->set_pagelayout('report');
$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('report', 'attendance')); $PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('report', 'attendance'));

3
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); $att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:manageattendances', $PAGE->context);
$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); $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_url($att->url_sessions(array('action'=>$pageparams->action)));
$PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_title($course->shortname. ": ".$att->name);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

3
tempedit.php

@ -46,8 +46,7 @@ if ($action) {
$PAGE->set_url($att->url_tempedit($params)); $PAGE->set_url($att->url_tempedit($params));
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:managetemporaryusers', $PAGE->context);
$att->perm->require_managetemp_capability();
$PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusersedit', 'attendance')); $PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusersedit', 'attendance'));
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

3
tempusers.php

@ -37,8 +37,7 @@ $att = new attendance($att, $cm, $course);
$PAGE->set_url($att->url_managetemp()); $PAGE->set_url($att->url_managetemp());
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:managetemporaryusers', $PAGE->context);
$att->perm->require_managetemp_capability();
$PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusers', 'attendance')); $PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusers', 'attendance'));
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

3
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); $attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm); require_login($course, true, $cm);
require_capability('mod/attendance:view', $PAGE->context);
$pageparams->init($cm); $pageparams->init($cm);
$att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams); $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_url($att->url_view());
$PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_title($course->shortname. ": ".$att->name);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);

Loading…
Cancel
Save