}
$property_types = OC_Contacts_App::getAddPropertyOptions();
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
-$categories = OC_Contacts_App::$categories->categories();
+$categories = OC_Contacts_App::getCategories();
+if(count($categories) == 0) {
+ $vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
+ if(count($vcaddressbooks) > 0) {
+ $vcaddressbookids = array();
+ foreach($vcaddressbooks as $vcaddressbook) {
+ $vcaddressbookids[] = $vcaddressbook['id'];
+ }
+ $vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
+ if(count($vccontacts) == 0) {
+ bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
+ }
+
+ $cards = array();
+ foreach($vccontacts as $vccontact) {
+ $cards[] = $vccontact['carddata'];
+ }
+
+ OC_Contacts_App::$categories->rescan($cards);
+ $categories = OC_Contacts_App::$categories->categories();
+ }
+}
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
$tmpl->assign('property_types',$property_types);
-$tmpl->assign('categories',OC_Contacts_App::getCategories());
$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('categories',$categories);
$tmpl->assign('addressbooks', $addressbooks);