2020-09-28 01:25:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Controller\AppController;
|
|
|
|
use Cake\Utility\Hash;
|
|
|
|
use Cake\Utility\Text;
|
|
|
|
use \Cake\Database\Expression\QueryExpression;
|
|
|
|
|
|
|
|
class MetaTemplatesController extends AppController
|
|
|
|
{
|
|
|
|
public function update()
|
|
|
|
{
|
2020-11-20 11:09:24 +01:00
|
|
|
if ($this->request->is('post')) {
|
|
|
|
$result = $this->MetaTemplates->update();
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->RestResponse->viewData($result, 'json');
|
|
|
|
} else {
|
|
|
|
$this->Flash->success(__('{0} templates updated.', count($result)));
|
|
|
|
$this->redirect($this->referer());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!$this->ParamHandler->isRest()) {
|
|
|
|
$this->set('title', __('Update Meta Templates'));
|
|
|
|
$this->set('question', __('Are you sure you wish to update the Meta Template definitions?'));
|
|
|
|
$this->set('actionName', __('Update'));
|
|
|
|
$this->set('path', ['controller' => 'metaTemplates', 'action' => 'update']);
|
|
|
|
$this->render('/genericTemplates/confirm');
|
|
|
|
}
|
|
|
|
}
|
2020-09-28 01:25:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$this->CRUD->index([
|
|
|
|
'filters' => ['name', 'uuid', 'scope'],
|
|
|
|
'quickFilters' => ['name', 'uuid', 'scope'],
|
2020-12-07 16:06:01 +01:00
|
|
|
'context' => 'scope',
|
2020-09-28 01:25:07 +02:00
|
|
|
'contain' => ['MetaTemplateFields']
|
|
|
|
]);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
|
|
|
}
|
|
|
|
$this->set('alignmentScope', 'individuals');
|
|
|
|
$this->set('metaGroup', 'Administration');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id)
|
|
|
|
{
|
|
|
|
$this->CRUD->view($id, [
|
|
|
|
'contain' => ['MetaTemplateFields']
|
|
|
|
]);
|
|
|
|
if ($this->ParamHandler->isRest()) {
|
|
|
|
return $this->restResponsePayload;
|
|
|
|
}
|
|
|
|
$this->set('metaGroup', 'Administration');
|
|
|
|
}
|
2020-11-20 11:09:24 +01:00
|
|
|
|
|
|
|
public function toggle($id)
|
|
|
|
{
|
2020-12-07 14:17:10 +01:00
|
|
|
$this->CRUD->toggle($id);
|
2020-11-20 11:09:24 +01:00
|
|
|
if ($this->ParamHandler->isRest()) {
|
2020-12-07 14:17:10 +01:00
|
|
|
return $this->restResponsePayload;
|
|
|
|
} else if($this->ParamHandler->isAjax() && $this->request->is(['post', 'put'])) {
|
|
|
|
return $this->ajaxResponsePayload;
|
2020-11-20 11:09:24 +01:00
|
|
|
}
|
|
|
|
}
|
2020-09-28 01:25:07 +02:00
|
|
|
}
|