add new created files from samir

This commit is contained in:
team-devstage 2020-09-24 08:01:11 +02:00
parent 99a68091ae
commit 0e5edbcd65
16 changed files with 1156 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?php
namespace App\Controller;
use App\Controller\AppController;
use Model\Navigation\NaviHierarchy;
use Model\Navigation\NaviHierarchyEntry;
/**
* Roles Controller
*
*
* @method \App\Model\Entity\Role[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class RolesController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|null
*/
public function index()
{
$roles = $this->paginate($this->Roles);
$this->set(compact('roles'));
}
/**
* View method
*
* @param string|null $id Role id.
* @return \Cake\Http\Response|null
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$role = $this->Roles->get($id, [
'contain' => [],
]);
$this->set('role', $role);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$role = $this->Roles->newEntity();
if ($this->request->is('post')) {
$role = $this->Roles->patchEntity($role, $this->request->getData());
if ($this->Roles->save($role)) {
$this->Flash->success(__('The role has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The role could not be saved. Please, try again.'));
}
$this->set(compact('role'));
}
/**
* Edit method
*
* @param string|null $id Role 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)
{
$role = $this->Roles->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$role = $this->Roles->patchEntity($role, $this->request->getData());
if ($this->Roles->save($role)) {
$this->Flash->success(__('The role has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The role could not be saved. Please, try again.'));
}
$this->set(compact('role'));
}
/**
* Delete method
*
* @param string|null $id Role 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']);
$role = $this->Roles->get($id);
if ($this->Roles->delete($role)) {
$this->Flash->success(__('The role has been deleted.'));
} else {
$this->Flash->error(__('The role could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}

View File

@ -0,0 +1,307 @@
<?php
namespace App\Controller;
use Cake\Routing\Router;
use Cake\I18n\I18n;
use Cake\I18n\FrozenTime;
use Cake\ORM\TableRegistry;
use App\Controller\AppController;
use App\Form\UserSearchForm;
use App\Model\Validation\GenericValidation;
use Model\Navigation\NaviHierarchy;
use Model\Navigation\NaviHierarchyEntry;
use Model\Transactions\TransactionCreation;
use App\Model\Table\StateUsersTable;
use App\Form\AssignRoleForm;
/**
* StateUserRoles Controller
*
* @property \App\Model\Table\StateUsersTable $StateUsers
*
* @method \App\Model\Entity\StateUser[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class StateUserRolesController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadComponent('JsonRequestClient');
$this->Auth->allow([
'search'
]);
$this->set(
'naviHierarchy',
(new NaviHierarchy())->
add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))->add(new NaviHierarchyEntry(__('Benutzer suchen'), 'StateUsers', 'search', true))
);
}
public function search()
{
$this->loadModel('StateUsers');
$startTime = microtime(true);
I18n::setLocale('de_DE');
$this->viewBuilder()->setLayout('frontend');
$session = $this->getRequest()->getSession();
$result = $this->requestLogin();
if ($result !== true) {
return $result;
}
$user = $session->read('StateUser');
if ($user['role'] != 'admin') {
return $this->redirect(['controller' => 'dashboard', 'action' => 'index']);
}
$searchForm = new UserSearchForm();
$timeUsed = microtime(true) - $startTime;
//$this->set('timeUsed', $timeUsed);
$csfr_token = $this->request->getParam('_csrfToken');
$this->set(compact('timeUsed', 'searchForm', 'csfr_token'));
if ($this->request->is('post')) {
$requestData = $this->request->getData();
if ($searchForm->validate($requestData)) {
//var_dump($requestData);
$searchString = $requestData['search'];
$searchType = 'unknown';
if (GenericValidation::email($searchString, [])) {
$searchType = 'email';
}
// find users on login server
$resultJson = $this->JsonRequestClient->getUsers($session->read('session_id'), $searchString);
$loginServerUser = [];
if ($resultJson['state'] == 'success') {
$dataJson = $resultJson['data'];
if ($dataJson['state'] != 'success') {
if ($dataJson['msg'] == 'session not found') {
$session->destroy();
return $this->redirect(Router::url('/', true) . 'account', 303);
}
}
//var_dump($dataJson);
if (isset($dataJson['users'])) {
$loginServerUser = $dataJson['users'];
}
}
$pubkeySorted = [];
$emptyPubkeys = [];
foreach ($loginServerUser as $u) {
if (!isset($u['public_hex']) || $u['public_hex'] == '') {
array_push($emptyPubkeys, $u);
} else {
if (!isset($pubkeySorted[$u['public_hex']])) {
$pubkeySorted[$u['public_hex']] = ['login' => [], 'community' => []];
}
array_push($pubkeySorted[$u['public_hex']]['login'], $u);
}
}
// find user on community server db
$globalSearch = '%' . $searchString . '%';
$communityUsers = $this->StateUsers
->find('all')
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]);
$communityUsers->where(['OR' => [
'first_name LIKE' => $globalSearch,
'last_name LIKE' => $globalSearch,
//'username LIKE' => $globalSearch,
'email LIKE' => $globalSearch
]]);
//var_dump($communityUsers->toArray());
foreach ($communityUsers as $u) {
$pubkey_hex = bin2hex(stream_get_contents($u->public_key));
$u->public_hex = $pubkey_hex;
if (!isset($pubkeySorted[$pubkey_hex])) {
$pubkeySorted[$pubkey_hex] = ['login' => [], 'community' => []];
}
array_push($pubkeySorted[$pubkey_hex]['community'], $u);
}
$finalUserEntrys = [];
// detect states
foreach ($pubkeySorted as $pubhex => $user) {
$finalUser = [];
$state = 'account created';
$color = 'secondary';
$finalUser['balance'] = 0;
$finalUser['pubkeyhex'] = $pubhex;
$finalUser['created'] = null;
if (count($user['community']) == 1) {
if (isset($user['community'][0]->state_balances) &&
isset($user['community'][0]->state_balances[0]['amount'])) {
$finalUser['balance'] = $user['community'][0]->state_balances[0]->amount;
}
}
if (count($user['login']) == 0) {
$state = 'account not on login-server';
$color = 'danger';
if (count($user['community']) == 1) {
$c_user = $user['community'][0];
$finalUser['name'] = $c_user->first_name . ' ' . $c_user->last_name;
$finalUser['first_name'] = $c_user->first_name;
$finalUser['last_name'] = $c_user->last_name;
//$finalUser['username'] = $c_user->username;
$finalUser['email'] = $c_user->email;
}
} elseif (count($user['login']) == 1) {
if ($user['login'][0]['email_checked'] == true) {
$state = 'email activated';
$color = 'primary';
if (count($user['community']) == 1) {
$state = 'account copied to community';
$color = 'success';
//var_dump($user['community'][0]->state_balances[0]['amount']);
}
} else {
$state = 'email not activated';
$color = 'warning';
}
$l_user = $user['login'][0];
$finalUser['name'] = $l_user['first_name'] . ' ' . $l_user['last_name'];
$finalUser['first_name'] = $l_user['first_name'];
$finalUser['last_name'] = $l_user['last_name'];
//$finalUser['username'] = $l_user['username'];
$finalUser['email'] = $l_user['email'];
$finalUser['created'] = new FrozenTime($l_user['created']);
} else {
$state = 'account multiple times on login-server';
$color = 'danger';
}
$this->loadModel('Roles');
$state_user_id = $user['community'][0]->id;
$stateUserRole = $this->StateUserRoles->find('all')->where(['state_user_id' => $state_user_id])->all();
$role_ids = "";
foreach ($stateUserRole as $userRole) {
if($role_ids != "")
$role_ids .= ",".$userRole->role_id;
else
$role_ids = $userRole->role_id;
}
$roles = $this->Roles->find('all')->where(['id IN' => explode(",",$role_ids)])->all();
$role_names = "";
foreach($roles as $role)
{
if($role_names != "")
$role_names .= "<br/>".$role->title;
else
$role_names = $role->title;
}
$finalUser['role_name'] = $role_names;
$finalUser['indicator'] = ['name' => $state, 'color' => $color];
array_push($finalUserEntrys, $finalUser);
}
foreach ($emptyPubkeys as $user) {
$finalUser = [];
$state = 'account not on community server';
$color = 'secondary';
if ($user['email_checked'] == false) {
$state = 'email not activated';
$color = 'warning';
} else {
$state = 'no keys';
$color = 'warning';
}
$finalUser['balance'] = 0;
$finalUser['pubkeyhex'] = '';
$finalUser['name'] = $user['first_name'] . ' ' . $user['last_name'];
$finalUser['first_name'] = $user['first_name'];
$finalUser['last_name'] = $user['last_name'];
//$finalUser['username'] = $user['username'];
$finalUser['email'] = $user['email'];
$finalUser['created'] = new FrozenTime($user['created']);
$finalUser['indicator'] = ['name' => $state, 'color' => $color];
array_push($finalUserEntrys, $finalUser);
}
//var_dump($pubkeySorted);
} else {
$this->Flash->error(__('Something was invalid, please try again!'));
}
$this->set('finalUserEntrys', $finalUserEntrys);
}
$timeUsed = microtime(true) - $startTime;
$this->set('timeUsed', $timeUsed);
}
public function assignRole()
{
$this->loadModel('Roles');
$this->loadModel('StateUsers');
if ($this->request->is('post')) {
$requestData = $this->request->getData();
$public_hex = hex2bin($requestData['public_hex']);
$stateUser = $this->StateUsers->find('all')->where(['public_key' => $public_hex])->first();
foreach($requestData['role_id'] as $role_id)
{
$newStateUserRole = $this->StateUserRoles->newEntity();
$post_data = [];
$post_data['state_user_id'] = $stateUser->id;
$post_data['role_id'] = $role_id;
$this->StateUserRoles->patchEntity($newStateUserRole, $post_data);
$this->StateUserRoles->save($newStateUserRole);
}
$this->Flash->success(__('Role has been assigned to User.'));
return $this->redirect(['controller' => 'state-user-roles', 'action' => 'search']);
}
$assignRoleForm = new AssignRoleForm();
$public_hex = $this->request->getParam('pass')[0];
$publichex = hex2bin($public_hex);
$stateUser = $this->StateUsers->find('all')->where(['public_key' => $publichex])->first();
$stateUserRoles = $this->StateUserRoles->find('all')->where(['state_user_id' => $stateUser->id])->all();
$role_ids = "";
foreach ($stateUserRoles as $userRole) {
if($role_ids != "")
$role_ids .= ",".$userRole->role_id;
else
$role_ids = $userRole->role_id;
}
$role_ids = explode(",", $role_ids);
$roles = $this->Roles->find('list', array('fields' => array('id', 'title')));
$this->set('roles', $roles);
$this->set('stateUser', $stateUser);
$this->set('role_ids', $role_ids);
$this->set('assignRoleForm', $assignRoleForm);
$this->set('public_hex', $public_hex);
}
}

26
src/Model/Entity/Role.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* Role Entity
*
* @property int $id
* @property string|null $title
*/
class Role 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 = [
'title' => true,
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* StateUserRole Entity
*
* @property int $id
* @property int $state_user_id
* @property int $role_id
*
* @property \App\Model\Entity\StateUser $state_user
*/
class StateUserRole 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 = [
'state_user_id' => true,
'role_id' => true
];
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* Roles Model
*
* @method \App\Model\Entity\Role get($primaryKey, $options = [])
* @method \App\Model\Entity\Role newEntity($data = null, array $options = [])
* @method \App\Model\Entity\Role[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\Role|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\Role saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\Role patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\Role[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\Role findOrCreate($search, callable $callback = null, $options = [])
*/
class RolesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('roles');
$this->setDisplayField('title');
$this->setPrimaryKey('id');
}
/**
* 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')
->add('id', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
$validator
->scalar('title')
->maxLength('title', 255)
->allowEmptyString('title');
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(['id']));
return $rules;
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* StateUserRoles Model
*
* @property \App\Model\Table\StateUsersTable&\Cake\ORM\Association\BelongsTo $StateUser
* @property \App\Model\Table\RolesTable&\Cake\ORM\Association\BelongsTo $Roles
*
* @method \App\Model\Entity\StateUserRole get($primaryKey, $options = [])
* @method \App\Model\Entity\StateUserRole newEntity($data = null, array $options = [])
* @method \App\Model\Entity\StateUserRole[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\StateUserRole|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\StateUserRole saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\StateUserRole patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\StateUserRole[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\StateUserRole findOrCreate($search, callable $callback = null, $options = [])
*/
class StateUserRolesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('state_user_roles');
$this->setPrimaryKey('id');
$this->belongsTo('StateUser', [
'foreignKey' => 'state_user_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Role', [
'foreignKey' => 'role_id',
'joinType' => 'INNER'
]);
}
/**
* 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');
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->existsIn(['index_id'], 'Indices'));
//$rules->add($rules->existsIn(['state_group_id'], 'StateGroups'));
return $rules;
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Role $role
*/
?>
<nav id="actions-sidebar">
<ul class="nav-horizontal nav-smaller">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('List Roles'), ['action' => 'index']) ?></li>
</ul>
</nav>
<div class="roles form large-9 medium-8 columns content">
<?= $this->Form->create($role) ?>
<fieldset>
<legend><?= __('Add Role') ?></legend>
<?php
echo $this->Form->control('title');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>

View File

@ -0,0 +1,29 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Role $role
*/
?>
<nav id="actions-sidebar">
<ul class="nav-horizontal nav-smaller">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $role->id],
['confirm' => __('Are you sure you want to delete # {0}?', $role->id)]
)
?></li>
<li><?= $this->Html->link(__('List Roles'), ['action' => 'index']) ?></li>
</ul>
</nav>
<div class="roles form large-9 medium-8 columns content">
<?= $this->Form->create($role) ?>
<fieldset>
<legend><?= __('Edit Role') ?></legend>
<?php
echo $this->Form->control('title');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Role[]|\Cake\Collection\CollectionInterface $roles
*/
?>
<nav id="actions-sidebar">
<ul class="nav-horizontal nav-smaller">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('New Role'), ['action' => 'add']) ?></li>
</ul>
</nav>
<div class="roles index large-9 medium-8 columns content">
<h3><?= __('Roles') ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col"><?= $this->Paginator->sort('id') ?></th>
<th scope="col"><?= $this->Paginator->sort('title') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($roles as $role): ?>
<tr>
<td><?= $this->Number->format($role->id) ?></td>
<td><?= h($role->title) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $role->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $role->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $role->id], ['confirm' => __('Are you sure you want to delete # {0}?', $role->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<ul class="nav-horizontal">
<?= $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>

View File

@ -0,0 +1,28 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\Role $role
*/
?>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('Edit Role'), ['action' => 'edit', $role->id]) ?> </li>
<li><?= $this->Form->postLink(__('Delete Role'), ['action' => 'delete', $role->id], ['confirm' => __('Are you sure you want to delete # {0}?', $role->id)]) ?> </li>
<li><?= $this->Html->link(__('List Roles'), ['action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New Role'), ['action' => 'add']) ?> </li>
</ul>
</nav>
<div class="roles view large-9 medium-8 columns content">
<h3><?= h($role->title) ?></h3>
<table class="vertical-table">
<tr>
<th scope="row"><?= __('Title') ?></th>
<td><?= h($role->title) ?></td>
</tr>
<tr>
<th scope="row"><?= __('Id') ?></th>
<td><?= $this->Number->format($role->id) ?></td>
</tr>
</table>
</div>

View File

@ -0,0 +1,49 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$this->assign('title', __('Assign Role'));
// In a View class
$this->loadHelper('Form', [
'templates' => 'horizontal_form',
]);
?>
<?= $this->Html->css([
'loginServer/style.css',
'rippleUI/style.css',
'materialdesignicons.min.css'
]) ?>
<style type="text/css">
td.actions {
padding: 10px 30px;
}
td.actions p {
white-space:normal;
font-size:16px;
}
td.actions ul {
list-style-type:decimal;
padding-left:20px;
}
td.actions ul li {
white-space:initial;
- font-size:14px;
}
td.actions ul li .btn {
margin: 0 15px;
}
</style>
<div class="action-form">
<p class="form-header">Assign Role</p>
<div class="form-body">
<?= $this->Form->create($assignRoleForm, []) ?>
<div>User:&nbsp;&nbsp;<?= $stateUser->first_name." ".$stateUser->last_name ?></div>
<div>Select Role:<br/><?= $this->Form->select('role_id', $roles, ['label' => __('Role'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Role'), "multiple" => "multiple", "value" => $role_ids]) ?></div>
<?= $this->Form->button('<i class="material-icons-outlined"></i>&nbsp;' . __('Assign Role'), ['class' => 'form-button']) ?>
<?= $this->Form->hidden('public_hex', ['id' => 'input-order-row', 'value' => $public_hex]) ?>
</div>
</div>

View File

@ -0,0 +1,69 @@
<?php
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\StateUser[]|\Cake\Collection\CollectionInterface $stateUsers
*/
?>
<nav id="actions-sidebar">
<ul class="nav-horizontal nav-smaller">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('New State User'), ['action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List State Groups'), ['controller' => 'StateGroups', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New State Group'), ['controller' => 'StateGroups', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List State Balances'), ['controller' => 'StateBalances', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New State Balance'), ['controller' => 'StateBalances', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List State Created'), ['controller' => 'StateCreated', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New State Created'), ['controller' => 'StateCreated', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Transaction Creations'), ['controller' => 'TransactionCreations', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Transaction Creation'), ['controller' => 'TransactionCreations', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Transaction Send Coins'), ['controller' => 'TransactionSendCoins', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Transaction Send Coin'), ['controller' => 'TransactionSendCoins', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="stateUsers index large-9 medium-8 columns content">
<h3><?= __('State Users') ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col"><?= $this->Paginator->sort('id') ?></th>
<!--<th scope="col"><?= $this->Paginator->sort('index_id') ?></th>
<th scope="col"><?= $this->Paginator->sort('state_group_id') ?></th>-->
<th scope="col"><?= $this->Paginator->sort('first_name') ?>
<th scope="col"><?= $this->Paginator->sort('last_name') ?>
<th scope="col"><?= $this->Paginator->sort('username') ?>
<th scope="col"><?= $this->Paginator->sort('email') ?>
<th scope="col"><?= $this->Paginator->sort('disabled') ?>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($stateUsers as $stateUser): ?>
<tr>
<td><?= $this->Number->format($stateUser->id) ?></td>
<!--<td><?= $this->Number->format($stateUser->index_id) ?></td>
<td><?= $stateUser->has('state_group') ? $this->Html->link($stateUser->state_group->name, ['controller' => 'StateGroups', 'action' => 'view', $stateUser->state_group->id]) : '' ?></td>-->
<td><?= $stateUser->first_name ?></td>
<td><?= $stateUser->last_name ?></td>
<td><?= $stateUser->username ?></td>
<td><?= $stateUser->email ?></td>
<td><?= $stateUser->disabled ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $stateUser->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $stateUser->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $stateUser->id], ['confirm' => __('Are you sure you want to delete # {0}?', $stateUser->id)]) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<ul class="nav-horizontal">
<?= $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>

View File

@ -0,0 +1,80 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$this->assign('title', __('Benutzer suchen'));
// In a View class
$this->loadHelper('Form', [
'templates' => 'horizontal_form',
]);
?>
<?= $this->Html->css([
'loginServer/style.css',
'rippleUI/style.css',
'materialdesignicons.min.css'
]) ?>
<style type="text/css">
td.actions {
padding: 10px 30px;
}
td.actions p {
white-space:normal;
font-size:16px;
}
td.actions ul {
list-style-type:decimal;
padding-left:20px;
}
td.actions ul li {
white-space:initial;
- font-size:14px;
}
td.actions ul li .btn {
margin: 0 15px;
}
</style>
<div class="action-form">
<p class="form-header">Benutzer suchen</p>
<div class="form-body">
<?= $this->Form->create($searchForm, []) ?>
<?= $this->Form->control('search', ['label' => __('Suchbegriff'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname/Nachname/E-Mail')]) ?>
<?= $this->Form->button('<i class="material-icons-outlined">search</i>&nbsp;' . __('Suchen'), ['class' => 'form-button']) ?>
<?= $this->Form->hidden('order_row', ['id' => 'input-order-row']) ?>
</div>
</div>
<div class="default-container">
<h3><?= __('State Users') ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col" width="25%"><?= $this->Paginator->sort('first_name') ?></th>
<th scope="col" width="25%"><?= $this->Paginator->sort('last_name') ?></th>
<th scope="col"><?= $this->Paginator->sort('email') ?></th>
<th scope="col" width="25%" style="padding-left: 10px;"><?= __('Role') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php
if(!empty($finalUserEntrys))
{
foreach ($finalUserEntrys as $stateUser): ?>
<tr>
<td><?= $stateUser['first_name'] ?></td>
<td><?= $stateUser['last_name'] ?></td>
<td><?= $stateUser['email'] ?></td>
<td style="padding-left: 10px;"><?= $stateUser['role_name'] ?></td>
<td class="actions">
<?= $this->Html->link(__('Assign Role'), ['action' => 'assignRole', $stateUser['pubkeyhex']]) ?>
</td>
</tr>
<?php endforeach; }?>
</tbody>
</table>
</div>
<?php // adding scripts vendor and core from ripple ui for popup/tooltip ?>

View File

@ -0,0 +1,45 @@
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* RolesFixture
*/
class RolesFixture extends TestFixture
{
/**
* Fields
*
* @var array
*/
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
'title' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
'roles_id_IDX' => ['type' => 'unique', 'columns' => ['id'], 'length' => []],
],
'_options' => [
'engine' => 'InnoDB',
'collation' => 'utf8mb4_unicode_ci'
],
];
// @codingStandardsIgnoreEnd
/**
* Init method
*
* @return void
*/
public function init()
{
$this->records = [
[
'id' => 1,
'title' => 'Lorem ipsum dolor sit amet',
],
];
parent::init();
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\RolesController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\RolesController Test Case
*
* @uses \App\Controller\RolesController
*/
class RolesControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.Roles',
];
/**
* Test index method
*
* @return void
*/
public function testIndex()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test view method
*
* @return void
*/
public function testView()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test add method
*
* @return void
*/
public function testAdd()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test edit method
*
* @return void
*/
public function testEdit()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test delete method
*
* @return void
*/
public function testDelete()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\RolesTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\RolesTable Test Case
*/
class RolesTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\RolesTable
*/
public $Roles;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.Roles',
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('Roles') ? [] : ['className' => RolesTable::class];
$this->Roles = TableRegistry::getTableLocator()->get('Roles', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->Roles);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
}