Fix latest merge

This commit is contained in:
Nicolas Le Goff
2014-07-17 15:11:26 +02:00
parent 3565d1c795
commit fcdc10c554
14 changed files with 100 additions and 26 deletions

View File

@@ -66,10 +66,16 @@ class Datafiles extends AbstractDelivery
$watermark = !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark');
if ($watermark && !$all_access) {
$subdef_class = null;
try {
$subdef_class = $databox
->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)) {
$watermark = false;
@@ -79,11 +85,8 @@ class Datafiles extends AbstractDelivery
}
if ($watermark && !$all_access) {
$repository = $app['repo.basket-elements'];
/* @var $repository BasketElementRepository */
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $app['authentication']->getUser());
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $app['authentication']->getUser());

View File

@@ -146,6 +146,7 @@ class Order implements ControllerProviderInterface
'order_id' => $order->getId(),
'usr_id' => $order->getUser()->getId()
]);
$success = true;
$app['EM']->persist($order);

View File

@@ -221,7 +221,7 @@ class Push implements ControllerProviderInterface
'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);
}
@@ -416,7 +416,7 @@ class Push implements ControllerProviderInterface
'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);
}

View File

@@ -110,7 +110,8 @@ class RegistryManipulator
'export-title-choice' => false,
'default-export-title' => 'title',
'social-tools' => 'none',
'force-authentication' => false,
'enable-push-authentication' => false,
'force-push-authentication' => false,
],
'ftp' => [
'ftp-enabled' => false,

View File

@@ -47,7 +47,7 @@ class ActionsFormType extends AbstractType
'label' => 'Enable this setting to share on Facebook and Twitter',
'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',
'help_message' => 'Adds an option to the push form submission to restrict push recipient(s) to Phraseanet users only.',
]);

View File

@@ -664,21 +664,25 @@ class databox extends base
try {
$metaStructData = $this->get_data_from_cache(self::CACHE_META_STRUCT);
} 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->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ($rs) {
$metaStructData = $rs;
$this->set_data_to_cache($metaStructData, self::CACHE_META_STRUCT);
}
}
$this->meta_struct = new databox_descriptionStructure();
if ($metaStructData) {
foreach ($metaStructData as $row) {
$this->meta_struct->add_element(databox_field::get_instance($this->app, $this, $row['id']));
}
}
return $this->meta_struct;
}

View File

@@ -48,7 +48,7 @@
{% if app['acl'].get(app['authentication'].getUser()).has_right('modifyrecord') %}
<div title="" class="context-menu-item menu3-custom-item">
<div onclick="editThis('SSTT','{{basket.getId()}}');" style=""
class="context-menu-item-inner">{% trans 'action::editer' %}
class="context-menu-item-inner">{{ 'edit' | trans }}
</div>
</div>
{% endif %}
@@ -219,7 +219,7 @@
onclick="downloadThis('lst={{story.getRecord(app).get_serialize_key()}}');">{{ 'action::exporter' | trans }}
</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 onclick="editThis('IMGT','{{story.getRecord(app).get_serialize_key()}}');" style=""
class="context-menu-item-inner">{{ 'action::editer' | trans }}

View File

@@ -91,7 +91,7 @@
</div>
<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 %}
<input type="hidden" name="anonymous" value="1" />
{% endif%}

View File

@@ -9,10 +9,28 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{
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(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
'subdef' => $subdef,
));
self::$DI['client']->request('GET', $path);
@@ -38,6 +56,23 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
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(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),

View File

@@ -593,6 +593,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
*/
public function testSetWatermarkBadRequest()
{
$this->setAdmin(true);
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/');
$this->assertBadResponse(self::$DI['client']->getResponse());

View File

@@ -48,12 +48,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$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/', [
'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',
'user_infos' => ['email' => 'toto@toto.fr' ]
]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));

View File

@@ -238,7 +238,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
;
$this->logout(self::$DI['app']);
$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);
$user->setMailLocked(true);

View File

@@ -527,7 +527,7 @@ abstract class PhraseanetTestCase extends WebTestCase
*
* @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)->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);
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;
}

View File

@@ -36,7 +36,34 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
*/
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')
->disableOriginalConstructor()
@@ -49,7 +76,7 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
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(),
'deadline' => '+10 minutes'
]);