diff --git a/appinfo/app.php b/appinfo/app.php index 60112aea..c36e43df 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -68,3 +68,4 @@ if (\OCP\User::isLoggedIn()) { } } } + diff --git a/lib/backend/localusers.php b/lib/backend/localusers.php index 0244ad19..69facf06 100644 --- a/lib/backend/localusers.php +++ b/lib/backend/localusers.php @@ -26,7 +26,8 @@ use OCA\Contacts\Contact, OCA\Contacts\VObject\VCard, OCA\Contacts\Utils\Properties, Sabre\VObject\Reader, - OCA\Contacts\Addressbook; + OCA\Contacts\Addressbook, + OCA\Contacts\LocalUsersAddressbookProvider; /** * Contact backend for storing all the ownCloud users in this installation. @@ -297,4 +298,8 @@ class LocalUsers extends AbstractBackend { return false; } } + + public function getSearchProvider(){ + return new LocalUsersAddressbookProvider(); + } } diff --git a/lib/localusersaddressbookprovider.php b/lib/localusersaddressbookprovider.php new file mode 100644 index 00000000..433d6996 --- /dev/null +++ b/lib/localusersaddressbookprovider.php @@ -0,0 +1,86 @@ +execute(array(\OCP\User::getUser(), '%' . $pattern . "%", '%' . $pattern . "%")); + } elseif(in_array("FN", $searchProperties)){ + echo "fn"; + $query = 'SELECT * FROM `*PREFIX*contacts_ocu_cards` WHERE addressbookid = ? AND `fullname` LIKE ? '; + $stmt = \OCP\DB::prepare($query); + $result = $stmt->execute(array(\OCP\User::getUser(), '%' . $pattern . "%")); + } elseif(in_array("id", $searchProperties)){ + echo "id"; + $query = 'SELECT * FROM `*PREFIX*contacts_ocu_cards` WHERE addressbookid = ? AND `id` LIKE ? '; + $stmt = \OCP\DB::prepare($query); + $result = $stmt->execute(array(\OCP\User::getUser(), '%' . $pattern . "%")); + } else { + echo "else"; + $query = 'SELECT * FROM `*PREFIX*contacts_ocu_cards` WHERE addressbookid = ?'; + $stmt = \OCP\DB::prepare($query); + $result = $stmt->execute(array(\OCP\User::getUser())); + } + + if (\OCP\DB::isError($result)) { + \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), + \OCP\Util::ERROR); + return false; + } + + $contacts = array(); + + while( $row = $result->fetchRow()) { + $contacts[] = $row['id']; + } + + return $contacts; + } + + public function getKey(){ + + } + + /** + * In comparison to getKey() this function returns a human readable (maybe translated) name + * @return mixed + */ + public function getDisplayName(){ + +} + + public function createOrUpdate($properties){ + + } + + /** + * @return mixed + */ + public function getPermissions(){ + + } + + /** + * @param object $id the unique identifier to a contact + * @return bool successful or not + */ + public function delete($id){ + + } + +}