PHP Class Bolt\Users

.
Mostra file Open project: bolt/bolt Class Usage Examples

Public Properties

Property Type Description
$currentuser
$users

Protected Properties

Property Type Description
$repository Bolt\Storage\Repository\UsersRepository

Public Methods

Method Description
__construct ( Silex\Application $app )
addRole ( string | integer $id, string $role ) : boolean Add a certain role from a specific user.
checkAntiCSRFToken ( $token = '' )
checkAvailability ( string $fieldname, string $value, integer $currentid ) : boolean Check if a certain field with a certain value doesn't exist already.
checkForRoot ( ) : boolean Check for a user with the 'root' role.
checkValidSession ( )
deleteUser ( integer $id ) : integer Remove a user from the database.
filterManipulatableRoles ( string | integer $id, array $newRoles ) : string[] Ensure changes to the user's roles match what the current user has permissions to manipulate.
getActiveSessions ( )
getAntiCSRFToken ( )
getCurrentUser ( ) : array Get the current user as an array.
getCurrentUserProperty ( string $property ) : string Get the current user's property.
getCurrentUsername ( ) : string Get the username of the current user.
getEmptyUser ( ) : array Create a stub for a new/empty user.
getUser ( integer | string $userId ) : array | false Get a user, specified by ID, username or email address.
getUsers ( ) : array[] Get an array with the current users.
hasRole ( string | integer $id, string $role ) : boolean Check if a certain user has a specific role.
hasUsers ( ) : integer Test to see if there are users in the user table.
isAllowed ( string $what, string $contenttype = null, integer $contentid = null ) : boolean Runs a permission check. Permissions are encoded as strings, where the ':' character acts as a separator for dynamic parts and sub-permissions.
isContentStatusTransitionAllowed ( string $fromStatus, string $toStatus, string $contenttype, string $contentid = null ) : boolean Check to see if the current user can change the status on the record.
isEnabled ( integer | boolean $id = false ) : boolean Check a user's enable status.
isValidSession ( )
removeRole ( string | integer $id, string $role ) : boolean Remove a certain role from a specific user.
saveUser ( Bolt\Storage\Entity\Users | array $user ) : integer Save changes to a user to the database. (re)hashing the password, if needed.
setEnabled ( integer | string $id, boolean | integer $enabled = true ) : integer Enable or disable a user, specified by id.
updateUserLogin ( $user )

Private Methods

Method Description
canonicalizeFieldValue ( string $fieldname, string $fieldvalue ) : string Create a correctly canonicalized value for a field, depending on its name.
getRepository ( ) : UsersRepository

Method Details

__construct() public method

public __construct ( Silex\Application $app )
$app Silex\Application

addRole() public method

Add a certain role from a specific user.
public addRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
return boolean

checkAntiCSRFToken() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public checkAntiCSRFToken ( $token = '' )

checkAvailability() public method

Depending on the field type, different pre-massaging of the compared values are applied, because what constitutes 'equal' for the purpose of this filtering depends on the field type.
public checkAvailability ( string $fieldname, string $value, integer $currentid ) : boolean
$fieldname string
$value string
$currentid integer
return boolean

checkForRoot() public method

There should always be at least one If there isn't we promote the current user.
public checkForRoot ( ) : boolean
return boolean

checkValidSession() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public checkValidSession ( )

deleteUser() public method

Remove a user from the database.
public deleteUser ( integer $id ) : integer
$id integer
return integer The number of affected rows.

filterManipulatableRoles() public method

Ensure changes to the user's roles match what the current user has permissions to manipulate.
public filterManipulatableRoles ( string | integer $id, array $newRoles ) : string[]
$id string | integer User ID
$newRoles array Roles from form submission
return string[] The user's roles with the allowed changes

getActiveSessions() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public getActiveSessions ( )

getAntiCSRFToken() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public getAntiCSRFToken ( )

getCurrentUser() public method

Get the current user as an array.
public getCurrentUser ( ) : array
return array

getCurrentUserProperty() public method

Get the current user's property.
public getCurrentUserProperty ( string $property ) : string
$property string
return string

getCurrentUsername() public method

Get the username of the current user.
Deprecation: Deprecated since 3.0, to be removed in 4.0.
public getCurrentUsername ( ) : string
return string

getEmptyUser() public method

Create a stub for a new/empty user.
public getEmptyUser ( ) : array
return array

getUser() public method

Get a user, specified by ID, username or email address.
public getUser ( integer | string $userId ) : array | false
$userId integer | string
return array | false

getUsers() public method

Get an array with the current users.
public getUsers ( ) : array[]
return array[]

hasRole() public method

Check if a certain user has a specific role.
public hasRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
return boolean

hasUsers() public method

Test to see if there are users in the user table.
public hasUsers ( ) : integer
return integer

isAllowed() public method

Apart from the route-based rules defined in permissions.yml, the following special cases are available: "overview:$contenttype" - view the overview for the content type. Alias for "contenttype:$contenttype:view". "contenttype:$contenttype", "contenttype:$contenttype:view", "contenttype:$contenttype:view:$id" - View any item or a particular item of the specified content type. "contenttype:$contenttype:edit", "contenttype:$contenttype:edit:$id" - Edit any item or a particular item of the specified content type. "contenttype:$contenttype:create" - Create a new item of the specified content type. (It doesn't make sense to provide this permission on a per-item basis, for obvious reasons) "contenttype:$contenttype:change-ownership", "contenttype:$contenttype:change-ownership:$id" - Change the ownership of the specified content type or item.
public isAllowed ( string $what, string $contenttype = null, integer $contentid = null ) : boolean
$what string The desired permission, as elaborated upon above.
$contenttype string
$contentid integer
return boolean TRUE if the permission is granted, FALSE if denied.

isContentStatusTransitionAllowed() public method

Check to see if the current user can change the status on the record.
public isContentStatusTransitionAllowed ( string $fromStatus, string $toStatus, string $contenttype, string $contentid = null ) : boolean
$fromStatus string
$toStatus string
$contenttype string
$contentid string
return boolean

isEnabled() public method

Check a user's enable status.
public isEnabled ( integer | boolean $id = false ) : boolean
$id integer | boolean User ID, or false for current user
return boolean

isValidSession() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public isValidSession ( )

removeRole() public method

Remove a certain role from a specific user.
public removeRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
return boolean

saveUser() public method

Save changes to a user to the database. (re)hashing the password, if needed.
public saveUser ( Bolt\Storage\Entity\Users | array $user ) : integer
$user Bolt\Storage\Entity\Users | array
return integer The number of affected rows.

setEnabled() public method

Enable or disable a user, specified by id.
public setEnabled ( integer | string $id, boolean | integer $enabled = true ) : integer
$id integer | string
$enabled boolean | integer
return integer

updateUserLogin() public method

Deprecation: Deprecated since 3.0, to be removed in 4.0.
public updateUserLogin ( $user )

Property Details

$currentuser public_oe property

public $currentuser

$repository protected_oe property

protected UsersRepository,Bolt\Storage\Repository $repository
return Bolt\Storage\Repository\UsersRepository

$users public_oe property

public $users