diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php index 830f0fd18..db1255b95 100644 --- a/app/Controller/AppController.php +++ b/app/Controller/AppController.php @@ -122,6 +122,12 @@ public function beforeFilter() { // XXX CO-351 Placeholder $this->Session->write('Config.language', 'eng'); + // CSRF token should expire along with the Session. This is the default in CAKEPHP 3.7.x+ + // https://book.cakephp.org/3/en/controllers/middleware.html#csrf-middleware + // https://github.com/cakephp/cakephp/issues/13532 + // - expiry, How long the CSRF token should last. Defaults to browser session. + $this->Security->csrfUseOnce = false; + Configure::write('Config.language', $this->Session->read('Config.language')); // Tell the Auth module to call the controller's isAuthorized() function. diff --git a/app/Controller/CoPeopleController.php b/app/Controller/CoPeopleController.php index 92f3e7cf7..d02db0029 100644 --- a/app/Controller/CoPeopleController.php +++ b/app/Controller/CoPeopleController.php @@ -252,6 +252,7 @@ public function canvas($id) { // This is pretty similar to the standard view or edit methods. if(!$this->request->is('restful') && $this->request->is('get')) { + $this->set('vv_title_status_bg', true); $this->edit($id); } } diff --git a/app/Controller/StandardController.php b/app/Controller/StandardController.php index b59c2e558..a96808014 100644 --- a/app/Controller/StandardController.php +++ b/app/Controller/StandardController.php @@ -538,7 +538,15 @@ function edit($id) { return; } - + + // Complete the request with the `status` field if it is of type PUT + // Usefull for asychronous single-field Requests + if($req === 'CoPerson' + && empty($this->request->data[$req]["status"]) + && !empty($curdata[$req]["status"])) { + $this->request->data[$req]["status"] = $curdata[$req]["status"]; + } + $data = $this->request->data; if(!isset($this->request->data[$req]['id'])) { @@ -633,6 +641,14 @@ function edit($id) { if($this->request->is('restful')) { $this->Api->restResultHeader(200, "OK"); + } elseif ($this->request->is('ajax')) { + // Return the new data + $this->layout = null; + $this->autoRender = false; + $this->response->type('json'); + $this->response->statusCode(201); + $this->response->body(json_encode(array(0 => $data))); + return $this->response; } else { // Redirect to index view diff --git a/app/View/CoPeople/fields.inc b/app/View/CoPeople/fields.inc index ec1aa9add..1b590b495 100644 --- a/app/View/CoPeople/fields.inc +++ b/app/View/CoPeople/fields.inc @@ -418,7 +418,7 @@ ); $linkparams = array( 'class' => 'addbutton', - //'escape' => false + 'escape' => false ); print $this->Html->link(_txt('op.add'), @@ -566,9 +566,11 @@ _txt('fd.name.primary_name'), $this->Badge->getBadgeColor('Secondary'), false, - true + true, + null, null, + 'ml-1' ); - $cn = $n['primary_name'] ? filter_var(generateCn($n),FILTER_SANITIZE_SPECIAL_CHARS) . " " . $primary_name_with_bg + $cn = $n['primary_name'] ? filter_var(generateCn($n),FILTER_SANITIZE_SPECIAL_CHARS) . $primary_name_with_bg : filter_var(generateCn($n),FILTER_SANITIZE_SPECIAL_CHARS); if($perm == PermissionEnum::ReadWrite) { print $this->Html->link( @@ -945,59 +947,20 @@
  • Form->create('CoPerson', array('url' => array('action'=>'edit','id'=>'CoPersonEditAttributesForm'))); - print $this->Form->hidden('CoPerson.co_id', array('default' => $co_people[0]['CoPerson']['co_id'],'id'=>'CoPersonCoIdAgain')). "\n"; + print $this->Form->create('CoPerson', + array( + 'url' => array( + 'action'=>'edit', + 'id'=>'CoPersonEditAttributesForm', + $co_people[0]['CoPerson']['id'], + ))); + print $this->Form->hidden('CoPerson.co_id', array('default' => $co_people[0]['CoPerson']['co_id'],'id'=>'CoPersonCoIdAgain')). PHP_EOL; ?> indeterminate_check_box