INFRA-132 - CRM/Core - Misc
[civicrm-core.git] / CRM / Core / BAO / CustomField.php
index dcdd91add8cbb69c4a667d165f873e1a6f240560..2d0f385674fe2e63269cc862967ea12f112f89f0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
   +--------------------------------------------------------------------+
-  | CiviCRM version 4.5                                                |
+  | CiviCRM version 4.6                                                |
   +--------------------------------------------------------------------+
   | Copyright CiviCRM LLC (c) 2004-2014                                |
   +--------------------------------------------------------------------+
@@ -69,10 +69,9 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    * @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'),
@@ -95,12 +94,14 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * @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',
@@ -126,13 +127,13 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    *
    * 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'])) {
@@ -158,13 +159,14 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
       $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':
@@ -188,14 +190,18 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
             $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',
@@ -203,7 +209,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         '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();
@@ -212,7 +217,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         $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();
@@ -260,8 +265,9 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         );
 
         if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR,
-              $defaultValue
-            ))) {
+          $defaultValue
+        ))
+        ) {
           $params['default_value'] = $defaultValue;
         }
       }
@@ -315,29 +321,31 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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();
 
@@ -349,11 +357,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * Get the field title.
    *
-   * @param int $id id of field.
+   * @param int $id
+   *   Id of field.
    *
    * @return string name
    *
-   * @access public
    * @static
    *
    */
@@ -364,28 +372,36 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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');
@@ -585,24 +601,28 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    * 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
@@ -656,11 +676,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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) {
@@ -682,18 +702,19 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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;
@@ -716,32 +737,38 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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
@@ -752,10 +779,23 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     $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)) {
@@ -774,7 +814,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
       // 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),
         );
@@ -856,18 +897,18 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
 
           $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) {
@@ -945,7 +986,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         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;
         }
@@ -957,7 +1002,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         // 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, ' "');
@@ -1043,11 +1088,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * Delete the Custom Field.
    *
-   * @param   object $field - the field object
+   * @param object $field
+   *   The field object.
    *
    * @return  boolean
    *
-   * @access public
    * @static
    *
    */
@@ -1075,9 +1120,12 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    * 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
@@ -1085,14 +1133,13 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    * @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,
@@ -1115,13 +1162,14 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    *
    * @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;
 
@@ -1145,7 +1193,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
           if ($value) {
             $display = ts('Yes');
           }
-          elseif ((string)$value === '0') {
+          elseif ((string) $value === '0') {
             $display = ts('No');
           }
         }
@@ -1312,18 +1360,24 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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,
@@ -1342,8 +1396,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     }
     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;
@@ -1438,7 +1492,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    *
    * @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);
@@ -1514,25 +1568,35 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   /**
    * 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
@@ -1542,8 +1606,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     }
 
     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;
@@ -1597,8 +1661,8 @@ SELECT id
           }
           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 = '';
@@ -1615,8 +1679,8 @@ SELECT id
         // 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 {
@@ -1760,7 +1824,7 @@ SELECT $columnName
    *
    * @return array
    */
-  static function &defaultCustomTableSchema(&$params) {
+  public static function &defaultCustomTableSchema(&$params) {
     // add the id and extends_id
     $table = array(
       'name' => $params['name'],
@@ -1804,7 +1868,7 @@ SELECT $columnName
    * @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,
@@ -1866,13 +1930,15 @@ SELECT $columnName
   /**
    * 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();
@@ -1930,7 +1996,8 @@ SELECT extends
 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'),
       );
 
@@ -1950,12 +2017,14 @@ WHERE  id IN ( %1, %2 )
   /**
    * 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));
@@ -1994,16 +2063,17 @@ WHERE  id IN ( %1, %2 )
   /**
    * 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 = "
@@ -2028,13 +2098,13 @@ AND    cf.id = %1";
   /**
    * 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
    */
@@ -2075,14 +2145,15 @@ INNER JOIN  civicrm_custom_field f ON ( g.id = f.option_group_id )
   /**
    * 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',
@@ -2103,12 +2174,13 @@ INNER JOIN  civicrm_custom_field f ON ( g.id = f.option_group_id )
    * 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
@@ -2128,7 +2200,7 @@ WHERE  option_group_id = {$optionGroupId}";
    *
    * @return null|string
    */
-  static function getOptionGroupDefault($optionGroupId, $htmlType) {
+  public static function getOptionGroupDefault($optionGroupId, $htmlType) {
     $query = "
 SELECT   default_value, html_type
 FROM     civicrm_custom_field
@@ -2136,8 +2208,8 @@ WHERE    option_group_id = {$optionGroupId}
 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) {
@@ -2178,7 +2250,8 @@ ORDER BY html_type";
    *
    * @return array
    */
-  static function postProcess(&$params,
+  static function postProcess(
+    &$params,
     &$customFields,
     $entityID,
     $customFieldExtends,
@@ -2218,7 +2291,7 @@ ORDER BY html_type";
    *
    * @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(
@@ -2229,12 +2302,13 @@ ORDER BY html_type";
 
     $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'];
       }
@@ -2272,7 +2346,7 @@ SELECT label, value
    *
    * @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');
@@ -2307,7 +2381,7 @@ WHERE      ( f.label = %1 OR f.name = %1 )
    * 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);
     }
@@ -2317,7 +2391,6 @@ FROM       civicrm_custom_field f
 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()) {
@@ -2334,19 +2407,19 @@ WHERE      f.id IN ($ids)";
   /**
    * 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);
@@ -2373,8 +2446,8 @@ WHERE      f.id IN ($ids)";
       $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;
       }
@@ -2442,7 +2515,7 @@ WHERE      f.id IN ($ids)";
    *
    * @return bool
    */
-  static function isMultiRecordField($customId) {
+  public static function isMultiRecordField($customId) {
     $isMultipleWithGid = FALSE;
     if (!is_numeric($customId)) {
       $customId = self::getKeyID($customId);
@@ -2470,11 +2543,10 @@ WHERE cf.id = %1 AND cg.is_multiple = 1";
    * @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);
   }
 }
-