See Release Notes
Long Term Support Release
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 $this->add_classes(['table-striped']); 54 } 55 56 protected function add_header_cells() { 57 echo '<th>' . get_string('allowed', 'core_role') . '</th>'; 58 } 59 60 protected function num_extra_columns() { 61 return 1; 62 } 63 64 protected function get_row_classes($capability) { 65 $this->hascap = has_capability($capability->name, $this->context, $this->user->id); 66 if ($this->hascap) { 67 return array('yes'); 68 } else { 69 return array('no'); 70 } 71 } 72 73 protected function add_row_cells($capability) { 74 if ($this->hascap) { 75 $result = $this->stryes; 76 } else { 77 $result = $this->strno; 78 } 79 $a = new stdClass; 80 $a->fullname = $this->fullname; 81 $a->capability = $capability->name; 82 $a->context = $this->contextname; 83 return '<td>' . $result . '</td>'; 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body