dolibarr  18.0.0
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
DolibarrModules Class Reference

Class DolibarrModules. More...

Inheritance diagram for DolibarrModules:
Inheritance graph
[legend]

Public Member Functions

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

Public Attributes

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

Protected Member Functions

 _init ($array_sql, $options='')
 Enables a module. More...
 
 _remove ($array_sql, $options='')
 Disable function. More...
 
 _active ()
 Insert constants for module activation. More...
 
 _unactive ()
 Module deactivation. More...
 
 _load_tables ($reldir, $onlywithsuffix='')
 Create tables and keys required by module: More...
 

Detailed Description

Class DolibarrModules.

Parent class for module descriptor class files

Definition at line 37 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 1039 of file DolibarrModules.class.php.

◆ _init()

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

Enables a module.

Inserts all informations into database.

Parameters
array$array_sqlSQL 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 436 of file DolibarrModules.class.php.

◆ _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 (usualy provided by external modules only)
  • Then update_xxx.sql (usualy 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 if KO, >0 if OK

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

◆ _remove()

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

Disable function.

Deletes the module constants and boxes from the database.

Parameters
string[]$array_sqlSQL requests to be executed when module is disabled
string$optionsOptions when disabling module:
Returns
int 1 if OK, 0 if KO

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

◆ _unactive()

DolibarrModules::_unactive ( )
protected

Module deactivation.

Returns
int Error count (0 if OK)

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

◆ checkForUpdate()

DolibarrModules::checkForUpdate ( )

Check for module update TODO : store results for $this->url_last_version and $this->needUpdate Add a cron task to monitor for updates.

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

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

◆ create_dirs()

DolibarrModules::create_dirs ( )

Creates directories.

Returns
int Error count (0 if OK)

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

◆ delete_boxes()

DolibarrModules::delete_boxes ( )

Removes boxes.

Returns
int Error count (0 if OK)

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

◆ delete_const()

DolibarrModules::delete_const ( )

Removes constants tagged 'deleteonunactive'.

Returns
int <0 if KO, 0 if OK

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

◆ delete_cronjobs()

DolibarrModules::delete_cronjobs ( )

Removes boxes.

Returns
int Error count (0 if OK)

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

◆ delete_dirs()

DolibarrModules::delete_dirs ( )

Removes directories.

Returns
int Error count (0 if OK)

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

◆ delete_menus()

DolibarrModules::delete_menus ( )

Removes menu entries.

Returns
int Error count (0 if OK)

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

◆ delete_module_parts()

DolibarrModules::delete_module_parts ( )

Removes generic parts.

Returns
int Error count (0 if OK)

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

◆ delete_permissions()

DolibarrModules::delete_permissions ( )

Removes access rights.

Returns
int Error count (0 if OK)

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

◆ delete_tabs()

DolibarrModules::delete_tabs ( )

Removes tabs.

Returns
int Error count (0 if OK)

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

◆ getChangeLog()

DolibarrModules::getChangeLog ( )

Gives the changelog.

First check ChangeLog-la_LA.md then ChangeLog.md

Returns
string Content of ChangeLog

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

◆ 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 651 of file DolibarrModules.class.php.

◆ 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 685 of file DolibarrModules.class.php.

◆ 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 739 of file DolibarrModules.class.php.

◆ getExportDatasetLabel()

DolibarrModules::getExportDatasetLabel (   $r)

Gives translated label of an export dataset.

Parameters
int$rDataset index
Returns
string Translated databaset label

Definition at line 926 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 948 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 2409 of file DolibarrModules.class.php.

◆ getLangFilesArray()

DolibarrModules::getLangFilesArray ( )

Gives module related language files list.

Returns
string[] Language files list

Definition at line 914 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 969 of file DolibarrModules.class.php.

◆ getLastActivationInfo()

DolibarrModules::getLastActivationInfo ( )

Gives the last author of activation.

Returns
array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation)

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

◆ getModulePosition()

DolibarrModules::getModulePosition ( )

Gives the module position.

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

Definition at line 871 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 617 of file DolibarrModules.class.php.

◆ getPublisher()

DolibarrModules::getPublisher ( )

Gives the publisher name.

Returns
string Publisher name

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

◆ getPublisherUrl()

DolibarrModules::getPublisherUrl ( )

Gives the publisher url.

Returns
string Publisher url

Definition at line 827 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 840 of file DolibarrModules.class.php.

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

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

◆ 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 1307 of file DolibarrModules.class.php.

◆ insert_const()

DolibarrModules::insert_const ( )

Adds constants.

Returns
int Error count (0 if OK)

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

◆ insert_cronjobs()

DolibarrModules::insert_cronjobs ( )

Adds cronjobs.

Returns
int Error count (0 if OK)

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

◆ 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 2204 of file DolibarrModules.class.php.

◆ insert_menus()

DolibarrModules::insert_menus ( )

Adds menu entries.

Returns
int Error count (0 if OK)

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

◆ insert_module_parts()

DolibarrModules::insert_module_parts ( )

Adds generic parts.

Returns
int Error count (0 if OK)

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

◆ insert_permissions()

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

Adds access rights.

Parameters
int$reinitadminpermsIf 1, we also grant them to all admin users
int$force_entityForce current entity
int$notrigger1=Does not execute triggers, 0= execute triggers
Returns
int Error count (0 if OK)

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

◆ insert_tabs()

DolibarrModules::insert_tabs ( )

Adds tabs.

Returns
int Error count (0 if ok)

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

◆ isCoreOrExternalModule()

DolibarrModules::isCoreOrExternalModule ( )

Tells if module is core or external.

'dolibarr' and 'dolibarr_deprecated' is core 'experimental' and 'development' is core

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

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

◆ 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 modMyModule, modZapier, modWorkstation, modWebhook, modTakePos, modSupplierProposal, modStockTransfer, modRecruitment, modPartnership, modMultiCurrency, modMrp, modKnowledgeManagement, modExternalRss, modEventOrganization, modEmailCollector, modDav, modDataPolicy, modBookCal, modBom, modBlockedLog, and modApi.

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


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