PHP 클래스 Gdn_Session, vanilla

파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$User A User object containing properties relevant to session
$UserID Unique user identifier.

보호된 프로퍼티들

프로퍼티 타입 설명
$_Attributes Attributes of the current user.
$_Preferences Preferences of the current user.
$_TransientKey The current user's transient key.

공개 메소드들

메소드 설명
__construct ( ) Private constructor prevents direct instantiation of object
addPermissions ( array $perms ) Add the permissions from a permissions array to this session's permissions.
checkPermission ( string | array $permission, boolean $fullMatch = true, string $junctionTable = '', integer | string $junctionID = '' ) : boolean Checks the currently authenticated user's permissions for the specified permission.
checkRankedPermission ( boolean | string $permission ) : boolean Check the given permission, but also return true if the user has a higher permission.
end ( Gdn_Authenticator $Authenticator = null ) End a session
ensureTransientKey ( ) : boolean | object | string
getAttribute ( unknown_type $AttributeName, string $DefaultValue = false ) : mixed Gets the currently authenticated user's attribute for the specified $AttributeName.
getAttributes ( ) : array
getCookie ( $Suffix, null $Default = null ) : mixed
getInstance ( ) : Session This is the singleton method that return the static Configuration::Instance.
getPermissions ( ) : array Returns all "allowed" permissions for the authenticated user in a one-dimensional array of permission names.
getPermissionsArray ( ) : array Returns all "allowed" permissions for the authenticated user in a one-dimensional array of permission names.
getPreference ( string $PreferenceName, mixed $DefaultValue = false ) : mixed Gets the currently authenticated user's preference for the specified $PreferenceName.
getPublicStash ( string $name, boolean $unset = false ) : mixed Get a public stash value.
getTimeZone ( ) : DateTimeZone Return the time zone for the current user.
hourOffset ( ) : integer Return the timezone hour difference between the user and utc.
isValid ( ) : boolean Ensure that there is an active session.
newVisit ( ) : boolean
setAttribute ( string | array $Name, mixed $Value = '' ) Sets a value in the $this->_Attributes array. This setting will persist only to the end of the page load. It is not intended for making permanent changes to user attributes.
setCookie ( $Suffix, $Value, $Expires )
setPermission ( string | array $PermissionName, null | boolean $Value = null ) : null Set a permission for the current runtime.
setPreference ( string | array $Name, mixed $Value = '', $SaveToDatabase = true ) Sets a value in the $this->_Preferences array. This setting will persist changes to user prefs.
setPublicStash ( string $name, mixed $value ) : Gdn_Session Sets a public stash value.
start ( integer $UserID = false, boolean $SetIdentity = true, boolean $Persist = false ) Authenticates the user with the provided Authenticator class.
stash ( string $name = '', mixed $value = '', boolean $unsetOnRetrieve = true ) : mixed Place a name/value pair into the user's session stash.
transientKey ( $NewKey = null ) : string Returns the transient key for the authenticated user.
validateTransientKey ( string $ForeignKey, $ValidateUser = true ) : boolean Validates that $ForeignKey was generated by the current user.

비공개 메소드들

메소드 설명
getStashSession ( Gdn_SQLDriver $sql, string $valueToStash ) : boolean | Gdn_DataSet Used by $this->stash() to create & manage sessions for users & guests.

메소드 상세

__construct() 공개 메소드

Private constructor prevents direct instantiation of object
public __construct ( )

addPermissions() 공개 메소드

Add the permissions from a permissions array to this session's permissions.
public addPermissions ( array $perms )
$perms array The permissions to add.

checkPermission() 공개 메소드

Returns a boolean value indicating if the action is permitted.
public checkPermission ( string | array $permission, boolean $fullMatch = true, string $junctionTable = '', integer | string $junctionID = '' ) : boolean
$permission string | array The permission (or array of permissions) to check.
$fullMatch boolean If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions.
$junctionTable string The name of the junction table for a junction permission.
$junctionID integer | string The JunctionID associated with $Permission (ie. A discussion category identifier).
리턴 boolean Returns **true** if the user has permission or **false** otherwise.

checkRankedPermission() 공개 메소드

Check the given permission, but also return true if the user has a higher permission.
public checkRankedPermission ( boolean | string $permission ) : boolean
$permission boolean | string The permission to check. Bool to force true/false.
리턴 boolean True on valid authorization, false on failure to authorize

end() 공개 메소드

End a session
public end ( Gdn_Authenticator $Authenticator = null )
$Authenticator Gdn_Authenticator

ensureTransientKey() 공개 메소드

getAttribute() 공개 메소드

Gets the currently authenticated user's attribute for the specified $AttributeName.
public getAttribute ( unknown_type $AttributeName, string $DefaultValue = false ) : mixed
$AttributeName unknown_type The name of the attribute to get.
$DefaultValue string The default value to return if the attribute does not exist.
리턴 mixed

getAttributes() 공개 메소드

public getAttributes ( ) : array
리턴 array

getCookie() 공개 메소드

public getCookie ( $Suffix, null $Default = null ) : mixed
$Suffix
$Default null
리턴 mixed

getInstance() 공개 정적인 메소드

This is the singleton method that return the static Configuration::Instance.
public static getInstance ( ) : Session
리턴 Session

getPermissions() 공개 메소드

Returns all "allowed" permissions for the authenticated user in a one-dimensional array of permission names.
사용 중단: We want to make this an accessor for the permissions property.
public getPermissions ( ) : array
리턴 array

getPermissionsArray() 공개 메소드

Returns all "allowed" permissions for the authenticated user in a one-dimensional array of permission names.
public getPermissionsArray ( ) : array
리턴 array

getPreference() 공개 메소드

Gets the currently authenticated user's preference for the specified $PreferenceName.
public getPreference ( string $PreferenceName, mixed $DefaultValue = false ) : mixed
$PreferenceName string The name of the preference to get.
$DefaultValue mixed The default value to return if the preference does not exist.
리턴 mixed

getPublicStash() 공개 메소드

Get a public stash value.
public getPublicStash ( string $name, boolean $unset = false ) : mixed
$name string The key of the stash.
$unset boolean Whether or not to unset the stash.
리턴 mixed Returns the value of the stash.

getTimeZone() 공개 메소드

Return the time zone for the current user.
public getTimeZone ( ) : DateTimeZone
리턴 DateTimeZone Returns the current timezone.

hourOffset() 공개 메소드

Return the timezone hour difference between the user and utc.
public hourOffset ( ) : integer
리턴 integer The hour offset.

isValid() 공개 메소드

If there isn't an active session, send the user to the SignIn Url
public isValid ( ) : boolean
리턴 boolean

newVisit() 공개 메소드

public newVisit ( ) : boolean
리턴 boolean

setAttribute() 공개 메소드

Sets a value in the $this->_Attributes array. This setting will persist only to the end of the page load. It is not intended for making permanent changes to user attributes.
public setAttribute ( string | array $Name, mixed $Value = '' )
$Name string | array
$Value mixed

setCookie() 공개 메소드

public setCookie ( $Suffix, $Value, $Expires )
$Suffix
$Value
$Expires

setPermission() 공개 메소드

Set a permission for the current runtime.
public setPermission ( string | array $PermissionName, null | boolean $Value = null ) : null
$PermissionName string | array
$Value null | boolean
리턴 null

setPreference() 공개 메소드

Sets a value in the $this->_Preferences array. This setting will persist changes to user prefs.
public setPreference ( string | array $Name, mixed $Value = '', $SaveToDatabase = true )
$Name string | array
$Value mixed

setPublicStash() 공개 메소드

Sets a public stash value.
public setPublicStash ( string $name, mixed $value ) : Gdn_Session
$name string The key of the stash value.
$value mixed The value of the stash to set. Pass null to clear the key.
리턴 Gdn_Session $this Returns $this for chaining.

start() 공개 메소드

Authenticates the user with the provided Authenticator class.
public start ( integer $UserID = false, boolean $SetIdentity = true, boolean $Persist = false )
$UserID integer The UserID to start the session with.
$SetIdentity boolean Whether or not to set the identity (cookie) or make this a one request session.
$Persist boolean If setting an identity, should we persist it beyond browser restart?

stash() 공개 메소드

Place a name/value pair into the user's session stash.
public stash ( string $name = '', mixed $value = '', boolean $unsetOnRetrieve = true ) : mixed
$name string The key of the stash value.
$value mixed The value of the stash to set. Pass null to retrieve the key.
$unsetOnRetrieve boolean Whether or not to unset the key from stash.
리턴 mixed Returns the value of the stash or null on failure.

transientKey() 공개 메소드

Returns the transient key for the authenticated user.
public transientKey ( $NewKey = null ) : string
리턴 string

validateTransientKey() 공개 메소드

Validates that $ForeignKey was generated by the current user.
public validateTransientKey ( string $ForeignKey, $ValidateUser = true ) : boolean
$ForeignKey string The key to validate.
리턴 boolean

프로퍼티 상세

$User 공개적으로 프로퍼티

A User object containing properties relevant to session
public $User

$UserID 공개적으로 프로퍼티

Unique user identifier.
public $UserID

$_Attributes 보호되어 있는 프로퍼티

Attributes of the current user.
protected $_Attributes

$_Preferences 보호되어 있는 프로퍼티

Preferences of the current user.
protected $_Preferences

$_TransientKey 보호되어 있는 프로퍼티

The current user's transient key.
protected $_TransientKey