small improvements in handling prof states :

- card date validation now uses direct card duration, not a parameter
- checker for both types of transfert valid and invalid
- mv checks for transfert and date expiration in specific functions
This commit is contained in:
asus
2024-03-21 16:10:07 +01:00
parent 782ae1b1d8
commit 66fbbfd586
7 changed files with 115 additions and 51 deletions

View File

@@ -0,0 +1,66 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* if field transfert-validation is not checked, do nothing
* else
* first reset the field
* then
* if no transfert was waiting, do nothing
* when transfert is validate :
* - change card to valid
* - update date
*
*/
function handle_transfert_validation_CIPF($user_id) {
PLGNTLS_class::debug_infos();
if (false === is_transfert_success_CIPF($user_id)) {
return;
}
reset_acf_transfert_CIPF($user_id);
if (false === is_account_waiting_transfert_CIPF($user_id)) {
return;
}
set_account_valid_CIPF($user_id);
update_card_expiration_CIPF($user_id);
}
/*
* if card expire, makes some changes
*
*/
function handle_card_expire_CIPF($user_id) {
PLGNTLS_class::debug_infos();
if (false === card_date_exists_CIPF($user_id)) {
return;
}
if (false === is_card_date_expired_CIPF($user_id)) {
return;
}
if (false === is_account_expired_CIPF($user_id)) {
set_account_expired_CIPF($user_id);
}
if (is_account_waiting_valid_CIPF($user_id)) {
set_account_waiting_invalid_CIPF($user_id);
}
}
?>