Methods summary
public
|
#
__construct( mixed $filename )
Constructor to set up the data source
Constructor to set up the data source
|
public
string
|
#
getSourceType( )
Get source type
Returns
string The data source type.
Implementation of
|
public
array|boolean
|
#
getUserByName( string $username )
Get array of users that match a given name.
Get array of users that match a given name.
Parameters
- $username
string $username The username to search for in the data source.
Returns
array|boolean An array of arrays containing user elements to create a user or FALSE if not
found.
Implementation of
|
public
array
|
#
getUsernames( )
Get a list of usernames
Returns
array An array of strings containing the usernames from the data source.
Implementation of
|
public
boolean
|
#
saveUser( array $user )
Save the provided user details in the data source.
Save the provided user details in the data source.
Parameters
- $user
array $user An array of user elements to be saved.
Returns
boolean Returns TRUE on success and FALSE on failure.
Implementation of
|
public
boolean
|
#
deleteUser( string $username )
Delete the specified user from the data source.
Delete the specified user from the data source.
Parameters
- $username
string $username The username of the user to delete.
Returns
boolean Returns TRUE on success and FALSE on failure.
Implementation of
|
private
integer|boolean
|
#
searchUsersForUser( array $users, mixed $username )
Search provided users array for the specified user.
Search provided users array for the specified user.
Parameters
- $users
array $users An array of user rows to search.
- $username
Returns
integer|boolean The array index for the user name or FALSE if not found.
|
public
array
|
#
readJSONFile( string $filename = NULL )
Read a JSON formatted file using the file locking mechanism and return as an
associative array
Read a JSON formatted file using the file locking mechanism and return as an
associative array
Parameters
- $filename
string $filename Optional filename of the JSON file to write. If not specified then the
objects filename setting will be used.
Returns
array | boolean An associative array or FALSE on failure.
|
public
boolean
|
#
writeJSONFile( array $data, string $filename = NULL )
Write a JSON formatted file using the file locking mechanism. The provided
data array or object element will be used for the file contents.
Write a JSON formatted file using the file locking mechanism. The provided
data array or object element will be used for the file contents.
Parameters
- $data
array | object $data An associative array or object to convert to JSON.
- $filename
string $filename Optional filename of the JSON file to write. If not specified then the
objects filename setting will be used.
Returns
boolean TRUE on success, FALSE on failure.
|
public
boolean
|
#
lockFile( BSN\CryptUser\CryptJSONSource::$filename $filename, createIfNotExist $createIfNotExist = TRUE )
Open and lock a file for both read and write operations.
Open and lock a file for both read and write operations.
Parameters
Returns
boolean Open status.
Throws
Exception If cannot get lock on file for any reason.
|
public
string
|
#
lockedRead( BSN\CryptUser\CryptJSONSource::$filename $filename, createIfNotExist $createIfNotExist = TRUE )
Read file with lock.
Parameters
Returns
string or boolean Returns file contents in a string or FALSE on failure.
Throws
Exception If for any reason the file is not locked.
|
public
boolean
|
#
lockedWrite( string $filename, string $buffer, boolean $createIfNotExist = TRUE )
Write buffer to file with lock
Write buffer to file with lock
Parameters
- $filename
string $filename The filename to write.
- $buffer
string $buffer The buffer to write to the file.
- $createIfNotExist
boolean $createIfNotExist Optional, specifies if the file should be created if it does
not already exist.
Returns
boolean FALSE if write fails
Throws
Exception If for any reason the file is not locked.
|
public
|
#
__wakeup( )
The magic __wakeup() function is used to clean up the file pointers when the
object is unserialized.
The magic __wakeup() function is used to clean up the file pointers when the
object is unserialized.
|