public static function fileList() { $config = CRM_Core_Config::singleton(); $postParams = $_GET; $result = array(); $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']; $url = null; $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fid, 'uri'); if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') { $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}", FALSE, NULL, TRUE, TRUE); } else { $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}"); } list($sql, $params) = CRM_Core_BAO_File::sql($postParams['entityTable'], $postParams['entityID'], NULL, $v['fileID']); $dao = CRM_Core_DAO::executeQuery($sql, $params); $fileSize = 0; if ($dao->fetch()) { $fileSize = filesize($config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri); } $result[] = array('entityTable' => $postParams['entityTable'], 'entityID' => $eid, 'fileID' => $fid, 'fileType' => $fileType, 'fileSize' => $fileSize, 'name' => $uri, 'url' => $url); } } echo html_entity_decode(stripcslashes(json_encode(array('values' => $result)))); CRM_Utils_System::civiExit(); }