improvement
authormonishdeb <monish.deb@webaccessglobal.com>
Fri, 8 Jan 2016 15:54:07 +0000 (21:24 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 11 Jan 2016 12:49:45 +0000 (18:19 +0530)
CRM/Activity/Form/Activity.php
CRM/Contact/Page/Inline/CustomData.php
CRM/Contact/Page/View/Summary.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomGroup.php
CRM/Member/Form/MembershipView.php
templates/CRM/Contact/Page/View/CustomDataFieldView.tpl
templates/CRM/Custom/Page/CustomDataView.tpl

index fde9ebeac3635d1a7331749b0aa83894c1092461..257fe7d5ff0fb277434e6c50e2331ec59fca67fa 100644 (file)
@@ -748,7 +748,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     // if we're viewing, we're assigning different buttons than for adding/editing
     if ($this->_action & CRM_Core_Action::VIEW) {
       if (isset($this->_groupTree)) {
-        CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
+        CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree, FALSE, NULL, NULL, NULL, $this->_activityId);
       }
       // form should be frozen for view mode
       $this->freeze();
index 98374a2f8c18a456d781af12d7bc704a2340a2ab..3df11dbfa26a392b5ce3c2ed4253b798770db229 100644 (file)
@@ -54,7 +54,7 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page {
     $groupTree = &CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId,
       $cgId, $entitySubType
     );
-    $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
+    $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
     //get the fields of single custom group record
     if ($customRecId == 1) {
       $fields = reset($details[$cgId]);
index d6cd3e55112d6249853729cfb3cf79c5123280ae..88973dad03d3904b1e6dd5ad7c565e676b601521 100644 (file)
@@ -63,9 +63,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
       $entitySubType
     );
 
-    CRM_Core_BAO_CustomGroup::buildCustomDataView($this,
-      $groupTree
-    );
+    CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_contactId);
 
     // also create the form element for the activity links box
     $controller = new CRM_Core_Controller_Simple(
index 6d69b5e18f88be806777a8e595ea860033eace62..a2f13a1e66dd3cf3eb537a8249ff5c3a9d2d2fee 100644 (file)
@@ -1140,11 +1140,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    *
    * @param string|array $value
    * @param array $field
-   * @param int|null $contactID
+   * @param int|null $entityId
    *
    * @return string
    */
-  private static function formatDisplayValue($value, $field, $contactID = NULL) {
+  private static function formatDisplayValue($value, $field, $entityId = NULL) {
 
     if (self::isSerialized($field) && !is_array($value)) {
       $value = CRM_Utils_Array::explodePadded($value);
@@ -1217,24 +1217,16 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
 
       case 'File':
         // In the context of displaying a profile, show file/image
-        if ($contactID && $value) {
-          $url = self::getFileURL($contactID, $field['id'], $value);
+        if ($entityId) {
+          $url = self::getFileURL($entityId, $field['id']);
           if ($url) {
             $display = $url['file_url'];
           }
         }
         elseif ($value) {
           // In other contexts show a paperclip icon
-          if (is_numeric($value)) {
-            $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
-            $display = $icons[$value];
-          }
-          // In the context of inline view, show file/image
-          else {
-            $fileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $value, 'id', 'uri');
-            $results = CRM_Core_BAO_File::getEntityFile('*', $fileId);
-            $display = $results[$fileId];
-          }
+          $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
+          $display = $icons[$value];
         }
         break;
 
index 73a2501130d2891518220d7171b32e40302b1873..fba9745c92aa7b8d40fa8b04419b1aba8e691c7e 100644 (file)
@@ -1864,10 +1864,11 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1,
    * @param int $gID
    * @param null $prefix
    * @param int $customValueId
+   * @param int $entityId
    *
    * @return array|int
    */
-  public static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL, $customValueId = NULL) {
+  public static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL, $customValueId = NULL, $entityId = NULL) {
     $details = array();
     foreach ($groupTree as $key => $group) {
       if ($key === 'info') {
@@ -1891,7 +1892,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1,
               'field_title' => CRM_Utils_Array::value('label', $properties),
               'field_type' => CRM_Utils_Array::value('html_type', $properties),
               'field_data_type' => CRM_Utils_Array::value('data_type', $properties),
-              'field_value' => CRM_Core_BAO_CustomField::displayValue($values['data'], $properties['id']),
+              'field_value' => CRM_Core_BAO_CustomField::displayValue($values['data'], $properties['id'], $entityId),
               'options_per_line' => CRM_Utils_Array::value('options_per_line', $properties),
             );
             // also return contact reference contact id if user has view all or edit all contacts perm
index a0b4f3ba05cd1a65f383b42e415db220a29a83c8..c98144ca34096ce0b89f0925ef842eedf731b15b 100644 (file)
@@ -378,7 +378,7 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,
       $memType = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $id, "membership_type_id");
 
       $groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $id, 0, $memType);
-      CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
+      CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $id);
 
       $isRecur = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $id, 'contribution_recur_id');
 
index 797f7456018b05fca319f806f58f11104449ee5f..6d1d15bafb8d917d83dad0231c7729b02f0fd5fb 100644 (file)
           </div>
         {else}
           <div class="crm-label">{$element.field_title}</div>
-          {if $element.field_type == 'File' && !empty($element.field_value)}
-            {if $element.field_value.displayURL}
+          {if $element.field_type == 'File' && !empty($element.field_value.displayURL)}
                 <div class="crm-content crm-custom_data crm-displayURL">
                   <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
                     <img src="{$element.field_value.displayURL}" height = "{$element.field_value.imageThumbHeight}"
                          width="{$element.field_value.imageThumbWidth}">
                   </a>
-                </div>
-            {else}
-                <div class="crm-content crm-custom_data crm-fileURL">
-                  <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
-                </div>
-            {/if}
+             </div>
           {elseif $element.field_data_type EQ 'ContactReference' && $element.contact_ref_id}
             {*Contact ref id passed if user has sufficient permissions - so make a link.*}
             <div class="crm-content crm-custom-data crm-contact-reference">
index 9d37f7b88d6919047582b769ce0a6f75ee8656f0..13226b82c953eebc3122c72452694f641e81ec7e 100644 (file)
@@ -74,7 +74,7 @@
                     {else}
                       <td class="label">{$element.field_title}</td>
                       {if $element.field_type == 'File'}
-                        {if $element.field_value.displayURL}
+                        {if !empty($element.field_value.displayURL)}
                           <td class="html-adjust">
                             <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
                               <img src="{$element.field_value.displayURL}" height="100" width="100">
@@ -82,7 +82,7 @@
                           </td>
                         {else}
                           <td class="html-adjust">
-                            <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
+                            {$element.field_value}
                           </td>
                         {/if}
                       {else}
        {else}
           <div class="label">{$element.field_title}</div>
           {if $element.field_type == 'File'}
-          {if $element.field_value.displayURL}
+          {if !empty($element.field_value.displayURL)}
             <div class="content">
               <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
                <img src="{$element.field_value.displayURL}" height="100" width="100">
           {else}
             <div class="content">
              {if $element.field_value}
-              <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
+              {$element.field_value}
              {else}
               <br/>
              {/if}