mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fix latest merge
This commit is contained in:
@@ -1036,8 +1036,8 @@ class V1 implements ControllerProviderInterface
|
|||||||
$devices = $request->get('devices', []);
|
$devices = $request->get('devices', []);
|
||||||
$mimes = $request->get('mimes', []);
|
$mimes = $request->get('mimes', []);
|
||||||
|
|
||||||
$ret = array_filter(array_map(function ($media) use ($record) {
|
$ret = array_filter(array_map(function ($media) use ($record, $app) {
|
||||||
if (null !== $embed = $this->list_embedable_media($record, $media)) {
|
if (null !== $embed = $this->list_embedable_media($app, $record, $media)) {
|
||||||
return $embed;
|
return $embed;
|
||||||
}
|
}
|
||||||
}, $record->get_embedable_medias($devices, $mimes)));
|
}, $record->get_embedable_medias($devices, $mimes)));
|
||||||
@@ -1063,8 +1063,8 @@ class V1 implements ControllerProviderInterface
|
|||||||
$devices = $request->get('devices', []);
|
$devices = $request->get('devices', []);
|
||||||
$mimes = $request->get('mimes', []);
|
$mimes = $request->get('mimes', []);
|
||||||
|
|
||||||
$ret = array_filter(array_map(function ($media) use ($record) {
|
$ret = array_filter(array_map(function ($media) use ($record, $app) {
|
||||||
if (null !== $embed = $this->list_embedable_media($record, $media)) {
|
if (null !== $embed = $this->list_embedable_media($app, $record, $media)) {
|
||||||
return $embed;
|
return $embed;
|
||||||
}
|
}
|
||||||
}, $record->get_embedable_medias($devices, $mimes)));
|
}, $record->get_embedable_medias($devices, $mimes)));
|
||||||
@@ -1555,19 +1555,19 @@ class V1 implements ControllerProviderInterface
|
|||||||
* @param media_subdef $media
|
* @param media_subdef $media
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function list_embedable_media(\record_adapter $record, \media_subdef $media)
|
private function list_embedable_media(Application $app, \record_adapter $record, \media_subdef $media)
|
||||||
{
|
{
|
||||||
if (!$media->is_physically_present()) {
|
if (!$media->is_physically_present()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->app['authentication']->isAuthenticated()) {
|
if ($app['authentication']->isAuthenticated()) {
|
||||||
if ($media->get_name() !== 'document' && false === $this->app['acl']->get($this->app['authentication']->getUser())->has_access_to_subdef($record, $media->get_name())) {
|
if ($media->get_name() !== 'document' && false === $app['acl']->get($app['authentication']->getUser())->has_access_to_subdef($record, $media->get_name())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($media->get_name() === 'document'
|
if ($media->get_name() === 'document'
|
||||||
&& !$this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'candwnldhd')
|
&& !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'candwnldhd')
|
||||||
&& !$this->app['acl']->get($this->app['authentication']->getUser())->has_hd_grant($record)) {
|
&& !$app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1757,7 +1757,7 @@ class V1 implements ControllerProviderInterface
|
|||||||
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
|
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
|
||||||
'collection_id' => \phrasea::collFromBas($app, $record->get_base_id()),
|
'collection_id' => \phrasea::collFromBas($app, $record->get_base_id()),
|
||||||
'sha256' => $record->get_sha256(),
|
'sha256' => $record->get_sha256(),
|
||||||
'thumbnail' => $this->list_embedable_media($record, $record->get_thumbnail()),
|
'thumbnail' => $this->list_embedable_media($app, $record, $record->get_thumbnail()),
|
||||||
'technical_informations' => $technicalInformation,
|
'technical_informations' => $technicalInformation,
|
||||||
'phrasea_type' => $record->get_type(),
|
'phrasea_type' => $record->get_type(),
|
||||||
'uuid' => $record->get_uuid(),
|
'uuid' => $record->get_uuid(),
|
||||||
@@ -1802,7 +1802,7 @@ class V1 implements ControllerProviderInterface
|
|||||||
'updated_on' => $story->get_modification_date()->format(DATE_ATOM),
|
'updated_on' => $story->get_modification_date()->format(DATE_ATOM),
|
||||||
'created_on' => $story->get_creation_date()->format(DATE_ATOM),
|
'created_on' => $story->get_creation_date()->format(DATE_ATOM),
|
||||||
'collection_id' => \phrasea::collFromBas($app, $story->get_base_id()),
|
'collection_id' => \phrasea::collFromBas($app, $story->get_base_id()),
|
||||||
'thumbnail' => $this->list_embedable_media($story, $story->get_thumbnail()),
|
'thumbnail' => $this->list_embedable_media($app, $story, $story->get_thumbnail()),
|
||||||
'uuid' => $story->get_uuid(),
|
'uuid' => $story->get_uuid(),
|
||||||
'metadatas' => [
|
'metadatas' => [
|
||||||
'@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG,
|
'@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG,
|
||||||
|
@@ -59,39 +59,21 @@ class PhraseaLocaleSubscriber implements EventSubscriberInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$confLocale = $this->app['locale'];
|
$event->getRequest()->setLocale($this->app['locale']);
|
||||||
|
|
||||||
$this->app['locale'] = $this->app->share(function (Application $app) use ($event, $confLocale) {
|
|
||||||
if (!$app['configuration.store']->isSetup()) {
|
|
||||||
$event->getRequest()->setDefaultLocale($confLocale);
|
|
||||||
$event->getRequest()->setLocale($confLocale);
|
|
||||||
}
|
|
||||||
|
|
||||||
$languages = $app['locales.available'];
|
|
||||||
if ($event->getRequest()->cookies->has('locale')
|
|
||||||
&& isset($languages[$event->getRequest()->cookies->get('locale')])) {
|
|
||||||
$event->getRequest()->setLocale($event->getRequest()->cookies->get('locale'));
|
|
||||||
|
|
||||||
return $event->getRequest()->getLocale();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($event->getRequest()->cookies->has('locale')
|
||||||
|
&& isset($this->app['locales.available'][$event->getRequest()->cookies->get('locale')])) {
|
||||||
|
$event->getRequest()->setLocale($event->getRequest()->cookies->get('locale'));
|
||||||
|
} else {
|
||||||
foreach ($event->getRequest()->getLanguages() as $code) {
|
foreach ($event->getRequest()->getLanguages() as $code) {
|
||||||
$data = preg_split('/[-_]/', $code);
|
$data = preg_split('/[-_]/', $code);
|
||||||
if (in_array($data[0], array_keys($app['locales.available']), true)) {
|
if (in_array($data[0], array_keys($this->app['locales.available']), true)) {
|
||||||
$event->getRequest()->setLocale($data[0]);
|
$event->getRequest()->setLocale($data[0]);
|
||||||
$localeSet = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$event->getRequest()->getLocale()) {
|
$this->locale = $this->app['locale'] = $event->getRequest()->getLocale();
|
||||||
$event->getRequest()->setLocale($confLocale);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $event->getRequest()->getLocale();
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->locale = $this->app['locale'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLocaleCookie(FilterResponseEvent $event)
|
public function addLocaleCookie(FilterResponseEvent $event)
|
||||||
|
@@ -49,7 +49,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
|||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
'configfile' => $this->generateSphinxConf($app['phraseanet.appbox']->get_databoxes(), $configuration),
|
'configfile' => $this->generateSphinxConf($app['phraseanet.appbox']->get_databoxes(), $configuration),
|
||||||
'charsets' => $this->getAvailableCharsets(),
|
'charsets' => $this->getAvailableCharsets(),
|
||||||
'date_fields' => $this->RecordgetAvailableDateFields($app['phraseanet.appbox']->get_databoxes()),
|
'date_fields' => $this->getAvailableDateFields($app['phraseanet.appbox']->get_databoxes()),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $app['twig']->render('admin/search-engine/sphinx-search.html.twig', $params);
|
return $app['twig']->render('admin/search-engine/sphinx-search.html.twig', $params);
|
||||||
|
@@ -238,7 +238,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<form name="formpushdoc" action="{{ path('prod_tools_rotate') }}" method="post">
|
<form name="formpushdoc" action="{{ path('prod_tools_rotate') }}" method="post">
|
||||||
<fieldset style='border:1px solid #999;padding:20px;'>
|
<fieldset style='border:1px solid #999;padding:20px;'>
|
||||||
<legend style='color:#EEE'> <b>{% trans "image rotation" %}</b> </legend>
|
<legend style='color:#EEE'> <b>{{ "image rotation" | trans }}</b> </legend>
|
||||||
<label for="ROTA_90" class="radio">
|
<label for="ROTA_90" class="radio">
|
||||||
<input type="radio" name="rotation" id="ROTA_90" value="90" checked="checked">
|
<input type="radio" name="rotation" id="ROTA_90" value="90" checked="checked">
|
||||||
{{ "rotation 90 degres horaire" | trans }}
|
{{ "rotation 90 degres horaire" | trans }}
|
||||||
@@ -253,8 +253,8 @@
|
|||||||
<input type="hidden" name="cchd" value="" />
|
<input type="hidden" name="cchd" value="" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div style='text-align:right;padding-top:10px;'>
|
<div style='text-align:right;padding-top:10px;'>
|
||||||
<button class="action_submiter btn btn-inverse">{% trans "validate" %}</button>
|
<button class="action_submiter btn btn-inverse">{{ "validate"|trans }}</button>
|
||||||
<button class="action_cancel btn btn-inverse">{% trans "cancel" %}</button>
|
<button class="action_cancel btn btn-inverse">{{ "cancel"|trans }}</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -109,7 +109,7 @@ class ApplicationTest extends \PhraseanetTestCase
|
|||||||
public function testCookieLocale()
|
public function testCookieLocale()
|
||||||
{
|
{
|
||||||
foreach (array_keys(Application::getAvailableLanguages()) as $locale) {
|
foreach (array_keys(Application::getAvailableLanguages()) as $locale) {
|
||||||
$client = $this->getClientWithCookie( $this->getAppThatReturnLocale(), $locale);
|
$client = $this->getClientWithCookie($this->getAppThatReturnLocale(), $locale);
|
||||||
$client->request('GET', '/');
|
$client->request('GET', '/');
|
||||||
|
|
||||||
$this->assertEquals($locale, $client->getResponse()->getContent());
|
$this->assertEquals($locale, $client->getResponse()->getContent());
|
||||||
|
@@ -19,6 +19,11 @@ class XSendFileMappingGeneratorTest extends \PhraseanetTestCase
|
|||||||
->with('type')
|
->with('type')
|
||||||
->will($this->returnValue('nginx'));
|
->will($this->returnValue('nginx'));
|
||||||
|
|
||||||
|
$input->expects($this->any())
|
||||||
|
->method('getOption')
|
||||||
|
->with($this->isType('string'))
|
||||||
|
->will($this->returnValue($option));
|
||||||
|
|
||||||
$command = new XSendFileMappingGenerator();
|
$command = new XSendFileMappingGenerator();
|
||||||
|
|
||||||
self::$DI['cli']['monolog'] = self::$DI['cli']->share(function () {
|
self::$DI['cli']['monolog'] = self::$DI['cli']->share(function () {
|
||||||
|
@@ -903,7 +903,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setToken($this->userAccessToken);
|
$this->setToken($this->userAccessToken);
|
||||||
|
|
||||||
self::$DI['acl']->get(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
self::$DI['app']['acl']->get(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
||||||
'candwnldpreview' => 1,
|
'candwnldpreview' => 1,
|
||||||
'candwnldhd' => 1
|
'candwnldhd' => 1
|
||||||
));
|
));
|
||||||
@@ -939,14 +939,14 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testRecordsEmbedRouteNoHdRights()
|
public function testRecordsEmbedRouteNoHdRights()
|
||||||
{
|
{
|
||||||
$this->setToken(self::$token);
|
$this->setToken($this->userAccessToken);
|
||||||
|
|
||||||
self::$DI['acl']->get(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
self::$DI['app']['acl']->get(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
||||||
'candwnldpreview' => 1,
|
'candwnldpreview' => 1,
|
||||||
'candwnldhd' => 0
|
'candwnldhd' => 0
|
||||||
));
|
));
|
||||||
|
|
||||||
$route = '/api/v1/records/' . $this->record->get_sbas_id() . '/' . $this->record->get_record_id() . '/embed/';
|
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
|
||||||
|
|
||||||
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
|
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
@@ -963,14 +963,14 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testRecordsEmbedRouteNoPreviewAndHdRights()
|
public function testRecordsEmbedRouteNoPreviewAndHdRights()
|
||||||
{
|
{
|
||||||
$this->setToken(self::$token);
|
$this->setToken($this->userAccessToken);
|
||||||
|
|
||||||
self::$DI['user_notAdmin']->ACL()->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
self::$DI['app']['acl']->get(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
||||||
'candwnldpreview' => 0,
|
'candwnldpreview' => 0,
|
||||||
'candwnldhd' => 0
|
'candwnldhd' => 0
|
||||||
));
|
));
|
||||||
|
|
||||||
$route = '/api/v1/records/' . $this->record->get_sbas_id() . '/' . $this->record->get_record_id() . '/embed/';
|
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
|
||||||
|
|
||||||
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
|
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
|
@@ -103,9 +103,6 @@ class SetupTest extends \PhraseanetWebTestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$user = $this->createUserMock();
|
$user = $this->createUserMock();
|
||||||
$user->expects($this->once())
|
|
||||||
->method('getId')
|
|
||||||
->will($this->returnValue(self::$DI['user']->getId()));
|
|
||||||
|
|
||||||
$this->app['phraseanet.installer']->expects($this->once())
|
$this->app['phraseanet.installer']->expects($this->once())
|
||||||
->method('install')
|
->method('install')
|
||||||
|
@@ -30,7 +30,6 @@ main:
|
|||||||
options: []
|
options: []
|
||||||
task-manager:
|
task-manager:
|
||||||
status: started
|
status: started
|
||||||
enabled: started
|
|
||||||
enabled: true
|
enabled: true
|
||||||
logger:
|
logger:
|
||||||
max-files: 10
|
max-files: 10
|
||||||
|
@@ -108,6 +108,9 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetTestCase
|
|||||||
$app['debug'] = true;
|
$app['debug'] = true;
|
||||||
$app->register(new LocaleServiceProvider());
|
$app->register(new LocaleServiceProvider());
|
||||||
$app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
|
$app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
|
||||||
|
$app['configuration.store']->expects($this->any())
|
||||||
|
->method('isSetup')
|
||||||
|
->will($this->returnValue(true));
|
||||||
$app['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess')
|
$app['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
@@ -125,7 +128,17 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetTestCase
|
|||||||
{
|
{
|
||||||
$app['conf']->expects($this->any())
|
$app['conf']->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue($locale));
|
->will($this->returnCallback(function ($param) use ($locale) {
|
||||||
|
|
||||||
|
switch ($param) {
|
||||||
|
case ['languages', 'default']:
|
||||||
|
return $locale;
|
||||||
|
break;
|
||||||
|
case ['languages', 'available']:
|
||||||
|
return [];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClientWithCookie(Application $app, $locale = 'fr')
|
private function getClientWithCookie(Application $app, $locale = 'fr')
|
||||||
|
Reference in New Issue
Block a user