<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
* @param NULL
*
* @return array Data type => Description
- * @access public
* @static
*/
- static function &dataType() {
+ public static function &dataType() {
if (!(self::$_dataType)) {
self::$_dataType = array(
'String' => ts('Alphanumeric'),
/**
* @return array
*/
- static function dataToHtml() {
+ public static function dataToHtml() {
if (!self::$_dataToHtml) {
self::$_dataToHtml = array(
array(
- 'Text' => 'Text', 'Select' => 'Select',
- 'Radio' => 'Radio', 'CheckBox' => 'CheckBox',
+ 'Text' => 'Text',
+ 'Select' => 'Select',
+ 'Radio' => 'Radio',
+ 'CheckBox' => 'CheckBox',
'Multi-Select' => 'Multi-Select',
'AdvMulti-Select' => 'AdvMulti-Select',
'Autocomplete-Select' => 'Autocomplete-Select',
*
* This function is invoked from within the web form layer and also from the api layer
*
- * @param array $params (reference) an assoc array of name/value pairs
+ * @param array $params
+ * (reference) an assoc array of name/value pairs.
*
* @return CRM_Core_DAO_CustomField object
- * @access public
* @static
*/
- static function create(&$params) {
+ public static function create(&$params) {
$origParams = array_merge(array(), $params);
if (!isset($params['id'])) {
$indexExist = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $params['id'], 'is_searchable');
}
- switch (CRM_Utils_Array::value('html_type', $params)){
+ switch (CRM_Utils_Array::value('html_type', $params)) {
case 'Select Date':
- if(empty($params['date_format'])){
+ if (empty($params['date_format'])) {
$config = CRM_Core_Config::singleton();
$params['date_format'] = $config->dateInputFormat;
}
break;
+
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
$params['default_value'] = $params['option_value'][$params['default_option']];
}
}
- break;
+ break;
}
$transaction = new CRM_Core_Transaction();
// create any option group & values if required
if ($params['html_type'] != 'Text' &&
in_array($params['data_type'], array(
- 'String', 'Int', 'Float', 'Money'))
+ 'String',
+ 'Int',
+ 'Float',
+ 'Money'
+ ))
) {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup',
'table_name'
);
-
if ($params['option_type'] == 1 && empty($params['option_group_id'])) {
// first create an option group for this custom group
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->is_active = 1;
$optionGroup->save();
$params['option_group_id'] = $optionGroup->id;
- if(!empty($params['option_value']) && is_array($params['option_value'])){
+ if (!empty($params['option_value']) && is_array($params['option_value'])) {
foreach ($params['option_value'] as $k => $v) {
if (strlen(trim($v))) {
$optionValue = new CRM_Core_DAO_OptionValue();
);
if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR,
- $defaultValue
- ))) {
+ $defaultValue
+ ))
+ ) {
$params['default_value'] = $defaultValue;
}
}
/**
* Fetch object based on array of properties
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $defaults (reference ) an assoc array to hold the flattened values
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
*
* @return CRM_Core_DAO_CustomField object
- * @access public
* @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
}
/**
* Update the is_active flag in the db
*
- * @param int $id Id of the database record
- * @param boolean $is_active Value we want to set the is_active field
+ * @param int $id
+ * Id of the database record.
+ * @param bool $is_active
+ * Value we want to set the is_active field.
*
* @return Object DAO object on sucess, null otherwise
*
- * @access public
* @static
*/
- static function setIsActive($id, $is_active) {
+ public static function setIsActive($id, $is_active) {
CRM_Utils_System::flushCache();
/**
* Get the field title.
*
- * @param int $id id of field.
+ * @param int $id
+ * Id of field.
*
* @return string name
*
- * @access public
* @static
*
*/
/**
* Store and return an array of all active custom fields.
*
- * @param string $customDataType type of Custom Data; empty is a synonym for "all contact data types"
- * @param boolean $showAll If true returns all fields (includes disabled fields)
- * @param boolean $inline If true returns all inline fields (includes disabled fields)
- * @param int $customDataSubType Custom Data sub type value
- * @param int $customDataSubName Custom Data sub name value
- * @param boolean $onlyParent return only top level custom data, for eg, only Participant and ignore subname and subtype
- * @param boolean $onlySubType return only custom data for subtype
- * @param boolean $checkPermission if false, do not include permissioning clause
+ * @param string $customDataType
+ * Type of Custom Data; empty is a synonym for "all contact data types".
+ * @param bool $showAll
+ * If true returns all fields (includes disabled fields).
+ * @param bool $inline
+ * If true returns all inline fields (includes disabled fields).
+ * @param int $customDataSubType
+ * Custom Data sub type value.
+ * @param int $customDataSubName
+ * Custom Data sub name value.
+ * @param bool $onlyParent
+ * Return only top level custom data, for eg, only Participant and ignore subname and subtype.
+ * @param bool $onlySubType
+ * Return only custom data for subtype.
+ * @param bool $checkPermission
+ * If false, do not include permissioning clause.
*
* @return array $fields - an array of active custom fields.
*
- * @access public
* @static
*/
- public static function &getFields($customDataType = 'Individual',
- $showAll = FALSE,
- $inline = FALSE,
- $customDataSubType = NULL,
- $customDataSubName = NULL,
- $onlyParent = FALSE,
- $onlySubType = FALSE,
- $checkPermission = TRUE
+ public static function &getFields(
+ $customDataType = 'Individual',
+ $showAll = FALSE,
+ $inline = FALSE,
+ $customDataSubType = NULL,
+ $customDataSubName = NULL,
+ $onlyParent = FALSE,
+ $onlySubType = FALSE,
+ $checkPermission = TRUE
) {
if (empty($customDataType)) {
$customDataType = array('Contact', 'Individual', 'Organization', 'Household');
* Return the field ids and names (with groups) for import purpose.
*
* @param int|string $contactType Contact type
- * @param boolean $showAll If true returns all fields (includes disabled fields)
- * @param boolean $onlyParent return fields ONLY related to basic types
- * @param boolean $search when called from search and multiple records need to be returned
- * @param boolean $checkPermission if false, do not include permissioning clause
+ * @param bool $showAll
+ * If true returns all fields (includes disabled fields).
+ * @param bool $onlyParent
+ * Return fields ONLY related to basic types.
+ * @param bool $search
+ * When called from search and multiple records need to be returned.
+ * @param bool $checkPermission
+ * If false, do not include permissioning clause.
*
* @param bool $withMultiple
*
* @return array $fields -
*
- * @access public
* @static
*/
- public static function &getFieldsForImport($contactType = 'Individual',
- $showAll = FALSE,
- $onlyParent = FALSE,
- $search = FALSE,
+ public static function &getFieldsForImport(
+ $contactType = 'Individual',
+ $showAll = FALSE,
+ $onlyParent = FALSE,
+ $search = FALSE,
$checkPermission = TRUE,
- $withMultiple = FALSE
+ $withMultiple = FALSE
) {
// Note: there are situations when we want getFieldsForImport() return fields related
// ONLY to basic contact types, but NOT subtypes. And thats where $onlyParent is helpful
/**
* Get the field id from an import key
*
- * @param string $key The key to parse
+ * @param string $key
+ * The key to parse.
*
* @param bool $all
* @return int|null The id (if exists)
- * @access public
* @static
*/
public static function getKeyID($key, $all = FALSE) {
/**
* Use the cache to get all values of a specific custom field
*
- * @param int $fieldID the custom field ID
+ * @param int $fieldID
+ * The custom field ID.
*
* @return CRM_Core_DAO_CustomField $field the field object
* @static
* public
*/
- static function getFieldObject($fieldID) {
+ public static function getFieldObject($fieldID) {
$field = new CRM_Core_DAO_CustomField();
// check if we can get the field values from the system cache
- $cacheKey = "CRM_Core_DAO_CustomField_{$fieldID}";
- $cache = CRM_Utils_Cache::singleton();
+ $cacheKey = "CRM_Core_DAO_CustomField_{$fieldID}";
+ $cache = CRM_Utils_Cache::singleton();
$fieldValues = $cache->get($cacheKey);
if (empty($fieldValues)) {
$field->id = $fieldID;
/**
* This function for building custom fields
*
- * @param CRM_Core_Form $qf form object (reference)
- * @param string $elementName name of the custom field
+ * @param CRM_Core_Form $qf
+ * Form object (reference).
+ * @param string $elementName
+ * Name of the custom field.
* @param int $fieldId
- * @param boolean $inactiveNeeded -deprecated
- * @param bool $useRequired true if required else false
- * @param boolean $search true if used for search else false
- * @param string $label label for custom field
+ * @param bool $inactiveNeeded
+ * -deprecated.
+ * @param bool $useRequired
+ * True if required else false.
+ * @param bool $search
+ * True if used for search else false.
+ * @param string $label
+ * Label for custom field.
*
- * @access public
* @static
*/
- public static function addQuickFormElement(&$qf,
+ public static function addQuickFormElement(
+ &$qf,
$elementName,
$fieldId,
$inactiveNeeded = FALSE,
- $useRequired = TRUE,
- $search = FALSE,
- $label = NULL
+ $useRequired = TRUE,
+ $search = FALSE,
+ $label = NULL
) {
$field = self::getFieldObject($fieldId);
$widget = $field->html_type;
// Custom field HTML should indicate group+field name
$groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id);
- $dataCrmCustomVal = $groupName.':'.$field->name;
- $dataCrmCustomAttr = 'data-crm-custom="'.$dataCrmCustomVal.'"';
+ $dataCrmCustomVal = $groupName . ':' . $field->name;
+ $dataCrmCustomAttr = 'data-crm-custom="' . $dataCrmCustomVal . '"';
$field->attributes .= $dataCrmCustomAttr;
// Fixed for Issue CRM-2183
$placeholder = $search ? ts('- any -') : ($useRequired ? ts('- select -') : ts('- none -'));
// FIXME: Why are select state/country separate widget types?
- $isSelect = (in_array($widget, array('Select', 'Multi-Select', 'Select State/Province', 'Multi-Select State/Province', 'Select Country', 'Multi-Select Country', 'AdvMulti-Select', 'CheckBox', 'Radio')));
+ $isSelect = (in_array($widget, array(
+ 'Select',
+ 'Multi-Select',
+ 'Select State/Province',
+ 'Multi-Select State/Province',
+ 'Select Country',
+ 'Multi-Select Country',
+ 'AdvMulti-Select',
+ 'CheckBox',
+ 'Radio'
+ )));
if ($isSelect) {
- $options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array('field' => "custom_$fieldId", 'context' => $search ? 'search' : 'create'), array()));
+ $options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array(
+ 'field' => "custom_$fieldId",
+ 'context' => $search ? 'search' : 'create'
+ ), array()));
// Consolidate widget types to simplify the below switch statement
if ($search || ($widget !== 'AdvMulti-Select' && strpos($widget, 'Select') !== FALSE)) {
// Add data for popup link. Normally this is handled by CRM_Core_Form->addSelect
if ($field->option_group_id && !$search && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM')) {
$selectAttributes += array(
- 'data-api-entity' => 'contact', // FIXME: This works because the getoptions api isn't picky about custom fields, but it's WRONG
+ 'data-api-entity' => 'contact',
+ // FIXME: This works because the getoptions api isn't picky about custom fields, but it's WRONG
'data-api-field' => 'custom_' . $field->id,
'data-option-edit-path' => 'civicrm/admin/options/' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $field->option_group_id),
);
$qf->addDate($elementName, $label, $required, array(
'format' => $field->date_format,
- 'timeFormat' => $field->time_format,
- 'startOffset' => $field->start_date_years,
- 'endOffset' => $field->end_date_years,
- 'data-crm-custom' => $dataCrmCustomVal,
- ));
+ 'timeFormat' => $field->time_format,
+ 'startOffset' => $field->start_date_years,
+ 'endOffset' => $field->end_date_years,
+ 'data-crm-custom' => $dataCrmCustomVal,
+ ));
}
break;
case 'Radio':
$choice = array();
foreach ($options as $v => $l) {
- $choice[] = $qf->createElement('radio', NULL, '', $l, (string)$v, $field->attributes);
+ $choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $field->attributes);
}
$group = $qf->addGroup($choice, $elementName, $label);
if ($useRequired && !$search) {
break;
case 'RichTextEditor':
- $attributes = array('rows' => $field->note_rows, 'cols' => $field->note_columns, 'data-crm-custom' => $dataCrmCustomVal);
+ $attributes = array(
+ 'rows' => $field->note_rows,
+ 'cols' => $field->note_columns,
+ 'data-crm-custom' => $dataCrmCustomVal
+ );
if ($field->text_length) {
$attributes['maxlength'] = $field->text_length;
}
// Fixme: why is this a string in the first place??
$attributes = array();
if ($field->attributes) {
- foreach(explode(' ', $field->attributes) as $at) {
+ foreach (explode(' ', $field->attributes) as $at) {
if (strpos($at, '=')) {
list($k, $v) = explode('=', $at);
$attributes[$k] = trim($v, ' "');
/**
* Delete the Custom Field.
*
- * @param object $field - the field object
+ * @param object $field
+ * The field object.
*
* @return boolean
*
- * @access public
* @static
*
*/
* Given a custom field value, its id and the set of options
* find the display value for this field
*
- * @param mixed $value the custom field value
- * @param int $id the custom field id
- * @param int $options the assoc array of option name/value pairs
+ * @param mixed $value
+ * The custom field value.
+ * @param int $id
+ * The custom field id.
+ * @param int $options
+ * The assoc array of option name/value pairs.
*
* @param int $contactID
* @param int $fieldID
* @return string the display value
*
* @static
- * @access public
*/
- static function getDisplayValue($value, $id, &$options, $contactID = NULL, $fieldID = NULL) {
- $option = &$options[$id];
+ public static function getDisplayValue($value, $id, &$options, $contactID = NULL, $fieldID = NULL) {
+ $option = &$options[$id];
$attributes = &$option['attributes'];
- $html_type = $attributes['html_type'];
- $data_type = $attributes['data_type'];
- $format = CRM_Utils_Array::value('format', $attributes);
+ $html_type = $attributes['html_type'];
+ $data_type = $attributes['data_type'];
+ $format = CRM_Utils_Array::value('format', $attributes);
return self::getDisplayValueCommon($value,
$option,
*
* @return array|mixed|null|string
*/
- static function getDisplayValueCommon($value,
+ static function getDisplayValueCommon(
+ $value,
&$option,
$html_type,
$data_type,
- $format = NULL,
+ $format = NULL,
$contactID = NULL,
- $fieldID = NULL
+ $fieldID = NULL
) {
$display = $value;
if ($value) {
$display = ts('Yes');
}
- elseif ((string)$value === '0') {
+ elseif ((string) $value === '0') {
$display = ts('No');
}
}
/**
* Set default values for custom data used in profile
*
- * @param int $customFieldId custom field id
- * @param string $elementName custom field name
- * @param array $defaults associated array of fields
- * @param int $contactId contact id
- * @param int $mode profile mode
- * @param mixed $value if passed - dont fetch value from db,
+ * @param int $customFieldId
+ * Custom field id.
+ * @param string $elementName
+ * Custom field name.
+ * @param array $defaults
+ * Associated array of fields.
+ * @param int $contactId
+ * Contact id.
+ * @param int $mode
+ * Profile mode.
+ * @param mixed $value
+ * If passed - dont fetch value from db,.
* just format the given value
*
* @static
- * @access public
*/
- static function setProfileDefaults($customFieldId,
+ static function setProfileDefaults(
+ $customFieldId,
$elementName,
&$defaults,
$contactId = NULL,
}
else {
if (!isset($value)) {
- $info = self::getTableColumnGroup($customFieldId);
- $query = "SELECT {$info[0]}.{$info[1]} as value FROM {$info[0]} WHERE {$info[0]}.entity_id = {$contactId}";
+ $info = self::getTableColumnGroup($customFieldId);
+ $query = "SELECT {$info[0]}.{$info[1]} as value FROM {$info[0]} WHERE {$info[0]}.entity_id = {$contactId}";
$result = CRM_Core_DAO::executeQuery($query);
if ($result->fetch()) {
$value = $result->value;
*
* @return array
*/
- static function getFileURL($contactID, $cfID, $fileID = NULL, $absolute = FALSE, $multiRecordWhereClause = NULL) {
+ public static function getFileURL($contactID, $cfID, $fileID = NULL, $absolute = FALSE, $multiRecordWhereClause = NULL) {
if ($contactID) {
if (!$fileID) {
$params = array('id' => $cfID);
/**
* Format custom fields before inserting
*
- * @param int $customFieldId custom field id
- * @param array $customFormatted formatted array
- * @param mix $value value of custom field
- * @param string $customFieldExtend custom field extends
- * @param int $customValueId custom option value id
- * @param int $entityId entity id (contribution, membership...)
- * @param boolean $inline consider inline custom groups only
- * @param boolean $checkPermission if false, do not include permissioning clause
- * @param boolean $includeViewOnly if true, fields marked 'View Only' are included. Required for APIv3.
+ * @param int $customFieldId
+ * Custom field id.
+ * @param array $customFormatted
+ * Formatted array.
+ * @param mix $value
+ * Value of custom field.
+ * @param string $customFieldExtend
+ * Custom field extends.
+ * @param int $customValueId
+ * Custom option value id.
+ * @param int $entityId
+ * Entity id (contribution, membership...).
+ * @param bool $inline
+ * Consider inline custom groups only.
+ * @param bool $checkPermission
+ * If false, do not include permissioning clause.
+ * @param bool $includeViewOnly
+ * If true, fields marked 'View Only' are included. Required for APIv3.
*
* @return array $customFormatted formatted custom field array
* @static
*/
- static function formatCustomField($customFieldId, &$customFormatted, $value,
+ static function formatCustomField(
+ $customFieldId, &$customFormatted, $value,
$customFieldExtend, $customValueId = NULL,
$entityId = NULL,
$inline = FALSE,
$checkPermission = TRUE,
- $includeViewOnly = false
+ $includeViewOnly = FALSE
) {
//get the custom fields for the entity
//subtype and basic type
}
if (in_array($customFieldExtend,
- CRM_Contact_BAO_ContactType::subTypes()
- )) {
+ CRM_Contact_BAO_ContactType::subTypes()
+ )) {
// This is the case when getFieldsForImport() requires fields
// of subtype and its parent.CRM-5143
$customDataSubType = $customFieldExtend;
}
if (!empty($selectedValues)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- $selectedValues
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $selectedValues
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
}
else {
$value = '';
// and you can directly use value, CRM-4385
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_values($value)
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_values($value)
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
}
}
else {
*
* @return array
*/
- static function &defaultCustomTableSchema(&$params) {
+ public static function &defaultCustomTableSchema(&$params) {
// add the id and extends_id
$table = array(
'name' => $params['name'],
* @param bool $indexExist
* @param bool $triggerRebuild
*/
- static function createField($field, $operation, $indexExist = FALSE, $triggerRebuild = TRUE) {
+ public static function createField($field, $operation, $indexExist = FALSE, $triggerRebuild = TRUE) {
$tableName = CRM_Core_DAO::getFieldValue(
'CRM_Core_DAO_CustomGroup',
$field->custom_group_id,
/**
* Determine whether it would be safe to move a field
*
- * @param int $fieldID FK to civicrm_custom_field
- * @param int $newGroupID FK to civicrm_custom_group
+ * @param int $fieldID
+ * FK to civicrm_custom_field.
+ * @param int $newGroupID
+ * FK to civicrm_custom_group.
*
* @return array(
- string) or TRUE
+ * string) or TRUE
*/
- static function _moveFieldValidate($fieldID, $newGroupID) {
+ public static function _moveFieldValidate($fieldID, $newGroupID) {
$errors = array();
$field = new CRM_Core_DAO_CustomField();
FROM civicrm_custom_group
WHERE id IN ( %1, %2 )
";
- $params = array(1 => array($oldGroup->id, 'Integer'),
+ $params = array(
+ 1 => array($oldGroup->id, 'Integer'),
2 => array($newGroup->id, 'Integer'),
);
/**
* Move a custom data field from one group (table) to another
*
- * @param int $fieldID FK to civicrm_custom_field
- * @param int $newGroupID FK to civicrm_custom_group
+ * @param int $fieldID
+ * FK to civicrm_custom_field.
+ * @param int $newGroupID
+ * FK to civicrm_custom_group.
*
* @return void
*/
- static function moveField($fieldID, $newGroupID) {
+ public static function moveField($fieldID, $newGroupID) {
$validation = self::_moveFieldValidate($fieldID, $newGroupID);
if (TRUE !== $validation) {
CRM_Core_Error::fatal(implode(' ', $validation));
/**
* Get the database table name and column name for a custom field
*
- * @param int $fieldID - the fieldID of the custom field
- * @param boolean $force - force the sql to be run again (primarily used for tests)
+ * @param int $fieldID
+ * The fieldID of the custom field.
+ * @param bool $force
+ * Force the sql to be run again (primarily used for tests).
*
* @return array - fatal is fieldID does not exists, else array of tableName, columnName
* @static
- * @public
*/
- static function getTableColumnGroup($fieldID, $force = FALSE) {
- $cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}";
- $cache = CRM_Utils_Cache::singleton();
+ public static function getTableColumnGroup($fieldID, $force = FALSE) {
+ $cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}";
+ $cache = CRM_Utils_Cache::singleton();
$fieldValues = $cache->get($cacheKey);
if (empty($fieldValues) || $force) {
$query = "
/**
* Get custom option groups
*
- * @param array $includeFieldIds ids of custom fields for which
+ * @param array $includeFieldIds
+ * Ids of custom fields for which.
* option groups must be included.
*
* Currently this is required in the cases where option groups are to be included
* for inactive fields : CRM-5369
*
- * @access public
*
* @return mixed $customOptionGroup@static
*/
/**
* Fix orphan groups
*
- * @param int $customFieldId custom field id
- * @param int $optionGroupId option group id
+ * @param int $customFieldId
+ * Custom field id.
+ * @param int $optionGroupId
+ * Option group id.
*
- * @access public
* @return void
* @static
*/
- static function fixOptionGroups($customFieldId, $optionGroupId) {
+ public static function fixOptionGroups($customFieldId, $optionGroupId) {
// check if option group belongs to any custom Field else delete
// get the current option group
$currentOptionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
* Check if option group is related to more than one
* custom field
*
- * @param int $optionGroupId option group id
+ * @param int $optionGroupId
+ * Option group id.
*
* @return void
* @static
*/
- static function checkOptionGroup($optionGroupId) {
+ public static function checkOptionGroup($optionGroupId) {
$query = "
SELECT count(*)
FROM civicrm_custom_field
*
* @return null|string
*/
- static function getOptionGroupDefault($optionGroupId, $htmlType) {
+ public static function getOptionGroupDefault($optionGroupId, $htmlType) {
$query = "
SELECT default_value, html_type
FROM civicrm_custom_field
AND default_value IS NOT NULL
ORDER BY html_type";
- $dao = CRM_Core_DAO::executeQuery($query);
- $defaultValue = NULL;
+ $dao = CRM_Core_DAO::executeQuery($query);
+ $defaultValue = NULL;
$defaultHTMLType = NULL;
while ($dao->fetch()) {
if ($dao->html_type == $htmlType) {
*
* @return array
*/
- static function postProcess(&$params,
+ static function postProcess(
+ &$params,
&$customFields,
$entityID,
$customFieldExtends,
*
* @throws Exception
*/
- static function buildOption($field, &$options) {
+ public static function buildOption($field, &$options) {
// Fixme - adding anything but options to the $options array is a bad idea
// What if an option had the key 'attributes'?
$options['attributes'] = array(
$optionGroupID = NULL;
if (($field['html_type'] == 'CheckBox' ||
- $field['html_type'] == 'Radio' ||
- $field['html_type'] == 'Select' ||
- $field['html_type'] == 'AdvMulti-Select' ||
- $field['html_type'] == 'Multi-Select' ||
- ($field['html_type'] == 'Autocomplete-Select' && $field['data_type'] != 'ContactReference')
- )) {
+ $field['html_type'] == 'Radio' ||
+ $field['html_type'] == 'Select' ||
+ $field['html_type'] == 'AdvMulti-Select' ||
+ $field['html_type'] == 'Multi-Select' ||
+ ($field['html_type'] == 'Autocomplete-Select' && $field['data_type'] != 'ContactReference')
+ )
+ ) {
if ($field['option_group_id']) {
$optionGroupID = $field['option_group_id'];
}
*
* @return null
*/
- static function getCustomFieldID($fieldLabel, $groupTitle = NULL) {
+ public static function getCustomFieldID($fieldLabel, $groupTitle = NULL) {
$params = array(1 => array($fieldLabel, 'String'));
if ($groupTitle) {
$params[2] = array($groupTitle, 'String');
* Given ID of a custom field, return its name as well as the name of the custom group it belongs to.
*
*/
- static function getNameFromID($ids) {
+ public static function getNameFromID($ids) {
if (is_array($ids)) {
$ids = implode(',', $ids);
}
INNER JOIN civicrm_custom_group g ON f.custom_group_id = g.id
WHERE f.id IN ($ids)";
-
$dao = CRM_Core_DAO::executeQuery($sql);
$result = array();
while ($dao->fetch()) {
/**
* Validate custom data.
*
- * @param array $params custom data submitted.
+ * @param array $params
+ * Custom data submitted.
* ie array( 'custom_1' => 'validate me' );
*
* @return array $errors validation errors.
* @static
*/
- static function validateCustomData($params) {
+ public static function validateCustomData($params) {
$errors = array();
if (!is_array($params) || empty($params)) {
return $errors;
}
-
//pick up profile fields.
$profileFields = array();
$ufGroupId = CRM_Utils_Array::value('ufGroupId', $params);
$dataType = $field->data_type;
$profileField = CRM_Utils_Array::value($key, $profileFields, array());
- $fieldTitle = CRM_Utils_Array::value('title', $profileField);
- $isRequired = CRM_Utils_Array::value('is_required', $profileField);
+ $fieldTitle = CRM_Utils_Array::value('title', $profileField);
+ $isRequired = CRM_Utils_Array::value('is_required', $profileField);
if (!$fieldTitle) {
$fieldTitle = $field->label;
}
*
* @return bool
*/
- static function isMultiRecordField($customId) {
+ public static function isMultiRecordField($customId) {
$isMultipleWithGid = FALSE;
if (!is_numeric($customId)) {
$customId = self::getKeyID($customId);
* @param CRM_Core_DAO_CustomField|array $field
* @return bool
*/
- static function isSerialized($field) {
+ public static function isSerialized($field) {
// Fields retrieved via api are an array, or from the dao are an object. We'll accept either.
$field = (array) $field;
// FIXME: Currently the only way to know if data is serialized is by looking at the html_type. It would be cleaner to decouple this.
return ($field['html_type'] == 'CheckBox' || strpos($field['html_type'], 'Multi') !== FALSE);
}
}
-