Account for extra fields in address book more correctly. Also account for no global...
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 14 Aug 2006 16:12:12 +0000 (16:12 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 14 Aug 2006 16:12:12 +0000 (16:12 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11585 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/addressbook.php
templates/default/addressbook_list.tpl

index 8b5c68b..42f5d2d 100644 (file)
@@ -26,7 +26,6 @@ require_once(SM_PATH . 'functions/forms.php');
 /** lets get the global vars we may need */
 
 /* From the address form */
-//sqgetGlobalVar('change_abook',  $change_abook,  SQ_POST);
 sqgetGlobalVar('addaddr',       $addaddr,       SQ_POST);
 sqgetGlobalVar('editaddr',      $editaddr,      SQ_POST);
 sqgetGlobalVar('deladdr',       $deladdr,       SQ_POST);
@@ -79,7 +78,6 @@ $defselected  = array();
 $form_url = 'addressbook.php';
 
 /* Handle user's actions */
-//if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST' && !isset($change_abook)) {
 if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'POST') {
 
     /**************************************************
@@ -277,6 +275,7 @@ if ($showaddrlist) {
     $oTemplate->assign('addresses', $addresses);
     $oTemplate->assign('current_backend', $current_backend);
     $oTemplate->assign('backends', $list_backends);
+    $oTemplate->assign('abook_has_extra_field', $abook->add_extra_field);
         
     $oTemplate->display('addressbook_list.tpl');
     
index 4561647..0907b71 100644 (file)
@@ -8,6 +8,8 @@
  *      $current_backend - integer containing backend currently displayed.
  *      $abook_select    - string containing HTML to display the address book
  *                         selection drop down
+ *      $abook_has_extra_field - boolean TRUE if the address book contains an
+ *                         additional field.  FALSE otherwise.
  *      $backends        - array containing all available backends for selection.
  *                         This will be empty if only 1 backend is available! 
  *      $addresses - array of addresses in the address book.  Each element
@@ -46,7 +48,6 @@ extract($t);
 #echo dump_array($addresses).'<br>';
 /** Begin template **/
 $source = $addresses[$current_backend];
-$abook_has_extra_field = isset($source['Addresses'][0]) && !is_null($source['Addresses'][0]['Extra']);
 $colspan = $abook_has_extra_field ? 6 : 5;
 ?>
 <div id="addressList">
@@ -62,14 +63,22 @@ $colspan = $abook_has_extra_field ? 6 : 5;
    <input type="submit" value=<?php echo '"'._("Delete selected").'"'; ?> name="deladdr" id="deladdr" />
   </td>
   <td colspan=<?php echo '"'.($colspan - 3).'"'; ?> class="abookSwitch">
+   <?php
+    if (count($backends) > 0) {
+        ?>
    <select name="new_bnum">
     <?php
         foreach ($backends as $id=>$name) {
             echo '<option value="'.$id.'"'.($id==$current_backend ? ' selected="selected"' : '').'>'.$name.'</option>'."\n";
         }
     ?>
-    </select>
+   </select>
    <input type="submit" value=<?php echo '"'._("Change").'"'; ?> name="change_abook" id="change_abook" />
+        <?php
+    } else {
+        echo '&nbsp;';
+    }
+   ?>
   </td>
  </tr>
  <tr>