+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
/**
- * Batch entry fields
+ * Batch entry fields.
*/
private static $_contriBatchEntryFields = NULL;
private static $_memberBatchEntryFields = NULL;
/**
- * Fetch object based on array of properties
+ * 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_BAO_UFField object
- * @access public
- * @static
+ * @return CRM_Core_BAO_UFField
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_UFField', $params, $defaults);
}
/**
* Get the form title.
*
- * @param int $id id of uf_form
- *
- * @return string title
+ * @param int $id
+ * Id of uf_form.
*
- * @access public
- * @static
+ * @return string
+ * title
*
*/
public static function getTitle($id) {
}
/**
- * Update the is_active flag in the db
+ * 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
+ * @return Object
+ * DAO object on sucess, null otherwise
*/
- static function setIsActive($id, $is_active) {
+ public static function setIsActive($id, $is_active) {
//check if custom data profile field is disabled
if ($is_active) {
if (CRM_Core_BAO_UFField::checkUFStatus($id)) {
/**
* Delete the profile Field.
*
- * @param int $id Field Id
- *
- * @return boolean
+ * @param int $id
+ * Field Id.
*
- * @access public
- * @static
+ * @return bool
*
*/
public static function del($id) {
}
/**
- * Check duplicate for duplicate field in a group
+ * Check duplicate for duplicate field in a group.
*
- * @param array $params an associative array with field and values
+ * @param array $params
+ * An associative array with field and values.
* @param $ids
*
* @return mixed
* @ids array $ids array that containd ids
*
- * @access public
- * @static
*/
public static function duplicateField($params, $ids) {
$ufField = new CRM_Core_DAO_UFField();
}
/**
- * Add the UF Field
- *
- * @param array $params (reference) array containing the values submitted by the form
- * @param array $ids array containing the id
+ * Add the UF Field.
*
- * @return CRM_Core_BAO_UFField object
+ * @param array $params
+ * (reference) array containing the values submitted by the form.
+ * @param array $ids
+ * Array containing the id.
*
- * @access public
- * @static
+ * @return CRM_Core_BAO_UFField
*
*/
- static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = array()) {
// set values for uf field properties and save
$ufField = new CRM_Core_DAO_UFField();
$ufField->field_type = $params['field_name'][0];
}
/**
- * Automatically determine one weight and modify others
+ * Automatically determine one weight and modify others.
*
- * @param array $params UFField record, e.g. with 'weight', 'uf_group_id', and 'field_id'
+ * @param array $params
+ * UFField record, e.g. with 'weight', 'uf_group_id', and 'field_id'.
* @return int
*/
public static function autoWeight($params) {
/**
* Enable/disable profile field given a custom field id
*
- * @param int $customFieldId custom field id
- * @param boolean $is_active set the is_active field
+ * @param int $customFieldId
+ * Custom field id.
+ * @param bool $is_active
+ * Set the is_active field.
*
* @return void
- * @static
- * @access public
*/
- static function setUFField($customFieldId, $is_active) {
+ public static function setUFField($customFieldId, $is_active) {
//find the profile id given custom field
$ufField = new CRM_Core_DAO_UFField();
$ufField->field_name = "custom_" . $customFieldId;
* Copy existing profile fields to
* new profile from the already built profile
*
- * @param int $old_id from which we need to copy
- * @param boolean $new_id in which to copy
+ * @param int $old_id
+ * From which we need to copy.
+ * @param bool $new_id
+ * In which to copy.
*
* @return void
- * @static
- * @access public
*/
- static function copy($old_id, $new_id) {
+ public static function copy($old_id, $new_id) {
$ufField = new CRM_Core_DAO_UFField();
$ufField->uf_group_id = $old_id;
$ufField->find();
}
/**
- * Delete profile field given a custom field
+ * Delete profile field given a custom field.
*
- * @param int $customFieldId ID of the custom field to be deleted
+ * @param int $customFieldId
+ * ID of the custom field to be deleted.
*
* @return void
*
- * @static
- * @access public
*/
- static function delUFField($customFieldId) {
+ public static function delUFField($customFieldId) {
//find the profile id given custom field id
$ufField = new CRM_Core_DAO_UFField();
$ufField->field_name = "custom_" . $customFieldId;
/**
* Enable/disable profile field given a custom group id
*
- * @param int $customGroupId custom group id
- * @param boolean $is_active value we want to set the is_active field
+ * @param int $customGroupId
+ * Custom group id.
+ * @param bool $is_active
+ * Value we want to set the is_active field.
*
* @return void
- * @static
- * @access public
*/
- static function setUFFieldStatus($customGroupId, $is_active) {
+ public static function setUFFieldStatus($customGroupId, $is_active) {
//find the profile id given custom group id
$queryString = "SELECT civicrm_custom_field.id as custom_field_id
FROM civicrm_custom_field, civicrm_custom_group
}
/**
- * Check the status of custom field used in uf fields
+ * Check the status of custom field used in uf fields.
*
* @param int $UFFieldId
*
- * @return boolean false if custom field are disabled else true
- * @static
- * @access public
+ * @return bool
+ * false if custom field are disabled else true
*/
- static function checkUFStatus($UFFieldId) {
+ public static function checkUFStatus($UFFieldId) {
$fieldName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $UFFieldId, 'field_name');
// return if field is not a custom field
if (!$customFieldId = CRM_Core_BAO_CustomField::getKeyID($fieldName)) {
* Find out whether given profile group using Activity
* Profile fields with contact fields
*/
- static function checkContactActivityProfileType($ufGroupId) {
+ public static function checkContactActivityProfileType($ufGroupId) {
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $ufGroupId;
$ufGroup->find(TRUE);
* Find out whether given profile group uses $required
* and/or $optional profile types
*
- * @param integer $ufGroupId profile id
- * @param array $required array of types those are required
- * @param array $optional array of types those are optional
+ * @param int $ufGroupId
+ * Profile id.
+ * @param array $required
+ * Array of types those are required.
+ * @param array $optional
+ * Array of types those are optional.
*
- * @return boolean $valid
- * @static
+ * @return bool
*/
- static function checkValidProfileType($ufGroupId, $required, $optional = NULL) {
+ public static function checkValidProfileType($ufGroupId, $required, $optional = NULL) {
if (!is_array($required) || empty($required)) {
- return;
+ return FALSE;
}
$ufGroup = new CRM_Core_DAO_UFGroup();
*
* @param int $ufGroupId
*
- * @return true for mix profile else false
- * @access public
- * @static
+ * @return bool
+ * true for mix profile else false
*/
- static function checkProfileType($ufGroupId) {
+ public static function checkProfileType($ufGroupId) {
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $ufGroupId;
$ufGroup->find(TRUE);
/**
* Get the profile type (eg: individual/organization/household)
*
- * @param int $ufGroupId uf group id
- * @param boolean $returnMixType this is true, then field type of mix profile field is returned
- * @param boolean $onlyPure true if only pure profiles are required
+ * @param int $ufGroupId
+ * Uf group id.
+ * @param bool $returnMixType
+ * This is true, then field type of mix profile field is returned.
+ * @param bool $onlyPure
+ * True if only pure profiles are required.
*
* @param bool $skipComponentType
*
- * @return string profile group_type
- * @access public
- * @static
+ * @return string
+ * profile group_type
*
- * TODO Why is this function in this class? It seems to be about the UFGroup.
*/
- static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) {
+ public static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) {
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $ufGroupId;
$ufGroup->is_active = 1;
* Get the profile type (eg: individual/organization/household)
*
* @param string $ufGroupType
- * @param boolean $returnMixType this is true, then field type of mix profile field is returned
- * @param boolean $onlyPure true if only pure profiles are required
+ * @param bool $returnMixType
+ * This is true, then field type of mix profile field is returned.
+ * @param bool $onlyPure
+ * True if only pure profiles are required.
* @param bool $skipComponentType
*
- * @return string profile group_type
- * @access public
- * @static
+ * @return string profile group_type
*
- * TODO Why is this function in this class? It seems to be about the UFGroup.
*/
- public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType= FALSE) {
+ public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) {
// profile types
$contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
$subTypes = CRM_Contact_BAO_ContactType::subTypes();
*
* @param $ctype
*
- * @return true for mix profile group else false
- * @access public
- * @static
+ * @return bool
+ * true for mix profile group else false
*/
- static function checkProfileGroupType($ctype) {
+ public static function checkProfileGroupType($ctype) {
$ufGroup = new CRM_Core_DAO_UFGroup();
$query = "
*
* @param int $profileID
*
- * @return boolean $result true/false.
+ * @return bool
*/
- static function checkSearchableORInSelector($profileID) {
+ public static function checkSearchableORInSelector($profileID) {
$result = FALSE;
if (!$profileID) {
return $result;
*
* @param int $profileID
*
- * @return void.
+ * @return void
*/
- function resetInSelectorANDSearchable($profileID) {
+ public function resetInSelectorANDSearchable($profileID) {
if (!$profileID) {
return;
}
* transfer profile address data to billing fields
* http://issues.civicrm.org/jira/browse/CRM-5869
*
- * @param string $key Field key - e.g. street_address-Primary, first_name
- * @param array $profileAddressFields array of profile fields that relate to address fields
- * @param array $profileFilter filter to apply to profile fields - expected usage is to only fill based on
- * the bottom profile per CRM-13726
+ * @param string $key
+ * Field key - e.g. street_address-Primary, first_name.
+ * @param array $profileAddressFields
+ * Array of profile fields that relate to address fields.
+ * @param array $profileFilter
+ * Filter to apply to profile fields - expected usage is to only fill based on.
+ * the bottom profile per CRM-13726
*
- * @return bool Can the address block be hidden safe in the knowledge all fields are elsewhere collected (see CRM-15118)
+ * @return bool
+ * Can the address block be hidden safe in the knowledge all fields are elsewhere collected (see CRM-15118)
*/
- static function assignAddressField($key, &$profileAddressFields, $profileFilter) {
+ public static function assignAddressField($key, &$profileAddressFields, $profileFilter) {
$billing_id = CRM_Core_BAO_LocationType::getBilling();
list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
$profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter,
- array('is_active' => 1, 'return' => 'field_name, is_required', 'options' => array(
- 'limit' => 0,
- ))
+ array(
+ 'is_active' => 1,
+ 'return' => 'field_name, is_required',
+ 'options' => array(
+ 'limit' => 0,
+ ),
+ )
));
//check for valid fields ( fields that are present in billing block )
$validBillingFields = array(
'city',
'state_province',
'postal_code',
- 'country'
+ 'country',
);
- $requiredBillingFields = array_diff($validBillingFields, array('middle_name','supplemental_address_1'));
+ $requiredBillingFields = array_diff($validBillingFields, array('middle_name', 'supplemental_address_1'));
$validProfileFields = array();
$requiredProfileFields = array();
foreach ($profileFields['values'] as $field) {
- if(in_array($field['field_name'], $validBillingFields)) {
+ if (in_array($field['field_name'], $validBillingFields)) {
$validProfileFields[] = $field['field_name'];
}
if ($field['is_required']) {
}
}
- if (!in_array($prefixName, $validProfileFields) ) {
- return;
+ if (!in_array($prefixName, $validProfileFields)) {
+ return FALSE;
}
if (!empty($index) && (
- // it's empty so we set it OR
- !CRM_Utils_array::value($prefixName, $profileAddressFields)
+ // it's empty so we set it OR
+ !CRM_Utils_array::value($prefixName, $profileAddressFields)
//we are dealing with billing id (precedence)
|| $index == $billing_id
// we are dealing with primary & billing not set
|| ($index == 'Primary' && $profileAddressFields[$prefixName] != $billing_id)
|| ($index == CRM_Core_BAO_LocationType::getDefault()->id
- && $profileAddressFields[$prefixName] != $billing_id
- && $profileAddressFields[$prefixName] != 'Primary'
+ && $profileAddressFields[$prefixName] != $billing_id
+ && $profileAddressFields[$prefixName] != 'Primary'
+ )
)
- )
) {
$profileAddressFields[$prefixName] = $index;
}
$potentiallyMissingRequiredFields = array_diff($requiredBillingFields, $requiredProfileFields);
- CRM_Core_Resources::singleton()->addSetting(array('billing' => array('billingProfileIsHideable' => empty($potentiallyMissingRequiredFields))));
+ CRM_Core_Resources::singleton()
+ ->addSetting(array('billing' => array('billingProfileIsHideable' => empty($potentiallyMissingRequiredFields))));
}
/**
- * Get a list of fields which can be added to profiles
+ * Get a list of fields which can be added to profiles.
*
- * @param int $gid: UF group ID
- * @param array $defaults: Form defaults
+ * @param int $gid : UF group ID
+ * @param array $defaults : Form defaults
* @return array, multidimensional; e.g. $result['FieldGroup']['field_name']['label']
- * @static
*/
public static function getAvailableFields($gid = NULL, $defaults = array()) {
$fields = array(
));
//unset selected fields
foreach ($groupFieldList as $key => $value) {
- if (is_integer($key)) {
+ if (is_int($key)) {
unset($fields['Individual'][$value], $fields['Household'][$value], $fields['Organization'][$value]);
continue;
}
}
/**
- * Get a list of fields which can be added to profiles
+ * Get a list of fields which can be added to profiles.
*
* @param bool $force
*
* @return array, multidimensional; e.g. $result['field_name']['label']
- * @static
*/
public static function getAvailableFieldsFlat($force = FALSE) {
// FIXME reset when data model changes
}
/**
- * Determine whether the given field_name is valid
+ * Determine whether the given field_name is valid.
*
* @param string $fieldName
* @return bool
*/
- static function isValidFieldName($fieldName) {
+ public static function isValidFieldName($fieldName) {
$availableFields = CRM_Core_BAO_UFField::getAvailableFieldsFlat();
return isset($availableFields[$fieldName]);
}
/**
* @return array|null
*/
- static function getContribBatchEntryFields() {
+ public static function getContribBatchEntryFields() {
if (self::$_contriBatchEntryFields === NULL) {
self::$_contriBatchEntryFields = array(
'send_receipt' => array(
}
return self::$_memberBatchEntryFields;
}
-}
+}