adapt layout to fit in read_body + fix for comp_in_new stuff
[squirrelmail.git] / plugins / listcommands / setup.php
index 8d90f187e44fb6b0c53174ffa124279d956aebc5..506bdc103cc4de0c13335f080f6795e3eb4a5002 100644 (file)
@@ -22,7 +22,9 @@ function squirrelmail_plugin_init_listcommands () {
 
 function plugin_listcommands_menu() {
     global $imapConnection, $passed_id, $color, $mailbox,
-           $subject, $ent_num, $priority_level, $compose_new_win;
+           $message, $ent_num, $priority_level, $compose_new_win, $uid_support;
+
+    $subject = trim($message->header->subject);
 
     /**
      * Array of commands we can deal with from the header. The Reply option
@@ -43,7 +45,7 @@ function plugin_listcommands_menu() {
 
     $lfields = 'List-' . implode (' List-', $fields);
 
-    $sid = sqimap_session_id();
+    $sid = sqimap_session_id($uid_support);
     fputs ($imapConnection, "$sid FETCH $passed_id BODY.PEEK[HEADER.FIELDS ($lfields)]\r\n");
     $read = sqimap_read_data($imapConnection, $sid, true, $response, $emessage);
 
@@ -75,31 +77,30 @@ function plugin_listcommands_menu() {
                 $url = 'compose.php?';
             } else {
                 $url = "../plugins/listcommands/mailout.php?action=$cmd&";
+               
             }
-
-            $url .= 'mailbox=' . urlencode($mailbox)
-                  . '&send_to=' . $purl['path'];
+            $url .= '&send_to=' . $purl['path'];
 
             if (isset($purl['query'])) {
                 $url .= '&' . $purl['query'];
             }
             if ($compose_new_win == '1') {
-                $output[] = '<A HREF="' . $url . '" target="compose_window" onClick="comp_in_new()">' . $fieldsdescr[$cmd] . '</A>';
+                $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</A>';
             }
             else {
                 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
             }
             if ($cmd == 'Post') {
-                $url .= '&amp;reply_subj=' . urlencode($subject)
-                      . '&amp;reply_id=' . $passed_id
-                      . '&amp;ent_num=' . $ent_num
-                      . '&amp;mailprio=' . $priority_level;
-            if ($compose_new_win == '1') {
-                $output[] = '<A HREF="' . $url . '" target="compose_window" onClick="comp_in_new()">' . $fieldsdescr['Reply'] . '</A>';
-            }
-            else {
-                $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
-            }
+               $url .= '&amp;passed_id='.$passed_id.
+                       '&amp;mailbox='.urlencode($mailbox).
+                       (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
+                $url .= '&amp;action=reply';
+                if ($compose_new_win == '1') {
+                    $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['Reply'] . '</A>';
+                }
+                else {
+                    $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
+                }
             }
         } else if (eregi('^(http|ftp)', $url)) {
             $output[] = '<A HREF="' . $url . '" TARGET="_blank">'
@@ -108,14 +109,14 @@ function plugin_listcommands_menu() {
     }
 
     if (count($output) > 0) {
-        echo "<tr>";
-        echo "<td ALIGN=RIGHT BGCOLOR=\"$color[0]\">"
-           .   str_replace(' ', '&nbsp;', _("Mailing List:"))
-           . '</td>';
-        echo "<td BGCOLOR=\"$color[0]\" WIDTH=\"100%\" colspan=\"2\">"
-           .   '<SMALL>' . implode('&nbsp;|&nbsp;', $output) . '</SMALL>'
-           . '</td>';
-        echo '</tr>';
+        echo '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
+             ' border="0" bgcolor="'.$color[0].'">'. "\n";
+        echo '<tr>';
+        echo html_tag( 'td', '<b>'._("Mailing List").':&nbsp;&nbsp;</b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
+        echo html_tag( 'td', 
+                '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>', 'left', $color[0], 'valign="top" width="80%"');
+        echo "\n</tr>";
+       echo '</table>'."\n";
     }
 }