You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
310 lines
18 KiB
310 lines
18 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\auth\User as UserAuth;
|
|
use app\core\auth\Unregister;
|
|
use app\core\auth\Page as Page;
|
|
use app\core\auth\Sso;
|
|
|
|
class MY_Controller extends CI_Controller
|
|
{
|
|
protected $data = array();
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function my_parent_controller($caller = '')
|
|
{
|
|
parent::__construct();
|
|
$this->data = add_csrf_token($this->data);
|
|
$this->load_default_language();
|
|
if ($caller !== "auth") $this->check_login_status();
|
|
$this->get_login_user_data();
|
|
|
|
/* Initialize BO users */
|
|
Page::initBOUserRoles();
|
|
|
|
/* Initialize current user privileges */
|
|
if ( UserAuth::isBOUser() )
|
|
Page::initUserPrivileges();
|
|
}
|
|
|
|
protected function frontoffice_parent_controller()
|
|
{
|
|
parent::__construct();
|
|
$this->data = add_csrf_token($this->data);
|
|
$this->load_default_language();
|
|
|
|
$this->check_login_status();
|
|
|
|
$this->get_login_user_data();
|
|
}
|
|
|
|
/**
|
|
* Get session data
|
|
* @return void
|
|
*/
|
|
protected function get_login_user_data() {
|
|
$this->data['logged_in'] = UserAuth::auth();
|
|
}
|
|
|
|
protected function clear_cache(){
|
|
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
|
|
$this->output->set_header("Pragma: no-cache");
|
|
}
|
|
|
|
public function load_default_language(){
|
|
$this->lang->load('system', 'fr');
|
|
}
|
|
|
|
public function load_language_backoffice(){
|
|
$this->lang->load('system', 'fr');
|
|
$this->lang->load('backoffice/system_message', 'fr');
|
|
}
|
|
|
|
public function load_language_frontoffice(){
|
|
$this->lang->load('system', 'fr');
|
|
$this->lang->load('frontoffice/homepage', 'fr');
|
|
$this->lang->load('frontoffice/system_config', 'fr');
|
|
}
|
|
|
|
protected function check_instance_of_reservation_modal(){
|
|
/*check which page is currently being accessed*/
|
|
|
|
if($this->data["logged_in"]) {
|
|
if(isset($this->data["logged_in"]['rs_action']) && !empty($this->data["logged_in"]['rs_action']))
|
|
{
|
|
$current_url = str_replace("?/","",current_url());
|
|
$base_url = base_url();
|
|
$found = false;
|
|
$search_items = ['home','event_details','my_account','faq','mentions-legales','contact'];
|
|
|
|
foreach($search_items as $search){
|
|
$found = strpos($current_url, $search);
|
|
if($found){
|
|
break;
|
|
}
|
|
}
|
|
/* check if there is active lock for the current session then release the lock
|
|
when one of these pages are currently being accessed */
|
|
if(($current_url === $base_url || $found) && $this->data["logged_in"]){
|
|
|
|
if(isset($this->data["logged_in"]['rs_action']) && !empty($this->data["logged_in"]['rs_action'])) {
|
|
$this->load->model('event_concurrent_process_model');
|
|
$check = $this->event_concurrent_process_model->unlock_action($this->data["logged_in"]['user_id'], $this->data["logged_in"]['login_id'], $this->data["logged_in"]['rs_action']['process_reference'], $this->data["logged_in"]['rs_action']['process_type']);
|
|
//remove from session
|
|
unset($this->data["logged_in"]['rs_action']);
|
|
if($this->session->userdata('first_logged_in')) {
|
|
unset($this->data["logged_in"]['rs_action']);
|
|
$this->session->set_userdata('first_logged_in', $this->data["logged_in"]);
|
|
} else if($this->session->userdata('logged_in')) {
|
|
$this->session->set_userdata('logged_in', $this->data["logged_in"]);
|
|
}
|
|
}
|
|
}
|
|
} // Second if
|
|
} // First if
|
|
}
|
|
|
|
public function load_extra_files($with=array()){
|
|
if(!isset($this->data["load_styles"]) && empty($this->data['load_styles'])) {
|
|
$this->data['load_styles'] = array();
|
|
}
|
|
|
|
if(!isset($this->data["load_scripts"]) && empty($this->data['load_scripts'])) {
|
|
$this->data['load_scripts'] = array();
|
|
}
|
|
|
|
if(isset($with["ajax_helper"]) && $with["ajax_helper"]){
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(base_url('resources/app/ajax.js')) . '"></script>');
|
|
}
|
|
|
|
if(isset($with["datatable"]) && $with["datatable"]){
|
|
array_push($this->data['load_styles'], '<!-- Bootstrap Datatable CSS -->');
|
|
array_push($this->data['load_styles'], '<link href="' . auto_version(plugins_bundle() . 'datatables/dataTables.bootstrap.min.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_styles'], '<link href="' . auto_version(plugins_bundle() . 'datatables/responsive.bootstrap.min.css').'" rel="stylesheet"/>');
|
|
|
|
array_push($this->data['load_scripts'], '<!-- Bootstrap Datatable JS-->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'datatables/jquery.dataTables.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'datatables/dataTables.bootstrap.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'datatables/dataTables.responsive.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'datatables/responsive.bootstrap.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'datatables/datatables.lang.fr.js').'" ></script>');
|
|
}
|
|
|
|
if(isset($with["moment"]) && $with["moment"]){
|
|
array_push($this->data['load_scripts'], '<!-- Datetimepicker JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'momentjs/moment.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'bootstrap/datepicker/moment-with-locales.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'momentjs/moment-range.min.js').'" ></script>');
|
|
}
|
|
|
|
if(isset($with["datetime"]) && $with["datetime"]){
|
|
array_push($this->data['load_styles'], '<!-- Datetimepicker CSS -->');
|
|
// array_push($this->data['load_styles'], '<link href="' . plugins_bundle() . 'bootstrap/datepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>');
|
|
array_push($this->data['load_styles'], '<link href="' . auto_version(plugins_bundle() . 'bootstrap/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css').'" rel="stylesheet"/>');
|
|
|
|
array_push($this->data['load_scripts'], '<!-- Datetimepicker JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'momentjs/moment.min.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'bootstrap/datepicker/moment-with-locales.js').'" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'momentjs/moment-range.min.js').'" ></script>');
|
|
|
|
// array_push($this->data['load_scripts'], '<script src="' . plugins_bundle() . 'bootstrap/datepicker/bootstrap-datetimepicker.min.js" ></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'bootstrap/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["money_formatter"]) && $with["money_formatter"]){
|
|
array_push($this->data['load_scripts'], '<!-- Money Formatter JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'bootstrap/currency/accounting.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["tinymce"]) && $with["tinymce"]){
|
|
array_push($this->data['load_scripts'], '<!-- TinyMCE JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'tinymce/tinymce.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["tinymcev5"]) && $with["tinymcev5"]){
|
|
array_push($this->data['load_scripts'], '<!-- TinyMCE_V5 JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'tinymce_5.6.1/tinymce.min.js').' "></script>');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'tinymce_5.6.1/jquery.tinymce.min.js').' "></script>');
|
|
}
|
|
if(isset($with["form_validator"]) && $with["form_validator"]){
|
|
array_push($this->data['load_styles'], '<!-- Form Validator CSS -->');
|
|
array_push($this->data['load_styles'], '<link href="' . auto_version(plugins_bundle() . 'bootstrap/validator/bootstrapValidator.min.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<!-- Form Validator JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="' . auto_version(plugins_bundle() . 'bootstrap/validator/bootstrapValidator.fr.min.js').'" ></script>');
|
|
}
|
|
|
|
if(isset($with["bootbox"]) && $with["bootbox"]){
|
|
array_push($this->data['load_scripts'], '<!-- Bootbox JS -->');
|
|
array_push($this->data['load_scripts'],'<script src="'.auto_version(plugins_bundle().'bootstrap/bootbox/bootbox.min.js').'"></script>');
|
|
}
|
|
if(isset($with["dotdotdot"]) && $with["dotdotdot"]){
|
|
array_push($this->data['load_scripts'], '<!-- Dotdotdot JS -->');
|
|
array_push($this->data['load_scripts'],'<script src="'.auto_version(plugins_bundle().'jquery/jquery.ellipsis.js').'" ></script>');
|
|
}
|
|
if(isset($with["notify"]) && $with["notify"]){
|
|
array_push($this->data['load_scripts'], '<!-- Notify JS -->');
|
|
array_push($this->data['load_scripts'],'<script src="'.auto_version(plugins_bundle().'bootstrap/notify_3.3.1/bootstrap-notify.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["typeahead"]) && $with["typeahead"]){
|
|
array_push($this->data['load_scripts'], '<!-- Boostrap-3-Typeahead JS -->');
|
|
array_push($this->data['load_scripts'],'<script src="'.auto_version(plugins_bundle().'bootstrap/typeahead/bootstrap3-typeahead.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["inputmask"]) && $with["inputmask"]){
|
|
array_push($this->data['load_scripts'], '<!-- Robin Herbots Inputmask JS -->');
|
|
array_push($this->data['load_scripts'],'<script src="'.auto_version(plugins_bundle().'inputmask/min/jquery.inputmask.bundle.min.js').'" ></script>');
|
|
}
|
|
if(isset($with["appjs"]) && $with["appjs"]){
|
|
array_push($this->data['load_scripts'], '<!-- App JS -->');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(app_bundle().'app.js').'" ></script>');
|
|
}
|
|
if(GDPR['on'] && isset($with["ga"]) && $with["ga"]){
|
|
array_push($this->data['load_scripts'], '<!-- Google Analytics -->');
|
|
array_push($this->data['load_scripts'], '<script '.(GDPR['on'] ? GDPR['external_src'] : "src=").'"'.auto_version(scripts_bundle().'google-analytics.js').'" ></script>');
|
|
}
|
|
if(isset($with["ga_embed"]) && $with["ga_embed"]){
|
|
array_push($this->data['load_scripts'], '<!-- Google Analytics -->');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(scripts_bundle().'google-analytics-embed.js').'" ></script>');
|
|
}
|
|
if(isset($with["date_range"]) && $with["date_range"]){
|
|
array_push($this->data['load_scripts'], '<!-- Google Analytics -->');
|
|
array_push($this->data['load_styles'], '<link href="'.auto_version(plugins_bundle().'bootstrap/datepicker/daterangepicker.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'bootstrap/datepicker/daterangepicker.js').'" ></script>');
|
|
}
|
|
|
|
if(isset($with["bootstrap_select"]) && $with["bootstrap_select"]){
|
|
array_push($this->data['load_scripts'], '<!-- Bootstrap Select -->');
|
|
array_push($this->data['load_styles'], '<link href="'.auto_version(plugins_bundle().'bootstrap/bootstrap-select/bootstrap-select.min.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'bootstrap/bootstrap-select/bootstrap-select.min.js').'"></script>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'bootstrap/bootstrap-select/ajax-bootstrap-select.min.js').'"></script>');
|
|
}
|
|
|
|
if(isset($with["easycomplete"]) && $with["easycomplete"]){
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'easycomplete/jquery.easy-autocomplete.min.js').'"></script>');
|
|
array_push($this->data['load_styles'], '<link rel="stylesheet" href="'.auto_version(plugins_bundle().'easycomplete/easy-autocomplete.min.css').'">');
|
|
array_push($this->data['load_styles'], '<link rel="stylesheet" href="'.auto_version(plugins_bundle().'easycomplete/easy-autocomplete.themes.min.css').'">');
|
|
array_push($this->data['load_styles'], '<link rel="stylesheet" href="'.auto_version(plugins_bundle().'easycomplete/maps/easy-autocomplete.css.map').'">');
|
|
array_push($this->data['load_styles'], '<link rel="stylesheet" href="'.auto_version(plugins_bundle().'easycomplete/maps/easy-autocomplete.themes.css.map').'">');
|
|
}
|
|
|
|
if(isset($with["autocomplete"]) && $with["autocomplete"]){
|
|
array_push($this->data['load_styles'], '<link href="'.auto_version(plugins_bundle().'autocomplete/jquery.autocomplete.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'autocomplete/jquery.autocomplete.js').'"></script>');
|
|
}
|
|
|
|
if(isset($with["select2"]) && $with["select2"]){
|
|
array_push($this->data['load_styles'], '<link href="'.auto_version(plugins_bundle().'select2/select2.min.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.8/js/select2.min.js" integrity="sha256-kQ6DQtOnXtjGYnAEMZQjpsioC75ND0K9I8MyjtdLCyk=" crossorigin="anonymous"></script>');
|
|
// array_push($this->data['load_scripts'], '<script src="'.plugins_bundle().'select2/select2.min.js"></script>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'select2/maximize-select2-height.min.js').'"></script>');
|
|
}
|
|
|
|
if(isset($with["selectize"]) && $with["selectize"]){
|
|
array_push($this->data['load_styles'], '<link href="'.auto_version(plugins_bundle().'selectize/selectize.css').'" rel="stylesheet"/>');
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'selectize/selectize.min.js').'"></script>');
|
|
|
|
}
|
|
|
|
if(isset($with["mask"]) && $with["mask"]){
|
|
array_push($this->data['load_scripts'], '<script src="'.auto_version(plugins_bundle().'mask/jquery.mask.min.js').'"></script>');
|
|
}
|
|
}
|
|
|
|
public function setCspHeader($report_only = true)
|
|
{
|
|
$http_protocol = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
|
|
$mode = $report_only? '-Report-Only': '';
|
|
$this->data['csp_nonce'] = base64_encode(date('now').time());
|
|
header('Access-Control-Allow-Origin: *');
|
|
header("Content-Security-Policy{$mode}: "
|
|
."default-src 'none';"
|
|
."connect-src *.tinymce.com *.tiny.cloud {$http_protocol}:;"
|
|
."font-src 'self' *.tinymce.com *.tiny.cloud {$http_protocol}: data:;"
|
|
."frame-src {$http_protocol}:;"
|
|
."img-src 'self' *.tinymce.com *.tiny.cloud {$http_protocol}: data: blob: mediastream: ;"
|
|
."media-src 'self' data: blob: mediastream: {$http_protocol}:; "
|
|
."object-src 'none'; "
|
|
."script-src 'nonce-{$this->data['csp_nonce']}' 'self' *.tinymce.com *.tiny.cloud 'unsafe-inline' {$http_protocol}:; "
|
|
."style-src 'self' 'unsafe-inline' *.tinymce.com *.tiny.cloud {$http_protocol}:;"
|
|
."frame-ancestors 'none';"
|
|
."base-uri 'self';"
|
|
."report-uri '';"
|
|
);
|
|
}
|
|
|
|
/*
|
|
* Check if user is logged in from main site
|
|
* if the user is logged out from the main site but logged in to evenements
|
|
* log out the user from evenements
|
|
*/
|
|
|
|
/*
|
|
* If the cookies indicating a user is logged in from lemonde fr
|
|
* and user is logged in on evenements is detected
|
|
* return true, do not check for logged in user from the main site anymore
|
|
*/
|
|
protected function check_login_status($userIsLoggedIn = false){
|
|
// Check session
|
|
Sso::signOutUserWhenLoggedOutFromParentSite();
|
|
|
|
// Making sure that this function runs for FO users ONLY!
|
|
if (isset( $_COOKIE['lmd_a_s'], $_COOKIE['lmd_a_m'])) {
|
|
|
|
Sso::resetSSOInSession();
|
|
|
|
return $this->getActiveUserFromWebService('self');
|
|
}
|
|
}
|
|
|
|
protected function getActiveUserFromWebService($caller='self') {
|
|
$sso = Sso::connect();
|
|
if (isset($sso['telephone']) && !empty($sso['telephone'])) {
|
|
if ($caller === 'self'){
|
|
Sso::authenticateBySSO($sso);
|
|
}
|
|
}
|
|
return $sso;
|
|
}
|
|
}
|
|
|
|
/* End of file MY_CONTROLLER.php */
|
|
/* Location: ./application/core/MY_Controller.php */
|
|
|