mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #422 from gradido/community_update_old_frontend
use new function for balance overview in old frontend, update balance…
This commit is contained in:
commit
a2320908bc
@ -21,7 +21,7 @@ use Cake\Routing\Router;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\I18n\Time;
|
||||
use Cake\I18n\I18n;
|
||||
use Cake\I18n\FrozenTime;
|
||||
|
||||
/**
|
||||
* Application Controller
|
||||
@ -174,6 +174,7 @@ class AppController extends Controller
|
||||
protected function requestLogin($sessionId = 0, $redirect = true)
|
||||
{
|
||||
$this->checkForMigration($redirect);
|
||||
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
|
||||
$session = $this->getRequest()->getSession();
|
||||
// check login
|
||||
// disable encryption for cookies
|
||||
@ -206,12 +207,15 @@ class AppController extends Controller
|
||||
$transactionPendings = $session->read('Transactions.pending');
|
||||
$transactionExecutings = $session->read('Transactions.executing');
|
||||
$transaction_can_signed = $session->read('Transactions.can_signed');
|
||||
|
||||
|
||||
|
||||
if ($session->read('session_id') != $session_id ||
|
||||
( $userStored && (!isset($userStored['id']) || !$userStored['email_checked'])) ||
|
||||
intval($transactionPendings) > 0 ||
|
||||
intval($transactionExecutings) > 0 ||
|
||||
intval($transaction_can_signed > 0)) {
|
||||
intval($transaction_can_signed > 0))
|
||||
{
|
||||
$http = new Client();
|
||||
|
||||
try {
|
||||
@ -242,6 +246,7 @@ class AppController extends Controller
|
||||
$session->write('Transactions.can_signed', $transaction_can_signed);
|
||||
$session->write('session_id', $session_id);
|
||||
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||
|
||||
|
||||
if (isset($json['user']['public_hex']) && $json['user']['public_hex'] != '') {
|
||||
$public_key_bin = hex2bin($json['user']['public_hex']);
|
||||
@ -270,11 +275,6 @@ class AppController extends Controller
|
||||
$this->Flash->error(__('error updating state user ' . json_encode($stateUser->errors())));
|
||||
}
|
||||
}
|
||||
//var_dump($stateUser);
|
||||
if (count($stateUser->state_balances) > 0) {
|
||||
|
||||
$session->write('StateUser.balance', $stateUser->state_balances[0]->decay);
|
||||
}
|
||||
$session->write('StateUser.id', $stateUser->id);
|
||||
//echo $stateUser['id'];
|
||||
} else {
|
||||
@ -326,6 +326,11 @@ class AppController extends Controller
|
||||
//continue;
|
||||
}
|
||||
}
|
||||
$state_balance = $stateBalancesTable->find()->where(['state_user_id' => $session->read('StateUser.id')])->first();
|
||||
if ($state_balance) {
|
||||
$now = new FrozenTime;
|
||||
$session->write('StateUser.balance', $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now));
|
||||
}
|
||||
} else {
|
||||
// no login
|
||||
//die("no login");
|
||||
|
||||
@ -360,7 +360,7 @@ class AppRequestsController extends AppController
|
||||
$body['decay'] = 0.0;
|
||||
} else {
|
||||
$body['balance'] = $state_balance->amount;
|
||||
$body['decay'] = $state_balance->partDecay($now);
|
||||
$body['decay'] = $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now);
|
||||
}
|
||||
|
||||
$this->set('body', $body);
|
||||
|
||||
@ -64,6 +64,7 @@ class MigrationsController extends AppController
|
||||
$commands = [
|
||||
[$blockchainTypesTable, 'fillWithDefault'],
|
||||
[$transactionTypesTable, 'fillWithDefault'],
|
||||
[$stateBalancesTable, 'truncate'],
|
||||
[$transactionsTable, 'fillStateUserTransactions'],
|
||||
[$stateBalancesTable, 'updateAllBalances']
|
||||
];
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\I18n\Time;
|
||||
use Cake\I18n\FrozenTime;
|
||||
|
||||
use Model\Navigation\NaviHierarchy;
|
||||
use Model\Navigation\NaviHierarchyEntry;
|
||||
@ -65,6 +65,7 @@ class StateBalancesController extends AppController
|
||||
if($update_balance_result['success'] !== true) {
|
||||
$this->addAdminError('StateBalances', 'overview', $update_balance_result, $user['id']);
|
||||
}
|
||||
|
||||
// sendRequestGDT
|
||||
// listPerEmailApi
|
||||
|
||||
@ -84,200 +85,68 @@ class StateBalancesController extends AppController
|
||||
//}
|
||||
//
|
||||
//
|
||||
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
|
||||
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
||||
|
||||
$creationsTable = TableRegistry::getTableLocator()->get('TransactionCreations');
|
||||
$creationTransactions = $creationsTable
|
||||
->find('all')
|
||||
->where(['state_user_id' => $user['id']])
|
||||
->contain(['Transactions']);
|
||||
|
||||
$transferTable = TableRegistry::getTableLocator()->get('TransactionSendCoins');
|
||||
$transferTransactions = $transferTable
|
||||
->find('all')
|
||||
->where(['OR' => ['state_user_id' => $user['id'], 'receiver_user_id' => $user['id']]])
|
||||
->contain(['Transactions']);
|
||||
|
||||
$involvedUserIds = [];
|
||||
|
||||
foreach ($transferTransactions as $sendCoins) {
|
||||
//var_dump($sendCoins);
|
||||
if ($sendCoins->state_user_id != $user['id']) {
|
||||
array_push($involvedUserIds, intval($sendCoins->state_user_id));
|
||||
} elseif ($sendCoins->receiver_user_id != $user['id']) {
|
||||
array_push($involvedUserIds, intval($sendCoins->receiver_user_id));
|
||||
}
|
||||
}
|
||||
|
||||
/*echo "state user from sendCoins: $sendCoins->state_user_id<br>";
|
||||
echo "receiver user from sendCoins: $sendCoins->receiver_user_id<br>";
|
||||
echo "user id from logged in user: ".$user['id']. '<br>';
|
||||
*/
|
||||
//var_dump($involvedUserIds);
|
||||
// exchange key with values and drop duplicates
|
||||
$involvedUser_temp = array_flip($involvedUserIds);
|
||||
// exchange back
|
||||
$involvedUserIds = array_flip($involvedUser_temp);
|
||||
$userTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||
$involvedUser = $userTable->find('all', [
|
||||
'contain' => false,
|
||||
'where' => ['id IN' => $involvedUserIds],
|
||||
'fields' => ['id', 'first_name', 'last_name', 'email']
|
||||
]);
|
||||
//var_dump($involvedUser->toArray());
|
||||
$involvedUserIndices = [];
|
||||
foreach ($involvedUser as $involvedUser) {
|
||||
$involvedUserIndices[$involvedUser->id] = $involvedUser;
|
||||
}
|
||||
|
||||
// sender or receiver when user has sended money
|
||||
// group name if creation
|
||||
// type: gesendet / empfangen / geschöpft
|
||||
// transaktion nr / id
|
||||
// date
|
||||
// balance
|
||||
|
||||
$transactions = [];
|
||||
foreach ($creationTransactions as $creation) {
|
||||
//var_dump($creation);
|
||||
array_push($transactions, [
|
||||
'name' => 'Gradido Akademie',
|
||||
'type' => 'creation',
|
||||
'transaction_id' => $creation->transaction_id,
|
||||
'date' => $creation->target_date,
|
||||
'balance' => $creation->amount,
|
||||
'memo' => $creation->transaction->memo
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($transferTransactions as $sendCoins) {
|
||||
$type = '';
|
||||
$otherUser = null;
|
||||
$other_user_public = '';
|
||||
if ($sendCoins->state_user_id == $user['id']) {
|
||||
$type = 'send';
|
||||
|
||||
if(isset($involvedUserIndices[$sendCoins->receiver_user_id])) {
|
||||
$otherUser = $involvedUserIndices[$sendCoins->receiver_user_id];
|
||||
}
|
||||
$other_user_public = bin2hex(stream_get_contents($sendCoins->receiver_public_key));
|
||||
} else if ($sendCoins->receiver_user_id == $user['id']) {
|
||||
$type = 'receive';
|
||||
if(isset($involvedUserIndices[$sendCoins->state_user_id])) {
|
||||
$otherUser = $involvedUserIndices[$sendCoins->state_user_id];
|
||||
}
|
||||
if($sendCoins->sender_public_key) {
|
||||
$other_user_public = bin2hex(stream_get_contents($sendCoins->sender_public_key));
|
||||
}
|
||||
}
|
||||
if(null == $otherUser) {
|
||||
$otherUser = $this->StateBalances->StateUsers->newEntity();
|
||||
}
|
||||
array_push($transactions, [
|
||||
'name' => $otherUser->first_name . ' ' . $otherUser->last_name,
|
||||
'email' => $otherUser->email,
|
||||
'type' => $type,
|
||||
'transaction_id' => $sendCoins->transaction_id,
|
||||
'date' => $sendCoins->transaction->received,
|
||||
'balance' => $sendCoins->amount,
|
||||
'memo' => $sendCoins->transaction->memo,
|
||||
'pubkey' => $other_user_public
|
||||
]);
|
||||
}
|
||||
uasort($transactions, array($this, 'sortTransactions'));
|
||||
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
|
||||
|
||||
// add decay transactions
|
||||
$month_start_state_balance = null;
|
||||
$current_state_balance = null;
|
||||
$cursor = 0;
|
||||
$transactions_reversed = array_reverse($transactions);
|
||||
$decay_transactions = [];
|
||||
$maxI = count($transactions_reversed);
|
||||
|
||||
$stateBalancesTable->updateBalances($user['id']);
|
||||
|
||||
foreach($transactions_reversed as $i => $transaction) {
|
||||
if(!isset($transaction['transaction_id'])) {
|
||||
//echo "missing transaction<br>";
|
||||
continue;
|
||||
}
|
||||
$transaction_id = $transaction['transaction_id'];
|
||||
//echo "transaction id: $transaction_id <br>";
|
||||
$decay_transaction = NULL;
|
||||
$state_balance = $this->StateBalances->newEntity();
|
||||
|
||||
if($i > 0 && isset($transactions_reversed[$i-1]['transaction_id'])) {
|
||||
$prev_transaction = $transactions_reversed[$i-1];
|
||||
$stateUserTransactions = $stateUserTransactionsTable
|
||||
->find()
|
||||
->where([
|
||||
'transaction_id IN' => [$transaction_id, $prev_transaction['transaction_id']],
|
||||
'state_user_id' => $user['id']
|
||||
])
|
||||
->order(['balance_date ASC'])
|
||||
->toArray();
|
||||
|
||||
$prev = $stateUserTransactions[0];
|
||||
if($prev->balance > 0) {
|
||||
// var_dump($stateUserTransactions);
|
||||
$current = $stateUserTransactions[1];
|
||||
//echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "<br>";
|
||||
$interval = $current->balance_date->diff($prev->balance_date);
|
||||
$state_balance->amount = $prev->balance;
|
||||
$state_balance->record_date = $prev->balance_date;
|
||||
$diff_amount = $state_balance->partDecay($current->balance_date);
|
||||
|
||||
//echo $interval->format('%R%a days');
|
||||
//echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "<br>";
|
||||
$decay_transaction = [
|
||||
'type' => 'decay',
|
||||
'balance' => -intval($prev->balance - $diff_amount),
|
||||
'decay_duration' => $interval->format('%a days, %H hours, %I minutes, %S seconds'),
|
||||
'memo' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if($decay_transaction) {
|
||||
$decay_transactions[] = $decay_transaction;
|
||||
//array_splice($transactions_reversed, $i + $cursor, 0, [$decay_transaction]);
|
||||
//$cursor++;
|
||||
}
|
||||
if($i == $maxI-1) {
|
||||
$stateUserTransaction = $stateUserTransactionsTable
|
||||
->find()
|
||||
->where(['transaction_id' => $transaction_id, 'state_user_id' => $user['id']])
|
||||
->order(['transaction_id ASC'])->first();
|
||||
//var_dump($stateUserTransaction);
|
||||
$state_balance->amount = $stateUserTransaction->balance;
|
||||
$state_balance->record_date = $stateUserTransaction->balance_date;
|
||||
$decay_transactions[] = [
|
||||
//$transactions_reversed[] = [
|
||||
'type' => 'decay',
|
||||
'balance' => -intval($stateUserTransaction->balance - $state_balance->decay),
|
||||
'decay_duration' => $stateUserTransaction->balance_date->timeAgoInWords(),
|
||||
'memo' => ''
|
||||
];
|
||||
|
||||
}
|
||||
$gdtSum = 0;
|
||||
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
|
||||
|
||||
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
|
||||
$gdtSum = intval($gdtEntries['data']['sum']);
|
||||
} else {
|
||||
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id'] ? $user['id'] : 0);
|
||||
}
|
||||
$final_transactions = [];
|
||||
foreach($transactions_reversed as $i => $transaction) {
|
||||
$final_transactions[] = $transaction;
|
||||
$final_transactions[] = $decay_transactions[$i];
|
||||
|
||||
|
||||
$stateUserTransactionsQuery = $stateUserTransactionsTable
|
||||
->find()
|
||||
->where(['state_user_id' => $user['id']])
|
||||
->order(['balance_date' => 'ASC'])
|
||||
->contain([])
|
||||
;
|
||||
$decay = true;
|
||||
$transactions = [];
|
||||
if($stateUserTransactionsQuery->count() > 0) {
|
||||
$transactions = $transactionsTable->listTransactionsHumanReadable($stateUserTransactionsQuery->toArray(), $user, $decay);
|
||||
}
|
||||
|
||||
$state_balance = $stateBalancesTable->find()->where(['state_user_id' => $user['id']])->first();
|
||||
|
||||
$body = [
|
||||
'state' => 'success',
|
||||
'transactions' => $transactions,
|
||||
'transactionExecutingCount' => $session->read('Transactions.executing'),
|
||||
'count' => count($transactions),
|
||||
'gdtSum' => $gdtSum,
|
||||
'timeUsed' => microtime(true) - $startTime
|
||||
];
|
||||
$now = new FrozenTime();
|
||||
$body['decay_date'] = $now;
|
||||
|
||||
if(!$state_balance) {
|
||||
$balance = 0.0;
|
||||
} else {
|
||||
$balance = $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now);
|
||||
//$balance = $state_balance->partDecay($now);
|
||||
}
|
||||
// for debugging
|
||||
$calculated_balance = 0;
|
||||
foreach($final_transactions as $tr) {
|
||||
if($tr['type'] == 'send') {
|
||||
$calculated_balance -= intval($tr['balance']);
|
||||
foreach($transactions as $transaction) {
|
||||
if($transaction['type'] == 'decay' || $transaction['type'] == 'send') {
|
||||
$calculated_balance -= $transaction['balance'];
|
||||
} else {
|
||||
$calculated_balance += intval($tr['balance']);
|
||||
$calculated_balance += $transaction['balance'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->set('calculated_balance', $calculated_balance);
|
||||
|
||||
$this->set('transactions', array_reverse($final_transactions));
|
||||
$this->set('transactions', array_reverse($transactions));
|
||||
$this->set('transactionExecutingCount', $session->read('Transactions.executing'));
|
||||
$this->set('balance', $session->read('StateUser.balance'));
|
||||
$this->set('balance', $balance);
|
||||
$this->set('timeUsed', microtime(true) - $startTime);
|
||||
$this->set('gdtSum', $gdtSum);
|
||||
}
|
||||
@ -301,151 +170,16 @@ class StateBalancesController extends AppController
|
||||
if(!$state_balance) {
|
||||
return $this->returnJson(['state' => 'success', 'balance' => 0]);
|
||||
}
|
||||
$now = new FrozenTime();
|
||||
|
||||
return $this->returnJson([
|
||||
'state' => 'success',
|
||||
'balance' => $state_balance->amount,
|
||||
'decay' => $state_balance->decay
|
||||
'decay' => $this->StateBalances->calculateDecay($state_balance->amount, $state_balance->record_date, $now),
|
||||
'decay_date' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function ajaxListTransactions($session_id, $page=1, $count=25)
|
||||
{
|
||||
if(!$session_id) {
|
||||
return $this->returnJson(['state' => 'error', 'msg' => 'invalid session id']);
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$login_result = $this->requestLogin($session_id, false);
|
||||
if($login_result !== true) {
|
||||
return $this->returnJson($login_result);
|
||||
}
|
||||
$session = $this->getRequest()->getSession();
|
||||
$user = $session->read('StateUser');
|
||||
|
||||
$this->StateBalances->updateBalances($user['id']);
|
||||
|
||||
$gdtSum = 0;
|
||||
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
|
||||
|
||||
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
|
||||
$gdtSum = intval($gdtEntries['data']['sum']);
|
||||
} else {
|
||||
if($user) {
|
||||
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id']);
|
||||
} else {
|
||||
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, 0);
|
||||
}
|
||||
}
|
||||
|
||||
$creationsTable = TableRegistry::getTableLocator()->get('TransactionCreations');
|
||||
$creationTransactions = $creationsTable
|
||||
->find('all')
|
||||
->where(['state_user_id' => $user['id']])
|
||||
->contain(['Transactions']);
|
||||
|
||||
$transferTable = TableRegistry::getTableLocator()->get('TransactionSendCoins');
|
||||
$transferTransactions = $transferTable
|
||||
->find('all')
|
||||
->where(['OR' => ['state_user_id' => $user['id'], 'receiver_user_id' => $user['id']]])
|
||||
->contain(['Transactions']);
|
||||
|
||||
$involvedUserIds = [];
|
||||
|
||||
foreach ($transferTransactions as $sendCoins) {
|
||||
//var_dump($sendCoins);
|
||||
if ($sendCoins->state_user_id != $user['id']) {
|
||||
array_push($involvedUserIds, intval($sendCoins->state_user_id));
|
||||
} elseif ($sendCoins->receiver_user_id != $user['id']) {
|
||||
array_push($involvedUserIds, intval($sendCoins->receiver_user_id));
|
||||
}
|
||||
}
|
||||
|
||||
/*echo "state user from sendCoins: $sendCoins->state_user_id<br>";
|
||||
echo "receiver user from sendCoins: $sendCoins->receiver_user_id<br>";
|
||||
echo "user id from logged in user: ".$user['id']. '<br>';
|
||||
*/
|
||||
//var_dump($involvedUserIds);
|
||||
// exchange key with values and drop duplicates
|
||||
$involvedUser_temp = array_flip($involvedUserIds);
|
||||
// exchange back
|
||||
$involvedUserIds = array_flip($involvedUser_temp);
|
||||
$userTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||
$involvedUser = $userTable->find('all', [
|
||||
'contain' => false,
|
||||
'where' => ['id IN' => $involvedUserIds],
|
||||
'fields' => ['id', 'first_name', 'last_name', 'email']
|
||||
]);
|
||||
//var_dump($involvedUser->toArray());
|
||||
$involvedUserIndices = [];
|
||||
foreach ($involvedUser as $involvedUser) {
|
||||
$involvedUserIndices[$involvedUser->id] = $involvedUser;
|
||||
}
|
||||
|
||||
// sender or receiver when user has sended money
|
||||
// group name if creation
|
||||
// type: gesendet / empfangen / geschöpft
|
||||
// transaktion nr / id
|
||||
// date
|
||||
// balance
|
||||
|
||||
$transactions = [];
|
||||
foreach ($creationTransactions as $creation) {
|
||||
//var_dump($creation);
|
||||
array_push($transactions, [
|
||||
'name' => 'Gradido Akademie',
|
||||
'type' => 'creation',
|
||||
'transaction_id' => $creation->transaction_id,
|
||||
'date' => $creation->transaction->received,
|
||||
'balance' => $creation->amount,
|
||||
'memo' => $creation->transaction->memo
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($transferTransactions as $sendCoins) {
|
||||
$type = '';
|
||||
$otherUser = null;
|
||||
if ($sendCoins->state_user_id == $user['id']) {
|
||||
$type = 'send';
|
||||
|
||||
if(isset($involvedUserIndices[$sendCoins->receiver_user_id])) {
|
||||
$otherUser = $involvedUserIndices[$sendCoins->receiver_user_id];
|
||||
}
|
||||
} else if ($sendCoins->receiver_user_id == $user['id']) {
|
||||
$type = 'receive';
|
||||
if(isset($involvedUserIndices[$sendCoins->state_user_id])) {
|
||||
$otherUser = $involvedUserIndices[$sendCoins->state_user_id];
|
||||
}
|
||||
}
|
||||
if(null == $otherUser) {
|
||||
$otherUser = $this->StateBalances->StateUsers->newEntity();
|
||||
}
|
||||
array_push($transactions, [
|
||||
'name' => $otherUser->first_name . ' ' . $otherUser->last_name,
|
||||
'email' => $otherUser->email,
|
||||
'type' => $type,
|
||||
'transaction_id' => $sendCoins->transaction_id,
|
||||
'date' => $sendCoins->transaction->received,
|
||||
'balance' => $sendCoins->amount,
|
||||
'memo' => $sendCoins->transaction->memo
|
||||
]);
|
||||
}
|
||||
uasort($transactions, array($this, 'sortTransactions'));
|
||||
if($sort == 'DESC') {
|
||||
$transactions = array_reverse($transactions);
|
||||
}
|
||||
return $this->returnJson([
|
||||
'state' => 'success',
|
||||
'transactions' => $transactions,
|
||||
'transactionExecutingCount' => $session->read('Transactions.executing'),
|
||||
'count' => count($transactions),
|
||||
'gdtSum' => $gdtSum,
|
||||
'timeUsed' => microtime(true) - $startTime
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function ajaxGdtOverview()
|
||||
{
|
||||
|
||||
@ -22,6 +22,7 @@ class AppTable extends Table
|
||||
$this->getConnection()->query($truncateCommand);
|
||||
}
|
||||
$this->getConnection()->query('ALTER TABLE ' . $this->getSchema()->name() . ' AUTO_INCREMENT=1');
|
||||
return ['success' => true];
|
||||
}
|
||||
public function saveManyWithErrors($entities)
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ use Cake\I18n\FrozenTime;
|
||||
*
|
||||
* @mixin \Cake\ORM\Behavior\TimestampBehavior
|
||||
*/
|
||||
class StateBalancesTable extends Table
|
||||
class StateBalancesTable extends AppTable
|
||||
{
|
||||
private static $startDecayDate = null;
|
||||
/**
|
||||
|
||||
@ -426,6 +426,9 @@ class TransactionsTable extends Table
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($state_user_ids) < 1) {
|
||||
return ['success' => true];
|
||||
}
|
||||
//var_dump($entities);
|
||||
$stateUsersTable = TableRegistry::getTableLocator()->get('StateUsers');
|
||||
$existingStateUsers = $stateUsersTable->find('all')->select(['id'])->where(['id IN' => $state_user_ids])->order(['id'])->all();
|
||||
|
||||
@ -134,6 +134,9 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
log_Path = "./";
|
||||
#endif
|
||||
if (mConfigPath != "") {
|
||||
log_Path = "./";
|
||||
}
|
||||
|
||||
// init speed logger
|
||||
Poco::AutoPtr<Poco::SimpleFileChannel> speedLogFileChannel(new Poco::SimpleFileChannel(log_Path + "speedLog.txt"));
|
||||
@ -165,10 +168,14 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
createConsoleFileAsyncLogger("emailLog", log_Path + "emailLog.txt");
|
||||
|
||||
// *************** load from config ********************************************
|
||||
|
||||
|
||||
std::string cfg_Path = Poco::Path::config() + "grd_login/";
|
||||
try {
|
||||
loadConfiguration(cfg_Path + "grd_login.properties");
|
||||
if(mConfigPath != "") {
|
||||
loadConfiguration(mConfigPath);
|
||||
} else {
|
||||
loadConfiguration(cfg_Path + "grd_login.properties");
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
errorLog.error("error loading config: %s", ex.displayText());
|
||||
@ -295,4 +302,4 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
|
||||
}
|
||||
return Application::EXIT_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ namespace controller {
|
||||
|
||||
using namespace Poco::Data::Keywords;
|
||||
Poco::Data::Statement select(session);
|
||||
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
||||
select << "SELECT id, first_name, last_name, email, pubkey, created, email_checked, disabled FROM " << db->getTableName();
|
||||
// typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, Poco::DateTime, int, int, int> UserTuple;
|
||||
select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id FROM " << db->getTableName();
|
||||
select << " where email_checked = 0 ";
|
||||
select, into(resultFromDB);
|
||||
if (searchString != "") {
|
||||
|
||||
@ -3,12 +3,12 @@ COLOR_GREEN="\033[0;32m"
|
||||
COLOR_YELLOW="\e[33m"
|
||||
COLOR_NONE="\033[0m"
|
||||
|
||||
LOGIN_DB_USER=gradido_login
|
||||
LOGIN_DB_NAME=gradido_login
|
||||
LOGIN_DB_USER=gradido_login_live
|
||||
LOGIN_DB_NAME=gradido_login_live
|
||||
LOGIN_DB_PASSWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
|
||||
|
||||
COMMUNITY_DB_USER=gradido_community
|
||||
COMMUNITY_DB_NAME=gradido_community
|
||||
COMMUNITY_DB_USER=gradido_community_live
|
||||
COMMUNITY_DB_NAME=gradido_community_live
|
||||
COMMUNITY_DB_PASSWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
|
||||
|
||||
# create table
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user