2018-04-02 08:29:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2021-02-17 13:51:12 +01:00
|
|
|
* This file is part of Zwii.
|
2018-04-02 08:29:19 +02:00
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
2021-02-17 13:49:58 +01:00
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
2023-01-09 10:23:32 +01:00
|
|
|
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
|
2022-12-29 17:02:20 +01:00
|
|
|
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
|
2020-09-01 20:48:40 +02:00
|
|
|
* @link http://zwiicms.fr/
|
2018-04-02 08:29:19 +02:00
|
|
|
*/
|
|
|
|
|
2023-06-29 17:01:27 +02:00
|
|
|
class redirection extends common
|
|
|
|
{
|
2018-04-02 08:29:19 +02:00
|
|
|
|
2023-01-19 13:32:07 +01:00
|
|
|
const VERSION = '1.6';
|
2021-02-18 10:07:05 +01:00
|
|
|
const REALNAME = 'Redirection';
|
2021-04-06 11:20:04 +02:00
|
|
|
const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json)
|
2021-02-18 10:07:05 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
public static $actions = [
|
|
|
|
'config' => self::GROUP_MODERATOR,
|
|
|
|
'index' => self::GROUP_VISITOR
|
|
|
|
];
|
|
|
|
|
2019-02-14 15:17:03 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
/**
|
|
|
|
* Configuration
|
|
|
|
*/
|
2023-06-29 17:01:27 +02:00
|
|
|
public function config()
|
|
|
|
{
|
2018-04-02 08:29:19 +02:00
|
|
|
// Soumission du formulaire
|
2023-06-29 17:01:27 +02:00
|
|
|
if (
|
2023-06-30 09:09:39 +02:00
|
|
|
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
|
2023-06-29 17:01:27 +02:00
|
|
|
$this->isPost()
|
|
|
|
) {
|
2019-12-02 12:48:17 +01:00
|
|
|
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
|
2018-04-02 08:29:19 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
2023-01-24 11:53:24 +01:00
|
|
|
'notification' => helper::translate('Modifications enregistrées'),
|
2018-04-02 08:29:19 +02:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
2023-01-24 11:53:24 +01:00
|
|
|
'title' => helper::translate('Configuration du module'),
|
2018-04-02 08:29:19 +02:00
|
|
|
'view' => 'config'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accueil
|
|
|
|
*/
|
2023-06-29 17:01:27 +02:00
|
|
|
public function index()
|
|
|
|
{
|
2018-04-02 08:29:19 +02:00
|
|
|
// Message si l'utilisateur peut éditer la page
|
2023-06-29 17:01:27 +02:00
|
|
|
if (
|
|
|
|
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
2023-06-29 10:30:12 +02:00
|
|
|
&& $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
|
|
|
|
&& $this->getUser('group') >= self::GROUP_MODERATOR
|
|
|
|
&& $this->getUrl(1) !== 'force'
|
2018-04-02 08:29:19 +02:00
|
|
|
) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_LAYOUT_BLANK,
|
|
|
|
'title' => '',
|
|
|
|
'view' => 'index'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Sinon redirection
|
|
|
|
else {
|
|
|
|
// Incrémente le compteur de clics
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'count', helper::filter($this->getData(['module', $this->getUrl(0), 'count']) + 1, helper::FILTER_INT)]);
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => $this->getData(['module', $this->getUrl(0), 'url']),
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 17:01:27 +02:00
|
|
|
}
|