Selaa lähdekoodia

NEW Add more tables activated by module activation only

Laurent Destailleur 1 vuosi sitten
vanhempi
commit
23f4fb9cdd

+ 7 - 2
htdocs/core/lib/phpsessionindb.lib.php

@@ -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.

+ 23 - 0
htdocs/core/modules/modDynamicPrices.class.php

@@ -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);
+	}
 }

+ 5 - 0
htdocs/core/modules/modExpenseReport.class.php

@@ -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);
 

+ 0 - 0
htdocs/install/mysql/data/llx_c_exp_tax_cat.sql → htdocs/install/mysql/data/llx_c_exp_tax_cat-expensereport.sql


+ 0 - 0
htdocs/install/mysql/data/llx_c_exp_tax_range.sql → htdocs/install/mysql/data/llx_c_exp_tax_range-expensereport.sql


+ 0 - 0
htdocs/install/mysql/data/llx_expensereport_ik.sql → htdocs/install/mysql/data/llx_expensereport_ik-expensereport.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_budget.sql → htdocs/install/mysql/tables/llx_budget-budget.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_budget_lines.key.sql → htdocs/install/mysql/tables/llx_budget_lines-budget.key.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_budget_lines.sql → htdocs/install/mysql/tables/llx_budget_lines-budget.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql → htdocs/install/mysql/tables/llx_c_exp_tax_cat-expensereport.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_exp_tax_range.sql → htdocs/install/mysql/tables/llx_c_exp_tax_range-expensereport.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_price_expression.sql → htdocs/install/mysql/tables/llx_c_price_expression-dynamicprices.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_price_global_variable.sql → htdocs/install/mysql/tables/llx_c_price_global_variable-dynamicprices.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_price_global_variable_updater.sql → htdocs/install/mysql/tables/llx_c_price_global_variable_updater-dynamicprices.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_c_recruitment_origin.sql → htdocs/install/mysql/tables/llx_c_recruitment_origin-recruitment.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_expensereport_ik.sql → htdocs/install/mysql/tables/llx_expensereport_ik-expensereport.sql


+ 0 - 0
htdocs/install/mysql/tables/llx_expensereport_rules.sql → htdocs/install/mysql/tables/llx_expensereport_rules-expensereport.sql


+ 0 - 29
htdocs/install/mysql/tables/llx_export_compta.sql

@@ -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;

+ 0 - 0
htdocs/install/mysql/tables/llx_session.sql → htdocs/install/mysql/tables/llx_session-disabled.sql


+ 3 - 0
htdocs/main.inc.php

@@ -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;