X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FForm%2FTask%2FBatch.php;h=718212524234b990684d0254cef13f6e2991188b;hb=3eb99314865180cc839aa99b70c140990ee0a013;hp=1e00bff6203fab373f152212f63da368b85e1412;hpb=06640b27e4f05ea6aa7829aec9466cd1c51ab694;p=civicrm-core.git diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index 1e00bff620..7182125242 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -1,9 +1,9 @@ exportValues(); - $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); - if (isset($params['field'])) { - foreach ($params['field'] as $key => $value) { - - //check for custom data - $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, - $key, - 'Participant' - ); - - $value['id'] = $key; - - if (!empty($value['participant_role'])) { - if (is_array($value['participant_role'])) { - $value['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value['participant_role'])); - } - else { - $value['role_id'] = $value['participant_role']; - } - } - - //need to send mail when status change - $statusChange = FALSE; - $relatedStatusChange = FALSE; - if (!empty($value['participant_status'])) { - $value['status_id'] = $value['participant_status']; - $fromStatusId = CRM_Utils_Array::value($key, $this->_fromStatusIds); - if (!$fromStatusId) { - $fromStatusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $key, 'status_id'); - } - - if ($fromStatusId != $value['status_id']) { - $relatedStatusChange = TRUE; - } - if ($statusClasses[$fromStatusId] != $statusClasses[$value['status_id']]) { - $statusChange = TRUE; - } - } - - unset($value['participant_status']); - - civicrm_api3('Participant', 'create', $value); - - //need to trigger mails when we change status - if ($statusChange) { - CRM_Event_BAO_Participant::transitionParticipants(array($key), $value['status_id'], $fromStatusId); - } - if ($relatedStatusChange) { - //update related contribution status, CRM-4395 - self::updatePendingOnlineContribution($key, $value['status_id']); - } - } - CRM_Core_Session::setStatus(ts('The updates have been saved.'), ts('Saved'), 'success'); - } - else { - CRM_Core_Session::setStatus(ts('No updates have been saved.'), ts('Not Saved'), 'alert'); - } + $this->submit($params); } /** @@ -519,4 +461,77 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { } } + /** + * @param $params + */ + public function submit($params) { + $statusClasses = CRM_Event_PseudoConstant::participantStatusClass(); + if (isset($params['field'])) { + foreach ($params['field'] as $key => $value) { + + //check for custom data + $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, + $key, + 'Participant' + ); + foreach (array_keys($value) as $fieldName) { + // Unset the original custom field now that it has been formatting to the 'custom' + // array as it may not be in the right format for the api as is (notably for + // multiple checkbox values). + // @todo extract submit functions on other Batch update classes & + // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test them. + if (substr($fieldName, 0, 7) === 'custom_') { + unset($value[$fieldName]); + } + } + + $value['id'] = $key; + + if (!empty($value['participant_role'])) { + if (is_array($value['participant_role'])) { + $value['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value['participant_role'])); + } + else { + $value['role_id'] = $value['participant_role']; + } + } + + //need to send mail when status change + $statusChange = FALSE; + $relatedStatusChange = FALSE; + if (!empty($value['participant_status'])) { + $value['status_id'] = $value['participant_status']; + $fromStatusId = CRM_Utils_Array::value($key, $this->_fromStatusIds); + if (!$fromStatusId) { + $fromStatusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $key, 'status_id'); + } + + if ($fromStatusId != $value['status_id']) { + $relatedStatusChange = TRUE; + } + if ($statusClasses[$fromStatusId] != $statusClasses[$value['status_id']]) { + $statusChange = TRUE; + } + } + + unset($value['participant_status']); + + civicrm_api3('Participant', 'create', $value); + + //need to trigger mails when we change status + if ($statusChange) { + CRM_Event_BAO_Participant::transitionParticipants(array($key), $value['status_id'], $fromStatusId); + } + if ($relatedStatusChange) { + //update related contribution status, CRM-4395 + self::updatePendingOnlineContribution($key, $value['status_id']); + } + } + CRM_Core_Session::setStatus(ts('The updates have been saved.'), ts('Saved'), 'success'); + } + else { + CRM_Core_Session::setStatus(ts('No updates have been saved.'), ts('Not Saved'), 'alert'); + } + } + }