mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add account state as parameter for user search, transmit to login-server and update handling by selecting from community server
This commit is contained in:
parent
83ab670858
commit
ffe6aefa13
@ -55,7 +55,7 @@ class JsonRequestClientComponent extends Component
|
|||||||
]), '/getRunningUserTasks');
|
]), '/getRunningUserTasks');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsers($session_id, $searchString)
|
public function getUsers($session_id, $searchString, $accountState)
|
||||||
{
|
{
|
||||||
if($searchString == "") {
|
if($searchString == "") {
|
||||||
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'search string is empty'];
|
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'search string is empty'];
|
||||||
@ -66,7 +66,8 @@ class JsonRequestClientComponent extends Component
|
|||||||
|
|
||||||
return $this->sendRequest(json_encode([
|
return $this->sendRequest(json_encode([
|
||||||
'session_id' => $session_id,
|
'session_id' => $session_id,
|
||||||
'search' => $searchString
|
'search' => $searchString,
|
||||||
|
'account_state' => $accountState,
|
||||||
]), '/getUsers');
|
]), '/getUsers');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,9 +99,14 @@ class StateUsersController extends AppController
|
|||||||
//$this->set('timeUsed', $timeUsed);
|
//$this->set('timeUsed', $timeUsed);
|
||||||
$csfr_token = $this->request->getParam('_csrfToken');
|
$csfr_token = $this->request->getParam('_csrfToken');
|
||||||
$this->set(compact('timeUsed', 'searchForm', 'csfr_token'));
|
$this->set(compact('timeUsed', 'searchForm', 'csfr_token'));
|
||||||
|
$empty_string = '... empty ...';
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
|
$finalUserEntrys = [];
|
||||||
$requestData = $this->request->getData();
|
$requestData = $this->request->getData();
|
||||||
|
$account_state = $requestData['account_state'];
|
||||||
|
if($requestData['search'] == '' && $account_state != 'all') {
|
||||||
|
$requestData['search'] = $empty_string;
|
||||||
|
}
|
||||||
|
|
||||||
if ($searchForm->validate($requestData)) {
|
if ($searchForm->validate($requestData)) {
|
||||||
//var_dump($requestData);
|
//var_dump($requestData);
|
||||||
@ -111,7 +116,7 @@ class StateUsersController extends AppController
|
|||||||
$searchType = 'email';
|
$searchType = 'email';
|
||||||
}
|
}
|
||||||
// find users on login server
|
// find users on login server
|
||||||
$resultJson = $this->JsonRequestClient->getUsers($session->read('session_id'), $searchString);
|
$resultJson = $this->JsonRequestClient->getUsers($session->read('session_id'), $searchString, $account_state);
|
||||||
$loginServerUser = [];
|
$loginServerUser = [];
|
||||||
if ($resultJson['state'] == 'success') {
|
if ($resultJson['state'] == 'success') {
|
||||||
$dataJson = $resultJson['data'];
|
$dataJson = $resultJson['data'];
|
||||||
@ -139,28 +144,42 @@ class StateUsersController extends AppController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find user on community server db
|
// find user on community server db
|
||||||
$globalSearch = '%' . $searchString . '%';
|
|
||||||
|
|
||||||
|
|
||||||
$communityUsers = $this->StateUsers
|
$communityUsers = $this->StateUsers
|
||||||
->find('all')
|
->find('all')
|
||||||
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]);
|
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]);
|
||||||
|
|
||||||
$communityUsers->where(['OR' => [
|
if($account_state == 'email not activated') {
|
||||||
'first_name LIKE' => $globalSearch,
|
if(count($pubkeySorted) > 0) {
|
||||||
'last_name LIKE' => $globalSearch,
|
$communityUsers->where(['hex(public_key) IN' => array_keys($pubkeySorted)]);
|
||||||
//'username LIKE' => $globalSearch,
|
} else {
|
||||||
'email LIKE' => $globalSearch
|
$communityUsers = null;
|
||||||
]]);
|
}
|
||||||
|
} else {
|
||||||
|
$globalSearch = '%' . $searchString . '%';
|
||||||
|
$communityUsers->where(['OR' => [
|
||||||
|
'first_name LIKE' => $globalSearch,
|
||||||
|
'last_name LIKE' => $globalSearch,
|
||||||
|
//'username LIKE' => $globalSearch,
|
||||||
|
'email LIKE' => $globalSearch
|
||||||
|
]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//var_dump($communityUsers->toArray());
|
//var_dump($communityUsers->toArray());
|
||||||
foreach ($communityUsers as $u) {
|
if($communityUsers) {
|
||||||
$pubkey_hex = bin2hex(stream_get_contents($u->public_key));
|
foreach ($communityUsers as $u) {
|
||||||
$u->public_hex = $pubkey_hex;
|
$pubkey_hex = bin2hex(stream_get_contents($u->public_key));
|
||||||
if (!isset($pubkeySorted[$pubkey_hex])) {
|
$u->public_hex = $pubkey_hex;
|
||||||
$pubkeySorted[$pubkey_hex] = ['login' => [], 'community' => []];
|
if (!isset($pubkeySorted[$pubkey_hex])) {
|
||||||
|
$pubkeySorted[$pubkey_hex] = ['login' => [], 'community' => []];
|
||||||
|
}
|
||||||
|
array_push($pubkeySorted[$pubkey_hex]['community'], $u);
|
||||||
}
|
}
|
||||||
array_push($pubkeySorted[$pubkey_hex]['community'], $u);
|
|
||||||
}
|
}
|
||||||
$finalUserEntrys = [];
|
|
||||||
// detect states
|
// detect states
|
||||||
foreach ($pubkeySorted as $pubhex => $user) {
|
foreach ($pubkeySorted as $pubhex => $user) {
|
||||||
$finalUser = [];
|
$finalUser = [];
|
||||||
|
|||||||
@ -11,7 +11,9 @@ class UserSearchForm extends Form
|
|||||||
|
|
||||||
protected function _buildSchema(Schema $schema)
|
protected function _buildSchema(Schema $schema)
|
||||||
{
|
{
|
||||||
return $schema->addField('search', ['type' => 'string']);
|
return $schema
|
||||||
|
->addField('search', ['type' => 'string'])
|
||||||
|
->addField('account_state', ['type' => 'select']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function validationDefault(Validator $validator)
|
function validationDefault(Validator $validator)
|
||||||
|
|||||||
@ -11,6 +11,19 @@ $this->assign('title', __('Benutzer suchen'));
|
|||||||
$this->loadHelper('Form', [
|
$this->loadHelper('Form', [
|
||||||
'templates' => 'horizontal_form',
|
'templates' => 'horizontal_form',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$stateOptions = [
|
||||||
|
'all' => __('Alle'),
|
||||||
|
//'account created'=>__('Konto angelegt'),
|
||||||
|
//'account not on login-server' => __('Konto nicht auf Login-Server'),
|
||||||
|
//'email activated' => __('Konto aktiviert'),
|
||||||
|
//'account copied to community' => __('Konto auf Gemeinschafts-Server'),
|
||||||
|
'email not activated' => __('Konto nicht aktiviert'),
|
||||||
|
//'account multiple times on login-server' => __('Konto mehrfach vorhanden'),
|
||||||
|
//'account not on community server' => __('Konto nicht auf Gemeinschafts-Server'),
|
||||||
|
//'no keys' => __('Keine Schlüssel generiert')
|
||||||
|
];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?= $this->Html->css([
|
<?= $this->Html->css([
|
||||||
'loginServer/style.css',
|
'loginServer/style.css',
|
||||||
@ -41,7 +54,8 @@ $this->loadHelper('Form', [
|
|||||||
<p class="form-header">Benutzer suchen</p>
|
<p class="form-header">Benutzer suchen</p>
|
||||||
<div class="form-body">
|
<div class="form-body">
|
||||||
<?= $this->Form->create($searchForm, []) ?>
|
<?= $this->Form->create($searchForm, []) ?>
|
||||||
<?= $this->Form->control('search', ['label' => __('Suchbegriff'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname/Nachname/E-Mail')]) ?>
|
<?= $this->Form->control('search', ['label' => __('Suchbegriff'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname/Nachname/E-Mail'), 'required' => false]) ?>
|
||||||
|
<?= $this->Form->control('account_state', ['label' => __('Konto Status'), 'class' => 'form-control', 'type' => 'select', 'options' => $stateOptions]) ?>
|
||||||
<?= $this->Form->button('<i class="material-icons-outlined">search</i> ' . __('Suchen'), ['class' => 'form-button']) ?>
|
<?= $this->Form->button('<i class="material-icons-outlined">search</i> ' . __('Suchen'), ['class' => 'form-button']) ?>
|
||||||
<?= $this->Form->hidden('order_row', ['id' => 'input-order-row']) ?>
|
<?= $this->Form->hidden('order_row', ['id' => 'input-order-row']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user