diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php
index 7d1b188e3c..170660fed6 100644
--- a/lib/Alchemy/Phrasea/Application.php
+++ b/lib/Alchemy/Phrasea/Application.php
@@ -639,7 +639,7 @@ class Application extends SilexApplication
}));
$twig->addFilter(new \Twig_SimpleFilter('thesaurus', function (\Twig_Environment $twig, $value) {
if (!$value instanceof \ThesaurusValue) {
- return twig_escape_filter($twig, str_replace(['[[em]]', '[[/em]]'], ['', ''], $value));
+ return str_replace(array('[[em]]', '[[/em]]'), array('', ''), twig_escape_filter($twig, $value));
}
return "getField()->get_databox()->get_sbas_id() . "','"
@@ -647,7 +647,7 @@ class Application extends SilexApplication
. "', '"
. str_replace("'", "\\'", $value->getField()->get_name())
. "');return(false);\">"
- . twig_escape_filter($twig, str_replace(['[[em]]', '[[/em]]'], ['', ''], $value->getValue()))
+ . str_replace(array('[[em]]', '[[/em]]'), array('', ''), twig_escape_filter($twig, $value->getValue()))
. "";
}, ['needs_environment' => true, 'is_safe' => ['html']]));
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
index ca7bc6539d..c2fd99396a 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
@@ -17,6 +17,8 @@ use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Alchemy\Phrasea\Notification\Receiver;
+use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
class Users implements ControllerProviderInterface
{
@@ -543,31 +545,30 @@ class Users implements ControllerProviderInterface
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $accept = $deny = '';
+ $acceptColl = $denyColl = [];
if ($row) {
-
if (\Swift_Validate::email($row['usr_mail'])) {
foreach ($bases as $bas => $isok) {
if ($isok) {
- $accept .= '
' . \phrasea::bas_labels($bas, $app) . "\n";
+ $acceptColl[] = \phrasea::bas_labels($bas, $app);
} else {
- $deny .= '' . \phrasea::bas_labels($bas, $app) . "\n";
+ $denyColl[] = \phrasea::bas_labels($bas, $app);
}
}
- if (($accept != '' || $deny != '')) {
+ if (0 !== count($acceptColl) || 0 !== count($denyColl)) {
$message = '';
- if ($accept != '') {
- $message .= "\n" . $app->trans('login::register:email: Vous avez ete accepte sur les collections suivantes :') . implode(', ', $accept). "\n";
+ if (0 !== count($acceptColl)) {
+ $message .= "\n" . $app->trans('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . implode(', ', $acceptColl). "\n";
}
- if ($deny != '') {
- $message .= "\n" . $app->trans('login::register:email: Vous avez ete refuse sur les collections suivantes :') . implode(', ', $deny) . "\n";
+ if (0 !== count($denyColl)) {
+ $message .= "\n" . $app->trans('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . implode(', ', $denyColl) . "\n";
}
$receiver = new Receiver(null, $row['usr_mail']);
- $mail = MailSuccessEmailUpdate::create($this->app, $receiver, null, $message);
+ $mail = MailSuccessEmailUpdate::create($app, $receiver, null, $message);
- $this->app['notification.deliverer']->deliver($mail);
+ $app['notification.deliverer']->deliver($mail);
}
}
}
diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php
index 2b85c54498..4d3305144c 100644
--- a/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php
+++ b/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php
@@ -37,7 +37,7 @@ class LocalesRequirements extends RequirementCollection implements RequirementIn
if (defined('INTL_ICU_VERSION')) {
$version = INTL_ICU_VERSION;
} else {
- $reflector = new ReflectionExtension('intl');
+ $reflector = new \ReflectionExtension('intl');
ob_start();
$reflector->info();
diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php
index 06b687468f..fb9e05404c 100644
--- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php
+++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Setup\Version\Migration;
use Alchemy\Phrasea\Application;
use Symfony\Component\Yaml\Yaml;
+use Alchemy\Phrasea\Exception\RuntimeException;
class Migration38 implements MigrationInterface
{
@@ -58,12 +59,12 @@ class Migration38 implements MigrationInterface
$app['configuration.store']->setConfig($conf);
- foreach ([
+ foreach (array(
$this->configYaml,
$this->connexionsYaml,
$this->binariesYaml,
$this->servicesYaml
- ] as $file) {
+ ) as $file) {
if (is_file($file)) {
rename($file, $file.'.bkp');
}
@@ -86,7 +87,8 @@ class Migration38 implements MigrationInterface
if (is_file($this->configYaml)) {
$data = $this->yaml->parse($this->configYaml);
- $conf['main']['key'] = $data['key'];
+ $key = isset($data['key']) ? $data['key'] : $this->fetchInstanceKey();
+ $conf['main']['key'] = $key;
$env = $data['environment'];
if (isset($data[$env])) {
$conf['main']['servername'] = $data[$env]['phraseanet']['servername'];
@@ -114,7 +116,9 @@ class Migration38 implements MigrationInterface
$conf['main']['cache']['options'] = [];
}
}
- $conf['border-manager'] = $services['Border']['border_manager']['options'];
+ if (isset($services['Border'])) {
+ $conf['border-manager'] = $services['Border']['border_manager']['options'];
+ }
}
}
@@ -127,4 +131,18 @@ class Migration38 implements MigrationInterface
$conf['main']['database-test'] = $data['test_connexion'];
}
}
+
+ private function fetchInstanceKey()
+ {
+ $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare('SELECT `value` FROM registry WHERE `key` = "GV_SIT"');
+ $stmt->execute();
+ $rs = $stmt->fetch(\PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ if (!$rs) {
+ throw new RuntimeException('Unable to fetch GV_SIT key from registry table.');
+ }
+
+ return $rs['key'];
+ }
}
diff --git a/lib/classes/databox.php b/lib/classes/databox.php
index 43dd15914f..bdaefa874e 100644
--- a/lib/classes/databox.php
+++ b/lib/classes/databox.php
@@ -111,15 +111,16 @@ class databox extends base
assert($sbas_id > 0);
$this->app = $app;
- $this->connection = connection::getPDOConnection($app, $sbas_id);
$this->id = $sbas_id;
$connection_params = phrasea::sbas_params($this->app);
- if ( ! isset($connection_params[$sbas_id])) {
+ if (! isset($connection_params[$sbas_id])) {
throw new NotFoundHttpException(sprintf('databox %d not found', $sbas_id));
}
+ $this->connection = connection::getPDOConnection($app, $sbas_id);
+
$this->host = $connection_params[$sbas_id]['host'];
$this->port = $connection_params[$sbas_id]['port'];
$this->user = $connection_params[$sbas_id]['user'];
diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php
index 5941caba1b..2381f8af17 100644
--- a/lib/classes/eventsmanager/notify/autoregister.php
+++ b/lib/classes/eventsmanager/notify/autoregister.php
@@ -198,7 +198,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
}
if ($readyToSend) {
- $mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, $body);
+ $mail = MailInfoSomebodyAutoregistered::create($this->app, $receiver, null, $body);
$this->app['notification.deliverer']->deliver($mail);
}
diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig
index 0bad23cf0c..35cd4319a0 100644
--- a/templates/web/prod/results/record.html.twig
+++ b/templates/web/prod/results/record.html.twig
@@ -23,7 +23,7 @@
- {{record.get_title(highlight, searchEngine)|raw}}
+ {{record.get_title(highlight, searchEngine)|thesaurus}}
{{record.get_status_icons|raw}}
diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php
index 487da0270a..4710357ad5 100644
--- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php
+++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php
@@ -412,6 +412,54 @@ class ControllerUsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
}
+ public function testPostDemands()
+ {
+ $id = self::$DI['user_alt1']->get_id();
+ $baseId = self::$DI['collection']->get_base_id();
+ $param = sprintf('%s_%s', $id, $baseId);
+
+ $appbox = self::$DI['app']['phraseanet.appbox'];
+
+ $stmt = $this->getMock('PDOStatement');
+
+ $stmt->expects($this->any())
+ ->method('fetchAll')
+ ->will($this->returnValue([
+ 'usr_id' => $id,
+ 'base_id' => $baseId,
+ 'en_cours' => 1,
+ 'refuser' => 0,
+ ]));
+
+ $pdo = $this->getMock('PDOMock');
+
+ $pdo->expects($this->any())
+ ->method('prepare')
+ ->will($this->returnValue($stmt));
+
+ $appbox = $this->getMockBuilder('\appbox')
+ ->setMethods(['get_connection'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $appbox->expects($this->any())
+ ->method('get_connection')
+ ->will($this->returnValue($pdo));
+
+ $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate');
+
+ self::$DI['client']->request('POST', '/admin/users/demands/', [
+ 'template' => [],
+ 'accept' => [$param],
+ 'accept_hd' => [$param],
+ 'watermark' => [$param],
+ ]);
+
+ self::$DI['app']['phraseanet.appbox'] = $appbox;
+
+ $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
+ }
+
public function testRenderImportFile()
{
self::$DI['client']->request('GET', '/admin/users/import/file/');
diff --git a/tests/classes/CsrfTestProvider.php b/tests/classes/CsrfTestProvider.php
new file mode 100644
index 0000000000..f8fbac0822
--- /dev/null
+++ b/tests/classes/CsrfTestProvider.php
@@ -0,0 +1,19 @@
+getMock('PDOMock')
+ */
+class PDOMock extends \PDO
+{
+ public function __construct() {}
+}
diff --git a/tests/classes/PhraseanetTestCase.php b/tests/classes/PhraseanetTestCase.php
index a2decd91d1..8591ec015b 100644
--- a/tests/classes/PhraseanetTestCase.php
+++ b/tests/classes/PhraseanetTestCase.php
@@ -529,16 +529,3 @@ abstract class PhraseanetTestCase extends WebTestCase
->getMock();
}
}
-
-class CsrfTestProvider implements CsrfProviderInterface
-{
- public function generateCsrfToken($intention)
- {
- return mt_rand();
- }
-
- public function isCsrfTokenValid($intention, $token)
- {
- return true;
- }
-}
diff --git a/tests/classes/unitTestsTest.php b/tests/classes/unitTestsTest.php
index 7ab28222fd..ab3db84fec 100644
--- a/tests/classes/unitTestsTest.php
+++ b/tests/classes/unitTestsTest.php
@@ -11,6 +11,8 @@ class unitTestsTest extends \PhraseanetTestCase
"PhraseanetAuthenticatedTestCase.php",
"PhraseanetAuthenticatedWebTestCase.php",
"PhraseanetPHPUnitListener.php",
+ "PDOMock.php",
+ "CsrfTestProvider.php",
];
$testDir = __DIR__ . '/';