Added signature into multiple identities.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 14 Feb 2002 06:12:51 +0000 (06:12 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 14 Feb 2002 06:12:51 +0000 (06:12 +0000)
Code by:
Stefan Meier <Stefan.Meier@cimsource.com>

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2442 7612ce4b-ef26-0410-bec9-ea0150e637f0

AUTHORS
ChangeLog
functions/abook_local_file.php
functions/file_prefs.php
src/compose.php
src/load_prefs.php
src/options_identities.php
src/options_personal.php

diff --git a/AUTHORS b/AUTHORS
index 2557a048088221a4e6bd3c04f28600ba89abcff5..9f7116b8f6f778ac238be6e917f198d1c2ac3afd 100644 (file)
--- a/AUTHORS
+++ b/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:
index ad4f958ef9a9c4eb4199a5beec2bb4be298e2759..7d05102ed42a883d0f9c6f8a53198cc0dd338edb 100644 (file)
--- a/ChangeLog
+++ b/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
index 904893e4ca7349b9487d0f0d81477b5595403de5..b91af2bc1b5a29ac9fc730d28593c5d5e5cf7c66 100644 (file)
@@ -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"));
index 74bf5bdd55af5e3200821a39e6e2d304ba0cfb5e..d52560a83fb4210c79c62c6b7e2ebba4295e57f7 100644 (file)
@@ -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');
index c8a3b1605c2b3ce0a00733f975fb82cc79e40bbf..d25a9e398f881291aa2b84d5d884a06dac52a544 100644 (file)
@@ -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").
index 4c9a0b2e7d83662af13e50ef2da24aea1a13096c..a7b539ddbe294ef72472ac784c4d24d77a4060d6 100644 (file)
@@ -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) {
index ddf01ee884b366fc59ee14e62ccee717c5bab12d..310f06079af83abcd0b58d37172a60eed2e040d3 100644 (file)
@@ -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>".
index 8258c161c6c4ea1def1a465f3e2509f8d840bf29..1e1614c5dfbc1fed2b61f2d71c980e66671b5a2a 100644 (file)
@@ -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);
 }
 
 ?>