basic html address book
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 3 May 2000 15:55:47 +0000 (15:55 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 3 May 2000 15:55:47 +0000 (15:55 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@485 7612ce4b-ef26-0410-bec9-ea0150e637f0

config/conf.pl
config/config_default.php
functions/url_parser.php
src/compose.php
src/load_prefs.php
src/options.php
src/options_submit.php

index 6e1159a..8d79287 100755 (executable)
@@ -67,7 +67,6 @@ while ($line = <FILE>) {
                   $tmp =~ s/^\s*"base"\s*=>\s*"//i;
                   $tmp =~ s/",\s*$//;
                   $tmp =~ s/"\);\s*$//;
-                  print $tmp."\n";
                   $base = $tmp;
                } elsif ($tmp =~ /^\s*"charset"/i) {
                   $tmp =~ s/^\s*"charset"\s*=>\s*"//i;
@@ -191,6 +190,7 @@ while (($command ne "q") && ($command ne "Q")) {
       for ($count = 0; $count <= $#ldap_host; $count++) {
          print "    >  $ldap_host[$count]\n";
       }
+      print "2.  Use Javascript Address Book Search  : $WHT$default_use_javascript_addr_book$NRM\n";
       print "\n";
       print "R   Return to Main Menu\n";
    } elsif ($menu == 7) {
@@ -270,7 +270,8 @@ while (($command ne "q") && ($command ne "Q")) {
             command41 (); 
          }
       } elsif ($menu == 6) {
-         if ($command == 1) { command61(); }
+         if    ($command == 1) { command61(); }
+         elsif ($command == 2) { command62(); }
       } elsif ($menu == 7) {
          if    ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;}
       }
@@ -1089,6 +1090,33 @@ sub command61 {
    }
 }   
 
+sub command62 {
+   print "Although our project goals stated that we would stay 100% HTML with\n";
+   print "no javascript, some of our developers have developed a wonderful\n";
+   print "javascript interface for searching for email addresses in your address\n";
+   print "books.  In order to stick with our project goals, and without having\n";
+   print "to refuse their work, we also developed an HTML version of address\n";
+   print "book searching.\n";
+   print "\n";
+   print "This is just the default value.  It is also a user option that each\n";
+   print "user can configure individually\n";
+   print "\n";
+   
+   if ($default_use_javascript_addr_book eq "true") {
+      $default_value = "y";
+   } else {
+      $default_use_javascript_addr_book = "false";
+      $default_value = "n";
+   }
+   print "Use javascript version (y/n) [$WHT$default_value$NRM]: $WHT";
+   $new_show = <STDIN>;
+   if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
+      $default_use_javascript_addr_book = "true";
+   } else {
+      $default_use_javascript_addr_book = "false";
+   }
+   return $default_use_javascript_addr_book;
+}
 
 
 sub save_data {
@@ -1142,6 +1170,10 @@ sub save_data {
    
    print FILE "\n";
 
+   if ($default_use_javascript_addr_book ne "true") {
+      $default_use_javascript_addr_book = "false";
+   }   
+   print FILE "\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
    for ($count=0; $count <= $#ldap_host; $count++) {
       print FILE "\t\$ldap_server[$count] = Array(\n";
       print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
@@ -1161,6 +1193,7 @@ sub save_data {
       print FILE ");\n\n";
    }
 
+   print FILE "\n";
    print FILE "\t\$motd = \"$motd\";\n";
 
    print FILE "?>\n";
index 9679ddb..2c2a574 100644 (file)
                        "base" => "",
                        "charset" => "iso8859-1");
 
+ // you have an option to chose between javascript or html version of
+ // address book searching.  
+ //   true = javascript
+ //  false = html
+
+ $default_use_javascript_addr_book = false;
+
 ?>
index fb47657..bcb5f7b 100644 (file)
@@ -18,7 +18,7 @@
    function parseUrl ($body) {
       #Possible ways a URL could finish.
 
-      $poss_ends=array(" ","\n","\r","<",">",".&nbsp","&nbsp",")","(");
+      $poss_ends=array(" ", "\n", "\r", "<", ">", ".\r", ".\n", ".&nbsp", "&nbsp", ")", "(");
       $done=False;
       while (!$done) {
          #Look for when a URL starts
index 018650a..5221cde 100644 (file)
@@ -31,7 +31,7 @@
    // This function is used when not sending or adding attachments
    function newMail () {
       global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
-         $reply_id, $send_to, $send_to_cc, $mailbox;
+         $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc;
 
       $send_to = decodeHeader($send_to);
       $send_to_cc = decodeHeader($send_to_cc);
    function showInputForm () {
       global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
          $passed_body, $color, $use_signature, $signature, $editor_size,
-         $attachments, $subject, $newmail;
+         $attachments, $subject, $newmail, $use_javascript_addr_book,
+         $send_to_bcc;
 
       $subject = decodeHeader($subject);
       $reply_subj = decodeHeader($reply_subj);
       $forward_subj = decodeHeader($forward_subj);
 
-      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";
+      if ($use_javascript_addr_book) {
+         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 ENCTYPE=\"multipart/form-data\">\n";
       echo "<TABLE COLS=2 WIDTH=50 ALIGN=center CELLSPACING=0 BORDER=0>\n";
       echo "   <TR>\n";
       echo "      <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
       echo _("To:");
-      echo "      </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
+      echo "      </TD><TD colspan=2 WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
       if ($send_to)
          echo "         <INPUT TYPE=TEXT NAME=send_to VALUE=\"$send_to\" SIZE=60><BR>";
       else
       echo "   <TR>\n";
       echo "      <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
       echo _("CC:");
-      echo "      </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
+      echo "      </TD><TD WIDTH=% colspan=2 BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
       if ($send_to_cc)
          echo "         <INPUT TYPE=TEXT NAME=send_to_cc SIZE=60 VALUE=\"$send_to_cc\"><BR>";
       else
       echo _("BCC:");
       echo "      </TD><TD WIDTH=% BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
       if ($send_to_bcc)
-         echo "         <INPUT TYPE=TEXT NAME=send_to_bcc VALUE=\"$send_to_bcc\" SIZE=60><BR>";
+         echo "         <INPUT TYPE=TEXT NAME=send_to_bcc VALUE=\"$send_to_bcc\" SIZE=55><BR>";
       else
-         echo "         <INPUT TYPE=TEXT NAME=send_to_bcc SIZE=60><BR>";
+         echo "         <INPUT TYPE=TEXT NAME=send_to_bcc SIZE=55><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 "<TD width=1% BGCOLOR=\"$color[4]\" ALIGN=Right>";
+      
+      if ($use_javascript_addr_book) {
+         $lookup_str = _("Addresses");
+         echo "<SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
+         echo "<a href=\\\"javascript:open_abook();\\\">$lookup_str</a><br>\");";
+         echo "// --></SCRIPT>\n";
+      } else {  
+         echo "<input type=submit name=html_addr_search value=\""._("Addresses")."\">";
+      }   
+      
+      echo "</TD></TR>\n";
 
       echo "   <TR>\n";
       echo "      <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
          $reply_subj = trim($reply_subj);
          if (substr(strtolower($reply_subj), 0, 3) != "re:")
             $reply_subj = "Re: $reply_subj";
-         echo "         <INPUT TYPE=TEXT NAME=subject SIZE=60 VALUE=\"$reply_subj\">";
+         echo "         <INPUT TYPE=TEXT NAME=subject SIZE=55 VALUE=\"$reply_subj\">";
       } else if ($forward_subj) {
          $forward_subj = str_replace("\"", "'", $forward_subj);
          $forward_subj = stripslashes($forward_subj);
              (substr(strtolower($forward_subj), 0, 5) != "[fwd:") &&
              (substr(strtolower($forward_subj), 0, 6) != "[ fwd:"))
             $forward_subj = "[Fwd: $forward_subj]";
-         echo "         <INPUT TYPE=TEXT NAME=subject SIZE=50 VALUE=\"$forward_subj\">";
+         echo "         <INPUT TYPE=TEXT NAME=subject SIZE=55 VALUE=\"$forward_subj\">";
       } else {
-         echo "         <INPUT TYPE=TEXT NAME=subject VALUE=\"$subject\" SIZE=50>";
+         echo "         <INPUT TYPE=TEXT NAME=subject VALUE=\"$subject\" SIZE=55>";
       }
-      echo "&nbsp;&nbsp;<INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">";
+      echo "</td><td align=right>";
+      echo "<INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">";
       echo "      </TD>\n";
       echo "   </TR>\n";
 
       echo "   <TR>\n";
-      echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
+      echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=3>\n";
       if ($use_signature == true && $newmail == true)
          echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>". $body . "\n\n-- \n".$signature."</TEXTAREA><BR>";
       else
       return true;
    } // function checkInput()
 
+
+
+
+
+
+
+
+
    if(isset($send)) {
       if (checkInput(false)) {
          sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body);
          
          showInputForm();
       }
+   } else if ($html_addr_search) {
+      //* I am using an include so as to elminiate an extra unnecessary click.  If you
+      //* can think of a better way, please implement it.
+      include ("addrbook_search_html.php");
+   } else if ($html_addr_search_done) {
+      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");
+
+      $body = stripslashes($body);
+      $send_to = stripslashes($send_to);
+      $send_to_cc = stripslashes($send_to_cc);
+      $send_to_bcc = stripslashes($send_to_bcc);
+      $subject = stripslashes($subject);
+      
+      showInputForm();
    } else if (isset($attach)) {
       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);
index a30be3b..3d28037 100644 (file)
       }
    }
 
+   $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
+   if ($use_javascript_addr_book == "")
+      $use_javascript_addr_book = $default_use_javascript_addr_book;
+
+   
    /** Load the user's sent folder preferences **/
    $move_to_sent = getPref($data_dir, $username, "move_to_sent");
    if ($move_to_sent == "")
index a641265..6e45190 100644 (file)
 
 
        // TRASH FOLDER
-
        echo "<tr><td align=right>";
        echo _("Trash Folder:");
        echo "</td><td>";
        echo "</td></tr>";      
 
        // SENT FOLDER
-
        echo "<tr><td align=right>";
        echo _("Sent Folder:");
        echo "</td><td>";
 
    echo "</TABLE>";
 
+   echo "<table width=1% cols=2 align=center>\n";
+   echo "   <tr>\n";
+   echo "      <td nowrap align=center>\n";
+   echo "         " . _("Use javascript version of address book?") . "\n";
+   echo "      </td>\n";
+   echo "   </tr>\n";
+   echo "   <tr>\n";
+   echo "      <td align=left>\n";
+   if ($use_javascript_addr_book == true) {
+      echo "         <input type=radio name=javascript_abook value=1 checked> &nbsp;&nbsp;" . _("Yes") . "<br>";
+      echo "         <input type=radio name=javascript_abook value=0> &nbsp;&nbsp;" . _("No") . "<br>";
+   } else {
+      echo "         <input type=radio name=javascript_abook value=1> &nbsp;&nbsp;" . _("Yes") . "<br>";
+      echo "         <input type=radio name=javascript_abook value=0 checked> &nbsp;&nbsp;" . _("No") . "<br>";
+   }
+   echo "      </td>\n";
+   echo "   </tr>\n";
+   echo "</table>\n";
+   
    echo "<TABLE WIDTH=100% COLS=2 ALIGN=CENTER>\n";
 
    // SHOW_NUM
index b96d031..506b95f 100644 (file)
@@ -29,6 +29,7 @@
    setPref($data_dir, $username, "language", $language);
    setPref($data_dir, $username, "left_size", $leftsize);
    setPref($data_dir, $username, "folder_prefix", $folderprefix);
+   setPref($data_dir, $username, "use_javascript_addr_book", $javascript_abook);
 
        if ($trash != "none") {
        setPref($data_dir, $username, "move_to_trash", true);