From: Michael M Slusarz Date: Tue, 25 Nov 2008 03:26:10 +0000 (-0700) Subject: Various compose fixes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b8bc9eaa79863f97034ab76090e0b933d6897f34;p=horde.git Various compose fixes. Remove disposition selection for attachments - always attach as attachment rather than inline. --- diff --git a/imp/compose.php b/imp/compose.php index 5dc9ec349..99546d010 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -243,9 +243,8 @@ if ($_SESSION['imp']['file_upload']) { /* Update the attachment information. */ foreach (array_keys($imp_compose->getAttachments()) as $i) { if (!in_array($i, $deleteList)) { - $disposition = Util::getFormData('file_disposition_' . $i); $description = Util::getFormData('file_description_' . $i); - $imp_compose->updateAttachment($i, array('disposition' => $disposition, 'description' => $description)); + $imp_compose->updateAttachment($i, array('description' => $description)); } } @@ -260,7 +259,7 @@ if ($_SESSION['imp']['file_upload']) { } /* Add new attachments. */ - if (!$imp_compose->addFilesFromUpload('upload_', 'upload_disposition_', $notify)) { + if (!$imp_compose->addFilesFromUpload('upload_', $notify)) { $actionID = null; } } @@ -1235,29 +1234,25 @@ if ($redirect) { $t->set('numberattach', $imp_compose->numberOfAttachments()); if ($t->get('numberattach')) { - require_once IMP_BASE . '/lib/MIME/Contents.php'; - $imp_contents = new IMP_Contents(new Horde_Mime_Part()); - $atc = array(); - $disp_num = 0; - foreach ($imp_compose->getAttachments() as $atc_num => $mime) { - $entry = array(); - $disposition = $mime->getDisposition(); - $viewer = &$imp_contents->getMIMEViewer($mime); - $linked = Util::getFormData (sprintf('file_linked_%d', $atc_num)); - $entry['name'] = $mime->getName(true, true); - if ($mime->getType() != 'application/octet-stream') { + foreach ($imp_compose->getAttachments() as $atc_num => $data) { + $mime = $data['part']; + $type = $mime->getType(); + + $entry = array( + 'name' => $mime->getName(true), + 'icon' => Horde_Mime_Viewer::getIcon($type), + 'number' => $atc_num, + 'type' => $type, + 'size' => $mime->getSize(), + 'description' => $mime->getDescription(true) + ); + + if ($type != 'application/octet-stream') { $preview_url = Util::addParameter(Horde::applicationUrl('view.php'), array('actionID' => 'compose_attach_preview', 'id' => $atc_num, 'composeCache' => $imp_compose->getCacheId())); $entry['name'] = Horde::link($preview_url, _("Preview") . ' ' . $entry['name'], 'link', 'compose_preview_window') . $entry['name'] . ''; } - $entry['icon'] = $viewer->getIcon($mime->getType()); - $entry['disp_number'] = ++$disp_num; - $entry['number'] = $atc_num; - $entry['type'] = $mime->getType(); - $entry['size'] = $mime->getSize(); - $entry['disp_atc'] = ($disposition == 'attachment'); - $entry['disp_inline'] = ($disposition == 'inline'); - $entry['description'] = $mime->getDescription(true); + $atc[] = $entry; } $t->set('atc', $atc); diff --git a/imp/js/compose.js b/imp/js/compose.js index abc13d442..76fbae225 100644 --- a/imp/js/compose.js +++ b/imp/js/compose.js @@ -1 +1 @@ -var display_unload_warning=true,textarea_ready=true;function confirmCancel(A){if(window.confirm(IMP.text.compose_cancel)){display_unload_warning=false;if(popup){if(cancel_url){self.location=cancel_url}else{self.close()}}else{window.location=cancel_url}return true}else{Event.extend(A);A.stop();return false}}function setCursorPosition(C,A){if(C.setSelectionRange){Field.focus(C);C.setSelectionRange(A,A)}else{if(C.createTextRange){var B=C.createTextRange();B.collapse(true);B.moveStart("character",A);B.moveEnd("character",0);Field.select(B);B.scrollIntoView(true)}}}function redirectSubmit(A){if($F("to")==""){alert(IMP.text.compose_recipient);$("to").focus();Event.extend(A);A.stop();return false}$("redirect").setStyle({cursor:"wait"});display_unload_warning=false;return true}function change_identity(A){var L=identities[$F("last_identity")],D=identities[A],B,E,G,K;if(rtemode){E=FCKeditorAPI.GetInstance("message");B=E.GetHTML.replace(/\r\n/g,"\n");G="

";K="

"+D[0].replace(/^ ?
\n/,"").replace(/ +/g," ")+"

";B=B.replace(/

\s*[\s\S]*?\s*<\/p>/,G)}else{B=$F("message").replace(/\r\n/g,"\n");G=L[0].replace(/^\n/,"");K=D[0].replace(/^\n/,"")}var J=(L[1])?B.indexOf(G):B.lastIndexOf(G);if(J!=-1){if(D[1]==L[1]){B=B.substring(0,J)+K+B.substring(J+G.length,B.length)}else{if(D[1]){B=K+B.substring(0,J)+B.substring(J+G.length,B.length)}else{B=B.substring(0,J)+B.substring(J+G.length,B.length)+K}}B=B.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n");$("last_identity").setValue(A);window.status=IMP.text.compose_sigreplace}else{window.status=IMP.text.compose_signotreplace}if(rtemode){E.SetHTML(B)}else{$("message").setValue(B)}var I=$("sent_mail_folder");if(smf_check){var C=0;$A(I.options).detect(function(N){if(N.value==D[2]){I.selectedIndex=C;return true}++C})}else{if(I.firstChild){I.replaceChild(document.createTextNode(D[2]),I.firstChild)}else{I.appendChild(document.createTextNode(D[2]))}}var H=$("ssm");if(H){H.checked=D[3]}var F=$("bcc");if(F){bccval=F.value;if(L[4]){var M=new RegExp(L[4]+",? ?","gi");bccval=bccval.replace(M,"");if(bccval){bccval=bccval.replace(/, ?$/,"")}}if(D[4]){if(bccval){bccval+=", "}bccval+=D[4]}F.setValue(bccval)}}function uniqSubmit(B,A){if(A){Event.extend(A);A.stop()}if(B=="send_message"){if(($F("subject")=="")&&!window.confirm(IMP.text.compose_nosubject)){return}if(compose_spellcheck&&IMP.SpellCheckerObject&&!IMP.SpellCheckerObject.isActive()){IMP.SpellCheckerObject.spellCheck();return}}if(IMP.SpellCheckerObject){IMP.SpellCheckerObject.resume()}if(!Prototype.Browser.WebKit){$("compose").setStyle({cursor:"wait"})}display_unload_warning=false;$("actionID").setValue(B);_uniqSubmit()}function _uniqSubmit(){if(textarea_ready){$("compose").submit()}else{_uniqSubmit.defer()}}function attachmentChanged(){var B=[],F=0;$("upload_atc").select('input[type="file"]').each(function(H){B[B.length]=H});if(max_attachments!==null&&B.length==max_attachments){return}B.each(function(H){if(H.value.length>0){F++}});if(F==B.length){var E=$("attachment_row_"+F);if(E){var G=new Element("TD",{align:"left"}).insert(new Element("STRONG").insert(IMP.text.compose_file+" "+(F+1)+":")).insert(" ");var D=new Element("INPUT",{type:"file",name:"upload_"+(F+1),size:25});D.observe("change",attachmentChanged);G.insert(D);var A=new Element("SELECT",{name:"upload_disposition_"+(F+1)});A.options[0]=new Option(IMP.text.compose_attachment,"attachment",true);A.options[1]=new Option(IMP.text.compose_inline,"inline");var C=new Element("TR",{id:"attachment_row_"+(F+1)}).insert(G).insert(new Element("TD",{align:"left"}).insert(A));E.parentNode.insertBefore(C,E.nextSibling)}}}function initializeSpellChecker(){if(typeof IMP.SpellCheckerObject!="object"){initializeSpellChecker.defer();return}IMP.SpellCheckerObject.onBeforeSpellCheck=function(){IMP.SpellCheckerObject.htmlAreaParent="messageParent";IMP.SpellCheckerObject.htmlArea=$("message").adjacent("iframe[id*=message]").first();$("message").setValue(FCKeditorAPI.GetInstance("message").GetHTML());textarea_ready=false};IMP.SpellCheckerObject.onAfterSpellCheck=function(){IMP.SpellCheckerObject.htmlArea=IMP.SpellCheckerObject.htmlAreaParent=null;var A=FCKeditorAPI.GetInstance("message");A.SetHTML($("message").value);A.Events.AttachEvent("OnAfterSetHTML",function(){textarea_ready=true})}}document.observe("dom:loaded",function(){$$("INPUT").each(function(A){if(A.type!="submit"&&A.type!="button"){A.observe("keydown",function(B){if(B.keyCode==10||B.keyCode==Event.KEY_RETURN){B.stop();return false}})}});if(cursor_pos!==null&&$("message")){setCursorPosition($("message"),cursor_pos)}if(redirect){$("to").focus()}else{if(Prototype.Browser.IE){$("subject").observe("keydown",function(A){if(A.keyCode==Event.KEY_TAB&&!A.shiftKey){A.stop();$("message").focus()}})}if(rtemode){initializeSpellChecker()}if($("to")&&!$F("to")){$("to").focus()}else{if(!$F("subject")){if(rtemode){$("subject").focus()}else{$("message").focus()}}}}});Event.observe(window,"load",function(){if(compose_popup&&!reloaded){var B,A=redirect?$("redirect"):$("compose");B=Math.min(A.getHeight(),screen.height-100)-document.viewport.getHeight();if(B>0){window.resizeBy(0,B)}}});Event.observe(window,"beforeunload",function(){if(display_unload_warning){return IMP.text.compose_discard}}); \ No newline at end of file +var display_unload_warning=true,textarea_ready=true;function confirmCancel(A){if(window.confirm(IMP.text.compose_cancel)){display_unload_warning=false;if(popup){if(cancel_url){self.location=cancel_url}else{self.close()}}else{window.location=cancel_url}return true}else{Event.extend(A);A.stop();return false}}function setCursorPosition(C,A){if(C.setSelectionRange){Field.focus(C);C.setSelectionRange(A,A)}else{if(C.createTextRange){var B=C.createTextRange();B.collapse(true);B.moveStart("character",A);B.moveEnd("character",0);Field.select(B);B.scrollIntoView(true)}}}function redirectSubmit(A){if($F("to")==""){alert(IMP.text.compose_recipient);$("to").focus();Event.extend(A);A.stop();return false}$("redirect").setStyle({cursor:"wait"});display_unload_warning=false;return true}function change_identity(A){var L=identities[$F("last_identity")],D=identities[A],B,E,G,K;if(rtemode){E=FCKeditorAPI.GetInstance("message");B=E.GetHTML.replace(/\r\n/g,"\n");G="

";K="

"+D[0].replace(/^ ?
\n/,"").replace(/ +/g," ")+"

";B=B.replace(/

\s*[\s\S]*?\s*<\/p>/,G)}else{B=$F("message").replace(/\r\n/g,"\n");G=L[0].replace(/^\n/,"");K=D[0].replace(/^\n/,"")}var J=(L[1])?B.indexOf(G):B.lastIndexOf(G);if(J!=-1){if(D[1]==L[1]){B=B.substring(0,J)+K+B.substring(J+G.length,B.length)}else{if(D[1]){B=K+B.substring(0,J)+B.substring(J+G.length,B.length)}else{B=B.substring(0,J)+B.substring(J+G.length,B.length)+K}}B=B.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n");$("last_identity").setValue(A);window.status=IMP.text.compose_sigreplace}else{window.status=IMP.text.compose_signotreplace}if(rtemode){E.SetHTML(B)}else{$("message").setValue(B)}var I=$("sent_mail_folder");if(smf_check){var C=0;$A(I.options).detect(function(N){if(N.value==D[2]){I.selectedIndex=C;return true}++C})}else{if(I.firstChild){I.replaceChild(document.createTextNode(D[2]),I.firstChild)}else{I.appendChild(document.createTextNode(D[2]))}}var H=$("ssm");if(H){H.checked=D[3]}var F=$("bcc");if(F){bccval=F.value;if(L[4]){var M=new RegExp(L[4]+",? ?","gi");bccval=bccval.replace(M,"");if(bccval){bccval=bccval.replace(/, ?$/,"")}}if(D[4]){if(bccval){bccval+=", "}bccval+=D[4]}F.setValue(bccval)}}function uniqSubmit(B,A){if(A){Event.extend(A);A.stop()}if(B=="send_message"){if(($F("subject")=="")&&!window.confirm(IMP.text.compose_nosubject)){return}if(compose_spellcheck&&IMP.SpellCheckerObject&&!IMP.SpellCheckerObject.isActive()){IMP.SpellCheckerObject.spellCheck();return}}if(IMP.SpellCheckerObject){IMP.SpellCheckerObject.resume()}if(!Prototype.Browser.WebKit){$("compose").setStyle({cursor:"wait"})}display_unload_warning=false;$("actionID").setValue(B);_uniqSubmit()}function _uniqSubmit(){if(textarea_ready){$("compose").submit()}else{_uniqSubmit.defer()}}function attachmentChanged(){var A=[],E=0;$("upload_atc").select('input[type="file"]').each(function(G){A[A.length]=G});if(max_attachments!==null&&A.length==max_attachments){return}A.each(function(G){if(G.value.length>0){E++}});if(E==A.length){var D=$("attachment_row_"+E);if(D){var F=new Element("TD",{align:"left"}).insert(new Element("STRONG").insert(IMP.text.compose_file+" "+(E+1)+":")).insert(" ");var C=new Element("INPUT",{type:"file",name:"upload_"+(E+1),size:25});C.observe("change",attachmentChanged);F.insert(C);var B=new Element("TR",{id:"attachment_row_"+(E+1)}).insert(F).insert(new Element("TD",{align:"left"}).insert(select));D.parentNode.insertBefore(B,D.nextSibling)}}}function initializeSpellChecker(){if(typeof IMP.SpellCheckerObject!="object"){initializeSpellChecker.defer();return}IMP.SpellCheckerObject.onBeforeSpellCheck=function(){IMP.SpellCheckerObject.htmlAreaParent="messageParent";IMP.SpellCheckerObject.htmlArea=$("message").adjacent("iframe[id*=message]").first();$("message").setValue(FCKeditorAPI.GetInstance("message").GetHTML());textarea_ready=false};IMP.SpellCheckerObject.onAfterSpellCheck=function(){IMP.SpellCheckerObject.htmlArea=IMP.SpellCheckerObject.htmlAreaParent=null;var A=FCKeditorAPI.GetInstance("message");A.SetHTML($("message").value);A.Events.AttachEvent("OnAfterSetHTML",function(){textarea_ready=true})}}document.observe("dom:loaded",function(){$$("INPUT").each(function(A){if(A.type!="submit"&&A.type!="button"){A.observe("keydown",function(B){if(B.keyCode==10||B.keyCode==Event.KEY_RETURN){B.stop();return false}})}});if(cursor_pos!==null&&$("message")){setCursorPosition($("message"),cursor_pos)}if(redirect){$("to").focus()}else{if(Prototype.Browser.IE){$("subject").observe("keydown",function(A){if(A.keyCode==Event.KEY_TAB&&!A.shiftKey){A.stop();$("message").focus()}})}if(rtemode){initializeSpellChecker()}if($("to")&&!$F("to")){$("to").focus()}else{if(!$F("subject")){if(rtemode){$("subject").focus()}else{$("message").focus()}}}}});Event.observe(window,"load",function(){if(compose_popup&&!reloaded){var B,A=redirect?$("redirect"):$("compose");B=Math.min(A.getHeight(),screen.height-100)-document.viewport.getHeight();if(B>0){window.resizeBy(0,B)}}});Event.observe(window,"beforeunload",function(){if(display_unload_warning){return IMP.text.compose_discard}}); \ No newline at end of file diff --git a/imp/js/src/compose.js b/imp/js/src/compose.js index aace3b4d2..5102ab177 100644 --- a/imp/js/src/compose.js +++ b/imp/js/src/compose.js @@ -237,10 +237,6 @@ function attachmentChanged() file.observe('change', attachmentChanged); td.insert(file); - var select = new Element('SELECT', { name: 'upload_disposition_' + (usedFields + 1) }); - select.options[0] = new Option(IMP.text.compose_attachment, 'attachment', true); - select.options[1] = new Option(IMP.text.compose_inline, 'inline'); - var newRow = new Element('TR', { id: 'attachment_row_' + (usedFields + 1) }).insert(td).insert(new Element('TD', { align: 'left' }).insert(select)); lastRow.parentNode.insertBefore(newRow, lastRow.nextSibling); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index d3bc51cfa..d85988119 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -73,6 +73,13 @@ class IMP_Compose protected $_cacheid; /** + * Has the attachment list been modified. + * + * @var boolean + */ + protected $_modified = false; + + /** * Attempts to return a reference to a concrete IMP_Compose instance. * * If a IMP_Cacheid object exists with the given cacheid, recreate that @@ -122,7 +129,8 @@ class IMP_Compose */ function __destruct() { - if (!empty($this->_cache)) { + if ($this->_modified) { + $this->_modified = false; $cacheSess = &Horde_SessionObjects::singleton(); $cacheSess->overwrite($this->_cacheid, $this, false); } @@ -1469,12 +1477,11 @@ class IMP_Compose * Horde_Mime_Part information entries 'temp_filename' and 'temp_filetype' * are set with this information. * - * @param string $name The input field name from the form. - * @param string $disposition The disposition to use for the file. + * @param string $name The input field name from the form. * * @return mixed Returns the filename on success; PEAR_Error on error. */ - public function addUploadAttachment($name, $disposition) + public function addUploadAttachment($name) { global $conf; @@ -1512,7 +1519,7 @@ class IMP_Compose $part->setCharset(NLS::getCharset()); $part->setName($filename); $part->setBytes($_FILES[$name]['size']); - $part->setDisposition($disposition); + $part->setDisposition('attachment'); if ($conf['compose']['use_vfs']) { $attachment = $tempfile; @@ -1642,6 +1649,8 @@ class IMP_Compose ); } + $this->_modified = true; + /* Add the size information to the counter. */ $this->_size += $part->getBytes(); } @@ -1689,6 +1698,8 @@ class IMP_Compose $this->_size -= $atc['part']->getBytes(); unset($this->_cache[$val]); + + $this->_modified = true; } return $names; @@ -1708,15 +1719,14 @@ class IMP_Compose * @param integer $number The attachment to update. * @param array $params An array of update information. *

-     * 'disposition'  --  The Content-Disposition value.
      * 'description'  --  The Content-Description value.
      * 
*/ public function updateAttachment($number, $params) { if (isset($this->_cache[$number])) { - $this->_cache[$number]['part']->setDisposition($params['disposition']); $this->_cache[$number]['part']->setDescription($params['description']); + $this->_modified = true; } } @@ -2262,14 +2272,12 @@ class IMP_Compose * Add uploaded files from form data. * * @param string $field The field prefix (numbering starts at 1). - * @param string $disp The prefix for a file disposition input - * (numbering starts at 1). * @param boolean $notify Add a notification message for each successful * attachment? * * @return boolean Returns false if any file was unsuccessfully added. */ - public function addFilesFromUpload($field, $disp = null, $notify = false) + public function addFilesFromUpload($field, $notify = false) { $success = true; @@ -2298,8 +2306,7 @@ class IMP_Compose $GLOBALS['notification']->push(sprintf(_("Did not attach \"%s\" as the file was empty."), $filename), 'horde.warning'); $success = false; } else { - $disposition = is_null($disp) ? 'attachment' : Util::getFormData($disp . $i); - $result = $this->addUploadAttachment($key, $disposition); + $result = $this->addUploadAttachment($key); if (is_a($result, 'PEAR_Error')) { $GLOBALS['notification']->push($result, 'horde.error'); $success = false; diff --git a/imp/templates/compose/compose.html b/imp/templates/compose/compose.html index 8ed08b7ec..4f5a07f49 100644 --- a/imp/templates/compose/compose.html +++ b/imp/templates/compose/compose.html @@ -274,13 +274,6 @@ - - - - @@ -326,22 +319,13 @@ [Icon] - .  ()   Size: KB +  ()   Size: KB - - - -
- -