From cdf392551813537cc1b3350cad1a0e785a52c911 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 31 Jan 2005 07:11:42 +0000 Subject: [PATCH] Messaging can now be completely disabled using $CFG->messaging --- admin/config.html | 16 +++++++++++++ blocks/messages/block_messages.php | 2 +- blocks/online_users/block_online_users.php | 2 +- lang/en/moodle.php | 1 + lib/defaults.php | 1 + lib/weblib.php | 4 +++- message/history.php | 4 ++++ message/index.php | 4 ++++ message/user.php | 4 ++++ user/view.php | 26 ++++++++++++---------- 10 files changed, 49 insertions(+), 15 deletions(-) diff --git a/admin/config.html b/admin/config.html index e11e41b759..ed8449a0ad 100644 --- a/admin/config.html +++ b/admin/config.html @@ -665,6 +665,22 @@ + + messaging: + + messaging, "", "", ""); + ?> + + + + + + diff --git a/blocks/messages/block_messages.php b/blocks/messages/block_messages.php index fdd409d264..f5e1d24968 100644 --- a/blocks/messages/block_messages.php +++ b/blocks/messages/block_messages.php @@ -18,7 +18,7 @@ class block_messages extends block_base { $this->content->text = ''; $this->content->footer = ''; - if (empty($this->instance) or empty($USER->id) or isguest()) { + if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) { return $this->content; } diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index 5f75eb53bb..9bb492e1ac 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -117,7 +117,7 @@ class block_online_users extends block_base { $this->content->text .= ' '; } $this->content->text .= ''.$user->fullname.''; - if (!empty($USER->id)) { // Only when logged in + if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging)) { // Only when logged in $this->content->text .= ' '; } $this->content->text .= ''; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 0ce7bd41a6..59985c49ce 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -203,6 +203,7 @@ $string['configloglifetime'] = 'This specifies the length of time you want to ke $string['configlongtimenosee'] = 'If students haven\'t logged in for a very long time, then they are automatically unsubscribed from courses. This parameter specifies that time limit.'; $string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP setting upload_max_filesize and the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level.'; $string['configmaxeditingtime'] = 'This specifies the amount of time people have to re-edit forum postings, journal feedback etc. Usually 30 minutes is a good value.'; +$string['configmessaging'] = 'Should the messaging system between site users be enabled?'; $string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the \"From\" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).'; $string['confignotifyloginfailures'] = 'If login failures have been recorded, email notifications can be sent out. Who should see these notifications?'; $string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?'; diff --git a/lib/defaults.php b/lib/defaults.php index ac7c2a14d1..358d60507e 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -45,6 +45,7 @@ 'longtimenosee' => 100, 'maxbytes' => 0, 'maxeditingtime' => 1800, + 'messaging' => true, 'noreplyaddress' => 'noreply@'.$_SERVER['HTTP_HOST'], 'notifyloginfailures' => '', 'notifyloginthreshold' => 10, diff --git a/lib/weblib.php b/lib/weblib.php index afae6a39fc..dddc142a88 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1655,7 +1655,9 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta= include ($CFG->dirroot .'/theme/'. $CFG->theme .'/header.html'); - echo message_popup_window(); + if (!empty($CFG->messaging)) { + echo message_popup_window(); + } } /** diff --git a/message/history.php b/message/history.php index 0f7782493f..bff3c9b911 100644 --- a/message/history.php +++ b/message/history.php @@ -6,6 +6,10 @@ require_login(); + if (empty($CFG->messaging)) { + error("Messaging is disabled on this site"); + } + /// Script parameters $userid1 = required_param('user1', PARAM_INT); if (! $user1 = get_record("user", "id", $userid1)) { // Check it's correct diff --git a/message/index.php b/message/index.php index d9ec3d4a21..807b8994da 100644 --- a/message/index.php +++ b/message/index.php @@ -6,6 +6,10 @@ require_login(0, false); + if (empty($CFG->messaging)) { + error("Messaging is disabled on this site"); + } + /// Optional variables that may be passed in $tab = optional_param('tab', 'contacts'); // current tab - default to contacts $addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact diff --git a/message/user.php b/message/user.php index b0a515fcb8..0371b23c79 100644 --- a/message/user.php +++ b/message/user.php @@ -5,6 +5,10 @@ require_login(); + if (empty($CFG->messaging)) { + error("Messaging is disabled on this site"); + } + /// Script parameters $userid = required_param('id', PARAM_INT); $frame = optional_param('frame', '', PARAM_ALPHA); diff --git a/user/view.php b/user/view.php index 4b8e5c74a5..36f79ccba5 100644 --- a/user/view.php +++ b/user/view.php @@ -282,20 +282,22 @@ echo ""; echo ""; } - if ($USER->id == $user->id) { - if ($countmessages = count_records('message', 'useridto', $user->id)) { - $messagebuttonname = get_string("messages", "message")."($countmessages)"; + if (!empty($CFG->messaging)) { + if ($USER->id == $user->id) { + if ($countmessages = count_records('message', 'useridto', $user->id)) { + $messagebuttonname = get_string("messages", "message")."($countmessages)"; + } else { + $messagebuttonname = get_string("messages", "message"); + } + echo "
"; + echo ""; + echo "
"; } else { - $messagebuttonname = get_string("messages", "message"); + echo "
id\" action=\"../message/user.php\" method=\"get\">"; + echo "id\" />"; + echo "id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />"; + echo "
"; } - echo "
"; - echo ""; - echo "
"; - } else { - echo "
id\" action=\"../message/user.php\" method=\"get\">"; - echo "id\" />"; - echo "id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />"; - echo "
"; } echo ""; echo "\n"; -- 2.39.5