MDL-8337 has_capability() ignores default roles for $userid and does not detect chang...
[moodle.git] / theme / chameleon / ui / css.php
CommitLineData
5452c725 1<?php
2
3require_once('../../../config.php');
4require_once('../config.php');
5
6
7if (empty($THEME->chameleonenabled)) {
8 die('CHAMELEON_ERROR Editing this theme has been disabled');
9}
10
11
12$chameleon_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
13if ($chameleon_id != 0 && !empty($CFG->allowcoursethemes) && !empty($THEME->chameleonteachereditenabled)) {
9ce384ba 14 if (!has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $chameleon_id))) {
5452c725 15 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
16 }
ae9e4c06 17} else if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
5452c725 18 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
19}
20
21
22require_once('ChameleonCSS.class.php');
23require_once('ChameleonFileBrowser.class.php');
24
25
26
27if (isset($_GET['path'])) {
28 $fm = new ChameleonFileBrowser;
29 die($fm->readfiles());
30}
31
32$chameleon = new ChameleonCSS('../', 'user_styles.css', 'temp_user_styles.css');
296ed48e 33
5452c725 34if (isset($_POST['css'])) {
35 if (!isset($_GET['temp'])) {
296ed48e 36 if (!$chameleon->update('perm', $_POST['css'])) {
37 die('CHAMELEON_ERROR ' . $chameleon->error);
38 }
39 if (!$chameleon->update('temp')) {
40 die('CHAMELEON_ERROR ' . $chameleon->error);
41 }
5452c725 42 } else {
296ed48e 43 if (!$chameleon->update('temp', $_POST['css'])) {
44 die('CHAMELEON_ERROR ' . $chameleon->error);
45 }
5452c725 46 }
47
48} else {
49
50 $css = $chameleon->read();
51 if ($css === false) {
52 echo 'CHAMELEON_ERROR ' . $chameleon->error;
53 } else {
54 echo $css;
55 }
56}
57
58
b1cdbbf9 59?>