- />
-
+ />
+
-
-
+
+
-
-
+
+
diff --git a/plugins/cipf_plugin/php/admin_menu.php b/plugins/cipf_plugin/php/admin_menu.php
index b1b01e0..c111f90 100644
--- a/plugins/cipf_plugin/php/admin_menu.php
+++ b/plugins/cipf_plugin/php/admin_menu.php
@@ -35,12 +35,9 @@ function add_plugin_content_CIPF() {
* options
*
*/
- $option_paypal_name = $option_paypal_object['_name'];
- $option_paypal = Plgntls::get_option_safe($option_paypal_object);
- $option_payment_name = $option_payment_object['_name'];
+ $option_paypal = Plgntls::get_option_safe($option_paypal_object);
$option_payment = Plgntls::get_option_safe($option_payment_object);
- $option_emails_name = $option_emails_object['_name'];
- $option_emails = Plgntls::get_option_safe($option_emails_object);
+ $option_emails = Plgntls::get_option_safe($option_emails_object);
ob_start();
include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
@@ -160,88 +157,73 @@ function update_paypal_credentials_CIPF($request, $option_name, $option_data, $o
+
+
+/*
+* update emails
+*
+*/
function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) {
Plgntls::debug_infos();
+//error_log("---");
+//error_log("request: " . json_encode($request));
+//error_log("option_data bedore: " . json_encode($option_data));
+ foreach ($option_data as $email_type => $email_options) {
+ //error_log("email_type: " . $email_type);
+ $option_data[$email_type] = update_email_by_type_CIPF($email_type, $email_options, $request);
+ }
+//error_log("option_data after : " . json_encode($option_data));
+
+error_log("option 2: " . json_encode($option_data['payment_success']['confirmation_message']));
+ Plgntls::update_option_safe($option_name, $option_data);
+}
+
+
+
+/*
+* utility function to update the emails
+*
+*/
+function update_email_by_type_CIPF($email_type, $email_options, $request) {
+ Plgntls::debug_infos();
+ //error_log("email type: " . $email_type);
/*
- *
+ * set notification/confirmation_send to false by default,
+ * because the request only contains the value 'on' if checked, nothing for false
*
*/
-error_log("request: " . json_encode($request));
-error_log("option_data: " . json_encode($option_data));
- foreach ($option_data as $email => $email_options) {
- error_log("email: " . $email);
- error_log("email_options: " . json_encode($email_options));
- if (isset($request[$email])) {
- error_log("email is set");
+ $email_options['notification_send'] = false;
+ $email_options['confirmation_send'] = false;
+
+ /*
+ * loop through all options to update them
+ *
+ */
+ foreach ($email_options as $option => $value) {
+ if (!isset($request[$email_type.'_'.$option])) {
+ continue;
+ }
+ $new_value = $request[$email_type.'_'.$option];
+ if ($new_value === $value) {
+ continue;
+ }
+ if ($option === 'notification_send' || $option === 'confirmation_send') {
+ $email_options[$option] = true;
+ }
+ else {
+ // error_log("option: " . $option);
+ // error_log("- previous value: " . $value);
+ // error_log("- newvalue : " . $new_value);
+ $email_options[$option] = $new_value;
}
}
-
-// $is_sandbox = false;
-// if (!isset($request['sandbox_or_live'])) {
-// return;
-// }
-// if ($request['sandbox_or_live'] === 'sandbox') {
-// $is_sandbox = true;
-// }
-// else if ($request['sandbox_or_live'] === 'live') {
-// $is_sandbox = false;
-// }
-// else {
-// return;
-// }
-//
-//
-// /*
-// * client id
-// *
-// */
-// $client_id = '';
-// if (!isset($request['client_id'])) {
-// return;
-// }
-// else {
-// $client_id = $request['client_id'];
-// }
-//
-//
-// /*
-// * client secret
-// *
-// */
-// $client_secret = '';
-// if (!isset($request['client_secret'])) {
-// return;
-// }
-// else {
-// $client_secret = $request['client_secret'];
-// }
-//
-//
-// /*
-// * update the option with new credentials
-// *
-// set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret);
-// */
-// $data = array(
-// 'is_sandbox' => $is_sandbox,
-// 'client_id' => $client_id,
-// 'client_secret' => $client_secret,
-// );
-// Plgntls::update_option_safe($option_name, $data);
+//error_log("email_options: " . json_encode($email_options));
+error_log("option 1: " . json_encode($email_options['confirmation_message']));
+ return $email_options;
}
-/*
- 'payment_success'=>[
- 'notification_send'=>true,
- 'notification_to'=>'$$__admin_email__$$',
- 'notification_subject'=>"paiement réussi",
- 'notification_message'=>"par ici la monnaie",
- 'confirmation_send'=>true,
- 'confirmation_subject'=>"paiement réussi",
- 'confirmation_message'=>"donne l'argent",
-*/
diff --git a/plugins/cipf_plugin/plgntls_class.php b/plugins/cipf_plugin/plgntls_class.php
index 4b5eaf3..ed08547 100644
--- a/plugins/cipf_plugin/plgntls_class.php
+++ b/plugins/cipf_plugin/plgntls_class.php
@@ -1120,6 +1120,7 @@ error_log("toggle menu: " . json_encode($option_toggle));
* it also works if the option is the name directly
*
*/
+error_log("option 3: " . json_encode($option_data['payment_success']['confirmation_message']));
$option_name = self::_init_option($option);
if (false === $option_name) {
return;