mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-11-29 11:24:11 +01:00
Some cleanups. cc @LEDfan
This commit is contained in:
parent
fd2b7423a6
commit
f75dee996e
@ -46,7 +46,7 @@ class AddressbookProvider implements \OCP\IAddressBook {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param integer $id
|
||||
* @param AddressBook $addressBook
|
||||
*/
|
||||
public function __construct($addressBook) {
|
||||
$this->addressBook = $addressBook;
|
||||
|
@ -101,7 +101,8 @@ class LocalUsers extends AbstractBackend {
|
||||
"id" => $addressBookId,
|
||||
"displayname" => (string)self::$l10n->t('On this %s', array(self::$defaults->getName())),
|
||||
"description" => (string)self::$l10n->t('On this %s', array(self::$defaults->getName())),
|
||||
"ctag" => time(),
|
||||
"lastmodified" => time(),
|
||||
/* FIXME: we need on 'owner' here */
|
||||
"permissions" => \OCP\PERMISSION_READ,
|
||||
"backend" => $this->name,
|
||||
"active" => 1
|
||||
@ -124,7 +125,7 @@ class LocalUsers extends AbstractBackend {
|
||||
if (\OCP\DB::isError($result)) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: '
|
||||
. \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
|
||||
return true;
|
||||
return $contacts;
|
||||
} else {
|
||||
while($row = $result->fetchRow()){
|
||||
$row['permissions'] = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE;
|
||||
@ -135,7 +136,7 @@ class LocalUsers extends AbstractBackend {
|
||||
} catch(\Exception $e) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__.' exception: '
|
||||
. $e->getMessage(), \OCP\Util::ERROR);
|
||||
return array();
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
}
|
||||
@ -156,7 +157,7 @@ class LocalUsers extends AbstractBackend {
|
||||
if (\OCP\DB::isError($result)) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: '
|
||||
. \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
|
||||
return array();
|
||||
return null;
|
||||
} else {
|
||||
$row = $result->fetchRow();
|
||||
$row['permissions'] = \OCP\PERMISSION_READ | \OCP\PERMISSION_UPDATE;
|
||||
@ -165,7 +166,7 @@ class LocalUsers extends AbstractBackend {
|
||||
} catch(\Exception $e) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__.' exception: '
|
||||
. $e->getMessage(), \OCP\Util::ERROR);
|
||||
return array();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +183,7 @@ class LocalUsers extends AbstractBackend {
|
||||
$sql = 'INSERT INTO ' . $this->cardsTableName . ' ('
|
||||
. 'id, '
|
||||
. 'addressbookid, '
|
||||
. 'fullname, '
|
||||
. 'fullname, ' /* Change to displayname*/
|
||||
. 'carddata, '
|
||||
. 'lastmodified'
|
||||
. ') VALUES ('
|
||||
@ -308,8 +309,8 @@ class LocalUsers extends AbstractBackend {
|
||||
* This is a hack so backends can have different search functions.
|
||||
* @return \OCA\Contacts\LocalUsersAddressbookProvider
|
||||
*/
|
||||
public function getSearchProvider(){
|
||||
return new LocalUsersAddressbookProvider($this);
|
||||
public function getSearchProvider($addressBook) {
|
||||
return new LocalUsersAddressbookProvider($addressBook);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -408,4 +409,12 @@ class LocalUsers extends AbstractBackend {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't cache
|
||||
*/
|
||||
public function lastModifiedAddressBook($addressBookId) {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,8 +52,12 @@ class LocalUsersAddressbookProvider implements \OCP\IAddressBook {
|
||||
*/
|
||||
private $backend;
|
||||
|
||||
public function __construct(LocalUsers $backend) {
|
||||
$this->backend = $backend;
|
||||
/**
|
||||
* Constructor
|
||||
* @param AddressBook $addressBook
|
||||
*/
|
||||
public function __construct(AddressBook $addressBook) {
|
||||
$this->addressBook = $addressBook;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +68,7 @@ class LocalUsersAddressbookProvider implements \OCP\IAddressBook {
|
||||
*/
|
||||
public function search($pattern, $searchProperties, $options) {
|
||||
// First make sure the database is updated
|
||||
$this->backend->updateDatabase();
|
||||
$this->addressBook->getBackend()->updateDatabase();
|
||||
|
||||
$ids = array();
|
||||
$results = array();
|
||||
|
Loading…
Reference in New Issue
Block a user