mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
Clean indentation
This commit is contained in:
parent
2e9ee72451
commit
a7ea3e4706
@ -64,7 +64,8 @@ class LocalUsers extends AbstractBackend {
|
|||||||
*/
|
*/
|
||||||
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'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* language object
|
* language object
|
||||||
@ -78,7 +79,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
*/
|
*/
|
||||||
public static $defaults;
|
public static $defaults;
|
||||||
|
|
||||||
public function __construct($userid){
|
public function __construct($userid) {
|
||||||
self::$l10n = \OCP\Util::getL10N('contacts');
|
self::$l10n = \OCP\Util::getL10N('contacts');
|
||||||
self::$defaults = new \OCP\Defaults();
|
self::$defaults = new \OCP\Defaults();
|
||||||
$this->userid = $userid ? $userid : \OCP\User::getUser();
|
$this->userid = $userid ? $userid : \OCP\User::getUser();
|
||||||
@ -112,7 +113,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* There are as many contacts in this addressbook as in this ownCloud installation
|
* 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();
|
$this->updateDatabase();
|
||||||
$contacts = array();
|
$contacts = array();
|
||||||
try{
|
try{
|
||||||
@ -146,7 +147,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* If your username is 'foo' and you want to retrieve the contact with
|
* If your username is 'foo' and you want to retrieve the contact with
|
||||||
* ownCloud username 'bar' the params would be: $addressbookid = 'foo'; $id = 'bar';
|
* 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{
|
try{
|
||||||
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
|
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
|
||||||
$query = \OCP\DB::prepare($sql);
|
$query = \OCP\DB::prepare($sql);
|
||||||
@ -175,9 +176,9 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* @param string $addressBookId
|
* @param string $addressBookId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function addContacts($contacts, $addressbookid){
|
private function addContacts($contacts, $addressbookid) {
|
||||||
foreach($contacts as $user){
|
foreach($contacts as $user){
|
||||||
try{
|
try {
|
||||||
$sql = 'INSERT INTO ' . $this->cardsTableName . ' ('
|
$sql = 'INSERT INTO ' . $this->cardsTableName . ' ('
|
||||||
. 'id, '
|
. 'id, '
|
||||||
. 'addressbookid, '
|
. 'addressbookid, '
|
||||||
@ -232,9 +233,9 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* @param string $addressBookId
|
* @param string $addressBookId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function removeContacts($contacts, $addressbookid){
|
private function removeContacts($contacts, $addressbookid) {
|
||||||
foreach($contacts as $user){
|
foreach($contacts as $user){
|
||||||
try{
|
try {
|
||||||
$sql = 'DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
|
$sql = 'DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND id = ?';
|
||||||
$query = \OCP\DB::prepare($sql);
|
$query = \OCP\DB::prepare($sql);
|
||||||
$result = $query->execute(array($this->userid, $user));
|
$result = $query->execute(array($this->userid, $user));
|
||||||
@ -318,7 +319,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* @param type $vcard
|
* @param type $vcard
|
||||||
* @return boolean
|
* @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);
|
||||||
$updatestmt = \OCP\DB::prepare('INSERT INTO `' . $this->indexTableName . '` '
|
$updatestmt = \OCP\DB::prepare('INSERT INTO `' . $this->indexTableName . '` '
|
||||||
@ -364,7 +365,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
* @param type $vcard
|
* @param type $vcard
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function purgeIndex($id){
|
private function purgeIndex($id) {
|
||||||
// Remove all indexes from the table
|
// Remove all indexes from the table
|
||||||
try {
|
try {
|
||||||
$query = \OCP\DB::prepare('DELETE FROM `' . $this->indexTableName . '`'
|
$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 = ?';
|
$sql = 'SELECT * FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?';
|
||||||
$query = \OCP\DB::prepare($sql);
|
$query = \OCP\DB::prepare($sql);
|
||||||
$result = $query->execute(array($this->userid));
|
$result = $query->execute(array($this->userid));
|
||||||
@ -387,7 +388,7 @@ class LocalUsers extends AbstractBackend {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$contactsId = array();
|
$contactsId = array();
|
||||||
while($row = $result->fetchRow()){
|
while($row = $result->fetchRow()) {
|
||||||
$contactsId[] = $row['id'];
|
$contactsId[] = $row['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,17 +396,16 @@ class LocalUsers extends AbstractBackend {
|
|||||||
|
|
||||||
$add = array_diff($users, $contactsId);
|
$add = array_diff($users, $contactsId);
|
||||||
$remove = array_diff($contactsId, $users);
|
$remove = array_diff($contactsId, $users);
|
||||||
if(count($add) > 0){
|
if(count($add) > 0) {
|
||||||
$this->addContacts($add, $addressbookid);
|
$this->addContacts($add, $addressbookid);
|
||||||
$recall = true;
|
$recall = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($remove) > 0){
|
if(count($remove) > 0) {
|
||||||
$this->removeContacts($remove, $addressbookid);
|
$this->removeContacts($remove, $addressbookid);
|
||||||
$recall = true;
|
$recall = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user