diff --git a/community_server/src/Controller/Component/JsonRequestClientComponent.php b/community_server/src/Controller/Component/JsonRequestClientComponent.php index 8a071b70b..66e65e3bb 100644 --- a/community_server/src/Controller/Component/JsonRequestClientComponent.php +++ b/community_server/src/Controller/Component/JsonRequestClientComponent.php @@ -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'); } diff --git a/community_server/src/Controller/StateUsersController.php b/community_server/src/Controller/StateUsersController.php index d85f8b449..9f07fffdb 100644 --- a/community_server/src/Controller/StateUsersController.php +++ b/community_server/src/Controller/StateUsersController.php @@ -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,28 +144,42 @@ class StateUsersController extends AppController } } // 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' => []]; + + if($account_state == 'email not activated') { + if(count($pubkeySorted) > 0) { + $communityUsers->where(['hex(public_key) IN' => array_keys($pubkeySorted)]); + } else { + $communityUsers = null; } - array_push($pubkeySorted[$pubkey_hex]['community'], $u); + } else { + $globalSearch = '%' . $searchString . '%'; + $communityUsers->where(['OR' => [ + 'first_name LIKE' => $globalSearch, + 'last_name LIKE' => $globalSearch, + //'username LIKE' => $globalSearch, + 'email LIKE' => $globalSearch + ]]); } - $finalUserEntrys = []; + + + //var_dump($communityUsers->toArray()); + if($communityUsers) { + 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); + } + } + // detect states foreach ($pubkeySorted as $pubhex => $user) { $finalUser = []; diff --git a/community_server/src/Form/UserSearchForm.php b/community_server/src/Form/UserSearchForm.php index e2955e244..c68269920 100644 --- a/community_server/src/Form/UserSearchForm.php +++ b/community_server/src/Form/UserSearchForm.php @@ -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) diff --git a/community_server/src/Template/StateUsers/search.ctp b/community_server/src/Template/StateUsers/search.ctp index e6775729b..07a20210c 100644 --- a/community_server/src/Template/StateUsers/search.ctp +++ b/community_server/src/Template/StateUsers/search.ctp @@ -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', [
Benutzer suchen