From b3fdbf3d1deb4246ecad25e62fe38f31b90f9e9c Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Mon, 1 Apr 2013 09:14:45 -0700 Subject: [PATCH] CRM-12261 --- CRM/Core/BAO/File.php | 16 ++++-- CRM/Core/Page/File.php | 9 ++-- CRM/Custom/Form/DeleteFile.php | 93 ---------------------------------- CRM/Dedupe/Merger.php | 12 ++--- 4 files changed, 21 insertions(+), 109 deletions(-) delete mode 100644 CRM/Custom/Form/DeleteFile.php diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index c10becaced..72ec638f92 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -154,11 +154,10 @@ } /** - * 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)) { @@ -190,6 +189,15 @@ 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 diff --git a/CRM/Core/Page/File.php b/CRM/Core/Page/File.php index 51a64dedcc..78a342be42 100644 --- a/CRM/Core/Page/File.php +++ b/CRM/Core/Page/File.php @@ -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 index 99d9ad56e8..0000000000 --- a/CRM/Custom/Form/DeleteFile.php +++ /dev/null @@ -1,93 +0,0 @@ -_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); - } -} - diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 721d0e8617..64fe53dd30 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -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 -- 2.25.1