DolibaseModule
class DolibaseModule extends DolibarrModules (View source)
DolibaseModule class
Known issue: When Dolibase is installed globally, DolibaseModule class will be loaded/included only once on "dolibarr/admin/modules.php" file, but when it's installed internally (in each module) then the class will be included from the first loaded module & in the rest of modules the inclusion will be stopped by the if condition above, otherwise you will get this error: DolibaseModule class already exists.
So the issue here is, if a module with an older version of Dolibase is loaded first & one of your modules requires a new version of this class to work properly, then you may face some errors like: Undefined function or attribute xxx in DolibaseModule class.
Solutions:
Use Dolibase module builder (will generate a custom class copy in your module directory).
Keep always your modules up-to-date with the latest version of Dolibase (painful solution).
Each time you add a function in this class/file, you need to copy & paste it into your module(s) class also.
Use namespaces to separate module file(s) from each others (complicated solution, may even not work on Dolibarr).
P.S: This issue affects only DolibaseModule & Widget class & not the other classes of Dolibase.
Properties
array | $config | ||
protected array | $addons |
Methods
Constructor
Function called after module configuration.
Function to check module updates.
Function called when module is enabled.
Enable module for external users
Disable module for external users
Set/Activate addons required by module
Create tables, keys and data required by module Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys and create data commands must be stored in directory /mymodule/sql/ This function is called by this->init
Function called when module is disabled.
Add a constant
Add a widget
Add a permission
Add a sub permission
Generate an ID for permissions
Add a top menu entry
Add a left menu entry
Add a left sub menu entry
Add a menu
Add a CSS file
Add an array of CSS files
Add a JS file
Add an array of JS files
Enable a hook
Enable an array of hooks
Enable triggers
Add a dictionary
Add a module part
Activate a numbering model
Activate a document model
Add a cron job
Add a cron job using a command
Add a cron job using a method
Details
at line 64
__construct($db)
Constructor
at line 155
loadSettings()
Function called after module configuration.
at line 165
protected
checkUpdates($langs)
Function to check module updates.
at line 200
int
init(string $options = '')
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
at line 225
protected
enableModuleForExternalUsers($module_rights_class)
Enable module for external users
at line 240
protected
disableModuleForExternalUsers($module_rights_class)
Disable module for external users
at line 265
protected
setAddons()
Set/Activate addons required by module
at line 294
protected int
loadTables()
Create tables, keys and data required by module Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys and create data commands must be stored in directory /mymodule/sql/ This function is called by this->init
at line 313
int
remove(string $options = '')
Function called when module is disabled.
Remove from database constants, boxes and permissions from Dolibarr database. Data directories are not deleted
at line 334
$this
addConstant($name, $value, $desc = '', $type = 'chaine')
Add a constant
at line 357
$this
addWidget($widget_filename, $note = '', $enabled_by_default_on = 'Home')
Add a widget
at line 377
$this
addPermission($name, $desc = '', $type = '', $enabled_by_default = 1)
Add a permission
at line 400
$this
addSubPermission($perm_name, $subperm_name, $desc = '', $type = '', $enabled_by_default = 1)
Add a sub permission
at line 425
protected int
generatePermissionID()
Generate an ID for permissions
at line 442
$this
addTopMenu($name, $title, $url, $perms = '1', $enabled = '1', $position = 100, $target = '')
Add a top menu entry
at line 462
$this
addLeftMenu($main_menu, $name, $title, $url, $perms = '1', $enabled = '1', $position = 100, $target = '')
Add a left menu entry
at line 483
$this
addLeftSubMenu($main_menu, $left_menu, $name, $title, $url, $perms = '1', $enabled = '1', $position = 100, $target = '')
Add a left sub menu entry
at line 504
protected
addMenu($type, $fk_menu, $main_menu, $left_menu, $title, $url, $position, $enabled = '1', $perms = '1', $target = '')
Add a menu
at line 528
$this
addCssFile($css_filename)
Add a CSS file
at line 541
$this
addCssFiles($css_files_array)
Add an array of CSS files
at line 556
$this
addJsFile($js_filename)
Add a JS file
at line 569
$this
addJsFiles($js_files_array)
Add an array of JS files
at line 584
$this
enableHook($hook)
Enable a hook
at line 597
$this
enableHooks($hooks_array)
Enable an array of hooks
at line 611
$this
enableTriggers()
Enable triggers
at line 632
$this
addDictionary($table_name, $table_label, $select_fields = 'rowid, label, active', $table_sort = 'label ASC', $fields_to_show = 'label', $fields_to_update = 'label', $fields_to_insert = 'label', $table_pk_field = 'rowid', $fields_help = array())
Add a dictionary
at line 663
protected
addModulePart($module_part, $value)
Add a module part
at line 675
$this
activateNumModel($name, $const_prefix = '')
Activate a numbering model
at line 690
$this
activateDocModel($name, $type = '', $const_prefix = '')
Activate a document model
at line 713
protected
addCronJob($label, $type, $command = '', $class = '', $object_name = '', $object_method = '', $method_parameters = '', $comment = '', $frequency = 2, $frequency_unit = 3600, $status, $priority)
Add a cron job
at line 744
$this
addCronCommand($label, $command, $frequency, $frequency_unit, $comment = '', $priority, $status = 1)
Add a cron job using a command
at line 766
$this
addCronMethod($label, $class, $object_name, $object_method, $method_parameters, $frequency, $frequency_unit, $comment = '', $priority, $status = 1)
Add a cron job using a method