Cart Boxx – User Library Reference

THE CLASS ITSELF

class Cart

Description: Users related functions.
File: cart-boxx/core/lib/LIB_User.php

Example Usage
$_CB->extend(“User”);
$_CB->User->signin($_POST[’email’],$_POST[‘password’]);

 

SESSION RELATED

function signin

Description: Process user sign in

Parameters
[STRING] $email – User email
[STRING] $password – User password
Return
[BOOL] True on success, false on failure.
MISSING SIGN OUT FUNCTION!?

Description: No. You only need to unset the $_SESSION[‘user’] variable to sign the user out.

 

GET AND SEARCH

function getAll

Description: Get all users

Parameters
[STRING] $search – Optional, search for this user name or email
[INT] $page – Optional, the current page number, will automatically LIMIT the results based on the PER_PAGE setting in the config database.
Return
[ARRAY] Users
[BOOL] False if no users are found
function count

Description: Count the total number of users

Parameters
[STRING] $search – Optional, search for this user name or email
Return
[INT] Total number of users
function getID

Description: Get user by ID

Parameters
[INT] $id – User ID
Return
[ARRAY] User data
[BOOL] False if not found
function getEmail

Description: Get user by email

Parameters
[STRING] $email – User email
[INT] $excl – Optional, exclude this user ID. Used for checking if user email is already registered. see checkReg below.
Return
[ARRAY] User data
[BOOL] False if not found
function checkReg

Description: Check if given email is already registered

Parameters
[STRING] $email- Email
[INT] $excl – (Optional) Exclude this user ID from the search. If you update a user and do not change the email – The system will give a false ‘already registered’ if you do not exclude the updating user.
Return
[BOOL] True on already registered, false on not registered.

 

ADMIN RELATED

function add

Description: Add new user, will send a verification email to the user – The account will not be activated until the user clicks on the link in the verification email.

Parameters
[ARRAY] $user – User data, as per fields in user table in database.
[STRING] $redirect – Optional, redirect to this given slug. This function will send an activation email to the user, if provided, the user will be redirected to this given slug on successful activation.
Return
[BOOL] True on successful, false on fail.
function edit

Description: Update user

Parameters
[ARRAY] $user – User data, as per fields in user table in database.
Return
[BOOL] True on successful, false on fail.
function togstat

Description: Toggle user account status

Parameters
[INT] $id – User ID
[INT] $stat – Account status. 0 for suspended, 1 for active, 2 for pending activation… Or define your own code.
Return
[BOOL] True on successful, false on fail.
function del

Description: Delete user (but will keep the orders)

Parameters
[INT] $id – User ID
Return
[BOOL] True on successful, false on fail.

 

FORGOTTEN PASSWORD AND ACTIVATION

function forgotA

Description: Send out password reset verification email

Parameters
[STRING] $email – User email.
[STRING] $redirect – Optional, redirect to this given slug. This function will send an verification email to the user, if provided, the user will be redirected to this given slug on successful verification.
Return
[BOOL] True on successful, false on fail.
function forgotB

Description: Verify the given hash, generate password and send to user via email.

Parameters
[INT] $id – User ID
[STRING] $hash – Random hash
Return
[BOOL] True on successful, false on fail.
function activate

Description: Check the given hash and activate the newly registered account.

Parameters
[INT] $id – User ID
[STRING] $hash – Random hash
Return
[BOOL] True on successful, false on fail.

Leave a Comment

Your email address will not be published. Required fields are marked *