Skip to content

Commit

Permalink
Eoxia#32 [Rework] add: saturne
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-charles committed Aug 29, 2024
1 parent 471592f commit c9095ad
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 67 deletions.
2 changes: 2 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
47 changes: 15 additions & 32 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,14 @@

// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER['CONTEXT_DOCUMENT_ROOT'])) {
$res = @include $_SERVER['CONTEXT_DOCUMENT_ROOT']. '/main.inc.php';
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)). '/main.inc.php')) {
$res = @include substr($tmp, 0, ($i + 1)). '/main.inc.php';
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php')) {
$res = @include dirname(substr($tmp, 0, ($i + 1))). '/main.inc.php';
}
// Try main.inc.php using relative path
if (!$res && file_exists('../../main.inc.php')) {
$res = @include '../../main.inc.php';
}
if (!$res && file_exists('../../../main.inc.php')) {
$res = @include '../../../main.inc.php';
}
if (!$res) {
die('Include of main fails');

// Load Priseo environment
if (file_exists('../priseo.main.inc.php')) {
require_once __DIR__ . '/../priseo.main.inc.php';
} elseif (file_exists('../../priseo.main.inc.php')) {
require_once __DIR__ . '/../../priseo.main.inc.php';
} else {
die('Include of priseo main fails');
}

// Libraries
Expand All @@ -58,17 +42,16 @@
// Global variables definitions
global $db, $langs, $user;

// Translations
$langs->loadLangs(['admin', 'priseo@priseo']);
// Load translation files required by the page
saturne_load_langs();

// Parameters
$backtopage = GETPOST('backtopage', 'alpha');

// Access control
$permissiontoread = $user->rights->priseo->adminpage->read;
if (empty($conf->priseo->enabled) || !$permissiontoread) {
accessforbidden();
}
// Security check - Protection if external user
$permissionToRead = $user->rights->gmao->adminpage->read;
saturne_check_access($permissionToRead);


/*
* View
Expand All @@ -77,7 +60,7 @@
$help_url = 'FR:Module_Priseo';
$title = $langs->trans('PriseoSetup');

llxHeader('', $title, $help_url);
saturne_header(0,'', $title, $help_url);

// Subheader
$linkback = '<a href="'.($backtopage ?: DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans('BackToModuleList').'</a>';
Expand Down
2 changes: 2 additions & 0 deletions class/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
8 changes: 7 additions & 1 deletion core/modules/modPriseo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ public function __construct($db)
global $langs, $conf;
$this->db = $db;

$langs->load('priseo@priseo');
if (file_exists(__DIR__ . '/../../../saturne/lib/saturne_functions.lib.php')) {
require_once __DIR__ . '/../../../saturne/lib/saturne_functions.lib.php';
saturne_load_langs(['gmao@gmao']);
} else {
$this->error++;
$this->errors[] = $langs->trans('activateModuleDependNotSatisfied', 'GMAO', 'Saturne');
}

// ID for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).
Expand Down
2 changes: 2 additions & 0 deletions core/modules/priseo/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
2 changes: 2 additions & 0 deletions lib/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
2 changes: 1 addition & 1 deletion lib/priseo.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function priseoAdminPrepareHead()
global $conf, $langs;

// Load translation files required by the page
$langs->load('priseo@priseo');
saturne_load_langs();

// Initialize values
$h = 0;
Expand Down
35 changes: 35 additions & 0 deletions priseo.main.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/* Copyright (C) 2024 EVARISK <[email protected]>
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file priseo.main.inc.php
* \ingroup priseo
* \brief File that defines environment for Saturne common functions
*/

$moduleName = 'Priseo';
$moduleNameLowerCase = strtolower($moduleName);
$moduleNameUpperCase = strtoupper($moduleName);

// Load Saturne environment
if (file_exists(__DIR__ . '/../saturne/saturne.main.inc.php')) {
require_once __DIR__ . '/../saturne/saturne.main.inc.php';
} elseif (file_exists(__DIR__ . '/../../saturne/saturne.main.inc.php')) {
require_once __DIR__ . '/../../saturne/saturne.main.inc.php';
} else {
die('Include of saturne main fails');
}
40 changes: 7 additions & 33 deletions view/competitorprice_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,13 @@
* \brief Page to create/edit/view competitorprice
*/

// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER['CONTEXT_DOCUMENT_ROOT'])) {
$res = @include $_SERVER['CONTEXT_DOCUMENT_ROOT'] . '/main.inc.php';
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
$tmp2 = realpath(__FILE__);
$i = strlen($tmp) - 1;
$j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . '/main.inc.php')) {
$res = @include substr($tmp, 0, ($i + 1)) . '/main.inc.php';
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . '/main.inc.php')) {
$res = @include dirname(substr($tmp, 0, ($i + 1))) . '/main.inc.php';
}
// Try main.inc.php using relative path
if (!$res && file_exists('../main.inc.php')) {
$res = @include '../main.inc.php';
}
if (!$res && file_exists('../../main.inc.php')) {
$res = @include '../../main.inc.php';
}
if (!$res && file_exists('../../../main.inc.php')) {
$res = @include '../../../main.inc.php';
}
if (!$res) {
die('Include of main fails');
// Load DigiQuali environment
if (file_exists('../priseo.main.inc.php')) {
require_once __DIR__ . '/../priseo.main.inc.php';
} elseif (file_exists('../../priseo.main.inc.php')) {
require_once __DIR__ . '/../../priseo.main.inc.php';
} else {
die('Include of priseo main fails');
}

// Libraries
Expand Down
2 changes: 2 additions & 0 deletions view/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden

0 comments on commit c9095ad

Please sign in to comment.