]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cleanup OC_Contacts_Addressbook::find usage
authorBart Visscher <bartv@thisnet.nl>
Sat, 11 Feb 2012 20:48:45 +0000 (21:48 +0100)
committerBart Visscher <bartv@thisnet.nl>
Sun, 12 Feb 2012 14:14:23 +0000 (15:14 +0100)
Use OC_Contacts_App::getAddressbook($id) instead of OC_Contacts_Addressbook::find($id), it contains access checks.

apps/contacts/import.php
apps/contacts/photo.php
apps/contacts/thumbnail.php

index 9008208db5911d0db0d64af70eaa8b9e98a94118..4638bf0d73cd609ff6ac4e9e4d6efc6ede26954e 100644 (file)
@@ -22,12 +22,8 @@ if($_POST['method'] == 'new'){
        $id = OC_Contacts_Addressbook::add(OC_User::getUser(), $_POST['addressbookname']);
        OC_Contacts_Addressbook::setActive($id, 1);
 }else{
-       $contacts = OC_Contacts_Addressbook::find($_POST['id']);
-       if($contacts['userid'] != OC_USER::getUser()){
-               OC_JSON::error();
-               exit();
-       }
        $id = $_POST['id'];
+       OC_Contacts_App::getAddressbook($id); // is owner access check
 }
 //analyse the contacts file
 if(is_writable('import_tmp/')){
index 756aae63c4d6d062480d0131f0ede9d340e6ba8f..9566764e70a58482a012ec66ac87f3d7d9dd5afe 100644 (file)
@@ -31,19 +31,7 @@ if(isset($GET['refresh'])) {
 }
 $l10n = new OC_L10N('contacts');
 
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
-       echo $l10n->t('Contact could not be found.');
-       exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
-       echo $l10n->t('This is not your contact.'); // This is a weird error, why would it come up? (Better feedback for users?)
-       exit();
-}
-
-$content = OC_VObject::parse($card['carddata']);
+$content = OC_Contacts_App::getContactVCard($id);
 $image = new OC_Image();
 // invalid vcard
 if( is_null($content)){
index 36d395171a92cd444147a7f830ead179716af633..b981fdbe1e7021f6184b83cf5cc54a636f2704f0 100644 (file)
@@ -50,21 +50,7 @@ $id = $_GET['id'];
 
 $l10n = new OC_L10N('contacts');
 
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
-       OC_Log::write('contacts','thumbnail.php. Contact could not be found: '.$id,OC_Log::ERROR);
-       getStandardImage();
-       exit();
-}
-
-// FIXME: Is this check necessary? It just takes up CPU time.
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
-       OC_Log::write('contacts','thumbnail.php. Wrong contact/addressbook - WTF?',OC_Log::ERROR);
-       exit();
-}
-
-$content = OC_VObject::parse($card['carddata']);
+$content = OC_Contacts_App::getContactVCard($id);
 
 // invalid vcard
 if( is_null($content)){