diff --git a/admin/about.php b/admin/about.php index 7f9dfe17..12f4f7b3 100644 --- a/admin/about.php +++ b/admin/about.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2022-2024 EVARISK * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,10 @@ /** * \file admin/about.php * \ingroup saturne - * \brief About page of module Saturne. + * \brief About page of module Saturne */ -// Load Saturne environment. +// Load Saturne environment if (file_exists('../saturne.main.inc.php')) { require_once __DIR__ . '/../saturne.main.inc.php'; } elseif (file_exists('../../saturne.main.inc.php')) { @@ -30,52 +30,48 @@ die('Include of saturne main fails'); } -// Get module parameters. +// Get module parameters $moduleName = GETPOST('module_name', 'alpha'); -$moduleNameLowerCase = strtolower($moduleName); +$moduleNameLowerCase = dol_strtolower($moduleName); -// Load Module Libraries. -require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/lib/' . $moduleNameLowerCase . '.lib.php'; -require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/core/modules/mod' . $moduleName . '.class.php'; +// Load Module libraries +saturne_load_module_files($moduleName, []); -// Global variables definitions. +// Global variables definitions global $db, $langs, $user; -// Load translation files required by the page. +// Load translation files required by the page saturne_load_langs(['admin']); -// Initialize technical objects. +// Initialize technical objects $className = 'mod' . $moduleName; $modModule = new $className($db); -// Get parameters. -$backtopage = GETPOST('backtopage', 'alpha'); - -// Security check - Protection if external user. -$permissiontoread = $user->rights->$moduleNameLowerCase->adminpage->read; -saturne_check_access($permissiontoread); +// Security check - Protection if external user +$permissionToRead = $user->hasRight($moduleNameLowerCase, 'adminpage', 'read'); +saturne_check_access($permissionToRead); /* * View */ -$title = $langs->trans('ModuleSetup', $moduleName); -$help_url = 'FR:Module_' . $moduleName; +$title = $langs->trans('ModuleSetup', $moduleName); +$helpUrl = 'FR:Module_' . $moduleName; -saturne_header(0, '', $title, $help_url); +saturne_header(0, '', $title, $helpUrl); -// Subheader. -$linkback = '' . $langs->trans('BackToModuleList') . ''; -print load_fiche_titre($title, $linkback, 'title_setup'); +// Subheader +$linkBack = '' . $langs->trans('BackToModuleList') . ''; +print load_fiche_titre($title, $linkBack, 'title_setup'); -// Configuration header. +// Configuration header $preHead = $moduleNameLowerCase . '_admin_prepare_head'; -$head = $preHead(); +$head = $preHead(); print dol_get_fiche_head($head, 'about', $title, -1, $moduleNameLowerCase . '_color@' . $moduleNameLowerCase); print $modModule->getDescLong(); -// Page end. +// Page end print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/admin/information.php b/admin/information.php index 9b17f9ea..22d0bec1 100644 --- a/admin/information.php +++ b/admin/information.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2022-2024 EVARISK * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,37 +37,40 @@ require_once __DIR__ . '/../lib/saturne.lib.php'; // Global variables definitions -global $db, $langs; +global $db, $langs, $user; // Load translation files required by the page saturne_load_langs(['admin']); // Get parameters -$filename = GETPOST('filename', 'alpha'); -$tabName = GETPOST('tab_name', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); +$fileName = GETPOST('filename', 'alpha'); +$tabName = GETPOST('tab_name', 'alpha'); // Initialize technical objects $parsedown = new Parsedown(); +// Security check - Protection if external user +$permissionToRead = $user->hasRight('saturne', 'adminpage', 'read'); +saturne_check_access($permissionToRead); + /* * View */ -$title = $langs->trans('ModuleSetup', 'Saturne'); -$help_url = 'FR:Module_Saturne'; +$title = $langs->trans('ModuleSetup', 'Saturne'); +$helpUrl = 'FR:Module_Saturne'; -saturne_header(0, '', $title, $help_url); +saturne_header(0, '', $title, $helpUrl); // Subheader -$linkback = '' . $langs->trans('BackToModuleList') . ''; -print load_fiche_titre($title, $linkback, 'title_setup'); +$linkBack = '' . $langs->trans('BackToModuleList') . ''; +print load_fiche_titre($title, $linkBack, 'title_setup'); // Configuration header $head = saturne_admin_prepare_head(); print dol_get_fiche_head($head, $tabName, $title, -1, 'saturne_color@saturne'); -$filePath = dol_buildpath('saturne/' . $filename . '.md'); +$filePath = dol_buildpath('saturne/' . $fileName . '.md'); $content = file_get_contents($filePath); print $parsedown->text($content); diff --git a/admin/object.php b/admin/object.php index ea251683..173a46a2 100644 --- a/admin/object.php +++ b/admin/object.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2021-2024 EVARISK * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ /** * \file admin/object/object.php * \ingroup saturne - * \brief Saturne object config page. + * \brief Saturne object config page */ // Load Saturne environment @@ -34,7 +34,7 @@ $moduleName = GETPOST('module_name', 'alpha'); $objectType = GETPOST('object_type', 'alpha'); -// If the previous action is from extrafields, the return value is PHP_SELF without querys +// If the previous action is from extra fields, the return value is PHP_SELF without query's // So we need to fill moduleName and objectType using the previous url (HTTP_REFERER) if (empty($moduleName) && empty($objectType)) { $lastUrl = $_SERVER['HTTP_REFERER']; @@ -50,12 +50,13 @@ } } -$moduleNameLowerCase = strtolower($moduleName); +$moduleNameLowerCase = dol_strtolower($moduleName); -// Libraries +// Load Dolibarr libraries require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/lib/' . $moduleNameLowerCase . '.lib.php'; +// Load Module libraries +saturne_load_module_files($moduleName, []); require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/class/' . $objectType . '.class.php'; // Global variables definitions @@ -65,8 +66,7 @@ saturne_load_langs(['admin']); // Get parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); // Initialize technical objects $className = ucfirst($objectType); @@ -75,11 +75,11 @@ // Initialize view objects $form = new Form($db); -$hookmanager->initHooks([$objectType . 'admin']); // Note that conf->hooks_modules contains array. +$hookmanager->initHooks([$objectType . 'admin']); // Note that conf->hooks_modules contains array // Security check - Protection if external user -$permissiontoread = $user->rights->$moduleNameLowerCase->adminpage->read; -saturne_check_access($permissiontoread); +$permissionToRead = $user->hasRight($moduleNameLowerCase, 'adminpage', 'read'); +saturne_check_access($permissionToRead); /* * View @@ -91,12 +91,12 @@ saturne_header(0,'', $title, $help_url); // Subheader -$linkback = '' . $langs->trans('BackToModuleList') . ''; -print load_fiche_titre($title, $linkback, 'title_setup'); +$linkBack = '' . $langs->trans('BackToModuleList') . ''; +print load_fiche_titre($title, $linkBack, 'title_setup'); // Configuration header $preHead = $moduleNameLowerCase . '_admin_prepare_head'; -$head = $preHead(); +$head = $preHead(); print dol_get_fiche_head($head, $object->element, $title, -1, $moduleNameLowerCase . '_color@' . $moduleNameLowerCase); require_once __DIR__ . '/../core/tpl/admin/object/object_numbering_module_view.tpl.php'; diff --git a/admin/pwa.php b/admin/pwa.php index 69227069..cc122c63 100644 --- a/admin/pwa.php +++ b/admin/pwa.php @@ -33,19 +33,19 @@ // Get module parameters $moduleName = GETPOST('module_name', 'alpha'); $startUrl = GETPOST('start_url', 'alpha'); -$moduleNameLowerCase = strtolower($moduleName); +$moduleNameLowerCase = dol_strtolower($moduleName); // Load Dolibarr libraries require_once TCPDF_PATH . 'tcpdf_barcodes_2d.php'; -// Load Module Libraries -require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/lib/' . $moduleNameLowerCase . '.lib.php'; +// Load Module libraries +saturne_load_module_files($moduleName); // Global variables definitions global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page -saturne_load_langs(); +saturne_load_langs(['admin']); // Get parameters $action = GETPOST('action', 'alpha'); @@ -56,7 +56,7 @@ $hookmanager->initHooks([$moduleNameLowerCase . 'pwaadmin', 'saturneadmin']); // Note that conf->hooks_modules contains array // Security check - Protection if external user -$permissionToRead = $user->rights->$moduleNameLowerCase->adminpage->read; +$permissionToRead = $user->hasRight($moduleNameLowerCase, 'adminpage', 'read'); saturne_check_access($permissionToRead); /* @@ -66,14 +66,13 @@ if ($action == 'generate_QRCode') { $urlToEncode = GETPOST('urlToEncode'); - $barcode = new TCPDF2DBarcode($urlToEncode, 'QRCODE,L'); + $barcode = new TCPDF2DBarcode($urlToEncode, 'QRCODE,H'); dol_mkdir($conf->$moduleNameLowerCase->multidir_output[$conf->entity] . '/pwa/qrcode/'); $file = $conf->$moduleNameLowerCase->multidir_output[$conf->entity] . '/pwa/qrcode/' . 'barcode_' . dol_print_date(dol_now(), 'dayhourlog') . '.png'; $imageData = $barcode->getBarcodePngData(); - $imageData = imagecreatefromstring($imageData); - imagepng($imageData, $file); + file_put_contents($file, $imageData); setEventMessage('SavedConfig'); header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName . '&start_url=' . $urlToEncode); @@ -90,7 +89,7 @@ saturne_header(0, '', $title, $helpUrl); // Subheader -$linkBack = '' . $langs->trans('BackToModuleList') . ''; +$linkBack = '' . $langs->trans('BackToModuleList') . ''; print load_fiche_titre($title, $linkBack, 'title_setup'); // Configuration header @@ -107,7 +106,7 @@ print '
'; print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/admin/redirection.php b/admin/redirection.php index 66bdfde2..f012b8a3 100644 --- a/admin/redirection.php +++ b/admin/redirection.php @@ -37,7 +37,7 @@ // Load Dolibarr libraries require_once TCPDF_PATH . 'tcpdf_barcodes_2d.php'; -// Load Module libraries +// Load Saturne libraries require_once __DIR__ . '/../lib/saturne.lib.php'; require_once __DIR__ . '/../class/saturneredirection.class.php'; @@ -45,7 +45,7 @@ global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page -saturne_load_langs(); +saturne_load_langs(['admin']); // Get parameters $action = GETPOST('action', 'alpha'); @@ -61,7 +61,7 @@ $hookmanager->initHooks([$moduleNameLowerCase . 'redirectionadmin', 'saturneadmin']); // Note that conf->hooks_modules contains array // Security check - Protection if external user -$permissionToRead = $user->rights->$moduleNameLowerCase->adminpage->read; +$permissionToRead = $user->hasRight($moduleNameLowerCase, 'adminpage', 'read'); saturne_check_access($permissionToRead); /* @@ -117,8 +117,8 @@ saturne_header(0, '', $title, $helpUrl); // Subheader -$linkBack = '' . $langs->trans('BackToModuleList') . ''; -print load_fiche_titre($title, '', 'title_setup'); +$linkBack = '' . $langs->trans('BackToModuleList') . ''; +print load_fiche_titre($title, $linkBack, 'title_setup'); // Configuration header $preHead = $moduleNameLowerCase . '_admin_prepare_head'; diff --git a/admin/setup.php b/admin/setup.php index 8d83f03b..b78ea77d 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2022-2024 EVARISK * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,22 +18,19 @@ /** * \file admin/setup.php * \ingroup saturne - * \brief Saturne setup page. + * \brief Saturne setup page */ // Load Saturne environment if (file_exists('../saturne.main.inc.php')) { - require_once __DIR__ . '/../saturne.main.inc.php'; + require_once __DIR__ . '/../saturne.main.inc.php'; } elseif (file_exists('../../saturne.main.inc.php')) { - require_once __DIR__ . '/../../saturne.main.inc.php'; + require_once __DIR__ . '/../../saturne.main.inc.php'; } else { die('Include of saturne main fails'); } - -// Libraries -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; - +// Load Saturne libraries require_once __DIR__ . '/../lib/saturne.lib.php'; // Global variables definitions @@ -46,13 +43,12 @@ $form = new Form($db); // Parameters -$action = GETPOST('action', 'alpha'); -$value = GETPOST('value', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); // Security check - Protection if external user -$permissiontoread = $user->rights->saturne->adminpage->read; -saturne_check_access($permissiontoread); +$permissionToRead = $user->hasRight('saturne', 'adminpage', 'read'); +saturne_check_access($permissionToRead); /* * Actions @@ -82,15 +78,14 @@ * View */ -$title = $langs->trans('ModuleSetup', 'Saturne'); -$help_url = 'FR:Module_Saturne#Configuration'; +$title = $langs->trans('ModuleSetup', 'Saturne'); +$helpUrl = 'FR:Module_Saturne#Configuration'; -saturne_header(0,'', $title, $help_url); +saturne_header(0,'', $title, $helpUrl); // Subheader -$linkback = '' . $langs->trans('BackToModuleList') . ''; - -print load_fiche_titre($title, $linkback, 'title_setup'); +$linkBack = '' . $langs->trans('BackToModuleList') . ''; +print load_fiche_titre($title, $linkBack, 'title_setup'); // Configuration header $head = saturne_admin_prepare_head(); @@ -160,7 +155,6 @@ print ajax_constantonoff('SATURNE_ATTENDANTS_ADD_STATUS_MANAGEMENT'); print ''; - // Use fast upload improvement print '
'; print $langs->trans('UseFastUploadImprovement'); @@ -178,7 +172,7 @@ print ''; print ''; print ''; -print ''; +print '
'; print ''; print ''; print '';
' . $langs->trans('Name') . '' . $langs->trans('Description') . '