obtain context and re-use to make for cleaner code.
authorDan Marsden <dan@danmarsden.com>
Thu, 13 Aug 2015 11:00:49 +0000 (23:00 +1200)
committerDan Marsden <dan@danmarsden.com>
Thu, 13 Aug 2015 11:00:49 +0000 (23:00 +1200)
renderables.php

index 053ca18..575803e 100644 (file)
@@ -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'));
         }