2023-09-05 15:21:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of Zwii.
|
|
|
|
* 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
|
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
|
|
|
|
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
|
|
|
|
* @link http://zwiicms.fr/
|
|
|
|
*/
|
|
|
|
|
|
|
|
class redirection extends common
|
|
|
|
{
|
|
|
|
|
|
|
|
const VERSION = '2.1';
|
|
|
|
const REALNAME = 'Redirection';
|
|
|
|
const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json)
|
|
|
|
|
|
|
|
public static $actions = [
|
2023-09-05 21:16:23 +02:00
|
|
|
'config' => self::GROUP_TEACHER,
|
2023-09-21 19:32:30 +02:00
|
|
|
'index' => self::GROUP_STUDENT
|
2023-09-05 15:21:01 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration
|
|
|
|
*/
|
|
|
|
public function config()
|
|
|
|
{
|
|
|
|
// Soumission du formulaire
|
|
|
|
if (
|
|
|
|
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
|
|
|
|
$this->isPost()
|
|
|
|
) {
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
|
|
|
'notification' => helper::translate('Modifications enregistrées'),
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'title' => helper::translate('Configuration du module'),
|
|
|
|
'view' => 'config'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accueil
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
// Message si l'utilisateur peut éditer la page
|
|
|
|
if (
|
|
|
|
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
|
2023-09-05 21:16:23 +02:00
|
|
|
&& $this->getUser('group') >= self::GROUP_TEACHER
|
2023-09-05 15:21:01 +02:00
|
|
|
&& $this->getUrl(1) !== 'force'
|
|
|
|
) {
|
|
|
|
// 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
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|