diff --git a/admin/config.html b/admin/config.html index e11e41b75952a..ed8449a0adfc1 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 fdd409d2649bb..f5e1d24968e7c 100644 --- a/blocks/messages/block_messages.php +++ b/blocks/messages/block_messages.php @@ -18,7 +18,7 @@ function get_content() { $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 5f75eb53bb8b0..9bb492e1acc44 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -117,7 +117,7 @@ function get_content() { $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 0ce7bd41a6c3b..59985c49ce85e 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -203,6 +203,7 @@ $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 ac7c2a14d1da6..358d60507ee17 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 afae6a39fce94..dddc142a88f0f 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 0f7782493f937..bff3c9b911444 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 d9ec3d4a21e7e..807b8994daa61 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 b0a515fcb850c..0371b23c79928 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 4b8e5c74a5670..36f79ccba5caf 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";