return $contributeSettings;
}
+ /**
+ * This function process contribution related objects.
+ *
+ * @param int $contributionId
+ * @param int $statusId
+ * @param int|null $previousStatusId
+ *
+ * @param string $receiveDate
+ *
+ * @return null|string
+ */
+ public static function transitionComponentWithReturnMessage($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL) {
+ $statusMsg = NULL;
+ if (!$contributionId || !$statusId) {
+ return $statusMsg;
+ }
+
+ $params = array(
+ 'contribution_id' => $contributionId,
+ 'contribution_status_id' => $statusId,
+ 'previous_contribution_status_id' => $previousStatusId,
+ 'receive_date' => $receiveDate,
+ );
+
+ $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
+
+ if (!is_array($updateResult) ||
+ !($updatedComponents = CRM_Utils_Array::value('updatedComponents', $updateResult)) ||
+ !is_array($updatedComponents) ||
+ empty($updatedComponents)
+ ) {
+ return $statusMsg;
+ }
+
+ // get the user display name.
+ $sql = "
+ SELECT display_name as displayName
+ FROM civicrm_contact
+LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_contact.id )
+ WHERE civicrm_contribution.id = {$contributionId}";
+ $userDisplayName = CRM_Core_DAO::singleValueQuery($sql);
+
+ // get the status message for user.
+ foreach ($updatedComponents as $componentName => $updatedStatusId) {
+
+ if ($componentName == 'CiviMember') {
+ $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
+ CRM_Member_PseudoConstant::membershipStatus()
+ );
+ if ($updatedStatusName == 'Cancelled') {
+ $statusMsg .= "<br />" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName));
+ }
+ elseif ($updatedStatusName == 'Expired') {
+ $statusMsg .= "<br />" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName));
+ }
+ else {
+ $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult);
+ if ($endDate) {
+ $statusMsg .= "<br />" . ts("Membership for %1 has been updated. The membership End Date is %2.",
+ array(
+ 1 => $userDisplayName,
+ 2 => $endDate,
+ )
+ );
+ }
+ }
+ }
+
+ if ($componentName == 'CiviEvent') {
+ $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
+ CRM_Event_PseudoConstant::participantStatus()
+ );
+ if ($updatedStatusName == 'Cancelled') {
+ $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName));
+ }
+ elseif ($updatedStatusName == 'Registered') {
+ $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName));
+ }
+ }
+
+ if ($componentName == 'CiviPledge') {
+ $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
+ CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')
+ );
+ if ($updatedStatusName == 'Cancelled') {
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName));
+ }
+ elseif ($updatedStatusName == 'Failed') {
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName));
+ }
+ elseif ($updatedStatusName == 'Completed') {
+ $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName));
+ }
+ }
+ }
+
+ return $statusMsg;
+ }
+
}
$dao->free();
}
- /**
- * This function process contribution related objects.
- *
- * @param int $contributionId
- * @param int $statusId
- * @param int|null $previousStatusId
- *
- * @param string $receiveDate
- *
- * @return null|string
- */
- public static function updateRelatedComponent($contributionId, $statusId, $previousStatusId = NULL, $receiveDate = NULL) {
- $statusMsg = NULL;
- if (!$contributionId || !$statusId) {
- return $statusMsg;
- }
-
- $params = array(
- 'contribution_id' => $contributionId,
- 'contribution_status_id' => $statusId,
- 'previous_contribution_status_id' => $previousStatusId,
- 'receive_date' => $receiveDate,
- );
-
- $updateResult = CRM_Contribute_BAO_Contribution::transitionComponents($params);
-
- if (!is_array($updateResult) ||
- !($updatedComponents = CRM_Utils_Array::value('updatedComponents', $updateResult)) ||
- !is_array($updatedComponents) ||
- empty($updatedComponents)
- ) {
- return $statusMsg;
- }
-
- // get the user display name.
- $sql = "
- SELECT display_name as displayName
- FROM civicrm_contact
-LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_contact.id )
- WHERE civicrm_contribution.id = {$contributionId}";
- $userDisplayName = CRM_Core_DAO::singleValueQuery($sql);
-
- // get the status message for user.
- foreach ($updatedComponents as $componentName => $updatedStatusId) {
-
- if ($componentName == 'CiviMember') {
- $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
- CRM_Member_PseudoConstant::membershipStatus()
- );
- if ($updatedStatusName == 'Cancelled') {
- $statusMsg .= "<br />" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName));
- }
- elseif ($updatedStatusName == 'Expired') {
- $statusMsg .= "<br />" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName));
- }
- else {
- $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult);
- if ($endDate) {
- $statusMsg .= "<br />" . ts("Membership for %1 has been updated. The membership End Date is %2.",
- array(
- 1 => $userDisplayName,
- 2 => $endDate,
- )
- );
- }
- }
- }
-
- if ($componentName == 'CiviEvent') {
- $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
- CRM_Event_PseudoConstant::participantStatus()
- );
- if ($updatedStatusName == 'Cancelled') {
- $statusMsg .= "<br />" . ts("Event Registration for %1 has been Cancelled.", array(1 => $userDisplayName));
- }
- elseif ($updatedStatusName == 'Registered') {
- $statusMsg .= "<br />" . ts("Event Registration for %1 has been updated.", array(1 => $userDisplayName));
- }
- }
-
- if ($componentName == 'CiviPledge') {
- $updatedStatusName = CRM_Utils_Array::value($updatedStatusId,
- CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')
- );
- if ($updatedStatusName == 'Cancelled') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Cancelled.", array(1 => $userDisplayName));
- }
- elseif ($updatedStatusName == 'Failed') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been Failed.", array(1 => $userDisplayName));
- }
- elseif ($updatedStatusName == 'Completed') {
- $statusMsg .= "<br />" . ts("Pledge Payment for %1 has been updated.", array(1 => $userDisplayName));
- }
- }
- }
-
- return $statusMsg;
- }
-
/**
* @return array
* Array of valid processors. The array resembles the DB table but also has 'object' as a key
// process associated membership / participant, CRM-4395
if ($contribution->id && $action & CRM_Core_Action::UPDATE) {
- $this->statusMessage[] = self::updateRelatedComponent($contribution->id,
+ $this->statusMessage[] = CRM_Contribute_BAO_Contribution::transitionComponentWithReturnMessage($contribution->id,
$contribution->contribution_status_id,
CRM_Utils_Array::value('contribution_status_id',
$this->_values
$contribution = CRM_Contribute_BAO_Contribution::add($value, $ids);
if (!empty($value['contribution_status_id'])) {
- CRM_Contribute_Form_AbstractEditPayment::updateRelatedComponent($contribution->id,
+ CRM_Contribute_BAO_Contribution::transitionComponentWithReturnMessage($contribution->id,
$value['contribution_status_id'],
CRM_Utils_Array::value("field[{$key}][contribution_status_id]",
$this->_defaultValues