xtxpatch saves the email settings, still need to handle them

This commit is contained in:
asus
2024-03-31 19:25:39 +02:00
parent b4745ff672
commit 995e230e32
4 changed files with 40 additions and 9 deletions

View File

@@ -34,16 +34,16 @@
</div> </div>
<!-- <!--
-->
<div class="send_email"> <div class="send_email">
<input type="checkbox" id="send_email_prof_cipf" name="is_email_prof" <?php if ($email_registration['is_email_prof'] === true) {echo 'checked';} ?> /> <input type="checkbox" id="send_email_prof_cipf" name="is_email_prof" <?php if ($option_register_email_value['is_email_prof'] === true) {echo 'checked';} ?> />
<label for="send_email_prof_cipf">envoyer un email à l'inscription des profs ?</label> <label for="send_email_prof_cipf">envoyer un email à l'inscription des profs ?</label>
</div> </div>
<div class="send_email"> <div class="send_email">
<input type="checkbox" id="send_email_partner_cipf" name="is_email_partner" <?php if ($email_registration['is_email_partner'] === true) {echo 'checked';} ?> /> <input type="checkbox" id="send_email_partner_cipf" name="is_email_partner" <?php if ($option_register_email_value['is_email_partner'] === true) {echo 'checked';} ?> />
<label for="send_email_partner_cipf">envoyer un email à l'inscription des partenaires ?</label> <label for="send_email_partner_cipf">envoyer un email à l'inscription des partenaires ?</label>
</div> </div>
-->
<input type="submit" value="send"/> <input type="submit" value="send"/>
</form> </form>

View File

@@ -329,7 +329,6 @@ class Plgntls_xtx {
$function = $trace[1]['function']; $function = $trace[1]['function'];
$file = $trace[0]['file']; $file = $trace[0]['file'];
$line = $trace[0]['line']; $line = $trace[0]['line'];
error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')');
} }
@@ -1086,7 +1085,6 @@ class Plgntls_xtx {
* *
*/ */
$option_data = get_option($option_name); $option_data = get_option($option_name);
error_log("get option safe: " . json_encode($option_data));
$false_serialized = serialize(false); $false_serialized = serialize(false);
$option_unserialized = @unserialize($option_data); $option_unserialized = @unserialize($option_data);
if ($option_unserialized === false && $option_data != $false_serialized) { if ($option_unserialized === false && $option_data != $false_serialized) {
@@ -1096,12 +1094,10 @@ error_log("get option safe: " . json_encode($option_data));
$ret_option = $option_unserialized; $ret_option = $option_unserialized;
} }
error_log("get option safe: " . json_encode($ret_option));
return $ret_option; return $ret_option;
} }
public static function update_option_safe($option, $option_data) { public static function update_option_safe($option, $option_data) {
error_log("- inside update option safe");
/* /*
* first init option, in case it was not already * first init option, in case it was not already
* it will returns the option name or false * it will returns the option name or false
@@ -1112,12 +1108,10 @@ error_log("- inside update option safe");
if (false === $option_name) { if (false === $option_name) {
return; return;
} }
error_log("update option safe: " . json_encode($option_data));
if (!is_string($option_data)) { if (!is_string($option_data)) {
$option_data = serialize($option_data); $option_data = serialize($option_data);
} }
error_log("update option safe: " . json_encode($option_data));
update_option($option_name, $option_data); update_option($option_name, $option_data);
} }

View File

@@ -18,6 +18,7 @@ if (!defined('ABSPATH')) {
class Xtxpatch { class Xtxpatch {
const OPTION_REGISTER_EMAIL = [ const OPTION_REGISTER_EMAIL = [
'_name'=>'define_email_at_register_xtxpatch', '_name'=>'define_email_at_register_xtxpatch',
'_callback'=>__NAMESPACE__.'\define_register_email',
'_default'=>[ '_default'=>[
'email'=> 'email'=>
'Bonjour, 'Bonjour,

View File

@@ -46,6 +46,42 @@ function menu_content() {
function define_register_email($request, $option_name, $option_value, $option_default) {
/*
* email
*
*/
$email = '';
if (isset($request['email'])) {
$email = $request['email'];
}
/*
* is email ?
*
*/
$is_email_prof = false;
if (isset($request['is_email_prof']) && $request['is_email_prof'] === 'on') {
$is_email_prof = true;
}
$is_email_partner = false;
if (isset($request['is_email_partner']) && $request['is_email_partner'] === 'on') {
$is_email_partner = true;
}
/*
* update the option with new values
*
*/
$option_data = array(
'email' => $email,
'is_email_prof' => $is_email_prof,
'is_email_partner' => $is_email_partner,
);
\Plgntls_xtx::update_option_safe($option_name, $option_data);
}