dolibarr  7.0.0-beta
Functions
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. More...
 
 versioncompare ($versionarray1, $versionarray2)
 Compare 2 versions (stored into 2 arrays). More...
 
 versionphparray ()
 Return version PHP. More...
 
 versiondolibarrarray ()
 Return version Dolibarr. More...
 
 run_sql ($sqlfile, $silent=1, $entity='', $usesavepoint=1, $handler='', $okerror='default')
 Launch a sql file. More...
 
 dolibarr_del_const ($db, $name, $entity=1)
 Effacement d'une constante dans la base de donnees. More...
 
 dolibarr_get_const ($db, $name, $entity=1)
 Recupere une constante depuis la base de donnees. More...
 
 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). More...
 
 modules_prepare_head ()
 Prepare array with list of tabs. More...
 
 security_prepare_head ()
 Prepare array with list of tabs. More...
 
 translation_prepare_head ()
 Prepare array with list of tabs. More...
 
 defaultvalues_prepare_head ()
 Prepare array with list of tabs. More...
 
 listOfSessions ()
 Return list of session. More...
 
 purgeSessions ($mysessionid)
 Purge existing sessions. More...
 
 activateModule ($value, $withdeps=1)
 Enable a module. More...
 
 unActivateModule ($value, $requiredby=1)
 Disable a module. More...
 
 complete_dictionary_with_modules (&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabfieldcheck)
 Add external modules to list of dictionaries. More...
 
 activateModulesRequiredByCountry ($country_code)
 Activate external modules mandatroy when country is country_code. More...
 
 complete_elementList_with_modules (&$elementList)
 Add external modules to list of contact element. More...
 
 form_constantes ($tableau, $strictw3c=0, $helptext='')
 Show array with constants to edit. More...
 
 showModulesExludedForExternal ($modules)
 Show array with constants to edit. More...
 
 addDocumentModel ($name, $type, $label='', $description='')
 Add document model used by doc generator. More...
 
 delDocumentModel ($name, $type)
 Delete document model used by doc generator. More...
 
 phpinfo_array ()
 Return the php_info into an array. More...
 
 email_admin_prepare_head ()
 Return array head with list of tabs to view object informations. More...
 

Detailed Description

Library of admin functions.

Definition in file admin.lib.php.

Function Documentation

activateModule (   $value,
  $withdeps = 1 
)

Enable a module.

Parameters
string$valueName of module to activate
int$withdepsActivate/Disable also all dependencies
Returns
array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added);

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

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

Referenced by activateModulesRequiredByCountry().

activateModulesRequiredByCountry (   $country_code)

Activate external modules mandatroy when country is country_code.

Parameters
string$country_codeCountryCode
Returns
int 1

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

References activateModule(), dol_osencode(), dol_strlen(), dol_syslog(), dolGetModulesDirs(), and setEventMessage().

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 <0 if KO, >0 if OK

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

References $resql, dol_print_error(), and dol_syslog().

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

Add external modules to list of dictionaries.

Parameters
array$taborderTaborder
array$tabnameTabname
array$tablibTablib
array$tabsqlTabsql
array$tabsqlsortTabsqlsort
array$tabfieldTabfield
array$tabfieldvalueTabfieldvalue
array$tabfieldinsertTabfieldinsert
array$tabrowidTabrowid
array$tabcondTabcond
array$tabhelpTabhelp
array$tabfieldcheckTabfieldcheck
Returns
int 1

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

References dol_osencode(), dol_strlen(), dol_syslog(), dolGetModulesDirs(), and print.

complete_elementList_with_modules ( $elementList)

Add external modules to list of contact element.

Parameters
array$elementListelementList
Returns
int 1

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

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

defaultvalues_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

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

References complete_head_from_modules().

delDocumentModel (   $name,
  $type 
)

Delete document model used by doc generator.

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

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

References $resql, dol_print_error(), and dol_syslog().

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

Effacement d'une constante dans la base de donnees.

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

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

References $resql, dol_print_error(), and dol_syslog().

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

Recupere une constante depuis la base de donnees.

Parameters
DoliDB$dbDatabase handler
string$nameNom de la constante
int$entityMulti company id
Returns
string Valeur de la constante
See also
dolibarr_del_const, dolibarr_set_const, dol_set_user_param

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

References $resql, and dol_syslog().

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 constante (chaine par defaut)
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 485 of file admin.lib.php.

References $resql, dol_print_error(), and dol_syslog().

Referenced by modGeneratePassPerso\__construct(), BlockedLog\getSignature(), and modProductBatch\init().

email_admin_prepare_head ( )

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

Returns
array head array with tabs

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

References complete_head_from_modules().

form_constantes (   $tableau,
  $strictw3c = 0,
  $helptext = '' 
)

Show array with constants to edit.

Parameters
array$tableauArray of constants
int$strictw3c0=Include form into table (deprecated), 1=Form is outside table to respect W3C (no form into table), 2=No form nor button at all
string$helptextHelp
Returns
void

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

References $form, dol_escape_htmltag(), dol_syslog(), img_down(), and print.

listOfSessions ( )

Return list of session.

Returns
array Array list of sessions

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

References dol_osencode(), and dol_syslog().

modules_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

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

phpinfo_array ( )

Return the php_info into an array.

Returns
array Array with PHP infos

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

References $title.

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 764 of file admin.lib.php.

References dol_osencode(), and dol_syslog().

run_sql (   $sqlfile,
  $silent = 1,
  $entity = '',
  $usesavepoint = 1,
  $handler = '',
  $okerror = 'default' 
)

Launch a sql file.

Function used by:

  • Migrate process (dolibarr-xyz-abc.sql)
  • Loading sql menus (auguria)
  • Running specific Sql by a module init Install process however does not use it. Note that Sql files must have all comments at start of line.
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
string$okerrorFamily of errors we accept ('default', 'none')
Returns
int <=0 if KO, >0 if OK

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

References $resql, dol_htmlentities(), dol_syslog(), print, and versioncompare().

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

security_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

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

showModulesExludedForExternal (   $modules)

Show array with constants to edit.

Parameters
array$modulesArray of all modules
Returns
string HTML string with warning

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

translation_prepare_head ( )

Prepare array with list of tabs.

Returns
array Array of tabs to show

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

References complete_head_from_modules().

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 956 of file admin.lib.php.

References dol_syslog(), and dolGetModulesDirs().

Referenced by activateModule().

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,-4)) >= 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)

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

Referenced by activateModule(), migrate_restore_missing_links(), and run_sql().

versiondolibarrarray ( )

Return version Dolibarr.

Returns
array Tableau de version (vermajeur,vermineur,autre)

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

Referenced by activateModule().

versionphparray ( )

Return version PHP.

Returns
array Tableau de version (vermajeur,vermineur,autre)

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

Referenced by activateModule().

versiontostring (   $versionarray)

Renvoi une version en chaine depuis une version en tableau.

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

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

Referenced by activateModule().