From 55243b590c9baaea47c78ed99c8099ff091ebad7 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 02 Mar 2010 09:48:26 -0500
Subject: [PATCH] - Hide 'add contact' icon if there's no writable address book

---
 program/steps/mail/func.inc |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index a8ef651..be3bbbf 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1170,7 +1170,8 @@
  */
 function rcmail_address_string($input, $max=null, $linked=false, $addicon=null)
 {
-  global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN;
+  global $IMAP, $RCMAIL, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN;
+  static $got_writable_abook = null;
 
   $a_parts = $IMAP->decode_address_list($input);
 
@@ -1181,6 +1182,10 @@
   $j = 0;
   $out = '';
 
+  if ($got_writable_abook === null && $books = $RCMAIL->get_address_sources(true)) {
+    $got_writable_abook = true;
+  }
+  
   foreach ($a_parts as $part) {
     $j++;
     if ($PRINT_MODE) {
@@ -1200,7 +1205,7 @@
         $out .= html::span(array('title' => $part['mailto'], 'class' => "rcmContactAddress"), Q($part['name']));
       }
 
-      if ($addicon) {
+      if ($addicon && $got_writable_abook) {
         $out .= '&nbsp;' . html::a(array(
             'href' => "#add",
             'onclick' => sprintf("return %s.command('add-contact','%s',this)", JS_OBJECT_NAME, urlencode($part['string'])),

--
Gitblit v1.9.1