Quellcode durchsuchen

Added signature into multiple identities.

Code by:
Stefan Meier <Stefan.Meier@cimsource.com>
philippe_mingo vor 23 Jahren
Ursprung
Commit
92e6b38f50
8 geänderte Dateien mit 97 neuen und 42 gelöschten Zeilen
  1. 1 0
      AUTHORS
  2. 5 4
      ChangeLog
  3. 1 0
      functions/abook_local_file.php
  4. 5 5
      functions/file_prefs.php
  5. 19 0
      src/compose.php
  6. 1 5
      src/load_prefs.php
  7. 50 14
      src/options_identities.php
  8. 15 14
      src/options_personal.php

+ 1 - 0
AUTHORS

@@ -78,6 +78,7 @@
    i18n support:        Sergiusz Pawlowicz 
    SquirrelMail logo:   Libor Kopecky <libor@globe.cz>
    Web Site Admin/PR:   Rick Castello <rick@squirrelmail.org>
+   Multisig support:    Stefan Meier <Stefan.Meier@cimsource.com> 
 
    Paginator Help: Charles Scheidecker
    Other Code contributions:

+ 5 - 4
ChangeLog

@@ -4,7 +4,7 @@
 
 Version 1.2.5 -- CVS
 --------------------
-  - Added the possibility to add special folders through plugins.
+  - Added the ability to add special folders through plugins.
   - Made searching on multiple criteria possible, with thanks to Jason Munro
   - Fixed 'list all' in addressbook (#506624, thanks to Kurt Yoder)
   - Fixed small bugs in db_prefs
@@ -18,15 +18,16 @@ Version 1.2.5 -- CVS
   - conf.pl can now configure database backed address books and
     preferences.
   - Version 0.3.7 of SquirrelSpell. Fixes a potential privacy
-    vulnerability (symlink attack), plus introduces formatting fixes 
+    vulnerability (symlink attack), plus introduces formatting fixes
     and javadoc-style comments.
   - Bugfix in mailfetch reported by Mateusz Mazur
   - Administrator plugin. A web based conf.pl replacement.
   - Removed GLOBALS from conf.pl
   - HTML messages optimization.
-  - Added support for requesting read receipts (MDN) and delivery receipts.  
+  - Added support for requesting read receipts (MDN) and delivery receipts.
   - Added the ability to stop users changing their names and email addresses.
-	
+  - Added signature into multiple identities (Stefan Meier <Stefan.Meier@cimsource.com>)
+
 Version 1.2.4 -- 25 January 2002
 --------------------------------
   - Fixes a nasty remote arbitrary command execution vulnerability

+ 1 - 0
functions/abook_local_file.php

@@ -134,6 +134,7 @@ class abook_local_file extends addressbook_backend {
     /* Overwrite the file with data from $rows
      * NOTE! Previous locks are broken by this function */
     function overwrite(&$rows) {
+        $this->unlock();
         $newfh = @fopen($this->filename, 'w');
         if(!$newfh) {
             return $this->set_error("$file: " . _("Open failed"));

+ 5 - 5
functions/file_prefs.php

@@ -175,8 +175,8 @@ function checkForPrefs($data_dir, $username, $filename = '') {
 /**
  * Write the User Signature.
  */
-function setSig($data_dir, $username, $value) {
-    $filename = getHashedFile($username, $data_dir, "$username.sig");
+function setSig($data_dir, $username, $number, $value) {
+    $filename = getHashedFile($username, $data_dir, "$username.si$number");
     $file = fopen($filename, 'w');
     fwrite($file, $value);
     fclose($file);
@@ -185,9 +185,9 @@ function setSig($data_dir, $username, $value) {
 /**
  * Get the signature.
  */
-function getSig($data_dir, $username) {
-    #$filename = $data_dir . $username . '.sig';
-    $filename = getHashedFile($username, $data_dir, "$username.sig");
+function getSig($data_dir, $username, $number) {
+    #$filename = $data_dir . $username . '.si$number';
+    $filename = getHashedFile($username, $data_dir, "$username.si$number");
     $sig = '';
     if (file_exists($filename)) {
         $file = fopen($filename, 'r');

+ 19 - 0
src/compose.php

@@ -213,6 +213,24 @@ if (isset($send)) {
             displayPageHeader($color, $mailbox);
         }
     showInputForm();
+}
+elseif (isset($sigappend)) {
+    $idents = getPref($data_dir, $username, 'identities', 0);
+    if ($idents > 1) {
+       if ($identity == 'default') {
+          $no = 'g';
+       } else {
+          $no = $identity;
+       }
+       $signature = getSig($data_dir, $username, $no);
+    }
+    $body .= "\n\n".($prefix_sig==true? "-- \n":'').$signature;
+    if ($compose_new_win == '1') {
+         compose_Header($color, $mailbox);
+    } else {
+        displayPageHeader($color, $mailbox);
+    }
+    showInputForm();
 } elseif (isset($do_delete)) {
         if ($compose_new_win == '1') {
             compose_Header($color, $mailbox);
@@ -674,6 +692,7 @@ function showComposeButtonRow() {
     }
 
     echo "   <TR><td>\n   </td><td>\n";
+    echo "\n    <INPUT TYPE=SUBMIT NAME=\"sigappend\" VALUE=\"". _("Signature") . "\">\n";
     if ($use_javascript_addr_book) {
         echo "      <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"".
              "         <input type=button value=\\\""._("Addresses").

+ 1 - 5
src/load_prefs.php

@@ -143,11 +143,7 @@ $left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE );
 $sort = getPref($data_dir, $username, 'sort', 6 );
 
 /** Load up the Signature file **/
-if ($use_signature) {
-    $signature_abs = $signature = getSig($data_dir, $username);
-} else {
-    $signature_abs = getSig($data_dir, $username);
-}
+$signature_abs = $signature = getSig($data_dir, $username, "g");
 
 /* Highlight comes in with the form: name, color, header, value. */
 for ($i = 0; $hlt = getPref($data_dir, $username, "highlight$i"); ++$i) {

+ 50 - 14
src/options_identities.php

@@ -34,7 +34,7 @@ require_once('../functions/display_messages.php');
         SaveUpdateFunction();
     }
  
-    LoadInfo($full_name, $email_address, $reply_to, '');
+   LoadInfo($full_name, $email_address, $reply_to, $signature, '');
 
 ?>
 <br>
@@ -56,10 +56,10 @@ require_once('../functions/display_messages.php');
   </tr>
 <?PHP
 
-    ShowTableInfo($full_name, $email_address, $reply_to, '');
+   ShowTableInfo($full_name, $email_address, $reply_to, $signature, '');
   
     $num = 1;
-    while (LoadInfo($full_name, $email_address, $reply_to, $num))
+   while (LoadInfo($full_name, $email_address, $reply_to, $signature, $num))
     {
 ?>
   <tr bgcolor="<?PHP echo $color[9] ?>">
@@ -67,7 +67,7 @@ require_once('../functions/display_messages.php');
     $num) ?></th>
   </tr>
 <?PHP
-        ShowTableInfo($full_name, $email_address, $reply_to, $num);
+       ShowTableInfo($full_name, $email_address, $reply_to, $signature, $num);
         $num ++;
     }
    
@@ -76,7 +76,7 @@ require_once('../functions/display_messages.php');
     <th colspan=2 align=center><?PHP echo _("Add a New Identity") ?></th>
   </tr>
 <?php
-    ShowTableInfo('', '', '', $num);
+    ShowTableInfo('', '', '', '', $num);
 ?>
 </table>
 </form>
@@ -91,7 +91,7 @@ require_once('../functions/display_messages.php');
 <?PHP
 
     function SaveUpdateFunction() {
-        global $username, $data_dir, $full_name, $email_address, $reply_to;
+        global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
 
         $i = 1;
         $fakeI = 1;
@@ -125,6 +125,12 @@ require_once('../functions/display_messages.php');
                 $filled ++;
                 setPref($data_dir, $username, 'reply_to' . $fakeI, $$name);
 
+                $name = 'signature' . $i;
+                global $$name;
+            if ($$name != '')
+                $filled ++;
+                setSig($data_dir, $username, $fakeI, $$name);
+
             if ($filled == 0)
                 $fakeI --;
             }
@@ -142,16 +148,19 @@ require_once('../functions/display_messages.php');
             removePref($data_dir, $username, 'full_name' . $fakeI);
             removePref($data_dir, $username, 'email_address' . $fakeI);
             removePref($data_dir, $username, 'reply_to' . $fakeI);
+            setSig($data_dir, $username, $fakeI, "");
             $fakeI ++;
         }
 
         setPref($data_dir, $username, 'full_name', $full_name);
         setPref($data_dir, $username, 'email_address', $email_address);
         setPref($data_dir, $username, 'reply_to', $reply_to);
+        setSig($data_dir, $username, "g", $signature);
+        
     }
 
     function CheckAndDoDefault() {
-        global $username, $data_dir, $full_name, $email_address, $reply_to;
+        global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
 
         $i = 1;
         $name = 'form_for_' . $i;
@@ -162,7 +171,7 @@ require_once('../functions/display_messages.php');
             global $$name;
             if (isset($$name)) {
                 do_hook('options_identities_renumber', $i, 'default');
-                global $full_name, $email_address, $reply_to;
+                global $full_name, $email_address, $reply_to, $signature;
 
                 $name = 'full_name' . $i;
                 global $$name;
@@ -182,6 +191,13 @@ require_once('../functions/display_messages.php');
                 $reply_to = $$name;
                 $$name = $temp;
 
+                $name = 'signature' . $i;
+                global $$name;
+                $temp = $signature;
+                $signature = $$name;
+                $$name = $temp;
+
+
                 return true;
             }
 
@@ -193,7 +209,7 @@ require_once('../functions/display_messages.php');
     }
 
     function CheckForDelete() {
-        global $username, $data_dir, $full_name, $email_address, $reply_to;
+        global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
 
         $i = 1;
         $name = 'form_for_' . $i;
@@ -246,6 +262,13 @@ require_once('../functions/display_messages.php');
                 $$nameA = $$nameB;
                 $$nameB = $temp;
 
+            $nameA = 'signature' . $i;
+            $nameB = 'signature' . ($i - 1);
+            global $$nameA, $$nameB;
+            $temp = $$nameA;
+            $$nameA = $$nameB;
+            $$nameB = $temp;
+
                 return true;
             }
 
@@ -256,14 +279,17 @@ require_once('../functions/display_messages.php');
         return false;
     }
 
-    function LoadInfo(&$n, &$e, &$r, $post) {
+    function LoadInfo(&$n, &$e, &$r, &$s, $post) {
         global $username, $data_dir;
 
         $n = getPref($data_dir, $username, 'full_name' . $post);
         $e = getPref($data_dir, $username, 'email_address' . $post);
         $r = getPref($data_dir, $username, 'reply_to' . $post);
+        if ($post == '')
+           $post = 'g';
+        $s = getSig($data_dir,$username,$post);
 
-        if ($n != '' || $e != '' || $r != '')
+        if ($n != '' || $e != '' || $r != '' || $s != '')
             return true;
     }
 
@@ -276,14 +302,23 @@ function sti_input( $title, $hd, $data, $post, $bg ) {
 
 }
 
-function ShowTableInfo($full_name, $email_address, $reply_to, $post) {
+function sti_textarea( $title, $hd, $data, $post, $bg ) {
+
+    echo "<tr$bg><td align=right nowrap>$title:".
+         '</td><td>'.
+         "<textarea cols=50 rows=5 name=\"$hd$post\">" . htmlspecialchars($data) .
+         "</textarea></td></tr>";
+
+}
+
+function ShowTableInfo($full_name, $email_address, $reply_to, $signature, $post) {
     global $color;
 
     $OtherBG = ' bgcolor="' . $color[0] . '"';
-    if ($full_name == '' && $email_address == '' && $reply_to == '')
+    if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '')
         $OtherBG = '';
 
-    if ($full_name == '' && $email_address == '' && $reply_to == '')
+    if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '')
         $isEmptySection = true;
     else
         $isEmptySection = false;
@@ -291,6 +326,7 @@ function ShowTableInfo($full_name, $email_address, $reply_to, $post) {
     sti_input( _("Full Name"), 'full_name', $full_name, $post, $OtherBG );
     sti_input( _("E-Mail Address"), 'email_address', $email_address, $post, $OtherBG );
     sti_input( _("Reply To"), 'reply_to', $reply_to, $post, $OtherBG );
+    sti_textarea( _("Signature"), 'signature', $signature, $post, $OtherBG );
 
     do_hook('options_identities_table', $OtherBG, $isEmptySection, $post);
     echo "<tr$OtherBG>".

+ 15 - 14
src/options_personal.php

@@ -13,7 +13,7 @@
 
 require_once('../functions/imap.php');
 require_once('../functions/array.php');
- 
+
 /* Define the group constants for the personal options page. */
 define('SMOPT_GRP_CONTACT', 0);
 define('SMOPT_GRP_REPLY', 1);
@@ -21,13 +21,14 @@ define('SMOPT_GRP_SIG', 2);
 
 /* Define the optpage load function for the personal options page. */
 function load_optpage_data_personal() {
-    global $data_dir, $username, $edit_identity, $edit_name;
-    global $full_name, $reply_to, $email_address;
+    global $data_dir, $username, $edit_identity, $edit_name,
+           $full_name, $reply_to, $email_address, $signature;
 
     /* Set the values of some global variables. */
     $full_name = getPref($data_dir, $username, 'full_name');
     $reply_to = getPref($data_dir, $username, 'reply_to');
-    $email_address  = getPref($data_dir, $username, 'email_address'); 
+    $email_address  = getPref($data_dir, $username, 'email_address');
+    $signature  = getSig($data_dir, $username, 'g');
 
     /* Build a simple array into which we will build options. */
     $optgrps = array();
@@ -88,6 +89,15 @@ function load_optpage_data_personal() {
         'size'    => SMOPT_SIZE_HUGE
     );
 
+    $optvals[SMOPT_GRP_CONTACT][] = array(
+        'name'    => 'signature',
+        'caption' => _("Signature"),
+        'type'    => SMOPT_TYPE_TEXTAREA,
+        'refresh' => SMOPT_REFRESH_NONE,
+        'size'    => SMOPT_SIZE_MEDIUM,
+        'save'    => 'save_option_signature'
+    );
+
     if ($edit_identity) {
         $identities_link_value = '<A HREF="options_identities.php">'
                                . _("Edit Advanced Identities")
@@ -151,15 +161,6 @@ function load_optpage_data_personal() {
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-    $optvals[SMOPT_GRP_SIG][] = array(
-        'name'    => 'signature_abs',
-        'caption' => _("Signature"),
-        'type'    => SMOPT_TYPE_TEXTAREA,
-        'refresh' => SMOPT_REFRESH_NONE,
-        'size'    => SMOPT_SIZE_MEDIUM,
-        'save'    => 'save_option_signature'
-    );
-
     /* Assemble all this together and return it as our result. */
     $result = array(
         'grps' => $optgrps,
@@ -174,7 +175,7 @@ function load_optpage_data_personal() {
 
 function save_option_signature($option) {
     global $data_dir, $username;
-    setSig($data_dir, $username, $option->new_value);
+    setSig($data_dir, $username, 'g', $option->new_value);
 }
 
 ?>