class Context (View source)

Class Context

Properties

DoliDB $db
string $title
string $desc
string $meta_title
string $meta_desc
string $appliName

The application name

string $controller
bool $controller_found
Controller $controllerInstance
string $error

for internal error msg

string[] $errors
string $action
string $tplDir
string $tplPath
stdClass $topMenu
string $rootUrl
string $cdnUrl
string[] $menu_active
array{mesgs: string[], warnings: string[], errors: string[]}|array{} $eventMessages
string $tokenKey
object $object

Current object of page

User $logged_user
Societe $logged_thirdparty
WebPortalMember $logged_member
WebPortalPartnership $logged_partnership
WebPortalTheme $theme

Methods

static Context
getInstance()

Singleton method to create one instance of this object

void
initController(bool $init_theme = true)

Init controller

bool
addControllerDefinition(string $controller, string $path, string $className)

Add controller definition

void
setControllerFound()

Set controller found

static string
getRootConfigUrl()

Get WebPortal root url

string
getRootUrl(string $controller = '', string|array<string, mixed> $moreParams = '', bool $addToken = true) deprecated

Get root url

string
getControllerUrl(string $controller = '', string|array<string, mixed> $moreParams = '', bool $addToken = true)

Get controller url according to context

static string
getPublicControllerUrl(string $controller = '', string|array<string, mixed> $moreParams = '', array<string, mixed> $Tparams = array())

Generate public controller URL Used for external link (like email or web page) so remove token and contextual behavior associate with current user

static string
urlOrigin(bool $withRequestUri = true, bool $use_forwarded_host = false)

Url origin

bool
userIsLog()

Check if user is logged

bool
menuIsActive(string $menuName)

Is menu enabled ?

void
setError(string|string[] $errors)

Set errors

int
getErrors()

Get errors

void
clearErrors()

Clear errors

void
setEventMessage(string|string[] $mesgs, string $style = 'mesgs')

Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events.

void
setEventMessages(string $mesg, string[]|null $mesgs, string $style = 'mesgs')

Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events.

int
loadEventMessages()

Load event messages

void
clearEventMessages()

Clear event messages

string
newToken()

Return the value of token currently saved into session with name 'newToken'.

string
generateNewToken() deprecated

Generate new token.

string|null
getUrlToken()

Get token url

string|null
getFormToken()

Get token input for form

int
getThirdPartyAccountFromLogin(string $login, string $pass)

Try to find the third-party account id from

int
getMemberAccountFromLogin(string $login, string $pass)

Try to find the member account id from

Details

static Context getInstance()

Singleton method to create one instance of this object

Return Value

Context Instance

void initController(bool $init_theme = true)

Init controller

Parameters

bool $init_theme

Init theme properties

Return Value

void

bool addControllerDefinition(string $controller, string $path, string $className)

Add controller definition

Parameters

string $controller Name
string $path Path
string $className

Class name

Return Value

bool

void setControllerFound()

Set controller found

Return Value

void

static string getRootConfigUrl()

Get WebPortal root url

Return Value

string

Web Portal root url

string getRootUrl(string $controller = '', string|array<string, mixed> $moreParams = '', bool $addToken = true) deprecated

deprecated see getControllerUrl()

Get root url

Parameters

string $controller

Controller name

string|array<string, mixed> $moreParams

More parameters

bool $addToken

Add token hash only if $controller is set

Return Value

string

string getControllerUrl(string $controller = '', string|array<string, mixed> $moreParams = '', bool $addToken = true)

Get controller url according to context

Parameters

string $controller

Controller name

string|array<string, mixed> $moreParams

More parameters

bool $addToken

Add token hash only if controller is set

Return Value

string

static string getPublicControllerUrl(string $controller = '', string|array<string, mixed> $moreParams = '', array<string, mixed> $Tparams = array())

Generate public controller URL Used for external link (like email or web page) so remove token and contextual behavior associate with current user

Parameters

string $controller Controller
string|array<string, mixed> $moreParams

More parameters

array<string, mixed> $Tparams Parameters

Return Value

string

static string urlOrigin(bool $withRequestUri = true, bool $use_forwarded_host = false)

Url origin

Parameters

bool $withRequestUri

With request URI

bool $use_forwarded_host

Use formatted host

Return Value

string

bool userIsLog()

Check if user is logged

Return Value

bool

bool menuIsActive(string $menuName)

Is menu enabled ?

Parameters

string $menuName

Menu name

Return Value

bool

void setError(string|string[] $errors)

Set errors

Parameters

string|string[] $errors Errors

Return Value

void

int getErrors()

Get errors

Return Value

int

void clearErrors()

Clear errors

Return Value

void

void setEventMessage(string|string[] $mesgs, string $style = 'mesgs')

Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events.

Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function.

Parameters

string|string[] $mesgs

Message string or array

string $style

Which style to use ('mesgs' by default, 'warnings', 'errors')

Return Value

void

void setEventMessages(string $mesg, string[]|null $mesgs, string $style = 'mesgs')

Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events.

Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function.

Parameters

string $mesg

Message string

string[]|null $mesgs

Message array

string $style

Which style to use ('mesgs' by default, 'warnings', 'errors')

Return Value

void

int loadEventMessages()

Load event messages

Return Value

int

void clearEventMessages()

Clear event messages

Return Value

void

string newToken()

Return the value of token currently saved into session with name 'newToken'.

This token must be sent by any POST as it will be used by next page for comparison with value in session. This token depends on controller

Return Value

string

protected string generateNewToken() deprecated

deprecated see main

Generate new token.

Return Value

string

string|null getUrlToken()

Get token url

Return Value

string|null

string|null getFormToken()

Get token input for form

Return Value

string|null

int getThirdPartyAccountFromLogin(string $login, string $pass)

Try to find the third-party account id from

Parameters

string $login Login
string $pass Password

Return Value

int

Third-party account id || <0 if error

int getMemberAccountFromLogin(string $login, string $pass)

Try to find the member account id from

Parameters

string $login Login
string $pass Password

Return Value

int

Member account id || <0 if error