[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 * This file processes AJAX requests and returns JSON 19 * 20 * This is a server part of yui permissions manager module 21 * 22 * @package core_role 23 * @copyright 2015 Martin Mastny 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 define('AJAX_SCRIPT', true); 27 28 require(__DIR__ . '/../../config.php'); 29 30 $contextid = required_param('contextid', PARAM_INT); 31 $getroles = optional_param('getroles', 0, PARAM_BOOL); 32 33 list($context, $course, $cm) = get_context_info_array($contextid); 34 35 require_login($course, false, $cm); 36 require_capability('moodle/role:review', $context); 37 require_sesskey(); 38 39 $OUTPUT->header(); 40 41 list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context, 42 ROLENAME_BOTH, true); 43 44 if ($getroles) { 45 echo json_encode($overridableroles); 46 die(); 47 } 48 49 $capability = required_param('capability', PARAM_CAPABILITY); 50 $roleid = required_param('roleid', PARAM_INT); 51 $action = required_param('action', PARAM_ALPHA); 52 53 $capability = $DB->get_record('capabilities', array('name' => $capability), '*', MUST_EXIST); 54 55 if (!isset($overridableroles[$roleid])) { 56 throw new moodle_exception('invalidarguments'); 57 } 58 59 if (!has_capability('moodle/role:override', $context)) { 60 if (!has_capability('moodle/role:safeoverride', $context) || !is_safe_capability($capability)) { 61 require_capability('moodle/role:override', $context); 62 } 63 } 64 65 switch ($action) { 66 case 'allow': 67 role_change_permission($roleid, $context, $capability->name, CAP_ALLOW); 68 break; 69 case 'prevent': 70 role_change_permission($roleid, $context, $capability->name, CAP_PREVENT); 71 break; 72 case 'prohibit': 73 role_change_permission($roleid, $context, $capability->name, CAP_PROHIBIT); 74 break; 75 case 'unprohibit': 76 role_change_permission($roleid, $context, $capability->name, CAP_INHERIT); 77 break; 78 default: 79 throw new moodle_exception('invalidarguments'); 80 } 81 82 echo json_encode($action); 83 die();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |