Compare commits

..
10 changed files with 66 additions and 556 deletions
-43
View File
@@ -1,43 +0,0 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class BankData extends Auth_Controller
{
/**
*
*/
public function __construct()
{
parent::__construct(
array(
'view' => 'basis/cis:r'
)
);
}
/**
*
*/
public function view()
{
$this->load->view('Cis/BankData');
}
}
@@ -1,213 +0,0 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/> .
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Controller between the bank related VueJS components and the backend
*/
class Bank extends FHCAPI_Controller
{
const BANK_NAME_PARAM = 'name';
const BIC_PARAM = 'bic';
const IBAN_PARAM = 'iban';
/**
* Object initialization
*/
public function __construct()
{
// Sets permissions
parent::__construct(array(
'getBankData' => self::PERM_LOGGED,
'postBankData' => self::PERM_LOGGED
));
// Load language phrases
$this->loadPhrases(array('person'));
// Loads model Bankverbindung_model
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Reads the bank data using the person id of the logged person and returns them in JSON format
*/
public function getBankData()
{
// Person id of the logged user
$loggedPersonId = getAuthPersonId();
// If null then not authenticated then terminate
if ($loggedPersonId == null) $this->terminateWithError('Not logged user/User without an associated person', self::ERROR_TYPE_AUTH);
// Gets the latest added to the database bank data for this logged user
$bankDataResult = $this->BankverbindungModel->execReadOnlyQuery(
'SELECT
bv.name,
bv.bic,
bv.iban,
COALESCE(bv.updateamum, bv.insertamum) AS update_date,
bv.insertamum
FROM
public.tbl_bankverbindung bv
WHERE bv.person_id = ?
ORDER BY bv.insertamum DESC, update_date DESC
LIMIT 1',
array($loggedPersonId)
);
// Get the retrieved data or terminate
$data = $this->getDataOrTerminateWithError($bankDataResult);
// Anyway terminate it!
$this->terminateWithSuccess($data);
}
/**
* Writes the bank data using the person id of the logged person and the posted bank data
*/
public function postBankData()
{
// UID and Person id of the logged user
$loggedUID = getAuthUID();
$loggedPersonId = getAuthPersonId();
// If null then not authenticated then terminate
if ($loggedUID == null) $this->terminateWithError('Not logged user/User without UID', self::ERROR_TYPE_AUTH);
if ($loggedPersonId == null) $this->terminateWithError('Not logged user/User without Person Id', self::ERROR_TYPE_AUTH);
// Loads model Mitarbeiter_model
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
// Checks if the logged user is an amployee, in case stop the execution
if (!$this->MitarbeiterModel->isMitarbeiter($loggedUID)) $this->terminateWithValidationErrors(array('' => $this->p->t('person', 'notForEmployees')));
// Loads the CI validation library
$this->load->library('form_validation');
// Checks if the posted parameters are fine
$this->form_validation->set_rules(self::BANK_NAME_PARAM, null, array('required', 'alpha_numeric_spaces'));
$this->form_validation->set_rules(self::BIC_PARAM, null, array('required', 'alpha_numeric'));
$this->form_validation->set_rules(self::IBAN_PARAM, null, array('required', 'alpha_numeric_spaces'));
// Run the validation and checks the result
if (!$this->form_validation->run()) $this->terminateWithValidationErrors($this->form_validation->error_array());
// Checks if the provided BIC is fine
$bic = preg_replace("/[^A-Za-z0-9 ]/", '', $this->input->post(self::BIC_PARAM));
if (!$this->_checkBic($bic)) $this->terminateWithValidationErrors(array('bic' => $this->p->t('person', 'notValidaBIC')));
// Checks if the provided IBAN is fine using the php-iban library
$iban = preg_replace("/[^A-Za-z0-9 ]/", '', $this->input->post(self::IBAN_PARAM));
if (!verify_iban($iban)) $this->terminateWithValidationErrors(array('iban' => $this->p->t('person', 'notValidaIBAN')));
// If the IBAN and the BIC code are for different countries
if (substr($iban, 0, 2) != substr($bic, 4, 2)) $this->terminateWithValidationErrors(array('' => $this->p->t('person', 'ibanBicCountryNotMatch')));
// Check if there is at least a record in the bank data table
$bankDataResult = $this->BankverbindungModel->execReadOnlyQuery(
'SELECT
bv.bankverbindung_id,
COALESCE(bv.updateamum, bv.insertamum) AS update_date,
bv.insertamum
FROM
public.tbl_bankverbindung bv
WHERE bv.person_id = ?
ORDER BY bv.insertamum DESC, update_date DESC
LIMIT 1',
array($loggedPersonId)
);
// If a db error occurred then terminate
if (isError($bankDataResult)) $this->terminateWithError('Database error while retrieving bank data', self::ERROR_TYPE_DB);
$writeDataResult = null; // it is considered as an error
// If at least a record exists then update
if (hasData($bankDataResult))
{
// Then update
$writeDataResult = $this->BankverbindungModel->update(
getData($bankDataResult)[0]->bankverbindung_id,
array(
'name' => $this->input->post(self::BANK_NAME_PARAM),
'bic' => $bic,
'iban' => $iban,
'updateamum' => 'NOW()',
'verrechnung' => true,
'updatevon' => $loggedUID,
'typ' => 'p'
)
);
}
else // otherwise insert
{
// Otherwise insert
$writeDataResult = $this->BankverbindungModel->insert(
array(
'person_id' => $loggedPersonId,
'name' => $this->input->post(self::BANK_NAME_PARAM),
'bic' => $this->input->post(self::BIC_PARAM),
'iban' => $this->input->post(self::IBAN_PARAM),
'insertamum' => 'NOW()',
'verrechnung' => true,
'insertvon' => $loggedUID,
'typ' => 'p'
)
);
}
// If a db error occurred then terminate
if (isError($writeDataResult)) $this->terminateWithError('Database error while writing bank data', self::ERROR_TYPE_DB);
// If everything was fine then return a success
$this->terminateWithSuccess('Database updated');
}
/**
* Generic SWIFT/BIC check
* Given the fake SWIFT/BIC: TBIC AT 12 ABC
* - 4 letters: Institution Code or bank code.
* - 2 letters: ISO 3166-1 alpha-2 country code
* - 2 letters or digits: location code
* (8 chars BIC)
* - 3 letters or digits: branch code, optional
* (11 chars BIC)
*/
private function _checkBic($bic)
{
// If the provided BIC is made up of 11 chars
if (strlen($bic) == 11)
{
// Check if the provided BIC is fine
return preg_match("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$^", $bic) == 1;
}
elseif (strlen($bic) == 8) // otherwise if it is made up of 8 chars
{
// Check if the provided BIC is fine
return preg_match("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}?$^", $bic) == 1;
}
return false;
}
}
+58 -3
View File
@@ -64,7 +64,7 @@ class AuthLib
{
// - The uid must be NOT an empty string
// - The current user should NOT be already logged as the given uid
if (!isEmptyString($uid) && $this->getAuthObj()->username != $uid)
if (!isEmptyString($uid) && $this->getAuthObj()->{self::AO_USERNAME} != $uid)
{
$this->_ci->load->library('PermissionLib'); // Loads permissions library
@@ -75,8 +75,28 @@ class AuthLib
$loginAS = $this->_createAuthObjByPerson(array('uid' => $uid));
if (isSuccess($loginAS))
{
$authObj = getData($loginAS); // get the authenticate object
// Store the new authentication object in authentication session
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, getData($loginAS));
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, $authObj);
$authObjOrigin = getSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ_ORIGIN);
// Load the LogLib
$this->_ci->load->library('LogLib');
// Setup the LogLib
$this->_ci->loglib->setConfigs(
array(
'dbLogType' => 'API', // required
'dbExecuteUser' => $authObjOrigin->{self::AO_USERNAME}, // current logged user
'requestId' => 'API'
)
);
// Log into the database
$this->_ci->loglib->logInfoDB(
'The user "'.$authObjOrigin->{self::AO_USERNAME}.'" has changed identity with the user "'.$authObj->{self::AO_USERNAME}.
'" and person id '.$authObj->{self::AO_PERSON_ID}
);
}
}
else
@@ -105,7 +125,7 @@ class AuthLib
{
// - The person id must be a number
// - The current user should NOT be already logged as the given person id
if (is_numeric($person_id) && $this->getAuthObj()->person_id != $person_id)
if (is_numeric($person_id) && $this->getAuthObj()->{self::AO_PERSON_ID} != $person_id)
{
$this->_ci->load->library('PermissionLib'); // Loads permissions library
@@ -124,6 +144,24 @@ class AuthLib
{
// Store the new authentication object in authentication session
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, $authObj);
$authObjOrigin = getSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ_ORIGIN);
// Load the LogLib
$this->_ci->load->library('LogLib');
// Setup the LogLib
$this->_ci->loglib->setConfigs(
array(
'dbLogType' => 'API', // required
'dbExecuteUser' => $authObjOrigin->{self::AO_USERNAME}, // current logged user
'requestId' => 'API'
)
);
// Log into the database
$this->_ci->loglib->logInfoDB(
'The user "'.$authObjOrigin->{self::AO_USERNAME}.'" has changed identity with the user "'.$authObj->{self::AO_USERNAME}.
'" and person id '.$authObj->{self::AO_PERSON_ID}
);
}
else // if does NOT have permissions
{
@@ -172,6 +210,22 @@ class AuthLib
// The LoginAs account is logged out
// The user is again connected with its real account
setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, $authObjOrigin);
// Load the LogLib
$this->_ci->load->library('LogLib');
// Setup the LogLib
$this->_ci->loglib->setConfigs(
array(
'dbLogType' => 'API', // required
'dbExecuteUser' => $authObjOrigin->{self::AO_USERNAME}, // current logged user
'requestId' => 'API'
)
);
// Log into the database
$this->_ci->loglib->logInfoDB(
'The user "'.$authObjOrigin->{self::AO_USERNAME}.'" has logout from the user "'.$authObj->{self::AO_USERNAME}.
'" and person id '.$authObj->{self::AO_PERSON_ID}
);
}
}
@@ -608,3 +662,4 @@ class AuthLib
return $finalUserBasicDataByUID;
}
}
@@ -1,23 +1,7 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
class Bankverbindung_model extends DB_Model
{
/**
* Constructor
*/
@@ -28,4 +12,3 @@ class Bankverbindung_model extends DB_Model
$this->pk = 'bankverbindung_id';
}
}
-40
View File
@@ -1,40 +0,0 @@
<?php
$includesArray = array(
'title' => 'Bank data',
'cis' => true,
'vue3' => true,
'axios027' => true,
'bootstrap5' => true,
'fontawesome6' => true,
'primevue3' => true,
'customJSModules' => array('public/js/apps/Cis/BankData.js'),
'customCSSs' => array(
'public/css/Fhc.css',
'public/css/components/primevue.css',
'public/css/components/FormUnderline.css'
)
);
if (defined('CIS4'))
{
$this->load->view('templates/CISVUE-Header', $includesArray);
}
else
{
$this->load->view('templates/FHC-Header', $includesArray);
}
?>
<div id="content"></div>
<?php
if (defined('CIS4'))
{
$this->load->view('templates/CISVUE-Footer', $includesArray);
}
else
{
$this->load->view('templates/FHC-Footer', $includesArray);
}
?>
-14
View File
@@ -1,14 +0,0 @@
export default {
getBankData() {
return this.$fhcApi.get('api/frontend/v1/Bank/getBankData');
},
postBankData(name, bic, iban) {
return this.$fhcApi.post(
'api/frontend/v1/Bank/postBankData', {
name: name,
bic: bic,
iban: iban
});
}
};
+7 -9
View File
@@ -33,7 +33,6 @@ import ort from "./ort.js";
import cms from "./cms.js";
import lehre from "./lehre.js";
import addons from "./addons.js";
import bankData from "./bankData.js";
import messages from "./messages.js";
import vorlagen from "./vorlagen.js";
import studiengang from "./studiengang.js";
@@ -64,14 +63,13 @@ export default {
cms,
lehre,
addons,
bankData,
messages,
vorlagen,
studiengang,
menu,
authinfo,
studium,
language,
vertraege
addons,
studiengang,
menu,
authinfo,
vertraege,
studium,
language
};
-31
View File
@@ -1,31 +0,0 @@
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import BankData from "../../components/Cis/BankData.js";
import fhcapifactory from "../../api/fhcapifactory.js";
import Phrasen from "../../plugin/Phrasen.js";
const bankDataApp = Vue.createApp({
name: 'BankDataApp',
components: {
BankData
},
template: `<bank-data></bank-data>`
});
bankDataApp.use(Phrasen).mount('#content');
-105
View File
@@ -1,105 +0,0 @@
/**
* Copyright (C) 2022 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import CoreForm from '../Form/Form.js';
import FormInput from '../Form/Input.js';
import FormValidation from "../Form/Validation.js";
export default {
components: {
CoreForm,
FormValidation,
FormInput
},
data() {
return {
bankName: '',
bic: '',
iban: ''
}
},
methods: {
save() {
this.$refs.form.clearValidation();
this.$refs.form.factory.bankData.postBankData(this.bankName, this.bic, this.iban)
.then(result => {
this.$emit('saved', result.data);
this.$fhcAlert.alertSuccess(this.$p.t('global', 'aenderungGespeichert'));
})
.catch(error => {
this.$fhcAlert.handleSystemError(error);
});
}
},
created() {
this.$fhcApi.factory.bankData.getBankData()
.then(result => {
if (result.data.length > 0)
{
this.bankName = result.data[0].name;
this.bic = result.data[0].bic;
this.iban = result.data[0].iban;
}
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div>
<core-form ref="form" @submit.prevent="save">
<fieldset class="overflow-hidden">
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('person', 'bank')"
type="text"
v-model="bankName"
name="bankName"
>
</form-input>
</div>
<div class="row mb-3"></div>
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('person', 'bic')"
type="text"
v-model="bic"
name="bic"
>
</form-input>
</div>
<div class="row mb-3"></div>
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('person', 'iban')"
type="text"
v-model="iban"
name="iban"
style="-webkit-text-security: disc; text-security: disc;"
>
</form-input>
</div>
<div class="row mb-3"></div>
</fieldset>
<div class="btn-group flex-grow-0" role="group">
<button type="button" class="btn btn-outline-secondary" @click="save">{{$p.t('global', 'speichern')}}</button>
</div>
</core-form>
</div>`
};
-80
View File
@@ -50689,86 +50689,6 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'person',
'phrase' => 'notForEmployees',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'This functionality is not enabled for employees DE',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'This functionality is not enabled for employees',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'person',
'phrase' => 'notValidaIBAN',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'The IBAN is not valid DE',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'The IBAN is not valid',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'person',
'phrase' => 'notValidaBIC',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'The BIC is not valid DE',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'The BIC is not valid',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'person',
'phrase' => 'ibanBicCountryNotMatch',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'IBAN and BIC codes are not for the same country DE',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'IBAN and BIC codes are not for the same country',
'description' => '',
'insertvon' => 'system'
)
)
)
// FHC4 Phrases Mobility End
// feature-55614 begin
array(