and back in sync again
[squirrelmail.git] / src / addressbook.php
index 0cd1f24a075c9364da2831e6d099f239c2a3a079..8d4c80ff719b6b03b327b02211ae759deb00a2bc 100644 (file)
@@ -16,40 +16,28 @@ define('SM_PATH','../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/display_messages.php');
 require_once(SM_PATH . 'functions/addressbook.php');
 require_once(SM_PATH . 'functions/strings.php');
 require_once(SM_PATH . 'functions/html.php');
 
 /* lets get the global vars we may need */
-$key  = $_COOKIE['key'];
+sqgetGlobalVar('key',       $key,           SQ_COOKIE);
 
-$username = $_SESSION['username'];
-$onetimepad = $_SESSION['onetimepad'];
-$base_uri = $_SESSION['base_uri'];
-$delimiter = $_SESSION['delimiter'];
+sqgetGlobalVar('username',  $username,      SQ_SESSION);
+sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
+sqgetGlobalVar('base_uri',  $base_uri,      SQ_SESSION);
+sqgetGlobalVar('delimiter', $delimiter,     SQ_SESSION);
 
 /* From the address form */
-if ( isset($_POST['addaddr']) ) {
-    $addaddr = &$_POST['addaddr'];
-}
-if ( isset($_POST['editaddr']) ) {
-    $editaddr = &$_POST['editaddr'];
-}
-if ( isset($_POST['deladdr']) ) {
-    $deladdr = &$_POST['deladdr'];
-}
-$sel = &$_POST['sel'];
-
-if (isset($_POST['oldnick'])) {
-    $oldnick = $_POST['oldnick'];
-}
-if (isset($_POST['backend'])) {
-    $backend = $_POST['backend'];
-}
-if (isset($_POST['doedit'])) {
-    $doedit = $_POST['doedit'];
-}
+sqgetGlobalVar('addaddr',   $addaddr,   SQ_POST);
+sqgetGlobalVar('editaddr',  $editaddr,  SQ_POST);
+sqgetGlobalVar('deladdr',   $deladdr,   SQ_POST);
+sqgetGlobalVar('sel',       $sel,       SQ_POST);
+sqgetGlobalVar('oldnick',   $oldnick,   SQ_POST);
+sqgetGlobalVar('backend',   $backend,   SQ_POST);
+sqgetGlobalVar('doedit',    $doedit,    SQ_POST); 
 
 /* Make an input field */
 function adressbook_inp_field($label, $field, $name, $size, $values, $add) {
@@ -68,8 +56,25 @@ function adressbook_inp_field($label, $field, $name, $size, $values, $add) {
 
 /* Output form to add and modify address data */
 function address_form($name, $submittext, $values = array()) {
-    global $color;
+    global $color, $squirrelmail_language;
     
+    if ($squirrelmail_language == 'ja_JP')
+        {
+    echo html_tag( 'table',
+                       adressbook_inp_field(_("Nickname"),     'nickname', $name, 15, $values,
+                           ' <SMALL>' . _("Must be unique") . '</SMALL>') .
+                       adressbook_inp_field(_("E-mail address"),  'email', $name, 45, $values, '') .
+                       adressbook_inp_field(_("Last name"),    'lastname', $name, 45, $values, '') .
+                       adressbook_inp_field(_("First name"),  'firstname', $name, 45, $values, '') .
+                       adressbook_inp_field(_("Additional info"), 'label', $name, 45, $values, '') .
+                       html_tag( 'tr',
+                           html_tag( 'td',
+                                       '<INPUT TYPE=submit NAME="' . $name . '[SUBMIT]" VALUE="' .
+                                       $submittext . '">',
+                                   'center', $color[4], 'colspan="2"')
+                       )
+    , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n";
+        } else {
     echo html_tag( 'table',
                        adressbook_inp_field(_("Nickname"),     'nickname', $name, 15, $values,
                            ' <SMALL>' . _("Must be unique") . '</SMALL>') .
@@ -85,6 +90,7 @@ function address_form($name, $submittext, $values = array()) {
                        )
     , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n";
 }
+}
 
 /* Open addressbook, with error messages on but without LDAP (the *
  * second "true"). Don't need LDAP here anyway                    */
@@ -107,12 +113,12 @@ $form_url = 'addressbook.php';
 
 
 /* Handle user's actions */
-if($_SERVER['REQUEST_METHOD'] == 'POST') {
+if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST') {
 
     /**************************************************
      * Add new address                                *
      **************************************************/
-    if (!empty($addaddr['nickname'])) {
+    if (isset($addaddr)) {
         foreach( $addaddr as $k => $adr ) {
             $addaddr[$k] = strip_tags( $adr );
         }
@@ -227,7 +233,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
                              echo html_tag( 'table',
                                 html_tag( 'tr',
                                    html_tag( 'td',
-                                      "\n". '<br><strong><font color="' . $color[2] .
+                                      "\n". '<strong><font color="' . $color[2] .
                                       '">' . _("ERROR") . ': ' . $abook->error . '</font></strong>' ."\n",
                                       'center' )
                                    ),
@@ -239,10 +245,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
                                  html_tag( 'table',
                                      html_tag( 'tr',
                                          html_tag( 'td',
-                                                    "\n". '<br><strong>' . _("Update address") . '</strong>' ."\n",
+                                                    "\n". '<strong>' . _("Update address") . '</strong>' ."\n",
                                          'center', $color[0] )
                                      ),
-                                 'center', '', 'width="100%"' ) .
+                                 'center', '', 'width="100%"' );
                             address_form("editaddr", _("Update address"), $newdata);
                             echo '<INPUT TYPE=hidden NAME=oldnick VALUE="' .
                                  htmlspecialchars($oldnick) . "\">\n" .
@@ -357,6 +363,18 @@ if ($showaddrlist) {
             /* Print one row */
             $tr_bgcolor = '';
             if ($line % 2) { $tr_bgcolor = $color[0]; }
+            if ($squirrelmail_language == 'ja_JP')
+                {
+            echo html_tag( 'tr', '') .
+                html_tag( 'td',
+                          '<SMALL>' .
+                          '<INPUT TYPE=checkbox ' . $selected . ' NAME="sel[]" VALUE="' .
+                          $row['backend'] . ':' . $row['nickname'] . '"></SMALL>' ,
+                          'center', '', 'valign="top" width="1%"' ) .
+                html_tag( 'td', '&nbsp;' . $row['nickname'] . '&nbsp;', 'left', '', 'valign="top" width="1%" nowrap' ) . 
+                html_tag( 'td', '&nbsp;' . $row['lastname'] . ' ' . $row['firstname'] . '&nbsp;', 'left', '', 'valign="top" width="1%" nowrap' ) .
+                html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . '&nbsp;';
+                } else {
             echo html_tag( 'tr', '') .
             html_tag( 'td',
                 '<SMALL>' .
@@ -366,14 +384,11 @@ if ($showaddrlist) {
             html_tag( 'td', '&nbsp;' . $row['nickname'] . '&nbsp;', 'left', '', 'valign="top" width="1%" nowrap' ) .
             html_tag( 'td', '&nbsp;' . $row['name'] . '&nbsp;', 'left', '', 'valign="top" width="1%" nowrap' ) .
             html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . '&nbsp;';
+                }
             $email = $abook->full_address($row);
-            if ($compose_new_win == '1') {
-                echo '<a href="javascript:void(0)" onclick=comp_in_new(false,"compose.php?send_to='.rawurlencode($email).'")>';
-            }
-            else {
-                echo '<A HREF="compose.php?send_to=' . rawurlencode($email).'">';
-            }
-            echo htmlspecialchars($row['email']) . '</A>&nbsp;</td>'."\n".
+            echo makeComposeLink('src/compose.php?send_to='.rawurlencode($email),
+                 htmlspecialchars($row['email']) ) .
+            '&nbsp;</td>'."\n".
             html_tag( 'td', '&nbsp;' . htmlspecialchars($row['label']) . '&nbsp;', 'left', '', 'valign="top" width="1%"' ) .
             "</tr>\n";
             $line++;