NEW Add more tables activated by module activation only

This commit is contained in:
Laurent Destailleur 2023-08-24 20:12:02 +02:00
parent 73c199adbf
commit 23f4fb9cdd
20 changed files with 38 additions and 31 deletions

View File

@ -22,9 +22,14 @@
* \brief Set function handlers for PHP session management in DB.
*/
// The session handler file must be included just after the call of the master.inc.php into main.inc.php
// This session handler file must be included just after the call of the master.inc.php into main.inc.php
// The $conf is already defined from conf.php file.
// To use it set in your PHP.ini: session.save_handler = user
// To use it set
// - create table ll_session from the llx_session-disabled.sql file
// - uncomment the include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php into main.inc.php
// - in your PHP.ini, set: session.save_handler = user
// The session_set_save_handler() at end of this fille will replace default session management.
/**
* The session open handler called by PHP whenever a session is initialized.

View File

@ -84,4 +84,27 @@ class modDynamicPrices extends DolibarrModules
$this->rights_class = 'dynamicprices';
$r = 0;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
*
* @param string $options Options
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
{
$result = $this->_load_tables('/install/mysql/', 'dynamicprices');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
// Remove permissions and default values
$this->remove($options);
$sql = array();
return $this->_init($sql, $options);
}
}

View File

@ -245,6 +245,11 @@ class modExpenseReport extends DolibarrModules
{
global $conf;
$result = $this->_load_tables('/install/mysql/', 'expensereport');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
// Remove permissions and default values
$this->remove($options);

View File

@ -1,29 +0,0 @@
-- ===================================================================
-- Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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/>.
--
-- ===================================================================
create table llx_export_compta
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(12) NOT NULL,
date_export datetime NOT NULL, -- date de creation
fk_user integer NOT NULL,
note text
)ENGINE=innodb;

View File

@ -357,6 +357,9 @@ if (!defined('NOSESSION')) {
// Init the 6 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc, $hookmanager
require_once 'master.inc.php';
// Uncomment this and set session.save_handler = user to use local session storing
// include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php
// If software has been locked. Only login $conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed.
if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
$ok = 0;