diff --git a/core/class/layout.class.php b/core/class/layout.class.php index 155983f..4c789da 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -1033,6 +1033,9 @@ class layout extends common $rightItems = ''; if ( $this->getUser('group') >= self::GROUP_EDITOR + // ZwiiCampus ------ + && self::$siteContent !== 'home' + // ZwiiCampus ------ && $this->getUser( 'permission', 'filemanager' diff --git a/core/module/course/course.php b/core/module/course/course.php index b148c71..da25466 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -177,6 +177,9 @@ class course extends common ] ]); + // Dossier du gestionnaire de fichier + mkdir(self::FILE_DIR . 'source/' . $courseId); + // Copie du thème $sourceId = $this->getInput('courseAddTheme'); copy(self::DATA_DIR . $sourceId . '/theme.json', self::DATA_DIR . $courseId . '/theme.json'); @@ -303,6 +306,11 @@ class course extends common $success = $this->deleteDir(self::DATA_DIR . $courseId); $this->deleteData(['course', $courseId]); $this->deleteData(['enrolment', $courseId]); + + } + // Dossier du gestionnaire de fichier + if (is_dir(self::FILE_DIR . 'source/' . $courseId)) { + $this->deleteDir(self::FILE_DIR . 'source/' . $courseId); } // Valeurs en sortie diff --git a/core/module/course/view/index/index.js.php b/core/module/course/view/index/index.js.php index 4ac9fff..5f3fba6 100644 --- a/core/module/course/view/index/index.js.php +++ b/core/module/course/view/index/index.js.php @@ -17,7 +17,7 @@ $(document).ready(function () { */ $(".courseDelete").on("click", function () { var _this = $(this); - var message = ""; + var message = ""; return core.confirm(message, function () { $(location).attr("href", _this.attr("href")); }); diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 654791d..d07a441 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -414,7 +414,7 @@ class init extends common 'copycut' => false, 'chmod' => false, 'share' => true, - 'path' => './site/file/source/partage/', + 'path' => '', ], 'page' => [ 'add' => false, @@ -496,7 +496,7 @@ class init extends common 'copycut' => true, 'chmod' => true, 'share' => true, - 'path' => './site/file/source/partage/', + 'path' => '', ], 'page' => [ 'add' => true, diff --git a/core/module/user/user.php b/core/module/user/user.php index 42a2aed..7c24160 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -651,11 +651,9 @@ class user extends common $oldProfil = $this->getInput('profilEditOldProfil', helper::FILTER_STRING_SHORT); // Gère le chemin $fileManager = $this->getInput('profilEditFileManager', helper::FILTER_BOOLEAN); - $path = $this->getInput('profilEditPath'); + // Sécurité supplémentaire if ( - $group <= self::GROUP_ADMIN - && $fileManager - && empty($path) + $group < self::GROUP_EDITOR ) { $fileManager = false; } @@ -691,7 +689,7 @@ class user extends common 'rename' => $this->getInput('profilEditFolderRename', helper::FILTER_BOOLEAN), 'copycut' => $this->getInput('profilEditFolderCopycut', helper::FILTER_BOOLEAN), 'chmod' => $this->getInput('profilEditFolderChmod', helper::FILTER_BOOLEAN), - 'path' => $path, + 'path' => $this->getInput('profilEditPath'), ], 'page' => [ 'add' => $this->getInput('profilEditPageAdd', helper::FILTER_BOOLEAN), @@ -740,13 +738,8 @@ class user extends common self::$sharePath = $this->getSubdirectories('./site/file/source'); self::$sharePath = array_flip(self::$sharePath); self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); - self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); - - // Chemin vers les dossiers du gestionnaire de fichier - self::$sharePath = $this->getSubdirectories('./site/file/source'); - self::$sharePath = array_flip(self::$sharePath); - self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); - self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); + //self::$sharePath = array_merge(['' => 'Aucun dossier'], self::$sharePath); + self::$sharePath = array_merge(['' => 'Dossier du cours'], self::$sharePath); // Liste des modules installés self::$listModules = helper::getModules(); @@ -809,11 +802,9 @@ class user extends common $profil = count($this->getData(['profil', $group])); // Gère le chemin $fileManager = $this->getInput('profilAddFileManager', helper::FILTER_BOOLEAN); - $path = $this->getInput('profilAddPath'); + // Sécurité supplémentaire if ( - $group <= self::GROUP_ADMIN - && $fileManager - && empty($path) + $group < self::GROUP_EDITOR ) { $fileManager = false; } @@ -846,7 +837,7 @@ class user extends common 'rename' => $this->getInput('profilAddFolderRename', helper::FILTER_BOOLEAN), 'copycut' => $this->getInput('profilAddFolderCopycut', helper::FILTER_BOOLEAN), 'chmod' => $this->getInput('profilAddFolderChmod', helper::FILTER_BOOLEAN), - 'path' => $path, + 'path' => $this->getInput('profilAddPath'), ], 'page' => [ 'add' => $this->getInput('profilAddPageAdd', helper::FILTER_BOOLEAN), @@ -903,13 +894,8 @@ class user extends common self::$sharePath = $this->getSubdirectories('./site/file/source'); self::$sharePath = array_flip(self::$sharePath); self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); - self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); - - // Chemin vers les dossiers du gestionnaire de fichier - self::$sharePath = $this->getSubdirectories('./site/file/source'); - self::$sharePath = array_flip(self::$sharePath); - self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); - self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); + //self::$sharePath = array_merge(['' => 'Aucun dossier'], self::$sharePath); + self::$sharePath = array_merge(['' => 'Dossier du cours'], self::$sharePath); // Liste des modules installés self::$listModules = helper::getModules(); diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index 4caad59..d15262f 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -19,6 +19,7 @@ setlocale(LC_CTYPE, $lang); /* Lecture du groupe de l'utilisateur connecté pour attribuer les droits et les dossiers */ $userId = $_COOKIE['ZWII_USER_ID']; +$courseId = $_COOKIE['ZWII_SITE_CONTENT']; $u = json_decode(file_get_contents('../../../site/data/user.json'), true); $g = json_decode(file_get_contents('../../../site/data/profil.json'), true); @@ -57,7 +58,18 @@ if (!is_null($u) && !is_null($g) && !is_null($userId)) { if (!is_null($profil)) { $file = $g['profil'][$group][$profil]['file']; $folder = $g['profil'][$group][$profil]['folder']; - $uploadDir = $g['profil'][$group][$profil]['folder']['path']; + $uploadDir = './site/file/source/'; + // Pointe vers le dossier du cours + if ( + isset($courseId) + && $courseId != 'home' + && $g['profil'][$group][$profil]['folder']['path'] === '' + ) { + $uploadDir = './site/file/source/' . $courseId . '/'; + } else { + $uploadDir = $g['profil'][$group][$profil]['folder']['path']; + } + $currentPath = '../../../' . $uploadDir; if (!is_dir($currentPath)) { mkdir($currentPath); @@ -121,77 +133,77 @@ define('DEBUG_ERROR_MESSAGE', false); // TRUE or FALSE $config = array( /* - |-------------------------------------------------------------------------- - | DON'T TOUCH (base url (only domain) of site). - |-------------------------------------------------------------------------- - | - | without final / (DON'T TOUCH) - | - */ + |-------------------------------------------------------------------------- + | DON'T TOUCH (base url (only domain) of site). + |-------------------------------------------------------------------------- + | + | without final / (DON'T TOUCH) + | + */ 'base_url' => ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no'))) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . rtrim(str_replace('/core/vendor/filemanager', '', pathinfo($_SERVER['PHP_SELF'])['dirname']), ' /'), /* - |-------------------------------------------------------------------------- - | path from base_url to base of upload folder - |-------------------------------------------------------------------------- - | - | with start and final / - | - */ + |-------------------------------------------------------------------------- + | path from base_url to base of upload folder + |-------------------------------------------------------------------------- + | + | with start and final / + | + */ 'upload_dir' => $uploadDir, /* - |-------------------------------------------------------------------------- - | relative path from filemanager folder to upload folder - |-------------------------------------------------------------------------- - | - | with final / - | - */ + |-------------------------------------------------------------------------- + | relative path from filemanager folder to upload folder + |-------------------------------------------------------------------------- + | + | with final / + | + */ 'current_path' => $currentPath, /* - |-------------------------------------------------------------------------- - | relative path from filemanager folder to thumbs folder - |-------------------------------------------------------------------------- - | - | with final / - | DO NOT put inside upload folder - | - */ + |-------------------------------------------------------------------------- + | relative path from filemanager folder to thumbs folder + |-------------------------------------------------------------------------- + | + | with final / + | DO NOT put inside upload folder + | + */ 'thumbs_base_path' => '../../../site/file/thumb/', /* - |-------------------------------------------------------------------------- - | path from base_url to base of thumbs folder - |-------------------------------------------------------------------------- - | - | with final / - | DO NOT put inside upload folder - | - */ + |-------------------------------------------------------------------------- + | path from base_url to base of thumbs folder + |-------------------------------------------------------------------------- + | + | with final / + | DO NOT put inside upload folder + | + */ 'thumbs_upload_dir' => '/thumb/', /* - |-------------------------------------------------------------------------- - | mime file control to define files extensions - |-------------------------------------------------------------------------- - | - | If you want to be forced to assign the extension starting from the mime type - | - */ + |-------------------------------------------------------------------------- + | mime file control to define files extensions + |-------------------------------------------------------------------------- + | + | If you want to be forced to assign the extension starting from the mime type + | + */ 'mime_extension_rename' => false, /* - |-------------------------------------------------------------------------- - | FTP configuration BETA VERSION - |-------------------------------------------------------------------------- - | - | If you want enable ftp use write these parametres otherwise leave empty - | Remember to set base_url properly to point in the ftp server domain and - | upload dir will be ftp_base_folder + upload_dir so without final / - | - */ + |-------------------------------------------------------------------------- + | FTP configuration BETA VERSION + |-------------------------------------------------------------------------- + | + | If you want enable ftp use write these parametres otherwise leave empty + | Remember to set base_url properly to point in the ftp server domain and + | upload dir will be ftp_base_folder + upload_dir so without final / + | + */ 'ftp_host' => false, //put the FTP host 'ftp_user' => "user", @@ -201,52 +213,52 @@ $config = array( // Directory where place files before to send to FTP with final / 'ftp_temp_folder' => "../temp/", /* - |--------------------------------------------------------------------------- - | path from ftp_base_folder to base of thumbs folder with start and final / - |--------------------------------------------------------------------------- - */ + |--------------------------------------------------------------------------- + | path from ftp_base_folder to base of thumbs folder with start and final / + |--------------------------------------------------------------------------- + */ 'ftp_thumbs_dir' => '/thumbs/', 'ftp_ssl' => false, 'ftp_port' => 21, /* EXAMPLE - 'ftp_host' => "host.com", - 'ftp_user' => "test@host.com", - 'ftp_pass' => "pass.1", - 'ftp_base_folder' => "", - 'ftp_base_url' => "http://host.com/testFTP", - */ + 'ftp_host' => "host.com", + 'ftp_user' => "test@host.com", + 'ftp_pass' => "pass.1", + 'ftp_base_folder' => "", + 'ftp_base_url' => "http://host.com/testFTP", + */ /* - |-------------------------------------------------------------------------- - | Multiple files selection - |-------------------------------------------------------------------------- - | The user can delete multiple files, select all files , deselect all files - */ + |-------------------------------------------------------------------------- + | Multiple files selection + |-------------------------------------------------------------------------- + | The user can delete multiple files, select all files , deselect all files + */ 'multiple_selection' => true, /* - | - | The user can have a select button that pass a json to external input or pass the first file selected to editor - | If you use responsivefilemanager tinymce extension can copy into editor multiple object like images, videos, audios, links in the same time - | - */ + | + | The user can have a select button that pass a json to external input or pass the first file selected to editor + | If you use responsivefilemanager tinymce extension can copy into editor multiple object like images, videos, audios, links in the same time + | + */ 'multiple_selection_action_button' => true, /* - |-------------------------------------------------------------------------- - | Access keys - |-------------------------------------------------------------------------- - | - | add access keys eg: array('myPrivateKey', 'someoneElseKey'); - | keys should only containt (a-z A-Z 0-9 \ . _ -) characters - | if you are integrating lets say to a cms for admins, i recommend making keys randomized something like this: - | $username = 'Admin'; - | $salt = 'dsflFWR9u2xQa' (a hard coded string) - | $akey = md5($username.$salt); - | DO NOT use 'key' as access key! - | Keys are CASE SENSITIVE! - | - */ + |-------------------------------------------------------------------------- + | Access keys + |-------------------------------------------------------------------------- + | + | add access keys eg: array('myPrivateKey', 'someoneElseKey'); + | keys should only containt (a-z A-Z 0-9 \ . _ -) characters + | if you are integrating lets say to a cms for admins, i recommend making keys randomized something like this: + | $username = 'Admin'; + | $salt = 'dsflFWR9u2xQa' (a hard coded string) + | $akey = md5($username.$salt); + | DO NOT use 'key' as access key! + | Keys are CASE SENSITIVE! + | + */ 'access_keys' => array($privateKey), @@ -255,51 +267,51 @@ $config = array( //-------------------------------------------------------------------------------------------------------- /* - |-------------------------------------------------------------------------- - | Maximum size of all files in source folder - |-------------------------------------------------------------------------- - | - | in Megabytes - | - */ + |-------------------------------------------------------------------------- + | Maximum size of all files in source folder + |-------------------------------------------------------------------------- + | + | in Megabytes + | + */ 'MaxSizeTotal' => false, /* - |-------------------------------------------------------------------------- - | Maximum upload size - |-------------------------------------------------------------------------- - | - | in Megabytes - | - */ + |-------------------------------------------------------------------------- + | Maximum upload size + |-------------------------------------------------------------------------- + | + | in Megabytes + | + */ 'MaxSizeUpload' => 20000, /* - |-------------------------------------------------------------------------- - | File and Folder permission - |-------------------------------------------------------------------------- - | - */ + |-------------------------------------------------------------------------- + | File and Folder permission + |-------------------------------------------------------------------------- + | + */ 'filePermission' => 0755, 'folderPermission' => 0777, /* - |-------------------------------------------------------------------------- - | default language file name - |-------------------------------------------------------------------------- - */ + |-------------------------------------------------------------------------- + | default language file name + |-------------------------------------------------------------------------- + */ 'default_language' => 'fr_FR', /* - |-------------------------------------------------------------------------- - | Icon theme - |-------------------------------------------------------------------------- - | - | Default available: ico and ico_dark - | Can be set to custom icon inside filemanager/img - | - */ + |-------------------------------------------------------------------------- + | Icon theme + |-------------------------------------------------------------------------- + | + | Default available: ico and ico_dark + | Can be set to custom icon inside filemanager/img + | + */ 'icon_theme' => "ico", @@ -337,12 +349,12 @@ $config = array( 'image_max_height' => 0, 'image_max_mode' => 'auto', /* - # $option: 0 / exact = defined size; - # 1 / portrait = keep aspect set height; - # 2 / landscape = keep aspect set width; - # 3 / auto = auto; - # 4 / crop= resize and crop; - */ + # $option: 0 / exact = defined size; + # 1 / portrait = keep aspect set height; + # 2 / landscape = keep aspect set width; + # 3 / auto = auto; + # 4 / crop= resize and crop; + */ //Automatic resizing // // If you set $image_resizing to TRUE the script converts all uploaded images exactly to image_resizing_width x image_resizing_height dimension @@ -477,13 +489,13 @@ $config = array( 'empty_filename' => false, /* - |-------------------------------------------------------------------------- - | accept files without extension - |-------------------------------------------------------------------------- - | - | If you want to accept files without extension, remember to add '' extension on allowed extension - | - */ + |-------------------------------------------------------------------------- + | accept files without extension + |-------------------------------------------------------------------------- + | + | If you want to accept files without extension, remember to add '' extension on allowed extension + | + */ 'files_without_extension' => false, /****************** @@ -604,12 +616,12 @@ $config = array( 'fixed_image_creation_height' => array(480), //height of image /* - # $option: 0 / exact = defined size; - # 1 / portrait = keep aspect set height; - # 2 / landscape = keep aspect set width; - # 3 / auto = auto; - # 4 / crop= resize and crop; - */ + # $option: 0 / exact = defined size; + # 1 / portrait = keep aspect set height; + # 2 / landscape = keep aspect set width; + # 3 / auto = auto; + # 4 / crop= resize and crop; + */ 'fixed_image_creation_option' => array('auto', 'crop'), //set the type of the crop @@ -632,12 +644,12 @@ $config = array( 'relative_image_creation_height' => array(200, 300), //height of image /* - # $option: 0 / exact = defined size; - # 1 / portrait = keep aspect set height; - # 2 / landscape = keep aspect set width; - # 3 / auto = auto; - # 4 / crop= resize and crop; - */ + # $option: 0 / exact = defined size; + # 1 / portrait = keep aspect set height; + # 2 / landscape = keep aspect set width; + # 3 / auto = auto; + # 4 / crop= resize and crop; + */ 'relative_image_creation_option' => array('crop', 'crop'), //set the type of the crop