version fixes
[civicrm-core.git] / api / v3 / File.php
index 4ea85825003c0aa492f01de72275ea794472bc20..cc9b35ed91366096fe92a52bd560faffa1006e6d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
@@ -127,25 +127,15 @@ function civicrm_api3_file_update($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.');
 }