Combu Server  3.1.1
PHP API Documentation
Public Member Functions | Static Public Member Functions | Data Fields
Account Class Reference
Inheritance diagram for Account:
DataClass

Public Member Functions

 __construct ($src=null, $stripSlashes=false)
 
 ExistsUsername ()
 
 ExistsEmail ()
 
 IsLogged ()
 
 IsOnline ()
 
 GetLastActionDate ()
 
 GetSession ()
 
 UpdateLastLogin ()
 
 Save ()
 
 Delete ()
 
 ChangePassword ($newPassword)
 
 ToJson ()
 
 ToArray ()
 
 ToArrayFiltered ()
 
 ToJsonFiltered ()
 
- Public Member Functions inherited from DataClass
 Save ()
 
 Delete ()
 
 ToJson ()
 
 ToArray ()
 

Static Public Member Functions

static Load ($username="", $email="", $customData=NULL, $appCustomData=NULL, $isOnline=FALSE, $limit=NULL, $offset=NULL, &$count=NULL, $returnArray=FALSE)
 
static LoadAny ($idApp=0, $username="", $email="", $customData=NULL, $appCustomData=NULL, $isOnline=FALSE, $limit=NULL, $offset=NULL, &$count=NULL, $returnArray=FALSE)
 
static LoadAnyByIp ($ip, $idApp=0, $username="", $email="", $customData=NULL, $appCustomData=NULL, $isOnline=FALSE, $limit=NULL, $offset=NULL, &$count=NULL, $returnArray=FALSE)
 
static LoadIds ($ids, $returnArray=FALSE)
 
static LoadUsernames ($usernames, $returnArray=FALSE)
 
static CheckLogin ($username, $password, &$account=null)
 
static SetSession (&$account)
 
static UnsetSession ()
 
static Logout ()
 
static Prune ()
 
static LoadRandom ($excludeIds=array(), $customData=NULL, $limit=null, $offset=null, &$count=null, $returnArray=false)
 
static LoadRandomFriends ($idUser, $excludeIds=array(), $customData=NULL, $limit=null, $offset=null, &$count=null, $returnArray=false)
 
static CreateRandom ($prefix, &$account=NULL)
 
- Static Public Member Functions inherited from DataClass
static GetTableName ($class)
 
static LoadRecords ($query, $returnedClass="")
 
static CountRecords ($tableName, $filter=null)
 
static TruncateTable ($tableName)
 
static TruncateClass ($class)
 

Data Fields

const TABLE_NAME = "Account"
 
 $Id = 0
 
 $Username = ""
 
 $Password = ""
 
 $GUID = ""
 
 $LastLoginDate = ""
 
 $LastLoginIp = ""
 
 $Email = ""
 
 $ActivationCode = ""
 
 $ChangePwdCode = ""
 
 $Enabled = 0
 

Additional Inherited Members

- Protected Member Functions inherited from DataClass
 _loadFilter ($tableName, $filter)
 
 _loadByRow ($row, $stripSlashes=false, $callbackOnExists=false)
 
 _Delete ($tableName, $filter=null)
 
- Static Protected Member Functions inherited from DataClass
static _count ($tableName, $filter=null)
 
static _load ($tableName, $returnedClass="", $where="", $order=null, $limit=null, $offset=null, &$count=null)
 
static _loadEx ($select, $from, $returnedClass="", $where="", $order=null, $limit=null, $offset=null, &$count=null, $debug=false)
 
static _loadQuery ($query, $returnedClass="")
 

Detailed Description

Class to handle user accounts

Author
Skared Creations

Definition at line 10 of file Account.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $src = null,
  $stripSlashes = false 
)

Contructor

Definition at line 30 of file Account.php.

Member Function Documentation

◆ ChangePassword()

ChangePassword (   $newPassword)

Change the password of this account

Database $Database

Parameters
string$newPasswordThe new password
Returns
boolean

Definition at line 473 of file Account.php.

◆ CheckLogin()

static CheckLogin (   $username,
  $password,
$account = null 
)
static

Check if specified login data are correct and the account is active

Parameters
string$usernameUsername
string$passwordPassword
\self$accountIs set to the account found
Returns
boolean Returns TRUE if login is valid

Definition at line 312 of file Account.php.

◆ CreateRandom()

static CreateRandom (   $prefix,
$account = NULL 
)
static

Create a user with a random Username

Parameters
string$prefixString to prepend to the Username
Returns
boolean Returns TRUE on success

Definition at line 577 of file Account.php.

◆ Delete()

Delete ( )

Delete the record from the database

Returns
bool Returns TRUE on success

Definition at line 429 of file Account.php.

◆ ExistsEmail()

ExistsEmail ( )

Check if the current Email already exists

Returns
boolean Returns TRUE if Email exists

Definition at line 74 of file Account.php.

◆ ExistsUsername()

ExistsUsername ( )

Check if the current Username already exists

Returns
boolean Returns TRUE if Username exists

Definition at line 55 of file Account.php.

◆ GetLastActionDate()

GetLastActionDate ( )

Definition at line 108 of file Account.php.

◆ GetSession()

GetSession ( )

Get the current session (only for $LoggedAccount)

Returns
SessionToken

Definition at line 122 of file Account.php.

◆ IsLogged()

IsLogged ( )

Verify if this account is logged

Returns
bool Returns TRUE if the account is logged

Definition at line 93 of file Account.php.

◆ IsOnline()

IsOnline ( )

Definition at line 98 of file Account.php.

◆ Load()

static Load (   $username = "",
  $email = "",
  $customData = NULL,
  $appCustomData = NULL,
  $isOnline = FALSE,
  $limit = NULL,
  $offset = NULL,
$count = NULL,
  $returnArray = FALSE 
)
static

Get the registered accounts (filtered by the current AppId, if set)

Parameters
string$usernameFilter Username initial
string$emailFilter Email initial
string[]$customData Filter CustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
string[]$appCustomData Filter AppCustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
boolean$isOnlineFilter Online state
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf TRUE then it will return associative arrays else objects AppId $AppId
Returns
[] Returns the array of records

Definition at line 144 of file Account.php.

◆ LoadAny()

static LoadAny (   $idApp = 0,
  $username = "",
  $email = "",
  $customData = NULL,
  $appCustomData = NULL,
  $isOnline = FALSE,
  $limit = NULL,
  $offset = NULL,
$count = NULL,
  $returnArray = FALSE 
)
static

Get the registered accounts (filtered by the current AppId, if set)

Parameters
int$idAppFilter players registered to an App
string$usernameFilter Username initial
string$emailFilter Email initial
string[]$customData Filter CustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
string[]$appCustomData Filter AppCustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
boolean$isOnlineFilter Online state
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf TRUE then it will return associative arrays else objects Database $Database
Returns
[] Returns the array of records

Definition at line 165 of file Account.php.

◆ LoadAnyByIp()

static LoadAnyByIp (   $ip,
  $idApp = 0,
  $username = "",
  $email = "",
  $customData = NULL,
  $appCustomData = NULL,
  $isOnline = FALSE,
  $limit = NULL,
  $offset = NULL,
$count = NULL,
  $returnArray = FALSE 
)
static

Get the registered accounts (filtered by the current AppId, if set)

Parameters
string$ipFilter Client IP
int$idAppFilter players registered to an App
string$usernameFilter Username initial
string$emailFilter Email initial
string[]$customData Filter CustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
string[]$appCustomData Filter AppCustomData (must be an array of associative array: array(array("key"=>"myKey","op"=>"=","value"=>"myValue"))
boolean$isOnlineFilter Online state
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf TRUE then it will return associative arrays else objects Database $Database
Returns
[] Returns the array of records

Definition at line 186 of file Account.php.

◆ LoadIds()

static LoadIds (   $ids,
  $returnArray = FALSE 
)
static

Load users by Id

Parameters
int[]$ids Filter Id
boolean$returnArrayIf TRUE then it will return associative arrays else objects
Returns
[]

Definition at line 257 of file Account.php.

◆ LoadRandom()

static LoadRandom (   $excludeIds = array(),
  $customData = NULL,
  $limit = null,
  $offset = null,
$count = null,
  $returnArray = false 
)
static

Get the registered accounts

Parameters
string$excludeIdsFilter array of Id to exclude
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf it is TRUE then the function returns an associative array, else it returns an array of Account objects
Returns
[] Returns the array of records found as associative array or array of Account objects

Definition at line 498 of file Account.php.

◆ LoadRandomFriends()

static LoadRandomFriends (   $idUser,
  $excludeIds = array(),
  $customData = NULL,
  $limit = null,
  $offset = null,
$count = null,
  $returnArray = false 
)
static

Get the registered accounts who are friends of a user

Parameters
int$excludeIdsFilter Id of user
int[]$excludeIds Filter array of Id to exclude
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf it is TRUE then the function returns an associative array, else it returns an array of Account objects
Returns
[] Returns the array of records found as associative array or array of Account objects

Definition at line 540 of file Account.php.

◆ LoadUsernames()

static LoadUsernames (   $usernames,
  $returnArray = FALSE 
)
static

Load users by Id

Parameters
int[]$usernames Filter Username
boolean$returnArrayIf TRUE then it will return associative arrays else objects Database $Database
Returns
[]

Definition at line 272 of file Account.php.

◆ Logout()

static Logout ( )
static

Log off this account $LoggedAccount

Definition at line 385 of file Account.php.

◆ Prune()

static Prune ( )
static

Delete all records associated to this class

Definition at line 448 of file Account.php.

◆ Save()

Save ( )

Save the record in the database

Returns
bool Returns TRUE on success

Definition at line 394 of file Account.php.

◆ SetSession()

static SetSession ( $account)
static

Set the specified account as currently logged

Parameters
Account$accountAccount to be set as current logged

Definition at line 352 of file Account.php.

◆ ToArray()

ToArray ( )

Returns the array representation of this object

$LoggedAccount

Returns
array Array of properties/values

Definition at line 606 of file Account.php.

◆ ToArrayFiltered()

ToArrayFiltered ( )

Generate a dictionary representation of the properties and custom data of this object $AppId Current App running as web service for clients

Returns
array[mixed] Key/Value dictionary of properties

Definition at line 652 of file Account.php.

◆ ToJson()

ToJson ( )

Returns the JSON representation of this object

Returns
string JSON string

Definition at line 595 of file Account.php.

◆ ToJsonFiltered()

ToJsonFiltered ( )

Generate a JSON representation of the properties and custom data of this object

Returns
string JSON string

Definition at line 686 of file Account.php.

◆ UnsetSession()

static UnsetSession ( )
static

Set the specified account as not currently logged $LoggedAccount Database $Database

Definition at line 372 of file Account.php.

◆ UpdateLastLogin()

UpdateLastLogin ( )

Update Last login info $Database

Returns
boolean

Definition at line 332 of file Account.php.

Field Documentation

◆ $ActivationCode

$ActivationCode = ""

Definition at line 21 of file Account.php.

◆ $ChangePwdCode

$ChangePwdCode = ""

Definition at line 22 of file Account.php.

◆ $Email

$Email = ""

Definition at line 20 of file Account.php.

◆ $Enabled

$Enabled = 0

Definition at line 23 of file Account.php.

◆ $GUID

$GUID = ""

Definition at line 17 of file Account.php.

◆ $Id

$Id = 0

Definition at line 14 of file Account.php.

◆ $LastLoginDate

$LastLoginDate = ""

Definition at line 18 of file Account.php.

◆ $LastLoginIp

$LastLoginIp = ""

Definition at line 19 of file Account.php.

◆ $Password

$Password = ""

Definition at line 16 of file Account.php.

◆ $Username

$Username = ""

Definition at line 15 of file Account.php.

◆ TABLE_NAME

const TABLE_NAME = "Account"

Definition at line 12 of file Account.php.