/* 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));
}
}
}
/* Add new attachments. */
- if (!$imp_compose->addFilesFromUpload('upload_', 'upload_disposition_', $notify)) {
+ if (!$imp_compose->addFilesFromUpload('upload_', $notify)) {
$actionID = null;
}
}
$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'] . '</a>';
}
- $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);
-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="<p><!--begin_signature--><!--end_signature--></p>";K="<p><!--begin_signature-->"+D[0].replace(/^ ?<br \/>\n/,"").replace(/ +/g," ")+"<!--end_signature--></p>";B=B.replace(/<p class="imp-signature">\s*<!--begin_signature-->[\s\S]*?<!--end_signature-->\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="<p><!--begin_signature--><!--end_signature--></p>";K="<p><!--begin_signature-->"+D[0].replace(/^ ?<br \/>\n/,"").replace(/ +/g," ")+"<!--end_signature--></p>";B=B.replace(/<p class="imp-signature">\s*<!--begin_signature-->[\s\S]*?<!--end_signature-->\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
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);
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
*/
function __destruct()
{
- if (!empty($this->_cache)) {
+ if ($this->_modified) {
+ $this->_modified = false;
$cacheSess = &Horde_SessionObjects::singleton();
$cacheSess->overwrite($this->_cacheid, $this, false);
}
* 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;
$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;
);
}
+ $this->_modified = true;
+
/* Add the size information to the counter. */
$this->_size += $part->getBytes();
}
$this->_size -= $atc['part']->getBytes();
unset($this->_cache[$val]);
+
+ $this->_modified = true;
}
return $names;
* @param integer $number The attachment to update.
* @param array $params An array of update information.
* <pre>
- * 'disposition' -- The Content-Disposition value.
* 'description' -- The Content-Description value.
* </pre>
*/
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;
}
}
* 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;
$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;
<td>
<strong><label for="upload_1"><gettext>File</gettext> 1:</label></strong> <input id="upload_1" name="upload_1" tabindex="<tag:file_tabindex />" type="file" onchange="attachmentChanged()" size="25" />
</td>
- <td>
- <label for="upload_disposition_1" class="hidden">Disposition</label>
- <select id="upload_disposition_1" name="upload_disposition_1">
- <option value="attachment" selected="selected"><gettext>Attachment</gettext></option>
- <option value="inline"><gettext>Inline</gettext></option>
- </select>
- </td>
</tr>
<tr>
<td colspan="2">
<tr class="item">
<td>
<img style="padding-right:5px" src="<tag:atc.icon />" alt="[Icon]" />
- <strong><tag:atc.disp_number />. <tag:atc.name /></strong> (<tag:atc.type />) <strong><gettext>Size:</gettext></strong> <tag:atc.size /> <gettext>KB</gettext>
+ <strong><tag:atc.name /></strong> (<tag:atc.type />) <strong><gettext>Size:</gettext></strong> <tag:atc.size /> <gettext>KB</gettext>
</td>
</tr>
<tr class="item">
<td style="padding-left:30px">
<table>
<tr>
- <td class="rightAlign" valign="middle"><strong><label for="file_disposition_<tag:atc.number />"><gettext>Disposition:</gettext></label></strong></td>
- <td>
- <select id="file_disposition_<tag:atc.number />" name="file_disposition_<tag:atc.number />">
- <option value="attachment"<if:atc.disp_atc> selected="selected"</if:atc.disp_atc>><gettext>Attachment</gettext></option>
- <option value="inline"<if:atc.disp_inline> selected="selected"</if:atc.disp_inline>><gettext>Inline</gettext></option>
- </select>
- </td>
- </tr>
- <tr>
<td class="rightAlign" valign="middle"><strong><label for="file_description_<tag:atc.number />"><gettext>Description:</gettext></label></strong> </td>
<td><input type="text" size="40" id="file_description_<tag:atc.number />" name="file_description_<tag:atc.number />" value="<tag:atc.description />" /></td>
</tr>