Browse Source

obtain context and re-use to make for cleaner code.

MOODLE_29_STABLE
Dan Marsden 10 years ago
parent
commit
e69858f9ef
  1. 14
      renderables.php

14
renderables.php

@ -66,37 +66,37 @@ class attendance_tabs implements renderable {
*/
public function get_tabs() {
$toprow = array();
$context = $this->att->context;
$capabilities = array(
'mod/attendance:manageattendances',
'mod/attendance:takeattendances',
'mod/attendance:changeattendances'
);
if (has_any_capability($capabilities, $this->att->context)) {
if (has_any_capability($capabilities, $context)) {
$toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(),
get_string('sessions', 'attendance'));
}
if (has_capability('mod/attendance:manageattendances', $this->att->context)) {
if (has_capability('mod/attendance:manageattendances', $context)) {
$toprow[] = new tabobject(self::TAB_ADD,
$this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)),
get_string('add', 'attendance'));
}
if (has_capability('mod/attendance:viewreports', $this->att->context)) {
if (has_capability('mod/attendance:viewreports', $context)) {
$toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(),
get_string('report', 'attendance'));
}
if (has_capability('mod/attendance:export', $this->att->context)) {
if (has_capability('mod/attendance:export', $context)) {
$toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(),
get_string('export', 'attendance'));
}
if (has_capability('mod/attendance:changepreferences', $this->att->context)) {
if (has_capability('mod/attendance:changepreferences', $context)) {
$toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(),
get_string('settings', 'attendance'));
}
if (has_capability('mod/attendance:managetemporaryusers', $this->att->context)) {
if (has_capability('mod/attendance:managetemporaryusers', $context)) {
$toprow[] = new tabobject(self::TAB_TEMPORARYUSERS, $this->att->url_managetemp()->out(),
get_string('tempusers', 'attendance'));
}

Loading…
Cancel
Save