From dd389be52f2ddba77cac430e18042a26823a4436 Mon Sep 17 00:00:00 2001 From: fidian Date: Mon, 9 Oct 2000 12:18:32 +0000 Subject: [PATCH] New attachment view, do_hook() with parameters, better attachment hook git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@780 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + functions/mime.php | 95 ++++++++++++++++++++++++++++++-------------- functions/plugin.php | 21 ++++++---- 3 files changed, 80 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4722c4a..6adba351 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Version 0.6pre1 -- DEVELOPMENT - Made message index order customizable (from, subject, date) can be (date, from, subject) - Fixed some security problems with uploading attachments - Added Catalan translation from Josep Sanz +- When reading, attachments look better and have a better plugin interface Version 0.5 -- September 25, 2000 diff --git a/functions/mime.php b/functions/mime.php index a3556f0d..82f239e9 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -459,27 +459,12 @@ $body .= "
". _("Download this as a file") ."

"; /** Display the ATTACHMENTS: message if there's more than one part **/ + $body .= ""; if ($message->entities) { - $body .= ""; - $body .= "
"; - $body .= "ATTACHMENTS:"; - $body .= "
"; - $num = 0; - $body .= formatAttachments ($message, $ent_num, $message->header->mailbox, $id); - $body .= "
"; - } else { - $body .= ""; } } else { - $body .= ""; - $body .= "
"; - $body .= "ATTACHMENTS:"; - $body .= "
"; - $num = 0; - - $body .= formatAttachments ($message, 999999, $message->header->mailbox, $id); - $body .= "
"; + $body .= formatAttachments ($message, -1, $message->header->mailbox, $id); } return $body; } @@ -488,7 +473,27 @@ // to where to download these attachments function formatAttachments ($message, $ent_id, $mailbox, $id) { global $where, $what; - global $startMessage; + global $startMessage, $color; + static $ShownHTML; + + if ($ShownHTML == 0) + { + $ShownHTML = 1; + + $body .= "\n"; + $body .= "
\n"; + $body .= _('Attachments') . ':'; + $body .= "
\n"; + + $body .= "\n"; + + $body .= formatAttachments ($message, $ent_id, $mailbox, $id); + + $body .= "
"; + + return $body; + } + if ($message) { if (!$message->entities) { $type0 = strtolower($message->header->type0); @@ -504,18 +509,50 @@ $urlMailbox = urlencode($mailbox); $ent = urlencode($message->header->entity_id); - if ($where && $what) { - // from a search - $body .= "   " . $display_filename . "  (TYPE: $type0/$type1)"; - } else { - $body .= "   " . $display_filename . "  (TYPE: $type0/$type1)"; - } + + $DefaultLink = + "../src/download.php?startMessage=$startMessage&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent"; + if ($where && $what) + $DefaultLink .= '&where=' . urlencode($where) . '&what=' . urlencode($what); + $Links['download link']['text'] = _('download'); + $Links['download link']['href'] = + "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent"; + $ImageURL = ''; + + $HookResults = do_hook("attachment $type0/$type1", $Links, + $startMessage, $id, $urlMailbox, $ent, $DefaultLink, + $where, $what); + + $Links = $HookResults[1]; + $DefaultLink = $HookResults[6]; + + $body .= '  '; + $body .= "$display_filename "; + $body .= "($type0/$type1) "; + $body .= ''; if ($message->header->description) - $body .= "  " . htmlspecialchars($message->header->description).""; - $body .= " ("._("download").")\n"; - do_hook("attachment $type0/$type1"); - $body .= "
"; - $num++; + $body .= '' . htmlspecialchars($message->header->description) . ''; + $body .= '
 '; + + + $SkipSpaces = 1; + foreach ($Links as $Val) + { + if ($SkipSpaces) + { + $SkipSpaces = 0; + } + else + { + $body .= '  '; + } + $body .= '(' . + $Val['text'] . ')'; + } + + unset($Links); + + $body .= "\n"; } return $body; } else { diff --git a/functions/plugin.php b/functions/plugin.php index cb845ea9..e4727f85 100644 --- a/functions/plugin.php +++ b/functions/plugin.php @@ -22,27 +22,32 @@ if (file_exists('../plugins/'.$name.'/setup.php')) { include ('../plugins/'.$name.'/setup.php'); $function = 'squirrelmail_plugin_init_'.$name; - $function(); + if (function_exists($function)) + $function(); } } // This function executes a hook function do_hook ($name) { global $squirrelmail_plugin_hooks; + $Data = func_get_args(); if (is_array($squirrelmail_plugin_hooks[$name])) { - reset($squirrelmail_plugin_hooks[$name]); - - while (list ($id, $function) = - each ($squirrelmail_plugin_hooks[$name])) { + foreach ($squirrelmail_plugin_hooks[$name] as $id => $function) { // Add something to set correct gettext domain for plugin - $function(); + if (function_exists($function)) { + $function(&$Data); + } } } - } + + // Variable-length argument lists have a slight problem when + // passing values by reference. Pity. This is a workaround. + return $Data; + } // On startup, register all plugins configured for use if (is_array($plugins)) - while (list ($id, $name) = each ($plugins)) + foreach ($plugins as $id => $name) use_plugin($name); ?> -- 2.25.1