1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Clean indentation

This commit is contained in:
Thomas Tanghus 2014-04-17 01:40:41 +02:00
parent 2e9ee72451
commit a7ea3e4706

View File

@ -64,7 +64,8 @@ class LocalUsers extends AbstractBackend {
*/
private $indexProperties = array(
'BDAY', 'UID', 'N', 'FN', 'TITLE', 'ROLE', 'NOTE', 'NICKNAME',
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO');
'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL', 'GEO'
);
/**
* language object
@ -78,7 +79,7 @@ class LocalUsers extends AbstractBackend {
*/
public static $defaults;
public function __construct($userid){
public function __construct($userid) {
self::$l10n = \OCP\Util::getL10N('contacts');
self::$defaults = new \OCP\Defaults();
$this->userid = $userid ? $userid : \OCP\User::getUser();
@ -112,7 +113,7 @@ class LocalUsers extends AbstractBackend {
* {@inheritdoc}
* There are as many contacts in this addressbook as in this ownCloud installation
*/
public function getContacts($addressbookid, array $options = array()){
public function getContacts($addressbookid, array $options = array()) {
$this->updateDatabase();
$contacts = array();
try{
@ -146,7 +147,7 @@ class LocalUsers extends AbstractBackend {
* If your username is 'foo' and you want to retrieve the contact with
* ownCloud username 'bar' the params would be: $addressbookid = 'foo'; $id = 'bar';
*/
public function getContact($addressbookid, $id, array $options = array()){
public function getContact($addressbookid, $id, array $options = array()) {
try{
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
$query = \OCP\DB::prepare($sql);
@ -175,9 +176,9 @@ class LocalUsers extends AbstractBackend {
* @param string $addressBookId
* @return bool
*/
private function addContacts($contacts, $addressbookid){
private function addContacts($contacts, $addressbookid) {
foreach($contacts as $user){
try{
try {
$sql = 'INSERT INTO ' . $this->cardsTableName . ' ('
. 'id, '
. 'addressbookid, '
@ -232,9 +233,9 @@ class LocalUsers extends AbstractBackend {
* @param string $addressBookId
* @return bool
*/
private function removeContacts($contacts, $addressbookid){
private function removeContacts($contacts, $addressbookid) {
foreach($contacts as $user){
try{
try {
$sql = 'DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
$query = \OCP\DB::prepare($sql);
$result = $query->execute(array($this->userid, $user));
@ -318,7 +319,7 @@ class LocalUsers extends AbstractBackend {
* @param type $vcard
* @return boolean
*/
private function updateIndex($contactId, $vcard){
private function updateIndex($contactId, $vcard) {
// Utils\Properties::updateIndex($parameters['id'], $contact);
$this->purgeIndex($contactId);
$updatestmt = \OCP\DB::prepare('INSERT INTO `' . $this->indexTableName . '` '
@ -364,7 +365,7 @@ class LocalUsers extends AbstractBackend {
* @param type $vcard
* @return boolean
*/
private function purgeIndex($id){
private function purgeIndex($id) {
// Remove all indexes from the table
try {
$query = \OCP\DB::prepare('DELETE FROM `' . $this->indexTableName . '`'
@ -376,7 +377,7 @@ class LocalUsers extends AbstractBackend {
}
}
public function updateDatabase(){
public function updateDatabase() {
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?';
$query = \OCP\DB::prepare($sql);
$result = $query->execute(array($this->userid));
@ -387,7 +388,7 @@ class LocalUsers extends AbstractBackend {
return true;
} else {
$contactsId = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$contactsId[] = $row['id'];
}
@ -395,17 +396,16 @@ class LocalUsers extends AbstractBackend {
$add = array_diff($users, $contactsId);
$remove = array_diff($contactsId, $users);
if(count($add) > 0){
if(count($add) > 0) {
$this->addContacts($add, $addressbookid);
$recall = true;
}
if(count($remove) > 0){
if(count($remove) > 0) {
$this->removeContacts($remove, $addressbookid);
$recall = true;
}
return true;
}
}
}