From adb948d1a52963ae3588fe845c6cc6051cb876e2 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 21 Aug 2020 13:05:31 +0000 Subject: [PATCH 1/9] adding error transaction api endpoint, only empty function --- src/Controller/JsonRequestHandlerController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Controller/JsonRequestHandlerController.php b/src/Controller/JsonRequestHandlerController.php index 89d07a93f..d97f27373 100644 --- a/src/Controller/JsonRequestHandlerController.php +++ b/src/Controller/JsonRequestHandlerController.php @@ -58,11 +58,20 @@ class JsonRequestHandlerController extends AppController { case 'checkUser': return $this->checkUser($jsonData->email, $jsonData->last_name); case 'getUsers' : return $this->getUsers($jsonData->page, $jsonData->limit); case 'getUserBalance': return $this->getUserBalance($jsonData->email, $jsonData->last_name); + case 'errorInTransaction': return $this->errorInTransaction($jsonData->created, $jsonData->transactionSha256, $jsonData->error, $jsonData->errorMessage); } return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for post', 'details' => $method]); } return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']); } + + //! \param $transactionCreated creation of transaction in timestamp in seconds + //! \param $transactionBodyBase64Sha256 sha256 hash from transaction body serialized and converted to base64 + //! \param $error short error name in user language + //! \param $errorDetails more detailed error message in user language + private function errorInTransaction($transactionCreated, $transactionBodyBase64Sha256, $error, $errorDetails) { + + } private function putTransaction($transactionBase64) { $transaction = new Transaction($transactionBase64); From 28ab6f3810da9823a1d36d6be2a901561cda10c6 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 21 Aug 2020 13:16:58 +0000 Subject: [PATCH 2/9] change to blake2 --- src/Controller/JsonRequestHandlerController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Controller/JsonRequestHandlerController.php b/src/Controller/JsonRequestHandlerController.php index d97f27373..af93d2190 100644 --- a/src/Controller/JsonRequestHandlerController.php +++ b/src/Controller/JsonRequestHandlerController.php @@ -58,7 +58,7 @@ class JsonRequestHandlerController extends AppController { case 'checkUser': return $this->checkUser($jsonData->email, $jsonData->last_name); case 'getUsers' : return $this->getUsers($jsonData->page, $jsonData->limit); case 'getUserBalance': return $this->getUserBalance($jsonData->email, $jsonData->last_name); - case 'errorInTransaction': return $this->errorInTransaction($jsonData->created, $jsonData->transactionSha256, $jsonData->error, $jsonData->errorMessage); + case 'errorInTransaction': return $this->errorInTransaction($jsonData->created, $jsonData->transactionGenericHash, $jsonData->error, $jsonData->errorMessage); } return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for post', 'details' => $method]); } @@ -66,10 +66,11 @@ class JsonRequestHandlerController extends AppController { } //! \param $transactionCreated creation of transaction in timestamp in seconds - //! \param $transactionBodyBase64Sha256 sha256 hash from transaction body serialized and converted to base64 + //! \param $transactionBodyBase64Sha256 generic hash from transaction body serialized and converted to base64 + //! using sodium_crypto_generichash to calculate //! \param $error short error name in user language //! \param $errorDetails more detailed error message in user language - private function errorInTransaction($transactionCreated, $transactionBodyBase64Sha256, $error, $errorDetails) { + private function errorInTransaction($transactionCreated, $transactionBodyBase64GenericHash, $error, $errorDetails) { } From e143a5c72954967d06738890c4b0035a68e19db7 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 4 Sep 2020 14:40:44 +0000 Subject: [PATCH 3/9] js for login server --- .../JsonRequestHandlerController.php | 2 + .../TransactionSendCoinsController.php | 2 +- webroot/js/time_calculations.js | 68 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 webroot/js/time_calculations.js diff --git a/src/Controller/JsonRequestHandlerController.php b/src/Controller/JsonRequestHandlerController.php index af93d2190..cced85daa 100644 --- a/src/Controller/JsonRequestHandlerController.php +++ b/src/Controller/JsonRequestHandlerController.php @@ -66,8 +66,10 @@ class JsonRequestHandlerController extends AppController { } //! \param $transactionCreated creation of transaction in timestamp in seconds + //! -1 if transaction couldn't decode //! \param $transactionBodyBase64Sha256 generic hash from transaction body serialized and converted to base64 //! using sodium_crypto_generichash to calculate + // hash also in base64 format //! \param $error short error name in user language //! \param $errorDetails more detailed error message in user language private function errorInTransaction($transactionCreated, $transactionBodyBase64GenericHash, $error, $errorDetails) { diff --git a/src/Controller/TransactionSendCoinsController.php b/src/Controller/TransactionSendCoinsController.php index 40cccb90e..d49038148 100644 --- a/src/Controller/TransactionSendCoinsController.php +++ b/src/Controller/TransactionSendCoinsController.php @@ -187,7 +187,7 @@ class TransactionSendCoinsController extends AppController $this->set('timeUsed', microtime(true) - $startTime); return; } - if($requestAnswear['data']['userData']['disabled']) { + if(isset($requestAnswear['data']['userData']['disabled']) && $requestAnswear['data']['userData']['disabled']) { $this->Flash->error(__('Der Empfänger ist deaktiviert, daher können ihm zurzeit keine Gradidos gesendet werden.')); $this->set('timeUsed', microtime(true) - $startTime); return; diff --git a/webroot/js/time_calculations.js b/webroot/js/time_calculations.js new file mode 100644 index 000000000..7ca61c492 --- /dev/null +++ b/webroot/js/time_calculations.js @@ -0,0 +1,68 @@ +/* + * 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. + */ + + + +var SECONDS_TO_YEAR = 31536000; +var SECONDS_TO_DAY = 86400; +var SECONDS_TO_HOUR = 3600; +var SECONDS_TO_MINUTE = 60; +SECONDS_TO = { + YEAR: SECONDS_TO_YEAR, + DAY: SECONDS_TO_DAY, + HOUR: SECONDS_TO_HOUR, + MINUTE: SECONDS_TO_MINUTE +}; + + + +function getReadableAge(timestamp) { + if(timestamp === undefined) { + return "no timestamp" + } + var ageSeconds = ((new Date()).getTime()/1000) - timestamp; + if(ageSeconds < SECONDS_TO_MINUTE) { + return Math.round(ageSeconds) + " seconds"; + } else if(ageSeconds < SECONDS_TO_HOUR) { + return "~ " + Math.round(ageSeconds / SECONDS_TO_MINUTE) + " minutes"; + } else if(ageSeconds < SECONDS_TO_DAY) { + return "~ " + Math.round(ageSeconds / SECONDS_TO_HOUR) + " hours"; + } else if(ageSeconds < SECONDS_TO_YEAR) { + return "~ " + Math.round(ageSeconds / SECONDS_TO_DAY) + " days"; + } else { + return "~ " + Math.round(ageSeconds / SECONDS_TO_YEAR) + " years"; + } +} + +function getExactTimeDuration(durationSeconds) { + var parts = { + seconds: durationSeconds, + minutes: 0, + hours: 0, + days: 0, + years: 0 + }; + var durationString = ''; + for(var i in SECONDS_TO) { + if(parts.seconds > SECONDS_TO[i]) { + var partIndexName = i.toLowerCase() + 's'; + parts[partIndexName] = Math.floor(parts.seconds / SECONDS_TO[i]); + parts.seconds -= parts[partIndexName] * SECONDS_TO[i]; + if(durationString.length > 0) { + durationString += ', '; + } + var unitName = partIndexName; + if(parts[partIndexName] === 1) { + unitName = partIndexName.substring(0, partIndexName.length-1); + } + durationString += parts[partIndexName] + ' ' + unitName; + break; + } + + } + return durationString; + +} \ No newline at end of file From a7ecfa45d9aad0b91129bd67f7043317a950b172 Mon Sep 17 00:00:00 2001 From: team-devstage Date: Mon, 7 Sep 2020 16:34:33 +0200 Subject: [PATCH 4/9] update grd styles --- mithril_client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mithril_client b/mithril_client index 21d4a0a5e..a04d47699 160000 --- a/mithril_client +++ b/mithril_client @@ -1 +1 @@ -Subproject commit 21d4a0a5e9a19f251e26c0ae07ce74be2fa99bbf +Subproject commit a04d4769974b9d93ba72e490ed7dca3fbaed768c From 69e7897fddb9451f73e6c653a4d91c03f0ec9662 Mon Sep 17 00:00:00 2001 From: team-devstage Date: Tue, 15 Sep 2020 14:57:29 +0200 Subject: [PATCH 5/9] git checkout work of samir --- src/Controller/AppController.php | 1 - src/Controller/ServerUsersController.php | 2 +- src/Template/Dashboard/index.ctp | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 94b99da73..97da257b3 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -129,7 +129,6 @@ class AppController extends Controller if ($this->Auth->user('id')) { $GLOBALS['ServerUser'] = $this->Auth->user(); } - // login server url $loginServer = Configure::read('LoginServer'); if ($loginServer && isset($loginServer['url'])) { diff --git a/src/Controller/ServerUsersController.php b/src/Controller/ServerUsersController.php index 52165bb3b..236e35b7f 100644 --- a/src/Controller/ServerUsersController.php +++ b/src/Controller/ServerUsersController.php @@ -15,7 +15,7 @@ class ServerUsersController extends AppController public function initialize() { parent::initialize(); - //$this->Auth->allow(['add', 'edit']); + $this->Auth->allow(['add', 'edit']); $this->Auth->deny('index'); } diff --git a/src/Template/Dashboard/index.ctp b/src/Template/Dashboard/index.ctp index 3e93e968a..095234222 100644 --- a/src/Template/Dashboard/index.ctp +++ b/src/Template/Dashboard/index.ctp @@ -111,4 +111,25 @@ $this->assign( +
+

Roles ...

+
+
+ roles + Html->link( + __('View'), + ['controller' => 'Roles', 'action' => 'index'], + ['class' => 'info-item-link'] + ); ?> +
+
+ assign_roles + Html->link( + __('Assign Roles'), + ['controller' => 'StateUserRoles', 'action' => 'search'], + ['class' => 'info-item-link'] + ); ?> +
+
+
From 99a68091ae0bae659c1dffbc7ed874aa671c653c Mon Sep 17 00:00:00 2001 From: team-devstage Date: Fri, 18 Sep 2020 18:08:17 +0200 Subject: [PATCH 6/9] add files created from samir --- src/Form/AssignRoleForm.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Form/AssignRoleForm.php diff --git a/src/Form/AssignRoleForm.php b/src/Form/AssignRoleForm.php new file mode 100644 index 000000000..158fa2296 --- /dev/null +++ b/src/Form/AssignRoleForm.php @@ -0,0 +1,30 @@ +addField('role_id', ['type' => 'string']); + } + + function validationDefault(Validator $validator) + { + $validator->setProvider('custom', 'App\Model\Validation\GenericValidation'); + + return $validator; + } + + + protected function _execute(array $data) + { + // Send an email. + return true; + } +} \ No newline at end of file From 0e5edbcd658642be5f1944d75216f66477ff560e Mon Sep 17 00:00:00 2001 From: team-devstage Date: Thu, 24 Sep 2020 08:01:11 +0200 Subject: [PATCH 7/9] add new created files from samir --- src/Controller/RolesController.php | 108 ++++++ src/Controller/StateUserRolesController.php | 307 ++++++++++++++++++ src/Model/Entity/Role.php | 26 ++ src/Model/Entity/StateUserRole.php | 30 ++ src/Model/Table/RolesTable.php | 72 ++++ src/Model/Table/StateUserRolesTable.php | 86 +++++ src/Template/Roles/add.ctp | 23 ++ src/Template/Roles/edit.ctp | 29 ++ src/Template/Roles/index.ctp | 47 +++ src/Template/Roles/view.ctp | 28 ++ src/Template/StateUserRoles/assign_role.ctp | 49 +++ src/Template/StateUserRoles/index.ctp | 69 ++++ src/Template/StateUserRoles/search.ctp | 80 +++++ tests/Fixture/RolesFixture.php | 45 +++ .../Controller/RolesControllerTest.php | 75 +++++ tests/TestCase/Model/Table/RolesTableTest.php | 82 +++++ 16 files changed, 1156 insertions(+) create mode 100644 src/Controller/RolesController.php create mode 100644 src/Controller/StateUserRolesController.php create mode 100644 src/Model/Entity/Role.php create mode 100644 src/Model/Entity/StateUserRole.php create mode 100644 src/Model/Table/RolesTable.php create mode 100644 src/Model/Table/StateUserRolesTable.php create mode 100644 src/Template/Roles/add.ctp create mode 100644 src/Template/Roles/edit.ctp create mode 100644 src/Template/Roles/index.ctp create mode 100644 src/Template/Roles/view.ctp create mode 100644 src/Template/StateUserRoles/assign_role.ctp create mode 100644 src/Template/StateUserRoles/index.ctp create mode 100644 src/Template/StateUserRoles/search.ctp create mode 100644 tests/Fixture/RolesFixture.php create mode 100644 tests/TestCase/Controller/RolesControllerTest.php create mode 100644 tests/TestCase/Model/Table/RolesTableTest.php diff --git a/src/Controller/RolesController.php b/src/Controller/RolesController.php new file mode 100644 index 000000000..80aa493d3 --- /dev/null +++ b/src/Controller/RolesController.php @@ -0,0 +1,108 @@ +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']); + } +} diff --git a/src/Controller/StateUserRolesController.php b/src/Controller/StateUserRolesController.php new file mode 100644 index 000000000..b61d6b82b --- /dev/null +++ b/src/Controller/StateUserRolesController.php @@ -0,0 +1,307 @@ +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 .= "
".$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); + } + +} diff --git a/src/Model/Entity/Role.php b/src/Model/Entity/Role.php new file mode 100644 index 000000000..ae0ddd0ba --- /dev/null +++ b/src/Model/Entity/Role.php @@ -0,0 +1,26 @@ + true, + ]; +} diff --git a/src/Model/Entity/StateUserRole.php b/src/Model/Entity/StateUserRole.php new file mode 100644 index 000000000..d510bb025 --- /dev/null +++ b/src/Model/Entity/StateUserRole.php @@ -0,0 +1,30 @@ + true, + 'role_id' => true + ]; +} diff --git a/src/Model/Table/RolesTable.php b/src/Model/Table/RolesTable.php new file mode 100644 index 000000000..940b7f246 --- /dev/null +++ b/src/Model/Table/RolesTable.php @@ -0,0 +1,72 @@ +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; + } +} diff --git a/src/Model/Table/StateUserRolesTable.php b/src/Model/Table/StateUserRolesTable.php new file mode 100644 index 000000000..895e788b2 --- /dev/null +++ b/src/Model/Table/StateUserRolesTable.php @@ -0,0 +1,86 @@ +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; + } + + +} diff --git a/src/Template/Roles/add.ctp b/src/Template/Roles/add.ctp new file mode 100644 index 000000000..c671ed011 --- /dev/null +++ b/src/Template/Roles/add.ctp @@ -0,0 +1,23 @@ + + +
+ Form->create($role) ?> +
+ + Form->control('title'); + ?> +
+ Form->button(__('Submit')) ?> + Form->end() ?> +
diff --git a/src/Template/Roles/edit.ctp b/src/Template/Roles/edit.ctp new file mode 100644 index 000000000..8a7cd385f --- /dev/null +++ b/src/Template/Roles/edit.ctp @@ -0,0 +1,29 @@ + + +
+ Form->create($role) ?> +
+ + Form->control('title'); + ?> +
+ Form->button(__('Submit')) ?> + Form->end() ?> +
diff --git a/src/Template/Roles/index.ctp b/src/Template/Roles/index.ctp new file mode 100644 index 000000000..2637ef958 --- /dev/null +++ b/src/Template/Roles/index.ctp @@ -0,0 +1,47 @@ + + +
+

+ + + + + + + + + + + + + + + + + +
Paginator->sort('id') ?>Paginator->sort('title') ?>
Number->format($role->id) ?>title) ?> + Html->link(__('View'), ['action' => 'view', $role->id]) ?> + Html->link(__('Edit'), ['action' => 'edit', $role->id]) ?> + Form->postLink(__('Delete'), ['action' => 'delete', $role->id], ['confirm' => __('Are you sure you want to delete # {0}?', $role->id)]) ?> +
+
+ +

Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?>

+
+
diff --git a/src/Template/Roles/view.ctp b/src/Template/Roles/view.ctp new file mode 100644 index 000000000..04e1dcec5 --- /dev/null +++ b/src/Template/Roles/view.ctp @@ -0,0 +1,28 @@ + + +
+

title) ?>

+ + + + + + + + + +
title) ?>
Number->format($role->id) ?>
+
diff --git a/src/Template/StateUserRoles/assign_role.ctp b/src/Template/StateUserRoles/assign_role.ctp new file mode 100644 index 000000000..64d3a1f8b --- /dev/null +++ b/src/Template/StateUserRoles/assign_role.ctp @@ -0,0 +1,49 @@ +assign('title', __('Assign Role')); +// In a View class +$this->loadHelper('Form', [ + 'templates' => 'horizontal_form', +]); +?> +Html->css([ + 'loginServer/style.css', + 'rippleUI/style.css', + 'materialdesignicons.min.css' +]) ?> + +
+

Assign Role

+
+ Form->create($assignRoleForm, []) ?> +
User:  first_name." ".$stateUser->last_name ?>
+
Select Role:
Form->select('role_id', $roles, ['label' => __('Role'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Role'), "multiple" => "multiple", "value" => $role_ids]) ?>
+ Form->button(' ' . __('Assign Role'), ['class' => 'form-button']) ?> + Form->hidden('public_hex', ['id' => 'input-order-row', 'value' => $public_hex]) ?> +
+
diff --git a/src/Template/StateUserRoles/index.ctp b/src/Template/StateUserRoles/index.ctp new file mode 100644 index 000000000..4e6ea8cb1 --- /dev/null +++ b/src/Template/StateUserRoles/index.ctp @@ -0,0 +1,69 @@ + + +
+

+ + + + + + + + + + + + + + + + + + + + + + +
Paginator->sort('id') ?>Paginator->sort('first_name') ?> + Paginator->sort('last_name') ?> + Paginator->sort('username') ?> + Paginator->sort('email') ?> + Paginator->sort('disabled') ?> +
Number->format($stateUser->id) ?>first_name ?>last_name ?>username ?>email ?>disabled ?> + Html->link(__('View'), ['action' => 'view', $stateUser->id]) ?> + Html->link(__('Edit'), ['action' => 'edit', $stateUser->id]) ?> + Form->postLink(__('Delete'), ['action' => 'delete', $stateUser->id], ['confirm' => __('Are you sure you want to delete # {0}?', $stateUser->id)]) ?> +
+
+ +

Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?>

+
+
diff --git a/src/Template/StateUserRoles/search.ctp b/src/Template/StateUserRoles/search.ctp new file mode 100644 index 000000000..c1234d245 --- /dev/null +++ b/src/Template/StateUserRoles/search.ctp @@ -0,0 +1,80 @@ +assign('title', __('Benutzer suchen')); +// In a View class +$this->loadHelper('Form', [ + 'templates' => 'horizontal_form', +]); +?> +Html->css([ + 'loginServer/style.css', + 'rippleUI/style.css', + 'materialdesignicons.min.css' +]) ?> + +
+

Benutzer suchen

+
+ Form->create($searchForm, []) ?> + Form->control('search', ['label' => __('Suchbegriff'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname/Nachname/E-Mail')]) ?> + Form->button('search ' . __('Suchen'), ['class' => 'form-button']) ?> + Form->hidden('order_row', ['id' => 'input-order-row']) ?> +
+
+
+

+ + + + + + + + + + + + + + + + + + + + + +
Paginator->sort('first_name') ?>Paginator->sort('last_name') ?>Paginator->sort('email') ?>
+ Html->link(__('Assign Role'), ['action' => 'assignRole', $stateUser['pubkeyhex']]) ?> +
+
+ + diff --git a/tests/Fixture/RolesFixture.php b/tests/Fixture/RolesFixture.php new file mode 100644 index 000000000..db2c7640f --- /dev/null +++ b/tests/Fixture/RolesFixture.php @@ -0,0 +1,45 @@ + ['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(); + } +} diff --git a/tests/TestCase/Controller/RolesControllerTest.php b/tests/TestCase/Controller/RolesControllerTest.php new file mode 100644 index 000000000..12b2868a2 --- /dev/null +++ b/tests/TestCase/Controller/RolesControllerTest.php @@ -0,0 +1,75 @@ +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.'); + } +} diff --git a/tests/TestCase/Model/Table/RolesTableTest.php b/tests/TestCase/Model/Table/RolesTableTest.php new file mode 100644 index 000000000..b40a0ca9b --- /dev/null +++ b/tests/TestCase/Model/Table/RolesTableTest.php @@ -0,0 +1,82 @@ +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.'); + } +} From 35b14d7480c66f54c40392fd01a68f1335503d41 Mon Sep 17 00:00:00 2001 From: team-devstage Date: Fri, 25 Sep 2020 15:01:33 +0200 Subject: [PATCH 8/9] cleanup samirs code, remove not needed stuff from my old code -Dario --- src/Controller/StateUserRolesController.php | 142 ++------------------ src/Template/StateUserRoles/search.ctp | 27 ---- 2 files changed, 10 insertions(+), 159 deletions(-) diff --git a/src/Controller/StateUserRolesController.php b/src/Controller/StateUserRolesController.php index b61d6b82b..9f83dc0bc 100644 --- a/src/Controller/StateUserRolesController.php +++ b/src/Controller/StateUserRolesController.php @@ -34,7 +34,7 @@ class StateUserRolesController extends AppController parent::initialize(); $this->loadComponent('JsonRequestClient'); $this->Auth->allow([ - 'search' +// 'search' ]); $this->set( 'naviHierarchy', @@ -49,22 +49,12 @@ class StateUserRolesController extends AppController $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')); + $this->set(compact('timeUsed', 'searchForm')); if ($this->request->is('post')) { $requestData = $this->request->getData(); @@ -72,43 +62,12 @@ class StateUserRolesController extends AppController 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']]]); + ->contain([]); $communityUsers->where(['OR' => [ 'first_name LIKE' => $globalSearch, @@ -118,71 +77,15 @@ class StateUserRolesController extends AppController ]]); //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'); +// foreach ($pubkeySorted as $pubhex => $user) { + foreach($communityUsers as $communityUser) { + $finalUser = $communityUser; + $finalUser['pubkeyhex'] = bin2hex(stream_get_contents($communityUser->public_key)); - $this->loadModel('Roles'); - $state_user_id = $user['community'][0]->id; + $state_user_id = $communityUser->id; $stateUserRole = $this->StateUserRoles->find('all')->where(['state_user_id' => $state_user_id])->all(); $role_ids = ""; @@ -206,34 +109,9 @@ class StateUserRolesController extends AppController $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!')); diff --git a/src/Template/StateUserRoles/search.ctp b/src/Template/StateUserRoles/search.ctp index c1234d245..aff7fbbcb 100644 --- a/src/Template/StateUserRoles/search.ctp +++ b/src/Template/StateUserRoles/search.ctp @@ -12,31 +12,6 @@ $this->loadHelper('Form', [ 'templates' => 'horizontal_form', ]); ?> -Html->css([ - 'loginServer/style.css', - 'rippleUI/style.css', - 'materialdesignicons.min.css' -]) ?> -

Benutzer suchen

@@ -76,5 +51,3 @@ $this->loadHelper('Form', [
- - From 9353d35a6fe871266fd84da6217a33d88ce2ee73 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Fri, 25 Sep 2020 13:56:16 +0000 Subject: [PATCH 9/9] add new gradido proto files and update parse proto script --- mithril_client | 2 +- parse_proto.php | 2 +- src/Controller/StateUserRolesController.php | 4 +- .../Proto/Gradido/CrossGroupTransfer.php | 146 +++++++++++++ .../Proto/Gradido/GradidoCreation.php | 102 +++++++++ .../Proto/Gradido/GradidoTransaction.php | 116 +++++++++++ .../Proto/Gradido/GradidoTransfer.php | 109 ++++++++++ .../Proto/Gradido/GroupFriendsUpdate.php | 92 +++++++++ .../Gradido/GroupFriendsUpdate/Action.php | 51 +++++ .../Gradido/GroupFriendsUpdate_Action.php | 16 ++ .../Proto/Gradido/GroupMemberUpdate.php | 146 +++++++++++++ .../GroupMemberUpdate/MemberUpdateType.php | 56 +++++ .../GroupMemberUpdate_MemberUpdateType.php | 16 ++ src/Model/Messages/Proto/Gradido/Key.php | 96 +++++++++ .../Messages/Proto/Gradido/LocalTransfer.php | 85 ++++++++ .../Messages/Proto/Gradido/SignatureMap.php | 65 ++++++ .../Messages/Proto/Gradido/SignaturePair.php | 123 +++++++++++ .../Messages/Proto/Gradido/Timestamp.php | 101 +++++++++ .../Proto/Gradido/TimestampSeconds.php | 67 ++++++ .../Proto/Gradido/TransactionBody.php | 193 ++++++++++++++++++ .../Messages/Proto/Gradido/TransferAmount.php | 85 ++++++++ src/protobuf | 2 +- 22 files changed, 1670 insertions(+), 5 deletions(-) create mode 100644 src/Model/Messages/Proto/Gradido/CrossGroupTransfer.php create mode 100644 src/Model/Messages/Proto/Gradido/GradidoCreation.php create mode 100644 src/Model/Messages/Proto/Gradido/GradidoTransaction.php create mode 100644 src/Model/Messages/Proto/Gradido/GradidoTransfer.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupFriendsUpdate.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupFriendsUpdate/Action.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupFriendsUpdate_Action.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupMemberUpdate.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupMemberUpdate/MemberUpdateType.php create mode 100644 src/Model/Messages/Proto/Gradido/GroupMemberUpdate_MemberUpdateType.php create mode 100644 src/Model/Messages/Proto/Gradido/Key.php create mode 100644 src/Model/Messages/Proto/Gradido/LocalTransfer.php create mode 100644 src/Model/Messages/Proto/Gradido/SignatureMap.php create mode 100644 src/Model/Messages/Proto/Gradido/SignaturePair.php create mode 100644 src/Model/Messages/Proto/Gradido/Timestamp.php create mode 100644 src/Model/Messages/Proto/Gradido/TimestampSeconds.php create mode 100644 src/Model/Messages/Proto/Gradido/TransactionBody.php create mode 100644 src/Model/Messages/Proto/Gradido/TransferAmount.php diff --git a/mithril_client b/mithril_client index a04d47699..21d4a0a5e 160000 --- a/mithril_client +++ b/mithril_client @@ -1 +1 @@ -Subproject commit a04d4769974b9d93ba72e490ed7dca3fbaed768c +Subproject commit 21d4a0a5e9a19f251e26c0ae07ce74be2fa99bbf diff --git a/parse_proto.php b/parse_proto.php index 576b99691..e6ccb451f 100755 --- a/parse_proto.php +++ b/parse_proto.php @@ -16,5 +16,5 @@ #PHP_PLUGIN="$(which grpc_php_plugin)" #protoc --proto_path=./src/protobuf/gradido --php_out=./src/ --grpc_out=./src/ --plugin=protoc-gen-grpc=$PHP_PLUGIN ./src/protobuf/gradido/*.proto -protoc --proto_path=./src/protobuf/gradido --php_out=./src/ ./src/protobuf/gradido/*.proto +protoc --proto_path=./src/protobuf --php_out=./src/Model/Messages ./src/protobuf/gradido/*.proto diff --git a/src/Controller/StateUserRolesController.php b/src/Controller/StateUserRolesController.php index 9f83dc0bc..9238c7ad6 100644 --- a/src/Controller/StateUserRolesController.php +++ b/src/Controller/StateUserRolesController.php @@ -81,9 +81,9 @@ class StateUserRolesController extends AppController // detect states $this->loadModel('Roles'); // foreach ($pubkeySorted as $pubhex => $user) { - foreach($communityUsers as $communityUser) { + foreach($communityUsers as $communityUser) { $finalUser = $communityUser; - $finalUser['pubkeyhex'] = bin2hex(stream_get_contents($communityUser->public_key)); + $finalUser['pubkeyhex'] = bin2hex(stream_get_contents($communityUser->public_key)); $state_user_id = $communityUser->id; $stateUserRole = $this->StateUserRoles->find('all')->where(['state_user_id' => $state_user_id])->all(); diff --git a/src/Model/Messages/Proto/Gradido/CrossGroupTransfer.php b/src/Model/Messages/Proto/Gradido/CrossGroupTransfer.php new file mode 100644 index 000000000..781ac8f25 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/CrossGroupTransfer.php @@ -0,0 +1,146 @@ +proto.gradido.CrossGroupTransfer + */ +class CrossGroupTransfer extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + */ + private $sender = null; + /** + * Generated from protobuf field bytes receiver = 2; + */ + private $receiver = ''; + /** + * Generated from protobuf field string other_group = 3; + */ + private $other_group = ''; + /** + * this matches related OutboundTransfer.paired_transaction_id + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 4; + */ + private $paired_transaction_id = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\TransferAmount $sender + * @type string $receiver + * @type string $other_group + * @type \Proto\Gradido\Timestamp $paired_transaction_id + * this matches related OutboundTransfer.paired_transaction_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GradidoTransfer::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + * @return \Proto\Gradido\TransferAmount + */ + public function getSender() + { + return $this->sender; + } + + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + * @param \Proto\Gradido\TransferAmount $var + * @return $this + */ + public function setSender($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\TransferAmount::class); + $this->sender = $var; + + return $this; + } + + /** + * Generated from protobuf field bytes receiver = 2; + * @return string + */ + public function getReceiver() + { + return $this->receiver; + } + + /** + * Generated from protobuf field bytes receiver = 2; + * @param string $var + * @return $this + */ + public function setReceiver($var) + { + GPBUtil::checkString($var, False); + $this->receiver = $var; + + return $this; + } + + /** + * Generated from protobuf field string other_group = 3; + * @return string + */ + public function getOtherGroup() + { + return $this->other_group; + } + + /** + * Generated from protobuf field string other_group = 3; + * @param string $var + * @return $this + */ + public function setOtherGroup($var) + { + GPBUtil::checkString($var, True); + $this->other_group = $var; + + return $this; + } + + /** + * this matches related OutboundTransfer.paired_transaction_id + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 4; + * @return \Proto\Gradido\Timestamp + */ + public function getPairedTransactionId() + { + return $this->paired_transaction_id; + } + + /** + * this matches related OutboundTransfer.paired_transaction_id + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 4; + * @param \Proto\Gradido\Timestamp $var + * @return $this + */ + public function setPairedTransactionId($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\Timestamp::class); + $this->paired_transaction_id = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GradidoCreation.php b/src/Model/Messages/Proto/Gradido/GradidoCreation.php new file mode 100644 index 000000000..9b4c3208d --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GradidoCreation.php @@ -0,0 +1,102 @@ +proto.gradido.GradidoCreation + */ +class GradidoCreation extends \Google\Protobuf\Internal\Message +{ + /** + * 40 Byte + * + * Generated from protobuf field .proto.gradido.TransferAmount receiver = 1; + */ + private $receiver = null; + /** + * 8 Byte + * + * Generated from protobuf field .proto.gradido.TimestampSeconds target_date = 3; + */ + private $target_date = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\TransferAmount $receiver + * 40 Byte + * @type \Proto\Gradido\TimestampSeconds $target_date + * 8 Byte + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GradidoCreation::initOnce(); + parent::__construct($data); + } + + /** + * 40 Byte + * + * Generated from protobuf field .proto.gradido.TransferAmount receiver = 1; + * @return \Proto\Gradido\TransferAmount + */ + public function getReceiver() + { + return $this->receiver; + } + + /** + * 40 Byte + * + * Generated from protobuf field .proto.gradido.TransferAmount receiver = 1; + * @param \Proto\Gradido\TransferAmount $var + * @return $this + */ + public function setReceiver($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\TransferAmount::class); + $this->receiver = $var; + + return $this; + } + + /** + * 8 Byte + * + * Generated from protobuf field .proto.gradido.TimestampSeconds target_date = 3; + * @return \Proto\Gradido\TimestampSeconds + */ + public function getTargetDate() + { + return $this->target_date; + } + + /** + * 8 Byte + * + * Generated from protobuf field .proto.gradido.TimestampSeconds target_date = 3; + * @param \Proto\Gradido\TimestampSeconds $var + * @return $this + */ + public function setTargetDate($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\TimestampSeconds::class); + $this->target_date = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GradidoTransaction.php b/src/Model/Messages/Proto/Gradido/GradidoTransaction.php new file mode 100644 index 000000000..b4b34c77e --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GradidoTransaction.php @@ -0,0 +1,116 @@ +proto.gradido.GradidoTransaction + */ +class GradidoTransaction extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .proto.gradido.SignatureMap sig_map = 1; + */ + private $sig_map = null; + /** + * TODO: consider if having concrete type wouldn't be better; + * having bytes would better show what is signed, still for + * blockchain it doesn't matter, as it has to be serialized again + * when validating + * UNICORN ANSWER: + * Maybe but hedera has at first concrete type and has depracted that now, so is must + * be reason for that + * + * Generated from protobuf field bytes body_bytes = 2; + */ + private $body_bytes = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\SignatureMap $sig_map + * @type string $body_bytes + * TODO: consider if having concrete type wouldn't be better; + * having bytes would better show what is signed, still for + * blockchain it doesn't matter, as it has to be serialized again + * when validating + * UNICORN ANSWER: + * Maybe but hedera has at first concrete type and has depracted that now, so is must + * be reason for that + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GradidoTransaction::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .proto.gradido.SignatureMap sig_map = 1; + * @return \Proto\Gradido\SignatureMap + */ + public function getSigMap() + { + return $this->sig_map; + } + + /** + * Generated from protobuf field .proto.gradido.SignatureMap sig_map = 1; + * @param \Proto\Gradido\SignatureMap $var + * @return $this + */ + public function setSigMap($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\SignatureMap::class); + $this->sig_map = $var; + + return $this; + } + + /** + * TODO: consider if having concrete type wouldn't be better; + * having bytes would better show what is signed, still for + * blockchain it doesn't matter, as it has to be serialized again + * when validating + * UNICORN ANSWER: + * Maybe but hedera has at first concrete type and has depracted that now, so is must + * be reason for that + * + * Generated from protobuf field bytes body_bytes = 2; + * @return string + */ + public function getBodyBytes() + { + return $this->body_bytes; + } + + /** + * TODO: consider if having concrete type wouldn't be better; + * having bytes would better show what is signed, still for + * blockchain it doesn't matter, as it has to be serialized again + * when validating + * UNICORN ANSWER: + * Maybe but hedera has at first concrete type and has depracted that now, so is must + * be reason for that + * + * Generated from protobuf field bytes body_bytes = 2; + * @param string $var + * @return $this + */ + public function setBodyBytes($var) + { + GPBUtil::checkString($var, False); + $this->body_bytes = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GradidoTransfer.php b/src/Model/Messages/Proto/Gradido/GradidoTransfer.php new file mode 100644 index 000000000..a76954c2e --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GradidoTransfer.php @@ -0,0 +1,109 @@ +proto.gradido.GradidoTransfer + */ +class GradidoTransfer extends \Google\Protobuf\Internal\Message +{ + protected $data; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\LocalTransfer $local + * @type \Proto\Gradido\CrossGroupTransfer $inbound + * @type \Proto\Gradido\CrossGroupTransfer $outbound + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GradidoTransfer::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .proto.gradido.LocalTransfer local = 1; + * @return \Proto\Gradido\LocalTransfer + */ + public function getLocal() + { + return $this->readOneof(1); + } + + /** + * Generated from protobuf field .proto.gradido.LocalTransfer local = 1; + * @param \Proto\Gradido\LocalTransfer $var + * @return $this + */ + public function setLocal($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\LocalTransfer::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.CrossGroupTransfer inbound = 2; + * @return \Proto\Gradido\CrossGroupTransfer + */ + public function getInbound() + { + return $this->readOneof(2); + } + + /** + * Generated from protobuf field .proto.gradido.CrossGroupTransfer inbound = 2; + * @param \Proto\Gradido\CrossGroupTransfer $var + * @return $this + */ + public function setInbound($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\CrossGroupTransfer::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.CrossGroupTransfer outbound = 3; + * @return \Proto\Gradido\CrossGroupTransfer + */ + public function getOutbound() + { + return $this->readOneof(3); + } + + /** + * Generated from protobuf field .proto.gradido.CrossGroupTransfer outbound = 3; + * @param \Proto\Gradido\CrossGroupTransfer $var + * @return $this + */ + public function setOutbound($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\CrossGroupTransfer::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getData() + { + return $this->whichOneof("data"); + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate.php b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate.php new file mode 100644 index 000000000..22e86d3e1 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate.php @@ -0,0 +1,92 @@ +proto.gradido.GroupFriendsUpdate + */ +class GroupFriendsUpdate extends \Google\Protobuf\Internal\Message +{ + /** + * char[16], alias + * + * Generated from protobuf field string group = 1; + */ + private $group = ''; + /** + * Generated from protobuf field .proto.gradido.GroupFriendsUpdate.Action action = 2; + */ + private $action = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $group + * char[16], alias + * @type int $action + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GroupFriendsUpdate::initOnce(); + parent::__construct($data); + } + + /** + * char[16], alias + * + * Generated from protobuf field string group = 1; + * @return string + */ + public function getGroup() + { + return $this->group; + } + + /** + * char[16], alias + * + * Generated from protobuf field string group = 1; + * @param string $var + * @return $this + */ + public function setGroup($var) + { + GPBUtil::checkString($var, True); + $this->group = $var; + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GroupFriendsUpdate.Action action = 2; + * @return int + */ + public function getAction() + { + return $this->action; + } + + /** + * Generated from protobuf field .proto.gradido.GroupFriendsUpdate.Action action = 2; + * @param int $var + * @return $this + */ + public function setAction($var) + { + GPBUtil::checkEnum($var, \Proto\Gradido\GroupFriendsUpdate_Action::class); + $this->action = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate/Action.php b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate/Action.php new file mode 100644 index 000000000..2a3396c55 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate/Action.php @@ -0,0 +1,51 @@ +proto.gradido.GroupFriendsUpdate.Action + */ +class Action +{ + /** + * Generated from protobuf enum ADD_FRIEND = 0; + */ + const ADD_FRIEND = 0; + /** + * Generated from protobuf enum REMOVE_FRIEND = 1; + */ + const REMOVE_FRIEND = 1; + + private static $valueToName = [ + self::ADD_FRIEND => 'ADD_FRIEND', + self::REMOVE_FRIEND => 'REMOVE_FRIEND', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Action::class, \Proto\Gradido\GroupFriendsUpdate_Action::class); + diff --git a/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate_Action.php b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate_Action.php new file mode 100644 index 000000000..24f8cef70 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GroupFriendsUpdate_Action.php @@ -0,0 +1,16 @@ +proto.gradido.GroupMemberUpdate + */ +class GroupMemberUpdate extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field bytes user_pubkey = 1; + */ + private $user_pubkey = ''; + /** + * Generated from protobuf field .proto.gradido.GroupMemberUpdate.MemberUpdateType member_update_type = 2; + */ + private $member_update_type = 0; + /** + * this only makes sense for user move, TODO: probably restructure + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 3; + */ + private $paired_transaction_id = null; + /** + * Generated from protobuf field string target_group = 4; + */ + private $target_group = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $user_pubkey + * @type int $member_update_type + * @type \Proto\Gradido\Timestamp $paired_transaction_id + * this only makes sense for user move, TODO: probably restructure + * @type string $target_group + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GroupMemberUpdate::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field bytes user_pubkey = 1; + * @return string + */ + public function getUserPubkey() + { + return $this->user_pubkey; + } + + /** + * Generated from protobuf field bytes user_pubkey = 1; + * @param string $var + * @return $this + */ + public function setUserPubkey($var) + { + GPBUtil::checkString($var, False); + $this->user_pubkey = $var; + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GroupMemberUpdate.MemberUpdateType member_update_type = 2; + * @return int + */ + public function getMemberUpdateType() + { + return $this->member_update_type; + } + + /** + * Generated from protobuf field .proto.gradido.GroupMemberUpdate.MemberUpdateType member_update_type = 2; + * @param int $var + * @return $this + */ + public function setMemberUpdateType($var) + { + GPBUtil::checkEnum($var, \Proto\Gradido\GroupMemberUpdate_MemberUpdateType::class); + $this->member_update_type = $var; + + return $this; + } + + /** + * this only makes sense for user move, TODO: probably restructure + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 3; + * @return \Proto\Gradido\Timestamp + */ + public function getPairedTransactionId() + { + return $this->paired_transaction_id; + } + + /** + * this only makes sense for user move, TODO: probably restructure + * + * Generated from protobuf field .proto.gradido.Timestamp paired_transaction_id = 3; + * @param \Proto\Gradido\Timestamp $var + * @return $this + */ + public function setPairedTransactionId($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\Timestamp::class); + $this->paired_transaction_id = $var; + + return $this; + } + + /** + * Generated from protobuf field string target_group = 4; + * @return string + */ + public function getTargetGroup() + { + return $this->target_group; + } + + /** + * Generated from protobuf field string target_group = 4; + * @param string $var + * @return $this + */ + public function setTargetGroup($var) + { + GPBUtil::checkString($var, True); + $this->target_group = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/GroupMemberUpdate/MemberUpdateType.php b/src/Model/Messages/Proto/Gradido/GroupMemberUpdate/MemberUpdateType.php new file mode 100644 index 000000000..57580cd75 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GroupMemberUpdate/MemberUpdateType.php @@ -0,0 +1,56 @@ +proto.gradido.GroupMemberUpdate.MemberUpdateType + */ +class MemberUpdateType +{ + /** + * Generated from protobuf enum ADD_USER = 0; + */ + const ADD_USER = 0; + /** + * Generated from protobuf enum MOVE_USER_INBOUND = 1; + */ + const MOVE_USER_INBOUND = 1; + /** + * Generated from protobuf enum MOVE_USER_OUTBOUND = 2; + */ + const MOVE_USER_OUTBOUND = 2; + + private static $valueToName = [ + self::ADD_USER => 'ADD_USER', + self::MOVE_USER_INBOUND => 'MOVE_USER_INBOUND', + self::MOVE_USER_OUTBOUND => 'MOVE_USER_OUTBOUND', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(MemberUpdateType::class, \Proto\Gradido\GroupMemberUpdate_MemberUpdateType::class); + diff --git a/src/Model/Messages/Proto/Gradido/GroupMemberUpdate_MemberUpdateType.php b/src/Model/Messages/Proto/Gradido/GroupMemberUpdate_MemberUpdateType.php new file mode 100644 index 000000000..b7080cf75 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/GroupMemberUpdate_MemberUpdateType.php @@ -0,0 +1,16 @@ +proto.gradido.Key + */ +class Key extends \Google\Protobuf\Internal\Message +{ + protected $key; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $ed25519 + * ed25519 signature (libsodium default) + * @type string $ed25519_ref10 + * ed25519 ref10 signature + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * ed25519 signature (libsodium default) + * + * Generated from protobuf field bytes ed25519 = 2; + * @return string + */ + public function getEd25519() + { + return $this->readOneof(2); + } + + /** + * ed25519 signature (libsodium default) + * + * Generated from protobuf field bytes ed25519 = 2; + * @param string $var + * @return $this + */ + public function setEd25519($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * ed25519 ref10 signature + * + * Generated from protobuf field bytes ed25519_ref10 = 3; + * @return string + */ + public function getEd25519Ref10() + { + return $this->readOneof(3); + } + + /** + * ed25519 ref10 signature + * + * Generated from protobuf field bytes ed25519_ref10 = 3; + * @param string $var + * @return $this + */ + public function setEd25519Ref10($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getKey() + { + return $this->whichOneof("key"); + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/LocalTransfer.php b/src/Model/Messages/Proto/Gradido/LocalTransfer.php new file mode 100644 index 000000000..58f5e23ae --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/LocalTransfer.php @@ -0,0 +1,85 @@ +proto.gradido.LocalTransfer + */ +class LocalTransfer extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + */ + private $sender = null; + /** + * Generated from protobuf field bytes receiver = 2; + */ + private $receiver = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\TransferAmount $sender + * @type string $receiver + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\GradidoTransfer::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + * @return \Proto\Gradido\TransferAmount + */ + public function getSender() + { + return $this->sender; + } + + /** + * Generated from protobuf field .proto.gradido.TransferAmount sender = 1; + * @param \Proto\Gradido\TransferAmount $var + * @return $this + */ + public function setSender($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\TransferAmount::class); + $this->sender = $var; + + return $this; + } + + /** + * Generated from protobuf field bytes receiver = 2; + * @return string + */ + public function getReceiver() + { + return $this->receiver; + } + + /** + * Generated from protobuf field bytes receiver = 2; + * @param string $var + * @return $this + */ + public function setReceiver($var) + { + GPBUtil::checkString($var, False); + $this->receiver = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/SignatureMap.php b/src/Model/Messages/Proto/Gradido/SignatureMap.php new file mode 100644 index 000000000..0977169d7 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/SignatureMap.php @@ -0,0 +1,65 @@ +proto.gradido.SignatureMap + */ +class SignatureMap extends \Google\Protobuf\Internal\Message +{ + /** + * Each signature pair corresponds to a unique Key required to sign the transaction. + * + * Generated from protobuf field repeated .proto.gradido.SignaturePair sigPair = 1; + */ + private $sigPair; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Proto\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $sigPair + * Each signature pair corresponds to a unique Key required to sign the transaction. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * Each signature pair corresponds to a unique Key required to sign the transaction. + * + * Generated from protobuf field repeated .proto.gradido.SignaturePair sigPair = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSigPair() + { + return $this->sigPair; + } + + /** + * Each signature pair corresponds to a unique Key required to sign the transaction. + * + * Generated from protobuf field repeated .proto.gradido.SignaturePair sigPair = 1; + * @param \Proto\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSigPair($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Proto\Gradido\SignaturePair::class); + $this->sigPair = $arr; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/SignaturePair.php b/src/Model/Messages/Proto/Gradido/SignaturePair.php new file mode 100644 index 000000000..2ef0e81c5 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/SignaturePair.php @@ -0,0 +1,123 @@ +proto.gradido.SignaturePair + */ +class SignaturePair extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field bytes pubKey = 1; + */ + private $pubKey = ''; + protected $signature; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $pubKey + * @type string $ed25519 + * ed25519 signature (libsodium default) + * @type string $ed25519_ref10 + * ed25519 ref10 signature + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field bytes pubKey = 1; + * @return string + */ + public function getPubKey() + { + return $this->pubKey; + } + + /** + * Generated from protobuf field bytes pubKey = 1; + * @param string $var + * @return $this + */ + public function setPubKey($var) + { + GPBUtil::checkString($var, False); + $this->pubKey = $var; + + return $this; + } + + /** + * ed25519 signature (libsodium default) + * + * Generated from protobuf field bytes ed25519 = 2; + * @return string + */ + public function getEd25519() + { + return $this->readOneof(2); + } + + /** + * ed25519 signature (libsodium default) + * + * Generated from protobuf field bytes ed25519 = 2; + * @param string $var + * @return $this + */ + public function setEd25519($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * ed25519 ref10 signature + * + * Generated from protobuf field bytes ed25519_ref10 = 3; + * @return string + */ + public function getEd25519Ref10() + { + return $this->readOneof(3); + } + + /** + * ed25519 ref10 signature + * + * Generated from protobuf field bytes ed25519_ref10 = 3; + * @param string $var + * @return $this + */ + public function setEd25519Ref10($var) + { + GPBUtil::checkString($var, False); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * @return string + */ + public function getSignature() + { + return $this->whichOneof("signature"); + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/Timestamp.php b/src/Model/Messages/Proto/Gradido/Timestamp.php new file mode 100644 index 000000000..ae3ecea0e --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/Timestamp.php @@ -0,0 +1,101 @@ +proto.gradido.Timestamp + */ +class Timestamp extends \Google\Protobuf\Internal\Message +{ + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + */ + private $seconds = 0; + /** + * Number of nanoseconds since the start of the last second + * + * Generated from protobuf field int32 nanos = 2; + */ + private $nanos = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $seconds + * Number of complete seconds since the start of the epoch + * @type int $nanos + * Number of nanoseconds since the start of the last second + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + * @return int|string + */ + public function getSeconds() + { + return $this->seconds; + } + + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + * @param int|string $var + * @return $this + */ + public function setSeconds($var) + { + GPBUtil::checkInt64($var); + $this->seconds = $var; + + return $this; + } + + /** + * Number of nanoseconds since the start of the last second + * + * Generated from protobuf field int32 nanos = 2; + * @return int + */ + public function getNanos() + { + return $this->nanos; + } + + /** + * Number of nanoseconds since the start of the last second + * + * Generated from protobuf field int32 nanos = 2; + * @param int $var + * @return $this + */ + public function setNanos($var) + { + GPBUtil::checkInt32($var); + $this->nanos = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/TimestampSeconds.php b/src/Model/Messages/Proto/Gradido/TimestampSeconds.php new file mode 100644 index 000000000..d31aa40d2 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/TimestampSeconds.php @@ -0,0 +1,67 @@ +proto.gradido.TimestampSeconds + */ +class TimestampSeconds extends \Google\Protobuf\Internal\Message +{ + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + */ + private $seconds = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int|string $seconds + * Number of complete seconds since the start of the epoch + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + * @return int|string + */ + public function getSeconds() + { + return $this->seconds; + } + + /** + * Number of complete seconds since the start of the epoch + * + * Generated from protobuf field int64 seconds = 1; + * @param int|string $var + * @return $this + */ + public function setSeconds($var) + { + GPBUtil::checkInt64($var); + $this->seconds = $var; + + return $this; + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/TransactionBody.php b/src/Model/Messages/Proto/Gradido/TransactionBody.php new file mode 100644 index 000000000..0484ecc92 --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/TransactionBody.php @@ -0,0 +1,193 @@ +proto.gradido.TransactionBody + */ +class TransactionBody extends \Google\Protobuf\Internal\Message +{ + /** + * max 150 chars + * + * Generated from protobuf field string memo = 1; + */ + private $memo = ''; + /** + * Generated from protobuf field uint64 version_number = 6; + */ + private $version_number = 0; + protected $data; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $memo + * max 150 chars + * @type \Proto\Gradido\GradidoTransfer $transfer + * @type \Proto\Gradido\GradidoCreation $creation + * @type \Proto\Gradido\GroupFriendsUpdate $group_friends_update + * @type \Proto\Gradido\GroupMemberUpdate $group_member_update + * @type int|string $version_number + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\TransactionBody::initOnce(); + parent::__construct($data); + } + + /** + * max 150 chars + * + * Generated from protobuf field string memo = 1; + * @return string + */ + public function getMemo() + { + return $this->memo; + } + + /** + * max 150 chars + * + * Generated from protobuf field string memo = 1; + * @param string $var + * @return $this + */ + public function setMemo($var) + { + GPBUtil::checkString($var, True); + $this->memo = $var; + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GradidoTransfer transfer = 2; + * @return \Proto\Gradido\GradidoTransfer + */ + public function getTransfer() + { + return $this->readOneof(2); + } + + /** + * Generated from protobuf field .proto.gradido.GradidoTransfer transfer = 2; + * @param \Proto\Gradido\GradidoTransfer $var + * @return $this + */ + public function setTransfer($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\GradidoTransfer::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GradidoCreation creation = 3; + * @return \Proto\Gradido\GradidoCreation + */ + public function getCreation() + { + return $this->readOneof(3); + } + + /** + * Generated from protobuf field .proto.gradido.GradidoCreation creation = 3; + * @param \Proto\Gradido\GradidoCreation $var + * @return $this + */ + public function setCreation($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\GradidoCreation::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GroupFriendsUpdate group_friends_update = 4; + * @return \Proto\Gradido\GroupFriendsUpdate + */ + public function getGroupFriendsUpdate() + { + return $this->readOneof(4); + } + + /** + * Generated from protobuf field .proto.gradido.GroupFriendsUpdate group_friends_update = 4; + * @param \Proto\Gradido\GroupFriendsUpdate $var + * @return $this + */ + public function setGroupFriendsUpdate($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\GroupFriendsUpdate::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * Generated from protobuf field .proto.gradido.GroupMemberUpdate group_member_update = 5; + * @return \Proto\Gradido\GroupMemberUpdate + */ + public function getGroupMemberUpdate() + { + return $this->readOneof(5); + } + + /** + * Generated from protobuf field .proto.gradido.GroupMemberUpdate group_member_update = 5; + * @param \Proto\Gradido\GroupMemberUpdate $var + * @return $this + */ + public function setGroupMemberUpdate($var) + { + GPBUtil::checkMessage($var, \Proto\Gradido\GroupMemberUpdate::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * Generated from protobuf field uint64 version_number = 6; + * @return int|string + */ + public function getVersionNumber() + { + return $this->version_number; + } + + /** + * Generated from protobuf field uint64 version_number = 6; + * @param int|string $var + * @return $this + */ + public function setVersionNumber($var) + { + GPBUtil::checkUint64($var); + $this->version_number = $var; + + return $this; + } + + /** + * @return string + */ + public function getData() + { + return $this->whichOneof("data"); + } + +} + diff --git a/src/Model/Messages/Proto/Gradido/TransferAmount.php b/src/Model/Messages/Proto/Gradido/TransferAmount.php new file mode 100644 index 000000000..7673582fa --- /dev/null +++ b/src/Model/Messages/Proto/Gradido/TransferAmount.php @@ -0,0 +1,85 @@ +proto.gradido.TransferAmount + */ +class TransferAmount extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field bytes pubkey = 1; + */ + private $pubkey = ''; + /** + * Generated from protobuf field sint64 amount = 2; + */ + private $amount = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $pubkey + * @type int|string $amount + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Gradido\BasicTypes::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field bytes pubkey = 1; + * @return string + */ + public function getPubkey() + { + return $this->pubkey; + } + + /** + * Generated from protobuf field bytes pubkey = 1; + * @param string $var + * @return $this + */ + public function setPubkey($var) + { + GPBUtil::checkString($var, False); + $this->pubkey = $var; + + return $this; + } + + /** + * Generated from protobuf field sint64 amount = 2; + * @return int|string + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Generated from protobuf field sint64 amount = 2; + * @param int|string $var + * @return $this + */ + public function setAmount($var) + { + GPBUtil::checkInt64($var); + $this->amount = $var; + + return $this; + } + +} + diff --git a/src/protobuf b/src/protobuf index 9004e6978..81a461566 160000 --- a/src/protobuf +++ b/src/protobuf @@ -1 +1 @@ -Subproject commit 9004e6978ac3dafcc635b2ffcf8bc6a156451cca +Subproject commit 81a461566e46d71533dc3e284fa075d7d68fd020