From 7df5447c251330227649ae6609e48d8b0dabe68e Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 3 Apr 2017 17:23:30 +0200 Subject: [PATCH] Register contactsmenu provider via info.xml Signed-off-by: Christoph Wurst --- appinfo/info.xml | 3 + .../Providers/DetailsProvider.php | 71 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 lib/ContactsMenu/Providers/DetailsProvider.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 03ca2f64a..51c01de74 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -26,4 +26,7 @@ 168708 + + OCA\Contacts\ContactsMenu\Providers\DetailsProvider + diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php new file mode 100644 index 000000000..3a4515648 --- /dev/null +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -0,0 +1,71 @@ + + * + * @author 2017 Christoph Wurst + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Contacts\ContactsMenu\Providers; + +use OCP\Contacts\ContactsMenu\IActionFactory; +use OCP\Contacts\ContactsMenu\IEntry; +use OCP\Contacts\ContactsMenu\IProvider; +use OCP\IURLGenerator; + +/** + * @todo move to contacts app + */ +class DetailsProvider implements IProvider { + + /** @var IURLGenerator */ + private $urlGenerator; + + /** @var IActionFactory */ + private $actionFactory; + + /** + * @param IURLGenerator $urlGenerator + * @param IActionFactory $actionFactory + */ + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { + $this->actionFactory = $actionFactory; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param IEntry $entry + */ + public function process(IEntry $entry) { + $uid = $entry->getProperty('UID'); + + if (is_null($uid)) { + // Nothing to do + return; + } + + // TODO: unique contact URL to the contacts app + // TODO: l10n + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); + $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); + $action->setPriority(0); + $entry->addAction($action); + } + +}