CRM-12261
authorDonald A. Lobo <lobo@civicrm.org>
Mon, 1 Apr 2013 16:14:45 +0000 (09:14 -0700)
committerDonald A. Lobo <lobo@civicrm.org>
Mon, 1 Apr 2013 16:14:45 +0000 (09:14 -0700)
CRM/Core/BAO/File.php
CRM/Core/Page/File.php
CRM/Custom/Form/DeleteFile.php [deleted file]
CRM/Dedupe/Merger.php

index c10becaced6d29a70feb4e9b1d7d89d01120776c..72ec638f925f5e7a12772716adc3ba23129d49ba 100644 (file)
    }
 
    /**
-    * The $useWhere is used so that the signature matches the parent class
+    * A static function wrapper that deletes the various objects that are
+    * connected to a file object (i.e. file, entityFile and customValue
     */
-   public function delete($useWhere = false) {
-     list($fileID, $entityID, $fieldID) = func_get_args();
-
+   public static function deleteFileReferences($fileID, $entityID, $fieldID) {
      $fileDAO = new CRM_Core_DAO_File();
      $fileDAO->id = $fileID;
      if (!$fileDAO->find(TRUE)) {
      CRM_Core_DAO::executeQuery($query, $params);
    }
 
+   /**
+    * The $useWhere is used so that the signature matches the parent class
+    */
+   public function delete($useWhere = false) {
+     list($fileID, $entityID, $fieldID) = func_get_args();
+
+     self::deleteFileReferences($fileID, $entityID, $fieldID);
+   }
+
    /**
     * delete all the files and associated object associated with this
     * combination
index 51a64dedcce0597ce9892191ea78f9e16d6e3697..78a342be4266777e21cfa016df518600f880430b 100644 (file)
@@ -53,20 +53,17 @@ class CRM_Core_Page_File extends CRM_Core_Page {
 
     if ($action & CRM_Core_Action::DELETE) {
       if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
-        CRM_Core_BAO_File::delete($id, $eid, $fid);
+        CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
         CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
 
         $session = CRM_Core_Session::singleton();
         $toUrl = $session->popUserContext();
         CRM_Utils_System::redirect($toUrl);
       }
-      else {
-        $wrapper = new CRM_Utils_Wrapper();
-        return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), NULL);
-      }
     }
     else {
-      CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)),
+      CRM_Utils_System::download(
+        CRM_Utils_File::cleanFileName(basename($path)),
         $mimeType,
         $buffer
       );
diff --git a/CRM/Custom/Form/DeleteFile.php b/CRM/Custom/Form/DeleteFile.php
deleted file mode 100644 (file)
index 99d9ad5..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
-*/
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
- * $Id$
- *
- */
-class CRM_Custom_Form_DeleteFile extends CRM_Core_Form {
-
-  /**
-   * the file id
-   *
-   * @var int
-   */
-  protected $_id;
-
-  /**
-   * the entity id
-   *
-   * @var array
-   */
-  protected $_eid;
-  
-  function preProcess() {
-    $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
-    $this->_eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
-  }
-
-  /**
-   * Function to actually build the form
-   *
-   * @return None
-   * @access public
-   */
-  public function buildQuickForm() {
-
-    $this->addButtons(array(
-        array(
-          'type' => 'next',
-          'name' => ts('Delete'),
-          'subName' => 'view',
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel'),
-        ),
-      ));
-  }
-
-  /**
-   * Process the form when submitted
-   *
-   * @return void
-   * @access public
-   */
-  public function postProcess() {
-    CRM_Core_BAO_File::delete($this->_id, $this->_eid);
-    CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Deleted'), 'success');
-
-    $session = CRM_Core_Session::singleton();
-    $toUrl = $session->popUserContext();
-    CRM_Utils_System::redirect($toUrl);
-  }
-}
-
index 721d0e8617e94fb6389ab72f0a349d9c3c3340cd..64fe53dd30ae6a89dee427c2b7766f6cc0fe35e4 100644 (file)
@@ -432,7 +432,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         // Skip normal processing
         continue;
       }
-  
+
       // use UPDATE IGNORE + DELETE query pair to skip on situations when
       // there's a UNIQUE restriction on ($field, some_other_field) pair
       if (isset($cidRefs[$table])) {
@@ -474,7 +474,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
   /**
    * Find differences between contacts.
-   * 
+   *
    * @param array $main contact details
    * @param array $other contact details
    *
@@ -785,8 +785,8 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
       if (CRM_Utils_array::value('preferred_communication_method', $contact)){
       // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
-      $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? 
-        implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : 
+      $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ?
+        implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) :
         $specialValues[$moniker]['preferred_communication_method'];
         $specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
       }
@@ -1371,7 +1371,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
     // **** Do file custom fields related migrations
     // FIXME: move this someplace else (one of the BAOs) after discussing
-    // where to, and whether CRM_Core_BAO_File::delete() shouldn't actually,
+    // where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
     // like, delete a file...
 
     if (!isset($customFiles)) {
@@ -1391,7 +1391,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
       // delete the main contact's file
       if (!empty($fileIds[$mainId])) {
-        CRM_Core_BAO_File::delete($fileIds[$mainId], $mainId, $customId);
+        CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
       }
 
       // move the other contact's file to main contact