PHP Класс Bolt\Users

.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$currentuser
$users

Защищенные свойства (Protected)

Свойство Тип Описание
$repository Bolt\Storage\Repository\UsersRepository

Открытые методы

Метод Описание
__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 )

Приватные методы

Метод Описание
canonicalizeFieldValue ( string $fieldname, string $fieldvalue ) : string Create a correctly canonicalized value for a field, depending on its name.
getRepository ( ) : UsersRepository

Описание методов

__construct() публичный Метод

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

addRole() публичный Метод

Add a certain role from a specific user.
public addRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
Результат boolean

checkAntiCSRFToken() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public checkAntiCSRFToken ( $token = '' )

checkAvailability() публичный Метод

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
Результат boolean

checkForRoot() публичный Метод

There should always be at least one If there isn't we promote the current user.
public checkForRoot ( ) : boolean
Результат boolean

checkValidSession() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public checkValidSession ( )

deleteUser() публичный Метод

Remove a user from the database.
public deleteUser ( integer $id ) : integer
$id integer
Результат integer The number of affected rows.

filterManipulatableRoles() публичный Метод

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
Результат string[] The user's roles with the allowed changes

getActiveSessions() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public getActiveSessions ( )

getAntiCSRFToken() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public getAntiCSRFToken ( )

getCurrentUser() публичный Метод

Get the current user as an array.
public getCurrentUser ( ) : array
Результат array

getCurrentUserProperty() публичный Метод

Get the current user's property.
public getCurrentUserProperty ( string $property ) : string
$property string
Результат string

getCurrentUsername() публичный Метод

Get the username of the current user.
Устаревший: Deprecated since 3.0, to be removed in 4.0.
public getCurrentUsername ( ) : string
Результат string

getEmptyUser() публичный Метод

Create a stub for a new/empty user.
public getEmptyUser ( ) : array
Результат array

getUser() публичный Метод

Get a user, specified by ID, username or email address.
public getUser ( integer | string $userId ) : array | false
$userId integer | string
Результат array | false

getUsers() публичный Метод

Get an array with the current users.
public getUsers ( ) : array[]
Результат array[]

hasRole() публичный Метод

Check if a certain user has a specific role.
public hasRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
Результат boolean

hasUsers() публичный Метод

Test to see if there are users in the user table.
public hasUsers ( ) : integer
Результат integer

isAllowed() публичный Метод

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
Результат boolean TRUE if the permission is granted, FALSE if denied.

isContentStatusTransitionAllowed() публичный Метод

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
Результат boolean

isEnabled() публичный Метод

Check a user's enable status.
public isEnabled ( integer | boolean $id = false ) : boolean
$id integer | boolean User ID, or false for current user
Результат boolean

isValidSession() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public isValidSession ( )

removeRole() публичный Метод

Remove a certain role from a specific user.
public removeRole ( string | integer $id, string $role ) : boolean
$id string | integer
$role string
Результат boolean

saveUser() публичный Метод

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
Результат integer The number of affected rows.

setEnabled() публичный Метод

Enable or disable a user, specified by id.
public setEnabled ( integer | string $id, boolean | integer $enabled = true ) : integer
$id integer | string
$enabled boolean | integer
Результат integer

updateUserLogin() публичный Метод

Устаревший: Deprecated since 3.0, to be removed in 4.0.
public updateUserLogin ( $user )

Описание свойств

$currentuser публичное свойство

public $currentuser

$repository защищенное свойство

protected UsersRepository,Bolt\Storage\Repository $repository
Результат Bolt\Storage\Repository\UsersRepository

$users публичное свойство

public $users