]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8323 finished full conversion to proper $COURSE global - no more $CFG->coursethem...
authorskodak <skodak>
Sun, 28 Jan 2007 21:18:08 +0000 (21:18 +0000)
committerskodak <skodak>
Sun, 28 Jan 2007 21:18:08 +0000 (21:18 +0000)
MDL-7962 chat seems to be completely broken in head (fixed wrong JS)
* reworked chat themes support
MDL-8338 Cron does not need cookies
MDL-8339 forum cron capabilities problems
* minor deprecated function current_encoding() cleanup

16 files changed:
admin/cron.php
lib/deprecatedlib.php
lib/moodlelib.php
lib/weblib.php
mod/chat/chatd.php
mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/jsupdate.php
mod/chat/gui_header_js/jsupdated.php
mod/chat/gui_header_js/users.php
mod/chat/gui_sockets/chatinput.php
mod/chat/lib.php
mod/forum/lib.php
mod/wiki/ewiki/ewiki.php
theme/chameleon/ui/chameleon.php
theme/chameleon/ui/css.php
user/editlib.php

index 7ad03d3290dfae8ebc7db223fe58e72994766aab..47dfd097a2080bb902a1573e089b23b1474109ec 100644 (file)
 /// from the command line.
 
     define('FULLME', 'cron');
-    
+
+
+/// Do not set moodle cookie because we do not need it here, it is better to emulate session
+    $nomoodlecookie = true;
+
 /// The current directory in PHP version 4.3.0 and above isn't necessarily the
 /// directory of the script when run from the command line. The require_once()
 /// would fail, so we'll have to chdir()
     require_once(dirname(__FILE__) . '/../config.php');
     require_once($CFG->libdir.'/adminlib.php');
 
+/// extra safety
+    @session_write_close();
+
+/// check if execution allowed
     if (isset($_SERVER['REMOTE_ADDR'])) { // if the script is accessed via the web.
         if (!empty($CFG->cronclionly)) { 
             // This script can only be run via the cli.
         }
     }
 
-    if (!$alreadyadmin = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
-        unset($_SESSION['USER']);
-        unset($USER);
-        unset($_SESSION['SESSION']);
-        unset($SESSION);
-        $USER = get_admin();      /// Temporarily, to provide environment for this script
-        // we need to override the admin timezone to the moodle timezone!
-        $USER->timezone = $CFG->timezone;
-    }
 
-    //unset test cookie, user must login again anyway
-    setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, '/');
+/// emulate normal session
+    $SESSION = new object();
+    $USER = get_admin();      /// Temporarily, to provide environment for this script
 
-/// switch to site language and locale
-    if (!empty($CFG->courselang)) {
-        unset ($CFG->courselang);
-    }
-    if (!empty($SESSION->lang)) {
-        unset ($SESSION->lang);
-    }
+/// ignore admins timezone, language and locale - use site deafult instead!
+    $USER->timezone = $CFG->timezone;
     $USER->lang = '';
-    moodle_setlocale();
+    $USER->theme = '';
+    course_setup(SITEID);
 
 /// send mime type and encoding
     if (check_browser_version('MSIE')) {
@@ -79,6 +75,9 @@
         @header('Content-Type: text/plain; charset=utf-8');
     }
 
+/// no more headers and buffers
+    while(@ob_end_flush());
+
 /// Start output log
 
     $timenow  = time();
index fa932916e1bdced8cd42da2c4c115e4d33685d21..771ed73559c03344034e90f052205d814e9f7920 100644 (file)
@@ -912,6 +912,16 @@ function detect_munged_arguments($string, $allowdots=1) {
     return false;
 }
 
+/** Deprecated function - returns the code of the current charset - originally depended on the selected language pack.
+ *
+ * @param $ignorecache not used anymore
+ * @return string always returns 'UTF-8'
+ */
+function current_charset($ignorecache = false) {
+    return 'UTF-8';
+}
+
+
 /////////////////////////////////////////////////////////////
 /// Old functions not used anymore - candidates for removal
 /////////////////////////////////////////////////////////////
index 7a84222ca22db0e0525967519b1ff3d78c77a578..fe2af18b63be5d9fdd5626d5a56bb90cc23e66e4 100644 (file)
@@ -1548,11 +1548,13 @@ function confirm_sesskey($sesskey=NULL) {
 }
 
 /**
- * Setup all global $CFG course variables, set locale and also 
+ * Setup all global $CFG course variables, set locale and also themes
+ * This function can be used on pages that do not require login instead of require_login()
+ *
  * @param mixed $courseorid id of the course or course object
  */
 function course_setup($courseorid=0) {
-    global $COURSE, $HTTPSPAGEREQUIRED, $CFG;
+    global $COURSE, $CFG, $SITE, $USER;
 
 /// Redefine global $COURSE if needed
     if (empty($courseorid)) {
@@ -1562,7 +1564,9 @@ function course_setup($courseorid=0) {
         $COURSE = clone($courseorid);
     } else {
         global $course; // used here only to prevent repeated fetching from DB - may be removed later
-        if ($course->id == $courseorid) {
+        if (!empty($course->id) and $course->id == SITEID) {
+            $COURSE = clone($SITE);
+        } else if (!empty($course->id) and $course->id == $courseorid) {
             $COURSE = clone($course);
         } else {
             if (!$COURSE = get_record('course', 'id', $courseorid)) {
@@ -1571,33 +1575,10 @@ function course_setup($courseorid=0) {
         }
     }
 
-/// set locale - we should use $COURSE->lang directly in the future
-/// $CFG->courselang is now used in cron and chat to override current language and locale
-    if ($COURSE->id == SITEID or empty($COURSE->lang)) {
-        unset($CFG->courselang);
-    } else {
-        $CFG->courselang = $COURSE->lang;
-    }
+/// set locale and themes
     moodle_setlocale();
-
-/// setup themes - $COURSE->theme should be used instead of $CFG->coursetheme soon 
-    if ($COURSE->id == SITEID or empty($CFG->allowcoursethemes) or empty($COURSE->theme)) {
-        unset($CFG->coursetheme);
-    } else {
-        $CFG->coursetheme = $COURSE->theme;
-    }
     theme_setup();
 
-/// We have to change some URLs in styles if we are in a $HTTPSPAGEREQUIRED page
-/// in case theme changed after call to httpsrequired();
-    if (!empty($HTTPSPAGEREQUIRED)) {
-        $CFG->themewww = str_replace('http:', 'https:', $CFG->themewww);
-        $CFG->pixpath = str_replace('http:', 'https:', $CFG->pixpath);
-        $CFG->modpixpath = str_replace('http:', 'https:', $CFG->modpixpath);
-        foreach ($CFG->stylesheets as $key => $stylesheet) {
-            $CFG->stylesheets[$key] = str_replace('http:', 'https:', $stylesheet);
-        }
-    }
 }
 
 /**
@@ -4024,15 +4005,15 @@ function clean_filename($string) {
  * @return string
  */
 function current_language() {
-    global $CFG, $USER, $SESSION;
+    global $CFG, $USER, $SESSION, $COURSE;
 
-    if (!empty($CFG->courselang)) {    // Course language can override all other settings for this page
-        $return = $CFG->courselang;
+    if (!empty($OURSE->lang)) {    // Course language can override all other settings for this page
+        $return = $OURSE->lang;
 
     } else if (!empty($SESSION->lang)) {    // Session language can override other settings
         $return = $SESSION->lang;
 
-    } else if (!empty($USER->lang)) {    // User language can override site language
+    } else if (!empty($USER->lang)) { 
         $return = $USER->lang;
 
     } else {
@@ -4046,15 +4027,6 @@ function current_language() {
     return $return;
 }
 
-/* Obsoleted function - returns the code of the current charset - originally depended on the selected language pack.
- *
- * @param $ignorecache not used anymore
- * @return string always returns 'UTF-8'
- */
-function current_charset($ignorecache = false) {
-    return 'UTF-8';
-}
-
 /**
  * Prints out a translated string.
  *
@@ -5874,13 +5846,9 @@ function httpsrequired() {
         $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
         $CFG->httpsthemewww = str_replace('http:', 'https:', $CFG->themewww);
 
-        // change theme paths to pictures
-        $CFG->themewww = str_replace('http:', 'https:', $CFG->themewww);
-        $CFG->pixpath = str_replace('http:', 'https:', $CFG->pixpath);
-        $CFG->modpixpath = str_replace('http:', 'https:', $CFG->modpixpath);
-        foreach ($CFG->stylesheets as $key => $stylesheet) {
-            $CFG->stylesheets[$key] = str_replace('http:', 'https:', $stylesheet);
-        }
+        // change theme URLs to https
+        theme_setup();
+
     } else {
         $CFG->httpswwwroot = $CFG->wwwroot;
         $CFG->httpsthemewww = $CFG->themewww;
@@ -6543,11 +6511,13 @@ function check_dir_exists($dir, $create=false, $recursive=false) {
 function report_session_error() {
     global $CFG, $FULLME;
 
-    theme_setup();  // Sets up theme global variables
     if (empty($CFG->lang)) {
         $CFG->lang = "en";
     }
+    // Set up default theme and locale
+    theme_setup();
     moodle_setlocale();
+
     //clear session cookies
     setcookie('MoodleSession'.$CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath);
     setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath);
index 59de6d1cc40e031fd3e7539787f6c42742888112..abdd7934d8039914e29dd50c1c15d4879942a61a 100644 (file)
@@ -2338,18 +2338,18 @@ function print_footer($course=NULL, $usercourse=NULL, $return=false) {
  * @return string
  */
 function current_theme() {
-    global $CFG, $USER, $SESSION;
+    global $CFG, $USER, $SESSION, $COURSE;
 
     if (!empty($CFG->pagetheme)) {  // Page theme is for special page-only themes set by code
         return $CFG->pagetheme;
 
-    } else if (!empty($CFG->coursetheme) and !empty($CFG->allowcoursethemes)) {  // Course themes override others
-        return $CFG->coursetheme;
+    } else if (!empty($CFG->allowcoursethemes) and !empty($COURSE->theme)) {  // Course themes override others
+        return $COURSE->theme;
 
     } else if (!empty($SESSION->theme)) {    // Session theme can override other settings
         return $SESSION->theme;
 
-    } else if (!empty($USER->theme) and !empty($CFG->allowuserthemes)) {    // User theme can override site theme
+    } else if (!empty($CFG->allowuserthemes) and !empty($USER->theme)) {    // User theme can override site theme
         return $USER->theme;
 
     } else {
@@ -2516,7 +2516,7 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $force
 function theme_setup($theme = '', $params=NULL) {
 /// Sets up global variables related to themes
 
-    global $CFG, $THEME, $SESSION, $USER;
+    global $CFG, $THEME, $SESSION, $USER, $HTTPSPAGEREQUIRED;
 
     if (empty($theme)) {
         $theme = current_theme();
@@ -2574,6 +2574,16 @@ function theme_setup($theme = '', $params=NULL) {
     }
     $CFG->stylesheets[] = $CFG->themewww.'/'.$theme.'/styles.php'.$paramstring;
 
+/// We have to change some URLs in styles if we are in a $HTTPSPAGEREQUIRED page
+    if (!empty($HTTPSPAGEREQUIRED)) {
+        $CFG->themewww = str_replace('http:', 'https:', $CFG->themewww);
+        $CFG->pixpath = str_replace('http:', 'https:', $CFG->pixpath);
+        $CFG->modpixpath = str_replace('http:', 'https:', $CFG->modpixpath);
+        foreach ($CFG->stylesheets as $key => $stylesheet) {
+            $CFG->stylesheets[$key] = str_replace('http:', 'https:', $stylesheet);
+        }
+    }
+
 }
 
 
index a6dd9d883d7846c9eedcfc873baa67eb190fdbde..86c462a8ef2e9bcef910a820b5932c9dd258685d 100755 (executable)
@@ -228,7 +228,7 @@ class ChatDaemon {
         static $str;
 
         $info = &$this->sets_info[$sessionid];
-        chat_force_language($info['lang']);
+        course_setup($info['course'], $info['user']);
 
         $timenow = time();
 
@@ -501,6 +501,7 @@ class ChatDaemon {
         $this->sets_info[$sessionid] = array(
             'lastinfocommit' => 0,
             'lastmessageindex' => 0,
+            'course'    => $course,
             'courseid'  => $course->id,
             'chatuser'  => $chatuser,
             'chatid'    => $chat->id,
@@ -706,7 +707,7 @@ class ChatDaemon {
             {
 
                 // Simply give them the message
-                chat_force_language($info['lang']);
+                course_setup($info['course'], $info['user']);
                 $output = chat_format_message_manually($message, $info['courseid'], $sender, $info['user']);
                 $this->trace('Delivering message "'.$output->text.'" to '.$this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL]);
 
index 4fbf97affb5a6d63e3a246c7e9eccbc27b84a046..c389234b418cb9c77f8abbd7a560c2e300777767 100644 (file)
         error('Not logged in!');
     }
 
-    //Get the course theme
-    $COURSE = get_record('course','id',$chatuser->course);
-
     //Get the user theme
-    $USER = get_record('user','id',$chatuser->userid);
-
-    //Adjust the prefered theme (main, course, user)
-    theme_setup();
+    $USER = get_record('user', 'id', $chatuser->userid);
 
-    chat_force_language($chatuser->lang);
+    //Setup course, lang and theme
+    course_setup($chatuser->course);
 
     ob_start();
     ?>
         if(waitFlag) return false;
         waitFlag = true;
         var input_chat_message = document.getElementById('input_chat_message');
-        getElementById('sendForm').chat_message.value = input_chat_message.value;
+        document.getElementById('sendForm').chat_message.value = input_chat_message.value;
         input_chat_message.value = '';
         input_chat_message.className = 'wait';
-        getElementById('sendForm').submit();
+        document.getElementById('sendForm').submit();
         enableForm();
         return false;
     }
index 5b15a73413a4e7a4aa6597390a205ff58c32cd44..f6825f5fddc6c4f039300162dd3f73dd0d0925ea 100644 (file)
         error('Not logged in!');
     }
 
-    //Get the course theme
-    $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
-    //Set the course theme if necessary
-    if (!empty($course->theme)) {
-        if (!empty($CFG->allowcoursethemes)) {
-            $CFG->coursetheme = $course->theme;
-        }
+    //Get the minimal course
+    if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
+        error('incorrect course id');
     }
 
     //Get the user theme and enough info to be used in chat_format_message() which passes it along to
-    // chat_format_message_manually() -- and only id and timezone are used.
-    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, theme, username, timezone')) {
+    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, lang, theme, username, timezone')) {
         error('User does not exist!');
     }
     $USER->description = '';
 
-    //Adjust the prefered theme (main, course, user)
-    theme_setup();
-
-    chat_force_language($chatuser->lang);
+    //Setup course, lang and theme
+    course_setup($course);
 
     // force deleting of timed out users if there is a silence in room or just entering
     if ((time() - $chat_lasttime) > $CFG->chat_old_ping) {
index 675e6312067f8f0b0d0fb3297abf81e712224b96..b9f657bd8bd135dfced719d20152a2f2817a67d2 100644 (file)
         error('Not logged in!');
     }
 
-    //Get the course theme
-    $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
-    //Set the course theme if necessary
-    if (!empty($course->theme)) {
-        if (!empty($CFG->allowcoursethemes)) {
-            $CFG->coursetheme = $course->theme;
-        }
+    //Get the minimal course
+    if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
+        error('incorrect course id');
     }
+
     //Get the user theme and enough info to be used in chat_format_message() which passes it along to
     // chat_format_message_manually() -- and only id and timezone are used.
-    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, theme, username, timezone')) {
+    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, lang, theme, username, timezone')) {
         error('User does not exist!');
     }
     $USER->description = '';
 
-    //Adjust the prefered theme (main, course, user)
-    theme_setup();
-
-    chat_force_language($chatuser->lang);
+    //Setup course, lang and theme
+    course_setup($course);
 
     // force deleting of timed out users if there is a silence in room or just entering
     if ((time() - $chat_lasttime) > $CFG->chat_old_ping) {
index eead4f30af0d87769b9894e5f750157f6fb5b2c9..9cd107c5afc7cb9c48156c772fc772f5459d3451 100644 (file)
         error('Not logged in!');
     }
 
-    //Get the course theme
-    $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
-    //Set the course theme if necessary
-    if (!empty($course->theme)) {
-        if (!empty($CFG->allowcoursethemes)) {
-            $CFG->coursetheme = $course->theme;
-        }
+    //Get the minimal course
+    if (!$course = get_record('course','id',$chatuser->course,'','','','','id,theme,lang')) {
+        error('incorrect course id');
     }
-    //Get the user theme
-    $USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
 
-    //Adjust the prefered theme (main, course, user)
-    theme_setup();
+    //Get the user theme and enough info to be used in chat_format_message() which passes it along to
+    if (!$USER = get_record('user','id',$chatuser->userid,'','','','','id, lang, theme, username, timezone')) {
+        error('User does not exist!');
+    }
+    $USER->description = '';
 
-    chat_force_language($chatuser->lang);
+    //Setup course, lang and theme
+    course_setup($course);
 
     $courseid = $chatuser->course;
 
index d89c9e5c3e56f9fbea0e1dff6afea1e72fc25315..c33e2ccb86e85c7b5c069493110ca6c8872927de 100644 (file)
         error('Not logged in!');
     }
 
-    chat_force_language($chatuser->lang);
+    //Get the user theme
+    $USER = get_record('user', 'id', $chatuser->userid);
+
+    //Setup course, lang and theme
+    course_setup($chatuser->course);
 
     ob_start();
     ?>
index f924e898b22715704bd69d062afacb448c8700df..7fe38cead78ad5ddc60ae87b90260faec2a90392 100644 (file)
@@ -311,18 +311,6 @@ function chat_refresh_events($courseid = 0) {
     return true;
 }
 
-function chat_force_language($lang) {
-/// This function prepares moodle to operate in given language
-/// usable when $nomoodlecookie = true;
-/// BEWARE: there must be no $course, $USER or $SESSION
-    global $CFG;
-
-    if(!empty($CFG->courselang)) {
-        unset($CFG->courselang);
-    }
-    $CFG->lang = $lang;
-    moodle_setlocale();
-}
 
 //////////////////////////////////////////////////////////////////////
 /// Functions that require some SQL
index 41ca909eef06b7abd66357719c6d57b8367c5e30..411e71efee7aa927a9a0254b765d8cd0b1b3e79e 100644 (file)
@@ -230,9 +230,7 @@ function forum_cron() {
         $strforums = get_string('forums', 'forum');
     }
 
-    if (!empty($USER->id)) { // Remember real USER account if necessary
-        $realuser = $USER;
-    }
+    $realuser = clone($USER);
 
     /// Posts older than 2 days will not be mailed.  This is to avoid the problem where
     /// cron has not been running for a long time, and then suddenly people are flooded
@@ -301,12 +299,6 @@ function forum_cron() {
             );
 
 
-            if (!empty($course->lang)) {
-                $CFG->courselang = $course->lang;
-            } else {
-                unset($CFG->courselang);
-            }
-
             // Get coursemodule record (and cache these)
 
             if (!empty($cachecm[$forum->id])) {
@@ -366,8 +358,8 @@ function forum_cron() {
 
                     /// Override the language and timezone of the "current" user, so that
                     /// mail is customised for the receiver.
-                    $USER->lang     = $userto->lang;
-                    $USER->timezone = $userto->timezone;
+                    $USER = $userto;
+                    course_setup($course);
 
                     $postsubject = "$course->shortname: ".format_string($post->subject,true);
                     $posttext = forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $userto);
@@ -405,15 +397,7 @@ function forum_cron() {
         }
     }
 
-    unset($CFG->courselang);
-
-    if (!empty($realuser)) {   // Restore real USER timezone if necessary
-        $sitetimezone = $realuser->timezone;
-        $USER->lang   = $realuser->lang;
-    } else {
-        $sitetimezone = $CFG->timezone;
-        $USER->lang   = $CFG->lang;
-    }
+    $sitetimezone = $CFG->timezone;
 
     /// Now see if there are any digest mails waiting to be sent, and if we should send them
 
@@ -470,8 +454,8 @@ function forum_cron() {
 
                 /// Override the language and timezone of the "current" user, so that
                 /// mail is customised for the receiver.
-                $USER->lang     = $userto->lang;
-                $USER->timezone = $userto->timezone;
+                $USER = $userto;
+                course_setup(SITEID);
 
 
                 $postsubject = get_string('digestmailsubject', 'forum', $site->shortname);
@@ -505,6 +489,9 @@ function forum_cron() {
                         continue;
                     }
 
+                    //override language
+                    course_setup($course);
+
                     $canunsubscribe = ! forum_is_forcesubscribed($forum->id);
                     $canreply = forum_user_can_post($forum, $userto);
 
@@ -618,9 +605,8 @@ function forum_cron() {
         mtrace(get_string('digestsentusers', 'forum', $usermailcount));
     }
 
-    if (!empty($realuser)) {   // Restore real USER if necessary
-        $USER = $realuser;
-    }
+    $USER = $realuser;
+    course_setup(SITEID); // reset cron user language, theme and timezone settings
 
     if (!empty($CFG->forum_lastreadclean)) {
         $timenow = time();
@@ -1660,7 +1646,7 @@ function forum_subscribed_users($course, $forum, $groupid=0, $cache=false) {
         $results = get_course_users($course->id);     // Otherwise get everyone in the course
     } else {
         $results = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop,
-                                   u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.lang, u.trackforums
+                                   u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums
                               FROM {$CFG->prefix}user u,
                                    {$CFG->prefix}forum_subscriptions s $grouptables
                              WHERE s.forum = '$forum->id'
index bd82f686362659d27fe2a79b491403713cef2c2d..677be7944dac936d34991a6eac0b18c9127ff312 100644 (file)
@@ -3,12 +3,12 @@
 /*
 
   ErfurtWiki - an embedable, fast and user-friendly wiki engine
-  ¯¯¯¯¯¯¯¯¯¯
+  ����������
   This is Public Domain (no license, no warranty); but feel free
   to redistribute it under GPL or anything else you like.
 
   http://erfurtwiki.sourceforge.net/
-  Mario Salzer <mario*erphesfurt·de> and many others(tm)
+  Mario Salzer <mario*erphesfurtde> and many others(tm)
 
 
   Use it from inside yoursite.php like that:
@@ -75,7 +75,7 @@
     define("EWIKI_UP_UPLOAD", "upload");
         #- other stuff
         define("EWIKI_DEFAULT_LANG", "en");
-        define("EWIKI_CHARSET", current_charset());
+        define("EWIKI_CHARSET", "UTF-8");
     #- user permissions
     define("EWIKI_PROTECTED_MODE", 0);  # disable funcs + require auth
     define("EWIKI_PROTECTED_MODE_HIDING", 0);  # hides disallowed actions
@@ -93,7 +93,7 @@
     else {
 #### END MOODLE CHANGES
 
-    define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
+    define("EWIKI_CHARS_L", "a-z_��$\337-\377");
     define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
 
 #### BEGIN MOODLE CHANGES   
     #<off># "###" => array("<big><b>", "</b></big>"),
         "**" => array("<b>", "</b>"),
         "##" => array("<big>", "</big>"),
-        "µµ" => array("<small>", "</small>"),
+        "��" => array("<small>", "</small>"),
            ),
            "wm_start_end" => array(
            ),
     ));
         #
         $ewiki_t["es"] = @array_merge(@$ewiki_t["es"], array(
-           "EDITTHISPAGE" => "EditarEstaPágina",
+           "EDITTHISPAGE" => "EditarEstaPgina",
            "BACKLINKS" => "EnlacesInversos",
-           "PAGESLINKINGTO" => "Páginas enlazando \$title",
-           "PAGEHISTORY" => "InfoPágina",
-           "INFOABOUTPAGE" => "Información sobre la página",
-           "LIKEPAGES" => "Páginas como esta",
-           "NEWESTPAGES" => "Páginas más nuevas",
-           "LASTCHANGED" => "última modificación %d/%m/%Y a las %H:%M",
-           "DOESNOTEXIST" => "Esta página aún no existe, por favor eliga EditarEstaPágina si desea crearla.",
-           "DISABLEDPAGE" => "Esta página no está disponible en este momento.",
-           "ERRVERSIONSAVE" => "Disculpe, mientras editaba esta página alguién más
-        salvó una versión modificada. Por favor regrese a
+           "PAGESLINKINGTO" => "Pginas enlazando \$title",
+           "PAGEHISTORY" => "InfoPgina",
+           "INFOABOUTPAGE" => "Informaci�n sobre la p�gina",
+           "LIKEPAGES" => "Pginas como esta",
+           "NEWESTPAGES" => "P�ginas m�s nuevas",
+           "LASTCHANGED" => "�ltima modificaci�n %d/%m/%Y a las %H:%M",
+           "DOESNOTEXIST" => "Esta p�gina a�n no existe, por favor eliga EditarEstaP�gina si desea crearla.",
+           "DISABLEDPAGE" => "Esta p�gina no est� disponible en este momento.",
+           "ERRVERSIONSAVE" => "Disculpe, mientras editaba esta p�gina algui�n m�s
+        salv� una versi�n modificada. Por favor regrese a
         a la pantalla anterior y copie sus cambios a su computador
-        para insertalos nuevamente después de que cargue
-        la pantalla de edición.",
-           "ERRORSAVING" => "Ocurrió un error mientras se salvavan sus cambios. Por favor intente de nuevo.",
-           "THANKSFORCONTRIBUTION" => "Gracias por su contribución!",
-           "CANNOTCHANGEPAGE" => "Esta página no puede ser modificada.",
-           "OLDVERCOMEBACK" => "Hacer que esta versión antigua regrese a remplazar la actual",
+        para insertalos nuevamente despus de que cargue
+        la pantalla de edicin.",
+           "ERRORSAVING" => "Ocurri un error mientras se salvavan sus cambios. Por favor intente de nuevo.",
+           "THANKSFORCONTRIBUTION" => "Gracias por su contribucin!",
+           "CANNOTCHANGEPAGE" => "Esta pgina no puede ser modificada.",
+           "OLDVERCOMEBACK" => "Hacer que esta versin antigua regrese a remplazar la actual",
            "PREVIEW" => "Previsualizar",
            "SAVE" => "Salvar",
-           "CANCEL_EDIT" => "CancelarEdición",
-           "UPLOAD_PICTURE_BUTTON" => "subir gráfica &gt;&gt;&gt;",
+           "CANCEL_EDIT" => "CancelarEdicin",
+           "UPLOAD_PICTURE_BUTTON" => "subir grfica &gt;&gt;&gt;",
            "EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."BuenEstilo\">BuenEstilo</a> es
         escribir lo que viene a su mente. No se preocupe mucho
-        por la apariencia. También puede agregar <a href=\"".EWIKI_SCRIPT."ReglasDeMarcadoWiki\">ReglasDeMarcadoWiki</a>
-        más adelante si piensa que es necesario.<br />",
+        por la apariencia. Tambin puede agregar <a href=\"".EWIKI_SCRIPT."ReglasDeMarcadoWiki\">ReglasDeMarcadoWiki</a>
+        ms adelante si piensa que es necesario.<br />",
            "EDIT_FORM_2" => "<br />Por favor no escriba cosas, que puedan
         enfadar a otras personas. Y por favor tenga en mente que
-        usted no es del todo anónimo en Internet 
-        (encuentre más sobre 
+        usted no es del todo annimo en Internet 
+        (encuentre ms sobre 
         '<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' de su computador con Google).",
-           "BIN_IMGTOOLARGE" => "¡La gráfica es demasiado grande!",
-           "BIN_NOIMG" => "¡No es un archivo con una gráfica (formato de archivo inaceptable)!",
-           "FORBIDDEN" => "No está autorizado para acceder a esta página.",
+           "BIN_IMGTOOLARGE" => "�La gr�fica es demasiado grande!",
+           "BIN_NOIMG" => "�No es un archivo con una gr�fica (formato de archivo inaceptable)!",
+           "FORBIDDEN" => "No est� autorizado para acceder a esta p�gina.",
         ));
         #
     $ewiki_t["de"] = @array_merge(@$ewiki_t["de"], array(
-       "EDITTHISPAGE" => "DieseSeiteÄndern",
-           "APPENDTOPAGE" => "Ergänze",
-       "BACKLINKS" => "ZurückLinks",
+       "EDITTHISPAGE" => "DieseSeitendern",
+           "APPENDTOPAGE" => "Ergnze",
+       "BACKLINKS" => "ZurckLinks",
        "PAGESLINKINGTO" => "Verweise zur Seite \$title",
        "PAGEHISTORY" => "SeitenInfo",
-       "INFOABOUTPAGE" => "Informationen über Seite",
-       "LIKEPAGES" => "Ähnliche Seiten",
+       "INFOABOUTPAGE" => "Informationen ber Seite",
+       "LIKEPAGES" => "hnliche Seiten",
        "NEWESTPAGES" => "Neueste Seiten",
-       "LASTCHANGED" => "zuletzt geändert am %d.%m.%Y um %H:%M",
+       "LASTCHANGED" => "zuletzt gendert am %d.%m.%Y um %H:%M",
        "DISABLEDPAGE" => "Diese Seite kann momentan nicht angezeigt werden.",
-       "ERRVERSIONSAVE" => "Entschuldige, aber während Du an der Seite
-        gearbeitet hast, hat bereits jemand anders eine geänderte
+       "ERRVERSIONSAVE" => "Entschuldige, aber whrend Du an der Seite
+        gearbeitet hast, hat bereits jemand anders eine genderte
         Fassung gespeichert. Damit nichts verloren geht, browse bitte
-        zurück und speichere Deine Änderungen in der Zwischenablage
+        zur�ck und speichere Deine �nderungen in der Zwischenablage
         (Bearbeiten->Kopieren) um sie dann wieder an der richtigen
-        Stelle einzufügen, nachdem du die EditBoxSeite nocheinmal
+        Stelle einzufgen, nachdem du die EditBoxSeite nocheinmal
         geladen hast.<br />
-        Vielen Dank für Deine Mühe.",
+        Vielen Dank f�r Deine M�he.",
        "ERRORSAVING" => "Beim Abspeichern ist ein Fehler aufgetreten. Bitte versuche es erneut.",
-       "THANKSFORCONTRIBUTION" => "Vielen Dank für Deinen Beitrag!",
-       "CANNOTCHANGEPAGE" => "Diese Seite kann nicht geändert werden.",
+       "THANKSFORCONTRIBUTION" => "Vielen Dank fr Deinen Beitrag!",
+       "CANNOTCHANGEPAGE" => "Diese Seite kann nicht gendert werden.",
        "OLDVERCOMEBACK" => "Diese alte Version der Seite wieder zur Aktuellen machen",
        "PREVIEW" => "Vorschau",
        "SAVE" => "Speichern",
-       "CANCEL_EDIT" => "ÄnderungenVerwerfen",
+       "CANCEL_EDIT" => "nderungenVerwerfen",
        "UPLOAD_PICTURE_BUTTON" => "Bild hochladen &gt;&gt;&gt;",
        "EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GuterStil\">GuterStil</a> ist es,
         ganz einfach das zu schreiben, was einem gerade in den
         Sinn kommt. Du solltest dich jetzt noch nicht so sehr
-        darum kümmern, wie die Seite aussieht. Du kannst später
-        immernoch zurückkommen und den Text mit <a href=\"".EWIKI_SCRIPT."FormatierungsRegeln\">WikiTextFormatierungsRegeln</a>
+        darum k�mmern, wie die Seite aussieht. Du kannst sp�ter
+        immernoch zurckkommen und den Text mit <a href=\"".EWIKI_SCRIPT."FormatierungsRegeln\">WikiTextFormatierungsRegeln</a>
         aufputschen.<br />",
        "EDIT_FORM_2" => "<br />Bitte schreib keine Dinge, die andere Leute
-        verärgern könnten. Und bedenke auch, daß es schnell auf
-        dich zurückfallen kann wenn du verschiedene andere Dinge sagst (mehr Informationen zur
+        ver�rgern k�nnten. Und bedenke auch, da� es schnell auf
+        dich zurckfallen kann wenn du verschiedene andere Dinge sagst (mehr Informationen zur
         '<a href=\"http://google.de/search?q=computer+IP+adresse\">IP Adresse</a>'
         deines Computers findest du bei Google).",
     ));
@@ -635,7 +635,7 @@ function ewiki_etag(&$data) {
 #-- encloses whole page output with a descriptive <div>
 function ewiki_page_css_container(&$o, &$id, &$data, &$action) {
    $o = "<div class=\"wiki $action "
-      . strtr($id, ' ./ --_!"§$%&()=?²³{[]}`+#*;:,<>| @µöäüÖÄÜߤ^°«»\'\\',
+      . strtr($id, ' ./ --_!"�$%&()=?��{[]}`+#*;:,<>| @�������ߤ^���\'\\',
                    '-  -----------------------------------------------')
       . "\">\n"
       . $o . "\n</div>\n";
@@ -2180,7 +2180,7 @@ function ewiki_format_html(&$str, &$in, &$iii, &$s) {
 
 
 function ewiki_format_comment(&$str, &$in, &$iii, &$s, $btype) {
-   $str = "<!-- "  . str_replace("--", "¯¯", $str) . " -->";
+   $str = "<!-- "  . str_replace("--", "��", $str) . " -->";
 }
 
 
index 3bf627c2fd027281c576c589fd35b89b11fae8fc..aac69aa330a876653c28b46d44a2f4c32d81638a 100644 (file)
@@ -1,23 +1,21 @@
 <?php
 
    
-if (isset($THEME->chameleonenabled) && $THEME->chameleonenabled) {
+if (!empty($THEME->chameleonenabled)) {
     $chameleon_isadmin = has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
     $chameleon_isteacher = false;
-    if (isset($course->id)) {
-        $chameleon_courseparam = '?id=' . $course->id;
-        if (!$chameleon_isadmin) {
-            $chameleon_isteacher = (has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id)) && isset($CFG->coursetheme));
-        }
-    } else {
+    if ($COURSE->id == SITEID) {
         $chameleon_courseparam = '';
+    } else {
+        $chameleon_courseparam = '?id=' . $COURSE->id;
+        $chameleon_isteacher = !empty($COURSE->theme) and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $COURSE->id));
     }
     
-    if ($chameleon_isadmin || ($chameleon_isteacher && !empty($CFG->allowcoursethemes) && !empty($THEME->chameleonteachereditenabled))) { 
+    if ($chameleon_isadmin or ($chameleon_isteacher and !empty($CFG->allowcoursethemes) and !empty($THEME->chameleonteachereditenabled))) { 
         // either we're an admin or we're a teacher and this is being used as the course theme
         // if we're on a page using a course theme edit that, otherwise edit the main chameleon theme
         // $chameleon_theme = (isset($CFG->coursetheme)) ? $CFG->coursetheme : $CFG->theme;
-        $chameleon_theme = (isset($CFG->coursetheme)) ? $CFG->coursetheme : current_theme();
+        $chameleon_theme = current_theme();
 ?>
 
 <style type="text/css"> @import '<?php echo "$CFG->themewww/$chameleon_theme" ?>/ui/chameleon_ui.css'; </style>
index dd4239087d126878462da778a8ebf29f1a46f044..3b78f645ff29a35a44f4db45a1c184749230bd1d 100644 (file)
@@ -8,10 +8,15 @@ if (empty($THEME->chameleonenabled)) {
     die('CHAMELEON_ERROR Editing this theme has been disabled');
 }
 
+$id = optional_param('id', SITEID, PARAM_INT);
+if (!$course = get_record('course', 'id', $id)) {
+    error('Incorrect course id');
+}
+
+course_setup($course); // we should not require login here
 
-$chameleon_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
-if ($chameleon_id != 0 && !empty($CFG->allowcoursethemes) && !empty($THEME->chameleonteachereditenabled)) {
-    if (!has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $chameleon_id))) {
+if ($id != SITEID and !empty($CFG->allowcoursethemes) and !empty($course->theme) and !empty($THEME->chameleonteachereditenabled)) {
+    if (!has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $id))) {
         die('CHAMELEON_ERROR Either you are not logged in or you are not allowed to edit this theme');
     }
 } else if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
index 6b18319e5f66a194455e70733f2e770645c822ee..4a8ce73db3cbd40b8a9e0cca6f5ade3702a4bcae 100644 (file)
@@ -96,7 +96,7 @@ function useredit_shared_definition(&$mform) {
         if (!empty($CFG->sitemailcharset)) {
             $choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
         } else {
-            $choices['0'] = get_string('site').' ('.current_charset().')';
+            $choices['0'] = get_string('site').' (UTF-8)';
         }
         $choices = array_merge($choices, $charsets);
         $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);