Documentation

Announcements
in package

Announcement management class for creating and getting announcements.

Tags
author

Aberdeener

version
2.1.0
license

MIT

Table of Contents

Properties

$_cache  : Cache

Methods

__construct()  : mixed
create()  : bool
Create an announcement.
edit()  : bool
Edit an existing announcement.
getAll()  : array<string|int, Announcement>
Get all announcements for listing in StaffCP.
getAvailable()  : array<string|int, Announcement>
Get all announcements matching the param filters.
getPages()  : array<string|int, string>
Get all pages which can have announcements on them (they will have a 'name' attribute).
getPagesCsv()  : string
Get prettified output of the pages a specific announcement is on.
resetCache()  : void
Erase and regenerate announcement cache file.

Properties

Methods

create()

Create an announcement.

public create(User $user, array<string|int, string> $pages, array<string|int, int> $groups, string $text_colour, string $background_colour, string $icon, bool $closable, string $header, string $message, int $order) : bool
Parameters
$user : User

User who is creating the announcement.

$pages : array<string|int, string>

Array of page names this announcement should be on.

$groups : array<string|int, int>

Array of group IDs this announcement should be visible to.

$text_colour : string

Hex code of text colour to use.

$background_colour : string

Hex code of background banner colour of announcement.

$icon : string

HTML to use to display icon on announcement.

$closable : bool

Whether this announcement should have an "x" to close and hide, or be shown 24/7.

$header : string

Header text to show at top of announcement.

$message : string

Main text to show in announcement.

$order : int

Order of this announcement to use for sorting.

Return values
bool

edit()

Edit an existing announcement.

public edit(int $id, array<string|int, string> $pages, array<string|int, int> $groups, string $text_colour, string $background_colour, string $icon, bool $closable, string $header, string $message, int $order) : bool
Parameters
$id : int

ID of announcement to edit.

$pages : array<string|int, string>

Array of page names this announcement should be on.

$groups : array<string|int, int>

Array of group IDs this announcement should be visible to.

$text_colour : string

Hex code of text colour to use.

$background_colour : string

Hex code of background banner colour of announcement.

$icon : string

HTML to use to display icon on announcement.

$closable : bool

Whether this announcement should have an "x" to close and hide, or be shown 24/7.

$header : string

Header text to show at top of announcement.

$message : string

Main text to show in announcement.

$order : int

Order of this announcement to use for sorting.

Return values
bool

getAvailable()

Get all announcements matching the param filters.

public getAvailable([string|null $page = null ][, string|null $custom_page = null ][, array<string|int, mixed> $user_groups = [0] ]) : array<string|int, Announcement>

If they have a cookie set for an announcement, it will be skipped.

Parameters
$page : string|null = null

Name of the page they're viewing.

$custom_page : string|null = null

Title of custom page they're viewing.

$user_groups : array<string|int, mixed> = [0]

All this user's groups.

Return values
array<string|int, Announcement>

Array of announcements they should see on this specific page with their groups.

getPages()

Get all pages which can have announcements on them (they will have a 'name' attribute).

public static getPages(Pages $pages) : array<string|int, string>
Parameters
$pages : Pages

Instance of Pages class.

Return values
array<string|int, string>

Name of all pages announcements can be on.

getPagesCsv()

Get prettified output of the pages a specific announcement is on.

public static getPagesCsv([string|null $pages_json = null ]) : string
Parameters
$pages_json : string|null = null

JSON array of pages to implode.

Return values
string

Comma seperated list of page names.

resetCache()

Erase and regenerate announcement cache file.

public resetCache() : void

Used when creating or editing announcements.


        
On this page

Search results