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


PHP CRM_Core_BAO_File::path方法代码示例

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


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

示例1: fileDisplay

 function fileDisplay()
 {
     // Display evidence file
     $postParams = $_POST;
     $fileID = CRM_Core_BAO_File::getEntityFile($postParams['entityTable'], $postParams['entityID']);
     if ($fileID) {
         foreach ($fileID as $k => $v) {
             $fileType = $v['mime_type'];
             $fid = $v['fileID'];
             $eid = $postParams['entityID'];
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 list($path) = CRM_Core_BAO_File::path($fid, $eid, NULL, NULL);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}", FALSE, NULL, TRUE, TRUE);
                 $file_url = "\n              <a href=\"{$url}\" class='crm-image-popup'>\n              <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n              </a>";
                 // for non image files
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fid, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}");
                 $file_url = "<a href=\"{$url}\">{$uri}</a>";
             }
             if (isset($fid)) {
                 $deleteurl = "<div class=file-delete><a class='action-item crm-hover-button' href='javascript:void(0)' id=file_{$fid}>Delete Attached File</a></div>";
                 echo "<div id='del_{$fid}'>{$file_url}{$deleteurl}</div>";
             }
         }
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:30,代码来源:Files.php

示例2: run

 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:File.php

示例3: run

 function run()
 {
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/DAO.php';
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     require_once 'CRM/Core/BAO/File.php';
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::delete($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
         }
     } else {
         require_once 'CRM/Utils/File.php';
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:File.php

示例4: copyExtendedActivityData

 /**
  * Copy custom fields and attachments from an existing activity to another.
  *
  * @see CRM_Case_Page_AJAX::_convertToCaseActivity()
  *
  * @param array $params
  */
 public static function copyExtendedActivityData($params)
 {
     // attach custom data to the new activity
     $customParams = $htmlType = array();
     $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($params['activityID'], 'Activity');
     if (!empty($customValues)) {
         $fieldIds = implode(', ', array_keys($customValues));
         $sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $htmlType[] = $result->id;
         }
         foreach ($customValues as $key => $value) {
             if ($value !== NULL) {
                 // CRM-10542
                 if (in_array($key, $htmlType)) {
                     $fileValues = CRM_Core_BAO_File::path($value, $params['activityID']);
                     $customParams["custom_{$key}_-1"] = array('name' => $fileValues[0], 'path' => $fileValues[1]);
                 } else {
                     $customParams["custom_{$key}_-1"] = $value;
                 }
             }
         }
         CRM_Core_BAO_CustomValueTable::postProcess($customParams, 'civicrm_activity', $params['mainActivityId'], 'Activity');
     }
     // copy activity attachments ( if any )
     CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $params['activityID'], 'civicrm_activity', $params['mainActivityId']);
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:35,代码来源:Activity.php

示例5: buildCustomFieldData

 /**
  * Build the entity-specific custom data into the group tree on a per-field basis
  *
  * @param object $dao
  *   Object representing the custom field to be populated into the groupTree.
  * @param array $groupTree
  *   (reference) the group tree being build.
  * @param string $table
  *   Table name.
  * @param int $groupID
  *   Custom group ID.
  * @param int $fieldID
  *   Custom field ID.
  */
 public static function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID)
 {
     $column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
     $idName = "{$table}_id";
     $fieldName = "{$table}_{$column}";
     $dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
     if ($dataType == 'File') {
         if (isset($dao->{$fieldName})) {
             $config = CRM_Core_Config::singleton();
             $fileDAO = new CRM_Core_DAO_File();
             $fileDAO->id = $dao->{$fieldName};
             if ($fileDAO->find(TRUE)) {
                 $entityIDName = "{$table}_entity_id";
                 $customValue['id'] = $dao->{$idName};
                 $customValue['data'] = $fileDAO->uri;
                 $customValue['fid'] = $fileDAO->id;
                 $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
                 $customValue['displayURL'] = NULL;
                 $deleteExtra = ts('Are you sure you want to delete attached file.');
                 $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&amp;confirmed=1\'; else return false;"'));
                 $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID), ts('more'), FALSE, 'file.manage.delete', 'File', $fileDAO->id);
                 $customValue['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs($table, $dao->{$entityIDName}, $fileDAO->id);
                 $customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
                 if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
                     $customValue['displayURL'] = $customValue['fileURL'];
                     $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'file_id');
                     $customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) . $fileDAO->uri;
                     list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, NULL, NULL);
                     if ($path && file_exists($path)) {
                         list($imageWidth, $imageHeight) = getimagesize($path);
                         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                         $customValue['imageThumbWidth'] = $imageThumbWidth;
                         $customValue['imageThumbHeight'] = $imageThumbHeight;
                     }
                 }
             }
         } else {
             $customValue = array('id' => $dao->{$idName}, 'data' => '');
         }
     } else {
         $customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
     }
     if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
     }
     if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
     } else {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:65,代码来源:CustomGroup.php

示例6: getFileURL

 /**
  * @param int $contactID
  * @param int $cfID
  * @param int $fileID
  * @param bool $absolute
  *
  * @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);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}", $absolute, NULL, TRUE, TRUE);
                 $result['file_url'] = "\n          <a href=\"{$url}\" class='crm-image-popup'>\n          <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n          </a>";
                 // for non image files
             } 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'] = "<a href=\"{$url}\">{$uri}</a>";
             }
         }
         return $result;
     }
 }
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:47,代码来源:CustomField.php

示例7: array


//.........这里部分代码省略.........
         $select = $from = $where = array();
         foreach ($groupTree['info']['tables'] as $table => $fields) {
             $from[] = $table;
             $select[] = "{$table}.id as {$table}_id";
             $select[] = "{$table}.entity_id as {$table}_entity_id";
             foreach ($fields as $column => $dontCare) {
                 $select[] = "{$table}.{$column} as {$table}_{$column}";
             }
             if ($entityID) {
                 $where[] = "{$table}.entity_id = {$entityID}";
             }
         }
         $groupTree['info']['select'] = $select;
         $groupTree['info']['from'] = $from;
         $groupTree['info']['where'] = null;
         if ($entityID) {
             $groupTree['info']['where'] = $where;
             $select = implode(', ', $select);
             // this is a hack to find a table that has some values for this
             // entityID to make the below LEFT JOIN work (CRM-2518)
             $firstTable = null;
             foreach ($from as $table) {
                 $query = "\nSELECT id\nFROM   {$table}\nWHERE  entity_id = {$entityID}\n";
                 $recordExists = CRM_Core_DAO::singleValueQuery($query);
                 if ($recordExists) {
                     $firstTable = $table;
                     break;
                 }
             }
             if ($firstTable) {
                 $fromSQL = $firstTable;
                 foreach ($from as $table) {
                     if ($table != $firstTable) {
                         $fromSQL .= "\nLEFT JOIN {$table} USING (entity_id)";
                     }
                 }
                 $query = "\nSELECT {$select}\n  FROM {$fromSQL}\n WHERE {$firstTable}.entity_id = {$entityID}\n";
                 $dao = CRM_Core_DAO::executeQuery($query);
                 while ($dao->fetch()) {
                     foreach ($groupTree as $groupID => $group) {
                         if ($groupID === 'info') {
                             continue;
                         }
                         $table = $groupTree[$groupID]['table_name'];
                         foreach ($group['fields'] as $fieldID => $dontCare) {
                             $column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
                             $idName = "{$table}_id";
                             $fieldName = "{$table}_{$column}";
                             $dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
                             if ($dataType == 'File') {
                                 if (isset($dao->{$fieldName})) {
                                     require_once 'CRM/Core/DAO/File.php';
                                     $config = CRM_Core_Config::singleton();
                                     $fileDAO = new CRM_Core_DAO_File();
                                     $fileDAO->id = $dao->{$fieldName};
                                     if ($fileDAO->find(true)) {
                                         $entityIDName = "{$table}_entity_id";
                                         $customValue['id'] = $dao->{$idName};
                                         $customValue['data'] = $fileDAO->uri;
                                         $customValue['fid'] = $fileDAO->id;
                                         $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
                                         $customValue['displayURL'] = null;
                                         $deleteExtra = ts('Are you sure you want to delete attached file.');
                                         $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&amp;confirmed=1\'; else return false;"'));
                                         $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID));
                                         $customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
                                         if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
                                             $customValue['displayURL'] = $customValue['fileURL'];
                                             $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'id');
                                             require_once 'CRM/Core/BAO/File.php';
                                             list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, null, null);
                                             list($imageWidth, $imageHeight) = getimagesize($path);
                                             require_once 'CRM/Contact/BAO/Contact.php';
                                             list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                                             $customValue['imageThumbWidth'] = $imageThumbWidth;
                                             $customValue['imageThumbHeight'] = $imageThumbHeight;
                                         }
                                     }
                                 } else {
                                     $customValue = array('id' => $dao->{$idName}, 'data' => '');
                                 }
                             } else {
                                 $customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
                             }
                             if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
                             }
                             if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
                             } else {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $groupTree;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:CustomGroup.php

示例8: getFileURL

 static function getFileURL($contactID, $cfID, $fileID = 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
             $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');
                 require_once 'CRM/Core/BAO/File.php';
                 list($path) = CRM_Core_BAO_File::path($fileID, $entityId, null, null);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}");
                 $result['file_url'] = "<a href='javascript:imagePopUp(\"{$url}\");'><img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/></a>";
             } else {
                 // for non image files
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}");
                 $result['file_url'] = "<a href=\"{$url}\">{$uri}</a>";
             }
         }
         return $result;
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:36,代码来源:CustomField.php

示例9: fileDelete

 public static function fileDelete()
 {
     $postParams = $_GET;
     $fileId = $postParams['fileID'];
     $result = 0;
     CRM_Core_BAO_File::deleteEntityFile($postParams['entityTable'], $postParams['entityID'], $fileTypeID = NULL, $fileId);
     list($path) = CRM_Core_BAO_File::path($fileId, $postParams['entityID'], NULL, NULL);
     if ($path === null) {
         $result = 1;
     }
     echo html_entity_decode(stripcslashes(json_encode(array('values' => array(array('result' => $result))), true)));
     CRM_Utils_System::civiExit();
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:13,代码来源:Files.php

示例10: 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


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