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>
|
2024-01-14 19:31:22 +01:00
|
|
|
* @copyright Copyright (C) 2018-2024, Frédéric Tempez
|
2023-09-05 15:21:01 +02:00
|
|
|
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
|
|
|
|
* @link http://zwiicms.fr/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class install extends common
|
|
|
|
{
|
|
|
|
|
|
|
|
public static $actions = [
|
2023-09-21 21:19:39 +02:00
|
|
|
'index' => self::GROUP_VISITOR,
|
|
|
|
"postinstall" => self::GROUP_VISITOR,
|
2023-09-05 15:21:01 +02:00
|
|
|
'steps' => self::GROUP_ADMIN,
|
|
|
|
'update' => self::GROUP_ADMIN
|
|
|
|
];
|
|
|
|
|
|
|
|
// Type de proxy
|
|
|
|
public static $proxyType = [
|
|
|
|
'tcp://' => 'TCP',
|
|
|
|
'http://' => 'HTTP'
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public static $newVersion;
|
|
|
|
|
|
|
|
// Fichiers des Interface
|
|
|
|
public static $i18nFiles = [];
|
|
|
|
|
2023-11-03 11:42:15 +01:00
|
|
|
public static $updateButtonText = 'Réinstaller';
|
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
/**
|
|
|
|
* Pré-installation - choix de la langue
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
// Accès refusé
|
|
|
|
if ($this->getData(['user']) !== []) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'access' => false
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Soumission du formulaire
|
|
|
|
if (
|
|
|
|
//$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
|
|
|
|
$this->isPost()
|
|
|
|
) {
|
|
|
|
|
|
|
|
$lang = $this->getInput('installLanguage');
|
|
|
|
// Pour la suite de l'installation
|
|
|
|
// setcookie('ZWII_UI', $lang, time() + 3600, helper::baseUrl(false, false), '', false, false);
|
|
|
|
|
|
|
|
$_SESSION['ZWII_UI'] = $this->getInput('installLanguage');
|
|
|
|
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . 'install/postinstall'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Liste des langues UI disponibles
|
|
|
|
if (is_dir(self::I18N_DIR)) {
|
|
|
|
foreach ($this->getData(['language']) as $lang => $value) {
|
|
|
|
self::$i18nFiles[$lang] = self::$languages[$lang];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
2023-12-07 11:35:17 +01:00
|
|
|
'title' => helper::translate('ZwiiCampus installation'),
|
2023-09-05 15:21:01 +02:00
|
|
|
'view' => 'index'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* post Installation
|
|
|
|
*/
|
|
|
|
public function postInstall()
|
|
|
|
{
|
|
|
|
// Accès refusé
|
|
|
|
if ($this->getData(['user']) !== []) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'access' => false
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Accès autorisé
|
|
|
|
else {
|
|
|
|
// Soumission du formulaire
|
|
|
|
if (
|
|
|
|
//$this->getUser('permission', __CLASS__, __FUNCTION__) !== true &&
|
|
|
|
$this->isPost()
|
|
|
|
) {
|
|
|
|
|
|
|
|
$success = true;
|
|
|
|
|
|
|
|
// Double vérification pour le mot de passe
|
|
|
|
if ($this->getInput('installPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
|
|
|
self::$inputNotices['installConfirmPassword'] = 'Incorrect';
|
|
|
|
$success = false;
|
|
|
|
}
|
|
|
|
// Utilisateur
|
|
|
|
$userFirstname = $this->getInput('installFirstname', helper::FILTER_STRING_SHORT, true);
|
|
|
|
$userLastname = $this->getInput('installLastname', helper::FILTER_STRING_SHORT, true);
|
|
|
|
$userMail = $this->getInput('installMail', helper::FILTER_MAIL, true);
|
|
|
|
$userId = $this->getInput('installId', helper::FILTER_ID, true);
|
|
|
|
|
|
|
|
// Validation de la langue transmise
|
|
|
|
self::$i18nUI = $_SESSION['ZWII_UI'];
|
|
|
|
self::$i18nUI = array_key_exists(self::$i18nUI, self::$languages) ? self::$i18nUI : 'fr_FR';
|
|
|
|
|
2023-11-15 18:06:49 +01:00
|
|
|
// Création du dossier de contenu avec le marqueur de langue par défaut
|
2023-09-13 18:30:24 +02:00
|
|
|
if (!is_dir(self::DATA_DIR . $_SESSION['ZWII_SITE_CONTENT'])) {
|
|
|
|
mkdir(self::DATA_DIR . $_SESSION['ZWII_SITE_CONTENT']);
|
|
|
|
touch(self::DATA_DIR . $_SESSION['ZWII_SITE_CONTENT'] . '/.default');
|
2023-09-05 15:21:01 +02:00
|
|
|
}
|
|
|
|
// Création de l'utilisateur si les données sont complétées.
|
|
|
|
// success retour de l'enregistrement des données
|
|
|
|
$this->setData([
|
|
|
|
'user',
|
|
|
|
$userId,
|
|
|
|
[
|
|
|
|
'firstname' => $userFirstname,
|
|
|
|
'forgot' => 0,
|
|
|
|
'group' => self::GROUP_ADMIN,
|
2023-11-15 14:10:08 +01:00
|
|
|
'profil' => 0,
|
2023-09-05 15:21:01 +02:00
|
|
|
'lastname' => $userLastname,
|
|
|
|
'pseudo' => 'Admin',
|
|
|
|
'signature' => 1,
|
|
|
|
'mail' => $userMail,
|
|
|
|
'password' => $this->getInput('installPassword', helper::FILTER_PASSWORD, true),
|
2023-09-13 18:30:24 +02:00
|
|
|
'language' => $_SESSION['ZWII_SITE_CONTENT']
|
2023-09-05 15:21:01 +02:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Envoie le mail
|
|
|
|
// Sent contient true si réussite sinon code erreur d'envoi en clair
|
|
|
|
$this->sendMail(
|
|
|
|
$userMail,
|
|
|
|
'Installation de votre site',
|
|
|
|
'Bonjour' . ' <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
|
|
|
|
'Voici les détails de votre installation.<br><br>' .
|
|
|
|
'<strong>URL du site :</strong> <a href="' . helper::baseUrl(false) . '" target="_blank">' . helper::baseUrl(false) . '</a><br>' .
|
|
|
|
'<strong>Identifiant du compte :</strong> ' . $this->getInput('installId') . '<br>',
|
|
|
|
null,
|
2023-10-11 21:10:48 +02:00
|
|
|
'no-reply@localhost'
|
2023-09-05 15:21:01 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Sauvegarder la configuration du Proxy
|
|
|
|
$this->setData(['config', 'proxyType', $this->getInput('installProxyType')]);
|
|
|
|
$this->setData(['config', 'proxyUrl', $this->getInput('installProxyUrl')]);
|
|
|
|
$this->setData(['config', 'proxyPort', $this->getInput('installProxyPort', helper::FILTER_INT)]);
|
|
|
|
|
|
|
|
// Images exemples livrées dans tous les cas
|
|
|
|
try {
|
|
|
|
// Décompression dans le dossier de fichier temporaires
|
|
|
|
if (file_exists(self::TEMP_DIR . 'files.tar.gz')) {
|
|
|
|
unlink(self::TEMP_DIR . 'files.tar.gz');
|
|
|
|
}
|
|
|
|
if (file_exists(self::TEMP_DIR . 'files.tar')) {
|
|
|
|
unlink(self::TEMP_DIR . 'files.tar');
|
|
|
|
}
|
|
|
|
copy('core/module/install/ressource/files.tar.gz', self::TEMP_DIR . 'files.tar.gz');
|
|
|
|
$pharData = new PharData(self::TEMP_DIR . 'files.tar.gz');
|
|
|
|
$pharData->decompress();
|
|
|
|
// Installation
|
|
|
|
$pharData->extractTo(__DIR__ . '/../../../', null, true);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$success = $e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nettoyage
|
|
|
|
unlink(self::TEMP_DIR . 'files.tar.gz');
|
|
|
|
unlink(self::TEMP_DIR . 'files.tar');
|
|
|
|
|
|
|
|
// Créer le dossier des fontes
|
|
|
|
if (!is_dir(self::DATA_DIR . 'font')) {
|
|
|
|
mkdir(self::DATA_DIR . 'font');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copie des langues de l'UI et génération de la base de données
|
|
|
|
if (is_dir(self::I18N_DIR) === false) {
|
|
|
|
mkdir(self::I18N_DIR);
|
|
|
|
}
|
|
|
|
|
2024-02-08 09:44:24 +01:00
|
|
|
// Créer le dossier de l'accueil dans les fichiers
|
|
|
|
if (is_dir(self::FILE_DIR . 'source/home') === false) {
|
|
|
|
mkdir(self::FILE_DIR . 'source/home');
|
|
|
|
}
|
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
// Créer la base de données des langues
|
|
|
|
$this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR);
|
|
|
|
|
|
|
|
// Fixe l'adresse from pour les envois d'email
|
|
|
|
$this->setData(['config', 'smtp', 'from', 'no-reply@' . str_replace('www.', '', $_SERVER['HTTP_HOST'])]);
|
|
|
|
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl(),
|
|
|
|
'notification' => helper::translate('Installation terminée'),
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Affichage du formulaire
|
|
|
|
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
2023-12-07 11:35:17 +01:00
|
|
|
'title' => helper::translate('ZwiiCampus Installation'),
|
2023-09-05 15:21:01 +02:00
|
|
|
'view' => 'postinstall'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Étapes de mise à jour
|
|
|
|
*/
|
|
|
|
public function steps()
|
|
|
|
{
|
|
|
|
// Action interdite
|
|
|
|
if (
|
|
|
|
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
|
|
|
) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'access' => false
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
switch ($this->getInput('step', helper::FILTER_INT)) {
|
|
|
|
// Préparation
|
|
|
|
case 1:
|
|
|
|
$success = true;
|
|
|
|
$message = '';
|
|
|
|
// RAZ la mise à jour auto
|
|
|
|
$this->setData(['core', 'updateAvailable', false]);
|
|
|
|
// Backup du dossier Data
|
|
|
|
helper::autoBackup(self::BACKUP_DIR, ['backup', 'tmp', 'file']);
|
|
|
|
// Sauvegarde htaccess
|
|
|
|
if ($this->getData(['config', 'autoUpdateHtaccess'])) {
|
|
|
|
$success = copy('.htaccess', '.htaccess' . '.bak');
|
|
|
|
$message = $success ? '' : 'Erreur de copie du fichier htaccess';
|
|
|
|
}
|
|
|
|
// Nettoyage des fichiers d'installation précédents
|
2024-02-03 18:42:00 +01:00
|
|
|
if ($success && file_exists(self::TEMP_DIR . 'update.tar.gz')) {
|
2023-09-05 15:21:01 +02:00
|
|
|
$success = unlink(self::TEMP_DIR . 'update.tar.gz');
|
|
|
|
$message = $success ? '' : 'Impossible d\'effacer la mise à jour précédente';
|
|
|
|
}
|
2024-02-03 18:42:00 +01:00
|
|
|
if ($success && file_exists(self::TEMP_DIR . 'update.tar')) {
|
2023-09-05 15:21:01 +02:00
|
|
|
$success = unlink(self::TEMP_DIR . 'update.tar');
|
|
|
|
$message = $success ? '' : 'Impossible d\'effacer la mise à jour précédente';
|
|
|
|
}
|
2024-02-03 18:59:42 +01:00
|
|
|
// Sauvegarde le message dans le journal
|
|
|
|
if (!empty($message)) {
|
|
|
|
$this->saveLog($message);
|
|
|
|
}
|
2023-09-05 15:21:01 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_JSON,
|
|
|
|
'content' => [
|
|
|
|
'success' => $success,
|
|
|
|
'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
// Téléchargement
|
|
|
|
case 2:
|
2024-02-03 18:42:00 +01:00
|
|
|
$success = true;
|
|
|
|
$message = '';
|
2024-04-02 18:25:39 +02:00
|
|
|
file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz'));
|
2023-09-05 15:21:01 +02:00
|
|
|
$md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5');
|
|
|
|
$md5origin = explode(' ', $md5origin);
|
|
|
|
$md5target = md5_file(self::TEMP_DIR . 'update.tar.gz');
|
|
|
|
// Vérifier si les checksums correspondent
|
|
|
|
if ($md5origin[0] === $md5target) {
|
|
|
|
$success = true;
|
|
|
|
$message = "";
|
|
|
|
} else {
|
|
|
|
$success = false;
|
2024-02-03 18:42:00 +01:00
|
|
|
$message = 'Erreur de téléchargement ou de somme de contrôle';
|
2023-09-05 15:21:01 +02:00
|
|
|
if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
|
|
|
|
unlink(self::TEMP_DIR . 'update.tar.gz');
|
|
|
|
http_response_code(500);
|
|
|
|
}
|
|
|
|
}
|
2024-02-03 18:59:42 +01:00
|
|
|
// Sauvegarde le message dans le journal
|
|
|
|
if (!empty($message)) {
|
|
|
|
$this->saveLog($message);
|
|
|
|
}
|
2023-09-05 15:21:01 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_JSON,
|
|
|
|
'content' => [
|
|
|
|
'success' => $success,
|
2024-02-03 18:42:00 +01:00
|
|
|
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
|
2023-09-05 15:21:01 +02:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
// Installation
|
|
|
|
case 3:
|
|
|
|
$success = true;
|
2024-02-03 18:42:00 +01:00
|
|
|
$message = '';
|
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
// Check la réécriture d'URL avant d'écraser les fichiers
|
2024-02-03 18:42:00 +01:00
|
|
|
if (helper::checkRewrite()) {
|
|
|
|
touch(self::DATA_DIR . '.rewrite');
|
|
|
|
}
|
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
// Décompression et installation
|
|
|
|
try {
|
|
|
|
// Décompression dans le dossier de fichier temporaires
|
|
|
|
$pharData = new PharData(self::TEMP_DIR . 'update.tar.gz');
|
|
|
|
$pharData->decompress();
|
|
|
|
// Installation
|
|
|
|
$pharData->extractTo(__DIR__ . '/../../../', null, true);
|
|
|
|
} catch (Exception $e) {
|
2024-02-03 18:42:00 +01:00
|
|
|
$message = $e->getMessage();
|
2023-09-05 15:21:01 +02:00
|
|
|
$success = false;
|
|
|
|
http_response_code(500);
|
|
|
|
}
|
2024-02-03 18:42:00 +01:00
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
// Nettoyage du dossier
|
|
|
|
if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
|
|
|
|
unlink(self::TEMP_DIR . 'update.tar.gz');
|
|
|
|
}
|
|
|
|
if (file_exists(self::TEMP_DIR . 'update.tar')) {
|
|
|
|
unlink(self::TEMP_DIR . 'update.tar');
|
|
|
|
}
|
2024-02-03 18:59:42 +01:00
|
|
|
// Sauvegarde le message dans le journal
|
|
|
|
if (!empty($message)) {
|
|
|
|
$this->saveLog($message);
|
|
|
|
}
|
2023-09-05 15:21:01 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_JSON,
|
|
|
|
'content' => [
|
|
|
|
'success' => $success,
|
2024-02-03 18:42:00 +01:00
|
|
|
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
|
2023-09-05 15:21:01 +02:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
// Configuration
|
|
|
|
case 4:
|
|
|
|
$success = true;
|
|
|
|
$message = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restaure le fichier htaccess
|
|
|
|
*/
|
|
|
|
// Recopie htaccess
|
|
|
|
if (
|
|
|
|
$this->getData(['config', 'autoUpdateHtaccess']) === true
|
|
|
|
) {
|
|
|
|
// L'écraser avec le backup
|
|
|
|
$success = copy('.htaccess.bak', '.htaccess');
|
|
|
|
if ($success === false) {
|
|
|
|
$message = helper::translate('La copie de sauvegarde du fichier htaccess n\'a pas été restaurée !');
|
|
|
|
http_response_code(500);
|
|
|
|
}
|
|
|
|
// Effacer le backup
|
|
|
|
unlink('.htaccess.bak');
|
|
|
|
} else {
|
|
|
|
/**
|
|
|
|
* Restaure la réécriture d'URL
|
|
|
|
*/
|
2024-02-03 18:42:00 +01:00
|
|
|
if (file_exists(self::DATA_DIR . '.rewrite')) { // Ajout des lignes dans le .htaccess
|
2023-09-05 15:21:01 +02:00
|
|
|
$fileContent = file_get_contents('.htaccess');
|
|
|
|
$rewriteData = PHP_EOL .
|
|
|
|
'# URL rewriting' . PHP_EOL .
|
|
|
|
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
|
|
|
"\tRewriteEngine on" . PHP_EOL .
|
|
|
|
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
|
|
|
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
|
|
|
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
|
|
|
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
|
|
|
'</IfModule>' . PHP_EOL .
|
|
|
|
'# URL rewriting' . PHP_EOL;
|
|
|
|
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
|
2024-04-02 18:25:39 +02:00
|
|
|
$success = file_put_contents(
|
2023-09-05 15:21:01 +02:00
|
|
|
'.htaccess',
|
|
|
|
$fileContent
|
|
|
|
);
|
2024-02-03 18:42:00 +01:00
|
|
|
unlink(self::DATA_DIR . '.rewrite');
|
2023-09-05 15:21:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Met à jour les dictionnaires des langues depuis les nouveaux modèles installés
|
|
|
|
*/
|
|
|
|
require_once('core/module/install/ressource/defaultdata.php');
|
|
|
|
$installedLanguages = $this->getData(['language']);
|
|
|
|
$defaultLanguages = init::$defaultData['language'];
|
|
|
|
foreach ($installedLanguages as $key => $value) {
|
|
|
|
|
|
|
|
if (
|
|
|
|
isset($defaultLanguages[$key]['date']) &&
|
|
|
|
$defaultLanguages[$key]['date'] > $value['date'] &&
|
|
|
|
isset($defaultLanguages[$key]['version']) &&
|
|
|
|
$defaultLanguages[$key]['version'] >= $value['version']
|
|
|
|
|
|
|
|
) {
|
|
|
|
copy('core/module/install/ressource/i18n/' . $key . '.json', self::I18N_DIR . $key . '.json');
|
|
|
|
$this->setData(['language', $key, $defaultLanguages[$key]]);
|
|
|
|
}
|
|
|
|
}
|
2024-02-03 18:59:42 +01:00
|
|
|
// Sauvegarde le message dans le journal
|
|
|
|
if (!empty($message)) {
|
|
|
|
$this->saveLog($message);
|
|
|
|
}
|
2023-09-05 15:21:01 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_JSON,
|
|
|
|
'content' => [
|
|
|
|
'success' => $success,
|
|
|
|
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mise à jour
|
|
|
|
*/
|
|
|
|
public function update()
|
|
|
|
{
|
|
|
|
// Action interdite
|
|
|
|
if (
|
|
|
|
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
|
|
|
|
) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'access' => false
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
// Nouvelle version
|
|
|
|
self::$newVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version');
|
2024-02-03 18:42:00 +01:00
|
|
|
|
2023-11-03 11:42:15 +01:00
|
|
|
// Variable de version
|
|
|
|
if (helper::checkNewVersion(common::ZWII_UPDATE_CHANNEL)) {
|
2024-02-03 09:35:48 +01:00
|
|
|
self::$updateButtonText = helper::translate('Mise à jour');
|
2023-11-03 11:42:15 +01:00
|
|
|
}
|
2024-02-03 18:42:00 +01:00
|
|
|
|
|
|
|
|
2023-09-05 15:21:01 +02:00
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
2023-11-03 11:42:15 +01:00
|
|
|
'title' => helper::translate(self::$updateButtonText),
|
2023-09-05 15:21:01 +02:00
|
|
|
'view' => 'update'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|