imPrivateArea
Kind: global class
Summary: Provides a set of useful methods for managing the private area, the users and the accesses.
To use it, you must include x5engine.php in your code.
- imPrivateArea
- new imPrivateArea()
- .getInstance() ⇒
Imprivatearea
- .login($uname, $pwd) ⇒
Number
- .logout() ⇒
Void
- .savePage() ⇒
Void
- ~~.who_is_logged() ⇒
Mixed
~~ - .whoIsLogged() ⇒
Mixed
- .checkAccess($page) ⇒
Number
- .getLandingPage() ⇒
Mixed
- .messageFromStatusCode($code) ⇒
String
- .getUserByUsername($id) ⇒
Mixed
- .getUsersById($ids) ⇒
Array
- .setDBData($host, $username, $password, $dbname, $dbtable) ⇒
Void
- .validateWaitingUserById($dbid) ⇒
Bool
- .validateWaitingUserByKey($keys, $login) ⇒
Booleal
- .removeWaitingUsers($ts, $usersToKeep) ⇒
Void
- .getKeyFromId($dbid) ⇒
String
- .createUsersTable() ⇒
Void
- .registerNewUser($username, $password, $email, $validated) ⇒
Number
- .sendNotificationEmail($id) ⇒
Void
- .sendValidationEmail($id) ⇒
Void
- .sendLostPasswordEmail($data) ⇒
Boolean
new imPrivateArea()
Create a new ImDb Object
.getInstance() ⇒ Imprivatearea
Get the instance of the private area
Kind: instance method of imPrivateArea
Returns: Imprivatearea
- The instance of a private area
.login($uname, $pwd) ⇒ Number
Login a user with username and password
Kind: instance method of imPrivateArea
Returns: Number
- An error code:
-5 if the user email is not validated,
-2 if the username or password are invalid,
-1 if there's a db error,
0 if the process exits correctly
Param | Type | Description |
---|---|---|
$uname | String |
Username |
$pwd | String |
Password |
.logout() ⇒ Void
Logout a user
Kind: instance method of imPrivateArea
.savePage() ⇒ Void
Save the current page as the referer
Kind: instance method of imPrivateArea
~~.who_is_logged() ⇒ Mixed
~~
Deprecated
Use whoIsLogged instead
Kind: instance method of imPrivateArea
.whoIsLogged() ⇒ Mixed
Get an array of data about the logged user
Kind: instance method of imPrivateArea
Returns: Mixed
- An array containing the data of the current logged user or false if no user is logged.
.checkAccess($page) ⇒ Number
Check if the logged user can access to a specific page.
The page is provided using its page id.
Kind: instance method of imPrivateArea
Returns: Number
- 0 if the current user can access the page,
-2 if the XSS security checks are not met
-3 if the user is not logged
-4 if the user is still not validated
-8 if the user cannot access the page
Param | Type | Description |
---|---|---|
$page | Number |
The page id. You can retrieve the page id from the file x5settings.php. |
.getLandingPage() ⇒ Mixed
Get the current user's landing page.
Kind: instance method of imPrivateArea
Returns: Mixed
- The filename of the user's landing page or false if the user is not logged.
.messageFromStatusCode($code) ⇒ String
Convert a status code to a text message
Kind: instance method of imPrivateArea
Returns: String
- The text message related to the provided error code
Param | Type | Description |
---|---|---|
$code | Number |
The error code |
.getUserByUsername($id) ⇒ Mixed
Get the data about a user.
Kind: instance method of imPrivateArea
Returns: Mixed
- The user's data (As associative array) or null if the user is not found.
The associative array contains the following keys: id, ts, ip, username, password, realname, email, key, validated, groups
Param | Type | Description |
---|---|---|
$id | String |
The username |
.getUsersById($ids) ⇒ Array
Get the user data relative to a set of user ids.
This method is available only in the Professional edition.
Kind: instance method of imPrivateArea
Returns: Array
- An array of associative arrays containing the users' data.
The array keys are: id, ts, ip, username, password, realname, email, key, validated
Param | Type | Description |
---|---|---|
$ids | Array |
The array of user ids. |
.setDBData($host, $username, $password, $dbname, $dbtable) ⇒ Void
Setup the db connection.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type |
---|---|
$host | String |
$username | String |
$password | String |
$dbname | String |
$dbtable | String |
.validateWaitingUserById($dbid) ⇒ Bool
Validate the waiting users listed in $ids. It must be an array of DB ids.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type |
---|---|
$dbid | Array |
.validateWaitingUserByKey($keys, $login) ⇒ Booleal
Validate the waiting users listed in $keys. It must be an array of DB keys.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type | Description |
---|---|---|
$keys | Array |
|
$login | Boolean |
Automatically login the user if validation is succesful |
.removeWaitingUsers($ts, $usersToKeep) ⇒ Void
Remove the remaining waiting users.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type | Description |
---|---|---|
$ts | String |
Remove only the users registered before this timestamp. |
$usersToKeep | Array |
Remove all the users but keep the ones listed in this array |
.getKeyFromId($dbid) ⇒ String
Get the validation key of user $dbid.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Returns: String
- The validation key
Param | Type |
---|---|
$dbid | String |
.createUsersTable() ⇒ Void
Create the users table if it doesn't exist
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
.registerNewUser($username, $password, $email, $validated) ⇒ Number
Register a new user in the database.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Returns: Number
- the user's ID or the error number (-1: user already exists, -2: generic error)
Param | Type |
---|---|
$username | String |
$password | String |
String |
|
$validated | String |
.sendNotificationEmail($id) ⇒ Void
Notify the registration of a new user to the site's owner.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type | Description |
---|---|---|
$id | Number |
The user id |
.sendValidationEmail($id) ⇒ Void
Send the validation email for the user indentified by $id.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Param | Type |
---|---|
$id | String |
.sendLostPasswordEmail($data) ⇒ Boolean
If the user has provided an email address, he receives a message with his password.
If the user's email is not available, the request is notified to the site's admin.
This method is only available in the Professional edition.
Kind: instance method of imPrivateArea
Returns: Boolean
- True if the email is sent correctly.
Param | Type | Description |
---|---|---|
$data | String |
The user's email or username |
getSavedPage() ⇒ Mixed
Return the referer page name (the one which caused the user to land on the login page).
Kind: global function
Returns: Mixed
- The name of the page or false if no referer is available.