Merge branch 'develop' of git+ssh://git@github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
8e023bb384
@ -72,13 +72,15 @@ class modMyModule extends DolibarrModules
|
||||
// for default path (eg: /mymodule/core/xxxxx) (0=disable, 1=enable)
|
||||
// for specific path of parts (eg: /mymodule/core/modules/barcode)
|
||||
// for specific css file (eg: /mymodule/css/mymodule.css.php)
|
||||
//$this->module_parts = array( 'triggers' => 1,
|
||||
// 'login' => 0,
|
||||
// 'substitutions' => 0,
|
||||
// 'menus' => 0,
|
||||
// 'css' => '/mymodule/css/mymodule.css.php',
|
||||
// 'barcode' => '/mymodule/path/to/your/parts',
|
||||
// 'hooks' => array('hookcontext1','hookcontext2'));
|
||||
//$this->module_parts = array(
|
||||
// 'triggers' => 0, // Set this to 1 if module has its own trigger directory
|
||||
// 'login' => 0, // Set this to 1 if module has its own login method directory
|
||||
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file
|
||||
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory
|
||||
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory
|
||||
// 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file
|
||||
// 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
|
||||
// );
|
||||
$this->module_parts = array();
|
||||
|
||||
// Data directories to create when module is enabled.
|
||||
|
||||
@ -33,6 +33,7 @@ $langs->load("admin");
|
||||
|
||||
$mode=isset($_GET["mode"])?GETPOST("mode"):(isset($_SESSION['mode'])?$_SESSION['mode']:0);
|
||||
$mesg=GETPOST("mesg");
|
||||
$action=GETPOST('action');
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
@ -41,7 +42,7 @@ if (!$user->admin) accessforbidden();
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'set' && $user->admin)
|
||||
if ($action == 'set' && $user->admin)
|
||||
{
|
||||
$result=activateModule($_GET["value"]);
|
||||
$mesg='';
|
||||
@ -50,7 +51,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'set' && $user->admin)
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'reset' && $user->admin)
|
||||
if ($action == 'reset' && $user->admin)
|
||||
{
|
||||
$result=unActivateModule($_GET["value"]);
|
||||
$mesg='';
|
||||
|
||||
@ -59,10 +59,10 @@ class HookManager
|
||||
* class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context).
|
||||
* Then when a hook is executeHook('aMethod'...) is called, the method aMethod found into class will be executed.
|
||||
*
|
||||
* @param array $arraytype Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ...
|
||||
* @return int Always 1
|
||||
* @param array $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ...
|
||||
* @return int Always 1
|
||||
*/
|
||||
function callHooks($arraytype)
|
||||
function callHooks($arraycontext)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -70,24 +70,27 @@ class HookManager
|
||||
if (! is_array($conf->hooks_modules) || empty($conf->hooks_modules)) return;
|
||||
|
||||
// For backward compatibility
|
||||
if (! is_array($arraytype)) $arraytype=array($arraytype);
|
||||
if (! is_array($arraycontext)) $arraycontext=array($arraycontext);
|
||||
|
||||
$this->contextarray=array_merge($arraytype,$this->contextarray);
|
||||
$this->contextarray=array_merge($arraycontext,$this->contextarray); // All contexts are concatenated
|
||||
|
||||
$i=0;
|
||||
foreach($conf->hooks_modules as $module => $hooks)
|
||||
{
|
||||
if ($conf->$module->enabled)
|
||||
{
|
||||
foreach($arraytype as $type)
|
||||
foreach($arraycontext as $context)
|
||||
{
|
||||
if (in_array($type,$hooks)) // We instantiate action class only if hook is required
|
||||
if (is_array($hooks)) $arrayhooks=$hooks; // New system
|
||||
else $arrayhooks=explode(':',$hooks); // Old system (for backward compatibility)
|
||||
|
||||
if (in_array($context,$arrayhooks)) // We instantiate action class only if hook is required
|
||||
{
|
||||
$path = '/'.$module.'/class/';
|
||||
$actionfile = 'actions_'.$module.'.class.php';
|
||||
$pathroot = '';
|
||||
|
||||
$this->hooks[$i]['type']=$type;
|
||||
$this->hooks[$i]['type']=$context;
|
||||
|
||||
// Include actions class overwriting hooks
|
||||
$resaction=dol_include_once($path.$actionfile);
|
||||
|
||||
@ -587,9 +587,9 @@ class DoliDBMssql
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate a SQL IF
|
||||
* Format a SQL IF
|
||||
*
|
||||
* @param string $test chaine test
|
||||
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
|
||||
* @param string $resok resultat si test egal
|
||||
* @param string $resko resultat si test non egal
|
||||
* @return string SQL string
|
||||
|
||||
@ -562,9 +562,9 @@ class DoliDBMysql
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate a SQL IF
|
||||
* Format a SQL IF
|
||||
*
|
||||
* @param string $test chaine test
|
||||
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
|
||||
* @param string $resok resultat si test egal
|
||||
* @param string $resko resultat si test non egal
|
||||
* @return string SQL string
|
||||
|
||||
@ -572,9 +572,9 @@ class DoliDBMysqli
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate a SQL IF
|
||||
* Format a SQL IF
|
||||
*
|
||||
* @param string $test chaine test
|
||||
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
|
||||
* @param string $resok resultat si test egal
|
||||
* @param string $resko resultat si test non egal
|
||||
* @return string SQL string
|
||||
|
||||
@ -758,9 +758,9 @@ class DoliDBPgsql
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate a SQL IF
|
||||
* Format a SQL IF
|
||||
*
|
||||
* @param string $test chaine test
|
||||
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
|
||||
* @param string $resok resultat si test egal
|
||||
* @param string $resko resultat si test non egal
|
||||
* @return string chaine formate SQL
|
||||
|
||||
@ -702,9 +702,9 @@ class DoliDBSqlite
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate a SQL IF
|
||||
* Format a SQL IF
|
||||
*
|
||||
* @param string $test chaine test
|
||||
* @param string $test Test string (example: 'cd.statut=0', 'field IS NULL')
|
||||
* @param string $resok resultat si test egal
|
||||
* @param string $resko resultat si test non egal
|
||||
* @return string SQL string
|
||||
|
||||
@ -73,7 +73,7 @@ abstract class DolibarrModules
|
||||
|
||||
// Insert new pages for tabs into llx_const
|
||||
if (! $err) $err+=$this->insert_tabs();
|
||||
|
||||
|
||||
// Insert activation of module's parts
|
||||
if (! $err) $err+=$this->insert_module_parts();
|
||||
|
||||
@ -164,7 +164,7 @@ abstract class DolibarrModules
|
||||
|
||||
// Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const)
|
||||
if (! $err) $err+=$this->delete_tabs();
|
||||
|
||||
|
||||
// Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const)
|
||||
if (! $err) $err+=$this->delete_module_parts();
|
||||
|
||||
@ -1253,22 +1253,22 @@ abstract class DolibarrModules
|
||||
|
||||
/**
|
||||
* Insert activation of generic parts from modules in llx_const
|
||||
*
|
||||
*
|
||||
* @return int Nb of errors (0 if OK)
|
||||
*/
|
||||
function insert_module_parts()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$err=0;
|
||||
$entity=$conf->entity;
|
||||
|
||||
|
||||
if (is_array($this->module_parts) && ! empty($this->module_parts))
|
||||
{
|
||||
foreach($this->module_parts as $key => $value)
|
||||
{
|
||||
$newvalue = $value;
|
||||
|
||||
|
||||
// Serialize array parameters
|
||||
if (is_array($value))
|
||||
{
|
||||
@ -1283,7 +1283,7 @@ abstract class DolibarrModules
|
||||
$newvalue = serialize($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
|
||||
$sql.= "name";
|
||||
$sql.= ", type";
|
||||
@ -1300,30 +1300,30 @@ abstract class DolibarrModules
|
||||
$sql.= ", '0'";
|
||||
$sql.= ", ".$entity;
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::insert_".$key." sql=".$sql);
|
||||
|
||||
dol_syslog(get_class($this)."::insert_const_".$key." sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::insert_".$key." ".$this->error);
|
||||
dol_syslog(get_class($this)."::insert_const_".$key." ".$this->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove activation of generic parts from modules in llx_const
|
||||
*
|
||||
* Remove activation of generic parts of modules from llx_const
|
||||
*
|
||||
* @return int Nb of errors (0 if OK)
|
||||
*/
|
||||
function delete_module_parts()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$err=0;
|
||||
|
||||
|
||||
if (is_array($this->module_parts) && ! empty($this->module_parts))
|
||||
{
|
||||
foreach($this->module_parts as $key => $value)
|
||||
@ -1331,17 +1331,17 @@ abstract class DolibarrModules
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this)."::delete_".$key." sql=".$sql);
|
||||
|
||||
dol_syslog(get_class($this)."::delete_const_".$key." sql=".$sql);
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::delete_".$key." ".$this->error, LOG_ERR);
|
||||
dol_syslog(get_class($this)."::delete_const_".$key." ".$this->error, LOG_ERR);
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $err;
|
||||
}
|
||||
|
||||
|
||||
@ -70,9 +70,6 @@ class modWorkflow extends DolibarrModules
|
||||
|
||||
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
|
||||
$this->config_page_url = 'workflow.php';
|
||||
|
||||
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
|
||||
$this->module_parts = array('triggers' => 1);
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
|
||||
|
||||
Loading…
Reference in New Issue
Block a user