source: moodle/trunk/fuentes/admin/tool/installaddon/permcheck.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 2.0 KB
Line 
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Checks the write permission for the given plugin type
20 *
21 * @package     tool_installaddon
22 * @subpackage  ajax
23 * @copyright   2013 David Mudrak <david@moodle.com>
24 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27define('AJAX_SCRIPT', true);
28
29require(dirname(__FILE__) . '/../../../config.php');
30require_once($CFG->libdir.'/adminlib.php');
31
32require_login();
33
34if (!has_capability('moodle/site:config', context_system::instance())) {
35    header('HTTP/1.1 403 Forbidden');
36    die();
37}
38
39if (!empty($CFG->disableonclickaddoninstall)) {
40    header('HTTP/1.1 403 Forbidden');
41    die();
42}
43
44if (!confirm_sesskey()) {
45    header('HTTP/1.1 403 Forbidden');
46    die();
47}
48
49$plugintype = optional_param('plugintype', null, PARAM_ALPHANUMEXT);
50if (is_null($plugintype)) {
51    header('HTTP/1.1 400 Bad Request');
52    die();
53}
54
55$installer = tool_installaddon_installer::instance();
56
57$plugintypepath = $installer->get_plugintype_root($plugintype);
58
59if (empty($plugintypepath)) {
60    header('HTTP/1.1 400 Bad Request');
61    die();
62}
63
64$response = array('path' => $plugintypepath);
65
66if ($installer->is_plugintype_writable($plugintype)) {
67    $response['writable'] = 1;
68} else {
69    $response['writable'] = 0;
70}
71
72header('Content-Type: application/json; charset: utf-8');
73echo json_encode($response);
Note: See TracBrowser for help on using the repository browser.