3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
27 / * Unchanged anonymous code contribution. No claim.
29 * civicrm_handler_field_custom_file.inc
30 * Displays File field uri instead of id.
35 * Field handler to provide acess control for the File field
37 * @ingroup civicrm_field_handlers
39 class civicrm_handler_field_custom_file extends views_handler_field {
40 function construct() {
43 $this->additional_fields['entity_id'] = 'entity_id';
46 function render($values) {
47 $value = $values->{$this->field_alias};
48 if (!is_null($value)) {
49 $path = 'civicrm/file';
50 $fileType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File',
55 if ($fileType && in_array($fileType, array(
56 "image/jpeg", "image/pjpeg", "image/gif", "image/x-png", "image/png"))) {
57 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File',
62 $path = sprintf('%s/imagefile',$path);
64 $entityField = $this->aliases['entity_id'];
65 $url = CRM_Utils_System::url($path,
66 "id={$value}&eid={$values->$entityField}",
67 TRUE, FALSE, FALSE, TRUE
69 return CRM_Utils_System::url($path,
70 "id={$value}&eid={$values->$entityField}",
71 TRUE, FALSE, FALSE, TRUE