contenido\classes\class.conuser.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

Description: This class will be a replacement for all other user classes, which encapsulates only small parts of user related tasks.

In current version you can administer optional password checks via following configuration values:

  • En- or disabling checks: $cfg['password']['check_password_mask'] = [true|false] Use this flag to enable (true) or disable (false) the mask checks.

    $cfg['password']['use_cracklib'] = [true|false] Use this to enable (true) or disable (false) the strength check, currently done with cracklib.

  • Mask checks: Password mask checks are checks belonging to the "format" of the needed password string.

    $cfg['password']['min_length'], int Minimum length a password has to have. If not set, 8 chars are set as default $cfg['password']['numbers_mandatory'], int If set to a value greater than 0, at least $cfg['password']['numbers_mandatory'] numbers must be in password $cfg['password']['symbols_mandatory'], int && $cfg['password']['symbols_regex'], String If 'symbols_mandatory' set to a value greater than 0, at least so many symbols has to appear in given password. What symbols are regcognized can be administrated via 'symbols_regex'. This has to be a regular expression which is used to "find" the symbols in $sNewPassword. If not set, following RegEx is used: "/[|!@#$%&*\/=?,;.:-_+~^�\]/" $cfg['password']['mixed_case_mandatory'], int If set to a value greater than 0 so many lower and upper case character must appear in the password. (e.g.: if set to 2, 2 upper and 2 lower case characters must appear)

  • Strength check Passwords should have some special characteristics to be a strong, i.e. not easy to guess, password. Currently cracklib is supported. These are the configuration possibilities:

    $cfg['password']['cracklib_dict'], string Path and file name (without file extension!) to dictionary you want to use. This setting is mandatory!

    Keep in mind that these type of check only works if crack module is available.

Author
Bilal Arslan, Holger Librenz  
Copyright
four for business AG {@internal created 04.11.2008 modified 2008-11-16, H. Librenz - added structure, comments fixed, code debugged modified 2008-11-21, H. Librenz - some documentation stuff added modified 2008-11-25, Timo Trautman - removed not existing include modified 2008-12-04, Bilal Arslan, Bugfixed for set passwort length, comments "how to use" fixed. Bugfixed for password, lower Case Upper case count, for symbols count and numbers count. modified 2008-12-04, Timo Trautman, Added Contenido $cfg as param for getErrorString() modified 2011-02-26, Ortwin Pinke, added unset for pw-request-marker, changed header svn-id and version declaration $Id:$ }}  
Package
Contenido Backend classes  
Subpackage
Backend User  
Version
1.4.0  

\ConUser

Package: Contenido Backend classes\Backend user
Project: Contenido Content Management System

Description: Class User to handle all user related task. In first implementations, it will only do some little things, like checking and setting passwords.

Requirements:

Parent(s)
\ConUser_Abstract
Author
Bilal Arslan, Holger Librenz  
Con_php_req
5.0  
Copyright
four for business AG  
License
http://www.contenido.org/license/LIZENZ.txt  
Link
http://www.4fb.de  
Link
http://www.contenido.org  
Since
file available since contenido release => 4.8.8  
Version
0.2.0  

Constants

>VConstantint  PASS_OK = 0
inherited
Password is ok and stored.
Inherited from: \iConUser::PASS_OK\ConUser_Abstract::PASS_OK
Final
 
Inherited_from
\iConUser::PASS_OK  
Inherited_from
\ConUser_Abstract::PASS_OK  
int

>VConstantint  PASS_TO_SHORT = 1
inherited
Given password is to short
Inherited from: \iConUser::PASS_TO_SHORT\ConUser_Abstract::PASS_TO_SHORT
Final
 
Inherited_from
\iConUser::PASS_TO_SHORT  
Inherited_from
\ConUser_Abstract::PASS_TO_SHORT  
int

>VConstantint  PASS_NOT_STRONG = 2
inherited
Given password is not strong enough
Inherited from: \iConUser::PASS_NOT_STRONG\ConUser_Abstract::PASS_NOT_STRONG
Final
 
Inherited_from
\iConUser::PASS_NOT_STRONG  
Inherited_from
\ConUser_Abstract::PASS_NOT_STRONG  
int

>VConstantint  PASS_NOT_COMPLEX = 3
inherited
Given password is not complex enough
Inherited from: \iConUser::PASS_NOT_COMPLEX\ConUser_Abstract::PASS_NOT_COMPLEX
Final
 
Inherited_from
\iConUser::PASS_NOT_COMPLEX  
Inherited_from
\ConUser_Abstract::PASS_NOT_COMPLEX  
int

>VConstantint  PASS_NOT_ENOUGH_NUMBERS = 4
inherited
Password does not contain enough numbers.
Inherited from: \iConUser::PASS_NOT_ENOUGH_NUMBERS\ConUser_Abstract::PASS_NOT_ENOUGH_NUMBERS
>VConstantint  PASS_NOT_ENOUGH_SYMBOLS = 5
inherited
Password does not contain enough symbols.
Inherited from: \iConUser::PASS_NOT_ENOUGH_SYMBOLS\ConUser_Abstract::PASS_NOT_ENOUGH_SYMBOLS
>VConstantint  PASS_NOT_ENOUGH_MIXED_CHARS = 6
inherited
Password does not contain enough mixed characters.
Inherited from: \iConUser::PASS_NOT_ENOUGH_MIXED_CHARS\ConUser_Abstract::PASS_NOT_ENOUGH_MIXED_CHARS
>VConstantint  PASS_NOT_ENOUGH_DIFFERENT_CHARS = 7
inherited
Password does not contain enough different characters.
Inherited from: \iConUser::PASS_NOT_ENOUGH_DIFFERENT_CHARS\ConUser_Abstract::PASS_NOT_ENOUGH_DIFFERENT_CHARS
>VConstantint  EXCEPTION_USERNAME_EXISTS = 8
inherited
Exception code, which is used if you try to add an user that already exists.
Inherited from: \iConUser::EXCEPTION_USERNAME_EXISTS\ConUser_Abstract::EXCEPTION_USERNAME_EXISTS
>VConstantint  EXCEPTION_PASSWORD_INVALID = 9
inherited
Exception code, which is used if an password is set to save that is not valid.
Inherited from: \iConUser::EXCEPTION_PASSWORD_INVALID\ConUser_Abstract::EXCEPTION_PASSWORD_INVALID
>VConstant  MIN_PASS_LENGTH_DEFAULT = 8
inherited
This value will be used if no minimum length for passwords are set via $cfg['password']['min_length']
Inherited from: \iConUser::MIN_PASS_LENGTH_DEFAULT\ConUser_Abstract::MIN_PASS_LENGTH_DEFAULT

Properties

>VPropertyprivatearray $aAddress = array()
Array of address data fill like below values

$aAddress['street'], $aAddress['city'], $aAddress['country'], $aAddress['zip']

Default valuearray()Details
Type
array
>VPropertyprotectedarray $aCfg = null
inherited
Contenido configuration array
Inherited from: \ConUser_Abstract::$$aCfg
Default valuenullDetails
Type
array
Inherited_from
\ConUser_Abstract::$$aCfg  
>VPropertyprivateint $iUseTiny = null
To Use Tiny Editor
Default valuenullDetails
Type
int
>VPropertyprotected\DB_Contenido $oDb = null
inherited
Referemces database abstraction instance
Inherited from: \ConUser_Abstract::$$oDb
Default valuenullDetails
Type
\DB_Contenido
Inherited_from
\ConUser_Abstract::$$oDb  
>VPropertyprivatestring $sMail = ""
Mail address
Default value""Details
Type
string
>VPropertyprivate\unknown_type $sPassword = null
inherited
Holds the password which should be set.
Inherited from: \ConUser_Abstract::$$sPassword
Default valuenullDetails
Type
\unknown_type
Inherited_from
\ConUser_Abstract::$$sPassword  
>VPropertyprivatestring $sPermName = ""
Permname
Default value""Details
Type
string
>VPropertyprivatestring $sRealName = ""
Realname
Default value""Details
Type
string
>VPropertyprivatestring $sTelNumber = ""
Telephone number
Default value""Details
Type
string
>VPropertyprivatestring $sUserId = null
inherited
current User ID
Inherited from: \ConUser_Abstract::$$sUserId
Default valuenullDetails
Type
string
Inherited_from
\ConUser_Abstract::$$sUserId  
>VPropertyprivatestring $sUserName = null
inherited
Login name of current user.
Inherited from: \ConUser_Abstract::$$sUserName
Default valuenullDetails
Type
string
Inherited_from
\ConUser_Abstract::$$sUserName  
>VPropertyprivatestring $sValidDateFrom = null
User valid date from
Default valuenullDetails
Type
string
>VPropertyprivatestring $sValidDateTo = null
User valid date to
Default valuenullDetails
Type
string

Methods

methodpublic__construct(array $aCfg,  $oDb = null,  $sUserId = null) : \ConUser

Calls constructor in base class.

Checks given values and initializes class.

Parameters
NameTypeDescription
$aCfgarray
$oDb
$sUserId
Returns
TypeDescription
\ConUser
Throws
ExceptionDescription
\ConUserException
methodpubliccheckPasswordMask(string $sNewPassword) : int

Following configuration values are recognized: $this->aCfg['password']['check_password_mask'], bool En- or disable these checks.

.. $this->aCfg['password']['min_length'], int Minimum length a password has to have. If not set, 8 chars are set as default $this->aCfg['password']['numbers_mandatory'], int If set to a value greater than 0, at least $this->aCfg['password']['numbers_mandatory'] numbers must be in password $this->aCfg['password']['symbols_mandatory'], int && $this->aCfg['password']['symbols_regex'], String If 'symbols_mandatory' set to a value greater than 0, at least so many symbols has to appear in given password. What symbols are regcognized can be administrated via 'symbols_regex'. This has to be a regular expression which is used to "find" the symbols in $sNewPassword. If not set, following RegEx is used: "/[|!@#$%&*\/=?,;.:-_+~^�\]/" $this->aCfg['password']['mixed_case_mandatory'], int If set to a value greater than 0 so many lower and upper case character must appear in the password. (e.g.: if set to 2, 2 upper and 2 lower case characters must appear)

Parameters
NameTypeDescription
$sNewPasswordstring
Returns
TypeDescription
int
methodpubliccheckPasswordStrength(string $sNewPassword) : int

This password checks the password strength.

In "standard" implementation, it uses cracklib, if administrated and available. Other possible checks are checks against user list with birth dates or similar, non direct "maskable" checks.

Following configuration values are recognized: $this->aCfg['password']['use_cracklib'], bool En- or disable these checks... $this->aCfg['password']['cracklib_dict'], string Path and file name (without file extension!) to dictionary you want to use. This setting is mandatory!

Please ensure that you have a working crack module installed. If the function crack_opendict is not available, the check are omitted and the result is iConUser::PASS_OK.

Parameters
NameTypeDescription
$sNewPasswordstring
Returns
TypeDescription
int
methodpublicencodePassword(string $sPassword) : string
static

{@see iConUser::encodePassword()}

You should use one-way encodings or hash-algorithms to ensure that nobody can read simply the passwords!

Parameters
NameTypeDescription
$sPasswordstring
Returns
TypeDescription
string
methodpublicgenerateUserId() : string
inherited

Generates new user id based on current user name.

Inherited from: \ConUser_Abstract::generateUserId()
Returns
TypeDescription
string
methodpublicgetAddressData() : string

Getter method to get user adress data

Returns
TypeDescription
stringRealname of user
methodpublicgetErrorString(int $iErrorCode, array $aCfg) : string
static

This static method provides a simple way to get error messages depending on error code $iErrorCode, which is returned by checkPassword* methods.

Parameters
NameTypeDescription
$iErrorCodeint
$aCfgarray

Contenido configuration array

Returns
TypeDescription
string
methodpublicgetMail() : string

Getter method to get user mail

Returns
TypeDescription
stringRealname of user
methodprotectedgetPassword() : string
inherited

Returns (unencoded!) password.

Inherited from: \ConUser_Abstract::getPassword()

This method should never be public available!

Returns
TypeDescription
string
methodpublicgetPerms() : string

Getter method to get user perm name

Returns
TypeDescription
stringRealname of user
methodpublicgetRealName() : string

Getter method to get user realname

Returns
TypeDescription
stringRealname of user
methodpublicgetTelNumber() : string

Getter method to get user tel number

Returns
TypeDescription
stringRealname of user
methodpublicgetUseTiny() : string

Getter method to get user wysi

Returns
TypeDescription
stringRealname of user
methodpublicgetUserId() : string
inherited

Returns user id, currently set.

Inherited from: \ConUser_Abstract::getUserId()
Returns
TypeDescription
string
methodpublicgetUserName() : string
inherited

Returns user name, currently set

Inherited from: \ConUser_Abstract::getUserName()
Returns
TypeDescription
string
methodpublicgetValidDateFrom() : string

Getter method to get user valid date from-to

Returns
TypeDescription
stringRealname of user
methodpublicgetValidDateTo() : string

Getter method to get user valid date from-to

Returns
TypeDescription
stringRealname of user
methodprotectedinsert() : boolean

Creates new user.

This method creates a new user with base informations. It is called within the iConUser::save() method.

Returns
TypeDescription
boolean
Details
Todo
add value checks!  
methodpublicload(string $sUserId) : boolean

Currently not implemented!

Parameters
NameTypeDescription
$sUserIdstring
Returns
TypeDescription
boolean
Details
See
\ConUser_Abstract::load()  
Todo
implement it  
methodpublicsave() : boolean

This method tries to save all information collected for an user.

If everything is fine, it returns true - otherwise false. On fatal errors a ConUserException will be thrown.

Returns
TypeDescription
boolean
Details
See
\ConUser_Abstract::save()  
methodpublicsavePassword(string $sNewPassword) : int

This method saves the given password $sNewPassword.

The password has to be checked, before it is set to the database. The resulting integer value represents the result code. Use the PASS_* constants to check what happens.

Parameters
NameTypeDescription
$sNewPasswordstring

Password to set

Returns
TypeDescription
int
Throws
ExceptionDescription
\ConUserException
Details
See
The method uses following config values:  
methodpublicsaveUser() : void

This function does update without password column to all columns of con_phplib_auth_user_md5 table.

methodpublicsetAddressData( $sAddressStreet,  $sAddressCity,  $sAddressZip,  $sAddressCountry) : void

Setter method to set Adress Data

Parameters
NameTypeDescription
$sAddressStreet
$sAddressCity
$sAddressZip
$sAddressCountry
methodpublicsetCity(string $sCity) : void

Sets value for city.

Parameters
NameTypeDescription
$sCitystring
methodpublicsetCountry(string $sCountry) : void

Sets value for country.

Parameters
NameTypeDescription
$sCountrystring
methodpublicsetMail( $sMail) : void

Setter method to set user mail address

Parameters
NameTypeDescription
$sMail
methodpublicsetPassword(string $sPassword) : int
inherited

Checks password which has to be set and return PASS_* values (i.e.

Inherited from: \ConUser_Abstract::setPassword()

on success PASS_OK).

Parameters
NameTypeDescription
$sPasswordstring
Returns
TypeDescription
int
methodpublicsetPerms( $aPerms) : void

setter method to set

Parameters
NameTypeDescription
$aPerms
methodpublicsetRealName( $sRealName) : void

Setter method to set user real name

Parameters
NameTypeDescription
$sRealName
methodpublicsetStreet(string $sStreet) : void

Sets value for street.

Parameters
NameTypeDescription
$sStreetstring
methodpublicsetTelNumber( $sTelNumber) : void

setter method to set user tel number

Parameters
NameTypeDescription
$sTelNumber
methodpublicsetUseTiny( $iUseTiny) : void

Setter method to set

Parameters
NameTypeDescription
$iUseTiny
methodpublicsetUserId(\unknown_type $sUserId) : void
inherited

Sets user ID.

Inherited from: \ConUser_Abstract::setUserId()
Parameters
NameTypeDescription
$sUserId\unknown_type

TODO check this

methodpublicsetUserName(string $sUserName) : void
inherited

Sets up new user name.

Inherited from: \ConUser_Abstract::setUserName()
Parameters
NameTypeDescription
$sUserNamestring
methodpublicsetValidDateFrom( $sValidateFrom) : void

setter method to set

Parameters
NameTypeDescription
$sValidateFrom
methodpublicsetValidDateTo( $sValidateTo) : void

setter method to set User

Parameters
NameTypeDescription
$sValidateTo
methodpublicsetZip(string $sZip) : void

Sets value for ZIP.

Parameters
NameTypeDescription
$sZipstring
methodprotectedupdate() : boolean

Updates a user

This method update base user informations in user table. It is called within the iConUser::save() method.

Returns
TypeDescription
boolean
Details
Todo
add type checks!  
methodpublicuserExists( $sUserId) : boolean

Checks if an user with user id $sUserId already exists in DB.

Parameters
NameTypeDescription
$sUserId
Returns
TypeDescription
boolean
methodpublicusernameExists(string $sUsername) : boolean

Checks if username $sUsername is already in use.

Parameters
NameTypeDescription
$sUsernamestring
Returns
TypeDescription
boolean
Details
Todo
to be implemented  
Documentation was generated by phpDocumentor 2.0.0a12.