dolibarr 20.0.0
Menubase Class Reference

Class to manage menu entries. More...

Public Member Functions

 __construct ($db, $menu_handler='')
 Constructor.
 
 create ($user=null)
 Create menu entry into database.
 
 update ($user=null, $notrigger=0)
 Update menu entry into database.
 
 fetch ($id, $user=null)
 Load object in memory from database.
 
 delete ($user)
 Delete object in database.
 
 initAsSpecimen ()
 Initialise an instance with random values.
 
 menuTopCharger ($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
 Load tabMenu array with top menu entries found into database.
 
 menuLeftCharger ($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
 Load entries found from database (and stored into $tabMenu) in $this->newmenu array.
 
 menuLoad ($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
 Load entries found in database into variable $tabMenu.
 

Private Member Functions

 recur ($tab, $pere, $level)
 Complete this->newmenu with menu entry found in $tab.
 

Detailed Description

Class to manage menu entries.

Definition at line 31 of file menubase.class.php.

Constructor & Destructor Documentation

◆ __construct()

Menubase::__construct ( $db,
$menu_handler = '' )

Constructor.

Parameters
DoliDB$dbDatabase handler
string$menu_handlerMenu handler

Definition at line 166 of file menubase.class.php.

Member Function Documentation

◆ create()

Menubase::create ( $user = null)

Create menu entry into database.

Parameters
User$userUser that create
Returns
int Return integer <0 if KO, Id of record if OK

Definition at line 179 of file menubase.class.php.

References dol_print_error(), dol_syslog(), position, type, and user.

◆ delete()

Menubase::delete ( $user)

Delete object in database.

Parameters
User$userUser that delete
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 459 of file menubase.class.php.

References dol_syslog().

◆ fetch()

Menubase::fetch ( $id,
$user = null )

Load object in memory from database.

Parameters
int$idId object
User$userUser that load
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 387 of file menubase.class.php.

References dol_syslog(), position, type, and user.

◆ initAsSpecimen()

Menubase::initAsSpecimen ( )

Initialise an instance with random values.

Used to build previews or test instances. id must be 0 if object instance is a specimen.

Returns
int

Definition at line 484 of file menubase.class.php.

References dol_now(), position, type, and user.

◆ menuLeftCharger()

Menubase::menuLeftCharger ( $newmenu,
$mymainmenu,
$myleftmenu,
$type_user,
$menu_handler,
& $tabMenu )

Load entries found from database (and stored into $tabMenu) in $this->newmenu array.

Warning: Entries in $tabMenu must have child after parent

Parameters
Menu$newmenuMenu array to complete (in most cases, it's empty, may be already initialized with some menu manager like eldy)
string$mymainmenuValue for mainmenu to filter menu to load (often $_SESSION["mainmenu"])
string$myleftmenuValue for leftmenu to filter menu to load (always '')
int$type_user0=Menu for backoffice, 1=Menu for front office
string$menu_handlerFilter on name of menu_handler used (auguria, eldy...)
array<array{rowid:string,fk_menu:string,module:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}>$tabMenu Array with menu entries already loaded
Returns
Menu Menu array for particular mainmenu value or full tabArray

Definition at line 548 of file menubase.class.php.

References dol_syslog(), and recur().

◆ menuLoad()

Menubase::menuLoad ( $mymainmenu,
$myleftmenu,
$type_user,
$menu_handler,
& $tabMenu )

Load entries found in database into variable $tabMenu.

Note that only "database menu entries" are loaded here, hardcoded will not be present into output.

Parameters
string$mymainmenuValue for mainmenu that defined mainmenu
string$myleftmenuValue for left that defined leftmenu
int$type_userLooks for menu entry for 0=Internal users, 1=External users
string$menu_handlerName of menu_handler used ('auguria', 'eldy'...)
array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}>$tabMenu Array to store new entries found (in most cases, it's empty, but may be already filled)
Returns
int >0 if OK, <0 if KO

Definition at line 630 of file menubase.class.php.

References dol_print_error(), make_substitutions(), and verifCond().

◆ menuTopCharger()

Menubase::menuTopCharger ( $mymainmenu,
$myleftmenu,
$type_user,
$menu_handler,
& $tabMenu )

Load tabMenu array with top menu entries found into database.

Parameters
string$mymainmenuValue for mainmenu to filter menu to load (always '')
string$myleftmenuValue for leftmenu to filter menu to load (always '')
int$type_user0=Menu for backoffice, 1=Menu for front office
string$menu_handlerFilter on name of menu_handler used (auguria, eldy...)
array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}>$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
Returns
array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}> Return array with menu entries for top menu

Definition at line 518 of file menubase.class.php.

◆ recur()

Menubase::recur ( $tab,
$pere,
$level )
private

Complete this->newmenu with menu entry found in $tab.

Parameters
array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}>$tab Tab array with all menu entries
int$pereId of parent
int$levelLevel
Returns
void

Definition at line 763 of file menubase.class.php.

References recur().

Referenced by menuLeftCharger(), and recur().

◆ update()

Menubase::update ( $user = null,
$notrigger = 0 )

Update menu entry into database.

Parameters
User$userUser that modify
int$notrigger0=no, 1=yes (no update trigger)
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 322 of file menubase.class.php.

References dol_syslog(), position, type, and user.


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