tp TouchPointWP Person - TenthPres/TouchPoint-WP GitHub Wiki

tp\TouchPointWP\Person

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

Constants

SHORTCODE_PEOPLE_LIST

const SHORTCODE_PEOPLE_LIST = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "People"

CRON_HOOK

const CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "person_cron_hook"

BACKUP_USER_PREFIX

const BACKUP_USER_PREFIX = "touchpoint-"

META_PEOPLEID

const META_PEOPLEID = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'peopleId'

META_FAMILYID

const META_FAMILYID = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . 'familyId'

META_CUSTOM_PREFIX

const META_CUSTOM_PREFIX = 'c_'

META_INV_MEMBER_PREFIX

const META_INV_MEMBER_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_mem_"

META_INV_ATTEND_PREFIX

const META_INV_ATTEND_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_att_"

META_INV_DESC_PREFIX

const META_INV_DESC_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "inv_desc_"

META_PEOPLE_EV_PREFIX

const META_PEOPLE_EV_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "pev_"

Properties

peopleId

public mixed peopleId
  • Visibility: public

familyId

public mixed familyId
  • Visibility: public

Methods

fromQueryResult

\tp\TouchPointWP\Person|\tp\TouchPointWP\TouchPointWP_Exception tp\TouchPointWP\Person::fromQueryResult(mixed queryResult)
  • Visibility: public
  • This method is static.

Arguments

  • queryResult mixed

Returns

  • \tp\TouchPointWP\Person|\tp\TouchPointWP\TouchPointWP_Exception - If a WP User ID is not provided, this exception is returned.

fromId

\tp\TouchPointWP\Person|null tp\TouchPointWP\Person::fromId(mixed id)

Get a person from a WordPress User ID

  • Visibility: public
  • This method is static.

Arguments

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

Returns

  • \tp\TouchPointWP\Person|null -

fromPeopleId

\tp\TouchPointWP\Person|null tp\TouchPointWP\Person::fromPeopleId(int pid)

Get a person from a TouchPoint PeopleID

  • Visibility: public
  • This method is static.

Arguments

  • pid int

Returns

  • \tp\TouchPointWP\Person|null -

from

\tp\TouchPointWP\Person|null tp\TouchPointWP\Person::from(mixed field, mixed value)
  • Visibility: public
  • This method is static.

Arguments

  • field mixed* value mixed

Returns

  • \tp\TouchPointWP\Person|null -

__get

int|mixed tp\TouchPointWP\Person::__get(string key)

Generic getter for fields and meta attributes.

  • Visibility: public

Arguments

  • key string

Returns

  • int|mixed -

__set

mixed tp\TouchPointWP\Person::__set(string key, mixed value)

Generic setter. Does not get submitted to the database until

  • Visibility: public

Arguments

  • key string* value mixed

Returns

  • mixed

peopleListShortcode

string tp\TouchPointWP\Person::peopleListShortcode(array|string params, string content)

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

  • Visibility: public
  • This method is static.

Arguments

  • params array|string* content string

Returns

  • string -

getInvolvementMemberships

\tp\TouchPointWP\InvolvementMembership[]|\tp\TouchPointWP\InvolvementMembership tp\TouchPointWP\Person::getInvolvementMemberships(?int iid)

Gets Involvement Memberships. If an involvement ID is provided, the matching membership is provided or null if no membership exists.

  • Visibility: public

Arguments

  • iid ?int

Returns

  • \tp\TouchPointWP\InvolvementMembership[]|\tp\TouchPointWP\InvolvementMembership -

getPictureUrl

string|null tp\TouchPointWP\Person::getPictureUrl(array args)
  • Visibility: public

Arguments

  • args array

Returns

  • string|null -

getPictureForPerson

string|null tp\TouchPointWP\Person::getPictureForPerson(mixed idEmailUserOrPerson, ?array args)
  • Visibility: public
  • This method is static.

Arguments

  • idEmailUserOrPerson mixed* args ?array

Returns

  • string|null -

pictureFilter

mixed tp\TouchPointWP\Person::pictureFilter(string|mixed url, mixed idEmailOrObject, array|mixed args)
  • Visibility: public
  • This method is static.

Arguments

  • 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|mixed - Arguments passed to get_avatar_data(…), after processing. Type is not guaranteed.

Returns

  • mixed

userContactMethods

string[] tp\TouchPointWP\Person::userContactMethods(mixed methods)

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.

  • Visibility: public
  • This method is static.

Arguments

  • methods mixed - string[] Methods available before this filter.

Returns

  • string[] - Methods available after this filter.

updateCron

void tp\TouchPointWP\updatesViaCron::updateCron()

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

updatePersonFromApiData

?\tp\TouchPointWP\Person tp\TouchPointWP\Person::updatePersonFromApiData(mixed pData, bool allowCreation, bool verbose, bool deferTPUpdate)

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

  • Visibility: public
  • This method is static.

Arguments

  • pData mixed* allowCreation bool* verbose bool* deferTPUpdate bool

Returns

  • ?\tp\TouchPointWP\Person - The updated person, or null if no user was found/updated.

setLoginTokens

void tp\TouchPointWP\Person::setLoginTokens(string|null session, string|null login)

Used for setting or clearing a user's login tokens

  • Visibility: public

Arguments

  • session string|null* login string|null

getActionButtons

string tp\TouchPointWP\Person::getActionButtons(?string context, string btnClass, bool withTouchPointLink)

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.

  • Visibility: public

Arguments

  • context ?string - 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.
  • withTouchPointLink bool

Returns

  • string -

enqueueForJS_byPeopleId

?bool tp\TouchPointWP\Person::enqueueForJS_byPeopleId(int pid)

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

  • Visibility: public
  • This method is static.

Arguments

  • pid int - TouchPoint People ID

Returns

  • ?bool - null if person is not found. True if newly enqueued, false if it was already enqueued.

enqueueUsersForJsInstantiation

void tp\TouchPointWP\Person::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)

  • Visibility: public
  • This method is static.

jsonSerialize

object tp\TouchPointWP\Person::jsonSerialize()

Get the JS for instantiation.

  • Visibility: public

Returns

  • object -

getJsInstantiationString

string tp\TouchPointWP\Person::getJsInstantiationString()

Get the JS for instantiation.

  • Visibility: public
  • This method is abstract.
  • This method is static.

Returns

  • string -

getTouchPointId

int tp\TouchPointWP\Person::getTouchPointId()

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

  • Visibility: public
  • This method is abstract.

Returns

  • int -

hasUserPage

bool tp\TouchPointWP\Person::hasUserPage()

Returns true if the person has posts and therefore has a user page.

  • Visibility: public

Returns

  • bool -

getUserUrl

?string tp\TouchPointWP\Person::getUserUrl()

Get the link to the person's author post page.

  • Visibility: public

Returns

  • ?string -

getProfileUrl

?string tp\TouchPointWP\Person::getProfileUrl()

Returns the person's TouchPoint profile URL.

  • Visibility: public

Returns

  • ?string -

arrangeNamesForPeople

?string tp\TouchPointWP\Person::arrangeNamesForPeople(\tp\TouchPointWP\Person[]|\tp\TouchPointWP\Utilities\PersonArray people, bool asLink, int familyLimit)

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

  • Visibility: public
  • This method is static.

Arguments

  • people tp\TouchPointWP\Person[]|tp\TouchPointWP\Person[] - TODO make api compliant with Person object--remove coalesces. (#120)

TODO merge with Utilities::stringArrayToListString()

  • asLink bool* familyLimit int

Returns

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

toNewWpUser

\WP_User tp\TouchPointWP\Person::toNewWpUser()

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

  • Visibility: public

Returns

  • \WP_User -

groupByFamily

\tp\TouchPointWP\Person[][]|object[][] tp\TouchPointWP\Person::groupByFamily(\tp\TouchPointWP\Person[]|object[]|\tp\TouchPointWP\Utilities\PersonArray people)

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

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

  • Visibility: public
  • This method is static.

Arguments

Returns

  • \tp\TouchPointWP\Person[][]|object[][] -

ident

array tp\TouchPointWP\Person::ident(mixed inputData)

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

This is used for both formal and informal auth. Email addresses should be checked for spam likelihood before this point.

  • Visibility: public
  • This method is static.

Arguments

  • inputData mixed

Returns

  • array -

api

bool tp\TouchPointWP\api::api(array uri)

Handle API requests

Arguments

  • uri array - The request URI already parsed by parse_url()

Returns

  • bool - False if endpoint is not found. Should print the result.

load

bool tp\TouchPointWP\module::load()

Loads the module and initializes the other actions.

Returns

  • bool -

checkUpdates

void tp\TouchPointWP\updatesViaCron::checkUpdates()

Check to see if a cron run is needed, and run it if so. Connected to an init function.

getExtraValue

mixed tp\TouchPointWP\Person::getExtraValue(string name)

Get an Extra Value.

  • Visibility: public
  • This method is abstract.

Arguments

  • name string - The name of the extra value to get.

Returns

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

ExtraValues

?\tp\TouchPointWP\ExtraValueHandler tp\TouchPointWP\Person::ExtraValues()
  • Visibility: public

Returns

  • ?\tp\TouchPointWP\ExtraValueHandler -

requireAllObjectsInJs

mixed tp\TouchPointWP\Person::requireAllObjectsInJs(bool require)

If all objects need to be included in the JS,

  • Visibility: public
  • This method is static.

Arguments

  • require bool - Whether all objects should be required. Almost always should be left with the default.

Returns

  • mixed