Users

Summary
Users
AuthorJaybill McCarthy
Licensehttp://communit.as/docs/license
See AlsoCts_Db_Table_Abstract
Constructors
UsersCalls the parent’s constructor and instantiates a logger.
Instance Methods
insertInserts a user into the database.
isEmailInUseDetermines whether a particular email address already exists in the database.
fetchByUsernameGets a set of user data for a particular username from the database.
deleteDelete a user from the database.
updateUpdates the attributes of a user in the database.
userExistsUsed to determine if a user exists.
fetchByRoleIdGets all users in a particular role.
isUserInRoleIndicates whether a certain user has a certain role.
setMetaDataUpdates the metadata object for a user.
getMetaDataUpdates the metadata object for a user.
getRecentlyRegisteredFetches a list of those users who have most recently registered.
getRecentlyUpdatedFetches a list of those users who have most recently updated.
getRecentlyOnlineFetches a list of those users who have most recently logged into the app.
Static Methods
getAvatarPathGets full path to avatar.
clearUserCacheDeletes all of a particular user’s images from the server cache.
Private or Protected Methods
parseTags

Author

Jaybill McCarthy

Constructors

Users

public function Users()

Calls the parent’s constructor and instantiates a logger.

Instance Methods

insert

public function insert(array $data)

Inserts a user into the database.

Arguments

dataAn array of attributes associated with a user.

Returns

TBD

isEmailInUse

public function isEmailInUse($email,  
$username =  null)

Determines whether a particular email address already exists in the database.

Arguments

emailThe email address string to look for.
username (optional)If specified, the username gets added to the where clause so you can see if an email address is being used with a particular username.

Returns

A boolean indicating whether the email exists (true) or does not (false).

fetchByUsername

public function fetchByUsername($username)

Gets a set of user data for a particular username from the database.

Arguments

usernameThe username for the user to be retrieved.

Returns

TBD

delete

public function delete($where)

Delete a user from the database.

Arguments

whereA where clause string to limit the rows that get deleted.  If the where clause is empty, all users will be deleted!

Plugin Hooks

  • default_users_table_delete (action) - TBD
param usernameThe username of the user to delete.

Returns

TBD

update

public function update(array $data,
 $where)

Updates the attributes of a user in the database.

Arguments

dataAn array with a key-value pair for each column in the users table.
whereA where clause string to limit the rows that get updated.  If the where clause is empty, all users will be updated with the data argument.

Returns

TBD

userExists

public function userExists($username)

Used to determine if a user exists.

Arguments

usernameThe username to check for.

Returns

A boolean telling whether the user exists (true) or does not (false).

fetchByRoleId

function fetchByRoleId($role_id)

Gets all users in a particular role.

Arguments

role_idThe ID of the role from which to retrieve all users.

Returns

An array of users.

isUserInRole

function isUserInRole($username,
$role_id)

Indicates whether a certain user has a certain role.

Arguments

usernameThe username to verify.
role_idThe ID (integer) of the role to verify.

setMetaData

function setMetaData($username,
$key,
$value)

Updates the metadata object for a user.

Arguments

usernameusername that will have thier metadata updated
keythe field name of the metadata field
valuethe metadata value to be set

getMetaData

function getMetaData($username,  
$key =  null)

Updates the metadata object for a user.

Arguments

usernameusername that will have thier metadata updated key (optional)- the field name of the metadata field.  If this isn’t specifed, an associative array with all values is returned.

getRecentlyRegistered

function getRecentlyRegistered($how_many)

Fetches a list of those users who have most recently registered.

Arguments

how_manyAn integer value which is passed as the limit parameter in the database query.

Returns: array of users or an empty array

getRecentlyUpdated

function getRecentlyUpdated($how_many)

Fetches a list of those users who have most recently updated.

Arguments

how_manyAn integer value which is passed as the limit parameter in the database query.

Returns: array of users or an empty array

getRecentlyOnline

function getRecentlyOnline($how_many)

Fetches a list of those users who have most recently logged into the app.

Arguments

how_manyAn integer value which is passed as the limit parameter in the database query.

Returns: array of users or an empty array

Static Methods

getAvatarPath

function getAvatarPath($username,  
$include_filename =  false)

Gets full path to avatar.  You should always use this instead of referencing the avatar directly.  Should be used both when storing an avatar and retrieving it.

Arguments

usernameThe username of the user whose avatar is needed.
include_filename (optional)Whether or not to include the filename or just the directory.  Defaults to false.

Plugin Hooks

  • default_users_table_avatar_path (filter) - Allows you to modify the default avatar path.
param paththe default path to the avatar.

clearUserCache

static function clearUserCache($username)

Deletes all of a particular user’s images from the server cache.

Arguments

usernameThe username of the user whose cache is to be cleared.

Private or Protected Methods

parseTags

protected function parseTags($all_tags)
public function Users()
Calls the parent’s constructor and instantiates a logger.
public function insert(array $data)
Inserts a user into the database.
public function isEmailInUse($email,  
$username =  null)
Determines whether a particular email address already exists in the database.
public function fetchByUsername($username)
Gets a set of user data for a particular username from the database.
public function delete($where)
Delete a user from the database.
public function update(array $data,
 $where)
Updates the attributes of a user in the database.
public function userExists($username)
Used to determine if a user exists.
function fetchByRoleId($role_id)
Gets all users in a particular role.
function isUserInRole($username,
$role_id)
Indicates whether a certain user has a certain role.
function setMetaData($username,
$key,
$value)
Updates the metadata object for a user.
function getMetaData($username,  
$key =  null)
Updates the metadata object for a user.
function getRecentlyRegistered($how_many)
Fetches a list of those users who have most recently registered.
function getRecentlyUpdated($how_many)
Fetches a list of those users who have most recently updated.
function getRecentlyOnline($how_many)
Fetches a list of those users who have most recently logged into the app.
function getAvatarPath($username,  
$include_filename =  false)
Gets full path to avatar.
static function clearUserCache($username)
Deletes all of a particular user’s images from the server cache.
protected function parseTags($all_tags)
Close