Skip to content
Snippets Groups Projects
Commit b3fdbf3d authored by lobo's avatar lobo
Browse files

CRM-12261

parent bc028df3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
);
......
<?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);
}
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment