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

DROP_STRIP_FUNCTION_43

SQL function used to format the phone_numeric field via trigger.

CREATE_STRIP_FUNCTION_43

Properties

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 $_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 boolean $_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
boolean $do_not_email from CRM_Contact_DAO_Contact
boolean $do_not_phone from CRM_Contact_DAO_Contact
boolean $do_not_mail from CRM_Contact_DAO_Contact
boolean $do_not_sms from CRM_Contact_DAO_Contact
boolean $do_not_trade from CRM_Contact_DAO_Contact
boolean $is_opt_out Has the contact opted out from receiving all bulk email from the organization or site domain? from CRM_Contact_DAO_Contact
$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
$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
boolean $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
boolean $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

__construct()

Class constructor.

static 
getTableName()

Returns the names of this table

static 
init(string $dsn)

Initialize the DAO object.

static DB_common
getConnection()

No description

assignTestFK(string $fieldName, $fieldDef, array $params)

No description

assignTestValue(string $fieldName, array $fieldDef, int $counter)

Generate and assign an arbitrary value to a field of a test object.

reset()

Reset the DAO object.

static string
getLocaleTableName(string $tableName)

No description

object
query(string $query, bool $i18nRewrite = TRUE)

Execute a query by the current DAO, localizing it along the way (if needed).

static 
setFactory(object $factory)

Static function to set the factory instance for this class.

factory(string $table = '')

Factory method to instantiate a new object from a table name.

initialize()

Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.

array
keys()

Defines the default key as 'id'.

array
sequenceKey()

Tells DB_DataObject which keys use autoincrement.

static array
getReferenceColumns()

Returns foreign keys and entity references.

static array
fields()

Returns all the column names of this table

array
table()

Get/set an associative array of table columns

save(bool $hook = TRUE)

Save DAO object.

delete(bool $useWhere = FALSE)

Deletes items from table which match current objects variables.

log(bool $created = FALSE)

No description

bool
copyValues(array $params)

Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values

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.

static array|null
makeAttribute(array $field)

Create an attribute for this specific field. We only do this for strings and text

static array
getAttribute(string $class, string $fieldName = NULL)

Get the size and maxLength attributes for this text field.

static 
transaction($type)

No description

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.

static bool
checkFieldExists(string $tableName, string $columnName, bool $i18nRewrite = TRUE)

Check if there is a given column in a specific table.

static array
getTableNames()

Scans all the tables using a slow query and table name.

static bool
isDBMyISAM(int $maxTablesToCheck = 10)

No description

static string
getDatabaseName()

Get the name of the CiviCRM database.

static bool
checkConstraintExists(string $tableName, string $constraint)

Checks if a constraint exists for a specified table.

static bool
schemaRequiresRebuilding(array $tables = array("civicrm_contact"))

Checks if CONSTRAINT keyword exists for a specified table.

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.

static bool
checkFieldHasAlwaysValue(string $tableName, string $columnName, string $columnValue)

Check whether a specific column in a specific table has always the same value.

static bool
checkFieldIsAlwaysNull(string $tableName, string $columnName)

Check whether a specific column in a specific table is always NULL.

static bool
checkTableExists(string $tableName)

Check if there is a given table in the database.

bool
checkVersion($version)

No description

static object
findById(int $id)

Find a DAO object for the given ID and return it.

array
fetchAll()

Returns all results as array-encoded records.

array
fetchMap(string $keyColumn, string $valueColumn)

Get all the result records as mapping between columns.

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

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

static string
getSortString(array|object $sort, string $default = NULL)

Get sort string.

static object
commonRetrieve(string $daoName, array $params, array $defaults, array $returnProperities = NULL)

Fetch object based on array of properties.

static 
deleteEntityContact(string $daoName, int $contactId)

Delete the object records that are associated with this contact.

static CRM_Core_DAO
executeUnbufferedQuery(string $query, array $params = array(), bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)

Execute an unbuffered query.

static CRM_Core_DAO|object
executeQuery(string $query, array $params = array(), bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)

Execute a query.

static string|null
singleValueQuery(string $query, array $params = array(), bool $abort = TRUE, bool $i18nRewrite = TRUE)

Execute a query and get the single result.

static string
composeQuery(string $query, array $params, bool $abort = TRUE)

Compose the query by merging the parameters into it.

static 
freeResult(null $ids = NULL)

No description

static CRM_Core_DAO
copyGeneric(string $daoName, array $criteria, array $newData = NULL, string $fieldsFix = NULL, string $blockCopyOfDependencies = NULL)

make a shallow copy of an object.

static CRM_Core_DAO|null
cascadeUpdate(string $daoName, $fromId, $toId, array $newData = array())

Cascade update through related entities.

static array
getContactIDsFromComponent($componentIDs, string $tableName)

Given the component id, compute the contact id since its used for things like send email

static object
commonRetrieveAll(string $daoName, string $fieldIdName = 'id', int $fieldId, $details, array $returnProperities = NULL)

Fetch object based on array of properties.

static 
dropAllTables()

No description

static string
escapeString($string)

No description

static string
escapeStrings(array $strings, string $default = NULL)

Escape a list of strings for use with "WHERE X IN (.

static string
escapeWildCardString($string)

No description

static object|array|NULL
createTestObject(string $daoName, array $params = array(), 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

static 
deleteTestObjects(string $daoName, array $params = array())

Deletes the this object plus any dependent objects that are associated with it.

static 
setCreateDefaults(array $params, $defaults)

Set defaults when creating new entity.

static string
createTempTableName(string $prefix = 'civicrm', bool $addRandomString = TRUE, null $string = NULL)

No description

static bool
checkTriggerViewPermission(bool $view = TRUE, bool $trigger = TRUE)

No description

static 
debugPrint(null $message = NULL, bool $printDAO = TRUE)

No description

static 
triggerRebuild(string $tableName = NULL, bool $force = FALSE) deprecated

Build a list of triggers via hook and add them to (err, reconcile them with) the database.

static 
checkSqlFunctionsExist()

Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests

static 
dropTriggers(string $tableName = NULL) deprecated

Wrapper function to drop triggers.

static 
createTriggers(array $info, string $onlyTableName = NULL) deprecated

No description

static array
createReferenceColumns(string $className)

Given a list of fields, create a list of references.

array
findReferences()

Find all records which refer to this entity.

array
getReferenceCounts()

No description

static array
getReferencesToTable(string $tableName)

List all tables which have hard foreign keys to this table.

static mixed
getGlobalSetting(string $name, mixed $default = NULL)

Lookup the value of a MySQL global configuration variable.

static 
appendPseudoConstantsToFields(array $fields)

Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.

static array|bool
buildOptions(string $fieldName, string $context = NULL, array $props = array())

Get options for a given contact field.

getOptionLabels()

Populate option labels for this object's fields.

static array
buildOptionsContext(string $context = NULL)

Provides documentation and validation for the buildOptions $context param

bool|array
getFieldSpec(string $fieldName)

No description

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.

static array
acceptedSQLOperators()

No description

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 .

setOptions(array $options)

https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query

_setDBOptions(array $options)

https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level

setApiFilter(array $params) deprecated

No description

array
addSelectWhereClause()

No description

static array
getSelectWhereClause(string $tableAlias = NULL)

This returns the final permissioned query string for this entity

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.

static array
fieldKeys()

Return a mapping from field-name to the corresponding key (as used in fields()).

boolean
getLog()

Returns if this table needs to be logged

static array
import(bool $prefix = false)

Returns the list of fields that can be imported

static array
export(bool $prefix = false)

Returns the list of fields that can be exported

static 
indices($localize = TRUE)

Returns the list of indices

add(array $params)

Takes an associative array and creates a contact object.

create(array $params, bool $fixAddress = TRUE, bool $invokeHooks = TRUE, bool $skipDelete = FALSE)

Create contact.

static array
getDisplayAndImage(int $id, bool $includeTypeInReturnParameters = FALSE)

Get the display name and image of a contact.

static 
addBillingNameFieldsIfOtherwiseNotSet(array $params)

Add billing fields to the params if appropriate.

array|NULL
createDefaultCrudLink(array $crudLinkSpec)

Create last viewed link to recently updated contact.

static 
resolveDefaults(array $defaults, bool $reverse = FALSE)

Get the values for pseudoconstants for name->value and reverse.

retrieve(array $params, array $defaults, bool $microformat = FALSE)

Fetch object based on array of properties.

static null|string
displayName(int $id)

Get the display name of a contact.

static bool
deleteContact(int $id, bool $restore = FALSE, bool $skipUndelete = FALSE, bool $checkPermissions = TRUE)

Delete a contact and all its associated records.

static 
updateContactCache(int $contactID, bool $isTrashed = FALSE)

Action to update any caches relating to a recently update contact.

static bool
deleteContactImage(int $id)

Delete the image of a contact.

static array
getThumbSize(int $imageWidth, int $imageHeight)

Return proportional height and width of the image.

static bool
processImageParams(array $params, string $imageIndex = 'image_URL', string $statusMsg = NULL, string $opType = 'status')

Validate type of contact image.

static 
processImage()

Extract contact id from url for deleting contact image.

static bool
contactTrashRestore(CRM_Contact_DAO_Contact $contact, bool $restore = FALSE)

Function to set is_delete true or restore deleted contact.

static string
getContactType(int $id)

Get contact type for a contact.

static string
getContactSubType(int $id, string $implodeDelimiter = NULL)

Get contact sub type for a contact.

static array
getContactTypes(int $id)

Get pair of contact-type and sub-type for a contact.

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.

static array
exportableFields($contactType = 'Individual', $status = FALSE, $export = FALSE, $search = FALSE, $withMultiRecord = FALSE, $checkPermissions = TRUE)

Combine all the exportable fields from the lower levels object.

static array
getHierContactDetails(int $contactId, array $fields)

Get the all contact details (Hierarchical).

static array
makeHierReturnProperties($fields, int $contactId = NULL)

Given a set of flat profile style field names, create a hierarchy.

static int
getPrimaryLocationType(int $contactId, bool $skipDefaultPriamry = FALSE, null $block = NULL)

Return the primary location type of a contact.

static array
getContactDetails(int $id)

Get the display name, primary email and location type of a contact.

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.

static array
formatProfileContactParams(array $params, $fields, int $contactID = NULL, int $ufGroupId = NULL, null $ctype = NULL, bool $skipCustom = FALSE)

Format profile contact parameters.

static object|null
matchContactOnEmail(string $mail, string $ctype = NULL)

Find the get contact details.

static object|null
matchContactOnOpenId(string $openId, string $ctype = NULL)

Find the contact details associated with an OpenID.

static string
getPrimaryEmail(int $contactID)

Get primary email of the contact.

static string
getPrimaryOpenId(int $contactID)

Function to get primary OpenID of the contact.

getValues(array $params, array $values)

Fetch the object and store the values in the values array.

static int
getCountComponent(string $component, int $contactId, string $tableName = NULL)

Given the component name and returns the count of participation of contact.

static 
processGreetings(object $contact, bool $useDefaults = FALSE)

Process greetings and cache.

static array
getLocBlockIds(int $contactId, array $criteria = array(), string $condOperator = 'AND')

Retrieve loc block ids w/ given condition.

static array
contextMenu(int $contactId = NULL)

Build context menu items.

static bool
checkUserMenuPermissions(array $aclPermissionedTasks, string $corePermission, array $menuOptions)

Check if user has permissions to access items in action menu.

static string|null
getMasterDisplayName(int $masterAddressId = NULL, int $contactId = NULL)

Retrieve display name of contact that address is shared.

static array
getTimestamps(int $contactId)

Get the creation/modification times for a contact.

static 
generateTimestampTriggers(array $info, string|null $reqTableName, array $relatedTableNames, string $contactRefColumn)

Generate triggers to update the timestamp.

static 
triggerInfo($info, null $tableName = NULL)

Get a list of triggers for the contact table.

static bool
checkDomainContact(int $contactId)

Check if contact is being used in civicrm_domain based on $contactId.

static bool
deleteObjectWithPrimary(string $type, int $id)

Delete a contact-related object that has an 'is_primary' field.

static array
getDuplicateContacts(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = array(), bool $checkPermissions = TRUE, int $ruleGroupID = NULL)

Get any existing duplicate contacts based on the input parameters.

static int|NULL
getFirstDuplicateContact(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = array(), bool $checkPermissions = TRUE, int $ruleGroupID = NULL)

Get the first duplicate contacts based on the input parameters.

Details

at line 101
CRM_Core_DAO __construct()

Class constructor.

Return Value

CRM_Core_DAO

in CRM_Contact_DAO_Contact at line 1381
static getTableName()

Returns the names of this table

in CRM_Core_DAO at line 112
static init(string $dsn)

Initialize the DAO object.

Parameters

string $dsn The database connection string.

in CRM_Core_DAO at line 131
static DB_common getConnection()

Return Value

DB_common

in CRM_Core_DAO at line 142
protected assignTestFK(string $fieldName, $fieldDef, array $params)

Parameters

string $fieldName
$fieldDef
array $params

in CRM_Core_DAO at line 191
protected assignTestValue(string $fieldName, array $fieldDef, int $counter)

Generate and assign an arbitrary value to a field of a test object.

Parameters

string $fieldName
array $fieldDef
int $counter The globally-unique ID of the test object.

in CRM_Core_DAO at line 303
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 323
static string getLocaleTableName(string $tableName)

Parameters

string $tableName

Return Value

string

in CRM_Core_DAO at line 345
object query(string $query, bool $i18nRewrite = TRUE)

Execute a query by the current DAO, localizing it along the way (if needed).

Parameters

string $query The SQL query for execution.
bool $i18nRewrite Whether to rewrite the query.

Return Value

object the current DAO object after the query execution

in CRM_Core_DAO at line 374
static setFactory(object $factory)

Static function to set the factory instance for this class.

Parameters

object $factory The factory application object.

in CRM_Core_DAO at line 383
factory(string $table = '')

Factory method to instantiate a new object from a table name.

Parameters

string $table

in CRM_Core_DAO at line 395
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 411
array keys()

Defines the default key as 'id'.

Return Value

array

in CRM_Core_DAO at line 426
array sequenceKey()

Tells DB_DataObject which keys use autoincrement.

'id' is autoincrementing by default.

Return Value

array

static array getReferenceColumns()

Returns foreign keys and entity references.

Return Value

array Array of CRM_Core_Reference_Interface

static array fields()

Returns all the column names of this table

Return Value

array

in CRM_Core_DAO at line 462
array table()

Get/set an associative array of table columns

Return Value

array (associative)

in CRM_Core_DAO at line 485
CRM_Core_DAO save(bool $hook = TRUE)

Save DAO object.

Parameters

bool $hook

Return Value

CRM_Core_DAO

in CRM_Core_DAO at line 536
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.

Parameters

bool $useWhere (optional) If DB_DATAOBJECT_WHEREADD_ONLY is passed in then we will build the condition only using the whereAdd's. Default is to build the condition only using the object parameters.

* @return mixed Int (No. of rows affected) on success, false on failure, 0 on no data affected

in CRM_Core_DAO at line 552
log(bool $created = FALSE)

Parameters

bool $created

in CRM_Core_DAO at line 587
bool copyValues(array $params)

Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values

Parameters

array $params (reference ) associative array of name/value pairs.

Return Value

bool Did we copy all null values into the object

in CRM_Core_DAO at line 628
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.

Parameters

object $object The object that we are extracting data from.
array $values (reference ) associative array of name/value pairs.

in CRM_Core_DAO at line 650
static array|null makeAttribute(array $field)

Create an attribute for this specific field. We only do this for strings and text

Parameters

array $field The field under task.

Return Value

array|null the attributes for the object

in CRM_Core_DAO at line 703
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.

Parameters

string $class Name of DAO class.
string $fieldName Field that i'm interested in or null if. you want the attributes for all DAO text fields

Return Value

array assoc array of name => attribute pairs

in CRM_Core_DAO at line 731
static transaction($type)

Parameters

$type

Exceptions

Exception

in CRM_Core_DAO at line 754
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.

Parameters

string $value The value of the field we are checking.
string $daoName The dao object name.
string $daoID The id of the object being updated. u can change your name. as long as there is no conflict
string $fieldName The name of the field in the DAO.
string $domainID The id of the domain. Object exists only for the given domain.

Return Value

bool true if object exists

in CRM_Core_DAO at line 780
static bool checkFieldExists(string $tableName, string $columnName, bool $i18nRewrite = TRUE)

Check if there is a given column in a specific table.

Parameters

string $tableName
string $columnName
bool $i18nRewrite Whether to rewrite the query on multilingual setups.

Return Value

bool true if exists, else false

in CRM_Core_DAO at line 798
static array getTableNames()

Scans all the tables using a slow query and table name.

Return Value

array

in CRM_Core_DAO at line 820
static bool isDBMyISAM(int $maxTablesToCheck = 10)

Parameters

int $maxTablesToCheck

Return Value

bool

in CRM_Core_DAO at line 837
static string getDatabaseName()

Get the name of the CiviCRM database.

Return Value

string

in CRM_Core_DAO at line 851
static bool checkConstraintExists(string $tableName, string $constraint)

Checks if a constraint exists for a specified table.

Parameters

string $tableName
string $constraint

Return Value

bool true if constraint exists, false otherwise

in CRM_Core_DAO at line 879
static bool schemaRequiresRebuilding(array $tables = array("civicrm_contact"))

Checks if CONSTRAINT keyword exists for a specified table.

Parameters

array $tables

Return Value

bool true if CONSTRAINT keyword exists, false otherwise

Exceptions

Exception

in CRM_Core_DAO at line 915
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.

Parameters

string $tableName
string $columnName

Return Value

bool true if in format, false otherwise

in CRM_Core_DAO at line 944
static bool checkFieldHasAlwaysValue(string $tableName, string $columnName, string $columnValue)

Check whether a specific column in a specific table has always the same value.

Parameters

string $tableName
string $columnName
string $columnValue

Return Value

bool true if the value is always $columnValue, false otherwise

in CRM_Core_DAO at line 961
static bool checkFieldIsAlwaysNull(string $tableName, string $columnName)

Check whether a specific column in a specific table is always NULL.

Parameters

string $tableName
string $columnName

Return Value

bool true if if the value is always NULL, false otherwise

in CRM_Core_DAO at line 977
static bool checkTableExists(string $tableName)

Check if there is a given table in the database.

Parameters

string $tableName

Return Value

bool true if exists, else false

in CRM_Core_DAO at line 995
bool checkVersion($version)

Parameters

$version

Return Value

bool

in CRM_Core_DAO at line 1013
static object findById(int $id)

Find a DAO object for the given ID and return it.

Parameters

int $id Id of the DAO object being searched for.

Return Value

object Object of the type of the class that called this function.

in CRM_Core_DAO at line 1027
array fetchAll()

Returns all results as array-encoded records.

Return Value

array

in CRM_Core_DAO at line 1045
array fetchMap(string $keyColumn, string $valueColumn)

Get all the result records as mapping between columns.

Parameters

string $keyColumn Ex: "name"
string $valueColumn Ex: "label"

Return Value

array Ex: ["foo" => "The Foo Bar", "baz" => "The Baz Qux"]

in CRM_Core_DAO at line 1070
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

Parameters

string $daoName Name of the DAO (Example: CRM_Contact_DAO_Contact to retrieve value from a contact).
int $searchValue Value of the column you want to search by.
string $returnColumn Name of the column you want to GET the value of.
string $searchColumn Name of the column you want to search by.
bool $force Skip use of the cache.

Return Value

string|null Value of $returnColumn in the retrieved record

in CRM_Core_DAO at line 1120
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

Parameters

string $daoName Name of the DAO (Example: CRM_Contact_DAO_Contact to retrieve value from a contact).
int $searchValue Value of the column you want to search by.
string $setColumn Name of the column you want to SET the value of.
string $setValue SET the setColumn to this value.
string $searchColumn Name of the column you want to search by.

Return Value

bool true if we found and updated the object, else false

in CRM_Core_DAO at line 1146
static string getSortString(array|object $sort, string $default = NULL)

Get sort string.

Parameters

array|object $sort either array or CRM_Utils_Sort
string $default Default sort value.

Return Value

string sortString

in CRM_Core_DAO at line 1177
static object commonRetrieve(string $daoName, array $params, array $defaults, array $returnProperities = NULL)

Fetch object based on array of properties.

Parameters

string $daoName Name of the dao object.
array $params (reference ) an assoc array of name/value pairs.
array $defaults (reference ) an assoc array to hold the flattened values.
array $returnProperities An assoc array of fields that need to be returned, eg array( 'first_name', 'last_name').

Return Value

object an object of type referenced by daoName

in CRM_Core_DAO at line 1202
static deleteEntityContact(string $daoName, int $contactId)

Delete the object records that are associated with this contact.

Parameters

string $daoName Name of the dao object.
int $contactId Id of the contact to delete.

in CRM_Core_DAO at line 1227
static CRM_Core_DAO executeUnbufferedQuery(string $query, array $params = array(), 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.

Parameters

string $query query to be executed
array $params
bool $abort
null $daoName
bool $freeDAO
bool $i18nRewrite
bool $trapException

Return Value

CRM_Core_DAO Object that points to an unbuffered result set

in CRM_Core_DAO at line 1293
static CRM_Core_DAO|object executeQuery(string $query, array $params = array(), bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE)

Execute a query.

Parameters

string $query Query to be executed.
array $params
bool $abort
null $daoName
bool $freeDAO
bool $i18nRewrite
bool $trapException

Return Value

CRM_Core_DAO|object object that holds the results of the query NB - if this is defined as just returning a DAO phpstorm keeps pointing out all the properties that are not part of the DAO

in CRM_Core_DAO at line 1343
static string|null singleValueQuery(string $query, array $params = array(), bool $abort = TRUE, bool $i18nRewrite = TRUE)

Execute a query and get the single result.

Parameters

string $query Query to be executed.
array $params
bool $abort
bool $i18nRewrite

Return Value

string|null the result of the query if any

in CRM_Core_DAO at line 1381
static string composeQuery(string $query, array $params, bool $abort = TRUE)

Compose the query by merging the parameters into it.

Parameters

string $query
array $params
bool $abort

Return Value

string

Exceptions

Exception

in CRM_Core_DAO at line 1428
static freeResult(null $ids = NULL)

Parameters

null $ids

in CRM_Core_DAO at line 1474
static CRM_Core_DAO copyGeneric(string $daoName, array $criteria, array $newData = NULL, string $fieldsFix = NULL, string $blockCopyOfDependencies = NULL)

make a shallow copy of an object.

and all the fields in the object

Parameters

string $daoName Name of the dao.
array $criteria Array of all the fields & values. on which basis to copy
array $newData Array of all the fields & values. to be copied besides the other fields
string $fieldsFix Array of fields that you want to prefix/suffix/replace.
string $blockCopyOfDependencies Fields that you want to block from. getting copied

Return Value

CRM_Core_DAO the newly created copy of the object

in CRM_Core_DAO at line 1557
static CRM_Core_DAO|null cascadeUpdate(string $daoName, $fromId, $toId, array $newData = array())

Cascade update through related entities.

Parameters

string $daoName
$fromId
$toId
array $newData

Return Value

CRM_Core_DAO|null

in CRM_Core_DAO at line 1601
static array getContactIDsFromComponent($componentIDs, string $tableName)

Given the component id, compute the contact id since its used for things like send email

Parameters

$componentIDs
string $tableName

Return Value

array

in CRM_Core_DAO at line 1636
static object commonRetrieveAll(string $daoName, string $fieldIdName = 'id', int $fieldId, $details, array $returnProperities = NULL)

Fetch object based on array of properties.

Parameters

string $daoName Name of the dao object.
string $fieldIdName
int $fieldId
$details
array $returnProperities An assoc array of fields that need to be returned, eg array( 'first_name', 'last_name').

Return Value

object an object of type referenced by daoName

in CRM_Core_DAO at line 1658
static dropAllTables()

in CRM_Core_DAO at line 1680
static string escapeString($string)

Parameters

$string

Return Value

string

in CRM_Core_DAO at line 1709
static string escapeStrings(array $strings, string $default = NULL)

Escape a list of strings for use with "WHERE X IN (.

..)" queries.

Parameters

array $strings
string $default the value to use if $strings has no elements.

Return Value

string eg "abc","def","ghi"

in CRM_Core_DAO at line 1728
static string escapeWildCardString($string)

Parameters

$string

Return Value

string

in CRM_Core_DAO at line 1756
static object|array|NULL createTestObject(string $daoName, array $params = array(), 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

Parameters

string $daoName
array $params
int $numObjects
bool $createOnly

Return Value

object|array|NULL NULL if $createOnly. A single object if $numObjects==1. Otherwise, an array of multiple objects.

in CRM_Core_DAO at line 1839
static deleteTestObjects(string $daoName, array $params = array())

Deletes the this object plus any dependent objects that are associated with it.

ONLY USE FOR TESTING

Parameters

string $daoName
array $params

in CRM_Core_DAO at line 1885
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)

Parameters

array $params
$defaults

in CRM_Core_DAO at line 1903
static string createTempTableName(string $prefix = 'civicrm', bool $addRandomString = TRUE, null $string = NULL)

Parameters

string $prefix
bool $addRandomString
null $string

Return Value

string

in CRM_Core_DAO at line 1923
static bool checkTriggerViewPermission(bool $view = TRUE, bool $trigger = TRUE)

Parameters

bool $view
bool $trigger

Return Value

bool

in CRM_Core_DAO at line 1971
static debugPrint(null $message = NULL, bool $printDAO = TRUE)

Parameters

null $message
bool $printDAO

in CRM_Core_DAO at line 1995
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.

Parameters

string $tableName the specific table requiring a rebuild; or NULL to rebuild all tables.
bool $force

See also

CRM-9716

in CRM_Core_DAO at line 2006
static checkSqlFunctionsExist()

Because sql functions are sometimes lost, esp during db migration, we check here to avoid numerous support requests

See also

http://issues.civicrm.org/jira/browse/CRM-13822 TODO: Alternative solutions might be * Stop using functions and find another way to strip numeric characters from phones * Give better error messages (currently a missing fn fatals with "unknown error")

in CRM_Core_DAO at line 2023
static dropTriggers(string $tableName = NULL) deprecated

deprecated

Wrapper function to drop triggers.

Parameters

string $tableName the specific table requiring a rebuild; or NULL to rebuild all tables.

in CRM_Core_DAO at line 2034
static createTriggers(array $info, string $onlyTableName = NULL) deprecated

deprecated

Parameters

array $info per hook_civicrm_triggerInfo.
string $onlyTableName the specific table requiring a rebuild; or NULL to rebuild all tables.

in CRM_Core_DAO at line 2045
static array createReferenceColumns(string $className)

Given a list of fields, create a list of references.

Parameters

string $className BAO/DAO class name.

Return Value

array

in CRM_Core_DAO at line 2068
array findReferences()

Find all records which refer to this entity.

Return Value

array Array of objects referencing this

in CRM_Core_DAO at line 2097
array getReferenceCounts()

Return Value

array each item has keys: - name: string - type: string - count: int - table: string|null SQL table name - key: string|null SQL column name

in CRM_Core_DAO at line 2134
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.

Parameters

string $tableName Table referred to.

Return Value

array structure of table and column, listing every table with a foreign key reference to $tableName, and the column where the key appears.

in CRM_Core_DAO at line 2158
static mixed getGlobalSetting(string $name, mixed $default = NULL)

Lookup the value of a MySQL global configuration variable.

Parameters

string $name E.g. "thread_stack".
mixed $default

Return Value

mixed

in CRM_Core_DAO at line 2183
static protected 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 for purposes keeping the scope of the change small, but is appropriate for other sorts of pseudoconstants.

Parameters

array $fields

at line 3438
static array|bool buildOptions(string $fieldName, string $context = NULL, array $props = array())

Get options for a given contact field.

Parameters

string $fieldName
string $context
array $props whatever is known about this bao object.

Return Value

array|bool

See also

CRM_Core_DAO::buildOptions TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow? TODO: In context of chainselect, what to return if e.g. a country has no states?
CRM_Core_DAO::buildOptionsContext

in CRM_Core_DAO at line 2220
getOptionLabels()

Populate option labels for this object's fields.

Exceptions

exception if called directly on the base class

in CRM_Core_DAO at line 2246
static array buildOptionsContext(string $context = NULL)

Provides documentation and validation for the buildOptions $context param

Parameters

string $context

Return Value

array

Exceptions

Exception

in CRM_Core_DAO at line 2266
bool|array getFieldSpec(string $fieldName)

Parameters

string $fieldName

Return Value

bool|array

in CRM_Core_DAO at line 2309
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

Parameters

string $fieldName Name of fields.
array $filter filter to be applied indexed by operator.
string $type type of field (not actually used - nor in api @todo ).
string $alias alternative field name ('as') @todo- not actually used.
bool $returnSanitisedArray Return a sanitised array instead of a clause. this is primarily so we can add filters @ the api level to the Query object based fields

Return Value

NULL|string|array a string is returned if $returnSanitisedArray is not set, otherwise and Array or NULL depending on whether it is supported as yet

Exceptions

Exception

in CRM_Core_DAO at line 2372
static array acceptedSQLOperators()

Return Value

array

See also

http://issues.civicrm.org/jira/browse/CRM-9150 support for other syntaxes is discussed in ticket but being put off for now

in CRM_Core_DAO at line 2409
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.

Parameters

string $string The string to be shortened.
int $length The max length of the string.
bool $makeRandom

Return Value

string

in CRM_Core_DAO at line 2435
setOptions(array $options)

https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query

Parameters

array $options

in CRM_Core_DAO at line 2448
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

Parameters

array $options

in CRM_Core_DAO at line 2463
setApiFilter(array $params) deprecated

deprecated

Parameters

array $params

at line 3530
array addSelectWhereClause()

Return Value

array

in CRM_Core_DAO at line 2521
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

Parameters

string $tableAlias

Return Value

array

in CRM_Core_DAO at line 2544
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.

Parameters

$database

Return Value

bool

in CRM_Contact_DAO_Contact at line 1370
static array fieldKeys()

Return a mapping from field-name to the corresponding key (as used in fields()).

Return Value

array Array(string $name => string $uniqueName).

in CRM_Contact_DAO_Contact at line 1389
boolean getLog()

Returns if this table needs to be logged

Return Value

boolean

in CRM_Contact_DAO_Contact at line 1399
static array import(bool $prefix = false)

Returns the list of fields that can be imported

Parameters

bool $prefix

Return Value

array

in CRM_Contact_DAO_Contact at line 1410
static array export(bool $prefix = false)

Returns the list of fields that can be exported

Parameters

bool $prefix

Return Value

array

in CRM_Contact_DAO_Contact at line 1417
static indices($localize = TRUE)

Returns the list of indices

Parameters

$localize

at line 119
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

Parameters

array $params (reference) an assoc array of name/value pairs.

Return Value

CRM_Contact_BAO_Contact|CRM_Core_Error|NULL Created or updated contact object or error object. (error objects are being phased out in favour of exceptions)

at line 272
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

Parameters

array $params (reference ) an assoc array of name/value pairs.
bool $fixAddress If we need to fix address.
bool $invokeHooks If we need to invoke hooks.
bool $skipDelete Unclear parameter, passed to website create

Return Value

CRM_Contact_BAO_Contact|CRM_Core_Error Created or updated contribution object. We are deprecating returning an error in favour of exceptions

Exceptions

Exception

at line 470
static array getDisplayAndImage(int $id, bool $includeTypeInReturnParameters = FALSE)

Get the display name and image of a contact.

Parameters

int $id The contactId.
bool $includeTypeInReturnParameters Should type be part of the returned array?

Return Value

array the displayName and contactImage for this contact

at line 522
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 filling 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.

Parameters

array $params

Create last viewed link to recently updated contact.

Parameters

array $crudLinkSpec
  • action: int, CRM_Core_Action::UPDATE or CRM_Core_Action::VIEW [default: VIEW]
    • entity_table: string, eg "civicrm_contact"
    • entity_id: int

Return Value

array|NULL NULL if unavailable, or [path: string, query: string, title: string]

See also

CRM_Utils_System::createDefaultCrudLink

at line 588
static resolveDefaults(array $defaults, bool $reverse = FALSE)

Get the values for pseudoconstants for name->value and reverse.

Parameters

array $defaults (reference) the default values, some of which need to be resolved.
bool $reverse True if we want to resolve the values in the reverse direction (value -> name).

at line 722
static CRM_Contact_BAO_Contact retrieve(array $params, array $defaults, bool $microformat = FALSE)

Fetch object based on array of properties.

Parameters

array $params (reference ) an assoc array of name/value pairs.
array $defaults (reference ) an assoc array to hold the name / value pairs. in a hierarchical manner
bool $microformat For location in microformat.

Return Value

CRM_Contact_BAO_Contact

at line 770
static null|string displayName(int $id)

Get the display name of a contact.

Parameters

int $id Id of the contact.

Return Value

null|string display name of the contact if found

at line 793
static bool deleteContact(int $id, bool $restore = FALSE, bool $skipUndelete = FALSE, bool $checkPermissions = TRUE)

Delete a contact and all its associated records.

Parameters

int $id Id of the contact to delete.
bool $restore Whether to actually restore, not delete.
bool $skipUndelete Whether to force contact delete or not.
bool $checkPermissions

Return Value

bool Was contact deleted?

at line 928
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.

Parameters

int $contactID
bool $isTrashed

at line 952
static bool deleteContactImage(int $id)

Delete the image of a contact.

Parameters

int $id Id of the contact.

Return Value

bool Was contact image deleted?

at line 976
static array getThumbSize(int $imageWidth, int $imageHeight)

Return proportional height and width of the image.

Parameters

int $imageWidth Width of image.
int $imageHeight Height of image.

Return Value

array Thumb dimension of image

at line 1010
static bool processImageParams(array $params, string $imageIndex = 'image_URL', string $statusMsg = NULL, string $opType = 'status')

Validate type of contact image.

Parameters

array $params
string $imageIndex Index of image field.
string $statusMsg Status message to be set after operation.
string $opType Type of operation like fatal, bounce etc.

Return Value

bool true if valid image extension

at line 1047
static processImage()

Extract contact id from url for deleting contact image.

at line 1076
static bool contactTrashRestore(CRM_Contact_DAO_Contact $contact, bool $restore = FALSE)

Function to set is_delete true or restore deleted contact.

Parameters

CRM_Contact_DAO_Contact $contact Contact DAO object.
bool $restore True to set the is_delete = 1 else false to restore deleted contact, i.e. is_delete = 0

Return Value

bool

at line 1107
static string getContactType(int $id)

Get contact type for a contact.

Parameters

int $id Id of the contact whose contact type is needed.

Return Value

string contact_type if $id found else null ""

at line 1122
static string getContactSubType(int $id, string $implodeDelimiter = NULL)

Get contact sub type for a contact.

Parameters

int $id Id of the contact whose contact sub type is needed.
string $implodeDelimiter

Return Value

string contact_sub_type if $id found else null ""

at line 1144
static array getContactTypes(int $id)

Get pair of contact-type and sub-type for a contact.

Parameters

int $id Id of the contact whose contact sub/contact type is needed.

Return Value

array

at line 1188
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

Parameters

int|string $contactType contact Type
bool $status Status is used to manipulate first title.
bool $showAll If true returns all fields (includes disabled fields).
bool $isProfile If its profile mode.
bool $checkPermission If false, do not include permissioning clause (for custom data).
bool $withMultiCustomFields

Return Value

array array of importable Fields

at line 1387
static array exportableFields($contactType = 'Individual', $status = FALSE, $export = FALSE, $search = FALSE, $withMultiRecord = FALSE, $checkPermissions = TRUE)

Combine all the exportable fields from the lower levels object.

Currently we are using importable fields as exportable fields

Parameters

$contactType
$status
$export
$search
$withMultiRecord
$checkPermissions

Return Value

array array of exportable Fields

at line 1626
static array getHierContactDetails(int $contactId, array $fields)

Get the all contact details (Hierarchical).

Parameters

int $contactId Contact id.
array $fields Fields array.

Return Value

array Contact details

at line 1654
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.

Parameters

$fields
int $contactId Contact id.

Return Value

array A hierarchical property tree if appropriate

at line 1729
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

Parameters

int $contactId
bool $skipDefaultPriamry
null $block

Return Value

int $locationType location_type_id

at line 1792
static array getContactDetails(int $id)

Get the display name, primary email and location type of a contact.

Parameters

int $id Id of the contact.

Return Value

array Array of display_name, email if found, do_not_email or (null,null,null)

at line 1848
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.

Parameters

array $params Array of profile fields to be edited/added.
array $fields Array of fields from UFGroup.
int $contactID Id of the contact to be edited/added.
int $addToGroupID Specifies the default group to which contact is added.
int $ufGroupId Uf group id (profile id).
string $ctype
bool $visibility Basically lets us know where this request is coming from. if via a profile from web, we restrict what groups are changed

Return Value

int contact id created/edited

at line 1959
static array formatProfileContactParams(array $params, $fields, int $contactID = NULL, int $ufGroupId = NULL, null $ctype = NULL, bool $skipCustom = FALSE)

Format profile contact parameters.

Parameters

array $params
$fields
int $contactID
int $ufGroupId
null $ctype
bool $skipCustom

Return Value

array

at line 2339
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.

Parameters

string $mail Primary email address of the contact.
string $ctype Contact type.

Return Value

object|null $dao contact details

at line 2390
static object|null matchContactOnOpenId(string $openId, string $ctype = NULL)

Find the contact details associated with an OpenID.

Parameters

string $openId OpenId of the contact.
string $ctype Contact type.

Return Value

object|null $dao contact details

at line 2427
static string getPrimaryEmail(int $contactID)

Get primary email of the contact.

Parameters

int $contactID Contact id.

Return Value

string Email address if present else null

at line 2455
static string getPrimaryOpenId(int $contactID)

Function to get primary OpenID of the contact.

Parameters

int $contactID Contact id.

Return Value

string

openid OpenID if present else null

at line 2485
static CRM_Contact_BAO_Contact|null getValues(array $params, array $values)

Fetch the object and store the values in the values array.

Parameters

array $params Input parameters to find object.
array $values Output values of the object.

Return Value

CRM_Contact_BAO_Contact|null The found object or null

at line 2568
static int getCountComponent(string $component, int $contactId, string $tableName = NULL)

Given the component name and returns the count of participation of contact.

Parameters

string $component Input component name.
int $contactId Input contact id.
string $tableName Optional tableName if component is custom group.

Return Value

int total number in database

at line 2647
static processGreetings(object $contact, bool $useDefaults = FALSE)

Process greetings and cache.

Parameters

object $contact Contact object after save.
bool $useDefaults Use default greeting values.

at line 2802
static array getLocBlockIds(int $contactId, array $criteria = array(), string $condOperator = 'AND')

Retrieve loc block ids w/ given condition.

Parameters

int $contactId Contact id.
array $criteria Key => value pair which should be. fulfill by return record ids.
string $condOperator Operator use for grouping multiple conditions.

Return Value

array loc block ids which fulfill condition.

at line 2851
static array contextMenu(int $contactId = NULL)

Build context menu items.

Parameters

int $contactId

Return Value

array Array of context menu for logged in user.

at line 3173
static bool checkUserMenuPermissions(array $aclPermissionedTasks, string $corePermission, array $menuOptions)

Check if user has permissions to access items in action menu.

Parameters

array $aclPermissionedTasks Array containing ACL related tasks.
string $corePermission The permission of the user (edit or view or null).
array $menuOptions Array containing params of the menu (title, href, etc).

Return Value

bool TRUE if user has all permissions, FALSE if otherwise.

at line 3234
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 .

Parameters

int $masterAddressId Master id.
int $contactId Contact id.

Return Value

string|null the found display name or null.

at line 3266
static array getTimestamps(int $contactId)

Get the creation/modification times for a contact.

Parameters

int $contactId

Return Value

array Dates - ('created_date' => $, 'modified_date' => $)

at line 3305
static generateTimestampTriggers(array $info, string|null $reqTableName, array $relatedTableNames, string $contactRefColumn)

Generate triggers to update the timestamp.

The corresponding civicrm_contact row is updated on insert/update/delete to a table that extends civicrm_contact. Don't regenerate triggers for all such tables if only asked for one table.

Parameters

array $info Reference to the array where generated trigger information is being stored
string|null $reqTableName Name of the table for which triggers are being generated, or NULL if all tables
array $relatedTableNames Array of all core or all custom table names extending civicrm_contact
string $contactRefColumn 'contact_id' if processing core tables, 'entity_id' if processing custom tables

See also

triggerInfo

at line 3341
static triggerInfo($info, null $tableName = NULL)

Get a list of triggers for the contact table.

Parameters

$info
null $tableName

See also

hook_civicrm_triggerInfo
CRM_Core_DAO::triggerRebuild
http://issues.civicrm.org/jira/browse/CRM-10554

at line 3408
static bool checkDomainContact(int $contactId)

Check if contact is being used in civicrm_domain based on $contactId.

Parameters

int $contactId Contact id.

Return Value

bool true if present else false.

at line 3490
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

Parameters

string $type
int $id

Return Value

bool

at line 3558
static array getDuplicateContacts(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = array(), bool $checkPermissions = TRUE, int $ruleGroupID = NULL)

Get any existing duplicate contacts based on the input parameters.

Parameters

array $input Input parameters to be matched.
string $contactType
string $rule
  • Supervised
    • Unsupervised
$excludedContactIDs An array of ids not to be included in the results.
bool $checkPermissions
int $ruleGroupID ID of the rule group to be used if an override is desirable.

Return Value

array

at line 3582
static int|NULL getFirstDuplicateContact(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = array(), bool $checkPermissions = TRUE, int $ruleGroupID = NULL)

Get the first duplicate contacts based on the input parameters.

Parameters

array $input Input parameters to be matched.
string $contactType
string $rule
  • Supervised
    • Unsupervised
$excludedContactIDs An array of ids not to be included in the results.
bool $checkPermissions
int $ruleGroupID ID of the rule group to be used if an override is desirable.

Return Value

int|NULL