예제 #1
0
/**
 * Attachment getfields helper.
 *
 * @return array
 *   list of fields (indexed by name)
 */
function _civicrm_api3_attachment_getfields()
{
    $fileFields = CRM_Core_DAO_File::fields();
    $entityFileFields = CRM_Core_DAO_EntityFile::fields();
    $spec = array();
    $spec['id'] = $fileFields['id'];
    $spec['name'] = array('title' => 'Name (write-once)', 'description' => 'The logical file name (not searchable)', 'type' => CRM_Utils_Type::T_STRING);
    $spec['field_name'] = array('title' => 'Field Name (write-once)', 'description' => 'Alternative to "entity_table" param - sets custom field value.', 'type' => CRM_Utils_Type::T_STRING);
    $spec['mime_type'] = $fileFields['mime_type'];
    $spec['description'] = $fileFields['description'];
    $spec['upload_date'] = $fileFields['upload_date'];
    $spec['entity_table'] = $entityFileFields['entity_table'];
    // Would be hard to securely handle changes.
    $spec['entity_table']['title'] = CRM_Utils_Array::value('title', $spec['entity_table'], 'Entity Table') . ' (write-once)';
    $spec['entity_id'] = $entityFileFields['entity_id'];
    $spec['entity_id']['title'] = CRM_Utils_Array::value('title', $spec['entity_id'], 'Entity ID') . ' (write-once)';
    // would be hard to securely handle changes
    $spec['url'] = array('title' => 'URL (read-only)', 'description' => 'URL for downloading the file (not searchable, expire-able)', 'type' => CRM_Utils_Type::T_STRING);
    $spec['path'] = array('title' => 'Path (read-only)', 'description' => 'Local file path (not searchable, local-only)', 'type' => CRM_Utils_Type::T_STRING);
    $spec['content'] = array('title' => 'Content', 'description' => 'File content (not searchable, not returned by default)', 'type' => CRM_Utils_Type::T_STRING);
    return $spec;
}