default_template = ' '; } public function get_form() { if(!isset($this->parameters['modal_only_connected']) || !$this->parameters['modal_only_connected']){ $this->parameters['modal_only_connected'] = (isset($this->managed_datas['modal_only_connected']) ? $this->managed_datas['modal_only_connected'] : false); } $form = parent::get_form()."
parameters['modal_only_connected'])? 'checked' : '' ).">
"; return $form; } public function save_form() { $this->parameters['modal_only_connected'] = $this->get_value_from_form('charte_modal_only_connected'); return parent::save_form(); } public function render($datas){ if (!empty($this->parameters['modal_only_connected'])) { if (empty($_SESSION["id_empr_session"])) { return ''; } } $datas->script_close_modal = ' var modal_'.$this->get_module_dom_id().' = UIkit.modal("#'.$this->get_module_dom_id().'", { keyboard: false, bgclose: false, modal: false }); var id_connected = '.(!$_SESSION["id_empr_session"]? 'null' : $_SESSION["id_empr_session"]).'; if (!localStorage.getItem("empr_accepted_conditions") == 1 || (localStorage.getItem("empr_accepted_conditions") == 1 && id_connected != null)) { modal_'.$this->get_module_dom_id().'.show(); if (document.querySelector("#'.$this->get_module_dom_id().' .uk-overflow-container").clientHeight != document.querySelector("#'.$this->get_module_dom_id().' .uk-overflow-container").scrollHeight) { document.querySelector("#'.$this->get_module_dom_id().' .uk-overflow-container").addEventListener("scroll", handleScroll_'.$this->get_module_dom_id().'); } else { document.querySelector("#'.$this->get_module_dom_id().' .uk-modal-close").removeAttribute("disabled"); } document.querySelector("#'.$this->get_module_dom_id().' .uk-modal-close").addEventListener("click", function() { fetch("'.$this->get_ajax_link([]).'",{ credentials: "same-origin" }) .then(function(res) { if (res.ok) { modal_'.$this->get_module_dom_id().'.hide(); localStorage.setItem("empr_accepted_conditions", 1); } }) }) function handleScroll_'.$this->get_module_dom_id().'() { checkScrollPosition("'.$this->get_module_dom_id().'"); } } else if(localStorage.getItem("empr_accepted_conditions") == 1) { var modal = document.getElementById("modal-usage-policy"); if (modal) { modal.remove(); } } '; if (!isset($_SESSION['empr_accepted_conditions'])) { $_SESSION['empr_accepted_conditions'] = 0; } if (!$_SESSION['empr_accepted_conditions']) { $html = parent::render($datas); if (!empty($datas->script_close_modal)) $html.= ''; return $html; } return ''; } public function execute_ajax() { $_SESSION['empr_accepted_conditions'] = 1; $response = array( 'content' => "", 'content-type' => "text/html" ); return $response; } public function get_format_data_structure(){ $datasource = new cms_module_common_datasource_charte(); return $datasource->get_format_data_structure(); } }