/** * Get a file. * * This api is used for finding an existing file. * Required parameters : id OR file_type_id of a file * * @param array $params an associative array of name/value property values of civicrm_file * * @return Array of all found file object property values. * @access public */ function crm_get_file($params) { if (!is_array($params)) { return _crm_error('params is not an array.'); } if (!isset($params['id']) && !isset($params['file_type_id'])) { return _crm_error('Required parameters missing.'); } require_once 'CRM/Core/DAO/File.php'; $fileDAO = new CRM_Core_DAO_File(); $properties = array('id', 'file_type_id', 'mime_type', 'uri', 'document', 'description', 'upload_date'); foreach ($properties as $name) { if (array_key_exists($name, $params)) { $fileDAO->{$name} = $params[$name]; } } if ($fileDAO->find()) { $file = array(); while ($fileDAO->fetch()) { _crm_object_to_array(clone $fileDAO, $file); $files[$fileDAO->id] = $file; } } else { return _crm_error('Exact match not found'); } return $files; }