Browse Source

* added signout_page option to redirect after signout
* added hook in compose

Luke Ehresman 24 years ago
parent
commit
b234c2de49
6 changed files with 66 additions and 31 deletions
  1. 3 1
      ChangeLog
  2. 21 0
      config/conf.pl
  3. 8 0
      config/config_default.php
  4. 1 1
      functions/imap_mailbox.php
  5. 27 29
      src/compose.php
  6. 6 0
      src/signout.php

+ 3 - 1
ChangeLog

@@ -1,6 +1,8 @@
 Version 1.1.0 -- DEVELOPMENT
 ----------------------------
-- Much improved SMTP error handling (patch by Jeff Evans)
+- Added option to have signout page redirect to another page (patch from Scott Bronson)
+    This can be configured in conf.pl (Org Prefs)
+- Much improved SMTP error handling (patch from Jeff Evans)
 - Preferences are now cached instead of read in every page load.
 - Improved URL parser
 - Added ability to read HTML messages by default instead of plain text (Display Options)

+ 21 - 0
config/conf.pl

@@ -282,6 +282,7 @@ while (($command ne "q") && ($command ne "Q")) {
       print "1.  Organization Name    : $WHT$org_name$NRM\n";
       print "2.  Organization Logo    : $WHT$org_logo$NRM\n";
       print "3.  Organization Title   : $WHT$org_title$NRM\n";
+      print "4.  Signout Page         : $WHT$signout_page$NRM\n";
       print "\n";
       print "R   Return to Main Menu\n";
    } elsif ($menu == 2) {
@@ -450,6 +451,7 @@ while (($command ne "q") && ($command ne "Q")) {
          if    ($command == 1) { $org_name   = command1 (); }
          elsif ($command == 2) { $org_logo   = command2 (); }
          elsif ($command == 3) { $org_title  = command3 (); }
+         elsif ($command == 4) { $signout_page  = command4 (); }
       } elsif ($menu == 2) {
          if    ($command == 1)  { $domain             = command11 (); }
          elsif ($command == 2)  { $imapServerAddress  = command12 (); }
@@ -548,6 +550,24 @@ sub command3 {
    return $new_org_title;
 }
 
+# signout_page
+sub command4 {
+   print "When users click the Sign Out button they will be logged out and\n";
+   print "then sent to signout_page.  If signout_page is left empty,\n";
+   print "(hit space and then return) they will be taken, as normal,\n";
+   print "to the default and rather sparse SquirrelMail signout page.\n";
+   print "\n";
+   print "[$WHT$signout_page$NRM]: $WHT";
+   $new_signout_page = <STDIN>;
+   if ($new_signout_page eq "\n") {
+      $new_signout_page = $signout_page;
+   } else {
+      $new_signout_page =~ s/[\r|\n]//g;
+      $new_signout_page =~ s/^\s+$//g;
+   }
+   return $new_signout_page;
+}
+
 ####################################################################################
 
 # domain
@@ -1563,6 +1583,7 @@ sub save_data {
    print FILE "\t\$org_name   = \"$org_name\";\n";
    print FILE "\t\$org_logo   = \"$org_logo\";\n";
    print FILE "\t\$org_title  = \"$org_title\";\n";
+   print FILE "\t\$signout_page  = \"$signout_page\";\n";
 
    print FILE "\n";
 

+ 8 - 0
config/config_default.php

@@ -73,6 +73,14 @@
     global $imap_server_type;
     $imap_server_type = "cyrus";
 
+// Rather than going to the signout.php page (which only allows you
+// to sign back in), setting signout_page allows you to sign
+// the user out and then redirect to whatever page you want.
+// For instance, the following would return the user to your
+// home page:    $signout_page = "/";
+// Set to the empty string to continue to use the default signout page.
+    $signout_page = "";
+
 //  Many servers store mail in your home directory.  With this, they
 //  store them in a subdirectory: mail/ or Mail/, etc.  If your
 //  server does this, please set this to what the default mail folder

+ 1 - 1
functions/imap_mailbox.php

@@ -207,7 +207,7 @@
 
       /** LSUB array **/
       $inbox_subscribed = false;
-      fputs ($imap_stream, "a001 LSUB \"\" \"*\"\r\n");
+      fputs ($imap_stream, "a001 LSUB \"\" \"*%\"\r\n");
       $lsub_ary = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
 
       /** OS: we don't want to parse last element of array, 'cause it is OK command, so we unset it **/

+ 27 - 29
src/compose.php

@@ -64,7 +64,7 @@
          } else {
             $body = "";
          }
-	 
+         
          if ($message->header->type1 == "html")
             $body = strip_tags($body);
 
@@ -90,7 +90,7 @@
             }
             sqWordWrap($body_ary[$i], $editor_size - 1);
             $body .= $body_ary[$i] . "\n";
-	    unset($body_ary[$i]);
+            unset($body_ary[$i]);
          }
          if ($forward_id)
          {
@@ -150,7 +150,7 @@
       if (!$message) {
            sqimap_mailbox_select($imapConnection, $mailbox);
            $message = sqimap_get_message($imapConnection, $forward_id, 
-	       $mailbox);
+               $mailbox);
       }
       
       if (count($message->entities) == 0) {
@@ -161,19 +161,19 @@
                   $filename = "untitled-".$message->header->entity_id;
       
               $localfilename = GenerateRandomString(32, '', 7);
-	      while (file_exists($attachment_dir . $localfilename))
-	          $localfilename = GenerateRandomString(32, '', 7);
+              while (file_exists($attachment_dir . $localfilename))
+                  $localfilename = GenerateRandomString(32, '', 7);
 
               $newAttachment['localfilename'] = $localfilename;
-	      $newAttachment['remotefilename'] = $filename;
-	      $newAttachment['type'] = strtolower($message->header->type0 .
-	         '/' . $message->header->type1);
+              $newAttachment['remotefilename'] = $filename;
+              $newAttachment['type'] = strtolower($message->header->type0 .
+                 '/' . $message->header->type1);
 
               // Write Attachment to file
               $fp = fopen ($attachment_dir.$localfilename, 'w');
               fputs ($fp, decodeBody(mime_fetch_body($imapConnection, 
-	          $forward_id, $message->header->entity_id), 
-		  $message->header->encoding));
+                  $forward_id, $message->header->entity_id), 
+                  $message->header->encoding));
               fclose ($fp);
       
               $attachments[] = $newAttachment;
@@ -210,7 +210,7 @@
 
       echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST ENCTYPE=\"multipart/form-data\"";
       do_hook("compose_form");
-	  echo ">\n";
+          echo ">\n";
       if ($reply_id) {
          echo "<input type=hidden name=reply_id value=$reply_id>\n";
       }                 
@@ -305,11 +305,11 @@
          echo "<tr><td bgcolor=\"$color[0]\" align=right>\n";
          echo "&nbsp;";
          echo "</td><td align=left bgcolor=\"$color[0]\">";
-	 foreach ($attachments as $key => $info) {
+         foreach ($attachments as $key => $info) {
             echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$key\">\n";
-	    echo $info['remotefilename'] . " - " . $info['type'] . " (";
-	    echo show_readable_size(filesize($attachment_dir . 
-	        $info['localfilename'])) . ")<br>\n";
+            echo $info['remotefilename'] . " - " . $info['type'] . " (";
+            echo show_readable_size(filesize($attachment_dir . 
+                $info['localfilename'])) . ")<br>\n";
          }
          
          echo "<input type=\"submit\" name=\"do_delete\" value=\""._("Delete selected attachments")."\">\n";
@@ -390,9 +390,9 @@
     //
     global $CHARSET, $SOURCE_CHARSET, $send_to, $send_to_cc, $send_to_bcc, $subject, $body;
     $charset_ary = array("koi8-r" => "k",
-   			 "windows-1251" => "w",
-			 "ibm866" => "a",
-			 "ISO-8859-5" => "i");
+                            "windows-1251" => "w",
+                         "ibm866" => "a",
+                         "ISO-8859-5" => "i");
     $body = convert_cyr_string($body, $charset_ary[$CHARSET], $charset_ary[$SOURCE_CHARSET]);
     $send_to = convert_cyr_string($send_to, $charset_ary[$CHARSET], $charset_ary[$SOURCE_CHARSET]);
     $send_to_cc = convert_cyr_string($send_to_cc, $charset_ary[$CHARSET], $charset_ary[$SOURCE_CHARSET]);
@@ -422,10 +422,11 @@
          if (! isset($reply_id))
              $reply_id = 0;
          // Set $default_charset to correspond with the user's selection
-	 // of language interface.
-	 set_my_charset();
+         // of language interface.
+         set_my_charset();
+         do_hook("compose_send");
+
          if (sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id) == 0) {showInputForm(); exit();}
-//         header ("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
          //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
          displayPageHeader($color, $mailbox);
@@ -494,7 +495,7 @@
          {
             unlink ($attachment_dir.$attachments[$index]['localfilename']);
             unset ($attachments[$index]);
-	 }
+         }
       }
 
       showInputForm();
@@ -520,16 +521,13 @@
    
    
    
-   function ClearAttachments()
-   {
+   function ClearAttachments() {
        global $attachments, $attachment_dir;
        
-       foreach ($attachments as $info)
-       {
-           if (file_exists($attachment_dir . $info['localfilename']))
-	   {
+       foreach ($attachments as $info) {
+           if (file_exists($attachment_dir . $info['localfilename'])) {
                unlink($attachment_dir . $info['localfilename']);
-	   }
+           }
        }
        
        $attachments = array();

+ 6 - 0
src/signout.php

@@ -42,6 +42,12 @@
    setcookie('key', '', 0, $base_uri);
    setcookie('logged_in', '', 0, $base_uri);
    session_destroy();
+
+   if ($signout_page) {
+       header("Status: 303 See Other");
+       header("Location: $signout_page");
+       exit; /* we send no content if we're redirecting. */
+   }
 ?>
 <HTML>
    <HEAD>