Merge pull request #3794 from rohankatkar/CRM-15070
[civicrm-core.git] / CRM / Core / BAO / CustomValueTable.php
index 5c004a44fa16bb2d4744c5293ed7537ea990468b..2cb38118fdb0efc4b423d88af632a6a70b562586 100644 (file)
  */
 class CRM_Core_BAO_CustomValueTable {
 
+  /**
+   * @param $customParams
+   *
+   * @throws Exception
+   */
   static function create(&$customParams) {
     if (empty($customParams) ||
       !is_array($customParams)
@@ -250,6 +255,8 @@ class CRM_Core_BAO_CustomValueTable {
    *
    * @param string $type the civicrm type string
    *
+   * @param int $maxLength
+   *
    * @return the mysql data store placeholder
    * @access public
    * @static
@@ -298,6 +305,11 @@ class CRM_Core_BAO_CustomValueTable {
     }
   }
 
+  /**
+   * @param $params
+   * @param $entityTable
+   * @param $entityID
+   */
   static function store(&$params, $entityTable, $entityID) {
     $cvParams = array();
     foreach ($params as $fieldID => $param) {
@@ -339,6 +351,13 @@ class CRM_Core_BAO_CustomValueTable {
     }
   }
 
+  /**
+   * @param $params
+   * @param $customFields
+   * @param $entityTable
+   * @param $entityID
+   * @param $customFieldExtends
+   */
   static function postProcess(&$params, &$customFields, $entityTable, $entityID, $customFieldExtends) {
     $customData = CRM_Core_BAO_CustomField::postProcess($params,
       $customFields,
@@ -354,16 +373,18 @@ class CRM_Core_BAO_CustomValueTable {
   /**
    * Return an array of all custom values associated with an entity.
    *
-   * @param int         $entityID      Identification number of the entity
-   * @param string      $entityType    Type of entity that the entityID corresponds to, specified
+   * @param int $entityID Identification number of the entity
+   * @param string $entityType Type of entity that the entityID corresponds to, specified
    *                                   as a string with format "'<EntityName>'". Comma separated
    *                                   list may be used to specify OR matches. Allowable values
    *                                   are enumerated types in civicrm_custom_group.extends field.
    *                                   Optional. Default value assumes entityID references a
    *                                   contact entity.
-   * @param array       $fieldIDs      optional list of fieldIDs that we want to retrieve. If this
+   * @param array $fieldIDs optional list of fieldIDs that we want to retrieve. If this
    *                                   is set the entityType is ignored
    *
+   * @param bool $formatMultiRecordField
+   *
    * @return array      $fields        Array of custom values for the entity with key=>value
    *                                   pairs specified as civicrm_custom_field.id => custom value.
    *                                   Empty array if no custom values found.
@@ -420,7 +441,7 @@ AND    $cond
       $fields[$dao->table_name][] = $dao->fieldID;
       $select[$dao->table_name][] = "{$dao->column_name} AS custom_{$dao->fieldID}";
       $isMultiple[$dao->table_name] = $dao->is_multiple ? TRUE : FALSE;
-      $file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType;     
+      $file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType;
     }
 
     $result = array();
@@ -453,7 +474,7 @@ AND    $cond
               }
             }
             else {
-              $result[$fieldID] = $dao->$fieldName;          
+              $result[$fieldID] = $dao->$fieldName;
             }
           }
         }
@@ -469,6 +490,9 @@ AND    $cond
    *
    * @array $params
    *
+   * @param $params
+   *
+   * @throws Exception
    * @return array
    * @static
    */
@@ -571,6 +595,10 @@ AND    cf.id IN ( $fieldIDList )
           'is_multiple' => $dao->is_multiple,
         );
 
+        if ($cvParam['type'] == 'File') {
+          $cvParam['file_id'] = $fieldValue['value'];
+        }
+
         if (!array_key_exists($dao->table_name, $cvParams)) {
           $cvParams[$dao->table_name] = array();
         }
@@ -607,6 +635,9 @@ AND    cf.id IN ( $fieldIDList )
    *
    * @array $params
    *
+   * @param $params
+   *
+   * @throws Exception
    * @return array
    * @static
    */