From 5e2f7bfda9ff5c05c157df894e0675958f634b6c Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sat, 6 Aug 2011 23:29:25 +0200 Subject: [PATCH] Small details in contacts --- apps/contacts/appinfo/app.php | 2 +- apps/contacts/index.php | 13 +++++++++++-- apps/contacts/js/interface.js | 5 +++++ apps/contacts/templates/index.php | 11 +++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index f38a45f279..7ff4726525 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -13,6 +13,6 @@ OC_App::addNavigationEntry( array( 'order' => 10, 'href' => OC_Helper::linkTo( 'contacts', 'index.php' ), 'icon' => OC_Helper::imagePath( 'contacts', 'icon.png' ), - 'name' => 'Addressbook' )); + 'name' => 'Contacts' )); ?> diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 2d5bcefd87..1e01b1c9fb 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -20,7 +20,7 @@ * */ -function contactsort($a,$b){ +function contacts_namesort($a,$b){ return strcmp($a['name'],$b['name']); } @@ -33,12 +33,20 @@ if( !OC_User::isLoggedIn()){ exit(); } +// Check if the user has an addressbook +$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_User::getUser()); +if( count($addressbooks) == 0){ + OC_Contacts_Addressbook::addAddressbook(OC_User::getUser(),'default','Default Address Book'); +} + // Load the files we need OC_App::setActiveNavigationEntry( 'contacts_index' ); // Load a specific user? $id = isset( $_GET['id'] ) ? $_GET['id'] : null; +// sort addressbooks (use contactsort) +usort($addressbooks,'contacts_namesort'); // Addressbooks to load $openaddressbooks = explode(';',OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null)); @@ -51,7 +59,7 @@ foreach( $openaddressbooks as $addressbook ){ } -usort($contacts,'contactsort'); +usort($contacts,'contacts_namesort'); $details = array(); if( !is_null($id) || count($contacts)){ @@ -62,6 +70,7 @@ if( !is_null($id) || count($contacts)){ // Process the template $tmpl = new OC_Template( 'contacts', 'index', 'user' ); +$tmpl->assign('addressbooks', $addressbooks); $tmpl->assign('contacts', $contacts); $tmpl->assign('details', $details ); $tmpl->assign('id',$id); diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 045562b496..6af160b392 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -11,4 +11,9 @@ $(document).ready(function(){ }); return false; }); + + $('.contacts_addressbooksexpander').click(function(){ + $('.contacts_addressbooksdetails').toggle(); + return false; + }); }); diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 0cd214bfb1..ca189cb4c8 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -3,6 +3,17 @@ OC_Util::addScript('contacts','interface'); OC_Util::addStyle('contacts','styles'); ?> +
+
+ Addressbooks +
+ +