Constants

USER_IMAGE_FOLDER

USER_IMAGE_FOLDER = './data/media/user-images/'

PASSWORD_RESET_TOKEN_VALIDITY

PASSWORD_RESET_TOKEN_VALIDITY = 6 * 60 * 60

Properties

$mailMessage

$mailMessage : \AclUser\Service\AclUser\Mail\MailMessage

Service that handles logic to actually sends an e-mail

Type

\AclUser\Service\AclUser\Mail\MailMessage

$entityManager

$entityManager : \Doctrine\ORM\EntityManager

Doctrine ORM manager/database abstraction

Type

\Doctrine\ORM\EntityManager

$languageManager

$languageManager : \Doctrine\ORM\EntityManager

Doctrine ORM manager/database abstraction

Type

\Doctrine\ORM\EntityManager

Methods

__construct()

__construct(\AclUser\Service\Doctrine\ORM\EntityManager  $entityManager, \AclUser\Service\AclUser\Mail\MailMessage  $mailMessage, \AclUser\Service\Translate\Service\LanguageManager  $languageManager) 

Instantiate UserManager object and inject services

Parameters

\AclUser\Service\Doctrine\ORM\EntityManager $entityManager
\AclUser\Service\AclUser\Mail\MailMessage $mailMessage
\AclUser\Service\Translate\Service\LanguageManager $languageManager

updateUser()

updateUser(\AclUser\Service\type  $user, \AclUser\Service\type  $data) : boolean

This method updates data of an existing user.

Parameters

\AclUser\Service\type $user
\AclUser\Service\type $data

Throws

\Exception

Returns

boolean

checkUserExists()

checkUserExists(string  $email) : boolean

Checks whether an active user with given email address already exists in the database.

Parameters

string $email

Returns

boolean —

whether the user exists in the database

getUserByEmailAddress()

getUserByEmailAddress(string  $email) : \AclUser\Entity\User

Find User by e-mail address

Parameters

string $email

Returns

\AclUser\Entity\User

getUserById()

getUserById(integer  $id) : \AclUser\Entity\User

Find User by database id

Parameters

integer $id

Returns

\AclUser\Entity\User

AclUser/Entity/User entity

validatePassword()

validatePassword(\AclUser\Entity\User  $user, string  $password) : boolean

Checks that the given password is correct.

Parameters

\AclUser\Entity\User $user
string $password

Returns

boolean

generatePasswordResetToken()

generatePasswordResetToken(\AclUser\Entity\User  $user) 

Generates a password reset token and save to database for this user. This token is then stored in database and sent to the user's E-mail address. When the user clicks the link in E-mail message, he is directed to the Set Password page.

Parameters

\AclUser\Entity\User $user

changePassword()

changePassword(\AclUser\Entity\User  $user, array  $data) : boolean

This method is used to change the password for the given user. To change the password, one must know the old password.

Parameters

\AclUser\Entity\User $user
array $data

Returns

boolean

fetchAllRoles()

fetchAllRoles() : \AclUser\Service\ArrayCollection

Get all Role object associated with this user

Returns

\AclUser\Service\ArrayCollection —

of Role entities

getRoleByName()

getRoleByName(string  $roleName) : \AclUser\Entity\Role

Get Role entity by role name

Parameters

string $roleName

Returns

\AclUser\Entity\Role

getRolesByUserId()

getRolesByUserId(integer  $userId) : \AclUser\Service\ArrayCollection

Get ArrayCollection of UserRoleMap entity objects

Parameters

integer $userId

Returns

\AclUser\Service\ArrayCollection —

of UserRoleMap entities

validateForgottenPasswordForm()

validateForgottenPasswordForm(\AclUser\Service\ZendForm  $form, array  $params) : \Zend\Authentication\Result

Validate forgotten password for an redirect as required.

Parameters

\AclUser\Service\ZendForm $form
array $params

Returns

\Zend\Authentication\Result

validateRegistrationForm()

validateRegistrationForm(\AclUser\Form\RegistrationForm  $form, array  $params, boolean  $withCaptcha) : \Zend\Authentication\Result

Validate

Parameters

\AclUser\Form\RegistrationForm $form
array $params

post parameters

boolean $withCaptcha

whether user is being created by new user or admin

Returns

\Zend\Authentication\Result

sendConfirmNewAccountEmail()

sendConfirmNewAccountEmail(\AclUser\Entity\User  $user, boolean  $social = false) 

Send e-mail when new user registers with application

Parameters

\AclUser\Entity\User $user

the newly created user

boolean $social

whether account was created through social provider

getUserPhotoLocationById()

getUserPhotoLocationById(integer  $id, boolean  $permitted) : string

Get the file path of the present user's image

Parameters

integer $id
boolean $permitted

whether user is permitted to view the image

Returns

string —

absolute file path to image of user

validateChangePasswordForm()

validateChangePasswordForm(\AclUser\Form\ChangePasswordForm  $form, array  $params, \AclUser\Service\Acluser\Entity\user  $user) : \Zend\Authentication\Result

Validate change password form

Parameters

\AclUser\Form\ChangePasswordForm $form
array $params
\AclUser\Service\Acluser\Entity\user $user

Returns

\Zend\Authentication\Result

checkResetToken()

checkResetToken(string  $token) : \Zend\Authentication\Result

Check that password reset token belongs to a user in the database and that it has not expired

Parameters

string $token

the password reset token

Returns

\Zend\Authentication\Result

validateResetPasswordForm()

validateResetPasswordForm(\AclUser\Form\ResetPasswordForm  $form, array  $params) : \Zend\Authentication\Result

Validate reset password form and complete logic as appropriate

Parameters

\AclUser\Form\ResetPasswordForm $form
array $params

post parameters

Returns

\Zend\Authentication\Result

updateValidUsersPassword()

updateValidUsersPassword(\AclUser\Entity\User  $user, string  $password, boolean  $newUser = false) 

Hash password and update database with hash for this user

Parameters

\AclUser\Entity\User $user

entity object

string $password

un-hashed password

boolean $newUser

whether this a newly created entity

activateAccountByToken()

activateAccountByToken(string  $token) : \Zend\Authentication\Result

Check that token belongs to a user then change their status to active if it does and update pwdResetToken and date to null. Either was assign feedback messages to the returned Result object

Parameters

string $token

Returns

\Zend\Authentication\Result

updateUserPhoto()

updateUserPhoto(integer  $id, boolean  $status) 

Get entity object for the user and update whether they have uploaded their photo

Parameters

integer $id

the id of the user

boolean $status

the status of the user

validatePhotoUploadForm()

validatePhotoUploadForm(boolean  $isPost, \AclUser\Service\AclUser\Form\RotateAndResizeImageForm  $form, \Zend\Mvc\Controller\Plugin\Params  $params, integer  $userId) : array

Validate user photo upload and perform transformation on same

Parameters

boolean $isPost
\AclUser\Service\AclUser\Form\RotateAndResizeImageForm $form
\Zend\Mvc\Controller\Plugin\Params $params
integer $userId

Returns

array

prepopulateUserProfile()

prepopulateUserProfile(\AclUser\Form\BasicProfileForm  $form, integer  $id) 

Pre-populate BasicProfileForm with the existing values for user corresponding to the user id

Parameters

\AclUser\Form\BasicProfileForm $form
integer $id

validateBasicProfileForm()

validateBasicProfileForm(\AclUser\Form\BasicProfileForm  $form, array  $params, integer  $id) : boolean

Validate posted parameters from BasicProfileForm and update user if they are valid

Parameters

\AclUser\Form\BasicProfileForm $form
array $params

the post parameters

integer $id

the logged in user id or the id of the user being updated

Returns

boolean

getTranslatedErrorMesssages()

getTranslatedErrorMesssages(\AclUser\Service\Translate\Mvc\Controller\Plugin\TranslateControllerPlugin  $translateContollerPlugin, array  $errorMessages) : array

Translate all error messages

Parameters

\AclUser\Service\Translate\Mvc\Controller\Plugin\TranslateControllerPlugin $translateContollerPlugin

translator controller plugin

array $errorMessages

untranslated error messages

Returns

array —

of translated error messages

getAllLocales()

getAllLocales() : array

Get an array of all locales that (could be) available to application

Returns

array

getAllUsers()

getAllUsers() : \AclUser\Service\ArrayCollection

Get ArrayCollection of system users

Returns

\AclUser\Service\ArrayCollection

findUserById()

findUserById(integer  $id) : \AclUser\Entity\User|null

Get User by their database id

Parameters

integer $id

Returns

\AclUser\Entity\User|null

findRoleById()

findRoleById(integer  $id) : \AclUser\Entity\Role|null

Get Role by its database id

Parameters

integer $id

Returns

\AclUser\Entity\Role|null

getRolesByUser()

getRolesByUser(\AclUser\Entity\User  $user) : array

Get this users roles and all possible roles

Parameters

\AclUser\Entity\User $user

Returns

array —

of ArrayCaollections This user's Roles & All possible Roles

updateUserRoleMembership()

updateUserRoleMembership(string  $type, integer  $userId, integer  $roleId) 

Grant or revoke User specific Role

Parameters

string $type

add or remove action

integer $userId

the user's id

integer $roleId

the role's id

toggleSuspensionUserById()

toggleSuspensionUserById(integer  $id) : boolean

Toggle suspended status of a user

Parameters

integer $id

Returns

boolean

deleteUserById()

deleteUserById(integer  $id) 

Delete user from database based on the db id

Parameters

integer $id

giveUserBasicRole()

giveUserBasicRole(\AclUser\Service\user  $user) 

Grand specified user the basic role

Parameters

\AclUser\Service\user $user

createNewUser()

createNewUser(array  $data, boolean  $withCaptcha) : \Zend\Authentication\Result

Create System user and set messages and send e-mail depending if admin created user

Parameters

array $data

post parameters

boolean $withCaptcha

indicates whether admin or anon is creating user

Returns

\Zend\Authentication\Result

sendForgottenPasswordEmail()

sendForgottenPasswordEmail(\AclUser\Entity\User  $user) 

Send forgotten password e-mail with reset token

Parameters

\AclUser\Entity\User $user

checkPasswordResetTokenForUser()

checkPasswordResetTokenForUser(\AclUser\Entity\User|null  $user, string  $message = null) : \Zend\Authentication\Result

Check that user is not null and that their password reset token has not expired Add messages and result validity to Result depending on user status

Parameters

\AclUser\Entity\User|null $user
string $message

Returns

\Zend\Authentication\Result

getUserByPasswordResetToken()

getUserByPasswordResetToken(string  $token) : \AclUser\Entity\User|null

Get user from database by password reset token

Parameters

string $token

the password reset token

Returns

\AclUser\Entity\User|null —

if user is not found in database