Class: I2CE User: Difference between revisions
No edit summary |
No edit summary |
||
Line 38: | Line 38: | ||
==Methods== | ==Methods== | ||
===__construct()=== | ===__construct()=== | ||
Create a new instance of a user. | Create a new instance of a user. If the id isn't given then it will be determined from the session array. | ||
If the id isn't given then it will be determined from the session array. | |||
*Signature: public function __construct($id,$populate,$checkSession,$log) | *Signature: public function __construct($id,$populate,$checkSession,$log) | ||
Parameters: | *Parameters: | ||
* integer $id<br/>The id of the user in the database. | ** integer $id <br/>The id of the user in the database. | ||
**Default Value: '0' | ***Default Value: '0' | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $populate<br/>A flag to determine if the user should be automatically populated at creation. Defaults to true | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $populate <br/>A flag to determine if the user should be automatically populated at creation. Defaults to true | ||
**Default Value: true | ***Default Value: true | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $checkSession<br/>A flag to determine if we should check the $_SESSION['userid'] for a user id. Defaults to true | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $checkSession <br/>A flag to determine if we should check the $_SESSION['userid'] for a user id. Defaults to true | ||
**Default Value: true | ***Default Value: true | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $log<br/>Defaults to true which means we dot record this in the login table | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $log <br/>Defaults to true which means we dot record this in the login table | ||
**Default Value: true | ***Default Value: true | ||
===addUserLog()=== | ===addUserLog()=== | ||
Add a new record to the user log for this user showing they have logged in. | Add a new record to the user log for this user showing they have logged in. @global array | ||
@global array | |||
*Signature: private function addUserLog() | *Signature: private function addUserLog() | ||
===changePassword()=== | ===changePassword()=== | ||
Change the password for this user. | Change the password for this user. This will update a user's record to change the password in the database. It checks to make sure the new password matches the confirmation. | ||
This will update a user's record to change the password in the database. It checks to make sure the | |||
new password matches the confirmation. | |||
*Signature: public function changePassword($old_password,$new_password) | *Signature: public function changePassword($old_password,$new_password) | ||
* | *Parameters: | ||
** [http://www.php.net/manual/en/language.types.string.php string ] $old_password | |||
** [http://www.php.net/manual/en/language.types.string.php string ] $new_password | |||
* [http://www.php.net/manual/en/language.types.string.php string ] $ | *Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>keys are 'sucess' and 'message' the message to display back to the user signifying success or failure. @global array | ||
* [http://www.php.net/manual/en/language.types. | |||
===displayName()=== | ===displayName()=== | ||
*Signature: public function displayName() | *Signature: public function displayName() | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] The first initial and last name of this user. | *Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>The first initial and last name of this user. | ||
===findUser()=== | ===findUser()=== | ||
*Signature: static public function findUser($field,$value,$log) | *Signature: static public function findUser($field,$value,$log) | ||
Parameters: | *Parameters: | ||
*$field | *$field | ||
*$value | *$value | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $log<br/>Defaults to false whch means we do not record this in the login table | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $log <br/>Defaults to false whch means we do not record this in the login table | ||
**Default Value: false | ***Default Value: false | ||
===getId()=== | ===getId()=== | ||
Get the ID of the user | Get the ID of the user | ||
Line 89: | Line 82: | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
===getUserDB()=== | ===getUserDB()=== | ||
Returns the database where the user table can be found. This will add the trailing period | Returns the database where the user table can be found. This will add the trailing period if it isn't already there. | ||
if it isn't already there. | |||
*Signature: static public function getUserDB() | *Signature: static public function getUserDB() | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
Line 98: | Line 90: | ||
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] | *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] | ||
===login()=== | ===login()=== | ||
Login the user. | Login the user. Check the login and password of the user and log them in. If the password is incorrect then an error message will be set on the {@link I2CE_Template template}. | ||
Check the login and password of the user and log them in. If the password is incorrect | |||
then an error message will be set on the {@link I2CE_Template template}. | |||
*Signature: public function login($username,$password,$template) | *Signature: public function login($username,$password,$template) | ||
Parameters: | *Parameters: | ||
* [http://www.php.net/manual/en/language.types.string.php string ] $username | ** [http://www.php.net/manual/en/language.types.string.php string ] $username | ||
* [http://www.php.net/manual/en/language.types.string.php string ] $password | ** [http://www.php.net/manual/en/language.types.string.php string ] $password | ||
* [[Class: I2CE_Template | I2CE_Template]] $template | ** [[Class: I2CE_Template | I2CE_Template]] $template @global array | ||
===logout()=== | ===logout()=== | ||
Log the user out of the system. | Log the user out of the system. @global array | ||
@global array | |||
*Signature: public function logout() | *Signature: public function logout() | ||
===mailPassword()=== | ===mailPassword()=== | ||
*Signature: protected function mailPassword() | *Signature: protected function mailPassword() | ||
===populate()=== | ===populate()=== | ||
Populate the member variables of this object. | Populate the member variables of this object. This will also update the user log to show the latest activity for this login. | ||
This will also update the user log to show the latest activity for this login. | |||
*Signature: public function populate($update_log) | *Signature: public function populate($update_log) | ||
Parameters: | *Parameters: | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $update_log | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $update_log @global array | ||
**Default Value: true | ***Default Value: true | ||
===save()=== | ===save()=== | ||
Saves the user to the database. | Saves the user to the database. This method saves all the user data and updates the access the user has for this system. @global array | ||
This method saves all the user data and updates the access the user has for this system. | |||
@global array | |||
*Signature: public function save($transact) | *Signature: public function save($transact) | ||
Parameters: | *Parameters: | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $transact<br/>Defaults to true meaning to wrap the save in a transaction. | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $transact <br/>Defaults to true meaning to wrap the save in a transaction. | ||
**Default Value: true | ***Default Value: true | ||
===setCreator()=== | ===setCreator()=== | ||
Set the creator id of this user. | Set the creator id of this user. | ||
*Signature: public function setCreator($creator) | *Signature: public function setCreator($creator) | ||
Parameters: | *Parameters: | ||
* integer $creator | ** integer $creator | ||
===setId()=== | ===setId()=== | ||
Sets the id of the user if not known at creation. | Sets the id of the user if not known at creation. | ||
*Signature: public function setId($id) | *Signature: public function setId($id) | ||
Parameters: | *Parameters: | ||
* integer $id | ** integer $id | ||
===setPassword()=== | ===setPassword()=== | ||
*Signature: public function setPassword($password,$do_email) | *Signature: public function setPassword($password,$do_email) | ||
Parameters: | *Parameters: | ||
*$password | *$password | ||
*$do_email | *$do_email | ||
**Default Value: true | ***Default Value: true | ||
===setPreferredLocale()=== | ===setPreferredLocale()=== | ||
Sets the prefered locales for the user | Sets the prefered locales for the user | ||
*Signature: public function setPreferredLocale($locale) | *Signature: public function setPreferredLocale($locale) | ||
* | *Parameters: | ||
** [http://www.php.net/manual/en/language.types.string.php string ] $locale | |||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>$locales. false on failure string or array of strings, the locales on success | |||
===username()=== | ===username()=== | ||
Get the username | Get the username |
Revision as of 22:43, 16 October 2009
This article desrcibes the class I2CE_User.
- Extends the class: I2CE_Fuzzy.
- Location: Part of the module user in the package I2CE
- Source: Defined in the file modules/User/lib/I2CE_User.php
Variables
$userDB
The user database -- may be empty to use the database that is currently being used set base on the value of I2CE::getConfig()->database->user
- Type: protected ng $userDB
$id
- Type: public $id
$username
- Type: public $username
$password
- Type: public $password
$firstname
- Type: public $firstname
$lastname
- Type: public $lastname
- Type: public $email
$role
- Type: public $role
$creator
- Type: public $creator
$md5password
- Type: public $md5password
Methods
__construct()
Create a new instance of a user. If the id isn't given then it will be determined from the session array.
- Signature: public function __construct($id,$populate,$checkSession,$log)
- Parameters:
- integer $id
The id of the user in the database.- Default Value: '0'
- boolean $populate
A flag to determine if the user should be automatically populated at creation. Defaults to true- Default Value: true
- boolean $checkSession
A flag to determine if we should check the $_SESSION['userid'] for a user id. Defaults to true- Default Value: true
- boolean $log
Defaults to true which means we dot record this in the login table- Default Value: true
- integer $id
addUserLog()
Add a new record to the user log for this user showing they have logged in. @global array
- Signature: private function addUserLog()
changePassword()
Change the password for this user. This will update a user's record to change the password in the database. It checks to make sure the new password matches the confirmation.
- Signature: public function changePassword($old_password,$new_password)
- Parameters:
- Returns: array
keys are 'sucess' and 'message' the message to display back to the user signifying success or failure. @global array
displayName()
- Signature: public function displayName()
- Returns: string
The first initial and last name of this user.
findUser()
- Signature: static public function findUser($field,$value,$log)
- Parameters:
- $field
- $value
- boolean $log
Defaults to false whch means we do not record this in the login table- Default Value: false
- boolean $log
getId()
Get the ID of the user
- Signature: public function getId()
- Returns: integer
getPreferredLocale()
Gets the prefered locales for the user
- Signature: public function getPreferredLocale()
- Returns: $string
getRole()
Get's the role associated with a user.
- Signature: public function getRole()
- Returns: string
getUserDB()
Returns the database where the user table can be found. This will add the trailing period if it isn't already there.
- Signature: static public function getUserDB()
- Returns: string
logged_in()
Checks to see if the user is logged in.
- Signature: public function logged_in()
- Returns: boolean
login()
Login the user. Check the login and password of the user and log them in. If the password is incorrect then an error message will be set on the {@link I2CE_Template template}.
- Signature: public function login($username,$password,$template)
- Parameters:
- string $username
- string $password
- I2CE_Template $template @global array
logout()
Log the user out of the system. @global array
- Signature: public function logout()
mailPassword()
- Signature: protected function mailPassword()
populate()
Populate the member variables of this object. This will also update the user log to show the latest activity for this login.
- Signature: public function populate($update_log)
- Parameters:
- boolean $update_log @global array
- Default Value: true
- boolean $update_log @global array
save()
Saves the user to the database. This method saves all the user data and updates the access the user has for this system. @global array
- Signature: public function save($transact)
- Parameters:
- boolean $transact
Defaults to true meaning to wrap the save in a transaction.- Default Value: true
- boolean $transact
setCreator()
Set the creator id of this user.
- Signature: public function setCreator($creator)
- Parameters:
- integer $creator
setId()
Sets the id of the user if not known at creation.
- Signature: public function setId($id)
- Parameters:
- integer $id
setPassword()
- Signature: public function setPassword($password,$do_email)
- Parameters:
- $password
- $do_email
- Default Value: true
setPreferredLocale()
Sets the prefered locales for the user
- Signature: public function setPreferredLocale($locale)
- Parameters:
- string $locale
- Returns: string
$locales. false on failure string or array of strings, the locales on success
username()
Get the username
- Signature: public function username()
Inherited Fuzzy Methods
userMessage()
This method is inherited from I2CE_Fuzzy->userMessage()