Author Topic: Download attachment link in message view  (Read 10952 times)

Offline qpmailman

  • Newbie
  • *
  • Posts: 8
Download attachment link in message view
« on: October 18, 2006, 01:58:03 PM »
I figured out how to add a download attachments link when viewing the messages.

modify the code in program/steps/mail/show.inc line 112
from:
Code: [Select]
   $out .= sprintf('<li><a href=&quot;%s&amp;_part=%s&quot; onclick=&quot;return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)&quot;>%s</a></li>'.&quot;\n&quot;,
            htmlentities($GET_URL),
            $attach_prop['part_id'],
            $JS_OBJECT_NAME,
            $attach_prop['part_id'],
            $attach_prop['mimetype'],
            $attach_prop['filename']);

To:
Code: [Select]
   $out .= sprintf('
  • %s [%s]
  • '."\n",
                htmlentities($GET_URL),
                $attach_prop['part_id'],
                $JS_OBJECT_NAME,
                $attach_prop['part_id'],
                $attach_prop['mimetype'],
                $attach_prop['filename'],
                htmlentities($GET_URL),
                $attach_prop['part_id'],
              rcube_label('download'));

    This puts a download link next to the link with the attachment name.

    Don't forget to back up the original file.

     :D

    Offline encode

    • Newbie
    • *
    • Posts: 8
    Re: Download attachment link in message view
    « Reply #1 on: October 18, 2006, 06:44:13 PM »
    Thanks for an excellent and useful modification :D

    Offline qpmailman

    • Newbie
    • *
    • Posts: 8
    Re: Download attachment link in message view
    « Reply #2 on: October 20, 2006, 09:24:23 AM »
    glad to help!

    Offline kmn

    • Jr. Member
    • **
    • Posts: 44
    Re: Download attachment link in message view
    « Reply #3 on: August 01, 2007, 08:57:42 AM »
    Hello,

    The code hack above does not apply to latest rc. What change does it need?

    Thanks

    Offline Light Shadow

    • Newbie
    • *
    • Posts: 1
    Re: Download attachment link in message view
    « Reply #4 on: August 09, 2007, 12:31:57 AM »
    I'm using the SVN #657. I suppose that for other versions this should work (in 0.1-rc1 this code starts on line 130).

    You should replace this:
    Code: [Select]
       $out .= sprintf('<li><a href=&quot;%s&amp;_part=%s&quot; onclick=&quot;return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)&quot;>%s</a></li>'.&quot;\n&quot;,
                htmlspecialchars($GET_URL),
                $attach_prop->mime_id,
                JS_OBJECT_NAME,
                $attach_prop->mime_id,
                $attach_prop->mimetype,
                $attach_prop->filename);

    with this:

    Code: [Select]
       $out .= sprintf('
  • %s [%s]
  • '."\n",
                htmlspecialchars($GET_URL),
                $attach_prop->mime_id,
                JS_OBJECT_NAME,
                $attach_prop->mime_id,
                $attach_prop->mimetype,
                $attach_prop->filename,
                htmlspecialchars($GET_URL),
                $attach_prop->mime_id,
                rcube_label('download'));

    Thanks qpmailman!

    Offline rhuckle

    • Newbie
    • *
    • Posts: 7
    Re: Download attachment link in message view
    « Reply #5 on: August 15, 2007, 06:24:46 AM »
    Here Is Another Method Just Showing 1 Link To Click On Saying Download Attachment - filename
    ( ie [Download Attachment - roundcube.zip )

    this is what the user will see not the filename which they were also able to click on as well as the download link, meaning it had 2 links to download the attachment

    i come to an conclusion that i only needed 1 link and not 2 with the filename showing also

    So here is how i achieved this method

    Open show.inc ( program/steps/mail )

    Find

    $out .= sprintf('
  • %s
  • '."\n",
                htmlspecialchars($GET_URL),
                $attach_prop->mime_id,
                JS_OBJECT_NAME,
                $attach_prop->mime_id,
                $attach_prop->mimetype,
                $attach_prop->filename);

    Replace With

    $out .= sprintf('
  • %s - %s
  • '."\n",
                htmlspecialchars($GET_URL),
                $attach_prop->mime_id,
                rcube_label('Download Attachment'),
                $attach_prop->filename);

    The Above Will Show [Download Attachment] - filename.zip

    (instead of just file name without the filename being a link)

    Hope This Helps :)

    Offline kmn

    • Jr. Member
    • **
    • Posts: 44
    Re: Download attachment link in message view
    « Reply #6 on: September 14, 2007, 01:18:55 PM »
    Thanks rhuckle.

    Exactly what I was looking for.

    Regards

    kmn

    Offline deathstar

    • Newbie
    • *
    • Posts: 1
    Re: Download attachment link in message view
    « Reply #7 on: March 11, 2008, 04:40:16 PM »
    Just an after thought, but where you're using rube_label('Download Attachment'), it would be better to put something like rcube_label('download_attachment'). Then you can add download_attachment to your localization file, with a full description... Something like $labels['download_attachment'] = "Download this attachment".

    Offline encode

    • Newbie
    • *
    • Posts: 8
    Re: Download attachment link in message view
    « Reply #8 on: March 12, 2008, 05:40:18 PM »
    I'm using SVN 1190, and the download link added in by the code in Light Shadow's post doesn't seem to work properly.

    It behaves the same as me clicking on the attachment link - starts loading the binary file (doc, pdf, etc) in the current window as text. When I right click and choose save link as, the filename has .htm appended to it.

    What can I do to fix this?

    Thanks.