3333Session::checkRight ('entity ' , UPDATE );
3434
3535if (!isset ($ _REQUEST ['id ' ])) {
36- echo __ ('Bad request ' , 'formcreator ' );
36+ Session:: addMessageAfterRedirect ( __ ('Bad request ' , 'formcreator ' ), false , ERROR );
3737 http_response_code (400 );
3838 exit ();
3939}
4040$ questionId = (int ) $ _REQUEST ['id ' ];
4141
4242$ question = new PluginFormcreatorQuestion ();
4343if (!$ question ->getFromDB ($ questionId )) {
44- http_response_code (404 );
45- echo __ ('Question not found ' , 'formcreator ' );
46- exit ;
44+ http_response_code (404 );
45+ Session:: addMessageAfterRedirect ( __ ('Question not found ' , 'formcreator ' ), false , ERROR );
46+ exit ;
4747}
4848
4949if (!$ question ->canUpdate ()) {
50- http_response_code (403 );
51- echo __ ('You don \'t have right for this action ' , 'formcreator ' );
52- exit ;
50+ http_response_code (403 );
51+ Session:: addMessageAfterRedirect ( __ ('You don \'t have right for this action ' , 'formcreator ' ), false , ERROR );
52+ exit ;
5353}
5454
5555$ success = $ question ->update ($ _REQUEST );
5656if (!$ success ) {
57- http_response_code (500 );
58- exit ();
57+ http_response_code (500 );
58+ exit ();
5959}
60- echo $ question ->fields ['name ' ];
60+ echo json_encode ([ ' name ' => $ question ->fields ['name ' ]], JSON_UNESCAPED_UNICODE ) ;
0 commit comments