mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
reset php changes
This commit is contained in:
parent
7d723986ce
commit
1952844c80
@ -223,22 +223,22 @@ class AppController extends Controller
|
|||||||
$public_key_bin = hex2bin($json['user']['public_hex']);
|
$public_key_bin = hex2bin($json['user']['public_hex']);
|
||||||
$stateUserQuery = $stateUserTable
|
$stateUserQuery = $stateUserTable
|
||||||
->find('all')
|
->find('all')
|
||||||
->where(['pubkey' => $public_key_bin])
|
->where(['public_key' => $public_key_bin])
|
||||||
->contain('StateBalances', function ($q) {
|
->contain('StateBalances', function ($q) {
|
||||||
return $q->order(['record_date' => 'DESC'])
|
return $q->order(['record_date' => 'DESC'])
|
||||||
->limit(1);
|
->limit(1);
|
||||||
});
|
});
|
||||||
if ($stateUserQuery->count() == 1) {
|
if ($stateUserQuery->count() == 1) {
|
||||||
$stateUser = $stateUserQuery->first();
|
$stateUser = $stateUserQuery->first();
|
||||||
if ($stateUser->firstName != $json['user']['first_name'] ||
|
if ($stateUser->first_name != $json['user']['first_name'] ||
|
||||||
$stateUser->lastName != $json['user']['last_name'] ||
|
$stateUser->last_name != $json['user']['last_name'] ||
|
||||||
$stateUser->disabled != $json['user']['disabled'] ||
|
$stateUser->disabled != $json['user']['disabled'] ||
|
||||||
//$stateUser->username != $json['user']['username'] ||
|
//$stateUser->username != $json['user']['username'] ||
|
||||||
// -> throws error
|
// -> throws error
|
||||||
$stateUser->email != $json['user']['email']
|
$stateUser->email != $json['user']['email']
|
||||||
) {
|
) {
|
||||||
$stateUser->firstName = $json['user']['first_name'];
|
$stateUser->first_name = $json['user']['first_name'];
|
||||||
$stateUser->lastName = $json['user']['last_name'];
|
$stateUser->last_name = $json['user']['last_name'];
|
||||||
$stateUser->disabled = intval($json['user']['disabled']);
|
$stateUser->disabled = intval($json['user']['disabled']);
|
||||||
//$stateUser->username = $json['user']['username'];
|
//$stateUser->username = $json['user']['username'];
|
||||||
$stateUser->email = $json['user']['email'];
|
$stateUser->email = $json['user']['email'];
|
||||||
@ -250,9 +250,9 @@ class AppController extends Controller
|
|||||||
//echo $stateUser['id'];
|
//echo $stateUser['id'];
|
||||||
} else {
|
} else {
|
||||||
$newStateUser = $stateUserTable->newEntity();
|
$newStateUser = $stateUserTable->newEntity();
|
||||||
$newStateUser->pubkey = $public_key_bin;
|
$newStateUser->public_key = $public_key_bin;
|
||||||
$newStateUser->firstName = $json['user']['first_name'];
|
$newStateUser->first_name = $json['user']['first_name'];
|
||||||
$newStateUser->lastName = $json['user']['last_name'];
|
$newStateUser->last_name = $json['user']['last_name'];
|
||||||
$newStateUser->disabled = intval($json['user']['disabled']);
|
$newStateUser->disabled = intval($json['user']['disabled']);
|
||||||
//$newStateUser->username = $json['user']['username'];
|
//$newStateUser->username = $json['user']['username'];
|
||||||
$newStateUser->email = $json['user']['email'];
|
$newStateUser->email = $json['user']['email'];
|
||||||
|
|||||||
@ -308,7 +308,7 @@ class JsonRequestHandlerController extends AppController {
|
|||||||
$stateError = $stateErrorTable->newEntity();
|
$stateError = $stateErrorTable->newEntity();
|
||||||
//
|
//
|
||||||
$pubkey = hex2bin($jsonData->public_key);
|
$pubkey = hex2bin($jsonData->public_key);
|
||||||
$user_query = $stateUsersTable->find('all')->select(['id'])->where(['pubkey' => $pubkey]);
|
$user_query = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $pubkey]);
|
||||||
if($user_query->count() != 1) {
|
if($user_query->count() != 1) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'user not found', 'details' => 'user pubkey hex:' . $jsonData->public_key]);
|
return $this->returnJson(['state' => 'error', 'msg' => 'user not found', 'details' => 'user pubkey hex:' . $jsonData->public_key]);
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ class JsonRequestHandlerController extends AppController {
|
|||||||
//$pubkeys->sender
|
//$pubkeys->sender
|
||||||
//$pubkeys->receiver
|
//$pubkeys->receiver
|
||||||
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
|
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||||
$user = $stateUserTable->find('all')->where(['pubkey' => hex2bin($pubkeys->sender)])->contain(['StateBalances']);
|
$user = $stateUserTable->find('all')->where(['public_key' => hex2bin($pubkeys->sender)])->contain(['StateBalances']);
|
||||||
if(!$user->count()) {
|
if(!$user->count()) {
|
||||||
return $this->returnJson(['state' => 'not found', 'msg' => 'user not found or empty balance']);
|
return $this->returnJson(['state' => 'not found', 'msg' => 'user not found or empty balance']);
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ class JsonRequestHandlerController extends AppController {
|
|||||||
|
|
||||||
private function userDelete($userPubkeyHex) {
|
private function userDelete($userPubkeyHex) {
|
||||||
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
|
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||||
$user = $stateUserTable->find('all')->where(['pubkey' => hex2bin($userPubkeyHex)]);
|
$user = $stateUserTable->find('all')->where(['public_key' => hex2bin($userPubkeyHex)]);
|
||||||
if(!$user || $user->count == 0) {
|
if(!$user || $user->count == 0) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'user not found']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'user not found']);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class StateUserRolesController extends AppController
|
|||||||
|
|
||||||
$public_hex = hex2bin($requestData['public_hex']);
|
$public_hex = hex2bin($requestData['public_hex']);
|
||||||
|
|
||||||
$stateUser = $this->StateUsers->find('all')->where(['pubkey' => $public_hex])->first();
|
$stateUser = $this->StateUsers->find('all')->where(['public_key' => $public_hex])->first();
|
||||||
|
|
||||||
foreach($requestData['role_id'] as $role_id)
|
foreach($requestData['role_id'] as $role_id)
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ class StateUserRolesController extends AppController
|
|||||||
|
|
||||||
$publichex = hex2bin($public_hex);
|
$publichex = hex2bin($public_hex);
|
||||||
|
|
||||||
$stateUser = $this->StateUsers->find('all')->where(['pubkey' => $publichex])->first();
|
$stateUser = $this->StateUsers->find('all')->where(['public_key' => $publichex])->first();
|
||||||
|
|
||||||
$stateUserRoles = $this->StateUserRoles->find('all')->where(['state_user_id' => $stateUser->id])->all();
|
$stateUserRoles = $this->StateUserRoles->find('all')->where(['state_user_id' => $stateUser->id])->all();
|
||||||
|
|
||||||
|
|||||||
@ -182,15 +182,15 @@ class StateUsersController extends AppController
|
|||||||
|
|
||||||
if($account_state == 'email not activated') {
|
if($account_state == 'email not activated') {
|
||||||
if(count($pubkeySorted) > 0) {
|
if(count($pubkeySorted) > 0) {
|
||||||
$communityUsers->where(['hex(pubkey) IN' => array_keys($pubkeySorted)]);
|
$communityUsers->where(['hex(public_key) IN' => array_keys($pubkeySorted)]);
|
||||||
} else {
|
} else {
|
||||||
$communityUsers = null;
|
$communityUsers = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$globalSearch = '%' . $searchString . '%';
|
$globalSearch = '%' . $searchString . '%';
|
||||||
$communityUsers->where(['OR' => [
|
$communityUsers->where(['OR' => [
|
||||||
'firstName LIKE' => $globalSearch,
|
'first_name LIKE' => $globalSearch,
|
||||||
'lastName LIKE' => $globalSearch,
|
'last_name LIKE' => $globalSearch,
|
||||||
'email LIKE' => $globalSearch
|
'email LIKE' => $globalSearch
|
||||||
]]);
|
]]);
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ class StateUsersController extends AppController
|
|||||||
//var_dump($communityUsers->toArray());
|
//var_dump($communityUsers->toArray());
|
||||||
if($communityUsers) {
|
if($communityUsers) {
|
||||||
foreach($communityUsers as $u) {
|
foreach($communityUsers as $u) {
|
||||||
$pubkey_hex = bin2hex(stream_get_contents($u->pubkey));
|
$pubkey_hex = bin2hex(stream_get_contents($u->public_key));
|
||||||
$u->public_hex = $pubkey_hex;
|
$u->public_hex = $pubkey_hex;
|
||||||
if(!isset($pubkeySorted[$pubkey_hex])) {
|
if(!isset($pubkeySorted[$pubkey_hex])) {
|
||||||
$pubkeySorted[$pubkey_hex] = ['login' => [], 'community' => []];
|
$pubkeySorted[$pubkey_hex] = ['login' => [], 'community' => []];
|
||||||
@ -229,9 +229,9 @@ class StateUsersController extends AppController
|
|||||||
$color = 'danger';
|
$color = 'danger';
|
||||||
if(count($user['community']) == 1) {
|
if(count($user['community']) == 1) {
|
||||||
$c_user = $user['community'][0];
|
$c_user = $user['community'][0];
|
||||||
$finalUser['name'] = $c_user->firstName . ' ' . $c_user->lastName;
|
$finalUser['name'] = $c_user->first_name . ' ' . $c_user->last_name;
|
||||||
$finalUser['first_name'] = $c_user->firstName;
|
$finalUser['first_name'] = $c_user->first_name;
|
||||||
$finalUser['last_name'] = $c_user->lastName;
|
$finalUser['last_name'] = $c_user->last_name;
|
||||||
$finalUser['email'] = $c_user->email;
|
$finalUser['email'] = $c_user->email;
|
||||||
}
|
}
|
||||||
} else if(count($user['login']) == 1) {
|
} else if(count($user['login']) == 1) {
|
||||||
@ -415,7 +415,7 @@ class StateUsersController extends AppController
|
|||||||
//$user = $jsonData['user'];
|
//$user = $jsonData['user'];
|
||||||
//var_dump($jsonData);
|
//var_dump($jsonData);
|
||||||
$pubkey = hex2bin($jsonData['pubkeyhex']);
|
$pubkey = hex2bin($jsonData['pubkeyhex']);
|
||||||
$stateUsers = $this->StateUsers->find('all')->where(['pubkey' => $pubkey]);
|
$stateUsers = $this->StateUsers->find('all')->where(['public_key' => $pubkey]);
|
||||||
if($stateUsers->count() != 1) {
|
if($stateUsers->count() != 1) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'invalid result count']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'invalid result count']);
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ class StateUsersController extends AppController
|
|||||||
$pubkey = hex2bin($jsonData['pubkeyhex']);
|
$pubkey = hex2bin($jsonData['pubkeyhex']);
|
||||||
$stateUsers = $this->StateUsers
|
$stateUsers = $this->StateUsers
|
||||||
->find('all')
|
->find('all')
|
||||||
->where(['pubkey' => $pubkey])
|
->where(['public_key' => $pubkey])
|
||||||
->select(['id']);
|
->select(['id']);
|
||||||
if($stateUsers->count() != 1) {
|
if($stateUsers->count() != 1) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'invalid result count']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'invalid result count']);
|
||||||
|
|||||||
@ -101,7 +101,7 @@ class TransactionCreationsController extends AppController
|
|||||||
$receiverProposal = [];
|
$receiverProposal = [];
|
||||||
foreach ($stateUsers as $stateUser) {
|
foreach ($stateUsers as $stateUser) {
|
||||||
$name = $stateUser->email;
|
$name = $stateUser->email;
|
||||||
$keyHex = bin2hex(stream_get_contents($stateUser->pubkey));
|
$keyHex = bin2hex(stream_get_contents($stateUser->public_key));
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
$name = $stateUser->first_name . ' ' . $stateUser->last_name;
|
$name = $stateUser->first_name . ' ' . $stateUser->last_name;
|
||||||
}
|
}
|
||||||
@ -241,14 +241,14 @@ class TransactionCreationsController extends AppController
|
|||||||
$this->log("search for text: ".$requestData['searchText'], 'debug');
|
$this->log("search for text: ".$requestData['searchText'], 'debug');
|
||||||
$stateUsers = $stateUserTable
|
$stateUsers = $stateUserTable
|
||||||
->find('all')
|
->find('all')
|
||||||
->select(['id', 'firstName', 'lastName', 'email'])
|
->select(['id', 'first_name', 'last_name', 'email'])
|
||||||
->order(['firstName', 'lastName'])
|
->order(['first_name', 'last_name'])
|
||||||
->where(
|
->where(
|
||||||
['AND' => [
|
['AND' => [
|
||||||
'disabled' => 0,
|
'disabled' => 0,
|
||||||
'OR' => [
|
'OR' => [
|
||||||
'LOWER(firstName) LIKE' => '%'.strtolower($requestData['searchText']).'%',
|
'LOWER(first_name) LIKE' => '%'.strtolower($requestData['searchText']).'%',
|
||||||
'LOWER(lastName) LIKE' => '%'.strtolower($requestData['searchText']).'%',
|
'LOWER(last_name) LIKE' => '%'.strtolower($requestData['searchText']).'%',
|
||||||
'LOWER(email) LIKE' => '%'.strtolower($requestData['searchText']).'%'
|
'LOWER(email) LIKE' => '%'.strtolower($requestData['searchText']).'%'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -265,10 +265,10 @@ class TransactionCreationsController extends AppController
|
|||||||
} else {
|
} else {
|
||||||
$stateUsers = $stateUserTable
|
$stateUsers = $stateUserTable
|
||||||
->find('all')
|
->find('all')
|
||||||
->select(['id', 'firstName', 'lastName', 'email'])
|
->select(['id', 'first_name', 'last_name', 'email'])
|
||||||
//->order(['id'])
|
//->order(['id'])
|
||||||
->where(['disabled' => 0])
|
->where(['disabled' => 0])
|
||||||
->order(['firstName', 'lastName'])
|
->order(['first_name', 'last_name'])
|
||||||
->contain(['TransactionCreations' => [
|
->contain(['TransactionCreations' => [
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'TransactionCreations.amount',
|
'TransactionCreations.amount',
|
||||||
@ -300,7 +300,7 @@ class TransactionCreationsController extends AppController
|
|||||||
|
|
||||||
//if($sumAmount < 20000000) {
|
//if($sumAmount < 20000000) {
|
||||||
array_push($possibleReceivers, [
|
array_push($possibleReceivers, [
|
||||||
'name' => $stateUser->firstName . ' ' . $stateUser->lastName,
|
'name' => $stateUser->first_name . ' ' . $stateUser->last_name,
|
||||||
'id' => $stateUser->id,
|
'id' => $stateUser->id,
|
||||||
'email' => $stateUser->email,
|
'email' => $stateUser->email,
|
||||||
'amount' => $sumAmount,
|
'amount' => $sumAmount,
|
||||||
@ -353,7 +353,7 @@ class TransactionCreationsController extends AppController
|
|||||||
}
|
}
|
||||||
$receiverUsers = $stateUserTable->find('all')
|
$receiverUsers = $stateUserTable->find('all')
|
||||||
->where(['id IN' => array_keys($users)])
|
->where(['id IN' => array_keys($users)])
|
||||||
->select(['pubkey', 'email', 'id'])
|
->select(['public_key', 'email', 'id'])
|
||||||
->contain(false);
|
->contain(false);
|
||||||
|
|
||||||
foreach ($receiverUsers as $receiverUser) {
|
foreach ($receiverUsers as $receiverUser) {
|
||||||
@ -371,7 +371,7 @@ class TransactionCreationsController extends AppController
|
|||||||
} else {
|
} else {
|
||||||
$pendings[$id] = $localAmountCent;
|
$pendings[$id] = $localAmountCent;
|
||||||
}
|
}
|
||||||
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->pubkey));
|
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key));
|
||||||
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode([
|
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode([
|
||||||
'session_id' => $session->read('session_id'),
|
'session_id' => $session->read('session_id'),
|
||||||
'email' => $receiverUser->email,
|
'email' => $receiverUser->email,
|
||||||
|
|||||||
@ -30,14 +30,16 @@ class StateUser extends Entity
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_accessible = [
|
protected $_accessible = [
|
||||||
'groupId' => true,
|
'index_id' => true,
|
||||||
'pubkey' => true,
|
'state_group_id' => true,
|
||||||
|
'public_key' => true,
|
||||||
'email' => true,
|
'email' => true,
|
||||||
'firstName' => true,
|
'first_name' => true,
|
||||||
'lastName' => true,
|
'last_name' => true,
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'username' => true,
|
'username' => true,
|
||||||
'index' => true,
|
'index' => true,
|
||||||
|
'state_group' => true,
|
||||||
'state_balances' => true,
|
'state_balances' => true,
|
||||||
'state_created' => true,
|
'state_created' => true,
|
||||||
'transaction_creations' => true,
|
'transaction_creations' => true,
|
||||||
@ -46,11 +48,11 @@ class StateUser extends Entity
|
|||||||
|
|
||||||
public function getEmailWithName()
|
public function getEmailWithName()
|
||||||
{
|
{
|
||||||
return $this->firstName . ' ' . $this->lastName . ' <' . $this->email . '>';
|
return $this->first_name . ' ' . $this->last_name . ' <' . $this->email . '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNames()
|
public function getNames()
|
||||||
{
|
{
|
||||||
return $this->firstName . ' ' . $this->lastName;
|
return $this->first_name . ' ' . $this->last_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class AdminErrorsTable extends Table
|
|||||||
|
|
||||||
$this->addBehavior('Timestamp');
|
$this->addBehavior('Timestamp');
|
||||||
|
|
||||||
$this->belongsTo('User', [
|
$this->belongsTo('StateUsers', [
|
||||||
'foreignKey' => 'state_user_id',
|
'foreignKey' => 'state_user_id',
|
||||||
'joinType' => 'INNER'
|
'joinType' => 'INNER'
|
||||||
]);
|
]);
|
||||||
@ -100,7 +100,7 @@ class AdminErrorsTable extends Table
|
|||||||
*/
|
*/
|
||||||
public function buildRules(RulesChecker $rules)
|
public function buildRules(RulesChecker $rules)
|
||||||
{
|
{
|
||||||
$rules->add($rules->existsIn(['state_user_id'], 'User'));
|
$rules->add($rules->existsIn(['state_user_id'], 'StateUsers'));
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,10 +37,18 @@ class StateUsersTable extends Table
|
|||||||
{
|
{
|
||||||
parent::initialize($config);
|
parent::initialize($config);
|
||||||
|
|
||||||
$this->setTable('user');
|
$this->setTable('state_users');
|
||||||
$this->setDisplayField('email');
|
$this->setDisplayField('email');
|
||||||
$this->setPrimaryKey('id');
|
$this->setPrimaryKey('id');
|
||||||
|
|
||||||
|
/*$this->belongsTo('Indices', [
|
||||||
|
'foreignKey' => 'index_id',
|
||||||
|
'joinType' => 'INNER'
|
||||||
|
]);*/
|
||||||
|
$this->belongsTo('StateGroups', [
|
||||||
|
'foreignKey' => 'state_group_id',
|
||||||
|
'joinType' => 'INNER'
|
||||||
|
]);
|
||||||
$this->hasMany('StateBalances', [
|
$this->hasMany('StateBalances', [
|
||||||
'foreignKey' => 'state_user_id'
|
'foreignKey' => 'state_user_id'
|
||||||
]);
|
]);
|
||||||
@ -72,8 +80,8 @@ class StateUsersTable extends Table
|
|||||||
->allowEmptyString('id', null, 'create');
|
->allowEmptyString('id', null, 'create');
|
||||||
|
|
||||||
$validator
|
$validator
|
||||||
->requirePresence('pubkey', 'create')
|
->requirePresence('public_key', 'create')
|
||||||
->notEmptyString('pubkey');
|
->notEmptyString('public_key');
|
||||||
|
|
||||||
return $validator;
|
return $validator;
|
||||||
}
|
}
|
||||||
@ -116,7 +124,7 @@ class StateUsersTable extends Table
|
|||||||
$involvedUser = $this->find('all', [
|
$involvedUser = $this->find('all', [
|
||||||
'contain' => [],
|
'contain' => [],
|
||||||
'where' => ['id IN' => $involvedUserIds],
|
'where' => ['id IN' => $involvedUserIds],
|
||||||
'fields' => ['id', 'firstName', 'lastName', 'email'],
|
'fields' => ['id', 'first_name', 'last_name', 'email'],
|
||||||
]);
|
]);
|
||||||
//var_dump($involvedUser->toArray());
|
//var_dump($involvedUser->toArray());
|
||||||
$involvedUserIndices = [];
|
$involvedUserIndices = [];
|
||||||
|
|||||||
@ -49,13 +49,13 @@ class TransactionBase {
|
|||||||
protected function getStateUserId($publicKey) {
|
protected function getStateUserId($publicKey) {
|
||||||
|
|
||||||
$stateUsersTable = self::getTable('state_users');
|
$stateUsersTable = self::getTable('state_users');
|
||||||
$stateUser = $stateUsersTable->find('all')->select(['id'])->where(['pubkey' => $publicKey])->first();
|
$stateUser = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $publicKey])->first();
|
||||||
if($stateUser) {
|
if($stateUser) {
|
||||||
return $stateUser->id;
|
return $stateUser->id;
|
||||||
}
|
}
|
||||||
// create new entry
|
// create new entry
|
||||||
$stateUserEntity = $stateUsersTable->newEntity();
|
$stateUserEntity = $stateUsersTable->newEntity();
|
||||||
$stateUserEntity->pubkey = $publicKey;
|
$stateUserEntity->public_key = $publicKey;
|
||||||
if($stateUsersTable->save($stateUserEntity)) {
|
if($stateUsersTable->save($stateUserEntity)) {
|
||||||
return $stateUserEntity->id;
|
return $stateUserEntity->id;
|
||||||
} else {
|
} else {
|
||||||
@ -77,7 +77,7 @@ class TransactionBase {
|
|||||||
|
|
||||||
protected function getStateUserFromPublickey($publicKey) {
|
protected function getStateUserFromPublickey($publicKey) {
|
||||||
$stateUsersTable = self::getTable('state_users');
|
$stateUsersTable = self::getTable('state_users');
|
||||||
$stateUser = $stateUsersTable->find('all')->where(['pubkey' => $publicKey])->first();
|
$stateUser = $stateUsersTable->find('all')->where(['public_key' => $publicKey])->first();
|
||||||
if($stateUser) {
|
if($stateUser) {
|
||||||
return $stateUser;
|
return $stateUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class TransactionCreation extends TransactionBase {
|
|||||||
$existingCreations2 = $this->transactionCreationsTable
|
$existingCreations2 = $this->transactionCreationsTable
|
||||||
->find('all')
|
->find('all')
|
||||||
->select(['amount', 'state_user_id', 'target_date'])
|
->select(['amount', 'state_user_id', 'target_date'])
|
||||||
->contain(['StateUsers' => ['fields' => ['StateUsers.pubkey']]]);
|
->contain(['StateUsers' => ['fields' => ['StateUsers.public_key']]]);
|
||||||
$q = $existingCreations2;
|
$q = $existingCreations2;
|
||||||
$targetDate = $this->protoTransactionCreation->getTargetDate();
|
$targetDate = $this->protoTransactionCreation->getTargetDate();
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ class TransactionCreation extends TransactionBase {
|
|||||||
|
|
||||||
|
|
||||||
$receiverAmount = new \Proto\Gradido\TransferAmount();
|
$receiverAmount = new \Proto\Gradido\TransferAmount();
|
||||||
$receiverAmount->setPubkey(stream_get_contents($stateUser->pubkey));
|
$receiverAmount->setPubkey(stream_get_contents($stateUser->public_key));
|
||||||
$receiverAmount->setAmount($transactionCreationEntity->amount);
|
$receiverAmount->setAmount($transactionCreationEntity->amount);
|
||||||
|
|
||||||
$protoCreation->setReceiver($receiverAmount);
|
$protoCreation->setReceiver($receiverAmount);
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class TransactionTransfer extends TransactionBase {
|
|||||||
$user = $stateUsersTable
|
$user = $stateUsersTable
|
||||||
->find('all')
|
->find('all')
|
||||||
->select(['id'])
|
->select(['id'])
|
||||||
->where(['pubkey' => $senderPublic])
|
->where(['public_key' => $senderPublic])
|
||||||
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]])->first();
|
->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]])->first();
|
||||||
if(!$user) {
|
if(!$user) {
|
||||||
$this->addError($functionName, 'couldn\'t find sender in db' );
|
$this->addError($functionName, 'couldn\'t find sender in db' );
|
||||||
@ -114,7 +114,7 @@ class TransactionTransfer extends TransactionBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if receiver exist
|
// check if receiver exist
|
||||||
$receiver_user = $stateUsersTable->find('all')->select(['id'])->where(['pubkey' => $receiver_public_key])->first();
|
$receiver_user = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $receiver_public_key])->first();
|
||||||
if(!$receiver_user) {
|
if(!$receiver_user) {
|
||||||
$this->addError($functionName, 'couldn\'t find receiver in db' );
|
$this->addError($functionName, 'couldn\'t find receiver in db' );
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -6,9 +6,8 @@ use Cake\TestSuite\Fixture\TestFixture;
|
|||||||
/**
|
/**
|
||||||
* StateUsersFixture
|
* StateUsersFixture
|
||||||
*/
|
*/
|
||||||
class UserFixture extends BaseTestFixture
|
class StateUsersFixture extends BaseTestFixture
|
||||||
{
|
{
|
||||||
public $import = [ 'model' => 'StateUsers', 'connection' => 'test' ];
|
|
||||||
/**
|
/**
|
||||||
* Fields
|
* Fields
|
||||||
*
|
*
|
||||||
@ -17,16 +16,17 @@ class UserFixture extends BaseTestFixture
|
|||||||
// @codingStandardsIgnoreStart
|
// @codingStandardsIgnoreStart
|
||||||
public $fields = [
|
public $fields = [
|
||||||
'id' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
|
'id' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
|
||||||
'groupId' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null],
|
'index_id' => ['type' => 'smallinteger', 'length' => 6, 'unsigned' => false, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null],
|
||||||
'pubkey' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
|
'group_id' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null],
|
||||||
|
'public_key' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
|
||||||
'email' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
'email' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
||||||
'firstNname' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
'first_name' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
||||||
'lastName' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
'last_name' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
||||||
'username' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
'username' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8mb4_unicode_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
|
||||||
'disabled' => ['type' => 'tinyinteger', 'length' => 4, 'unsigned' => false, 'null' => true, 'default' => '0', 'comment' => '', 'precision' => null],
|
'disabled' => ['type' => 'tinyinteger', 'length' => 4, 'unsigned' => false, 'null' => true, 'default' => '0', 'comment' => '', 'precision' => null],
|
||||||
'_constraints' => [
|
'_constraints' => [
|
||||||
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
|
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
|
||||||
'pubkey' => ['type' => 'unique', 'columns' => ['pubkey'], 'length' => []],
|
'public_key' => ['type' => 'unique', 'columns' => ['public_key'], 'length' => []],
|
||||||
],
|
],
|
||||||
'_options' => [
|
'_options' => [
|
||||||
'engine' => 'InnoDB',
|
'engine' => 'InnoDB',
|
||||||
@ -44,9 +44,9 @@ class UserFixture extends BaseTestFixture
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$sql_entrys = [
|
$sql_entrys = [
|
||||||
[1, 0, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 'test1.gmail.de', 'Max', 'Mustermann', NULL, 0],
|
[1, 0, 0, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 'test1.gmail.de', 'Max', 'Mustermann', NULL, 0],
|
||||||
[3, 0, '131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6', 'test2.gmail.com', 'Ines', 'Mustermann', NULL, 0],
|
[3, 0, 0, '131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6', 'test2.gmail.com', 'Ines', 'Mustermann', NULL, 0],
|
||||||
[4, 0, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 'test3.yahoo.com', 'Samuel', 'Schmied', NULL, 0]
|
[4, 0, 0, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 'test3.yahoo.com', 'Samuel', 'Schmied', NULL, 0]
|
||||||
];
|
];
|
||||||
$this->records = $this->sqlEntrysToRecords($sql_entrys, $this->fields);
|
$this->records = $this->sqlEntrysToRecords($sql_entrys, $this->fields);
|
||||||
parent::init();
|
parent::init();
|
||||||
@ -21,7 +21,7 @@ class AdminErrorsControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.AdminErrors',
|
'app.AdminErrors',
|
||||||
'app.User'
|
'app.StateUsers'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class JsonRequestHandlerControllerTest extends TestCase
|
|||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.TransactionCreations',
|
'app.TransactionCreations',
|
||||||
'app.Transactions',
|
'app.Transactions',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.StateUserTransactions',
|
'app.StateUserTransactions',
|
||||||
'app.StateErrors',
|
'app.StateErrors',
|
||||||
'app.TransactionSignatures',
|
'app.TransactionSignatures',
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class ProfilesControllerTest extends TestCase
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.CommunityProfiles',
|
'app.CommunityProfiles',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class StateBalancesControllerTest extends TestCase
|
|||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.TransactionCreations',
|
'app.TransactionCreations',
|
||||||
'app.Transactions',
|
'app.Transactions',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.StateUserTransactions',
|
'app.StateUserTransactions',
|
||||||
'app.StateErrors',
|
'app.StateErrors',
|
||||||
'app.TransactionSignatures',
|
'app.TransactionSignatures',
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class StateErrorsControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.StateErrors',
|
'app.StateErrors',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.TransactionTypes'
|
'app.TransactionTypes'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class StateUserTransactionsControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.StateUserTransactions',
|
'app.StateUserTransactions',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.Transactions',
|
'app.Transactions',
|
||||||
'app.TransactionTypes',
|
'app.TransactionTypes',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class TransactionCreationsControllerTest extends TestCase
|
|||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.TransactionCreations',
|
'app.TransactionCreations',
|
||||||
'app.Transactions',
|
'app.Transactions',
|
||||||
'app.User'
|
'app.StateUsers'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class AdminErrorsTableTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.AdminErrors',
|
'app.AdminErrors',
|
||||||
'app.User'
|
'app.StateUsers'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class StateBalancesTableTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.StateBalances',
|
'app.StateBalances',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class StateErrorsTableTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.StateErrors',
|
'app.StateErrors',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.TransactionTypes'
|
'app.TransactionTypes'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class StateUserTransactionsTableTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.StateUserTransactions',
|
'app.StateUserTransactions',
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.Transactions',
|
'app.Transactions',
|
||||||
'app.TransactionTypes',
|
'app.TransactionTypes',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class StateUsersTableTest extends TestCase
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $fixtures = [
|
public $fixtures = [
|
||||||
'app.User',
|
'app.StateUsers',
|
||||||
'app.StateGroups',
|
'app.StateGroups',
|
||||||
'app.StateBalances',
|
'app.StateBalances',
|
||||||
'app.StateCreated',
|
'app.StateCreated',
|
||||||
@ -39,8 +39,8 @@ class StateUsersTableTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$config = TableRegistry::getTableLocator()->exists('User') ? [] : ['className' => StateUsersTable::class];
|
$config = TableRegistry::getTableLocator()->exists('StateUsers') ? [] : ['className' => StateUsersTable::class];
|
||||||
$this->StateUsersTable = TableRegistry::getTableLocator()->get('User', $config);
|
$this->StateUsersTable = TableRegistry::getTableLocator()->get('StateUsers', $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user