Documentation

Folks_Driver_sql extends Folks_Driver
in package

Folks storage implementation for PHP's PEAR database abstraction layer.

Required values for $params:

'phptype'       The database type (e.g. 'pgsql', 'mysql', etc.).
'table'         The name of the foo table in 'database'.
'charset'       The database's internal charset.

Required by some database implementations:

'database'      The name of the database.
'hostspec'      The hostname of the database server.
'protocol'      The communication protocol ('tcp', 'unix', etc.).
'username'      The username with which to connect to the database.
'password'      The password associated with 'username'.
'options'       Additional options to pass to the database.
'tty'           The TTY on which to connect to the database.
'port'          The port on which to connect to the database.

The table structure can be created by the scripts/sql/folks_foo.sql script.

Copyright 2008-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Tags
author

Duck duck@obala.net

Table of Contents

$_params  : array<string|int, mixed>
Hash containing connection parameters.
$_db  : DB
Handle for the current database connection.
$_write_db  : DB
Handle for the current database connection, used for writing. Defaults to the same handle as $_db if a separate write database is not required.
__construct()  : mixed
Constructs a new SQL storage object.
addUser()  : bool
Adds a set of authentication credentials.
changePassword()  : mixed
Change user password
comparePassword()  : bool
Compare an encrypted pasword to a plaintext string to see if they match.
countUsers()  : mixed
Count users by attributes
deleteActivity()  : true
Delete users activity
deleteImage()  : mixed
Delete user image
deleteOnlineUser()  : mixed
Remove user if is online
deleteSavedSearch()  : mixed
Delete saved search
deleteUser()  : bool
Delete user
factory()  : Folks_Driver
Attempts to return a concrete Folks_Driver instance based on $driver.
getActivity()  : array<string|int, mixed>
Get user's activity
getAttributes()  : mixed
Get user attributes
getConfirmationCode()  : string
Get confirmation code
getCookie()  : string
Get encripted cookie login string
getNewUsers()  : array<string|int, mixed>
Get last signed up users
getOnlineUsers()  : array<string|int, mixed>
Get usersnames online
getProfile()  : mixed
Get user profile
getRandomUsers()  : array<string|int, mixed>
Get random users
getRawProfile()  : mixed
Get raw profile of current user
getRecentVisitors()  : array<string|int, mixed>
Get usersnames online
getSavedSearch()  : array<string|int, mixed>
Get saved search
getSearchCriteria()  : array<string|int, mixed>
Get saved search criteria
getUsers()  : mixed
Get users by attributes
getViews()  : mixed
Get user groups
isOnline()  : bool
Check if a user is online
logActivity()  : true
Log users activity
logView()  : bool
Logs a user view.
resetOnlineUsers()  : bool
Reset online users cache
saveAttributes()  : mixed
Save user attributes
saveProfile()  : mixed
Save user profile
saveSearch()  : mixed
Save search criteria
updateComments()  : mixed
Update user comments count
updateOnlineStatus()  : mixed
Update user online status
userExists()  : bool
Check if user exist
_deleteActivity()  : true
Delete users activity
_deleteImage()  : mixed
Delete user image
_deleteOnlineStatus()  : mixed
Delete users online
_deleteSavedSearch()  : mixed
Delete saved search
_deleteUser()  : bool
Delete user
_getActivity()  : array<string|int, mixed>
Get user's activity
_getCryptedPassword()  : string
Formats a password using the current encryption.
_getOnlineUsers()  : mixed
Get usersnames online
_getProfile()  : mixed
Get user profile
_getRandomUsers()  : array<string|int, mixed>
Get random users
_getRecentVisitors()  : array<string|int, mixed>
Get last visitors
_getSavedSearch()  : array<string|int, mixed>
Get saved search
_getSearchCriteria()  : array<string|int, mixed>
Get saved search criteria
_logActivity()  : true
Log users actions
_logView()  : mixed
Log user view
_saveImage()  : mixed
Store image
_saveProfile()  : mixed
Save basic user profile
_saveSearch()  : mixed
Save search criteria
_updateOnlineStatus()  : mixed
Get usersnames online
_buildWhere()  : array<string|int, mixed>
Build attributes query
_connect()  : bool
Attempts to open a persistent connection to the SQL server.

Properties

$_params

Hash containing connection parameters.

protected array<string|int, mixed> $_params = array()

$_db

Handle for the current database connection.

private DB $_db

$_write_db

Handle for the current database connection, used for writing. Defaults to the same handle as $_db if a separate write database is not required.

private DB $_write_db

Methods

__construct()

Constructs a new SQL storage object.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

A hash containing connection parameters.

Return values
mixed

addUser()

Adds a set of authentication credentials.

public addUser(mixed $user, array<string|int, mixed> $credentials) : bool
Parameters
$user : mixed
$credentials : array<string|int, mixed>

The credentials to use.

Return values
bool

true|PEAR_Error

changePassword()

Change user password

public changePassword(string $password[, string $user = null ]) : mixed
Parameters
$password : string

Plain password

$user : string = null

Username

Return values
mixed

comparePassword()

Compare an encrypted pasword to a plaintext string to see if they match.

public comparePassword(string $user, string $plaintext) : bool
Parameters
$user : string

Username

$plaintext : string

The plaintext pasword to verify.

Return values
bool

True if matched, false otherwise.

countUsers()

Count users by attributes

public countUsers([mixed $criteria = array() ]) : mixed
Parameters
$criteria : mixed = array()
Return values
mixed

deleteActivity()

Delete users activity

public deleteActivity(string $scope, int $date) : true
Parameters
$scope : string

Scope

$date : int

Date

Return values
true

on success

deleteImage()

Delete user image

public deleteImage(string $user) : mixed
Parameters
$user : string

User pricture belongs to

Return values
mixed

deleteOnlineUser()

Remove user if is online

public deleteOnlineUser(mixed $user) : mixed
Parameters
$user : mixed
Return values
mixed

deleteSavedSearch()

Delete saved search

public deleteSavedSearch(string $name) : mixed
Parameters
$name : string

Username

Return values
mixed

deleteUser()

Delete user

public deleteUser(string $user) : bool
Parameters
$user : string

Username

Return values
bool

factory()

Attempts to return a concrete Folks_Driver instance based on $driver.

public factory([string $driver = null ][, array<string|int, mixed> $params = null ]) : Folks_Driver
Parameters
$driver : string = null

The type of the concrete Folks_Driver subclas to return. The clas name is based on the storage driver ($driver). The code is dynamically included.

$params : array<string|int, mixed> = null

A hash containing any additional configuration or connection parameters a subclas might need.

Return values
Folks_Driver

The newly created concrete Folks_Driver instance, or false on an error.

getActivity()

Get user's activity

public getActivity(string $user[, int $limit = 10 ]) : array<string|int, mixed>
Parameters
$user : string

Username

$limit : int = 10

Number of actions to return

Return values
array<string|int, mixed>

Activity log

getAttributes()

Get user attributes

public getAttributes([string $user = null ][, string $group = null ]) : mixed
Parameters
$user : string = null

Username

$group : string = null

Only a specific group

Return values
mixed

getConfirmationCode()

Get confirmation code

public getConfirmationCode(string $user[, string $type = 'activate' ]) : string
Parameters
$user : string

Username to get code for

$type : string = 'activate'

Code type

Return values
string

Confirmation code

getCookie()

Get encripted cookie login string

public getCookie(string $user) : string
Parameters
$user : string

Username to get cookie for

Return values
string

Encripted

getNewUsers()

Get last signed up users

public getNewUsers([mixed $limit = 10 ]) : array<string|int, mixed>
Parameters
$limit : mixed = 10
Return values
array<string|int, mixed>

users online

getOnlineUsers()

Get usersnames online

public getOnlineUsers() : array<string|int, mixed>
Return values
array<string|int, mixed>

users online

getProfile()

Get user profile

public getProfile([string $user = null ]) : mixed
Parameters
$user : string = null

Username

Return values
mixed

getRandomUsers()

Get random users

public getRandomUsers([int $limit = 10 ][, bool $online = true ]) : array<string|int, mixed>
Parameters
$limit : int = 10

Username to check

$online : bool = true

User is online?

Return values
array<string|int, mixed>

users

getRawProfile()

Get raw profile of current user

public getRawProfile(mixed $user) : mixed
Parameters
$user : mixed
Return values
mixed

getRecentVisitors()

Get usersnames online

public getRecentVisitors([mixed $limit = 10 ]) : array<string|int, mixed>
Parameters
$limit : mixed = 10
Return values
array<string|int, mixed>

users online

getSavedSearch()

Get saved search

public getSavedSearch() : array<string|int, mixed>
Return values
array<string|int, mixed>

saved searches

getSearchCriteria()

Get saved search criteria

public getSearchCriteria(string $name) : array<string|int, mixed>
Parameters
$name : string

Username

Return values
array<string|int, mixed>

search criteria

getUsers()

Get users by attributes

public getUsers([mixed $criteria = array() ], mixed $from, mixed $count) : mixed
Parameters
$criteria : mixed = array()
$from : mixed
$count : mixed
Return values
mixed

getViews()

Get user groups

public getViews() : mixed
Return values
mixed

isOnline()

Check if a user is online

public isOnline(string $user) : bool
Parameters
$user : string

Username to check

Return values
bool

logActivity()

Log users activity

public logActivity(string $message[, string $scope = 'folks' ][, string $user = null ]) : true
Parameters
$message : string

Activity message

$scope : string = 'folks'

Scope

$user : string = null

$user

Return values
true

on success

logView()

Logs a user view.

public logView(string $id) : bool
Parameters
$id : string

Username

Return values
bool

True, if the view was logged, false if the mesage was aleredy seen

resetOnlineUsers()

Reset online users cache

public resetOnlineUsers() : bool
Return values
bool

saveAttributes()

Save user attributes

public saveAttributes(array<string|int, mixed> $data, string $group[, string $user = null ]) : mixed
Parameters
$data : array<string|int, mixed>

Attributes data

$group : string

Only a specific group

$user : string = null

Username

Return values
mixed

saveProfile()

Save user profile

public saveProfile(array<string|int, mixed> $data[, string $user = null ]) : mixed
Parameters
$data : array<string|int, mixed>

Profile data

$user : string = null

Username

Return values
mixed

saveSearch()

Save search criteria

public saveSearch(string $criteria, string $name) : mixed
Parameters
$criteria : string

Search criteria

$name : string

Search name

Return values
mixed

updateComments()

Update user comments count

public updateComments(string $user[, mixed $reset = false ]) : mixed
Parameters
$user : string

Username

$reset : mixed = false
Return values
mixed

updateOnlineStatus()

Update user online status

public updateOnlineStatus() : mixed
Return values
mixed

userExists()

Check if user exist

public userExists(string $user) : bool
Parameters
$user : string

Username

Return values
bool

_deleteActivity()

Delete users activity

protected _deleteActivity(string $scope, int $date, string $user) : true
Parameters
$scope : string

Scope

$date : int

Date

$user : string

Username

Return values
true

on success

_deleteImage()

Delete user image

protected _deleteImage(string $user) : mixed
Parameters
$user : string

Username

Return values
mixed

_deleteOnlineStatus()

Delete users online

protected _deleteOnlineStatus(mixed $to) : mixed
Parameters
$to : mixed
Return values
mixed

_deleteSavedSearch()

Delete saved search

protected _deleteSavedSearch(string $name) : mixed
Parameters
$name : string

Username

Return values
mixed

_deleteUser()

Delete user

protected _deleteUser(string $user) : bool
Parameters
$user : string

Username

Return values
bool

_getActivity()

Get user's activity

protected _getActivity(string $user, mixed $limit) : array<string|int, mixed>
Parameters
$user : string

Username

$limit : mixed
Return values
array<string|int, mixed>

Activity log

_getCryptedPassword()

Formats a password using the current encryption.

protected _getCryptedPassword(string $user) : string
Parameters
$user : string

User we are getting password for

Return values
string

The encrypted password.

_getOnlineUsers()

Get usersnames online

protected _getOnlineUsers() : mixed
Return values
mixed

_getProfile()

Get user profile

protected _getProfile(string $user) : mixed
Parameters
$user : string

Username

Return values
mixed

_getRandomUsers()

Get random users

protected _getRandomUsers([int $limit = 10 ][, bool $online = false ]) : array<string|int, mixed>
Parameters
$limit : int = 10

Username to check

$online : bool = false

User is online?

Return values
array<string|int, mixed>

users

_getRecentVisitors()

Get last visitors

protected _getRecentVisitors([int $limit = 10 ]) : array<string|int, mixed>
Parameters
$limit : int = 10

Username to check

Return values
array<string|int, mixed>

users

_getSavedSearch()

Get saved search

protected _getSavedSearch() : array<string|int, mixed>
Return values
array<string|int, mixed>

saved searches

_getSearchCriteria()

Get saved search criteria

protected _getSearchCriteria(string $name) : array<string|int, mixed>
Parameters
$name : string

Username

Return values
array<string|int, mixed>

search criteria

_logActivity()

Log users actions

protected _logActivity(string $message, string $scope, string $user) : true
Parameters
$message : string

Log message

$scope : string

Scope

$user : string

Username

Return values
true

on success

_logView()

Log user view

protected _logView(mixed $id) : mixed
Parameters
$id : mixed
Return values
mixed

_saveImage()

Store image

protected _saveImage(string $file, string $user) : mixed
Parameters
$file : string

Image file

$user : string

User pricture belongs to

Return values
mixed

_saveProfile()

Save basic user profile

protected _saveProfile(array<string|int, mixed> $data, string $user) : mixed
Parameters
$data : array<string|int, mixed>

A hash containing profile data

$user : string

Username

Return values
mixed

_saveSearch()

Save search criteria

protected _saveSearch(string $criteria, string $name) : mixed
Parameters
$criteria : string

Search criteria

$name : string

Search name

Return values
mixed

_updateOnlineStatus()

Get usersnames online

protected _updateOnlineStatus() : mixed
Return values
mixed

_buildWhere()

Build attributes query

private _buildWhere([mixed $criteria = array() ]) : array<string|int, mixed>
Parameters
$criteria : mixed = array()
Return values
array<string|int, mixed>

An array containing sql statement and parameters

_connect()

Attempts to open a persistent connection to the SQL server.

private _connect() : bool
Tags
throws
Horde_Exception
Return values
bool

True on success.

Search results