2424use OCA \Libresign \Service \IdentifyMethodService ;
2525use OCA \Libresign \Service \Install \ConfigureCheckService ;
2626use OCA \Libresign \Service \Install \InstallService ;
27+ use OCA \Libresign \Service \Policy \PolicyService ;
2728use OCA \Libresign \Service \ReminderService ;
2829use OCA \Libresign \Service \SignatureBackgroundService ;
2930use OCA \Libresign \Service \SignatureTextService ;
3031use OCA \Libresign \Settings \Admin ;
3132use OCP \AppFramework \Http ;
3233use OCP \AppFramework \Http \Attribute \ApiRoute ;
34+ use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
3335use OCP \AppFramework \Http \Attribute \NoCSRFRequired ;
3436use OCP \AppFramework \Http \ContentSecurityPolicy ;
3537use OCP \AppFramework \Http \DataDownloadResponse ;
@@ -83,6 +85,7 @@ public function __construct(
8385 private ReminderService $ reminderService ,
8486 private FooterService $ footerService ,
8587 private DocMdpConfigService $ docMdpConfigService ,
88+ private PolicyService $ policyService ,
8689 private IdentifyMethodService $ identifyMethodService ,
8790 private FileMapper $ fileMapper ,
8891 ) {
@@ -875,7 +878,7 @@ public function getFooterTemplate(): DataResponse {
875878 public function saveFooterTemplate (string $ template = '' , int $ width = 595 , int $ height = 50 ) {
876879 try {
877880 $ this ->footerService ->saveTemplate ($ template );
878- $ pdf = $ this ->footerService ->renderPreviewPdf ('' , $ width , $ height );
881+ $ pdf = $ this ->footerService ->renderPreviewPdf ($ template , $ width , $ height );
879882
880883 return new DataDownloadResponse ($ pdf , 'footer-preview.pdf ' , 'application/pdf ' );
881884 } catch (\Exception $ e ) {
@@ -894,15 +897,18 @@ public function saveFooterTemplate(string $template = '', int $width = 595, int
894897 * @param string $template Template to preview
895898 * @param int $width Width of preview in points (default: 595 - A4 width)
896899 * @param int $height Height of preview in points (default: 50)
900+ * @param ?bool $writeQrcodeOnFooter Whether to force QR code rendering in footer preview (null uses policy)
897901 * @return DataDownloadResponse<Http::STATUS_OK, 'application/pdf', array{}>|DataResponse<Http::STATUS_BAD_REQUEST, LibresignErrorResponse, array{}>
898902 *
899903 * 200: OK
900904 * 400: Bad request
901905 */
906+ #[NoAdminRequired]
907+ #[NoCSRFRequired]
902908 #[ApiRoute(verb: 'POST ' , url: '/api/{apiVersion}/admin/footer-template/preview-pdf ' , requirements: ['apiVersion ' => '(v1) ' ])]
903- public function footerTemplatePreviewPdf (string $ template = '' , int $ width = 595 , int $ height = 50 ) {
909+ public function footerTemplatePreviewPdf (string $ template = '' , int $ width = 595 , int $ height = 50 , ? bool $ writeQrcodeOnFooter = null ) {
904910 try {
905- $ pdf = $ this ->footerService ->renderPreviewPdf ($ template ?: null , $ width , $ height );
911+ $ pdf = $ this ->footerService ->renderPreviewPdf ($ template ?: null , $ width , $ height, $ writeQrcodeOnFooter );
906912 return new DataDownloadResponse ($ pdf , 'footer-preview.pdf ' , 'application/pdf ' );
907913 } catch (\Exception $ e ) {
908914 return new DataResponse ([
@@ -960,57 +966,6 @@ private function saveOrDeleteConfig(string $key, ?string $value, string $default
960966 }
961967 }
962968
963- /**
964- * Set signature flow configuration
965- *
966- * @param bool $enabled Whether to force a signature flow for all documents
967- * @param string|null $mode Signature flow mode: 'parallel' or 'ordered_numeric' (only used when enabled is true)
968- * @return DataResponse<Http::STATUS_OK, LibresignMessageResponse, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, LibresignErrorResponse, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, LibresignErrorResponse, array{}>
969- *
970- * 200: Configuration saved successfully
971- * 400: Invalid signature flow mode provided
972- * 500: Internal server error
973- */
974- #[ApiRoute(verb: 'POST ' , url: '/api/{apiVersion}/admin/signature-flow/config ' , requirements: ['apiVersion ' => '(v1) ' ])]
975- public function setSignatureFlowConfig (bool $ enabled , ?string $ mode = null ): DataResponse {
976- try {
977- if (!$ enabled ) {
978- $ this ->appConfig ->deleteKey (Application::APP_ID , 'signature_flow ' );
979- return new DataResponse ([
980- 'message ' => $ this ->l10n ->t ('Settings saved ' ),
981- ]);
982- }
983-
984- if ($ mode === null ) {
985- return new DataResponse ([
986- 'error ' => $ this ->l10n ->t ('Mode is required when signature flow is enabled. ' ),
987- ], Http::STATUS_BAD_REQUEST );
988- }
989-
990- try {
991- $ signatureFlow = \OCA \Libresign \Enum \SignatureFlow::from ($ mode );
992- } catch (\ValueError ) {
993- return new DataResponse ([
994- 'error ' => $ this ->l10n ->t ('Invalid signature flow mode. Use "parallel" or "ordered_numeric". ' ),
995- ], Http::STATUS_BAD_REQUEST );
996- }
997-
998- $ this ->appConfig ->setValueString (
999- Application::APP_ID ,
1000- 'signature_flow ' ,
1001- $ signatureFlow ->value
1002- );
1003-
1004- return new DataResponse ([
1005- 'message ' => $ this ->l10n ->t ('Settings saved ' ),
1006- ]);
1007- } catch (\Exception $ e ) {
1008- return new DataResponse ([
1009- 'error ' => $ e ->getMessage (),
1010- ], Http::STATUS_INTERNAL_SERVER_ERROR );
1011- }
1012- }
1013-
1014969 /**
1015970 * Configure DocMDP signature restrictions
1016971 *
0 commit comments