From 34f51a07cbfbad0e17d45ee0f246571f75404f44 Mon Sep 17 00:00:00 2001 From: Nileema Date: Wed, 6 Nov 2013 13:25:21 +0530 Subject: [PATCH] -- CRM-13624 Display paper clip icon for file attachments for Note and CiviHR profiles ---------------------------------------- * CRM-13624: All Tabs - Paperclip Icon http://issues.civicrm.org/jira/browse/CRM-13624 --- CRM/Contact/Page/View/Note.php | 4 ++ CRM/Core/BAO/CustomValueTable.php | 24 +++++++++-- CRM/Core/BAO/File.php | 49 ++++++++++++++++++++++- css/civicrm.css | 3 ++ i/icons/jquery-ui-3E3E3E.gif | Bin 0 -> 3238 bytes templates/CRM/Contact/Page/View/Note.tpl | 6 +++ 6 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 i/icons/jquery-ui-3E3E3E.gif diff --git a/CRM/Contact/Page/View/Note.php b/CRM/Contact/Page/View/Note.php index e6d54f7df0..9a570257ae 100644 --- a/CRM/Contact/Page/View/Note.php +++ b/CRM/Contact/Page/View/Note.php @@ -131,6 +131,10 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $contact->fetch(); $values[$note->id]['createdBy'] = $contact->display_name; $values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id); + + // paper icon view for attachments part + $paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id); + $values[$note->id]['attachment'] = $paperIconAttachmentInfo; } } diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index 74beeed525..011116f98e 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -399,7 +399,8 @@ SELECT cg.table_name, cg.id as groupID, cg.is_multiple, cf.column_name, - cf.id as fieldID + cf.id as fieldID, + cf.data_type as fieldDataType FROM civicrm_custom_group cg, civicrm_custom_field cf WHERE cf.custom_group_id = cg.id @@ -419,6 +420,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; } $result = array(); @@ -430,13 +432,29 @@ AND $cond $fieldName = "custom_{$fieldID}"; if ($isMultiple[$tableName]) { if ($formatMultiRecordField) { - $result["{$dao->id}"]["{$fieldID}"] = $dao->$fieldName; + if($file[$tableName][$fieldID] == 'File') { + if($fileid = $dao->$fieldName) { + $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID); + $result["{$dao->id}"]["{$fieldID}"] = $fileurl[$dao->$fieldName]; + } + } + else { + $result["{$dao->id}"]["{$fieldID}"] = $dao->$fieldName; + } } else { $result["{$fieldID}_{$dao->id}"] = $dao->$fieldName; } } else { - $result[$fieldID] = $dao->$fieldName; + if($file[$tableName][$fieldID] == 'File') { + if($fileid = $dao->$fieldName) { + $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID); + $result[$fieldID] = $fileurl[$dao->$fieldName]; + } + } + else { + $result[$fieldID] = $dao->$fieldName; + } } } } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index f09e64a11d..c74d6488d8 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -556,5 +556,52 @@ CRM_Core_BAO_File::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']); } -} + /** + * function to display paper icon for a file attachment -- CRM-13624 + * + * @static + * @access public + */ + static function paperIconAttachment( $entityTable, $entityID ) { + if (empty($entityTable) || !$entityID) { + $results = NULL; + return $results; + } + $currentAttachmentInfo = self::getEntityFile( $entityTable, $entityID ); + foreach($currentAttachmentInfo as $fileKey => $fileValue) { + $fileID = $fileValue['fileID']; + $fileType = $fileValue['mime_type']; + $eid = $entityID; + if($fileID) { + if ($fileType == 'image/jpeg' || + $fileType == 'image/pjpeg' || + $fileType == 'image/gif' || + $fileType == 'image/x-png' || + $fileType == 'image/png' + ) { + $url = $fileValue['url']; + $alt = $fileValue['cleanName']; + $file_url[$fileID] = " + +
+
"; + // for non image files + } + else { + $url = $fileValue['url']; + $alt = $fileValue['cleanName']; + $file_url[$fileID] = "
"; + } + } + } + if(empty($file_url)) { + $results = NULL; + } + else { + $results = $file_url; + } + return $results; + } + +} \ No newline at end of file diff --git a/css/civicrm.css b/css/civicrm.css index e20282fb89..78f36da8e4 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -4032,3 +4032,6 @@ span.crm-status-icon { color: #fff; } +.crm-container .paper-icon { + background-position: -101px -222px;background-image: url("../i/icons/jquery-ui-3E3E3E.gif"); +} \ No newline at end of file diff --git a/i/icons/jquery-ui-3E3E3E.gif b/i/icons/jquery-ui-3E3E3E.gif new file mode 100644 index 0000000000000000000000000000000000000000..f74568b72115466f531c45d86e1dbee3c26a966b GIT binary patch literal 3238 zcmV;X3|aF>Nk%w1VE_T}0M$PL1_lNe78X4{Ju53K6ciK+3JN47Br!2DA|fI!EiDKL z2p%3D85tQI92_SnCk_q{3=9ks5)vC58)jx^LPA0s8X7e`tsH3f=hljUpyMn#ETadD|WSP0gNtVC8 z%Av@Un5nV9#Dv4ZilV{V+0MD7oYd9hmE@6g!+PT8?Cr(w@bU8V^!4`l`1$(#{Qds_ z00RmfNU)&6g9sBUeCKW*qlIIZaZ4udmNIZr(oJNw%n(Fd5;aN;^@`$?k`!e%>vj#| zN|GdZp-c%gW=%h+92UGdGMmi*naOl9(OvfM(CsA+ zPo_xa6nqy|7vyRnsuCJ=Jkm5{ap3So`m}V-TKvg2@`Rb;Wfa=DIiDtJbvZt{|XlBj{ zS)O&HMtcvgIV!vVV}+)9t6L}L2J5RdqjQD5BwFRneQuK4v1go6dvfVA)dm z@1O;bNUEmxSPSvQ6jyBV#TaL-@x~ml+HqAOCdh8FBn=XKvaoA(3 zJ9b8|Vlyk~vbOBnr_QjB4Ging(h5hkXGi0_I=ZkL1MNg}1)%s@LAJH-U zx@K)jH|x>NqO4oCq+JL7t=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sL$JPmvzOu|xniFaRO&0~{ts}Subject{/ts} {ts}Date{/ts} {ts}Created By{/ts} + {ts}Attachment(s){/ts} @@ -267,6 +268,11 @@ {$note.createdBy} + + {foreach from=$note.attachment item=fileinfo} + {$fileinfo} + {/foreach} + {$note.action|replace:'xx':$note.id} {/foreach} -- 2.25.1