Issues (4069)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

modules/Campaigns/WizardNewsletter.php (6 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
/*********************************************************************************
4
 * SugarCRM Community Edition is a customer relationship management program developed by
5
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6
7
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
8
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
9
 *
10
 * This program is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU Affero General Public License version 3 as published by the
12
 * Free Software Foundation with the addition of the following permission added
13
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
14
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
15
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
16
 *
17
 * This program is distributed in the hope that it will be useful, but WITHOUT
18
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
20
 * details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License along with
23
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
24
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
 * 02110-1301 USA.
26
 *
27
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
28
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
29
 *
30
 * The interactive user interfaces in modified source and object code versions
31
 * of this program must display Appropriate Legal Notices, as required under
32
 * Section 5 of the GNU Affero General Public License version 3.
33
 *
34
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
35
 * these Appropriate Legal Notices must retain the display of the "Powered by
36
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
37
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
38
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
39
 ********************************************************************************/
40
41
/*********************************************************************************
42
43
 * Description:  TODO: To be written.
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45
 * All Rights Reserved.
46
 * Contributor(s): ______________________________________..
47
 ********************************************************************************/
48
49
/******** general UI Stuff ***********/
50
51
52
53
require_once('modules/Campaigns/utils.php');
54
55
56
global $app_strings;
57
global $timedate;
58
global $app_list_strings;
59
global $mod_strings;
60
global $current_user;
61
global $sugar_version, $sugar_config;
62
63
64
/*************** GENERAL SETUP WORK **********/
65
66
$focus = new Campaign();
67
if(isset($_REQUEST['record'])) {
68
    $focus->retrieve($_REQUEST['record']);
69
}
70
if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
71
    $focus->id = "";
72
}
73
global $theme;
74
75
76
77
$json = getJSONobj();
78
79
$GLOBALS['log']->info("Campaign NewsLetter Wizard");
80
81
if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
82
    echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_NEWSLETTER WIZARD_TITLE'].$focus->name), true, false);
83
}else{
84
    echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN'].$focus->name), true, false);   
85
}
86
87
88
$ss = new Sugar_Smarty();
89
$ss->assign("MOD", $mod_strings);
90
$ss->assign("APP", $app_strings);
91
92
if (isset($_REQUEST['return_module'])) $ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
93
if (isset($_REQUEST['return_action'])) $ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
94
if (isset($_REQUEST['return_id'])) $ss->assign("RETURN_ID", $_REQUEST['return_id']);
95
// handle Create $module then Cancel
96
if (empty($_REQUEST['return_id'])) {
97
    $ss->assign("RETURN_ACTION", 'index');
98
}
99
$ss->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
100
101
require_once('include/QuickSearchDefaults.php');
102
$qsd = QuickSearchDefaults::getQuickSearchDefaults();
103
$qsd->setFormName('wizform');
104
$sqs_objects = array('parent_name' => $qsd->getQSParent(), 
105
                    'assigned_user_name' => $qsd->getQSUser(),
106
                    //'prospect_list_name' => getProspectListQSObjects(),
107
                    'test_name' => getProspectListQSObjects('prospect_list_type_test', 'test_name','wiz_step3_test_name_id'),
108
                    'unsubscription_name' => getProspectListQSObjects('prospect_list_type_exempt', 'unsubscription_name','wiz_step3_unsubscription_name_id'),
109
                    'subscription_name' => getProspectListQSObjects('prospect_list_type_default', 'subscription_name','wiz_step3_subscription_name_id'),
110
                    );
111
                    
112
113
$quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
114
115
$ss->assign("JAVASCRIPT", $quicksearch_js);
116
117
118
//set the campaign type based on wizardtype value from request object
119
$campaign_type = 'newsletter';
120
if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
121
    $campaign_type = 'newsletter';
122
    $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());    
123
}elseif( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==2)  || ($focus->campaign_type=='Email') ){
124
    $campaign_type = 'email';
125
    $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
126
}else{
127
    $campaign_type = 'general';
128
}
129
130
131
//******** CAMPAIGN HEADER AND BUDGET UI DIV Stuff (both divs) **********/
132
/// Users Popup
133
$popup_request_data = array(
134
    'call_back_function' => 'set_return',
135
    'form_name' => 'wizform',
136
    'field_to_name_array' => array(
137
        'id' => 'assigned_user_id',
138
        'user_name' => 'assigned_user_name',
139
        ),
140
    );
141
$ss->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
142
143
144
//set default values
145
$ss->assign("CALENDAR_LANG", "en");
146
$ss->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
147
$ss->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
148
$ss->assign("CAMP_DATE_ENTERED", $focus->date_entered);
149
$ss->assign("CAMP_DATE_MODIFIED", $focus->date_modified);
150
$ss->assign("CAMP_CREATED_BY", $focus->created_by_name);
151
$ss->assign("CAMP_MODIFIED_BY", $focus->modified_by_name);
152
$ss->assign("ID", $focus->id);
153
$ss->assign("CAMP_TRACKER_TEXT", $focus->tracker_text);
154
$ss->assign("CAMP_START_DATE", $focus->start_date);
155
$ss->assign("CAMP_END_DATE", $focus->end_date);
156
$ss->assign("CAMP_BUDGET", $focus->budget);
157
$ss->assign("CAMP_ACTUAL_COST", $focus->actual_cost);
158
$ss->assign("CAMP_EXPECTED_REVENUE", $focus->expected_revenue);
159
$ss->assign("CAMP_EXPECTED_COST", $focus->expected_cost);
160
$ss->assign("CAMP_OBJECTIVE", $focus->objective);
161
$ss->assign("CAMP_CONTENT", $focus->content);
162
$ss->assign("CAMP_NAME", $focus->name);
163
$ss->assign("CAMP_RECORD", $focus->id);
164
$ss->assign("CAMP_IMPRESSIONS", $focus->impressions);
165
if (empty($focus->assigned_user_id) && empty($focus->id))  $focus->assigned_user_id = $current_user->id;
166
if (empty($focus->assigned_name) && empty($focus->id))  $focus->assigned_user_name = $current_user->user_name;
167
$ss->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
168
//$ss->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
169
170
$focus->list_view_parse_additional_sections($ss);
171
172
$ss->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
173
174
if((!isset($focus->status)) && (!isset($focus->id)))
175
    $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], 'Planning'));
176
else
177
    $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], $focus->status));
178
179
//hide frequency options if this is not a newsletter
180
if($campaign_type == 'newsletter'){
181
    $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "Select");
182
    $ss->assign("FREQUENCY_LABEL", $mod_strings['LBL_CAMPAIGN_FREQUENCY']);
183
    if((!isset($focus->frequency)) && (!isset($focus->id))){
184
        $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], 'Monthly'));
185
    }else{
186
        $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], $focus->frequency));
187
    }
188
}else{
189
    $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "input type='hidden'");
190
    $ss->assign("FREQUENCY_LABEL", '&nbsp;');
191
}
192
global $current_user;
193
require_once('modules/Currencies/ListCurrency.php');
194
$currency = new ListCurrency();
195
if(isset($focus->currency_id) && !empty($focus->currency_id)){
196
    $selectCurrency = $currency->getSelectOptions($focus->currency_id);
197
    $ss->assign("CURRENCY", $selectCurrency);
198
}
199
else if($current_user->getPreference('currency') && !isset($focus->id))
200
{
201
    $selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency'));
202
    $ss->assign("CURRENCY", $selectCurrency);
203
}else{
204
205
    $selectCurrency = $currency->getSelectOptions();
206
    $ss->assign("CURRENCY", $selectCurrency);
207
208
}
209
global $current_user;
210
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){  
211
    $record = '';
212
    if(!empty($_REQUEST['record'])){
213
        $record =   $_REQUEST['record'];
214
    }
215
    $ss->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>");
216
217
}
218
219
echo $currency->getJavascript();
220
221
$seps = get_number_seperators();
222
$ss->assign("NUM_GRP_SEP", $seps[0]);
223
$ss->assign("DEC_SEP", $seps[1]);
224
225
226
//fill out the campaign type dropdown based on type of campaign being created
227
if($campaign_type == 'general'){
228
    //get regular campaign dom object and strip out entries for email and newsletter
229
    $myTypeOptionsArr = array();
230
    $OptionsArr = $app_list_strings['campaign_type_dom'];
231
    foreach($OptionsArr as $key=>$val){
232
        if($val =='Newsletter' || $val =='Email' || $val =='' ){
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
233
            //do not add   
234
        }else{
235
            $myTypeOptionsArr[$key] = $val;
236
        }
237
    }
238
    
239
    //now create select option html without the newsletter/email, or blank ('') options
240
    $type_option_html =' ';
241
    $selected = false;
242
    foreach($myTypeOptionsArr as $optionKey=>$optionName){
243
        //if the selected flag is set to true, then just populate
244
        if($selected){
245
            $type_option_html .="<option value='$optionKey' >$optionName</option>";
246
        }else{//if not selected yet, check to see if this option should be selected
247
            //if the campaign type is not empty, then select the retrieved type
248
            if(!empty($focus->campaign_type)){
249
                //check to see if key matches campaign type
250
                if($optionKey == $focus->campaign_type){
251
                    //mark as selected
252
                    $type_option_html .="<option value='$optionKey' selected>$optionName</option>";
253
                    //mark as selected for next time
254
                    $selected=true;
255
                }else{
256
                    //key does not match, just populate
257
                    $type_option_html .="<option value='$optionKey' >$optionName</option>";
258
                }
259
            }else{
260
            //since the campaign type is empty, then select first one                
261
                $type_option_html .="<option value='$optionKey' selected>$optionName</option>";    
262
                //mark as selected for next time
263
                $selected=true;
264
            }
265
        }    
266
    }
267
    //assign the modified dropdown for general campaign creation
268
    $ss->assign("CAMPAIGN_TYPE_OPTIONS", $type_option_html);
269
    $ss->assign("SHOULD_TYPE_BE_DISABLED", "select");    
270
}elseif($campaign_type == 'email'){
271
    //Assign Email as type of campaign being created an disable the select widget
272
    $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_EMAIL']);
273
    $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='Email'");
274
    $ss->assign("HIDE_CAMPAIGN_TYPE", true);
275
}else{
276
    //Assign NewsLetter as type of campaign being created an disable the select widget
277
    $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']);
278
    $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'");
279
    $ss->assign("HIDE_CAMPAIGN_TYPE", true);
280
281
}
282
283
284
285
286
287
/***************  TRACKER UI DIV Stuff ***************/
288
//retrieve the trackers
289
$focus->load_relationship('tracked_urls');
290
291
$trkr_lists = $focus->tracked_urls->get();
292
$trkr_html ='';    
293
$ss->assign('TRACKER_COUNT',count($trkr_lists));
294
if(count($trkr_lists)>0){
295
global $odd_bg, $even_bg, $hilite_bg;
296
    
297
    $trkr_count = 0;
298
//create the html to create tracker table
299
    foreach($trkr_lists as $trkr_id){
300
        $ct_focus = new CampaignTracker();
301
        $ct_focus->retrieve($trkr_id);
302
      if(isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)){
303
            if($ct_focus->is_optout){$opt = 'checked';}else{$opt = '';}
304
            $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>" ;
305
            $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout".$trkr_count."' title='".$mod_strings['LBL_EDIT_OPT_OUT'] . $trkr_count ."' id='existing_is_optout". $trkr_count ."' class='checkbox' type='checkbox' $opt  /><input name='wiz_step3_id".$trkr_count."' value='".$ct_focus->id."' id='existing_tracker_id". $trkr_count ."'type='hidden''/></td>";
306
            $trkr_html .= "<td width='40%'> <input id='existing_tracker_name". $trkr_count ."' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_NAME']. $trkr_count ."' value='".$ct_focus->tracker_name."' ></td>";
307
            $trkr_html .= "<td width='40%'><input type='text' size='60' maxlength='255' name='wiz_step3_tracker_url". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_URL']. $trkr_count ."' id='existing_tracker_url". $trkr_count ."' value='".$ct_focus->tracker_url."' ></td>";
308
            $trkr_html .= "<td><a href='#' onclick=\"javascript:remove_existing_tracker('existing_trkr".$trkr_count."','".$ct_focus->id."'); \" >  ";
309
            $trkr_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0'  align='absmiddle'", 12, 12, ".gif", $mod_strings['LBL_DELETE'])."</a></td></tr></table></div>";
310
311
312
313
      }
314
      $trkr_count =$trkr_count+1;
315
    }
316
    
317
    $trkr_html .= "<div id='no_trackers'></div>";
318
    }else{
319
        $trkr_html .= "<div id='no_trackers'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
320
    }
321
    $ss->assign('EXISTING_TRACKERS', $trkr_html);
322
323
324
325
326
327
328
329
330
331
/************** SUBSCRIPTION UI DIV Stuff ***************/
332
//fill in popups for target list options
333
    $popup_request_data = array(
334
        'call_back_function' => 'set_return', 
335
        'form_name' => 'wizform',
336
        'field_to_name_array' => array(
337
            'id' => 'wiz_step3_subscription_name_id',
338
            'name' => 'wiz_step3_subscription_name',
339
            
340
            ),
341
        );
342
343
$json = getJSONobj();
344
$encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
345
$ss->assign('encoded_subscription_popup_request_data', $encoded_newsletter_popup_request_data);
346
347
    $popup_request_data = array(
348
        'call_back_function' => 'set_return', 
349
        'form_name' => 'wizform',
350
        'field_to_name_array' => array(
351
            'id' => 'wiz_step3_unsubscription_name_id',
352
            'name' => 'unsubscription_name',
353
            
354
            ),
355
        );
356
357
$json = getJSONobj();
358
$encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
359
$ss->assign('encoded_unsubscription_popup_request_data', $encoded_newsletter_popup_request_data);
360
361
    $popup_request_data = array(
362
        'call_back_function' => 'set_return', //set_return_and_save_background
363
        'form_name' => 'wizform',
364
        'field_to_name_array' => array(
365
            'id' => 'wiz_step3_test_name_id',
366
            'name' => 'test_name',
367
            
368
            ),
369
        );
370
371
$json = getJSONobj();
372
$encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
373
$ss->assign('encoded_test_popup_request_data', $encoded_newsletter_popup_request_data);
374
375
376
    $popup_request_data = array(
377
        'call_back_function' => 'set_return_prospect_list', 
378
        'form_name' => 'wizform',
379
        'field_to_name_array' => array(
380
            'id' => 'popup_target_list_id',
381
            'name' => 'popup_target_list_name',
382
            'list_type' => 'popup_target_list_type',
383
            
384
            ),
385
        );
386
387
$json = getJSONobj();
388
$encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
389
$ss->assign('encoded_target_list_popup_request_data', $encoded_newsletter_popup_request_data);
390
391
392
// ----- show target lists...
393
394
$targetList = BeanFactory::getBean('ProspectLists')->get_full_list();
395
396
$targetListData = array();
397
foreach($targetList as $prospectLst) {
0 ignored issues
show
The expression $targetList of type array<integer,object>|null is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
398
    $nxt = array(
399
        'id' => $prospectLst->id,
400
        'name' => $prospectLst->name,
401
        //'type' => $prospectLst->type,
402
        'description' => $prospectLst->description,
403
        'type' => $prospectLst->list_type,
404
        'count' => $prospectLst->get_entry_count(),
405
    );
406
    $targetListDataArray[] = $nxt;
407
    $targetListDataAssoc[$prospectLst->id] = $nxt;
408
}
409
410
411
$ss->assign('targetListData', $targetListDataArray);
412
413
$targetListDataJSON = json_encode($targetListDataAssoc);
414
$ss->assign('targetListDataJSON', $targetListDataJSON);
415
416
// -----
417
418
419
$ss->assign('TARGET_OPTIONS', get_select_options_with_id($app_list_strings['prospect_list_type_dom'], 'default'));
420
421
//retrieve the subscriptions
422
$focus->load_relationship('prospectlists');
423
424
$prospect_lists = $focus->prospectlists->get();
425
426
if((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] ==1) || ($focus->campaign_type=='NewsLetter')){
427
 //this is a newsletter type campaign, fill in subscription values   
428
429
//if prospect lists are returned, then iterate through and populate form values
430
if(count($prospect_lists)>0){
431
    
432
    foreach($prospect_lists as $pl_id){
433
    //retrieve prospect list
434
     $pl = new ProspectList();   
435
     $pl->retrieve($pl_id);
436
437
      if(isset($pl->list_type) && !empty($pl->list_type)){
438
         //assign values based on type
439
         if(($pl->list_type == 'default') || ($pl->list_type == 'seed')){            
440
            $ss->assign('SUBSCRIPTION_ID', $pl->id);
441
            $ss->assign('SUBSCRIPTION_NAME', $pl->name);
442
         };
443
         if($pl->list_type == 'exempt'){
444
            $ss->assign('UNSUBSCRIPTION_ID', $pl->id);
445
            $ss->assign('UNSUBSCRIPTION_NAME', $pl->name);
446
         
447
         };
448
         if($pl->list_type == 'test'){
449
            $ss->assign('TEST_ID', $pl->id);
450
            $ss->assign('TEST_NAME', $pl->name);
451
         
452
         };
453
      }
454
     
455
    }
456
}
457
458
459
460
}else{
461
    //this is not a newlsetter campaign, so fill in target list table
462
    //create array for javascript, this will help to display the option text, not the value
463
    $dom_txt =' ';
464
    foreach($app_list_strings['prospect_list_type_dom'] as $key=>$val){
465
        $dom_txt .="if(trgt_type_text =='$key'){trgt_type_text='$val';}";
466
    }
467
    $ss->assign("PL_DOM_STMT", $dom_txt);
468
    $trgt_count = 0;
469
    $trgt_html = ' ';
470
    if(count($prospect_lists)>0){
471
472
        foreach($prospect_lists as $pl_id){
473
            //retrieve prospect list
474
            $pl = new ProspectList();
475
            $pl_focus = $pl->retrieve($pl_id);
476
            $trgt_html .= "<div id='existing_trgt".$trgt_count."'> <table class='tabDetailViewDL2' width='100%'>" ;
477
            $trgt_html .= "<td width='100' style=\"width:25%\"> <input id='existing_target_name". $trgt_count ."' type='hidden' type='text' size='60' maxlength='255' name='existing_target_name". $trgt_count ."'  value='". $pl_focus->name."' ><a href=\"index.php?module=ProspectLists&action=DetailView&record=" . $pl_focus->id . "\" target=\"_blank\" title=\"" . $mod_strings['LBL_OPEN_IN_NEW_WINDOW'] . "\">". $pl_focus->name."</a></td>";
478
            $trgt_html .= "<td width='100' style=\"width:25%\">".$pl_focus->get_entry_count()."</td>";
479
            $trgt_html .= "<td width='100' style=\"width:25%\"><input type='hidden' size='60' maxlength='255' name='existing_tracker_list_type". $trgt_count ."'   id='existing_tracker_list_type". $trgt_count ."' value='".$pl_focus->list_type."' >".$app_list_strings['prospect_list_type_dom'][$pl_focus->list_type];
480
            $trgt_html .= "<input type='hidden' name='added_target_id". $trgt_count ."' id='added_target_id". $trgt_count ."' value='". $pl_focus->id ."' ></td>";
481
            $trgt_html .= "<td width='100' style=\"width:25%\"><a href='#' onclick=\"javascript:remove_existing_target('existing_trgt".$trgt_count."','".$pl_focus->id."'); \" >  ";
482
            $trgt_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0' align='absmiddle'", 12, 12, ".gif", $mod_strings['LBL_DELETE'])."</a></td></tr></table></div>";
483
484
            $trgt_count =$trgt_count +1;
485
        }
486
487
        $trgt_html  .= "<div id='no_targets'></div>";
488
    }else{
489
        $trgt_html  .= "<div id='no_targets'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
490
491
    }
492
    $ss->assign('EXISTING_TARGETS', $trgt_html );
493
494
}
495
496
    
497
/**************************** WIZARD UI DIV Stuff *******************/
498
$mrkt_string = $mod_strings['LBL_NAVIGATION_MENU_MARKETING'];
499
if(!empty($focus->id)){
500
    $mrkt_url = "<a  href='index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
501
    $mrkt_url .= "&return_id=".$focus->id."&campaign_id=".$focus->id;
502
    $mrkt_url .= "'>". $mrkt_string."</a>";
503
    $mrkt_string = $mrkt_url;
504
}
505
    $summ_url = $mod_strings['LBL_NAVIGATION_MENU_SUMMARY'];
506
    if(!empty($focus->id)){
507
        $summ_url = "<a  href='index.php?action=WizardHome&module=Campaigns";
508
        $summ_url .= "&return_id=".$focus->id."&record=".$focus->id;
509
        $summ_url .= "'> ". $mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."</a>";
510
    } 
511
   
512
513
514
$script_to_call ='';
515
    if (!empty($focus->id)){
516
        $maxStep = 2;
517
        $script_to_call = "link_navs(1, {$maxStep});";
518
        if(isset($_REQUEST['direct_step']) and !empty($_REQUEST['direct_step'])){
519
            $directStep = (int) $_REQUEST['direct_step'];
520
            if($directStep < 1) {
521
                $directStep = 1;
522
            }
523
            if($directStep > $maxStep) {
524
                $directStep = $maxStep;
525
            }
526
            $script_to_call .='   direct(' . $directStep . ');';
527
        }
528
    } 
529
    $ss->assign("HILITE_ALL", $script_to_call);
530
531
532
//  this is the wizard control script that resides in page    
533
 $divScript = <<<EOQ
534
535
 <script type="text/javascript" language="javascript">
536
   
537
    /*
538
     * this is the custom validation script that will call the right validation for each div
539
     */
540
    function validate_wiz_form(step){
541
        switch (step){
542
            case 'step1':
543
            if(!validate_step1()){return false;}
544
            break;
545
            case 'step2':
546
            //if(!validate_step2()){return false;}
547
            break;                  
548
            default://no additional validation needed      
549
        }
550
        return true;
551
    
552
    }
553
554
    showfirst('newsletter');
555
</script>
556
EOQ;
557
558
$ss->assign("DIV_JAVASCRIPT", $divScript);
559
560
561
$sshtml = ' ';
562
    $i = 1;
563
564
//Create the html to fill in the wizard steps
565
566
if($campaign_type == 'general'){
567
    $steps = create_campaign_steps();
568
569
    foreach($steps as $key => $step) {
570
        $_steps[$key] = false;
571
    }
572
    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'campaign',$mrkt_string,$summ_url, 'dotlist'));
0 ignored issues
show
The call to create_wiz_menu_items() has too many arguments starting with 'dotlist'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
573
    $ss->assign('HIDE_CONTINUE','hidden');
574
575
}elseif($campaign_type == 'email'){
576
    $steps = create_email_steps();
577
    if($focus->id) {
578
        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
579
    }
580
    else {
581
        $summ_url = false;
582
    }
583
    foreach($steps as $key => $step) {
584
        $_steps[$key] = false;
585
    }
586
    $campaign_id = $focus->id;
587
    $marketing_id = isset($_REQUEST['marketing_id']) && $_REQUEST['marketing_id'] ? $_REQUEST['marketing_id'] : null;
588
    $template_id = isset($_REQUEST['template_id']) && $_REQUEST['template_id'] ? $_REQUEST['template_id'] : null;
589
    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'email',$mrkt_string,$summ_url, 'dotlist', $campaign_id, $marketing_id, $template_id));
0 ignored issues
show
The call to create_wiz_menu_items() has too many arguments starting with 'dotlist'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
590
    $ss->assign('HIDE_CONTINUE','submit');
591
}else{
592
    $steps = create_newsletter_steps();
593
594
    if($focus->id) {
595
        $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
596
    }
597
    else {
598
        $summ_url = false;
599
    }
600
    foreach($steps as $key => $step) {
601
        $_steps[$key] = false;
602
    }
603
    $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'newsletter',$mrkt_string,$summ_url, 'dotlist'));
0 ignored issues
show
The call to create_wiz_menu_items() has too many arguments starting with 'dotlist'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
604
    $ss->assign('HIDE_CONTINUE','submit');
605
}
606
607
$ss->assign('TOTAL_STEPS', count($steps));
608
$sshtml = create_wiz_step_divs($steps,$ss);
609
$ss->assign('STEPS',$sshtml);
610
     	   	
611
612
/**************************** FINAL END OF PAGE UI Stuff *******************/
613
614
if(isset($_REQUEST['wizardtype'])) {
615
    switch($_REQUEST['wizardtype']) {
616
        case '1':
617
            $ss->assign('campaign_type', 'NewsLetter');
618
            break;
619
        case '2':
620
            $ss->assign('campaign_type', 'Email');
621
            break;
622
        case '3':
623
            $ss->assign('campaign_type', 'Telesales');
624
            break;
625
    }
626
}
627
628
$ss->display(file_exists('custom/modules/Campaigns/tpls/WizardNewsletter.tpl') ? 'custom/modules/Campaigns/tpls/WizardNewsletter.tpl' : 'modules/Campaigns/tpls/WizardNewsletter.tpl');
629
630
631
function create_newsletter_steps(){
632
    global $mod_strings;
633
    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
634
    //$steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
635
    //$steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
636
    $steps[$mod_strings['LBL_NAVIGATION_MENU_SUBSCRIPTIONS']] = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetList.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetList.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetList.tpl';
637
    return  $steps;
638
}
639
640
function create_campaign_steps(){
641
    global $mod_strings;
642
    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
643
    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
644
    $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
645
    return  $steps;
646
}
647
648
function create_email_steps(){
649
    global $mod_strings;
650
    $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
651
    //$steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
652
    //$steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
653
    $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
654
    return  $steps;
655
}
656
657
658
function create_wiz_step_divs($steps,$ss){
659
    $step_html = '';
660
    if(isset($steps)  && !empty($steps)){
661
        $i=1;
662
        foreach($steps as $name=>$step){
663
            $step_html .="<p><div id='step$i'>";
664
            $step_html .= $ss->fetch($step);
665
            $step_html .="</div></p>";
666
            $i = $i+1;
667
        }    
668
    }
669
    return $step_html;
670
}
671
672
function create_wiz_menu_items($steps,$type,$mrkt_string,$summ_url, $view = null, $campaign_id = null, $marketing_id = null, $template_id = null){
0 ignored issues
show
The function create_wiz_menu_items() has been defined more than once; this definition is ignored, only the first definition in modules/Campaigns/WizardHome.php (L500-537) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
673
674
    global $mod_strings;
675
676
677
    if($view == 'dotlist') {
678
679
        include_once 'modules/Campaigns/DotListWizardMenu.php';
680
681
        if($type!='campaign') {
682
            $templateURLForProgressBar = false;
683
            if ($campaign_id && $marketing_id && $template_id) {
684
                $templateURLForProgressBar = "index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id={$campaign_id}&campaign_id={$campaign_id}&jump=2&marketing_id={$marketing_id}&record={$marketing_id}&campaign_type=Email&template_id={$template_id}";
685
            }
686
687
            if(preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches)) {
688
                $templateURLForProgressBar = $matches[1];
689
            }
690
691
            $steps[$mod_strings['LBL_SELECT_TEMPLATE']] = $templateURLForProgressBar;
692
        }
693
694
        if ($type == 'newsletter' || $type == 'email') {
695
696
            preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches);
697
            if(isset($matches[1])) {
698
                $marketingLink = $matches[1] . ($matches[1] ? '&jump=2' : false);
699
            }
700
            else {
701
                $marketingLink = false;
702
            }
703
704
            $steps[$mod_strings['LBL_NAVIGATION_MENU_MARKETING']] = $marketingLink;
705
            $steps[$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL_AND_SUMMARY']] = $summ_url ? $summ_url : false;
706
            //$steps[$summ_url] = '#';
707
        } else {
708
            $steps[$summ_url] = false; //'#';
709
        }
710
711
        $nav_html = new DotListWizardMenu($mod_strings, $steps, true);
712
713
    }
714
    else {
715
        $nav_html = '<table border="0" cellspacing="0" cellpadding="0" width="100%" >';
716
        if(isset($steps)  && !empty($steps)){
717
            $i=1;
718
            foreach($steps as $name=>$step){
719
                $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step$i'>$name</div></td></tr>";
720
                $i=$i+1;
721
            }
722
        }
723
        if($type == 'newsletter'  ||  $type == 'email'){
724
            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">$mrkt_string</div></td></tr>";
725
            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
726
            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+3).">".$summ_url."</div></td></tr>";
727
        }else{
728
            $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">".$summ_url."</div></td></tr>";
729
        }
730
731
        $nav_html .= '</table>';
732
    }
733
734
    return $nav_html;
735
}
736
    
737
738
739
?>
740