} elseif ($action == 'filterContact') { /////////////////////////////////////////////////////////////////////////////// if(function_exists('user_modify_contact_search_pattern')) { $params['searchpattern'] = user_modify_contact_search_pattern($params['searchpattern']); } $addressbooks = OBM_AddressBook::search(); if($params['contactfilter']) $pattern = 'displayname:'.$params['contactfilter']; $contacts = $addressbooks->searchContacts($params['searchpattern'].' '.$pattern); $subTemplate['contacts'] = new OBM_Template('contacts'); $subTemplate['contacts']->set('fields', get_display_pref($GLOBALS['obm']['uid'], 'contact')); } elseif ($action == 'storeAddressBook') { /////////////////////////////////////////////////////////////////////////////// if($params['addressbook_id']) { OBM_AddressBook::store($params); } else { OBM_AddressBook::create($params); } $addressbooks = OBM_AddressBook::search(); $subTemplate['addressbooks'] = new OBM_Template('addressbooks'); //FIXME Erreur de droit } elseif ($action == 'deleteAddressBook') { /////////////////////////////////////////////////////////////////////////////// OBM_AddressBook::delete($params); $addressbooks = OBM_AddressBook::search(); $subTemplate['addressbooks'] = new OBM_Template('addressbooks'); //FIXME Erreur de droit } elseif ($action == 'toggleSyncable') { /////////////////////////////////////////////////////////////////////////////// OBM_AddressBook::store($params); $addressbooks = OBM_AddressBook::search(); $subTemplate['addressbooks'] = new OBM_Template('addressbooks');
/** * Perform the import of the contacts */ function user_contacts_import($vcf_contacts, $user_id) { include_once 'php/contact/addressbook.php'; include_once 'php/contact/contact_query.inc'; $remember_uid = $GLOBALS['obm']['uid']; $GLOBALS['obm']['uid'] = $user_id; // some kind of sudo $user_id $addressbooks = OBM_AddressBook::search(); $addressBookByName = array(); foreach ($addressbooks as $addressbook) { if ($addressbook->name != 'public_contacts') { // I'd better filter this addressbook on search if ($addressbook->isDefault || isset($vcf_contacts[$addressbook->name])) { $addressbook->reset(); $addressBookByName[$addressbook->name] = $addressbook; } else { OBM_AddressBook::delete(array('addressbook_id' => $addressbook->id)); } } } foreach ($vcf_contacts as $addBookName => $fd) { if (isset($addressBookByName[$addBookName])) { $addressbook = $addressBookByName[$addBookName]; } else { $addressbook = OBM_AddressBook::create(array('name' => $addBookName)); } if ($fd && $addressbook->write) { $ids = run_query_vcard_insert(array('vcard_fd' => $fd), $addressbook); } } $GLOBALS['obm']['uid'] = $remember_uid; }