securité des modules du coeur
This commit is contained in:
parent
1bd9cf41ef
commit
b0e8cfbb9e
|
@ -4,6 +4,7 @@
|
||||||
- Modifications :
|
- Modifications :
|
||||||
- Une troisième langue d'administration est disponible : espagnol / castillan,
|
- Une troisième langue d'administration est disponible : espagnol / castillan,
|
||||||
- Thème / Menu : le menu en petit écran (burger) dispose maintenant de ses propres paramètres,
|
- Thème / Menu : le menu en petit écran (burger) dispose maintenant de ses propres paramètres,
|
||||||
|
- Modules du coeur et de page : renforcement de la sécurité,
|
||||||
- Langues : la traduction automatique est supprimée, ce qui parachève la dégooglisation de Deltacms,
|
- Langues : la traduction automatique est supprimée, ce qui parachève la dégooglisation de Deltacms,
|
||||||
- Edition de page / emplacement dans le menu : une page désactivée est signalée par le curseur 'not-allowed' et par une typographie italique en petit écran, son lien est inactif,
|
- Edition de page / emplacement dans le menu : une page désactivée est signalée par le curseur 'not-allowed' et par une typographie italique en petit écran, son lien est inactif,
|
||||||
- Nouveaux gabarits pour l'éditeur Tinymce : accordéon à 3 et 4 paragraphes,
|
- Nouveaux gabarits pour l'éditeur Tinymce : accordéon à 3 et 4 paragraphes,
|
||||||
|
|
|
@ -48,42 +48,52 @@ class addon extends common {
|
||||||
* Effacement d'un module installé et non utilisé
|
* Effacement d'un module installé et non utilisé
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Jeton incorrect
|
if( $group < addon::$actions['delete'] ) {
|
||||||
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
'access' => false
|
||||||
'state' => false,
|
|
||||||
'notification' => $text['core_addon']['delete'][0]
|
|
||||||
]);
|
]);
|
||||||
}
|
} else {
|
||||||
else{
|
// Lexique
|
||||||
// Suppression des dossiers
|
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
||||||
$infoModules = helper::getModules();
|
|
||||||
$module = $this->getUrl(2);
|
// Jeton incorrect
|
||||||
//Liste des dossiers associés au module non effacés
|
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
if( $this->removeDir('./module/'.$module ) === true ){
|
// Valeurs en sortie
|
||||||
$success = true;
|
$this->addOutput([
|
||||||
$notification = 'Module '. $module .$text['core_addon']['delete'][1];
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
if( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) ) {
|
'state' => false,
|
||||||
if (!$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory'])){
|
'notification' => $text['core_addon']['delete'][0]
|
||||||
$notification = 'Module '.$module .$text['core_addon']['delete'][2] . $infoModules[$this->getUrl(2)]['dataDirectory'];
|
]);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$success = false;
|
// Suppression des dossiers
|
||||||
$notification = $text['core_addon']['delete'][3];
|
$infoModules = helper::getModules();
|
||||||
|
$module = $this->getUrl(2);
|
||||||
|
//Liste des dossiers associés au module non effacés
|
||||||
|
if( $this->removeDir('./module/'.$module ) === true ){
|
||||||
|
$success = true;
|
||||||
|
$notification = 'Module '. $module .$text['core_addon']['delete'][1];
|
||||||
|
if( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) ) {
|
||||||
|
if (!$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory'])){
|
||||||
|
$notification = 'Module '.$module .$text['core_addon']['delete'][2] . $infoModules[$this->getUrl(2)]['dataDirectory'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$success = false;
|
||||||
|
$notification = $text['core_addon']['delete'][3];
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
|
'notification' => $notification,
|
||||||
|
'state' => $success
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
|
||||||
'notification' => $notification,
|
|
||||||
'state' => $success
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,308 +216,367 @@ class addon extends common {
|
||||||
* Installation d'un module à partir du gestionnaire de fichier
|
* Installation d'un module à partir du gestionnaire de fichier
|
||||||
*/
|
*/
|
||||||
public function upload() {
|
public function upload() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Soumission du formulaire
|
if( $group < addon::$actions['upload'] ) {
|
||||||
if($this->isPost()) {
|
// Valeurs en sortie
|
||||||
// Installation d'un module
|
|
||||||
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
|
|
||||||
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
|
|
||||||
if( $zipFilename !== ''){
|
|
||||||
$success = [
|
|
||||||
'success' => false,
|
|
||||||
'notification'=> ''
|
|
||||||
];
|
|
||||||
$state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
|
|
||||||
}
|
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . $this->getUrl(),
|
'access' => false
|
||||||
'notification' => $state['notification'],
|
]);
|
||||||
'state' => $state['success']
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
||||||
|
|
||||||
|
// Soumission du formulaire
|
||||||
|
if($this->isPost()) {
|
||||||
|
// Installation d'un module
|
||||||
|
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
|
||||||
|
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
|
||||||
|
if( $zipFilename !== ''){
|
||||||
|
$success = [
|
||||||
|
'success' => false,
|
||||||
|
'notification'=> ''
|
||||||
|
];
|
||||||
|
$state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj);
|
||||||
|
}
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
||||||
|
'notification' => $state['notification'],
|
||||||
|
'state' => $state['success']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_addon']['upload'][0],
|
||||||
|
'view' => 'upload'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_addon']['upload'][0],
|
|
||||||
'view' => 'upload'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Installation d'un module par le catalogue
|
* Installation d'un module par le catalogue
|
||||||
*/
|
*/
|
||||||
public function uploadItem() {
|
public function uploadItem() {
|
||||||
// Jeton incorrect
|
// Autorisation
|
||||||
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
|
if( $group < addon::$actions['uploadItem'] ) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'store',
|
'access' => false
|
||||||
'state' => false,
|
|
||||||
'notification' => 'Action non autorisée'
|
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
// Récupérer le module en ligne
|
// Jeton incorrect
|
||||||
$moduleName = $this->getUrl(2);
|
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
// Informations sur les module en ligne
|
// Valeurs en sortie
|
||||||
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
$this->addOutput([
|
||||||
// Url du module à télécharger
|
'redirect' => helper::baseUrl() . 'store',
|
||||||
$moduleFilePath = $store[$moduleName]['file'];
|
'state' => false,
|
||||||
// Télécharger le fichier
|
'notification' => 'Action non autorisée'
|
||||||
$moduleData = helper::urlGetContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath);
|
]);
|
||||||
// Extraire de l'arborescence
|
} else {
|
||||||
$d = explode('/',$moduleFilePath);
|
// Récupérer le module en ligne
|
||||||
$moduleFile = $d[count($d)-1];
|
$moduleName = $this->getUrl(2);
|
||||||
// Créer le dossier modules
|
// Informations sur les module en ligne
|
||||||
if (!is_dir(self::FILE_DIR . 'source/modules')) {
|
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
||||||
mkdir (self::FILE_DIR . 'source/modules', 0755);
|
// Url du module à télécharger
|
||||||
|
$moduleFilePath = $store[$moduleName]['file'];
|
||||||
|
// Télécharger le fichier
|
||||||
|
$moduleData = helper::urlGetContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath);
|
||||||
|
// Extraire de l'arborescence
|
||||||
|
$d = explode('/',$moduleFilePath);
|
||||||
|
$moduleFile = $d[count($d)-1];
|
||||||
|
// Créer le dossier modules
|
||||||
|
if (!is_dir(self::FILE_DIR . 'source/modules')) {
|
||||||
|
mkdir (self::FILE_DIR . 'source/modules', 0755);
|
||||||
|
}
|
||||||
|
// Sauver les données du fichiers
|
||||||
|
file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $if( $moduleFile !== ''){
|
||||||
|
* $success = [
|
||||||
|
* 'success' => false,
|
||||||
|
* 'notification'=> ''
|
||||||
|
* ];
|
||||||
|
* $state = $this->install(self::FILE_DIR.'source/modules/'.$moduleFile, false);
|
||||||
|
*}
|
||||||
|
*/
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'addon/store',
|
||||||
|
'notification' => $moduleFile . ' téléchargé dans le dossier modules du gestionnaire de fichiers',
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
// Sauver les données du fichiers
|
// Valeurs en sortie
|
||||||
file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $if( $moduleFile !== ''){
|
|
||||||
* $success = [
|
|
||||||
* 'success' => false,
|
|
||||||
* 'notification'=> ''
|
|
||||||
* ];
|
|
||||||
* $state = $this->install(self::FILE_DIR.'source/modules/'.$moduleFile, false);
|
|
||||||
*}
|
|
||||||
*/
|
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon/store',
|
'title' => 'Catalogue de modules',
|
||||||
'notification' => $moduleFile . ' téléchargé dans le dossier modules du gestionnaire de fichiers',
|
'view' => 'store'
|
||||||
'state' => true
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => 'Catalogue de modules',
|
|
||||||
'view' => 'store'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Catalogue des modules sur le site DeltaCMS.fr
|
* Catalogue des modules sur le site DeltaCMS.fr
|
||||||
*/
|
*/
|
||||||
public function store() {
|
public function store() {
|
||||||
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
// Autorisation
|
||||||
if ($store) {
|
$group = $this->getUser('group');
|
||||||
// Modules installés
|
if ($group === false ) $group = 0;
|
||||||
$infoModules = helper::getModules();
|
if( $group < addon::$actions['store'] ) {
|
||||||
// Clés moduleIds dans les pages
|
// Valeurs en sortie
|
||||||
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
$this->addOutput([
|
||||||
foreach( $inPages as $key=>$value){
|
'access' => false
|
||||||
$inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
|
]);
|
||||||
}
|
} else {
|
||||||
// Parcourir les données des modules
|
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
||||||
foreach ($store as $key=>$value) {
|
if ($store) {
|
||||||
// Module non installé
|
// Modules installés
|
||||||
$ico = template::ico('download');
|
$infoModules = helper::getModules();
|
||||||
$class = '';
|
// Clés moduleIds dans les pages
|
||||||
// Le module est installé
|
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
||||||
if (array_key_exists($key,$infoModules) === true) {
|
foreach( $inPages as $key=>$value){
|
||||||
$class = 'buttonGreen';
|
$inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
|
||||||
$ico = template::ico('update');
|
|
||||||
}
|
}
|
||||||
// Le module est installé et utilisé
|
// Parcourir les données des modules
|
||||||
if (in_array($key,$inPages) === true) {
|
foreach ($store as $key=>$value) {
|
||||||
$class = 'buttonRed';
|
// Module non installé
|
||||||
$ico = template::ico('update');
|
$ico = template::ico('download');
|
||||||
|
$class = '';
|
||||||
|
// Le module est installé
|
||||||
|
if (array_key_exists($key,$infoModules) === true) {
|
||||||
|
$class = 'buttonGreen';
|
||||||
|
$ico = template::ico('update');
|
||||||
|
}
|
||||||
|
// Le module est installé et utilisé
|
||||||
|
if (in_array($key,$inPages) === true) {
|
||||||
|
$class = 'buttonRed';
|
||||||
|
$ico = template::ico('update');
|
||||||
|
}
|
||||||
|
self::$storeList [] = [
|
||||||
|
$store[$key]['category'],
|
||||||
|
'<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >'.$store[$key]['title'].'</a>',
|
||||||
|
$store[$key]['version'],
|
||||||
|
mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true)
|
||||||
|
? strftime('%d %B %Y', $store[$key]['versionDate'])
|
||||||
|
: utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])),
|
||||||
|
implode(', ', array_keys($inPagesTitle,$key)),
|
||||||
|
template::button('moduleExport' . $key, [
|
||||||
|
'class' => $class,
|
||||||
|
'href' => helper::baseUrl(). $this->getUrl(0) . '/uploadItem/' . $key.'/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
||||||
|
'value' => $ico
|
||||||
|
])
|
||||||
|
];
|
||||||
}
|
}
|
||||||
self::$storeList [] = [
|
|
||||||
$store[$key]['category'],
|
|
||||||
'<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >'.$store[$key]['title'].'</a>',
|
|
||||||
$store[$key]['version'],
|
|
||||||
mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true)
|
|
||||||
? strftime('%d %B %Y', $store[$key]['versionDate'])
|
|
||||||
: utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])),
|
|
||||||
implode(', ', array_keys($inPagesTitle,$key)),
|
|
||||||
template::button('moduleExport' . $key, [
|
|
||||||
'class' => $class,
|
|
||||||
'href' => helper::baseUrl(). $this->getUrl(0) . '/uploadItem/' . $key.'/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
|
||||||
'value' => $ico
|
|
||||||
])
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => 'Catalogue de modules en ligne',
|
||||||
|
'view' => 'store'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => 'Catalogue de modules en ligne',
|
|
||||||
'view' => 'store'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Détail d'un objet du catalogue
|
* Détail d'un objet du catalogue
|
||||||
*/
|
*/
|
||||||
public function item() {
|
public function item() {
|
||||||
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
// Autorisation
|
||||||
self::$storeItem = $store [$this->getUrl(2)] ;
|
$group = $this->getUser('group');
|
||||||
self::$storeItem ['fileDate'] = mb_detect_encoding(strftime('%d %B %Y',self::$storeItem ['fileDate']), 'UTF-8', true)
|
if ($group === false ) $group = 0;
|
||||||
? strftime('%d %B %Y', self::$storeItem ['fileDate'])
|
if( $group < addon::$actions['item'] ) {
|
||||||
: utf8_encode(strftime('%d %B %Y', self::$storeItem ['fileDate']));
|
// Valeurs en sortie
|
||||||
// Valeurs en sortie
|
$this->addOutput([
|
||||||
$this->addOutput([
|
'access' => false
|
||||||
'title' =>'Module ' . self::$storeItem['title'],
|
]);
|
||||||
'view' => 'item'
|
} else {
|
||||||
]);
|
$store = json_decode(helper::urlGetContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
|
||||||
|
self::$storeItem = $store [$this->getUrl(2)] ;
|
||||||
|
self::$storeItem ['fileDate'] = mb_detect_encoding(strftime('%d %B %Y',self::$storeItem ['fileDate']), 'UTF-8', true)
|
||||||
|
? strftime('%d %B %Y', self::$storeItem ['fileDate'])
|
||||||
|
: utf8_encode(strftime('%d %B %Y', self::$storeItem ['fileDate']));
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' =>'Module ' . self::$storeItem['title'],
|
||||||
|
'view' => 'item'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gestion des modules
|
* Gestion des modules
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
|
if( $group < addon::$actions['index'] ) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
||||||
|
|
||||||
// Lister les modules
|
// Lister les modules
|
||||||
// $infoModules[nom_module]['realName'], ['version'], ['update'], ['delete'], ['dataDirectory']
|
// $infoModules[nom_module]['realName'], ['version'], ['update'], ['delete'], ['dataDirectory']
|
||||||
$infoModules = helper::getModules();
|
$infoModules = helper::getModules();
|
||||||
|
|
||||||
// Clés moduleIds dans les pages
|
// Clés moduleIds dans les pages
|
||||||
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
||||||
foreach( $inPages as $key=>$value){
|
foreach( $inPages as $key=>$value){
|
||||||
$inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
|
$inPagesTitle[ $this->getData(['page', $key, 'title' ]) ] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parcourir les données des modules
|
||||||
|
foreach ($infoModules as $key=>$value) {
|
||||||
|
// Construire le tableau de sortie
|
||||||
|
self::$modInstal[] = [
|
||||||
|
$key,
|
||||||
|
$infoModules[$key]['realName'],
|
||||||
|
$infoModules[$key]['version'],
|
||||||
|
implode(', ', array_keys($inPagesTitle,$key)),
|
||||||
|
//|| ('delete',$infoModules[$key]) && $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
|
||||||
|
$infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
|
||||||
|
? template::button('moduleDelete' . $key, [
|
||||||
|
'class' => 'moduleDelete buttonRed',
|
||||||
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
|
||||||
|
'value' => template::ico('cancel')
|
||||||
|
])
|
||||||
|
: '',
|
||||||
|
implode(', ',array_keys($inPages,$key)) !== ''
|
||||||
|
? template::button('moduleExport' . $key, [
|
||||||
|
'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
||||||
|
'value' => template::ico('download')
|
||||||
|
])
|
||||||
|
: '',
|
||||||
|
implode(', ',array_keys($inPages,$key)) === ''
|
||||||
|
? template::button('moduleExport' . $key, [
|
||||||
|
'href' => helper::baseUrl(). $this->getUrl(0) . '/import/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
||||||
|
'value' => template::ico('upload')
|
||||||
|
])
|
||||||
|
: ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_addon']['index'][0],
|
||||||
|
'view' => 'index'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parcourir les données des modules
|
|
||||||
foreach ($infoModules as $key=>$value) {
|
|
||||||
// Construire le tableau de sortie
|
|
||||||
self::$modInstal[] = [
|
|
||||||
$key,
|
|
||||||
$infoModules[$key]['realName'],
|
|
||||||
$infoModules[$key]['version'],
|
|
||||||
implode(', ', array_keys($inPagesTitle,$key)),
|
|
||||||
//|| ('delete',$infoModules[$key]) && $infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
|
|
||||||
$infoModules[$key]['delete'] === true && implode(', ',array_keys($inPages,$key)) === ''
|
|
||||||
? template::button('moduleDelete' . $key, [
|
|
||||||
'class' => 'moduleDelete buttonRed',
|
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
|
|
||||||
'value' => template::ico('cancel')
|
|
||||||
])
|
|
||||||
: '',
|
|
||||||
implode(', ',array_keys($inPages,$key)) !== ''
|
|
||||||
? template::button('moduleExport' . $key, [
|
|
||||||
'href' => helper::baseUrl(). $this->getUrl(0) . '/export/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
|
||||||
'value' => template::ico('download')
|
|
||||||
])
|
|
||||||
: '',
|
|
||||||
implode(', ',array_keys($inPages,$key)) === ''
|
|
||||||
? template::button('moduleExport' . $key, [
|
|
||||||
'href' => helper::baseUrl(). $this->getUrl(0) . '/import/' . $key . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre
|
|
||||||
'value' => template::ico('upload')
|
|
||||||
])
|
|
||||||
: ''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_addon']['index'][0],
|
|
||||||
'view' => 'index'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Export des données d'un module externes ou interne à module.json
|
* Export des données d'un module externes ou interne à module.json
|
||||||
*/
|
*/
|
||||||
public function export(){
|
public function export(){
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Jeton incorrect
|
if( $group < addon::$actions['export'] ) {
|
||||||
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
'access' => false
|
||||||
'state' => false,
|
|
||||||
'notification' => $text['core_addon']['export'][0]
|
|
||||||
]);
|
]);
|
||||||
}
|
} else {
|
||||||
else {
|
// Lexique
|
||||||
// Lire les données du module
|
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
||||||
$infoModules = helper::getModules();
|
|
||||||
// Créer un dossier par défaut
|
// Jeton incorrect
|
||||||
$tmpFolder = self::TEMP_DIR . uniqid();
|
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
//$tmpFolder = self::TEMP_DIR . 'test';
|
|
||||||
if (!is_dir($tmpFolder)) {
|
|
||||||
mkdir($tmpFolder, 0755);
|
|
||||||
}
|
|
||||||
// Clés moduleIds dans les pages
|
|
||||||
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
|
||||||
// Parcourir les pages utilisant le module
|
|
||||||
foreach (array_keys($inPages,$this->getUrl(2)) as $pageId) {
|
|
||||||
// Export des pages hébergeant le module
|
|
||||||
$pageParam[$pageId] = $this->getData(['page',$pageId]);
|
|
||||||
// Export du contenu de la page
|
|
||||||
//$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content']));
|
|
||||||
$pageContent[$pageId] = $this->getPage($pageId, self::$i18n);
|
|
||||||
// Export de base/module.json
|
|
||||||
$moduleId = 'base/module.json';
|
|
||||||
$moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);
|
|
||||||
// Création de l'arborescence des langues
|
|
||||||
// Pas de nom dossier de langue - dossier par défaut
|
|
||||||
$t = explode ('/',$moduleId);
|
|
||||||
if ( is_array($t)) {
|
|
||||||
$lang = 'base';
|
|
||||||
} else {
|
|
||||||
$lang = $t[0];
|
|
||||||
}
|
|
||||||
// Créer le dossier temporaire si inexistant sinon le nettoyer et le créer
|
|
||||||
if (!is_dir($tmpFolder . '/' . $lang)) {
|
|
||||||
mkdir ($tmpFolder . '/' . $lang, 0755, true);
|
|
||||||
} else {
|
|
||||||
$this->removeDir($tmpFolder . '/' . $lang);
|
|
||||||
mkdir ($tmpFolder . '/' . $lang, 0755, true);
|
|
||||||
}
|
|
||||||
// Créer le dossier temporaire des données du module
|
|
||||||
if ($infoModules[$this->getUrl(2)]['dataDirectory']) {
|
|
||||||
if (!is_dir($tmpFolder . '/' . $moduleDir)) {
|
|
||||||
mkdir ($tmpFolder . '/' . $moduleDir, 0755, true) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Sauvegarde si données non vides
|
|
||||||
$tmpData [$pageId] = $this->getData(['module',$pageId ]);
|
|
||||||
if ($tmpData [$pageId] !== null) {
|
|
||||||
file_put_contents($tmpFolder . '/' . $moduleId, json_encode($tmpData));
|
|
||||||
}
|
|
||||||
// Export des données localisées dans le dossier de données du module
|
|
||||||
if ($infoModules[$this->getUrl(2)]['dataDirectory'] &&
|
|
||||||
is_dir($infoModules[$this->getUrl(2)]['dataDirectory'])) {
|
|
||||||
$this->copyDir ($infoModules[$this->getUrl(2)]['dataDirectory'], $tmpFolder . '/' . $moduleDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Enregistrement des pages dans le dossier de langue identique à module
|
|
||||||
if (!file_exists($tmpFolder . '/' . $lang . '/page.json')) {
|
|
||||||
file_put_contents($tmpFolder . '/' . $lang . '/page.json', json_encode($pageParam));
|
|
||||||
mkdir ($tmpFolder . '/' . $lang . '/content', 0755);
|
|
||||||
file_put_contents($tmpFolder . '/' . $lang . '/content/' . $this->getData(['page', $pageId, 'content']), $pageContent);
|
|
||||||
}
|
|
||||||
// création du zip
|
|
||||||
$fileName = $this->getUrl(2) . '.zip';
|
|
||||||
$this->makeZip ($fileName, $tmpFolder, []);
|
|
||||||
if (file_exists($fileName)) {
|
|
||||||
ob_start();
|
|
||||||
header('Content-Type: application/octet-stream');
|
|
||||||
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
|
||||||
header('Content-Length: ' . filesize($fileName));
|
|
||||||
ob_clean();
|
|
||||||
ob_end_flush();
|
|
||||||
readfile( $fileName);
|
|
||||||
unlink($fileName);
|
|
||||||
$this->removeDir($tmpFolder);
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
'notification' => $text['core_addon']['export'][1],
|
'state' => false,
|
||||||
'state' => false
|
'notification' => $text['core_addon']['export'][0]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Lire les données du module
|
||||||
|
$infoModules = helper::getModules();
|
||||||
|
// Créer un dossier par défaut
|
||||||
|
$tmpFolder = self::TEMP_DIR . uniqid();
|
||||||
|
//$tmpFolder = self::TEMP_DIR . 'test';
|
||||||
|
if (!is_dir($tmpFolder)) {
|
||||||
|
mkdir($tmpFolder, 0755);
|
||||||
|
}
|
||||||
|
// Clés moduleIds dans les pages
|
||||||
|
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
||||||
|
// Parcourir les pages utilisant le module
|
||||||
|
foreach (array_keys($inPages,$this->getUrl(2)) as $pageId) {
|
||||||
|
// Export des pages hébergeant le module
|
||||||
|
$pageParam[$pageId] = $this->getData(['page',$pageId]);
|
||||||
|
// Export du contenu de la page
|
||||||
|
//$pageContent[$pageId] = file_get_contents(self::DATA_DIR . self::$i18n . '/content/' . $this->getData(['page', $pageId, 'content']));
|
||||||
|
$pageContent[$pageId] = $this->getPage($pageId, self::$i18n);
|
||||||
|
// Export de base/module.json
|
||||||
|
$moduleId = 'base/module.json';
|
||||||
|
$moduleDir = str_replace('site/data/','',$infoModules[$this->getUrl(2)]['dataDirectory']);
|
||||||
|
// Création de l'arborescence des langues
|
||||||
|
// Pas de nom dossier de langue - dossier par défaut
|
||||||
|
$t = explode ('/',$moduleId);
|
||||||
|
if ( is_array($t)) {
|
||||||
|
$lang = 'base';
|
||||||
|
} else {
|
||||||
|
$lang = $t[0];
|
||||||
|
}
|
||||||
|
// Créer le dossier temporaire si inexistant sinon le nettoyer et le créer
|
||||||
|
if (!is_dir($tmpFolder . '/' . $lang)) {
|
||||||
|
mkdir ($tmpFolder . '/' . $lang, 0755, true);
|
||||||
|
} else {
|
||||||
|
$this->removeDir($tmpFolder . '/' . $lang);
|
||||||
|
mkdir ($tmpFolder . '/' . $lang, 0755, true);
|
||||||
|
}
|
||||||
|
// Créer le dossier temporaire des données du module
|
||||||
|
if ($infoModules[$this->getUrl(2)]['dataDirectory']) {
|
||||||
|
if (!is_dir($tmpFolder . '/' . $moduleDir)) {
|
||||||
|
mkdir ($tmpFolder . '/' . $moduleDir, 0755, true) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Sauvegarde si données non vides
|
||||||
|
$tmpData [$pageId] = $this->getData(['module',$pageId ]);
|
||||||
|
if ($tmpData [$pageId] !== null) {
|
||||||
|
file_put_contents($tmpFolder . '/' . $moduleId, json_encode($tmpData));
|
||||||
|
}
|
||||||
|
// Export des données localisées dans le dossier de données du module
|
||||||
|
if ($infoModules[$this->getUrl(2)]['dataDirectory'] &&
|
||||||
|
is_dir($infoModules[$this->getUrl(2)]['dataDirectory'])) {
|
||||||
|
$this->copyDir ($infoModules[$this->getUrl(2)]['dataDirectory'], $tmpFolder . '/' . $moduleDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Enregistrement des pages dans le dossier de langue identique à module
|
||||||
|
if (!file_exists($tmpFolder . '/' . $lang . '/page.json')) {
|
||||||
|
file_put_contents($tmpFolder . '/' . $lang . '/page.json', json_encode($pageParam));
|
||||||
|
mkdir ($tmpFolder . '/' . $lang . '/content', 0755);
|
||||||
|
file_put_contents($tmpFolder . '/' . $lang . '/content/' . $this->getData(['page', $pageId, 'content']), $pageContent);
|
||||||
|
}
|
||||||
|
// création du zip
|
||||||
|
$fileName = $this->getUrl(2) . '.zip';
|
||||||
|
$this->makeZip ($fileName, $tmpFolder, []);
|
||||||
|
if (file_exists($fileName)) {
|
||||||
|
ob_start();
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
||||||
|
header('Content-Length: ' . filesize($fileName));
|
||||||
|
ob_clean();
|
||||||
|
ob_end_flush();
|
||||||
|
readfile( $fileName);
|
||||||
|
unlink($fileName);
|
||||||
|
$this->removeDir($tmpFolder);
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
|
'notification' => $text['core_addon']['export'][1],
|
||||||
|
'state' => false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,94 +584,104 @@ class addon extends common {
|
||||||
* Importer des données d'un module externes ou interne à module.json
|
* Importer des données d'un module externes ou interne à module.json
|
||||||
*/
|
*/
|
||||||
public function import(){
|
public function import(){
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Jeton incorrect
|
if( $group < addon::$actions['import'] ) {
|
||||||
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
'access' => false
|
||||||
'state' => false,
|
|
||||||
'notification' => $text['core_addon']['import'][0]
|
|
||||||
]);
|
]);
|
||||||
}
|
} else {
|
||||||
else {
|
// Lexique
|
||||||
// Soumission du formulaire
|
include('./core/module/addon/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_addon.php');
|
||||||
if($this->isPost()) {
|
|
||||||
// Récupérer le fichier et le décompacter
|
// Jeton incorrect
|
||||||
$zipFilename = $this->getInput('addonImportFile', helper::FILTER_STRING_SHORT, true);
|
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
$tempFolder = uniqid();
|
// Valeurs en sortie
|
||||||
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
$this->addOutput([
|
||||||
$zip = new ZipArchive();
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
|
'state' => false,
|
||||||
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
'notification' => $text['core_addon']['import'][0]
|
||||||
}
|
]);
|
||||||
// Import des données localisées page.json et module.json
|
}
|
||||||
// Pour chaque dossier localisé
|
else {
|
||||||
$dataTarget = array();
|
// Soumission du formulaire
|
||||||
$dataSource = array();
|
if($this->isPost()) {
|
||||||
// Liste des pages de même nom dans l'archive et le site
|
// Récupérer le fichier et le décompacter
|
||||||
$list = '';
|
$zipFilename = $this->getInput('addonImportFile', helper::FILTER_STRING_SHORT, true);
|
||||||
// Tableau des langues avec langue originale
|
$tempFolder = uniqid();
|
||||||
$origin = ['base'=>'Langue originale'];
|
mkdir (self::TEMP_DIR . $tempFolder, 0755);
|
||||||
$i18nListComplet = array_merge( self::$i18nList, $origin);
|
$zip = new ZipArchive();
|
||||||
foreach ($i18nListComplet as $key=>$value) {
|
if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
|
||||||
// Les Pages et les modules
|
$zip->extractTo(self::TEMP_DIR . $tempFolder );
|
||||||
foreach (['page','module'] as $fileTarget){
|
}
|
||||||
if (file_exists(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json')) {
|
// Import des données localisées page.json et module.json
|
||||||
// Le dossier de langue existe
|
// Pour chaque dossier localisé
|
||||||
// faire la fusion
|
$dataTarget = array();
|
||||||
$dataSource = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json'), true);
|
$dataSource = array();
|
||||||
// Des pages de même nom que celles de l'archive existent
|
// Liste des pages de même nom dans l'archive et le site
|
||||||
if( $fileTarget === 'page' ){
|
$list = '';
|
||||||
foreach( $dataSource as $keydataSource=>$valuedataSource ){
|
// Tableau des langues avec langue originale
|
||||||
foreach( $this->getData(['page']) as $keypage=>$valuepage ){
|
$origin = ['base'=>'Langue originale'];
|
||||||
if( $keydataSource === $keypage){
|
$i18nListComplet = array_merge( self::$i18nList, $origin);
|
||||||
$list === '' ? $list .= ' '.$this->getData(['page', $keypage, 'title']) : $list .= ', '.$this->getData(['page', $keypage, 'title']);
|
foreach ($i18nListComplet as $key=>$value) {
|
||||||
|
// Les Pages et les modules
|
||||||
|
foreach (['page','module'] as $fileTarget){
|
||||||
|
if (file_exists(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json')) {
|
||||||
|
// Le dossier de langue existe
|
||||||
|
// faire la fusion
|
||||||
|
$dataSource = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json'), true);
|
||||||
|
// Des pages de même nom que celles de l'archive existent
|
||||||
|
if( $fileTarget === 'page' ){
|
||||||
|
foreach( $dataSource as $keydataSource=>$valuedataSource ){
|
||||||
|
foreach( $this->getData(['page']) as $keypage=>$valuepage ){
|
||||||
|
if( $keydataSource === $keypage){
|
||||||
|
$list === '' ? $list .= ' '.$this->getData(['page', $keypage, 'title']) : $list .= ', '.$this->getData(['page', $keypage, 'title']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$dataTarget = json_decode(file_get_contents(self::DATA_DIR . $key . '/' . $fileTarget . '.json'), true);
|
||||||
|
$data [$fileTarget] = array_merge($dataTarget[$fileTarget], $dataSource);
|
||||||
|
if( $list === ''){
|
||||||
|
file_put_contents(self::DATA_DIR . '/' .$key . '/' . $fileTarget . '.json', json_encode( $data ,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|LOCK_EX) );
|
||||||
|
}
|
||||||
|
// copie du contenu de la page
|
||||||
|
$this->copyDir (self::TEMP_DIR . $tempFolder . '/' .$key . '/content', self::DATA_DIR . '/' .$key . '/content');
|
||||||
|
// Supprimer les fichiers importés
|
||||||
|
unlink (self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json');
|
||||||
}
|
}
|
||||||
$dataTarget = json_decode(file_get_contents(self::DATA_DIR . $key . '/' . $fileTarget . '.json'), true);
|
|
||||||
$data [$fileTarget] = array_merge($dataTarget[$fileTarget], $dataSource);
|
|
||||||
if( $list === ''){
|
|
||||||
file_put_contents(self::DATA_DIR . '/' .$key . '/' . $fileTarget . '.json', json_encode( $data ,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|LOCK_EX) );
|
|
||||||
}
|
|
||||||
// copie du contenu de la page
|
|
||||||
$this->copyDir (self::TEMP_DIR . $tempFolder . '/' .$key . '/content', self::DATA_DIR . '/' .$key . '/content');
|
|
||||||
// Supprimer les fichiers importés
|
|
||||||
unlink (self::TEMP_DIR . $tempFolder . '/' .$key . '/' . $fileTarget . '.json');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Import des fichiers placés ailleurs que dans les dossiers localisés.
|
// Import des fichiers placés ailleurs que dans les dossiers localisés.
|
||||||
$this->copyDir (self::TEMP_DIR . $tempFolder,self::DATA_DIR );
|
$this->copyDir (self::TEMP_DIR . $tempFolder,self::DATA_DIR );
|
||||||
|
|
||||||
// Supprimer le dossier temporaire
|
// Supprimer le dossier temporaire
|
||||||
$this->removeDir(self::TEMP_DIR . $tempFolder);
|
$this->removeDir(self::TEMP_DIR . $tempFolder);
|
||||||
$zip->close();
|
$zip->close();
|
||||||
if( $list !== '' ){
|
if( $list !== '' ){
|
||||||
$success = false;
|
$success = false;
|
||||||
strpos( $list, ',') === false ? $notification = $text['core_addon']['import'][1].$list : $notification = $text['core_addon']['import'][2].$list;
|
strpos( $list, ',') === false ? $notification = $text['core_addon']['import'][1].$list : $notification = $text['core_addon']['import'][2].$list;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$success = true;
|
$success = true;
|
||||||
$notification = $text['core_addon']['import'][3];
|
$notification = $text['core_addon']['import'][3];
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'addon',
|
||||||
|
'state' => $success,
|
||||||
|
'notification' => $notification
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . 'addon',
|
'title' => $text['core_addon']['import'][4],
|
||||||
'state' => $success,
|
'view' => 'import'
|
||||||
'notification' => $notification
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_addon']['import'][4],
|
|
||||||
'view' => 'import'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -205,114 +205,124 @@ class install extends common {
|
||||||
* Étapes de mise à jour
|
* Étapes de mise à jour
|
||||||
*/
|
*/
|
||||||
public function steps() {
|
public function steps() {
|
||||||
switch($this->getInput('step', helper::FILTER_INT)) {
|
// Autorisation
|
||||||
// Préparation
|
$group = $this->getUser('group');
|
||||||
case 1:
|
if ($group === false ) $group = 0;
|
||||||
$success = true;
|
if( $group < install::$actions['steps'] ) {
|
||||||
// RAZ la mise à jour auto
|
// Valeurs en sortie
|
||||||
$this->setData(['core','updateAvailable', false]);
|
$this->addOutput([
|
||||||
// Backup du dossier Data
|
'access' => false
|
||||||
helper::autoBackup(self::BACKUP_DIR,['backup','tmp','file']);
|
]);
|
||||||
// Sauvegarde htaccess
|
} else {
|
||||||
if ($this->getData(['config','autoUpdateHtaccess'])) {
|
switch($this->getInput('step', helper::FILTER_INT)) {
|
||||||
$success = copy('.htaccess', '.htaccess' . '.bak');
|
// Préparation
|
||||||
}
|
case 1:
|
||||||
// Nettoyage des fichiers d'installation précédents
|
$success = true;
|
||||||
if(file_exists(self::TEMP_DIR.'update.tar.gz') && $success) {
|
// RAZ la mise à jour auto
|
||||||
$success = unlink(self::TEMP_DIR.'update.tar.gz');
|
$this->setData(['core','updateAvailable', false]);
|
||||||
}
|
// Backup du dossier Data
|
||||||
if(file_exists(self::TEMP_DIR.'update.tar') && $success) {
|
helper::autoBackup(self::BACKUP_DIR,['backup','tmp','file']);
|
||||||
$success = unlink(self::TEMP_DIR.'update.tar');
|
// Sauvegarde htaccess
|
||||||
}
|
if ($this->getData(['config','autoUpdateHtaccess'])) {
|
||||||
// Valeurs en sortie
|
$success = copy('.htaccess', '.htaccess' . '.bak');
|
||||||
$this->addOutput([
|
}
|
||||||
'display' => self::DISPLAY_JSON,
|
// Nettoyage des fichiers d'installation précédents
|
||||||
'content' => [
|
if(file_exists(self::TEMP_DIR.'update.tar.gz') && $success) {
|
||||||
'success' => $success,
|
$success = unlink(self::TEMP_DIR.'update.tar.gz');
|
||||||
'data' => null
|
}
|
||||||
]
|
if(file_exists(self::TEMP_DIR.'update.tar') && $success) {
|
||||||
]);
|
$success = unlink(self::TEMP_DIR.'update.tar');
|
||||||
break;
|
}
|
||||||
// Téléchargement
|
// Valeurs en sortie
|
||||||
case 2:
|
$this->addOutput([
|
||||||
$success = (file_put_contents(self::TEMP_DIR.'update.tar.gz', helper::urlGetContents(common::DELTA_UPDATE_URL . common::DELTA_UPDATE_CHANNEL . '/update.tar.gz')) !== false);
|
'display' => self::DISPLAY_JSON,
|
||||||
// Valeurs en sortie
|
'content' => [
|
||||||
$this->addOutput([
|
'success' => $success,
|
||||||
'display' => self::DISPLAY_JSON,
|
'data' => null
|
||||||
'content' => [
|
]
|
||||||
'success' => $success,
|
]);
|
||||||
'data' => null
|
break;
|
||||||
]
|
// Téléchargement
|
||||||
]);
|
case 2:
|
||||||
break;
|
$success = (file_put_contents(self::TEMP_DIR.'update.tar.gz', helper::urlGetContents(common::DELTA_UPDATE_URL . common::DELTA_UPDATE_CHANNEL . '/update.tar.gz')) !== false);
|
||||||
// Installation
|
// Valeurs en sortie
|
||||||
case 3:
|
$this->addOutput([
|
||||||
$success = true;
|
'display' => self::DISPLAY_JSON,
|
||||||
// Check la réécriture d'URL avant d'écraser les fichiers
|
'content' => [
|
||||||
$rewrite = helper::checkRewrite();
|
'success' => $success,
|
||||||
// Décompression et installation
|
'data' => null
|
||||||
try {
|
]
|
||||||
// Décompression dans le dossier de fichier temporaires
|
]);
|
||||||
$pharData = new PharData(self::TEMP_DIR.'update.tar.gz');
|
break;
|
||||||
$pharData->decompress();
|
// Installation
|
||||||
// Installation
|
case 3:
|
||||||
$pharData->extractTo(__DIR__ . '/../../../', null, true);
|
$success = true;
|
||||||
} catch (Exception $e) {
|
// Check la réécriture d'URL avant d'écraser les fichiers
|
||||||
$success = $e->getMessage();
|
$rewrite = helper::checkRewrite();
|
||||||
}
|
// Décompression et installation
|
||||||
// Nettoyage du dossier
|
try {
|
||||||
if(file_exists(self::TEMP_DIR.'update.tar.gz')) {
|
// Décompression dans le dossier de fichier temporaires
|
||||||
unlink(self::TEMP_DIR.'update.tar.gz');
|
$pharData = new PharData(self::TEMP_DIR.'update.tar.gz');
|
||||||
}
|
$pharData->decompress();
|
||||||
if(file_exists(self::TEMP_DIR.'update.tar')) {
|
// Installation
|
||||||
unlink(self::TEMP_DIR.'update.tar');
|
$pharData->extractTo(__DIR__ . '/../../../', null, true);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
// Valeurs en sortie
|
$success = $e->getMessage();
|
||||||
$this->addOutput([
|
}
|
||||||
'display' => self::DISPLAY_JSON,
|
// Nettoyage du dossier
|
||||||
'content' => [
|
if(file_exists(self::TEMP_DIR.'update.tar.gz')) {
|
||||||
'success' => $success,
|
unlink(self::TEMP_DIR.'update.tar.gz');
|
||||||
'data' => $rewrite
|
}
|
||||||
]
|
if(file_exists(self::TEMP_DIR.'update.tar')) {
|
||||||
]);
|
unlink(self::TEMP_DIR.'update.tar');
|
||||||
break;
|
}
|
||||||
// Configuration
|
// Valeurs en sortie
|
||||||
case 4:
|
$this->addOutput([
|
||||||
$success = true;
|
'display' => self::DISPLAY_JSON,
|
||||||
$rewrite = $this->getInput('data');
|
'content' => [
|
||||||
// Réécriture d'URL
|
'success' => $success,
|
||||||
if ($rewrite === "true") {
|
'data' => $rewrite
|
||||||
$success = (file_put_contents(
|
]
|
||||||
'.htaccess',
|
]);
|
||||||
PHP_EOL .
|
break;
|
||||||
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
// Configuration
|
||||||
"\tRewriteEngine on" . PHP_EOL .
|
case 4:
|
||||||
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
$success = true;
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
$rewrite = $this->getInput('data');
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
// Réécriture d'URL
|
||||||
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
if ($rewrite === "true") {
|
||||||
'</IfModule>',
|
$success = (file_put_contents(
|
||||||
FILE_APPEND
|
'.htaccess',
|
||||||
) !== false);
|
PHP_EOL .
|
||||||
}
|
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
||||||
// Recopie htaccess
|
"\tRewriteEngine on" . PHP_EOL .
|
||||||
if ($this->getData(['config','autoUpdateHtaccess']) &&
|
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
||||||
$success && file_exists( '.htaccess.bak')
|
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
||||||
) {
|
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
||||||
// L'écraser avec le backup
|
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
||||||
$success = copy( '.htaccess.bak' ,'.htaccess' );
|
'</IfModule>',
|
||||||
// Effacer l ebackup
|
FILE_APPEND
|
||||||
unlink('.htaccess.bak');
|
) !== false);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Recopie htaccess
|
||||||
$this->addOutput([
|
if ($this->getData(['config','autoUpdateHtaccess']) &&
|
||||||
'display' => self::DISPLAY_JSON,
|
$success && file_exists( '.htaccess.bak')
|
||||||
'content' => [
|
) {
|
||||||
'success' => $success,
|
// L'écraser avec le backup
|
||||||
'data' => null
|
$success = copy( '.htaccess.bak' ,'.htaccess' );
|
||||||
]
|
// Effacer l ebackup
|
||||||
]);
|
unlink('.htaccess.bak');
|
||||||
break;
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'display' => self::DISPLAY_JSON,
|
||||||
|
'content' => [
|
||||||
|
'success' => $success,
|
||||||
|
'data' => null
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,16 +330,26 @@ class install extends common {
|
||||||
* Mise à jour
|
* Mise à jour
|
||||||
*/
|
*/
|
||||||
public function update() {
|
public function update() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/install/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_install.php');
|
$group = $this->getUser('group');
|
||||||
// Nouvelle version
|
if ($group === false ) $group = 0;
|
||||||
self::$newVersion = helper::urlGetContents(common::DELTA_UPDATE_URL . common::DELTA_UPDATE_CHANNEL . '/version');
|
if( $group < install::$actions['update'] ) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
'access' => false
|
||||||
'title' => $text['core_install']['update'][0],
|
]);
|
||||||
'view' => 'update'
|
} else {
|
||||||
]);
|
// Lexique
|
||||||
|
include('./core/module/install/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_install.php');
|
||||||
|
// Nouvelle version
|
||||||
|
self::$newVersion = helper::urlGetContents(common::DELTA_UPDATE_URL . common::DELTA_UPDATE_CHANNEL . '/version');
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'display' => self::DISPLAY_LAYOUT_LIGHT,
|
||||||
|
'title' => $text['core_install']['update'][0],
|
||||||
|
'view' => 'update'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ $text['core_page_view']['edit'][43] = " will be deleted. Do you confirm?";
|
||||||
$text['core_page_view']['edit'][44] = "Group required to edit the page :";
|
$text['core_page_view']['edit'][44] = "Group required to edit the page :";
|
||||||
$text['core_page_view']['edit'][45] = "You do not have editing rights, contact an administrator.";
|
$text['core_page_view']['edit'][45] = "You do not have editing rights, contact an administrator.";
|
||||||
$text['core_page']['duplicate'][0] = "Invalid token";
|
$text['core_page']['duplicate'][0] = "Invalid token";
|
||||||
$text['core_page']['duplicate'][1] = "Unauthorized deletion";
|
$text['core_page']['duplicate'][1] = "Unauthorised duplication";
|
||||||
$text['core_page']['duplicate'][2] = "The page has been duplicated";
|
$text['core_page']['duplicate'][2] = "The page has been duplicated";
|
||||||
$text['core_page']['duplicate'][3] = "The page and its module have been duplicated";
|
$text['core_page']['duplicate'][3] = "The page and its module have been duplicated";
|
||||||
$text['core_page']['add'][0] = "New page";
|
$text['core_page']['add'][0] = "New page";
|
||||||
|
|
|
@ -47,7 +47,7 @@ $text['core_page_view']['edit'][43] = "será eliminado. ¿Confirmas?";
|
||||||
$text['core_page_view']['edit'][44] = "Se requiere grupo para editar la página:";
|
$text['core_page_view']['edit'][44] = "Se requiere grupo para editar la página:";
|
||||||
$text['core_page_view']['edit'][45] = "No tiene derechos de edición, póngase en contacto con un administrador.";
|
$text['core_page_view']['edit'][45] = "No tiene derechos de edición, póngase en contacto con un administrador.";
|
||||||
$text['core_page']['duplicate'][0] = "Token no válido";
|
$text['core_page']['duplicate'][0] = "Token no válido";
|
||||||
$text['core_page']['duplicate'][1] = "Eliminación no autorizada";
|
$text['core_page']['duplicate'][1] = "Duplicación no autorizada";
|
||||||
$text['core_page']['duplicate'][2] = "La página ha sido duplicada";
|
$text['core_page']['duplicate'][2] = "La página ha sido duplicada";
|
||||||
$text['core_page']['duplicate'][3] = "La página y su módulo han sido duplicados";
|
$text['core_page']['duplicate'][3] = "La página y su módulo han sido duplicados";
|
||||||
$text['core_page']['add'][0] = "Nueva página";
|
$text['core_page']['add'][0] = "Nueva página";
|
||||||
|
|
|
@ -47,7 +47,7 @@ $text['core_page_view']['edit'][43] = " seront effacées. Confirmez-vous ?";
|
||||||
$text['core_page_view']['edit'][44] = "Groupe requis pour modifier la page :";
|
$text['core_page_view']['edit'][44] = "Groupe requis pour modifier la page :";
|
||||||
$text['core_page_view']['edit'][45] = "Vous n'avez pas les droits d'édition, contactez un administrateur.";
|
$text['core_page_view']['edit'][45] = "Vous n'avez pas les droits d'édition, contactez un administrateur.";
|
||||||
$text['core_page']['duplicate'][0] = "Jeton invalide";
|
$text['core_page']['duplicate'][0] = "Jeton invalide";
|
||||||
$text['core_page']['duplicate'][1] = "Suppression non autorisée";
|
$text['core_page']['duplicate'][1] = "Duplication non autorisée";
|
||||||
$text['core_page']['duplicate'][2] = "La page a été dupliquée";
|
$text['core_page']['duplicate'][2] = "La page a été dupliquée";
|
||||||
$text['core_page']['duplicate'][3] = "La page et son module ont été dupliqués";
|
$text['core_page']['duplicate'][3] = "La page et son module ont été dupliqués";
|
||||||
$text['core_page']['add'][0] = "Nouvelle page";
|
$text['core_page']['add'][0] = "Nouvelle page";
|
||||||
|
|
|
@ -33,59 +33,70 @@ class page extends common {
|
||||||
* Duplication
|
* Duplication
|
||||||
*/
|
*/
|
||||||
public function duplicate() {
|
public function duplicate() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
$group = $this->getUser('group');
|
||||||
// Adresse sans le token
|
if ($group === false ) $group = 0;
|
||||||
$url = explode('&',$this->getUrl(2));
|
if( $group < page::$actions['duplicate'] ) {
|
||||||
// La page n'existe pas
|
|
||||||
if($this->getData(['page', $url[0]]) === null) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'access' => false
|
'access' => false
|
||||||
]);
|
]);
|
||||||
} // Jeton incorrect
|
} else {
|
||||||
elseif(!isset($_GET['csrf'])) {
|
// Lexique
|
||||||
// Valeurs en sortie
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
||||||
$this->addOutput([
|
// Adresse sans le token
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
$url = explode('&',$this->getUrl(2));
|
||||||
'notification' => $text['core_page']['duplicate'][0]
|
// La page n'existe pas
|
||||||
]);
|
if($this->getData(['page', $url[0]]) === null) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
} // Jeton incorrect
|
||||||
|
elseif(!isset($_GET['csrf'])) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
|
'notification' => $text['core_page']['duplicate'][0]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
|
'notification' => $text['core_page']['duplicate'][1]
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Duplication de la page
|
||||||
|
$pageTitle = $this->getData(['page',$url[0],'title']);
|
||||||
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
||||||
|
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
||||||
|
$pageId = helper::increment($pageId, self::$moduleIds);
|
||||||
|
$data = $this->getData([
|
||||||
|
'page',
|
||||||
|
$url[0]
|
||||||
|
]);
|
||||||
|
// Ecriture
|
||||||
|
$this->setData (['page',$pageId,$data]);
|
||||||
|
$notification = $text['core_page']['duplicate'][2];
|
||||||
|
// Duplication du module présent
|
||||||
|
if ($this->getData(['page',$url[0],'moduleId'])) {
|
||||||
|
$data = $this->getData([
|
||||||
|
'module',
|
||||||
|
$url[0]
|
||||||
|
]);
|
||||||
|
// Ecriture
|
||||||
|
$this->setData (['module',$pageId,$data]);
|
||||||
|
$notification = $text['core_page']['duplicate'][3];
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
||||||
|
'notification' => $notification,
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
|
||||||
'notification' => $text['core_page']['duplicate'][1]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Duplication de la page
|
|
||||||
$pageTitle = $this->getData(['page',$url[0],'title']);
|
|
||||||
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
|
||||||
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
|
||||||
$pageId = helper::increment($pageId, self::$moduleIds);
|
|
||||||
$data = $this->getData([
|
|
||||||
'page',
|
|
||||||
$url[0]
|
|
||||||
]);
|
|
||||||
// Ecriture
|
|
||||||
$this->setData (['page',$pageId,$data]);
|
|
||||||
$notification = $text['core_page']['duplicate'][2];
|
|
||||||
// Duplication du module présent
|
|
||||||
if ($this->getData(['page',$url[0],'moduleId'])) {
|
|
||||||
$data = $this->getData([
|
|
||||||
'module',
|
|
||||||
$url[0]
|
|
||||||
]);
|
|
||||||
// Ecriture
|
|
||||||
$this->setData (['module',$pageId,$data]);
|
|
||||||
$notification = $text['core_page']['duplicate'][3];
|
|
||||||
}
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $pageId,
|
|
||||||
'notification' => $notification,
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,184 +104,204 @@ class page extends common {
|
||||||
* Création
|
* Création
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
$group = $this->getUser('group');
|
||||||
$pageTitle = $text['core_page']['add'][0];
|
if ($group === false ) $group = 0;
|
||||||
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
if( $group < page::$actions['add'] ) {
|
||||||
$this->setData([
|
// Valeurs en sortie
|
||||||
'page',
|
$this->addOutput([
|
||||||
$pageId,
|
'access' => false
|
||||||
[
|
]);
|
||||||
'typeMenu' => 'text',
|
} else {
|
||||||
'iconUrl' => '',
|
// Lexique
|
||||||
'disable' => false,
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
||||||
'content' => $pageId . '.html',
|
$pageTitle = $text['core_page']['add'][0];
|
||||||
'hideTitle' => false,
|
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
|
||||||
'breadCrumb' => false,
|
$this->setData([
|
||||||
'metaDescription' => '',
|
'page',
|
||||||
'metaTitle' => '',
|
$pageId,
|
||||||
'moduleId' => '',
|
[
|
||||||
'parentPageId' => '',
|
'typeMenu' => 'text',
|
||||||
'modulePosition' => 'bottom',
|
'iconUrl' => '',
|
||||||
'position' => 100,
|
'disable' => false,
|
||||||
'group' => self::GROUP_VISITOR,
|
'content' => $pageId . '.html',
|
||||||
'targetBlank' => false,
|
'hideTitle' => false,
|
||||||
'title' => $pageTitle,
|
'breadCrumb' => false,
|
||||||
'shortTitle' => $pageTitle,
|
'metaDescription' => '',
|
||||||
'block' => '12',
|
'metaTitle' => '',
|
||||||
'barLeft' => '',
|
'moduleId' => '',
|
||||||
'barRight' => '',
|
'parentPageId' => '',
|
||||||
'displayMenu' => '0',
|
'modulePosition' => 'bottom',
|
||||||
'hideMenuSide' => false,
|
'position' => 100,
|
||||||
'hideMenuHead' => false,
|
'group' => self::GROUP_VISITOR,
|
||||||
'hideMenuChildren' => false
|
'targetBlank' => false,
|
||||||
]
|
'title' => $pageTitle,
|
||||||
]);
|
'shortTitle' => $pageTitle,
|
||||||
// Creation du contenu de la page
|
'block' => '12',
|
||||||
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
|
'barLeft' => '',
|
||||||
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
|
'barRight' => '',
|
||||||
|
'displayMenu' => '0',
|
||||||
|
'hideMenuSide' => false,
|
||||||
|
'hideMenuHead' => false,
|
||||||
|
'hideMenuChildren' => false
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
// Creation du contenu de la page
|
||||||
|
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
|
||||||
|
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
|
||||||
|
}
|
||||||
|
$this->setPage($pageId, '<p>'.$text['core_page']['add'][1].'</p>', self::$i18n);
|
||||||
|
// Met à jour le site map
|
||||||
|
// $this->createSitemap('all');
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . $pageId,
|
||||||
|
'notification' => $text['core_page']['add'][2],
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
$this->setPage($pageId, '<p>'.$text['core_page']['add'][1].'</p>', self::$i18n);
|
|
||||||
// Met à jour le site map
|
|
||||||
// $this->createSitemap('all');
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . $pageId,
|
|
||||||
'notification' => $text['core_page']['add'][2],
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suppression
|
* Suppression
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
$group = $this->getUser('group');
|
||||||
// $url prend l'adresse sans le token
|
if ($group === false ) $group = 0;
|
||||||
$url = explode('&',$this->getUrl(2));
|
if( $group < page::$actions['delete'] ) {
|
||||||
// La page n'existe pas
|
|
||||||
if($this->getData(['page', $url[0]]) === null) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'access' => false
|
'access' => false
|
||||||
]);
|
]);
|
||||||
} // Jeton incorrect
|
} else {
|
||||||
elseif(!isset($_GET['csrf'])) {
|
// Lexique
|
||||||
// Valeurs en sortie
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
||||||
$this->addOutput([
|
// $url prend l'adresse sans le token
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
$url = explode('&',$this->getUrl(2));
|
||||||
'notification' => $text['core_page']['delete'][0]
|
// La page n'existe pas
|
||||||
]);
|
if($this->getData(['page', $url[0]]) === null) {
|
||||||
}
|
// Valeurs en sortie
|
||||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
$this->addOutput([
|
||||||
// Valeurs en sortie
|
'access' => false
|
||||||
$this->addOutput([
|
]);
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
} // Jeton incorrect
|
||||||
'notification' => $text['core_page']['delete'][1]
|
elseif(!isset($_GET['csrf'])) {
|
||||||
]);
|
// Valeurs en sortie
|
||||||
}
|
$this->addOutput([
|
||||||
// Impossible de supprimer la page d'accueil
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
elseif($url[0] === $this->getData(['locale', 'homePageId'])) {
|
'notification' => $text['core_page']['delete'][0]
|
||||||
// Valeurs en sortie
|
]);
|
||||||
$this->addOutput([
|
}
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
// Impossible de supprimer la page de recherche affectée
|
'notification' => $text['core_page']['delete'][1]
|
||||||
elseif($url[0] === $this->getData(['locale', 'searchPageId'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page d'accueil
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif($url[0] === $this->getData(['locale', 'homePageId'])) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
// Impossible de supprimer la page des mentions légales affectée
|
'notification' => $text['core_page']['delete'][2]
|
||||||
elseif($url[0] === $this->getData(['locale', 'legalPageId'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page de recherche affectée
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif($url[0] === $this->getData(['locale', 'searchPageId'])) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
// Impossible de supprimer la page des mentions légales affectée
|
'notification' => $text['core_page']['delete'][2]
|
||||||
elseif($url[0] === $this->getData(['locale', 'page404'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page des mentions légales affectée
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif($url[0] === $this->getData(['locale', 'legalPageId'])) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
// Impossible de supprimer la page des mentions légales affectée
|
'notification' => $text['core_page']['delete'][2]
|
||||||
elseif($url[0] === $this->getData(['locale', 'page403'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page des mentions légales affectée
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif($url[0] === $this->getData(['locale', 'page404'])) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
// Impossible de supprimer la page des mentions légales affectée
|
'notification' => $text['core_page']['delete'][2]
|
||||||
elseif($url[0] === $this->getData(['locale', 'page302'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page des mentions légales affectée
|
||||||
'redirect' => helper::baseUrl() . 'config',
|
elseif($url[0] === $this->getData(['locale', 'page403'])) {
|
||||||
'notification' => $text['core_page']['delete'][2]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
// Jeton incorrect
|
'notification' => $text['core_page']['delete'][2]
|
||||||
elseif(!isset($_GET['csrf'])) {
|
]);
|
||||||
// Valeurs en sortie
|
}
|
||||||
$this->addOutput([
|
// Impossible de supprimer la page des mentions légales affectée
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
elseif($url[0] === $this->getData(['locale', 'page302'])) {
|
||||||
'notification' => $text['core_page']['delete'][0]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'config',
|
||||||
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
'notification' => $text['core_page']['delete'][2]
|
||||||
// Valeurs en sortie
|
]);
|
||||||
$this->addOutput([
|
}
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
// Jeton incorrect
|
||||||
'notification' => $text['core_page']['delete'][1]
|
elseif(!isset($_GET['csrf'])) {
|
||||||
]);
|
// Valeurs en sortie
|
||||||
}
|
$this->addOutput([
|
||||||
// Impossible de supprimer une page contenant des enfants
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
elseif($this->getHierarchy($url[0],null)) {
|
'notification' => $text['core_page']['delete'][0]
|
||||||
// Valeurs en sortie
|
]);
|
||||||
$this->addOutput([
|
}
|
||||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||||
'notification' => $text['core_page']['delete'][3]
|
// Valeurs en sortie
|
||||||
]);
|
$this->addOutput([
|
||||||
}
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
// Suppression
|
'notification' => $text['core_page']['delete'][1]
|
||||||
else {
|
]);
|
||||||
|
}
|
||||||
|
// Impossible de supprimer une page contenant des enfants
|
||||||
|
elseif($this->getHierarchy($url[0],null)) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||||
|
'notification' => $text['core_page']['delete'][3]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Suppression
|
||||||
|
else {
|
||||||
|
|
||||||
// Effacer le dossier du module
|
// Effacer le dossier du module
|
||||||
$moduleId = $this->getData(['page',$url[0],'moduleId']);
|
$moduleId = $this->getData(['page',$url[0],'moduleId']);
|
||||||
$modulesData = helper::getModules();
|
$modulesData = helper::getModules();
|
||||||
if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) {
|
if (is_dir($modulesData[$moduleId]['dataDirectory']. $url[0])) {
|
||||||
$this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] );
|
$this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] );
|
||||||
|
}
|
||||||
|
// Effacer la page
|
||||||
|
$this->deleteData(['page', $url[0]]);
|
||||||
|
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {
|
||||||
|
unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html');
|
||||||
|
}
|
||||||
|
$this->deleteData(['module', $url[0]]);
|
||||||
|
// Met à jour le site map
|
||||||
|
// $this->createSitemap('all');
|
||||||
|
// Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite
|
||||||
|
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
||||||
|
$statislite = 'off';
|
||||||
|
foreach($inPages as $key=>$value){
|
||||||
|
if( $value === 'statislite') $statislite = 'on';
|
||||||
|
}
|
||||||
|
if( $statislite === 'off') $this->setData(['config', 'statislite', 'enable', false ]);
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl(false),
|
||||||
|
'notification' => $text['core_page']['delete'][4],
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Effacer la page
|
|
||||||
$this->deleteData(['page', $url[0]]);
|
|
||||||
if (file_exists(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html')) {
|
|
||||||
unlink(self::DATA_DIR . self::$i18n . '/content/' . $url[0] . '.html');
|
|
||||||
}
|
|
||||||
$this->deleteData(['module', $url[0]]);
|
|
||||||
// Met à jour le site map
|
|
||||||
// $this->createSitemap('all');
|
|
||||||
// Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite
|
|
||||||
$inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC');
|
|
||||||
$statislite = 'off';
|
|
||||||
foreach($inPages as $key=>$value){
|
|
||||||
if( $value === 'statislite') $statislite = 'on';
|
|
||||||
}
|
|
||||||
if( $statislite === 'off') $this->setData(['config', 'statislite', 'enable', false ]);
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl(false),
|
|
||||||
'notification' => $text['core_page']['delete'][4],
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,221 +310,231 @@ class page extends common {
|
||||||
* Édition
|
* Édition
|
||||||
*/
|
*/
|
||||||
public function edit() {
|
public function edit() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
$group = $this->getUser('group');
|
||||||
// La page n'existe pas
|
if ($group === false ) $group = 0;
|
||||||
if($this->getData(['page', $this->getUrl(2)]) === null) {
|
if( $group < page::$actions['edit'] ) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'access' => false
|
'access' => false
|
||||||
]);
|
]);
|
||||||
}
|
} else {
|
||||||
// La page existe
|
// Lexique
|
||||||
else {
|
include('./core/module/page/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_page.php');
|
||||||
// Soumission du formulaire
|
// La page n'existe pas
|
||||||
if($this->isPost()) {
|
if($this->getData(['page', $this->getUrl(2)]) === null) {
|
||||||
// Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire
|
// Valeurs en sortie
|
||||||
if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){
|
$this->addOutput([
|
||||||
// Génére l'ID si le titre de la page a changé
|
'access' => false
|
||||||
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) {
|
]);
|
||||||
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
|
}
|
||||||
} else {
|
// La page existe
|
||||||
$pageId = $this->getUrl(2);
|
else {
|
||||||
}
|
// Soumission du formulaire
|
||||||
// un dossier existe du même nom (erreur en cas de redirection)
|
if($this->isPost()) {
|
||||||
if (file_exists($pageId)) {
|
// Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire
|
||||||
$pageId = uniqid($pageId);
|
if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){
|
||||||
}
|
// Génére l'ID si le titre de la page a changé
|
||||||
// Si l'id a changée
|
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) {
|
||||||
if ($pageId !== $this->getUrl(2)) {
|
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
|
||||||
// Incrémente le nouvel id de la page
|
} else {
|
||||||
$pageId = helper::increment($pageId, $this->getData(['page']));
|
$pageId = $this->getUrl(2);
|
||||||
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
|
||||||
$pageId = helper::increment($pageId, self::$moduleIds);
|
|
||||||
// Met à jour les enfants
|
|
||||||
foreach($this->getHierarchy($this->getUrl(2),null) as $childrenPageId) {
|
|
||||||
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
|
|
||||||
}
|
}
|
||||||
// Change l'id de page dans les données des modules
|
// un dossier existe du même nom (erreur en cas de redirection)
|
||||||
if ($this->getData(['module', $this->getUrl(2)]) !== null ) {
|
if (file_exists($pageId)) {
|
||||||
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
|
$pageId = uniqid($pageId);
|
||||||
$this->deleteData(['module', $this->getUrl(2)]);
|
}
|
||||||
// Renommer le dossier du module
|
// Si l'id a changée
|
||||||
$moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']);
|
if ($pageId !== $this->getUrl(2)) {
|
||||||
$modulesData = helper::getModules();
|
// Incrémente le nouvel id de la page
|
||||||
if (is_dir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2))) {
|
$pageId = helper::increment($pageId, $this->getData(['page']));
|
||||||
// Placer la feuille de style dans un dossier au nom de la nouvelle instance
|
$pageId = helper::increment($pageId, self::$coreModuleIds);
|
||||||
mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 );
|
$pageId = helper::increment($pageId, self::$moduleIds);
|
||||||
copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId);
|
// Met à jour les enfants
|
||||||
$this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2));
|
foreach($this->getHierarchy($this->getUrl(2),null) as $childrenPageId) {
|
||||||
// Mettre à jour le nom de la feuille de style
|
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
|
||||||
$this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]);
|
}
|
||||||
|
// Change l'id de page dans les données des modules
|
||||||
|
if ($this->getData(['module', $this->getUrl(2)]) !== null ) {
|
||||||
|
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
|
||||||
|
$this->deleteData(['module', $this->getUrl(2)]);
|
||||||
|
// Renommer le dossier du module
|
||||||
|
$moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']);
|
||||||
|
$modulesData = helper::getModules();
|
||||||
|
if (is_dir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2))) {
|
||||||
|
// Placer la feuille de style dans un dossier au nom de la nouvelle instance
|
||||||
|
mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 );
|
||||||
|
copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId);
|
||||||
|
$this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2));
|
||||||
|
// Mettre à jour le nom de la feuille de style
|
||||||
|
$this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
|
||||||
|
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {
|
||||||
|
$this->setData(['locale', 'homePageId', $pageId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site
|
// Supprime les données du module en cas de changement de module
|
||||||
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {
|
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
|
||||||
$this->setData(['locale', 'homePageId', $pageId]);
|
$this->deleteData(['module', $pageId]);
|
||||||
}
|
}
|
||||||
}
|
// Supprime l'ancienne page si l'id a changée
|
||||||
// Supprime les données du module en cas de changement de module
|
if($pageId !== $this->getUrl(2)) {
|
||||||
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
|
$this->deleteData(['page', $this->getUrl(2)]);
|
||||||
$this->deleteData(['module', $pageId]);
|
unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html');
|
||||||
}
|
|
||||||
// Supprime l'ancienne page si l'id a changée
|
|
||||||
if($pageId !== $this->getUrl(2)) {
|
|
||||||
$this->deleteData(['page', $this->getUrl(2)]);
|
|
||||||
unlink (self::DATA_DIR . self::$i18n . '/content/' . $this->getUrl(2) . '.html');
|
|
||||||
}
|
|
||||||
// Traitement des pages spéciales affectées dans la config :
|
|
||||||
if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) {
|
|
||||||
$this->setData(['locale','legalPageId', $pageId]);
|
|
||||||
}
|
|
||||||
if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) {
|
|
||||||
$this->setData(['locale','searchPageId', $pageId]);
|
|
||||||
}
|
|
||||||
if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) {
|
|
||||||
$this->setData(['locale','page404', $pageId]);
|
|
||||||
}
|
|
||||||
if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) {
|
|
||||||
$this->setData(['locale','page403', $pageId]);
|
|
||||||
}
|
|
||||||
if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) {
|
|
||||||
$this->setData(['locale','page302', $pageId]);
|
|
||||||
}
|
|
||||||
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
|
|
||||||
$lastPosition = 1;
|
|
||||||
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
|
|
||||||
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
|
|
||||||
foreach($hierarchy as $hierarchyPageId) {
|
|
||||||
// Ignore la page en cours de modification
|
|
||||||
if($hierarchyPageId === $this->getUrl(2)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
|
// Traitement des pages spéciales affectées dans la config :
|
||||||
if($lastPosition === $position) {
|
if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) {
|
||||||
|
$this->setData(['locale','legalPageId', $pageId]);
|
||||||
|
}
|
||||||
|
if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) {
|
||||||
|
$this->setData(['locale','searchPageId', $pageId]);
|
||||||
|
}
|
||||||
|
if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) {
|
||||||
|
$this->setData(['locale','page404', $pageId]);
|
||||||
|
}
|
||||||
|
if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) {
|
||||||
|
$this->setData(['locale','page403', $pageId]);
|
||||||
|
}
|
||||||
|
if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) {
|
||||||
|
$this->setData(['locale','page302', $pageId]);
|
||||||
|
}
|
||||||
|
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
|
||||||
|
$lastPosition = 1;
|
||||||
|
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
|
||||||
|
$position = $this->getInput('pageEditPosition', helper::FILTER_INT);
|
||||||
|
foreach($hierarchy as $hierarchyPageId) {
|
||||||
|
// Ignore la page en cours de modification
|
||||||
|
if($hierarchyPageId === $this->getUrl(2)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification
|
||||||
|
if($lastPosition === $position) {
|
||||||
|
$lastPosition++;
|
||||||
|
}
|
||||||
|
// Change la position
|
||||||
|
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
|
||||||
|
// Incrémente pour la prochaine position
|
||||||
$lastPosition++;
|
$lastPosition++;
|
||||||
}
|
}
|
||||||
// Change la position
|
if ($this->getinput('pageEditBlock') !== 'bar') {
|
||||||
$this->setData(['page', $hierarchyPageId, 'position', $lastPosition]);
|
$barLeft = $this->getinput('pageEditBarLeft');
|
||||||
// Incrémente pour la prochaine position
|
$barRight = $this->getinput('pageEditBarRight');
|
||||||
$lastPosition++;
|
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
|
||||||
}
|
|
||||||
if ($this->getinput('pageEditBlock') !== 'bar') {
|
|
||||||
$barLeft = $this->getinput('pageEditBarLeft');
|
|
||||||
$barRight = $this->getinput('pageEditBarRight');
|
|
||||||
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Une barre ne peut pas avoir de barres
|
// Une barre ne peut pas avoir de barres
|
||||||
$barLeft = "";
|
$barLeft = "";
|
||||||
$barRight = "";
|
$barRight = "";
|
||||||
// Une barre est masquée
|
// Une barre est masquée
|
||||||
$position = 0;
|
$position = 0;
|
||||||
$hideTitle = true;
|
$hideTitle = true;
|
||||||
}
|
}
|
||||||
// Modifie la page ou en crée une nouvelle si l'id a changé
|
// Modifie la page ou en crée une nouvelle si l'id a changé
|
||||||
$this->setData([
|
$this->setData([
|
||||||
'page',
|
'page',
|
||||||
$pageId,
|
$pageId,
|
||||||
[
|
[
|
||||||
'typeMenu' => $this->getinput('pageTypeMenu'),
|
'typeMenu' => $this->getinput('pageTypeMenu'),
|
||||||
'iconUrl' => $this->getinput('pageIconUrl'),
|
'iconUrl' => $this->getinput('pageIconUrl'),
|
||||||
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
|
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
|
||||||
'content' => $pageId . '.html',
|
'content' => $pageId . '.html',
|
||||||
'hideTitle' => $hideTitle,
|
'hideTitle' => $hideTitle,
|
||||||
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
|
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
|
||||||
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
|
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
|
||||||
'metaTitle' => $this->getInput('pageEditMetaTitle'),
|
'metaTitle' => $this->getInput('pageEditMetaTitle'),
|
||||||
'moduleId' => $this->getInput('pageEditModuleId'),
|
'moduleId' => $this->getInput('pageEditModuleId'),
|
||||||
'modulePosition' => $this->getInput('configModulePosition'),
|
'modulePosition' => $this->getInput('configModulePosition'),
|
||||||
'parentPageId' => $this->getInput('pageEditParentPageId'),
|
'parentPageId' => $this->getInput('pageEditParentPageId'),
|
||||||
'position' => $position,
|
'position' => $position,
|
||||||
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
|
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,
|
||||||
'groupEdit' => $this->getInput('pageEditGroupEdit', helper::FILTER_INT),
|
'groupEdit' => $this->getInput('pageEditGroupEdit', helper::FILTER_INT),
|
||||||
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
|
'targetBlank' => $this->getInput('pageEditTargetBlank', helper::FILTER_BOOLEAN),
|
||||||
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
|
'title' => $this->getInput('pageEditTitle', helper::FILTER_STRING_SHORT),
|
||||||
'shortTitle' => $this->getInput('pageEditShortTitle', helper::FILTER_STRING_SHORT, true),
|
'shortTitle' => $this->getInput('pageEditShortTitle', helper::FILTER_STRING_SHORT, true),
|
||||||
'block' => $this->getinput('pageEditBlock'),
|
'block' => $this->getinput('pageEditBlock'),
|
||||||
'barLeft' => $barLeft,
|
'barLeft' => $barLeft,
|
||||||
'barRight' => $barRight,
|
'barRight' => $barRight,
|
||||||
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
|
'displayMenu' => $this->getinput('pageEditDisplayMenu'),
|
||||||
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
|
'hideMenuSide' => $this->getinput('pageEditHideMenuSide', helper::FILTER_BOOLEAN),
|
||||||
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
|
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
|
||||||
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
|
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
// Creation du contenu de la page
|
// Creation du contenu de la page
|
||||||
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
|
if (!is_dir(self::DATA_DIR . self::$i18n . '/content')) {
|
||||||
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
|
mkdir(self::DATA_DIR . self::$i18n . '/content', 0755);
|
||||||
}
|
}
|
||||||
$content = empty($this->getInput('pageEditContent', null)) ? '<p></p>' : str_replace('<p></p>', '<p> </p>', $this->getInput('pageEditContent', null));
|
$content = empty($this->getInput('pageEditContent', null)) ? '<p></p>' : str_replace('<p></p>', '<p> </p>', $this->getInput('pageEditContent', null));
|
||||||
//file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html' , $content );
|
//file_put_contents( self::DATA_DIR . self::$i18n . '/content/' . $pageId . '.html' , $content );
|
||||||
$this->setPage($pageId , $content, self::$i18n);
|
$this->setPage($pageId , $content, self::$i18n);
|
||||||
// Barre renommée : changement le nom de la barre dans les pages mères
|
// Barre renommée : changement le nom de la barre dans les pages mères
|
||||||
if ($this->getinput('pageEditBlock') === 'bar') {
|
if ($this->getinput('pageEditBlock') === 'bar') {
|
||||||
foreach ($this->getHierarchy() as $eachPageId=>$parentId) {
|
foreach ($this->getHierarchy() as $eachPageId=>$parentId) {
|
||||||
if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) {
|
if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) {
|
||||||
$this->setData(['page',$eachPageId,'barRight',$pageId]);
|
$this->setData(['page',$eachPageId,'barRight',$pageId]);
|
||||||
}
|
|
||||||
if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) {
|
|
||||||
$this->setData(['page',$eachPageId,'barLeft',$pageId]);
|
|
||||||
}
|
|
||||||
foreach ($parentId as $childId) {
|
|
||||||
if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) {
|
|
||||||
$this->setData(['page',$childId,'barRight',$pageId]);
|
|
||||||
}
|
}
|
||||||
if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) {
|
if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) {
|
||||||
$this->setData(['page',$childId,'barLeft',$pageId]);
|
$this->setData(['page',$eachPageId,'barLeft',$pageId]);
|
||||||
|
}
|
||||||
|
foreach ($parentId as $childId) {
|
||||||
|
if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) {
|
||||||
|
$this->setData(['page',$childId,'barRight',$pageId]);
|
||||||
|
}
|
||||||
|
if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) {
|
||||||
|
$this->setData(['page',$childId,'barLeft',$pageId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// Met à jour le site map
|
||||||
// Met à jour le site map
|
// $this->createSitemap('all');
|
||||||
// $this->createSitemap('all');
|
// Redirection vers la configuration
|
||||||
// Redirection vers la configuration
|
if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) {
|
||||||
if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) {
|
// Valeurs en sortie
|
||||||
// Valeurs en sortie
|
$this->addOutput([
|
||||||
$this->addOutput([
|
'redirect' => helper::baseUrl() . $pageId . '/config',
|
||||||
'redirect' => helper::baseUrl() . $pageId . '/config',
|
'state' => true
|
||||||
'state' => true
|
]);
|
||||||
]);
|
}
|
||||||
}
|
// Redirection vers la page
|
||||||
// Redirection vers la page
|
else {
|
||||||
else {
|
// Valeurs en sortie
|
||||||
// Valeurs en sortie
|
$this->addOutput([
|
||||||
$this->addOutput([
|
'redirect' => helper::baseUrl() . $pageId,
|
||||||
'redirect' => helper::baseUrl() . $pageId,
|
'notification' => $text['core_page']['edit'][0],
|
||||||
'notification' => $text['core_page']['edit'][0],
|
'state' => true
|
||||||
'state' => true
|
]);
|
||||||
]);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
self::$moduleIds = array_merge( ['' => $text['core_page']['edit'][1]] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent
|
||||||
self::$moduleIds = array_merge( ['' => $text['core_page']['edit'][1]] , helper::arrayCollumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent
|
self::$pagesNoParentId = $pagesNoParentId;
|
||||||
self::$pagesNoParentId = $pagesNoParentId;
|
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
|
||||||
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
|
if($parentPageId !== $this->getUrl(2)) {
|
||||||
if($parentPageId !== $this->getUrl(2)) {
|
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
||||||
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
//self::$pagesNoParentId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
||||||
//self::$pagesNoParentId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Pages barre latérales
|
|
||||||
self::$pagesBarId = $pagesBarId;
|
|
||||||
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
|
|
||||||
if($parentPageId !== $this->getUrl(2) &&
|
|
||||||
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
|
|
||||||
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
|
||||||
//self::$pagesBarId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Pages barre latérales
|
||||||
|
self::$pagesBarId = $pagesBarId;
|
||||||
|
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) {
|
||||||
|
if($parentPageId !== $this->getUrl(2) &&
|
||||||
|
$this->getData(['page', $parentPageId, 'block']) === 'bar') {
|
||||||
|
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
||||||
|
//self::$pagesBarId_en[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Mise à jour de la liste des pages pour TinyMCE
|
||||||
|
$this->pages2Json();
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
|
||||||
|
'vendor' => ['tinymce'],
|
||||||
|
'view' => 'edit'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Mise à jour de la liste des pages pour TinyMCE
|
|
||||||
$this->pages2Json();
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $this->getData(['page', $this->getUrl(2), 'title']),
|
|
||||||
'vendor' => ['tinymce'],
|
|
||||||
'view' => 'edit'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,155 +37,175 @@ class translate extends common {
|
||||||
* Configuration avancée des langues
|
* Configuration avancée des langues
|
||||||
*/
|
*/
|
||||||
public function copy() {
|
public function copy() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Soumission du formulaire
|
if( $group < translate::$actions['copy'] ) {
|
||||||
if ($this->isPost()) {
|
|
||||||
// Initialisation
|
|
||||||
$success = false;
|
|
||||||
$copyFrom = $this->getInput('translateFormCopySource');
|
|
||||||
$toCreate = $this->getInput('translateFormCopyTarget');
|
|
||||||
if ($copyFrom !== $toCreate) {
|
|
||||||
// Création du dossier
|
|
||||||
if (is_dir(self::DATA_DIR . $toCreate) === false ) { // Si le dossier est déjà créé
|
|
||||||
$success = mkdir (self::DATA_DIR . $toCreate, 0755);
|
|
||||||
$success = mkdir (self::DATA_DIR . $toCreate.'/content', 0755);
|
|
||||||
} else {
|
|
||||||
$success = true;
|
|
||||||
}
|
|
||||||
// Copier les données par défaut avec gestion des erreurs
|
|
||||||
$success = (copy (self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false;
|
|
||||||
$success = (copy (self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false;
|
|
||||||
$success = (copy (self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false;
|
|
||||||
$success = ($this->copyDir (self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false;
|
|
||||||
// Enregistrer la langue
|
|
||||||
if ($success) {
|
|
||||||
$this->setData(['config', 'i18n', $toCreate, 'site' ]);
|
|
||||||
$i18nListBase = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$i18nList);
|
|
||||||
$notification = $text['core_translate']['copy'][3] . $i18nListBase[$copyFrom] . $text['core_translate']['copy'][4] . self::$i18nList[$toCreate];
|
|
||||||
} else {
|
|
||||||
$notification = $text['core_translate']['copy'][0];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$success = false;
|
|
||||||
$notification = $text['core_translate']['copy'][1];
|
|
||||||
}
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'notification' => $notification,
|
'access' => false
|
||||||
'title' => $text['core_translate']['copy'][2],
|
]);
|
||||||
'view' => 'index',
|
} else {
|
||||||
'state' => $success
|
// Lexique
|
||||||
|
include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php');
|
||||||
|
|
||||||
|
// Soumission du formulaire
|
||||||
|
if ($this->isPost()) {
|
||||||
|
// Initialisation
|
||||||
|
$success = false;
|
||||||
|
$copyFrom = $this->getInput('translateFormCopySource');
|
||||||
|
$toCreate = $this->getInput('translateFormCopyTarget');
|
||||||
|
if ($copyFrom !== $toCreate) {
|
||||||
|
// Création du dossier
|
||||||
|
if (is_dir(self::DATA_DIR . $toCreate) === false ) { // Si le dossier est déjà créé
|
||||||
|
$success = mkdir (self::DATA_DIR . $toCreate, 0755);
|
||||||
|
$success = mkdir (self::DATA_DIR . $toCreate.'/content', 0755);
|
||||||
|
} else {
|
||||||
|
$success = true;
|
||||||
|
}
|
||||||
|
// Copier les données par défaut avec gestion des erreurs
|
||||||
|
$success = (copy (self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false;
|
||||||
|
$success = (copy (self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false;
|
||||||
|
$success = (copy (self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false;
|
||||||
|
$success = ($this->copyDir (self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false;
|
||||||
|
// Enregistrer la langue
|
||||||
|
if ($success) {
|
||||||
|
$this->setData(['config', 'i18n', $toCreate, 'site' ]);
|
||||||
|
$i18nListBase = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$i18nList);
|
||||||
|
$notification = $text['core_translate']['copy'][3] . $i18nListBase[$copyFrom] . $text['core_translate']['copy'][4] . self::$i18nList[$toCreate];
|
||||||
|
} else {
|
||||||
|
$notification = $text['core_translate']['copy'][0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$success = false;
|
||||||
|
$notification = $text['core_translate']['copy'][1];
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => $notification,
|
||||||
|
'title' => $text['core_translate']['copy'][2],
|
||||||
|
'view' => 'index',
|
||||||
|
'state' => $success
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Tableau des langues installées
|
||||||
|
foreach ($i18nList as $key => $value) {
|
||||||
|
if ($this->getData(['config','i18n', $key]) === 'site') {
|
||||||
|
self::$languagesTarget[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Langues cibles base en plus
|
||||||
|
self::$languagesInstalled = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$languagesTarget);
|
||||||
|
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_translate']['copy'][2],
|
||||||
|
'view' => 'copy'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Tableau des langues installées
|
|
||||||
foreach ($i18nList as $key => $value) {
|
|
||||||
if ($this->getData(['config','i18n', $key]) === 'site') {
|
|
||||||
self::$languagesTarget[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Langues cibles base en plus
|
|
||||||
self::$languagesInstalled = array_merge(['base' => $text['core_translate']['copy'][5] ],self::$languagesTarget);
|
|
||||||
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_translate']['copy'][2],
|
|
||||||
'view' => 'copy'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration
|
* Configuration
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
// Soumission du formulaire
|
if( $group < translate::$actions['index'] ) {
|
||||||
if($this->isPost()) {
|
|
||||||
// Edition des langues
|
|
||||||
foreach (self::$i18nList as $keyi18n => $value) {
|
|
||||||
if ($keyi18n === 'base') continue;
|
|
||||||
|
|
||||||
// Effacement d'une langue installée
|
|
||||||
if ( is_dir( self::DATA_DIR . $keyi18n ) === true
|
|
||||||
AND $this->getInput('translate' . strtoupper($keyi18n)) === 'delete')
|
|
||||||
{
|
|
||||||
$this->removeDir( self::DATA_DIR . $keyi18n);
|
|
||||||
// Au cas ou la langue est sélectionnée
|
|
||||||
helper::deleteCookie('DELTA_I18N_SITE');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 'langBase' mémorise le code ISO de la langue sélectionnée ou de la valeur saisie si la langue sélectionnée est Autre langue
|
|
||||||
$requiredOtherLang = false;
|
|
||||||
$langBase = $this->getInput('translateLangBase');
|
|
||||||
if( $langBase === 'none'){
|
|
||||||
$langBase = $this->getInput('translateOtherBase');
|
|
||||||
$requiredOtherLang = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enregistrement des données
|
|
||||||
$this->setData(['config','i18n', [
|
|
||||||
'enable' => $this->getData(['config', 'i18n', 'enable']),
|
|
||||||
'langAdmin' => $this->getInput('translateLangAdmin'),
|
|
||||||
'langBase' => $langBase,
|
|
||||||
'otherLangBase' => $this->getInput('translateOtherBase', helper::FILTER_STRING_SHORT,$requiredOtherLang),
|
|
||||||
'fr' => $this->getInput('translateFR'),
|
|
||||||
'de' => $this->getInput('translateDE'),
|
|
||||||
'en' => $this->getInput('translateEN'),
|
|
||||||
'es' => $this->getInput('translateES'),
|
|
||||||
'it' => $this->getInput('translateIT'),
|
|
||||||
'nl' => $this->getInput('translateNL'),
|
|
||||||
'pt' => $this->getInput('translatePT'),
|
|
||||||
'el' => $this->getInput('translateEL'),
|
|
||||||
'da' => $this->getInput('translateDA'),
|
|
||||||
'fi' => $this->getInput('translateFI'),
|
|
||||||
'ga' => $this->getInput('translateGA'),
|
|
||||||
'sv' => $this->getInput('translateSV'),
|
|
||||||
'br' => $this->getInput('translateBR'),
|
|
||||||
'ca' => $this->getInput('translateCA'),
|
|
||||||
'co' => $this->getInput('translateCO'),
|
|
||||||
'eu' => $this->getInput('translateEU')
|
|
||||||
|
|
||||||
]]);
|
|
||||||
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => helper::baseUrl() . $this->getUrl(),
|
'access' => false
|
||||||
'notification' => $text['core_translate']['index'][0],
|
]);
|
||||||
'state' => true
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/translate/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_translate.php');
|
||||||
|
|
||||||
|
// Soumission du formulaire
|
||||||
|
if($this->isPost()) {
|
||||||
|
// Edition des langues
|
||||||
|
foreach (self::$i18nList as $keyi18n => $value) {
|
||||||
|
if ($keyi18n === 'base') continue;
|
||||||
|
|
||||||
|
// Effacement d'une langue installée
|
||||||
|
if ( is_dir( self::DATA_DIR . $keyi18n ) === true
|
||||||
|
AND $this->getInput('translate' . strtoupper($keyi18n)) === 'delete')
|
||||||
|
{
|
||||||
|
$this->removeDir( self::DATA_DIR . $keyi18n);
|
||||||
|
// Au cas ou la langue est sélectionnée
|
||||||
|
helper::deleteCookie('DELTA_I18N_SITE');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 'langBase' mémorise le code ISO de la langue sélectionnée ou de la valeur saisie si la langue sélectionnée est Autre langue
|
||||||
|
$requiredOtherLang = false;
|
||||||
|
$langBase = $this->getInput('translateLangBase');
|
||||||
|
if( $langBase === 'none'){
|
||||||
|
$langBase = $this->getInput('translateOtherBase');
|
||||||
|
$requiredOtherLang = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enregistrement des données
|
||||||
|
$this->setData(['config','i18n', [
|
||||||
|
'enable' => $this->getData(['config', 'i18n', 'enable']),
|
||||||
|
'langAdmin' => $this->getInput('translateLangAdmin'),
|
||||||
|
'langBase' => $langBase,
|
||||||
|
'otherLangBase' => $this->getInput('translateOtherBase', helper::FILTER_STRING_SHORT,$requiredOtherLang),
|
||||||
|
'fr' => $this->getInput('translateFR'),
|
||||||
|
'de' => $this->getInput('translateDE'),
|
||||||
|
'en' => $this->getInput('translateEN'),
|
||||||
|
'es' => $this->getInput('translateES'),
|
||||||
|
'it' => $this->getInput('translateIT'),
|
||||||
|
'nl' => $this->getInput('translateNL'),
|
||||||
|
'pt' => $this->getInput('translatePT'),
|
||||||
|
'el' => $this->getInput('translateEL'),
|
||||||
|
'da' => $this->getInput('translateDA'),
|
||||||
|
'fi' => $this->getInput('translateFI'),
|
||||||
|
'ga' => $this->getInput('translateGA'),
|
||||||
|
'sv' => $this->getInput('translateSV'),
|
||||||
|
'br' => $this->getInput('translateBR'),
|
||||||
|
'ca' => $this->getInput('translateCA'),
|
||||||
|
'co' => $this->getInput('translateCO'),
|
||||||
|
'eu' => $this->getInput('translateEU')
|
||||||
|
|
||||||
|
]]);
|
||||||
|
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
||||||
|
'notification' => $text['core_translate']['index'][0],
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Modification des options de suppression de la langue installée.
|
||||||
|
foreach (self::$i18nList as $key => $value) {
|
||||||
|
if ($this->getData(['config','i18n',$key]) === 'site') {
|
||||||
|
self::$translateOptions [$key] = [
|
||||||
|
'none' => $text['core_translate']['index'][1],
|
||||||
|
'site' => $text['core_translate']['index'][3],
|
||||||
|
'delete' => $text['core_translate']['index'][4]
|
||||||
|
];
|
||||||
|
self::$siteTranslate = $key !== $this->getData(['config', 'i18n', 'langBase']) ? false : true;
|
||||||
|
} else {
|
||||||
|
self::$translateOptions [$key] = [
|
||||||
|
'none' => $text['core_translate']['index'][1],
|
||||||
|
'site' => $text['core_translate']['index'][3]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// Limitation du choix pour la langue d'origine
|
||||||
|
if ( $key === $this->getData(['config', 'i18n', 'langBase'])){
|
||||||
|
self::$translateOptions [$key] = [
|
||||||
|
'none' => $text['core_translate']['index'][1],
|
||||||
|
'site' => $text['core_translate']['index'][5]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_translate']['index'][6],
|
||||||
|
'view' => 'index'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Modification des options de suppression de la langue installée.
|
|
||||||
foreach (self::$i18nList as $key => $value) {
|
|
||||||
if ($this->getData(['config','i18n',$key]) === 'site') {
|
|
||||||
self::$translateOptions [$key] = [
|
|
||||||
'none' => $text['core_translate']['index'][1],
|
|
||||||
'site' => $text['core_translate']['index'][3],
|
|
||||||
'delete' => $text['core_translate']['index'][4]
|
|
||||||
];
|
|
||||||
self::$siteTranslate = $key !== $this->getData(['config', 'i18n', 'langBase']) ? false : true;
|
|
||||||
} else {
|
|
||||||
self::$translateOptions [$key] = [
|
|
||||||
'none' => $text['core_translate']['index'][1],
|
|
||||||
'site' => $text['core_translate']['index'][3]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
// Limitation du choix pour la langue d'origine
|
|
||||||
if ( $key === $this->getData(['config', 'i18n', 'langBase'])){
|
|
||||||
self::$translateOptions [$key] = [
|
|
||||||
'none' => $text['core_translate']['index'][1],
|
|
||||||
'site' => $text['core_translate']['index'][5]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_translate']['index'][6],
|
|
||||||
'view' => 'index'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,257 +47,81 @@ class user extends common {
|
||||||
* Ajout
|
* Ajout
|
||||||
*/
|
*/
|
||||||
public function add() {
|
public function add() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
$group = $this->getUser('group');
|
||||||
// Soumission du formulaire
|
if ($group === false ) $group = 0;
|
||||||
if($this->isPost()) {
|
if( $group < user::$actions['add'] ) {
|
||||||
$check=true;
|
|
||||||
// L'identifiant d'utilisateur est indisponible
|
|
||||||
$userId = $this->getInput('userAddId', helper::FILTER_ID, true);
|
|
||||||
if($this->getData(['user', $userId])) {
|
|
||||||
self::$inputNotices['userAddId'] = $text['core_user']['add'][0];
|
|
||||||
$check=false;
|
|
||||||
}
|
|
||||||
// Double vérification pour le mot de passe
|
|
||||||
if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
|
||||||
self::$inputNotices['userAddConfirmPassword'] = $text['core_user']['add'][1];
|
|
||||||
$check = false;
|
|
||||||
}
|
|
||||||
// Crée l'utilisateur
|
|
||||||
$userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true);
|
|
||||||
$userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true);
|
|
||||||
$userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true);
|
|
||||||
|
|
||||||
// Stockage des données
|
|
||||||
$this->setData([
|
|
||||||
'user',
|
|
||||||
$userId,
|
|
||||||
[
|
|
||||||
'firstname' => $userFirstname,
|
|
||||||
'forgot' => 0,
|
|
||||||
'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true),
|
|
||||||
'lastname' => $userLastname,
|
|
||||||
'pseudo' => $this->getInput('userAddPseudo', helper::FILTER_STRING_SHORT, true),
|
|
||||||
'signature' => $this->getInput('userAddSignature', helper::FILTER_INT, true),
|
|
||||||
'mail' => $userMail,
|
|
||||||
'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true),
|
|
||||||
"connectFail" => null,
|
|
||||||
"connectTimeout" => null,
|
|
||||||
"accessUrl" => null,
|
|
||||||
"accessTimer" => null,
|
|
||||||
"accessCsrf" => null,
|
|
||||||
"files" => $this->getInput('userAddFiles', helper::FILTER_BOOLEAN),
|
|
||||||
"redirectPageId" => $this->getInput('userRedirectPageId', helper::FILTER_STRING_SHORT)
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Envoie le mail
|
|
||||||
$sent = true;
|
|
||||||
if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) {
|
|
||||||
$sent = $this->sendMail(
|
|
||||||
$userMail,
|
|
||||||
$text['core_user']['add'][2] . $this->getData(['locale', 'title']),
|
|
||||||
$text['core_user']['add'][3].'<strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
|
|
||||||
$text['core_user']['add'][4] . $this->getData(['locale', 'title']) . $text['core_user']['add'][5].'<br><br>' .
|
|
||||||
'<strong>'.$text['core_user']['add'][6].'</strong> ' . $this->getInput('userAddId') . '<br>' .
|
|
||||||
'<small>'.$text['core_user']['add'][7].'</small>',
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
|
||||||
'notification' => $sent === true ? $text['core_user']['add'][8] : $sent,
|
|
||||||
'state' => $sent === true ? true : null
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Générer la liste des pages disponibles
|
|
||||||
$redirectPage = array( 'noRedirect'=> array( 'title'=>$text['core_user']['add'][10]));
|
|
||||||
self::$pagesList = $this->getData(['page']);
|
|
||||||
foreach(self::$pagesList as $page => $pageId) {
|
|
||||||
if ($this->getData(['page',$page,'block']) === 'bar' ||
|
|
||||||
$this->getData(['page',$page,'disable']) === true ||
|
|
||||||
$this->getData(['page',$page,'title']) === null ) {
|
|
||||||
unset(self::$pagesList[$page]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self::$pagesList = array_merge( $redirectPage, self::$pagesList);
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_user']['add'][9],
|
|
||||||
'view' => 'add'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Suppression
|
|
||||||
*/
|
|
||||||
public function delete() {
|
|
||||||
// Lexique
|
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
|
||||||
// Accès refusé
|
|
||||||
if(
|
|
||||||
// L'utilisateur n'existe pas
|
|
||||||
$this->getData(['user', $this->getUrl(2)]) === null
|
|
||||||
// Groupe insuffisant
|
|
||||||
AND ($this->getUrl('group') < self::GROUP_MODERATOR)
|
|
||||||
) {
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'access' => false
|
'access' => false
|
||||||
]);
|
]);
|
||||||
}
|
} else {
|
||||||
// Jeton incorrect
|
// Lexique
|
||||||
elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
|
||||||
'notification' => $text['core_user']['delete'][0]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Bloque la suppression de son propre compte
|
|
||||||
elseif($this->getUser('id') === $this->getUrl(2)) {
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
|
||||||
'notification' => $text['core_user']['delete'][1]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Suppression
|
|
||||||
else {
|
|
||||||
$this->deleteData(['user', $this->getUrl(2)]);
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
|
||||||
'notification' => $text['core_user']['delete'][2],
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Édition
|
|
||||||
*/
|
|
||||||
public function edit() {
|
|
||||||
// Lexique
|
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
|
||||||
|
|
||||||
if ($this->getUrl(3) !== $_SESSION['csrf'] &&
|
|
||||||
$this->getUrl(4) !== $_SESSION['csrf']) {
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl() . 'user',
|
|
||||||
'notification' => $text['core_user']['edit'][0]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Accès refusé
|
|
||||||
if(
|
|
||||||
// L'utilisateur n'existe pas
|
|
||||||
$this->getData(['user', $this->getUrl(2)]) === null
|
|
||||||
// Droit d'édition
|
|
||||||
AND (
|
|
||||||
// Impossible de s'auto-éditer
|
|
||||||
(
|
|
||||||
$this->getUser('id') === $this->getUrl(2)
|
|
||||||
AND $this->getUrl('group') <= self::GROUP_VISITOR
|
|
||||||
)
|
|
||||||
// Impossible d'éditer un autre utilisateur
|
|
||||||
OR ($this->getUrl('group') < self::GROUP_MODERATOR)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'access' => false
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// Accès autorisé
|
|
||||||
else {
|
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
|
$check=true;
|
||||||
|
// L'identifiant d'utilisateur est indisponible
|
||||||
|
$userId = $this->getInput('userAddId', helper::FILTER_ID, true);
|
||||||
|
if($this->getData(['user', $userId])) {
|
||||||
|
self::$inputNotices['userAddId'] = $text['core_user']['add'][0];
|
||||||
|
$check=false;
|
||||||
|
}
|
||||||
// Double vérification pour le mot de passe
|
// Double vérification pour le mot de passe
|
||||||
$newPassword = $this->getData(['user', $this->getUrl(2), 'password']);
|
if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
|
||||||
if($this->getInput('userEditNewPassword')) {
|
self::$inputNotices['userAddConfirmPassword'] = $text['core_user']['add'][1];
|
||||||
// L'ancien mot de passe est correct
|
$check = false;
|
||||||
if(password_verify($this->getInput('userEditOldPassword'), $this->getData(['user', $this->getUrl(2), 'password']))) {
|
|
||||||
// La confirmation correspond au mot de passe
|
|
||||||
if($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) {
|
|
||||||
$newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true);
|
|
||||||
// Déconnexion de l'utilisateur si il change le mot de passe de son propre compte
|
|
||||||
if($this->getUser('id') === $this->getUrl(2)) {
|
|
||||||
helper::deleteCookie('DELTA_USER_ID');
|
|
||||||
helper::deleteCookie('DELTA_USER_PASSWORD');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self::$inputNotices['userEditConfirmPassword'] = $text['core_user']['edit'][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self::$inputNotices['userEditOldPassword'] = $text['core_user']['edit'][1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Modification du groupe
|
// Crée l'utilisateur
|
||||||
if(
|
$userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true);
|
||||||
$this->getUser('group') === self::GROUP_ADMIN
|
$userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true);
|
||||||
AND $this->getUrl(2) !== $this->getUser('id')
|
$userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true);
|
||||||
) {
|
|
||||||
$newGroup = $this->getInput('userEditGroup', helper::FILTER_INT, true);
|
// Stockage des données
|
||||||
}
|
|
||||||
else {
|
|
||||||
$newGroup = $this->getData(['user', $this->getUrl(2), 'group']);
|
|
||||||
}
|
|
||||||
// Modification de nom Prénom
|
|
||||||
if($this->getUser('group') === self::GROUP_ADMIN){
|
|
||||||
$newfirstname = $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true);
|
|
||||||
$newlastname = $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$newfirstname = $this->getData(['user', $this->getUrl(2), 'firstname']);
|
|
||||||
$newlastname = $this->getData(['user', $this->getUrl(2), 'lastname']);
|
|
||||||
}
|
|
||||||
// Modifie l'utilisateur
|
|
||||||
$this->setData([
|
$this->setData([
|
||||||
'user',
|
'user',
|
||||||
$this->getUrl(2),
|
$userId,
|
||||||
[
|
[
|
||||||
'firstname' => $newfirstname,
|
'firstname' => $userFirstname,
|
||||||
'forgot' => 0,
|
'forgot' => 0,
|
||||||
'group' => $newGroup,
|
'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true),
|
||||||
'lastname' => $newlastname,
|
'lastname' => $userLastname,
|
||||||
'pseudo' => $this->getInput('userEditPseudo', helper::FILTER_STRING_SHORT, true),
|
'pseudo' => $this->getInput('userAddPseudo', helper::FILTER_STRING_SHORT, true),
|
||||||
'signature' => $this->getInput('userEditSignature', helper::FILTER_INT, true),
|
'signature' => $this->getInput('userAddSignature', helper::FILTER_INT, true),
|
||||||
'mail' => $this->getInput('userEditMail', helper::FILTER_MAIL, true),
|
'mail' => $userMail,
|
||||||
'password' => $newPassword,
|
'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true),
|
||||||
'connectFail' => $this->getData(['user',$this->getUrl(2),'connectFail']),
|
"connectFail" => null,
|
||||||
'connectTimeout' => $this->getData(['user',$this->getUrl(2),'connectTimeout']),
|
"connectTimeout" => null,
|
||||||
'accessUrl' => $this->getData(['user',$this->getUrl(2),'accessUrl']),
|
"accessUrl" => null,
|
||||||
'accessTimer' => $this->getData(['user',$this->getUrl(2),'accessTimer']),
|
"accessTimer" => null,
|
||||||
'accessCsrf' => $this->getData(['user',$this->getUrl(2),'accessCsrf']),
|
"accessCsrf" => null,
|
||||||
'files' => $this->getInput('userEditFiles', helper::FILTER_BOOLEAN),
|
"files" => $this->getInput('userAddFiles', helper::FILTER_BOOLEAN),
|
||||||
'redirectPageId' => $this->getInput('userRedirectPageId', helper::FILTER_STRING_SHORT)
|
"redirectPageId" => $this->getInput('userRedirectPageId', helper::FILTER_STRING_SHORT)
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
// Redirection spécifique si l'utilisateur change son mot de passe
|
|
||||||
if($this->getUser('id') === $this->getUrl(2) AND $this->getInput('userEditNewPassword')) {
|
// Envoie le mail
|
||||||
$redirect = helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl());
|
$sent = true;
|
||||||
}
|
if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) {
|
||||||
// Redirection si retour en arrière possible
|
$sent = $this->sendMail(
|
||||||
elseif($this->getUser('group') === self::GROUP_ADMIN) {
|
$userMail,
|
||||||
$redirect = helper::baseUrl() . 'user';
|
$text['core_user']['add'][2] . $this->getData(['locale', 'title']),
|
||||||
}
|
$text['core_user']['add'][3].'<strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
|
||||||
// Redirection normale
|
$text['core_user']['add'][4] . $this->getData(['locale', 'title']) . $text['core_user']['add'][5].'<br><br>' .
|
||||||
else {
|
'<strong>'.$text['core_user']['add'][6].'</strong> ' . $this->getInput('userAddId') . '<br>' .
|
||||||
$redirect = helper::baseUrl();
|
'<small>'.$text['core_user']['add'][7].'</small>',
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'redirect' => $redirect,
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
'notification' => $text['core_user']['edit'][2],
|
'notification' => $sent === true ? $text['core_user']['add'][8] : $sent,
|
||||||
'state' => true
|
'state' => $sent === true ? true : null
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// Générer la liste des pages disponibles
|
// Générer la liste des pages disponibles
|
||||||
$redirectPage = array( 'noRedirect'=> array( 'title'=> $text['core_user']['edit'][3]) );
|
$redirectPage = array( 'noRedirect'=> array( 'title'=>$text['core_user']['add'][10]));
|
||||||
self::$pagesList = $this->getData(['page']);
|
self::$pagesList = $this->getData(['page']);
|
||||||
foreach(self::$pagesList as $page => $pageId) {
|
foreach(self::$pagesList as $page => $pageId) {
|
||||||
if ($this->getData(['page',$page,'block']) === 'bar' ||
|
if ($this->getData(['page',$page,'block']) === 'bar' ||
|
||||||
|
@ -309,12 +133,218 @@ class user extends common {
|
||||||
self::$pagesList = array_merge( $redirectPage, self::$pagesList);
|
self::$pagesList = array_merge( $redirectPage, self::$pagesList);
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => $this->getData(['user', $this->getUrl(2), 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(2), 'lastname']),
|
'title' => $text['core_user']['add'][9],
|
||||||
'view' => 'edit'
|
'view' => 'add'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suppression
|
||||||
|
*/
|
||||||
|
public function delete() {
|
||||||
|
// Autorisation
|
||||||
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
|
if( $group < user::$actions['delete'] ) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
|
// Accès refusé
|
||||||
|
if(
|
||||||
|
// L'utilisateur n'existe pas
|
||||||
|
$this->getData(['user', $this->getUrl(2)]) === null
|
||||||
|
// Groupe insuffisant
|
||||||
|
AND ($this->getUrl('group') < self::GROUP_MODERATOR)
|
||||||
|
) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Jeton incorrect
|
||||||
|
elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => $text['core_user']['delete'][0]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Bloque la suppression de son propre compte
|
||||||
|
elseif($this->getUser('id') === $this->getUrl(2)) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => $text['core_user']['delete'][1]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Suppression
|
||||||
|
else {
|
||||||
|
$this->deleteData(['user', $this->getUrl(2)]);
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => $text['core_user']['delete'][2],
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Édition
|
||||||
|
*/
|
||||||
|
public function edit() {
|
||||||
|
// Autorisation
|
||||||
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
|
if( $group < user::$actions['edit'] ) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
|
|
||||||
|
if ($this->getUrl(3) !== $_SESSION['csrf'] &&
|
||||||
|
$this->getUrl(4) !== $_SESSION['csrf']) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl() . 'user',
|
||||||
|
'notification' => $text['core_user']['edit'][0]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Accès refusé
|
||||||
|
if(
|
||||||
|
// L'utilisateur n'existe pas
|
||||||
|
$this->getData(['user', $this->getUrl(2)]) === null
|
||||||
|
// Droit d'édition
|
||||||
|
AND (
|
||||||
|
// Impossible de s'auto-éditer
|
||||||
|
(
|
||||||
|
$this->getUser('id') === $this->getUrl(2)
|
||||||
|
AND $this->getUrl('group') <= self::GROUP_VISITOR
|
||||||
|
)
|
||||||
|
// Impossible d'éditer un autre utilisateur
|
||||||
|
OR ($this->getUrl('group') < self::GROUP_MODERATOR)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Accès autorisé
|
||||||
|
else {
|
||||||
|
// Soumission du formulaire
|
||||||
|
if($this->isPost()) {
|
||||||
|
// Double vérification pour le mot de passe
|
||||||
|
$newPassword = $this->getData(['user', $this->getUrl(2), 'password']);
|
||||||
|
if($this->getInput('userEditNewPassword')) {
|
||||||
|
// L'ancien mot de passe est correct
|
||||||
|
if(password_verify($this->getInput('userEditOldPassword'), $this->getData(['user', $this->getUrl(2), 'password']))) {
|
||||||
|
// La confirmation correspond au mot de passe
|
||||||
|
if($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) {
|
||||||
|
$newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true);
|
||||||
|
// Déconnexion de l'utilisateur si il change le mot de passe de son propre compte
|
||||||
|
if($this->getUser('id') === $this->getUrl(2)) {
|
||||||
|
helper::deleteCookie('DELTA_USER_ID');
|
||||||
|
helper::deleteCookie('DELTA_USER_PASSWORD');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self::$inputNotices['userEditConfirmPassword'] = $text['core_user']['edit'][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self::$inputNotices['userEditOldPassword'] = $text['core_user']['edit'][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Modification du groupe
|
||||||
|
if(
|
||||||
|
$this->getUser('group') === self::GROUP_ADMIN
|
||||||
|
AND $this->getUrl(2) !== $this->getUser('id')
|
||||||
|
) {
|
||||||
|
$newGroup = $this->getInput('userEditGroup', helper::FILTER_INT, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$newGroup = $this->getData(['user', $this->getUrl(2), 'group']);
|
||||||
|
}
|
||||||
|
// Modification de nom Prénom
|
||||||
|
if($this->getUser('group') === self::GROUP_ADMIN){
|
||||||
|
$newfirstname = $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true);
|
||||||
|
$newlastname = $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$newfirstname = $this->getData(['user', $this->getUrl(2), 'firstname']);
|
||||||
|
$newlastname = $this->getData(['user', $this->getUrl(2), 'lastname']);
|
||||||
|
}
|
||||||
|
// Modifie l'utilisateur
|
||||||
|
$this->setData([
|
||||||
|
'user',
|
||||||
|
$this->getUrl(2),
|
||||||
|
[
|
||||||
|
'firstname' => $newfirstname,
|
||||||
|
'forgot' => 0,
|
||||||
|
'group' => $newGroup,
|
||||||
|
'lastname' => $newlastname,
|
||||||
|
'pseudo' => $this->getInput('userEditPseudo', helper::FILTER_STRING_SHORT, true),
|
||||||
|
'signature' => $this->getInput('userEditSignature', helper::FILTER_INT, true),
|
||||||
|
'mail' => $this->getInput('userEditMail', helper::FILTER_MAIL, true),
|
||||||
|
'password' => $newPassword,
|
||||||
|
'connectFail' => $this->getData(['user',$this->getUrl(2),'connectFail']),
|
||||||
|
'connectTimeout' => $this->getData(['user',$this->getUrl(2),'connectTimeout']),
|
||||||
|
'accessUrl' => $this->getData(['user',$this->getUrl(2),'accessUrl']),
|
||||||
|
'accessTimer' => $this->getData(['user',$this->getUrl(2),'accessTimer']),
|
||||||
|
'accessCsrf' => $this->getData(['user',$this->getUrl(2),'accessCsrf']),
|
||||||
|
'files' => $this->getInput('userEditFiles', helper::FILTER_BOOLEAN),
|
||||||
|
'redirectPageId' => $this->getInput('userRedirectPageId', helper::FILTER_STRING_SHORT)
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
// Redirection spécifique si l'utilisateur change son mot de passe
|
||||||
|
if($this->getUser('id') === $this->getUrl(2) AND $this->getInput('userEditNewPassword')) {
|
||||||
|
$redirect = helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl());
|
||||||
|
}
|
||||||
|
// Redirection si retour en arrière possible
|
||||||
|
elseif($this->getUser('group') === self::GROUP_ADMIN) {
|
||||||
|
$redirect = helper::baseUrl() . 'user';
|
||||||
|
}
|
||||||
|
// Redirection normale
|
||||||
|
else {
|
||||||
|
$redirect = helper::baseUrl();
|
||||||
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => $redirect,
|
||||||
|
'notification' => $text['core_user']['edit'][2],
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// Générer la liste des pages disponibles
|
||||||
|
$redirectPage = array( 'noRedirect'=> array( 'title'=> $text['core_user']['edit'][3]) );
|
||||||
|
self::$pagesList = $this->getData(['page']);
|
||||||
|
foreach(self::$pagesList as $page => $pageId) {
|
||||||
|
if ($this->getData(['page',$page,'block']) === 'bar' ||
|
||||||
|
$this->getData(['page',$page,'disable']) === true ||
|
||||||
|
$this->getData(['page',$page,'title']) === null ) {
|
||||||
|
unset(self::$pagesList[$page]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::$pagesList = array_merge( $redirectPage, self::$pagesList);
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $this->getData(['user', $this->getUrl(2), 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(2), 'lastname']),
|
||||||
|
'view' => 'edit'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mot de passe perdu
|
* Mot de passe perdu
|
||||||
*/
|
*/
|
||||||
|
@ -365,34 +395,44 @@ class user extends common {
|
||||||
* Liste des utilisateurs
|
* Liste des utilisateurs
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
$group = $this->getUser('group');
|
||||||
|
if ($group === false ) $group = 0;
|
||||||
|
if( $group < user::$actions['index'] ) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'access' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
|
|
||||||
$userIdsFirstnames = helper::arrayCollumn($this->getData(['user']), 'firstname');
|
$userIdsFirstnames = helper::arrayCollumn($this->getData(['user']), 'firstname');
|
||||||
ksort($userIdsFirstnames);
|
ksort($userIdsFirstnames);
|
||||||
foreach($userIdsFirstnames as $userId => $userFirstname) {
|
foreach($userIdsFirstnames as $userId => $userFirstname) {
|
||||||
if ($this->getData(['user', $userId, 'group'])) {
|
if ($this->getData(['user', $userId, 'group'])) {
|
||||||
self::$users[] = [
|
self::$users[] = [
|
||||||
$userId,
|
$userId,
|
||||||
$userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']),
|
$userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']),
|
||||||
$groups[$this->getData(['user', $userId, 'group'])],
|
$groups[$this->getData(['user', $userId, 'group'])],
|
||||||
template::button('userEdit' . $userId, [
|
template::button('userEdit' . $userId, [
|
||||||
'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back/'. $_SESSION['csrf'],
|
'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back/'. $_SESSION['csrf'],
|
||||||
'value' => template::ico('pencil')
|
'value' => template::ico('pencil')
|
||||||
]),
|
]),
|
||||||
template::button('userDelete' . $userId, [
|
template::button('userDelete' . $userId, [
|
||||||
'class' => 'userDelete buttonRed',
|
'class' => 'userDelete buttonRed',
|
||||||
'href' => helper::baseUrl() . 'user/delete/' . $userId. '/' . $_SESSION['csrf'],
|
'href' => helper::baseUrl() . 'user/delete/' . $userId. '/' . $_SESSION['csrf'],
|
||||||
'value' => template::ico('cancel')
|
'value' => template::ico('cancel')
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_user']['index'][0],
|
||||||
|
'view' => 'index'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_user']['index'][0],
|
|
||||||
'view' => 'index'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,22 +621,32 @@ class user extends common {
|
||||||
* Déconnexion
|
* Déconnexion
|
||||||
*/
|
*/
|
||||||
public function logout() {
|
public function logout() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
$group = $this->getUser('group');
|
||||||
// Ne pas effacer l'identifiant mais seulement le mot de passe
|
if ($group === false ) $group = 0;
|
||||||
if (array_key_exists('DELTA_USER_LONGTIME',$_COOKIE)
|
if( $group < user::$actions['logout'] ) {
|
||||||
AND $_COOKIE['DELTA_USER_LONGTIME'] !== 'true' ) {
|
// Valeurs en sortie
|
||||||
helper::deleteCookie('DELTA_USER_ID');
|
$this->addOutput([
|
||||||
helper::deleteCookie('DELTA_USER_LONGTIME');
|
'access' => false
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Lexique
|
||||||
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
|
// Ne pas effacer l'identifiant mais seulement le mot de passe
|
||||||
|
if (array_key_exists('DELTA_USER_LONGTIME',$_COOKIE)
|
||||||
|
AND $_COOKIE['DELTA_USER_LONGTIME'] !== 'true' ) {
|
||||||
|
helper::deleteCookie('DELTA_USER_ID');
|
||||||
|
helper::deleteCookie('DELTA_USER_LONGTIME');
|
||||||
|
}
|
||||||
|
helper::deleteCookie('DELTA_USER_PASSWORD');
|
||||||
|
session_destroy();
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => $text['core_user']['logout'][0],
|
||||||
|
'redirect' => helper::baseUrl(false),
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
helper::deleteCookie('DELTA_USER_PASSWORD');
|
|
||||||
session_destroy();
|
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'notification' => $text['core_user']['logout'][0],
|
|
||||||
'redirect' => helper::baseUrl(false),
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -662,128 +712,138 @@ class user extends common {
|
||||||
* Importation CSV d'utilisateurs
|
* Importation CSV d'utilisateurs
|
||||||
*/
|
*/
|
||||||
public function import() {
|
public function import() {
|
||||||
// Lexique
|
// Autorisation
|
||||||
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
$group = $this->getUser('group');
|
||||||
// Soumission du formulaire
|
if ($group === false ) $group = 0;
|
||||||
$notification = '';
|
if( $group < user::$actions['import'] ) {
|
||||||
$success = true;
|
// Valeurs en sortie
|
||||||
if($this->isPost()) {
|
$this->addOutput([
|
||||||
// Lecture du CSV et construction du tableau
|
'access' => false
|
||||||
$file = $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true);
|
]);
|
||||||
$filePath = self::FILE_DIR . 'source/' . $file;
|
} else {
|
||||||
if ($file AND file_exists($filePath)) {
|
// Lexique
|
||||||
// Analyse et extraction du CSV
|
include('./core/module/user/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_user.php');
|
||||||
$rows = array_map(function($row) { return str_getcsv($row, $this->getInput('userImportSeparator') ); }, file($filePath));
|
// Soumission du formulaire
|
||||||
$header = array_shift($rows);
|
$notification = '';
|
||||||
$csv = array();
|
$success = true;
|
||||||
foreach($rows as $row) {
|
if($this->isPost()) {
|
||||||
$csv[] = array_combine($header, $row);
|
// Lecture du CSV et construction du tableau
|
||||||
}
|
$file = $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true);
|
||||||
// Traitement des données
|
$filePath = self::FILE_DIR . 'source/' . $file;
|
||||||
foreach($csv as $item ) {
|
if ($file AND file_exists($filePath)) {
|
||||||
// Données valides
|
// Analyse et extraction du CSV
|
||||||
if( array_key_exists('id', $item)
|
$rows = array_map(function($row) { return str_getcsv($row, $this->getInput('userImportSeparator') ); }, file($filePath));
|
||||||
AND array_key_exists('prenom',$item)
|
$header = array_shift($rows);
|
||||||
AND array_key_exists('nom',$item)
|
$csv = array();
|
||||||
AND array_key_exists('groupe',$item)
|
foreach($rows as $row) {
|
||||||
AND array_key_exists('email',$item)
|
$csv[] = array_combine($header, $row);
|
||||||
AND $item['nom']
|
}
|
||||||
AND $item['prenom']
|
// Traitement des données
|
||||||
AND $item['id']
|
foreach($csv as $item ) {
|
||||||
AND $item['email']
|
// Données valides
|
||||||
AND $item['groupe']
|
if( array_key_exists('id', $item)
|
||||||
) {
|
AND array_key_exists('prenom',$item)
|
||||||
// Validation du groupe
|
AND array_key_exists('nom',$item)
|
||||||
$item['groupe'] = (int) $item['groupe'];
|
AND array_key_exists('groupe',$item)
|
||||||
$item['groupe'] = ( $item['groupe'] >= self::GROUP_BANNED AND $item['groupe'] <= self::GROUP_ADMIN )
|
AND array_key_exists('email',$item)
|
||||||
? $item['groupe'] : 1;
|
AND $item['nom']
|
||||||
// L'utilisateur existe
|
AND $item['prenom']
|
||||||
if ( $this->getData(['user',helper::filter($item['id'] , helper::FILTER_ID)]))
|
AND $item['id']
|
||||||
{
|
AND $item['email']
|
||||||
// Notification du doublon
|
AND $item['groupe']
|
||||||
$item['notification'] = template::ico('cancel');
|
) {
|
||||||
// Création du tableau de confirmation
|
// Validation du groupe
|
||||||
self::$users[] = [
|
$item['groupe'] = (int) $item['groupe'];
|
||||||
helper::filter($item['id'] , helper::FILTER_ID),
|
$item['groupe'] = ( $item['groupe'] >= self::GROUP_BANNED AND $item['groupe'] <= self::GROUP_ADMIN )
|
||||||
$item['nom'],
|
? $item['groupe'] : 1;
|
||||||
$item['prenom'],
|
// L'utilisateur existe
|
||||||
$groups[$item['groupe']],
|
if ( $this->getData(['user',helper::filter($item['id'] , helper::FILTER_ID)]))
|
||||||
$item['prenom'],
|
{
|
||||||
helper::filter($item['email'] , helper::FILTER_MAIL),
|
// Notification du doublon
|
||||||
$item['notification']
|
$item['notification'] = template::ico('cancel');
|
||||||
];
|
// Création du tableau de confirmation
|
||||||
// L'utilisateur n'existe pas
|
self::$users[] = [
|
||||||
} else {
|
helper::filter($item['id'] , helper::FILTER_ID),
|
||||||
// Nettoyage de l'identifiant
|
$item['nom'],
|
||||||
$userId = helper::filter($item['id'] , helper::FILTER_ID);
|
$item['prenom'],
|
||||||
// Enregistre le user
|
$groups[$item['groupe']],
|
||||||
$create = $this->setData([
|
$item['prenom'],
|
||||||
'user',
|
helper::filter($item['email'] , helper::FILTER_MAIL),
|
||||||
$userId, [
|
$item['notification']
|
||||||
'firstname' => $item['prenom'],
|
];
|
||||||
'forgot' => 0,
|
// L'utilisateur n'existe pas
|
||||||
'group' => $item['groupe'] ,
|
} else {
|
||||||
'lastname' => $item['nom'],
|
// Nettoyage de l'identifiant
|
||||||
'mail' => $item['email'],
|
$userId = helper::filter($item['id'] , helper::FILTER_ID);
|
||||||
'pseudo' => $item['prenom'],
|
// Enregistre le user
|
||||||
'signature' => 1, // Pseudo
|
$create = $this->setData([
|
||||||
'password' => uniqid(), // A modifier à la première connexion
|
'user',
|
||||||
"connectFail" => null,
|
$userId, [
|
||||||
"connectTimeout" => null,
|
'firstname' => $item['prenom'],
|
||||||
"accessUrl" => null,
|
'forgot' => 0,
|
||||||
"accessTimer" => null,
|
'group' => $item['groupe'] ,
|
||||||
"accessCsrf" => null
|
'lastname' => $item['nom'],
|
||||||
]]);
|
'mail' => $item['email'],
|
||||||
// Icône de notification
|
'pseudo' => $item['prenom'],
|
||||||
$item['notification'] = $create ? template::ico('check') : template::ico('cancel');
|
'signature' => 1, // Pseudo
|
||||||
// Envoi du mail
|
'password' => uniqid(), // A modifier à la première connexion
|
||||||
if ($create
|
"connectFail" => null,
|
||||||
AND $this->getInput('userImportNotification',helper::FILTER_BOOLEAN) === true) {
|
"connectTimeout" => null,
|
||||||
$sent = $this->sendMail(
|
"accessUrl" => null,
|
||||||
$item['email'],
|
"accessTimer" => null,
|
||||||
$text['core_user']['import'][0] . $this->getData(['locale', 'title']),
|
"accessCsrf" => null
|
||||||
$text['core_user']['import'][0].' <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' .
|
]]);
|
||||||
$text['core_user']['import'][2]. $this->getData(['locale', 'title']) . $text['core_user']['import'][3].'<br><br>' .
|
// Icône de notification
|
||||||
'<strong>'.$text['core_user']['import'][4].'</strong> ' . $userId . '<br>' .
|
$item['notification'] = $create ? template::ico('check') : template::ico('cancel');
|
||||||
'<small>'.$text['core_user']['import'][5].'</small>'
|
// Envoi du mail
|
||||||
);
|
if ($create
|
||||||
if ($sent === true) {
|
AND $this->getInput('userImportNotification',helper::FILTER_BOOLEAN) === true) {
|
||||||
// Mail envoyé changement de l'icône
|
$sent = $this->sendMail(
|
||||||
$item['notification'] = template::ico('mail') ;
|
$item['email'],
|
||||||
|
$text['core_user']['import'][0] . $this->getData(['locale', 'title']),
|
||||||
|
$text['core_user']['import'][0].' <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' .
|
||||||
|
$text['core_user']['import'][2]. $this->getData(['locale', 'title']) . $text['core_user']['import'][3].'<br><br>' .
|
||||||
|
'<strong>'.$text['core_user']['import'][4].'</strong> ' . $userId . '<br>' .
|
||||||
|
'<small>'.$text['core_user']['import'][5].'</small>'
|
||||||
|
);
|
||||||
|
if ($sent === true) {
|
||||||
|
// Mail envoyé changement de l'icône
|
||||||
|
$item['notification'] = template::ico('mail') ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Création du tableau de confirmation
|
||||||
|
self::$users[] = [
|
||||||
|
$userId,
|
||||||
|
$item['nom'],
|
||||||
|
$item['prenom'],
|
||||||
|
$groups[$item['groupe']],
|
||||||
|
$item['prenom'],
|
||||||
|
$item['email'],
|
||||||
|
$item['notification']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
// Création du tableau de confirmation
|
|
||||||
self::$users[] = [
|
|
||||||
$userId,
|
|
||||||
$item['nom'],
|
|
||||||
$item['prenom'],
|
|
||||||
$groups[$item['groupe']],
|
|
||||||
$item['prenom'],
|
|
||||||
$item['email'],
|
|
||||||
$item['notification']
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (empty(self::$users)) {
|
||||||
if (empty(self::$users)) {
|
$notification = $text['core_user']['import'][6] ;
|
||||||
$notification = $text['core_user']['import'][6] ;
|
$success = false;
|
||||||
$success = false;
|
} else {
|
||||||
|
$notification = $text['core_user']['import'][7] ;
|
||||||
|
$success = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$notification = $text['core_user']['import'][7] ;
|
$notification = $text['core_user']['import'][8];
|
||||||
$success = true;
|
$success = false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$notification = $text['core_user']['import'][8];
|
|
||||||
$success = false;
|
|
||||||
}
|
}
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'title' => $text['core_user']['import'][9],
|
||||||
|
'view' => 'import',
|
||||||
|
'notification' => $notification,
|
||||||
|
'state' => $success
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'title' => $text['core_user']['import'][9],
|
|
||||||
'view' => 'import',
|
|
||||||
'notification' => $notification,
|
|
||||||
'state' => $success
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue