Skip to content

Commit

Permalink
Merge pull request #896 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
nicolas-eoxia authored Apr 2, 2024
2 parents 7382aef + d03904d commit 49ca309
Show file tree
Hide file tree
Showing 57 changed files with 2,245 additions and 992 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
/.gitattributes
node_modules
package-lock.json
/.idea
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
## Informations

- Numéro du module : 436318
- Dernière mise à jour : 19/01/2024
- Dernière mise à jour : 02/04/2024
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

### Version

- Version : 1.2.1
- Version : 1.3.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.4
- Compatibilité : Dolibarr 16.0.0 - 19.0.1

## Liens

Expand Down
79 changes: 41 additions & 38 deletions admin/documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
/**
* \file admin/documents.php
* \ingroup saturne
* \brief Saturne documents page.
* \brief Saturne documents page
*/

// 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')) {
Expand All @@ -30,71 +30,64 @@
die('Include of saturne main fails');
}

// Get module parameters.
// Get module parameters
$moduleName = GETPOST('module_name', 'alpha');
$moduleNameLowerCase = strtolower($moduleName);

// Load Dolibarr libraries.
// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';

// Load Module libraries.
// Load Module libraries
require_once __DIR__ . '/../../' . $moduleNameLowerCase . '/lib/' . $moduleNameLowerCase . '.lib.php';

// Global variables definitions.
// Global variables definitions
global $conf, $db, $hookmanager, $langs, $user;

// Load translation files required by the page.
// Load translation files required by the page
saturne_load_langs(['admin']);

// Initialize view objects.
// Initialize view objects
$form = new Form($db);

// Get parameters.
// Get parameters
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$type = GETPOST('type', 'alpha');
$const = GETPOST('const', 'alpha');
$label = GETPOST('label', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php.
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php

$hookmanager->initHooks([$moduleNameLowerCase . 'admindocuments']); // Note that conf->hooks_modules contains array.
$hookmanager->initHooks([$moduleNameLowerCase . 'admindocuments']); // Note that conf->hooks_modules contains array

// Security check - Protection if external user.
// Security check - Protection if external user
$permissiontoread = $user->rights->$moduleNameLowerCase->adminpage->read;
saturne_check_access($permissiontoread);

/*
* Actions
*/

// Activate a model.
// Actions set_mod, update_mask
require_once __DIR__ . '/../core/tpl/actions/admin_conf_actions.tpl.php';

// Activate a model
if ($action == 'set') {
addDocumentModel($value, $type, $label, $const);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName . '#' . $type);
exit;
} elseif ($action == 'del') {
delDocumentModel($value, $type);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName . '#' . $type);
exit;
}

// Set default model.
// Set default model
if ($action == 'setdoc') {
$constforval = strtoupper($moduleName) . '_' . strtoupper($type) . '_DEFAULT_MODEL';
$label = '';

if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
$conf->global->$constforval = $value;
}

// Active model.
$ret = delDocumentModel($value, $type);

if ($ret > 0) {
$ret = addDocumentModel($value, $type, $label);
}
} elseif ($action == 'setmod') {
$constforval = strtoupper($moduleName) . '_' . strtoupper($type) . '_ADDON';
dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
$confName = dol_strtoupper($moduleName . '_' . $type) . '_DEFAULT_MODEL';
dolibarr_set_const($db, $confName, $value, 'chaine', 0, '', $conf->entity);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName . '#' . $type);
exit;
}

if ($action == 'deletefile' && $modulepart == 'ecm' && !empty($user->admin)) {
Expand Down Expand Up @@ -123,7 +116,8 @@
$result = dol_delete_file($filetodelete);
if ($result > 0) {
setEventMessages($langs->trans('FileWasRemoved', GETPOST('file')), null);
header('Location: ' . $_SERVER['PHP_SELF']);
header('Location: ' . $_SERVER['PHP_SELF'] . '?module_name=' . $moduleName . '#' . $type);
exit;
}
}

Expand Down Expand Up @@ -166,9 +160,9 @@
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('File')), null, 'errors');
}
}
if (preg_match('/__.*__/', $_FILES['userfile']['name'][$key])) {
if (pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION) != 'odt') {
$error++;
setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors');
setEventMessages($langs->trans('ErrorWrongFileNameExtension', $_FILES['userfile']['name']), [], 'errors');
}
}

Expand All @@ -179,7 +173,6 @@
}
}
}

}

if ($action == 'update_documents_config') {
Expand Down Expand Up @@ -227,6 +220,16 @@
}
}

if ($action == 'download_template') {
$fileName = GETPOST('filename');
dol_copy(DOL_DOCUMENT_ROOT . '/custom/' . $moduleNameLowerCase . '/documents/doctemplates/' . $type . '/' . $fileName, DOL_DOCUMENT_ROOT . '/custom/' . $moduleNameLowerCase . '/documents/temp/' . $fileName);
}

if ($action == 'remove_file') {
$fileName = GETPOST('filename');
dol_delete_file(DOL_DOCUMENT_ROOT . '/custom/' . $moduleNameLowerCase . '/documents/temp/' . $fileName);
}

/*
* View
*/
Expand All @@ -245,7 +248,7 @@
// Subheader
$selectorAnchor = '<select onchange="location = this.value;">';
foreach ($types as $type => $documentType) {
$selectorAnchor .= '<option value="#' . $langs->trans($type) . '">' . $langs->trans($type) . '</option>';
$selectorAnchor .= '<option value="#' . dol_strtolower($type) . '">' . $langs->trans($type) . '</option>';
}
$selectorAnchor .= '</select>';

Expand Down Expand Up @@ -346,7 +349,7 @@

$object = new $type($db);

print load_fiche_titre($langs->trans($type), '', $documentData['picto'], 0, $langs->trans($type));
print load_fiche_titre($langs->trans($type), '', $documentData['picto'], 0, dol_strtolower($type));

$documentPath = true;

Expand Down
9 changes: 9 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@
print '</td><td class="center">';
print ajax_constantonoff('SATURNE_USE_ALL_EMAIL_MODE');
print '</td></tr>';

// Use fast upload improvement
print '<tr class="oddeven"><td>';
print $langs->trans('UseFastUploadImprovement');
print '</td><td>';
print $langs->transnoentities('UseFastUploadImprovementDescription');
print '</td><td class="center">';
print ajax_constantonoff('SATURNE_USE_FAST_UPLOAD_IMPROVEMENT');
print '</td></tr>';
print '</table>';

// Page end
Expand Down
Loading

0 comments on commit 49ca309

Please sign in to comment.