add stamp / no-stamp to export-by-email and export-by-ftp (#4437)

add default (disabled) stamp settings on new collections
add "record_edit" & "image_tools" to conf / export-stamp-choice privilege
This commit is contained in:
jygaulier
2023-12-14 17:20:53 +01:00
committed by GitHub
parent e97751be96
commit 8df3cf55b7
12 changed files with 210 additions and 66 deletions

View File

@@ -15,10 +15,11 @@ use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Authentication\Authenticator; use Alchemy\Phrasea\Authentication\Authenticator;
use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\Controller;
use Alchemy\Phrasea\Core\Configuration\DisplaySettingService; use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
use Alchemy\Phrasea\Model\Manipulator\TaskManipulator;
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions; use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
use Alchemy\Phrasea\WorkerManager\Event\PopulateIndexEvent; use Alchemy\Phrasea\WorkerManager\Event\PopulateIndexEvent;
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents; use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
use collection;
use Exception;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -103,7 +104,8 @@ class DataboxController extends Controller
$success = true; $success = true;
$msg = $this->app->trans('Successful removal'); $msg = $this->app->trans('Successful removal');
} }
} catch (\Exception $e) { }
catch (Exception $e) {
} }
if (!$databox) { if (!$databox) {
@@ -150,7 +152,8 @@ class DataboxController extends Controller
$value = $labels[$code] ?: null; $value = $labels[$code] ?: null;
$databox->set_label($code, $value); $databox->set_label($code, $value);
} }
} catch (\Exception $e) { }
catch (Exception $e) {
$success = false; $success = false;
} }
@@ -190,7 +193,9 @@ class DataboxController extends Controller
try { try {
$this->getDispatcher()->dispatch(WorkerEvents::POPULATE_INDEX, new PopulateIndexEvent($populateInfo)); $this->getDispatcher()->dispatch(WorkerEvents::POPULATE_INDEX, new PopulateIndexEvent($populateInfo));
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -222,8 +227,8 @@ class DataboxController extends Controller
$indexable = !!$request->request->get('indexable', false); $indexable = !!$request->request->get('indexable', false);
$this->getApplicationBox()->set_databox_indexable($databox, $indexable); $this->getApplicationBox()->set_databox_indexable($databox, $indexable);
$success = true; $success = true;
} catch (\Exception $e) { } catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -255,7 +260,8 @@ class DataboxController extends Controller
foreach ($request->request->get('TOU', []) as $loc => $terms) { foreach ($request->request->get('TOU', []) as $loc => $terms) {
$databox->update_cgus($loc, $terms, !!$request->request->get('valid', false)); $databox->update_cgus($loc, $terms, !!$request->request->get('valid', false));
} }
} catch (\Exception $e) { }
catch (Exception $e) {
return $this->app->redirectPath('admin_database_display_cgus', [ return $this->app->redirectPath('admin_database_display_cgus', [
'databox_id' => $databox_id, 'databox_id' => $databox_id,
'success' => 0, 'success' => 0,
@@ -283,7 +289,7 @@ class DataboxController extends Controller
try { try {
/** @var Authenticator $authenticator */ /** @var Authenticator $authenticator */
$authenticator = $this->app->getAuthenticator(); $authenticator = $this->app->getAuthenticator();
$baseId = \collection::mount_collection( $baseId = collection::mount_collection(
$this->app, $this->app,
$this->findDataboxById($databox_id), $this->findDataboxById($databox_id),
$collection_id, $collection_id,
@@ -315,7 +321,8 @@ class DataboxController extends Controller
'databox_id' => $databox_id, 'databox_id' => $databox_id,
'mount' => 'ok', 'mount' => 'ok',
]); ]);
} catch (\Exception $e) { }
catch (Exception $e) {
$connection->rollBack(); $connection->rollBack();
return $this->app->redirectPath('admin_database', [ return $this->app->redirectPath('admin_database', [
@@ -366,7 +373,8 @@ class DataboxController extends Controller
'error' => 'file-invalid', 'error' => 'file-invalid',
]); ]);
} }
} catch (\Exception $e) { }
catch (Exception $e) {
return $this->app->redirectPath('admin_database', [ return $this->app->redirectPath('admin_database', [
'databox_id' => $databox_id, 'databox_id' => $databox_id,
'success' => '0', 'success' => '0',
@@ -395,8 +403,9 @@ class DataboxController extends Controller
\databox::PIC_PDF \databox::PIC_PDF
); );
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -428,8 +437,9 @@ class DataboxController extends Controller
try { try {
$this->findDataboxById($databox_id)->clear_logs(); $this->findDataboxById($databox_id)->clear_logs();
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -465,8 +475,9 @@ class DataboxController extends Controller
try { try {
$this->findDataboxById($databox_id)->set_viewname($viewName); $this->findDataboxById($databox_id)->set_viewname($viewName);
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -500,8 +511,9 @@ class DataboxController extends Controller
$databox->unmount_databox(); $databox->unmount_databox();
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -553,8 +565,9 @@ class DataboxController extends Controller
// if ($taskCreated) { // if ($taskCreated) {
// $msg = $this->app->trans('A task has been created, please run it to complete empty collection'); // $msg = $this->app->trans('A task has been created, please run it to complete empty collection');
// } // }
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
if ('json' === $request->getRequestFormat()) { if ('json' === $request->getRequestFormat()) {
@@ -612,8 +625,9 @@ class DataboxController extends Controller
$ret['success'] = true; $ret['success'] = true;
$ret['msg'] = $this->app->trans('Successful update'); $ret['msg'] = $this->app->trans('Successful update');
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
return $this->app->json($ret); return $this->app->json($ret);
@@ -645,11 +659,12 @@ class DataboxController extends Controller
{ {
try { try {
foreach ($request->request->get('order', []) as $data) { foreach ($request->request->get('order', []) as $data) {
$collection = \collection::getByBaseId($this->app, $data['id']); $collection = collection::getByBaseId($this->app, $data['id']);
$collection->set_ord($data['offset']); $collection->set_ord($data['offset']);
} }
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
$success = false; $success = false;
} }
@@ -680,11 +695,11 @@ class DataboxController extends Controller
/** /**
* Create a new collection * Create a new collection
* *
* @param Request $request The current HTTP request * @param Request $request The current HTTP request
* @param integer $databox_id The requested databox * @param integer $databox_id The requested databox
* @return Response * @return Response
*/ */
public function createCollection(Request $request, $databox_id) public function createCollection(Request $request, int $databox_id)
{ {
if (($name = trim($request->request->get('name', ''))) === '') { if (($name = trim($request->request->get('name', ''))) === '') {
return $this->app->redirectPath('admin_database_display_new_collection_form', [ return $this->app->redirectPath('admin_database_display_new_collection_form', [
@@ -695,7 +710,7 @@ class DataboxController extends Controller
try { try {
$databox = $this->findDataboxById($databox_id); $databox = $this->findDataboxById($databox_id);
$collection = \collection::create( $collection = collection::create(
$this->app, $databox, $this->app, $databox,
$this->getApplicationBox(), $this->getApplicationBox(),
$name, $name,
@@ -721,7 +736,8 @@ class DataboxController extends Controller
'success' => 1, 'success' => 1,
'reload-tree' => 1, 'reload-tree' => 1,
]); ]);
} catch (\Exception $e) { }
catch (Exception $e) {
return $this->app->redirectPath('admin_database_submit_collection', [ return $this->app->redirectPath('admin_database_submit_collection', [
'databox_id' => $databox_id, 'databox_id' => $databox_id,
'error' => $e->getMessage(), 'error' => $e->getMessage(),

View File

@@ -22,6 +22,7 @@ use Alchemy\Phrasea\WorkerManager\Event\ExportFtpEvent;
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents; use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Exception;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -61,8 +62,10 @@ class ExportController extends Controller
$removeable_stamp = false; // true if at least one coll is "unstampable" $removeable_stamp = false; // true if at least one coll is "unstampable"
$removeable_stamp_by_base = []; // unset: no stamp ; false: stamp not "unstampable" ; true: stamp "unstampable" $removeable_stamp_by_base = []; // unset: no stamp ; false: stamp not "unstampable" ; true: stamp "unstampable"
$colls_manageable = array_keys($this->getAclForConnectedUser()->get_granted_base([ACL::COLL_MANAGE]) ?? []); $colls_manageable = array_keys($this->getAclForConnectedUser()->get_granted_base([ACL::COLL_MANAGE]) ?? []);
$dbox_manageable = array_keys($this->getAclForConnectedUser()->get_granted_sbas([ACL::BAS_MANAGE]) ?? []); $colls_editable = array_keys($this->getAclForConnectedUser()->get_granted_base([ACL::CANMODIFRECORD]) ?? []);
$colls_imgtoolsable = array_keys($this->getAclForConnectedUser()->get_granted_base([ACL::IMGTOOLS]) ?? []);
$dbox_manageable = array_keys($this->getAclForConnectedUser()->get_granted_sbas([ACL::BAS_MANAGE]) ?? []);
foreach($download->get_elements() as $recordAdapter) { foreach($download->get_elements() as $recordAdapter) {
// check collection only once // check collection only once
@@ -92,6 +95,16 @@ class ExportController extends Controller
$removeable_stamp_by_base[$bid] = $removeable_stamp = true; $removeable_stamp_by_base[$bid] = $removeable_stamp = true;
} }
break; break;
case 'record_edit':
if (in_array($bid, $colls_editable)) {
$removeable_stamp_by_base[$bid] = $removeable_stamp = true;
}
break;
case 'image_tools':
if (in_array($bid, $colls_imgtoolsable)) {
$removeable_stamp_by_base[$bid] = $removeable_stamp = true;
}
break;
case 'manage_databox': case 'manage_databox':
if (in_array($recordAdapter->getDatabox()->get_sbas_id(), $dbox_manageable)) { if (in_array($recordAdapter->getDatabox()->get_sbas_id(), $dbox_manageable)) {
$removeable_stamp_by_base[$bid] = $removeable_stamp = true; $removeable_stamp_by_base[$bid] = $removeable_stamp = true;
@@ -138,7 +151,9 @@ class ExportController extends Controller
$ftpClient->close(); $ftpClient->close();
$msg = $this->app->trans('Connection to FTP succeed'); $msg = $this->app->trans('Connection to FTP succeed');
$success = true; $success = true;
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
return $this->app->json([ return $this->app->json([
@@ -184,7 +199,7 @@ class ExportController extends Controller
\set_export::STAMP_ASYNC, \set_export::STAMP_ASYNC,
$request->request->get('stamp_choice') === "REMOVE_STAMP", $request->request->get('stamp_choice') === "REMOVE_STAMP",
false false
); );
$exportFtpId = $download->export_ftp( $exportFtpId = $download->export_ftp(
$request->request->get('user_dest'), $request->request->get('user_dest'),
@@ -206,7 +221,8 @@ class ExportController extends Controller
'success' => true, 'success' => true,
'message' => $this->app->trans('Export saved in the waiting queue') 'message' => $this->app->trans('Export saved in the waiting queue')
]); ]);
} catch (\Exception $e) { }
catch (Exception $e) {
return $this->app->json([ return $this->app->json([
'success' => false, 'success' => false,
'message' => $e->getMessage()//$this->app->trans('Something went wrong') 'message' => $e->getMessage()//$this->app->trans('Something went wrong')
@@ -217,8 +233,9 @@ class ExportController extends Controller
/** /**
* Export document by mail * Export document by mail
* *
* @param Request $request * @param Request $request
* @return JsonResponse * @return JsonResponse
* @throws Exception
*/ */
public function exportMail(Request $request) public function exportMail(Request $request)
{ {

View File

@@ -72,6 +72,7 @@ class Databox implements ControllerProviderInterface, ServiceProviderInterface
->before([$this, 'requireManageRightOnSbas']) ->before([$this, 'requireManageRightOnSbas'])
->bind('admin_database_submit_collections_order'); ->bind('admin_database_submit_collections_order');
/** @uses DataboxController::createCollection */
$controllers->post('/{databox_id}/collection/', 'controller.admin.databox:createCollection') $controllers->post('/{databox_id}/collection/', 'controller.admin.databox:createCollection')
->before([$this, 'requireManageRightOnSbas']) ->before([$this, 'requireManageRightOnSbas'])
->bind('admin_database_submit_collection'); ->bind('admin_database_submit_collection');
@@ -97,6 +98,7 @@ class Databox implements ControllerProviderInterface, ServiceProviderInterface
->before([$this, 'requireManageRightOnSbas']) ->before([$this, 'requireManageRightOnSbas'])
->bind('admin_database_display_document_details'); ->bind('admin_database_display_document_details');
/** @uses DataboxController::mountCollection */
$controllers->post('/{databox_id}/collection/{collection_id}/mount/', 'controller.admin.databox:mountCollection') $controllers->post('/{databox_id}/collection/{collection_id}/mount/', 'controller.admin.databox:mountCollection')
->assert('collection_id', '\d+') ->assert('collection_id', '\d+')
->before([$this, 'requireManageRightOnSbas']) ->before([$this, 'requireManageRightOnSbas'])

View File

@@ -95,6 +95,11 @@ class FtpExportElement
*/ */
private $updated; private $updated;
/**
* @ORM\Column(type="boolean", options={"default" = 0})
*/
private $toStamp = false;
/** /**
* Get id * Get id
* *
@@ -368,4 +373,20 @@ class FtpExportElement
{ {
return $this->export; return $this->export;
} }
/**
* @return bool
*/
public function isToStamp(): bool
{
return $this->toStamp;
}
/**
* @param bool $toStamp
*/
public function setToStamp(bool $toStamp)
{
$this->toStamp = $toStamp;
}
} }

View File

@@ -88,7 +88,7 @@ class ExportMailWorker implements WorkerInterface
foreach($list['files'] as $k_file => $v_file) { foreach($list['files'] as $k_file => $v_file) {
foreach($v_file['subdefs'] as $k_subdef => $v_subdef) { foreach($v_file['subdefs'] as $k_subdef => $v_subdef) {
if($k_subdef === "document" && $v_subdef['to_stamp']) { if($v_subdef['to_stamp']) {
// we must stamp this document // we must stamp this document
try { try {
$record = $this->app->getApplicationBox()->get_databox($v_file['databox_id'])->get_record($v_file['record_id']); $record = $this->app->getApplicationBox()->get_databox($v_file['databox_id'])->get_record($v_file['record_id']);

View File

@@ -15,6 +15,8 @@ use Alchemy\Phrasea\Notification\Mail\MailSuccessFTPReceiver;
use Alchemy\Phrasea\Notification\Mail\MailSuccessFTPSender; use Alchemy\Phrasea\Notification\Mail\MailSuccessFTPSender;
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher; use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
use Exception;
use ftpClient;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
@@ -83,7 +85,8 @@ class FtpWorker implements WorkerInterface
$em->flush(); $em->flush();
$em->commit(); $em->commit();
} catch (\Exception $e) { }
catch (Exception $e) {
$em->rollback(); $em->rollback();
} }
} else { } else {
@@ -101,7 +104,8 @@ class FtpWorker implements WorkerInterface
$em->flush(); $em->flush();
$em->commit(); $em->commit();
} catch (\Exception $e) { }
catch (Exception $e) {
$em->rollback(); $em->rollback();
} }
} }
@@ -146,7 +150,7 @@ class FtpWorker implements WorkerInterface
try { try {
$ssl = $export->isSsl(); $ssl = $export->isSsl();
/** @var \ftpClient $ftp_client */ /** @var ftpClient $ftp_client */
$ftp_client = $this->app['phraseanet.ftp.client']( $ftp_client = $this->app['phraseanet.ftp.client'](
$ftp_server, 21, 300, $ssl, $proxy, $proxyport, $ftp_server, 21, 300, $ssl, $proxy, $proxyport,
$proxyuser, $proxypwd $proxyuser, $proxypwd
@@ -156,7 +160,8 @@ class FtpWorker implements WorkerInterface
if ($export->isPassif()) { if ($export->isPassif()) {
try { try {
$ftp_client->passive(true); $ftp_client->passive(true);
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug($e->getMessage()); $this->logger->debug($e->getMessage());
} }
} }
@@ -165,7 +170,8 @@ class FtpWorker implements WorkerInterface
try { try {
$ftp_client->chdir($export->getDestFolder()); $ftp_client->chdir($export->getDestFolder());
$export->setDestfolder('/' . $export->getDestfolder()); $export->setDestfolder('/' . $export->getDestfolder());
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug($e->getMessage()); $this->logger->debug($e->getMessage());
} }
} else { } else {
@@ -175,14 +181,16 @@ class FtpWorker implements WorkerInterface
if (trim($export->getFoldertocreate()) != '') { if (trim($export->getFoldertocreate()) != '') {
try { try {
$ftp_client->mkdir($export->getFoldertocreate()); $ftp_client->mkdir($export->getFoldertocreate());
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug($e->getMessage()); $this->logger->debug($e->getMessage());
} }
try { try {
$new_dir = $ftp_client->add_end_slash($export->getDestfolder()) $new_dir = $ftp_client->add_end_slash($export->getDestfolder())
. $export->getFoldertocreate(); . $export->getFoldertocreate();
$ftp_client->chdir($new_dir); $ftp_client->chdir($new_dir);
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug($e->getMessage()); $this->logger->debug($e->getMessage());
} }
} }
@@ -223,25 +231,35 @@ class FtpWorker implements WorkerInterface
$localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand()); $localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) { if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire'); throw new Exception('Impossible de creer un fichier temporaire');
} }
} elseif ($subdef == 'caption-yaml') { }
elseif ($subdef == 'caption-yaml') {
$desc = $this->app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields()); $desc = $this->app['serializer.caption']->serialize($record->get_caption(), CaptionSerializer::SERIALIZE_YAML, $exportElement->isBusinessfields());
$localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand()); $localfile = sys_get_temp_dir().'/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) { if (file_put_contents($localfile, $desc) === false) {
throw new \Exception('Impossible de creer un fichier temporaire'); throw new Exception('Impossible de creer un fichier temporaire');
} }
} else { }
else {
try { try {
$sd = $record->get_subdef($subdef); $sd = $record->get_subdef($subdef);
} catch (\Exception_Media_SubdefNotFound $notFount) { $localfile = $sd->getRealPath();
if($exportElement->isToStamp()) {
if (!is_null($path = \recordutils_image::stamp($this->app, $sd))) {
// stamped !
$localfile = $path;
}
}
}
catch (\Exception_Media_SubdefNotFound $notFound) {
continue; continue;
} }
$localfile = $sd->getRealPath(); if (!$localfile || !file_exists($localfile)) {
if (!file_exists($localfile)) { throw new Exception('Le fichier local n\'existe pas');
throw new \Exception('Le fichier local n\'existe pas');
} }
} }
@@ -250,7 +268,8 @@ class FtpWorker implements WorkerInterface
if ($ftp_client->pwd() != $current_folder) { if ($ftp_client->pwd() != $current_folder) {
try { try {
$ftp_client->chdir($current_folder); $ftp_client->chdir($current_folder);
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug($e->getMessage()); $this->logger->debug($e->getMessage());
} }
} }
@@ -272,7 +291,8 @@ class FtpWorker implements WorkerInterface
$this->app['orm.em']->persist($exportElement); $this->app['orm.em']->persist($exportElement);
$this->app['orm.em']->flush(); $this->app['orm.em']->flush();
$this->logexport($this->app, $record, $obj, $ftpLog); $this->logexport($this->app, $record, $obj, $ftpLog);
} catch (\Exception $e) { }
catch (Exception $e) {
$state .= $line = $this->translator->trans('task::ftp:File "%file%" (record %record_id%) de la base "%basename%" (Export du Document) : Transfert cancelled (le document n\'existe plus)', ['%file%' => basename($localfile), '%record_id%' => $record_id, '%basename%' => \phrasea::sbas_labels(\phrasea::sbasFromBas($this->app, $base_id), $this->app)]) . "\n<br/>"; $state .= $line = $this->translator->trans('task::ftp:File "%file%" (record %record_id%) de la base "%basename%" (Export du Document) : Transfert cancelled (le document n\'existe plus)', ['%file%' => basename($localfile), '%record_id%' => $record_id, '%basename%' => \phrasea::sbas_labels(\phrasea::sbasFromBas($this->app, $base_id), $this->app)]) . "\n<br/>";
$this->logger->debug($line); $this->logger->debug($line);
@@ -317,7 +337,8 @@ class FtpWorker implements WorkerInterface
} }
$ftp_client->close(); $ftp_client->close();
} catch (\Exception $e) { }
catch (Exception $e) {
$state .= $line = $e . "\n"; $state .= $line = $e . "\n";
$this->logger->debug($line); $this->logger->debug($line);
@@ -342,7 +363,8 @@ class FtpWorker implements WorkerInterface
$em->persist($workerRunningJob); $em->persist($workerRunningJob);
$em->flush(); $em->flush();
$em->commit(); $em->commit();
} catch (\Exception $e) { }
catch (Exception $e) {
$em->rollback(); $em->rollback();
} }
} else { } else {
@@ -360,7 +382,8 @@ class FtpWorker implements WorkerInterface
$em->persist($workerRunningJob); $em->persist($workerRunningJob);
$em->flush(); $em->flush();
$em->commit(); $em->commit();
} catch (\Exception $e) { }
catch (Exception $e) {
$em->rollback(); $em->rollback();
} }
@@ -472,7 +495,9 @@ class FtpWorker implements WorkerInterface
$mail = MailSuccessFTPSender::create($app, $receiver, null, $sender_message); $mail = MailSuccessFTPSender::create($app, $receiver, null, $sender_message);
$mail->setServer($ftp_server); $mail->setServer($ftp_server);
$this->deliver($mail); $this->deliver($mail);
} catch (\Exception $e) { }
catch (Exception $e) {
// no-op
} }
try { try {
@@ -480,7 +505,8 @@ class FtpWorker implements WorkerInterface
$mail = MailSuccessFTPReceiver::create($app, $receiver, null, $receiver_message); $mail = MailSuccessFTPReceiver::create($app, $receiver, null, $receiver_message);
$mail->setServer($ftp_server); $mail->setServer($ftp_server);
$this->deliver($mail); $this->deliver($mail);
} catch (\Exception $e) { }
catch (Exception $e) {
$this->logger->debug(sprintf('Unable to deliver success message : %s', $e->getMessage())); $this->logger->debug(sprintf('Unable to deliver success message : %s', $e->getMessage()));
} }
} }

View File

@@ -66,6 +66,19 @@ class collection implements ThumbnailedElement, cache_cacheableInterface
$repository = self::getRepository($app, $databoxId); $repository = self::getRepository($app, $databoxId);
$collection = new CollectionVO($databoxId, 0, $name); $collection = new CollectionVO($databoxId, 0, $name);
$dom = new \DOMDocument();
try {
if(!@$dom->load($app['root.path'] . '/lib/conf.d/collection_settings.xml')) {
$dom = null;
}
}
catch (Exception $e) {
$dom = null;
}
if($dom) {
$collection->setPreferences($dom->saveXML());
}
$repository->save($collection); $repository->save($collection);
$repository = $app['repo.collection-references']; $repository = $app['repo.collection-references'];

View File

@@ -1339,9 +1339,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
/** /**
* @param $metadatas * @param $metadatas
* @throws Exception * @throws Exception|Exception_InvalidArgument
* *
* nb : use of "silent" @ operator on stdClass member access (equals null in not defined) is more simple than "iseet()" or "empty()" * nb : use of "silent" @ operator on stdClass member access (equals null if not defined) is more simple than "isset()" or "empty()"
*/ */
private function do_metadatas(array $metadatas) private function do_metadatas(array $metadatas)
{ {

View File

@@ -458,8 +458,10 @@ class set_export extends set_abstract
// remove stamp on this collection // remove stamp on this collection
$stamp_by_base = []; // unset: no stamp ; false: stamp not "unstampable" ; true: stamp "unstampable" $stamp_by_base = []; // unset: no stamp ; false: stamp not "unstampable" ; true: stamp "unstampable"
$colls_manageable = array_keys($this->getAclForUser($user)->get_granted_base([ACL::COLL_MANAGE]) ?? []); $colls_manageable = array_keys($this->getAclForUser($user)->get_granted_base([ACL::COLL_MANAGE]) ?? []);
$dbox_manageable = array_keys($this->getAclForUser($user)->get_granted_sbas([ACL::BAS_MANAGE]) ?? []); $colls_editable = array_keys($this->getAclForUser($user)->get_granted_base([ACL::CANMODIFRECORD]) ?? []);
$colls_imgtoolsable = array_keys($this->getAclForUser($user)->get_granted_base([ACL::IMGTOOLS]) ?? []);
$dbox_manageable = array_keys($this->getAclForUser($user)->get_granted_sbas([ACL::BAS_MANAGE]) ?? []);
/** @var record_exportElement $download_element */ /** @var record_exportElement $download_element */
foreach ($this->elements as $download_element) { foreach ($this->elements as $download_element) {
@@ -511,6 +513,16 @@ class set_export extends set_abstract
$stamp_by_base[$bid] = self::NO_STAMP; $stamp_by_base[$bid] = self::NO_STAMP;
} }
break; break;
case 'record_edit':
if (in_array($bid, $colls_editable)) {
$stamp_by_base[$bid] = self::NO_STAMP;
}
break;
case 'image_tools':
if (in_array($bid, $colls_imgtoolsable)) {
$stamp_by_base[$bid] = self::NO_STAMP;
}
break;
case 'manage_databox': case 'manage_databox':
if (in_array($download_element->getDatabox()->get_sbas_id(), $dbox_manageable)) { if (in_array($download_element->getDatabox()->get_sbas_id(), $dbox_manageable)) {
$stamp_by_base[$bid] = self::NO_STAMP; $stamp_by_base[$bid] = self::NO_STAMP;

View File

@@ -83,7 +83,8 @@ class set_exportftp extends set_export
->setFilename($filename) ->setFilename($filename)
->setFolder($properties['folder']) ->setFolder($properties['folder'])
->setRecordId($file['record_id']) ->setRecordId($file['record_id'])
->setSubdef($subdef); ->setSubdef($subdef)
->setToStamp($file['to_stamp'] !== set_export::NO_STAMP);
$export->addElement($element); $export->addElement($element);
$this->app['orm.em']->persist($element); $this->app['orm.em']->persist($element);

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<baseprefs>
<!--
<status>0</status>
<caninscript>0</caninscript>
-->
<!-- stamper settings -->
<!-- color = "R,G,B,t" with R,G,B: [0...255] ; trancparency: [0 (opaque)...127 (transparent)] -->
<!--
<stamp position="top-over" background="255,255,255,40">
<text size="250%" color="255,255,0,32" shadow="0,0,0,64">Record-id : <var name="RECORD_ID"/></text>
<text size="120%" color="255,255,255,0" shadow="0,0,0,0">Title : <field name="Title"/></text>
<text size="100%" color="255,255,255,0" shadow="0,0,0,0">Creator : <field name="Creator"/></text>
</stamp>
<stamp position="bottom-over" background="255,255,255,127">
<logo position="left" width="25%"/>
<text size="100%" color="255,255,255,0" shadow="0,0,0,50">Date export : <var name="DATE"/></text>
</stamp>
-->
</baseprefs>

View File

@@ -171,9 +171,9 @@
</div> </div>
{% endif %} {% endif %}
{% if removeable_stamp and download.has_stamp_option() == true %} {% if removeable_stamp and download.has_stamp_option() == true %}
<div id="stamp_choice" class="well-small" style="margin-left: 20px;" > <div class="well-small" style="margin-left: 20px;" >
<label for="option_stamp" class="checkbox"> <label for="export_stamp_choice" class="checkbox">
<input class="stamp_choice" type="checkbox" id="stamp_choice" name="stamp_choice" value="REMOVE_STAMP" /> <input class="stamp_choice" type="checkbox" id="export_stamp_choice" name="stamp_choice" value="REMOVE_STAMP" />
{{ 'prod::download: delete-marking-stamp' | trans }} {{ 'prod::download: delete-marking-stamp' | trans }}
</label> </label>
</div> </div>
@@ -249,6 +249,14 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% if removeable_stamp and download.has_stamp_option() == true %}
<div class="well-small" style="margin-left: 20px;" >
<label for="email_stamp_choice" class="checkbox">
<input class="stamp_choice" type="checkbox" id="email_stamp_choice" name="stamp_choice" value="REMOVE_STAMP" />
{{ 'prod::download: delete-marking-stamp' | trans }}
</label>
</div>
{% endif %}
{% if download.has_business_fields_access() %} {% if download.has_business_fields_access() %}
<div class="businessfields well-small" style="margin-left:20px;display:none;"> <div class="businessfields well-small" style="margin-left:20px;display:none;">
<label for="business_sendmail" class="checkbox"> <label for="business_sendmail" class="checkbox">
@@ -478,6 +486,14 @@
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if removeable_stamp and download.has_stamp_option() == true %}
<div class="well-small" style="margin-left: 20px;" >
<label for="ftp_stamp_choice" class="checkbox">
<input class="stamp_choice" type="checkbox" id="ftp_stamp_choice" name="stamp_choice" value="REMOVE_STAMP" />
{{ 'prod::download: delete-marking-stamp' | trans }}
</label>
</div>
{% endif %}
</div> </div>
{% if download.has_business_fields_access() %} {% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;"> <div class="businessfields" style="margin-left:20px;display:none;">