dolibarr 21.0.0-beta
DolibarrModules Class Reference

Class DolibarrModules. More...

Inheritance diagram for DolibarrModules:
Collaboration diagram for DolibarrModules:

Public Member Functions

 __construct ($db)
 Constructor.
 
 getName ()
 Gives the translated module name if translation exists in admin.lang or into language files of module.
 
 getDesc ()
 Gives the translated module description if translation exists in admin.lang or the default module description.
 
 getDescLong ()
 Gives the long description of a module.
 
 getDescLongReadmeFound ()
 Return path of file if a README file was found.
 
 getChangeLog ()
 Gives the changelog.
 
 getPublisher ()
 Gives the publisher name.
 
 getPublisherUrl ()
 Gives the publisher url.
 
 getVersion ($translated=1)
 Gives module version (translated if param $translated is on) For 'experimental' modules, gives 'experimental' translation For 'dolibarr' modules, gives Dolibarr version.
 
 getModulePosition ()
 Gives the module position.
 
 isCoreOrExternalModule ()
 Tells if module is core or external.
 
 getLangFilesArray ()
 Gives module related language files list.
 
 getExportDatasetLabel ($r)
 Gives translated label of an export dataset.
 
 getImportDatasetLabel ($r)
 Gives translated label of an import dataset.
 
 getLastActivationDate ()
 Gives the last date of activation.
 
 getLastActivationInfo ()
 Gives the last author of activation.
 
 insert_boxes ($option='')
 Adds boxes.
 
 delete_boxes ()
 Removes boxes.
 
 insert_cronjobs ()
 Adds cronjobs.
 
 delete_cronjobs ()
 Removes boxes.
 
 delete_tabs ()
 Removes tabs.
 
 insert_tabs ()
 Adds tabs.
 
 insert_const ()
 Adds constants.
 
 delete_const ()
 Removes constants tagged 'deleteonunactive'.
 
 insert_permissions ($reinitadminperms=0, $force_entity=null, $notrigger=0)
 Adds access rights.
 
 delete_permissions ()
 Removes access rights.
 
 insert_menus ()
 Adds menu entries.
 
 delete_menus ()
 Removes menu entries.
 
 create_dirs ()
 Creates directories.
 
 insert_dirs ($name, $dir)
 Adds directories definitions.
 
 delete_dirs ()
 Removes directories.
 
 insert_module_parts ()
 Save configuration for generic features.
 
 delete_module_parts ()
 Removes generic parts.
 
 init ($options='')
 Function called when module is enabled.
 
 remove ($options='')
 Function called when module is disabled.
 
 getKanbanView ($codeenabledisable='', $codetoconfig='')
 Return Kanban view of a module.
 
 checkForUpdate ()
 Check for module update.
 
 checkForCompliance ($nametocheck='')
 Check for module compliance with Dolibarr rules and law If a module is reported by this function,it is surely a malware.
 

Public Attributes

 $lastVersion = ''
 Module last version.
 
 $needUpdate = false
 true indicate this module need update
 

Protected Member Functions

 _init ($array_sql, $options='')
 Enables a module.
 
 _remove ($array_sql, $options='')
 Disable function.
 
 _active ()
 Insert constants for module activation.
 
 _unactive ()
 Module deactivation.
 
 _load_tables ($reldir, $onlywithsuffix='')
 Create tables and keys required by module:
 
 declareNewDictionary ($dictionaryArray, $langs='')
 Helper method to declare dictionaries one at a time (rather than declaring dictionaries property by property).
 

Detailed Description

Class DolibarrModules.

Parent class for module descriptor class files

Definition at line 38 of file DolibarrModules.class.php.

Constructor & Destructor Documentation

◆ __construct()

DolibarrModules::__construct ( $db)

Member Function Documentation

◆ _active()

DolibarrModules::_active ( )
protected

Insert constants for module activation.

Returns
int Error count (0 if OK)

Definition at line 1166 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _init().

◆ _init()

DolibarrModules::_init ( $array_sql,
$options = '' )
protected

Enables a module.

Inserts all information into database.

Parameters
array<array{sql:string,ignoreerror:int<0,1>}>|array<string,string>$array_sql SQL requests to be executed when enabling module
string$optionsString with options when disabling module:
  • 'noboxes' = Do all actions but do not insert boxes
  • 'newboxdefonly' = Do all actions but for boxes, insert def of boxes only and not boxes activation
Returns
int 1 if OK, 0 if KO

Definition at line 537 of file DolibarrModules.class.php.

References $conf, _active(), create_dirs(), dol_syslog(), insert_boxes(), insert_const(), insert_cronjobs(), insert_menus(), insert_module_parts(), insert_permissions(), and insert_tabs().

Referenced by init(), modAdherent\init(), modAgenda\init(), modAi\init(), modApi\init(), modAsset\init(), modBanque\init(), modBarcode\init(), modBlockedLog\init(), modBom\init(), modBookCal\init(), modCategorie\init(), modCommande\init(), modComptabilite\init(), modContrat\init(), modDataPolicy\init(), modDav\init(), modDebugBar\init(), modDeplacement\init(), modDocumentGeneration\init(), modDon\init(), modDynamicPrices\init(), modEmailCollector\init(), modEventOrganization\init(), modExpedition\init(), modExpenseReport\init(), modExternalRss\init(), modFacture\init(), modFicheinter\init(), modFournisseur\init(), modHoliday\init(), modHRM\init(), modIntracommreport\init(), modKnowledgeManagement\init(), modLabel\init(), modLoan\init(), modMailing\init(), modMrp\init(), modMultiCurrency\init(), modMyModule\init(), modNotification\init(), modOauth\init(), modOpenIDConnect\init(), modOpenSurvey\init(), modPartnership\init(), modPaymentByBankTransfer\init(), modPrelevement\init(), modProduct\init(), modProductBatch\init(), modProjet\init(), modPropale\init(), modReceiptPrinter\init(), modReception\init(), modRecruitment\init(), modResource\init(), modSalaries\init(), modService\init(), modSociete\init(), modStock\init(), modStockTransfer\init(), modSupplierProposal\init(), modTakePos\init(), modTax\init(), modTicket\init(), modUser\init(), modVariants\init(), modWebhook\init(), modWebPortal\init(), modWebsite\init(), modWorkflow\init(), modWorkstation\init(), and modZapier\init().

◆ _load_tables()

DolibarrModules::_load_tables ( $reldir,
$onlywithsuffix = '' )
protected

Create tables and keys required by module:

  • Files table.sql or table-module.sql with create table instructions
  • Then table.key.sql or table-module.key.sql with create keys instructions
  • Then data_xxx.sql (usually provided by external modules only)
  • Then update_xxx.sql (usually provided by external modules only) Files must be stored in subdirectory 'tables' or 'data' into directory $reldir (Example: '/install/mysql/' or '/module/sql/') This function may also be called by :
  • _load_tables('/install/mysql/', 'modulename') into the this->init() of core module descriptors.
  • _load_tables('/mymodule/sql/') into the this->init() of external module descriptors.
Parameters
string$reldirRelative directory where to scan files. Example: '/install/mysql/' or '/module/sql/'
string$onlywithsuffixOnly with the defined suffix
Returns
int<0,1> Return integer <=0 if KO, >0 if OK

Definition at line 1253 of file DolibarrModules.class.php.

References $conf, dol_syslog(), getDolGlobalString(), and run_sql().

Referenced by modAsset\init(), modBom\init(), modBookCal\init(), modDeplacement\init(), modDon\init(), modDynamicPrices\init(), modExpenseReport\init(), modHRM\init(), modIntracommreport\init(), modKnowledgeManagement\init(), modLoan\init(), modMailing\init(), modMrp\init(), modMyModule\init(), modOpenSurvey\init(), modPartnership\init(), modReceiptPrinter\init(), modRecruitment\init(), modStock\init(), modStockTransfer\init(), modTakePos\init(), modTicket\init(), modVariants\init(), modWebhook\init(), modWebsite\init(), modWorkstation\init(), and modZapier\init().

◆ _remove()

◆ _unactive()

DolibarrModules::_unactive ( )
protected

Module deactivation.

Returns
int Error count (0 if OK)

Definition at line 1216 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ checkForCompliance()

DolibarrModules::checkForCompliance ( $nametocheck = '')

Check for module compliance with Dolibarr rules and law If a module is reported by this function,it is surely a malware.

Delete it as soon as possible.

Parameters
string$nametocheckName to check
Returns
int|string Return integer <0 if Error, 0 == not compliant, 'string' with message if module not compliant

Definition at line 2729 of file DolibarrModules.class.php.

◆ checkForUpdate()

DolibarrModules::checkForUpdate ( )

Check for module update.

Get URL content of $this->url_last_version and set $this->lastVersion and$this->needUpdate TODO Store result in DB. TODO Add a cron task to monitor for updates.

Returns
int Return integer <0 if Error, 0 == no update needed, >0 if need update

Definition at line 2700 of file DolibarrModules.class.php.

◆ create_dirs()

DolibarrModules::create_dirs ( )

Creates directories.

Returns
int Error count (0 if OK)

Definition at line 2290 of file DolibarrModules.class.php.

References $conf, dol_mkdir(), dol_syslog(), getDolGlobalString(), and insert_dirs().

Referenced by _init().

◆ declareNewDictionary()

DolibarrModules::declareNewDictionary ( $dictionaryArray,
$langs = '' )
protected

Helper method to declare dictionaries one at a time (rather than declaring dictionaries property by property).

Parameters
array{name:string,lib:string,sql:string,sqlsort:string,field:string,fieldvalue:string,fieldinsert:string,rowid:string,cond:bool,help:array<string,string>,fieldcheck?:null}$dictionaryArray Array describing one dictionary. Keys are: 'name', table name (without prefix) 'lib', dictionary label 'sql', query for select 'sqlsort', sort order 'field', comma-separated list of fields to select 'fieldvalue', list of columns used for editing existing rows 'fieldinsert', list of columns used for inserting new rows 'rowid', name of the technical ID (primary key) column, usually 'rowid' 'cond', condition for the dictionary to be shown / active 'help', optional array of translation keys by column for tooltips 'fieldcheck' (appears to be unused)
string$langsOptional translation file to include (appears to be unused)
Returns
void

Definition at line 2799 of file DolibarrModules.class.php.

Referenced by modTicket\__construct().

◆ delete_boxes()

DolibarrModules::delete_boxes ( )

Removes boxes.

Returns
int Error count (0 if OK)

Definition at line 1532 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ delete_const()

DolibarrModules::delete_const ( )

Removes constants tagged 'deleteonunactive'.

Returns
int Return integer <0 if KO, 0 if OK

Definition at line 1919 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ delete_cronjobs()

DolibarrModules::delete_cronjobs ( )

Removes boxes.

Returns
int Error count (0 if OK)

Definition at line 1726 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and name.

Referenced by _remove().

◆ delete_dirs()

DolibarrModules::delete_dirs ( )

Removes directories.

Returns
int Error count (0 if OK)

Definition at line 2398 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ delete_menus()

DolibarrModules::delete_menus ( )

Removes menu entries.

Returns
int Error count (0 if OK)

Definition at line 2259 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and name.

Referenced by _remove().

◆ delete_module_parts()

DolibarrModules::delete_module_parts ( )

Removes generic parts.

Returns
int Error count (0 if OK)

Definition at line 2538 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ delete_permissions()

DolibarrModules::delete_permissions ( )

Removes access rights.

Returns
int Error count (0 if OK)

Definition at line 2125 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and name.

Referenced by _remove().

◆ delete_tabs()

DolibarrModules::delete_tabs ( )

Removes tabs.

Returns
int Error count (0 if OK)

Definition at line 1757 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _remove().

◆ getChangeLog()

DolibarrModules::getChangeLog ( )

Gives the changelog.

First check ChangeLog-la_LA.md then ChangeLog.md

Returns
string Content of ChangeLog

Definition at line 899 of file DolibarrModules.class.php.

References dol_buildpath(), dol_is_file(), dolMd2Html(), and name.

◆ getDesc()

DolibarrModules::getDesc ( )

Gives the translated module description if translation exists in admin.lang or the default module description.

Returns
string Translated module description

Definition at line 776 of file DolibarrModules.class.php.

References description, and name.

Referenced by getKanbanView().

◆ getDescLong()

DolibarrModules::getDescLong ( )

Gives the long description of a module.

First check README-la_LA.md then README.md If no markdown files found, it returns translated value of the key ->descriptionlong.

Returns
string Long description of a module from README.md of from property.

Definition at line 810 of file DolibarrModules.class.php.

References dol_buildpath(), dolMd2Html(), getDescLongReadmeFound(), and name.

◆ getDescLongReadmeFound()

DolibarrModules::getDescLongReadmeFound ( )

Return path of file if a README file was found.

Returns
string Path of file if a README file was found.

Definition at line 864 of file DolibarrModules.class.php.

References dol_buildpath(), dol_is_file(), and name.

Referenced by getDescLong().

◆ getExportDatasetLabel()

DolibarrModules::getExportDatasetLabel ( $r)

Gives translated label of an export dataset.

Parameters
int$rDataset index
Returns
string Translated databaset label

Definition at line 1053 of file DolibarrModules.class.php.

◆ getImportDatasetLabel()

DolibarrModules::getImportDatasetLabel ( $r)

Gives translated label of an import dataset.

Parameters
int$rDataset index
Returns
string Translated dataset label

Definition at line 1075 of file DolibarrModules.class.php.

◆ getKanbanView()

DolibarrModules::getKanbanView ( $codeenabledisable = '',
$codetoconfig = '' )

Return Kanban view of a module.

Parameters
string$codeenabledisableHTML code for button to enable/disable module
string$codetoconfigHTML code to go to config page
Returns
string HTML code of Kanban view

Definition at line 2608 of file DolibarrModules.class.php.

References $lastVersion, dol_escape_htmltag(), dol_escape_js(), getDesc(), getDolGlobalString(), getName(), getVersion(), img_object(), img_picto(), and isCoreOrExternalModule().

◆ getLangFilesArray()

DolibarrModules::getLangFilesArray ( )

Gives module related language files list.

Returns
string[] Language files list

Definition at line 1041 of file DolibarrModules.class.php.

◆ getLastActivationDate()

DolibarrModules::getLastActivationDate ( )

Gives the last date of activation.

Returns
int|string Date of last activation or '' if module was never activated

Definition at line 1096 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

◆ getLastActivationInfo()

DolibarrModules::getLastActivationInfo ( )

Gives the last author of activation.

Returns
array{}|array{authorid:int|'',ip:string,lastactivationdate:int|'',lastactivationversion:string} Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation)

Definition at line 1126 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

◆ getModulePosition()

DolibarrModules::getModulePosition ( )

Gives the module position.

Returns
string Module position (an external module should never return a value lower than 100000. 1-100000 are reserved for core)

Definition at line 998 of file DolibarrModules.class.php.

◆ getName()

DolibarrModules::getName ( )

Gives the translated module name if translation exists in admin.lang or into language files of module.

Otherwise return the module key name.

Returns
string Translated module name

Definition at line 742 of file DolibarrModules.class.php.

References name.

Referenced by getKanbanView().

◆ getPublisher()

DolibarrModules::getPublisher ( )

Gives the publisher name.

Returns
string Publisher name

Definition at line 944 of file DolibarrModules.class.php.

◆ getPublisherUrl()

DolibarrModules::getPublisherUrl ( )

Gives the publisher url.

Returns
string Publisher url

Definition at line 954 of file DolibarrModules.class.php.

◆ getVersion()

DolibarrModules::getVersion ( $translated = 1)

Gives module version (translated if param $translated is on) For 'experimental' modules, gives 'experimental' translation For 'dolibarr' modules, gives Dolibarr version.

Parameters
int$translated1=Special version keys are translated, 0=Special version keys are not translated
Returns
string Module version

Definition at line 967 of file DolibarrModules.class.php.

Referenced by getKanbanView().

◆ init()

DolibarrModules::init ( $options = '')

Function called when module is enabled.

The init function adds tabs, constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. It also creates data directories

Parameters
string$optionsOptions when enabling module ('', 'newboxdefonly', 'noboxes', 'menuonly') 'noboxes' = Do not insert boxes 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
Returns
int 1 if OK, 0 if KO

Reimplemented in modAdherent, modAgenda, modAi, modApi, modAsset, modBanque, modBarcode, modBlockedLog, modBom, modBookCal, modCategorie, modCommande, modComptabilite, modContrat, modDataPolicy, modDav, modDebugBar, modDeplacement, modDocumentGeneration, modDon, modDynamicPrices, modEmailCollector, modEventOrganization, modExpedition, modExpenseReport, modExternalRss, modFacture, modFicheinter, modFournisseur, modHoliday, modHRM, modIntracommreport, modKnowledgeManagement, modLabel, modLoan, modMailing, modMrp, modMultiCurrency, modMyModule, modNotification, modOauth, modOpenIDConnect, modOpenSurvey, modPartnership, modPaymentByBankTransfer, modPrelevement, modProduct, modProductBatch, modProjet, modPropale, modReceiptPrinter, modReception, modRecruitment, modResource, modSalaries, modService, modSociete, modStock, modStockTransfer, modSupplierProposal, modTakePos, modTax, modTicket, modUser, modVariants, modWebhook, modWebPortal, modWebsite, modWorkflow, modWorkstation, and modZapier.

Definition at line 2582 of file DolibarrModules.class.php.

References _init().

◆ insert_boxes()

DolibarrModules::insert_boxes ( $option = '')

Adds boxes.

Parameters
string$optionOptions when disabling module ('newboxdefonly'=insert only boxes definition)
Returns
int Error count (0 if OK)

Definition at line 1434 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and InfoBox\getListOfPagesForBoxes().

Referenced by _init().

◆ insert_const()

DolibarrModules::insert_const ( )

Adds constants.

Returns
int Error count (0 if OK)

Definition at line 1850 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _init().

◆ insert_cronjobs()

DolibarrModules::insert_cronjobs ( )

Adds cronjobs.

Returns
int Error count (0 if OK)

Definition at line 1606 of file DolibarrModules.class.php.

References $conf, dol_now(), dol_syslog(), and name.

Referenced by _init().

◆ insert_dirs()

DolibarrModules::insert_dirs ( $name,
$dir )

Adds directories definitions.

Parameters
string$nameName
string$dirDirectory
Returns
int Error count (0 if OK)

Definition at line 2359 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and name.

Referenced by create_dirs().

◆ insert_menus()

DolibarrModules::insert_menus ( )

Adds menu entries.

Returns
int Error count (0 if OK)

Definition at line 2158 of file DolibarrModules.class.php.

References $conf, dol_syslog(), and name.

Referenced by _init().

◆ insert_module_parts()

DolibarrModules::insert_module_parts ( )

Save configuration for generic features.

This also generate website templates if the module provide some.

Returns
int Error count (0 if OK)

Definition at line 2425 of file DolibarrModules.class.php.

References $conf, dol_buildpath(), dol_copy(), dol_delete_file(), dol_dir_list(), dol_syslog(), and name.

Referenced by _init().

◆ insert_permissions()

DolibarrModules::insert_permissions ( $reinitadminperms = 0,
$force_entity = null,
$notrigger = 0 )

Adds access rights.

Parameters
int<0,1>$reinitadminperms If 1, we also grant them to all admin users
?int$force_entityForce current entity
int<0,1>$notrigger 1=Does not execute triggers, 0= execute triggers
Returns
int Error count (0 if OK)

Definition at line 1958 of file DolibarrModules.class.php.

References $conf, dol_print_error(), dol_syslog(), and name.

Referenced by _init().

◆ insert_tabs()

DolibarrModules::insert_tabs ( )

Adds tabs.

Returns
int Error count (0 if ok)

Definition at line 1783 of file DolibarrModules.class.php.

References $conf, and dol_syslog().

Referenced by _init().

◆ isCoreOrExternalModule()

DolibarrModules::isCoreOrExternalModule ( )

Tells if module is core or external.

Version = 'dolibarr', 'dolibarr_deprecated', 'experimental' and 'development' means core modules

Returns
string 'core', 'external' or 'unknown'

Definition at line 1018 of file DolibarrModules.class.php.

Referenced by getKanbanView().

◆ remove()

DolibarrModules::remove ( $options = '')

Function called when module is disabled.

The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. Data directories are not deleted

Parameters
string$optionsOptions when enabling module ('', 'noboxes')
Returns
int 1 if OK, 0 if KO

Reimplemented in modAi, modApi, modBlockedLog, modBom, modBookCal, modDataPolicy, modDav, modEmailCollector, modEventOrganization, modExternalRss, modKnowledgeManagement, modMrp, modMultiCurrency, modMyModule, modPartnership, modRecruitment, modStockTransfer, modSupplierProposal, modTakePos, modWebhook, modWebPortal, modWorkstation, and modZapier.

Definition at line 2595 of file DolibarrModules.class.php.

References _remove().


The documentation for this class was generated from the following file: