a05c565ebbef99b585284a76978855be9a760ee4
[moodle.git] / theme / chameleon / ui / css.php
1 <?php
3 require_once('../../../config.php');
4 require_once('../config.php');
7 if (empty($THEME->chameleonenabled)) {
8     die('CHAMELEON_ERROR Editing this theme has been disabled');
9 }
12 $chameleon_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
13 if ($chameleon_id != 0 && !empty($CFG->allowcoursethemes) && !empty($THEME->chameleonteachereditenabled)) {
14     if (!isteacheredit($chameleon_id)) {
15         die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
16     }
17 } else if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
18     die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
19 }
22 require_once('ChameleonCSS.class.php');
23 require_once('ChameleonFileBrowser.class.php');
27 if (isset($_GET['path'])) {
28     $fm = new ChameleonFileBrowser;
29     die($fm->readfiles());
30 }
32 $chameleon = new ChameleonCSS('../', 'user_styles.css', 'temp_user_styles.css');
34 if (isset($_POST['css'])) {
35     if (!isset($_GET['temp'])) {
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         }
42     } else {
43         if (!$chameleon->update('temp', $_POST['css'])) {
44             die('CHAMELEON_ERROR ' . $chameleon->error);
45         }
46     }
47     
48 } else {
50     $css = $chameleon->read();
51     if ($css === false) {
52         echo 'CHAMELEON_ERROR ' . $chameleon->error;
53     } else {
54         echo $css;
55     }
56 }
59 ?>