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');
11 $id = optional_param('id', SITEID
, PARAM_INT
);
12 if (!$course = get_record('course', 'id', $id)) {
13 error('Incorrect course id');
16 course_setup($course); // we should not require login here
18 if ($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))) {
20 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
22 } else if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM
, SITEID
))) {
23 die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
27 require_once('ChameleonCSS.class.php');
28 require_once('ChameleonFileBrowser.class.php');
32 if (isset($_GET['path'])) {
33 $fm = new ChameleonFileBrowser
;
34 die($fm->readfiles());
37 $chameleon = new ChameleonCSS('../', 'user_styles.css', 'temp_user_styles.css');
39 if (isset($_POST['css'])) {
40 if (!isset($_GET['temp'])) {
41 if (!$chameleon->update('perm', $_POST['css'])) {
42 die('CHAMELEON_ERROR ' . $chameleon->error
);
44 if (!$chameleon->update('temp')) {
45 die('CHAMELEON_ERROR ' . $chameleon->error
);
48 if (!$chameleon->update('temp', $_POST['css'])) {
49 die('CHAMELEON_ERROR ' . $chameleon->error
);
55 $css = $chameleon->read();
57 echo 'CHAMELEON_ERROR ' . $chameleon->error
;