CRM_Contact_BAO_Contact
class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact
Constants
NOT_NULL |
|
IS_NULL |
|
DB_DAO_NOTNULL |
|
VALUE_SEPARATOR |
|
BULK_INSERT_COUNT |
|
BULK_INSERT_HIGH_COUNT |
|
QUERY_FORMAT_WILDCARD |
|
QUERY_FORMAT_NO_QUOTES |
|
SERIALIZE_SEPARATOR_BOOKEND |
|
SERIALIZE_SEPARATOR_TRIMMED |
|
SERIALIZE_JSON |
|
SERIALIZE_PHP |
|
SERIALIZE_COMMA |
|
DROP_STRIP_FUNCTION_43 |
SQL function used to format the phone_numeric field via trigger. |
CREATE_STRIP_FUNCTION_43 |
|
Properties
protected int | $resultCopies | How many times has this instance been cloned. | from CRM_Core_DAO |
static null | $_nullObject | from CRM_Core_DAO | |
static array | $_nullArray | from CRM_Core_DAO | |
static | $_dbColumnValueCache | from CRM_Core_DAO | |
static array | $_testEntitiesToSkip | Define entities that shouldn't be created or deleted when creating/ deleting test objects - this prevents world regions, countries etc from being added / deleted | from CRM_Core_DAO |
static object | $_factory | The factory class for this application. | from CRM_Core_DAO |
static | $_checkedSqlFunctionsExist | from CRM_Core_DAO | |
protected array | $_options | https://issues.civicrm.org/jira/browse/CRM-17748 internal variable for DAO to hold per-query settings | from CRM_Core_DAO |
static string | $_tableName | Static instance to hold the table name. | from CRM_Contact_DAO_Contact |
static bool | $_log | Should CiviCRM log any modifications to this table in the civicrm_log table. | from CRM_Contact_DAO_Contact |
int | $id | Unique Contact ID | from CRM_Contact_DAO_Contact |
string | $contact_type | Type of Contact. | from CRM_Contact_DAO_Contact |
string | $contact_sub_type | May be used to over-ride contact view and edit templates. | from CRM_Contact_DAO_Contact |
bool | $do_not_email | from CRM_Contact_DAO_Contact | |
bool | $do_not_phone | from CRM_Contact_DAO_Contact | |
bool | $do_not_mail | from CRM_Contact_DAO_Contact | |
bool | $do_not_sms | from CRM_Contact_DAO_Contact | |
bool | $do_not_trade | from CRM_Contact_DAO_Contact | |
bool | $is_opt_out | Has the contact opted out from receiving all bulk email from the organization or site domain? | from CRM_Contact_DAO_Contact |
string | $legal_identifier | May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID. | from CRM_Contact_DAO_Contact |
string | $external_identifier | Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations. | from CRM_Contact_DAO_Contact |
string | $sort_name | Name used for sorting different contact types | from CRM_Contact_DAO_Contact |
string | $display_name | Formatted name representing preferred format for display/print/other output. | from CRM_Contact_DAO_Contact |
string | $nick_name | Nickname. | from CRM_Contact_DAO_Contact |
string | $legal_name | Legal Name. | from CRM_Contact_DAO_Contact |
text | $image_URL | optional URL for preferred image (photo, logo, etc.) to display for this contact. | from CRM_Contact_DAO_Contact |
string | $preferred_communication_method | What is the preferred mode of communication. | from CRM_Contact_DAO_Contact |
string | $preferred_language | Which language is preferred for communication. FK to languages in civicrm_option_value. | from CRM_Contact_DAO_Contact |
string | $preferred_mail_format | What is the preferred mode of sending an email. | from CRM_Contact_DAO_Contact |
string | $hash | Key for validating requests related to this contact. | from CRM_Contact_DAO_Contact |
string | $api_key | API Key for validating requests related to this contact. | from CRM_Contact_DAO_Contact |
string | $source | where contact come from, e.g. import, donate module insert. | from CRM_Contact_DAO_Contact |
string | $first_name | First Name. | from CRM_Contact_DAO_Contact |
string | $middle_name | Middle Name. | from CRM_Contact_DAO_Contact |
string | $last_name | Last Name. | from CRM_Contact_DAO_Contact |
int | $prefix_id | Prefix or Title for name (Ms, Mr. | from CRM_Contact_DAO_Contact |
int | $suffix_id | Suffix for name (Jr, Sr. | from CRM_Contact_DAO_Contact |
string | $formal_title | Formal (academic or similar) title in front of name. (Prof., Dr. etc.) | from CRM_Contact_DAO_Contact |
int | $communication_style_id | Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value. | from CRM_Contact_DAO_Contact |
int | $email_greeting_id | FK to civicrm_option_value.id, that has to be valid registered Email Greeting. | from CRM_Contact_DAO_Contact |
string | $email_greeting_custom | Custom Email Greeting. | from CRM_Contact_DAO_Contact |
string | $email_greeting_display | Cache Email Greeting. | from CRM_Contact_DAO_Contact |
int | $postal_greeting_id | FK to civicrm_option_value.id, that has to be valid registered Postal Greeting. | from CRM_Contact_DAO_Contact |
string | $postal_greeting_custom | Custom Postal greeting. | from CRM_Contact_DAO_Contact |
string | $postal_greeting_display | Cache Postal greeting. | from CRM_Contact_DAO_Contact |
int | $addressee_id | FK to civicrm_option_value.id, that has to be valid registered Addressee. | from CRM_Contact_DAO_Contact |
string | $addressee_custom | Custom Addressee. | from CRM_Contact_DAO_Contact |
string | $addressee_display | Cache Addressee. | from CRM_Contact_DAO_Contact |
string | $job_title | Job Title | from CRM_Contact_DAO_Contact |
int | $gender_id | FK to gender ID | from CRM_Contact_DAO_Contact |
date | $birth_date | Date of birth | from CRM_Contact_DAO_Contact |
bool | $is_deceased | from CRM_Contact_DAO_Contact | |
date | $deceased_date | Date of deceased | from CRM_Contact_DAO_Contact |
string | $household_name | Household Name. | from CRM_Contact_DAO_Contact |
int | $primary_contact_id | Optional FK to Primary Contact for this household. | from CRM_Contact_DAO_Contact |
string | $organization_name | Organization Name. | from CRM_Contact_DAO_Contact |
string | $sic_code | Standard Industry Classification Code. | from CRM_Contact_DAO_Contact |
string | $user_unique_id | the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM | from CRM_Contact_DAO_Contact |
int | $employer_id | OPTIONAL FK to civicrm_contact record. | from CRM_Contact_DAO_Contact |
bool | $is_deleted | from CRM_Contact_DAO_Contact | |
timestamp | $created_date | When was the contact was created. | from CRM_Contact_DAO_Contact |
timestamp | $modified_date | When was the contact (or closely related entity) was created or modified or deleted. | from CRM_Contact_DAO_Contact |
static array | $_commPrefs | The types of communication preferences. | |
static array | $_greetingTypes | Types of greetings. | |
static array | $_importableFields | Static field for all the contact information that we can potentially import. | |
static array | $_exportableFields | Static field for all the contact information that we can potentially export. |
Methods
Class constructor.
Disables usage of the ONLY_FULL_GROUP_BY Mode if necessary
Re-enables ONLY_FULL_GROUP_BY sql_mode as necessary.
Generate and assign an arbitrary value to a field of a test object.
Execute a query by the current DAO, localizing it along the way (if needed).
Static function to set the factory instance for this class.
Factory method to instantiate a new object from a table name.
Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.
Returns foreign keys and entity references.
Deletes items from table which match current objects variables.
Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values
Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.
Create an attribute for this specific field. We only do this for strings and text
Get the size and maxLength attributes for this text field.
Check if there is a record with the same name in the db.
Check if there is a given column in a specific table.
Scans all the tables using a slow query and table name.
Checks if a constraint exists for a specified table.
Checks if CONSTRAINT keyword exists for a specified table.
Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.
Check whether a specific column in a specific table has always the same value.
Check whether a specific column in a specific table is always NULL.
Check if there is a given table in the database.
Find a DAO object for the given ID and return it.
Get all the result records as mapping between columns.
Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record
Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record
Get sort string.
Fetch object based on array of properties.
Delete the object records that are associated with this contact.
Execute an unbuffered query.
Execute a query.
Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level
Execute a query and get the single result.
Compose the query by merging the parameters into it.
Make a shallow copy of an object and all the fields in the object.
Method that copies custom fields values from an old entity to a new one.
Cascade update through related entities.
Given the component id, compute the contact id since its used for things like send email
Fetch object based on array of properties.
Escape a list of strings for use with "WHERE X IN (.
Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING
Deletes the this object plus any dependent objects that are associated with it.
Set defaults when creating new entity.
No description
No description
Build a list of triggers via hook and add them to (err, reconcile them with) the database.
Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests
Given a list of fields, create a list of references.
List all tables which have hard foreign keys to this table.
Add custom tables that extend contacts to the list of contact references.
Add custom ContactReference fields to the list of contact references
Lookup the value of a MySQL global configuration variable.
Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
Get options for a given contact field.
Provides documentation and validation for the buildOptions $context param
Get SQL where clause for SQL filter syntax input parameters.
SQL has a limit of 64 characters on various names: table name, trigger name, column name .
https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query
https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level
No description
This returns the final permissioned query string for this entity
ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insenstive.
Transform an array to a serialized string for database storage.
Transform a serialized string from the database into an array.
No description
Get exportable fields with pseudoconstants rendered as an extra field.
Return a mapping from field-name to the corresponding key (as used in fields()).
Returns the list of fields that can be imported
Returns the list of fields that can be exported
Returns the list of indices
Takes an associative array and creates a contact object.
Create contact.
Format the output of the create contact function
Ensure greeting parameters are set.
Get the display name and image of a contact.
Add billing fields to the params if appropriate.
Resolve a state province string (UT or Utah) to an ID.
Get the relevant location entity for the array key.
Create last viewed link to recently updated contact.
Get the values for pseudoconstants for name->value and reverse.
Fetch object based on array of properties.
Get the display name of a contact.
Delete a contact and all its associated records.
Action to update any caches relating to a recently update contact.
Delete the image of a contact.
Return proportional height and width of the image.
Validate type of contact image.
Extract contact id from url for deleting contact image.
Function to set is_delete true or restore deleted contact.
Get contact type for a contact.
Get contact sub type for a contact.
Get pair of contact-type and sub-type for a contact.
Combine all the importable fields from the lower levels object.
Combine all the exportable fields from the lower levels object.
Get the all contact details (Hierarchical).
Given a set of flat profile style field names, create a hierarchy.
Return the primary location type of a contact.
Get the display name, primary email and location type of a contact.
Add/edit/register contacts through profile.
Format profile contact parameters.
Find the get contact details.
Find the contact details associated with an OpenID.
Get primary email of the contact.
Function to get primary OpenID of the contact.
Fetch the object and store the values in the values array.
Given the component name and returns the count of participation of contact.
Update contact greetings if an update has resulted in a custom field change.
Process greetings and cache.
Retrieve loc block ids w/ given condition.
Build context menu items.
Check if user has permissions to access items in action menu.
Retrieve display name of contact that address is shared.
Get the creation/modification times for a contact.
Get a list of triggers for the contact table.
Check if contact is being used in civicrm_domain based on $contactId.
Delete a contact-related object that has an 'is_primary' field.
Get any existing duplicate contacts based on the input parameters.
Get the first duplicate contacts based on the input parameters.
Check if a field is associated with an entity that has a location type.
No description
Details
at line 103
CRM_Core_DAO
__construct()
Class constructor.
in CRM_Core_DAO at line 130
__clone()
in CRM_Core_DAO at line 139
__destruct()
Class destructor.
in CRM_Contact_DAO_Contact at line 1409
static
getTableName()
Returns the names of this table
in CRM_Core_DAO at line 159
static
init(string $dsn)
Initialize the DAO object.
in CRM_Core_DAO at line 185
static DB_common
getConnection()
in CRM_Core_DAO at line 194
static
disableFullGroupByMode()
Disables usage of the ONLY_FULL_GROUP_BY Mode if necessary
in CRM_Core_DAO at line 206
static
reenableFullGroupByMode()
Re-enables ONLY_FULL_GROUP_BY sql_mode as necessary.
.
in CRM_Core_DAO at line 219
protected
assignTestFK(string $fieldName, $fieldDef, array $params)
in CRM_Core_DAO at line 264
protected
assignTestValue(string $fieldName, array $fieldDef, int $counter)
Generate and assign an arbitrary value to a field of a test object.
in CRM_Core_DAO at line 376
reset()
Reset the DAO object.
DAO is kinda crappy in that there is an unwritten rule of one query per DAO.
We attempt to get around this crappy restriction by resetting some of DAO's internal fields. Use this with caution
in CRM_Core_DAO at line 396
static string
getLocaleTableName(string $tableName)
in CRM_Core_DAO at line 418
object
query(string $query, bool $i18nRewrite = TRUE)
Execute a query by the current DAO, localizing it along the way (if needed).
in CRM_Core_DAO at line 447
static
setFactory(object $factory)
Static function to set the factory instance for this class.
in CRM_Core_DAO at line 457
DataObject|PEAR_Error
factory(string $table = '')
Factory method to instantiate a new object from a table name.
in CRM_Core_DAO at line 469
initialize()
Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.
in CRM_Core_DAO at line 484
array
keys()
Defines the default key as 'id'.
in CRM_Core_DAO at line 499
array
sequenceKey()
Tells DB_DataObject which keys use autoincrement.
'id' is autoincrementing by default.
in CRM_Contact_DAO_Contact at line 395
static array
getReferenceColumns()
Returns foreign keys and entity references.
in CRM_Contact_DAO_Contact at line 410
static array
fields()
Returns all the column names of this table
in CRM_Core_DAO at line 535
array
table()
Get/set an associative array of table columns
in CRM_Core_DAO at line 558
CRM_Core_DAO
save(bool $hook = TRUE)
Save DAO object.
in CRM_Core_DAO at line 610
delete(bool $useWhere = FALSE)
Deletes items from table which match current objects variables.
Returns the true on success
for example
Designed to be extended
$object = new mytable(); $object->ID=123; echo $object->delete(); // builds a conditon
$object = new mytable(); $object->whereAdd('age > 12'); $object->limit(1); $object->orderBy('age DESC'); $object->delete(true); // dont use object vars, use the conditions, limit and order.
in CRM_Core_DAO at line 628
log(bool $created = FALSE)
in CRM_Core_DAO at line 669
bool
copyValues(array $params, bool $serializeArrays = FALSE)
Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values
in CRM_Core_DAO at line 725
static
storeValues(object $object, array $values)
Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.
in CRM_Core_DAO at line 747
static array|null
makeAttribute(array $field)
Create an attribute for this specific field. We only do this for strings and text
in CRM_Core_DAO at line 800
static array
getAttribute(string $class, string $fieldName = NULL)
Get the size and maxLength attributes for this text field.
(or for all text fields) in the DAO object.
in CRM_Core_DAO at line 842
static bool
objectExists(string $value, string $daoName, string $daoID, string $fieldName = 'name', string $domainID = NULL)
Check if there is a record with the same name in the db.
in CRM_Core_DAO at line 871
static bool
checkFieldExists(string $tableName, string $columnName, bool $i18nRewrite = TRUE)
deprecated
deprecated
Check if there is a given column in a specific table.
in CRM_Core_DAO at line 880
static array
getTableNames()
Scans all the tables using a slow query and table name.
in CRM_Core_DAO at line 901
static bool
isDBMyISAM(int $maxTablesToCheck = 10)
in CRM_Core_DAO at line 919
static string
getDatabaseName()
Get the name of the CiviCRM database.
in CRM_Core_DAO at line 933
static bool
checkConstraintExists(string $tableName, string $constraint)
Checks if a constraint exists for a specified table.
in CRM_Core_DAO at line 960
static bool
schemaRequiresRebuilding(array $tables = ["civicrm_contact"])
Checks if CONSTRAINT keyword exists for a specified table.
in CRM_Core_DAO at line 995
static bool
checkFKConstraintInFormat(string $tableName, string $columnName)
Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.
in CRM_Core_DAO at line 1023
static bool
checkFieldHasAlwaysValue(string $tableName, string $columnName, string $columnValue)
Check whether a specific column in a specific table has always the same value.
in CRM_Core_DAO at line 1039
static bool
checkFieldIsAlwaysNull(string $tableName, string $columnName)
Check whether a specific column in a specific table is always NULL.
in CRM_Core_DAO at line 1054
static bool
checkTableExists(string $tableName)
Check if there is a given table in the database.
in CRM_Core_DAO at line 1073
static bool
checkTableHasData(string $tableName)
Check if a given table has data.
in CRM_Core_DAO at line 1083
bool
checkVersion($version)
in CRM_Core_DAO at line 1103
static CRM_Core_DAO
findById(int $id)
Find a DAO object for the given ID and return it.
in CRM_Core_DAO at line 1117
array
fetchAll()
Returns all results as array-encoded records.
in CRM_Core_DAO at line 1131
fetchGenerator(string $type = 'dao')
Return the results as PHP generator.
in CRM_Core_DAO at line 1153
mixed|NULL
fetchValue()
Returns a singular value.
in CRM_Core_DAO at line 1174
array
fetchMap(string $keyColumn, string $valueColumn)
Get all the result records as mapping between columns.
in CRM_Core_DAO at line 1199
static string|null
getFieldValue(string $daoName, int $searchValue, string $returnColumn = 'name', string $searchColumn = 'id', bool $force = FALSE)
Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record
in CRM_Core_DAO at line 1252
static bool
setFieldValue(string $daoName, int $searchValue, string $setColumn, string $setValue, string $searchColumn = 'id')
Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record
in CRM_Core_DAO at line 1277
static string
getSortString(array|object $sort, string $default = NULL)
Get sort string.
in CRM_Core_DAO at line 1310
static object
commonRetrieve(string $daoName, array $params, array $defaults, array $returnProperities = NULL)
Fetch object based on array of properties.
in CRM_Core_DAO at line 1335
static
deleteEntityContact(string $daoName, int $contactId)
Delete the object records that are associated with this contact.
in CRM_Core_DAO at line 1360
static CRM_Core_DAO
executeUnbufferedQuery(string $query, array $params = [], bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)
Execute an unbuffered query.
This is a wrapper around new functionality exposed with CRM-17748.
in CRM_Core_DAO at line 1401
static CRM_Core_DAO|object
executeQuery(string $query, array $params = [], bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE, array $options = [])
Execute a query.
in CRM_Core_DAO at line 1456
bool
isValidOption(array $options)
Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level
in CRM_Core_DAO at line 1491
static string|null
singleValueQuery(string $query, array $params = [], bool $abort = TRUE, bool $i18nRewrite = TRUE)
Execute a query and get the single result.
in CRM_Core_DAO at line 1529
static string
composeQuery(string $query, array $params = [], bool $abort = TRUE)
Compose the query by merging the parameters into it.
in CRM_Core_DAO at line 1576
static
freeResult(null $ids = NULL)
in CRM_Core_DAO at line 1623
static CRM_Core_DAO|bool
copyGeneric(string $daoName, array $criteria, array $newData = NULL, string $fieldsFix = NULL, string $blockCopyOfDependencies = NULL, bool $blockCopyofCustomValues = FALSE)
Make a shallow copy of an object and all the fields in the object.
in CRM_Core_DAO at line 1713
copyCustomFields(int $entityID, int $newEntityID)
Method that copies custom fields values from an old entity to a new one.
Fixes bug CRM-19302, where if a custom field of File type was present, left both events using the same file, breaking download URL's for the old event.
in CRM_Core_DAO at line 1768
static CRM_Core_DAO|null
cascadeUpdate(string $daoName, $fromId, $toId, array $newData = [])
Cascade update through related entities.
in CRM_Core_DAO at line 1813
static array
getContactIDsFromComponent($componentIDs, string $tableName, string $idField = 'id')
Given the component id, compute the contact id since its used for things like send email
in CRM_Core_DAO at line 1848
static object
commonRetrieveAll(string $daoName, string $fieldIdName = 'id', int $fieldId, $details, array $returnProperities = NULL)
Fetch object based on array of properties.
in CRM_Core_DAO at line 1875
static
dropAllTables()
Drop all CiviCRM tables.
in CRM_Core_DAO at line 1897
static string
escapeString($string)
in CRM_Core_DAO at line 1926
static string
escapeStrings(array $strings, string $default = NULL)
Escape a list of strings for use with "WHERE X IN (.
..)" queries.
in CRM_Core_DAO at line 1945
static string
escapeWildCardString($string)
in CRM_Core_DAO at line 1973
static object|array|NULL
createTestObject(string $daoName, array $params = [], int $numObjects = 1, bool $createOnly = FALSE)
Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING
in CRM_Core_DAO at line 2062
static
deleteTestObjects(string $daoName, array $params = [])
Deletes the this object plus any dependent objects that are associated with it.
ONLY USE FOR TESTING
in CRM_Core_DAO at line 2110
static
setCreateDefaults(array $params, $defaults)
Set defaults when creating new entity.
(don't call this set defaults as already in use with different signature in some places)
in CRM_Core_DAO at line 2130
static string
createTempTableName(string $prefix = 'civicrm', bool $addRandomString = TRUE, null $string = NULL)
deprecated
deprecated
in CRM_Core_DAO at line 2150
static bool
checkTriggerViewPermission(bool $view = TRUE, bool $trigger = TRUE)
in CRM_Core_DAO at line 2198
static
debugPrint(null $message = NULL, bool $printDAO = TRUE)
in CRM_Core_DAO at line 2222
static
triggerRebuild(string $tableName = NULL, bool $force = FALSE)
deprecated
deprecated
Build a list of triggers via hook and add them to (err, reconcile them with) the database.
in CRM_Core_DAO at line 2233
static
checkSqlFunctionsExist()
Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests
in CRM_Core_DAO at line 2250
static
dropTriggers(string $tableName = NULL)
deprecated
deprecated
Wrapper function to drop triggers.
in CRM_Core_DAO at line 2261
static
createTriggers(array $info, string $onlyTableName = NULL)
deprecated
deprecated
in CRM_Core_DAO at line 2272
static array
createReferenceColumns(string $className)
Given a list of fields, create a list of references.
in CRM_Core_DAO at line 2295
array
findReferences()
Find all records which refer to this entity.
in CRM_Core_DAO at line 2324
array
getReferenceCounts()
in CRM_Core_DAO at line 2361
static array
getReferencesToTable(string $tableName)
List all tables which have hard foreign keys to this table.
For now, this returns a description of every entity_id/entity_table reference. TODO: filter dynamic entity references on the $tableName, based on schema metadata in dynamicForeignKey which enumerates a restricted set of possible entity_table's.
in CRM_Core_DAO at line 2386
static
getReferencesToContactTable()
Get all references to contact table.
This includes core tables, custom group tables, tables added by the merge hook and the entity_tag table.
Refer to CRM-17454 for information on the danger of querying the information schema to derive this.
in CRM_Core_DAO at line 2418
static
appendCustomTablesExtendingContacts(array $cidRefs)
Add custom tables that extend contacts to the list of contact references.
CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity seems like a safe-ish function to be sure all are retrieved & we don't miss subtypes or inactive or multiples - the down side is it is not cached.
Further changes should be include tests in the CRM_Core_MergerTest class to ensure that disabled, subtype, multiple etc groups are still captured.
in CRM_Core_DAO at line 2435
static
appendCustomContactReferenceFields(array $cidRefs)
Add custom ContactReference fields to the list of contact references
This includes active and inactive fields/groups
in CRM_Core_DAO at line 2453
static mixed
getGlobalSetting(string $name, mixed $default = NULL)
Lookup the value of a MySQL global configuration variable.
in CRM_Core_DAO at line 2477
static
appendPseudoConstantsToFields(array $fields)
Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
This is relevant where we want to offer both the ID field and the label field as an option, e.g. search builder.
It is currently limited for optionGroupName & id+ name+ FK combos for purposes keeping the scope of the change small, but is appropriate for other sorts of pseudoconstants.
at line 3501
static array|bool
buildOptions(string $fieldName, string $context = NULL, array $props = [])
Get options for a given contact field.
in CRM_Core_DAO at line 2542
getOptionLabels()
Populate option labels for this object's fields.
in CRM_Core_DAO at line 2568
static array
buildOptionsContext(string $context = NULL)
Provides documentation and validation for the buildOptions $context param
in CRM_Core_DAO at line 2588
bool|array
getFieldSpec(string $fieldName)
in CRM_Core_DAO at line 2631
static NULL|string|array
createSQLFilter(string $fieldName, array $filter, string $type = NULL, string $alias = NULL, bool $returnSanitisedArray = FALSE)
Get SQL where clause for SQL filter syntax input parameters.
SQL version of api function to assign filters to the DAO based on the syntax $field => array('IN' => array(4,6,9)) OR $field => array('LIKE' => array('%me%)) etc
in CRM_Core_DAO at line 2696
static array
acceptedSQLOperators()
in CRM_Core_DAO at line 2733
static string
shortenSQLName(string $string, int $length = 60, bool $makeRandom = FALSE)
SQL has a limit of 64 characters on various names: table name, trigger name, column name .
..
For custom groups and fields we generated names from user entered input which can be longer than this length, this function helps with creating strings that meet various criteria.
in CRM_Core_DAO at line 2759
setOptions(array $options)
https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query
in CRM_Core_DAO at line 2772
protected
_setDBOptions(array $options)
https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level
in CRM_Core_DAO at line 2787
setApiFilter(array $params)
deprecated
deprecated
at line 3593
array
addSelectWhereClause()
in CRM_Core_DAO at line 2845
static array
getSelectWhereClause(string $tableAlias = NULL)
This returns the final permissioned query string for this entity
With acls from related entities + additional clauses from hook_civicrm_selectWhereClause
in CRM_Core_DAO at line 2868
static bool
requireSafeDBName($database)
ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insenstive.
in CRM_Core_DAO at line 2890
static string|null
serializeField(array|null $value, int $serializationType)
Transform an array to a serialized string for database storage.
in CRM_Core_DAO at line 2924
static array|null
unSerializeField(string|null $value, $serializationType)
Transform a serialized string from the database into an array.
at line 3738
static array
getEntityRefFilters()
in CRM_Core_DAO at line 2966
static array
getExportableFieldsWithPseudoConstants(string $baoClass)
Get exportable fields with pseudoconstants rendered as an extra field.
in CRM_Contact_DAO_Contact at line 1397
static array
fieldKeys()
Return a mapping from field-name to the corresponding key (as used in fields()).
in CRM_Contact_DAO_Contact at line 1418
bool
getLog()
Returns if this table needs to be logged
in CRM_Contact_DAO_Contact at line 1429
static array
import(bool $prefix = FALSE)
Returns the list of fields that can be imported
in CRM_Contact_DAO_Contact at line 1441
static array
export(bool $prefix = FALSE)
Returns the list of fields that can be exported
in CRM_Contact_DAO_Contact at line 1453
static array
indices(bool $localize = TRUE)
Returns the list of indices
at line 122
static CRM_Contact_BAO_Contact|CRM_Core_Error|NULL
add(array $params)
Takes an associative array and creates a contact object.
The function extracts all the params it needs to initialize the create a contact object. the params array could contain additional unused name/value pairs
at line 267
static CRM_Contact_BAO_Contact|CRM_Core_Error
create(array $params, bool $fixAddress = TRUE, bool $invokeHooks = TRUE, bool $skipDelete = FALSE)
Create contact.
takes an associative array and creates a contact object and all the associated derived objects (i.e. individual, location, email, phone etc)
This function is invoked from within the web form layer and also from the api layer
at line 463
static
unsetProtectedFields(CRM_Contact_DAO_Contact[]|array[] $contacts)
Format the output of the create contact function
at line 491
static
ensureGreetingParamsAreSet(array $params)
Ensure greeting parameters are set.
By always populating greetings here we can be sure they are set if required & avoid a call later. (ie. knowing we have definitely tried disambiguates between NULL & not loaded.)
at line 542
static array
getDisplayAndImage(int $id, bool $includeTypeInReturnParameters = FALSE)
Get the display name and image of a contact.
at line 596
static
addBillingNameFieldsIfOtherwiseNotSet(array $params)
Add billing fields to the params if appropriate.
If we have ANY name fields then we want to ignore all the billing name fields. However, if we don't then we should set the name fields to the billing fields AND add the preserveDBName parameter (which will tell the BAO only to set those fields if none already exist.
We specifically don't want to set first name from billing and last name form an on-page field. Mixing & matching is best done by hipsters.
at line 627
static protected int|null
resolveStateProvinceID(array $values, int|null $countryID)
Resolve a state province string (UT or Utah) to an ID.
If country has been passed in we should select a state belonging to that country.
Alternatively we should choose from enabled countries, prioritising the default country.
at line 702
static protected string
getLocationEntityForKey(string $fieldName)
Get the relevant location entity for the array key.
Based on the field name we determine which location entity we are dealing with. Apart from a few specific ones they are mostly 'address' (the default).
at line 725
array|NULL
createDefaultCrudLink(array $crudLinkSpec)
Create last viewed link to recently updated contact.
at line 767
static
resolveDefaults(array $defaults, bool $reverse = FALSE)
deprecated
deprecated
Get the values for pseudoconstants for name->value and reverse.
at line 874
static CRM_Contact_BAO_Contact
retrieve(array $params, array $defaults, bool $microformat = FALSE)
Fetch object based on array of properties.
at line 922
static null|string
displayName(int $id)
Get the display name of a contact.
at line 945
static bool
deleteContact(int $id, bool $restore = FALSE, bool $skipUndelete = FALSE, bool $checkPermissions = TRUE)
Delete a contact and all its associated records.
at line 1078
static
updateContactCache(int $contactID, bool $isTrashed = FALSE)
Action to update any caches relating to a recently update contact.
I was going to call this from delete as well as from create to ensure the delete is being done whenever a contact is set to is_deleted=1 BUT I found create is already over-aggressive in that regard so adding it to delete seems to be enough to remove it from CRM_Contact_BAO_Contact_Permission where the call involved a subquery that was locking the table.
at line 1102
static bool
deleteContactImage(int $id)
Delete the image of a contact.
at line 1127
static array
getThumbSize(int $imageWidth, int $imageHeight)
Return proportional height and width of the image.
at line 1161
static bool
processImageParams(array $params, string $imageIndex = 'image_URL', string $statusMsg = NULL, string $opType = 'status')
Validate type of contact image.
at line 1198
static
processImage()
Extract contact id from url for deleting contact image.
at line 1227
static bool
contactTrashRestore(CRM_Contact_DAO_Contact $contact, bool $restore = FALSE)
Function to set is_delete true or restore deleted contact.
at line 1259
static string
getContactType(int $id)
Get contact type for a contact.
at line 1274
static string
getContactSubType(int $id, string $implodeDelimiter = NULL)
Get contact sub type for a contact.
at line 1296
static array
getContactTypes(int $id)
Get pair of contact-type and sub-type for a contact.
at line 1340
static array
importableFields(int|string $contactType = 'Individual', bool $status = FALSE, bool $showAll = FALSE, bool $isProfile = FALSE, bool $checkPermission = TRUE, bool $withMultiCustomFields = FALSE)
Combine all the importable fields from the lower levels object.
The ordering is important, since currently we do not have a weight scheme. Adding weight is super important
at line 1536
static array
exportableFields(int|string $contactType = 'Individual', bool $status = FALSE, bool $export = FALSE, bool $search = FALSE, bool $withMultiRecord = FALSE, bool $checkPermissions = TRUE)
Combine all the exportable fields from the lower levels object.
Currently we are using importable fields as exportable fields
at line 1770
static array
getHierContactDetails(int $contactId, array $fields)
Get the all contact details (Hierarchical).
at line 1798
static array
makeHierReturnProperties($fields, int $contactId = NULL)
Given a set of flat profile style field names, create a hierarchy.
This is for the query to use, create the right sql.
at line 1873
static int
getPrimaryLocationType(int $contactId, bool $skipDefaultPriamry = FALSE, null $block = NULL)
Return the primary location type of a contact.
$params int $contactId contact_id $params boolean $isPrimaryExist if true, return primary contact location type otherwise null $params boolean $skipDefaultPriamry if true, return primary contact location type otherwise null
at line 1936
static array
getContactDetails(int $id)
Get the display name, primary email and location type of a contact.
at line 1992
static int
createProfileContact(array $params, array $fields = [], int $contactID = NULL, int $addToGroupID = NULL, int $ufGroupId = NULL, string $ctype = NULL, bool $visibility = FALSE)
Add/edit/register contacts through profile.
at line 2105
static array
formatProfileContactParams(array $params, $fields, int $contactID = NULL, int $ufGroupId = NULL, null $ctype = NULL, bool $skipCustom = FALSE)
Format profile contact parameters.
at line 2478
static object|null
matchContactOnEmail(string $mail, string $ctype = NULL)
Find the get contact details.
This function does not respect ACLs for now, which might need to be rectified at some stage based on how its used.
at line 2529
static object|null
matchContactOnOpenId(string $openId, string $ctype = NULL)
Find the contact details associated with an OpenID.
at line 2566
static string
getPrimaryEmail(int $contactID)
Get primary email of the contact.
at line 2593
static string
getPrimaryOpenId(int $contactID)
Function to get primary OpenID of the contact.
at line 2622
static CRM_Contact_BAO_Contact|null
getValues(array $params, array $values)
Fetch the object and store the values in the values array.
at line 2705
static int
getCountComponent(string $component, int $contactId, string $tableName = NULL)
Given the component name and returns the count of participation of contact.
at line 2786
static
updateGreetingsOnTokenFieldChange(array $updatedFields, array $contactParams)
Update contact greetings if an update has resulted in a custom field change.
at line 2807
static
processGreetings(object $contact)
Process greetings and cache.
at line 2940
static array
getLocBlockIds(int $contactId, array $criteria = [], string $condOperator = 'AND')
Retrieve loc block ids w/ given condition.
at line 2988
static array
contextMenu(int $contactId = NULL)
Build context menu items.
at line 3310
static bool
checkUserMenuPermissions(array $aclPermissionedTasks, string $corePermission, array $menuOptions)
Check if user has permissions to access items in action menu.
at line 3371
static string|null
getMasterDisplayName(int $masterAddressId = NULL, int $contactId = NULL)
Retrieve display name of contact that address is shared.
This is based on $masterAddressId or $contactId .
at line 3394
static array
getTimestamps(int $contactId)
Get the creation/modification times for a contact.
at line 3425
static
triggerInfo($info, null $tableName = NULL)
Get a list of triggers for the contact table.
at line 3471
static bool
checkDomainContact(int $contactId)
Check if contact is being used in civicrm_domain based on $contactId.
at line 3554
static bool
deleteObjectWithPrimary(string $type, int $id)
Delete a contact-related object that has an 'is_primary' field.
Ensures that is_primary gets assigned to another object if available Also calls pre/post hooks
at line 3623
static array
getDuplicateContacts(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = [], bool $checkPermissions = TRUE, int $ruleGroupID = NULL, array $contextParams = [])
Get any existing duplicate contacts based on the input parameters.
at line 3658
static int|null
getFirstDuplicateContact(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = [], bool $checkPermissions = TRUE, int $ruleGroupID = NULL, array $contextParams = [])
Get the first duplicate contacts based on the input parameters.
at line 3676
static bool
isFieldHasLocationType(string $fieldTitle)
Check if a field is associated with an entity that has a location type.
(ie. is an address, phone, email etc field).