Merge branch 'master' into elastic-indexer

Conflicts:
	.gitignore
This commit is contained in:
Damien Alexandre
2014-10-06 18:24:58 +02:00
96 changed files with 3436 additions and 3129 deletions

2
Vagrantfile vendored
View File

@@ -7,7 +7,7 @@ end
root = File.dirname(File.expand_path(__FILE__)) root = File.dirname(File.expand_path(__FILE__))
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
Dir.glob(root+"/resources/vagrant/vms/**/puphpet/config.yaml").each do|f| Dir.glob(root+"/vagrant/vms/**/puphpet/config.yaml").each do|f|
dir = File.dirname(File.expand_path(f+"/..")) dir = File.dirname(File.expand_path(f+"/.."))
base_path = dir base_path = dir
configValues = YAML.load_file(f) configValues = YAML.load_file(f)

View File

@@ -12,7 +12,6 @@
namespace KonsoleKommander; namespace KonsoleKommander;
use Alchemy\Phrasea\Command\Plugin\ListPlugin; use Alchemy\Phrasea\Command\Plugin\ListPlugin;
use Alchemy\Phrasea\Command\Setup\CrossDomainGenerator;
use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper; use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper;
use Alchemy\Phrasea\Command\Setup\H264MappingGenerator; use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
use Alchemy\Phrasea\Command\SearchEngine\IndexCreateCommand; use Alchemy\Phrasea\Command\SearchEngine\IndexCreateCommand;
@@ -118,7 +117,6 @@ $cli->command(new H264ConfigurationDumper());
$cli->command(new H264MappingGenerator()); $cli->command(new H264MappingGenerator());
$cli->command(new XSendFileConfigurationDumper()); $cli->command(new XSendFileConfigurationDumper());
$cli->command(new XSendFileMappingGenerator()); $cli->command(new XSendFileMappingGenerator());
$cli->command(new CrossDomainGenerator());
if ($cli['search_engine.type'] === SearchEngineInterface::TYPE_ELASTICSEARCH) { if ($cli['search_engine.type'] === SearchEngineInterface::TYPE_ELASTICSEARCH) {
$cli->command(new IndexCreateCommand()); $cli->command(new IndexCreateCommand());

View File

@@ -14,6 +14,7 @@ namespace KonsoleKommander;
use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Core\Version;
use Alchemy\Phrasea\Command\UpgradeDBDatas; use Alchemy\Phrasea\Command\UpgradeDBDatas;
use Alchemy\Phrasea\Command\Setup\Install; use Alchemy\Phrasea\Command\Setup\Install;
use Alchemy\Phrasea\Command\Setup\CrossDomainGenerator;
use Alchemy\Phrasea\Command\Setup\PluginsReset; use Alchemy\Phrasea\Command\Setup\PluginsReset;
use Alchemy\Phrasea\Command\Plugin\ListPlugin; use Alchemy\Phrasea\Command\Plugin\ListPlugin;
use Alchemy\Phrasea\Command\Plugin\AddPlugin; use Alchemy\Phrasea\Command\Plugin\AddPlugin;
@@ -71,5 +72,6 @@ $app->command(new EnablePlugin());
$app->command(new DisablePlugin()); $app->command(new DisablePlugin());
$app->command(new CheckEnvironment('check:system')); $app->command(new CheckEnvironment('check:system'));
$app->command(new Install('system:install')); $app->command(new Install('system:install'));
$app->command(new CrossDomainGenerator());
exit(is_int($app->run()) ? : 1); exit(is_int($app->run()) ? : 1);

View File

@@ -69,11 +69,19 @@ use Alchemy\Phrasea\Controller\Thesaurus\Thesaurus;
use Alchemy\Phrasea\Controller\Thesaurus\Xmlhttp as ThesaurusXMLHttp; use Alchemy\Phrasea\Controller\Thesaurus\Xmlhttp as ThesaurusXMLHttp;
use Alchemy\Phrasea\Controller\User\Notifications; use Alchemy\Phrasea\Controller\User\Notifications;
use Alchemy\Phrasea\Controller\User\Preferences; use Alchemy\Phrasea\Controller\User\Preferences;
use Alchemy\Phrasea\Core\Event\Subscriber\BasketSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ExportSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\FeedEntrySubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\LazaretSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\OrderSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\RegistrationSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ValidationSubscriber;
use Alchemy\Phrasea\Core\Middleware\TokenMiddlewareProvider;
use Alchemy\Phrasea\Core\PhraseaExceptionHandler; use Alchemy\Phrasea\Core\PhraseaExceptionHandler;
use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaInstallSubscriber; use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaInstallSubscriber;
use Alchemy\Phrasea\Core\Middleware\ApiApplicationMiddlewareProvider; use Alchemy\Phrasea\Core\Middleware\ApiApplicationMiddlewareProvider;
use Alchemy\Phrasea\Core\Middleware\BasketMiddlewareProvider; use Alchemy\Phrasea\Core\Middleware\BasketMiddlewareProvider;
use Alchemy\Phrasea\Core\Middleware\TokenMiddlewareProvider;
use Alchemy\Phrasea\Core\Provider\ACLServiceProvider; use Alchemy\Phrasea\Core\Provider\ACLServiceProvider;
use Alchemy\Phrasea\Core\Provider\APIServiceProvider; use Alchemy\Phrasea\Core\Provider\APIServiceProvider;
use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider; use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider;
@@ -479,6 +487,14 @@ class Application extends SilexApplication
$dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']); $dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']); $dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']);
$dispatcher->addSubscriber(new PhraseaInstallSubscriber($app)); $dispatcher->addSubscriber(new PhraseaInstallSubscriber($app));
$dispatcher->addSubscriber(new FeedEntrySubscriber($app));
$dispatcher->addSubscriber(new RegistrationSubscriber($app));
$dispatcher->addSubscriber(new BridgeSubscriber($app));
$dispatcher->addSubscriber(new ExportSubscriber($app));
$dispatcher->addSubscriber(new OrderSubscriber($app));
$dispatcher->addSubscriber(new BasketSubscriber($app));
$dispatcher->addSubscriber(new LazaretSubscriber($app));
$dispatcher->addSubscriber(new ValidationSubscriber($app));
return $dispatcher; return $dispatcher;
}) })

View File

@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea;
use Alchemy\Phrasea\Command\CommandInterface; use Alchemy\Phrasea\Command\CommandInterface;
use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\WebsocketServerServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\WebsocketServerServiceProvider;
use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber;
use Alchemy\Phrasea\Core\PhraseaCLIExceptionHandler; use Alchemy\Phrasea\Core\PhraseaCLIExceptionHandler;
use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Exception\RuntimeException;
use Symfony\Component\Console; use Symfony\Component\Console;
@@ -25,6 +26,7 @@ use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider;
use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\EventDispatcher\EventDispatcher;
/** /**
* Phraseanet Command Line Application * Phraseanet Command Line Application
@@ -53,9 +55,16 @@ class CLI extends Application
return new Console\Application($name, $version); return new Console\Application($name, $version);
}); });
$this['dispatcher']->addListener('phraseanet.notification.sent', function () use ($app) { $this['dispatcher'] = $this->share(
$app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']); $this->extend('dispatcher', function (EventDispatcher $dispatcher, Application $app) {
}); $dispatcher->addListener('phraseanet.notification.sent', function () use ($app) {
$app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
});
$dispatcher->addSubscriber(new BridgeSubscriber($app));
return $dispatcher;
})
);
$this->register(new PluginServiceProvider()); $this->register(new PluginServiceProvider());
$this->register(new WebsocketServerServiceProvider()); $this->register(new WebsocketServerServiceProvider());

View File

@@ -46,7 +46,7 @@ class CreateCollection extends Command
if ($new_collection && $input->getOption('base_id_rights')) { if ($new_collection && $input->getOption('base_id_rights')) {
$query = new \User_Query($this->container); $query = $this->container['phraseanet.user-query'];
$total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total(); $total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total();
$n = 0; $n = 0;

View File

@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Command\Command;
use Alchemy\Phrasea\Utilities\CrossDomainDumper; use Alchemy\Phrasea\Utilities\CrossDomainDumper;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
class CrossDomainGenerator extends Command class CrossDomainGenerator extends Command
{ {
@@ -30,13 +31,16 @@ class CrossDomainGenerator extends Command
*/ */
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)
{ {
$configuration = $this->container['phraseanet.configuration']['crossdomain']; if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
$configuration = $this->container['phraseanet.configuration']['crossdomain'];
} else {
$default = Yaml::parse($this->container['root.path'].'/lib/conf.d/configuration.yml');
$configuration = $default['crossdomain'];
}
$dumper = new CrossDomainDumper(); $dumper = new CrossDomainDumper();
$xml = $dumper->dump($configuration); $xml = $dumper->dump($configuration);
$output->writeln("Generating crossdomain.xml");
$output->writeln($xml);
$this->container['filesystem']->dumpFile($this->container['root.path'].'/www/crossdomain.xml', $xml); $this->container['filesystem']->dumpFile($this->container['root.path'].'/www/crossdomain.xml', $xml);

View File

@@ -136,7 +136,7 @@ class Collection implements ControllerProviderInterface
$admins = []; $admins = [];
if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($bas_id, 'manage')) { if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($bas_id, 'manage')) {
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$admins = $query->on_base_ids([$bas_id]) $admins = $query->on_base_ids([$bas_id])
->who_have_right(['order_master']) ->who_have_right(['order_master'])
->execute() ->execute()
@@ -198,7 +198,7 @@ class Collection implements ControllerProviderInterface
$conn->beginTransaction(); $conn->beginTransaction();
try { try {
$userQuery = new \User_Query($app); $userQuery = $app['phraseanet.user-query'];
$result = $userQuery->on_base_ids([$bas_id]) $result = $userQuery->on_base_ids([$bas_id])
->who_have_right(['order_master']) ->who_have_right(['order_master'])

View File

@@ -400,7 +400,7 @@ class Databox implements ControllerProviderInterface
$othCollSel = (int) $request->request->get("othcollsel") ?: null; $othCollSel = (int) $request->request->get("othcollsel") ?: null;
if (null !== $othCollSel) { if (null !== $othCollSel) {
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$n = 0; $n = 0;
while ($n < $query->on_base_ids([$othCollSel])->get_total()) { while ($n < $query->on_base_ids([$othCollSel])->get_total()) {
@@ -798,7 +798,7 @@ class Databox implements ControllerProviderInterface
if (($request->request->get('ccusrothercoll') === "on") if (($request->request->get('ccusrothercoll') === "on")
&& (null !== $othcollsel = $request->request->get('othcollsel'))) { && (null !== $othcollsel = $request->request->get('othcollsel'))) {
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$total = $query->on_base_ids([$othcollsel])->get_total(); $total = $query->on_base_ids([$othcollsel])->get_total();
$n = 0; $n = 0;
while ($n < $total) { while ($n < $total) {

View File

@@ -326,6 +326,7 @@ class Fields implements ControllerProviderInterface
->set_thumbtitle($data['thumbtitle']) ->set_thumbtitle($data['thumbtitle'])
->set_tag(\databox_field::loadClassFromTagName($data['tag'])) ->set_tag(\databox_field::loadClassFromTagName($data['tag']))
->set_business($data['business']) ->set_business($data['business'])
->set_aggregable($data['aggregable'])
->set_indexable($data['indexable']) ->set_indexable($data['indexable'])
->set_required($data['required']) ->set_required($data['required'])
->set_separator($data['separator']) ->set_separator($data['separator'])
@@ -366,7 +367,7 @@ class Fields implements ControllerProviderInterface
private function getMandatoryFieldProperties() private function getMandatoryFieldProperties()
{ {
return [ return [
'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'aggregable',
'required', 'separator', 'readonly', 'type', 'tbranch', 'report', 'required', 'separator', 'readonly', 'type', 'tbranch', 'report',
'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels' 'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels'
]; ];

View File

@@ -215,8 +215,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/typeahead/search/', function (Application $app) { $controllers->get('/typeahead/search/', function (Application $app) {
$request = $app['request']; $request = $app['request'];
$user_query = new \User_Query($app); $user_query = $app['phraseanet.user-query'];
$like_value = $request->query->get('term'); $like_value = $request->query->get('term');
$rights = $request->query->get('filter_rights') ? : []; $rights = $request->query->get('filter_rights') ? : [];
$have_right = $request->query->get('have_right') ? : []; $have_right = $request->query->get('have_right') ? : [];
@@ -279,7 +278,7 @@ class Users implements ControllerProviderInterface
$controllers->post('/export/csv/', function (Application $app) { $controllers->post('/export/csv/', function (Application $app) {
$request = $app['request']; $request = $app['request'];
$user_query = new \User_Query($app); $user_query = $app['phraseanet.user-query'];
$like_value = $request->request->get('like_value'); $like_value = $request->request->get('like_value');
$like_field = $request->request->get('like_field'); $like_field = $request->request->get('like_field');

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Controller; namespace Alchemy\Phrasea\Controller;
use Alchemy\Phrasea\Core\Event\ValidationEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement; use Alchemy\Phrasea\Model\Entities\BasketElement;
use Alchemy\Phrasea\Exception\SessionNotFound; use Alchemy\Phrasea\Exception\SessionNotFound;
@@ -461,14 +463,8 @@ class Lightbox implements ControllerProviderInterface
$url = $app->url('lightbox', ['LOG' => $token->getValue()]); $url = $app->url('lightbox', ['LOG' => $token->getValue()]);
$to = $basket->getValidation()->getInitiator($app)->getId(); $to = $basket->getValidation()->getInitiator($app)->getId();
$params = [
'ssel_id' => $basket->getId(),
'from' => $app['authentication']->getUser()->getId(),
'url' => $url,
'to' => $to
];
$app['events-manager']->trigger('__VALIDATION_DONE__', $params); $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_DONE, new ValidationEvent($participant, $basket, $url));
$participant->setIsConfirmed(true); $participant->setIsConfirmed(true);

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\ExportEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -63,16 +65,8 @@ class Download implements ControllerProviderInterface
); );
$list['export_name'] = sprintf('%s.zip', $download->getExportName()); $list['export_name'] = sprintf('%s.zip', $download->getExportName());
$token = $app['manipulator.token']->createDownloadToken($app['authentication']->getUser(), serialize($list)); $token = $app['manipulator.token']->createDownloadToken($app['authentication']->getUser(), serialize($list));
$app['dispatcher']->dispatch(PhraseaEvents::EXPORT_CREATE, new ExportEvent($app['authentication']->getUser(), $ssttid, $lst, $subdefs, $download->getExportName()));
$app['events-manager']->trigger('__DOWNLOAD__', [
'lst' => $lst,
'downloader' => $app['authentication']->getUser()->getId(),
'subdefs' => $subdefs,
'from_basket' => $ssttid,
'export_file' => $download->getExportName()
]);
return $app->redirectPath('prepare_download', ['token' => $token->getValue()]); return $app->redirectPath('prepare_download', ['token' => $token->getValue()]);
} }

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\ExportFailureEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\InvalidArgumentException;
@@ -205,13 +207,7 @@ class Export implements ControllerProviderInterface
if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
$destMails[] = $mail; $destMails[] = $mail;
} else { } else {
$app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ $app['dispatcher']->dispatch(PhraseaEvents::EXPORT_MAIL_FAILURE, new ExportFailureEvent($app['authentication']->getUser()->getId(), $ssttid, $lst, \eventsmanager_notify_downloadmailfail::MAIL_NO_VALID, $mail));
'usr_id' => $app['authentication']->getUser()->getId(),
'lst' => $lst,
'ssttid' => $ssttid,
'dest' => $mail,
'reason' => \eventsmanager_notify_downloadmailfail::MAIL_NO_VALID
]);
} }
} }
@@ -250,13 +246,7 @@ class Export implements ControllerProviderInterface
//some mails failed //some mails failed
if (count($remaingEmails) > 0) { if (count($remaingEmails) > 0) {
foreach ($remaingEmails as $mail) { foreach ($remaingEmails as $mail) {
$app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ $app['dispatcher']->dispatch(PhraseaEvents::EXPORT_MAIL_FAILURE, new ExportFailureEvent($app['authentication']->getUser()->getId(), $ssttid, $lst, \eventsmanager_notify_downloadmailfail::MAIL_FAIL, $mail));
'usr_id' => $app['authentication']->getUser()->getId(),
'lst' => $lst,
'ssttid' => $ssttid,
'dest' => $mail,
'reason' => \eventsmanager_notify_downloadmailfail::MAIL_FAIL
]);
} }
} }
} }

View File

@@ -12,6 +12,8 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\FeedEntryEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Feed\Aggregate; use Alchemy\Phrasea\Feed\Aggregate;
use Alchemy\Phrasea\Feed\Link\AggregateLinkGenerator; use Alchemy\Phrasea\Feed\Link\AggregateLinkGenerator;
use Alchemy\Phrasea\Feed\Link\FeedLinkGenerator; use Alchemy\Phrasea\Feed\Link\FeedLinkGenerator;
@@ -83,7 +85,7 @@ class Feed implements ControllerProviderInterface
$app['EM']->persist($feed); $app['EM']->persist($feed);
$app['EM']->flush(); $app['EM']->flush();
$app['events-manager']->trigger('__FEED_ENTRY_CREATE__', ['entry_id' => $entry->getId(), 'notify_email' => (Boolean) $request->request->get('notify')], $entry); $app['dispatcher']->dispatch(PhraseaEvents::FEED_ENTRY_CREATE, new FeedEntryEvent($entry, $request->request->get('notify')));
$datas = ['error' => false, 'message' => false]; $datas = ['error' => false, 'message' => false];

View File

@@ -12,6 +12,9 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Core\Event\OrderDeliveryEvent;
use Alchemy\Phrasea\Core\Event\OrderEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement; use Alchemy\Phrasea\Model\Entities\BasketElement;
@@ -98,8 +101,6 @@ class Order implements ControllerProviderInterface
$order->setDeadline((null !== $deadLine = $request->request->get('deadline')) ? new \DateTime($deadLine) : $deadLine); $order->setDeadline((null !== $deadLine = $request->request->get('deadline')) ? new \DateTime($deadLine) : $deadLine);
$order->setOrderUsage($request->request->get('use', '')); $order->setOrderUsage($request->request->get('use', ''));
foreach ($records as $key => $record) { foreach ($records as $key => $record) {
$query = new \User_Query($app);
if ($collectionHasOrderAdmins->containsKey($record->get_base_id())) { if ($collectionHasOrderAdmins->containsKey($record->get_base_id())) {
if (!$collectionHasOrderAdmins->get($record->get_base_id())) { if (!$collectionHasOrderAdmins->get($record->get_base_id())) {
$records->remove($key); $records->remove($key);
@@ -107,7 +108,7 @@ class Order implements ControllerProviderInterface
} }
if (!isset($hasOneAdmin[$record->get_base_id()])) { if (!isset($hasOneAdmin[$record->get_base_id()])) {
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids([$record->get_base_id()]) $hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids([$record->get_base_id()])
->who_have_right(['order_master']) ->who_have_right(['order_master'])
->execute()->get_results()); ->execute()->get_results());
@@ -139,28 +140,18 @@ class Order implements ControllerProviderInterface
if ($noAdmins) { if ($noAdmins) {
$msg = $app->trans('There is no one to validate orders, please contact an administrator'); $msg = $app->trans('There is no one to validate orders, please contact an administrator');
}
$order->setTodo($order->getElements()->count());
try {
$app['events-manager']->trigger('__NEW_ORDER__', [
'order_id' => $order->getId(),
'usr_id' => $order->getUser()->getId()
]);
$success = true;
$app['EM']->persist($order);
$app['EM']->flush();
} catch (\Exception $e) {
}
if ($success) {
$msg = $app->trans('The records have been properly ordered');
} else { } else {
$msg = $app->trans('An error occured'); $order->setTodo($order->getElements()->count());
try {
$app['dispatcher']->dispatch(PhraseaEvents::ORDER_CREATE, new OrderEvent($order));
$app['EM']->persist($order);
$app['EM']->flush();
$msg = $app->trans('The records have been properly ordered');
$success = true;
} catch (\Exception $e) {
$msg = $app->trans('An error occured');
}
} }
} else { } else {
$msg = $app->trans('There is no record eligible for an order'); $msg = $app->trans('There is no record eligible for an order');
@@ -280,13 +271,7 @@ class Order implements ControllerProviderInterface
try { try {
if ($n > 0) { if ($n > 0) {
$order->setTodo($order->getTodo() - $n); $order->setTodo($order->getTodo() - $n);
$app['dispatcher']->dispatch(PhraseaEvents::ORDER_DELIVER, new OrderDeliveryEvent($order, $app['authentication']->getUser(), $n));
$app['events-manager']->trigger('__ORDER_DELIVER__', [
'ssel_id' => $order->getBasket()->getId(),
'from' => $app['authentication']->getUser()->getId(),
'to' => $order->getUser()->getId(),
'n' => $n
]);
} }
$success = true; $success = true;
@@ -343,12 +328,7 @@ class Order implements ControllerProviderInterface
try { try {
if ($n > 0) { if ($n > 0) {
$order->setTodo($order->getTodo() - $n); $order->setTodo($order->getTodo() - $n);
$app['dispatcher']->dispatch(PhraseaEvents::ORDER_DENY, new OrderDeliveryEvent($order, $app['authentication']->getUser(), $n));
$app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [
'from' => $app['authentication']->getUser()->getId(),
'to' => $order->getUser()->getId(),
'n' => $n
]);
} }
$success = true; $success = true;

View File

@@ -11,6 +11,9 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\PushEvent;
use Alchemy\Phrasea\Core\Event\ValidationEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement; use Alchemy\Phrasea\Model\Entities\BasketElement;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
@@ -227,21 +230,9 @@ class Push implements ControllerProviderInterface
$url = $app->url('lightbox_compare', $arguments); $url = $app->url('lightbox_compare', $arguments);
$receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : '';
$params = [ $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
'from' => $app['authentication']->getUser()->getId(), $app['dispatcher']->dispatch(PhraseaEvents::BASKET_PUSH, new PushEvent($Basket, $request->request->get('message'), $url, $receipt));
'from_email' => $app['authentication']->getUser()->getEmail(),
'to' => $user_receiver->getId(),
'to_email' => $user_receiver->getEmail(),
'to_name' => $user_receiver->getDisplayName(),
'url' => $url,
'accuse' => $receipt,
'message' => $request->request->get('message'),
'ssel_id' => $Basket->getId(),
];
$app['events-manager']->trigger('__PUSH_DATAS__', $params);
} }
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox()) $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
@@ -352,47 +343,47 @@ class Push implements ControllerProviderInterface
} }
foreach ($participants as $key => $participant) { foreach ($participants as $key => $participant) {
foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryparam) { foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryParam) {
if (!array_key_exists($mandatoryparam, $participant)) if (!array_key_exists($mandatoryParam, $participant))
throw new ControllerException($app->trans('Missing mandatory parameter %parameter%', ['%parameter%' => $mandatoryparam])); throw new ControllerException($app->trans('Missing mandatory parameter %parameter%', ['%parameter%' => $mandatoryParam]));
} }
try { try {
$participant_user = $app['repo.users']->find($participant['usr_id']); $participantUser = $app['repo.users']->find($participant['usr_id']);
} catch (\Exception $e) { } catch (\Exception $e) {
throw new ControllerException($app->trans('Unknown user %usr_id%', ['%usr_id%' => $participant['usr_id']])); throw new ControllerException($app->trans('Unknown user %usr_id%', ['%usr_id%' => $participant['usr_id']]));
} }
try { try {
$Participant = $Validation->getParticipant($participant_user); $Validation->getParticipant($participantUser);
continue; continue;
} catch (NotFoundHttpException $e) { } catch (NotFoundHttpException $e) {
} }
$Participant = new ValidationParticipant(); $validationParticipant = new ValidationParticipant();
$Participant->setUser($participant_user); $validationParticipant->setUser($participantUser);
$Participant->setSession($Validation); $validationParticipant->setSession($Validation);
$Participant->setCanAgree($participant['agree']); $validationParticipant->setCanAgree($participant['agree']);
$Participant->setCanSeeOthers($participant['see_others']); $validationParticipant->setCanSeeOthers($participant['see_others']);
$app['EM']->persist($Participant); $app['EM']->persist($validationParticipant);
foreach ($Basket->getElements() as $BasketElement) { foreach ($Basket->getElements() as $BasketElement) {
$ValidationData = new ValidationData(); $ValidationData = new ValidationData();
$ValidationData->setParticipant($Participant); $ValidationData->setParticipant($validationParticipant);
$ValidationData->setBasketElement($BasketElement); $ValidationData->setBasketElement($BasketElement);
$BasketElement->addValidationData($ValidationData); $BasketElement->addValidationData($ValidationData);
if ($participant['HD']) { if ($participant['HD']) {
$app['acl']->get($participant_user)->grant_hd_on( $app['acl']->get($participantUser)->grant_hd_on(
$BasketElement->getRecord($app) $BasketElement->getRecord($app)
, $app['authentication']->getUser() , $app['authentication']->getUser()
, \ACL::GRANT_ACTION_VALIDATE , \ACL::GRANT_ACTION_VALIDATE
); );
} else { } else {
$app['acl']->get($participant_user)->grant_preview_on( $app['acl']->get($participantUser)->grant_preview_on(
$BasketElement->getRecord($app) $BasketElement->getRecord($app)
, $app['authentication']->getUser() , $app['authentication']->getUser()
, \ACL::GRANT_ACTION_VALIDATE , \ACL::GRANT_ACTION_VALIDATE
@@ -403,12 +394,12 @@ class Push implements ControllerProviderInterface
$app['EM']->persist($ValidationData); $app['EM']->persist($ValidationData);
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox()) $app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participant_user->getId(), ''); ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participantUser->getId(), '');
$Participant->addData($ValidationData); $validationParticipant->addData($ValidationData);
} }
$Participant = $app['EM']->merge($Participant); $validationParticipant = $app['EM']->merge($validationParticipant);
$app['EM']->flush(); $app['EM']->flush();
@@ -417,32 +408,19 @@ class Push implements ControllerProviderInterface
]; ];
if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) { if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) {
$arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participant_user); $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participantUser);
} }
$url = $app->url('lightbox_validation', $arguments); $url = $app->url('lightbox_validation', $arguments);
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : ''; $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
$params = [ $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_CREATE, new ValidationEvent($validationParticipant, $Basket, $url, $request->request->get('message'), $receipt, (int) $request->request->get('duration')));
'from' => $app['authentication']->getUser()->getId(),
'from_email' => $app['authentication']->getUser()->getEmail(),
'to' => $participant_user->getId(),
'to_email' => $participant_user->getEmail(),
'to_name' => $participant_user->getDisplayName(),
'url' => $url,
'accuse' => $receipt,
'message' => $request->request->get('message'),
'ssel_id' => $Basket->getId(),
'duration' => (int) $request->request->get('duration'),
];
$app['events-manager']->trigger('__PUSH_VALIDATION__', $params);
} }
$Basket = $app['EM']->merge($Basket); $app['EM']->merge($Basket);
$Validation = $app['EM']->merge($Validation); $app['EM']->merge($Validation);
$app['EM']->flush(); $app['EM']->flush();
$message = $app->trans('%quantity_records% records have been sent for validation to %quantity_users% users', [ $message = $app->trans('%quantity_records% records have been sent for validation to %quantity_users% users', [
@@ -469,7 +447,7 @@ class Push implements ControllerProviderInterface
$request = $app['request']; $request = $app['request'];
$query = new \User_Query($app); $query = new $app['phraseanet.user-query'];
$query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);
@@ -580,7 +558,7 @@ class Push implements ControllerProviderInterface
$controllers->get('/search-user/', function (Application $app) use ($userFormatter, $listFormatter) { $controllers->get('/search-user/', function (Application $app) use ($userFormatter, $listFormatter) {
$request = $app['request']; $request = $app['request'];
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);
@@ -620,7 +598,7 @@ class Push implements ControllerProviderInterface
$list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id); $list = $repository->findUserListByUserAndId($app['authentication']->getUser(), $list_id);
$query = new \User_Query($app); $query = $app['phraseanet.user-query'];
$query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']);

View File

@@ -13,6 +13,8 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status; use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Core\Event\LazaretEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use DataURI\Parser; use DataURI\Parser;
use DataURI\Exception\Exception as DataUriException; use DataURI\Exception\Exception as DataUriException;
use Alchemy\Phrasea\Model\Entities\LazaretSession; use Alchemy\Phrasea\Model\Entities\LazaretSession;
@@ -230,9 +232,7 @@ class Upload implements ControllerProviderInterface
} }
} }
} else { } else {
$params = ['lazaret_file' => $elementCreated]; $app['dispatcher']->dispatch(PhraseaEvents::LAZARET_CREATE, new LazaretEvent($elementCreated));
$app['events-manager']->trigger('__UPLOAD_QUARANTINE__', $params);
$id = $elementCreated->getId(); $id = $elementCreated->getId();
$element = 'lazaret'; $element = 'lazaret';

View File

@@ -318,7 +318,7 @@ class Account implements ControllerProviderInterface
return $app['twig']->render('account/account.html.twig', [ return $app['twig']->render('account/account.html.twig', [
'user' => $app['authentication']->getUser(), 'user' => $app['authentication']->getUser(),
'evt_mngr' => $app['events-manager'], 'evt_mngr' => $app['events-manager'],
'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->getId()), 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()),
]); ]);
} }
@@ -402,7 +402,7 @@ class Account implements ControllerProviderInterface
$requestedNotifications = (array) $request->request->get('notifications', []); $requestedNotifications = (array) $request->request->get('notifications', []);
foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->getId()) as $notifications) { foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()) as $notifications) {
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
$app['manipulator.user']->setNotificationSetting($app['authentication']->getUser(), $notification['id'], isset($requestedNotifications[$notification['id']])); $app['manipulator.user']->setNotificationSetting($app['authentication']->getUser(), $notification['id'], isset($requestedNotifications[$notification['id']]));
} }

View File

@@ -19,6 +19,8 @@ use Alchemy\Phrasea\Authentication\Provider\ProviderInterface;
use Alchemy\Phrasea\Core\Event\LogoutEvent; use Alchemy\Phrasea\Core\Event\LogoutEvent;
use Alchemy\Phrasea\Core\Event\PreAuthenticate; use Alchemy\Phrasea\Core\Event\PreAuthenticate;
use Alchemy\Phrasea\Core\Event\PostAuthenticate; use Alchemy\Phrasea\Core\Event\PostAuthenticate;
use Alchemy\Phrasea\Core\Event\RegistrationEvent;
use Alchemy\Phrasea\Core\Event\ValidationEvent;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Exception\FormProcessingException; use Alchemy\Phrasea\Exception\FormProcessingException;
@@ -398,23 +400,18 @@ class Login implements ControllerProviderInterface
$autoReg = $app['acl']->get($user)->get_granted_base(); $autoReg = $app['acl']->get($user)->get_granted_base();
foreach ($inscOK as $baseId => $authorization) { array_walk($inscOK, function ($authorization, $baseId) use ($app, $user, &$registrationsOK) {
if (false === $authorization || $app['acl']->get($user)->has_access_to_base($baseId)) { if (false === $authorization || $app['acl']->get($user)->has_access_to_base($baseId)) {
continue; return;
} }
$app['manipulator.registration']->createRegistration($user, \collection::get_from_base_id($app, $baseId)); $collection = \collection::get_from_base_id($app, $baseId);
$registrationsOK[$baseId] = true; $app['manipulator.registration']->createRegistration($user, $collection);
} $registrationsOK[$baseId] = $collection;
});
$params = [ $app['dispatcher']->dispatch(PhraseaEvents::REGISTRATION_AUTOREGISTER, new RegistrationEvent($user, $autoReg));
'registrations'=> $registrationsOK, $app['dispatcher']->dispatch(PhraseaEvents::REGISTRATION_CREATE, new RegistrationEvent($user, $registrationsOK));
'autoregister' => $autoReg,
'usr_id' => $user->getId()
];
$app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params);
$app['events-manager']->trigger('__REGISTER_APPROVAL__', $params);
$user->setMailLocked(true); $user->setMailLocked(true);
@@ -819,20 +816,14 @@ class Login implements ControllerProviderInterface
/* @var $participant ValidationParticipant */ /* @var $participant ValidationParticipant */
$validationSession = $participant->getSession(); $validationSession = $participant->getSession();
$participantId = $participant->getUser()->getId();
$basket = $validationSession->getBasket(); $basket = $validationSession->getBasket();
if (null === $token = $app['repo.tokens']->findValidationToken($basket, $participant->getUser())) { if (null === $token = $app['repo.tokens']->findValidationToken($basket, $participant->getUser())) {
continue; continue;
} }
$app['events-manager']->trigger('__VALIDATION_REMINDER__', [ $url = $app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
'to' => $participantId, $app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));
'ssel_id' => $basket->getId(),
'from' => $validationSession->getInitiator()->getId(),
'validate_id' => $validationSession->getId(),
'url' => $app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]),
]);
$participant->setReminded(new \DateTime('now')); $participant->setReminded(new \DateTime('now'));
$app['EM']->persist($participant); $app['EM']->persist($participant);

View File

@@ -139,20 +139,20 @@ class Setup implements ControllerProviderInterface
$abConn = $dbConn = null; $abConn = $dbConn = null;
$hostname = $request->request->get('ab_hostname'); $database_host = $request->request->get('hostname');
$port = $request->request->get('ab_port'); $database_port = $request->request->get('port');
$user_ab = $request->request->get('ab_user'); $database_user = $request->request->get('user');
$ab_password = $request->request->get('ab_password'); $database_password = $request->request->get('password');
$appbox_name = $request->request->get('ab_name'); $appbox_name = $request->request->get('ab_name');
$databox_name = $request->request->get('db_name'); $databox_name = $request->request->get('db_name');
try { try {
$abConn = $app['dbal.provider']->get([ $abConn = $app['dbal.provider']->get([
'host' => $hostname, 'host' => $database_host,
'port' => $port, 'port' => $database_port,
'user' => $user_ab, 'user' => $database_user,
'password' => $ab_password, 'password' => $database_password,
'dbname' => $appbox_name, 'dbname' => $appbox_name,
]); ]);
$abConn->connect(); $abConn->connect();
@@ -165,10 +165,10 @@ class Setup implements ControllerProviderInterface
try { try {
if ($databox_name) { if ($databox_name) {
$dbConn = $app['dbal.provider']->get([ $dbConn = $app['dbal.provider']->get([
'host' => $hostname, 'host' => $database_host,
'port' => $port, 'port' => $database_port,
'user' => $user_ab, 'user' => $database_user,
'password' => $ab_password, 'password' => $database_password,
'dbname' => $databox_name, 'dbname' => $databox_name,
]); ]);
$dbConn->connect(); $dbConn->connect();

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class BridgeUploadFailureEvent extends SfEvent
{
private $element;
private $reason;
public function __construct(\Bridge_Element $element, $reason)
{
$this->element = $element;
$this->reason = $reason;
}
/**
* @return \Bridge_Element
*/
public function getElement()
{
return $this->element;
}
public function getReason()
{
return $this->reason;
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class ExportEvent extends SfEvent
{
private $user;
private $basketId;
private $list;
private $subdefs;
private $exportFileName;
public function __construct(User $user, $basketId, $list, $subdefs, $exportFileName)
{
$this->user = $user;
$this->basketId = $basketId;
$this->list = $list;
$this->subdefs = $subdefs;
$this->exportFileName = $exportFileName;
}
/**
* @return mixed
*/
public function getBasketId()
{
return $this->basketId;
}
/**
* @return mixed
*/
public function getList()
{
return $this->list;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @return mixed
*/
public function getExportFileName()
{
return $this->exportFileName;
}
/**
* @return mixed
*/
public function getSubdefs()
{
return $this->subdefs;
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class ExportFailureEvent extends SfEvent
{
private $user;
private $basketId;
private $list;
private $reason;
private $target;
public function __construct(User $user, $basketId, $list, $reason, $target)
{
$this->user = $user;
$this->basketId = $basketId;
$this->list = $list;
$this->reason = $reason;
$this->target = $target;
}
/**
* @return mixed
*/
public function getBasketId()
{
return $this->basketId;
}
/**
* @return mixed
*/
public function getList()
{
return $this->list;
}
/**
* @return mixed
*/
public function getReason()
{
return $this->reason;
}
/**
* @return mixed
*/
public function getTarget()
{
return $this->target;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class FeedEntryEvent extends SfEvent
{
private $entry;
private $emailNotification;
public function __construct(FeedEntry $entry, $emailNotification)
{
$this->entry = $entry;
$this->emailNotification = (Boolean) $emailNotification;
}
public function getFeedEntry()
{
return $this->entry;
}
public function hasEmailNotification()
{
return $this->emailNotification;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class LazaretEvent extends SfEvent
{
private $file;
public function __construct(LazaretFile $file)
{
$this->file = $file;
}
/**
* @return LazaretFile
*/
public function getFile()
{
return $this->file;
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\Order;
use Alchemy\Phrasea\Model\Entities\User;
class OrderDeliveryEvent extends OrderEvent
{
private $admin;
private $quantity;
public function __construct(Order $order, User $admin, $quantity)
{
parent::__construct($order);
$this->admin = $admin;
$this->quantity = $quantity;
}
/**
* @return User
*/
public function getAdmin()
{
return $this->admin;
}
/**
* @return mixed
*/
public function getQuantity()
{
return $this->quantity;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\Order;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class OrderEvent extends SfEvent
{
private $order;
public function __construct(Order $order)
{
$this->order = $order;
}
/**
* @return Order
*/
public function getOrder()
{
return $this->order;
}
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\Basket;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class PushEvent extends SfEvent
{
private $basket;
private $message;
private $receipt;
private $url;
public function __construct(Basket $basket, $message, $url, $receipt)
{
$this->basket = $basket;
$this->message = $message;
$this->url = $url;
$this->receipt = (Boolean) $receipt;
}
/**
* @return Basket
*/
public function getBasket()
{
return $this->basket;
}
/**
* @return mixed
*/
public function getMessage()
{
return $this->message;
}
public function hasReceipt()
{
return $this->receipt;
}
public function getUrl()
{
return $this->url;
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\EventDispatcher\Event as SfEvent;
class RegistrationEvent extends SfEvent
{
/** @var \collection[] */
private $collections;
private $user;
public function __construct(User $user, array $collections)
{
$this->collections = $collections;
$this->user = $user;
}
/**
* @return \collection[]
*/
public function getCollections()
{
return $this->collections;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
abstract class AbstractNotificationSubscriber implements EventSubscriberInterface
{
protected $app;
public function __construct(Application $app)
{
$this->app = $app;
}
protected function shouldSendNotificationFor(User $user, $type)
{
return $this->app['settings']->getUserNotificationSetting($user, $type);
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\PushEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Mail\MailInfoPushReceived;
use Alchemy\Phrasea\Notification\Receiver;
class BasketSubscriber extends AbstractNotificationSubscriber
{
public function onPush(PushEvent $event)
{
$params = [
'from' => $event->getBasket()->getPusher()->getId(),
'to' => $event->getBasket()->getUser()->getId(),
'message' => $event->getMessage(),
'ssel_id' => $event->getBasket()->getId(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getBasket()->getUser(), 'eventsmanager_notify_push')) {
$basket = $event->getBasket();
$user_from = $event->getBasket()->getPusher();
$user_to = $event->getBasket()->getUser();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$mail = MailInfoPushReceived::create($this->app, $receiver, $emitter, $params['message'], $event->getUrl());
$mail->setBasket($basket);
$mail->setPusher($user_from);
$this->app['notification.deliverer']->deliver($mail, $event->hasReceipt());
$mailed = true;
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_push', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::BASKET_PUSH => 'onPush',
];
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\BridgeUploadFailureEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoBridgeUploadFailed;
class BridgeSubscriber extends AbstractNotificationSubscriber
{
public function onUploadFailure(BridgeUploadFailureEvent $event)
{
$account = $event->getElement()->get_account();
$user = $account->get_user();
$params = [
'usr_id' => $user->getId(),
'reason' => $event->getReason(),
'account_id' => $account->get_id(),
'sbas_id' => $event->getElement()->get_record()->get_sbas_id(),
'record_id' => $event->getElement()->get_record()->get_record_id(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($user, 'eventsmanager_notify_bridgeuploadfail')) {
try {
$receiver = Receiver::fromUser($user);
$readyToSend = true;
} catch (\Exception $e) {
$readyToSend = false;
}
if ($readyToSend) {
$mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
$mail->setAdapter($account->get_api()->get_connector()->get_name());
$mail->setReason($params['reason']);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->app['events-manager']->notify($params['usr_id'], 'eventsmanager_notify_bridgeuploadfail', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::BRIDGE_UPLOAD_FAILURE => 'onUploadFailure',
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\ExportFailureEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
class ExportSubscriber extends AbstractNotificationSubscriber
{
public function onMailExportFailure(ExportFailureEvent $event)
{
$params = [
'usr_id' => $event->getUser()->getId(),
'lst' => $event->getList(),
'ssttid' => $event->getBasketId(),
'dest' => $event->getTarget(),
'reason' => $event->getReason(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getUser(), 'eventsmanager_notify_downloadmailfail')) {
if (parent::email()) {
$mailed = true;
}
}
$this->app['event-manager']->notify($params['usr_id'], 'eventsmanager_notify_downloadmailfail', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::EXPORT_MAIL_FAILURE => 'onMailExportFailure'
];
}
}

View File

@@ -0,0 +1,94 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\FeedEntryEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication;
class FeedEntrySubscriber extends AbstractNotificationSubscriber
{
public function onCreate(FeedEntryEvent $event)
{
$entry = $event->getFeedEntry();
$params = [
'entry_id' => $entry->getId(),
'notify_email' => $event->hasEmailNotification(),
];
$this->app['manipulator.webhook-event']->create(
WebhookEvent::NEW_FEED_ENTRY,
WebhookEvent::FEED_ENTRY_TYPE,
array_merge(array('feed_id' => $entry->getFeed()->getId()), $params)
);
$datas = json_encode($params);
$Query = $this->app['phraseanet.user-query'];
$Query->include_phantoms(true)
->include_invite(false)
->include_templates(false)
->email_not_null(true);
if ($entry->getFeed()->getCollection($this->app)) {
$Query->on_base_ids([$entry->getFeed()->getCollection($this->app)->get_base_id()]);
}
$start = 0;
$perLoop = 100;
do {
$results = $Query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user_to_notif) {
$mailed = false;
if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif, 'eventsmanager_notify_feed')) {
$readyToSend = false;
try {
$token = $this->app['manipulator.token']->createFeedEntryToken($user_to_notif, $entry);
$url = $this->app->url('lightbox', ['LOG' => $token->getValue()]);
$receiver = Receiver::fromUser($user_to_notif);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoNewPublication::create($this->app, $receiver);
$mail->setButtonUrl($url);
$mail->setAuthor($entry->getAuthorName());
$mail->setTitle($entry->getTitle());
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->app['events-manager']->notify($user_to_notif->getId(), 'eventsmanager_notify_feed', $datas, $mailed);
}
$start += $perLoop;
} while (count($results) > 0);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::FEED_ENTRY_CREATE => 'onCreate',
];
}
}

View File

@@ -0,0 +1,80 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\LazaretEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\LazaretCheck;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined;
use Alchemy\Phrasea\Notification\Receiver;
class LazaretSubscriber extends AbstractNotificationSubscriber
{
public function onCreate(LazaretEvent $event)
{
$lazaretFile = $event->getFile();
$params = [
'filename' => $lazaretFile->getOriginalName(),
'reasons' => array_map(function (LazaretCheck $check) {
return $check->getCheckClassname();
}, iterator_to_array($lazaretFile->getChecks())),
];
if (null !== $user = $lazaretFile->getSession()->getUser()) {
$params['sender'] = $user->getDisplayName();
$this->notifyUser($user, json_encode($params));
} else { //No lazaretSession user, fil is uploaded via automated tasks etc ..
$query = $this->app['phraseanet.user-query'];
$users = $query
->on_base_ids([$lazaretFile->getBaseId()])
->who_have_right(['canaddrecord'])
->execute()
->get_results();
foreach ($users as $user) {
$this->notifyUser($user, json_encode($params));
}
}
}
private function notifyUser(User $user, $datas)
{
$mailed = false;
if ($this->shouldSendNotificationFor($user, 'eventsmanager_notify_uploadquarantine')) {
$readyToSend = false;
try {
$receiver = Receiver::fromUser($user);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoRecordQuarantined::create($this->app, $receiver);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->app['events-manager']->notify($user->getId(), 'eventsmanager_notify_uploadquarantine', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::LAZARET_CREATE => 'onCreate',
];
}
}

View File

@@ -0,0 +1,149 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\OrderDeliveryEvent;
use Alchemy\Phrasea\Core\Event\OrderEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\OrderElement;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewOrder;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered;
use Alchemy\Phrasea\Notification\Receiver;
class OrderSubscriber extends AbstractNotificationSubscriber
{
public function onCreate(OrderEvent $event)
{
$params = [
'usr_id' => $event->getOrder()->getUser()->getId(),
'order_id' => $event->getOrder()->getId(),
];
$base_ids = array_unique(array_map(function (OrderElement $element) {
return $element->getBaseId();
}, iterator_to_array($event->getOrder()->getElements())));
$query = $this->app['phraseanet.user-query'];
$users = $query->on_base_ids($base_ids)
->who_have_right(['order_master'])
->execute()->get_results();
if (count($users) == 0) {
return;
}
$datas = json_encode($params);
$orderInitiator = $event->getOrder()->getUser();
foreach ($users as $user) {
$mailed = false;
if ($this->shouldSendNotificationFor($user, 'eventsmanager_notify_order')) {
try {
$receiver = Receiver::fromUser($user);
} catch (\Exception $e) {
continue;
}
$mail = MailInfoNewOrder::create($this->app, $receiver);
$mail->setUser($orderInitiator);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
$this->app['events-manager']->notify($user->getId(), 'eventsmanager_notify_order', $datas, $mailed);
}
}
public function onDeliver(OrderDeliveryEvent $event)
{
$params = [
'from' => $event->getAdmin()->getId(),
'to' => $event->getOrder()->getUser()->getId(),
'ssel_id' => $event->getOrder()->getBasket()->getId(),
'n' => $event->getQuantity(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getOrder()->getUser(), 'eventsmanager_notify_orderdeliver')) {
$user_from = $event->getAdmin();
$user_to = $event->getOrder()->getUser();
$receiver = Receiver::fromUser($event->getOrder()->getUser());
$emitter = Emitter::fromUser($event->getAdmin());
$basket = $event->getOrder()->getBasket();
$url = $this->app->url('lightbox_compare', [
'basket' => $basket->getId(),
'LOG' => $this->app['manipulator.token']->createBasketAccessToken($basket, $user_to)->getValue(),
]);
$mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter, null);
$mail->setButtonUrl($url);
$mail->setBasket($basket);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_orderdeliver', $datas, $mailed);
}
public function onDeny(OrderDeliveryEvent $event)
{
$params = [
'from' => $event->getAdmin()->getId(),
'to' => $event->getOrder()->getUser()->getId(),
'n' => $event->getQuantity(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getOrder()->getUser(), 'eventsmanager_notify_ordernotdelivered')) {
$user_from = $event->getAdmin();
$user_to = $event->getOrder()->getUser();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
$mail->setQuantity($params['n']);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_ordernotdelivered', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::ORDER_CREATE => 'onCreate',
PhraseaEvents::ORDER_DELIVER => 'onDeliver',
PhraseaEvents::ORDER_DENY => 'onDeny',
];
}
}

View File

@@ -0,0 +1,138 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\RegistrationEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered;
class RegistrationSubscriber extends AbstractNotificationSubscriber
{
public function onRegistration(RegistrationEvent $event)
{
$baseIds = array_map(function (\collection $coll) { return $coll->get_base_id(); }, $event->getCollections());
if (count($baseIds) === 0) {
return;
}
$params = [
'usr_id' => $event->getUser()->getId(),
'base_ids' => $baseIds,
];
try {
$rs = $this->app['EM.native-query']->getAdminsOfBases(array_keys($baseIds));
$adminUsers = array_map(function ($row) { return $row[0]; }, $rs);
} catch (\Exception $e) {
return;
}
$datas = json_encode($params);
$registeredUser = $event->getUser();
foreach ($adminUsers as $adminUser) {
$mailed = false;
if ($this->shouldSendNotificationFor($adminUser, 'eventsmanager_notify_register')) {
try {
$receiver = Receiver::fromUser($adminUser);
} catch (\Exception $e) {
continue;
}
$mail = MailInfoUserRegistered::create($this->app, $receiver);
$mail->setRegisteredUser($registeredUser);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
$this->app['events-manager']->notify($adminUser->getId(), 'eventsmanager_notify_register', $datas, $mailed);
}
}
public function onAutoRegistration(RegistrationEvent $event)
{
if (count($event->getCollections()) === 0) {
return;
}
$baseIds = array_map(function (\collection $coll) {
return $coll->get_base_id();
}, $event->getCollections());
$params = [
'usr_id' => $event->getUser()->getId() ,
'base_ids' => $baseIds,
];
try {
$rs = $this->app['EM.native-query']->getAdminsOfBases(array_keys($baseIds));
$adminUsers = array_map(function ($row) { return $row[0]; }, $rs);
} catch (\Exception $e) {
return;
}
$datas = json_encode($params);
$registered_user = $event->getUser();
foreach ($adminUsers as $adminUser) {
$mailed = false;
if ($this->shouldSendNotificationFor($adminUser, 'eventsmanager_notify_autoregister')) {
$mailed = $this->autoregisterEMail($adminUser, $registered_user);
}
$this->app['events-manager']->notify($adminUser->getId(), 'eventsmanager_notify_autoregister', $datas, $mailed);
}
}
private function autoregisterEMail(User $to, User $registeredUser)
{
$body = '';
$body .= sprintf("Login : %s\n", $registeredUser->getLogin());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->getFirstName());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->getLastName());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->getEmail());
$body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->getCompany());
$readyToSend = false;
try {
$receiver = Receiver::fromUser($to);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, null, $body);
$this->app['notification.deliverer']->deliver($mail);
}
return true;
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::REGISTRATION_AUTOREGISTER => 'onAutoRegistration',
PhraseaEvents::REGISTRATION_CREATE => 'onRegistration',
];
}
}

View File

@@ -0,0 +1,162 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\ValidationEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationDone;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationReminder;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest;
use Alchemy\Phrasea\Notification\Receiver;
class ValidationSubscriber extends AbstractNotificationSubscriber
{
public function onCreate(ValidationEvent $event)
{
$params = [
'from' => $event->getBasket()->getValidation()->getInitiator()->getId(),
'to' => $event->getParticipant()->getUser()->getId(),
'message' => $event->getMessage(),
'ssel_id' => $event->getBasket()->getId(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getParticipant()->getUser(), 'eventsmanager_notify_validate')) {
try {
$user_from = $event->getBasket()->getValidation()->getInitiator();
$user_to = $event->getParticipant()->getUser();
$basket = $event->getBasket();
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
$readyToSend = false;
}
if ($readyToSend) {
$mail = MailInfoValidationRequest::create($this->app, $receiver, $emitter, $params['message']);
$mail->setButtonUrl($event->getUrl());
$mail->setDuration($event->getDuration());
$mail->setTitle($title);
$mail->setUser($user_from);
$this->app['notification.deliverer']->deliver($mail, $event->hasReceipt());
$mailed = true;
}
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_validate', $datas, $mailed);
}
public function onFinish(ValidationEvent $event)
{
$params = [
'from' => $event->getParticipant()->getUser()->getId(),
'to' => $event->getBasket()->getValidation()->getInitiator()->getId(),
'ssel_id' => $event->getBasket()->getId(),
];
$datas = json_encode($params);
$mailed = false;
if ($this->shouldSendNotificationFor($event->getBasket()->getValidation()->getInitiator(), 'eventsmanager_notify_validationdone')) {
$readyToSend = false;
try {
$user_from = $event->getParticipant()->getUser();
$user_to = $event->getBasket()->getValidation()->getInitiator();
$basket = $event->getBasket();
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
$mail->setButtonUrl($event->getUrl());
$mail->setTitle($title);
$mail->setUser($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_validationdone', $datas, $mailed);
}
public function onRemind(ValidationEvent $event)
{
$params = [
'from' => $event->getBasket()->getValidation()->getInitiator()->getId(),
'to' => $event->getParticipant()->getUser()->getId(),
'ssel_id' => $event->getBasket()->getId(),
'url' => $event->getUrl(),
];
$datas = json_encode($params);
$mailed = false;
$user_from = $event->getBasket()->getValidation()->getInitiator();
$user_to = $event->getParticipant()->getUser();
if ($this->shouldSendNotificationFor($event->getParticipant()->getUser(), 'eventsmanager_notify_validationreminder')) {
$readyToSend = false;
try {
$basket = $event->getBasket();
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoValidationReminder::create($this->app, $receiver, $emitter);
$mail->setButtonUrl($params['url']);
$mail->setTitle($title);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_validationreminder', $datas, $mailed);
}
public static function getSubscribedEvents()
{
return [
PhraseaEvents::VALIDATION_CREATE => 'onCreate',
PhraseaEvents::VALIDATION_DONE => 'onFinish',
PhraseaEvents::VALIDATION_REMINDER => 'onRemind',
];
}
}

View File

@@ -0,0 +1,44 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
class ValidationEvent extends PushEvent
{
private $participant;
private $duration;
public function __construct(ValidationParticipant $participant, Basket $basket, $url, $message = null, $receipt = false, $duration = 0)
{
parent::__construct($basket, $message, $url, $receipt);
$this->participant = $participant;
$this->duration = $duration;
}
/**
* @return ValidationParticipant
*/
public function getParticipant()
{
return $this->participant;
}
/**
* @return null|integer
*/
public function getDuration()
{
return $this->duration;
}
}

View File

@@ -26,5 +26,20 @@ final class PhraseaEvents
const API_LOAD_END = 'api.load.end'; const API_LOAD_END = 'api.load.end';
const API_RESULT = 'api.result'; const API_RESULT = 'api.result';
const ORDER_CREATE = 'order.create';
const ORDER_DELIVER = 'order.deliver';
const ORDER_DENY = 'order.deny';
const COLLECTION_CREATE = 'collection.create'; const COLLECTION_CREATE = 'collection.create';
const FEED_ENTRY_CREATE = 'feed-entry.create';
const REGISTRATION_CREATE = 'registration.create';
const REGISTRATION_AUTOREGISTER = 'registration.autoregister';
const BASKET_PUSH = 'basket.push';
const VALIDATION_CREATE = 'validation.create';
const VALIDATION_DONE = 'validation.done';
const VALIDATION_REMINDER = 'validation.reminder';
const LAZARET_CREATE = 'lazaret.create';
const BRIDGE_UPLOAD_FAILURE = 'bridge.upload-failure';
const EXPORT_MAIL_FAILURE = 'export.mail-failure';
const EXPORT_CREATE = 'export.create';
} }

View File

@@ -61,6 +61,10 @@ class PhraseanetServiceProvider implements ServiceProviderInterface
$app['phraseanet.metadata-setter'] = $app->share(function (SilexApplication $app) { $app['phraseanet.metadata-setter'] = $app->share(function (SilexApplication $app) {
return new PhraseanetMetadataSetter(); return new PhraseanetMetadataSetter();
}); });
$app['phraseanet.user-query'] = function (SilexApplication $app) {
return new \User_Query($app);
};
} }
public function boot(SilexApplication $app) public function boot(SilexApplication $app)

View File

@@ -13,8 +13,8 @@ namespace Alchemy\Phrasea\Core;
class Version class Version
{ {
protected static $number = '3.9.0-alpha.19'; protected static $number = '3.9.0-alpha.20';
protected static $name = 'Gorgosaurus'; protected static $name = 'Epanterias';
public static function getNumber() public static function getNumber()
{ {

View File

@@ -164,7 +164,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
} }
} }
$query = new \User_Query($this->app); $query = $this->app['phraseanet.user-query'];
$templates = $query $templates = $query
->only_templates(true) ->only_templates(true)
->execute()->get_results(); ->execute()->get_results();

View File

@@ -57,7 +57,7 @@ class Manage extends Helper
, 'offset_start' => 0 , 'offset_start' => 0
]; ];
$query = new \User_Query($this->app); $query = $this->app['phraseanet.user-query'];
if (is_array($this->query_parms['base_id'])) if (is_array($this->query_parms['base_id']))
$query->on_base_ids($this->query_parms['base_id']); $query->on_base_ids($this->query_parms['base_id']);
@@ -95,7 +95,7 @@ class Manage extends Helper
, 'offset_start' => $offset_start , 'offset_start' => $offset_start
]; ];
$query = new \User_Query($this->app); $query = $this->app['phraseanet.user-query'];
if (is_array($this->query_parms['base_id'])) if (is_array($this->query_parms['base_id']))
$query->on_base_ids($this->query_parms['base_id']); $query->on_base_ids($this->query_parms['base_id']);
@@ -124,7 +124,7 @@ class Manage extends Helper
$this->query_parms[$k] = false; $this->query_parms[$k] = false;
} }
$query = new \User_Query($this->app); $query = $this->app['phraseanet.user-query'];
$templates = $query $templates = $query
->only_templates(true) ->only_templates(true)
->execute()->get_results(); ->execute()->get_results();

View File

@@ -40,6 +40,7 @@ class WriteMetadataEditor extends AbstractEditor
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
<cleardoc>0</cleardoc> <cleardoc>0</cleardoc>
<mwg>0</mwg>
</tasksettings> </tasksettings>
EOF; EOF;
} }
@@ -51,6 +52,7 @@ EOF;
{ {
return [ return [
'cleardoc' => static::FORM_TYPE_BOOLEAN, 'cleardoc' => static::FORM_TYPE_BOOLEAN,
'mwg' => static::FORM_TYPE_BOOLEAN,
]; ];
} }
} }

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\TaskManager\Job; namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Event\BridgeUploadFailureEvent;
use Alchemy\Phrasea\TaskManager\Editor\DefaultEditor; use Alchemy\Phrasea\TaskManager\Editor\DefaultEditor;
class BridgeJob extends AbstractJob class BridgeJob extends AbstractJob
@@ -153,16 +154,7 @@ class BridgeJob extends AbstractJob
switch ($status) { switch ($status) {
case \Bridge_Element::STATUS_ERROR: case \Bridge_Element::STATUS_ERROR:
$app['dispatcher']->dispatch(new BridgeUploadFailureEvent($element, $error_message));
$params = [
'usr_id' => $account->get_user()->getId(),
'reason' => $error_message,
'account_id' => $account->get_id(),
'sbas_id' => $element->get_record()->get_sbas_id(),
'record_id' => $element->get_record()->get_record_id(),
];
$app['events-manager']->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break; break;
default: default:
case \Bridge_Element::STATUS_DONE: case \Bridge_Element::STATUS_DONE:

View File

@@ -63,13 +63,13 @@ class SubdefsJob extends AbstractJob
if (!$this->isStarted()) { if (!$this->isStarted()) {
break; break;
} }
$connbas = $databox->get_connection(); $conn = $databox->get_connection();
$sql = 'SELECT coll_id, record_id $sql = 'SELECT coll_id, record_id
FROM record FROM record
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0 WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
ORDER BY record_id DESC LIMIT 0, 30'; ORDER BY record_id DESC LIMIT 0, 30';
$stmt = $connbas->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -91,7 +91,7 @@ class SubdefsJob extends AbstractJob
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW() SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
WHERE record_id=:record_id'; WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute([':record_id' => $row['record_id']]); $stmt->execute([':record_id' => $row['record_id']]);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -100,7 +100,7 @@ class SubdefsJob extends AbstractJob
SET status=(status & ~0x03), SET status=(status & ~0x03),
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ') jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')
WHERE record_id=:record_id'; WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute([':record_id' => $row['record_id']]); $stmt->execute([':record_id' => $row['record_id']]);
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -17,6 +17,9 @@ use PHPExiftool\Driver\Value;
use PHPExiftool\Driver\Tag; use PHPExiftool\Driver\Tag;
use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException; use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException;
use PHPExiftool\Writer; use PHPExiftool\Writer;
use PHPExiftool\Driver\TagFactory;
use PHPExiftool\Writer as ExifWriter;
use PHPExiftool\Exception\TagUnknown;
class WriteMetadataJob extends AbstractJob class WriteMetadataJob extends AbstractJob
{ {
@@ -60,69 +63,65 @@ class WriteMetadataJob extends AbstractJob
$app = $data->getApplication(); $app = $data->getApplication();
$settings = simplexml_load_string($data->getTask()->getSettings()); $settings = simplexml_load_string($data->getTask()->getSettings());
$clearDoc = (Boolean) (string) $settings->cleardoc; $clearDoc = (Boolean) (string) $settings->cleardoc;
$MWG = (Boolean) (string) $settings->mwg;
// move this in service provider configuration // move this in service provider configuration
$app['exiftool.writer']->setModule(Writer::MODULE_MWG, true); // $app['exiftool.writer']->setModule(Writer::MODULE_MWG, true);
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
$connbas = $databox->get_connection(); $conn = $databox->get_connection();
$subdefgroups = $databox->get_subdef_structure(); $metaSubdefs = [];
$metasubdefs = [];
foreach ($subdefgroups as $type => $subdefs) { foreach ($databox->get_subdef_structure() as $type => $definitions) {
foreach ($subdefs as $sub) { foreach ($definitions as $sub) {
$name = $sub->get_name(); $name = $sub->get_name();
if ($sub->meta_writeable()) { if ($sub->meta_writeable()) {
$metasubdefs[$name . '_' . $type] = true; $metaSubdefs[$name . '_' . $type] = true;
} }
} }
} }
$sql = 'SELECT record_id, coll_id, jeton $sql = 'SELECT record_id, coll_id, jeton FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)';
$stmt = $connbas->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) { foreach ($rs as $row) {
$record_id = $row['record_id']; $record_id = $row['record_id'];
$jeton = $row['jeton']; $token = $row['jeton'];
$record = $databox->get_record($record_id); $record = $databox->get_record($record_id);
$type = $record->get_type(); $type = $record->get_type();
$subdefs = $record->get_subdefs();
$tsub = []; $subdefs = [];
foreach ($record->get_subdefs() as $name => $subdef) {
foreach ($subdefs as $name => $subdef) { $write_document = (($token & JETON_WRITE_META_DOC) && $name == 'document');
$write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document'); $write_subdef = (($token & JETON_WRITE_META_SUBDEF) && isset($metaSubdefs[$name . '_' . $type]));
$write_subdef = (($jeton & JETON_WRITE_META_SUBDEF) && isset($metasubdefs[$name . '_' . $type]));
if (($write_document || $write_subdef) && $subdef->is_physically_present()) { if (($write_document || $write_subdef) && $subdef->is_physically_present()) {
$tsub[$name] = $subdef->get_pathfile(); $subdefs[$name] = $subdef->get_pathfile();
} }
} }
$metadatas = new Metadata\MetadataBag(); $metadata = new Metadata\MetadataBag();
if ($record->get_uuid()) { if ($record->get_uuid()) {
$metadatas->add( $metadata->add(
new Metadata\Metadata( new Metadata\Metadata(
new Tag\XMPExif\ImageUniqueID(), new Tag\XMPExif\ImageUniqueID(),
new Value\Mono($record->get_uuid()) new Value\Mono($record->get_uuid())
) )
); );
$metadatas->add( $metadata->add(
new Metadata\Metadata( new Metadata\Metadata(
new Tag\ExifIFD\ImageUniqueID(), new Tag\ExifIFD\ImageUniqueID(),
new Value\Mono($record->get_uuid()) new Value\Mono($record->get_uuid())
) )
); );
$metadatas->add( $metadata->add(
new Metadata\Metadata( new Metadata\Metadata(
new Tag\IPTC\UniqueDocumentID(), new Tag\IPTC\UniqueDocumentID(),
new Value\Mono($record->get_uuid()) new Value\Mono($record->get_uuid())
@@ -130,44 +129,76 @@ class WriteMetadataJob extends AbstractJob
); );
} }
foreach ($record->get_caption()->get_fields() as $field) { $caption = $record->get_caption();
$meta = $field->get_databox_field(); foreach($databox->get_meta_structure() as $fieldStructure) {
/* @var $meta \databox_field */
$datas = $field->get_values(); $tagName = $fieldStructure->get_tag()->getTagname();
$fieldName = $fieldStructure->get_name();
if ($meta->is_multi()) { // skip fields with no src
$values = []; if($tagName == '') {
foreach ($datas as $data) { continue;
$values[] = $data->getValue();
}
$value = new Value\Multi($values);
} else {
$data = array_pop($datas);
$value = new Value\Mono($data->getValue());
} }
$metadatas->add( // check exiftool known tags to skip Phraseanet:tf-*
new Metadata\Metadata($meta->get_tag(), $value) try {
TagFactory::getFromRDFTagname($tagName);
} catch (TagUnknown $e) {
continue;
}
try {
$field = $caption->get_field($fieldName);
$data = $field->get_values();
if ($fieldStructure->is_multi()) {
$values = array();
foreach ($data as $value) {
$values[] = $value->getValue();
}
$value = new Value\Multi($values);
} else {
$data = array_pop($data);
$value = $data->getValue();
$value = new Value\Mono($value);
}
} catch(\Exception $e) {
// the field is not set in the record, erase it
if ($fieldStructure->is_multi()) {
$value = new Value\Multi(Array(''));
}
else {
$value = new Value\Mono('');
}
}
$metadata->add(
new Metadata\Metadata($fieldStructure->get_tag(), $value)
); );
} }
foreach ($tsub as $name => $file) { $app['exiftool.writer']->reset();
$app['exiftool.writer']->erase($name != 'document' || $clearDoc, true);
if($MWG) {
$app['exiftool.writer']->setModule(ExifWriter::MODULE_MWG, true);
}
foreach ($subdefs as $name => $file) {
$app['exiftool.writer']->erase($name != 'document' || $clearDoc, true);
try { try {
$app['exiftool.writer']->write($file, $metadatas); $app['exiftool.writer']->write($file, $metadata);
$this->log('debug', sprintf('meta written for sbasid=%1$d - recordid=%2$d (%3$s)', $databox->get_sbas_id(), $record_id, $name));
$this->log(sprintf('meta written for sbasid=%1$d - recordid=%2$d (%3$s)', $databox->get_sbas_id(), $record_id, $name), self::LOG_INFO);
} catch (PHPExiftoolException $e) { } catch (PHPExiftoolException $e) {
$this->log('error', sprintf('meta was not written for sbasid=%d - recordid=%d (%s) because "%s"', $databox->get_sbas_id(), $record_id, $name, $e->getMessage())); $this->log(sprintf('meta NOT written for sbasid=%1$d - recordid=%2$d (%3$s) because "%s"', $databox->get_sbas_id(), $record_id, $name, $e->getMessage()), self::LOG_ERROR);
} }
} }
$sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . ' $sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . ' WHERE record_id = :record_id';
WHERE record_id = :record_id'; $stmt = $conn->prepare($sql);
$stmt = $connbas->prepare($sql); $stmt->execute([':record_id' => $record_id]);
$stmt->execute([':record_id' => $row['record_id']]);
$stmt->closeCursor(); $stmt->closeCursor();
} }
} }

View File

@@ -0,0 +1,518 @@
<?php
namespace Alchemy\Phrasea\Utilities;
class Countries
{
public static function getCountries($lng = 'fr')
{
$countries['en'] = [
'AF' => 'AFGHANISTAN',
'AX' => 'ÅLAND ISLANDS',
'AL' => 'ALBANIA',
'DZ' => 'ALGERIA',
'AS' => 'AMERICAN SAMOA',
'AD' => 'ANDORRA',
'AO' => 'ANGOLA',
'AI' => 'ANGUILLA',
'AQ' => 'ANTARCTICA',
'AG' => 'ANTIGUA AND BARBUDA',
'AR' => 'ARGENTINA',
'AM' => 'ARMENIA',
'AW' => 'ARUBA',
'AU' => 'AUSTRALIA',
'AT' => 'AUSTRIA',
'AZ' => 'AZERBAIJAN',
'BS' => 'BAHAMAS',
'BH' => 'BAHRAIN',
'BD' => 'BANGLADESH',
'BB' => 'BARBADOS',
'BY' => 'BELARUS',
'BE' => 'BELGIUM',
'BZ' => 'BELIZE',
'BJ' => 'BENIN',
'BM' => 'BERMUDA',
'BT' => 'BHUTAN',
'BO' => 'BOLIVIA',
'BA' => 'BOSNIA AND HERZEGOVINA',
'BW' => 'BOTSWANA',
'BV' => 'BOUVET ISLAND',
'BR' => 'BRAZIL',
'IO' => 'BRITISH INDIAN OCEAN TERRITORY',
'BN' => 'BRUNEI DARUSSALAM',
'BG' => 'BULGARIA',
'BF' => 'BURKINA FASO',
'BI' => 'BURUNDI',
'KH' => 'CAMBODIA',
'CM' => 'CAMEROON',
'CA' => 'CANADA',
'CV' => 'CAPE VERDE',
'KY' => 'CAYMAN ISLANDS',
'CF' => 'CENTRAL AFRICAN REPUBLIC',
'TD' => 'CHAD',
'CL' => 'CHILE',
'CN' => 'CHINA',
'CX' => 'CHRISTMAS ISLAND',
'CC' => 'COCOS (KEELING) ISLANDS',
'CO' => 'COLOMBIA',
'KM' => 'COMOROS',
'CG' => 'CONGO',
'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
'CK' => 'COOK ISLANDS',
'CR' => 'COSTA RICA',
'CI' => 'CÔTE D\'IVOIRE',
'HR' => 'CROATIA',
'CU' => 'CUBA',
'CY' => 'CYPRUS',
'CZ' => 'CZECH REPUBLIC',
'DK' => 'DENMARK',
'DJ' => 'DJIBOUTI',
'DM' => 'DOMINICA',
'DO' => 'DOMINICAN REPUBLIC',
'EC' => 'ECUADOR',
'EG' => 'EGYPT',
'SV' => 'EL SALVADOR',
'GQ' => 'EQUATORIAL GUINEA',
'ER' => 'ERITREA',
'EE' => 'ESTONIA',
'ET' => 'ETHIOPIA',
'FK' => 'FALKLAND ISLANDS (MALVINAS)',
'FO' => 'FAROE ISLANDS',
'FJ' => 'FIJI',
'FI' => 'FINLAND',
'FR' => 'FRANCE',
'GF' => 'FRENCH GUIANA',
'PF' => 'FRENCH POLYNESIA',
'TF' => 'FRENCH SOUTHERN TERRITORIES',
'GA' => 'GABON',
'GM' => 'GAMBIA',
'GE' => 'GEORGIA',
'DE' => 'GERMANY',
'GH' => 'GHANA',
'GI' => 'GIBRALTAR',
'GR' => 'GREECE',
'GL' => 'GREENLAND',
'GD' => 'GRENADA',
'GP' => 'GUADELOUPE',
'GU' => 'GUAM',
'GT' => 'GUATEMALA',
'GG' => 'GUERNSEY',
'GN' => 'GUINEA',
'GW' => 'GUINEA-BISSAU',
'GY' => 'GUYANA',
'HT' => 'HAITI',
'HM' => 'HEARD ISLAND AND MCDONALD ISLANDS',
'VA' => 'HOLY SEE (VATICAN CITY STATE)',
'HN' => 'HONDURAS',
'HK' => 'HONG KONG',
'HU' => 'HUNGARY',
'IS' => 'ICELAND',
'IN' => 'INDIA',
'ID' => 'INDONESIA',
'IR' => 'IRAN, ISLAMIC REPUBLIC OF',
'IQ' => 'IRAQ',
'IE' => 'IRELAND',
'IM' => 'ISLE OF MAN',
'IL' => 'ISRAEL',
'IT' => 'ITALY',
'JM' => 'JAMAICA',
'JP' => 'JAPAN',
'JE' => 'JERSEY',
'JO' => 'JORDAN',
'KZ' => 'KAZAKHSTAN',
'KE' => 'KENYA',
'KI' => 'KIRIBATI',
'KP' => 'KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF',
'KR' => 'KOREA, REPUBLIC OF',
'KW' => 'KUWAIT',
'KG' => 'KYRGYZSTAN',
'LA' => 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC',
'LV' => 'LATVIA',
'LB' => 'LEBANON',
'LS' => 'LESOTHO',
'LR' => 'LIBERIA',
'LY' => 'LIBYAN ARAB JAMAHIRIYA',
'LI' => 'LIECHTENSTEIN',
'LT' => 'LITHUANIA',
'LU' => 'LUXEMBOURG',
'MO' => 'MACAO',
'MK' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF',
'MG' => 'MADAGASCAR',
'MW' => 'MALAWI',
'MY' => 'MALAYSIA',
'MV' => 'MALDIVES',
'ML' => 'MALI',
'MT' => 'MALTA',
'MH' => 'MARSHALL ISLANDS',
'MQ' => 'MARTINIQUE',
'MR' => 'MAURITANIA',
'MU' => 'MAURITIUS',
'YT' => 'MAYOTTE',
'MX' => 'MEXICO',
'FM' => 'MICRONESIA, FEDERATED STATES OF',
'MD' => 'MOLDOVA, REPUBLIC OF',
'MC' => 'MONACO',
'MN' => 'MONGOLIA',
'ME' => 'MONTENEGRO',
'MS' => 'MONTSERRAT',
'MA' => 'MOROCCO',
'MZ' => 'MOZAMBIQUE',
'MM' => 'MYANMAR',
'NA' => 'NAMIBIA',
'NR' => 'NAURU',
'NP' => 'NEPAL',
'NL' => 'NETHERLANDS',
'AN' => 'NETHERLANDS ANTILLES',
'NC' => 'NEW CALEDONIA',
'NZ' => 'NEW ZEALAND',
'NI' => 'NICARAGUA',
'NE' => 'NIGER',
'NG' => 'NIGERIA',
'NU' => 'NIUE',
'NF' => 'NORFOLK ISLAND',
'MP' => 'NORTHERN MARIANA ISLANDS',
'NO' => 'NORWAY',
'OM' => 'OMAN',
'PK' => 'PAKISTAN',
'PW' => 'PALAU',
'PS' => 'PALESTINIAN TERRITORY, OCCUPIED',
'PA' => 'PANAMA',
'PG' => 'PAPUA NEW GUINEA',
'PY' => 'PARAGUAY',
'PE' => 'PERU',
'PH' => 'PHILIPPINES',
'PN' => 'PITCAIRN',
'PL' => 'POLAND',
'PT' => 'PORTUGAL',
'PR' => 'PUERTO RICO',
'QA' => 'QATAR',
'RE' => 'REUNION',
'RO' => 'ROMANIA',
'RU' => 'RUSSIAN FEDERATION',
'RW' => 'RWANDA',
'BL' => 'SAINT BARTHÉLEMY',
'SH' => 'SAINT HELENA',
'KN' => 'SAINT KITTS AND NEVIS',
'LC' => 'SAINT LUCIA',
'MF' => 'SAINT MARTIN',
'PM' => 'SAINT PIERRE AND MIQUELON',
'VC' => 'SAINT VINCENT AND THE GRENADINES',
'WS' => 'SAMOA',
'SM' => 'SAN MARINO',
'ST' => 'SAO TOME AND PRINCIPE',
'SA' => 'SAUDI ARABIA',
'SN' => 'SENEGAL',
'RS' => 'SERBIA',
'SC' => 'SEYCHELLES',
'SL' => 'SIERRA LEONE',
'SG' => 'SINGAPORE',
'SK' => 'SLOVAKIA',
'SI' => 'SLOVENIA',
'SB' => 'SOLOMON ISLANDS',
'SO' => 'SOMALIA',
'ZA' => 'SOUTH AFRICA',
'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
'ES' => 'SPAIN',
'LK' => 'SRI LANKA',
'SD' => 'SUDAN',
'SR' => 'SURINAME',
'SJ' => 'SVALBARD AND JAN MAYEN',
'SZ' => 'SWAZILAND',
'SE' => 'SWEDEN',
'CH' => 'SWITZERLAND',
'SY' => 'SYRIAN ARAB REPUBLIC',
'TW' => 'TAIWAN, PROVINCE OF CHINA',
'TJ' => 'TAJIKISTAN',
'TZ' => 'TANZANIA, UNITED REPUBLIC OF',
'TH' => 'THAILAND',
'TL' => 'TIMOR-LESTE',
'TG' => 'TOGO',
'TK' => 'TOKELAU',
'TO' => 'TONGA',
'TT' => 'TRINIDAD AND TOBAGO',
'TN' => 'TUNISIA',
'TR' => 'TURKEY',
'TM' => 'TURKMENISTAN',
'TC' => 'TURKS AND CAICOS ISLANDS',
'TV' => 'TUVALU',
'UG' => 'UGANDA',
'UA' => 'UKRAINE',
'AE' => 'UNITED ARAB EMIRATES',
'GB' => 'UNITED KINGDOM',
'US' => 'UNITED STATES',
'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS',
'UY' => 'URUGUAY',
'UZ' => 'UZBEKISTAN',
'VU' => 'VANUATU',
'VE' => 'VENEZUELA',
'VN' => 'VIET NAM',
'VG' => 'VIRGIN ISLANDS, BRITISH',
'VI' => 'VIRGIN ISLANDS, U.S.',
'WF' => 'WALLIS AND FUTUNA',
'EH' => 'WESTERN SAHARA',
'YE' => 'YEMEN',
'ZM' => 'ZAMBIA',
'ZW' => 'ZIMBABWE',
];
$countries['us'] = $countries['en'];
$countries['fr'] = [
'AF' => 'AFGHANISTAN',
'ZA' => 'AFRIQUE DU SUD',
'AX' => 'ÅLAND, ÎLES',
'AL' => 'ALBANIE',
'DZ' => 'ALGÉRIE',
'DE' => 'ALLEMAGNE',
'AD' => 'ANDORRE',
'AO' => 'ANGOLA',
'AI' => 'ANGUILLA',
'AQ' => 'ANTARCTIQUE',
'AG' => 'ANTIGUA-ET-BARBUDA',
'AN' => 'ANTILLES NÉERLANDAISES',
'SA' => 'ARABIE SAOUDITE',
'AR' => 'ARGENTINE',
'AM' => 'ARMÉNIE',
'AW' => 'ARUBA',
'AU' => 'AUSTRALIE',
'AT' => 'AUTRICHE',
'AZ' => 'AZERBAÏDJAN',
'BS' => 'BAHAMAS',
'BH' => 'BAHREÏN',
'BD' => 'BANGLADESH',
'BB' => 'BARBADE',
'BY' => 'BÉLARUS',
'BE' => 'BELGIQUE',
'BZ' => 'BELIZE',
'BJ' => 'BÉNIN',
'BM' => 'BERMUDES',
'BT' => 'BHOUTAN',
'BO' => 'BOLIVIE',
'BA' => 'BOSNIE-HERZÉGOVINE',
'BW' => 'BOTSWANA',
'BV' => 'BOUVET, ÎLE',
'BR' => 'BRÉSIL',
'BN' => 'BRUNÉI DARUSSALAM',
'BG' => 'BULGARIE',
'BF' => 'BURKINA FASO',
'BI' => 'BURUNDI',
'KY' => 'CAÏMANES, ÎLES',
'KH' => 'CAMBODGE',
'CM' => 'CAMEROUN',
'CA' => 'CANADA',
'CV' => 'CAP-VERT',
'CF' => 'CENTRAFRICAINE, RÉPUBLIQUE',
'CL' => 'CHILI',
'CN' => 'CHINE',
'CX' => 'CHRISTMAS, ÎLE',
'CY' => 'CHYPRE',
'CC' => 'COCOS (KEELING), ÎLES',
'CO' => 'COLOMBIE',
'KM' => 'COMORES',
'CG' => 'CONGO',
'CD' => 'CONGO, LA RÉPUBLIQUE DÉMOCRATIQUE DU',
'CK' => 'COOK, ÎLES',
'KR' => 'CORÉE, RÉPUBLIQUE DE',
'KP' => 'CORÉE, RÉPUBLIQUE POPULAIRE DÉMOCRATIQUE DE',
'CR' => 'COSTA RICA',
'CI' => 'CÔTE D\'IVOIRE',
'HR' => 'CROATIE',
'CU' => 'CUBA',
'DK' => 'DANEMARK',
'DJ' => 'DJIBOUTI',
'DO' => 'DOMINICAINE, RÉPUBLIQUE',
'DM' => 'DOMINIQUE',
'EG' => 'ÉGYPTE',
'SV' => 'EL SALVADOR',
'AE' => 'ÉMIRATS ARABES UNIS',
'EC' => 'ÉQUATEUR',
'ER' => 'ÉRYTHRÉE',
'ES' => 'ESPAGNE',
'EE' => 'ESTONIE',
'US' => 'ÉTATS-UNIS',
'ET' => 'ÉTHIOPIE',
'FK' => 'FALKLAND, ÎLES (MALVINAS)',
'FO' => 'FÉROÉ, ÎLES',
'FJ' => 'FIDJI',
'FI' => 'FINLANDE',
'FR' => 'FRANCE',
'GA' => 'GABON',
'GM' => 'GAMBIE',
'GE' => 'GÉORGIE',
'GS' => 'GÉORGIE DU SUD ET LES ÎLES SANDWICH DU SUD',
'GH' => 'GHANA',
'GI' => 'GIBRALTAR',
'GR' => 'GRÈCE',
'GD' => 'GRENADE',
'GL' => 'GROENLAND',
'GP' => 'GUADELOUPE',
'GU' => 'GUAM',
'GT' => 'GUATEMALA',
'GG' => 'GUERNESEY',
'GN' => 'GUINÉE',
'GW' => 'GUINÉE-BISSAU',
'GQ' => 'GUINÉE ÉQUATORIALE',
'GY' => 'GUYANA',
'GF' => 'GUYANE FRANÇAISE',
'HT' => 'HAÏTI',
'HM' => 'HEARD, ÎLE ET MCDONALD, ÎLES',
'HN' => 'HONDURAS',
'HK' => 'HONG-KONG',
'HU' => 'HONGRIE',
'IM' => 'ÎLE DE MAN',
'UM' => 'ÎLES MINEURES ÉLOIGNÉES DES ÉTATS-UNIS',
'VG' => 'ÎLES VIERGES BRITANNIQUES',
'VI' => 'ÎLES VIERGES DES ÉTATS-UNIS',
'IN' => 'INDE',
'ID' => 'INDONÉSIE',
'IR' => 'IRAN, RÉPUBLIQUE ISLAMIQUE D\'',
'IQ' => 'IRAQ',
'IE' => 'IRLANDE',
'IS' => 'ISLANDE',
'IL' => 'ISRAËL',
'IT' => 'ITALIE',
'JM' => 'JAMAÏQUE',
'JP' => 'JAPON',
'JE' => 'JERSEY',
'JO' => 'JORDANIE',
'KZ' => 'KAZAKHSTAN',
'KE' => 'KENYA',
'KG' => 'KIRGHIZISTAN',
'KI' => 'KIRIBATI',
'KW' => 'KOWEÏT',
'LA' => 'LAO, RÉPUBLIQUE DÉMOCRATIQUE POPULAIRE',
'LS' => 'LESOTHO',
'LV' => 'LETTONIE',
'LB' => 'LIBAN',
'LR' => 'LIBÉRIA',
'LY' => 'LIBYENNE, JAMAHIRIYA ARABE',
'LI' => 'LIECHTENSTEIN',
'LT' => 'LITUANIE',
'LU' => 'LUXEMBOURG',
'MO' => 'MACAO',
'MK' => 'MACÉDOINE, L\'EX-RÉPUBLIQUE YOUGOSLAVE DE',
'MG' => 'MADAGASCAR',
'MY' => 'MALAISIE',
'MW' => 'MALAWI',
'MV' => 'MALDIVES',
'ML' => 'MALI',
'MT' => 'MALTE',
'MP' => 'MARIANNES DU NORD, ÎLES',
'MA' => 'MAROC',
'MH' => 'MARSHALL, ÎLES',
'MQ' => 'MARTINIQUE',
'MU' => 'MAURICE',
'MR' => 'MAURITANIE',
'YT' => 'MAYOTTE',
'MX' => 'MEXIQUE',
'FM' => 'MICRONÉSIE, ÉTATS FÉDÉRÉS DE',
'MD' => 'MOLDOVA, RÉPUBLIQUE DE',
'MC' => 'MONACO',
'MN' => 'MONGOLIE',
'ME' => 'MONTÉNÉGRO',
'MS' => 'MONTSERRAT',
'MZ' => 'MOZAMBIQUE',
'MM' => 'MYANMAR',
'NA' => 'NAMIBIE',
'NR' => 'NAURU',
'NP' => 'NÉPAL',
'NI' => 'NICARAGUA',
'NE' => 'NIGER',
'NG' => 'NIGÉRIA',
'NU' => 'NIUÉ',
'NF' => 'NORFOLK, ÎLE',
'NO' => 'NORVÈGE',
'NC' => 'NOUVELLE-CALÉDONIE',
'NZ' => 'NOUVELLE-ZÉLANDE',
'IO' => 'OCÉAN INDIEN, TERRITOIRE BRITANNIQUE DE L\'',
'OM' => 'OMAN',
'UG' => 'OUGANDA',
'UZ' => 'OUZBÉKISTAN',
'PK' => 'PAKISTAN',
'PW' => 'PALAOS',
'PS' => 'PALESTINIEN OCCUPÉ, TERRITOIRE',
'PA' => 'PANAMA',
'PG' => 'PAPOUASIE-NOUVELLE-GUINÉE',
'PY' => 'PARAGUAY',
'NL' => 'PAYS-BAS',
'PE' => 'PÉROU',
'PH' => 'PHILIPPINES',
'PN' => 'PITCAIRN',
'PL' => 'POLOGNE',
'PF' => 'POLYNÉSIE FRANÇAISE',
'PR' => 'PORTO RICO',
'PT' => 'PORTUGAL',
'QA' => 'QATAR',
'RE' => 'RÉUNION',
'RO' => 'ROUMANIE',
'GB' => 'ROYAUME-UNI',
'RU' => 'RUSSIE, FÉDÉRATION DE',
'RW' => 'RWANDA',
'EH' => 'SAHARA OCCIDENTAL',
'BL' => 'SAINT-BARTHÉLEMY',
'SH' => 'SAINTE-HÉLÈNE',
'LC' => 'SAINTE-LUCIE',
'KN' => 'SAINT-KITTS-ET-NEVIS',
'SM' => 'SAINT-MARIN',
'MF' => 'SAINT-MARTIN',
'PM' => 'SAINT-PIERRE-ET-MIQUELON',
'VA' => 'SAINT-SIÈGE (ÉTAT DE LA CITÉ DU VATICAN)',
'VC' => 'SAINT-VINCENT-ET-LES GRENADINES',
'SB' => 'SALOMON, ÎLES',
'WS' => 'SAMOA',
'AS' => 'SAMOA AMÉRICAINES',
'ST' => 'SAO TOMÉ-ET-PRINCIPE',
'SN' => 'SÉNÉGAL',
'RS' => 'SERBIE',
'SC' => 'SEYCHELLES',
'SL' => 'SIERRA LEONE',
'SG' => 'SINGAPOUR',
'SK' => 'SLOVAQUIE',
'SI' => 'SLOVÉNIE',
'SO' => 'SOMALIE',
'SD' => 'SOUDAN',
'LK' => 'SRI LANKA',
'SE' => 'SUÈDE',
'CH' => 'SUISSE',
'SR' => 'SURINAME',
'SJ' => 'SVALBARD ET ÎLE JAN MAYEN',
'SZ' => 'SWAZILAND',
'SY' => 'SYRIENNE, RÉPUBLIQUE ARABE',
'TJ' => 'TADJIKISTAN',
'TW' => 'TAÏWAN, PROVINCE DE CHINE',
'TZ' => 'TANZANIE, RÉPUBLIQUE-UNIE DE',
'TD' => 'TCHAD',
'CZ' => 'TCHÈQUE, RÉPUBLIQUE',
'TF' => 'TERRES AUSTRALES FRANÇAISES',
'TH' => 'THAÏLANDE',
'TL' => 'TIMOR-LESTE',
'TG' => 'TOGO',
'TK' => 'TOKELAU',
'TO' => 'TONGA',
'TT' => 'TRINITÉ-ET-TOBAGO',
'TN' => 'TUNISIE',
'TM' => 'TURKMÉNISTAN',
'TC' => 'TURKS ET CAÏQUES, ÎLES',
'TR' => 'TURQUIE',
'TV' => 'TUVALU',
'UA' => 'UKRAINE',
'UY' => 'URUGUAY',
'VU' => 'VANUATU',
'VE' => 'VENEZUELA',
'VN' => 'VIET NAM',
'WF' => 'WALLIS ET FUTUNA',
'YE' => 'YÉMEN',
'ZM' => 'ZAMBIE',
'ZW' => 'ZIMBABWE'
];
if (!isset($countries[$lng])) {
$lng = 'us';
}
foreach ($countries[$lng] as $k => $country) {
$countries[$lng][$k] = mb_strtolower($country);
}
return $countries[$lng];
}
}

View File

@@ -52,7 +52,7 @@ class UserProvider implements ControlProviderInterface
*/ */
public function find($query, User $for_user,\databox $on_databox = null) public function find($query, User $for_user,\databox $on_databox = null)
{ {
$user_query = new \User_Query($this->app); $user_query = $this->app['phraseanet.user-query'];
$users = $user_query $users = $user_query
->like(\User_Query::LIKE_EMAIL, $query) ->like(\User_Query::LIKE_EMAIL, $query)

View File

@@ -22,7 +22,7 @@ class FeedEntryProcessor extends AbstractProcessor implements ProcessorInterface
$feed = $entry->getFeed(); $feed = $entry->getFeed();
$query = new \User_Query($this->app); $query = $this->app['phraseanet.user-query'];
$query->include_phantoms(true) $query->include_phantoms(true)
->include_invite(false) ->include_invite(false)

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,6 @@ use Alchemy\Phrasea\Application;
interface User_QueryInterface interface User_QueryInterface
{ {
public function __construct(Application $app); public function __construct(Application $app);
public function get_results(); public function get_results();

View File

@@ -515,7 +515,7 @@ class collection implements cache_cacheableInterface
{ {
$params = [':base_id' => $this->get_base_id()]; $params = [':base_id' => $this->get_base_id()];
$query = new User_Query($app); $query = $app['phraseanet.user-query'];
$total = $query->on_base_ids([$this->get_base_id()]) $total = $query->on_base_ids([$this->get_base_id()])
->include_phantoms(false) ->include_phantoms(false)
->include_special_users(true) ->include_special_users(true)

View File

@@ -439,19 +439,14 @@ class databox extends base
$ret['thesaurus_indexed'] += $row['n']; $ret['thesaurus_indexed'] += $row['n'];
} }
$sql = "SELECT type, jeton, COUNT(record_id) AS n FROM record WHERE jeton & ".JETON_MAKE_SUBDEF." GROUP BY type, jeton"; $sql = "SELECT type, COUNT(record_id) AS n FROM record WHERE jeton & ".JETON_MAKE_SUBDEF." GROUP BY type";
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
$stmt->execute(); $stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) { foreach ($rs as $row) {
if(!array_key_exists($row['type'], $ret['jeton_subdef'])) { $ret['jeton_subdef'][$row['type']] = (int)$row['n'];
$ret['jeton_subdef'][$row['type']] = 0;
}
if((int)$row['jeton'] & JETON_MAKE_SUBDEF) {
$ret['jeton_subdef'][$row['type']] += (int)$row['n'];
}
} }
return $ret; return $ret;
@@ -463,7 +458,7 @@ class databox extends base
$collection->unmount_collection($this->app); $collection->unmount_collection($this->app);
} }
$query = new User_Query($this->app); $query = $this->app['phraseanet.user-query'];
$total = $query->on_sbas_ids([$this->id]) $total = $query->on_sbas_ids([$this->id])
->include_phantoms(false) ->include_phantoms(false)
->include_special_users(true) ->include_special_users(true)
@@ -986,6 +981,7 @@ class databox extends base
->set_separator(isset($field['separator']) ? (string) $field['separator'] : '') ->set_separator(isset($field['separator']) ? (string) $field['separator'] : '')
->set_required((isset($field['required']) && (string) $field['required'] == 1)) ->set_required((isset($field['required']) && (string) $field['required'] == 1))
->set_business((isset($field['business']) && (string) $field['business'] == 1)) ->set_business((isset($field['business']) && (string) $field['business'] == 1))
->set_aggregable((isset($field['aggregable']) && (string) $field['aggregable'] == 1))
->set_type($type) ->set_type($type)
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '') ->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) ->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))

View File

@@ -117,6 +117,9 @@ class databox_field implements cache_cacheableInterface
* @var boolean * @var boolean
*/ */
protected $Business; protected $Business;
protected $aggregable;
protected $renamed = false; protected $renamed = false;
/** /**
@@ -180,7 +183,7 @@ class databox_field implements cache_cacheableInterface
$sql = "SELECT `thumbtitle`, `separator`, `dces_element`, `tbranch`, $sql = "SELECT `thumbtitle`, `separator`, `dces_element`, `tbranch`,
`type`, `report`, `multi`, `required`, `readonly`, `indexable`, `type`, `report`, `multi`, `required`, `readonly`, `indexable`,
`name`, `src`, `business`, `VocabularyControlType`, `name`, `src`, `business`, `aggregable`, `VocabularyControlType`,
`RestrictToVocabularyControl`, `sorter`, `RestrictToVocabularyControl`, `sorter`,
`label_en`, `label_fr`, `label_de`, `label_nl` `label_en`, `label_fr`, `label_de`, `label_nl`
FROM metadatas_structure WHERE id=:id"; FROM metadatas_structure WHERE id=:id";
@@ -214,6 +217,7 @@ class databox_field implements cache_cacheableInterface
$this->multi = (Boolean) $row['multi']; $this->multi = (Boolean) $row['multi'];
$this->Business = (Boolean) $row['business']; $this->Business = (Boolean) $row['business'];
$this->report = (Boolean) $row['report']; $this->report = (Boolean) $row['report'];
$this->aggregable = (Boolean) $row['aggregable'];
$this->position = (Int) $row['sorter']; $this->position = (Int) $row['sorter'];
$this->type = $row['type'] ? : self::TYPE_STRING; $this->type = $row['type'] ? : self::TYPE_STRING;
$this->tbranch = $row['tbranch']; $this->tbranch = $row['tbranch'];
@@ -261,6 +265,11 @@ class databox_field implements cache_cacheableInterface
return $this->Business; return $this->Business;
} }
public function isAggregable()
{
return $this->aggregable;
}
/** /**
* *
* @param Application $app * @param Application $app
@@ -370,6 +379,7 @@ class databox_field implements cache_cacheableInterface
`separator` = :separator, `separator` = :separator,
`multi` = :multi, `multi` = :multi,
`business` = :business, `business` = :business,
`aggregable` = :aggregable,
`report` = :report, `report` = :report,
`type` = :type, `type` = :type,
`tbranch` = :tbranch, `tbranch` = :tbranch,
@@ -392,6 +402,7 @@ class databox_field implements cache_cacheableInterface
':separator' => $this->separator, ':separator' => $this->separator,
':multi' => $this->multi ? '1' : '0', ':multi' => $this->multi ? '1' : '0',
':business' => $this->Business ? '1' : '0', ':business' => $this->Business ? '1' : '0',
':aggregable' => $this->aggregable ? '1' : '0',
':report' => $this->report ? '1' : '0', ':report' => $this->report ? '1' : '0',
':type' => $this->type, ':type' => $this->type,
':tbranch' => $this->tbranch, ':tbranch' => $this->tbranch,
@@ -443,6 +454,7 @@ class databox_field implements cache_cacheableInterface
$meta->setAttribute('multi', $this->multi ? '1' : '0'); $meta->setAttribute('multi', $this->multi ? '1' : '0');
$meta->setAttribute('report', $this->report ? '1' : '0'); $meta->setAttribute('report', $this->report ? '1' : '0');
$meta->setAttribute('business', $this->Business ? '1' : '0'); $meta->setAttribute('business', $this->Business ? '1' : '0');
$meta->setAttribute('aggregable', $this->aggregable ? '1' : '0');
$meta->setAttribute('type', $this->type); $meta->setAttribute('type', $this->type);
$meta->setAttribute('tbranch', $this->tbranch); $meta->setAttribute('tbranch', $this->tbranch);
if ($this->multi) { if ($this->multi) {
@@ -601,6 +613,7 @@ class databox_field implements cache_cacheableInterface
{ {
$connbas = $this->get_connection(); $connbas = $this->get_connection();
if (null !== $DCES_element) { if (null !== $DCES_element) {
$sql = 'UPDATE metadatas_structure $sql = 'UPDATE metadatas_structure
SET dces_element = null WHERE dces_element = :dces_element'; SET dces_element = null WHERE dces_element = :dces_element';
@@ -695,6 +708,14 @@ class databox_field implements cache_cacheableInterface
return $this; return $this;
} }
public function set_aggregable($boolean)
{
$this->aggregable = ! ! $boolean;
return $this;
}
/** /**
* *
* @param boolean $required * @param boolean $required
@@ -932,6 +953,7 @@ class databox_field implements cache_cacheableInterface
'name' => $this->name, 'name' => $this->name,
'tag' => $this->tag->getTagname(), 'tag' => $this->tag->getTagname(),
'business' => $this->Business, 'business' => $this->Business,
'aggregable' => $this->aggregable,
'type' => $this->type, 'type' => $this->type,
'sorter' => $this->position, 'sorter' => $this->position,
'thumbtitle' => $this->thumbtitle, 'thumbtitle' => $this->thumbtitle,
@@ -975,11 +997,11 @@ class databox_field implements cache_cacheableInterface
$sql = "INSERT INTO metadatas_structure $sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`, (`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
`thumbtitle`, `multi`, `business`, `thumbtitle`, `multi`, `business`, `aggregable`,
`report`, `sorter`) `report`, `sorter`)
VALUES (null, :name, '', 0, 1, 'string', '', VALUES (null, :name, '', 0, 1, 'string', '',
null, :multi, null, :multi,
0, 1, :sorter)"; 0, 0, 1, :sorter)";
$name = self::generateName($name); $name = self::generateName($name);

View File

@@ -1,519 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
function getCountries($lng = 'fr')
{
$countries['en'] = [
'AF' => 'AFGHANISTAN',
'AX' => 'ÅLAND ISLANDS',
'AL' => 'ALBANIA',
'DZ' => 'ALGERIA',
'AS' => 'AMERICAN SAMOA',
'AD' => 'ANDORRA',
'AO' => 'ANGOLA',
'AI' => 'ANGUILLA',
'AQ' => 'ANTARCTICA',
'AG' => 'ANTIGUA AND BARBUDA',
'AR' => 'ARGENTINA',
'AM' => 'ARMENIA',
'AW' => 'ARUBA',
'AU' => 'AUSTRALIA',
'AT' => 'AUSTRIA',
'AZ' => 'AZERBAIJAN',
'BS' => 'BAHAMAS',
'BH' => 'BAHRAIN',
'BD' => 'BANGLADESH',
'BB' => 'BARBADOS',
'BY' => 'BELARUS',
'BE' => 'BELGIUM',
'BZ' => 'BELIZE',
'BJ' => 'BENIN',
'BM' => 'BERMUDA',
'BT' => 'BHUTAN',
'BO' => 'BOLIVIA',
'BA' => 'BOSNIA AND HERZEGOVINA',
'BW' => 'BOTSWANA',
'BV' => 'BOUVET ISLAND',
'BR' => 'BRAZIL',
'IO' => 'BRITISH INDIAN OCEAN TERRITORY',
'BN' => 'BRUNEI DARUSSALAM',
'BG' => 'BULGARIA',
'BF' => 'BURKINA FASO',
'BI' => 'BURUNDI',
'KH' => 'CAMBODIA',
'CM' => 'CAMEROON',
'CA' => 'CANADA',
'CV' => 'CAPE VERDE',
'KY' => 'CAYMAN ISLANDS',
'CF' => 'CENTRAL AFRICAN REPUBLIC',
'TD' => 'CHAD',
'CL' => 'CHILE',
'CN' => 'CHINA',
'CX' => 'CHRISTMAS ISLAND',
'CC' => 'COCOS (KEELING) ISLANDS',
'CO' => 'COLOMBIA',
'KM' => 'COMOROS',
'CG' => 'CONGO',
'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
'CK' => 'COOK ISLANDS',
'CR' => 'COSTA RICA',
'CI' => 'CÔTE D\'IVOIRE',
'HR' => 'CROATIA',
'CU' => 'CUBA',
'CY' => 'CYPRUS',
'CZ' => 'CZECH REPUBLIC',
'DK' => 'DENMARK',
'DJ' => 'DJIBOUTI',
'DM' => 'DOMINICA',
'DO' => 'DOMINICAN REPUBLIC',
'EC' => 'ECUADOR',
'EG' => 'EGYPT',
'SV' => 'EL SALVADOR',
'GQ' => 'EQUATORIAL GUINEA',
'ER' => 'ERITREA',
'EE' => 'ESTONIA',
'ET' => 'ETHIOPIA',
'FK' => 'FALKLAND ISLANDS (MALVINAS)',
'FO' => 'FAROE ISLANDS',
'FJ' => 'FIJI',
'FI' => 'FINLAND',
'FR' => 'FRANCE',
'GF' => 'FRENCH GUIANA',
'PF' => 'FRENCH POLYNESIA',
'TF' => 'FRENCH SOUTHERN TERRITORIES',
'GA' => 'GABON',
'GM' => 'GAMBIA',
'GE' => 'GEORGIA',
'DE' => 'GERMANY',
'GH' => 'GHANA',
'GI' => 'GIBRALTAR',
'GR' => 'GREECE',
'GL' => 'GREENLAND',
'GD' => 'GRENADA',
'GP' => 'GUADELOUPE',
'GU' => 'GUAM',
'GT' => 'GUATEMALA',
'GG' => 'GUERNSEY',
'GN' => 'GUINEA',
'GW' => 'GUINEA-BISSAU',
'GY' => 'GUYANA',
'HT' => 'HAITI',
'HM' => 'HEARD ISLAND AND MCDONALD ISLANDS',
'VA' => 'HOLY SEE (VATICAN CITY STATE)',
'HN' => 'HONDURAS',
'HK' => 'HONG KONG',
'HU' => 'HUNGARY',
'IS' => 'ICELAND',
'IN' => 'INDIA',
'ID' => 'INDONESIA',
'IR' => 'IRAN, ISLAMIC REPUBLIC OF',
'IQ' => 'IRAQ',
'IE' => 'IRELAND',
'IM' => 'ISLE OF MAN',
'IL' => 'ISRAEL',
'IT' => 'ITALY',
'JM' => 'JAMAICA',
'JP' => 'JAPAN',
'JE' => 'JERSEY',
'JO' => 'JORDAN',
'KZ' => 'KAZAKHSTAN',
'KE' => 'KENYA',
'KI' => 'KIRIBATI',
'KP' => 'KOREA, DEMOCRATIC PEOPLE\'S REPUBLIC OF',
'KR' => 'KOREA, REPUBLIC OF',
'KW' => 'KUWAIT',
'KG' => 'KYRGYZSTAN',
'LA' => 'LAO PEOPLE\'S DEMOCRATIC REPUBLIC',
'LV' => 'LATVIA',
'LB' => 'LEBANON',
'LS' => 'LESOTHO',
'LR' => 'LIBERIA',
'LY' => 'LIBYAN ARAB JAMAHIRIYA',
'LI' => 'LIECHTENSTEIN',
'LT' => 'LITHUANIA',
'LU' => 'LUXEMBOURG',
'MO' => 'MACAO',
'MK' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF',
'MG' => 'MADAGASCAR',
'MW' => 'MALAWI',
'MY' => 'MALAYSIA',
'MV' => 'MALDIVES',
'ML' => 'MALI',
'MT' => 'MALTA',
'MH' => 'MARSHALL ISLANDS',
'MQ' => 'MARTINIQUE',
'MR' => 'MAURITANIA',
'MU' => 'MAURITIUS',
'YT' => 'MAYOTTE',
'MX' => 'MEXICO',
'FM' => 'MICRONESIA, FEDERATED STATES OF',
'MD' => 'MOLDOVA, REPUBLIC OF',
'MC' => 'MONACO',
'MN' => 'MONGOLIA',
'ME' => 'MONTENEGRO',
'MS' => 'MONTSERRAT',
'MA' => 'MOROCCO',
'MZ' => 'MOZAMBIQUE',
'MM' => 'MYANMAR',
'NA' => 'NAMIBIA',
'NR' => 'NAURU',
'NP' => 'NEPAL',
'NL' => 'NETHERLANDS',
'AN' => 'NETHERLANDS ANTILLES',
'NC' => 'NEW CALEDONIA',
'NZ' => 'NEW ZEALAND',
'NI' => 'NICARAGUA',
'NE' => 'NIGER',
'NG' => 'NIGERIA',
'NU' => 'NIUE',
'NF' => 'NORFOLK ISLAND',
'MP' => 'NORTHERN MARIANA ISLANDS',
'NO' => 'NORWAY',
'OM' => 'OMAN',
'PK' => 'PAKISTAN',
'PW' => 'PALAU',
'PS' => 'PALESTINIAN TERRITORY, OCCUPIED',
'PA' => 'PANAMA',
'PG' => 'PAPUA NEW GUINEA',
'PY' => 'PARAGUAY',
'PE' => 'PERU',
'PH' => 'PHILIPPINES',
'PN' => 'PITCAIRN',
'PL' => 'POLAND',
'PT' => 'PORTUGAL',
'PR' => 'PUERTO RICO',
'QA' => 'QATAR',
'RE' => 'REUNION',
'RO' => 'ROMANIA',
'RU' => 'RUSSIAN FEDERATION',
'RW' => 'RWANDA',
'BL' => 'SAINT BARTHÉLEMY',
'SH' => 'SAINT HELENA',
'KN' => 'SAINT KITTS AND NEVIS',
'LC' => 'SAINT LUCIA',
'MF' => 'SAINT MARTIN',
'PM' => 'SAINT PIERRE AND MIQUELON',
'VC' => 'SAINT VINCENT AND THE GRENADINES',
'WS' => 'SAMOA',
'SM' => 'SAN MARINO',
'ST' => 'SAO TOME AND PRINCIPE',
'SA' => 'SAUDI ARABIA',
'SN' => 'SENEGAL',
'RS' => 'SERBIA',
'SC' => 'SEYCHELLES',
'SL' => 'SIERRA LEONE',
'SG' => 'SINGAPORE',
'SK' => 'SLOVAKIA',
'SI' => 'SLOVENIA',
'SB' => 'SOLOMON ISLANDS',
'SO' => 'SOMALIA',
'ZA' => 'SOUTH AFRICA',
'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
'ES' => 'SPAIN',
'LK' => 'SRI LANKA',
'SD' => 'SUDAN',
'SR' => 'SURINAME',
'SJ' => 'SVALBARD AND JAN MAYEN',
'SZ' => 'SWAZILAND',
'SE' => 'SWEDEN',
'CH' => 'SWITZERLAND',
'SY' => 'SYRIAN ARAB REPUBLIC',
'TW' => 'TAIWAN, PROVINCE OF CHINA',
'TJ' => 'TAJIKISTAN',
'TZ' => 'TANZANIA, UNITED REPUBLIC OF',
'TH' => 'THAILAND',
'TL' => 'TIMOR-LESTE',
'TG' => 'TOGO',
'TK' => 'TOKELAU',
'TO' => 'TONGA',
'TT' => 'TRINIDAD AND TOBAGO',
'TN' => 'TUNISIA',
'TR' => 'TURKEY',
'TM' => 'TURKMENISTAN',
'TC' => 'TURKS AND CAICOS ISLANDS',
'TV' => 'TUVALU',
'UG' => 'UGANDA',
'UA' => 'UKRAINE',
'AE' => 'UNITED ARAB EMIRATES',
'GB' => 'UNITED KINGDOM',
'US' => 'UNITED STATES',
'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS',
'UY' => 'URUGUAY',
'UZ' => 'UZBEKISTAN',
'VU' => 'VANUATU',
'VE' => 'VENEZUELA',
'VN' => 'VIET NAM',
'VG' => 'VIRGIN ISLANDS, BRITISH',
'VI' => 'VIRGIN ISLANDS, U.S.',
'WF' => 'WALLIS AND FUTUNA',
'EH' => 'WESTERN SAHARA',
'YE' => 'YEMEN',
'ZM' => 'ZAMBIA',
'ZW' => 'ZIMBABWE',
];
$countries['us'] = $countries['en'];
$countries['fr'] = [
'AF' => 'AFGHANISTAN',
'ZA' => 'AFRIQUE DU SUD',
'AX' => 'ÅLAND, ÎLES',
'AL' => 'ALBANIE',
'DZ' => 'ALGÉRIE',
'DE' => 'ALLEMAGNE',
'AD' => 'ANDORRE',
'AO' => 'ANGOLA',
'AI' => 'ANGUILLA',
'AQ' => 'ANTARCTIQUE',
'AG' => 'ANTIGUA-ET-BARBUDA',
'AN' => 'ANTILLES NÉERLANDAISES',
'SA' => 'ARABIE SAOUDITE',
'AR' => 'ARGENTINE',
'AM' => 'ARMÉNIE',
'AW' => 'ARUBA',
'AU' => 'AUSTRALIE',
'AT' => 'AUTRICHE',
'AZ' => 'AZERBAÏDJAN',
'BS' => 'BAHAMAS',
'BH' => 'BAHREÏN',
'BD' => 'BANGLADESH',
'BB' => 'BARBADE',
'BY' => 'BÉLARUS',
'BE' => 'BELGIQUE',
'BZ' => 'BELIZE',
'BJ' => 'BÉNIN',
'BM' => 'BERMUDES',
'BT' => 'BHOUTAN',
'BO' => 'BOLIVIE',
'BA' => 'BOSNIE-HERZÉGOVINE',
'BW' => 'BOTSWANA',
'BV' => 'BOUVET, ÎLE',
'BR' => 'BRÉSIL',
'BN' => 'BRUNÉI DARUSSALAM',
'BG' => 'BULGARIE',
'BF' => 'BURKINA FASO',
'BI' => 'BURUNDI',
'KY' => 'CAÏMANES, ÎLES',
'KH' => 'CAMBODGE',
'CM' => 'CAMEROUN',
'CA' => 'CANADA',
'CV' => 'CAP-VERT',
'CF' => 'CENTRAFRICAINE, RÉPUBLIQUE',
'CL' => 'CHILI',
'CN' => 'CHINE',
'CX' => 'CHRISTMAS, ÎLE',
'CY' => 'CHYPRE',
'CC' => 'COCOS (KEELING), ÎLES',
'CO' => 'COLOMBIE',
'KM' => 'COMORES',
'CG' => 'CONGO',
'CD' => 'CONGO, LA RÉPUBLIQUE DÉMOCRATIQUE DU',
'CK' => 'COOK, ÎLES',
'KR' => 'CORÉE, RÉPUBLIQUE DE',
'KP' => 'CORÉE, RÉPUBLIQUE POPULAIRE DÉMOCRATIQUE DE',
'CR' => 'COSTA RICA',
'CI' => 'CÔTE D\'IVOIRE',
'HR' => 'CROATIE',
'CU' => 'CUBA',
'DK' => 'DANEMARK',
'DJ' => 'DJIBOUTI',
'DO' => 'DOMINICAINE, RÉPUBLIQUE',
'DM' => 'DOMINIQUE',
'EG' => 'ÉGYPTE',
'SV' => 'EL SALVADOR',
'AE' => 'ÉMIRATS ARABES UNIS',
'EC' => 'ÉQUATEUR',
'ER' => 'ÉRYTHRÉE',
'ES' => 'ESPAGNE',
'EE' => 'ESTONIE',
'US' => 'ÉTATS-UNIS',
'ET' => 'ÉTHIOPIE',
'FK' => 'FALKLAND, ÎLES (MALVINAS)',
'FO' => 'FÉROÉ, ÎLES',
'FJ' => 'FIDJI',
'FI' => 'FINLANDE',
'FR' => 'FRANCE',
'GA' => 'GABON',
'GM' => 'GAMBIE',
'GE' => 'GÉORGIE',
'GS' => 'GÉORGIE DU SUD ET LES ÎLES SANDWICH DU SUD',
'GH' => 'GHANA',
'GI' => 'GIBRALTAR',
'GR' => 'GRÈCE',
'GD' => 'GRENADE',
'GL' => 'GROENLAND',
'GP' => 'GUADELOUPE',
'GU' => 'GUAM',
'GT' => 'GUATEMALA',
'GG' => 'GUERNESEY',
'GN' => 'GUINÉE',
'GW' => 'GUINÉE-BISSAU',
'GQ' => 'GUINÉE ÉQUATORIALE',
'GY' => 'GUYANA',
'GF' => 'GUYANE FRANÇAISE',
'HT' => 'HAÏTI',
'HM' => 'HEARD, ÎLE ET MCDONALD, ÎLES',
'HN' => 'HONDURAS',
'HK' => 'HONG-KONG',
'HU' => 'HONGRIE',
'IM' => 'ÎLE DE MAN',
'UM' => 'ÎLES MINEURES ÉLOIGNÉES DES ÉTATS-UNIS',
'VG' => 'ÎLES VIERGES BRITANNIQUES',
'VI' => 'ÎLES VIERGES DES ÉTATS-UNIS',
'IN' => 'INDE',
'ID' => 'INDONÉSIE',
'IR' => 'IRAN, RÉPUBLIQUE ISLAMIQUE D\'',
'IQ' => 'IRAQ',
'IE' => 'IRLANDE',
'IS' => 'ISLANDE',
'IL' => 'ISRAËL',
'IT' => 'ITALIE',
'JM' => 'JAMAÏQUE',
'JP' => 'JAPON',
'JE' => 'JERSEY',
'JO' => 'JORDANIE',
'KZ' => 'KAZAKHSTAN',
'KE' => 'KENYA',
'KG' => 'KIRGHIZISTAN',
'KI' => 'KIRIBATI',
'KW' => 'KOWEÏT',
'LA' => 'LAO, RÉPUBLIQUE DÉMOCRATIQUE POPULAIRE',
'LS' => 'LESOTHO',
'LV' => 'LETTONIE',
'LB' => 'LIBAN',
'LR' => 'LIBÉRIA',
'LY' => 'LIBYENNE, JAMAHIRIYA ARABE',
'LI' => 'LIECHTENSTEIN',
'LT' => 'LITUANIE',
'LU' => 'LUXEMBOURG',
'MO' => 'MACAO',
'MK' => 'MACÉDOINE, L\'EX-RÉPUBLIQUE YOUGOSLAVE DE',
'MG' => 'MADAGASCAR',
'MY' => 'MALAISIE',
'MW' => 'MALAWI',
'MV' => 'MALDIVES',
'ML' => 'MALI',
'MT' => 'MALTE',
'MP' => 'MARIANNES DU NORD, ÎLES',
'MA' => 'MAROC',
'MH' => 'MARSHALL, ÎLES',
'MQ' => 'MARTINIQUE',
'MU' => 'MAURICE',
'MR' => 'MAURITANIE',
'YT' => 'MAYOTTE',
'MX' => 'MEXIQUE',
'FM' => 'MICRONÉSIE, ÉTATS FÉDÉRÉS DE',
'MD' => 'MOLDOVA, RÉPUBLIQUE DE',
'MC' => 'MONACO',
'MN' => 'MONGOLIE',
'ME' => 'MONTÉNÉGRO',
'MS' => 'MONTSERRAT',
'MZ' => 'MOZAMBIQUE',
'MM' => 'MYANMAR',
'NA' => 'NAMIBIE',
'NR' => 'NAURU',
'NP' => 'NÉPAL',
'NI' => 'NICARAGUA',
'NE' => 'NIGER',
'NG' => 'NIGÉRIA',
'NU' => 'NIUÉ',
'NF' => 'NORFOLK, ÎLE',
'NO' => 'NORVÈGE',
'NC' => 'NOUVELLE-CALÉDONIE',
'NZ' => 'NOUVELLE-ZÉLANDE',
'IO' => 'OCÉAN INDIEN, TERRITOIRE BRITANNIQUE DE L\'',
'OM' => 'OMAN',
'UG' => 'OUGANDA',
'UZ' => 'OUZBÉKISTAN',
'PK' => 'PAKISTAN',
'PW' => 'PALAOS',
'PS' => 'PALESTINIEN OCCUPÉ, TERRITOIRE',
'PA' => 'PANAMA',
'PG' => 'PAPOUASIE-NOUVELLE-GUINÉE',
'PY' => 'PARAGUAY',
'NL' => 'PAYS-BAS',
'PE' => 'PÉROU',
'PH' => 'PHILIPPINES',
'PN' => 'PITCAIRN',
'PL' => 'POLOGNE',
'PF' => 'POLYNÉSIE FRANÇAISE',
'PR' => 'PORTO RICO',
'PT' => 'PORTUGAL',
'QA' => 'QATAR',
'RE' => 'RÉUNION',
'RO' => 'ROUMANIE',
'GB' => 'ROYAUME-UNI',
'RU' => 'RUSSIE, FÉDÉRATION DE',
'RW' => 'RWANDA',
'EH' => 'SAHARA OCCIDENTAL',
'BL' => 'SAINT-BARTHÉLEMY',
'SH' => 'SAINTE-HÉLÈNE',
'LC' => 'SAINTE-LUCIE',
'KN' => 'SAINT-KITTS-ET-NEVIS',
'SM' => 'SAINT-MARIN',
'MF' => 'SAINT-MARTIN',
'PM' => 'SAINT-PIERRE-ET-MIQUELON',
'VA' => 'SAINT-SIÈGE (ÉTAT DE LA CITÉ DU VATICAN)',
'VC' => 'SAINT-VINCENT-ET-LES GRENADINES',
'SB' => 'SALOMON, ÎLES',
'WS' => 'SAMOA',
'AS' => 'SAMOA AMÉRICAINES',
'ST' => 'SAO TOMÉ-ET-PRINCIPE',
'SN' => 'SÉNÉGAL',
'RS' => 'SERBIE',
'SC' => 'SEYCHELLES',
'SL' => 'SIERRA LEONE',
'SG' => 'SINGAPOUR',
'SK' => 'SLOVAQUIE',
'SI' => 'SLOVÉNIE',
'SO' => 'SOMALIE',
'SD' => 'SOUDAN',
'LK' => 'SRI LANKA',
'SE' => 'SUÈDE',
'CH' => 'SUISSE',
'SR' => 'SURINAME',
'SJ' => 'SVALBARD ET ÎLE JAN MAYEN',
'SZ' => 'SWAZILAND',
'SY' => 'SYRIENNE, RÉPUBLIQUE ARABE',
'TJ' => 'TADJIKISTAN',
'TW' => 'TAÏWAN, PROVINCE DE CHINE',
'TZ' => 'TANZANIE, RÉPUBLIQUE-UNIE DE',
'TD' => 'TCHAD',
'CZ' => 'TCHÈQUE, RÉPUBLIQUE',
'TF' => 'TERRES AUSTRALES FRANÇAISES',
'TH' => 'THAÏLANDE',
'TL' => 'TIMOR-LESTE',
'TG' => 'TOGO',
'TK' => 'TOKELAU',
'TO' => 'TONGA',
'TT' => 'TRINITÉ-ET-TOBAGO',
'TN' => 'TUNISIE',
'TM' => 'TURKMÉNISTAN',
'TC' => 'TURKS ET CAÏQUES, ÎLES',
'TR' => 'TURQUIE',
'TV' => 'TUVALU',
'UA' => 'UKRAINE',
'UY' => 'URUGUAY',
'VU' => 'VANUATU',
'VE' => 'VENEZUELA',
'VN' => 'VIET NAM',
'WF' => 'WALLIS ET FUTUNA',
'YE' => 'YÉMEN',
'ZM' => 'ZAMBIE',
'ZW' => 'ZIMBABWE'
];
if ( ! isset($countries[$lng]))
$lng = 'us';
foreach ($countries[$lng] as $k => $country)
$countries[$lng][$k] = mb_strtolower($country);
return $countries[$lng];
}

View File

@@ -10,10 +10,10 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
class eventsmanager_broker class eventsmanager_broker
{ {
protected $events = [];
protected $notifications = []; protected $notifications = [];
protected $pool_classes = []; protected $pool_classes = [];
@@ -60,10 +60,7 @@ class eventsmanager_broker
if ( ! class_exists($classname, true)) { if ( ! class_exists($classname, true)) {
continue; continue;
} }
$this->pool_classes[$classname] = new $classname($this->app, $this); $this->pool_classes[$classname] = new $classname($this->app);
foreach ($this->pool_classes[$classname]->get_events() as $event)
$this->bind($event, $classname);
if ($type === 'notify' && $this->pool_classes[$classname]) if ($type === 'notify' && $this->pool_classes[$classname])
$this->notifications[] = $classname; $this->notifications[] = $classname;
@@ -73,26 +70,6 @@ class eventsmanager_broker
return; return;
} }
public function trigger($event, $array_params = [], &$object = false)
{
if (array_key_exists($event, $this->events)) {
foreach ($this->events[$event] as $classname) {
$this->pool_classes[$classname]->fire($event, $array_params, $object);
}
}
return;
}
public function bind($event, $object_name)
{
if ( ! array_key_exists($event, $this->events))
$this->events[$event] = [];
$this->events[$event][] = $object_name;
}
public function notify($usr_id, $event_type, $datas, $mailed = false) public function notify($usr_id, $event_type, $datas, $mailed = false)
{ {
try { try {
@@ -151,7 +128,13 @@ class eventsmanager_broker
foreach ($rs as $row) { foreach ($rs as $row) {
$type = 'eventsmanager_' . $row['type']; $type = 'eventsmanager_' . $row['type'];
$content = $this->pool_classes[$type]->datas($row['datas'], $row['unread']); $data = @json_decode($row['datas'], true);
if (json_last_error() !== JSON_ERROR_NONE) {
continue;
}
$content = $this->pool_classes[$type]->datas($data, $row['unread']);
if ( ! isset($this->pool_classes[$type]) || count($content) === 0) { if ( ! isset($this->pool_classes[$type]) || count($content) === 0) {
$sql = 'DELETE FROM notifications WHERE id = :id'; $sql = 'DELETE FROM notifications WHERE id = :id';
@@ -241,7 +224,13 @@ class eventsmanager_broker
if ( ! isset($this->pool_classes[$type])) { if ( ! isset($this->pool_classes[$type])) {
continue; continue;
} }
$datas = $this->pool_classes[$type]->datas($row['datas'], $row['unread']); $data = @json_decode($row['datas'], true);
if (json_last_error() !== JSON_ERROR_NONE) {
continue;
}
$datas = $this->pool_classes[$type]->datas($data, $row['unread']);
if ( ! isset($this->pool_classes[$type]) || count($datas) === 0) { if ( ! isset($this->pool_classes[$type]) || count($datas) === 0) {
$sql = 'DELETE FROM notifications WHERE id = :id'; $sql = 'DELETE FROM notifications WHERE id = :id';
@@ -282,12 +271,12 @@ class eventsmanager_broker
return $this; return $this;
} }
public function list_notifications_available($usr_id) public function list_notifications_available(User $user)
{ {
$personnal_notifications = []; $personnal_notifications = [];
foreach ($this->notifications as $notification) { foreach ($this->notifications as $notification) {
if (!$this->pool_classes[$notification]->is_available($usr_id)) { if (!$this->pool_classes[$notification]->is_available($user)) {
continue; continue;
} }
$group = $this->pool_classes[$notification]->get_group(); $group = $this->pool_classes[$notification]->get_group();

View File

@@ -1,36 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class eventsmanager_event_test extends eventsmanager_eventAbstract
{
/**
*
* @var Array
*/
protected $events = ['__EVENT__'];
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return event_test
*/
public function fire($event, $params, &$object)
{
return $this;
}
public function get_name()
{
return 'Test event';
}
}

View File

@@ -1,52 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
abstract class eventsmanager_eventAbstract
{
protected $events = [];
protected $group = null;
/**
*
* @var Application
*/
protected $app;
/**
*
* @var eventsmanager
*/
protected $broker;
public function __construct(Application $app, eventsmanager_broker $broker)
{
$this->app = $app;
$this->broker = $broker;
return $this;
}
public function get_group()
{
return $this->group;
}
public function get_events()
{
return $this->events;
}
abstract public function get_name();
abstract public function fire($event, $params, &$object);
}

View File

@@ -9,18 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__REGISTER_AUTOREGISTER__'];
/** /**
* *
* @return string * @return string
@@ -30,99 +22,15 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
return '/skins/icons/user.png'; return '/skins/icons/user.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = ['usr_id' => '' , 'autoregister' => []];
$params = array_merge($default, $params);
$base_ids = array_keys($params['autoregister']);
if (count($base_ids) == 0) {
return;
}
$mailColl = [];
try {
$rs = $this->app['EM.native-query']->getAdminsOfBases(array_keys($base_ids));
foreach ($rs as $row) {
$user = $row[0];
if (!isset($mailColl[$user->getId()])) {
$mailColl[$user->getId()] = [];
}
$mailColl[$user->getId()][] = $row['base_id'];
}
} catch (\Exception $e) {
}
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$usr_id = $dom_xml->createElement('usr_id');
$base_ids = $dom_xml->createElement('base_ids');
$usr_id->appendChild($dom_xml->createTextNode($params['usr_id']));
foreach ($params['autoregister'] as $base_id => $collection) {
$base_id_node = $dom_xml->createElement('base_id');
$base_id_node->appendChild($dom_xml->createTextNode($base_id));
$base_ids->appendChild($base_id_node);
}
$root->appendChild($usr_id);
$root->appendChild($base_ids);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
if (null === $registered_user = $this->app['repo.users']->find($params['usr_id'])) {
return;
}
foreach ($mailColl as $usr_id => $base_ids) {
$mailed = false;
if ($this->shouldSendNotificationFor($usr_id)) {
if (null === $admin_user = $this->app['repo.users']->find($usr_id)) {
continue;
}
if (self::mail($admin_user, $registered_user))
$mailed = true;
}
$this->broker->notify($usr_id, __CLASS__, $datas, $mailed);
}
return;
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $usr_id = $data['usr_id'];
$usr_id = (string) $sx->usr_id;
if (null === $user = $this->app['repo.users']->find($usr_id)) { if (null === $user = $this->app['repo.users']->find($usr_id)) {
return []; return [];
@@ -154,53 +62,17 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
return $this->app->trans('Recevoir des notifications lorsqu\'un utilisateur s\'inscrit sur une collection'); return $this->app->trans('Recevoir des notifications lorsqu\'un utilisateur s\'inscrit sur une collection');
} }
/**
*
* @param User $to
* @param User $registeredUser
*
* @return boolean
*/
public function mail(User $to, User $registeredUser)
{
$body = '';
$body .= sprintf("Login : %s\n", $registeredUser->getLogin());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->getFirstName());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->getLastName());
$body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->getEmail());
$body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->getCompany());
$readyToSend = false;
try {
$receiver = Receiver::fromUser($to);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, null, $body);
$this->app['notification.deliverer']->deliver($mail);
}
return true;
}
/** /**
* @param integer $usr_id The id of the user to check * @param integer $usr_id The id of the user to check
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
if (! $this->app['registration.manager']->isRegistrationEnabled()) { if (! $this->app['registration.manager']->isRegistrationEnabled()) {
return false; return false;
} }
if (null === $user = $this->app['repo.users']->find($usr_id)) {
return false;
}
return $this->app['acl']->get($user)->has_right('manageusers'); return $this->app['acl']->get($user)->has_right('manageusers');
} }
} }

View File

@@ -9,17 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoBridgeUploadFailed;
class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__BRIDGE_UPLOAD_FAIL__'];
/** /**
* *
* @return string * @return string
@@ -29,93 +22,18 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
return '/skins/icons/user.png'; return '/skins/icons/user.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = [
'usr_id' => null
, 'reason' => ''
, 'account_id' => null
, 'base_id' => null
, 'record_id' => null
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$reason = $dom_xml->createElement('reason');
$account_id = $dom_xml->createElement('account_id');
$sbas_id = $dom_xml->createElement('sbas_id');
$record_id = $dom_xml->createElement('record_id');
$reason->appendChild($dom_xml->createTextNode($params['reason']));
$account_id->appendChild($dom_xml->createTextNode($params['account_id']));
$sbas_id->appendChild($dom_xml->createTextNode($params['sbas_id']));
$record_id->appendChild($dom_xml->createTextNode($params['record_id']));
$root->appendChild($reason);
$root->appendChild($account_id);
$root->appendChild($sbas_id);
$root->appendChild($record_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['usr_id'])) {
$readyToSend = false;
try {
$user = $this->app['repo.users']->find($params['usr_id']);
$account = Bridge_Account::load_account($this->app, $params['account_id']);
$receiver = Receiver::fromUser($user);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
/** ADD MAIL TEST */
$mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
$mail->setAdapter($account->get_api()->get_connector()->get_name());
$mail->setReason($params['reason']);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
return;
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $reason = $data['reason'];
$account_id = $data['account_id'];
$reason = (string) $sx->reason; $sbas_id = $data['sbas_id'];
$account_id = (int) $sx->account_id; $rid = $data['record_id'];
$sbas_id = (int) $sx->sbas_id;
$rid = (int) $sx->record_id;
try { try {
$account = Bridge_Account::load_account($this->app, $account_id); $account = Bridge_Account::load_account($this->app, $account_id);
@@ -159,7 +77,7 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,17 +9,13 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Model\Entities\User;
class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
{ {
const MAIL_NO_VALID = 1; const MAIL_NO_VALID = 1;
const MAIL_FAIL = 2; const MAIL_FAIL = 2;
/**
*
* @var string
*/
public $events = ['__EXPORT_MAIL_FAIL__'];
/** /**
* *
* @return string * @return string
@@ -29,73 +25,16 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
return '/skins/icons/user.png'; return '/skins/icons/user.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = [
'usr_id' => null
, 'lst' => ''
, 'ssttid' => ''
, 'dest' => ''
, 'reason' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$lst = $dom_xml->createElement('lst');
$ssttid = $dom_xml->createElement('ssttid');
$dest = $dom_xml->createElement('dest');
$reason = $dom_xml->createElement('reason');
$lst->appendChild($dom_xml->createTextNode($params['lst']));
$ssttid->appendChild($dom_xml->createTextNode($params['ssttid']));
$dest->appendChild($dom_xml->createTextNode($params['dest']));
$reason->appendChild($dom_xml->createTextNode($params['reason']));
$root->appendChild($lst);
$root->appendChild($ssttid);
$root->appendChild($dest);
$root->appendChild($reason);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['usr_id'])) {
if (parent::email())
$mailed = true;
}
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
return;
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $reason = $data['reason'];
$reason = (int) $sx->reason; $dest = $data['dest'];
$dest = (string) $sx->dest;
if ($reason == self::MAIL_NO_VALID) { if ($reason == self::MAIL_NO_VALID) {
$reason = $this->app->trans('email is not valid'); $reason = $this->app->trans('email is not valid');
@@ -138,7 +77,7 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,18 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication;
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
class eventsmanager_notify_feed extends eventsmanager_notifyAbstract class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__FEED_ENTRY_CREATE__'];
/** /**
* *
* @return string * @return string
@@ -32,102 +24,13 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
/** /**
* *
* @param string $event * @param Array $datas
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$entry)
{
$params = [
'entry_id' => $entry->getId(),
'notify_email' => $params['notify_email'],
];
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$entry_id = $dom_xml->createElement('entry_id');
$entry_id->appendChild($dom_xml->createTextNode($params['entry_id']));
$root->appendChild($entry_id);
$dom_xml->appendChild($root);
$data = $dom_xml->saveXml();
$this->app['manipulator.webhook-event']->create(
WebhookEvent::NEW_FEED_ENTRY,
WebhookEvent::FEED_ENTRY_TYPE,
array_merge(['feed_id' => $entry->getFeed()->getId()], $params)
);
$Query = new \User_Query($this->app);
$Query->include_phantoms(true)
->include_invite(false)
->include_templates(false)
->email_not_null(true);
if ($entry->getFeed()->getCollection($this->app)) {
$Query->on_base_ids([$entry->getFeed()->getCollection($this->app)->get_base_id()]);
}
$start = 0;
$perLoop = 100;
do {
$results = $Query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user_to_notif) {
$mailed = false;
if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif->getId())) {
$readyToSend = false;
try {
$token = $this->app['manipulator.token']->createFeedEntryToken($user_to_notif, $entry);
$url = $this->app->url('lightbox', ['LOG' => $token->getValue()]);
$receiver = Receiver::fromUser($user_to_notif);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoNewPublication::create($this->app, $receiver);
$mail->setButtonUrl($url);
$mail->setAuthor($entry->getAuthorName());
$mail->setTitle($entry->getTitle());
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->broker->notify($user_to_notif->getId(), __CLASS__, $data, $mailed);
}
$start += $perLoop;
} while (count($results) > 0);
return true;
}
/**
*
* @param Array $data
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($data, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($data); $entry = $this->app['repo.feed-entries']->find($data['entry_id']);
$entry = $this->app['repo.feed-entries']->find((int) $sx->entry_id);
if (null === $entry) { if (null === $entry) {
return []; return [];
@@ -164,7 +67,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,17 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoNewOrder;
class eventsmanager_notify_order extends eventsmanager_notifyAbstract class eventsmanager_notify_order extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__NEW_ORDER__'];
/** /**
* *
* @return string * @return string
@@ -29,112 +22,16 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
return '/skins/icons/user.png'; return '/skins/icons/user.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = [
'usr_id' => ''
, 'order_id' => []
];
$params = array_merge($default, $params);
$order_id = $params['order_id'];
$users = [];
try {
$repository = $this->app['repo.order-elements'];
$results = $repository->findBy(['orderId' => $order_id]);
$base_ids = [];
foreach ($results as $result) {
$base_ids[] = $result->getBaseId();
}
$base_ids = array_unique($base_ids);
$query = new User_Query($this->app);
$users = $query->on_base_ids($base_ids)
->who_have_right(['order_master'])
->execute()->get_results();
} catch (\Exception $e) {
}
if (count($users) == 0) {
return;
}
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$usr_id_dom = $dom_xml->createElement('usr_id');
$order_id_dom = $dom_xml->createElement('order_id');
$usr_id_dom->appendChild($dom_xml->createTextNode($params['usr_id']));
$order_id_dom->appendChild($dom_xml->createTextNode($order_id));
$root->appendChild($usr_id_dom);
$root->appendChild($order_id_dom);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
if (null === $orderInitiator = $this->app['repo.users']->find($params['usr_id'])) {
return;
}
foreach ($users as $user) {
$mailed = false;
if ($this->shouldSendNotificationFor($user->getId())) {
$readyToSend = false;
try {
$receiver = Receiver::fromUser($user);
$readyToSend = true;
} catch (\Exception $e) {
continue;
}
if ($readyToSend) {
$mail = MailInfoNewOrder::create($this->app, $receiver);
$mail->setUser($orderInitiator);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->broker->notify($user->getId(), __CLASS__, $datas, $mailed);
}
return;
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return string * @return string
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $usr_id = $data['usr_id'];
$order_id = $data['order_id'];
$usr_id = (string) $sx->usr_id;
$order_id = (string) $sx->order_id;
if (null === $user = $this->app['repo.users']->find($usr_id)) { if (null === $user = $this->app['repo.users']->find($usr_id)) {
return []; return [];
@@ -176,12 +73,8 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
if (null === $user = $this->app['repo.users']->find($usr_id)) {
return false;
}
return $this->app['acl']->get($user)->has_right('order_master'); return $this->app['acl']->get($user)->has_right('order_master');
} }
} }

View File

@@ -10,28 +10,14 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Emitter; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered;
class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
{ {
/** public function __construct(Application $app)
*
* @var string
*/
public $events = ['__ORDER_DELIVER__'];
/**
*
* @return notify_orderdeliver
*/
public function __construct(Application $app, eventsmanager_broker $broker)
{ {
parent::__construct($app, $broker); parent::__construct($app);
$this->group = $this->app->trans('Commande'); $this->group = $this->app->trans('Commande');
return $this;
} }
/** /**
@@ -43,101 +29,17 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
return '/skins/prod/000000/images/disktt_history.gif'; return '/skins/prod/000000/images/disktt_history.gif';
} }
/**
*
* @param string $event
* @param Array $params
* @param Array $object
* @return boolean
*/
public function fire($event, $params, &$object)
{
$default = [
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
, 'n' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$ssel_id = $dom_xml->createElement('ssel_id');
$n = $dom_xml->createElement('n');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
$n->appendChild($dom_xml->createTextNode($params['n']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($ssel_id);
$root->appendChild($n);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$repository = $this->app['repo.baskets'];
$basket = $repository->find($params['ssel_id']);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$url = $this->app->url('lightbox_compare', [
'basket' => $basket->getId(),
'LOG' => $this->app['manipulator.token']->createBasketAccessToken($basket, $user_to)->getValue(),
]);
$mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter, null);
$mail->setButtonUrl($url);
$mail->setBasket($basket);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return string * @return string
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $from = $data['from'];
$ssel_id = $data['ssel_id'];
$from = (string) $sx->from; $n = $data['n'];
$ssel_id = (string) $sx->ssel_id;
$n = (int) $sx->n;
if (null === $user= $this->app['repo.users']->find(($from))) { if (null === $user= $this->app['repo.users']->find(($from))) {
return []; return [];
@@ -154,7 +56,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
} }
$ret = [ $ret = [
'text' => $this->app->trans('%user% vous a delivre %quantity% document(s) pour votre commande %title%', ['%user%' => $sender, '%quantity%' => $n, '%title%' => '<a href="/lightbox/compare/' 'text' => $this->app->trans('%user% vous a delivre %quantity% document(s) pour votre commande %title%', ['%user%' => $sender, '%quantity%' => $n, '%title%' => '<a href="/lightbox/compare/'
. (string) $sx->ssel_id . '/" target="_blank">' . $ssel_id . '/" target="_blank">'
. $basket->getName() . '</a>']) . $basket->getName() . '</a>'])
, 'class' => '' , 'class' => ''
]; ];
@@ -185,7 +87,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -10,21 +10,13 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled;
class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstract class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstract
{ {
/** public function __construct(Application $app)
*
* @var string
*/
public $events = ['__ORDER_NOT_DELIVERED__'];
public function __construct(Application $app, eventsmanager_broker $broker)
{ {
parent::__construct($app, $broker); parent::__construct($app);
$this->group = $this->app->trans('Commande'); $this->group = $this->app->trans('Commande');
return $this; return $this;
@@ -35,77 +27,10 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
return '/skins/prod/000000/images/disktt_history.gif'; return '/skins/prod/000000/images/disktt_history.gif';
} }
public function fire($event, $params, &$object) public function datas(array $data, $unread)
{ {
$default = [ $from = $data['from'];
'from' => '' $n = $data['n'];
, 'to' => ''
, 'n' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$n = $dom_xml->createElement('n');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$n->appendChild($dom_xml->createTextNode($params['n']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($n);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
$mail->setQuantity($params['n']);
$mail->setDeliverer($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
public function datas($datas, $unread)
{
$sx = simplexml_load_string($datas);
$from = (string) $sx->from;
$n = (int) $sx->n;
if (null === $user = $this->app['repo.users']->find($from)) { if (null === $user = $this->app['repo.users']->find($from)) {
return []; return [];
@@ -136,7 +61,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,18 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Emitter; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoPushReceived;
class eventsmanager_notify_push extends eventsmanager_notifyAbstract class eventsmanager_notify_push extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__PUSH_DATAS__'];
/** /**
* *
* @return string * @return string
@@ -30,94 +22,15 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
return '/skins/icons/push16.png'; return '/skins/icons/push16.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$object)
{
$default = [
'from' => ''
, 'to' => ''
, 'message' => ''
, 'ssel_id' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$message = $dom_xml->createElement('message');
$ssel_id = $dom_xml->createElement('ssel_id');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$message->appendChild($dom_xml->createTextNode($params['message']));
$ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($message);
$root->appendChild($ssel_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$repository = $this->app['repo.baskets'];
$basket = $repository->find($params['ssel_id']);
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoPushReceived::create($this->app, $receiver, $emitter, $params['message'], $params['url']);
$mail->setBasket($basket);
$mail->setPusher($user_from);
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $from = $data['from'];
$from = (string) $sx->from;
if (null === $user = $this->app['repo.users']->find($from)) { if (null === $user = $this->app['repo.users']->find($from)) {
return []; return [];
@@ -127,7 +40,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
$ret = [ $ret = [
'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => '<a href="#" onclick="openPreview(\'BASK\',1,\'' 'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => '<a href="#" onclick="openPreview(\'BASK\',1,\''
. (string) $sx->ssel_id . '\');return false;">', '%after_link%' => '</a>']) . $data['ssel_id'] . '\');return false;">', '%after_link%' => '</a>'])
, 'class' => ($unread == 1 ? 'reload_baskets' : '') , 'class' => ($unread == 1 ? 'reload_baskets' : '')
]; ];
@@ -157,7 +70,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,17 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered;
class eventsmanager_notify_register extends eventsmanager_notifyAbstract class eventsmanager_notify_register extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__REGISTER_APPROVAL__'];
/** /**
* *
* @return string * @return string
@@ -29,110 +22,15 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
return '/skins/icons/user.png'; return '/skins/icons/user.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return Void
*/
public function fire($event, $params, &$object)
{
$default = ['usr_id' => '', 'registrations' => []];
$params = array_merge($default, $params);
$base_ids = $params['registrations'];
if (count($base_ids) == 0) {
return;
}
$mailColl = [];
try {
$rs = $this->app['EM.native-query']->getAdminsOfBases(array_keys($base_ids));
foreach ($rs as $row) {
$user = $row[0];
if (!isset($mailColl[$user->getId()])) {
$mailColl[$user->getId()] = [];
}
$mailColl[$user->getId()][] = $row['base_id'];
}
} catch (\Exception $e) {
}
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$usr_id = $dom_xml->createElement('usr_id');
$base_ids = $dom_xml->createElement('base_ids');
$usr_id->appendChild($dom_xml->createTextNode($params['usr_id']));
foreach ($params['registrations'] as $base_id => $is_ok) {
$base_id_node = $dom_xml->createElement('base_id');
$base_id_node->appendChild($dom_xml->createTextNode($base_id));
$base_ids->appendChild($base_id_node);
}
$root->appendChild($usr_id);
$root->appendChild($base_ids);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
if (null === $registeredUser = $this->app['repo.users']->find($params['usr_id'])) {
return;
}
foreach ($mailColl as $usr_id => $base_ids) {
$mailed = false;
if ($this->shouldSendNotificationFor($usr_id)) {
$readyToSend = false;
try {
$admin_user = $this->app['repo.users']->find($usr_id);
$receiver = Receiver::fromUser($admin_user);
$readyToSend = true;
} catch (\Exception $e) {
continue;
}
if ($readyToSend) {
$mail = MailInfoUserRegistered::create($this->app, $receiver);
$mail->setRegisteredUser($registeredUser);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->broker->notify($usr_id, __CLASS__, $datas, $mailed);
}
return;
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $usr_id = $data['usr_id'];
$usr_id = (string) $sx->usr_id;
if (null === $user = $this->app['repo.users']->find($usr_id)) { if (null === $user = $this->app['repo.users']->find($usr_id)) {
return []; return [];
@@ -171,16 +69,12 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
if (!$this->app['registration.manager']->isRegistrationEnabled()) { if (!$this->app['registration.manager']->isRegistrationEnabled()) {
return false; return false;
} }
if (null === $user = $this->app['repo.users']->find($usr_id)) {
return false;
}
return $this->app['acl']->get($user)->has_right('manageusers'); return $this->app['acl']->get($user)->has_right('manageusers');
} }
} }

View File

@@ -9,20 +9,10 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Model\Entities\LazaretCheck;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined;
class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
{ {
/**
*
* @var string
*/
public $events = ['__UPLOAD_QUARANTINE__'];
/** /**
* *
* @return string * @return string
@@ -32,120 +22,23 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
return ''; return '';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
*/
public function fire($event, $params, &$object)
{
if (isset($params['lazaret_file']) && $params['lazaret_file'] instanceof LazaretFile) {
/* @var $lazaretFile LazaretFile */
$lazaretFile = $params['lazaret_file'];
$domXML = new DOMDocument('1.0', 'UTF-8');
$domXML->preserveWhiteSpace = false;
$domXML->formatOutput = true;
$root = $domXML->createElement('datas');
//Filename
$filename = $domXML->createElement('filename');
$filename->appendChild($domXML->createTextNode($lazaretFile->getOriginalName()));
$root->appendChild($filename);
//Reasons for quarantine
$reasons = $domXML->createElement('reasons');
foreach ($lazaretFile->getChecks() as $check) {
/* @var $check LazaretCheck */
$reason = $domXML->createElement('checkClassName');
$reason->appendChild($domXML->createTextNode($check->getCheckClassname()));
$reasons->appendChild($reason);
}
$root->appendChild($reasons);
$domXML->appendChild($root);
$datas = $domXML->saveXml();
//Sender
if (null !== $user = $lazaretFile->getSession()->getUser()) {
$sender = $domXML->createElement('sender');
$sender->appendChild($domXML->createTextNode($user->getDisplayName()));
$root->appendChild($sender);
$this->notifyUser($user, $datas);
} else { //No lazaretSession user, fil is uploaded via automated tasks etc ..
$query = new User_Query($this->app);
$users = $query
->on_base_ids([$lazaretFile->getBaseId()])
->who_have_right(['canaddrecord'])
->execute()
->get_results();
foreach ($users as $user) {
$this->notifyUser($user, $datas);
}
}
}
return;
}
/**
* Notifiy an user using the specified datas
*
* @param User $user
* @param string $datas
*/
private function notifyUser(User $user, $datas)
{
$mailed = false;
if ($this->shouldSendNotificationFor($user->getId())) {
$readyToSend = false;
try {
$receiver = Receiver::fromUser($user);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoRecordQuarantined::create($this->app, $receiver);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
$this->broker->notify($user->getId(), __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param Array $datas * @param Array $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas);
$reasons = []; $reasons = [];
foreach ($sx->reasons as $reason) { foreach ($data['reasons'] as $reason) {
$checkClassName = (string) $reason->checkClassName; if (class_exists($reason)) {
$reasons[] = $reason::getMessage($this->app['translator']);
if (class_exists($checkClassName)) {
$reasons[] = $checkClassName::getMessage($this->app['translator']);
} }
} }
$filename = (string) $sx->filename; $filename = $data['filename'];
$text = $this->app->trans('The document %name% has been quarantined', ['%name%' => $filename]); $text = $this->app->trans('The document %name% has been quarantined', ['%name%' => $filename]);
@@ -181,12 +74,8 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
if (null === $user = $this->app['repo.users']->find($usr_id)) {
return false;
}
return $this->app['acl']->get($user)->has_right('addrecord'); return $this->app['acl']->get($user)->has_right('addrecord');
} }
} }

View File

@@ -10,28 +10,14 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Receiver;
class eventsmanager_notify_validate extends eventsmanager_notifyAbstract class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
{ {
/** public function __construct(Application $app)
*
* @var string
*/
public $events = ['__PUSH_VALIDATION__'];
/**
*
* @return notify_validate
*/
public function __construct(Application $app, eventsmanager_broker $broker)
{ {
parent::__construct($app, $broker); parent::__construct($app);
$this->group = $this->app->trans('Validation'); $this->group = $this->app->trans('Validation');
return $this;
} }
/** /**
@@ -43,98 +29,16 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
return '/skins/icons/push16.png'; return '/skins/icons/push16.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$object)
{
$default = [
'from' => ''
, 'to' => ''
, 'message' => ''
, 'ssel_id' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$message = $dom_xml->createElement('message');
$ssel_id = $dom_xml->createElement('ssel_id');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$message->appendChild($dom_xml->createTextNode($params['message']));
$ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($message);
$root->appendChild($ssel_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
$basket = $this->app['repo.baskets']
->find($params['ssel_id']);
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoValidationRequest::create($this->app, $receiver, $emitter, $params['message']);
$mail->setButtonUrl($params['url']);
$mail->setDuration($params['duration']);
$mail->setTitle($title);
$mail->setUser($user_from);
$this->app['notification.deliverer']->deliver($mail, $params['accuse']);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param string $datas * @param string $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $from = $data['from'];
$ssel_id = $data['ssel_id'];
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
if (null === $user = $this->app['repo.users']->find($from)) { if (null === $user = $this->app['repo.users']->find($from)) {
return []; return [];
@@ -150,7 +54,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
} }
$bask_link = '<a href="' $bask_link = '<a href="'
. $this->app->url('lightbox_validation', ['basket' => (string) $sx->ssel_id]) . $this->app->url('lightbox_validation', ['basket' => $ssel_id])
. '" target="_blank">' . '" target="_blank">'
. $basket_name . '</a>'; . $basket_name . '</a>';
@@ -188,7 +92,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -10,28 +10,14 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationDone; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Emitter;
use Alchemy\Phrasea\Notification\Receiver;
class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{ {
/** public function __construct(Application $app)
*
* @var string
*/
public $events = ['__VALIDATION_DONE__'];
/**
*
* @return notify_validationdone
*/
public function __construct(Application $app, eventsmanager_broker $broker)
{ {
parent::__construct($app, $broker); parent::__construct($app);
$this->group = $this->app->trans('Validation'); $this->group = $this->app->trans('Validation');
return $this;
} }
/** /**
@@ -43,92 +29,16 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
return '/skins/icons/push16.png'; return '/skins/icons/push16.png';
} }
/**
*
* @param Array $event
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$object)
{
$default = [
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$ssel_id = $dom_xml->createElement('ssel_id');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($ssel_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
$basket = $this->app['repo.baskets']
->find($params['ssel_id']);
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
$mail->setButtonUrl($params['url']);
$mail->setTitle($title);
$mail->setUser($user_from);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param string $datas * @param string $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $from = $data['from'];
$ssel_id = $data['ssel_id'];
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
if (null === $registered_user = $this->app['repo.users']->find($from)) { if (null === $registered_user = $this->app['repo.users']->find($from)) {
return []; return [];
@@ -146,7 +56,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$ret = [ $ret = [
'text' => $this->app->trans('%user% a envoye son rapport de validation de %title%', ['%user%' => $sender, '%title%' => '<a href="/lightbox/validate/' 'text' => $this->app->trans('%user% a envoye son rapport de validation de %title%', ['%user%' => $sender, '%title%' => '<a href="/lightbox/validate/'
. (string) $sx->ssel_id . '/" target="_blank">' . $ssel_id . '/" target="_blank">'
. $basket->getName() . '</a>' . $basket->getName() . '</a>'
]) ])
, 'class' => '' , 'class' => ''
@@ -178,12 +88,8 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
* *
* @return boolean * @return boolean
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
if (null === $user = $this->app['repo.users']->find($usr_id)) {
return false;
}
return $this->app['acl']->get($user)->has_right('push'); return $this->app['acl']->get($user)->has_right('push');
} }
} }

View File

@@ -10,28 +10,14 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationReminder; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Emitter;
class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstract class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstract
{ {
/** public function __construct(Application $app)
*
* @var string
*/
public $events = ['__VALIDATION_REMINDER__'];
/**
*
* @return notify_validationreminder
*/
public function __construct(Application $app, eventsmanager_broker $broker)
{ {
parent::__construct($app, $broker); parent::__construct($app);
$this->group = $this->app->trans('Validation'); $this->group = $this->app->trans('Validation');
return $this;
} }
/** /**
@@ -43,97 +29,16 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
return '/skins/icons/push16.png'; return '/skins/icons/push16.png';
} }
/**
*
* @param string $event
* @param Array $params
* @param mixed content $object
* @return boolean
*/
public function fire($event, $params, &$object)
{
$default = [
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
, 'url' => ''
];
$params = array_merge($default, $params);
$dom_xml = new DOMDocument('1.0', 'UTF-8');
$dom_xml->preserveWhiteSpace = false;
$dom_xml->formatOutput = true;
$root = $dom_xml->createElement('datas');
$from = $dom_xml->createElement('from');
$to = $dom_xml->createElement('to');
$ssel_id = $dom_xml->createElement('ssel_id');
$from->appendChild($dom_xml->createTextNode($params['from']));
$to->appendChild($dom_xml->createTextNode($params['to']));
$ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
$root->appendChild($from);
$root->appendChild($to);
$root->appendChild($ssel_id);
$dom_xml->appendChild($root);
$datas = $dom_xml->saveXml();
$mailed = false;
$user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']);
if (null === $user_from || null === $user_to) {
return false;
}
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
$basket = $this->app['repo.baskets']
->find($params['ssel_id']);
$title = $basket->getName();
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
$readyToSend = true;
} catch (\Exception $e) {
}
if ($readyToSend) {
$mail = MailInfoValidationReminder::create($this->app, $receiver, $emitter);
$mail->setButtonUrl($params['url']);
$mail->setTitle($title);
$this->app['notification.deliverer']->deliver($mail);
$mailed = true;
}
}
return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
}
/** /**
* *
* @param string $datas * @param string $datas
* @param boolean $unread * @param boolean $unread
* @return Array * @return Array
*/ */
public function datas($datas, $unread) public function datas(array $data, $unread)
{ {
$sx = simplexml_load_string($datas); $from = $data['from'];
$ssel_id = $data['ssel_id'];
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
if (null === $user = $this->app['repo.users']->find($from)) { if (null === $user = $this->app['repo.users']->find($from)) {
return []; return [];
@@ -149,7 +54,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
} }
$bask_link = '<a href="#" onclick="openPreview(\'BASK\',1,\'' $bask_link = '<a href="#" onclick="openPreview(\'BASK\',1,\''
. (string) $sx->ssel_id . '\');return false;">' . $ssel_id . '\');return false;">'
. $basket_name . '</a>'; . $basket_name . '</a>';
$ret = [ $ret = [
@@ -183,7 +88,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
* *
* @return string * @return string
*/ */
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }

View File

@@ -9,18 +9,27 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
abstract class eventsmanager_notifyAbstract
{ {
protected $events = ['__EVENT__']; /** @var null|string */
protected $group = null;
/** @var Application */
protected $app;
public function fire($event, $params, &$object) public function __construct(Application $app)
{ {
$this->app = $app;
} }
abstract public function datas($datas, $unread); public function get_group()
{
return $this->group;
}
public function is_available($usr_id) public function is_available(User $user)
{ {
return true; return true;
} }
@@ -30,12 +39,9 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
return true; return true;
} }
abstract public function get_name();
abstract public function datas(array $data, $unread);
abstract public function icon_url(); abstract public function icon_url();
protected function shouldSendNotificationFor($usrId)
{
$user = $this->app['repo.users']->find($usrId);
return $this->app['settings']->getUserNotificationSetting($user, get_class($this));
}
} }

View File

@@ -0,0 +1,107 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_390alpha20a extends patchAbstract
{
/** @var string */
private $release = '3.9.0-alpha.20';
/** @var array */
private $concern = [base::APPLICATION_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$perRequest = 100;
$offset = 0;
do {
$sql = sprintf('SELECT id, datas, type FROM notifications ORDER BY id ASC LIMIT %d, %d', $offset, $perRequest);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'UPDATE notifications SET datas = :json WHERE id = :id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$json = $row['datas'];
if (false !== ($sx = @simplexml_load_string($row['datas']))) {
$data = [];
foreach ($sx->children() as $name => $value) {
$data[$name] = (string) $value;
}
if ($row['type'] === 'notify_uploadquarantine') {
$data['reasons'] = [];
if (isset($sx->reasons)) {
foreach ($sx->reasons as $reason) {
$data['reasons'][] = (string) $reason->checkClassName;
}
}
}
if (in_array($row['type'], ['notify_autoregister', 'notify_register'])) {
$data['base_ids'] = [];
if (isset($sx->base_ids)) {
foreach ($sx->base_ids as $base_id) {
$data['base_ids'][] = (int) $base_id->base_id;
}
}
}
$json = json_encode($data);
}
$stmt->execute([':id' => $row['id'], ':json' => $json]);
}
$stmt->closeCursor();
$offset += $perRequest;
} while (count($rs) > 0);
return true;
}
}

View File

@@ -116,7 +116,7 @@ class record_exportElement extends record_adapter
$go_dl['preview'] = true; $go_dl['preview'] = true;
} }
$query = new User_Query($this->app); $query = $this->app['phraseanet.user-query'];
$masters = $query->on_base_ids([$this->base_id]) $masters = $query->on_base_ids([$this->base_id])
->who_have_right(['order_master']) ->who_have_right(['order_master'])

View File

@@ -2654,6 +2654,14 @@
<default></default> <default></default>
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>aggregable</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default>0</default>
<comment></comment>
</field>
<field> <field>
<name>indexable</name> <name>indexable</name>
<type>int(1) unsigned</type> <type>int(1) unsigned</type>

View File

@@ -0,0 +1,4 @@
{
"directory" : "tmp-assets",
"interactive": false
}

View File

@@ -1,18 +1,6 @@
#! /bin/bash #! /bin/bash
# open rabbitmq ports # stoping iptable
sudo iptables -I INPUT -p tcp --dport 15672 -j ACCEPT sudo service iptables-persistent stop
# open elastic search ports
sudo iptables -I INPUT -p tcp --dport 9200 -j ACCEPT
# open mysql ports
sudo iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
# locales
export LANGUAGE=fr_FR.UTF-8
export LANG=fr_FR.UTF-8
export LC_ALL=fr_FR.UTF-8
source ~/.bashrc source ~/.bashrc

View File

@@ -5,9 +5,9 @@ sudo sh -c 'echo "Europe/Paris" > /etc/timezone'
sudo dpkg-reconfigure -f noninteractive tzdata sudo dpkg-reconfigure -f noninteractive tzdata
# locales # locales
export LANGUAGE=fr_FR.UTF-8 sudo sh -c "echo 'LANGUAGE=fr_FR.UTF-8' >> /etc/environment"
export LANG=fr_FR.UTF-8 sudo sh -c "echo 'LANG=fr_FR.UTF-8' >> /etc/environment"
export LC_ALL=fr_FR.UTF-8 sudo sh -c "echo 'LC_ALL=fr_FR.UTF-8' >> /etc/environment"
sudo sh -c 'echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen' sudo sh -c 'echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen'
sudo sh -c 'echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen' sudo sh -c 'echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen'
sudo sh -c 'echo "es_ES.UTF-8 UTF-8" >> /etc/locale.gen' sudo sh -c 'echo "es_ES.UTF-8 UTF-8" >> /etc/locale.gen'
@@ -39,6 +39,7 @@ unzip compiler-latest.zip -d closure
mv /tmp/closure /home/vagrant mv /tmp/closure /home/vagrant
sudo sh -c "echo 'JS_COMPILER=/home/vagrant/closure/compiler.jar' >> /etc/environment" sudo sh -c "echo 'JS_COMPILER=/home/vagrant/closure/compiler.jar' >> /etc/environment"
export JS_COMPILER=/home/vagrant/closure/compiler.jar export JS_COMPILER=/home/vagrant/closure/compiler.jar
sudo chown -R vagrant: /home/vagrant/closure
# java # java
sudo sh -c "echo 'JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/' >> /etc/environment" sudo sh -c "echo 'JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/' >> /etc/environment"
@@ -114,12 +115,16 @@ then
#copy configuration template #copy configuration template
mv /var/www/phraseanet/lib/conf.d/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml.bkp mv /var/www/phraseanet/lib/conf.d/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml.bkp
cp /vagrant/resources/vagrant/config/phraseanet/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml cp /vagrant/resources/vagrant/config/phraseanet/configuration.yml /var/www/phraseanet/lib/conf.d/configuration.yml
mv /var/www/phraseanet/.bowerrc /var/www/phraseanet/.bowerrc.bkp
cp /vagrant/resources/vagrant/config/bower/.bower.rc /var/www/phraseanet/.bowerrc
cd /var/www/phraseanet cd /var/www/phraseanet
composer install -n --prefer-source --dev composer install -n --prefer-source --dev
npm install npm install
grunt install-assets grunt install-assets
bin/developer assets:compile-less bin/developer assets:compile-less
rm -f /var/www/phraseanet/lib/conf.d/configuration.yml rm -f /var/www/phraseanet/lib/conf.d/configuration.yml
rm -f /var/www/phraseanet/.bowerrc
mv /www/phraseanet/.bowerrc.bkp /www/phraseanet/.bowerrc
mv /var/www/phraseanet/lib/conf.d/configuration.yml.bkp /var/www/phraseanet/lib/conf.d/configuration.yml mv /var/www/phraseanet/lib/conf.d/configuration.yml.bkp /var/www/phraseanet/lib/conf.d/configuration.yml
fi fi
@@ -128,3 +133,9 @@ sudo service mysql restart
sudo service php5-fpm restart sudo service php5-fpm restart
sudo service nginx restart sudo service nginx restart
# stoping iptable
sudo service iptables-persistent stop
# reload bash
source ~/.bashrc

View File

@@ -55,7 +55,7 @@ class nginx::params {
$nx_client_body_temp_path = "${nx_run_dir}/client_body_temp" $nx_client_body_temp_path = "${nx_run_dir}/client_body_temp"
$nx_client_body_buffer_size = '128k' $nx_client_body_buffer_size = '128k'
$nx_client_max_body_size = '10m' $nx_client_max_body_size = '1000m'
$nx_proxy_temp_path = "${nx_run_dir}/proxy_temp" $nx_proxy_temp_path = "${nx_run_dir}/proxy_temp"
$nx_proxy_connect_timeout = '90' $nx_proxy_connect_timeout = '90'
$nx_proxy_send_timeout = '90' $nx_proxy_send_timeout = '90'

View File

@@ -287,6 +287,9 @@
{ {
t += (t==""?"":" ; ") + i + ": " + data.jeton_subdef[i]; t += (t==""?"":" ; ") + i + ": " + data.jeton_subdef[i];
} }
if(t == "") {
t = "0";
}
$("#subdefs_todo").text(t); $("#subdefs_todo").text(t);
} }

View File

@@ -176,6 +176,14 @@
</label> </label>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<label for="aggregable" class="checkbox">
<input id="aggregable" type="checkbox" <%= field.aggregable ? "checked='checked'" : "" %> />
{% trans %}Aggregable fields{% endtrans %}
</label>
</td>
</tr>
<tr> <tr>
<td><label for="separator">{% trans %}Separator{% endtrans %}</label></td> <td><label for="separator">{% trans %}Separator{% endtrans %}</label></td>
<td><input id="separator" type="text" value="<%= field.separator %>" /></td> <td><input id="separator" type="text" value="<%= field.separator %>" /></td>

View File

@@ -9,6 +9,14 @@
</label> </label>
</div> </div>
</div> </div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input class="formElem" type="checkbox" name="mwg">
{{ 'task::writemeta:Compatibilité MWG' | trans }}
</label>
</div>
</div>
{% endblock %} {% endblock %}
@@ -22,6 +30,7 @@
with(document.forms['graphicForm']) with(document.forms['graphicForm'])
{ {
cleardoc.checked = Number(xml.find("cleardoc").text()) > 0; cleardoc.checked = Number(xml.find("cleardoc").text()) > 0;
mwg.checked = Number(xml.find("mwg").text()) > 0;
} }
} }
} }

View File

@@ -59,15 +59,15 @@
password : {password:"#create_admin input[name=email]"}, password : {password:"#create_admin input[name=email]"},
password_confirm : {equalTo:"#create_admin input[name=password]"}, password_confirm : {equalTo:"#create_admin input[name=password]"},
ab_hostname : {required:true}, hostname : {required:true},
ab_user : {required:true}, user : {required:true},
ab_name : {required:true} ab_name : {required:true}
}, },
messages: { messages: {
email:{ email:{
email : language.validateEmail email : language.validateEmail
}, },
ab_hostname : { hostname : {
required : language.requiredField required : language.requiredField
}, },
password : { password : {
@@ -149,10 +149,10 @@
function test_connection_appbox(callback) function test_connection_appbox(callback)
{ {
var scope = $('.appbox_settings'); var scope = $('.appbox_settings');
var hostname_input = $('input[name="ab_hostname"]:visible', scope); var hostname_input = $('input[name="hostname"]:visible', scope);
var port_input = $('input[name="ab_port"]:visible', scope); var port_input = $('input[name="port"]:visible', scope);
var user_input = $('input[name="ab_user"]', scope); var user_input = $('input[name="user"]', scope);
var password_input = $('input[name="ab_password"]', scope); var password_input = $('input[name="password"]', scope);
var dbname_input = $('input[name="ab_name"]', scope); var dbname_input = $('input[name="ab_name"]', scope);
var user = user_input.val(); var user = user_input.val();
@@ -187,10 +187,10 @@
var appbox_scope = $('.appbox_settings'); var appbox_scope = $('.appbox_settings');
var databox_scope = $('.databox_settings'); var databox_scope = $('.databox_settings');
var hostname_input = $('input[name="ab_hostname"]', appbox_scope); var hostname_input = $('input[name="hostname"]', appbox_scope);
var port_input = $('input[name="ab_port"]', appbox_scope); var port_input = $('input[name="port"]', appbox_scope);
var user_input = $('input[name="ab_user"]', appbox_scope); var user_input = $('input[name="user"]', appbox_scope);
var password_input = $('input[name="ab_password"]', appbox_scope); var password_input = $('input[name="password"]', appbox_scope);
var dbname_input = $('input[name="db_name"]', databox_scope); var dbname_input = $('input[name="db_name"]', databox_scope);
@@ -549,19 +549,19 @@
</tr> </tr>
<tr class="optional_ab_datas"> <tr class="optional_ab_datas">
<td style="width:200px;"><label>{{ 'phraseanet:: adresse' | trans }}</label></td> <td style="width:200px;"><label>{{ 'phraseanet:: adresse' | trans }}</label></td>
<td><input autocomplete="off" type="text" name="ab_hostname" value="localhost" /></td> <td><input autocomplete="off" type="text" name="hostname" value="localhost" /></td>
</tr> </tr>
<tr> <tr>
<td style="width:200px;"><label>{{ 'Database user' | trans }}</label></td> <td style="width:200px;"><label>{{ 'Database user' | trans }}</label></td>
<td><input type="text" name="ab_user" value="" /></td> <td><input type="text" name="user" value="" /></td>
</tr> </tr>
<tr> <tr>
<td style="width:200px;"><label>{{ 'admin::compte-utilisateur mot de passe' | trans }}</label></td> <td style="width:200px;"><label>{{ 'admin::compte-utilisateur mot de passe' | trans }}</label></td>
<td><input type="password" name="ab_password" value="" autocomplete="off" /></td> <td><input type="password" name="password" value="" autocomplete="off" /></td>
</tr> </tr>
<tr class="optional_ab_datas"> <tr class="optional_ab_datas">
<td style="width:200px;"><label>{{ 'phraseanet:: port' | trans }}</label></td> <td style="width:200px;"><label>{{ 'phraseanet:: port' | trans }}</label></td>
<td><input autocomplete="off" type="text" name="ab_port" value="3306" /></td> <td><input autocomplete="off" type="text" name="port" value="3306" /></td>
</tr> </tr>
<tr> <tr>
<td style="width:200px;"><label>{{ 'Database' | trans }}</label></td> <td style="width:200px;"><label>{{ 'Database' | trans }}</label></td>

View File

@@ -221,6 +221,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'thumbtitle' => false, 'thumbtitle' => false,
'tag' => 'XMP:XMP', 'tag' => 'XMP:XMP',
'business' => false, 'business' => false,
'aggregable' => false,
'indexable' => true, 'indexable' => true,
'required' => true, 'required' => true,
'labels' => [ 'labels' => [

View File

@@ -2,6 +2,10 @@
namespace Alchemy\Tests\Phrasea\Controller\Prod; namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Symfony\Component\EventDispatcher\Event;
class DownloadTest extends \PhraseanetAuthenticatedWebTestCase class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
{ {
protected $client; protected $client;
@@ -11,17 +15,10 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testDownloadRecords() public function testDownloadRecords()
{ {
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') $triggered = false;
->disableOriginalConstructor() self::$DI['app']['dispatcher']->addListener(PhraseaEvents::EXPORT_CREATE, function (Event $event) use (&$triggered) {
->getMock(); $triggered = true;
});
$eventManagerStub->expects($this->once())
->method('trigger')
->with($this->equalTo('__DOWNLOAD__'), $this->isType('array'))
->will($this->returnValue(null));
self::$DI['app']['events-manager'] = $eventManagerStub;
self::$DI['client']->request('POST', '/prod/download/', [ self::$DI['client']->request('POST', '/prod/download/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => self::$DI['record_1']->get_serialize_key(),
'ssttid' => '', 'ssttid' => '',
@@ -33,6 +30,7 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location')); $this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location'));
$this->assertTrue($triggered);
unset($response, $eventManagerStub); unset($response, $eventManagerStub);
} }
@@ -41,17 +39,10 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testDownloadRestricted() public function testDownloadRestricted()
{ {
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') $triggered = false;
->disableOriginalConstructor() self::$DI['app']['dispatcher']->addListener(PhraseaEvents::EXPORT_CREATE, function (Event $event) use (&$triggered) {
->getMock(); $triggered = true;
});
$eventManagerStub->expects($this->once())
->method('trigger')
->with($this->equalTo('__DOWNLOAD__'), $this->isType('array'))
->will($this->returnValue(null));
self::$DI['app']['events-manager'] = $eventManagerStub;
self::$DI['app']['authentication']->setUser(self::$DI['user']); self::$DI['app']['authentication']->setUser(self::$DI['user']);
$stubbedACL = $this->getMockBuilder('\ACL') $stubbedACL = $this->getMockBuilder('\ACL')
@@ -92,6 +83,7 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertTrue($triggered);
$this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location')); $this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location'));
unset($response, $eventManagerStub); unset($response, $eventManagerStub);
} }
@@ -103,16 +95,10 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4);
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') $triggered = false;
->disableOriginalConstructor() self::$DI['app']['dispatcher']->addListener(PhraseaEvents::EXPORT_CREATE, function (Event $event) use (&$triggered) {
->getMock(); $triggered = true;
});
$eventManagerStub->expects($this->once())
->method('trigger')
->with($this->equalTo('__DOWNLOAD__'), $this->isType('array'))
->will($this->returnValue(null));
self::$DI['app']['events-manager'] = $eventManagerStub;
self::$DI['client']->request('POST', '/prod/download/', [ self::$DI['client']->request('POST', '/prod/download/', [
'lst' => '', 'lst' => '',
@@ -124,6 +110,7 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertTrue($triggered);
$this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location')); $this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location'));
unset($response, $eventManagerStub); unset($response, $eventManagerStub);
} }
@@ -135,16 +122,10 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4);
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') $triggered = false;
->disableOriginalConstructor() self::$DI['app']['dispatcher']->addListener(PhraseaEvents::EXPORT_CREATE, function (Event $event) use (&$triggered) {
->getMock(); $triggered = true;
});
$eventManagerStub->expects($this->once())
->method('trigger')
->with($this->equalTo('__DOWNLOAD__'), $this->isType('array'))
->will($this->returnValue(null));
self::$DI['app']['events-manager'] = $eventManagerStub;
self::$DI['client']->request('POST', '/prod/download/', [ self::$DI['client']->request('POST', '/prod/download/', [
'lst' => '', 'lst' => '',
@@ -156,6 +137,7 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertTrue($triggered);
$this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location')); $this->assertRegExp('#/download/[a-zA-Z0-9]{8,32}/#', $response->headers->get('location'));
unset($response, $eventManagerStub); unset($response, $eventManagerStub);
} }

View File

@@ -2,6 +2,9 @@
namespace Alchemy\Tests\Phrasea\Controller\Prod; namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\EventDispatcher\Event;
use Alchemy\Phrasea\Model\Entities\Order; use Alchemy\Phrasea\Model\Entities\Order;
use Alchemy\Phrasea\Model\Entities\OrderElement; use Alchemy\Phrasea\Model\Entities\OrderElement;
@@ -20,22 +23,30 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testCreateOrder() public function testCreateOrder()
{ {
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') self::$DI['app']['phraseanet.user-query'] = $this->getMockBuilder('\User_Query')->disableOriginalConstructor()->getMock();
->disableOriginalConstructor() self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('get_results')->will($this->returnValue(new ArrayCollection([self::$DI['user_alt2']])));
->getMock(); self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('on_base_ids')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('who_have_right')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('execute')->will($this->returnSelf());
$eventManagerStub->expects($this->once()) self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->method('trigger') ->disableOriginalConstructor()
->with($this->equalTo('__NEW_ORDER__'), $this->isType('array')) ->getMock();
->will($this->returnValue(null)); $triggered = false;
self::$DI['app']['dispatcher']->addListener(PhraseaEvents::ORDER_CREATE, function (Event $event) use (&$triggered) {
self::$DI['app']['events-manager'] = $eventManagerStub; $triggered = true;
});
self::$DI['client']->request('POST', '/prod/order/', [ self::$DI['client']->request('POST', '/prod/order/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => self::$DI['record_1']->get_serialize_key(),
'deadline' => '+10 minutes' 'deadline' => '+10 minutes'
]); ]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$url = parse_url(self::$DI['client']->getResponse()->headers->get('location'));
$var = [];
parse_str($url['query'], $var);
$this->assertTrue(!!$var['success']);
$this->assertTrue($triggered);
} }
/** /**
@@ -43,16 +54,20 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testCreateOrderJson() public function testCreateOrderJson()
{ {
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') self::$DI['app']['phraseanet.user-query'] = $this->getMockBuilder('\User_Query')->disableOriginalConstructor()->getMock();
->disableOriginalConstructor() self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('get_results')->will($this->returnValue(new ArrayCollection([self::$DI['user_alt2']])));
->getMock(); self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('on_base_ids')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('who_have_right')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('execute')->will($this->returnSelf());
$eventManagerStub->expects($this->once())
->method('trigger')
->with($this->equalTo('__NEW_ORDER__'), $this->isType('array'))
->will($this->returnValue(null));
self::$DI['app']['events-manager'] = $eventManagerStub; self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->disableOriginalConstructor()
->getMock();
$triggered = false;
self::$DI['app']['dispatcher']->addListener(PhraseaEvents::ORDER_CREATE, function (Event $event) use (&$triggered) {
$triggered = true;
});
$this->XMLHTTPRequest('POST', '/prod/order/', [ $this->XMLHTTPRequest('POST', '/prod/order/', [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => self::$DI['record_1']->get_serialize_key(),
@@ -61,6 +76,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertTrue($triggered);
$this->assertEquals('application/json', $response->headers->get('Content-Type')); $this->assertEquals('application/json', $response->headers->get('Content-Type'));
$content = json_decode($response->getContent()); $content = json_decode($response->getContent());
$this->assertTrue(is_object($content)); $this->assertTrue(is_object($content));
@@ -158,8 +174,9 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]); self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$url = parse_url(self::$DI['client']->getResponse()->headers->get('location')); $url = parse_url(self::$DI['client']->getResponse()->headers->get('location'));
parse_str($url['query']); $var = [];
$this->assertTrue( ! ! $success); parse_str($url['query'], $var);
$this->assertTrue( ! ! $var['success']);
} }
/** /**

View File

@@ -362,7 +362,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
$this->markTestSkipped('No collections'); $this->markTestSkipped('No collections');
} }
foreach (self::$DI['app']['events-manager']->list_notifications_available(self::$DI['app']['authentication']->getUser()->getId()) as $notifications) { foreach (self::$DI['app']['events-manager']->list_notifications_available(self::$DI['app']['authentication']->getUser()) as $notifications) {
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
$notifs[] = $notification['id']; $notifs[] = $notification['id'];
} }

View File

@@ -147,10 +147,10 @@ class SetupTest extends \PhraseanetWebTestCase
'binary_convert' => '/path/to/convert', 'binary_convert' => '/path/to/convert',
'binary_php' => '/path/to/php', 'binary_php' => '/path/to/php',
'datapath_noweb' => sys_get_temp_dir() . '/datainstall/noweb', 'datapath_noweb' => sys_get_temp_dir() . '/datainstall/noweb',
'ab_hostname' => $host, 'hostname' => $host,
'ab_port' => $port, 'port' => $port,
'ab_user' => $user, 'user' => $user,
'ab_password' => $password, 'password' => $password,
'ab_name' => $abName, 'ab_name' => $abName,
'db_name' => $dbName, 'db_name' => $dbName,
'db_template' => 'en', 'db_template' => 'en',

View File

@@ -11,7 +11,7 @@ class WriteMetadataEditorTest extends EditorTestCase
return [ return [
['<?xml version="1.0" encoding="UTF-8"?> ['<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
<cleardoc>0</cleardoc></tasksettings> <cleardoc>0</cleardoc><mwg>0</mwg></tasksettings>
', '<?xml version="1.0" encoding="UTF-8"?> ', '<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
</tasksettings>', [] </tasksettings>', []
@@ -19,6 +19,7 @@ class WriteMetadataEditorTest extends EditorTestCase
['<?xml version="1.0" encoding="UTF-8"?> ['<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
<cleardoc>1</cleardoc> <cleardoc>1</cleardoc>
<mwg>0</mwg>
</tasksettings> </tasksettings>
', '<?xml version="1.0" encoding="UTF-8"?> ', '<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
@@ -26,9 +27,17 @@ class WriteMetadataEditorTest extends EditorTestCase
</tasksettings>', ['cleardoc' => 1] </tasksettings>', ['cleardoc' => 1]
], ],
['<?xml version="1.0" encoding="UTF-8"?> ['<?xml version="1.0" encoding="UTF-8"?>
<tasksettings>
<cleardoc>0</cleardoc><mwg>1</mwg></tasksettings>
', '<?xml version="1.0" encoding="UTF-8"?>
<tasksettings>
</tasksettings>', ['mwg' => 1]
],
['<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>
<customtag>value</customtag> <customtag>value</customtag>
<cleardoc>0</cleardoc> <cleardoc>0</cleardoc>
<mwg>0</mwg>
</tasksettings> </tasksettings>
', '<?xml version="1.0" encoding="UTF-8"?> ', '<?xml version="1.0" encoding="UTF-8"?>
<tasksettings> <tasksettings>

View File

@@ -274,6 +274,12 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
return $collection->get_base_id(); return $collection->get_base_id();
}, $acl->get_order_master_collections())); }, $acl->get_order_master_collections()));
$this->assertEquals(0, count($tbas)); $this->assertEquals(0, count($tbas));
foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$acl->set_order_master($collection, true);
}
}
} }
public function testIs_restricted_download() public function testIs_restricted_download()

View File

@@ -1,6 +1,9 @@
<?php <?php
use Rhumsaa\Uuid\Uuid; use Rhumsaa\Uuid\Uuid;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Symfony\Component\EventDispatcher\Event;
use Doctrine\Common\Collections\ArrayCollection;
class record_adapterTest extends \PhraseanetAuthenticatedTestCase class record_adapterTest extends \PhraseanetAuthenticatedTestCase
{ {
@@ -65,21 +68,26 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
self::$DI['app']['acl'] = $aclProvider; self::$DI['app']['acl'] = $aclProvider;
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') self::$DI['app']['phraseanet.user-query'] = $this->getMockBuilder('\User_Query')->disableOriginalConstructor()->getMock();
->disableOriginalConstructor() self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('get_results')->will($this->returnValue(new ArrayCollection([self::$DI['user_alt2']])));
->getMock(); self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('on_base_ids')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('who_have_right')->will($this->returnSelf());
self::$DI['app']['phraseanet.user-query']->expects($this->any())->method('execute')->will($this->returnSelf());
$eventManagerStub->expects($this->once()) self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
->method('trigger') ->disableOriginalConstructor()
->with($this->equalTo('__NEW_ORDER__'), $this->isType('array')) ->getMock();
->will($this->returnValue(null)); $triggered = false;
self::$DI['app']['dispatcher']->addListener(PhraseaEvents::ORDER_CREATE, function (Event $event) use (&$triggered) {
self::$DI['app']['events-manager'] = $eventManagerStub; $triggered = true;
});
self::$DI['client']->request('POST', self::$DI['app']['url_generator']->generate('prod_order_new'), [ self::$DI['client']->request('POST', self::$DI['app']['url_generator']->generate('prod_order_new'), [
'lst' => self::$DI['record_1']->get_serialize_key(), 'lst' => self::$DI['record_1']->get_serialize_key(),
'deadline' => '+10 minutes' 'deadline' => '+10 minutes'
]); ]);
$this->assertTrue($triggered);
} }
public function testGet_creation_date() public function testGet_creation_date()

View File

@@ -0,0 +1,169 @@
main:
servername: 'http://local.phrasea/'
maintenance: false
languages: []
key: ''
database:
host: 'sql-host'
port: 3306
user: 'sql-user'
password: 'sql-password'
dbname: ab_phraseanet
driver: pdo_mysql
charset: UTF8
database-test:
driver: pdo_sqlite
path: '/tmp/db.sqlite'
charset: UTF8
api-timers: false
cache:
type: ArrayCache
options:
options: []
opcodecache:
type: ArrayCache
options: []
search-engine:
type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine
options: []
task-manager:
enabled: true
logger:
max-files: 10
enabled: true
level: INFO
trusted-proxies: []
debugger:
allowed-ips: ['192.168.56.1']
binaries:
ghostscript_binary: null
php_binary: null
swf_extract_binary: null
pdf2swf_binary: null
swf_render_binary: null
unoconv_binary: null
ffmpeg_binary: null
ffprobe_binary: null
mp4box_binary: null
pdftotext_binary: null
recess_binary: null
phraseanet_indexer: null
ffmpeg_timeout: 3600
ffprobe_timeout: 60
gs_timeout: 60
mp4box_timeout: 60
swftools_timeout: 60
unoconv_timeout: 60
border-manager:
enabled: true
extension-mapping: { }
checkers:
-
type: Checker\Sha256
enabled: true
-
type: Checker\UUID
enabled: true
-
type: Checker\Colorspace
enabled: false
options:
colorspaces: [cmyk, grayscale, rgb]
-
type: Checker\Dimension
enabled: false
options:
width: 80
height: 160
-
type: Checker\Extension
enabled: false
options:
extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2]
-
type: Checker\Filename
enabled: false
options:
sensitive: true
-
type: Checker\MediaType
enabled: false
options:
mediatypes: [Audio, Document, Flash, Image, Video]
authentication:
auto-create:
templates: { }
captcha:
enabled: true
trials-before-display: 9
providers:
facebook:
enabled: false
options:
app-id: ''
secret: ''
twitter:
enabled: false
options:
consumer-key: ''
consumer-secret: ''
google-plus:
enabled: false
options:
client-id: ''
client-secret: ''
github:
enabled: false
options:
client-id: ''
client-secret: ''
viadeo:
enabled: false
options:
client-id: ''
client-secret: ''
linkedin:
enabled: false
options:
client-id: ''
client-secret: ''
registration-fields:
-
name: company
required: true
-
name: lastname
required: true
-
name: firstname
required: true
-
name: geonameid
required: true
xsendfile:
enabled: false
type: nginx
mapping: []
h264-pseudo-streaming:
enabled: false
type: nginx
mapping: []
plugins: []
api_cors:
enabled: false
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
session:
idle: 0
# 1 week
lifetime: 604800
crossdomain:
allow-access-from:
-
domain: '*.cooliris.com'
secure: 'false'

View File

@@ -0,0 +1,2 @@
!.gitignore
!insecure_private_key