mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
Fix latest merge
This commit is contained in:
@@ -66,10 +66,16 @@ class Datafiles extends AbstractDelivery
|
|||||||
$watermark = !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark');
|
$watermark = !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark');
|
||||||
|
|
||||||
if ($watermark && !$all_access) {
|
if ($watermark && !$all_access) {
|
||||||
$subdef_class = $databox
|
$subdef_class = null;
|
||||||
->get_subdef_structure()
|
try {
|
||||||
->get_subdef($record->get_type(), $subdef)
|
$subdef_class = $databox
|
||||||
->get_class();
|
->get_subdef_structure()
|
||||||
|
->get_subdef($record->get_type(), $subdef)
|
||||||
|
->get_class();
|
||||||
|
} catch(\Exception_Databox_SubdefNotFound $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) {
|
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) {
|
||||||
$watermark = false;
|
$watermark = false;
|
||||||
@@ -79,11 +85,8 @@ class Datafiles extends AbstractDelivery
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($watermark && !$all_access) {
|
if ($watermark && !$all_access) {
|
||||||
|
|
||||||
$repository = $app['repo.basket-elements'];
|
$repository = $app['repo.basket-elements'];
|
||||||
|
|
||||||
/* @var $repository BasketElementRepository */
|
|
||||||
|
|
||||||
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $app['authentication']->getUser());
|
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $app['authentication']->getUser());
|
||||||
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $app['authentication']->getUser());
|
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $app['authentication']->getUser());
|
||||||
|
|
||||||
|
@@ -146,6 +146,7 @@ class Order implements ControllerProviderInterface
|
|||||||
'order_id' => $order->getId(),
|
'order_id' => $order->getId(),
|
||||||
'usr_id' => $order->getUser()->getId()
|
'usr_id' => $order->getUser()->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
$app['EM']->persist($order);
|
$app['EM']->persist($order);
|
||||||
|
@@ -221,7 +221,7 @@ class Push implements ControllerProviderInterface
|
|||||||
'basket' => $Basket->getId(),
|
'basket' => $Basket->getId(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$app['conf']->get(['registry', 'actions', 'force-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, $user_receiver);
|
$arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ class Push implements ControllerProviderInterface
|
|||||||
'basket' => $Basket->getId(),
|
'basket' => $Basket->getId(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$app['conf']->get(['registry', 'actions', 'force-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, $participant_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -110,7 +110,8 @@ class RegistryManipulator
|
|||||||
'export-title-choice' => false,
|
'export-title-choice' => false,
|
||||||
'default-export-title' => 'title',
|
'default-export-title' => 'title',
|
||||||
'social-tools' => 'none',
|
'social-tools' => 'none',
|
||||||
'force-authentication' => false,
|
'enable-push-authentication' => false,
|
||||||
|
'force-push-authentication' => false,
|
||||||
],
|
],
|
||||||
'ftp' => [
|
'ftp' => [
|
||||||
'ftp-enabled' => false,
|
'ftp-enabled' => false,
|
||||||
|
@@ -47,7 +47,7 @@ class ActionsFormType extends AbstractType
|
|||||||
'label' => 'Enable this setting to share on Facebook and Twitter',
|
'label' => 'Enable this setting to share on Facebook and Twitter',
|
||||||
'choices' => ['none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Enabled'],
|
'choices' => ['none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Enabled'],
|
||||||
]);
|
]);
|
||||||
$builder->add('force-authentication', 'checkbox', [
|
$builder->add('enable-push-authentication', 'checkbox', [
|
||||||
'label' => 'Enable Forcing authentication to see push content',
|
'label' => 'Enable Forcing authentication to see push content',
|
||||||
'help_message' => 'Adds an option to the push form submission to restrict push recipient(s) to Phraseanet users only.',
|
'help_message' => 'Adds an option to the push form submission to restrict push recipient(s) to Phraseanet users only.',
|
||||||
]);
|
]);
|
||||||
|
@@ -664,20 +664,24 @@ class databox extends base
|
|||||||
try {
|
try {
|
||||||
$metaStructData = $this->get_data_from_cache(self::CACHE_META_STRUCT);
|
$metaStructData = $this->get_data_from_cache(self::CACHE_META_STRUCT);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$sql = 'SELECT id, name FROM metadatas_structure ORDER BY sorter ASC';
|
$sql = 'SELECT id, `name` FROM metadatas_structure ORDER BY sorter ASC';
|
||||||
$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();
|
||||||
|
|
||||||
$metaStructData = $rs;
|
if ($rs) {
|
||||||
$this->set_data_to_cache($metaStructData, self::CACHE_META_STRUCT);
|
$metaStructData = $rs;
|
||||||
|
$this->set_data_to_cache($metaStructData, self::CACHE_META_STRUCT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->meta_struct = new databox_descriptionStructure();
|
$this->meta_struct = new databox_descriptionStructure();
|
||||||
|
|
||||||
foreach ($metaStructData as $row) {
|
if ($metaStructData) {
|
||||||
$this->meta_struct->add_element(databox_field::get_instance($this->app, $this, $row['id']));
|
foreach ($metaStructData as $row) {
|
||||||
|
$this->meta_struct->add_element(databox_field::get_instance($this->app, $this, $row['id']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->meta_struct;
|
return $this->meta_struct;
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
{% if app['acl'].get(app['authentication'].getUser()).has_right('modifyrecord') %}
|
{% if app['acl'].get(app['authentication'].getUser()).has_right('modifyrecord') %}
|
||||||
<div title="" class="context-menu-item menu3-custom-item">
|
<div title="" class="context-menu-item menu3-custom-item">
|
||||||
<div onclick="editThis('SSTT','{{basket.getId()}}');" style=""
|
<div onclick="editThis('SSTT','{{basket.getId()}}');" style=""
|
||||||
class="context-menu-item-inner">{% trans 'action::editer' %}
|
class="context-menu-item-inner">{{ 'edit' | trans }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
onclick="downloadThis('lst={{story.getRecord(app).get_serialize_key()}}');">{{ 'action::exporter' | trans }}
|
onclick="downloadThis('lst={{story.getRecord(app).get_serialize_key()}}');">{{ 'action::exporter' | trans }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if app['authentication'].getUser().ACL().has_right('modifyrecord') %}
|
{% if app['acl'].get(app['authentication'].getUser()).has_right('modifyrecord') %}
|
||||||
<div title="" class="context-menu-item menu3-custom-item">
|
<div title="" class="context-menu-item menu3-custom-item">
|
||||||
<div onclick="editThis('IMGT','{{story.getRecord(app).get_serialize_key()}}');" style=""
|
<div onclick="editThis('IMGT','{{story.getRecord(app).get_serialize_key()}}');" style=""
|
||||||
class="context-menu-item-inner">{{ 'action::editer' | trans }}
|
class="context-menu-item-inner">{{ 'action::editer' | trans }}
|
||||||
|
@@ -91,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
<form name="download" action="{{ path('document_download', {'token': token, 'type': type, 'anonymous': anonymous}) }}" method="post" target="file_frame">
|
<form name="download" action="{{ path('document_download', {'token': token.getValue(), 'type': type, 'anonymous': anonymous}) }}" method="post" target="file_frame">
|
||||||
{% if anonymous %}
|
{% if anonymous %}
|
||||||
<input type="hidden" name="anonymous" value="1" />
|
<input type="hidden" name="anonymous" value="1" />
|
||||||
{% endif%}
|
{% endif%}
|
||||||
|
@@ -9,10 +9,28 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
public function testDatafilesRouteAuthenticated()
|
public function testDatafilesRouteAuthenticated()
|
||||||
{
|
{
|
||||||
|
$subdef = 'preview';
|
||||||
|
$acl = $this->getMockBuilder('ACL')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_access_to_subdef')
|
||||||
|
->with($this->isInstanceOf('\record_adapter'), $this->equalTo($subdef))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$aclProvider->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($acl));
|
||||||
|
|
||||||
|
self::$DI['app']['acl'] = $aclProvider;
|
||||||
|
|
||||||
$path = self::$DI['app']['url_generator']->generate('datafile', array(
|
$path = self::$DI['app']['url_generator']->generate('datafile', array(
|
||||||
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
|
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
|
||||||
'record_id' => self::$DI['record_1']->get_record_id(),
|
'record_id' => self::$DI['record_1']->get_record_id(),
|
||||||
'subdef' => 'preview',
|
'subdef' => $subdef,
|
||||||
));
|
));
|
||||||
|
|
||||||
self::$DI['client']->request('GET', $path);
|
self::$DI['client']->request('GET', $path);
|
||||||
@@ -38,6 +56,23 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
public function testEtag()
|
public function testEtag()
|
||||||
{
|
{
|
||||||
|
$acl = $this->getMockBuilder('ACL')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_access_to_subdef')
|
||||||
|
->with($this->isInstanceOf('\record_adapter'), $this->isType('string'))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$aclProvider->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($acl));
|
||||||
|
|
||||||
|
self::$DI['app']['acl'] = $aclProvider;
|
||||||
|
|
||||||
$path = self::$DI['app']['url_generator']->generate('datafile', array(
|
$path = self::$DI['app']['url_generator']->generate('datafile', array(
|
||||||
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
|
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
|
||||||
'record_id' => self::$DI['record_1']->get_record_id(),
|
'record_id' => self::$DI['record_1']->get_record_id(),
|
||||||
|
@@ -593,6 +593,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetWatermarkBadRequest()
|
public function testSetWatermarkBadRequest()
|
||||||
{
|
{
|
||||||
|
$this->setAdmin(true);
|
||||||
|
|
||||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/');
|
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/');
|
||||||
|
|
||||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||||
|
@@ -48,12 +48,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr');
|
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr');
|
||||||
|
|
||||||
|
self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), array(self::$DI['collection']->get_base_id()), true);
|
||||||
|
|
||||||
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
|
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
|
||||||
'users' => $user->getId(),
|
'users' => $user->getId(),
|
||||||
'values' => 'canreport_' . self::$DI['collection']->get_base_id() . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1',
|
'values' => 'canreport_' . self::$DI['collection']->get_base_id() . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1',
|
||||||
'user_infos' => ['email' => 'toto@toto.fr' ]
|
'user_infos' => ['email' => 'toto@toto.fr' ]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
$response = self::$DI['client']->getResponse();
|
||||||
$this->assertTrue($response->isOK());
|
$this->assertTrue($response->isOK());
|
||||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||||
|
@@ -238,7 +238,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
;
|
;
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
$email = $this->generateEmail();
|
$email = $this->generateEmail();
|
||||||
$user = self::$DI['app']['manipulator.user']->createUser('test', 'test', $email);
|
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('test_'), uniqid('test_'), $email);
|
||||||
$token = self::$DI['app']['manipulator.token']->createResetEmailToken($user, $email);
|
$token = self::$DI['app']['manipulator.token']->createResetEmailToken($user, $email);
|
||||||
|
|
||||||
$user->setMailLocked(true);
|
$user->setMailLocked(true);
|
||||||
|
@@ -527,7 +527,7 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
public static function giveRightsToUser(Application $app, User $user, $base_ids = null)
|
public static function giveRightsToUser(Application $app, User $user, $base_ids = null, $force = false)
|
||||||
{
|
{
|
||||||
$app['acl']->get($user)->delete_data_from_cache(\ACL::CACHE_GLOBAL_RIGHTS);
|
$app['acl']->get($user)->delete_data_from_cache(\ACL::CACHE_GLOBAL_RIGHTS);
|
||||||
$app['acl']->get($user)->give_access_to_sbas(array_keys($app['phraseanet.appbox']->get_databoxes()));
|
$app['acl']->get($user)->give_access_to_sbas(array_keys($app['phraseanet.appbox']->get_databoxes()));
|
||||||
@@ -553,7 +553,7 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
|
|
||||||
$app['acl']->get($user)->delete_data_from_cache(\ACL::CACHE_RIGHTS_BAS);
|
$app['acl']->get($user)->delete_data_from_cache(\ACL::CACHE_RIGHTS_BAS);
|
||||||
|
|
||||||
if ($app['acl']->get($user)->has_access_to_base($base_id)) {
|
if ($app['acl']->get($user)->has_access_to_base($base_id) && false === $force) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,34 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetExport()
|
public function testSetExport()
|
||||||
{
|
{
|
||||||
self::$DI['app']['acl']->get( self::$DI['app']['authentication']->getUser())->update_rights_to_base(self::$DI['record_1']->get_base_id(), ['order_master' => true]);
|
$acl = $this->getMockBuilder('ACL')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_right')
|
||||||
|
->with($this->equalTo('order'))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_access_to_record')
|
||||||
|
->with($this->isInstanceOf('\record_adapter'))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_right_on_base')
|
||||||
|
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo('cancmd'))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
$acl->expects($this->any())
|
||||||
|
->method('has_right_on_sbas')
|
||||||
|
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo('cancmd'))
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$aclProvider->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($acl));
|
||||||
|
|
||||||
|
self::$DI['app']['acl'] = $aclProvider;
|
||||||
|
|
||||||
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker')
|
$eventManagerStub = $this->getMockBuilder('\eventsmanager_broker')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@@ -49,7 +76,7 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
|
|
||||||
self::$DI['app']['events-manager'] = $eventManagerStub;
|
self::$DI['app']['events-manager'] = $eventManagerStub;
|
||||||
|
|
||||||
self::$DI['client']->request('POST', '/prod/order/', [
|
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'
|
||||||
]);
|
]);
|
||||||
|
Reference in New Issue
Block a user