Added addressbook+LDAP functions.
[squirrelmail.git] / src / compose.php
index 3571c55ec5e4fba683e3ffe13b9988ac65f32fe9..c92d1d55bdb55f5bbf342fa75f8f13337538c194 100644 (file)
       $reply_subj = decodeHeader($reply_subj);
       $forward_subj = decodeHeader($forward_subj);
 
-      echo "\n<FORM action=\"compose.php\" METHOD=POST\n";
+      echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
+      echo "function open_abook() { \n";
+      echo "  var nwin = window.open(\"addrbook_popup.php\",\"abookpopup\",";
+      echo "\"width=670,height=300,resizable=yes,scrollbars=yes\");\n";
+      echo "  if((!nwin.opener) && (document.windows != null))\n";
+      echo "    nwin.opener = document.windows;\n";
+      echo "}\n";
+      echo "// --></SCRIPT>\n\n";
+
+      echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST\n";
       echo "ENCTYPE=\"multipart/form-data\">\n";
       echo "<TABLE COLS=2 WIDTH=50 ALIGN=center CELLSPACING=0 BORDER=0>\n";
       echo "   <TR>\n";
          echo "         <INPUT TYPE=TEXT NAME=send_to_bcc SIZE=60><BR>";
       echo "      </TD>\n";
       echo "   </TR>\n";
+
+      echo "<SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
+      echo "<TR><TD BGCOLOR=\\\"$color[4]\\\">&nbsp;</TD>";
+      echo "</TD><TD BGCOLOR=\\\"$color[4]\\\" ALIGN=LEFT>";
+      printf("<A HREF=\\\"javascript:open_abook();\\\">%s</A>",
+            _("Lookup recipients in addressbook.<BR>"));
+      echo "</TD></TR>\");\n";
+      echo "// --></SCRIPT>\n";
+
       echo "   <TR>\n";
       echo "      <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
       echo _("Subject:");
       echo "</CENTER>";
    }
 
-   function checkInput () {
-      global $body, $send_to, $subject;
+   function checkInput ($show) {
+      /** I implemented the $show variable because the error messages
+          were getting sent before the page header.  So, I check once
+          using $show=false, and then when i'm ready to display the
+          error message, show=true **/
+      global $body, $send_to, $subject, $color;
 
       if ($body == "") {
-         plain_error_message(_("You have not entered a message body."), $color);
+         if ($show)
+            plain_error_message(_("You have not entered a message body."), $color);
          return false;
       } else if ($send_to == "") {
-         displayPageHeader($color, "None");
-         plain_error_message(_("You have not filled in the \"To:\" field."), $color);
+         if ($show)
+            plain_error_message(_("You have not filled in the \"To:\" field."), $color);
          return false;
       } else if ($subject == "") {
-         plain_error_message(_("You have not entered a subject."), $color);
+         if ($show)
+            plain_error_message(_("You have not entered a subject."), $color);
          return false;
       }
       return true;
    } // function checkInput()
 
    if(isset($send)) {
-      if (checkInput()) {
+      if (checkInput(false)) {
          sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body);
          header ("Location: right_main.php");
       } else {
          echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
          $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
          displayPageHeader($color, "None");
-
+         checkInput(true);
+         
          showInputForm();
       }
    } else if (isset($attach)) {