PHP Class Bolt\Users

.
Afficher le fichier Open project: bolt/bolt Class Usage Examples

Méthodes publiques

Свойство Type Description
$currentuser
$users

Protected Properties

Свойство Type Description
$repository Bolt\Storage\Repository\UsersRepository

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

addRole() public méthode

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

checkAntiCSRFToken() public méthode

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

checkAvailability() public méthode

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
Résultat boolean

checkForRoot() public méthode

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

checkValidSession() public méthode

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

deleteUser() public méthode

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

filterManipulatableRoles() public méthode

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
Résultat string[] The user's roles with the allowed changes

getActiveSessions() public méthode

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

getAntiCSRFToken() public méthode

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

getCurrentUser() public méthode

Get the current user as an array.
public getCurrentUser ( ) : array
Résultat array

getCurrentUserProperty() public méthode

Get the current user's property.
public getCurrentUserProperty ( string $property ) : string
$property string
Résultat string

getCurrentUsername() public méthode

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

getEmptyUser() public méthode

Create a stub for a new/empty user.
public getEmptyUser ( ) : array
Résultat array

getUser() public méthode

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

getUsers() public méthode

Get an array with the current users.
public getUsers ( ) : array[]
Résultat array[]

hasRole() public méthode

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

hasUsers() public méthode

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

isAllowed() public méthode

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
Résultat boolean TRUE if the permission is granted, FALSE if denied.

isContentStatusTransitionAllowed() public méthode

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
Résultat boolean

isEnabled() public méthode

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

isValidSession() public méthode

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

removeRole() public méthode

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

saveUser() public méthode

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
Résultat integer The number of affected rows.

setEnabled() public méthode

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

updateUserLogin() public méthode

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
Résultat Bolt\Storage\Repository\UsersRepository

$users public_oe property

public $users