mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding serverUsers
This commit is contained in:
parent
8c38a5529d
commit
a25f6e05de
@ -1 +1 @@
|
||||
Subproject commit 132a1de23b48f3b685e05fce6e1fbbb25b74671d
|
||||
Subproject commit 055f2bb572244fbd5b4d71c2ca84d4493ae88dd1
|
||||
106
src/Controller/ServerUsersController.php
Normal file
106
src/Controller/ServerUsersController.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Controller\AppController;
|
||||
|
||||
/**
|
||||
* ServerUsers Controller
|
||||
*
|
||||
* @property \App\Model\Table\ServerUsersTable $ServerUsers
|
||||
*
|
||||
* @method \App\Model\Entity\ServerUser[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
|
||||
*/
|
||||
class ServerUsersController extends AppController
|
||||
{
|
||||
/**
|
||||
* Index method
|
||||
*
|
||||
* @return \Cake\Http\Response|null
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$serverUsers = $this->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']);
|
||||
}
|
||||
}
|
||||
49
src/Model/Entity/ServerUser.php
Normal file
49
src/Model/Entity/ServerUser.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace App\Model\Entity;
|
||||
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
* ServerUser Entity
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $username
|
||||
* @property string $password
|
||||
* @property string $email
|
||||
* @property string $role
|
||||
* @property bool $activated
|
||||
* @property \Cake\I18n\FrozenTime|null $last_login
|
||||
* @property \Cake\I18n\FrozenTime $created
|
||||
* @property \Cake\I18n\FrozenTime $modified
|
||||
*/
|
||||
class ServerUser extends Entity
|
||||
{
|
||||
/**
|
||||
* Fields that can be mass assigned using newEntity() or patchEntity().
|
||||
*
|
||||
* Note that when '*' is set to true, this allows all unspecified fields to
|
||||
* be mass assigned. For security purposes, it is advised to set '*' to false
|
||||
* (or remove it), and explicitly make individual fields accessible as needed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_accessible = [
|
||||
'username' => 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'
|
||||
];
|
||||
}
|
||||
101
src/Model/Table/ServerUsersTable.php
Normal file
101
src/Model/Table/ServerUsersTable.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
namespace App\Model\Table;
|
||||
|
||||
use Cake\ORM\Query;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Validation\Validator;
|
||||
|
||||
/**
|
||||
* ServerUsers Model
|
||||
*
|
||||
* @method \App\Model\Entity\ServerUser get($primaryKey, $options = [])
|
||||
* @method \App\Model\Entity\ServerUser newEntity($data = null, array $options = [])
|
||||
* @method \App\Model\Entity\ServerUser[] newEntities(array $data, array $options = [])
|
||||
* @method \App\Model\Entity\ServerUser|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
|
||||
* @method \App\Model\Entity\ServerUser saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
|
||||
* @method \App\Model\Entity\ServerUser patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
|
||||
* @method \App\Model\Entity\ServerUser[] patchEntities($entities, array $data, array $options = [])
|
||||
* @method \App\Model\Entity\ServerUser findOrCreate($search, callable $callback = null, $options = [])
|
||||
*
|
||||
* @mixin \Cake\ORM\Behavior\TimestampBehavior
|
||||
*/
|
||||
class ServerUsersTable extends Table
|
||||
{
|
||||
/**
|
||||
* Initialize method
|
||||
*
|
||||
* @param array $config The configuration for the Table.
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(array $config)
|
||||
{
|
||||
parent::initialize($config);
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
14
src/Template/Pages/gradido.ctp
Normal file
14
src/Template/Pages/gradido.ctp
Normal file
@ -0,0 +1,14 @@
|
||||
<?php $this->layout = false;?><html>
|
||||
<head>
|
||||
<title>Web Assembly Test (CakePHP Single Node Version)</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div id="gradido-mithril">Wird geladen...</div>
|
||||
<script type="text/javascript">
|
||||
csfr = "<?= $this->request->getParam('_csrfToken') ?>";
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<script type="text/javascript" src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
28
src/Template/ServerUsers/add.ctp
Normal file
28
src/Template/ServerUsers/add.ctp
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\ServerUser $serverUser
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('List Server Users'), ['action' => 'index']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="serverUsers form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($serverUser) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Add Server User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('username');
|
||||
echo $this->Form->control('password');
|
||||
echo $this->Form->control('email');
|
||||
echo $this->Form->control('role');
|
||||
echo $this->Form->control('activated');
|
||||
echo $this->Form->control('last_login', ['empty' => true]);
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
34
src/Template/ServerUsers/edit.ctp
Normal file
34
src/Template/ServerUsers/edit.ctp
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\ServerUser $serverUser
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Form->postLink(
|
||||
__('Delete'),
|
||||
['action' => 'delete', $serverUser->id],
|
||||
['confirm' => __('Are you sure you want to delete # {0}?', $serverUser->id)]
|
||||
)
|
||||
?></li>
|
||||
<li><?= $this->Html->link(__('List Server Users'), ['action' => 'index']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="serverUsers form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($serverUser) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Edit Server User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('username');
|
||||
echo $this->Form->control('password');
|
||||
echo $this->Form->control('email');
|
||||
echo $this->Form->control('role');
|
||||
echo $this->Form->control('activated');
|
||||
echo $this->Form->control('last_login', ['empty' => true]);
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
61
src/Template/ServerUsers/index.ctp
Normal file
61
src/Template/ServerUsers/index.ctp
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\ServerUser[]|\Cake\Collection\CollectionInterface $serverUsers
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('New Server User'), ['action' => 'add']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="serverUsers index large-9 medium-8 columns content">
|
||||
<h3><?= __('Server Users') ?></h3>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><?= $this->Paginator->sort('id') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('username') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('password') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('email') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('role') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('activated') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('last_login') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('created') ?></th>
|
||||
<th scope="col"><?= $this->Paginator->sort('modified') ?></th>
|
||||
<th scope="col" class="actions"><?= __('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($serverUsers as $serverUser): ?>
|
||||
<tr>
|
||||
<td><?= $this->Number->format($serverUser->id) ?></td>
|
||||
<td><?= h($serverUser->username) ?></td>
|
||||
<td><?= h($serverUser->password) ?></td>
|
||||
<td><?= h($serverUser->email) ?></td>
|
||||
<td><?= h($serverUser->role) ?></td>
|
||||
<td><?= h($serverUser->activated) ?></td>
|
||||
<td><?= h($serverUser->last_login) ?></td>
|
||||
<td><?= h($serverUser->created) ?></td>
|
||||
<td><?= h($serverUser->modified) ?></td>
|
||||
<td class="actions">
|
||||
<?= $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)]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="paginator">
|
||||
<ul class="pagination">
|
||||
<?= $this->Paginator->first('<< ' . __('first')) ?>
|
||||
<?= $this->Paginator->prev('< ' . __('previous')) ?>
|
||||
<?= $this->Paginator->numbers() ?>
|
||||
<?= $this->Paginator->next(__('next') . ' >') ?>
|
||||
<?= $this->Paginator->last(__('last') . ' >>') ?>
|
||||
</ul>
|
||||
<p><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
56
src/Template/ServerUsers/view.ctp
Normal file
56
src/Template/ServerUsers/view.ctp
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\ServerUser $serverUser
|
||||
*/
|
||||
?>
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('Edit Server User'), ['action' => 'edit', $serverUser->id]) ?> </li>
|
||||
<li><?= $this->Form->postLink(__('Delete Server User'), ['action' => 'delete', $serverUser->id], ['confirm' => __('Are you sure you want to delete # {0}?', $serverUser->id)]) ?> </li>
|
||||
<li><?= $this->Html->link(__('List Server Users'), ['action' => 'index']) ?> </li>
|
||||
<li><?= $this->Html->link(__('New Server User'), ['action' => 'add']) ?> </li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="serverUsers view large-9 medium-8 columns content">
|
||||
<h3><?= h($serverUser->id) ?></h3>
|
||||
<table class="vertical-table">
|
||||
<tr>
|
||||
<th scope="row"><?= __('Username') ?></th>
|
||||
<td><?= h($serverUser->username) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Password') ?></th>
|
||||
<td><?= h($serverUser->password) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Email') ?></th>
|
||||
<td><?= h($serverUser->email) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Role') ?></th>
|
||||
<td><?= h($serverUser->role) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Id') ?></th>
|
||||
<td><?= $this->Number->format($serverUser->id) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Last Login') ?></th>
|
||||
<td><?= h($serverUser->last_login) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Created') ?></th>
|
||||
<td><?= h($serverUser->created) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Modified') ?></th>
|
||||
<td><?= h($serverUser->modified) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Activated') ?></th>
|
||||
<td><?= $serverUser->activated ? __('Yes') : __('No'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user