Skip to content

Commit

Permalink
#116 [Mod] add: Include file for use saturne framework
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jan 26, 2023
1 parent 7658f60 commit c50d17b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
32 changes: 32 additions & 0 deletions dolimeet.main.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/* Copyright (C) 2023 EVARISK <dev@evarisk.com>
*
* 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 dolimeet.main.inc.php
* \ingroup dolimeet
* \brief File that defines environment for Saturne common functions
*/

$moduleName = 'DoliMeet';
$moduleNameLowerCase = strtolower($moduleName);

// Load Saturne environment
if (file_exists(__DIR__ . '/../saturne/saturne.main.inc.php')) {
require_once __DIR__ . '/../saturne/saturne.main.inc.php';
} else {
die('Include of saturne main fails');
}
39 changes: 19 additions & 20 deletions dolimeetindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,44 @@
* \brief Home page of dolimeet top menu
*/

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

// Libraries
require_once __DIR__ . '/core/modules/modDoliMeet.class.php';

// Global variables definitions
global $conf, $db, $langs, $user;
global $conf, $db, $langs, $moduleName, $moduleNameLowerCase, $user;

// Libraries
require_once __DIR__ . '/core/modules/mod' . $moduleName . '.class.php';

// Load translation files required by the page
$langs->loadLangs(['dolimeet@dolimeet']);
$langs->loadLangs([$moduleNameLowerCase . '@' . $moduleNameLowerCase]);

// Initialize technical objects
$modDoliMeet = new modDoliMeet($db);
$classname = 'mod' . $moduleName;
$modModule = new $classname($db);

// Security check
$permissiontoread = $user->rights->dolimeet->read;
if (empty($conf->dolimeet->enabled) || !$permissiontoread) {
$permissiontoread = $user->rights->$moduleNameLowerCase->read;
if (empty($conf->$moduleNameLowerCase->enabled) || !$permissiontoread) {
accessforbidden();
}

/*
* View
*/

$help_url = 'FR:Module_DoliMeet';
$title = $langs->trans('DoliMeetArea');
$morejs = ['/dolimeet/js/dolimeet.js'];
$morecss = ['/dolimeet/css/dolimeet.css'];
$title = $langs->trans($moduleName . 'Area');
$helpUrl = 'FR:Module_' . $moduleName;
$morejs = ['/' . $moduleNameLowerCase . '/js/' . $moduleNameLowerCase . '.js'];
$morecss = ['/' . $moduleNameLowerCase . '/css/' . $moduleNameLowerCase . '.css'];

llxHeader('', $title . ' ' . $modDoliMeet->version, $help_url, '', 0, 0, $morejs, $morecss);
llxHeader('', $title . ' ' . $modModule->version, $helpUrl, '', 0, 0, $morejs, $morecss);

print load_fiche_titre($title . ' ' . $modDoliMeet->version, '', 'dolimeet_color.png@dolimeet');
print load_fiche_titre($title . ' ' . $modModule->version, '', $moduleNameLowerCase . '_color.png@' . $moduleNameLowerCase);

// End of page
llxFooter();
Expand Down

0 comments on commit c50d17b

Please sign in to comment.