From 4fda6af725ea775750905983255ab3dc9ceeb2b9 Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Mon, 9 Apr 2012 16:29:56 +0200
Subject: [PATCH] Contacts: Fix for not being able to add contact to
 empty/non-existant address book.

---
 apps/contacts/ajax/addcontact.php | 2 --
 apps/contacts/css/contacts.css    | 2 +-
 apps/contacts/lib/addressbook.php | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index 947b35bab5..68da54655a 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -47,8 +47,6 @@ OC_Contacts_App::getAddressbook( $aid ); // is owner access check
 
 $fn = trim($_POST['fn']);
 $n = trim($_POST['n']);
-debug('N: '.$n);
-debug('FN: '.$fn);
 
 $vcard = new OC_VObject('VCARD');
 $vcard->setUID();
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 5d3ebf65fb..2d20794384 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -56,7 +56,7 @@ dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; }
 
 .contactpart legend { width:auto; padding:.3em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
 #cropbox { margin: auto; }
-#contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; padding: 0.5em; margin: 0.3em; cursor: pointer; background: url(../../../core/img/loading.gif) no-repeat center center; display: block; /* clear: right;*/ }
+#contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; margin: 0.3em; cursor: pointer; background: url(../../../core/img/loading.gif) no-repeat center center; display: block; /* clear: right;*/ }
 #contacts_details_photo:hover { background: #fff; }
 /*#contacts_details_photo_progress { margin: 0.3em 0.3em 0.3em 7em; clear: left; }*/
 /* Address editor */
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 052c19e55f..9061fa1914 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -169,7 +169,7 @@ class OC_Contacts_Addressbook{
 			$uid = OC_User::getUser();
 		}
 		$prefbooks = OC_Preferences::getValue($uid,'contacts','openaddressbooks',null);
-		if(is_null($prefbooks)){
+		if(!$prefbooks){
 			$addressbooks = OC_Contacts_Addressbook::all($uid);
 			if(count($addressbooks) == 0){
 				OC_Contacts_Addressbook::add($uid,'default','Default Address Book');
-- 
GitLab