mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Fix and re-activate Contact sharing backend.
While not needed for actual contacts sharing (which is solely done via the Addressbook sharing backend), we need its isValidSource() function in core's \OC\Tags::getIdsForTag() (which implements \OCP\ITags::getIdsForTag()). It is required there to test if the items that are tagged with a given tag are actually allowed to be accessed by the user, i.e. owned by the user or someone who is sharing it with the user.
This commit is contained in:
parent
e8a735a210
commit
51d6783240
@ -56,7 +56,7 @@ $api->connectHook('OC_Calendar', 'getSources', 'OCA\Contacts\Hooks', 'getCalende
|
||||
\OCP\Util::addscript('contacts', 'admin');
|
||||
|
||||
\OC_Search::registerProvider('OCA\Contacts\Search\Provider');
|
||||
//\OCP\Share::registerBackend('contact', 'OCA\Contacts\Share_Backend_Contact');
|
||||
\OCP\Share::registerBackend('contact', 'OCA\Contacts\Share\Contact');
|
||||
\OCP\Share::registerBackend('addressbook', 'OCA\Contacts\Share\Addressbook', 'contact');
|
||||
//\OCP\App::registerPersonal('contacts','personalsettings');
|
||||
\OCP\App::registerAdmin('contacts', 'admin');
|
||||
|
@ -20,42 +20,56 @@
|
||||
*/
|
||||
|
||||
namespace OCA\Contacts\Share;
|
||||
use OCA\Contacts;
|
||||
use OCA\Contacts\App;
|
||||
|
||||
class Contact implements \OCP\Share_Backend {
|
||||
|
||||
const FORMAT_CONTACT = 0;
|
||||
|
||||
private static $contact;
|
||||
/**
|
||||
* @var \OCA\Contacts\App;
|
||||
*/
|
||||
public $app;
|
||||
|
||||
/**
|
||||
* @var \OCA\Contacts\Backend\Database;
|
||||
*/
|
||||
public $backend;
|
||||
|
||||
public function __construct() {
|
||||
// Currently only share
|
||||
$this->backend = new Backend\Database();
|
||||
$this->app = new App(\OCP\User::getUser());
|
||||
$this->backend = $this->app->getBackend('local');
|
||||
}
|
||||
|
||||
public function isValidSource($itemSource, $uidOwner) {
|
||||
self::$contact = VCard::find($itemSource);
|
||||
if (self::$contact) {
|
||||
return true;
|
||||
// TODO: Cache address books.
|
||||
$app = new App($uidOwner);
|
||||
$userAddressBooks = $app->getAddressBooksForUser();
|
||||
|
||||
foreach ($userAddressBooks as $addressBook) {
|
||||
if ($addressBook->childExists($itemSource)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function generateTarget($itemSource, $shareWith, $exclude = null) {
|
||||
// TODO Get default addressbook and check for conflicts
|
||||
return self::$contact['fullname'];
|
||||
$contact = $this->backend->getContact(null, $itemSource,
|
||||
array('noCollection' => true));
|
||||
return $contact['fullname'];
|
||||
}
|
||||
|
||||
public function formatItems($items, $format, $parameters = null) {
|
||||
$contacts = array();
|
||||
if ($format == self::FORMAT_CONTACT) {
|
||||
foreach ($items as $item) {
|
||||
$contact = VCard::find($item['item_source']);
|
||||
$contact['fullname'] = $item['item_target'];
|
||||
$contacts[] = $contact;
|
||||
$contacts[] = $this->backend->getContact(null, $item,
|
||||
array('noCollection' => true));
|
||||
}
|
||||
}
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user