mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
cleanup samirs code, remove not needed stuff from my old code -Dario
This commit is contained in:
parent
0e5edbcd65
commit
35b14d7480
@ -34,7 +34,7 @@ class StateUserRolesController extends AppController
|
|||||||
parent::initialize();
|
parent::initialize();
|
||||||
$this->loadComponent('JsonRequestClient');
|
$this->loadComponent('JsonRequestClient');
|
||||||
$this->Auth->allow([
|
$this->Auth->allow([
|
||||||
'search'
|
// 'search'
|
||||||
]);
|
]);
|
||||||
$this->set(
|
$this->set(
|
||||||
'naviHierarchy',
|
'naviHierarchy',
|
||||||
@ -49,22 +49,12 @@ class StateUserRolesController extends AppController
|
|||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
I18n::setLocale('de_DE');
|
I18n::setLocale('de_DE');
|
||||||
$this->viewBuilder()->setLayout('frontend');
|
$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();
|
$searchForm = new UserSearchForm();
|
||||||
|
|
||||||
$timeUsed = microtime(true) - $startTime;
|
$timeUsed = microtime(true) - $startTime;
|
||||||
//$this->set('timeUsed', $timeUsed);
|
//$this->set('timeUsed', $timeUsed);
|
||||||
$csfr_token = $this->request->getParam('_csrfToken');
|
$this->set(compact('timeUsed', 'searchForm'));
|
||||||
$this->set(compact('timeUsed', 'searchForm', 'csfr_token'));
|
|
||||||
|
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
$requestData = $this->request->getData();
|
$requestData = $this->request->getData();
|
||||||
@ -72,43 +62,12 @@ class StateUserRolesController extends AppController
|
|||||||
if ($searchForm->validate($requestData)) {
|
if ($searchForm->validate($requestData)) {
|
||||||
//var_dump($requestData);
|
//var_dump($requestData);
|
||||||
$searchString = $requestData['search'];
|
$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
|
// find user on community server db
|
||||||
$globalSearch = '%' . $searchString . '%';
|
$globalSearch = '%' . $searchString . '%';
|
||||||
$communityUsers = $this->StateUsers
|
$communityUsers = $this->StateUsers
|
||||||
->find('all')
|
->find('all')
|
||||||
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]);
|
->contain([]);
|
||||||
|
|
||||||
$communityUsers->where(['OR' => [
|
$communityUsers->where(['OR' => [
|
||||||
'first_name LIKE' => $globalSearch,
|
'first_name LIKE' => $globalSearch,
|
||||||
@ -118,71 +77,15 @@ class StateUserRolesController extends AppController
|
|||||||
]]);
|
]]);
|
||||||
|
|
||||||
//var_dump($communityUsers->toArray());
|
//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 = [];
|
$finalUserEntrys = [];
|
||||||
// detect states
|
// detect states
|
||||||
foreach ($pubkeySorted as $pubhex => $user) {
|
$this->loadModel('Roles');
|
||||||
$finalUser = [];
|
// foreach ($pubkeySorted as $pubhex => $user) {
|
||||||
$state = 'account created';
|
foreach($communityUsers as $communityUser) {
|
||||||
$color = 'secondary';
|
$finalUser = $communityUser;
|
||||||
$finalUser['balance'] = 0;
|
$finalUser['pubkeyhex'] = bin2hex(stream_get_contents($communityUser->public_key));
|
||||||
$finalUser['pubkeyhex'] = $pubhex;
|
|
||||||
$finalUser['created'] = null;
|
|
||||||
|
|
||||||
if (count($user['community']) == 1) {
|
$state_user_id = $communityUser->id;
|
||||||
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();
|
$stateUserRole = $this->StateUserRoles->find('all')->where(['state_user_id' => $state_user_id])->all();
|
||||||
|
|
||||||
$role_ids = "";
|
$role_ids = "";
|
||||||
@ -206,34 +109,9 @@ class StateUserRolesController extends AppController
|
|||||||
|
|
||||||
$finalUser['role_name'] = $role_names;
|
$finalUser['role_name'] = $role_names;
|
||||||
|
|
||||||
$finalUser['indicator'] = ['name' => $state, 'color' => $color];
|
|
||||||
array_push($finalUserEntrys, $finalUser);
|
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);
|
//var_dump($pubkeySorted);
|
||||||
} else {
|
} else {
|
||||||
$this->Flash->error(__('Something was invalid, please try again!'));
|
$this->Flash->error(__('Something was invalid, please try again!'));
|
||||||
|
|||||||
@ -12,31 +12,6 @@ $this->loadHelper('Form', [
|
|||||||
'templates' => 'horizontal_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">
|
<div class="action-form">
|
||||||
<p class="form-header">Benutzer suchen</p>
|
<p class="form-header">Benutzer suchen</p>
|
||||||
<div class="form-body">
|
<div class="form-body">
|
||||||
@ -76,5 +51,3 @@ $this->loadHelper('Form', [
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<?php // adding scripts vendor and core from ripple ui for popup/tooltip ?>
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user