modVariants
class modVariants extends DolibarrModules (View source)
Description and activation class for module Product variants
Constants
| URL_FOR_BLACKLISTED_MODULES |
|
| KEY_ID |
|
| KEY_LABEL |
|
| KEY_TYPE |
|
| KEY_DEFAULT |
|
| KEY_FIRST_LEVEL |
|
| KEY_SECOND_LEVEL |
|
| KEY_MODULE |
|
| KEY_ENABLED |
|
Properties
| DoliDB | $db | from DolibarrModules | |
| int | $numero | from DolibarrModules | |
| string | $editor_name | from DolibarrModules | |
| string | $editor_url | from DolibarrModules | |
| string | $editor_squarred_logo | from DolibarrModules | |
| $family | from DolibarrModules | ||
| $familyinfo | from DolibarrModules | ||
| string | $module_position | from DolibarrModules | |
| string | $name | from DolibarrModules | |
| string[] | $dirs | from DolibarrModules | |
| array<array{file?: string, note?: string, enabledbydefaulton: string, 1?: string}> | $boxes | from DolibarrModules | |
| array<array{0: string, 1: string, 2: string|int, 3: string, 4?: int<0, 1>, 5?: string, 6?: int<0, 1>}> | $const | from DolibarrModules | |
| array<array{entity?: int, label?: string, jobtype?: string, class?: string, objectname?: string, method?: string, command?: string, parameters?: string, md5params?: string, comment?: string, frequency?: int, unitfrequency?: int, priority?: int, datestart?: int, dateend?: int, datenextrun?: string, status?: int, maxrun?: int, libname?: string, test?: string|bool}> | $cronjobs | from DolibarrModules | |
| array<int, array<int<0, 7>, string|int>> | $rights | from DolibarrModules | |
| int<0, 1> | $rights_admin_allowed | from DolibarrModules | |
| string | $rights_class | from DolibarrModules | |
| array<array{commentgroup?: string, mainmenu: string, leftmenu: string, langs: string, enabled: int|string, target: string, titre: string, user: int, fk_menu: string, fk_parent: string, url: string, position: int, positionfull: int|string, perms: string, type: string}>|int<1, 1> | $menu | from DolibarrModules | |
| array{triggers?: int<0, 1>, login?: int<0, 1>, substitutions?: int<0, 1>, menus?: int<0, 1>, theme?: int<0, 1>, tpl?: int<0, 1>, barcode?: int<0, 1>, models?: int<0, 1>, printing?: int<0, 1>, css?: string[], js?: string[], hooks?: array{data?: string[], entity?: string}, moduleforexternal?: int<0, 1>, websitetemplates?: int<0, 1>, contactelement?: int<0, 1>} | $module_parts | from DolibarrModules | |
| string | $error | from DolibarrModules | |
| string[] | $errors | from DolibarrModules | |
| string | $version | from DolibarrModules | |
| string | $lastVersion | Module last version |
from DolibarrModules |
| bool | $needUpdate | true indicate this module need update |
from DolibarrModules |
| string | $description | from DolibarrModules | |
|
string
Since: 4.0.0 HTML content supported.
|
$descriptionlong | from DolibarrModules | |
| array{}|array{langs: string, tabname: string[], tablib: string[], tabsql: string[], tabsqlsort: string[], tabfield: string[], tabfieldvalue: string[], tabfieldinsert: string[], tabrowid: string[], tabcond: array<bool|int<0, 1>>, tabhelp: array<array<string, string>>} | $dictionaries | from DolibarrModules | |
| array<string|array{data: string, entity: int}> | $tabs | from DolibarrModules | |
| string[] | $export_code | from DolibarrModules | |
| string[] | $export_label | from DolibarrModules | |
| string[] | $export_icon | from DolibarrModules | |
| string[] | $export_enabled | from DolibarrModules | |
| array<array<array{string, string}>> | $export_permission | from DolibarrModules | |
| array<array<string, string>> | $export_fields_array | from DolibarrModules | |
| array<array<string, string>> | $export_TypeFields_array | from DolibarrModules | |
| array<array<string, string>> | $export_entities_array | from DolibarrModules | |
| array<array<string, string>> | $export_aggregate_array | from DolibarrModules | |
| array<array<string, string>> | $export_examplevalues_array | from DolibarrModules | |
| array<array<string, string>> | $export_help_array | from DolibarrModules | |
| array<array<array{rule: string, file: string, classfile: string, class: string, method: string, method_params: string[]}>>|array<array<string, string>> | $export_special_array | from DolibarrModules | |
| array<int, array<string, string|string[]>> | $export_dependencies_array | from DolibarrModules | |
| string[] | $export_sql_start | from DolibarrModules | |
| string[] | $export_sql_end | from DolibarrModules | |
| string[] | $export_sql_order | from DolibarrModules | |
| string | $import_code | from DolibarrModules | |
| string[] | $import_label | from DolibarrModules | |
| string[] | $import_icon | from DolibarrModules | |
| array<array<string, string>> | $import_entities_array | from DolibarrModules | |
| array<array<string, string>> | $import_tables_array | from DolibarrModules | |
| array<array<string, string>> | $import_tables_creator_array | from DolibarrModules | |
| array<array<string, string>> | $import_fields_array | from DolibarrModules | |
| $import_fieldshidden_array | from DolibarrModules | ||
| array<array<array<string, string>>> | $import_convertvalue_array | from DolibarrModules | |
| array<array<string, string>> | $import_regex_array | from DolibarrModules | |
| array<array<string, string>> | $import_examplevalues_array | from DolibarrModules | |
| array<array<string, string>> | $import_updatekeys_array | from DolibarrModules | |
| array<int, array<int, string>> | $import_run_sql_after_array | from DolibarrModules | |
| array<array<string, string>> | $import_TypeFields_array | from DolibarrModules | |
| array<array<string, string>> | $import_help_array | from DolibarrModules | |
| string | $const_name | from DolibarrModules | |
| bool | $always_enabled | from DolibarrModules | |
| bool | $disabled | from DolibarrModules | |
| array<string, string> | $automatic_activation | from DolibarrModules | |
| int | $core_enabled | from DolibarrModules | |
| string | $picto | from DolibarrModules | |
| string[]|string | $config_page_url | from DolibarrModules | |
| $depends | from DolibarrModules | ||
| $requiredby | from DolibarrModules | ||
| $conflictwith | from DolibarrModules | ||
| null|string[] | $langfiles | from DolibarrModules | |
| array<string, mixed> | $warnings_activation | from DolibarrModules | |
| array<string, mixed> | $warnings_activation_ext | from DolibarrModules | |
| array<string, string> | $warnings_unactivation | from DolibarrModules | |
| null|int[] | $phpmin | from DolibarrModules | |
| null|int[] | $phpmax | from DolibarrModules | |
| null|int[] | $need_dolibarr_version | from DolibarrModules | |
| int[] | $max_dolibarr_version | from DolibarrModules | |
| int<0, 1> | $need_javascript_ajax | from DolibarrModules | |
| bool | $enabled_bydefault | from DolibarrModules | |
| $hidden | from DolibarrModules | ||
| string | $url_last_version | from DolibarrModules |
Methods
Enables a module.
Disable function. Deletes the module constants and boxes from the database.
Gives the translated module name if translation exists in admin.lang or into language files of module.
Gives the translated module description if translation exists in admin.lang or the default module description
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.
Return path of file if a README file was found.
Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md
Gives module version (translated if param $translated is on) For 'experimental' modules, gives 'experimental' translation For 'dolibarr' modules, gives Dolibarr version
Gives translated label of an export dataset
Gives translated label of an import dataset
Gives the last author of activation
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.
Adds access rights
Function called when module is enabled.
Return Kanban view of a module
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.
Helper method to declare dictionaries one at a time (rather than declaring dictionaries property by property).
Details
__construct(DoliDB $db)
Constructor. Define names, constants, directories, boxes, permissions
@param DoliDB $db Database handler
protected int
_init(array<array{sql: string, ignoreerror: int<0, 1>}>|string[] $array_sql, string $options = '')
Enables a module.
Inserts all information into database.
protected int
_remove(string[] $array_sql, string $options = '')
Disable function. Deletes the module constants and boxes from the database.
string
getName()
Gives the translated module name if translation exists in admin.lang or into language files of module.
Otherwise return the module key name.
string
getDesc(int<0, 1> $foruseinpopupdesc = 0)
Gives the translated module description if translation exists in admin.lang or the default module description
string
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.
string
getDescLongReadmeFound()
Return path of file if a README file was found.
string
getChangeLog()
Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md
string
getPublisher()
Gives the publisher name
string
getPublisherUrl()
Gives the publisher url
string
getVersion(int $translated = 1)
Gives module version (translated if param $translated is on) For 'experimental' modules, gives 'experimental' translation For 'dolibarr' modules, gives Dolibarr version
string
getModulePosition()
Gives the module position
string
isCoreOrExternalModule()
Tells if module is core or external.
Version = 'dolibarr', 'dolibarr_deprecated', 'experimental' and 'development' means core modules
string[]
getLangFilesArray()
Gives module related language files list
string
getExportDatasetLabel(int $r)
Gives translated label of an export dataset
string
getImportDatasetLabel(int $r)
Gives translated label of an import dataset
int|string
getLastActivationDate()
Gives the last date of activation
array{}|array{authorid: int|"", ip: string, lastactivationdate: int|"", lastactivationversion: string}
getLastActivationInfo()
Gives the last author of activation
protected int
_active()
Insert constants for module activation
protected int
_unactive()
Module deactivation
protected int<0, 1>
_load_tables(string $reldir, string $onlywithsuffix = '')
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.
int
insert_boxes(string $option = '')
Adds boxes
int
delete_boxes()
Removes boxes
int
insert_cronjobs()
Adds cronjobs
int
delete_cronjobs()
Removes boxes
int
delete_tabs()
Removes tabs
int
insert_tabs()
Adds tabs
int
insert_const()
Adds constants
int
delete_const()
Removes constants tagged 'deleteonunactive'
int
insert_permissions(int<0, 1> $reinitadminperms = 0, ?int $force_entity = null, int<0, 1> $notrigger = 0)
Adds access rights
int
delete_permissions()
Removes access rights
int
insert_menus()
Adds menu entries
int
delete_menus()
Removes menu entries
int
create_dirs()
Creates directories
int
insert_dirs(string $name, string $dir)
Adds directories definitions
int
delete_dirs()
Removes directories
int
insert_module_parts()
Save configuration for generic features.
This also generate website templates if the module provide some.
int
delete_module_parts()
Removes generic parts
int
init(string $options = '')
Function called when module is enabled.
The init function adds constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. It also creates data directories
int
remove(string $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
string
getKanbanView(string $codeenabledisable = '', string $codetoconfig = '')
Return Kanban view of a module
int
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.
int|string
checkForCompliance(string $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.
protected void
declareNewDictionary(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, string $langs = '')
Helper method to declare dictionaries one at a time (rather than declaring dictionaries property by property).