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

Fix #2009 - Default for Campaign Type field causes incorrect wizard #10555

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
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
31 changes: 10 additions & 21 deletions modules/Campaigns/WizardNewsletter.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
* Copyright (C) 2011 - 2024 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
Expand Down Expand Up @@ -41,15 +39,14 @@
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/


if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

/******** general UI Stuff ***********/



require_once('modules/Campaigns/utils.php');


global $app_strings;
global $timedate;
global $app_list_strings;
Expand Down Expand Up @@ -119,20 +116,12 @@


//set the campaign type based on wizardtype value from request object
$campaign_type = 'newsletter';
if ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype']==1) || ($focus->campaign_type=='NewsLetter')) {
$campaign_type = 'newsletter';
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
} elseif ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype']==2) || ($focus->campaign_type=='Email')) {
$campaign_type = 'email';
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
} elseif ((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype']==4) || ($focus->campaign_type == 'Survey')) {
$campaign_type = 'survey';
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
} else {
$campaign_type = 'general';
}
$campaign_type = '';

$wizardType = $_REQUEST['wizardtype'] ?? '';

$campaign_type = assignCampaignType($focus, $wizardType, checkRequestWizardType($wizardType));
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());

//******** CAMPAIGN HEADER AND BUDGET UI DIV Stuff (both divs) **********/
/// Users Popup
Expand Down
64 changes: 60 additions & 4 deletions modules/Campaigns/utils.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
* Copyright (C) 2011 - 2024 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
Expand Down Expand Up @@ -49,6 +47,10 @@
* Contributor(s): ______________________________________..
********************************************************************************/

if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}

/*
*returns a list of objects a message can be scoped by, the list contacts the current campaign
*name and list of all prospects associated with this campaign..
Expand Down Expand Up @@ -1202,3 +1204,57 @@ function isValidWebToPersonModule(string $module): bool

return in_array($module, $validModules, true);
}

/**
* Helper function to check request data is present;
* @param string $requestWizardType
* @return bool
*/
function checkRequestWizardType(string $requestWizardType): bool
{
if (isset($requestWizardType) && !empty($requestWizardType)) {
return true;
}

return false;
}

/**
* Assigns a value of campaign type wheather recieved from $_REQUEST object
* (values from WizardHomeStart.tpl) or based on the bean properties;
* @param SugarBean $focus
* @param bool $requestWizardType
* @return string
*/
function assignCampaignType(SugarBean $focus, string $wizardType, bool $requestWizardType): string
{
$campaignType = '';

$campaignTypes = [
'NewsLetter' => 'newsletter',
'Email' => 'email',
'General' => 'general',
'Survey' => 'survey',
];

if ($requestWizardType) {
switch ($wizardType) {
case '1':
$campaignType = $campaignTypes['NewsLetter'];
break;
case '2':
$campaignType = $campaignTypes['Email'];
break;
case '4':
$campaignType = $campaignTypes['Survey'];
break;
case '3':
default:
$campaignType = $campaignTypes['General'];
}
} else {
$campaignType = $campaignTypes[$focus->campaign_type] ?? $campaignTypes['General'];
}

return $campaignType;
}