CMS Made Simple API

page.functions.php

Page related functions. Generally these are functions not necessarily related to content, but more to the underlying mechanisms of the system.

Tags
license

GPL

Table of Contents

Functions

get_userid()  : int
Gets the userid of the currently logged in user.
get_username()  : string
Gets the username of the currently logged in user.
check_login()  : bool
Checks to see if the user is logged in and the request has the proper key. If not, redirects the browser to the admin login.
check_permission()  : bool
Checks to see that the given userid has access to the given permission.
audit()  : void
Put an event into the audit (admin) log. This should be done on most admin events for consistency.
get_site_preference()  : mixed
Gets the given site prefernce
remove_site_preference()  : void
Removes the given site preference
set_site_preference()  : void
Sets the given site perference with the given value.
locale_ftime()  : string
Replacement for deprecated strftime function

Functions

get_userid()

Gets the userid of the currently logged in user.

get_userid([bool $redirect = true ]) : int

If an effective uid has been set in the session, AND the primary user is a member of the admin group then allow emulating that effective uid.

Parameters
$redirect : bool = true

Redirect to the admin login page if the user is not logged in.

Tags
since
0.1
Return values
int

The UID of the logged in administrator, otherwise FALSE

get_username()

Gets the username of the currently logged in user.

get_username([bool $check = true ]) : string

If an effective username has been set in the session, AND the primary user is a member of the admin group then return the effective username.

Parameters
$check : bool = true

Redirect to the admin login page if the user is not logged in.

Tags
since
2.0
Return values
string

the username of the logged in user.

check_login()

Checks to see if the user is logged in and the request has the proper key. If not, redirects the browser to the admin login.

check_login([string $no_redirect = false ]) : bool

Note: Because this method validates that the secret key is in the URL and matches the one that is in the session this method should only be called from admin actions.

Parameters
$no_redirect : string = false

If true, then don't redirect if not logged in

Tags
since
0.1
Return values
bool

check_permission()

Checks to see that the given userid has access to the given permission.

check_permission(int $userid, string $permname) : bool

Members of the admin group have all permissions.

Parameters
$userid : int

The user id

$permname : string

The permission name

Tags
since
0.1
Return values
bool

audit()

Put an event into the audit (admin) log. This should be done on most admin events for consistency.

audit(int $itemid, string $itemname, string $action) : void
Parameters
$itemid : int

The item id (perhaps a content id, or a record id from a module)

$itemname : string

The item name (perhaps Content, or the module name)

$action : string

The action that needs to be audited

Tags
since
0.3

get_site_preference()

Gets the given site prefernce

get_site_preference(string $prefname[, mixed $defaultvalue = '' ]) : mixed
Parameters
$prefname : string

The preference name

$defaultvalue : mixed = ''

The default value if the preference does not exist

Tags
since
0.6
see
cms_siteprefs::get

remove_site_preference()

Removes the given site preference

remove_site_preference(string $prefname[, bool $uselike = false ]) : void
Parameters
$prefname : string

Preference name to remove

$uselike : bool = false

Wether or not to remove all preferences that are LIKE the supplied name

Tags
see
cms_siteprefs::remove

set_site_preference()

Sets the given site perference with the given value.

set_site_preference(string $prefname, mixed $value) : void
Parameters
$prefname : string

The preference name

$value : mixed

The preference value (will be stored as a string)

Tags
see
cms_siteprefs::set
since
0.6

locale_ftime()

Replacement for deprecated strftime function

locale_ftime(string $format[, mixed $datevar = null ]) : string
Parameters
$format : string

strftime()- and/or date()-compatible format specifier

$datevar : mixed = null

timestamp | date-time-string | DateTime object | empty to use time() value

Tags
since
2.2.16
Return values
string

        
On this page

Search results