1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00
This commit is contained in:
LEDfan 2014-04-06 08:39:58 +02:00
parent 17d7ed7e99
commit c769e33a49

View File

@ -51,14 +51,36 @@ class LocalUsers extends AbstractBackend {
*/ */
private $cardsTableName = '*PREFIX*contacts_ocu_cards'; private $cardsTableName = '*PREFIX*contacts_ocu_cards';
/**
* The table that holds the properties of the contacts.
* This is used to provice a search function.
* @var string
*/
private $indexTableName = '*PREFIX*contacts_ocu_cards_properties'; private $indexTableName = '*PREFIX*contacts_ocu_cards_properties';
/**
* All possible properties which can be stored in the $indexTableName.
* @var string
*/
private $indexProperties = array( private $indexProperties = array(
'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME', 'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO'); 'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO');
public function __construct($userid){ /**
* language object
* @var OC_L10N
*/
public static $l10n;
/**
* Defaults object
* @var OC_Defaults
*/
public static $defaults;
public function __construct($userid){
self::$l10n = \OCP\Util::getL10N('contacts');
self::$defaults = new \OCP\Defaults();
$this->userid = $userid ? $userid : \OCP\User::getUser(); $this->userid = $userid ? $userid : \OCP\User::getUser();
} }
@ -76,8 +98,8 @@ class LocalUsers extends AbstractBackend {
public function getAddressBook($addressBookId, array $options = array()) { public function getAddressBook($addressBookId, array $options = array()) {
$addressbook = array( $addressbook = array(
"id" => $addressBookId, "id" => $addressBookId,
"displayname" => 'Local Users', "displayname" => self::$l10n->t('On this') . self::$defaults->getName(),
"description" => 'Local Users', "description" => self::$l10n->t('On this') . self::$defaults->getName(),
"ctag" => time(), "ctag" => time(),
"permissions" => \OCP\PERMISSION_READ, "permissions" => \OCP\PERMISSION_READ,
"backend" => $this->name, "backend" => $this->name,
@ -227,6 +249,7 @@ class LocalUsers extends AbstractBackend {
} }
} }
} }
/** /**
* Help function to remove contacts from an addressbook. * Help function to remove contacts from an addressbook.
* This only happens when an admin remove an ownCloud user * This only happens when an admin remove an ownCloud user
@ -305,10 +328,21 @@ class LocalUsers extends AbstractBackend {
} }
} }
/**
* This is a hack so backends can have different search functions.
* @return \OCA\Contacts\LocalUsersAddressbookProvider
*/
public function getSearchProvider(){ public function getSearchProvider(){
return new LocalUsersAddressbookProvider(); return new LocalUsersAddressbookProvider();
} }
/**
* Updates the index table. All properties of a contact are stored in it.
* Needed for the search function.
* @param type $contactId
* @param type $vcard
* @return boolean
*/
private function updateIndex($contactId, $vcard){ private function updateIndex($contactId, $vcard){
// Utils\Properties::updateIndex($parameters['id'], $contact); // Utils\Properties::updateIndex($parameters['id'], $contact);
$this->purgeIndex($contactId); $this->purgeIndex($contactId);
@ -348,6 +382,13 @@ class LocalUsers extends AbstractBackend {
} }
} }
/**
* Remove all indexes from the table.
* This is always called before adding new properties.
* @param type $contactId
* @param type $vcard
* @return boolean
*/
private function purgeIndex($id){ private function purgeIndex($id){
// Remove all indexes from the table // Remove all indexes from the table
try { try {