Chyrp

User

The User model.

See Also

Model

Summary
User The User model.
Functions
__construct Model::grab
find Model::search
authenticate Checks to see if a given Login and Password match a user in the database.
add Adds a user to the database with the passed username, password, and e-mail.
update Updates the user with the given login, password, full name, e-mail, website, and Group ID.
delete Deletes a given user.  Calls the “delete_user” trigger and passes the User as an argument.
group Returns a user’s group.  Example: $user->group()->can(“do_something”)
posts Returns all the posts of the user.
pages Returns all the pages of the user.
edit_link Outputs an edit link for the user, if they can edit_user.
delete_link Outputs an delete link for the user, if they can delete_user.

Functions

__construct

public function __construct( $user_id,   
$options  =  array() )

See Also

Model::grab

find

static function find( $options  =  array(),
$options_for_object  =  array() )

See Also

Model::search

authenticate

static function authenticate( $login,
$password )

Checks to see if a given Login and Password match a user in the database.

Parameters

$login The Login to check.
$password The matching Password to check.

Returns

true if a match is found.

add

static function add( $login,   
$password,   
$email,   
$full_name  =  "",
$website  =  "",
$joined_at  =  null,
$group_id  =  null )

Adds a user to the database with the passed username, password, and e-mail.

Calls the add_user trigger with the inserted ID.

Parameters

$login The Login for the new user.
$password The Password for the new user.  Don’t MD5 this, it’s done in the function.
$email The E-Mail for the new user.

Returns

$id The newly created users ID.

See Also

update

update

public function update( $login,
$password,
$email,
$full_name,
$website,
$group_id )

Updates the user with the given login, password, full name, e-mail, website, and Group ID.

Passes all of the arguments to the update_user trigger.

Parameters

$login The new Login to set.
$password The new Password to set.
$full_name The new Full Name to set.
$email The new E-Mail to set.
$website The new Website to set.
$group_id The new Group to set.

See Also

add

delete

static function delete( $id )

Deletes a given user.  Calls the “delete_user” trigger and passes the User as an argument.

Parameters

$id The user to delete.

group

public function group()

Returns a user’s group.  Example: $user->group()->can(“do_something”)

posts

public function posts()

Returns all the posts of the user.

pages

public function pages()

Returns all the pages of the user.

edit_link

public function edit_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs an edit link for the user, if they can edit_user.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.

delete_link

public function delete_link( $text  =  null,
$before  =  null,
$after  =  null )

Outputs an delete link for the user, if they can delete_user.

Parameters

$text The text to show for the link.
$before If the link can be shown, show this before it.
$after If the link can be shown, show this after it.