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