Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-03-03-23-44-14
[civicrm-core.git] / CRM / Core / BAO / CustomField.php
index c923c542ac2e567ba1d85f50af457f11af4810d6..17b461639c7fdea7010d5f95ba51f45573ff316e 100644 (file)
@@ -61,7 +61,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   public static $_importFields = NULL;
 
   /**
-   * Build and retrieve the list of data types and descriptions
+   * Build and retrieve the list of data types and descriptions.
    *
    * @return array
    *   Data type => Description
@@ -118,7 +118,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Takes an associative array and creates a custom field object
+   * Takes an associative array and creates a custom field object.
    *
    * This function is invoked from within the web form layer and also from the api layer
    *
@@ -278,7 +278,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     $customField->is_searchable = CRM_Utils_Array::value('is_searchable', $params, FALSE);
     $customField->in_selector = CRM_Utils_Array::value('in_selector', $params, FALSE);
     $customField->is_search_range = CRM_Utils_Array::value('is_search_range', $params, FALSE);
-    $customField->is_active = CRM_Utils_Array::value('is_active', $params, FALSE);
+    //CRM-15792 - Custom field gets disabled if is_active not set
+    $customField->is_active = CRM_Utils_Array::value('is_active', $params, TRUE);
     $customField->is_view = CRM_Utils_Array::value('is_view', $params, FALSE);
     $customField->save();
 
@@ -313,7 +314,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * 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.
@@ -327,7 +328,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Update the is_active flag in the db
+   * Update the is_active flag in the db.
    *
    * @param int $id
    *   Id of the database record.
@@ -666,7 +667,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Get the field id from an import key
+   * Get the field id from an import key.
    *
    * @param string $key
    *   The key to parse.
@@ -692,7 +693,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Use the cache to get all values of a specific custom field
+   * Use the cache to get all values of a specific custom field.
    *
    * @param int $fieldID
    *   The custom field ID.
@@ -726,7 +727,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * This function for building custom fields
+   * This function for building custom fields.
    *
    * @param CRM_Core_Form $qf
    *   Form object (reference).
@@ -1312,11 +1313,9 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         break;
 
       case 'File':
-        if ($contactID) {
-          $url = self::getFileURL($contactID, $fieldID, $value);
-          if ($url) {
-            $display = $url['file_url'];
-          }
+        if ($value) {
+          $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
+          $display = $icons[$value];
         }
         break;
 
@@ -1341,7 +1340,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Set default values for custom data used in profile
+   * Set default values for custom data used in profile.
    *
    * @param int $customFieldId
    *   Custom field id.
@@ -1548,7 +1547,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
   }
 
   /**
-   * Format custom fields before inserting
+   * Format custom fields before inserting.
    *
    * @param int $customFieldId
    *   Custom field id.
@@ -1910,7 +1909,7 @@ SELECT $columnName
   }
 
   /**
-   * Determine whether it would be safe to move a field
+   * Determine whether it would be safe to move a field.
    *
    * @param int $fieldID
    *   FK to civicrm_custom_field.
@@ -2043,7 +2042,7 @@ WHERE  id IN ( %1, %2 )
   }
 
   /**
-   * Get the database table name and column name for a custom field
+   * Get the database table name and column name for a custom field.
    *
    * @param int $fieldID
    *   The fieldID of the custom field.
@@ -2078,7 +2077,7 @@ AND    cf.id = %1";
   }
 
   /**
-   * Get custom option groups
+   * Get custom option groups.
    *
    * @param array $includeFieldIds
    *   Ids of custom fields for which.
@@ -2125,7 +2124,7 @@ INNER JOIN  civicrm_custom_field f ON ( g.id = f.option_group_id )
   }
 
   /**
-   * Fix orphan groups
+   * Fix orphan groups.
    *
    * @param int $customFieldId
    *   Custom field id.