+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Array per getfields metadata.
*
* @return array
- * Array of newly created file property values.
*/
function civicrm_api3_file_create($params) {
$file = array();
_civicrm_api3_object_to_array($fileDAO, $file);
- return civicrm_api3_create_success($file, $params, 'file', 'create', $fileDAO);
+ return civicrm_api3_create_success($file, $params, 'File', 'create', $fileDAO);
}
/**
- * Get a file.
+ * Get a File.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Update an existing file.
+ * Update an existing File.
*
* @param array $params
* Array per getfields metadata.
}
/**
- * Delete an existing file.
+ * Delete an existing File.
*
* @param array $params
* Array per getfields metadata.
*
* @return array
- * API result array
+ * API Result Array
*/
function civicrm_api3_file_delete($params) {
civicrm_api3_verify_mandatory($params, NULL, array('id'));
-
- $check = FALSE;
-
- $entityFileDAO = new CRM_Core_DAO_EntityFile();
- $entityFileDAO->file_id = $params['id'];
- if ($entityFileDAO->find()) {
- $check = $entityFileDAO->delete();
+ if (CRM_Core_BAO_File::deleteEntityFile('*', $params['id'])) {
+ return civicrm_api3_create_success();
}
-
- $fileDAO = new CRM_Core_DAO_File();
- $fileDAO->id = $params['id'];
- if ($fileDAO->find(TRUE)) {
- $check = $fileDAO->delete();
+ else {
+ throw new API_Exception('Error while deleting a file.');
}
-
- return $check ? NULL : civicrm_api3_create_error('Error while deleting a file.');
}