From a894ba5029a09fb9d0453b5cf9c944ce313f8a48 Mon Sep 17 00:00:00 2001 From: svncommit Date: Thu, 29 Jun 2006 23:41:40 +0000 Subject: Removeable attachments, Auto-default folder creation, bug fixes --- CHANGELOG | 9 ++++ UPGRADING | 1 + index.php | 2 +- program/include/rcube_imap.inc | 19 +++++-- program/js/app.js | 60 +++++++++++++++++------ program/localization/it/labels.inc | 4 +- program/localization/it/messages.inc | 4 +- program/steps/mail/compose.inc | 22 ++++++++- program/steps/mail/func.inc | 6 +-- program/steps/mail/getunread.inc | 4 +- program/steps/mail/move_del.inc | 2 +- program/steps/mail/upload.inc | 6 ++- program/steps/settings/manage_folders.inc | 4 +- skins/default/images/icons/remove-attachment.png | Bin 0 -> 775 bytes skins/default/mail.css | 7 +-- skins/default/templates/compose.html | 2 +- 16 files changed, 109 insertions(+), 43 deletions(-) create mode 100644 skins/default/images/icons/remove-attachment.png diff --git a/CHANGELOG b/CHANGELOG index ced9dba4a..ed07dce16 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,15 @@ CHANGELOG RoundCube Webmail --------------------------- +2006/06/29 (richs) +---------- +- Added ability to remove attachments (Feature #1436721) +- Default folders are now auto-created on first login (Feature #1471594) +- Fixed compatibility with folder apostrophes (e.g.: Joe's Folder) (Bug #1429458) +- Corrected Italian localizations +- Tweaked rename-folder form to clear after a rename + + 2006/06/26 (richs) ---------- - Added button to immediately check for new messages diff --git a/UPGRADING b/UPGRADING index fecc37753..36736f04f 100644 --- a/UPGRADING +++ b/UPGRADING @@ -123,6 +123,7 @@ form version 0.1-beta $rcmail_config['product_name'] = 'RoundCube Webmail'; $rcmail_config['read_when_deleted'] = TRUE; $rcmail_config['enable_spellcheck'] = TRUE; + $rcmail_config['protect_default_folders'] = TRUE; - replace the following line from /config/main.inc.php @include($_SERVER['HTTP_HOST'].'.inc.php'); with diff --git a/index.php b/index.php index 84e11aeba..88c712082 100644 --- a/index.php +++ b/index.php @@ -259,7 +259,7 @@ if ($_task=='mail') if ($_action=='upload') include('program/steps/mail/upload.inc'); - if ($_action=='compose') + if ($_action=='compose' || $_action=='remove-attachment') include('program/steps/mail/compose.inc'); if ($_action=='addcontact') diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index 16cfb522e..d825a35b0 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -362,13 +362,18 @@ class rcube_imap if (!is_array($a_folders) || !sizeof($a_folders)) $a_folders = array(); - // create INBOX if it does not exist - if (!in_array_nocase('INBOX', $a_folders)) + // create Default folders if they do not exist + global $CONFIG; + foreach ($CONFIG['default_imap_folders'] as $folder) { - $this->create_mailbox('INBOX', TRUE); - array_unshift($a_folders, 'INBOX'); + if (!in_array_nocase($folder, $a_folders)) + { + $this->create_mailbox($folder, TRUE); + $this->subscribe($folder); + } } + $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter); $a_mailbox_cache = array(); // write mailboxlist to cache @@ -991,6 +996,7 @@ class rcube_imap // append a mail message (source) to a specific mailbox function save_message($mbox_name, &$message) { + $mbox_name = stripslashes($mbox_name); $mailbox = $this->_mod_mailbox($mbox_name); // make sure mailbox exists @@ -1010,6 +1016,8 @@ class rcube_imap // move a message from one mailbox to another function move_message($uids, $to_mbox, $from_mbox='') { + $to_mbox = stripslashes($to_mbox); + $from_mbox = stripslashes($from_mbox); $to_mbox = $this->_mod_mailbox($to_mbox); $from_mbox = $from_mbox ? $this->_mod_mailbox($from_mbox) : $this->mailbox; @@ -1067,6 +1075,7 @@ class rcube_imap // mark messages as deleted and expunge mailbox function delete_message($uids, $mbox_name='') { + $mbox_name = stripslashes($mbox_name); $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; // convert the list of uids to array @@ -1114,6 +1123,7 @@ class rcube_imap // clear all messages in a specific mailbox function clear_mailbox($mbox_name=NULL) { + $mbox_name = stripslashes($mbox_name); $mailbox = !empty($mbox_name) ? $this->_mod_mailbox($mbox_name) : $this->mailbox; $msg_count = $this->_messagecount($mailbox, 'ALL'); @@ -1140,6 +1150,7 @@ class rcube_imap // send IMAP expunge command and clear cache function expunge($mbox_name='', $clear_cache=TRUE) { + $mbox_name = stripslashes($mbox_name); $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; return $this->_expunge($mailbox, $clear_cache); } diff --git a/program/js/app.js b/program/js/app.js index c61c20a63..fb103bf43 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -143,7 +143,7 @@ function rcube_webmail() if (this.env.action=='compose') { - this.enable_command('add-attachment', 'send-attachment', 'send', true); + this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true); if (this.env.spellcheck) this.enable_command('spellcheck', true); if (this.env.drafts_mailbox) @@ -945,6 +945,10 @@ function rcube_webmail() case 'send-attachment': this.upload_file(props) break; + + case 'remove-attachment': + this.remove_attachment(props); + break; case 'reply-all': case 'reply': @@ -1347,8 +1351,6 @@ function rcube_webmail() { 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); } @@ -1669,7 +1671,6 @@ function rcube_webmail() lock = true; this.set_busy(true, 'movingmessage'); } - // send request to server this.http_request('moveto', '_uid='+a_uids.join(',')+'&_mbox='+escape(this.env.mailbox)+'&_target_mbox='+escape(mbox)+'&_from='+(this.env.action ? this.env.action : ''), lock); }; @@ -2095,17 +2096,36 @@ function rcube_webmail() // add file name to attachment list // called from upload page - this.add2attachment_list = function(name) + this.add2attachment_list = function(name,content) { if (!this.gui_objects.attachmentlist) return false; var li = document.createElement('LI'); - li.innerHTML = name; + li.id = name; + li.innerHTML = content; this.gui_objects.attachmentlist.appendChild(li); return true; }; + this.remove_from_attachment_list = function(name) + { + if (!this.gui_objects.attachmentlist) + return false; + + var list = this.gui_objects.attachmentlist.getElementsByTagName("li"); + for (i=0;i \ No newline at end of file +?> diff --git a/program/localization/it/messages.inc b/program/localization/it/messages.inc index ae3c81819..92b7013c3 100644 --- a/program/localization/it/messages.inc +++ b/program/localization/it/messages.inc @@ -36,7 +36,7 @@ $messages['loading'] = 'Caricamento...'; $messages['loadingdata'] = 'Caricamento dati...'; -$messages['checkingmail'] = 'Controllando per vedere se c'è nuovi messaggi...'; +$messages['checkingmail'] = 'Controllo per vedere se ci sono nuovi messaggi...'; $messages['sendingmessage'] = 'Invio messaggio in corso...'; @@ -95,4 +95,4 @@ $messages['nocontactsreturned'] = 'Nessun contatto trovato'; $messages['nosearchname'] = 'Per favore, immetti un nome o un indirizzo e-mail'; -?> \ No newline at end of file +?> diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index ba80a54f1..6d4cf9a61 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -32,6 +32,20 @@ $DRAFT_MESSAGE = NULL; if (!is_array($_SESSION['compose'])) $_SESSION['compose'] = array('id' => uniqid(rand())); +// remove an attachment +if ($_action=='remove-attachment' && !empty($_GET['_filename'])) + { + if (is_array($_SESSION['compose']['attachments'])) + foreach ($_SESSION['compose']['attachments'] as $i => $attachment) + if ($attachment['name'] == $_GET['_filename']) + { + @unlink($attachment['path']); + unset($_SESSION['compose']['attachments'][$i]); + $commands = sprintf("parent.%s.remove_from_attachment_list('%s');\n", $JS_OBJECT_NAME, $_GET['_filename']); + rcube_remote_response($commands); + exit; + } + } // add some labels to client rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'savingmessage', 'messagesaved'); @@ -611,8 +625,13 @@ function rcmail_compose_attachment_list($attrib) if (is_array($_SESSION['compose']['attachments'])) { + if ($attrib['deleteicon']) + $button = sprintf('%s', $CONFIG['skin_path'], $attrib['deleteicon'], rcube_label('delete')); + else + $button = rcube_label('delete'); + foreach ($_SESSION['compose']['attachments'] as $i => $a_prop) - $out .= sprintf("
  • %s
  • \n", $a_prop['name']); + $out .= sprintf('
  • %s%s
  • ', $a_prop['name'], $JS_OBJECT_NAME, $a_prop['name'], rcube_label('deletefolder'), $button, $a_prop['name']); } $OUTPUT->add_script(sprintf("%s.gui_object('attachmentlist', '%s');", $JS_OBJECT_NAME, $attrib['id'])); @@ -663,7 +682,6 @@ function rcmail_compose_attachment_field($attrib) return $out; } - function rcmail_priority_selector($attrib) { list($form_start, $form_end) = get_form_tags($attrib); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index eac4e3747..7e2b3b28d 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -220,13 +220,13 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $m $class_name, $zebra_class, $unread_count ? ' unread' : '', - $folder['id']==$mbox_name ? ' selected' : '', + addslashes($folder['id'])==addslashes($mbox_name) ? ' selected' : '', $COMM_PATH, urlencode($folder['id']), $JS_OBJECT_NAME, - $folder['id'], + addslashes($folder['id']), $JS_OBJECT_NAME, - $folder['id'], + addslashes($folder['id']), $title, rep_specialchars_output($foldername, 'html', 'all')); diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc index 437e3aa00..ed4a5fb77 100644 --- a/program/steps/mail/getunread.inc +++ b/program/steps/mail/getunread.inc @@ -27,10 +27,10 @@ if (!empty($a_folders)) { foreach ($a_folders as $mbox_row) { - $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN')); + $commands = sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_row), $IMAP->messagecount($mbox_row, 'UNSEEN')); rcube_remote_response($commands, TRUE); } } exit; -?> \ No newline at end of file +?> diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index e4da207f4..116332a64 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -88,4 +88,4 @@ if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages) rcube_remote_response($commands); exit; -?> \ No newline at end of file +?> diff --git a/program/steps/mail/upload.inc b/program/steps/mail/upload.inc index 4cd929d0d..7fe7d3dcc 100644 --- a/program/steps/mail/upload.inc +++ b/program/steps/mail/upload.inc @@ -45,7 +45,9 @@ foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) 'mimetype' => $_FILES['_attachments']['type'][$i], 'path' => $tmpfname); - $response .= sprintf("parent.%s.add2attachment_list('%s');\n", $JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i]); + $button = sprintf('%s', $CONFIG['skin_path'], rcube_label('delete')); + $content = sprintf('%s%s',$JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i], rcube_label('deletefolder'), $button, $_FILES['_attachments']['name'][$i]); + $response .= sprintf('parent.%s.add2attachment_list(\'%s\',\'%s\');',$JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i], $content); } } @@ -64,4 +66,4 @@ parent.$JS_OBJECT_NAME.show_attachment_form(false); EOF; exit; -?> \ No newline at end of file +?> diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc index dd321f0d8..7274bdc50 100644 --- a/program/steps/settings/manage_folders.inc +++ b/program/steps/settings/manage_folders.inc @@ -71,8 +71,8 @@ else if ($_action=='rename-folder') if ($rename && $REMOTE_REQUEST) { - $commands = sprintf("this.add_folder_row('%s');", rep_specialchars_output($rename, 'js')); - $commands .= sprintf("this.remove_folder_row('%s')", rep_specialchars_output($_GET['_folder_oldname'], 'js')); + $commands = sprintf("this.add_folder_row('%s');\n", addslashes(rep_specialchars_output($rename, 'js'))); + $commands .= sprintf("this.remove_folder_row('%s');", rep_specialchars_output($_GET['_folder_oldname'], 'js')); rcube_remote_response($commands); } else if (!$rename && $REMOTE_REQUEST) diff --git a/skins/default/images/icons/remove-attachment.png b/skins/default/images/icons/remove-attachment.png new file mode 100644 index 000000000..0712aaa71 Binary files /dev/null and b/skins/default/images/icons/remove-attachment.png differ diff --git a/skins/default/mail.css b/skins/default/mail.css index 808ab6ccb..4d54be31d 100644 --- a/skins/default/mail.css +++ b/skins/default/mail.css @@ -597,12 +597,11 @@ table.headers-table tr td.subject #attachment-list { margin: 0px; - padding: 0px 0px 0px 68px; + padding: 0px 0px 0px 0px; height: 18px; list-style-image: none; list-style-type: none; background-color: #DFDFDF; - background: url(images/icons/attachment.png) no-repeat #DFDFDF; background-position: 52px 1px; border-bottom: 1px solid #FFFFFF; } @@ -818,11 +817,9 @@ div.message-part pre { height: 18px; font-size: 11px; - padding-left: 26px; + padding-left: 2px; padding-top: 2px; padding-right: 4px; - background: url(images/icons/attachment.png) no-repeat; - background-position: 4px 1px; border-bottom: 1px solid #EBEBEB; white-space: nowrap; overflow: hidden; diff --git a/skins/default/templates/compose.html b/skins/default/templates/compose.html index ab8b0ced0..bcb232fbc 100644 --- a/skins/default/templates/compose.html +++ b/skins/default/templates/compose.html @@ -112,7 +112,7 @@ self.setTimeout('rcmail_auto_save()',300000);
    - +

    -- cgit v1.2.3