2017-01-24 06:47:14 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
2017-11-06 14:56:42 +00:00
|
|
|
* @author Christoph Wurst <christoph@owncloud.com>
|
2017-01-24 06:47:14 +00:00
|
|
|
*
|
|
|
|
* @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 <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OC\Contacts\ContactsMenu\Providers;
|
|
|
|
|
|
|
|
use OCP\Contacts\ContactsMenu\IActionFactory;
|
|
|
|
use OCP\Contacts\ContactsMenu\IEntry;
|
|
|
|
use OCP\Contacts\ContactsMenu\IProvider;
|
2017-04-11 07:09:45 +00:00
|
|
|
use OCP\IURLGenerator;
|
2017-01-24 06:47:14 +00:00
|
|
|
|
|
|
|
class EMailProvider implements IProvider {
|
|
|
|
|
|
|
|
/** @var IActionFactory */
|
|
|
|
private $actionFactory;
|
|
|
|
|
2017-04-11 07:09:45 +00:00
|
|
|
/** @var IURLGenerator */
|
|
|
|
private $urlGenerator;
|
|
|
|
|
2017-01-24 06:47:14 +00:00
|
|
|
/**
|
|
|
|
* @param IActionFactory $actionFactory
|
2017-04-11 07:09:45 +00:00
|
|
|
* @param IURLGenerator $urlGenerator
|
2017-01-24 06:47:14 +00:00
|
|
|
*/
|
2017-04-11 07:09:45 +00:00
|
|
|
public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) {
|
2017-01-24 06:47:14 +00:00
|
|
|
$this->actionFactory = $actionFactory;
|
2017-04-11 07:09:45 +00:00
|
|
|
$this->urlGenerator = $urlGenerator;
|
2017-01-24 06:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IEntry $entry
|
|
|
|
*/
|
|
|
|
public function process(IEntry $entry) {
|
2017-04-11 07:09:45 +00:00
|
|
|
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
|
2017-01-24 06:47:14 +00:00
|
|
|
foreach ($entry->getEMailAddresses() as $address) {
|
2017-05-02 12:12:04 +00:00
|
|
|
if (empty($address)) {
|
|
|
|
// Skip
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-11 07:09:45 +00:00
|
|
|
$action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
|
2017-01-24 06:47:14 +00:00
|
|
|
$entry->addAction($action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|