Uneditable address book entries no longer have checkboxes next to them on addresses...
[squirrelmail.git] / src / addressbook.php
index 262eb2d1a928a841336d41a614ba1597e83ec1fc..7c3ae718ad57ec236ee792cdfe91c993f06f1565 100644 (file)
@@ -43,6 +43,9 @@ sqgetGlobalVar('oldnick',   $oldnick,   SQ_POST);
 sqgetGlobalVar('backend',   $backend,   SQ_POST);
 sqgetGlobalVar('doedit',    $doedit,    SQ_POST);
 
+/* Get sorting order */
+$abook_sort_order = get_abook_sort();
+
 /**
  * Make an input field
  * @param string $label
@@ -159,14 +162,11 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P
      * Add new address                                *
      **************************************************/
     if (isset($addaddr)) {
-        foreach( $addaddr as $k => $adr ) {
-            $addaddr[$k] = strip_tags( $adr );
+        if (isset($backend)) {
+            $r = $abook->add($addaddr, $backend);
+        } else {
+            $r = $abook->add($addaddr, $abook->localbackend);
         }
-    if (isset($backend)) {
-      $r = $abook->add($addaddr, $backend);
-    } else {
-      $r = $abook->add($addaddr, $abook->localbackend);
-    }
 
         /* Handle error messages */
         if (!$r) {
@@ -377,28 +377,17 @@ if ($showaddrlist) {
                       html_tag( 'tr', "\n" .
                           html_tag( 'th', ' ', 'left', '', 'width="1%"' ) . "\n" .
                           html_tag( 'th', _("Nickname") .
-                                    " <a href=\"$form_url?abook_sort=nickname\">".
-                                    "<img src=\"../images/sort_none.png\" border=\"0\" width=\"12\" height=\"10\" alt=\"sort by nickname\" title=\"" .
-                                    _("Click here to change the sorting of the address list") . 
-                                    "\" /></a>", 'left', '', 'width="1%"' ) . "\n" .
+                                    show_abook_sort_button($abook_sort_order, _("sort by nickname"), 0, 1)
+                                    , 'left', '', 'width="1%"' ) . "\n" .
                           html_tag( 'th', _("Name") . 
-                                    " <a href=\"$form_url?abook_sort=name\">" .
-                                    "<img src=\"../images/sort_none.png\" border=\"0\" width=\"12\" height=\"10\" " .
-                                    "alt=\"sort by name\" title=\"" .
-                                    _("Click here to change the sorting of the address list") . 
-                                    "\" /></a>", 'left', '', 'width="1%"' ) . "\n" .
+                                    show_abook_sort_button($abook_sort_order, _("sort by name"), 2, 3)
+                                    , 'left', '', 'width="1%"' ) . "\n" .
                           html_tag( 'th', _("E-mail") . 
-                                    " <a href=\"$form_url?abook_sort=email\">" .
-                                    "<img src=\"../images/sort_none.png\" border=\"0\" width=\"12\" height=\"10\" " .
-                                    "alt=\"sort by email\" title=\"" .
-                                    _("Click here to change the sorting of the address list") . 
-                                    "\" /></a>", 'left', '', 'width="1%"' ) . "\n" .
+                                    show_abook_sort_button($abook_sort_order, _("sort by email"), 4, 5)
+                                    , 'left', '', 'width="1%"' ) . "\n" .
                           html_tag( 'th', _("Info") .
-                                    " <a href=\"$form_url?abook_sort=label\">" .
-                                    "<img src=\"../images/sort_none.png\" border=\"0\" width=\"12\" height=\"10\" " .
-                                    "alt=\"sort by info\" title=\"" .
-                                    _("Click here to change the sorting of the address list") . 
-                                    "\" /></a>", 'left', '', 'width="1%"' ) . "\n",
+                                    show_abook_sort_button($abook_sort_order, _("sort by info"), 6, 7)
+                                    , 'left', '', 'width="1%"' ) . "\n",
                                 '', $color[9] ) . "\n";
                 }
 
@@ -423,28 +412,43 @@ if ($showaddrlist) {
             /* Check if this user is selected */
             $selected = in_array($row['backend'] . ':' . $row['nickname'], $defselected);
     
-            /* Print one row */
-            $tr_bgcolor = '';
-            if ($line % 2) { $tr_bgcolor = $color[0]; }
+            /* Print one row, with alternating color */
+            if ($line % 2) { 
+                $tr_bgcolor = $color[12];
+            } else {
+                $tr_bgcolor = $color[4];
+            }
             if ($squirrelmail_language == 'ja_JP')
                 {
-            echo html_tag( 'tr', '', '', $tr_bgcolor) .
-                html_tag( 'td',
+            echo html_tag( 'tr', '', '', $tr_bgcolor);
+            if ($abook->backends[$row['backend']]->writeable) {
+                echo html_tag( 'td',
                           '<small>' .
                           addCheckBox('sel[]', $selected, $row['backend'].':'.$row['nickname']).
                           '</small>' ,
-                          'center', '', 'valign="top" width="1%"' ) .
-                html_tag( 'td', '&nbsp;' . $row['nickname'] . '&nbsp;', 'left', '', 'valign="top" width="1%" nowrap' ) . 
+                          'center', '', 'valign="top" width="1%"' );
+            } else {
+                echo html_tag( 'td',
+                        '&nbsp;' ,
+                        'center', '', 'valign="top" width="1%"' );
+            }
+            echo 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', '', '', $tr_bgcolor) .
-            html_tag( 'td',
+            echo html_tag( 'tr', '', '', $tr_bgcolor);
+            if ($abook->backends[$row['backend']]->writeable) {
+                echo 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' ) .
+                'center', '', 'valign="top" width="1%"' );
+            } else {
+                echo html_tag( 'td',
+                        '&nbsp;' ,
+                        'center', '', 'valign="top" width="1%"' );
+            }
+            echo 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;';
                 }
@@ -494,4 +498,4 @@ echo "</form>\n";
 do_hook('addressbook_bottom');
 ?>
 
-</body></html>
\ No newline at end of file
+</body></html>