Documentation

functions.php

Table of Contents

Classes

JarsUser

Functions

comment()  : mixed
is_logged_in()  : userid
global function for checking whether user is logged in or not.
check_logged_in()  : mixed
checks whether user is logged in. If not redirects to the login page (index)
is_logged_in_admin()  : mixed
msg_redirect()  : mixed
check_user()  : mixed
If user isn't valid for given level (or 4), this will redirect to main.
check_user_main()  : mixed
Returns current users usermode.
check_superuser()  : mixed
inpostvalue()  : string
check whether a value is in $_POST and return the value or an empty string
datediff()  : mixed
jars_insert()  : int
jars_insert
jars_error()  : mixed
add_date()  : mixed
getHolidays()  : mixed
getHolidays creates a list of bank holidays we should actually use the official govt file from gov.uk/bank_hoidays.json
external_cmd()  : mixed
sendIcalEvent()  : mixed
pagelist()  : string
Creates a string containing a list of links to pages
IsReal()  : true
Determine if a mysql column type requires left alignment
get_sig()  : img
Little function to create an img element with a signature if the signature img exists - tries using initals as-is, of not, then using lowercase - TODO take userid and use numerical sig file
base32_encode()  : string
Base32 encode for use in 2fa
make_radio()  : mixed
make_radio create entry for radio button
icon()  : mixed
searchform()  : mixed
display a search form requires the action module to have a 'do_search' action
showPageList()  : mixed
date_adjust()  : mixed
little function to return the date offset for the friday of the specified week replaces the switch/case statements used widely in pre-mp code
debugPost()  : mixed
display_message()  : mixed
TblCheckbox()  : mixed
Table Checkbox.
two_dp()  : mixed
printDayHeaders()  : mixed

Functions

comment()

comment(mixed $data) : mixed
Parameters
$data : mixed

is_logged_in()

global function for checking whether user is logged in or not.

is_logged_in() : userid

you will notice we will use it everwhere in the script. NB checks against database password, which therefore must have been sync'd to LDAP

Return values
userid

or 0 if not logged in also adds usermode, fullname to $USR object

  • perms 2025-01-19

check_logged_in()

checks whether user is logged in. If not redirects to the login page (index)

check_logged_in() : mixed

@return userid if logged in

is_logged_in_admin()

is_logged_in_admin(mixed $admin) : mixed
Parameters
$admin : mixed

msg_redirect()

msg_redirect(mixed $msg, mixed $url, mixed $seconds) : mixed
Parameters
$msg : mixed
$url : mixed
$seconds : mixed

check_user()

If user isn't valid for given level (or 4), this will redirect to main.

check_user(mixed $user[, mixed $value = 4 ]) : mixed
Parameters
$user : mixed
$value : mixed = 4

check_user_main()

Returns current users usermode.

check_user_main() : mixed

deprecated - just use glocal $USR->mode

check_superuser()

check_superuser(mixed $userid) : mixed
Parameters
$userid : mixed

inpostvalue()

check whether a value is in $_POST and return the value or an empty string

inpostvalue(string $key) : string
Parameters
$key : string
Return values
string

value from _POST or blank if it doesn't exist

datediff()

datediff(mixed $interval, mixed $datefrom, mixed $dateto[, mixed $using_timestamps = false ]) : mixed
Parameters
$interval : mixed
$datefrom : mixed
$dateto : mixed
$using_timestamps : mixed = false

jars_insert()

jars_insert

jars_insert(string $qry[, string $redirect = '' ][, mixed $sent_id = 0 ]) : int
Parameters
$qry : string

is a query to be performed should not provide a result set: suited to updates and inserts

$redirect : string = ''

gives a URL to deirect to after performing the query

$sent_id : mixed = 0
Return values
int

last insert id if not redirected

jars_error()

jars_error(mixed $errortext, mixed $redirect) : mixed
Parameters
$errortext : mixed
$redirect : mixed

add_date()

add_date(mixed $givendate[, mixed $day = 0 ][, mixed $mth = 0 ][, mixed $yr = 0 ]) : mixed
Parameters
$givendate : mixed
$day : mixed = 0
$mth : mixed = 0
$yr : mixed = 0

getHolidays()

getHolidays creates a list of bank holidays we should actually use the official govt file from gov.uk/bank_hoidays.json

getHolidays([mixed $year = null ]) : mixed
Parameters
$year : mixed = null

external_cmd()

external_cmd(mixed $ext_cmd, mixed $ext_arg) : mixed
Parameters
$ext_cmd : mixed
$ext_arg : mixed

sendIcalEvent()

sendIcalEvent(mixed $email_message, mixed $headers, mixed $to_name, mixed $to_address, mixed $startTime, mixed $endTime, mixed $subject, mixed $description, mixed $location) : mixed
Parameters
$email_message : mixed
$headers : mixed
$to_name : mixed
$to_address : mixed
$startTime : mixed
$endTime : mixed
$subject : mixed
$description : mixed
$location : mixed

pagelist()

Creates a string containing a list of links to pages

pagelist(int $totpages, int $currentpage, string $actionstring) : string
Parameters
$totpages : int

often like ceil($totalrows/$users_per_page)

$currentpage : int
$actionstring : string

eg action=ListUsers

Return values
string

IsReal()

Determine if a mysql column type requires left alignment

IsReal(mixed $x) : true
Parameters
$x : mixed

may be string or integer depending on mysql version

Return values
true

if its for example a real and wants to be right formatted

get_sig()

Little function to create an img element with a signature if the signature img exists - tries using initals as-is, of not, then using lowercase - TODO take userid and use numerical sig file

get_sig(string $initials[, mixed $path = "../admin/sigs" ]) : img
Parameters
$initials : string
$path : mixed = "../admin/sigs"
Return values
img

element for signature image

base32_encode()

Base32 encode for use in 2fa

base32_encode(string $data) : string
Parameters
$data : string
Return values
string

encode data

make_radio()

make_radio create entry for radio button

make_radio(mixed $fieldname, mixed $key, mixed $text, mixed $val) : mixed
Parameters
$fieldname : mixed
$key : mixed
$text : mixed
$val : mixed

icon()

icon(mixed $name[, mixed $class = "icon" ]) : mixed
Parameters
$name : mixed
$class : mixed = "icon"

searchform()

display a search form requires the action module to have a 'do_search' action

searchform(mixed $action[, mixed $value = '' ][, mixed $width = '40em' ][, mixed $method = 'POST' ]) : mixed
Parameters
$action : mixed
$value : mixed = ''
$width : mixed = '40em'
$method : mixed = 'POST'

showPageList()

showPageList(mixed $currentPage, mixed $totalPages[, mixed $extraParms = '' ]) : mixed
Parameters
$currentPage : mixed
$totalPages : mixed
$extraParms : mixed = ''

date_adjust()

little function to return the date offset for the friday of the specified week replaces the switch/case statements used widely in pre-mp code

date_adjust(mixed $weekdiff) : mixed
Parameters
$weekdiff : mixed

display_message()

display_message() : mixed

TblCheckbox()

Table Checkbox.

TblCheckbox(mixed $field[, mixed $ttl = '' ][, mixed $indent = " " ]) : mixed

Converts a boolean/tinyint to display as a readonly checkbox

Parameters
$field : mixed

number field value @return null

$ttl : mixed = ''
$indent : mixed = " "

two_dp()

two_dp(mixed $num[, mixed $empty = '' ]) : mixed
Parameters
$num : mixed
$empty : mixed = ''

printDayHeaders()

printDayHeaders(mixed $datestring[, mixed $class = 'dayhead' ][, mixed $style = '' ]) : mixed
Parameters
$datestring : mixed
$class : mixed = 'dayhead'
$style : mixed = ''

        
On this page

Search results