Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1233 Fix deleting of campaigns and saving of custom data for campaign and … #15233

Merged
merged 1 commit into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions CRM/Campaign/Form/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function setDefaultValues() {
}

public function buildQuickForm() {
$this->add('hidden', 'id', $this->_campaignId);
if ($this->_action & CRM_Core_Action::DELETE) {

$this->addButtons([
Expand All @@ -186,7 +187,6 @@ public function buildQuickForm() {
//lets assign custom data type and subtype.
$this->assign('customDataType', 'Campaign');
$this->assign('entityID', $this->_campaignId);
$this->assign('id', $this->_campaignId);
$this->assign('customDataSubType', CRM_Utils_Array::value('campaign_type_id', $this->_values));

$attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Campaign');
Expand Down Expand Up @@ -292,14 +292,18 @@ public function postProcess() {

$session = CRM_Core_Session::singleton();
$params = $this->controller->exportValues($this->_name);
if (isset($this->_campaignId)) {
// To properly save the DAO we need to ensure we don't have a blank id key passed through.
if (empty($params['id'])) {
unset($params['id']);
}
if (!empty($params['id'])) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Campaign::del($this->_campaignId);
CRM_Campaign_BAO_Campaign::del($params['id']);
CRM_Core_Session::setStatus(ts('Campaign has been deleted.'), ts('Record Deleted'), 'success');
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
return;
}
$params['id'] = $this->_campaignId;
$this->_campaignId = $params['id'];
}
else {
$params['created_id'] = $session->get('userID');
Expand Down Expand Up @@ -328,7 +332,7 @@ public function postProcess() {

public static function submit($params = [], $form) {
$groups = [];
if (is_array($params['includeGroups'])) {
if (!empty($params['includeGroups']) && is_array($params['includeGroups'])) {
foreach ($params['includeGroups'] as $key => $id) {
if ($id) {
$groups['include'][] = $id;
Expand All @@ -355,6 +359,7 @@ public static function submit($params = [], $form) {
$form->_campaignId,
'Campaign'
);

// dev/core#1067 Clean Money before passing onto BAO to do the create.
$params['goal_revenue'] = CRM_Utils_Rule::cleanMoney($params['goal_revenue']);
$result = civicrm_api3('Campaign', 'create', $params);
Expand Down
2 changes: 2 additions & 0 deletions CRM/Utils/API/HTMLInputCoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public function getSkipFields() {
'operator',
// CRM-20468
'content',
// CiviCampaign Goal Details
'goal_general',
];
$custom = CRM_Core_DAO::executeQuery('SELECT id FROM civicrm_custom_field WHERE html_type = "RichTextEditor"');
while ($custom->fetch()) {
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Campaign/Form/CampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function testSubmit($thousandSeparator) {
'custom' => [],
'campaign_type_id' => 1,
], $form);
var_dump($form);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that

$campaign = $this->callAPISuccess('campaign', 'get', ['id' => $result['id']]);
$this->assertEquals('10000', $campaign['values'][$campaign['id']]['goal_revenue']);
}
Expand Down