+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
/**
* Build all the data structures needed to build the form.
- *
- * @return void
*/
public function preProcess() {
//check for delete
/**
* Build the form object.
- *
- *
- * @return void
*/
public function buildQuickForm() {
- $this->addDefaultButtons(ts('Delete Contributions'), 'done');
+ $count = 0;
+ if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
+ foreach ($this->_contributionIds as $key => $id) {
+ $finTypeID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $id, 'financial_type_id');
+ if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($finTypeID))) {
+ unset($this->_contributionIds[$key]);
+ $count++;
+ }
+ // Now check for lineItems
+ if ($lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($id)) {
+ foreach ($lineItems as $items) {
+ if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
+ unset($this->_contributionIds[$key]);
+ $count++;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if ($count && empty($this->_contributionIds)) {
+ CRM_Core_Session::setStatus(ts('1 contribution could not be deleted.', array('plural' => '%count contributions could not be deleted.', 'count' => $count)), ts('Error'), 'error');
+ $this->addButtons(array(
+ array(
+ 'type' => 'back',
+ 'name' => ts('Cancel'),
+ ),
+ )
+ );
+ }
+ elseif ($count && !empty($this->_contributionIds)) {
+ CRM_Core_Session::setStatus(ts('1 contribution will not be deleted.', array('plural' => '%count contributions will not be deleted.', 'count' => $count)), ts('Warning'), 'warning');
+ $this->addDefaultButtons(ts('Delete Contributions'), 'done');
+ }
+ else {
+ $this->addDefaultButtons(ts('Delete Contributions'), 'done');
+ }
}
/**
* Process the form after the input has been submitted and validated.
- *
- *
- * @return void
*/
public function postProcess() {
$deleted = $failed = 0;