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');
|
||||
}
|
||||
|
||||
public function getUsers($session_id, $searchString)
|
||||
public function getUsers($session_id, $searchString, $accountState)
|
||||
{
|
||||
if($searchString == "") {
|
||||
return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'search string is empty'];
|
||||
@ -66,7 +66,8 @@ class JsonRequestClientComponent extends Component
|
||||
|
||||
return $this->sendRequest(json_encode([
|
||||
'session_id' => $session_id,
|
||||
'search' => $searchString
|
||||
'search' => $searchString,
|
||||
'account_state' => $accountState,
|
||||
]), '/getUsers');
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +99,14 @@ class StateUsersController extends AppController
|
||||
//$this->set('timeUsed', $timeUsed);
|
||||
$csfr_token = $this->request->getParam('_csrfToken');
|
||||
$this->set(compact('timeUsed', 'searchForm', 'csfr_token'));
|
||||
|
||||
$empty_string = '... empty ...';
|
||||
if ($this->request->is('post')) {
|
||||
$finalUserEntrys = [];
|
||||
$requestData = $this->request->getData();
|
||||
$account_state = $requestData['account_state'];
|
||||
if($requestData['search'] == '' && $account_state != 'all') {
|
||||
$requestData['search'] = $empty_string;
|
||||
}
|
||||
|
||||
if ($searchForm->validate($requestData)) {
|
||||
//var_dump($requestData);
|
||||
@ -111,7 +116,7 @@ class StateUsersController extends AppController
|
||||
$searchType = 'email';
|
||||
}
|
||||
// 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 = [];
|
||||
if ($resultJson['state'] == 'success') {
|
||||
$dataJson = $resultJson['data'];
|
||||
@ -139,19 +144,32 @@ class StateUsersController extends AppController
|
||||
}
|
||||
}
|
||||
// find user on community server db
|
||||
$globalSearch = '%' . $searchString . '%';
|
||||
|
||||
|
||||
|
||||
$communityUsers = $this->StateUsers
|
||||
->find('all')
|
||||
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]);
|
||||
|
||||
if($account_state == 'email not activated') {
|
||||
if(count($pubkeySorted) > 0) {
|
||||
$communityUsers->where(['hex(public_key) IN' => array_keys($pubkeySorted)]);
|
||||
} else {
|
||||
$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());
|
||||
if($communityUsers) {
|
||||
foreach ($communityUsers as $u) {
|
||||
$pubkey_hex = bin2hex(stream_get_contents($u->public_key));
|
||||
$u->public_hex = $pubkey_hex;
|
||||
@ -160,7 +178,8 @@ class StateUsersController extends AppController
|
||||
}
|
||||
array_push($pubkeySorted[$pubkey_hex]['community'], $u);
|
||||
}
|
||||
$finalUserEntrys = [];
|
||||
}
|
||||
|
||||
// detect states
|
||||
foreach ($pubkeySorted as $pubhex => $user) {
|
||||
$finalUser = [];
|
||||
|
||||
@ -11,7 +11,9 @@ class UserSearchForm extends Form
|
||||
|
||||
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)
|
||||
|
||||
@ -11,6 +11,19 @@ $this->assign('title', __('Benutzer suchen'));
|
||||
$this->loadHelper('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([
|
||||
'loginServer/style.css',
|
||||
@ -41,7 +54,8 @@ $this->loadHelper('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->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->hidden('order_row', ['id' => 'input-order-row']) ?>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user