WPCrm
in package
Class de gestion des users en session avec Wordpress (ce truc immonde)
Tags
Table of Contents
- $api : CrmApiV2
- The user object
- $user : WPCrmUser
- The user object
- $sessionDestroyed : bool
- The session live status
- $sessionKey : string
- The session key name
- activateUser() : bool
- Toggle the current user optin value on the current user and the crm
- check() : bool
- Check if the user is logged in.
- deleteUser() : bool
- Delete current customer from the local database and the crm
- getNewUser() : WPCrmUser
- Generate a new user
- getUser() : WPCrmUser|null
- Get the current user return null if the user is not logged in
- getUserFromApi() : WPCrmUser|false
- Get the current user return api response code if an error occurs
- getUserFromTable() : array<string|int, mixed>|null
- Get a customer from table
- getUserFromTableByEmail() : array<string|int, mixed>|null
- Get a customer from table by an email
- getUserFromTableByUuid() : array<string|int, mixed>|null
- Get a customer from table by an email
- login() : WPCrmUser|false
- Try to login with CRM API A session will be started if credentials are valid.
- logout() : void
- Destroy the customer from session and therefore logout
- saveUser() : bool
- Save current customer to the local database and on crm
- setSingleOptin() : bool
- Set the single optin status for an email on the crm
- toggleUserOptin() : bool
- Toggle the current user optin value on the current user and the crm
- unsetActiveUser() : void
- Remove active user to prevent WPCrm::check to return true
- bootSessionIfNeeded() : void
- Boot the php session if needed
- deleteUserFromTable() : int
- Save or update the user to the table
- getCustomer() : Customer|null
- Get all customer infos
- getWpDb() : object
- Get WP 'pdo instance'
- initLdcApi() : CrmApiV2
- Get the initialized API object
- loginUserWithApi() : bool
- Check customer credentials using the CRM.
- makeApiV2Call() : mixed|false
- Make a call using apiV2
- query() : int|bool
- Query in DB
- saveOrUpdateUserToTable() : int
- Save or update the user to the table
- setUser() : void
- Create a user stores it to the session and finally saves it to the database if it does not exists
Properties
$api
The user object
protected
static CrmApiV2
$api
= null
$user
The user object
protected
static WPCrmUser
$user
= null
$sessionDestroyed
The session live status
private
static bool
$sessionDestroyed
= false
$sessionKey
The session key name
private
static string
$sessionKey
= null
Methods
activateUser()
Toggle the current user optin value on the current user and the crm
public
static activateUser() : bool
Tags
Return values
bool —True if the operation succeeded.
check()
Check if the user is logged in.
public
static check() : bool
This means he has an active valid session.
Return values
bool —deleteUser()
Delete current customer from the local database and the crm
public
static deleteUser() : bool
Tags
Return values
bool —true if the operation succeeded
getNewUser()
Generate a new user
public
static getNewUser() : WPCrmUser
Return values
WPCrmUser —getUser()
Get the current user return null if the user is not logged in
public
static getUser() : WPCrmUser|null
Return values
WPCrmUser|null —getUserFromApi()
Get the current user return api response code if an error occurs
public
static getUserFromApi(string $identification) : WPCrmUser|false
Parameters
- $identification : string
-
The customer hashcode or email.
Tags
Return values
WPCrmUser|false —getUserFromTable()
Get a customer from table
public
static getUserFromTable(string $hashcode) : array<string|int, mixed>|null
Parameters
- $hashcode : string
-
The customer hashcode.
Return values
array<string|int, mixed>|null —Database query result in format specified by $output or null on failure.
getUserFromTableByEmail()
Get a customer from table by an email
public
static getUserFromTableByEmail(string $email) : array<string|int, mixed>|null
Parameters
- $email : string
-
The customer email.
Return values
array<string|int, mixed>|null —Database query result in format specified by $output or null on failure.
getUserFromTableByUuid()
Get a customer from table by an email
public
static getUserFromTableByUuid(string $uuid) : array<string|int, mixed>|null
Parameters
- $uuid : string
-
The customer transaction uuid.
Return values
array<string|int, mixed>|null —Database query result in format specified by $output or null on failure.
login()
Try to login with CRM API A session will be started if credentials are valid.
public
static login(string $email, string $password) : WPCrmUser|false
Parameters
- $email : string
-
The customer email.
- $password : string
-
The customer password.
Tags
Return values
WPCrmUser|false —logout()
Destroy the customer from session and therefore logout
public
static logout() : void
Return values
void —saveUser()
Save current customer to the local database and on crm
public
static saveUser() : bool
Tags
Return values
bool —true if the operation succeeded false otherwise
setSingleOptin()
Set the single optin status for an email on the crm
public
static setSingleOptin(string $email, bool $opt_in) : bool
Parameters
- $email : string
- $opt_in : bool
Tags
Return values
bool —true if the operation succeeded false otherwise
toggleUserOptin()
Toggle the current user optin value on the current user and the crm
public
static toggleUserOptin() : bool
Tags
Return values
bool —true if the operation succeeded
unsetActiveUser()
Remove active user to prevent WPCrm::check to return true
public
static unsetActiveUser() : void
Return values
void —bootSessionIfNeeded()
Boot the php session if needed
private
static bootSessionIfNeeded() : void
Return values
void —deleteUserFromTable()
Save or update the user to the table
private
static deleteUserFromTable() : int
Return values
int —The number of row removed from the table.
getCustomer()
Get all customer infos
private
static getCustomer() : Customer|null
Return values
Customer|null —getWpDb()
Get WP 'pdo instance'
private
static getWpDb() : object
Return values
object —The $wpdb variable
initLdcApi()
Get the initialized API object
private
static initLdcApi() : CrmApiV2
Tags
Return values
CrmApiV2 —loginUserWithApi()
Check customer credentials using the CRM.
private
static loginUserWithApi(string $email, string $password) : bool
Parameters
- $email : string
-
The customer email.
- $password : string
-
The customer password.
Tags
Return values
bool —makeApiV2Call()
Make a call using apiV2
private
static makeApiV2Call(object|string $obj, string $method[, array<string|int, mixed> $arguments = [] ]) : mixed|false
Parameters
- $obj : object|string
-
An object or a class name.
- $method : string
-
The method to call.
- $arguments : array<string|int, mixed> = []
-
Arguments to pass.
Tags
Return values
mixed|false —query()
Query in DB
private
static query(string $query[, array<string|int, mixed> $params = [] ]) : int|bool
Parameters
- $query : string
-
La request avec les variables en points d'interrogation.
- $params : array<string|int, mixed> = []
-
Les paramètres des la requète.
Return values
int|bool —Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error.
saveOrUpdateUserToTable()
Save or update the user to the table
private
static saveOrUpdateUserToTable() : int
Return values
int —The number of row affected on the table.
setUser()
Create a user stores it to the session and finally saves it to the database if it does not exists
private
static setUser(Customer $customer) : void
Parameters
- $customer : Customer