Documentation

Person extends WP_User
in package
implements api, JsonSerializable, module, updatesViaCron Uses jsInstantiation, extraValues

The Person class connects a WordPress User with a TouchPoint Person.

Table of Contents

Interfaces

api
API Interface
JsonSerializable
module
This is a base interface for all feature classes.
updatesViaCron
Interface to standardize items that are updated with Cron.

Constants

BACKUP_USER_PREFIX  = "touchpoint-"
CRON_HOOK  = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "person_cron_hook"
META_CUSTOM_PREFIX  = 'c_'
META_FAMILYID  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'familyId'
META_INV_ATTEND_PREFIX  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_att_"
META_INV_DESC_PREFIX  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_desc_"
META_INV_MEMBER_PREFIX  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_mem_"
META_PEOPLE_EV_PREFIX  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "pev_"
META_PEOPLEID  = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'peopleId'
SHORTCODE_PEOPLE_LIST  = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "People"

Properties

$familyId  : int
$loginSessionToken  : string|null
$loginToken  : string|null
$peopleId  : int
$picture  : object|null

Methods

__get()  : int|mixed
Generic getter for fields and meta attributes.
__set()  : mixed
Generic setter. Does not get submitted to the database until
api()  : bool
Handle API requests
arrangeNamesForPeople()  : string|null
Take an array of Person-ish objects and return a nicely human-readable list of names.
checkUpdates()  : void
Run cron if it hasn't been run before or is overdue.
enqueueForJS_byPeopleId()  : bool|null
Ensure a person with a given PeopleId will be available in JS.
enqueueUsersForJsInstantiation()  : void
Call this function if user (and immediate family members, probably) should be automatically instantiated in JS on page load. (e.g. if the page contains an RSVP button)
ExtraValues()  : ExtraValueHandler|null
from()  : Person|null
fromId()  : Person|null
Get a person from a WordPress User ID
fromPeopleId()  : Person|null
Get a person from a TouchPoint PeopleID
fromQueryResult()  : Person|TouchPointWP_Exception
getActionButtons()  : string
Returns the html with buttons for actions the user can perform. This must be called *within* an element with the `data-tp-person` attribute with the invId as the value.
getExtraValue()  : mixed
Get an Extra Value.
getInvolvementMemberships()  : array<string|int, InvolvementMembership>|InvolvementMembership
Gets Involvement Memberships. If an involvement ID is provided, the matching membership is provided or null if no membership exists.
getJsInstantiationString()  : string
Get the JS for instantiation.
getPictureForPerson()  : string|null
getPictureUrl()  : string|null
getProfileUrl()  : string|null
getTouchPointId()  : int
Gets a TouchPoint item ID number, regardless of what type of object this is.
groupByFamily()  : array<string|int, array<string|int, Person>>|array<string|int, array<string|int, object>>
Take an array of Person-like objects and group them by family id.
hasProfilePage()  : bool
ident()  : array<string|int, mixed>
Make the API call to get family members, store the results to the Session, and return them.
jsonSerialize()  : array<string|int, mixed>
Controls the information that's actually serialized for jsInstantiation
load()  : bool
Loads the module and initializes the other actions.
peopleListShortcode()  : string
Display a collection of People, such as a list of leaders
pictureFilter()  : string|null
requireAllObjectsInJs()  : void
If all objects need to be included in the JS,
setLoginTokens()  : void
Used for setting or clearing a user's login tokens
toNewWpUser()  : WP_User
Functionally convert this Person object to a WP_User object for working with the WP API.
updateCron()  : void
Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
updatePersonFromApiData()  : Person|null
Update a single person's information on WordPress, and WP User ID TouchPoint.
userContactMethods()  : array<string|int, string>
Controls the list of Contact Methods visible on the wp-admin/user-edit view. Allows admins to add/edit TouchPoint People IDs. Array is keyed on the Meta name.

Constants

BACKUP_USER_PREFIX

public mixed BACKUP_USER_PREFIX = "touchpoint-"

CRON_HOOK

public mixed CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "person_cron_hook"

META_CUSTOM_PREFIX

public mixed META_CUSTOM_PREFIX = 'c_'

META_FAMILYID

public mixed META_FAMILYID = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'familyId'

META_INV_ATTEND_PREFIX

public mixed META_INV_ATTEND_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_att_"

META_INV_DESC_PREFIX

public mixed META_INV_DESC_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_desc_"

META_INV_MEMBER_PREFIX

public mixed META_INV_MEMBER_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_mem_"

META_PEOPLE_EV_PREFIX

public mixed META_PEOPLE_EV_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "pev_"

META_PEOPLEID

public mixed META_PEOPLEID = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'peopleId'

SHORTCODE_PEOPLE_LIST

public mixed SHORTCODE_PEOPLE_LIST = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "People"

Properties

$loginSessionToken

public string|null $loginSessionToken

A token that is saved on the Session variable and used to ensure links aren't used between sessions.

$loginToken

public string|null $loginToken

A token used to validate the user.

$picture

public object|null $picture

An object with the picture URLs and other metadata

Methods

__get()

Generic getter for fields and meta attributes.

public __get(string $key) : int|mixed
Parameters
$key : string
Return values
int|mixed

__set()

Generic setter. Does not get submitted to the database until

public __set(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed

api()

Handle API requests

public static api(array<string|int, mixed> $uri) : bool
Parameters
$uri : array<string|int, mixed>

The request URI already parsed by parse_url()

Return values
bool

False if endpoint is not found. Should print the result.

arrangeNamesForPeople()

Take an array of Person-ish objects and return a nicely human-readable list of names.

public static arrangeNamesForPeople(array<string|int, Person>|PersonArray $people[, int $familyLimit = 3 ]) : string|null
Parameters
$people : array<string|int, Person>|PersonArray

TODO make api compliant with Person object--remove coalesces. (#120)

$familyLimit : int = 3
Return values
string|null

Returns a human-readable list of names, nicely formatted with commas and such.

checkUpdates()

Run cron if it hasn't been run before or is overdue.

public static checkUpdates() : void

enqueueForJS_byPeopleId()

Ensure a person with a given PeopleId will be available in JS.

public static enqueueForJS_byPeopleId(int $pid) : bool|null
Parameters
$pid : int

TouchPoint People ID

Return values
bool|null

null if person is not found. True if newly enqueued, false if it was already enqueued.

enqueueUsersForJsInstantiation()

Call this function if user (and immediate family members, probably) should be automatically instantiated in JS on page load. (e.g. if the page contains an RSVP button)

public static enqueueUsersForJsInstantiation() : void

from()

public static from( $field,  $value) : Person|null
Parameters
$field :
$value :
Return values
Person|null

fromId()

Get a person from a WordPress User ID

public static fromId( $id) : Person|null
Parameters
$id :

int|array|object The WordPress user ID, or an object/array with an ID property representing that ID.

Return values
Person|null

fromPeopleId()

Get a person from a TouchPoint PeopleID

public static fromPeopleId(int $pid) : Person|null
Parameters
$pid : int
Return values
Person|null

getActionButtons()

Returns the html with buttons for actions the user can perform. This must be called *within* an element with the `data-tp-person` attribute with the invId as the value.

public getActionButtons([string|null $context = null ][, string $btnClass = "" ]) : string
Parameters
$context : string|null = null

A reference to where the action buttons are meant to be used.

$btnClass : string = ""

A string for classes to add to the buttons. Note that buttons can be a or button elements.

Return values
string

getExtraValue()

Get an Extra Value.

public abstract getExtraValue(string $name) : mixed
Parameters
$name : string

The name of the extra value to get.

Return values
mixed

The value of the extra value. Returns null if it doesn't exist.

getJsInstantiationString()

Get the JS for instantiation.

public abstract static getJsInstantiationString() : string
Return values
string

getPictureForPerson()

public static getPictureForPerson(mixed $idEmailUserOrPerson[, array<string|int, mixed>|null $args = [] ]) : string|null
Parameters
$idEmailUserOrPerson : mixed
$args : array<string|int, mixed>|null = []
Return values
string|null

getPictureUrl()

public getPictureUrl([array<string|int, mixed> $args = [] ]) : string|null
Parameters
$args : array<string|int, mixed> = []
Tags
noinspection

PhpUnused

Return values
string|null

getProfileUrl()

public getProfileUrl() : string|null
Return values
string|null

getTouchPointId()

Gets a TouchPoint item ID number, regardless of what type of object this is.

public abstract getTouchPointId() : int
Return values
int

groupByFamily()

Take an array of Person-like objects and group them by family id.

public static groupByFamily(array<string|int, Person>|array<string|int, object>|PersonArray $people) : array<string|int, array<string|int, Person>>|array<string|int, array<string|int, object>>

Objects must have a FamilyId or familyId field. TODO standardize... (#120)

Parameters
$people : array<string|int, Person>|array<string|int, object>|PersonArray
Return values
array<string|int, array<string|int, Person>>|array<string|int, array<string|int, object>>

hasProfilePage()

public hasProfilePage() : bool
Return values
bool

ident()

Make the API call to get family members, store the results to the Session, and return them.

public static ident( $inputData) : array<string|int, mixed>
Parameters
$inputData :
Return values
array<string|int, mixed>

jsonSerialize()

Controls the information that's actually serialized for jsInstantiation

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

load()

Loads the module and initializes the other actions.

public static load() : bool
Return values
bool

peopleListShortcode()

Display a collection of People, such as a list of leaders

public static peopleListShortcode([array<string|int, mixed>|string $params = [] ][, string $content = "" ]) : string
Parameters
$params : array<string|int, mixed>|string = []
$content : string = ""
Tags
noinspection

PhpUnusedParameterInspection

Return values
string

pictureFilter()

public static pictureFilter(string|mixed $url, mixed $idEmailOrObject[, array<string|int, mixed>|mixed $args = [] ]) : string|null
Parameters
$url : string|mixed

The URL of the avatar. Type is not guaranteed.

$idEmailOrObject : mixed

The person for whom to retrieve. Accepts a user_id, gravatar md5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.

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

Arguments passed to get_avatar_data(…), after processing. Type is not guaranteed.

Tags
noinspection

PhpUnusedParameterInspection

Return values
string|null

requireAllObjectsInJs()

If all objects need to be included in the JS,

public static requireAllObjectsInJs([bool $require = true ]) : void
Parameters
$require : bool = true

Whether all objects should be required. Almost always should be left with the default.

setLoginTokens()

Used for setting or clearing a user's login tokens

public setLoginTokens(string|null $session, string|null $login) : void
Parameters
$session : string|null
$login : string|null

toNewWpUser()

Functionally convert this Person object to a WP_User object for working with the WP API.

public toNewWpUser() : WP_User
Return values
WP_User

updateCron()

Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.

public static updateCron() : void

updatePersonFromApiData()

Update a single person's information on WordPress, and WP User ID TouchPoint.

public static updatePersonFromApiData(mixed $pData, bool $allowCreation[, bool $verbose = false ][, bool $deferTPUpdate = false ]) : Person|null
Parameters
$pData : mixed
$allowCreation : bool
$verbose : bool = false
$deferTPUpdate : bool = false
Return values
Person|null

The updated person, or null if no user was found/updated.

userContactMethods()

Controls the list of Contact Methods visible on the wp-admin/user-edit view. Allows admins to add/edit TouchPoint People IDs. Array is keyed on the Meta name.

public static userContactMethods( $methods) : array<string|int, string>
Parameters
$methods :

string[] Methods available before this filter.

Return values
array<string|int, string>

Methods available after this filter.


        
On this page

Search results