@@ -228,20 +228,32 @@ public function setCanAdd($bool) {
228
228
* @return boolean
229
229
*/
230
230
public function canAdd () {
231
+ if ($ this ->readonly ) {
232
+ return false ;
233
+ }
234
+
231
235
return $ this ->canAdd ;
232
236
}
233
237
234
238
/**
235
239
* @return boolean
236
240
*/
237
241
public function canRemove () {
242
+ if ($ this ->readonly ) {
243
+ return false ;
244
+ }
245
+
238
246
return $ this ->canRemove ;
239
247
}
240
248
241
249
/**
242
250
* @return boolean
243
251
*/
244
252
public function canSort () {
253
+ if ($ this ->readonly ) {
254
+ return false ;
255
+ }
256
+
245
257
return $ this ->canSort ;
246
258
}
247
259
@@ -369,6 +381,10 @@ public function saveRecord()
369
381
return Controller::curr ()->httpError (400 );
370
382
}
371
383
384
+ if ($ this ->readonly ) {
385
+ return Controller::curr ()->httpError (401 );
386
+ }
387
+
372
388
$ index = Controller::curr ()->getRequest ()->requestVar ('ID ' );
373
389
$ class = Controller::curr ()->getRequest ()->requestVar ('ClassName ' );
374
390
@@ -437,15 +453,14 @@ public function recordForm()
437
453
438
454
$ record = $ class ::get ()->byId ($ index );
439
455
440
- if (!$ record || !$ record ->canEdit ()) {
456
+ if (!$ record || !$ record ->canView ()) {
441
457
return Controller::curr ()->httpError (404 );
442
458
}
443
459
444
460
$ response = new HTTPResponse ();
445
461
446
462
$ edit = $ this ->generateRow (0 , $ record , false );
447
463
$ edit ->removeExtraClass ('row manyfield__row ' );
448
-
449
464
$ response ->setBody ($ edit ->FieldHolder ());
450
465
451
466
return $ response ;
@@ -462,6 +477,10 @@ public function deleteRecord()
462
477
return Controller::curr ()->httpError (400 );
463
478
}
464
479
480
+ if ($ this ->readonly ) {
481
+ return Controller::curr ()->httpError (401 );
482
+ }
483
+
465
484
$ index = Controller::curr ()->getRequest ()->getVar ('ID ' );
466
485
$ class = Controller::curr ()->getRequest ()->getVar ('ClassName ' );
467
486
@@ -638,6 +657,9 @@ public function generateRow($index, $value = null, $prefixName = true)
638
657
$ field = clone $ child ;
639
658
$ field = $ this ->updateManyNestedField ($ field , $ index , $ value , $ prefixName );
640
659
660
+ $ field = $ field ->setReadonly ($ this ->readonly );
661
+ $ field = $ field ->setDisabled ($ this ->readonly );
662
+
641
663
$ row ->push ($ field );
642
664
}
643
665
0 commit comments