[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/roles/classes/ -> check_capability_table.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Library code used by the roles administration interfaces.
  19   *
  20   * @package    core_role
  21   * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Subclass of core_role_capability_table_base for use on the Check permissions page.
  29   *
  30   * We have one additional column, Allowed, which contains yes/no.
  31   */
  32  class core_role_check_capability_table extends core_role_capability_table_base {
  33      protected $user;
  34      protected $fullname;
  35      protected $contextname;
  36      protected $stryes;
  37      protected $strno;
  38      private $hascap;
  39  
  40      /**
  41       * Constructor
  42       * @param object $context the context this table relates to.
  43       * @param object $user the user we are generating the results for.
  44       * @param string $contextname $context->get_context_name() - to save recomputing.
  45       */
  46      public function __construct($context, $user, $contextname) {
  47          parent::__construct($context, 'explaincaps');
  48          $this->user = $user;
  49          $this->fullname = fullname($user);
  50          $this->contextname = $contextname;
  51          $this->stryes = get_string('yes');
  52          $this->strno = get_string('no');
  53      }
  54  
  55      protected function add_header_cells() {
  56          echo '<th>' . get_string('allowed', 'core_role') . '</th>';
  57      }
  58  
  59      protected function num_extra_columns() {
  60          return 1;
  61      }
  62  
  63      protected function get_row_classes($capability) {
  64          $this->hascap = has_capability($capability->name, $this->context, $this->user->id);
  65          if ($this->hascap) {
  66              return array('yes');
  67          } else {
  68              return array('no');
  69          }
  70      }
  71  
  72      protected function add_row_cells($capability) {
  73          if ($this->hascap) {
  74              $result = $this->stryes;
  75          } else {
  76              $result = $this->strno;
  77          }
  78          $a = new stdClass;
  79          $a->fullname = $this->fullname;
  80          $a->capability = $capability->name;
  81          $a->context = $this->contextname;
  82          return '<td>' . $result . '</td>';
  83      }
  84  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1