MDL-8323 finished full conversion to proper $COURSE global - no more $CFG->coursethem...
[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
9152fc99 11$id = optional_param('id', SITEID, PARAM_INT);
12if (!$course = get_record('course', 'id', $id)) {
13 error('Incorrect course id');
14}
15
16course_setup($course); // we should not require login here
5452c725 17
9152fc99 18if ($id != SITEID and !empty($CFG->allowcoursethemes) and !empty($course->theme) and !empty($THEME->chameleonteachereditenabled)) {
19 if (!has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $id))) {
5452c725 20 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
21 }
ae9e4c06 22} else if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
5452c725 23 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
24}
25
26
27require_once('ChameleonCSS.class.php');
28require_once('ChameleonFileBrowser.class.php');
29
30
31
32if (isset($_GET['path'])) {
33 $fm = new ChameleonFileBrowser;
34 die($fm->readfiles());
35}
36
37$chameleon = new ChameleonCSS('../', 'user_styles.css', 'temp_user_styles.css');
296ed48e 38
5452c725 39if (isset($_POST['css'])) {
40 if (!isset($_GET['temp'])) {
296ed48e 41 if (!$chameleon->update('perm', $_POST['css'])) {
42 die('CHAMELEON_ERROR ' . $chameleon->error);
43 }
44 if (!$chameleon->update('temp')) {
45 die('CHAMELEON_ERROR ' . $chameleon->error);
46 }
5452c725 47 } else {
296ed48e 48 if (!$chameleon->update('temp', $_POST['css'])) {
49 die('CHAMELEON_ERROR ' . $chameleon->error);
50 }
5452c725 51 }
52
53} else {
54
55 $css = $chameleon->read();
56 if ($css === false) {
57 echo 'CHAMELEON_ERROR ' . $chameleon->error;
58 } else {
59 echo $css;
60 }
61}
62
63
b1cdbbf9 64?>