Files should be in custom folder
reload.sh search for class name given in the module path
./reload.sh modulepah [0|1]
reload module with module class name (eg: modFacture)
php reload.php modModuleName [0|1]
<?php | |
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr | |
* Copyright (C) 2013 Florian Henry <[email protected] | |
* Copyright (C) 2013-2015 Laurent Destailleur <[email protected]> | |
* Copyright (C) 2020-2024 Jacquel jérome <[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 <http://www.gnu.org/licenses/>. | |
*/ | |
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal | |
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); | |
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); | |
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); | |
if (!defined('NOLOGIN')) define('NOLOGIN', '1'); | |
$sapi_type = php_sapi_name(); | |
$script_file = basename(__FILE__); | |
$path = dirname(__FILE__) . '/'; | |
// Test if batch mode | |
if (substr($sapi_type, 0, 3) == 'cgi') { | |
echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; | |
exit(-1); | |
} | |
const MAIN_LANG_DEFAULT = 'FR_fr'; | |
require_once $path . "../master.inc.php"; | |
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; | |
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; | |
$user = new User($db); | |
$user->fetch(1); | |
$user->getrights(); | |
// Global variables | |
$version = DOL_VERSION; | |
$error = 0; | |
$class = $argv[1]; | |
$activate = isset($argv[2]) && $argv[2] != '' ? $argv[2] : -1; | |
$modName = $class; | |
$modFile = $modName . ".class.php"; | |
$modFileLower = strtolower($modName) . ".class.php"; | |
// Loop on each directory to fill $modulesdir | |
$modulesdir = dolGetModulesDirs(); | |
// Loop on each modulesdir directories | |
$found = false; | |
foreach ($modulesdir as $dir) { | |
if (file_exists($dir . $modFile)) { | |
$found = @include_once $dir . $modFile; | |
if ($found) { | |
break; | |
} | |
} | |
if (file_exists($dir . $modFileLower)) { | |
$found = @include_once $dir . $modFileLower; | |
if ($found) { | |
break; | |
} | |
} | |
} | |
$objMod = new $modName($db); | |
$const_name = $objMod->const_name; | |
if (isset($conf->global->$const_name) && (!$activate || $activate < 0)) { | |
print 'unactivate'.PHP_EOL; | |
unActivateModule($class); | |
unset($conf->global->$const_name); | |
} | |
if ($activate || $activate < 0) { | |
print 'activate'.PHP_EOL; | |
$ret = activateModule($class); | |
} |
#!/bin/bash | |
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
MODULEPATH=$1 | |
ACTIVE=$2 | |
mod=$(find "${DIR}/${MODULEPATH}/core/modules/" -type f -regex "${DIR}/${MODULEPATH}/core/modules/mod.*\\.class\\.php") | |
CLASSNAME=$(grep 'extends DolibarrModules' "${mod}" | cut -d ' ' -f2) | |
php ./reload.php "${CLASSNAME}" "${ACTIVE}" |