Disciple_Tools_Contacts

Extends \Disciple_Tools_Posts

Class Disciple_Tools_Contacts

package

Disciple_Tools\Posts\Contacts

Methods

Disciple_Tools_Posts constructor.

__construct() 
inherited

accept_contact

accept_contact(integer $contact_id, boolean $accepted) : array|\WP_Error
static

Arguments

$contact_id

integer

$accepted

boolean

Response

array|\WP_Error

add_comm_channel_comment_section

add_comm_channel_comment_section( $sections,  $post_type) 

Arguments

$sections

$post_type

add_comment

add_comment(integer $contact_id, string $comment_html, string $type = "comment", array $args = array(), boolean $check_permissions = true, boolean $silent = false) : false|integer|\WP_Error
static

Arguments

$contact_id

integer

$comment_html

string

$type

string

normally 'comment', different comment types can have their own section in the comments activity

$args

array

[user_id, comment_date, comment_author etc]

$check_permissions

boolean

$silent

boolean

Response

false|integer|\WP_Error

add_connection_to_post

add_connection_to_post(\string $post_type, \int $post_id, \string $field_key, \int $value) 
inherited static

Arguments

$post_type

\string

$post_id

\int

$field_key

\string

$value

\int

add_default_custom_list_filters

add_default_custom_list_filters( $filters) 
static

Arguments

$filters

add_post_contact_method

add_post_contact_method(array $post_settings, \int $post_id, \string $key, \string $value, array $field) 
inherited static

Arguments

$post_settings

array

$post_id

\int

$key

\string

$value

\string

$field

array

Adds a share record

add_shared_on_contact(integer $post_id, integer $user_id, array $meta = null, boolean $send_notifications = true, boolean $check_permissions = true, boolean $insert_activity = true) : false|integer|\WP_Error
static

Arguments

$post_id

integer

$user_id

integer

$meta

array

$send_notifications

boolean

$check_permissions

boolean

$insert_activity

boolean

Response

false|integer|\WP_Error

Used in in the method get_custom, this method mutates $fields to add data about a particular contact in the required format. You might want to use this instead of get_custom for performance reasons.

adjust_post_custom_fields(array $post_settings, integer $post_id, array &$fields, array $fields_to_return = array(), null $meta_fields = null, null $post_user_meta = null) : void
inherited static

Arguments

$post_settings

array

This is what get_custom_fields_settings() returns

$post_id

integer

The ID number of the contact

$fields

array

This array will be mutated with the results

$fields_to_return

array

if not empty only add the fields that are specified (optional)

$meta_fields

null

a way to pass in the post's meta fields instead of getting in from the database (optional)

$post_user_meta

null

pass in the user post meta if already available (optional)

can_access

can_access(string $post_type) : boolean
inherited static

Arguments

$post_type

string

Response

boolean

can_create

can_create(string $post_type) : boolean
inherited static

Arguments

$post_type

string

Response

boolean

can_delete

can_delete(string $post_type) : boolean
inherited static

Arguments

$post_type

string

Response

boolean

A user can update the record if they have the global permission or if the post if assigned or shared with them

can_update(string $post_type, integer $post_id) : boolean
inherited static

Arguments

$post_type

string

$post_id

integer

Response

boolean

A user can view the record if they have the global permission or if the post if assigned or shared with them

can_view(string $post_type, integer $post_id) : boolean
inherited static

Arguments

$post_type

string

$post_id

integer

Response

boolean

can_view_all

can_view_all(string $post_type) : boolean
inherited static

Arguments

$post_type

string

Response

boolean

check_for_duplicates

check_for_duplicates( $contact_id,  $fields) 

Arguments

$contact_id

$fields

Make sure there are no extra or misspelled fields Make sure the field values are the correct format

check_for_invalid_post_fields(array $post_settings, array $fields, array $allowed_fields = array()) : array
inherited static

Arguments

$post_settings

array

$fields

array

$allowed_fields

array

Response

array

check_requires_update

check_requires_update( $contact_id) 
static

Arguments

$contact_id

Make sure activity is created for all the steps before the current seeker path

check_seeker_path( $contact_id,  $initial_fields,  $contact,  $previous_values) 

Arguments

$contact_id

$initial_fields

$contact

$previous_values

close_duplicate_contact

close_duplicate_contact(\int $duplicate_id, \int $contact_id) 
static

Arguments

$duplicate_id

\int

$contact_id

\int

copy_comments

copy_comments(\int $master_id, \int $non_master_id,  $check_permissions = true) 
static

Arguments

$master_id

\int

$non_master_id

\int

$check_permissions

Helper function to create a unique metakey for contact channels.

create_channel_metakey( $channel_key,  $field_type) : string
inherited static

Arguments

$channel_key

$field_type

Response

string

Create a new Contact

create_contact(array $fields = array(), boolean|true $check_permissions = true, boolean|true $silent = false) : integer
static
since 0.1.0

Arguments

$fields

array

, the new contact's data

$check_permissions

boolean|true

$silent

boolean|true

Response

integer

| WP_Error

create_post_field_hook

create_post_field_hook( $fields,  $post_type) 

Arguments

$fields

$post_type

delete_comment

delete_comment(\int $contact_id, \int $comment_id, \bool $check_permissions = true) 
static

Arguments

$contact_id

\int

$comment_id

\int

$check_permissions

\bool

delete_post

delete_post(\int $post_id, \string $post_type) 
inherited static

Arguments

$post_id

\int

$post_type

\string

dismiss_all

dismiss_all(\int $contact_id) 
static

Arguments

$contact_id

\int

dismiss_duplicate

dismiss_duplicate(\int $contact_id, \int $dismiss_id) 
static

Arguments

$contact_id

\int

$dismiss_id

\int

dt_comment_created

dt_comment_created( $post_type,  $post_id,  $comment_id,  $type) 

Arguments

$post_type

$post_id

$comment_id

$type

dt_get_post_fields_filter

dt_get_post_fields_filter( $fields,  $post_type) 

Arguments

$fields

$post_type

dt_user_list_filters

dt_user_list_filters( $filters,  $post_type) 
static

Arguments

$filters

$post_type

escape_regex_mysql

escape_regex_mysql(\string $regex) 
static

Arguments

$regex

\string

Reduced the number of fields on a post to what is useful in D.T

filter_wp_post_object_fields(object $post) : array
inherited static

Arguments

$post

object

Response

array

find_contacts_by_title

find_contacts_by_title( $title,  $exclude_id) 

Arguments

$title

$exclude_id

find_contacts_with

find_contacts_with( $field,  $value,  $exclude_id = "",  $exact_match = false) 
static

Arguments

$field

$value

$exclude_id

$exact_match

format_activity_message

format_activity_message( $activity,  $post_type_settings) 
inherited static

Arguments

$activity

$post_type_settings

format_connection_message

format_connection_message( $p2p_id,  $activity,  $action = 'connected to') 
inherited static

Arguments

$p2p_id

$activity

$action

format_post_contact_details

format_post_contact_details( $post_settings,  $meta_fields,  $type,  $key,  $value) 
inherited static

Arguments

$post_settings

$meta_fields

$type

$key

$value

get_activity

get_activity( $contact_id) : array|null|object
static

Arguments

$contact_id

Response

array|null|object

get_all_contacts_status_seeker_path

get_all_contacts_status_seeker_path() 
static

get_all_duplicates

get_all_duplicates() 

get_channel_list

get_channel_list() : mixed
static

Response

mixed

get_comments

get_comments(integer $contact_id, boolean $check_permissions = true, string $type = "all") : array|integer|\WP_Error
static

Arguments

$contact_id

integer

$check_permissions

boolean

$type

string

Response

array|integer|\WP_Error

Get a single contact

get_contact(integer $contact_id, boolean $check_permissions = true, boolean $load_cache = false) : array
static
access

public

since 0.1.0

Arguments

$contact_id

integer

, the contact post_id

$check_permissions

boolean

$load_cache

boolean

Response

array

WP_Error, On success: the contact, else: the error message

get_contact_fields

get_contact_fields() : mixed
static

Response

mixed

Returns numbers for multiplier and dispatcher

get_count_of_contacts(string $tab = "my", boolean $show_closed = false) : array|\WP_Error
static

Example Array Return: [ [my_contacts] => 39 [update_needed] => 0 [contact_attempted] => 1 [meeting_scheduled] => 0 [shared] => 5 [all_contacts] => 43 [needs_assigned] => 0 ]

This function will always return this array even if the counts are zero.

If the current user/supplied user is not a dispatcher role or similar, then it will skip the query and return zeros for all_contacts and needs assigned array elements.

Arguments

$tab

string

$show_closed

boolean

Response

array|\WP_Error

get_duplicate_data

get_duplicate_data( $contact_id,  $field) 

Arguments

$contact_id

$field

get_duplicates_on_contact

get_duplicates_on_contact( $contact_id) 
static

Arguments

$contact_id

get_field_details

get_field_details( $field,  $contact_id) 

Arguments

$field

$contact_id

get_label_for_post_type

get_label_for_post_type( $post_type,  $singular = false) 
inherited static

Arguments

$post_type

$singular

get_merge_data

get_merge_data(\int $contact_id, \int $duplicate_id) 
static

Arguments

$contact_id

\int

$duplicate_id

\int

Get most recent activity for the field

get_most_recent_activity_for_field( $post_id,  $field_key) : mixed
inherited static

Arguments

$post_id

$field_key

Response

mixed

get_multi_select_options

get_multi_select_options( $post_type,  $field,  $search = "") 
inherited static

Arguments

$post_type

$field

$search

get_my_contacts_status_seeker_path

get_my_contacts_status_seeker_path() 
static

Cached version of get_page_by_title so that we're not making unnecessary SQL all the time

get_post_by_title_cached(string $title, string $output = OBJECT, string|array $post_type = 'page',  $connection_type = 'none') : \WP_Post|null
inherited static
link

Uncached Functions

Arguments

$title

string

Page title

$output

string

Optional. Output type; OBJECT*, ARRAY_N, or ARRAY_A.

$post_type

string|array

Optional. Post type; default is 'page'.

$connection_type

Response

\WP_Post|null

WP_Post on success or null on failure

get_posts_shared_with_user

get_posts_shared_with_user(string $post_type, integer $user_id,  $search_for_post_name = '') : array
inherited static

Arguments

$post_type

string

$user_id

integer

$search_for_post_name

Response

array

Get settings related to contacts

get_settings() : array|\WP_Error
static

Response

array|\WP_Error

Gets an array of users whom the contact is shared with.

get_shared_with_on_contact(integer $post_id) : array|mixed
static

Arguments

$post_id

integer

Response

array|mixed

get_single_activity

get_single_activity( $contact_id,  $activity_id) : array|null|object
static

Arguments

$contact_id

$activity_id

Response

array|null|object

get_subassigned_users

get_subassigned_users( $post_id) 
inherited static

Arguments

$post_id

Get Contacts assigned to a user

get_user_contacts(integer $user_id, boolean $check_permissions = true, array $query_pagination_args = array()) : \WP_Query
static
access

public

since 0.1.0

Arguments

$user_id

integer

$check_permissions

boolean

$query_pagination_args

array

-Pass in pagination and ordering parameters if wanted.

Response

\WP_Query

| WP_Error

get_user_posts

get_user_posts() 
static

get_viewable

get_viewable(string $post_type, integer $most_recent) : array|\WP_Error|\WP_Query
inherited static

Arguments

$post_type

string

$most_recent

integer

Response

array|\WP_Error|\WP_Query

Get Contacts viewable by a user

get_viewable_contacts(integer $most_recent, boolean $check_permissions = true) : array
static
access

public

since 0.1.0

Arguments

$most_recent

integer

date of most recent update

$check_permissions

boolean

Response

array

| WP_Error | WP_Query

get_viewable_contacts_compact

get_viewable_contacts_compact(string $search_string) : array|\WP_Query
static

Arguments

$search_string

string

Response

array|\WP_Query

handle_quick_action_button_event

handle_quick_action_button_event(integer $contact_id, array $field, boolean $check_permissions = true) : array|integer|\WP_Error
static

Arguments

$contact_id

integer

$field

array

$check_permissions

boolean

Response

array|integer|\WP_Error

increment

increment( &$var,  $val) 
static

Arguments

$var

$val

is_post_key_contact_method_or_connection

is_post_key_contact_method_or_connection( $post_settings,  $key) 
inherited static

Arguments

$post_settings

$key

merge_p2p

merge_p2p(\int $master_id, \int $non_master_id) 
static

Arguments

$master_id

\int

$non_master_id

\int

post_connection_added

post_connection_added( $post_type,  $post_id,  $post_key,  $value) 

Arguments

$post_type

$post_id

$post_key

$value

post_connection_removed

post_connection_removed( $post_type,  $post_id,  $post_key,  $value) 

Arguments

$post_type

$post_id

$post_key

$value

post_created_hook

post_created_hook( $post_type,  $post_id,  $initial_fields) 

Arguments

$post_type

$post_id

$initial_fields

post_updated_hook

post_updated_hook( $post_type,  $post_id,  $updated_fields,  $previous_values) 

Arguments

$post_type

$post_id

$updated_fields

$previous_values

Helper method for creating a WP_Query with pagination and ordering separated into a separate argument for validation.

query_with_pagination(array $query_args, array $query_pagination_args) : \WP_Query
static

These two statements are equivalent in this example: $query = self::query_with_pagination( [ "post_type" => "contacts" ], [ "orderby" => "ID" ] ); // equivalent to: $query = new WP_Query( [ "post_type" => "contacts", "orderby" => "ID" ] ); The second argument, $query_pagination_args, may only contain keys related to ordering and pagination, if it doesn't, this method will return a WP_Error instance. This is useful in case you want to allow a caller to modify pagination and ordering, but not anything else, in order to keep permission checking valid. If $query_pagination_args is specified with at least one value, then all pagination-related keys in the first argument are ignored.

Arguments

$query_args

array

$query_pagination_args

array

Response

\WP_Query

| WP_Error

recheck_duplicates

recheck_duplicates(\int $contact_id) 
static

Arguments

$contact_id

\int

remove_connection_from_post

remove_connection_from_post(\string $post_type, \int $post_id, \string $field_key, \int $value) 
inherited static

Arguments

$post_type

\string

$post_id

\int

$field_key

\string

$value

\int

remove_fields

remove_fields( $contact_id,  $fields = array(),  $ignore = array()) 
static

Arguments

$contact_id

$fields

$ignore

Removes share record

remove_shared_on_contact(integer $post_id, integer $user_id) : false|integer|\WP_Error
static

Arguments

$post_id

integer

$user_id

integer

Response

false|integer|\WP_Error

revert_activity

revert_activity( $contact_id,  $activity_id) : boolean|integer|\WP_Error
static

Arguments

$contact_id

$activity_id

Response

boolean|integer|\WP_Error

save_duplicate_data

save_duplicate_data(\int $contact_id, array $duplicates) 
static

Arguments

$contact_id

\int

$duplicates

array

save_duplicate_finding

save_duplicate_finding( $field,  $dups,  $contact_id) 

Arguments

$field

$dups

$contact_id

search_viewable_contacts

search_viewable_contacts(array $query, \bool $check_permissions = true) 
static

Arguments

$query

array

$check_permissions

\bool

search_viewable_post

search_viewable_post(\string $post_type, array $query, \bool $check_permissions = true) 
inherited static

Arguments

$post_type

\string

$query

array

$check_permissions

\bool

unique_hash

unique_hash() 
inherited static

unsure_all

unsure_all(\int $contact_id) 
static

Arguments

$contact_id

\int

unsure_duplicate

unsure_duplicate(\int $contact_id, \int $unsure_id) 
static

Arguments

$contact_id

\int

$unsure_id

\int

update_comment

update_comment(\int $contact_id, \int $comment_id, \string $comment_content, \bool $check_permissions = true) 
static

Arguments

$contact_id

\int

$comment_id

\int

$comment_content

\string

$check_permissions

\bool

update_connections

update_connections(array $post_settings, \int $post_id, array $fields,  $existing_contact = null) 
inherited static

Arguments

$post_settings

array

$post_id

\int

$fields

array

$existing_contact

Update an existing Contact

update_contact(integer|null $contact_id, array $fields, boolean|null $check_permissions = true, boolean $silent = false) : array
static
access

public

since 0.1.0

Arguments

$contact_id

integer|null

, the post id for the contact

$fields

array

, the meta fields

$check_permissions

boolean|null

$silent

boolean

Response

array

| WP_Error the contact

update_location_grid_fields

update_location_grid_fields(array $field_settings, \int $post_id, array $fields,  $post_type, array $existing_post = null) 
inherited static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$post_type

$existing_post

array

update_multi_select_fields

update_multi_select_fields(array $field_settings, \int $post_id, array $fields, array $existing_contact = null) 
inherited static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$existing_contact

array

update_post_contact_method

update_post_contact_method(\int $post_id, \string $key, array $values) 
inherited static

Arguments

$post_id

\int

$key

\string

$values

array

update_post_contact_methods

update_post_contact_methods(array $post_settings, \int $post_id, array $fields, array $existing_contact = null) 
inherited static

Arguments

$post_settings

array

$post_id

\int

$fields

array

$existing_contact

array

update_post_field_hook

update_post_field_hook( $fields,  $post_type,  $post_id) 

Arguments

$fields

$post_type

$post_id

update_post_user_meta_fields

update_post_user_meta_fields(array $field_settings, \int $post_id, array $fields, array $existing_record) 
inherited static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$existing_record

array

update_quick_action_buttons

update_quick_action_buttons( $contact_id,  $seeker_path) 
static

Arguments

$contact_id

$seeker_path

update_seeker_path

update_seeker_path(integer $contact_id, string $path_option, boolean $check_permissions = true) : array|integer|\WP_Error
static

Arguments

$contact_id

integer

$path_option

string

$check_permissions

boolean

Response

array|integer|\WP_Error