Skip to content
Browse files

Added Drafts support (Feature #1326839) (richs)

  • Loading branch information...
1 parent a8435bd commit 1966c53255495890dd7f25c31bac73d97ecc3291 svncommit committed
Showing with 410 additions and 127 deletions.
  1. +4 −0 CHANGELOG
  2. +5 −1 config/main.inc.php.dist
  3. +5 −5 program/include/rcube_imap.inc
  4. +62 −10 program/js/app.js
  5. +2 −0 program/localization/cn/labels.inc
  6. +4 −0 program/localization/cn/messages.inc
  7. +2 −0 program/localization/de_CH/labels.inc
  8. +4 −0 program/localization/de_CH/messages.inc
  9. +2 −0 program/localization/de_DE/labels.inc
  10. +4 −0 program/localization/de_DE/messages.inc
  11. +2 −0 program/localization/el/labels.inc
  12. +4 −0 program/localization/el/messages.inc
  13. +2 −0 program/localization/en_GB/labels.inc
  14. +4 −0 program/localization/en_GB/messages.inc
  15. +2 −1 program/localization/en_US/labels.inc
  16. +4 −0 program/localization/en_US/messages.inc
  17. +2 −0 program/localization/es/labels.inc
  18. +4 −0 program/localization/es/messages.inc
  19. +2 −0 program/localization/fr/labels.inc
  20. +4 −0 program/localization/fr/messages.inc
  21. +2 −0 program/localization/it/labels.inc
  22. +4 −0 program/localization/it/messages.inc
  23. +2 −0 program/localization/ja/labels.inc
  24. +4 −0 program/localization/ja/messages.inc
  25. +2 −0 program/localization/pt_BR/labels.inc
  26. +4 −0 program/localization/pt_BR/messages.inc
  27. +2 −0 program/localization/pt_PT/labels.inc
  28. +4 −0 program/localization/pt_PT/messages.inc
  29. +2 −0 program/localization/ru/labels.inc
  30. +4 −0 program/localization/ru/messages.inc
  31. +112 −17 program/steps/mail/compose.inc
  32. +4 −1 program/steps/mail/func.inc
  33. +125 −90 program/steps/mail/sendmail.inc
  34. BIN skins/default/images/buttons/drafts_act.png
  35. BIN skins/default/images/buttons/drafts_pas.png
  36. BIN skins/default/images/icons/folder-drafts.png
  37. +7 −2 skins/default/mail.css
  38. +8 −0 skins/default/templates/compose.html
View
4 CHANGELOG
@@ -1,6 +1,10 @@
CHANGELOG RoundCube Webmail
---------------------------
+2006/06/19
+----------
+- Added Drafts support (Feature #1326839) (richs)
+
2006/06/02
----------
- Updated Estonian localization and moved from ee to et
View
6 config/main.inc.php.dist
@@ -117,6 +117,10 @@ $rcmail_config['product_name'] = 'RoundCube Webmail';
// only list folders within this path
$rcmail_config['imap_root'] = '';
+// store draft message is this mailbox
+// leave blank if draft messages should not be stored
+$rcmail_config['drafts_mbox'] = 'Drafts';
+
// store sent message is this mailbox
// leave blank if sent messages should not be stored
$rcmail_config['sent_mbox'] = 'Sent';
@@ -202,4 +206,4 @@ $rcmail_config['javascript_config'] = array('read_when_deleted', 'flag_for_delet
// end of config file
-?>
+?>
View
10 program/include/rcube_imap.inc
@@ -1840,14 +1840,14 @@ class rcube_imap
return array_merge($a_defaults, $a_out);
}
- function get_id($uid)
+ function get_id($uid, $mbox_name=NULL)
{
- return $this->_uid2id($uid);
+ return $this->_uid2id($uid, $mbox_name);
}
- function get_uid($id)
+ function get_uid($id,$mbox_name=NULL)
{
- return $this->_id2uid($id);
+ return $this->_id2uid($id, $mbox_name);
}
function _uid2id($uid, $mbox_name=NULL)
@@ -2086,4 +2086,4 @@ function quoted_printable_encode($input="", $line_max=76, $space_conv=false)
return trim($output);
}
-?>
+?>
View
72 program/js/app.js
@@ -146,6 +146,8 @@ function rcube_webmail()
this.enable_command('add-attachment', 'send-attachment', 'send', true);
if (this.env.spellcheck)
this.enable_command('spellcheck', true);
+ if (this.env.drafts_mailbox)
+ this.enable_command('savedraft', true);
}
if (this.env.messagecount)
@@ -676,7 +678,17 @@ function rcube_webmail()
{
var uid = this.get_single_uid();
if (uid && (!this.env.uid || uid != this.env.uid))
- this.show_message(uid);
+ {
+ if (this.env.mailbox==this.env.drafts_mailbox)
+ {
+ this.set_busy(true);
+ location.href = this.env.comm_path+'&_action=compose&_draft_uid='+uid+'&_mbox='+escape(this.env.mailbox);
+ }
+ else
+ {
+ this.show_message(uid);
+ }
+ }
}
else if (this.task=='addressbook')
{
@@ -833,9 +845,14 @@ function rcube_webmail()
case 'compose':
var url = this.env.comm_path+'&_action=compose';
-
+
+ if (this.task=='mail' && this.env.mailbox==this.env.drafts_mailbox)
+ {
+ var uid = this.get_single_uid();
+ url += '&_draft_uid='+uid+'&_mbox='+escape(this.env.mailbox);
+ }
// modify url if we're in addressbook
- if (this.task=='addressbook')
+ else if (this.task=='addressbook')
{
url = this.get_task_url('mail', url);
var a_cids = new Array();
@@ -886,6 +903,19 @@ function rcube_webmail()
this.env.spellcheck.spellCheck(this.env.spellcheck.check_link);
break;
+ case 'savedraft':
+ if (!this.gui_objects.messageform)
+ break;
+
+ // if saving Drafts is disabled in main.inc.php
+ if (!this.env.drafts_mailbox)
+ break;
+
+ this.set_busy(true, 'savingmessage');
+ var form = this.gui_objects.messageform;
+ form.submit();
+ break;
+
case 'send':
if (!this.gui_objects.messageform)
break;
@@ -896,6 +926,7 @@ function rcube_webmail()
// all checks passed, send message
this.set_busy(true, 'sendingmessage');
var form = this.gui_objects.messageform;
+ form._draft.value='';
form.submit();
break;
@@ -1171,7 +1202,15 @@ function rcube_webmail()
// row was double clicked
if (this.task=='mail' && this.list_rows && this.list_rows[id].clicked && this.in_selection(id))
{
- this.show_message(id);
+ if (this.env.mailbox==this.env.drafts_mailbox)
+ {
+ this.set_busy(true);
+ location.href = this.env.comm_path+'&_action=compose&_draft_uid='+id+'&_mbox='+escape(this.env.mailbox);
+ }
+ else
+ {
+ this.show_message(id);
+ }
return false;
}
else if (this.task=='addressbook')
@@ -1293,8 +1332,18 @@ function rcube_webmail()
// enable/disable commands for message
if (this.task=='mail')
{
- this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
- this.enable_command('delete', 'moveto', this.selection.length>0 ? true : false);
+ if (this.env.mailbox==this.env.drafts_mailbox)
+ {
+ //alert(this.env.mailbox);
+ //this.disable_command('reply', 'reply-all', 'forward', 'print', 'moveto');
+ this.enable_command('show', selected);
+ this.enable_command('delete', this.selection.length>0 ? true : false);
+ }
+ else
+ {
+ this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected);
+ this.enable_command('delete', 'moveto', this.selection.length>0 ? true : false);
+ }
}
else if (this.task=='addressbook')
{
@@ -1907,12 +1956,15 @@ function rcube_webmail()
var message = input_message ? input_message.value : '';
var sig, p;
+ if (!this.env.identity)
+ this.env.identity = id
+
// remove the 'old' signature
if (this.env.identity && this.env.signatures && this.env.signatures[this.env.identity])
{
sig = this.env.signatures[this.env.identity];
- if (sig.indexOf('-- ')!=0)
- sig = '-- \n'+sig;
+ if (sig.indexOf('--')!=0)
+ sig = '--\n'+sig;
p = message.lastIndexOf(sig);
if (p>=0)
@@ -1923,8 +1975,8 @@ function rcube_webmail()
if (this.env.signatures && this.env.signatures[id])
{
sig = this.env.signatures[id];
- if (sig.indexOf('-- ')!=0)
- sig = '-- \n'+sig;
+ if (sig.indexOf('--')!=0)
+ sig = '--\n'+sig;
message += '\n'+sig;
}
View
2 program/localization/cn/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = '地址薄';
// mailbox names
$labels['inbox'] = '收件箱';
+$labels['drafts'] = '草稿';
$labels['sent'] = '发件箱';
$labels['trash'] = '垃圾桶';
$labels['drafts'] = '草稿';
@@ -113,6 +114,7 @@ $labels['quota'] = '空间使用';
// message compose
$labels['compose'] = '写新邮件';
+$labels['savemessage'] = '保存这份草稿';
$labels['sendmessage'] = '立刻发送邮件';
$labels['addattachment'] = '添加附件';
View
4 program/localization/cn/messages.inc
@@ -41,6 +41,10 @@ $messages['sendingmessage'] = '正在发送邮件...';
$messages['messagesent'] = '邮件发送成功';
+$messages['savingmessage'] = '挽救消息...';
+
+$messages['messagesaved'] = '消息被保存对草稿';
+
$messages['successfullysaved'] = '保存成功';
$messages['addedsuccessfully'] = '联系信息成功增加到地址薄';
View
2 program/localization/de_CH/labels.inc
@@ -34,6 +34,7 @@ $labels['addressbook'] = 'Adressbuch';
// mailbox names // E-Mail-Ordnernamen
$labels['inbox'] = 'Posteingang';
+$labels['drafts'] = 'Entwürfe';
$labels['sent'] = 'Gesendet';
$labels['trash'] = 'Gelöscht';
$labels['drafts'] = 'Vorlagen';
@@ -120,6 +121,7 @@ $labels['resetsearch'] = 'Löschen';
// message compose // Nachrichten erstellen
$labels['compose'] = 'Neue Nachricht verfassen';
+$labels['savemessage'] = 'Außer diesem Entwurf';
$labels['sendmessage'] = 'Nachricht jetzt senden';
$labels['addattachment'] = 'Datei anfügen';
$labels['charset'] = 'Zeichensatz';
View
4 program/localization/de_CH/messages.inc
@@ -38,6 +38,10 @@ $messages['sendingmessage'] = 'Nachricht wird gesendet...';
$messages['messagesent'] = 'Nachricht erfolgreich gesendet';
+$messages['savingmessage'] = 'Einsparunganzeige...';
+
+$messages['messagesaved'] = 'Anzeige gespeichert zu den Entwürfen';
+
$messages['successfullysaved'] = 'Erfolgreich gespeichert';
$messages['addedsuccessfully'] = 'Kontakt zum Adressbuch hinzugefügt';
View
2 program/localization/de_DE/labels.inc
@@ -35,6 +35,7 @@ $labels['addressbook'] = 'Adressbuch';
// mailbox names // E-Mail-Ordnernamen
$labels['inbox'] = 'Posteingang';
+$labels['drafts'] = 'Entwürfe';
$labels['sent'] = 'Gesendet';
$labels['trash'] = 'Gelöscht';
$labels['drafts'] = 'Entwürfe';
@@ -121,6 +122,7 @@ $labels['resetsearch'] = 'Löschen';
// message compose // Nachrichten erstellen
$labels['compose'] = 'Neue Nachricht verfassen';
+$labels['savemessage'] = 'Außer diesem Entwurf';
$labels['sendmessage'] = 'Nachricht jetzt senden';
$labels['addattachment'] = 'Datei anfügen';
$labels['charset'] = 'Zeichensatz';
View
4 program/localization/de_DE/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'Nachricht wird gesendet...';
$messages['messagesent'] = 'Nachricht erfolgreich gesendet';
+$messages['savingmessage'] = 'Einsparunganzeige...';
+
+$messages['messagesaved'] = 'Anzeige gespeichert zu den Entwürfen';
+
$messages['successfullysaved'] = 'Erfolgreich gespeichert';
$messages['addedsuccessfully'] = 'Kontakt zum Adressbuch hinzugefügt';
View
2 program/localization/el/labels.inc
@@ -34,6 +34,7 @@ $labels['addressbook'] = 'Βιβλίο διευθύνσεων';
// mailbox names
$labels['inbox'] = 'Εισερχόμενα';
+$labels['drafts'] = 'Σχέδια';
$labels['sent'] = 'Απεσταλμένα';
$labels['trash'] = 'Κάδος αχρήστων';
$labels['drafts'] = 'Προσχέδια';
@@ -113,6 +114,7 @@ $labels['unread'] = 'Αδιάβαστα';
// message compose
$labels['compose'] = 'Σύνθεση μηνύματος';
+$labels['savemessage'] = 'Εκτός από αυτό το σχέδιο';
$labels['sendmessage'] = 'Αποστολή του μηνύματος τώρα';
$labels['addattachment'] = 'Επισύναψη αρχείου';
$labels['attachments'] = 'Συνημμένα';
View
4 program/localization/el/messages.inc
@@ -42,6 +42,10 @@ $messages['sendingmessage'] = 'Αποστολή μηνύματος...';
$messages['messagesent'] = 'Το μήνυμα στάλθηκε επιτυχώς';
+$messages['savingmessage'] = 'Μήνυμα αποταμίευσης...';
+
+$messages['messagesaved'] = 'Μήνυμα που σώζεται στα σχέδια';
+
$messages['successfullysaved'] = 'Αποθηκεύτηκε επιτυχώς';
$messages['addedsuccessfully'] = 'Η επαφή προστέθηκε επιτυχώς στο βιβλίο διευθύνσεων';
View
2 program/localization/en_GB/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = 'Address Book';
// mailbox names
$labels['inbox'] = 'Inbox';
+$labels['drafts'] = 'Drafts';
$labels['sent'] = 'Sent';
$labels['trash'] = 'Deleted Items';
$labels['drafts'] = 'Drafts';
@@ -115,6 +116,7 @@ $labels['quota'] = 'Disk usage';
// message compose
$labels['compose'] = 'Compose a message';
+$labels['savemessage'] = 'Save this draft';
$labels['sendmessage'] = 'Send the message now';
$labels['addattachment'] = 'Attach a file';
$labels['charset'] = 'Charset';
View
4 program/localization/en_GB/messages.inc
@@ -38,6 +38,10 @@ $messages['loadingdata'] = 'Loading data...';
$messages['messagesent'] = 'Message sent successfully';
+$messages['savingmessage'] = 'Saving message...';
+
+$messages['messagesaved'] = 'Message saved to Drafts';
+
$messages['successfullysaved'] = 'Successfully saved';
$messages['addedsuccessfully'] = 'Contact added successfully to address book';
View
3 program/localization/en_US/labels.inc
@@ -33,9 +33,9 @@ $labels['addressbook'] = 'Address Book';
// mailbox names
$labels['inbox'] = 'Inbox';
+$labels['drafts'] = 'Drafts';
$labels['sent'] = 'Sent';
$labels['trash'] = 'Trash';
-$labels['drafts'] = 'Drafts';
$labels['junk'] = 'Junk';
// message listing
@@ -120,6 +120,7 @@ $labels['resetsearch'] = 'Reset search';
// message compose
$labels['compose'] = 'Compose a message';
+$labels['savemessage'] = 'Save this draft';
$labels['sendmessage'] = 'Send the message now';
$labels['addattachment'] = 'Attach a file';
$labels['charset'] = 'Charset';
View
4 program/localization/en_US/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'Sending message...';
$messages['messagesent'] = 'Message sent successfully';
+$messages['savingmessage'] = 'Saving message...';
+
+$messages['messagesaved'] = 'Message saved to Drafts';
+
$messages['successfullysaved'] = 'Successfully saved';
$messages['addedsuccessfully'] = 'Contact added successfully to address book';
View
2 program/localization/es/labels.inc
@@ -37,6 +37,7 @@ $labels['addressbook'] = 'Contactos';
// mailbox names
$labels['inbox'] = 'Entrada';
+$labels['drafts'] = 'Bosquejos';
$labels['sent'] = 'Enviados';
$labels['trash'] = 'Papelera';
$labels['drafts'] = 'Borradores';
@@ -118,6 +119,7 @@ $labels['quota'] = 'Uso de disco';
// message compose
$labels['compose'] = 'Escribir un mensaje';
+$labels['savemessage'] = 'Excepto este bosquejo';
$labels['sendmessage'] = 'Enviar ahora el mensaje';
$labels['addattachment'] = 'Añadir un fichero';
$labels['charset'] = 'Codigo';
View
4 program/localization/es/messages.inc
@@ -47,6 +47,10 @@ $messages['sendingmessage'] = 'Enviando mensaje...';
$messages['messagesent'] = 'Mensaje enviado correctamente';
+$messages['savingmessage'] = 'Mensaje del ahorro...';
+
+$messages['messagesaved'] = 'Mensaje ahorrado a los bosquejos';
+
$messages['successfullysaved'] = 'guardado correctamente';
$messages['addedsuccessfully'] = 'Contacto añadido correctamente a la libreta de direcciones';
View
2 program/localization/fr/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = 'Carnet d\'adresses';
// mailbox names
$labels['inbox'] = 'Boîte de réception';
+$labels['drafts'] = 'Ébauches';
$labels['sent'] = 'Messages envoyés';
$labels['trash'] = 'Corbeille';
$labels['drafts'] = 'Brouillons';
@@ -115,6 +116,7 @@ $labels['quota'] = 'Utilisation Disque';
// message compose
$labels['compose'] = 'Composer un nouveau message';
+$labels['savemessage'] = 'Économiser cette ébauche';
$labels['sendmessage'] = 'Envoyer le message maintenant';
$labels['addattachment'] = 'Joindre un fichier';
$labels['charset'] = 'Encodage';
View
4 program/localization/fr/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'Message en cours d\'envoi...';
$messages['messagesent'] = 'Message envoyé';
+$messages['savingmessage'] = 'Message d\'économie...';
+
+$messages['messagesaved'] = 'Message sauvé aux ébauches';
+
$messages['successfullysaved'] = 'Sauvegarde effectuée';
$messages['addedsuccessfully'] = 'Contact ajouté dans le carnet d\'adresses';
View
2 program/localization/it/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = 'Rubrica';
// mailbox names
$labels['inbox'] = 'Posta in arrivo';
+$labels['drafts'] = 'Brutte copie';
$labels['sent'] = 'Inviata';
$labels['trash'] = 'Cestino';
$labels['drafts'] = 'Bozze';
@@ -115,6 +116,7 @@ $labels['quota'] = 'Utilizzo spazio';
// message compose
$labels['compose'] = 'Componi un messaggio';
+$labels['savemessage'] = 'Risparmi questa brutta copia';
$labels['sendmessage'] = 'Invia il messaggio adesso';
$labels['addattachment'] = 'Allega un file';
$labels['charset'] = 'Set di caratteri';
View
4 program/localization/it/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'Invio messaggio in corso...';
$messages['messagesent'] = 'Messaggio inviato correttamente';
+$messages['savingmessage'] = 'Messaggio di Saving...';
+
+$messages['messagesaved'] = 'Messaggio conservato alle brutte copie';
+
$messages['successfullysaved'] = 'Salvato correttamente';
$messages['addedsuccessfully'] = 'Contatto aggiunto alla rubrica';
View
2 program/localization/ja/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = 'アドレス帳';
// mailbox names
$labels['inbox'] = '受信箱';
+$labels['drafts'] = '草案';
$labels['sent'] = '送信箱';
$labels['trash'] = 'ごみ箱';
$labels['drafts'] = '草稿';
@@ -115,6 +116,7 @@ $labels['quota'] = 'ディスク使用量';
// message compose
$labels['compose'] = 'メッセージを作成する';
+$labels['savemessage'] = 'この草案を救いなさい';
$labels['sendmessage'] = 'メッセージを今すぐ送信する';
$labels['addattachment'] = 'ファイルを添付する';
$labels['charset'] = '文字エンコード';
View
4 program/localization/ja/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'メッセージの送信中です...';
$messages['messagesent'] = 'メッセージの送信に成功しました。';
+$messages['savingmessage'] = 'セービングメッセージ...';
+
+$messages['messagesaved'] = 'メッセージは草案に救った';
+
$messages['successfullysaved'] = '保存に成功しました。';
$messages['addedsuccessfully'] = '連絡先をアドレス帳への追加に成功しました。';
View
2 program/localization/pt_BR/labels.inc
@@ -32,6 +32,7 @@ $labels['addressbook'] = 'Catálogo de endereços';
// Nome das pastas de correio
$labels['inbox'] = 'Caixa de entrada';
+$labels['drafts'] = 'Esboços';
$labels['sent'] = 'Enviados';
$labels['trash'] = 'Lixeira';
$labels['drafts'] = 'Rascunhos';
@@ -114,6 +115,7 @@ $labels['quota'] = 'Utilização';
// message compose
$labels['compose'] = 'Escrever mensagem';
+$labels['savemessage'] = 'Excepto este esboço';
$labels['sendmessage'] = 'Enviar';
$labels['addattachment'] = 'Anexar';
$labels['charset'] = 'Charset';
View
4 program/localization/pt_BR/messages.inc
@@ -36,6 +36,10 @@ $messages['loadingdata'] = 'Carregando informações...';
$messages['messagesent'] = 'Mensagem enviada';
+$messages['savingmessage'] = 'Mensagem do Saving...';
+
+$messages['messagesaved'] = 'Mensagem conservada aos esboços';
+
$messages['successfullysaved'] = 'Salvo com sucesso';
$messages['addedsuccessfully'] = 'Contato incluído com sucesso';
View
2 program/localization/pt_PT/labels.inc
@@ -31,6 +31,7 @@ $labels['addressbook'] = 'Catálogo de endereços';
// Nome das pastas de correio
$labels['inbox'] = 'Caixa de entrada';
+$labels['drafts'] = 'Esboços';
$labels['sent'] = 'Enviados';
$labels['trash'] = 'Lixeira';
$labels['drafts'] = 'Rascunhos';
@@ -113,6 +114,7 @@ $labels['quota'] = 'Quota de espaço';
// message compose
$labels['compose'] = 'Escrever mensagem';
+$labels['savemessage'] = 'Excepto este esboço';
$labels['sendmessage'] = 'Enviar';
$labels['addattachment'] = 'Anexar';
$labels['charset'] = 'Charset';
View
4 program/localization/pt_PT/messages.inc
@@ -39,6 +39,10 @@ $messages['sendingmessage'] = 'A enviar mensagem...';
$messages['messagesent'] = 'Mensagem enviada';
+$messages['savingmessage'] = 'Mensagem do Saving...';
+
+$messages['messagesaved'] = 'Mensagem conservada aos esboços';
+
$messages['successfullysaved'] = 'Ficheiro gravado';
$messages['addedsuccessfully'] = 'Contacto adicionado ao catálogo de endereços';
View
2 program/localization/ru/labels.inc
@@ -33,6 +33,7 @@ $labels['addressbook'] = 'Контакты';
// mailbox names
$labels['inbox'] = 'Входящие';
+$labels['drafts'] = 'Проекты';
$labels['sent'] = 'Отправленные';
$labels['trash'] = 'Корзина';
$labels['drafts'] = 'Черновики';
@@ -120,6 +121,7 @@ $labels['resetsearch'] = 'Сброс';
// message compose
$labels['compose'] = 'Написать сообщение';
+$labels['savemessage'] = 'За исключением этого проекта';
$labels['sendmessage'] = 'Отправить сейчас';
$labels['addattachment'] = 'Добавить вложение';
$labels['charset'] = 'Кодировка';
View
4 program/localization/ru/messages.inc
@@ -40,6 +40,10 @@ $messages['sendingmessage'] = 'Отправка сообщения...';
$messages['messagesent'] = 'Сообщение отправлено';
+$messages['savingmessage'] = 'Сообщение сбережения...';
+
+$messages['messagesaved'] = 'Сообщение сохраненное к проектам';
+
$messages['successfullysaved'] = 'Сохранено';
$messages['addedsuccessfully'] = 'Контакт добавлен в список контактов';
View
129 program/steps/mail/compose.inc
@@ -26,6 +26,7 @@ require_once('Mail/mimeDecode.php');
$MESSAGE_FORM = NULL;
$REPLY_MESSAGE = NULL;
$FORWARD_MESSAGE = NULL;
+$DRAFT_MESSAGE = NULL;
if (!is_array($_SESSION['compose']))
@@ -33,12 +34,12 @@ if (!is_array($_SESSION['compose']))
// add some labels to client
-rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'sendingmessage', 'notsentwarning');
+rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'savingmessage', 'messagesaved');
-if ($_GET['_reply_uid'] || $_GET['_forward_uid'])
+if ($_GET['_reply_uid'] || $_GET['_forward_uid'] || $_GET['_draft_uid'])
{
- $msg_uid = $_GET['_reply_uid'] ? $_GET['_reply_uid'] : $_GET['_forward_uid'];
+ $msg_uid = ($_GET['_reply_uid'] ? $_GET['_reply_uid'] : ($_GET['_forward_uid'] ? $_GET['_forward_uid'] : $_GET['_draft_uid']));
// similar as in program/steps/mail/show.inc
$MESSAGE = array();
@@ -53,7 +54,7 @@ if ($_GET['_reply_uid'] || $_GET['_forward_uid'])
$MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);
$MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']);
-
+
if ($_GET['_reply_uid'])
{
$REPLY_MESSAGE = &$MESSAGE;
@@ -65,22 +66,27 @@ if ($_GET['_reply_uid'] || $_GET['_forward_uid'])
if ($_GET['_all'])
$REPLY_MESSAGE['reply_all'] = 1;
+
}
- else
+ else if ($_GET['_forward_uid'])
{
$FORWARD_MESSAGE = $MESSAGE;
$_SESSION['compose']['forward_uid'] = $_GET['_forward_uid'];
}
- }
-
+ else
+ {
+ $DRAFT_MESSAGE = $MESSAGE;
+ $_SESSION['compose']['draft_uid'] = $_GET['_draft_uid'];
+ }
+ }
/****** compose mode functions ********/
function rcmail_compose_headers($attrib)
{
- global $IMAP, $REPLY_MESSAGE, $DB;
+ global $IMAP, $REPLY_MESSAGE, $DRAFT_MESSAGE, $DB;
static $sa_recipients = array();
list($form_start, $form_end) = get_form_tags($attrib);
@@ -139,8 +145,7 @@ function rcmail_compose_headers($attrib)
break;
}
-
-
+
if ($fname && !empty($_POST[$fname]))
$fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE);
else if ($header && is_object($REPLY_MESSAGE['headers']))
@@ -182,6 +187,19 @@ function rcmail_compose_headers($attrib)
}
}
}
+ else if ($header && is_object($DRAFT_MESSAGE['headers']))
+ {
+ // get drafted headers
+ if ($header=='to' && $DRAFT_MESSAGE['headers']->to)
+ $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->to);
+
+ if ($header=='cc' && $DRAFT_MESSAGE['headers']->cc)
+ $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->cc);
+
+ if ($header=='bcc' && $DRAFT_MESSAGE['headers']->bcc)
+ $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->bcc);
+
+ }
if ($fname && $field_type)
@@ -199,7 +217,7 @@ function rcmail_compose_headers($attrib)
if ($form_start)
$out = $form_start.$out;
-
+
return $out;
}
@@ -207,7 +225,7 @@ function rcmail_compose_headers($attrib)
function rcmail_compose_header_from($attrib)
{
- global $IMAP, $REPLY_MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME;
+ global $IMAP, $REPLY_MESSAGE, $DRAFT_MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME;
// pass the following attributes to the form class
$field_attrib = array('name' => '_from');
@@ -269,6 +287,10 @@ function rcmail_compose_header_from($attrib)
if ($REPLY_MESSAGE && is_array($REPLY_MESSAGE['FROM']))
$REPLY_MESSAGE['FROM'][] = $sql_arr['email'];
+
+ if (strstr($DRAFT_MESSAGE['headers']->from,$sql_arr['email']))
+ $from_id = $sql_arr['identity_id'];
+
}
// overwrite identity selection with post parameter
@@ -286,7 +308,7 @@ function rcmail_compose_header_from($attrib)
$input_from = new textfield($field_attrib);
$out = $input_from->show($_POST['_from']);
}
-
+
if ($form_start)
$out = $form_start.$out;
@@ -297,7 +319,7 @@ function rcmail_compose_header_from($attrib)
function rcmail_compose_body($attrib)
{
- global $CONFIG, $OUTPUT, $REPLY_MESSAGE, $FORWARD_MESSAGE, $JS_OBJECT_NAME;
+ global $CONFIG, $OUTPUT, $REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE, $JS_OBJECT_NAME;
list($form_start, $form_end) = get_form_tags($attrib);
unset($attrib['form']);
@@ -329,8 +351,32 @@ function rcmail_compose_body($attrib)
if (strlen($body))
$body = rcmail_create_forward_body($body);
}
+
+ // forward message body inline
+ else if (is_array($DRAFT_MESSAGE['parts']))
+ {
+ $body = rcmail_first_text_part($DRAFT_MESSAGE['parts']);
+ if (strlen($body))
+ $body = rcmail_create_draft_body($body);
+ }
$out = $form_start ? "$form_start\n" : '';
+
+ // Check if a previous save was done so we can delete it upon the next save
+ if (!empty($_POST['_draft_newsaveid']))
+ $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => $_POST['_draft_newsaveid']));
+ else if (strlen($DRAFT_MESSAGE['headers']->messageID) > 6)
+ $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) ));
+
+ if ($saveid)
+ $out .= $saveid->show();
+
+ $newsaveid = new hiddenfield(array('name' => '_draft_newsaveid', 'value' => sprintf('%s@%s', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']) ));
+ $out .= $newsaveid->show();
+
+ $drafttoggle = new hiddenfield(array('name' => '_draft', 'value' => 'yes'));
+ $out .= $drafttoggle->show();
+
$out .= $textarea->show($body);
$out .= $form_end ? "\n$form_end" : '';
@@ -456,11 +502,57 @@ function rcmail_create_forward_body($body)
return $prefix.$body;
}
+function rcmail_create_draft_body($body)
+ {
+ global $IMAP, $DRAFT_MESSAGE;
+
+ // add attachments
+ if (!isset($_SESSION['compose']['forward_attachments']) && is_array($DRAFT_MESSAGE['parts']) && sizeof($DRAFT_MESSAGE['parts'])>1)
+ {
+ $temp_dir = rcmail_create_compose_tempdir();
+
+ if (!is_array($_SESSION['compose']['attachments']))
+ $_SESSION['compose']['attachments'] = array();
+
+ foreach ($DRAFT_MESSAGE['parts'] as $part)
+ {
+ if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] ||
+ (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name'])))
+ {
+ $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
+ if ($fp = fopen($tmp_path, 'w'))
+ {
+ fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding']));
+ fclose($fp);
+
+ if ($part->d_parameters['filename'])
+ $_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'],
+ 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary,
+ 'path' => $tmp_path);
+
+ else if ($part->ctype_parameters['name'])
+ $_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'],
+ 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary,
+ 'path' => $tmp_path);
+
+ else if ($part->headers['content-description'])
+ $_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'],
+ 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary,
+ 'path' => $tmp_path);
+ }
+ }
+ }
+
+ $_SESSION['compose']['forward_attachments'] = TRUE;
+ }
+
+ return $body;
+ }
function rcmail_compose_subject($attrib)
{
- global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE;
+ global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE;
list($form_start, $form_end) = get_form_tags($attrib);
unset($attrib['form']);
@@ -492,6 +584,9 @@ function rcmail_compose_subject($attrib)
$subject = 'Fwd: '.$FORWARD_MESSAGE['subject'];
}
+ // creeate a draft-subject
+ else if (isset($DRAFT_MESSAGE['subject']))
+ $subject = $DRAFT_MESSAGE['subject'];
$out = $form_start ? "$form_start\n" : '';
$out .= $textfield->show($subject);
@@ -619,7 +714,7 @@ function get_form_tags($attrib)
{
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
$hiddenfields->add(array('name' => '_action', 'value' => 'send'));
-
+
$form_start = empty($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
$form_start .= "\n$SESS_HIDDEN_FIELD\n";
$form_start .= $hiddenfields->show();
@@ -675,4 +770,4 @@ if ($DB->num_rows($sql_result))
parse_template('compose');
-?>
+?>
View
5 program/steps/mail/func.inc
@@ -64,6 +64,9 @@ $OUTPUT->add_script(sprintf("%s.set_env('mailbox', '%s');", $JS_OBJECT_NAME, $IM
if ($CONFIG['trash_mbox'])
$OUTPUT->add_script(sprintf("%s.set_env('trash_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['trash_mbox']));
+if ($CONFIG['drafts_mbox'])
+ $OUTPUT->add_script(sprintf("%s.set_env('drafts_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['drafts_mbox']));
+
// return the mailboxlist in HTML
@@ -1484,4 +1487,4 @@ function rcmail_compose_cleanup()
}
-?>
+?>
View
215 program/steps/mail/sendmail.inc
@@ -62,8 +62,16 @@ function rcmail_get_identity($id)
return FALSE;
}
-
-
+if (strlen($_POST['_draft_saveid']) > 3) {
+ $olddraftmessageid = $_POST['_draft_saveid'];
+}
+if (strlen($_POST['_draft_newsaveid']) > 3) {
+ $newdraftmessageid = $_POST['_draft_newsaveid'];
+}
+if ($_POST['_draft']) {
+ $savedraft = 1;
+}
+
/****** check submission and compose message ********/
@@ -94,8 +102,12 @@ $from = $identity_arr['mailto'];
$first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto;
-// create unique message-id
-$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail')), $_SESSION['imap_host']);
+// try the message-id submitted by the compose form
+if ($newdraftmessageid) {
+ $message_id = sprintf('<%s>',$newdraftmessageid);
+} else {
+ $message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']);
+}
// compose headers array
@@ -213,119 +225,142 @@ $msg_subject = $headers['Subject'];
if ($MBSTRING && function_exists("mb_encode_mimeheader"))
$headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset);
-// send thru SMTP server using cusotm SMTP library
-if ($CONFIG['smtp_server'])
- {
- // generate list of recipients
- $a_recipients = array($mailto);
-
- if (strlen($headers['Cc']))
- $a_recipients[] = $headers['Cc'];
- if (strlen($headers['Bcc']))
- $a_recipients[] = $headers['Bcc'];
-
- // clean Bcc from header for recipients
- $send_headers = $headers;
- unset($send_headers['Bcc']);
-
- // generate message headers
- $header_str = $MAIL_MIME->txtHeaders($send_headers);
-
- // send message
- $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body);
+// Begin SMTP Delivery Block
+if (!$savedraft) {
- // log error
- if (!$sent)
+ // send thru SMTP server using custom SMTP library
+ if ($CONFIG['smtp_server'])
{
- raise_error(array('code' => 800,
- 'type' => 'smtp',
- 'line' => __LINE__,
- 'file' => __FILE__,
- 'message' => "SMTP error: $SMTP_ERROR"), TRUE, FALSE);
+ // generate list of recipients
+ $a_recipients = array($mailto);
+
+ if (strlen($headers['Cc']))
+ $a_recipients[] = $headers['Cc'];
+ if (strlen($headers['Bcc']))
+ $a_recipients[] = $headers['Bcc'];
+
+ // clean Bcc from header for recipients
+ $send_headers = $headers;
+ unset($send_headers['Bcc']);
+
+ // generate message headers
+ $header_str = $MAIL_MIME->txtHeaders($send_headers);
+
+ // send message
+ $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body);
+
+ // log error
+ if (!$sent)
+ {
+ raise_error(array('code' => 800,
+ 'type' => 'smtp',
+ 'line' => __LINE__,
+ 'file' => __FILE__,
+ 'message' => "SMTP error: $SMTP_ERROR"), TRUE, FALSE);
+ }
}
- }
-
-// send mail using PHP's mail() function
-else
- {
- // unset some headers because they will be added by the mail() function
- $headers_enc = $MAIL_MIME->headers($headers);
- $headers_php = $MAIL_MIME->_headers;
- unset($headers_php['To'], $headers_php['Subject']);
- // reset stored headers and overwrite
- $MAIL_MIME->_headers = array();
- $header_str = $MAIL_MIME->txtHeaders($headers_php);
-
- if (ini_get('safe_mode'))
- $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
+ // send mail using PHP's mail() function
else
- $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
- }
-
-
-// return to compose page if sending failed
-if (!$sent)
- {
- show_message("sendingfailed", 'error');
- rcmail_overwrite_action('compose');
- return;
- }
-
+ {
+ // unset some headers because they will be added by the mail() function
+ $headers_enc = $MAIL_MIME->headers($headers);
+ $headers_php = $MAIL_MIME->_headers;
+ unset($headers_php['To'], $headers_php['Subject']);
+
+ // reset stored headers and overwrite
+ $MAIL_MIME->_headers = array();
+ $header_str = $MAIL_MIME->txtHeaders($headers_php);
+
+ if (ini_get('safe_mode'))
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
+ else
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
+ }
+
+
+ // return to compose page if sending failed
+ if (!$sent)
+ {
+ show_message("sendingfailed", 'error');
+ rcmail_overwrite_action('compose');
+ return;
+ }
+
+
+ // set repliead flag
+ if ($_SESSION['compose']['reply_uid'])
+ $IMAP->set_flag($_SESSION['compose']['reply_uid'], 'ANSWERED');
-// set repliead flag
-if ($_SESSION['compose']['reply_uid'])
- $IMAP->set_flag($_SESSION['compose']['reply_uid'], 'ANSWERED');
+ } // End of SMTP Delivery Block
+// Determine which folder to save message
+if ($savedraft) {
+ $store_target = 'drafts_mbox';
+} else {
+ $store_target = 'sent_mbox';
+}
-// copy message to sent folder
-if ($CONFIG['sent_mbox'])
+if ($CONFIG[$store_target])
{
// create string of complete message headers
$header_str = $MAIL_MIME->txtHeaders($headers);
// check if mailbox exists
- if (!in_array_nocase($CONFIG['sent_mbox'], $IMAP->list_mailboxes()))
- $sent_folder = $IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE);
+ if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes()))
+ $store_folder = $IMAP->create_mailbox($CONFIG[$store_target], TRUE);
else
- $sent_folder = TRUE;
+ $store_folder = TRUE;
// append message to sent box
- if ($sent_folder)
- $saved = $IMAP->save_message($CONFIG['sent_mbox'], $header_str."\r\n".$msg_body);
+ if ($store_folder)
+ $saved = $IMAP->save_message($CONFIG[$store_target], $header_str."\r\n".$msg_body);
// raise error if saving failed
if (!$saved)
raise_error(array('code' => 800,
'type' => 'imap',
'file' => __FILE__,
- 'message' => "Could not save message in $CONFIG[sent_mbox]"), TRUE, FALSE);
+ 'message' => "Could not save message in $CONFIG[$store_target]"), TRUE, FALSE);
+
+ if ($olddraftmessageid) {
+ // delete previous saved draft
+ $a_deleteid = $IMAP->search($CONFIG['drafts_mbox'],'HEADER Message-ID',$olddraftmessageid);
+ $deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0],$CONFIG['drafts_mbox']),$CONFIG['drafts_mbox']);
+
+ if (!$deleted)
+ raise_error(array('code' => 800,
+ 'type' => 'imap',
+ 'file' => __FILE__,
+ 'message' => "Could not delete message from ".$CONFIG['drafts_mbox']), TRUE, FALSE);
+ }
}
-
-// log mail sending
-if ($CONFIG['smtp_log'])
+if ($savedraft)
+ {
+ show_message('messagesaved', 'confirmation');
+ rcmail_overwrite_action('compose');
+ }
+else
{
- $log_entry = sprintf("[%s] User: %d on %s; Message for %s; Subject: %s\n",
- date("d-M-Y H:i:s O", mktime()),
- $_SESSION['user_id'],
- $_SERVER['REMOTE_ADDR'],
- $mailto,
- $msg_subject);
-
- if ($fp = @fopen($CONFIG['log_dir'].'/sendmail', 'a'))
+ if ($CONFIG['smtp_log'])
{
- fwrite($fp, $log_entry);
- fclose($fp);
+ $log_entry = sprintf("[%s] User: %d on %s; Message for %s; Subject: %s\n",
+ date("d-M-Y H:i:s O", mktime()),
+ $_SESSION['user_id'],
+ $_SERVER['REMOTE_ADDR'],
+ $mailto,
+ $msg_subject);
+
+ if ($fp = @fopen($CONFIG['log_dir'].'/sendmail', 'a'))
+ {
+ fwrite($fp, $log_entry);
+ fclose($fp);
+ }
}
+ show_message('messagesent', 'confirmation');
+ rcmail_compose_cleanup();
}
-// show confirmation
-show_message('messagesent', 'confirmation');
-
-
-// kill compose entry from session
-rcmail_compose_cleanup();
-
-?>
+?>
View
BIN skins/default/images/buttons/drafts_act.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN skins/default/images/buttons/drafts_pas.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN skins/default/images/icons/folder-drafts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 skins/default/mail.css
@@ -225,6 +225,11 @@
background-image: url(images/icons/folder-inbox.png);
}
+#mailboxlist li.drafts
+{
+ background-image: url(images/icons/folder-drafts.png);
+}
+
#mailboxlist li.sent
{
background-image: url(images/icons/folder-sent.png);
@@ -674,14 +679,14 @@ div.message-part pre
#priority-selector
{
position: absolute;
- left: 220px;
+ left: 280px;
top: 10px;
}
#receipt-selector
{
position: absolute;
- left: 390px;
+ left: 450px;
top: 10px;
}
View
8 skins/default/templates/compose.html
@@ -20,6 +20,13 @@
return false;
}
+function rcmail_auto_save()
+ {
+ rcmail.command('savedraft','',this);
+ self.setTimeout('rcmail_auto_save()',300000);
+ }
+self.setTimeout('rcmail_auto_save()',300000);
+
//-->
</script>
</head>
@@ -36,6 +43,7 @@
<!--<roundcube:button command="contacts" imageAct="/images/buttons/contacts_act.png" imagePas="/images/buttons/contacts_pas.png" width="32" height="32" title="addressbook" />-->
<roundcube:button command="spellcheck" imageAct="/images/buttons/spellcheck_act.png" imagePas="/images/buttons/spellcheck_pas.png" width="32" height="32" title="checkspelling" />
<roundcube:button command="add-attachment" imageAct="/images/buttons/attach_act.png" imagePas="/images/buttons/attach_pas.png" width="32" height="32" title="addattachment" />
+<roundcube:button command="savedraft" imageAct="/images/buttons/drafts_act.png" imagePas="/images/buttons/drafts_pas.png" width="32" height="32" title="savemessage" />
<div id="priority-selector">
<roundcube:label name="priority" />:&nbsp;<roundcube:object name="prioritySelector" form="form" />

0 comments on commit 1966c53

Please sign in to comment.
Something went wrong with that request. Please try again.