Files
Phraseanet/lib/classes/eventsmanager/notify/uploadquarantine.php
Benoît Burnichon d645b92afa Add AclAware Trait
2015-07-02 12:33:18 +02:00

85 lines
2.0 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Border\Manager;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\Translation\TranslatorInterface;
class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
{
/**
*
* @return string
*/
public function icon_url()
{
return '';
}
/**
*
* @param Array $datas
* @param boolean $unread
* @return Array
*/
public function datas(array $data, $unread)
{
/** @var Manager $manager */
$manager = $this->app['border-manager'];
/** @var TranslatorInterface $translator */
$translator = $this->app['translator'];
$reasons = array_map(function ($checkerFQCN) use ($manager, $translator) {
return $manager->getCheckerFromFQCN($checkerFQCN)->getMessage($translator);
}, $data['reasons']);
$filename = $data['filename'];
$text = $this->app->trans('The document %name% has been quarantined', ['%name%' => $filename]);
if ( ! ! count($reasons)) {
$text .= ' ' . $this->app->trans('for the following reasons : %reasons%', ['%reasons%' => implode(', ', $reasons)]);
}
$ret = ['text' => $text, 'class' => ''];
return $ret;
}
/**
*
* @return string
*/
public function get_name()
{
return $this->app->trans('Quarantine notificaton');
}
/**
*
* @return string
*/
public function get_description()
{
return $this->app->trans('be notified when a document is placed in quarantine');
}
/**
* @param integer $usr_id The id of the user to check
*
* @return boolean
*/
public function is_available(User $user)
{
return $this->app->getAclForUser($user)->has_right('addrecord');
}
}