class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup

UF group BAO class.

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

PUBLIC_VISIBILITY

ADMIN_VISIBILITY

LISTINGS_VISIBILITY

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_Core_DAO_UFGroup
static bool $_log Should CiviCRM log any modifications to this table in the civicrm_log table. from CRM_Core_DAO_UFGroup
int $id Unique table ID from CRM_Core_DAO_UFGroup
bool $is_active Is this form currently active? If false, hide all related fields for all sharing contexts. from CRM_Core_DAO_UFGroup
string $group_type Comma separated list of the type(s) of profile fields. from CRM_Core_DAO_UFGroup
string $title Form title. from CRM_Core_DAO_UFGroup
string $frontend_title Profile Form Public title from CRM_Core_DAO_UFGroup
text $description Optional verbose description of the profile. from CRM_Core_DAO_UFGroup
text $help_pre Description and/or help text to display before fields in form. from CRM_Core_DAO_UFGroup
text $help_post Description and/or help text to display after fields in form. from CRM_Core_DAO_UFGroup
int $limit_listings_group_id Group id, foreign key from civicrm_group from CRM_Core_DAO_UFGroup
string $post_URL Redirect to URL. from CRM_Core_DAO_UFGroup
int $add_to_group_id foreign key to civicrm_group_id from CRM_Core_DAO_UFGroup
bool $add_captcha Should a CAPTCHA widget be included this Profile form. from CRM_Core_DAO_UFGroup
bool $is_map Do we want to map results from this profile. from CRM_Core_DAO_UFGroup
$is_edit_link Should edit link display in profile selector from CRM_Core_DAO_UFGroup
$is_uf_link Should we display a link to the website profile in profile selector from CRM_Core_DAO_UFGroup
bool $is_update_dupe Should we update the contact record if we find a duplicate from CRM_Core_DAO_UFGroup
string $cancel_URL Redirect to URL when Cancle button clik . from CRM_Core_DAO_UFGroup
bool $is_cms_user Should we create a cms user for this profile from CRM_Core_DAO_UFGroup
text $notify from CRM_Core_DAO_UFGroup
bool $is_reserved Is this group reserved for use by some other CiviCRM functionality? from CRM_Core_DAO_UFGroup
string $name Name of the UF group for directly addressing it in the codebase from CRM_Core_DAO_UFGroup
int $created_id FK to civicrm_contact, who created this UF group from CRM_Core_DAO_UFGroup
datetime $created_date Date and time this UF group was created. from CRM_Core_DAO_UFGroup
$is_proximity_search Should we include proximity search feature in this profile search form? from CRM_Core_DAO_UFGroup
string $cancel_button_text Custom Text to display on the Cancel button when used in create or edit mode from CRM_Core_DAO_UFGroup
string $submit_button_text Custom Text to display on the submit button on profile edit/create screens from CRM_Core_DAO_UFGroup
bool $add_cancel_button Should a Cancel button be included in this Profile form. from CRM_Core_DAO_UFGroup
static string $_matchFields Cache the match clause used in this transaction.

Methods

__construct()

Class constructor.

__clone()

No description

__destruct()

Class destructor.

static 
getTableName()

Returns the names of this table

static 
init(string $dsn)

Initialize the DAO object.

static DB_common
getConnection()

No description

static 
disableFullGroupByMode()

Disables usage of the ONLY_FULL_GROUP_BY Mode if necessary

static 
reenableFullGroupByMode()

Re-enables ONLY_FULL_GROUP_BY sql_mode as necessary.

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.

DataObject|PEAR_Error
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, 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

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 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) deprecated

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 = ["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.

static bool
checkTableHasData(string $tableName)

Check if a given table has data.

bool
checkVersion($version)

No description

static CRM_Core_DAO
findById(int $id)

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

array
fetchAll()

Returns all results as array-encoded records.

fetchGenerator(string $type = 'dao')

Return the results as PHP generator.

mixed|NULL
fetchValue()

Returns a singular value.

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 = [], 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 = [], bool $abort = TRUE, null $daoName = NULL, bool $freeDAO = FALSE, bool $i18nRewrite = TRUE, bool $trapException = FALSE, array $options = [])

Execute a query.

bool
isValidOption(array $options)

Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level

static string|null
singleValueQuery(string $query, array $params = [], 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|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.

copyCustomFields(int $entityID, int $newEntityID)

Method that copies custom fields values from an old entity to a new one.

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

Cascade update through related entities.

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

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

Fetch object based on array of properties.

static 
dropAllTables()

Drop all CiviCRM tables.

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 = [], 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 = [])

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) deprecated

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 
getReferencesToContactTable()

Get all references to contact table.

static 
appendCustomTablesExtendingContacts(array $cidRefs)

Add custom tables that extend contacts to the list of contact references.

static 
appendCustomContactReferenceFields(array $cidRefs)

Add custom ContactReference fields to the list of contact references

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 = [])

Get options for the called BAO object's 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()

Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity

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 string|null
serializeField(array|null $value, int $serializationType)

Transform an array to a serialized string for database storage.

static array|null
unSerializeField(string|null $value, $serializationType)

Transform a serialized string from the database into an array.

static array
getEntityRefFilters()

No description

static array
getExportableFieldsWithPseudoConstants(string $baoClass)

Get exportable fields with pseudoconstants rendered as an extra field.

static array
fieldKeys()

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

bool
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 array
indices(bool $localize = TRUE)

Returns the list of indices

static object
retrieve(array $params, array $defaults)

Fetch object based on array of properties.

static string
getContactType(int $id)

Retrieve the first non-generic contact type

static string
getTitle(int $id)

Get the form title.

static bool
setIsActive(int $id, bool $is_active)

Update the is_active flag in the db.

static array
getRegistrationFields(int $action, int $mode, string $ctype = NULL)

Get all the registration fields.

static array
getListingFields(int $action, int $visibility, bool $considerSelector = FALSE, array $ufGroupIds = NULL, bool $searchable = NULL, null $restrict = NULL, bool $skipPermission = FALSE, int $permissionType = CRM_Core_Permission::SEARCH)

Get all the listing fields.

static array
getFields(mix $id, bool|int $register = FALSE, int $action = NULL, int $visibility = NULL, $searchable = NULL, bool $showAll = FALSE, string $restrict = NULL, bool $skipPermission = FALSE, null $ctype = NULL, int $permissionType = CRM_Core_Permission::CREATE, string $orderBy = 'field_name', null $orderProfiles = NULL, bool $eventProfile = FALSE)

Get all the fields that belong to the group with the name title, and format for use with buildProfile. This is the SQL analog of formatUFFields().

static array
formatUFFields(array $groupArr, array $fieldArrs, bool $visibility = NULL, bool $searchable = NULL, bool $showAll = FALSE, null $ctype = NULL, int $permissionType = CRM_Core_Permission::CREATE)

Format a list of UFFields for use with buildProfile. This is the in-memory analog of getFields().

static array
formatUFField(CRM_Core_DAO_UFGroup|CRM_Core_DAO $group, CRM_Core_DAO_UFField|CRM_Core_DAO $field, array $customFields, array $addressCustomFields, array $importableFields, int $permissionType = CRM_Core_Permission::CREATE)

Prepare a field for rendering with CRM_Core_BAO_UFGroup::buildProfile.

static string
createUFFieldQuery(int $groupId, bool $searchable, bool $showAll, int $visibility, string $orderBy)

Create a query to find all visible UFFields in a UFGroup.

static bool
filterUFField(CRM_Core_DAO_UFField|CRM_Core_DAO $field, bool $searchable, bool $showAll, int $visibility)

Create a query to find all visible UFFields in a UFGroup.

static array
getImportableFields($showAll, $profileType, $contactActivityProfile, bool $filterMode = TRUE) deprecated

Get a list of filtered field metadata.

static array
getProfileFieldMetadata(bool $isIncludeInactive)

Get the metadata for all potential profile fields.

static array
getLocationFields()

Get the fields relating to locations.

static mixed
getCustomFields($ctype)

No description

static bool
isValid(int $userID, string $name, bool $register = FALSE, int $action = NULL)

Check the data validity.

static string
getEditHTML(int $userID, string $title, int $action = NULL, bool $register = FALSE, bool $reset = FALSE, int $profileID = NULL, bool $doNotProcess = FALSE, null $ctype = NULL)

Get the html for the form that represents this particular group.

static null|array
getValues(int $cid, array $fields, array $values, bool $searchable = TRUE, array $componentWhere = NULL, bool $absolute = FALSE, null $additionalWhereClause = NULL)

Given a contact id and a field set, return the values from the db.

static bool
usedByModule(int $id)

Check if profile Group used by any module.

static bool
del(int $id)

Delete the profile Group.

static object
add(array $params, array $ids = [])

Add the UF Group.

static 
createUFJoin(array $params, int $ufGroupId)

Make uf join entries for an uf group.

static array
getUFJoinRecord(int $ufGroupId = NULL, int $displayName = NULL, int $status = NULL)

Get the UF Join records for an ufgroup id.

addUFJoin(array $params)

Function takes an associative array and creates a ufjoin record for ufgroup.

static 
delUFJoin(array $params)

Delete the uf join record for an uf group.

static int
getWeight(int $ufGroupId = NULL)

Get the weight for ufjoin record.

static array
getModuleUFGroup(string $moduleName = NULL, int $count = 0, bool $skipPermission = TRUE, int $op = CRM_Core_Permission::VIEW, array|NULL $returnFields = NULL)

Get the uf group for a module.

static bool
filterUFGroups(int $ufGroupId, int $contactID = NULL)

Filter ufgroups based on logged in user contact type.

static null
buildProfile(CRM_Core_Form $form, array $field, int $mode, int $contactId = NULL, bool $online = FALSE, string $usedFor = NULL, int $rowNumber = NULL, string $prefix = '')

Add profile field to a form.

static 
setProfileDefaults(int $contactId, array $fields, array $defaults, bool $singleProfile = TRUE, int $componentId = NULL, null $component = NULL)

Set profile defaults.

static array
getProfiles(array $types, bool $onlyPure = FALSE)

Get profiles by type eg: pure Individual etc

static array
getValidProfiles(array $required, array $optional = NULL)

Check whether a profile is valid combination of required and/or optional profile types

static array
checkValidProfile(array $ufId, array $required = NULL)

Check whether a profile is valid combination of required profile fields

static array
setRegisterDefaults(array $fields, array $defaults)

Get default value for Register.

static CRM_Core_DAO
copy(int $id)

make a copy of a profile, including all the fields in the profile

static 
commonSendMail(int $contactID, array $values)

Process that send notification e-mails

array
checkFieldsEmptyValues(int $gid, int $cid, array $params, bool $skipCheck = FALSE)

Given a contact id and a group id, returns the field values from the db for this group and notify email only if group's notify field is set and field values are not empty

static 
profileDisplay(int $gid, array $values, CRM_Core_Smarty $template)

Assign uf fields to template.

static array
formatFields(array $params, int $contactId = NULL)

Format fields for dupe Contact Matching.

static array
calculateGroupType(int $gId, bool $includeTypeValues = FALSE, int $ignoreFieldId = NULL)

Calculate the profile type 'group_type' as per profile fields.

static array
_calculateGroupType($ufFields, bool $includeTypeValues = FALSE, int $ignoreFieldId = NULL)

Calculate the profile type 'group_type' as per profile fields.

static bool
updateGroupTypes(int $gId, array $groupTypes = [])

Update the profile type 'group_type' as per profile fields including group types and group subtype values.

static string
encodeGroupType(array $coreTypes, array $subTypes, string $delim = CRM_Core_DAO::VALUE_SEPARATOR)

Create a "group_type" string.

static 
setComponentDefaults(array $fields, int $componentId, string $component, array $defaults, bool $isStandalone = FALSE)

setDefault componet specific profile fields.

static array
profileGroups(int $profileID)

Retrieve groups of profiles.

static array
getDoubleOptInGroupIds(array $params, int $contactId = NULL)

Alter contact params by filtering existing subscribed groups and returns unsubscribed groups array for subscription.

static bool
checkForMixProfiles(array $profileIds)

Check if we are rendering mixed profiles.

static bool
showOverlayProfile()

Determine of we show overlay profile or not.

static array
groupTypeValues(int $profileId, string $groupType = NULL)

Get group type values of the profile.

static bool|object
isProfileDoubleOptin()

No description

static bool|object
static array
getBatchProfiles()

Get profiles used for batch entry.

static array|null
shiftMultiRecordFields($source, $destination, bool $returnMultiSummaryFields = FALSE)

No description

static 
reformatProfileFields(array $fields)

This is function is used to format pseudo fields.

static string
getFrontEndTitle(int $profileID)

Get the frontend_title for the profile, falling back on 'title' if none.

static $defaults
reformatProfileDefaults(array $field, string $value)

This function is used to format the profile default values.

Details

in CRM_Core_DAO_UFGroup at line 221
CRM_Core_DAO __construct()

Class constructor.

Return Value

CRM_Core_DAO

in CRM_Core_DAO at line 130
__clone()

in CRM_Core_DAO at line 139
__destruct()

Class destructor.

in CRM_Core_DAO_UFGroup at line 633
static getTableName()

Returns the names of this table

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

Initialize the DAO object.

Parameters

string $dsn The database connection string.

in CRM_Core_DAO at line 185
static DB_common getConnection()

Return Value

DB_common

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)

Parameters

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.

Parameters

string $fieldName
array $fieldDef
int $counter The globally-unique ID of the 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)

Parameters

string $tableName

Return Value

string

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).

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 447
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 457
DataObject|PEAR_Error factory(string $table = '')

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

Parameters

string $table

Return Value

DataObject|PEAR_Error

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'.

Return Value

array

in CRM_Core_DAO at line 499
array sequenceKey()

Tells DB_DataObject which keys use autoincrement.

'id' is autoincrementing by default.

Return Value

array

in CRM_Core_DAO_UFGroup at line 232
static array getReferenceColumns()

Returns foreign keys and entity references.

Return Value

array Array of CRM_Core_Reference_Interface

in CRM_Core_DAO_UFGroup at line 248
static array fields()

Returns all the column names of this table

Return Value

array

in CRM_Core_DAO at line 535
array table()

Get/set an associative array of table columns

Return Value

array (associative)

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

Save DAO object.

Parameters

bool $hook

Return Value

CRM_Core_DAO

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.

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 628
log(bool $created = FALSE)

Parameters

bool $created

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

Parameters

array $params (reference ) associative array of name/value pairs.
bool $serializeArrays Should arrays that are passed in be serialised according to the metadata. Eventually this should be always true / gone, but in the interests of caution it is being grandfathered in. In general an array is not valid on the DAO but there may be instances where this function is called & then some handling takes place on the would-be array.

Return Value

bool Did we copy all null values into the object

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.

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 747
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 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.

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 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.

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 871
static bool checkFieldExists(string $tableName, string $columnName, bool $i18nRewrite = TRUE) deprecated

deprecated

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

See also

CRM_Core_BAO_SchemaHandler::checkIfFieldExists

in CRM_Core_DAO at line 880
static array getTableNames()

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

Return Value

array

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

Parameters

int $maxTablesToCheck

Return Value

bool

in CRM_Core_DAO at line 919
static string getDatabaseName()

Get the name of the CiviCRM database.

Return Value

string

in CRM_Core_DAO at line 933
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 960
static bool schemaRequiresRebuilding(array $tables = ["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 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.

Parameters

string $tableName
string $columnName

Return Value

bool true if in format, false otherwise

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.

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 1039
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 1054
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 1073
static bool checkTableHasData(string $tableName)

Check if a given table has data.

Parameters

string $tableName

Return Value

bool TRUE if $tableName has at least one record.

in CRM_Core_DAO at line 1083
bool checkVersion($version)

Parameters

$version

Return Value

bool

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.

Parameters

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

Return Value

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

Exceptions

Exception

in CRM_Core_DAO at line 1117
array fetchAll()

Returns all results as array-encoded records.

Return Value

array

in CRM_Core_DAO at line 1131
fetchGenerator(string $type = 'dao')

Return the results as PHP generator.

Parameters

string $type Whether the generator yields 'dao' objects or 'array's.

in CRM_Core_DAO at line 1153
mixed|NULL fetchValue()

Returns a singular value.

Return Value

mixed|NULL

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

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 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

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 1277
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

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.

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 1335
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 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.

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 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.

Parameters

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

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 1456
bool isValidOption(array $options)

Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level

Parameters

array $options

Return Value

bool Provided options are valid

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.

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 1529
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 1576
static freeResult(null $ids = NULL)

Parameters

null $ids

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.

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
bool $blockCopyofCustomValues Case when you don't want to copy the custom values set in a template as it will override/ignore the submitted custom values

Return Value

CRM_Core_DAO|bool the newly created copy of the object. False if none created.

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.

Parameters

int $entityID
int $newEntityID

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

Cascade update through related entities.

Parameters

string $daoName
$fromId
$toId
array $newData

Return Value

CRM_Core_DAO|null

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

Parameters

$componentIDs
string $tableName
string $idField

Return Value

array

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.

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 1875
static dropAllTables()

Drop all CiviCRM tables.

Exceptions

CRM_Core_Exception

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

Parameters

$string

Return Value

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.

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 1945
static string escapeWildCardString($string)

Parameters

$string

Return Value

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

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 2062
static deleteTestObjects(string $daoName, array $params = [])

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 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)

Parameters

array $params
$defaults

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

deprecated

Parameters

string $prefix
bool $addRandomString
null $string

Return Value

string

See also

CRM_Utils_SQL_TempTable

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

Parameters

bool $view
bool $trigger

Return Value

bool

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

Parameters

null $message
bool $printDAO

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.

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 2233
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 2250
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 2261
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 2272
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 2295
array findReferences()

Find all records which refer to this entity.

Return Value

array Array of objects referencing this

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

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 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.

Parameters

array $cidRefs

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

Parameters

array $cidRefs

Exceptions

CiviCRM_API3_Exception

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

Parameters

array $fields

in CRM_Core_DAO at line 2531
static array|bool buildOptions(string $fieldName, string $context = NULL, array $props = [])

Get options for the called BAO object's field.

This function can be overridden by each BAO to add more logic related to context. The overriding function will generally call the lower-level CRM_Core_PseudoConstant::get

Parameters

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

Return Value

array|bool

See also

CRM_Core_DAO::buildOptionsContext

in CRM_Core_DAO at line 2542
getOptionLabels()

Populate option labels for this object's fields.

Exceptions

exception if called directly on the base class

in CRM_Core_DAO at line 2568
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 2588
bool|array getFieldSpec(string $fieldName)

Parameters

string $fieldName

Return Value

bool|array

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

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 2696
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 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.

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 2759
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 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

Parameters

array $options

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

deprecated

Parameters

array $params

in CRM_Core_DAO at line 2804
array addSelectWhereClause()

Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity

Return format is in the form of fieldname => clauses starting with an operator. e.g.:

Return Value

array

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

Parameters

string $tableAlias

Return Value

array

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.

Parameters

$database

Return Value

bool

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.

Parameters

array|null $value
int $serializationType

Return Value

string|null

Exceptions

Exception

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.

Parameters

string|null $value
$serializationType

Return Value

array|null

Exceptions

CRM_Core_Exception

in CRM_Core_DAO at line 2955
static array getEntityRefFilters()

Return Value

array

in CRM_Core_DAO at line 2966
static array getExportableFieldsWithPseudoConstants(string $baoClass)

Get exportable fields with pseudoconstants rendered as an extra field.

Parameters

string $baoClass

Return Value

array

in CRM_Core_DAO_UFGroup at line 621
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_Core_DAO_UFGroup at line 642
bool getLog()

Returns if this table needs to be logged

Return Value

bool

in CRM_Core_DAO_UFGroup at line 653
static array import(bool $prefix = FALSE)

Returns the list of fields that can be imported

Parameters

bool $prefix

Return Value

array

in CRM_Core_DAO_UFGroup at line 665
static array export(bool $prefix = FALSE)

Returns the list of fields that can be exported

Parameters

bool $prefix

Return Value

array

in CRM_Core_DAO_UFGroup at line 677
static array indices(bool $localize = TRUE)

Returns the list of indices

Parameters

bool $localize

Return Value

array

at line 61
static object retrieve(array $params, array $defaults)

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 flattened values.

Return Value

object CRM_Core_DAO_UFGroup object

at line 74
static string getContactType(int $id)

Retrieve the first non-generic contact type

Parameters

int $id Id of uf_group.

Return Value

string contact type

at line 108
static string getTitle(int $id)

Get the form title.

Parameters

int $id Id of uf_form.

Return Value

string title

at line 123
static bool setIsActive(int $id, bool $is_active)

Update the is_active flag in the db.

Parameters

int $id Id of the database record.
bool $is_active Value we want to set the is_active field.

Return Value

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

at line 142
static array getRegistrationFields(int $action, int $mode, string $ctype = NULL)

Get all the registration fields.

Parameters

int $action What action are we doing.
int $mode Mode.
string $ctype

Return Value

array the fields that are needed for registration

Exceptions

Exception

at line 206
static array getListingFields(int $action, int $visibility, bool $considerSelector = FALSE, array $ufGroupIds = NULL, bool $searchable = NULL, null $restrict = NULL, bool $skipPermission = FALSE, int $permissionType = CRM_Core_Permission::SEARCH)

Get all the listing fields.

Parameters

int $action What action are we doing.
int $visibility Visibility of fields we are interested in.
bool $considerSelector Whether to consider the in_selector parameter.
array $ufGroupIds
bool $searchable
null $restrict
bool $skipPermission
int $permissionType

Return Value

array the fields that are listings related

Exceptions

Exception

at line 289
static array getFields(mix $id, bool|int $register = FALSE, int $action = NULL, int $visibility = NULL, $searchable = NULL, bool $showAll = FALSE, string $restrict = NULL, bool $skipPermission = FALSE, null $ctype = NULL, int $permissionType = CRM_Core_Permission::CREATE, string $orderBy = 'field_name', null $orderProfiles = NULL, bool $eventProfile = FALSE)

Get all the fields that belong to the group with the name title, and format for use with buildProfile. This is the SQL analog of formatUFFields().

Parameters

mix $id The id of the UF group or ids of ufgroup.
bool|int $register are we interested in registration fields
int $action What action are we doing.
int $visibility Visibility of fields we are interested in.
$searchable
bool $showAll
string $restrict Should we restrict based on a specified profile type.
bool $skipPermission
null $ctype
int $permissionType
string $orderBy
null $orderProfiles
bool $eventProfile

Return Value

array The fields that belong to this ufgroup(s)

Exceptions

CRM_Core_Exception

at line 399
static array formatUFFields(array $groupArr, array $fieldArrs, bool $visibility = NULL, bool $searchable = NULL, bool $showAll = FALSE, null $ctype = NULL, int $permissionType = CRM_Core_Permission::CREATE)

Format a list of UFFields for use with buildProfile. This is the in-memory analog of getFields().

Parameters

array $groupArr (mimic CRM_UF_DAO_UFGroup).
array $fieldArrs List of fields (each mimics CRM_UF_DAO_UFField).
bool $visibility Visibility of fields we are interested in.
bool $searchable
bool $showAll
null $ctype
int $permissionType

Return Value

array

See also

self::getFields

at line 449
static protected array formatUFField(CRM_Core_DAO_UFGroup|CRM_Core_DAO $group, CRM_Core_DAO_UFField|CRM_Core_DAO $field, array $customFields, array $addressCustomFields, array $importableFields, int $permissionType = CRM_Core_Permission::CREATE)

Prepare a field for rendering with CRM_Core_BAO_UFGroup::buildProfile.

Parameters

CRM_Core_DAO_UFGroup|CRM_Core_DAO $group
CRM_Core_DAO_UFField|CRM_Core_DAO $field
array $customFields
array $addressCustomFields
array $importableFields
int $permissionType Eg CRM_Core_Permission::CREATE.

Return Value

array

at line 572
static protected string createUFFieldQuery(int $groupId, bool $searchable, bool $showAll, int $visibility, string $orderBy)

Create a query to find all visible UFFields in a UFGroup.

This is the SQL-variant of checkUFFieldDisplayable().

Parameters

int $groupId
bool $searchable
bool $showAll
int $visibility
string $orderBy Comma-delimited list of SQL columns.

Return Value

string

at line 620
static protected bool filterUFField(CRM_Core_DAO_UFField|CRM_Core_DAO $field, bool $searchable, bool $showAll, int $visibility)

Create a query to find all visible UFFields in a UFGroup.

This is the PHP in-memory variant of createUFFieldQuery().

Parameters

CRM_Core_DAO_UFField|CRM_Core_DAO $field
bool $searchable
bool $showAll
int $visibility

Return Value

bool TRUE if field is displayable

at line 667
static protected array getImportableFields($showAll, $profileType, $contactActivityProfile, bool $filterMode = TRUE) deprecated

deprecated use getProfileFieldMetadata

Get a list of filtered field metadata.

Parameters

$showAll
$profileType
$contactActivityProfile
bool $filterMode Filter mode means you are using importable fields for filtering rather than just getting metadata. With filter mode = FALSE BOTH activity fields and component fields are returned. I can't see why you would ever want to use this function in filter mode as the component fields are still unfiltered. However, I feel scared enough to leave it as it is. I have marked this function as deprecated and am recommending the wrapper 'getProfileFieldMetadata' in order to try to send this confusion to history.

Return Value

array

at line 705
static protected array getProfileFieldMetadata(bool $isIncludeInactive)

Get the metadata for all potential profile fields.

Parameters

bool $isIncludeInactive Should disabled fields be included.

Return Value

array Field metadata for all fields that might potentially be in a profile.

at line 714
static array getLocationFields()

Get the fields relating to locations.

Return Value

array

at line 743
static protected mixed getCustomFields($ctype)

Parameters

$ctype

Return Value

mixed

at line 775
static bool isValid(int $userID, string $name, bool $register = FALSE, int $action = NULL)

Check the data validity.

Parameters

int $userID The user id that we are actually editing.
string $name The machine-name of the group we are interested in.
bool $register
int $action The action of the form.

Return Value

bool true if form is valid

at line 826
static string getEditHTML(int $userID, string $title, int $action = NULL, bool $register = FALSE, bool $reset = FALSE, int $profileID = NULL, bool $doNotProcess = FALSE, null $ctype = NULL)

Get the html for the form that represents this particular group.

Parameters

int $userID The user id that we are actually editing.
string $title The title of the group we are interested in.
int $action The action of the form.
bool $register Is this the registration form.
bool $reset Should we reset the form?.
int $profileID Do we have the profile ID?.
bool $doNotProcess
null $ctype

Return Value

string the html for the form on success, otherwise empty string

at line 980
static null|array getValues(int $cid, array $fields, array $values, bool $searchable = TRUE, array $componentWhere = NULL, bool $absolute = FALSE, null $additionalWhereClause = NULL)

Given a contact id and a field set, return the values from the db.

Parameters

int $cid
array $fields The profile fields of interest.
array $values The values for the above fields.
bool $searchable Searchable or not.
array $componentWhere Component condition.
bool $absolute Return urls in absolute form (useful when sending an email).
null $additionalWhereClause

Return Value

null|array

at line 1397
static bool usedByModule(int $id)

Check if profile Group used by any module.

Parameters

int $id Profile Id.

Return Value

bool

at line 1422
static bool del(int $id)

Delete the profile Group.

Parameters

int $id Profile Id.

Return Value

bool

at line 1454
static object add(array $params, array $ids = [])

Add the UF Group.

Parameters

array $params Reference array contains the values submitted by the form.
array $ids Reference array contains the id.

Return Value

object

at line 1502
static createUFJoin(array $params, int $ufGroupId)

Make uf join entries for an uf group.

Parameters

array $params (reference) an assoc array of name/value pairs.
int $ufGroupId Ufgroup id.

at line 1573
static array getUFJoinRecord(int $ufGroupId = NULL, int $displayName = NULL, int $status = NULL)

Get the UF Join records for an ufgroup id.

Parameters

int $ufGroupId Uf group id.
int $displayName If set return display name in array.
int $status If set return module other than default modules (User Account/User registration/Profile).

Return Value

array

at line 1617
static CRM_Core_BAO_UFJoin addUFJoin(array $params)

Function takes an associative array and creates a ufjoin record for ufgroup.

Parameters

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

Return Value

CRM_Core_BAO_UFJoin

at line 1630
static delUFJoin(array $params)

Delete the uf join record for an uf group.

Parameters

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

at line 1645
static int getWeight(int $ufGroupId = NULL)

Get the weight for ufjoin record.

Parameters

int $ufGroupId If $ufGroupId get update weight or add weight.

Return Value

int weight of the UFGroup

at line 1681
static array getModuleUFGroup(string $moduleName = NULL, int $count = 0, bool $skipPermission = TRUE, int $op = CRM_Core_Permission::VIEW, array|NULL $returnFields = NULL)

Get the uf group for a module.

Parameters

string $moduleName Module name.
int $count No to increment the weight.
bool $skipPermission
int $op Which operation (view, edit, create, etc) to check permission for.
array|NULL $returnFields list of UFGroup fields to return; NULL for default

Return Value

array array of ufgroups for a module

at line 1753
static bool filterUFGroups(int $ufGroupId, int $contactID = NULL)

Filter ufgroups based on logged in user contact type.

Parameters

int $ufGroupId Uf group id (profile id).
int $contactID

Return Value

bool true or false

at line 1807
static null buildProfile(CRM_Core_Form $form, array $field, int $mode, int $contactId = NULL, bool $online = FALSE, string $usedFor = NULL, int $rowNumber = NULL, string $prefix = '')

Add profile field to a form.

Parameters

CRM_Core_Form $form
array $field Properties.
int $mode Profile mode.
int $contactId
bool $online
string $usedFor For building up prefixed fieldname for special cases (e.g. onBehalf, Honor).
int $rowNumber
string $prefix

Return Value

null

at line 2301
static setProfileDefaults(int $contactId, array $fields, array $defaults, bool $singleProfile = TRUE, int $componentId = NULL, null $component = NULL)

Set profile defaults.

Parameters

int $contactId Contact id.
array $fields Associative array of fields.
array $defaults Defaults array.
bool $singleProfile True for single profile else false(Update multiple items).
int $componentId Id for specific components like contribute, event etc.
null $component

at line 2505
static array getProfiles(array $types, bool $onlyPure = FALSE)

Get profiles by type eg: pure Individual etc

Parameters

array $types Associative array of types eg: types('Individual').
bool $onlyPure True if only pure profiles are required.

Return Value

array associative array of profiles

at line 2535
static array getValidProfiles(array $required, array $optional = NULL)

Check whether a profile is valid combination of required and/or optional profile types

Parameters

array $required Array of types those are required.
array $optional Array of types those are optional.

Return Value

array associative array of profiles

at line 2567
static array checkValidProfile(array $ufId, array $required = NULL)

Check whether a profile is valid combination of required profile fields

Parameters

array $ufId Integer id of the profile.
array $required Array of fields those are required in the profile.

Return Value

array associative array of profiles

at line 2607
static array setRegisterDefaults(array $fields, array $defaults)

Get default value for Register.

Parameters

array $fields
array $defaults

Return Value

array

at line 2633
static CRM_Core_DAO copy(int $id)

make a copy of a profile, including all the fields in the profile

Parameters

int $id The profile id to copy.

Return Value

CRM_Core_DAO

at line 2700
static commonSendMail(int $contactID, array $values)

Process that send notification e-mails

Parameters

int $contactID Contact id.
array $values Associative array of name/value pair.

at line 2761
array checkFieldsEmptyValues(int $gid, int $cid, array $params, bool $skipCheck = FALSE)

Given a contact id and a group id, returns the field values from the db for this group and notify email only if group's notify field is set and field values are not empty

Parameters

int $gid Group id.
int $cid Contact id.
array $params
bool $skipCheck

Return Value

array

at line 2793
static profileDisplay(int $gid, array $values, CRM_Core_Smarty $template)

Assign uf fields to template.

Parameters

int $gid Group id.
array $values
CRM_Core_Smarty $template

at line 2811
static array formatFields(array $params, int $contactId = NULL)

Format fields for dupe Contact Matching.

Parameters

array $params
int $contactId

Return Value

array associated formatted array

at line 2946
static array calculateGroupType(int $gId, bool $includeTypeValues = FALSE, int $ignoreFieldId = NULL)

Calculate the profile type 'group_type' as per profile fields.

Parameters

int $gId Profile id.
bool $includeTypeValues
int $ignoreFieldId Ignore particular profile field.

Return Value

array list of calculated group type

at line 2963
static array _calculateGroupType($ufFields, bool $includeTypeValues = FALSE, int $ignoreFieldId = NULL)

Calculate the profile type 'group_type' as per profile fields.

Parameters

$ufFields
bool $includeTypeValues
int $ignoreFieldId Ignore perticular profile field.

Return Value

array list of calculated group type

at line 3032
static bool updateGroupTypes(int $gId, array $groupTypes = [])

Update the profile type 'group_type' as per profile fields including group types and group subtype values.

Build and store string like: group_type1,group_type2[VALUE_SEPERATOR]group_type1Type:1:2:3,group_type2Type:1:2

FIELDS GROUP_TYPE BirthDate + Email Individual,Contact BirthDate + Subject Individual,Activity BirthDate + Subject + SurveyOnlyField Individual,Activity\0ActivityType:28 BirthDate + Subject + SurveyOnlyField + PhoneOnlyField (Not allowed) BirthDate + SurveyOnlyField Individual,Activity\0ActivityType:28 BirthDate + Subject + SurveyOrPhoneField Individual,Activity\0ActivityType:2:28 BirthDate + SurveyOrPhoneField Individual,Activity\0ActivityType:2:28 BirthDate + SurveyOrPhoneField + SurveyOnlyField Individual,Activity\0ActivityType:2:28 BirthDate + StudentField + Subject + SurveyOnlyField Individual,Activity,Student\0ActivityType:28

Parameters

int $gId
array $groupTypes With key having group type names.

Return Value

bool

at line 3105
static string encodeGroupType(array $coreTypes, array $subTypes, string $delim = CRM_Core_DAO::VALUE_SEPARATOR)

Create a "group_type" string.

Parameters

array $coreTypes E.g. array('Individual','Contact','Student').
array $subTypes E.g. array('ActivityType' => array(7, 11)).
string $delim

Return Value

string

Exceptions

CRM_Core_Exception

at line 3136
static setComponentDefaults(array $fields, int $componentId, string $component, array $defaults, bool $isStandalone = FALSE)

setDefault componet specific profile fields.

Parameters

array $fields Profile fields.
int $componentId ComponetID.
string $component Component name.
array $defaults An array of default values.
bool $isStandalone

at line 3283
static array profileGroups(int $profileID)

Retrieve groups of profiles.

Parameters

int $profileID Id of the profile.

Return Value

array returns array

at line 3305
static array getDoubleOptInGroupIds(array $params, int $contactId = NULL)

Alter contact params by filtering existing subscribed groups and returns unsubscribed groups array for subscription.

Parameters

array $params Contact params.
int $contactId User contact id.

Return Value

array This contains array of groups for subscription

at line 3379
static bool checkForMixProfiles(array $profileIds)

Check if we are rendering mixed profiles.

Parameters

array $profileIds Associated array of profile ids.

Return Value

bool true if profile is mixed

at line 3429
static bool showOverlayProfile()

Determine of we show overlay profile or not.

Return Value

bool true if profile should be shown else false

at line 3456
static array groupTypeValues(int $profileId, string $groupType = NULL)

Get group type values of the profile.

Parameters

int $profileId
string $groupType

Return Value

array group type values

at line 3498
static bool|object isProfileDoubleOptin()

Return Value

bool|object

at line 3510
static bool|object isProfileAddToGroupDoubleOptin()

Return Value

bool|object

at line 3525
static array getBatchProfiles()

Get profiles used for batch entry.

Return Value

array profileIds profile ids

at line 3545
static array|null shiftMultiRecordFields($source, $destination, bool $returnMultiSummaryFields = FALSE)

Parameters

$source
$destination
bool $returnMultiSummaryFields

Return Value

array|null

at line 3571
static reformatProfileFields(array $fields)

This is function is used to format pseudo fields.

Parameters

array $fields Associated array of profile fields.

at line 3604
static string getFrontEndTitle(int $profileID)

Get the frontend_title for the profile, falling back on 'title' if none.

Parameters

int $profileID

Return Value

string

Exceptions

CiviCRM_API3_Exception

at line 3620
static $defaults reformatProfileDefaults(array $field, string $value)

This function is used to format the profile default values.

Parameters

array $field Associated array of profile fields to render.
string $value Value to render

Return Value

$defaults String or array, depending on the html type