dolibarr 23.0.3
Context Class Reference

Class Context. More...

Collaboration diagram for Context:

Public Member Functions

 initController ($init_theme=true)
 Init controller.
 
 addControllerDefinition ($controller, $path, $className)
 Add controller definition.
 
 setControllerFound ()
 Set controller found.
 
 getRootUrl ($controller='', $moreParams='', $addToken=true)
 Get root url.
 
 getControllerUrl ($controller='', $moreParams='', $addToken=true)
 Get controller url according to context.
 
 userIsLog ()
 Check if user is logged.
 
 menuIsActive ($menuName)
 Is menu enabled ?
 
 setError ($errors)
 Set errors.
 
 getErrors ()
 Get errors.
 
 clearErrors ()
 Clear errors.
 
 setEventMessage ($mesgs, $style='mesgs')
 Set event messages in dol_events session object.
 
 setEventMessages ($mesg, $mesgs, $style='mesgs')
 Set event messages in dol_events session object.
 
 loadEventMessages ()
 Load event messages.
 
 clearEventMessages ()
 Clear event messages.
 
 newToken ()
 Return the value of token currently saved into session with name 'newToken'.
 
 getUrlToken ()
 Get token url.
 
 getFormToken ()
 Get token input for form.
 
 getThirdPartyAccountFromLogin ($login, $pass)
 Try to find the third-party account id from.
 
 getMemberAccountFromLogin ($login, $pass)
 Try to find the member account id from.
 

Static Public Member Functions

static getInstance ()
 Singleton method to create one instance of this object.
 
static getRootConfigUrl ()
 Get WebPortal root url.
 
static getPublicControllerUrl ($controller='', $moreParams='', $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 urlOrigin ($withRequestUri=true, $use_forwarded_host=false)
 Url origin.
 

Public Attributes

 $appliName
 The application name.
 
 $object
 Current object of page.
 

Protected Member Functions

 generateNewToken ()
 Generate new token.
 

Private Member Functions

 __construct ()
 Constructor.
 

Detailed Description

Class Context.

Definition at line 32 of file context.class.php.

Constructor & Destructor Documentation

◆ __construct()

Context::__construct ( )
private

Constructor.

Returns
void

Definition at line 185 of file context.class.php.

References dol_buildpath(), getControllerUrl(), getDolGlobalString(), GETPOST(), getRootConfigUrl(), and initController().

Member Function Documentation

◆ addControllerDefinition()

Context::addControllerDefinition ( $controller,
$path,
$className )

Add controller definition.

Parameters
string$controllerName
string$pathPath
string$classNameClass name
Returns
bool

Definition at line 293 of file context.class.php.

References setError().

Referenced by initController().

◆ clearErrors()

Context::clearErrors ( )

Clear errors.

Returns
void

Definition at line 547 of file context.class.php.

◆ clearEventMessages()

Context::clearEventMessages ( )

Clear event messages.

Returns
void

Definition at line 633 of file context.class.php.

◆ generateNewToken()

Context::generateNewToken ( )
protected

Generate new token.

Deprecated
see main
Returns
string

Definition at line 656 of file context.class.php.

References dol_hash(), and newToken().

◆ getControllerUrl()

Context::getControllerUrl ( $controller = '',
$moreParams = '',
$addToken = true )

Get controller url according to context.

Parameters
string$controllerController name
string|array<string,mixed>$moreParams More parameters
bool$addTokenAdd token hash only if controller is set
Returns
string

Definition at line 363 of file context.class.php.

References getPublicControllerUrl(), and newToken().

Referenced by __construct(), and getRootUrl().

◆ getErrors()

Context::getErrors ( )

Get errors.

Returns
int

Definition at line 532 of file context.class.php.

◆ getFormToken()

Context::getFormToken ( )

Get token input for form.

Returns
string|null

Definition at line 696 of file context.class.php.

References newToken().

◆ getInstance()

◆ getMemberAccountFromLogin()

Context::getMemberAccountFromLogin ( $login,
$pass )

Try to find the member account id from.

Parameters
string$loginLogin
string$passPassword
Returns
int Member account id || <0 if error

Definition at line 767 of file context.class.php.

References $id, dol_syslog(), dol_verifyHash(), and getEntity().

◆ getPublicControllerUrl()

static Context::getPublicControllerUrl ( $controller = '',
$moreParams = '',
$Tparams = array() )
static

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$controllerController
string|array<string,mixed>$moreParams More parameters
array<string,mixed>$Tparams Parameters
Returns
string

Definition at line 394 of file context.class.php.

References getRootConfigUrl().

Referenced by getControllerUrl().

◆ getRootConfigUrl()

static Context::getRootConfigUrl ( )
static

Get WebPortal root url.

Returns
string Web Portal root url

Definition at line 326 of file context.class.php.

References dol_buildpath(), and getDolGlobalString().

Referenced by __construct(), WebPortalFieldsManager\__construct(), getPublicControllerUrl(), and WebPortalTheme\init().

◆ getRootUrl()

Context::getRootUrl ( $controller = '',
$moreParams = '',
$addToken = true )

Get root url.

Parameters
string$controllerController name
string|array<string,mixed>$moreParams More parameters
bool$addTokenAdd token hash only if $controller is set
Returns
string
Deprecated
see getControllerUrl()

Definition at line 350 of file context.class.php.

References getControllerUrl().

◆ getThirdPartyAccountFromLogin()

Context::getThirdPartyAccountFromLogin ( $login,
$pass )

Try to find the third-party account id from.

Parameters
string$loginLogin
string$passPassword
Returns
int Third-party account id || <0 if error

Definition at line 713 of file context.class.php.

References $id, dol_syslog(), dol_verifyHash(), and getEntity().

◆ getUrlToken()

Context::getUrlToken ( )

Get token url.

Returns
string|null

Definition at line 681 of file context.class.php.

References newToken().

◆ initController()

Context::initController ( $init_theme = true)

Init controller.

Parameters
bool$init_themeInit theme properties
Returns
void

Definition at line 243 of file context.class.php.

References addControllerDefinition(), and setControllerFound().

Referenced by __construct().

◆ loadEventMessages()

Context::loadEventMessages ( )

Load event messages.

Returns
int

Definition at line 618 of file context.class.php.

◆ menuIsActive()

Context::menuIsActive ( $menuName)

Is menu enabled ?

Parameters
string$menuNameMenu name
Returns
bool

Definition at line 501 of file context.class.php.

◆ newToken()

Context::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

Returns
string

Definition at line 646 of file context.class.php.

References newToken().

Referenced by generateNewToken(), getControllerUrl(), getFormToken(), getUrlToken(), and newToken().

◆ setControllerFound()

Context::setControllerFound ( )

Set controller found.

Returns
void

Definition at line 316 of file context.class.php.

Referenced by initController().

◆ setError()

Context::setError ( $errors)

Set errors.

Parameters
string | string[]$errorsErrors
Returns
void

Definition at line 512 of file context.class.php.

Referenced by addControllerDefinition().

◆ setEventMessage()

Context::setEventMessage ( $mesgs,
$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[]$mesgsMessage string or array
string$styleWhich style to use ('mesgs' by default, 'warnings', 'errors')
Returns
void

Definition at line 561 of file context.class.php.

Referenced by setEventMessages().

◆ setEventMessages()

Context::setEventMessages ( $mesg,
$mesgs,
$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$mesgMessage string
string[] | null$mesgsMessage array
string$styleWhich style to use ('mesgs' by default, 'warnings', 'errors')
Returns
void

Definition at line 594 of file context.class.php.

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

◆ urlOrigin()

static Context::urlOrigin ( $withRequestUri = true,
$use_forwarded_host = false )
static

Url origin.

Parameters
bool$withRequestUriWith request URI
bool$use_forwarded_hostUse formatted host
Returns
string

Definition at line 448 of file context.class.php.

◆ userIsLog()

Context::userIsLog ( )

Check if user is logged.

Returns
bool

Definition at line 474 of file context.class.php.


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