Use the form functions instead
authorindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 11 May 2004 20:26:49 +0000 (20:26 +0000)
committerindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 11 May 2004 20:26:49 +0000 (20:26 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7437 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/abook_take/functions.php
plugins/abook_take/take.php

index 6351cfb520f1e129e3064a15c695504fecab31e2..b8042501897d6835a04eb87e56ba488866dc76a3 100644 (file)
@@ -15,6 +15,7 @@
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'functions/url_parser.php');
+require_once(SM_PATH . 'functions/forms.php');
 
 function valid_email ($email, $verify)
 {
@@ -38,8 +39,7 @@ function abook_take_read_string($str)
         $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
         if (! isset($abook_found_email[$hits[0]]))
         {
-            echo '<input type="hidden" name="email[]" value="' .
-                 htmlspecialchars($hits[0]) . "\" />\n";
+            echo addHidden('email[]', htmlspecialchars($hits[0]));
             $abook_found_email[$hits[0]] = 1;
         }
     }
@@ -57,7 +57,8 @@ function abook_take_read()
 {
     global $message;
 
-    echo '<br /><form action="../plugins/abook_take/take.php" method="post"><center>'."\n";
+    echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') .
+         '<center>' . "\n";
 
     if (isset($message->rfc822_header->reply_to))
         abook_take_read_array($message->rfc822_header->reply_to);
@@ -68,26 +69,24 @@ function abook_take_read()
     if (isset($message->rfc822_header->to))
         abook_take_read_array($message->rfc822_header->to);
 
-    echo '<input type="submit" value="' . _("Take Address") . '" />' .
-         '</center></form>';
+    echo addSubmit(_("Take Address")) .
+         '</center>';
 }
 
 function abook_take_pref()
 {
     global $username, $data_dir, $abook_take_verify;
 
-    $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
+    $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify', false);
 }
 
 function abook_take_options()
 {
     global $abook_take_verify;
 
-    echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','nowrap') . "\n" .
-         '<td><input name="abook_take_abook_take_verify" type="checkbox"';
-    if (isset($abook_take_verify) && $abook_take_verify)
-        echo ' checked';
-    echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n";
+    echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','nowrap') . "\n" .  '<td>' .
+         addCheckbox('abook_take_abook_take_verify', $abook_take_verify) .
+         _("Try to verify addresses") . "</td></tr>\n";
 }
 
 function abook_take_save()
index e7d87ed0b1a255bf9c4bb8d217e02d6bb65ae5ea..b5b110e57c084589c13efe43a9fea25ea1dc14ee 100644 (file)
@@ -13,7 +13,7 @@
  * @package plugins
  * @subpackage abook_take
  */
-   
+
 /**
  * Path for SquirrelMail required files.
  * @ignore */
@@ -28,7 +28,8 @@ require_once(SM_PATH . 'functions/page_header.php');
 require_once(SM_PATH . 'functions/addressbook.php');
 require_once(SM_PATH . 'include/load_prefs.php');
 require_once(SM_PATH . 'functions/html.php');
-   
+require_once(SM_PATH . 'functions/forms.php');
+
 displayPageHeader($color, 'None');
 
 /* input form data */
@@ -39,79 +40,64 @@ $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
 $abook = addressbook_init(false, true);
 $name = 'addaddr';
 
-echo '<form action="../../src/addressbook.php" name="f_add" method="post">' ."\n" .
+$addrs = array();
+foreach ($email as $Val) {
+    if (valid_email($Val, $abook_take_verify)) {
+        $addrs[$Val] = $Val;
+    } else {
+        $addrs[$Val] = 'FAIL - ' . $Val;
+    }
+}
+
+echo addForm(SM_PATH . 'src/addressbook.php', 'POST', 'f_add') . "\n" .
     html_tag( 'table',
         html_tag( 'tr',
             html_tag( 'th', sprintf(_("Add to %s"), $abook->localbackendname), 'center', $color[0] )
         ) ,
-    'center', '', 'width="100%" cols="1"' ) .
+    'center', '', 'width="100%"' ) . "\n" .
 
     html_tag( 'table', '', 'center', '', 'border="0" cellpadding="1" cols="2" width="90%"' ) . "\n" .
             html_tag( 'tr', "\n" .
                 html_tag( 'td', _("Nickname") . ':', 'right', $color[4], 'width="50"' ) . "\n" .
-                html_tag( 'td', '<input name="' . $name . '[nickname]" size="15" value="">' .
+                html_tag( 'td', addInput($name . '[nickname]', '', 15) .
                     '&nbsp;<small>' . _("Must be unique") . '</small>',
                 'left', $color[4] )
             ) . "\n" .
             html_tag( 'tr' ) . "\n" .
             html_tag( 'td', _("E-mail address") . ':', 'right', $color[4], 'width="50"' ) . "\n" .
-            html_tag( 'td', '', 'left', $color[4] ) .
-                '<select name="' . $name . "[email]\">\n";
+            html_tag( 'td', '', 'left', $color[4] ) . "\n" .
+            addSelect($name . '[email]', $addrs, null, true) .
+            '</td></tr>' . "\n";
 
-    foreach ($email as $Val)
-    {
-        if (valid_email($Val, $abook_take_verify))
-        {
-            echo '<option value="' . htmlspecialchars($Val) .
-                '">' . htmlspecialchars($Val) . "</option>\n";
-        } else {
-            echo '<option value="' . htmlspecialchars($Val) .
-             '">FAIL - ' . htmlspecialchars($Val) . "</option>\n";
-        }
-    }
     if ($squirrelmail_language == 'ja_JP') {
-        echo '</select></td></tr>' . "\n" . 
-            
-            html_tag( 'tr', "\n" .
-                      html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
-                      html_tag( 'td', '<input name="' . $name . '[lastname]" size="45" value="">', 'left', $color[4] )
-                      ) . "\n" .
-            html_tag( 'tr', "\n" .
-                      html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
-                      html_tag( 'td', '<input name="' . $name . '[firstname]" size="45" value="">', 'left', $color[4] )
-                      ) . "\n" .
-            html_tag( 'tr', "\n" .
-                      html_tag( 'td', _("Additional info") . ':', 'right', $color[4], 'width="50"' ) .
-                      html_tag( 'td', '<input name="' . $name . '[label]" size="45" value="">', 'left', $color[4] )
-                      ) . "\n" .
-            html_tag( 'tr', "\n" .
-                      html_tag( 'td',
-                                '<input type="submit" name="' . $name . '[SUBMIT]" size="45" value="'. _("Add address") .'">' ,
-                                'center', $color[4], 'colspan="2"' )
-                      ) . "\n" .
-            '</table>';
+        echo html_tag( 'tr', "\n" .
+                html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
+                html_tag( 'td', addInput($name . '[lastname]', '', 45), 'left', $color[4] )
+             ) . "\n" .
+             html_tag( 'tr', "\n" .
+                html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
+                html_tag( 'td', addInput($name . '[firstname]', '', 45), 'left', $color[4] )
+             ) . "\n";
     } else {
-    echo '</select></td></tr>' . "\n" . 
-
-    html_tag( 'tr', "\n" .
-        html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
-        html_tag( 'td', '<input name="' . $name . '[firstname]" size="45" value="">', 'left', $color[4] )
-    ) . "\n" .
-    html_tag( 'tr', "\n" .
-        html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
-        html_tag( 'td', '<input name="' . $name . '[lastname]" size="45" value="">', 'left', $color[4] )
-    ) . "\n" .
-    html_tag( 'tr', "\n" .
-        html_tag( 'td', _("Additional info") . ':', 'right', $color[4], 'width="50"' ) .
-        html_tag( 'td', '<input name="' . $name . '[label]" size="45" value="">', 'left', $color[4] )
-    ) . "\n" .
-    html_tag( 'tr', "\n" .
-        html_tag( 'td',
-            '<input type="submit" name="' . $name . '[SUBMIT]" size="45" value="'. _("Add address") .'">' ,
-        'center', $color[4], 'colspan="2"' )
-    ) . "\n" .
-    '</table>';
+        echo html_tag( 'tr', "\n" .
+                html_tag( 'td', _("First name") . ':', 'right', $color[4], 'width="50"' ) .
+                html_tag( 'td', addInput($name . '[firstname]', '', 45), 'left', $color[4] )
+             ) . "\n" .
+             html_tag( 'tr', "\n" .
+                html_tag( 'td', _("Last name") . ':', 'right', $color[4], 'width="50"' ) .
+                html_tag( 'td', addInput($name . '[lastname]', '', 45), 'left', $color[4] )
+             ) . "\n";
     }
+    echo html_tag( 'tr', "\n" .
+            html_tag( 'td', _("Additional info") . ':', 'right', $color[4], 'width="50"' ) .
+            html_tag( 'td', addInput($name . '[label]', '', 45), 'left', $color[4] )
+         ) . "\n" .
+         html_tag( 'tr', "\n" .
+            html_tag( 'td',
+                addSubmit(_("Add address"), $name . '[SUBMIT]'),
+                'center', $color[4], 'colspan="2"' )
+         ) . "\n";
 ?>
+</table>
 </form></body>
 </html>