diff --git a/mithril_client b/mithril_client index 132a1de23..055f2bb57 160000 --- a/mithril_client +++ b/mithril_client @@ -1 +1 @@ -Subproject commit 132a1de23b48f3b685e05fce6e1fbbb25b74671d +Subproject commit 055f2bb572244fbd5b4d71c2ca84d4493ae88dd1 diff --git a/src/Controller/ServerUsersController.php b/src/Controller/ServerUsersController.php new file mode 100644 index 000000000..7bc23e033 --- /dev/null +++ b/src/Controller/ServerUsersController.php @@ -0,0 +1,106 @@ +paginate($this->ServerUsers); + + $this->set(compact('serverUsers')); + } + + /** + * View method + * + * @param string|null $id Server User id. + * @return \Cake\Http\Response|null + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function view($id = null) + { + $serverUser = $this->ServerUsers->get($id, [ + 'contain' => [] + ]); + + $this->set('serverUser', $serverUser); + } + + /** + * Add method + * + * @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise. + */ + public function add() + { + $serverUser = $this->ServerUsers->newEntity(); + if ($this->request->is('post')) { + $serverUser = $this->ServerUsers->patchEntity($serverUser, $this->request->getData()); + if ($this->ServerUsers->save($serverUser)) { + $this->Flash->success(__('The server user has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The server user could not be saved. Please, try again.')); + } + $this->set(compact('serverUser')); + } + + /** + * Edit method + * + * @param string|null $id Server User id. + * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function edit($id = null) + { + $serverUser = $this->ServerUsers->get($id, [ + 'contain' => [] + ]); + if ($this->request->is(['patch', 'post', 'put'])) { + $serverUser = $this->ServerUsers->patchEntity($serverUser, $this->request->getData()); + if ($this->ServerUsers->save($serverUser)) { + $this->Flash->success(__('The server user has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The server user could not be saved. Please, try again.')); + } + $this->set(compact('serverUser')); + } + + /** + * Delete method + * + * @param string|null $id Server User id. + * @return \Cake\Http\Response|null Redirects to index. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function delete($id = null) + { + $this->request->allowMethod(['post', 'delete']); + $serverUser = $this->ServerUsers->get($id); + if ($this->ServerUsers->delete($serverUser)) { + $this->Flash->success(__('The server user has been deleted.')); + } else { + $this->Flash->error(__('The server user could not be deleted. Please, try again.')); + } + + return $this->redirect(['action' => 'index']); + } +} diff --git a/src/Model/Entity/ServerUser.php b/src/Model/Entity/ServerUser.php new file mode 100644 index 000000000..c180e060f --- /dev/null +++ b/src/Model/Entity/ServerUser.php @@ -0,0 +1,49 @@ + true, + 'password' => true, + 'email' => true, + 'role' => true, + 'activated' => true, + 'last_login' => true, + 'created' => true, + 'modified' => true + ]; + + /** + * Fields that are excluded from JSON versions of the entity. + * + * @var array + */ + protected $_hidden = [ + 'password' + ]; +} diff --git a/src/Model/Table/ServerUsersTable.php b/src/Model/Table/ServerUsersTable.php new file mode 100644 index 000000000..63b6fb2fe --- /dev/null +++ b/src/Model/Table/ServerUsersTable.php @@ -0,0 +1,101 @@ +setTable('server_users'); + $this->setDisplayField('id'); + $this->setPrimaryKey('id'); + + $this->addBehavior('Timestamp'); + } + + /** + * Default validation rules. + * + * @param \Cake\Validation\Validator $validator Validator instance. + * @return \Cake\Validation\Validator + */ + public function validationDefault(Validator $validator) + { + $validator + ->integer('id') + ->allowEmptyString('id', null, 'create'); + + $validator + ->scalar('username') + ->maxLength('username', 50) + ->requirePresence('username', 'create') + ->notEmptyString('username'); + + $validator + ->scalar('password') + ->maxLength('password', 255) + ->requirePresence('password', 'create') + ->notEmptyString('password'); + + $validator + ->email('email') + ->requirePresence('email', 'create') + ->notEmptyString('email'); + + $validator + ->scalar('role') + ->maxLength('role', 20) + ->notEmptyString('role'); + + $validator + ->boolean('activated') + ->notEmptyString('activated'); + + $validator + ->dateTime('last_login') + ->allowEmptyDateTime('last_login'); + + return $validator; + } + + /** + * Returns a rules checker object that will be used for validating + * application integrity. + * + * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. + * @return \Cake\ORM\RulesChecker + */ + public function buildRules(RulesChecker $rules) + { + $rules->add($rules->isUnique(['username'])); + $rules->add($rules->isUnique(['email'])); + + return $rules; + } +} diff --git a/src/Template/Pages/gradido.ctp b/src/Template/Pages/gradido.ctp new file mode 100644 index 000000000..14d4bb3fc --- /dev/null +++ b/src/Template/Pages/gradido.ctp @@ -0,0 +1,14 @@ +layout = false;?> +
+| = $this->Paginator->sort('id') ?> | += $this->Paginator->sort('username') ?> | += $this->Paginator->sort('password') ?> | += $this->Paginator->sort('email') ?> | += $this->Paginator->sort('role') ?> | += $this->Paginator->sort('activated') ?> | += $this->Paginator->sort('last_login') ?> | += $this->Paginator->sort('created') ?> | += $this->Paginator->sort('modified') ?> | += __('Actions') ?> | +
|---|---|---|---|---|---|---|---|---|---|
| = $this->Number->format($serverUser->id) ?> | += h($serverUser->username) ?> | += h($serverUser->password) ?> | += h($serverUser->email) ?> | += h($serverUser->role) ?> | += h($serverUser->activated) ?> | += h($serverUser->last_login) ?> | += h($serverUser->created) ?> | += h($serverUser->modified) ?> | ++ = $this->Html->link(__('View'), ['action' => 'view', $serverUser->id]) ?> + = $this->Html->link(__('Edit'), ['action' => 'edit', $serverUser->id]) ?> + = $this->Form->postLink(__('Delete'), ['action' => 'delete', $serverUser->id], ['confirm' => __('Are you sure you want to delete # {0}?', $serverUser->id)]) ?> + | +
= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?>
+| = __('Username') ?> | += h($serverUser->username) ?> | +
|---|---|
| = __('Password') ?> | += h($serverUser->password) ?> | +
| = __('Email') ?> | += h($serverUser->email) ?> | +
| = __('Role') ?> | += h($serverUser->role) ?> | +
| = __('Id') ?> | += $this->Number->format($serverUser->id) ?> | +
| = __('Last Login') ?> | += h($serverUser->last_login) ?> | +
| = __('Created') ?> | += h($serverUser->created) ?> | +
| = __('Modified') ?> | += h($serverUser->modified) ?> | +
| = __('Activated') ?> | += $serverUser->activated ? __('Yes') : __('No'); ?> | +