From e54370d7fbc558b33d5820372db2c0d8c578fb9b Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 23 Aug 2012 10:24:10 +0800 Subject: [PATCH 1/4] MDL-27398 mod_chat Adding CLI_SCRIPT to chat daemon Credit to Jorge Villalon --- mod/chat/chatd.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index f255c17dfd2..caedaa55dda 100644 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -1,6 +1,8 @@ #!/usr/bin/php -q Date: Tue, 4 Sep 2012 10:22:47 +0800 Subject: [PATCH 2/4] MDL-27398 mod_chat Removing deprecated calls and moving dependencies Credit to Jorge Villalon --- mod/chat/chatd.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index caedaa55dda..748bc04e04e 100644 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -1,8 +1,10 @@ -#!/usr/bin/php -q dirroot . '/mod/chat/lib.php'); + // Browser quirks define('QUIRK_CHUNK_UPDATE', 0x0001); @@ -29,30 +31,15 @@ $_SERVER['PHP_SELF'] = 'dummy'; $_SERVER['SERVER_NAME'] = 'dummy'; $_SERVER['HTTP_USER_AGENT'] = 'dummy'; -define('NO_MOODLE_COOKIES', true); // session not used here - -include('../../config.php'); -include('lib.php'); - $_SERVER['SERVER_NAME'] = $CFG->chat_serverhost; $_SERVER['PHP_SELF'] = "http://$CFG->chat_serverhost:$CFG->chat_serverport/mod/chat/chatd.php"; $safemode = ini_get('safe_mode'); - -if($phpversion < '4.3') { - die("Error: The Moodle chat daemon requires at least PHP version 4.3 to run.\n Since your version is $phpversion, you have to upgrade.\n\n"); -} if(!empty($safemode)) { die("Error: Cannot run with PHP safe_mode = On. Turn off safe_mode in php.ini.\n"); } -$passref = ini_get('allow_call_time_pass_reference'); -if(empty($passref)) { - die("Error: Cannot run with PHP allow_call_time_pass_reference = Off. Turn on allow_call_time_pass_reference in php.ini.\n"); -} - @set_time_limit (0); -set_magic_quotes_runtime(0); error_reporting(E_ALL); function chat_empty_connection() { From 32b49bbd84c2f5200a1fd5b29d54ffde9194aec5 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 4 Sep 2012 10:23:56 +0800 Subject: [PATCH 3/4] MDL-27398 mod_chat Adding file basic doc --- mod/chat/chatd.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index 748bc04e04e..ff86aaa6eed 100644 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -1,5 +1,28 @@ . + +/** + * Chat daemon + * + * @package mod_chat + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + define('CLI_SCRIPT', true); require(dirname(dirname(dirname(__FILE__))).'/config.php'); From bd9cb43e09baf4ba50e33423400b736530c5f77e Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 4 Sep 2012 10:24:45 +0800 Subject: [PATCH 4/4] MDL-27398 mod_chat Removing PAGE references --- mod/chat/chatd.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index ff86aaa6eed..b1879913e82 100644 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -237,12 +237,11 @@ class ChatDaemon { } function get_user_window($sessionid) { - global $CFG, $PAGE, $OUTPUT; + global $CFG, $OUTPUT; static $str; $info = &$this->sets_info[$sessionid]; - $PAGE->set_course($info['course']); $timenow = time(); @@ -719,7 +718,6 @@ EOD; } function message_broadcast($message, $sender) { - global $PAGE; if(empty($this->conn_sets)) { return true; @@ -737,7 +735,6 @@ EOD; { // Simply give them the message - $PAGE->set_course($info['course']); $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]);