Overview

Namespaces

  • Sleepy
  • Module
    • Authentication
    • CSV
    • DB
    • FormBuilder
    • FSDB
    • IP2Country
    • Mailer
    • MobiDetect
    • Navigation
    • StaticCache
  • PHP

Classes

  • Permission
  • Role
  • User
  • UserMeta
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class User

Example of using the User module

if (class_exists('User')) {
        // Try to login
        try {
            $u = new \Module\Authentication\User();

            // check if the admin user exists
            $uid = $u->authenticate('developer@envivent.com', 'test');

            echo "Authentication successful. User ID is ", $uid;
        } catch (\Exception $e) {
            // Admin uses doesn't exist. Let's create it.
            $u->columns['role_id'] = 1;
            $u->columns['email'] = 'developer@envivent.com';
            $u->columns['password'] = $u->saltPassword('test');
            $u->save();
        }
    }
Module\DB\Record
Extended by Module\Authentication\User
Namespace: Module\Authentication
Located at class.user.php
Methods summary
public integer
# authenticate( string $email, string $pass )

Authenticates a user

Authenticates a user

Parameters

$email
The username
$pass
The password

Returns

integer
The user_id
public string
# hasPermission( string $key )

Gets the permission for their role

Gets the permission for their role

Parameters

$key
What role do you want to query?

Returns

string
the value associated with the permission e.g. True, False, etc.
public mixed
# getUserData( string $key )

Gets the data associated with the user

Gets the data associated with the user

Parameters

$key
The data you want to lookup

Returns

mixed
The data associated with the key
public
# load( integer $id = 0 )

Loads the user

Loads the user

Parameters

$id
The user ID

Overrides

Module\DB\Record::load()
public
# setUserData( string $key, mixed $value )

Sets user data by a key

Sets user data by a key

Parameters

$key
The key to store the data into
$value
The data to store at the key
public string
# saltPassword( string $pass )

Salts the password

Salts the password

Parameters

$pass
The password

Returns

string
The encrypted password
public
# save( )

Saves the user

Saves the user

Overrides

Module\DB\Record::save()
public boolean
# isLoaded( )

Checks if a user is loaded

Checks if a user is loaded

Returns

boolean
True, if loaded
public boolean
# isLoggedIn( )

Checks if a user is logged in

Checks if a user is logged in

Returns

boolean
True, if logged in
public boolean
# isAdmin( )

Checks if a user is an admin (role_id == 1)

Checks if a user is an admin (role_id == 1)

Returns

boolean
True, if role_id == 1
public string
# getRole( )

Gets the name of the role of the user

Gets the name of the role of the user

Returns

string
The role
Methods inherited from Module\DB\Record
__construct(), delete(), form()
Properties summary
public string $table

The name of the users table

The name of the users table

# 'users'
public mixed $metadata

The meta data for the table, e.g. fields and field data

The meta data for the table, e.g. fields and field data

#
private Module\Authentication\Role $role

The users Role

The users Role

#
private string $salt

The salt for password encryption

The salt for password encryption

# 'o_PXO=1-BCTkq>|>*}KmkM8CA-!x|J6Y/UyDJC#ph(*A6me>CJ1Uu8E7gye|Vek['
Properties inherited from Module\DB\Record
$columns, $db, $meta, $primaryKey
sleepyMUSTACHE v.0.8 API documentation generated by ApiGen