\Folks_Driver_sql

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.

Summary

Methods
Properties
Constants
factory()
deleteImage()
getOnlineUsers()
resetOnlineUsers()
getRecentVisitors()
getNewUsers()
getRandomUsers()
isOnline()
updateOnlineStatus()
getRawProfile()
getProfile()
changePassword()
saveProfile()
logView()
deleteUser()
getAttributes()
saveAttributes()
comparePassword()
getCookie()
getConfirmationCode()
saveSearch()
getSavedSearch()
getSearchCriteria()
deleteSavedSearch()
logActivity()
getActivity()
deleteActivity()
__construct()
deleteOnlineUser()
getUsers()
countUsers()
updateComments()
getViews()
userExists()
addUser()
No public properties found
No constants found
_saveImage()
_getOnlineUsers()
_getRecentVisitors()
_getRandomUsers()
_updateOnlineStatus()
_deleteOnlineStatus()
_getCryptedPassword()
_getProfile()
_saveProfile()
_deleteImage()
_logView()
_deleteUser()
_saveSearch()
_getSavedSearch()
_getSearchCriteria()
_deleteSavedSearch()
_logActivity()
_getActivity()
_deleteActivity()
$_params
N/A
_buildWhere()
_connect()
$_db
$_write_db
N/A

Properties

$_params

$_params : array

Hash containing connection parameters.

Type

array

$_db

$_db : \DB

Handle for the current database connection.

Type

\DB

$_write_db

$_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.

Type

\DB

Methods

factory()

factory(string  $driver = null, array  $params = null) : \Folks_Driver

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

Parameters

string $driver

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.

array $params

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

Returns

\Folks_Driver

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

deleteImage()

deleteImage(string  $user) 

Delete user image

Parameters

string $user

User pricture belongs to

getOnlineUsers()

getOnlineUsers() : array

Get usersnames online

Returns

array —

users online

resetOnlineUsers()

resetOnlineUsers() : boolean

Reset online users cache

Returns

boolean

getRecentVisitors()

getRecentVisitors(  $limit = 10) : array

Get usersnames online

Parameters

$limit

Returns

array —

users online

getNewUsers()

getNewUsers(  $limit = 10) : array

Get last signed up users

Parameters

$limit

Returns

array —

users online

getRandomUsers()

getRandomUsers(integer  $limit = 10, boolean  $online = true) : array

Get random users

Parameters

integer $limit

Username to check

boolean $online

User is online?

Returns

array —

users

isOnline()

isOnline(string  $user) : boolean

Check if a user is online

Parameters

string $user

Username to check

Returns

boolean

updateOnlineStatus()

updateOnlineStatus() 

Update user online status

getRawProfile()

getRawProfile(  $user) 

Get raw profile of current user

Parameters

$user

getProfile()

getProfile(string  $user = null) 

Get user profile

Parameters

string $user

Username

changePassword()

changePassword(string  $password, string  $user = null) 

Change user password

Parameters

string $password

Plain password

string $user

Username

saveProfile()

saveProfile(array  $data, string  $user = null) 

Save user profile

Parameters

array $data

Profile data

string $user

Username

logView()

logView(string  $id) : boolean

Logs a user view.

Parameters

string $id

Username

Returns

boolean —

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

deleteUser()

deleteUser(string  $user) : boolean

Delete user

Parameters

string $user

Username

Returns

boolean

getAttributes()

getAttributes(string  $user = null, string  $group = null) 

Get user attributes

Parameters

string $user

Username

string $group

Only a specific group

saveAttributes()

saveAttributes(array  $data, string  $group, string  $user = null) 

Save user attributes

Parameters

array $data

Attributes data

string $group

Only a specific group

string $user

Username

comparePassword()

comparePassword(string  $user, string  $plaintext) : boolean

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

Parameters

string $user

Username

string $plaintext

The plaintext pasword to verify.

Returns

boolean —

True if matched, false otherwise.

getCookie()

getCookie(string  $user) : string

Get encripted cookie login string

Parameters

string $user

Username to get cookie for

Returns

string —

Encripted

getConfirmationCode()

getConfirmationCode(string  $user, string  $type = 'activate') : string

Get confirmation code

Parameters

string $user

Username to get code for

string $type

Code type

Returns

string —

Confirmation code

saveSearch()

saveSearch(string  $criteria, string  $name) 

Save search criteria

Parameters

string $criteria

Search criteria

string $name

Search name

getSavedSearch()

getSavedSearch() : array

Get saved search

Returns

array —

saved searches

getSearchCriteria()

getSearchCriteria(string  $name) : array

Get saved search criteria

Parameters

string $name

Username

Returns

array —

search criteria

deleteSavedSearch()

deleteSavedSearch(string  $name) 

Delete saved search

Parameters

string $name

Username

logActivity()

logActivity(string  $message, string  $scope = 'folks', string  $user = null) : true

Log users activity

Parameters

string $message

Activity message

string $scope

Scope

string $user

$user

Returns

true —

on success

getActivity()

getActivity(string  $user, integer  $limit = 10) : array

Get user's activity

Parameters

string $user

Username

integer $limit

Number of actions to return

Returns

array —

Activity log

deleteActivity()

deleteActivity(string  $scope, integer  $date) : true

Delete users activity

Parameters

string $scope

Scope

integer $date

Date

Returns

true —

on success

__construct()

__construct(array  $params = array()) 

Constructs a new SQL storage object.

Parameters

array $params

A hash containing connection parameters.

deleteOnlineUser()

deleteOnlineUser(  $user) 

Remove user if is online

Parameters

$user

getUsers()

getUsers(  $criteria = array(),   $from,   $count) 

Get users by attributes

Parameters

$criteria
$from
$count

countUsers()

countUsers(  $criteria = array()) 

Count users by attributes

Parameters

$criteria

updateComments()

updateComments(string  $user,   $reset = false) 

Update user comments count

Parameters

string $user

Username

$reset

getViews()

getViews() 

Get user groups

userExists()

userExists(string  $user) : boolean

Check if user exist

Parameters

string $user

Username

Returns

boolean

addUser()

addUser(  $user, array  $credentials) : boolean

Adds a set of authentication credentials.

Parameters

$user
array $credentials

The credentials to use.

Returns

boolean —

true|PEAR_Error

_saveImage()

_saveImage(string  $file, string  $user) 

Store image

Parameters

string $file

Image file

string $user

User pricture belongs to

_getOnlineUsers()

_getOnlineUsers() 

Get usersnames online

_getRecentVisitors()

_getRecentVisitors(integer  $limit = 10) : array

Get last visitors

Parameters

integer $limit

Username to check

Returns

array —

users

_getRandomUsers()

_getRandomUsers(integer  $limit = 10, boolean  $online = false) : array

Get random users

Parameters

integer $limit

Username to check

boolean $online

User is online?

Returns

array —

users

_updateOnlineStatus()

_updateOnlineStatus() 

Get usersnames online

_deleteOnlineStatus()

_deleteOnlineStatus(  $to) 

Delete users online

Parameters

$to

_getCryptedPassword()

_getCryptedPassword(string  $user) : string

Formats a password using the current encryption.

Parameters

string $user

User we are getting password for

Returns

string —

The encrypted password.

_getProfile()

_getProfile(string  $user) 

Get user profile

Parameters

string $user

Username

_saveProfile()

_saveProfile(array  $data, string  $user) 

Save basic user profile

Parameters

array $data

A hash containing profile data

string $user

Username

_deleteImage()

_deleteImage(string  $user) 

Delete user image

Parameters

string $user

Username

_logView()

_logView(  $id) 

Log user view

Parameters

$id

_deleteUser()

_deleteUser(string  $user) : boolean

Delete user

Parameters

string $user

Username

Returns

boolean

_saveSearch()

_saveSearch(string  $criteria, string  $name) 

Save search criteria

Parameters

string $criteria

Search criteria

string $name

Search name

_getSavedSearch()

_getSavedSearch() : array

Get saved search

Returns

array —

saved searches

_getSearchCriteria()

_getSearchCriteria(string  $name) : array

Get saved search criteria

Parameters

string $name

Username

Returns

array —

search criteria

_deleteSavedSearch()

_deleteSavedSearch(string  $name) 

Delete saved search

Parameters

string $name

Username

_logActivity()

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

Log users actions

Parameters

string $message

Log message

string $scope

Scope

string $user

Username

Returns

true —

on success

_getActivity()

_getActivity(string  $user,   $limit) : array

Get user's activity

Parameters

string $user

Username

$limit

Returns

array —

Activity log

_deleteActivity()

_deleteActivity(string  $scope, integer  $date, string  $user) : true

Delete users activity

Parameters

string $scope

Scope

integer $date

Date

string $user

Username

Returns

true —

on success

_buildWhere()

_buildWhere(  $criteria = array()) : array

Build attributes query

Parameters

$criteria

Returns

array —

An array containing sql statement and parameters

_connect()

_connect() : boolean

Attempts to open a persistent connection to the SQL server.

Throws

\Horde_Exception

Returns

boolean —

True on success.