From: Nileema Date: Wed, 6 Nov 2013 07:55:21 +0000 (+0530) Subject: -- CRM-13624 Display paper clip icon for file attachments for Note and CiviHR profiles X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=34f51a07cbfbad0e17d45ee0f246571f75404f44;p=civicrm-core.git -- 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 --- 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 0000000000..f74568b721 Binary files /dev/null and b/i/icons/jquery-ui-3E3E3E.gif differ diff --git a/templates/CRM/Contact/Page/View/Note.tpl b/templates/CRM/Contact/Page/View/Note.tpl index 6dc07d0e38..2a9dbf73d2 100644 --- a/templates/CRM/Contact/Page/View/Note.tpl +++ b/templates/CRM/Contact/Page/View/Note.tpl @@ -236,6 +236,7 @@ {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}