11<?php
22
3- /**
4- * This file is part of ILIAS, a powerful learning management system
5- * published by ILIAS open source e-Learning e.V.
6- *
7- * ILIAS is licensed with the GPL-3.0,
8- * see https://www.gnu.org/licenses/gpl-3.0.en.html
9- * You should have received a copy of said license along with the
10- * source code, too.
11- *
12- * If this is not the case or you just want to try ILIAS, you'll find
13- * us at:
14- * https://www.ilias.de
15- * https://github.com/ILIAS-eLearning
16- *
17- *********************************************************************/
18-
193namespace ILIAS \components \File \Preview ;
204
215use ILIAS \UI \Component \Input \Field \Factory ;
@@ -31,8 +15,10 @@ class Form
3115 private Factory $ field_factory ;
3216 private \ILIAS \Refinery \Factory $ refinery ;
3317
34- public function __construct (private Settings $ settings )
35- {
18+ public function __construct (
19+ private Settings $ settings ,
20+ private bool $ write_access
21+ ) {
3622 global $ DIC ;
3723 $ this ->language = $ DIC ->language ();
3824 $ this ->field_factory = $ DIC ->ui ()->factory ()->input ()->field ();
@@ -56,10 +42,10 @@ public function asFormGroup(): Group
5642 $ this ->language ->txt ('enable_preview ' ),
5743 $ this ->language ->txt ('enable_preview_info ' )
5844 )
59- ->withDisabled (!$ possible )
45+ ->withDisabled (!$ this -> write_access || ! $ possible )
6046 ->withValue ($ this ->settings ->isPreviewEnabled ())
6147 ->withAdditionalTransformation (
62- $ this ->refinery ->custom ()->transformation (function ($ v ): void {
48+ $ this ->refinery ->custom ()->transformation (function (bool $ v ): void {
6349 $ this ->settings ->setPreviewEnabled ($ v );
6450 })
6551 );
@@ -69,11 +55,11 @@ public function asFormGroup(): Group
6955 $ this ->language ->txt ('preview_image_size ' ),
7056 $ this ->language ->txt ('preview_image_size_info ' )
7157 )
72- ->withDisabled (!$ possible )
58+ ->withDisabled (!$ this -> write_access || ! $ possible )
7359 ->withRequired (true )
7460 ->withValue ($ this ->settings ->getImageSize ())
7561 ->withAdditionalTransformation (
76- $ this ->refinery ->custom ()->transformation (function ($ v ): void {
62+ $ this ->refinery ->custom ()->transformation (function (int $ v ): void {
7763 $ this ->settings ->setImageSize ($ v );
7864 })
7965 );
@@ -83,10 +69,10 @@ public function asFormGroup(): Group
8369 $ this ->language ->txt ('preview_persisting ' ),
8470 $ this ->language ->txt ('preview_persisting_info ' )
8571 )
86- ->withDisabled (!$ possible )
72+ ->withDisabled (!$ this -> write_access || ! $ possible )
8773 ->withValue ($ this ->settings ->isPersisting ())
8874 ->withAdditionalTransformation (
89- $ this ->refinery ->custom ()->transformation (function ($ v ): void {
75+ $ this ->refinery ->custom ()->transformation (function (bool $ v ): void {
9076 $ this ->settings ->setPersisting ($ v );
9177 })
9278 );
@@ -96,10 +82,10 @@ public function asFormGroup(): Group
9682 $ this ->language ->txt ('max_previews_per_object ' ),
9783 $ this ->language ->txt ('max_previews_per_object_info ' )
9884 )
99- ->withDisabled (!$ possible )
85+ ->withDisabled (!$ this -> write_access || ! $ possible )
10086 ->withValue ($ this ->settings ->getMaximumPreviews ())
10187 ->withAdditionalTransformation (
102- $ this ->refinery ->custom ()->transformation (function ($ v ): void {
88+ $ this ->refinery ->custom ()->transformation (function (int $ v ): void {
10389 $ this ->settings ->setMaximumPreviews ($ v );
10490 })
10591 );
@@ -109,10 +95,10 @@ public function asFormGroup(): Group
10995 $ this ->language ->txt ('previews_for_tiles ' ),
11096 $ this ->language ->txt ('previews_for_tiles_info ' )
11197 )
112- ->withDisabled (!$ possible )
98+ ->withDisabled (!$ this -> write_access || ! $ possible )
11399 ->withValue ($ this ->settings ->hasTilePreviews ())
114100 ->withAdditionalTransformation (
115- $ this ->refinery ->custom ()->transformation (function ($ v ): void {
101+ $ this ->refinery ->custom ()->transformation (function (bool $ v ): void {
116102 $ this ->settings ->setTilePreviews ($ v );
117103 })
118104 );
0 commit comments