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