This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | |||
44 | // load the correct demo data and main application language file depending upon the installer language selected; if |
||
45 | // it's not found fall back on en_us |
||
46 | if(file_exists("include/language/{$current_language}.lang.php")){ |
||
47 | require_once("include/language/{$current_language}.lang.php"); |
||
48 | } |
||
49 | else { |
||
50 | require_once("include/language/en_us.lang.php"); |
||
51 | } |
||
52 | require_once('install/UserDemoData.php'); |
||
53 | require_once('install/TeamDemoData.php'); |
||
54 | |||
55 | global $sugar_demodata; |
||
56 | if(file_exists("install/demoData.{$current_language}.php")){ |
||
57 | require_once("install/demoData.{$current_language}.php"); |
||
58 | } |
||
59 | else { |
||
60 | require_once("install/demoData.en_us.php"); |
||
61 | } |
||
62 | |||
63 | $last_name_count = count($sugar_demodata['last_name_array']); |
||
64 | $first_name_count = count($sugar_demodata['first_name_array']); |
||
65 | $company_name_count = count($sugar_demodata['company_name_array']); |
||
66 | $street_address_count = count($sugar_demodata['street_address_array']); |
||
67 | $city_array_count = count($sugar_demodata['city_array']); |
||
68 | global $app_list_strings; |
||
69 | global $sugar_config; |
||
70 | $_REQUEST['useEmailWidget'] = "true"; |
||
71 | if(empty($app_list_strings)) { |
||
72 | $app_list_strings = return_app_list_strings_language('en_us'); |
||
73 | } |
||
74 | /* |
||
75 | * Seed the random number generator with a fixed constant. This will make all installs of the same code have the same |
||
76 | * seed data. This facilitates cross database testing.. |
||
77 | */ |
||
78 | mt_srand(93285903); |
||
79 | $db = DBManagerFactory::getInstance(); |
||
80 | $timedate = TimeDate::getInstance(); |
||
81 | // Set the max time to one hour (helps Windows load the seed data) |
||
82 | ini_set("max_execution_time", "3600"); |
||
83 | // ensure we have enough memory |
||
84 | $memory_needed = 256; |
||
85 | $memory_limit = ini_get('memory_limit'); |
||
86 | if( $memory_limit != "" && $memory_limit != "-1" ){ // if memory_limit is set |
||
87 | rtrim($memory_limit, 'M'); |
||
88 | $memory_limit_int = (int) $memory_limit; |
||
89 | if( $memory_limit_int < $memory_needed ){ |
||
90 | ini_set("memory_limit", "$memory_needed" . "M"); |
||
91 | } |
||
92 | } |
||
93 | $large_scale_test = empty($sugar_config['large_scale_test']) ? |
||
94 | false : $sugar_config['large_scale_test']; |
||
95 | |||
96 | $seed_user = new User(); |
||
97 | $user_demo_data = new UserDemoData($seed_user, $large_scale_test); |
||
98 | $user_demo_data->create_demo_data(); |
||
99 | $number_contacts = 200; |
||
100 | $number_companies = 50; |
||
101 | $number_leads = 200; |
||
102 | $large_scale_test = empty($sugar_config['large_scale_test']) ? false : $sugar_config['large_scale_test']; |
||
103 | // If large scale test is set to true, increase the seed data. |
||
104 | if($large_scale_test) { |
||
105 | // increase the cuttoff time to 1 hour |
||
106 | ini_set("max_execution_time", "3600"); |
||
107 | $number_contacts = 100000; |
||
108 | $number_companies = 15000; |
||
109 | $number_leads = 100000; |
||
110 | } |
||
111 | |||
112 | |||
113 | $possible_duration_hours_arr = array( 0, 1, 2, 3); |
||
114 | $possible_duration_minutes_arr = array('00' => '00','15' => '15', '30' => '30', '45' => '45'); |
||
115 | $account_ids = Array(); |
||
116 | $accounts = Array(); |
||
117 | $opportunity_ids = Array(); |
||
118 | |||
119 | // Determine the assigned user for all demo data. This is the default user if set, or admin |
||
120 | $assigned_user_name = "admin"; |
||
121 | if(!empty($sugar_config['default_user_name']) && |
||
122 | !empty($sugar_config['create_default_user']) && |
||
123 | $sugar_config['create_default_user']) |
||
124 | { |
||
125 | $assigned_user_name = $sugar_config['default_user_name']; |
||
126 | } |
||
127 | |||
128 | // Look up the user id for the assigned user |
||
129 | $seed_user = new User(); |
||
130 | $assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name); |
||
131 | $patterns[] = '/ /'; |
||
132 | $patterns[] = '/\./'; |
||
133 | $patterns[] = '/&/'; |
||
134 | $patterns[] = '/\//'; |
||
135 | $replacements[] = ''; |
||
136 | $replacements[] = ''; |
||
137 | $replacements[] = ''; |
||
138 | $replacements[] = ''; |
||
139 | |||
140 | /////////////////////////////////////////////////////////////////////////////// |
||
141 | //// ACCOUNTS |
||
142 | |||
143 | for($i = 0; $i < $number_companies; $i++) { |
||
144 | $account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)]; |
||
145 | // Create new accounts. |
||
146 | $account = new Account(); |
||
147 | $account->name = $account_name; |
||
148 | $account->phone_office = create_phone_number(); |
||
149 | $account->assigned_user_id = $assigned_user_id; |
||
150 | $account->emailAddress->addAddress(createEmailAddress(), true); |
||
151 | $account->emailAddress->addAddress(createEmailAddress()); |
||
152 | $account->website = createWebAddress(); |
||
153 | $account->billing_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_count-1)]; |
||
154 | $account->billing_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_count-1)]; |
||
155 | if($i % 3 == 1) { |
||
156 | $account->billing_address_state = "NY"; |
||
157 | $assigned_user_id = mt_rand(9,10); |
||
158 | if($assigned_user_id == 9) { |
||
159 | $account->assigned_user_name = "seed_will"; |
||
160 | $account->assigned_user_id = $account->assigned_user_name."_id"; |
||
161 | } else { |
||
162 | $account->assigned_user_name = "seed_chris"; |
||
163 | $account->assigned_user_id = $account->assigned_user_name."_id"; |
||
164 | } |
||
165 | |||
166 | $account->assigned_user_id = $account->assigned_user_name."_id"; |
||
167 | } else { |
||
168 | $account->billing_address_state = "CA"; |
||
169 | $assigned_user_id = mt_rand(6,8); |
||
170 | if($assigned_user_id == 6) { |
||
171 | $account->assigned_user_name = "seed_sarah"; |
||
172 | } elseif($assigned_user_id == 7) { |
||
173 | $account->assigned_user_name = "seed_sally"; |
||
174 | } else { |
||
175 | $account->assigned_user_name = "seed_max"; |
||
176 | } |
||
177 | |||
178 | $account->assigned_user_id = $account->assigned_user_name."_id"; |
||
179 | } |
||
180 | |||
181 | $account->billing_address_postalcode = mt_rand(10000, 99999); |
||
182 | $account->billing_address_country = 'USA'; |
||
183 | $account->shipping_address_street = $account->billing_address_street; |
||
184 | $account->shipping_address_city = $account->billing_address_city; |
||
185 | $account->shipping_address_state = $account->billing_address_state; |
||
186 | $account->shipping_address_postalcode = $account->billing_address_postalcode; |
||
187 | $account->shipping_address_country = $account->billing_address_country; |
||
188 | $account->industry = array_rand($app_list_strings['industry_dom']); |
||
189 | $account->account_type = "Customer"; |
||
190 | $account->save(); |
||
191 | $account_ids[] = $account->id; |
||
192 | $accounts[] = $account; |
||
193 | |||
194 | // Create a case for the account |
||
195 | $case = new aCase(); |
||
196 | $case->account_id = $account->id; |
||
197 | $case->priority = array_rand($app_list_strings['case_priority_dom']); |
||
198 | $case->status = array_rand($app_list_strings['case_status_dom']); |
||
199 | $case->name = $sugar_demodata['case_seed_names'][mt_rand(0,4)]; |
||
200 | $case->assigned_user_id = $account->assigned_user_id; |
||
201 | $case->assigned_user_name = $account->assigned_user_name; |
||
202 | $case->save(); |
||
203 | |||
204 | // Create a bug for the account |
||
205 | $bug = new Bug(); |
||
206 | $bug->account_id = $account->id; |
||
207 | $bug->priority = array_rand($app_list_strings['bug_priority_dom']); |
||
208 | $bug->status = array_rand($app_list_strings['bug_status_dom']); |
||
209 | $bug->name = $sugar_demodata['bug_seed_names'][mt_rand(0,4)]; |
||
210 | $bug->assigned_user_id = $account->assigned_user_id; |
||
211 | $bug->assigned_user_name = $account->assigned_user_name; |
||
212 | $bug->save(); |
||
213 | |||
214 | $note = new Note(); |
||
215 | $note->parent_type = 'Accounts'; |
||
216 | $note->parent_id = $account->id; |
||
217 | $seed_data_index = mt_rand(0,3); |
||
218 | $note->name = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][0]; |
||
219 | $note->description = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][1]; |
||
220 | $note->assigned_user_id = $account->assigned_user_id; |
||
221 | $note->assigned_user_name = $account->assigned_user_name; |
||
222 | $note->save(); |
||
223 | |||
224 | $call = new Call(); |
||
225 | $call->parent_type = 'Accounts'; |
||
226 | $call->parent_id = $account->id; |
||
227 | $call->name = $sugar_demodata['call_seed_data_names'][mt_rand(0,3)]; |
||
228 | $call->assigned_user_id = $account->assigned_user_id; |
||
229 | $call->assigned_user_name = $account->assigned_user_name; |
||
230 | $call->direction='Outbound'; |
||
231 | $call->date_start = create_date(). ' ' . create_time(); |
||
232 | $call->duration_hours='0'; |
||
233 | $call->duration_minutes='30'; |
||
234 | $call->account_id =$account->id; |
||
235 | $call->status='Planned'; |
||
236 | $call->save(); |
||
237 | |||
238 | //Set the user to accept the call |
||
239 | $seed_user->id = $call->assigned_user_id; |
||
240 | $call->set_accept_status($seed_user,'accept'); |
||
241 | |||
242 | //Create new opportunities |
||
243 | $opp = new Opportunity(); |
||
244 | $opp->assigned_user_id = $account->assigned_user_id; |
||
245 | $opp->assigned_user_name = $account->assigned_user_name; |
||
246 | $opp->name = substr($account_name." - 1000 units", 0, 50); |
||
247 | $opp->date_closed = create_date(); |
||
248 | $opp->lead_source = array_rand($app_list_strings['lead_source_dom']); |
||
249 | $opp->sales_stage = array_rand($app_list_strings['sales_stage_dom']); |
||
250 | // If the deal is already one, make the date closed occur in the past. |
||
251 | if($opp->sales_stage == "Closed Won" || $opp->sales_stage == "Closed Lost") |
||
252 | { |
||
253 | $opp->date_closed = create_past_date(); |
||
254 | } |
||
255 | $opp->opportunity_type = array_rand($app_list_strings['opportunity_type_dom']); |
||
256 | $amount = array("10000", "25000", "50000", "75000"); |
||
257 | $key = array_rand($amount); |
||
258 | $opp->amount = $amount[$key]; |
||
259 | $probability = array("10", "70", "40", "60"); |
||
260 | $key = array_rand($probability); |
||
261 | $opp->probability = $probability[$key]; |
||
262 | $opp->save(); |
||
263 | $opportunity_ids[] = $opp->id; |
||
264 | // Create a linking table entry to assign an account to the opportunity. |
||
265 | $opp->set_relationship('accounts_opportunities', array('opportunity_id'=>$opp->id ,'account_id'=> $account->id), false); |
||
266 | |||
267 | } |
||
268 | |||
269 | $titles = $sugar_demodata['titles']; |
||
270 | $account_max = count($account_ids) - 1; |
||
271 | $first_name_max = $first_name_count - 1; |
||
272 | $last_name_max = $last_name_count - 1; |
||
273 | $street_address_max = $street_address_count - 1; |
||
274 | $city_array_max = $city_array_count - 1; |
||
275 | $lead_source_max = count($app_list_strings['lead_source_dom']) - 1; |
||
276 | $lead_status_max = count($app_list_strings['lead_status_dom']) - 1; |
||
277 | $title_max = count($titles) - 1; |
||
278 | /////////////////////////////////////////////////////////////////////////////// |
||
279 | //// DEMO CONTACTS |
||
280 | for($i=0; $i<$number_contacts; $i++) { |
||
281 | $contact = new Contact(); |
||
282 | $contact->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)]; |
||
283 | $contact->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)]; |
||
284 | $contact->assigned_user_id = $account->assigned_user_id; |
||
285 | $contact->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)]; |
||
286 | $contact->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)]; |
||
287 | $contact->lead_source = array_rand($app_list_strings['lead_source_dom']); |
||
288 | $contact->title = $titles[mt_rand(0,$title_max)]; |
||
289 | $contact->emailAddress->addAddress(createEmailAddress(), true, true); |
||
290 | $contact->emailAddress->addAddress(createEmailAddress(), false, false, false, true); |
||
291 | $assignedUser = new User(); |
||
292 | $assignedUser->retrieve($contact->assigned_user_id); |
||
293 | $contact->assigned_user_id = $assigned_user_id; |
||
294 | $contact->email1 = createEmailAddress(); |
||
295 | $key = array_rand($sugar_demodata['street_address_array']); |
||
296 | $contact->primary_address_street = $sugar_demodata['street_address_array'][$key]; |
||
297 | $key = array_rand($sugar_demodata['city_array']); |
||
298 | $contact->primary_address_city = $sugar_demodata['city_array'][$key]; |
||
299 | $contact->lead_source = array_rand($app_list_strings['lead_source_dom']); |
||
300 | $contact->title = $titles[array_rand($titles)]; |
||
301 | $contact->phone_work = create_phone_number(); |
||
302 | $contact->phone_home = create_phone_number(); |
||
303 | $contact->phone_mobile = create_phone_number(); |
||
304 | $account_number = mt_rand(0,$account_max); |
||
305 | $account_id = $account_ids[$account_number]; |
||
306 | // Fill in a bogus address |
||
307 | $contacts_account = $accounts[$account_number]; |
||
308 | $contact->primary_address_state = $contacts_account->billing_address_state; |
||
309 | $contact->assigned_user_id = $contacts_account->assigned_user_id; |
||
310 | $contact->assigned_user_name = $contacts_account->assigned_user_name; |
||
311 | $contact->primary_address_postalcode = mt_rand(10000,99999); |
||
312 | $contact->primary_address_country = 'USA'; |
||
313 | $contact->save(); |
||
314 | // Create a linking table entry to assign an account to the contact. |
||
315 | $contact->set_relationship('accounts_contacts', array('contact_id'=>$contact->id ,'account_id'=> $account_id), false); |
||
316 | // This assumes that there will be one opportunity per company in the seed data. |
||
317 | $opportunity_key = array_rand($opportunity_ids); |
||
318 | $contact->set_relationship('opportunities_contacts', array('contact_id'=>$contact->id ,'opportunity_id'=> $opportunity_ids[$opportunity_key], 'contact_role'=>$app_list_strings['opportunity_relationship_type_default_key']), false); |
||
319 | |||
320 | //Create new tasks |
||
321 | $task = new Task(); |
||
322 | $key = array_rand($sugar_demodata['task_seed_data_names']); |
||
323 | $task->name = $sugar_demodata['task_seed_data_names'][$key]; |
||
324 | //separate date and time field have been merged into one. |
||
325 | $task->date_due = create_date() . ' ' . create_time(); |
||
326 | $task->date_due_flag = 0; |
||
327 | $task->assigned_user_id = $contacts_account->assigned_user_id; |
||
328 | $task->assigned_user_name = $contacts_account->assigned_user_name; |
||
329 | $task->priority = array_rand($app_list_strings['task_priority_dom']); |
||
330 | $task->status = array_rand($app_list_strings['task_status_dom']); |
||
331 | $task->contact_id = $contact->id; |
||
332 | if ($contact->primary_address_city == "San Mateo") { |
||
333 | $task->parent_id = $account_id; |
||
334 | $task->parent_type = 'Accounts'; |
||
335 | } |
||
336 | $task->save(); |
||
337 | |||
338 | //Create new meetings |
||
339 | $meeting = new Meeting(); |
||
340 | $key = array_rand($sugar_demodata['meeting_seed_data_names']); |
||
341 | $meeting->name = $sugar_demodata['meeting_seed_data_names'][$key]; |
||
342 | $meeting->date_start = create_date(). ' ' . create_time(); |
||
343 | //$meeting->time_start = date("H:i",time()); |
||
344 | $meeting->duration_hours = array_rand($possible_duration_hours_arr); |
||
345 | $meeting->duration_minutes = array_rand($possible_duration_minutes_arr); |
||
346 | $meeting->assigned_user_id = $assigned_user_id; |
||
347 | $meeting->assigned_user_id = $contacts_account->assigned_user_id; |
||
348 | $meeting->assigned_user_name = $contacts_account->assigned_user_name; |
||
349 | $meeting->description = $sugar_demodata['meeting_seed_data_descriptions']; |
||
350 | $meeting->status = array_rand($app_list_strings['meeting_status_dom']); |
||
351 | $meeting->contact_id = $contact->id; |
||
352 | $meeting->parent_id = $account_id; |
||
353 | $meeting->parent_type = 'Accounts'; |
||
354 | // dont update vcal |
||
355 | $meeting->update_vcal = false; |
||
356 | $meeting->save(); |
||
357 | // leverage the seed user to set the acceptance status on the meeting. |
||
358 | $seed_user->id = $meeting->assigned_user_id; |
||
359 | $meeting->set_accept_status($seed_user,'accept'); |
||
360 | |||
361 | //Create new emails |
||
362 | $email = new Email(); |
||
363 | $key = array_rand($sugar_demodata['email_seed_data_subjects']); |
||
364 | $email->name = $sugar_demodata['email_seed_data_subjects'][$key]; |
||
365 | $email->date_start = create_date(); |
||
366 | $email->time_start = create_time(); |
||
367 | $email->duration_hours = array_rand($possible_duration_hours_arr); |
||
368 | $email->duration_minutes = array_rand($possible_duration_minutes_arr); |
||
369 | $email->assigned_user_id = $assigned_user_id; |
||
370 | $email->assigned_user_id = $contacts_account->assigned_user_id; |
||
371 | $email->assigned_user_name = $contacts_account->assigned_user_name; |
||
372 | $email->description = $sugar_demodata['email_seed_data_descriptions']; |
||
373 | $email->status = 'sent'; |
||
374 | $email->parent_id = $account_id; |
||
375 | $email->parent_type = 'Accounts'; |
||
376 | $email->to_addrs = $contact->emailAddress->getPrimaryAddress($contact); |
||
377 | $email->from_addr = $assignedUser->emailAddress->getPrimaryAddress($assignedUser); |
||
378 | $email->from_addr_name = $email->from_addr; |
||
379 | $email->to_addrs_names = $email->to_addrs; |
||
380 | $email->type = 'out'; |
||
381 | $email->save(); |
||
382 | $email->load_relationship('contacts'); |
||
383 | $email->contacts->add($contact); |
||
384 | $email->load_relationship('accounts'); |
||
385 | $email->accounts->add($contacts_account); |
||
386 | } |
||
387 | |||
388 | for($i=0; $i<$number_leads; $i++) |
||
389 | { |
||
390 | $lead = new Lead(); |
||
391 | $lead->account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)]; |
||
392 | $lead->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)]; |
||
393 | $lead->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)]; |
||
394 | $lead->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)]; |
||
395 | $lead->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)]; |
||
396 | $lead->lead_source = array_rand($app_list_strings['lead_source_dom']); |
||
397 | $lead->title = $sugar_demodata['titles'][mt_rand(0,$title_max)]; |
||
398 | $lead->phone_work = create_phone_number(); |
||
399 | $lead->phone_home = create_phone_number(); |
||
400 | $lead->phone_mobile = create_phone_number(); |
||
401 | $lead->emailAddress->addAddress(createEmailAddress(), true); |
||
402 | // Fill in a bogus address |
||
403 | $lead->primary_address_state = $sugar_demodata['primary_address_state']; |
||
404 | $leads_account = $accounts[$account_number]; |
||
405 | $lead->primary_address_state = $leads_account->billing_address_state; |
||
406 | $lead->status = array_rand($app_list_strings['lead_status_dom']); |
||
407 | $lead->lead_source = array_rand($app_list_strings['lead_source_dom']); |
||
408 | if($i % 3 == 1) |
||
409 | { |
||
410 | $lead->billing_address_state = $sugar_demodata['billing_address_state']['east']; |
||
411 | $assigned_user_id = mt_rand(9,10); |
||
412 | if($assigned_user_id == 9) |
||
413 | { |
||
414 | $lead->assigned_user_name = "seed_will"; |
||
415 | $lead->assigned_user_id = $lead->assigned_user_name."_id"; |
||
416 | } |
||
417 | else |
||
418 | { |
||
419 | $lead->assigned_user_name = "seed_chris"; |
||
420 | $lead->assigned_user_id = $lead->assigned_user_name."_id"; |
||
421 | } |
||
422 | |||
423 | $lead->assigned_user_id = $lead->assigned_user_name."_id"; |
||
424 | } |
||
425 | else |
||
426 | { |
||
427 | $lead->billing_address_state = $sugar_demodata['billing_address_state']['west']; |
||
428 | $assigned_user_id = mt_rand(6,8); |
||
429 | if($assigned_user_id == 6) |
||
430 | { |
||
431 | $lead->assigned_user_name = "seed_sarah"; |
||
432 | } |
||
433 | else if($assigned_user_id == 7) |
||
434 | { |
||
435 | $lead->assigned_user_name = "seed_sally"; |
||
436 | } |
||
437 | else |
||
438 | { |
||
439 | $lead->assigned_user_name = "seed_max"; |
||
440 | } |
||
441 | |||
442 | $lead->assigned_user_id = $lead->assigned_user_name."_id"; |
||
443 | } |
||
444 | |||
445 | |||
446 | // If this is a large scale test, switch to the bulk teams 90% of the time. |
||
447 | if ($large_scale_test) |
||
448 | { |
||
449 | if(mt_rand(0,100) < 90) { |
||
450 | $assigned_team = $team_demo_data->get_random_team(); |
||
451 | $lead->assigned_user_name = $assigned_team; |
||
452 | } else { |
||
0 ignored issues
–
show
|
|||
453 | } |
||
454 | } |
||
455 | $lead->primary_address_postalcode = mt_rand(10000,99999); |
||
456 | $lead->primary_address_country = $sugar_demodata['primary_address_country']; |
||
457 | $lead->save(); |
||
458 | } |
||
459 | |||
460 | |||
461 | /// |
||
462 | /// SEED DATA FOR EMAIL TEMPLATES |
||
463 | /// |
||
464 | if(!empty($sugar_demodata['emailtemplates_seed_data'])) { |
||
465 | foreach($sugar_demodata['emailtemplates_seed_data'] as $v){ |
||
466 | $EmailTemp = new EmailTemplate(); |
||
467 | $EmailTemp->name = $v['name']; |
||
468 | $EmailTemp->description = $v['description']; |
||
469 | $EmailTemp->subject = $v['subject']; |
||
470 | $EmailTemp->body = $v['text_body']; |
||
471 | $EmailTemp->body_html = $v['body']; |
||
472 | $EmailTemp->deleted = 0; |
||
0 ignored issues
–
show
The property
$deleted was declared of type boolean , but 0 is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
|||
473 | $EmailTemp->published = 'off'; |
||
474 | $EmailTemp->text_only = 0; |
||
475 | $id =$EmailTemp->save(); |
||
476 | } |
||
477 | } |
||
478 | /// |
||
479 | /// SEED DATA FOR PROJECT AND PROJECT TASK |
||
480 | /// |
||
481 | include_once('modules/Project/Project.php'); |
||
482 | include_once('modules/ProjectTask/ProjectTask.php'); |
||
483 | // Project: Audit Plan |
||
484 | $project = new Project(); |
||
485 | $project->name = $sugar_demodata['project_seed_data']['audit']['name']; |
||
486 | $project->description = $sugar_demodata['project_seed_data']['audit']['description']; |
||
487 | $project->assigned_user_id = 1; |
||
488 | $project->estimated_start_date = $sugar_demodata['project_seed_data']['audit']['estimated_start_date']; |
||
489 | $project->estimated_end_date = $sugar_demodata['project_seed_data']['audit']['estimated_end_date']; |
||
490 | $project->status = $sugar_demodata['project_seed_data']['audit']['status']; |
||
491 | $project->priority = $sugar_demodata['project_seed_data']['audit']['priority']; |
||
492 | $audit_plan_id = $project->save(); |
||
493 | |||
494 | $project_task_id_counter = 1; // all the project task IDs cannot be 1, so using couter |
||
495 | foreach($sugar_demodata['project_seed_data']['audit']['project_tasks'] as $v){ |
||
496 | $project_task = new ProjectTask(); |
||
497 | $project_task->assigned_user_id = 1; |
||
498 | $project_task->name = $v['name']; |
||
499 | $project_task->date_start = $v['date_start']; |
||
500 | $project_task->date_finish = $v['date_finish']; |
||
501 | $project_task->project_id = $audit_plan_id; |
||
502 | $project_task->project_task_id = $project_task_id_counter; |
||
503 | $project_task->description = $v['description']; |
||
504 | $project_task->duration = $v['duration']; |
||
505 | $project_task->duration_unit = $v['duration_unit']; |
||
506 | $project_task->percent_complete = $v['percent_complete']; |
||
507 | $communicate_stakeholders_id = $project_task->save(); |
||
508 | |||
509 | $project_task_id_counter++; |
||
510 | } |
||
511 | |||
512 | |||
513 | ?> |
||
514 |
This check looks for the
else
branches ofif
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
else
branches can be removed.could be turned into
This is much more concise to read.