From d38755249d481cf6d76799a1fa4fcbbb1b3be982 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Thu, 11 Nov 2010 06:11:43 +0000 Subject: [PATCH] message MDL-25148 using method on $PAGE to allow or disallow popup notifications --- admin/index.php | 6 +++--- lib/moodlelib.php | 4 ++-- message/lib.php | 3 ++- mod/quiz/accessrules.php | 3 +-- user/policy.php | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/admin/index.php b/admin/index.php index f8c72469ba6..e70c14c01b1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -111,7 +111,7 @@ $CFG->xmlstrictheaders = false; if (!core_tables_exist()) { $PAGE->set_pagelayout('maintenance'); - define('MESSAGE_WINDOW', true); + $PAGE->set_popup_notification_allowed(false); // fake some settings $CFG->docroot = 'http://docs.moodle.org'; @@ -194,7 +194,7 @@ if (empty($CFG->version)) { if ($version > $CFG->version) { // upgrade $PAGE->set_pagelayout('maintenance'); - define('MESSAGE_WINDOW', true); + $PAGE->set_popup_notification_allowed(false); $a->oldversion = "$CFG->release ($CFG->version)"; $a->newversion = "$release ($version)"; @@ -278,7 +278,7 @@ if (moodle_needs_upgrading()) { // means core upgrade or installation was not already done if (!$confirmplugins) { $PAGE->set_pagelayout('maintenance'); - define('MESSAGE_WINDOW', true); + $PAGE->set_popup_notification_allowed(false); $strplugincheck = get_string('plugincheck'); $PAGE->navbar->add($strplugincheck); $PAGE->set_title($strplugincheck); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a915dd83ef1..20a64b38a56 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -9107,8 +9107,8 @@ function moodle_request_shutdown() { */ function message_popup_window() { global $USER, $DB, $PAGE, $CFG, $SITE; - - if (defined('MESSAGE_WINDOW') || empty($CFG->messaging)) { + + if (!$PAGE->get_popup_notification_allowed() || empty($CFG->messaging)) { return; } diff --git a/message/lib.php b/message/lib.php index e279a744a72..88102018650 100644 --- a/message/lib.php +++ b/message/lib.php @@ -27,7 +27,8 @@ require_once($CFG->libdir.'/eventslib.php'); define ('MESSAGE_SHORTLENGTH', 300); -define ('MESSAGE_WINDOW', true); // We are in a message window (so don't pop up a new one!) + +$PAGE->set_popup_notification_allowed(false); // We are in a message window (so don't pop up a new one) define ('MESSAGE_DISCUSSION_WIDTH',600); define ('MESSAGE_DISCUSSION_HEIGHT',500); diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index fddedc049ab..4107514ce4a 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -775,8 +775,7 @@ class securewindow_access_rule extends quiz_access_rule_base { */ public function setup_secure_page($title, $headtags=null) { global $OUTPUT, $PAGE; - /// This prevents the message window coming up. - define('MESSAGE_WINDOW', true); + $PAGE->set_popup_notification_allowed(false);//prevent message notifications $PAGE->set_title($title); $PAGE->set_cacheable(false); $PAGE->set_pagelayout('popup'); diff --git a/user/policy.php b/user/policy.php index 45741331891..46a2f2bb20f 100644 --- a/user/policy.php +++ b/user/policy.php @@ -30,8 +30,7 @@ require_once($CFG->libdir.'/resourcelib.php'); $agree = optional_param('agree', 0, PARAM_BOOL); $PAGE->set_url('/user/policy.php'); - -define('MESSAGE_WINDOW', true); // This prevents the message window coming up - TODO: this is a hack! (skodak) +$PAGE->set_popup_notification_allowed(false); if (!isloggedin()) { require_login();