\midcom_connection

Wrapper for Midgard-related functionality

Summary

Methods
Properties
Constants
setup()
is_connected()
set_loglevel()
set_error()
get_error()
get_error_string()
login()
verify_password()
prepare_password()
is_user()
get_user()
is_admin()
logout()
get()
get_schema_types()
get_url()
get_unique_host_name()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
_get()
_parse_url()
$_data
N/A

Properties

$_data

$_data : array

Private cache for connection information

Type

array

Methods

setup()

setup(string  $basedir = null) : boolean

DB connection setup routine

Parameters

string $basedir

The directory to look for config files if necessary

Throws

\Exception

We use regular exceptions here, because this might run before things are properly set up

Returns

boolean —

Indicating success

is_connected()

is_connected() : boolean

Check whether Midgard database connection exists

Returns

boolean

set_loglevel()

set_loglevel(string  $loglevel) 

Set Midgard log level

Parameters

string $loglevel

Midgard log level

set_error()

set_error(integer  $errorcode) 

Set Midgard error code

Parameters

integer $errorcode

Midgard error code

get_error()

get_error() : integer

Get Midgard error code

Returns

integer —

Midgard error code

get_error_string()

get_error_string() : string

Get Midgard error message

Returns

string —

Midgard error message

login()

login(string  $username, string  $password, boolean  $trusted = false) : boolean|\midgard_user

Perform a login against the midgard backend

Parameters

string $username

The username as entered

string $password

The password as entered

boolean $trusted

Use trusted auth

Returns

boolean|\midgard_user —

The appropriate object or false

verify_password()

verify_password(  $password,   $hash) 

Parameters

$password
$hash

prepare_password()

prepare_password(  $password) 

Parameters

$password

is_user()

is_user(  $person) 

Parameters

$person

get_user()

get_user() : integer

Get current Midgard user

Returns

integer —

The current user ID

is_admin()

is_admin() : boolean

Check if the current user is admin

Returns

boolean —

True or false

logout()

logout() 

Logout the current user, if any

get()

get(string  $key) : mixed

Getter for various environment-related variables.

Parameters

string $key

The key to look up

Returns

mixed —

The found value or null

get_schema_types()

get_schema_types() : array

Lists all available MgdSchema types

Returns

array —

A list of class names

get_url()

get_url(  $key) : mixed

Get various pieces of information extracted from the URL

Parameters

$key

Returns

mixed —

The data for the requested key or false if it doesn't exist

get_unique_host_name()

get_unique_host_name() 

_get()

_get(  $key) 

Parameters

$key

_parse_url()

_parse_url(string  $uri, string  $self, string  $prefix) 

Enables themes to have subdirectories (which have a similar effect to mgd1 pages)

Parameters

string $uri

The request path

string $self

The instance's root URL

string $prefix

The root URL's prefix, if any (corresponds to mgd1 host)