当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_File::getFileURL方法代码示例

本文整理汇总了PHP中CRM_Utils_File::getFileURL方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::getFileURL方法的具体用法?PHP CRM_Utils_File::getFileURL怎么用?PHP CRM_Utils_File::getFileURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_File的用法示例。


在下文中一共展示了CRM_Utils_File::getFileURL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFileURL

 /**
  * Get file url.
  *
  * @param int $contactID
  * @param int $cfID
  * @param int $fileID
  * @param bool $absolute
  *
  * @param string $multiRecordWhereClause
  *
  * @return array
  */
 public static function getFileURL($contactID, $cfID, $fileID = NULL, $absolute = FALSE, $multiRecordWhereClause = NULL)
 {
     if ($contactID) {
         if (!$fileID) {
             $params = array('id' => $cfID);
             $defaults = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
             $columnName = $defaults['column_name'];
             //table name of custom data
             $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $defaults['custom_group_id'], 'table_name', 'id');
             //query to fetch id from civicrm_file
             if ($multiRecordWhereClause) {
                 $query = "SELECT {$columnName} FROM {$tableName} where entity_id = {$contactID} AND {$multiRecordWhereClause}";
             } else {
                 $query = "SELECT {$columnName} FROM {$tableName} where entity_id = {$contactID}";
             }
             $fileID = CRM_Core_DAO::singleValueQuery($query);
         }
         $result = array();
         if ($fileID) {
             $fileType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'mime_type', 'id');
             $result['file_id'] = $fileID;
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileID, 'entity_id', 'id');
                 list($path) = CRM_Core_BAO_File::path($fileID, $entityId, NULL, NULL);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}", $absolute, NULL, TRUE, TRUE);
                 $result['file_url'] = CRM_Utils_File::getFileURL($path, $fileType, $url);
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}", $absolute, NULL, TRUE, TRUE);
                 $result['file_url'] = CRM_Utils_File::getFileURL($uri, $fileType, $url);
             }
         }
         return $result;
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:48,代码来源:CustomField.php

示例2: buildCustom

 /**
  * Add the custom fields.
  *
  * @param int $id
  * @param string $name
  * @param bool $viewOnly
  * @param null $profileContactType
  * @param array $fieldTypes
  */
 public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL)
 {
     if ($id) {
         $contactID = $this->getContactID();
         // we don't allow conflicting fields to be
         // configured via profile - CRM 2100
         $fieldsToIgnore = array('receive_date' => 1, 'trxn_id' => 1, 'invoice_id' => 1, 'net_amount' => 1, 'fee_amount' => 1, 'non_deductible_amount' => 1, 'total_amount' => 1, 'amount_level' => 1, 'contribution_status_id' => 1, 'payment_instrument' => 1, 'check_number' => 1, 'financial_type' => 1);
         $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
         if ($fields) {
             // unset any email-* fields since we already collect it, CRM-2888
             foreach (array_keys($fields) as $fieldName) {
                 if (substr($fieldName, 0, 6) == 'email-' && !in_array($profileContactType, array('honor', 'onbehalf'))) {
                     unset($fields[$fieldName]);
                 }
             }
             if (array_intersect_key($fields, $fieldsToIgnore)) {
                 $fields = array_diff_key($fields, $fieldsToIgnore);
                 CRM_Core_Session::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
             }
             //remove common fields only if profile is not configured for onbehalf/honor
             if (!in_array($profileContactType, array('honor', 'onbehalf'))) {
                 $fields = array_diff_assoc($fields, $this->_fields);
             }
             CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID);
             $addCaptcha = FALSE;
             // fetch file preview when not submitted yet, like in online contribution Confirm and ThankYou page
             $viewOnlyFileValues = empty($profileContactType) ? array() : array($profileContactType => array());
             foreach ($fields as $key => $field) {
                 if ($viewOnly && isset($field['data_type']) && $field['data_type'] == 'File' || $viewOnly && $field['name'] == 'image_URL') {
                     //retrieve file value from submitted values on basis of $profileContactType
                     $fileValue = CRM_Utils_Array::value($key, $this->_params);
                     if (!empty($profileContactType) && !empty($this->_params[$profileContactType])) {
                         $fileValue = CRM_Utils_Array::value($key, $this->_params[$profileContactType]);
                     }
                     if ($fileValue) {
                         $path = CRM_Utils_Array::value('name', $fileValue);
                         $fileType = CRM_Utils_Array::value('type', $fileValue);
                         $fileValue = CRM_Utils_File::getFileURL($path, $fileType);
                     }
                     // format custom file value fetched from submitted value
                     if ($profileContactType) {
                         $viewOnlyFileValues[$profileContactType][$key] = $fileValue;
                     } else {
                         $viewOnlyFileValues[$key] = $fileValue;
                     }
                 }
                 if ($profileContactType) {
                     //Since we are showing honoree name separately so we are removing it from honoree profile just for display
                     if ($profileContactType == 'honor') {
                         $honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
                         if (in_array($field['name'], $honoreeNamefields)) {
                             unset($fields[$field['name']]);
                             continue;
                         }
                     }
                     if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
                         CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE, $profileContactType);
                         $this->_fields[$profileContactType][$key] = $field;
                     } else {
                         unset($fields[$key]);
                     }
                 } else {
                     CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
                     $this->_fields[$key] = $field;
                 }
                 // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
                 if ($field['add_captcha'] && !$this->_userID) {
                     $addCaptcha = TRUE;
                 }
             }
             $this->assign($name, $fields);
             if ($profileContactType && count($viewOnlyFileValues[$profileContactType])) {
                 $this->assign('viewOnlyPrefixFileValues', $viewOnlyFileValues);
             } elseif (count($viewOnlyFileValues)) {
                 $this->assign('viewOnlyFileValues', $viewOnlyFileValues);
             }
             if ($addCaptcha && !$viewOnly) {
                 $captcha = CRM_Utils_ReCAPTCHA::singleton();
                 $captcha->add($this);
                 $this->assign('isCaptcha', TRUE);
             }
         }
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:93,代码来源:ContributionBase.php


注:本文中的CRM_Utils_File::getFileURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。