Skip to content

Commit

Permalink
Messaging can now be completely disabled using $CFG->messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Jan 31, 2005
1 parent cc15a60 commit cdf3925
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 15 deletions.
16 changes: 16 additions & 0 deletions admin/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,22 @@
</td>
</tr>

<tr valign="top">
<td align="right">messaging:</td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");

choose_from_menu ($options, "messaging", $config->messaging, "", "", "");
?>
</td>
<td>
<?php print_string("configmessaging") ?>
</td>
</tr>

<tr>
<td colspan="3" align="center">
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
Expand Down
2 changes: 1 addition & 1 deletion blocks/messages/block_messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion blocks/online_users/block_online_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function get_content() {
$this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> ';
}
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->instance->pageid.'" title="'.$timeago.'">'.$user->fullname.'</a>';
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 .= '&nbsp;<a target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/user.php?id='.$user->id.'" onclick="return openpopup(\'/message/user.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img height="11" width="11" src="'.$CFG->pixpath.'/t/message.gif"></a>';
}
$this->content->text .= '</div>';
Expand Down
1 change: 1 addition & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?';
Expand Down
1 change: 1 addition & 0 deletions lib/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'longtimenosee' => 100,
'maxbytes' => 0,
'maxeditingtime' => 1800,
'messaging' => true,
'noreplyaddress' => 'noreply@'.$_SERVER['HTTP_HOST'],
'notifyloginfailures' => '',
'notifyloginthreshold' => 10,
Expand Down
4 changes: 3 additions & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions message/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions message/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions message/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 14 additions & 12 deletions user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,22 @@
echo "<input type=\"submit\" value=\"".get_string("loginas")."\" />";
echo "</form></td>";
}
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 "<td nowrap=\"nowrap\"><form target=\"message\" action=\"../message/index.php\" method=\"get\">";
echo "<input type=\"submit\" value=\"$messagebuttonname\" onclick=\"return openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
echo "</form></td>";
} else {
$messagebuttonname = get_string("messages", "message");
echo "<td nowrap=\"nowrap\"><form target=\"message_$user->id\" action=\"../message/user.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$user->id\" />";
echo "<input type=\"submit\" value=\"".get_string("sendmessage", "message")."\" onclick=\"return openpopup('/message/user.php?id=$user->id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
echo "</form></td>";
}
echo "<td nowrap=\"nowrap\"><form target=\"message\" action=\"../message/index.php\" method=\"get\">";
echo "<input type=\"submit\" value=\"$messagebuttonname\" onclick=\"return openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
echo "</form></td>";
} else {
echo "<td nowrap=\"nowrap\"><form target=\"message_$user->id\" action=\"../message/user.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$user->id\" />";
echo "<input type=\"submit\" value=\"".get_string("sendmessage", "message")."\" onclick=\"return openpopup('/message/user.php?id=$user->id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
echo "</form></td>";
}
echo "<td></td>";
echo "</tr></table></center>\n";
Expand Down

0 comments on commit cdf3925

Please sign in to comment.