Merge remote-tracking branch 'upstream/master' into 20150306-elastic-indexer

Conflicts:
	bin/console
	bower.json
	composer.json
	composer.lock
	lib/Alchemy/Phrasea/Application.php
	lib/Alchemy/Phrasea/Border/Manager.php
	lib/Alchemy/Phrasea/Controller/Api/V1.php
	lib/Alchemy/Phrasea/Core/PhraseaEvents.php
	lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php
	lib/classes/caption/field.php
	lib/classes/record/Interface.php
	templates/web/prod/index.html.twig
	www/skins/prod/000000/prodcolor.css
This commit is contained in:
Nicolas Le Goff
2015-03-06 14:35:29 +01:00
committed by Mathieu Darse
1078 changed files with 7964 additions and 16363 deletions

View File

@@ -95,13 +95,13 @@ class BasketController implements ControllerProviderInterface
{
if ($basket->getIsRead() === false) {
$basket->setIsRead(true);
$app['EM']->flush();
$app['orm.em']->flush();
}
if ($basket->getValidation()) {
if ($basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsAware() === false) {
$basket->getValidation()->getParticipant($app['authentication']->getUser())->setIsAware(true);
$app['EM']->flush();
$app['orm.em']->flush();
}
}
@@ -121,7 +121,7 @@ class BasketController implements ControllerProviderInterface
$Basket->setUser($app['authentication']->getUser());
$Basket->setDescription($request->request->get('desc'));
$app['EM']->persist($Basket);
$app['orm.em']->persist($Basket);
$n = 0;
@@ -136,14 +136,14 @@ class BasketController implements ControllerProviderInterface
$basket_element->setRecord($record);
$basket_element->setBasket($Basket);
$app['EM']->persist($basket_element);
$app['orm.em']->persist($basket_element);
$Basket->addElement($basket_element);
$n++;
}
$app['EM']->flush();
$app['orm.em']->flush();
if ($request->getRequestFormat() === 'json') {
$data = [
@@ -162,8 +162,8 @@ class BasketController implements ControllerProviderInterface
public function deleteBasket(Application $app, Request $request, BasketEntity $basket)
{
$app['EM']->remove($basket);
$app['EM']->flush();
$app['orm.em']->remove($basket);
$app['orm.em']->flush();
$data = [
'success' => true
@@ -179,7 +179,7 @@ class BasketController implements ControllerProviderInterface
public function removeBasketElement(Application $app, Request $request, BasketEntity $basket, $basket_element_id)
{
$basketElement = $app['EM']->getRepository('Phraseanet:BasketElement')->find($basket_element_id);
$basketElement = $app['orm.em']->getRepository('Phraseanet:BasketElement')->find($basket_element_id);
$ord = $basketElement->getOrd();
foreach ($basket->getElements() as $basket_element) {
@@ -188,12 +188,12 @@ class BasketController implements ControllerProviderInterface
}
if ($basket_element->getId() === (int) $basket_element_id) {
$basket->removeElement($basket_element);
$app['EM']->remove($basket_element);
$app['orm.em']->remove($basket_element);
}
}
$app['EM']->persist($basket);
$app['EM']->flush();
$app['orm.em']->persist($basket);
$app['orm.em']->flush();
$data = ['success' => true, 'message' => $app->trans('Record removed from basket')];
@@ -212,8 +212,8 @@ class BasketController implements ControllerProviderInterface
$basket->setName($request->request->get('name', ''));
$basket->setDescription($request->request->get('description'));
$app['EM']->merge($basket);
$app['EM']->flush();
$app['orm.em']->merge($basket);
$app['orm.em']->flush();
$success = true;
$msg = $app->trans('Basket has been updated');
@@ -259,11 +259,11 @@ class BasketController implements ControllerProviderInterface
if (isset($order[$basketElement->getId()])) {
$basketElement->setOrd($order[$basketElement->getId()]);
$app['EM']->merge($basketElement);
$app['orm.em']->merge($basketElement);
}
}
$app['EM']->flush();
$app['orm.em']->flush();
$ret = ['success' => true, 'message' => $app->trans('Basket updated')];
} catch (\Exception $e) {
@@ -278,8 +278,8 @@ class BasketController implements ControllerProviderInterface
$basket->setArchived($archive_status);
$app['EM']->merge($basket);
$app['EM']->flush();
$app['orm.em']->merge($basket);
$app['orm.em']->flush();
if ($archive_status) {
$message = $app->trans('Basket has been archived');
@@ -314,7 +314,7 @@ class BasketController implements ControllerProviderInterface
$basket_element->setRecord($record);
$basket_element->setBasket($basket);
$app['EM']->persist($basket_element);
$app['orm.em']->persist($basket_element);
$basket->addElement($basket_element);
@@ -327,14 +327,14 @@ class BasketController implements ControllerProviderInterface
$validationData->setParticipant($participant);
$validationData->setBasketElement($basket_element);
$app['EM']->persist($validationData);
$app['orm.em']->persist($validationData);
}
}
$n++;
}
$app['EM']->flush();
$app['orm.em']->flush();
$data = [
'success' => true
@@ -365,7 +365,7 @@ class BasketController implements ControllerProviderInterface
$n++;
}
$app['EM']->flush();
$app['orm.em']->flush();
$data = ['success' => true, 'message' => $app->trans('%quantity% records moved', ['%quantity%' => $n])];

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -180,12 +180,19 @@ class DoDownload implements ControllerProviderInterface
$app['session']->save();
ignore_user_abort(true);
\set_export::build_zip(
$app,
$token,
$list,
sprintf($app['tmp.download.path'].'/%s.zip', $token->getValue()) // Dest file
);
if ($list['count'] > 1) {
\set_export::build_zip(
$app,
$token,
$list,
sprintf($app['tmp.download.path'].'/%s.zip', $token->getValue()) // Dest file
);
} else {
$list['complete'] = true;
$token->setData(serialize($list));
$app['orm.em']->persist($token);
$app['orm.em']->flush();
}
return $app->json([
'success' => true,

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Core\Event\RecordEdit;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Metadata\Tag\TfEditdate;
@@ -292,6 +294,7 @@ class Edit implements ControllerProviderInterface
$media = $app['mediavorus']->guess($value->get_pathfile());
$app['subdef.substituer']->substitute($reg_record, $name, $media);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($reg_record));
$app['phraseanet.logger']($reg_record->get_databox())->log(
$reg_record,
\Session_Logger::EVENT_SUBSTITUTE,
@@ -311,15 +314,6 @@ class Edit implements ControllerProviderInterface
$databoxes = $records->databoxes();
$databox = array_pop($databoxes);
$meta_struct = $databox->get_meta_structure();
$write_edit_el = false;
$date_obj = new \DateTime();
foreach ($meta_struct->get_elements() as $meta_struct_el) {
if ($meta_struct_el->get_tag() instanceof TfEditdate) {
$write_edit_el = $meta_struct_el;
}
}
$elements = $records->toArray();
foreach ($request->request->get('mds') as $rec) {
@@ -346,31 +340,7 @@ class Edit implements ControllerProviderInterface
if (isset($rec['metadatas']) && is_array($rec['metadatas'])) {
$record->set_metadatas($rec['metadatas']);
}
/**
* todo : this should not work
*/
if ($write_edit_el instanceof \databox_field) {
$fields = $record->get_caption()->get_fields([$write_edit_el->get_name()], true);
$field = array_pop($fields);
$meta_id = null;
if ($field && !$field->is_multi()) {
$values = $field->get_values();
$meta_id = array_pop($values)->getId();
}
$metas = [
[
'meta_struct_id' => $write_edit_el->get_id(),
'meta_id' => $meta_id,
'value' => $date_obj->format('Y-m-d h:i:s'),
]
];
$record->set_metadatas($metas, true);
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($record));
}
$newstat = $record->get_status();

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -91,6 +91,8 @@ class Export implements ControllerProviderInterface
}
$success = false;
$msg = _('Error while connecting to FTP');
try {
$ftpClient = $app['phraseanet.ftp.client']($request->request->get('address', ''), 21, 90, !!$request->request->get('ssl'));
$ftpClient->login($request->request->get('login', 'anonymous'), $request->request->get('password', 'anonymous'));
@@ -98,7 +100,6 @@ class Export implements ControllerProviderInterface
$msg = $app->trans('Connection to FTP succeed');
$success = true;
} catch (\Exception $e) {
$msg = $app->trans('Error while connecting to FTP');
}
return $app->json([

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -78,12 +78,12 @@ class Feed implements ControllerProviderInterface
->setRecordId($record->get_record_id())
->setSbasId($record->get_sbas_id());
$entry->addItem($item);
$app['EM']->persist($item);
$app['orm.em']->persist($item);
}
$app['EM']->persist($entry);
$app['EM']->persist($feed);
$app['EM']->flush();
$app['orm.em']->persist($entry);
$app['orm.em']->persist($feed);
$app['orm.em']->flush();
$app['dispatcher']->dispatch(PhraseaEvents::FEED_ENTRY_CREATE, new FeedEntryEvent($entry, $request->request->get('notify')));
@@ -159,11 +159,11 @@ class Feed implements ControllerProviderInterface
}
$item = $app['repo.feed-items']->find($item_sort_datas[0]);
$item->setOrd($item_sort_datas[1]);
$app['EM']->persist($item);
$app['orm.em']->persist($item);
}
$app['EM']->persist($entry);
$app['EM']->flush();
$app['orm.em']->persist($entry);
$app['orm.em']->flush();
return $app->json([
'error' => false,
@@ -190,8 +190,8 @@ class Feed implements ControllerProviderInterface
$app->abort(403, $app->trans('Action Forbidden : You are not the publisher'));
}
$app['EM']->remove($entry);
$app['EM']->flush();
$app['orm.em']->remove($entry);
$app['orm.em']->flush();
return $app->json(['error' => false, 'message' => 'succes']);
})
@@ -209,7 +209,7 @@ class Feed implements ControllerProviderInterface
$datas = $app['twig']->render('prod/results/feeds.html.twig', [
'feeds' => $feeds,
'feed' => new Aggregate($app['EM'], $feeds),
'feed' => new Aggregate($app['orm.em'], $feeds),
'page' => $page
]);
@@ -238,7 +238,7 @@ class Feed implements ControllerProviderInterface
$feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($app['authentication']->getUser()));
$link = $app['feed.aggregate-link-generator']->generate(new Aggregate($app['EM'], $feeds),
$link = $app['feed.aggregate-link-generator']->generate(new Aggregate($app['orm.em'], $feeds),
$app['authentication']->getUser(),
AggregateLinkGenerator::FORMAT_RSS,
null, $renew

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -242,8 +242,8 @@ class Lazaret implements ControllerProviderInterface
}
//Delete lazaret file
$app['EM']->remove($lazaretFile);
$app['EM']->flush();
$app['orm.em']->remove($lazaretFile);
$app['orm.em']->flush();
$ret['success'] = true;
} catch (\Exception $e) {
@@ -295,8 +295,8 @@ class Lazaret implements ControllerProviderInterface
$lazaretFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getFilename();
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
$app['EM']->remove($lazaretFile);
$app['EM']->flush();
$app['orm.em']->remove($lazaretFile);
$app['orm.em']->flush();
try {
$app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]);
@@ -317,22 +317,58 @@ class Lazaret implements ControllerProviderInterface
*/
public function emptyLazaret(Application $app, Request $request)
{
$ret = ['success' => false, 'message' => '', 'result' => []];
$ret = array(
'success' => false,
'message' => '',
'result' => array(
'tobedone' => 0,
'done' => 0,
'todo' => 0,
'max' => '',
)
);
$lazaretFiles = $app['repo.lazaret-files']->findAll();
$maxTodo = -1; // all
if($request->get('max') !== null) {
$maxTodo = (int)($request->get('max'));
$ret['result']['max'] = $maxTodo;
if( $maxTodo <= 0) {
$maxTodo = -1; // all
}
}
$ret['result']['max'] = $maxTodo;
$app['EM']->beginTransaction();
$repo = $app['repo.lazaret-files'];
$ret['result']['tobedone'] = $repo->createQueryBuilder('id')
->select('COUNT(id)')
->getQuery()
->getSingleScalarResult();
if($maxTodo == -1) {
// all
$lazaretFiles = $repo->findAll();
}
else {
// limit maxTodo
$lazaretFiles = $repo->findBy(array(), null, $maxTodo);
}
$app['orm.em']->beginTransaction();
try {
foreach ($lazaretFiles as $lazaretFile) {
$this->denyLazaretFile($app, $lazaretFile);
$ret['result']['done']++;
}
$app['EM']->commit();
$app['orm.em']->commit();
$ret['success'] = true;
} catch (\Exception $e) {
$app['EM']->rollback();
$app['orm.em']->rollback();
$ret['message'] = $app->trans('An error occured');
}
$ret['result']['todo'] = $ret['result']['tobedone'] - $ret['result']['done'];
return $app->json($ret);
}
@@ -400,8 +436,8 @@ class Lazaret implements ControllerProviderInterface
);
//Delete lazaret file
$app['EM']->remove($lazaretFile);
$app['EM']->flush();
$app['orm.em']->remove($lazaretFile);
$app['orm.em']->flush();
$ret['success'] = true;
} catch (\Exception $e) {
@@ -437,6 +473,6 @@ class Lazaret implements ControllerProviderInterface
$lazaretThumbFileName = $app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();
return $app['phraseanet.file-serve']->deliverFile($lazaretThumbFileName, $lazaretFile->getOriginalName(), DeliverDataInterface::DISPOSITION_INLINE, 'image/jpeg', 3600);
return $app['phraseanet.file-serve']->deliverFile($lazaretThumbFileName, $lazaretFile->getOriginalName(), DeliverDataInterface::DISPOSITION_INLINE, 'image/jpeg');
}
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -124,7 +124,7 @@ class Order implements ControllerProviderInterface
$orderElement->setOrder($order);
$orderElement->setBaseId($record->get_base_id());
$orderElement->setRecordId($record->get_record_id());
$app['EM']->persist($orderElement);
$app['orm.em']->persist($orderElement);
}
}
@@ -145,8 +145,8 @@ class Order implements ControllerProviderInterface
try {
$app['dispatcher']->dispatch(PhraseaEvents::ORDER_CREATE, new OrderEvent($order));
$app['EM']->persist($order);
$app['EM']->flush();
$app['orm.em']->persist($order);
$app['orm.em']->flush();
$msg = $app->trans('The records have been properly ordered');
$success = true;
} catch (\Exception $e) {
@@ -242,8 +242,8 @@ class Order implements ControllerProviderInterface
$basket->setUser($order->getUser());
$basket->setPusher($app['authentication']->getUser());
$app['EM']->persist($basket);
$app['EM']->flush();
$app['orm.em']->persist($basket);
$app['orm.em']->flush();
}
$n = 0;
@@ -275,10 +275,10 @@ class Order implements ControllerProviderInterface
}
$success = true;
$app['EM']->persist($basket);
$app['EM']->persist($orderElement);
$app['EM']->persist($order);
$app['EM']->flush();
$app['orm.em']->persist($basket);
$app['orm.em']->persist($orderElement);
$app['orm.em']->persist($order);
$app['orm.em']->flush();
} catch (\Exception $e) {
}
@@ -320,7 +320,7 @@ class Order implements ControllerProviderInterface
$orderElement->setOrderMaster($app['authentication']->getUser());
$orderElement->setDeny(true);
$app['EM']->persist($orderElement);
$app['orm.em']->persist($orderElement);
$n++;
}
}
@@ -332,8 +332,8 @@ class Order implements ControllerProviderInterface
}
$success = true;
$app['EM']->persist($order);
$app['EM']->flush();
$app['orm.em']->persist($order);
$app['orm.em']->flush();
} catch (\Exception $e) {
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -187,16 +187,23 @@ class Property implements ControllerProviderInterface
{
$typeLst = $request->request->get('types', []);
$records = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']);
$mimeLst = $request->request->get('mimes', []);
$forceType = $request->request->get('force_types', '');
$updated = [];
foreach ($records as $record) {
try {
$recordType = !empty($forceType) ? $forceType : (isset($typeLst[$record->get_serialize_key()]) ? $typeLst[$record->get_serialize_key()] : null);
$mimeType = isset($mimeLst[$record->get_serialize_key()]) ? $mimeLst[$record->get_serialize_key()] : null;
if ($recordType) {
$record->set_type($recordType);
$updated[$record->get_serialize_key()] = $recordType;
$updated[$record->get_serialize_key()]['record_type'] = $recordType;
}
if ($mimeType) {
$record->set_mime($mimeType);
$updated[$record->get_serialize_key()]['mime_type'] = $mimeType;
}
} catch (\Exception $e) {

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -192,14 +192,14 @@ class Push implements ControllerProviderInterface
$Basket->setPusher($app['authentication']->getUser());
$Basket->setIsRead(false);
$app['EM']->persist($Basket);
$app['orm.em']->persist($Basket);
foreach ($pusher->get_elements() as $element) {
$BasketElement = new BasketElement();
$BasketElement->setRecord($element);
$BasketElement->setBasket($Basket);
$app['EM']->persist($BasketElement);
$app['orm.em']->persist($BasketElement);
$Basket->addElement($BasketElement);
@@ -218,7 +218,7 @@ class Push implements ControllerProviderInterface
}
}
$app['EM']->flush();
$app['orm.em']->flush();
$arguments = [
'basket' => $Basket->getId(),
@@ -238,7 +238,7 @@ class Push implements ControllerProviderInterface
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
->log($BasketElement->getRecord($app), \Session_Logger::EVENT_VALIDATE, $user_receiver->getId(), '');
$app['EM']->flush();
$app['orm.em']->flush();
$message = $app->trans('%quantity_records% records have been sent to %quantity_users% users', [
'%quantity_records%' => count($pusher->get_elements()),
@@ -264,7 +264,7 @@ class Push implements ControllerProviderInterface
'message' => $app->trans('Unable to send the documents')
];
$app['EM']->beginTransaction();
$app['orm.em']->beginTransaction();
try {
$pusher = new RecordHelper\Push($app, $app['request']);
@@ -291,21 +291,21 @@ class Push implements ControllerProviderInterface
$Basket->setUser($app['authentication']->getUser());
$Basket->setIsRead(false);
$app['EM']->persist($Basket);
$app['orm.em']->persist($Basket);
foreach ($pusher->get_elements() as $element) {
$BasketElement = new BasketElement();
$BasketElement->setRecord($element);
$BasketElement->setBasket($Basket);
$app['EM']->persist($BasketElement);
$app['orm.em']->persist($BasketElement);
$Basket->addElement($BasketElement);
}
$app['EM']->flush();
$app['orm.em']->flush();
}
$app['EM']->refresh($Basket);
$app['orm.em']->refresh($Basket);
if (!$Basket->getValidation()) {
$Validation = new ValidationSession();
@@ -320,7 +320,7 @@ class Push implements ControllerProviderInterface
}
$Basket->setValidation($Validation);
$app['EM']->persist($Validation);
$app['orm.em']->persist($Validation);
} else {
$Validation = $Basket->getValidation();
}
@@ -368,7 +368,7 @@ class Push implements ControllerProviderInterface
$validationParticipant->setCanAgree($participant['agree']);
$validationParticipant->setCanSeeOthers($participant['see_others']);
$app['EM']->persist($validationParticipant);
$app['orm.em']->persist($validationParticipant);
foreach ($Basket->getElements() as $BasketElement) {
$ValidationData = new ValidationData();
@@ -390,8 +390,8 @@ class Push implements ControllerProviderInterface
);
}
$app['EM']->merge($BasketElement);
$app['EM']->persist($ValidationData);
$app['orm.em']->merge($BasketElement);
$app['orm.em']->persist($ValidationData);
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participantUser->getId(), '');
@@ -399,9 +399,9 @@ class Push implements ControllerProviderInterface
$validationParticipant->addData($ValidationData);
}
$validationParticipant = $app['EM']->merge($validationParticipant);
$validationParticipant = $app['orm.em']->merge($validationParticipant);
$app['EM']->flush();
$app['orm.em']->flush();
$arguments = [
'basket' => $Basket->getId(),
@@ -419,9 +419,9 @@ class Push implements ControllerProviderInterface
$app['dispatcher']->dispatch(PhraseaEvents::VALIDATION_CREATE, new ValidationEvent($validationParticipant, $Basket, $url, $request->request->get('message'), $receipt, (int) $request->request->get('duration')));
}
$app['EM']->merge($Basket);
$app['EM']->merge($Validation);
$app['EM']->flush();
$app['orm.em']->merge($Basket);
$app['orm.em']->merge($Validation);
$app['orm.em']->flush();
$message = $app->trans('%quantity_records% records have been sent for validation to %quantity_users% users', [
'%quantity_records%' => count($pusher->get_elements()),
@@ -433,10 +433,10 @@ class Push implements ControllerProviderInterface
'message' => $message
];
$app['EM']->commit();
$app['orm.em']->commit();
} catch (ControllerException $e) {
$ret['message'] = $e->getMessage();
$app['EM']->rollback();
$app['orm.em']->rollback();
}
return $app->json($ret);

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -152,7 +152,7 @@ class Query implements ControllerProviderInterface
$explain .= '<br><div>' . $result->getDuration() . ' s</div>dans index ' . $result->getIndexes();
$explain .= "</div>";
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '&quot;', $explain) . '">' . $app->trans('reponses:: %total% reponses', ['%total%' => $result->getTotal()]) . '</a> | ' . $app->trans('reponses:: %number% documents selectionnes', ['%number%' => '<span id="nbrecsel"></span>']);
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '&quot;', $explain) . '">' .$app->trans('%total% reponses', ['%total%' => '<span>'.$result->getTotal().'</span>']) . '</a>';
$json['infos'] = $infoResult;
$json['navigation'] = $string;

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -122,7 +122,7 @@ class Records implements ControllerProviderInterface
]),
"others" => $app['twig']->render('prod/preview/appears_in.html.twig', [
'parents' => $record->get_grouping_parents(),
'baskets' => $record->get_container_baskets($app['EM'], $app['authentication']->getUser())
'baskets' => $record->get_container_baskets($app['orm.em'], $app['authentication']->getUser())
]),
"current" => $train,
"history" => $app['twig']->render('prod/preview/short_history.html.twig', [
@@ -135,7 +135,9 @@ class Records implements ControllerProviderInterface
'record' => $record
]),
"pos" => $record->get_number(),
"title" => str_replace(['[[em]]', '[[/em]]'], ['<em>', '</em>'], $record->get_title($query, $searchEngine))
"title" => str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), $record->get_title($query, $searchEngine)),
"collection_name" => $record->get_collection()->get_name(),
"collection_logo" => $record->get_collection()->getLogo($record->get_base_id(), $app)
]);
}
@@ -162,14 +164,14 @@ class Records implements ControllerProviderInterface
$basketElements = $basketElementsRepository->findElementsByRecord($record);
foreach ($basketElements as $element) {
$app['EM']->remove($element);
$app['orm.em']->remove($element);
$deleted[] = $element->getRecord($app)->get_serialize_key();
}
$attachedStories = $StoryWZRepository->findByRecord($app, $record);
foreach ($attachedStories as $attachedStory) {
$app['EM']->remove($attachedStory);
$app['orm.em']->remove($attachedStory);
}
$deleted[] = $record->get_serialize_key();
@@ -179,7 +181,7 @@ class Records implements ControllerProviderInterface
}
}
$app['EM']->flush();
$app['orm.em']->flush();
return $app->json($deleted);
}

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -102,10 +102,13 @@ class Root implements ControllerProviderInterface
}
}
$helper = new Helper\Prod($app, $app['request']);
return $app['twig']->render('prod/index.html.twig', [
'module_name' => 'Production',
'WorkZone' => new Helper\WorkZone($app, $app['request']),
'module_prod' => new Helper\Prod($app, $app['request']),
'module_prod' => $helper,
'search_datas' => $helper->get_search_datas(),
'cssfile' => $cssfile,
'module' => 'prod',
'events' => $app['events-manager'],

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Controller\Exception as ControllerException;
use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Model\Entities\StoryWZ;
use Alchemy\Phrasea\Core\Event\RecordEdit;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -78,9 +80,9 @@ class Story implements ControllerProviderInterface
$StoryWZ->setUser($app['authentication']->getUser());
$StoryWZ->setRecord($Story);
$app['EM']->persist($StoryWZ);
$app['orm.em']->persist($StoryWZ);
$app['EM']->flush();
$app['orm.em']->flush();
if ($request->getRequestFormat() == 'json') {
$data = [
@@ -132,6 +134,8 @@ class Story implements ControllerProviderInterface
$n++;
}
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($Story));
$data = [
'success' => true
, 'message' => $app->trans('%quantity% records added', ['%quantity%' => $n])
@@ -159,6 +163,9 @@ class Story implements ControllerProviderInterface
, 'message' => $app->trans('Record removed from story')
];
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($Story));
if ($request->getRequestFormat() == 'json') {
return $app->json($data);
} else {
@@ -222,6 +229,8 @@ class Story implements ControllerProviderInterface
$stmt->closeCursor();
$ret = ['success' => true, 'message' => $app->trans('Story updated')];
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($story));
} catch (ControllerException $e) {
$ret = ['success' => false, 'message' => $e->getMessage()];
} catch (\Exception $e) {

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -87,23 +87,30 @@ class Tools implements ControllerProviderInterface
$controllers->post('/image/', function (Application $app, Request $request) {
$return = ['success' => true];
$selection = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']);
$force = $request->request->get('force_substitution') == '1';
$selection = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord'));
foreach ($selection as $record) {
$substituted = false;
foreach ($record->get_subdefs() as $subdef) {
if ($subdef->is_substituted()) {
$substituted = true;
if ($force) {
// unset flag
$subdef->set_substituted(false);
}
break;
}
}
if (!$substituted || $request->request->get('ForceThumbSubstit') == '1') {
if (!$substituted || $force) {
$record->rebuild_subdefs();
}
}
return $app->json($return);
})->bind('prod_tools_image');

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,7 +14,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Core\Event\LazaretEvent;
use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Core\Event\RecordEdit;use Alchemy\Phrasea\Core\PhraseaEvents;
use DataURI\Parser;
use DataURI\Exception\Exception as DataUriException;
use Alchemy\Phrasea\Model\Entities\LazaretSession;
@@ -51,6 +51,8 @@ class Upload implements ControllerProviderInterface
$controllers->get('/flash-version/', 'controller.prod.upload:getFlashUploadForm')
->bind('upload_flash_form');
$controllers->get('/html5-version/', 'controller.prod.upload:getHtml5UploadForm')
->bind('upload_html5_form');
$controllers->post('/', 'controller.prod.upload:upload')
->bind('upload');
@@ -71,12 +73,25 @@ class Upload implements ControllerProviderInterface
$maxFileSize = $this->getUploadMaxFileSize();
return $app['twig']->render(
'prod/upload/upload-flash.html.twig', [
'sessionId' => session_id(),
'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
]);
'prod/upload/upload-flash.html.twig', array(
'sessionId' => session_id(),
'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
));
}
public function getHtml5UploadForm(Application $app, Request $request)
{
$maxFileSize = $this->getUploadMaxFileSize();
return $app['twig']->render(
'prod/upload/upload.html.twig', array(
'sessionId' => session_id(),
'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
));
}
/**
@@ -162,7 +177,7 @@ class Upload implements ControllerProviderInterface
$lazaretSession = new LazaretSession();
$lazaretSession->setUser($app['authentication']->getUser());
$app['EM']->persist($lazaretSession);
$app['orm.em']->persist($lazaretSession);
$packageFile = new File($app, $media, $collection, $file->getClientOriginalName());
@@ -208,6 +223,8 @@ class Upload implements ControllerProviderInterface
$element = 'record';
$message = $app->trans('The record was successfully created');
$app['dispatcher']->dispatch(PhraseaEvents::RECORD_UPLOAD, new RecordEdit($elementCreated));
// try to create thumbnail from data URI
if ('' !== $b64Image = $request->request->get('b64_image', '')) {
try {

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -170,9 +170,9 @@ class UsrLists implements ControllerProviderInterface
$List->setName($list_name);
$List->addOwner($Owner);
$app['EM']->persist($Owner);
$app['EM']->persist($List);
$app['EM']->flush();
$app['orm.em']->persist($Owner);
$app['orm.em']->persist($List);
$app['orm.em']->flush();
$datas = [
'success' => true
@@ -261,7 +261,7 @@ class UsrLists implements ControllerProviderInterface
$list->setName($list_name);
$app['EM']->flush();
$app['orm.em']->flush();
$datas = [
'success' => true
@@ -290,8 +290,8 @@ class UsrLists implements ControllerProviderInterface
throw new ControllerException($app->trans('You are not authorized to do this'));
}
$app['EM']->remove($list);
$app['EM']->flush();
$app['orm.em']->remove($list);
$app['orm.em']->flush();
$datas = [
'success' => true
@@ -329,8 +329,8 @@ class UsrLists implements ControllerProviderInterface
$user_entry = $entry_repository->findEntryByListAndUsrId($list, $usr_id);
$app['EM']->remove($user_entry);
$app['EM']->flush();
$app['orm.em']->remove($user_entry);
$app['orm.em']->flush();
$datas = [
'success' => true
@@ -381,12 +381,12 @@ class UsrLists implements ControllerProviderInterface
$list->addEntrie($entry);
$app['EM']->persist($entry);
$app['orm.em']->persist($entry);
$inserted_usr_ids[] = $user_entry->getId();
}
$app['EM']->flush();
$app['orm.em']->flush();
if (count($inserted_usr_ids) > 1) {
$datas = [
@@ -476,14 +476,14 @@ class UsrLists implements ControllerProviderInterface
$list->addOwner($owner);
$app['EM']->persist($owner);
$app['orm.em']->persist($owner);
}
$role = $app['request']->request->get('role');
$owner->setRole($role);
$app['EM']->flush();
$app['orm.em']->flush();
$datas = [
'success' => true
@@ -521,8 +521,8 @@ class UsrLists implements ControllerProviderInterface
$owner = $owners_repository->findByListAndUsrId($list, $usr_id);
$app['EM']->remove($owner);
$app['EM']->flush();
$app['orm.em']->remove($owner);
$app['orm.em']->flush();
$datas = [
'success' => true

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
* (c) 2005-2015 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -150,11 +150,11 @@ class WorkZone implements ControllerProviderInterface
$StoryWZ->setUser($app['authentication']->getUser());
$StoryWZ->setRecord($Story);
$app['EM']->persist($StoryWZ);
$app['orm.em']->persist($StoryWZ);
$done++;
}
$app['EM']->flush();
$app['orm.em']->flush();
if ($alreadyFixed === 0) {
if ($done <= 1) {
@@ -192,8 +192,8 @@ class WorkZone implements ControllerProviderInterface
throw new NotFoundHttpException('Story not found');
}
$app['EM']->remove($StoryWZ);
$app['EM']->flush();
$app['orm.em']->remove($StoryWZ);
$app['orm.em']->flush();
if ($request->getRequestFormat() == 'json') {
return $app->json([