Documentation

Page extends SimpleModel
in package
Uses FWEdit, HandleRole, MakeGuard

A class implementing a RedBean model for Page beans

Tags
psalm-suppress

UnusedClass

Table of Contents

$editfields  : array<, mixed>
$roletype  : string
add()  : OODBBean
Add a Page
addrole()  : OODBBean
Add a role
addRoleByBean()  : OODBBean
Add a role
check()  : void
Check user can access the page - does not return if they cannot
checkrole()  : array<, mixed>
Check that user has one of a set of roles
delrole()  : void
Delete a role
edit()  : array<, mixed>
Handle an edit form for this page
editroles()  : void
Deal with the role selecting part of a form
guard()  : string
Return the CSRFGuard inputs for inclusion in a form;
hasrole()  : object|null
Check for a role
hasRoleByBean()  : object|null
Check for a role by bean
roles()  : array<, OODBBean>
Get all currently valid roles for this bean
startEdit()  : void
Setup for an edit
update()  : void
Function called when a page bean is updated - do error checking in here
dofields()  : array<, string>
Handle editing of beans
maketwig()  : void
Make a twig file if we have permission

Properties

$editfields

private static array<, mixed> $editfields = ['name' => [TRUE, FALSE], 'kind' => [TRUE, FALSE], 'source' => [TRUE, FALSE], 'active' => [TRUE, TRUE], 'mobileonly' => [TRUE, TRUE], 'needlogin' => [TRUE, TRUE], 'needajax' => [TRUE, TRUE], 'needfwutils' => [TRUE, TRUE], 'needparsley' => [TRUE, TRUE], 'neededitable' => [TRUE, TRUE]]

Key is name of field and the array contains flags for checkboxes

Tags
phpcsSuppress

SlevomatCodingStandard.Classes.UnusedPrivateElements

$roletype

private string $roletype = ConfigFramework::PAGEROLE

The type of the bean that stores roles for this page

Tags
phpcsSuppress

SlevomatCodingStandard.Classes.UnusedPrivateElements

Methods

add()

Add a Page

public static add(Context $context) : OODBBean

This will be called from ajax.php

Parameters
$context : Context

The context object for the site

Return values
OODBBean

addrole()

Add a role

public addrole(string $contextname, string $rolename, string $otherinfo, string $start[, string $end = '' ]) : OODBBean
Parameters
$contextname : string

The name of a context...

$rolename : string

The name of a role....

$otherinfo : string

Any other info that is to be stored with the role

$start : string

A datetime

$end : string = ''

A datetime or ''

Tags
throws
BadValue
Return values
OODBBean

addRoleByBean()

Add a role

public addRoleByBean(OODBBean $rolecontext, OODBBean $rolename, string $otherinfo, string $start[, string $end = '' ]) : OODBBean
Parameters
$rolecontext : OODBBean

Contextname

$rolename : OODBBean

Rolename

$otherinfo : string

Any other info that is to be stored with the role

$start : string

A datetime

$end : string = ''

A datetime or ''

Return values
OODBBean

check()

Check user can access the page - does not return if they cannot

public check(Context $context) : void
Parameters
$context : Context

The context object

Tags
psalm-suppress

PossiblyNullReference - we know we have a user when we call context->user

Return values
void

checkrole()

Check that user has one of a set of roles

public checkrole(array<, array<, string>> $roles[, bool $or = TRUE ]) : array<, mixed>
Parameters
$roles : array<, array<, string>>

[['context', 'role'],...]]

$or : bool = TRUE

If TRUE then the condition is OR

Tags
todo

support nested AND/OR

Return values
array<, mixed>

delrole()

Delete a role

public delrole(string $contextname, string $rolename) : void
Parameters
$contextname : string

The name of a context...

$rolename : string

The name of a role....

Tags
throws
BadValue
Return values
void

edit()

Handle an edit form for this page

public edit(Context $context) : array<, mixed>
Parameters
$context : Context

The context object

Return values
array<, mixed>

[TRUE if error, [error messages]]

editroles()

Deal with the role selecting part of a form

public editroles(Context $context) : void
Parameters
$context : Context

The context object

Tags
psalm-suppress

UndefinedClass

Return values
void

guard()

Return the CSRFGuard inputs for inclusion in a form;

public guard() : string
Return values
string

hasrole()

Check for a role

public hasrole(string $contextname, string $rolename) : object|null
Parameters
$contextname : string

The name of a context...

$rolename : string

The name of a role - if this is the empty string then having the context is enough

Return values
object|null

hasRoleByBean()

Check for a role by bean

public hasRoleByBean(OODBBean $rolecontext, OODBBean|null $rolename) : object|null
Parameters
$rolecontext : OODBBean

A rolecontext

$rolename : OODBBean|null

A rolename - if this is NULL having the context is enough

Return values
object|null

roles()

Get all currently valid roles for this bean

public roles([bool $all = FALSE ]) : array<, OODBBean>
Parameters
$all : bool = FALSE

If TRUE then include expired roles

Return values
array<, OODBBean>

startEdit()

Setup for an edit

public startEdit(Context $context, array<, mixed> $rest) : void
Parameters
$context : Context

The context object

$rest : array<, mixed>
Tags
phpcsSuppress

SlevomatCodingStandard.Functions.UnusedParameter

Return values
void

update()

Function called when a page bean is updated - do error checking in here

public update() : void
Tags
throws
BadValue
Return values
void

dofields()

Handle editing of beans

private dofields(AccessBase $fdt) : array<, string>
Parameters
$fdt : AccessBase

The formdata object from the context

Return values
array<, string>

maketwig()

Make a twig file if we have permission

private static maketwig(Context $context, string $name) : void
Parameters
$context : Context

The Context object

$name : string

The name of the twig

Return values
void

Search results