summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-09-15 06:53:18 +0000
committeralecpl <alec@alec.pl>2008-09-15 06:53:18 +0000
commitacb08f517d22a6acd9525ced7ea3fcc2e80d29f0 (patch)
treee11f972961299ee1e67cdd7315e728a6396b0391
parenta81be1b534d2d3380330e1e8dec0b39683a49f12 (diff)
- Added 'sendmail_delay' option to restrict messages sending interval (#1484491)
-rw-r--r--CHANGELOG4
-rw-r--r--config/main.inc.php.dist3
-rw-r--r--program/localization/en_GB/messages.inc1
-rw-r--r--program/localization/en_US/messages.inc1
-rw-r--r--program/localization/pl_PL/messages.inc1
-rw-r--r--program/steps/mail/sendmail.inc39
6 files changed, 34 insertions, 15 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a82605e59..6d3a3cf8e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
CHANGELOG RoundCube Webmail
---------------------------
+2008/09/15 (alec)
+----------
+- Added 'sendmail_delay' option to restrict messages sending interval (#1484491)
+
2008/09/12 (alec)
----------
- Added vertical splitter for folders list resizing
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index fcf7e8fff..ffa2d060f 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -107,6 +107,9 @@ $rcmail_config['smtp_helo_host'] = '';
// Log sent messages
$rcmail_config['smtp_log'] = TRUE;
+// how many seconds must pass between emails sent by a user
+$rcmail_config['sendmail_delay'] = 0;
+
// these cols are shown in the message list
// available cols are: subject, from, to, cc, replyto, date, size, encoding, flag
$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size', 'flag');
diff --git a/program/localization/en_GB/messages.inc b/program/localization/en_GB/messages.inc
index 255aac35e..7ca8d28aa 100644
--- a/program/localization/en_GB/messages.inc
+++ b/program/localization/en_GB/messages.inc
@@ -40,6 +40,7 @@ $messages['encryptedmessage'] = 'This is an encrypted message and can not be dis
$messages['nocontactsfound'] = 'No contacts found';
$messages['contactnotfound'] = 'The requested contact was not found';
$messages['sendingfailed'] = 'Failed to send message';
+$messages['senttooquickly'] = 'You have to wait $sec sec. to sent the message';
$messages['errorsavingsent'] = 'An error occured while saving sent message';
$messages['errorsaving'] = 'An error occured while saving';
$messages['errormoving'] = 'Could not move the message';
diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc
index c4de6dd98..9373be88e 100644
--- a/program/localization/en_US/messages.inc
+++ b/program/localization/en_US/messages.inc
@@ -40,6 +40,7 @@ $messages['encryptedmessage'] = 'This is an encrypted message and can not be dis
$messages['nocontactsfound'] = 'No contacts found';
$messages['contactnotfound'] = 'The requested contact was not found';
$messages['sendingfailed'] = 'Failed to send message';
+$messages['senttooquickly'] = 'You have to wait $sec sec. to sent the message';
$messages['errorsavingsent'] = 'An error occured while saving sent message';
$messages['errorsaving'] = 'An error occured while saving';
$messages['errormoving'] = 'Could not move the message';
diff --git a/program/localization/pl_PL/messages.inc b/program/localization/pl_PL/messages.inc
index 986a8590a..5b7f60f3a 100644
--- a/program/localization/pl_PL/messages.inc
+++ b/program/localization/pl_PL/messages.inc
@@ -45,6 +45,7 @@ $messages['encryptedmessage'] = 'Przepraszamy, nie można wyświetlić zaszyfrow
$messages['nocontactsfound'] = 'Nie znaleziono kontaktu!';
$messages['contactnotfound'] = 'Szukany kontakt nie został odnaleziony';
$messages['sendingfailed'] = 'Nie udało się wysłać wiadomości!';
+$messages['senttooquickly'] = 'Musisz poczekać $sec sek. aby móc wysłać tą wiadomość!';
$messages['errorsavingsent'] = 'Wystąpił błąd podczas zapisu wysłanej wiadomości!';
$messages['errorsaving'] = 'Wystąpił błąd podczas zapisu!';
$messages['errormoving'] = 'Nie można przenieść wybranej wiadomości!';
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 9efb0d7ad..543895dec 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -25,6 +25,9 @@
$OUTPUT->reset();
$OUTPUT->framed = TRUE;
+$savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
+
+/****** checks ********/
if (!isset($_SESSION['compose']['id'])) {
raise_error(array('code' => 500, 'file' => __FILE__, 'message' => "Invalid compose ID"), true, false);
@@ -33,10 +36,23 @@ if (!isset($_SESSION['compose']['id'])) {
$OUTPUT->send('iframe');
}
+if (!$savedraft && empty($_POST['_to']) && empty($_POST['_cc']) && empty($_POST['_bcc']) && empty($_POST['_subject']) && $_POST['_message']) {
+ $OUTPUT->show_message('sendingfailed', 'error');
+ $OUTPUT->send('iframe');
+}
-/****** message sending functions ********/
+if(!$savedraft && !empty($CONFIG['sendmail_delay'])) {
+ $wait_sec = time() - intval($CONFIG['sendmail_delay']) - intval($_SESSION['last_message_time']);
+ if($wait_sec < 0)
+ {
+ $OUTPUT->show_message('senttooquickly', 'error', array('sec' => $wait_sec * -1));
+ $OUTPUT->send('iframe');
+ }
+}
+/****** message sending functions ********/
+
// get identity record
function rcmail_get_identity($id)
{
@@ -116,23 +132,13 @@ function rcmail_attach_emoticons(&$mime_message)
$mime_message->setHTMLBody($body);
}
+
+/****** compose message ********/
+
if (strlen($_POST['_draft_saveid']) > 3)
$olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST);
$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host']));
-$savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
-
-
-/****** check submission and compose message ********/
-
-
-if (!$savedraft && empty($_POST['_to']) && empty($_POST['_cc']) && empty($_POST['_bcc']) && empty($_POST['_subject']) && $_POST['_message'])
- {
- $OUTPUT->show_message("sendingfailed", 'error');
- $OUTPUT->send('iframe');
- return;
- }
-
// set default charset
$input_charset = $OUTPUT->get_charset();
@@ -346,8 +352,11 @@ if (!$savedraft)
{
$OUTPUT->show_message("sendingfailed", 'error');
$OUTPUT->send('iframe');
- return;
}
+
+ // save message sent time
+ if (!empty($CONFIG['sendmail_delay']))
+ $_SESSION['last_message_time'] = time();
// set replied/forwarded flag
if ($_SESSION['compose']['reply_uid'])