dolibarr 20.0.0
admin.lib.php File Reference

Library of admin functions. More...

Go to the source code of this file.

Functions

 versiontostring ($versionarray)
 Renvoi une version en chaine depuis une version en tableau.
 
 versioncompare ($versionarray1, $versionarray2)
 Compare 2 versions (stored into 2 arrays).
 
 versionphparray ()
 Return version PHP.
 
 versiondolibarrarray ()
 Return version Dolibarr.
 
 run_sql ($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
 Launch a sql file.
 
 dolibarr_del_const ($db, $name, $entity=1)
 Delete a constant.
 
 dolibarr_get_const ($db, $name, $entity=1)
 Get the value of a setup constant from database.
 
 dolibarr_set_const ($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
 Insert a parameter (key,value) into database (delete old key then insert it again).
 
 modules_prepare_head ($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
 Prepare array with list of tabs.
 
 ihm_prepare_head ()
 Prepare array with list of tabs.
 
 security_prepare_head ()
 Prepare array with list of tabs.
 
 modulehelp_prepare_head ($object)
 Prepare array with list of tabs.
 
 translation_prepare_head ()
 Prepare array with list of tabs.
 
 defaultvalues_prepare_head ()
 Prepare array with list of tabs.
 
 listOfSessions ()
 Return list of session.
 
 purgeSessions ($mysessionid)
 Purge existing sessions.
 
 activateModule ($value, $withdeps=1, $noconfverification=0)
 Enable a module.
 
 unActivateModule ($value, $requiredby=1)
 Disable a module.
 
 complete_dictionary_with_modules (&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
 Add external modules to list of dictionaries.
 
 activateModulesRequiredByCountry ($country_code)
 Activate external modules mandatory when country is country_code.
 
 complete_elementList_with_modules (&$elementList)
 Search external modules to complete the list of contact element.
 
 form_constantes ($tableau, $strictw3c=2, $helptext='', $text='Value')
 Show array with constants to edit.
 
 showModulesExludedForExternal ($modules)
 Show array with constants to edit.
 
 addDocumentModel ($name, $type, $label='', $description='')
 Add document model used by doc generator.
 
 delDocumentModel ($name, $type)
 Delete document model used by doc generator.
 
 phpinfo_array ()
 Return the php_info into an array.
 
 company_admin_prepare_head ()
 Return array head with list of tabs to view object information.
 
 email_admin_prepare_head ()
 Return array head with list of tabs to view object information.
 

Detailed Description

Library of admin functions.

Definition in file admin.lib.php.

Function Documentation

◆ activateModule()

activateModule ( $value,
$withdeps = 1,
$noconfverification = 0 )

Enable a module.

Parameters
string$valueName of module to activate
int$withdepsActivate/Disable also all dependencies
int$noconfverificationRemove verification of $conf variable for module
Returns
array{nbmodules?:int,errors:string[],nbperms?:int} array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added);

Definition at line 1125 of file admin.lib.php.

References activateModule(), dol_syslog(), dolGetModulesDirs(), getDolGlobalString(), unActivateModule(), versioncompare(), versiondolibarrarray(), versionphparray(), and versiontostring().

Referenced by activateModule(), and activateModulesRequiredByCountry().

◆ activateModulesRequiredByCountry()

activateModulesRequiredByCountry ( $country_code)

Activate external modules mandatory when country is country_code.

Parameters
string$country_codeCountryCode
Returns
int 1

Definition at line 1515 of file admin.lib.php.

References activateModule(), dol_osencode(), dol_strlen(), dol_syslog(), dolGetModulesDirs(), getDolGlobalInt(), getDolGlobalString(), and setEventMessages().

◆ addDocumentModel()

addDocumentModel ( $name,
$type,
$label = '',
$description = '' )

Add document model used by doc generator.

Parameters
string$nameModel name
string$typeModel type
string$labelModel label
string$descriptionModel description
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 1940 of file admin.lib.php.

References dol_print_error(), and dol_syslog().

◆ company_admin_prepare_head()

company_admin_prepare_head ( )

Return array head with list of tabs to view object information.

Returns
array head array with tabs

Definition at line 2029 of file admin.lib.php.

References complete_head_from_modules().

◆ complete_dictionary_with_modules()

complete_dictionary_with_modules ( & $taborder,
& $tabname,
& $tablib,
& $tabsql,
& $tabsqlsort,
& $tabfield,
& $tabfieldvalue,
& $tabfieldinsert,
& $tabrowid,
& $tabcond,
& $tabhelp,
& $tabcomplete )

Add external modules to list of dictionaries.

Addition is done into var $taborder, $tabname, etc... that are passed with pointers.

Parameters
array$taborderTaborder
array$tabnameTabname
array$tablibTablib
array$tabsqlTabsql
array$tabsqlsortTabsqlsort
array$tabfieldTabfield
array$tabfieldvalueTabfieldvalue
array$tabfieldinsertTabfieldinsert
array$tabrowidTabrowid
array$tabcondTabcond
array$tabhelpTabhelp
array$tabcompleteTab complete (will replace all other in future). Key is table name.
Returns
int 1

Definition at line 1344 of file admin.lib.php.

References dol_osencode(), dol_strlen(), dol_syslog(), dolGetModulesDirs(), getDolGlobalInt(), and getDolGlobalString().

◆ complete_elementList_with_modules()

complete_elementList_with_modules ( & $elementList)

Search external modules to complete the list of contact element.

Parameters
array<string,string>$elementList elementList
Returns
int 1

Definition at line 1577 of file admin.lib.php.

References dol_osencode(), dol_strlen(), dol_syslog(), dolGetModulesDirs(), getDolGlobalInt(), and getDolGlobalString().

◆ defaultvalues_prepare_head()

defaultvalues_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

Definition at line 964 of file admin.lib.php.

References complete_head_from_modules().

◆ delDocumentModel()

delDocumentModel ( $name,
$type )

Delete document model used by doc generator.

Parameters
string$nameModel name
string$typeModel type
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 1971 of file admin.lib.php.

References dol_print_error(), and dol_syslog().

◆ dolibarr_del_const()

dolibarr_del_const ( $db,
$name,
$entity = 1 )

Delete a constant.

Parameters
DoliDB$dbDatabase handler
string | int$nameName of constant or rowid of line
int$entityMulti company id, -1 for all entities
Returns
int Return integer <0 if KO, >0 if OK
See also
dolibarr_get_const(), dolibarr_set_const(), dol_set_user_param()

Definition at line 580 of file admin.lib.php.

References dol_print_error(), and dol_syslog().

◆ dolibarr_get_const()

dolibarr_get_const ( $db,
$name,
$entity = 1 )

Get the value of a setup constant from database.

Parameters
DoliDB$dbDatabase handler
string$nameName of constant
int$entityMulti company id
Returns
string Value of constant
See also
dolibarr_del_const(), dolibarr_set_const(), dol_set_user_param()

Definition at line 620 of file admin.lib.php.

References dol_syslog(), and dolDecrypt().

◆ dolibarr_set_const()

dolibarr_set_const ( $db,
$name,
$value,
$type = 'chaine',
$visible = 0,
$note = '',
$entity = 1 )

Insert a parameter (key,value) into database (delete old key then insert it again).

Parameters
DoliDB$dbDatabase handler
string$nameName of constant
string$valueValue of constant
string$typeType of constant. Deprecated, only strings are allowed for $value. Caller must json encode/decode to store other type of data.
int$visibleIs constant visible in Setup->Other page (0 by default)
string$noteNote on parameter
int$entityMulti company id (0 means all entities)
Returns
int -1 if KO, 1 if OK
See also
dolibarr_del_const(), dolibarr_get_const(), dol_set_user_param()

Definition at line 656 of file admin.lib.php.

References dol_print_error(), dol_syslog(), and dolEncrypt().

Referenced by modGeneratePassPerso\__construct(), BlockedLog\getSignature(), modEventOrganization\init(), modProductBatch\init(), modTakePos\init(), FormSetupItem\saveConfValue(), and top_htmlhead().

◆ email_admin_prepare_head()

email_admin_prepare_head ( )

Return array head with list of tabs to view object information.

Returns
array head array with tabs

Definition at line 2068 of file admin.lib.php.

References complete_head_from_modules().

◆ form_constantes()

form_constantes ( $tableau,
$strictw3c = 2,
$helptext = '',
$text = 'Value' )

Show array with constants to edit.

Parameters
array<string,array{type:string,label:string}>$tableau Array of constants array('key'=>array('type'=>type, 'label'=>label) where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ...
int<2,3>$strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (deprecated), 2=No form nor button at all, 3=No form nor button at all and each field has a unique name (form is output by caller, recommended) (typed as int<2,3> to highlight the deprecated values)
string$helptextTooltip help to use for the column name of values
string$textText to use for the column name of values
Returns
void

Definition at line 1684 of file admin.lib.php.

References dol_escape_htmltag(), dol_syslog(), img_down(), and img_picto().

◆ ihm_prepare_head()

ihm_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

Definition at line 773 of file admin.lib.php.

References complete_head_from_modules().

◆ listOfSessions()

listOfSessions ( )

Return list of session.

Returns
array<string,array{login:string,age:int,creation:int,modification:int,raw:string}> Array list of sessions

Definition at line 1016 of file admin.lib.php.

References dol_osencode(), dol_syslog(), and getDolGlobalString().

◆ modulehelp_prepare_head()

modulehelp_prepare_head ( $object)

Prepare array with list of tabs.

Parameters
object$objectDescriptor class
Returns
array Array of tabs to show

Definition at line 896 of file admin.lib.php.

References $object, and complete_head_from_modules().

◆ modules_prepare_head()

modules_prepare_head ( $nbofactivatedmodules,
$nboftotalmodules,
$nbmodulesnotautoenabled )

Prepare array with list of tabs.

Parameters
int$nbofactivatedmodulesNumber if activated modules
int$nboftotalmodulesNb of total modules
int$nbmodulesnotautoenabledNb of modules not auto enabled that are activated
Returns
array Array of tabs to show

Definition at line 728 of file admin.lib.php.

References getDolGlobalInt(), getDolGlobalString(), and img_picto().

◆ phpinfo_array()

phpinfo_array ( )

Return the php_info into an array.

Returns
array Array with PHP infos

Definition at line 2000 of file admin.lib.php.

◆ purgeSessions()

purgeSessions ( $mysessionid)

Purge existing sessions.

Parameters
int$mysessionidTo avoid to try to delete my own session
Returns
int >0 if OK, <0 if KO

Definition at line 1072 of file admin.lib.php.

References dol_osencode(), dol_syslog(), and getDolGlobalString().

◆ run_sql()

run_sql ( $sqlfile,
$silent = 1,
$entity = 0,
$usesavepoint = 1,
$handler = '',
$okerror = 'default',
$linelengthlimit = 32768,
$nocommentremoval = 0,
$offsetforchartofaccount = 0,
$colspan = 0,
$onlysqltoimportwebsite = 0,
$database = '' )

Launch a sql file.

Function is used by:

  • Migrate process (dolibarr-xyz-abc.sql)
  • Loading sql menus (auguria)
  • Running specific Sql by a module init
  • Loading sql file of website import package Install process however does not use it. Note that Sql files must have all comments at start of line. Also this function take ';' as the char to detect end of sql request
Parameters
string$sqlfileFull path to sql file
int$silent1=Do not output anything, 0=Output line for update page
int$entityEntity targeted for multicompany module
int$usesavepoint1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
string$handlerHandler targeted for menu (replace HANDLER with this value between quotes)
string$okerrorFamily of errors we accept ('default', 'none')
int$linelengthlimitLimit for length of each line (Use 0 if unknown, may be faster if defined)
int$nocommentremovalDo no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0)
int$offsetforchartofaccountOffset to use to load chart of account table to update sql on the fly to add offset to rowid and account_parent value
int$colspan2=Add a colspan=2 on td
int$onlysqltoimportwebsiteOnly sql requests used to import a website template are allowed
string$databaseDatabase (replace DATABASE with this value)
Returns
int Return integer <=0 if KO, >0 if OK

Definition at line 170 of file admin.lib.php.

References checkPHPCode(), dol_htmlentities(), dol_syslog(), dolKeepOnlyPhpCode(), and versioncompare().

Referenced by DolibarrModules\_load_tables(), and migrate_reload_menu().

◆ security_prepare_head()

security_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

Definition at line 818 of file admin.lib.php.

References dol_print_error(), and getDolGlobalString().

◆ showModulesExludedForExternal()

showModulesExludedForExternal ( $modules)

Show array with constants to edit.

Parameters
DolibarrModules[]$modulesArray of all modules
Returns
string HTML string with warning

Definition at line 1890 of file admin.lib.php.

References dol_sort_array(), and getDolGlobalString().

◆ translation_prepare_head()

translation_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

Definition at line 934 of file admin.lib.php.

References complete_head_from_modules().

◆ unActivateModule()

unActivateModule ( $value,
$requiredby = 1 )

Disable a module.

Parameters
string$valueNom du module a desactiver
int$requiredby1=Desactive aussi modules dependants
Returns
string Error message or '';

Definition at line 1268 of file admin.lib.php.

References dol_syslog(), dolGetModulesDirs(), and unActivateModule().

Referenced by activateModule(), and unActivateModule().

◆ versioncompare()

versioncompare ( $versionarray1,
$versionarray2 )

Compare 2 versions (stored into 2 arrays).

To check if Dolibarr version is lower than (x,y,z), do "if versioncompare(versiondolibarrarray(), array(x.y.z)) <= 0" For example: if (versioncompare(versiondolibarrarray(),array(4,0,-5)) >= 0) is true if version is 4.0 alpha or higher. For example: if (versioncompare(versiondolibarrarray(),array(4,0,0)) >= 0) is true if version is 4.0 final or higher. For example: if (versioncompare(versiondolibarrarray(),array(4,0,1)) >= 0) is true if version is 4.0.1 or higher. Alternative way to compare: if ((float) DOL_VERSION >= 4.0) is true if version is 4.0 alpha or higher (works only to compare first and second level)

Parameters
array$versionarray1Array of version (vermajor,verminor,patch)
array$versionarray2Array of version (vermajor,verminor,patch)
Returns
int -4,-3,-2,-1 if versionarray1<versionarray2 (value depends on level of difference) 0 if same 1,2,3,4 if versionarray1>versionarray2 (value depends on level of difference)
See also
versiontostring()

Definition at line 68 of file admin.lib.php.

Referenced by ImportCsv\__construct(), ImportXlsx\__construct(), activateModule(), migrate_restore_missing_links(), and run_sql().

◆ versiondolibarrarray()

versiondolibarrarray ( )

Return version Dolibarr.

Returns
array Tableau de version (vermajeur,vermineur,autre)
See also
versioncompare()

Definition at line 141 of file admin.lib.php.

Referenced by activateModule().

◆ versionphparray()

versionphparray ( )

Return version PHP.

Returns
array Tableau de version (vermajeur,vermineur,autre)
See also
versioncompare()

Definition at line 130 of file admin.lib.php.

Referenced by ImportCsv\__construct(), ImportXlsx\__construct(), and activateModule().

◆ versiontostring()

versiontostring ( $versionarray)

Renvoi une version en chaine depuis une version en tableau.

Parameters
array$versionarrayTableau de version (vermajeur,vermineur,autre)
Returns
string Chaine version
See also
versioncompare()

Definition at line 38 of file admin.lib.php.

Referenced by activateModule().