1
|
|
|
<?php |
|
|
|
|
2
|
|
|
namespace App\Controller; |
|
|
|
|
3
|
|
|
|
4
|
|
|
use App\Controller\AppController; |
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Useroptions Controller |
8
|
|
|
* |
9
|
|
|
* @property \App\Model\Table\UseroptionsTable $Useroptions |
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
class UseroptionsController extends AppController |
12
|
|
|
{ |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Index method |
16
|
|
|
* |
17
|
|
|
* @return \Cake\Network\Response|null |
|
|
|
|
18
|
|
|
*/ |
19
|
|
|
public function index() |
20
|
|
|
{ |
|
|
|
|
21
|
|
|
$this->paginate = [ |
22
|
|
|
'contain' => ['Users'] |
|
|
|
|
23
|
|
|
]; |
24
|
|
|
$useroptions = $this->paginate($this->Useroptions); |
|
|
|
|
25
|
|
|
|
26
|
|
|
$this->set(compact('useroptions')); |
27
|
|
|
$this->set('_serialize', ['useroptions']); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* View method |
32
|
|
|
* |
33
|
|
|
* @param string|null $id Useroption id. |
|
|
|
|
34
|
|
|
* @return \Cake\Network\Response|null |
|
|
|
|
35
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
|
|
|
36
|
|
|
*/ |
37
|
|
|
public function view($id = null) |
38
|
|
|
{ |
|
|
|
|
39
|
|
|
$useroption = $this->Useroptions->get($id, [ |
40
|
|
|
'contain' => ['Users'] |
|
|
|
|
41
|
|
|
]); |
42
|
|
|
|
43
|
|
|
$this->set('useroption', $useroption); |
44
|
|
|
$this->set('_serialize', ['useroption']); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Add method |
49
|
|
|
* |
50
|
|
|
* @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise. |
51
|
|
|
*/ |
52
|
|
|
public function add() |
53
|
|
|
{ |
|
|
|
|
54
|
|
|
$useroption = $this->Useroptions->newEntity(); |
55
|
|
|
if ($this->request->is('post')) { |
56
|
|
|
$useroption = $this->Useroptions->patchEntity($useroption, $this->request->data); |
57
|
|
|
if ($this->Useroptions->save($useroption)) { |
58
|
|
|
$this->Flash->success(__('The useroption has been saved.')); |
59
|
|
|
|
60
|
|
|
return $this->redirect(['action' => 'index']); |
61
|
|
|
} |
|
|
|
|
62
|
|
|
$this->Flash->error(__('The useroption could not be saved. Please, try again.')); |
63
|
|
|
} |
|
|
|
|
64
|
|
|
$users = $this->Useroptions->Users->find('list', ['limit' => 200]); |
65
|
|
|
$this->set(compact('useroption', 'users')); |
66
|
|
|
$this->set('_serialize', ['useroption']); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Edit method |
71
|
|
|
* |
72
|
|
|
* @param string|null $id Useroption id. |
|
|
|
|
73
|
|
|
* @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise. |
|
|
|
|
74
|
|
|
* @throws \Cake\Network\Exception\NotFoundException When record not found. |
|
|
|
|
75
|
|
|
*/ |
76
|
|
|
public function edit($id = null) |
77
|
|
|
{ |
|
|
|
|
78
|
|
|
$useroption = $this->Useroptions->get($id, [ |
79
|
|
|
'contain' => [] |
|
|
|
|
80
|
|
|
]); |
81
|
|
|
if ($this->request->is(['patch', 'post', 'put'])) { |
82
|
|
|
$useroption = $this->Useroptions->patchEntity($useroption, $this->request->data); |
83
|
|
|
if ($this->Useroptions->save($useroption)) { |
84
|
|
|
$this->Flash->success(__('The useroption has been saved.')); |
85
|
|
|
|
86
|
|
|
return $this->redirect(['action' => 'index']); |
87
|
|
|
} |
|
|
|
|
88
|
|
|
$this->Flash->error(__('The useroption could not be saved. Please, try again.')); |
89
|
|
|
} |
|
|
|
|
90
|
|
|
$users = $this->Useroptions->Users->find('list', ['limit' => 200]); |
91
|
|
|
$this->set(compact('useroption', 'users')); |
92
|
|
|
$this->set('_serialize', ['useroption']); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Delete method |
97
|
|
|
* |
98
|
|
|
* @param string|null $id Useroption id. |
|
|
|
|
99
|
|
|
* @return \Cake\Network\Response|null Redirects to index. |
|
|
|
|
100
|
|
|
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
|
|
|
|
101
|
|
|
*/ |
102
|
|
|
public function delete($id = null) |
103
|
|
|
{ |
|
|
|
|
104
|
|
|
$this->request->allowMethod(['post', 'delete']); |
105
|
|
|
$useroption = $this->Useroptions->get($id); |
106
|
|
|
if ($this->Useroptions->delete($useroption)) { |
107
|
|
|
$this->Flash->success(__('The useroption has been deleted.')); |
108
|
|
|
} else { |
|
|
|
|
109
|
|
|
$this->Flash->error(__('The useroption could not be deleted. Please, try again.')); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $this->redirect(['action' => 'index']); |
113
|
|
|
} |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|