diff --git a/:b debu b/:b debu new file mode 100644 index 0000000..2616d18 --- /dev/null +++ b/:b debu @@ -0,0 +1,286 @@ + $success, + 'failure' => $failure, + 'problem' => $problem, + ); + Plgntls::update_option_safe($option_name, $data); +} + + + + + + +function update_paypal_credentials_CIPF($request, $option_name, $option_data, $option_default) { + Plgntls::debug_infos(); + + if (!isset( + $request['sandbox_or_live'], + $request['live_client_id'], + $request['live_client_secret'], + $request['sandbox_client_id'], + $request['sandbox_client_secret'], + )) { + return; + } + + /* + * force price 1 cent ? + * + */ + $force_1_cent = false; + if (isset($request['force_1_cent'])) { + $force_1_cent = true; + } + + /* + * is sandbox or live ? + * + */ + $is_sandbox = false; + if ($request['sandbox_or_live'] === 'sandbox') { + $is_sandbox = true; + } + else if ($request['sandbox_or_live'] === 'live') { + $is_sandbox = false; + } + + + /* + * ids + * + */ + $live_client_id = $request['live_client_id']; + $live_client_secret = $request['live_client_secret']; + $sandbox_client_id = $request['sandbox_client_id']; + $sandbox_client_secret = $request['sandbox_client_secret']; + + + /* + * update the option with new credentials + * + set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret); + */ + $data = array( + 'force_1_cent' => $force_1_cent, + 'is_sandbox' => $is_sandbox, + 'live_client_id' => $live_client_id, + 'live_client_secret' => $live_client_secret, + 'sandbox_client_id' => $sandbox_client_id, + 'sandbox_client_secret' => $sandbox_client_secret, + ); + Plgntls::update_option_safe($option_name, $data); +} + + + + + + +/* +* update emails +* +*/ +function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) { + Plgntls::debug_infos(); + + /* + * loop through saved data option + * update them + * add them to the option that will be saved + * + */ + foreach ($option_data as $email_type => $email_options) { +error_log("1:"); + $ret_update = update_email_by_type_CIPF($email_type, $email_options, $option_default[$email_type], $request); + if ($ret_update !== false) { + $option_data[$email_type] = $ret_update; + } + } + + /* + * to reorder and add new data with the default data + * also take the name of the default + * + */ + $new_option = array(); + foreach ($option_default as $email => $options) { + if (isset($option_data[$email])) { + $new_option[$email] = $option_data[$email]; + } + else { + // it means it was not in the saved data, but was added in the default +error_log("2:"); + $ret_update = update_email_by_type_CIPF($email, $options, $option_default[$email], $request); + if ($ret_update !== false) { + $new_option[$email] = $ret_update; + } + else { + $new_option[$email] = $options; + } + } + $new_option[$email]['name'] = $options['name']; + } + + Plgntls::update_option_safe($option_name, $new_option); +} + + + +/* +* utility function to update the emails +* +*/ +function update_email_by_type_CIPF($email_type, $email_options, $email_default_options, $request) { + Plgntls::debug_infos(); + $is_new = false; + +if($email_type === 'cron_job')error_log("---"); +if($email_type === 'cron_job')error_log("email_type: " . json_encode($email_type)); + /* + * set notification/confirmation_send to false by default, + * because the request only contains the value 'on' if checked, nothing for false + * + */ + $email_options['notification_send'] = false; + $email_options['confirmation_send'] = false; + + /* + * loop through all options to update them + * + */ + //$tmp_type = 'cron_job'; + $tmp_type = 'payment_success'; + $tmp_option = 'notification_send'; + if($email_type === $tmp_type)error_log("request : " . json_encode($request)); + foreach ($email_default_options as $default_option => $default_value) { + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("default_option: " . json_encode($default_option) . " -> default_value : " . json_encode($default_value)); + $request_name = $email_type.'_'.$default_option; + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("isset? : " . $request_name); + if (!isset($request[$request_name])) { + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("!isset"); + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("- email_options: " . json_encode($email_options)); + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("- default_option: " . json_encode($default_option)); + if (isset($email_options[$default_option])) { + continue; + } + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("--!isset"); + $is_new = true; + $email_options[$default_option] = $default_value; + continue; + } + $new_value = $request[$request_name]; + $value = $email_options[$default_option]; + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("new_value: " . json_encode($new_value)); + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("value : " . json_encode($value)); + if ($new_value === $value) { + continue; + } + $is_new = true; + if ($default_option === 'notification_send' || $default_option === 'confirmation_send') { + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("is notification_send"); + $email_options[$default_option] = true; + } + else { + if($email_type === $tmp_type && $default_option === $tmp_option)error_log("is not notification_send"); + $email_options[$default_option] = $new_value; + } + } + + if ($is_new === false) { + return false; + } + else { + return $email_options; + } +} + + + + + +?> diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index 46ada2f..28052ba 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -4,7 +4,7 @@ Plugin Name: hggg_cipf Plugin URI: Description: Author: hugogogo -Version: 0.5.8 +Version: 0.5.9 Author URI: */ @@ -309,6 +309,14 @@ contactez la fipf directement", 'confirmation_subject'=>"[CIPF - offre expirée]", 'confirmation_message'=>'votre offre a expiré, pour la renouveler rendez-vous sur $$__base_url__$$', ], + 'cron_job'=>[ + 'name'=>"cron-job - une fois par jour", + 'notification_send'=>true, + 'notification_from'=>'$$__admin_email__$$', + 'notification_to'=>'$$__admin_email__$$', + 'notification_subject'=>"[CIPF - cron job]", + 'notification_message'=>'la tache journaliere cron a bien fonctionné', + ], ], ]; diff --git a/plugins/cipf_plugin/css/fipf_user_profile.css b/plugins/cipf_plugin/css/fipf_user_profile.css index 1a75e4b..e713033 100644 --- a/plugins/cipf_plugin/css/fipf_user_profile.css +++ b/plugins/cipf_plugin/css/fipf_user_profile.css @@ -10,6 +10,9 @@ * hide all acf fields with the class 'hide-for-fipf' * */ +form#your-profile h2:has(+ .form-table .hide-group-for-fipf) { + display: none; +} form#your-profile .hide-for-fipf { display: none; } diff --git a/plugins/cipf_plugin/html/menu/cipf_menu.html b/plugins/cipf_plugin/html/menu/cipf_menu.html index 4f17f00..e948d01 100644 --- a/plugins/cipf_plugin/html/menu/cipf_menu.html +++ b/plugins/cipf_plugin/html/menu/cipf_menu.html @@ -159,54 +159,72 @@