Contacts: rescan categories on load if there are none.
This commit is contained in:
parent
bd9fa658de
commit
896bff5748
1 changed files with 22 additions and 2 deletions
|
@ -34,7 +34,28 @@ if(!is_null($id)) {
|
|||
}
|
||||
$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'));
|
||||
|
@ -61,7 +82,6 @@ $tmpl = new OC_Template( "contacts", "index", "user" );
|
|||
$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);
|
||||
|
|
Loading…
Reference in a new issue