summaryrefslogtreecommitdiffstats
path: root/apps/contacts/index.php
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2011-12-09 15:10:51 +0100
committerThomas Tanghus <thomas@tanghus.net>2011-12-09 15:10:51 +0100
commitb3661adf028570f6158dfd5092ecb1398d5be0df (patch)
treeeb421923ccdea71a34203a83fbec16732760b196 /apps/contacts/index.php
parent830efdccac71ebbd4ee5f9414abd0878f2ff9349 (diff)
downloadnextcloud-server-b3661adf028570f6158dfd5092ecb1398d5be0df.tar.gz
nextcloud-server-b3661adf028570f6158dfd5092ecb1398d5be0df.zip
Various fixes to multiple address books handling
Diffstat (limited to 'apps/contacts/index.php')
-rw-r--r--apps/contacts/index.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 57c28a5761c..917335fb68b 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -21,7 +21,7 @@
*/
function contacts_namesort($a,$b){
- return strcmp($a['name'],$b['name']);
+ return strcmp($a['fullname'],$b['fullname']);
}
// Init owncloud
@@ -32,16 +32,17 @@ OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
// Check if the user has an addressbook
-$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
-if( count($addressbooks) == 0){
- OC_Contacts_Addressbook::add(OC_User::getUser(),'default','Default Address Book');
- $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
-}
-$prefbooks = OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null);
-if(is_null($prefbooks)){
- $prefbooks = $addressbooks[0]['id'];
- OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',$prefbooks);
-}
+$openaddressbooks = OC_Contacts_Addressbook::activeAddressbookIds(OC_User::getUser());
+OC_Log::write('contacts','Got IDs'.implode(',', $openaddressbooks),OC_Log::DEBUG);
+// if( count($addressbooks) == 0){
+// OC_Contacts_Addressbook::add(OC_User::getUser(),'default','Default Address Book');
+// $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
+// }
+// $prefbooks = OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null);
+// if(is_null($prefbooks)){
+// $prefbooks = $addressbooks[0]['id'];
+// OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',$prefbooks);
+// }
// Load the files we need
OC_App::setActiveNavigationEntry( 'contacts_index' );
@@ -52,16 +53,18 @@ $id = isset( $_GET['id'] ) ? $_GET['id'] : null;
// sort addressbooks (use contactsort)
usort($addressbooks,'contacts_namesort');
// Addressbooks to load
-$openaddressbooks = explode(';',$prefbooks);
+//$openaddressbooks = explode(';',$prefbooks);
$contacts = array();
foreach( $openaddressbooks as $addressbook ){
$addressbookcontacts = OC_Contacts_VCard::all($addressbook);
+ OC_Log::write('contacts','index.php. Getting contacts for: '.$addressbook,OC_Log::DEBUG);
foreach( $addressbookcontacts as $contact ){
if(is_null($contact['fullname'])){
continue;
}
- $contacts[] = array( 'name' => $contact['fullname'], 'id' => $contact['id'] );
+ $contacts[] = $contact;
+ //$contacts[] = array( 'name' => $contact['fullname'], 'id' => $contact['id'] );
}
}
@@ -75,10 +78,6 @@ if( !is_null($id) || count($contacts)){
$details = OC_Contacts_VCard::structureContact($vcard);
}
-$l10n = new OC_L10N('contacts');
-$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
-$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
-
// Include Style and Script
OC_Util::addScript('contacts','interface');
OC_Util::addStyle('contacts','styles');
@@ -86,6 +85,10 @@ OC_Util::addStyle('contacts','formtastic');
OC_Util::addScript('', 'jquery.multiselect');
OC_Util::addStyle('', 'jquery.multiselect');
+$l10n = new OC_L10N('contacts');
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
// Process the template
$tmpl = new OC_Template( 'contacts', 'index', 'user' );
$tmpl->assign('adr_types',$adr_types);