Merge pull request #1841 from GPCsolutions/modules
Modules classes documentation enhancements
This commit is contained in:
commit
013023204f
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -25,31 +26,88 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class of boxes
|
* Class ModeleBoxes
|
||||||
|
*
|
||||||
|
* Boxes parent class
|
||||||
*/
|
*/
|
||||||
class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes
|
class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes
|
||||||
{
|
{
|
||||||
var $db;
|
/**
|
||||||
var $error='';
|
* @var DoliDB Database handler
|
||||||
var $max=5;
|
*/
|
||||||
var $enabled=1;
|
public $db;
|
||||||
|
|
||||||
var $rowid;
|
|
||||||
var $id;
|
|
||||||
var $position;
|
|
||||||
var $box_order;
|
|
||||||
var $fk_user;
|
|
||||||
var $sourcefile;
|
|
||||||
var $class;
|
|
||||||
var $box_id;
|
|
||||||
var $note;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* @var string Error message
|
||||||
|
*/
|
||||||
|
public $error = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Maximum lines
|
||||||
|
*/
|
||||||
|
public $max = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Status
|
||||||
|
*/
|
||||||
|
public $enabled=1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Box definition database ID
|
||||||
|
*/
|
||||||
|
public $rowid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int ID
|
||||||
|
* @deprecated Same as box_id?
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Position?
|
||||||
|
*/
|
||||||
|
public $position;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Display order
|
||||||
|
*/
|
||||||
|
public $box_order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int User ID
|
||||||
|
*/
|
||||||
|
public $fk_user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Source file
|
||||||
|
*/
|
||||||
|
public $sourcefile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Class name
|
||||||
|
*/
|
||||||
|
public $class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string ID
|
||||||
|
*/
|
||||||
|
public $box_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Alphanumeric ID
|
||||||
|
*/
|
||||||
|
public $boxcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Note
|
||||||
|
*/
|
||||||
|
public $note;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param string $param More parameters
|
* @param string $param More parameters
|
||||||
*/
|
*/
|
||||||
function __construct($db,$param='')
|
function __construct($db,$param='')
|
||||||
{
|
{
|
||||||
@ -57,9 +115,9 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return last error message
|
* Return last error message
|
||||||
*
|
*
|
||||||
* @return string Error message
|
* @return string Error message
|
||||||
*/
|
*/
|
||||||
function error()
|
function error()
|
||||||
{
|
{
|
||||||
@ -68,10 +126,11 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a box line from its rowid
|
* Load a box line from its rowid
|
||||||
*
|
*
|
||||||
* @param int $rowid Row id to load
|
* @param int $rowid Row id to load
|
||||||
* @return int <0 if KO, >0 if OK
|
*
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($rowid)
|
function fetch($rowid)
|
||||||
{
|
{
|
||||||
@ -110,11 +169,12 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
|
*Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
|
||||||
*
|
*
|
||||||
* @param array $head Array with properties of box title
|
* @param array $head Array with properties of box title
|
||||||
* @param array $contents Array with properties of box lines
|
* @param array $contents Array with properties of box lines
|
||||||
* @return void
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showBox($head, $contents)
|
function showBox($head, $contents)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,48 +22,184 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/core/modules/DolibarrModules.class.php
|
* \file htdocs/core/modules/DolibarrModules.class.php
|
||||||
* \brief File of parent class of module descriptor class files
|
* \brief File of parent class of module descriptor class files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent class of module descriptor class files
|
* Class DolibarrModules
|
||||||
|
*
|
||||||
|
* Parent class for module descriptor class files
|
||||||
*/
|
*/
|
||||||
abstract class DolibarrModules
|
abstract class DolibarrModules
|
||||||
{
|
{
|
||||||
//! Database handler
|
|
||||||
var $db;
|
|
||||||
//! Relative path to module style sheet
|
|
||||||
var $style_sheet = ''; // deprecated
|
|
||||||
//! Path to create when module activated
|
|
||||||
var $dirs = array();
|
|
||||||
//! Tableau des boites
|
|
||||||
var $boxes;
|
|
||||||
//! Tableau des constantes
|
|
||||||
var $const;
|
|
||||||
//! Tableau des droits
|
|
||||||
var $rights;
|
|
||||||
//! Tableau des menus
|
|
||||||
var $menu=array();
|
|
||||||
//! Module parts array
|
|
||||||
var $module_parts=array();
|
|
||||||
//! Tableau des documents ???
|
|
||||||
var $docs;
|
|
||||||
|
|
||||||
var $dbversion = "-";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to enable a module. Insert into database all constants, boxes of module
|
* @var DoliDb Database handler
|
||||||
*
|
|
||||||
* @param array $array_sql Array of SQL requests to execute when enabling module
|
|
||||||
* @param string $options String with options when disabling module ('newboxdefonly|noboxes')
|
|
||||||
* @return int 1 if OK, 0 if KO
|
|
||||||
*/
|
*/
|
||||||
|
public $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Relative path to module style sheet
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $style_sheet = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Paths to create when module is activated
|
||||||
|
*/
|
||||||
|
public $dirs = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Module boxes
|
||||||
|
*/
|
||||||
|
public $boxes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Module constants
|
||||||
|
*/
|
||||||
|
public $const = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Module access rights
|
||||||
|
*/
|
||||||
|
public $rights;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module access rights family
|
||||||
|
*/
|
||||||
|
public $rights_class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Module menu entries
|
||||||
|
*/
|
||||||
|
public $menu = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Module parts
|
||||||
|
* array(
|
||||||
|
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
|
||||||
|
* 'triggers' => 0,
|
||||||
|
* // Set this to 1 if module has its own login method directory (/mymodule/core/login)
|
||||||
|
* 'login' => 0,
|
||||||
|
* // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
|
||||||
|
* 'substitutions' => 0,
|
||||||
|
* // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
|
||||||
|
* 'menus' => 0,
|
||||||
|
* // Set this to 1 if module has its own theme directory (/mymodule/theme)
|
||||||
|
* 'theme' => 0,
|
||||||
|
* // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
|
||||||
|
* 'tpl' => 0,
|
||||||
|
* // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
|
||||||
|
* 'barcode' => 0,
|
||||||
|
* // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
|
||||||
|
* 'models' => 0,
|
||||||
|
* // Set this to relative path of css file if module has its own css file
|
||||||
|
* 'css' => '/mymodule/css/mymodule.css.php',
|
||||||
|
* // Set this to relative path of js file if module must load a js on all pages
|
||||||
|
* 'js' => '/mymodule/js/mymodule.js',
|
||||||
|
* // Set here all hooks context managed by module
|
||||||
|
* 'hooks' => array('hookcontext1','hookcontext2'),
|
||||||
|
* // Set here all workflow context managed by module
|
||||||
|
* 'workflow' => array(
|
||||||
|
* 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
|
||||||
|
* 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
|
||||||
|
* 'picto'=>'yourpicto@mymodule'
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public $module_parts = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module documents ?
|
||||||
|
* @deprecated Seems unused anywhere
|
||||||
|
*/
|
||||||
|
public $docs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string ?
|
||||||
|
* @deprecated Seems unused anywhere
|
||||||
|
*/
|
||||||
|
public $dbversion = "-";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Error message
|
||||||
|
*/
|
||||||
|
public $error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Module unique ID
|
||||||
|
*/
|
||||||
|
public $numero;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module name
|
||||||
|
*/
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module version
|
||||||
|
*/
|
||||||
|
public $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module description
|
||||||
|
*/
|
||||||
|
public $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[] Module language files
|
||||||
|
*/
|
||||||
|
public $langfiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module export code
|
||||||
|
*/
|
||||||
|
public $export_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module export label
|
||||||
|
*/
|
||||||
|
public $export_label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module import code
|
||||||
|
*/
|
||||||
|
public $import_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module import label
|
||||||
|
*/
|
||||||
|
public $import_label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Module constant name
|
||||||
|
*/
|
||||||
|
public $const_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Module can't be disabled
|
||||||
|
*/
|
||||||
|
public $always_enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Module is enabled globally (Multicompany support)
|
||||||
|
*/
|
||||||
|
public $core_enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables a module.
|
||||||
|
* Inserts all informations into database
|
||||||
|
*
|
||||||
|
* @param string[] $array_sql SQL requests to be executed when enabling module
|
||||||
|
* @param string $options String with options when disabling module ('newboxdefonly|noboxes')
|
||||||
|
*
|
||||||
|
* @return int 1 if OK, 0 if KO
|
||||||
|
*/
|
||||||
function _init($array_sql, $options='')
|
function _init($array_sql, $options='')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf;
|
||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -98,18 +235,13 @@ abstract class DolibarrModules
|
|||||||
if (! $err)
|
if (! $err)
|
||||||
{
|
{
|
||||||
$val=$array_sql[$i];
|
$val=$array_sql[$i];
|
||||||
$sql='';
|
$sql=$val;
|
||||||
$ignoreerror=0;
|
$ignoreerror=0;
|
||||||
if (is_array($val))
|
if (is_array($val))
|
||||||
{
|
{
|
||||||
$sql=$val['sql'];
|
$sql=$val['sql'];
|
||||||
$ignoreerror=$val['ignoreerror'];
|
$ignoreerror=$val['ignoreerror'];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql=$val;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add current entity id
|
// Add current entity id
|
||||||
$sql=str_replace('__ENTITY__', $conf->entity, $sql);
|
$sql=str_replace('__ENTITY__', $conf->entity, $sql);
|
||||||
|
|
||||||
@ -144,15 +276,15 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction de desactivation. Supprime de la base les constantes et boites du module
|
* Disable function. Deletes the module constant and boxes from the database.
|
||||||
*
|
*
|
||||||
* @param array $array_sql Array of SQL requests to execute when disable module
|
* @param string[] $array_sql SQL requests to be executed when module is disabled
|
||||||
* @param string $options String with options when disabling module ('newboxdefonly|noboxes')
|
* @param string $options Options when disabling module ('newboxdefonly|noboxes')
|
||||||
* @return int 1 if OK, 0 if KO
|
*
|
||||||
|
* @return int 1 if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
function _remove($array_sql, $options='')
|
function _remove($array_sql, $options='')
|
||||||
{
|
{
|
||||||
global $langs;
|
|
||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -212,10 +344,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne le nom traduit du module si la traduction existe dans admin.lang,
|
* Gives the translated module name if translation exists in admin.lang or the default module name.
|
||||||
* sinon le nom defini par defaut dans le module.
|
|
||||||
*
|
*
|
||||||
* @return string Nom du module traduit
|
* @return string Translated module name
|
||||||
*/
|
*/
|
||||||
function getName()
|
function getName()
|
||||||
{
|
{
|
||||||
@ -224,22 +355,21 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
if ($langs->trans("Module".$this->numero."Name") != ("Module".$this->numero."Name"))
|
if ($langs->trans("Module".$this->numero."Name") != ("Module".$this->numero."Name"))
|
||||||
{
|
{
|
||||||
// Si traduction du nom du module existe
|
// If module name translation exists
|
||||||
return $langs->trans("Module".$this->numero."Name");
|
return $langs->trans("Module".$this->numero."Name");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If translation of module with its numero does not exists, we take its name
|
// If module name translation using it's unique id does not exists, we take its name
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne la description traduite du module si la traduction existe dans admin.lang,
|
* Gives the translated module description if translation exists in admin.lang or the default module description
|
||||||
* sinon la description definie par defaut dans le module
|
|
||||||
*
|
*
|
||||||
* @return string Nom du module traduit
|
* @return string Translated module description
|
||||||
*/
|
*/
|
||||||
function getDesc()
|
function getDesc()
|
||||||
{
|
{
|
||||||
@ -248,24 +378,23 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc"))
|
if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc"))
|
||||||
{
|
{
|
||||||
// Si traduction de la description du module existe
|
// If module description translation exists
|
||||||
return $langs->trans("Module".$this->numero."Desc");
|
return $langs->trans("Module".$this->numero."Desc");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si traduction de la description du module n'existe pas, on prend definition en dur dans module
|
// If module description translation using it's unique id does not exists, we take its description
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return module version.
|
* Gives module version
|
||||||
* Pour les modules a l'etat 'experimental', retourne la traduction de 'experimental'
|
* For 'experimental' modules, gives 'experimental' translation
|
||||||
* Pour les modules 'dolibarr', retourne la version de Dolibarr
|
* For 'dolibarr' modules, gives Dolibarr version
|
||||||
* Pour les autres modules, retourne la version du module
|
|
||||||
*
|
*
|
||||||
* @return string Version du module
|
* @return string Module version
|
||||||
*/
|
*/
|
||||||
function getVersion()
|
function getVersion()
|
||||||
{
|
{
|
||||||
@ -281,9 +410,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return if a module is a core or external module
|
* Tells if module is core or external
|
||||||
*
|
*
|
||||||
* @return string 'core', 'external' or 'unknown'
|
* @return string 'core', 'external' or 'unknown'
|
||||||
*/
|
*/
|
||||||
function isCoreOrExternalModule()
|
function isCoreOrExternalModule()
|
||||||
{
|
{
|
||||||
@ -295,9 +424,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of lang files related to module
|
* Gives module related language files list
|
||||||
*
|
*
|
||||||
* @return array Array of lang files
|
* @return string[] Language files list
|
||||||
*/
|
*/
|
||||||
function getLangFilesArray()
|
function getLangFilesArray()
|
||||||
{
|
{
|
||||||
@ -305,10 +434,11 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return translated label of a export dataset
|
* Gives translated label of an export dataset
|
||||||
*
|
*
|
||||||
* @param int $r Index of dataset
|
* @param int $r Dataset index
|
||||||
* @return string Label of databaset
|
*
|
||||||
|
* @return string Translated databaset label
|
||||||
*/
|
*/
|
||||||
function getExportDatasetLabel($r)
|
function getExportDatasetLabel($r)
|
||||||
{
|
{
|
||||||
@ -329,10 +459,11 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return translated label of an import dataset
|
* Gives translated label of an import dataset
|
||||||
*
|
*
|
||||||
* @param int $r Index of dataset
|
* @param int $r Dataset index
|
||||||
* @return string Label of databaset
|
*
|
||||||
|
* @return string Translated dataset label
|
||||||
*/
|
*/
|
||||||
function getImportDatasetLabel($r)
|
function getImportDatasetLabel($r)
|
||||||
{
|
{
|
||||||
@ -354,9 +485,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert constant to activate module
|
* Insert constants for module activation
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function _active()
|
function _active()
|
||||||
{
|
{
|
||||||
@ -389,10 +520,10 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove activation line
|
* Module deactivation
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
**/
|
*/
|
||||||
function _unactive()
|
function _unactive()
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
@ -414,24 +545,24 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create tables and keys required by module.
|
* Create tables and keys required by module.
|
||||||
* Files module.sql and module.key.sql with create table and create keys
|
* Files module.sql and module.key.sql with create table and create keys
|
||||||
* commands must be stored in directory reldir='/module/sql/'
|
* commands must be stored in directory reldir='/module/sql/'
|
||||||
* This function is called by this->init
|
* This function is called by this->init
|
||||||
*
|
*
|
||||||
* @param string $reldir Relative directory where to scan files
|
* @param string $reldir Relative directory where to scan files
|
||||||
* @return int <=0 if KO, >0 if OK
|
* @return int <=0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function _load_tables($reldir)
|
function _load_tables($reldir)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
$dirfound=0;
|
$dirfound=0;
|
||||||
|
|
||||||
if (empty($reldir)) return 1;
|
if (empty($reldir)) return 1;
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT .'/core/lib/admin.lib.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
||||||
|
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
foreach($conf->file->dol_document_root as $dirroot)
|
foreach($conf->file->dol_document_root as $dirroot)
|
||||||
@ -508,14 +639,15 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert boxes into llx_boxes_def
|
* Adds boxes
|
||||||
*
|
*
|
||||||
* @param string $option String with options when disabling module ('newboxdefonly'=insert only boxes definition)
|
* @param string $option Options when disabling module ('newboxdefonly'=insert only boxes definition)
|
||||||
* @return int Nb of errors (0 if OK)
|
*
|
||||||
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_boxes($option='')
|
function insert_boxes($option='')
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
|
||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -605,9 +737,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete boxes
|
* Removes boxes
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_boxes()
|
function delete_boxes()
|
||||||
{
|
{
|
||||||
@ -657,9 +789,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove links to new module page present in llx_const
|
* Removes tabs
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_tabs()
|
function delete_tabs()
|
||||||
{
|
{
|
||||||
@ -682,9 +814,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add links of new pages from modules in llx_const
|
* Adds tabs
|
||||||
*
|
*
|
||||||
* @return int Number of errors (0 if ok)
|
* @return int Error count (0 if ok)
|
||||||
*/
|
*/
|
||||||
function insert_tabs()
|
function insert_tabs()
|
||||||
{
|
{
|
||||||
@ -717,13 +849,7 @@ abstract class DolibarrModules
|
|||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
|
dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
/* Allow duplicate key
|
|
||||||
if (! $resql)
|
|
||||||
{
|
|
||||||
$err++;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -732,9 +858,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert constants defined into $this->const array into table llx_const
|
* Adds constants
|
||||||
*
|
*
|
||||||
* @return int Number of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_const()
|
function insert_const()
|
||||||
{
|
{
|
||||||
@ -799,9 +925,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove constants with tags deleteonunactive
|
* Removes constants tagged 'deleteonunactive'
|
||||||
*
|
*
|
||||||
* @return int <0 if KO, 0 if OK
|
* @return int <0 if KO, 0 if OK
|
||||||
*/
|
*/
|
||||||
function delete_const()
|
function delete_const()
|
||||||
{
|
{
|
||||||
@ -832,11 +958,12 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert permissions definitions related to the module into llx_rights_def
|
* Adds access rights
|
||||||
*
|
*
|
||||||
* @param int $reinitadminperms If 1, we also grant them to all admin users
|
* @param int $reinitadminperms If 1, we also grant them to all admin users
|
||||||
* @param int $force_entity Force current entity
|
* @param int $force_entity Force current entity
|
||||||
* @return int Number of error (0 if OK)
|
*
|
||||||
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_permissions($reinitadminperms=0, $force_entity=null)
|
function insert_permissions($reinitadminperms=0, $force_entity=null)
|
||||||
{
|
{
|
||||||
@ -928,7 +1055,7 @@ abstract class DolibarrModules
|
|||||||
if ($reinitadminperms)
|
if ($reinitadminperms)
|
||||||
{
|
{
|
||||||
if (! class_exists('User')) {
|
if (! class_exists('User')) {
|
||||||
require DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
|
||||||
}
|
}
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";
|
||||||
dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);
|
dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);
|
||||||
@ -972,9 +1099,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete permissions
|
* Removes access rights
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_permissions()
|
function delete_permissions()
|
||||||
{
|
{
|
||||||
@ -997,15 +1124,15 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert menus entries found into $this->menu into llx_menu*
|
* Adds menu entries
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_menus()
|
function insert_menus()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
|
||||||
|
|
||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
@ -1101,9 +1228,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove menus entries
|
* Removes menu entries
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_menus()
|
function delete_menus()
|
||||||
{
|
{
|
||||||
@ -1127,9 +1254,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create directories required by module
|
* Creates directories
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function create_dirs()
|
function create_dirs()
|
||||||
{
|
{
|
||||||
@ -1185,11 +1312,12 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert directories in llx_const
|
* Adds directories definitions
|
||||||
*
|
*
|
||||||
* @param string $name Name
|
* @param string $name Name
|
||||||
* @param string $dir Directory
|
* @param string $dir Directory
|
||||||
* @return int Nb of errors (0 if OK)
|
*
|
||||||
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_dirs($name,$dir)
|
function insert_dirs($name,$dir)
|
||||||
{
|
{
|
||||||
@ -1214,7 +1342,7 @@ abstract class DolibarrModules
|
|||||||
$sql.= " VALUES (".$this->db->encrypt($name,1).",'chaine',".$this->db->encrypt($dir,1).",'Directory for module ".$this->name."','0',".$conf->entity.")";
|
$sql.= " VALUES (".$this->db->encrypt($name,1).",'chaine',".$this->db->encrypt($dir,1).",'Directory for module ".$this->name."','0',".$conf->entity.")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);
|
dol_syslog(get_class($this)."::insert_dirs", LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1228,9 +1356,9 @@ abstract class DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove directory entries
|
* Removes directories
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_dirs()
|
function delete_dirs()
|
||||||
{
|
{
|
||||||
@ -1253,23 +1381,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert activation of generic parts from modules in llx_const
|
* Adds generic parts
|
||||||
* Input entry use $this->module_parts = array(
|
|
||||||
* 'triggers' => 0, // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
|
|
||||||
* 'login' => 0, // Set this to 1 if module has its own login method directory (/mymodule/core/login)
|
|
||||||
* 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
|
|
||||||
* 'menus' => 0, // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
|
|
||||||
* 'theme' => 0, // Set this to 1 if module has its own theme directory (/mymodule/theme)
|
|
||||||
* 'tpl' => 0, // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
|
|
||||||
* 'barcode' => 0, // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
|
|
||||||
* 'models' => 0, // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
|
|
||||||
* 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css file if module has its own css file
|
|
||||||
* 'js' => '/mymodule/js/mymodule.js', // Set this to relative path of js file if module must load a js on all pages
|
|
||||||
* 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
|
|
||||||
* 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule') // Set here all workflow context managed by module
|
|
||||||
* )
|
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function insert_module_parts()
|
function insert_module_parts()
|
||||||
{
|
{
|
||||||
@ -1338,9 +1452,9 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove activation of generic parts of modules from llx_const
|
* Removes generic parts
|
||||||
*
|
*
|
||||||
* @return int Nb of errors (0 if OK)
|
* @return int Error count (0 if OK)
|
||||||
*/
|
*/
|
||||||
function delete_module_parts()
|
function delete_module_parts()
|
||||||
{
|
{
|
||||||
@ -1368,7 +1482,6 @@ abstract class DolibarrModules
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $err;
|
return $err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user