Suppression du cookie configLayout

This commit is contained in:
Fred Tempez 2024-09-18 19:34:04 +02:00
parent ecd0f5827a
commit e3bc6ce1d3
4 changed files with 42 additions and 49 deletions

View File

@ -30,7 +30,8 @@ class config extends common
'logReset' => self::GROUP_ADMIN, 'logReset' => self::GROUP_ADMIN,
'logDownload' => self::GROUP_ADMIN, 'logDownload' => self::GROUP_ADMIN,
'blacklistReset' => self::GROUP_ADMIN, 'blacklistReset' => self::GROUP_ADMIN,
'blacklistDownload' => self::GROUP_ADMIN 'blacklistDownload' => self::GROUP_ADMIN,
'register' => self::GROUP_ADMIN,
]; ];
public static $timezones = [ public static $timezones = [
@ -907,7 +908,8 @@ class config extends common
* Fonction pour vérifier la présence du module de réécriture * Fonction pour vérifier la présence du module de réécriture
* @return bool * @return bool
*/ */
public function isModRewriteEnabled() { public function isModRewriteEnabled()
{
// Check if Apache and mod_rewrite is loaded // Check if Apache and mod_rewrite is loaded
if (function_exists('apache_get_modules')) { if (function_exists('apache_get_modules')) {
$modules = apache_get_modules(); $modules = apache_get_modules();
@ -917,4 +919,25 @@ class config extends common
return getenv('HTTP_MOD_REWRITE') == 'On' || getenv('REDIRECT_STATUS') == '200'; return getenv('HTTP_MOD_REWRITE') == 'On' || getenv('REDIRECT_STATUS') == '200';
} }
} }
/**
* Stocke la variable dans les paramètres de l'utilisateur pour activer la tab à sa prochaine visite
* @return never
*/
public function register(): void
{
$this->setData([
'user',
$this->getUser('id'),
'view',
[
'config' => $this->getUrl(2),
'page' => $this->getData(['user', $this->getUser('id'), 'view', 'page']),
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config/' . $this->getUrl(2),
]);
}
} }

View File

@ -66,11 +66,11 @@ $(document).ready(function () {
$("#connectCaptchaStrong").prop("checked", false); $("#connectCaptchaStrong").prop("checked", false);
} }
var configLayout = getCookie("configLayout"); var configLayout = "<?php echo $this->getData(['user', $this->getUser('id'), 'view', 'config']);?>";
if (configLayout == null) { // Non défini, valeur par défaut
if (configLayout == null) {
configLayout = "setup"; configLayout = "setup";
setCookie("configLayout", "setup"); }
}
$("#socialContainer").hide(); $("#socialContainer").hide();
$("#connectContainer").hide(); $("#connectContainer").hide();
@ -166,7 +166,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "setup");
}); });
$("#configSocialButton").on("click", function () { $("#configSocialButton").on("click", function () {
$("#connectContainer").hide(); $("#connectContainer").hide();
@ -177,7 +176,6 @@ $(document).ready(function () {
$("#configSocialButton").addClass("activeButton"); $("#configSocialButton").addClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "social");
}); });
$("#configConnectButton").on("click", function () { $("#configConnectButton").on("click", function () {
$("#setupContainer").hide(); $("#setupContainer").hide();
@ -188,7 +186,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").addClass("activeButton"); $("#configConnectButton").addClass("activeButton");
$("#configNetworkButton").removeClass("activeButton"); $("#configNetworkButton").removeClass("activeButton");
setCookie("configLayout", "connect");
}); });
$("#configNetworkButton").on("click", function () { $("#configNetworkButton").on("click", function () {
$("#setupContainer").hide(); $("#setupContainer").hide();
@ -199,7 +196,6 @@ $(document).ready(function () {
$("#configSocialButton").removeClass("activeButton"); $("#configSocialButton").removeClass("activeButton");
$("#configConnectButton").removeClass("activeButton"); $("#configConnectButton").removeClass("activeButton");
$("#configNetworkButton").addClass("activeButton"); $("#configNetworkButton").addClass("activeButton");
setCookie("configLayout", "network");
}); });
@ -285,28 +281,6 @@ $(document).ready(function () {
}); });
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
// Define function to capitalize the first letter of a string // Define function to capitalize the first letter of a string
function capitalizeFirstLetter(string) { function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);

View File

@ -7,15 +7,6 @@
'value' => template::ico('home') 'value' => template::ico('home')
]); ?> ]); ?>
</div> </div>
<div class="col1">
<?php /**echo template::button('configHelp', [
'class' => 'buttonHelp',
'href' => 'https://doc.zwiicms.fr/configuration-du-site',
'target' => '_blank',
'value' => template::ico('help'),
'help' => 'Consulter l\'aide en ligne'
]); */?>
</div>
<div class="col2 offset6"> <div class="col2 offset6">
<?php echo template::button('configLocaleButton', [ <?php echo template::button('configLocaleButton', [
'value' => 'Identité', 'value' => 'Identité',
@ -30,20 +21,24 @@
<div class="tab"> <div class="tab">
<?php echo template::button('configSetupButton', [ <?php echo template::button('configSetupButton', [
'value' => 'Configuration', 'value' => 'Configuration',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/setup'
]); ?> ]); ?>
<?php echo template::button('configSocialButton', [ <?php echo template::button('configSocialButton', [
'value' => 'Référencement', 'value' => 'Référencement',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/social'
]); ?> ]); ?>
<?php echo template::button('configConnectButton', [ <?php echo template::button('configConnectButton', [
'value' => 'Connexion', 'value' => 'Connexion',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/connect'
]); ?> ]); ?>
<?php echo template::button('configNetworkButton', [ <?php echo template::button('configNetworkButton', [
'value' => 'Réseau', 'value' => 'Réseau',
'class' => 'buttonTab' 'class' => 'buttonTab',
'href' => helper::baseUrl() . 'config/register/network'
]); ?> ]); ?>
</div> </div>

View File

@ -727,7 +727,8 @@ class page extends common
$this->getUser('id'), $this->getUser('id'),
'view', 'view',
[ [
'page' => $this->getUrl(2) 'page' => $this->getUrl(2),
'config' => $this->getData(['user', $this->getUser('id'), 'view', 'config']),
] ]
]); ]);
// Valeurs en sortie // Valeurs en sortie