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.

include/MassUpdate.php (27 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 1
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 1
require_once('include/EditView/EditView2.php');
43
44
/**
45
 * MassUpdate class for updating multiple records at once
46
 * @api
47
 */
48
class MassUpdate
49
{
50
	/*
51
	 * internal sugarbean reference
52
	 */
53
	var $sugarbean = null;
54
55
	/**
56
	 * where clauses used to filter rows that have to be updated
57
	 */
58
	var $where_clauses = '';
59
60
	/**
61
	  * set the sugar bean to its internal member
62
	  * @param sugar bean reference
63
	  */
64 4
	function setSugarBean($sugar)
65
	{
66 4
		$this->sugarbean = $sugar;
67 4
	}
68
69
	/**
70
	 * get the massupdate form
71
	 * @param bool boolean need to execute the massupdate form or not
72
	 * @param multi_select_popup booleanif it is a multi-select value
73
	 */
74 1
	function getDisplayMassUpdateForm($bool, $multi_select_popup = false)
75
	{
76
77 1
		require_once('include/formbase.php');
78
79 1
		if(!$multi_select_popup)
80 1
		$form = '<form action="index.php" method="post" name="displayMassUpdate" id="displayMassUpdate">' . "\n";
81
		else
82
		$form = '<form action="index.php" method="post" name="MassUpdate" id="MassUpdate">' . "\n";
83
84 1
		if($bool)
85
		{
86 1
			$form .= '<input type="hidden" name="mu" value="false" />' . "\n";
87
		}
88
		else
89
		{
90
			$form .= '<input type="hidden" name="mu" value="true" />' . "\n";
91
		}
92
93 1
		$form .= getAnyToForm('mu', true);
94 1
		if(!$multi_select_popup) $form .= "</form>\n";
95
96 1
		return $form;
97
	}
98
	/**
99
	 * returns the mass update's html form header
100
	 * @param multi_select_popup boolean if it is a mult-select or not
101
	 */
102 1
	function getMassUpdateFormHeader($multi_select_popup = false)
103
	{
104 1
		global $sugar_version;
105 1
		global $sugar_config;
106 1
		global $current_user;
107
108 1
		unset($_REQUEST['current_query_by_page']);
109 1
		unset($_REQUEST[session_name()]);
110 1
		unset($_REQUEST['PHPSESSID']);
111 1
		$query = base64_encode(serialize($_REQUEST));
112
113 1
        $bean = loadBean($_REQUEST['module']);
0 ignored issues
show
Deprecated Code introduced by
The function loadBean() has been deprecated with message: use SugarModule::loadBean() instead

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
114 1
       $order_by_name = $bean->module_dir.'2_'.strtoupper($bean->object_name).'_ORDER_BY' ;
115 1
       $lvso = isset($_REQUEST['lvso'])?$_REQUEST['lvso']:"";
116 1
       $request_order_by_name = isset($_REQUEST[$order_by_name])?$_REQUEST[$order_by_name]:"";
117 1
       $action = isset($_REQUEST['action'])?$_REQUEST['action']:"";
118 1
       $module = isset($_REQUEST['module'])?$_REQUEST['module']:"";
119 1
		if($multi_select_popup)
120
		$tempString = '';
121
		else
122
		$tempString = "<form action='index.php' method='post' name='MassUpdate'  id='MassUpdate' onsubmit=\"return check_form('MassUpdate');\">\n"
123 1
		. "<input type='hidden' name='return_action' value='{$action}' />\n"
124 1
        . "<input type='hidden' name='return_module' value='{$module}' />\n"
125 1
		. "<input type='hidden' name='massupdate' value='true' />\n"
126 1
		. "<input type='hidden' name='delete' value='false' />\n"
127 1
		. "<input type='hidden' name='merge' value='false' />\n"
128 1
        . "<input type='hidden' name='current_query_by_page' value='{$query}' />\n"
129 1
        . "<input type='hidden' name='module' value='{$module}' />\n"
130 1
        . "<input type='hidden' name='action' value='MassUpdate' />\n"
131 1
        . "<input type='hidden' name='lvso' value='{$lvso}' />\n"
132 1
        . "<input type='hidden' name='{$order_by_name}' value='{$request_order_by_name}' />\n";
133
134
		// cn: bug 9103 - MU navigation in emails is broken
135 1
		if($_REQUEST['module'] == 'Emails') {
136
			$type = "";
137
			// determine "type" - inbound, archive, etc.
138
			if (isset($_REQUEST['type'])) {
139
				$type = $_REQUEST['type'];
140
			}
141
			// determine owner
142
			$tempString .=<<<eoq
143
				<input type='hidden' name='type' value="{$type}" />
144
				<input type='hidden' name='ie_assigned_user_id' value="{$current_user->id}" />
145
eoq;
146
		}
147
148 1
		return $tempString;
149
	}
150
151
	/**
152
	  * Executes the massupdate form
153
	  * @param displayname Name to display in the popup window
154
      * @param varname name of the variable
155
	  */
156 2
	function handleMassUpdate(){
157
158 2
		require_once('include/formbase.php');
159 2
		global $current_user, $db, $disable_date_format, $timedate;
160
161 2
		foreach($_POST as $post=>$value){
162
			if(is_array($value)){
163
				if(empty($value)){
164
					unset($_POST[$post]);
165
				}
166
			}elseif(strlen($value) == 0){
167
				if( isset($this->sugarbean->field_defs[$post]) && $this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) ){
168
				  $_POST[$post] = '';
169
				}else{
170
				  unset($_POST[$post]);
171
			    }
172
            }
173
174
			if(is_string($value) && isset($this->sugarbean->field_defs[$post])) {
175
		        if(($this->sugarbean->field_defs[$post]['type'] == 'bool'
176
				 	|| (!empty($this->sugarbean->field_defs[$post]['custom_type']) && $this->sugarbean->field_defs[$post]['custom_type'] == 'bool'
177
				 	))){
178
				 		if(strcmp($value, '2') == 0)$_POST[$post] = 0;
179
				 		if(!empty($this->sugarbean->field_defs[$post]['dbType']) && strcmp($this->sugarbean->field_defs[$post]['dbType'], 'varchar') == 0 ){
180
				 			if(strcmp($value, '1') == 0 )$_POST[$post] = 'on';
181
				 			if(strcmp($value, '2') == 0)$_POST[$post] = 'off';
182
				 		}
183
    			}
184
185
			    if( ($this->sugarbean->field_defs[$post]['type'] == 'radioenum' && isset($_POST[$post]) && strlen($value) == 0)
186
			    || ($this->sugarbean->field_defs[$post]['type'] == 'enum' && $value == '__SugarMassUpdateClearField__') // Set to '' if it's an explicit clear
187
			    ){
188
				    $_POST[$post] = '';
189
			    }
190
                if ($this->sugarbean->field_defs[$post]['type'] == 'bool') {
191
                    $this->checkClearField($post, $value);
192
                }
193
			    if($this->sugarbean->field_defs[$post]['type'] == 'date' && !empty($_POST[$post])){
194
			        $_POST[$post] = $timedate->to_db_date($_POST[$post], false);
195
			    }
196
                if($this->sugarbean->field_defs[$post]['type'] == 'datetime' && !empty($_POST[$post])){
197
			        $_POST[$post] = $timedate->to_db($this->date_to_dateTime($post, $value));
198
			    }
199
			    if($this->sugarbean->field_defs[$post]['type'] == 'datetimecombo' && !empty($_POST[$post])){
200
			        $_POST[$post] = $timedate->to_db($_POST[$post]);
201
			    }
202
            }
203
         }
204
205
		//We need to disable_date_format so that date values for the beans remain in database format
206
		//notice we make this call after the above section since the calls to TimeDate class there could wind up
207
		//making it's way to the UserPreferences objects in which case we want to enable the global date formatting
208
		//to correctly retrieve the user's date format preferences
209 2
		$old_value = $disable_date_format;
210 2
		$disable_date_format = true;
211
212 2
		if(!empty($_REQUEST['uid'])) $_POST['mass'] = explode(',', $_REQUEST['uid']); // coming from listview
213 2
		elseif(isset($_REQUEST['entire']) && empty($_POST['mass'])) {
214
			if(empty($order_by))$order_by = '';
0 ignored issues
show
The variable $order_by seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true.

This check marks calls to isset(...) or empty(...) that are found before the variable itself is defined. These will always have the same result.

This is likely the result of code being shifted around. Consider removing these calls.

Loading history...
215
216
            // TODO: define filter array here to optimize the query
217
            // by not joining the unneeded tables
218
            $query = $this->sugarbean->create_new_list_query($order_by, $this->where_clauses, array(), array(), 0, '', false, $this, true, true);
219
			$result = $db->query($query,true);
220
			$new_arr = array();
221
			while($val = $db->fetchByAssoc($result,false))
222
			{
223
				array_push($new_arr, $val['id']);
224
			}
225
			$_POST['mass'] = $new_arr;
226
		}
227
228 2
		if(isset($_POST['mass']) && is_array($_POST['mass'])  && $_REQUEST['massupdate'] == 'true'){
229
			$count = 0;
230
231
232
			foreach($_POST['mass'] as $id){
233
                if(empty($id)) {
234
                    continue;
235
                }
236
				if(isset($_POST['Delete'])){
237
					$this->sugarbean->retrieve($id);
238
					if($this->sugarbean->ACLAccess('Delete')){
239
						$this->sugarbean->mark_deleted($id);
240
					}
241
				}
242
				else {
243
					if($this->sugarbean->object_name == 'Contact' && isset($_POST['Sync'])){ // special for contacts module
244
						if($_POST['Sync'] == 'true') {
245
							$this->sugarbean->retrieve($id);
246
							if($this->sugarbean->ACLAccess('Save')){
247
								if($this->sugarbean->object_name == 'Contact'){
248
249
									$this->sugarbean->contacts_users_id = $current_user->id;
250
									$this->sugarbean->save(false);
251
								}
252
							}
253
						}
254
						elseif($_POST['Sync'] == 'false') {
255
							$this->sugarbean->retrieve($id);
256
							if($this->sugarbean->ACLAccess('Save')){
257
								if($this->sugarbean->object_name == 'Contact'){
258
									if (!isset($this->sugarbean->users))
259
									{
260
										$this->sugarbean->load_relationship('user_sync');
261
									}
262
									$this->sugarbean->contacts_users_id = null;
263
									$this->sugarbean->user_sync->delete($this->sugarbean->id, $current_user->id);
264
								}
265
							}
266
						}
267
					} //end if for special Contact handling
268
269
					if($count++ != 0) {
270
					   //Create a new instance to clear values and handle additional updates to bean's 2,3,4...
271
                       $className = get_class($this->sugarbean);
272
                       $this->sugarbean = new $className();
273
					}
274
275
					$this->sugarbean->retrieve($id);
276
277
278
					if($this->sugarbean->ACLAccess('Save')){
279
						$_POST['record'] = $id;
280
						$_GET['record'] = $id;
281
						$_REQUEST['record'] = $id;
282
						$newbean=$this->sugarbean;
283
284
						$old_reports_to_id = null;
285
						if(!empty($_POST['reports_to_id']) && $newbean->reports_to_id != $_POST['reports_to_id']) {
286
						   $old_reports_to_id = empty($newbean->reports_to_id) ? 'null' : $newbean->reports_to_id;
287
						}
288
289
						$check_notify = FALSE;
290
291
						if (isset( $this->sugarbean->assigned_user_id)) {
292
							$old_assigned_user_id = $this->sugarbean->assigned_user_id;
293
							if (!empty($_POST['assigned_user_id'])
294
							&& ($old_assigned_user_id != $_POST['assigned_user_id'])
295
							&& ($_POST['assigned_user_id'] != $current_user->id)) {
296
								$check_notify = TRUE;
297
							}
298
						}
299
300
						//Call include/formbase.php, but do not call retrieve again
301
                        populateFromPost('', $newbean, true, true);
302
						$newbean->save_from_post = false;
303
304
						if (!isset($_POST['parent_id'])) {
305
							$newbean->parent_type = null;
306
						}
307
308
						$email_address_id = '';
309
	                    if (!empty($_POST['optout_primary'])) {
310
	                    	$optout_flag_value = 0;
311
	                    	if ($_POST['optout_primary'] == 'true') {
312
	                    		$optout_flag_value = 1;
313
	                    	} // if
314
	                    	if (isset($this->sugarbean->emailAddress)) {
315
	                    		if (!empty($this->sugarbean->emailAddress->addresses)) {
316
	                    			foreach($this->sugarbean->emailAddress->addresses as $key =>$emailAddressRow) {
317
	                    				if ($emailAddressRow['primary_address'] == '1') {
318
	                    					$email_address_id = $emailAddressRow['email_address_id'];
319
	                    					break;
320
										} // if
321
									} // foreach
322
								} // if
323
324
							} // if
325
	                    } // if
326
327
328
						$newbean->save($check_notify);
329
						if (!empty($email_address_id)) {
330
	    					$query = "UPDATE email_addresses SET opt_out = {$optout_flag_value} where id = '{$emailAddressRow['email_address_id']}'";
0 ignored issues
show
The variable $emailAddressRow seems to be defined by a foreach iteration on line 316. Are you sure the iterator is never empty, otherwise this variable is not defined?

It seems like you are relying on a variable being defined by an iteration:

foreach ($a as $b) {
}

// $b is defined here only if $a has elements, for example if $a is array()
// then $b would not be defined here. To avoid that, we recommend to set a
// default value for $b.


// Better
$b = 0; // or whatever default makes sense in your context
foreach ($a as $b) {
}

// $b is now guaranteed to be defined here.
Loading history...
331
	    					$GLOBALS['db']->query($query);
332
333
						} // if
334
335
						if(!empty($old_reports_to_id) && method_exists($newbean, 'update_team_memberships')) {
336
						   $old_id = $old_reports_to_id == 'null' ? '' : $old_reports_to_id;
337
						}
338
					}
339
				}
340
			}
341
342
		}
343 2
		$disable_date_format = $old_value;
344 2
	}
345
	/**
346
  	  * Displays the massupdate form
347
  	  */
348 1
	function getMassUpdateForm(
349
	    $hideDeleteIfNoFieldsAvailable = false
350
	    )
351
	{
352 1
		global $app_strings;
353 1
		global $current_user;
354
355 1
		if($this->sugarbean->bean_implements('ACL') && ( !ACLController::checkAccess($this->sugarbean->module_dir, 'edit', true) || !ACLController::checkAccess($this->sugarbean->module_dir, 'massupdate', true) ) ){
356
			return '';
357
		}
358
359 1
		$lang_delete = translate('LBL_DELETE');
360 1
		$lang_update = translate('LBL_UPDATE');
361 1
		$lang_confirm= translate('NTC_DELETE_CONFIRMATION_MULTIPLE');
362 1
		$lang_sync = translate('LBL_SYNC_CONTACT');
363 1
		$lang_oc_status = translate('LBL_OC_STATUS');
364 1
		$lang_unsync = translate('LBL_UNSYNC');
365 1
		$lang_archive = translate('LBL_ARCHIVE');
366 1
		$lang_optout_primaryemail = $app_strings['LBL_OPT_OUT_FLAG_PRIMARY'];
367
368 1
		$field_count = 0;
369
370 1
		$html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE']."</h3></td></tr></table>";
371 1
		$html .= "<div id='mass_update_div'><table cellpadding='0' cellspacing='1' border='0' width='100%' class='edit view' id='mass_update_table'>";
372
373 1
		$even = true;
374
375 1
		if($this->sugarbean->object_name == 'Contact')
376
		{
377
			$html .= "<tr><td width='15%' scope='row'>$lang_sync</td><td width='35%' class='dataField'><select name='Sync'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td>";
378
			$even = false;
379 1
		} else if($this->sugarbean->object_name == 'Employee') {
380
			$this->sugarbean->field_defs['employee_status']['type'] = 'enum';
381
			$this->sugarbean->field_defs['employee_status']['massupdate'] = true;
382
			$this->sugarbean->field_defs['employee_status']['options'] = 'employee_status_dom';
383 1
		} else if($this->sugarbean->object_name == 'InboundEmail'){
384
			$this->sugarbean->field_defs['status']['type'] = 'enum';
385
			$this->sugarbean->field_defs['status']['options'] = 'user_status_dom';
386
		}
387
388
		//These fields should never appear on mass update form
389 1
		static $banned = array('date_modified'=>1, 'date_entered'=>1, 'created_by'=>1, 'modified_user_id'=>1, 'deleted'=>1,'modified_by_name'=>1,);
390
391 1
		foreach($this->sugarbean->field_defs as $field)
392
		{
393 1
			 if(!isset($banned[$field['name']]) && (!isset($field['massupdate']) || !empty($field['massupdate'])))
394
			 {
395 1
				$newhtml = '';
396
397 1
				if($even)
398
				{
399 1
					$newhtml .= "<tr>";
400
				}
401
402 1
				if(isset($field['vname']))
403
				{
404 1
					$displayname = translate($field['vname']);
405
				}else{
406
					$displayname = '';
407
				}
408
409 1
				if(isset($field['type']) && $field['type'] == 'relate' && isset($field['id_name']) && $field['id_name'] == 'assigned_user_id')
410
				{
411
					$field['type'] = 'assigned_user_name';
412
				}
413
414 1
				if(isset($field['custom_type']))
415
				{
416
					$field['type'] = $field['custom_type'];
417
				}
418
419 1
				if(isset($field['type']))
420
				{
421 1
					switch($field["type"])
422
					{
423 1
						case "relate":
424
    						    // bug 14691: avoid laying out an empty cell in the <table>
425 1
    							$handleRelationship = $this->handleRelationship($displayname, $field);
426 1
    							if ($handleRelationship != '')
427
    							{
428 1
    								$even = !$even;
429 1
    								$newhtml .= $handleRelationship;
430
    							}
431 1
							break;
432 1
						case "parent":$even = !$even; $newhtml .=$this->addParent($displayname, $field); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
433 1
						case "int":
434
							if(!empty($field['massupdate']) && empty($field['auto_increment']))
435
							{
436
								$even = !$even; $newhtml .=$this->addInputType($displayname, $field);
437
							}
438
							 break;
439 1
						case "contact_id":$even = !$even; $newhtml .=$this->addContactID($displayname, $field["name"]); break;
0 ignored issues
show
The method addContactID() does not seem to exist on object<MassUpdate>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
440 1
						case "assigned_user_name":$even = !$even; $newhtml .= $this->addAssignedUserID($displayname,  $field["name"]); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
441 1
						case "account_id":$even = !$even; $newhtml .= $this->addAccountID($displayname,  $field["name"]); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
442 1
						case "account_name":$even = !$even; $newhtml .= $this->addAccountID($displayname,  $field["id_name"]); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
443 1
						case "bool": $even = !$even; $newhtml .= $this->addBool($displayname,  $field["name"]); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
444 1
						case "enum":
445 1
						case "multienum":
446 1
							if(!empty($field['isMultiSelect']))
447
							{
448
								$even = !$even; $newhtml .= $this->addStatusMulti($displayname,  $field["name"], translate($field["options"])); break;
449 1
							}else if(!empty($field['options'])) {
450 1
								$even = !$even; $newhtml .= $this->addStatus($displayname,  $field["name"], translate($field["options"])); break;
451
							}else if(!empty($field['function'])){
452
								$functionValue = $this->getFunctionValue($this->sugarbean, $field);
453
								$even = !$even; $newhtml .= $this->addStatus($displayname,  $field["name"], $functionValue); break;
454
							}
455
							break;
456 1
						case "radioenum":
457
						$even = !$even; $newhtml .= $this->addRadioenum($displayname,  $field["name"] , translate($field["options"])); break;
0 ignored issues
show
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
458 1
						case "datetimecombo":
459
						$even = !$even; $newhtml .= $this->addDatetime($displayname,  $field["name"]); break;
0 ignored issues
show
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
460 1
						case "datetime":
461 1
						case "date":$even = !$even; $newhtml .= $this->addDate($displayname,  $field["name"]); break;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
462
                        default:
463 1
                            $newhtml .= $this->addDefault($displayname,  $field, $even); break;
0 ignored issues
show
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
464
                            break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
465
					}
466
				}
467
468 1
				if($even)
469
				{
470 1
					$newhtml .="</tr>";
471
				}
472
473 1
				$field_count++;
474
475 1
				if(!in_array($newhtml, array('<tr>', '</tr>', '<tr></tr>', '<tr><td></td></tr>'))){
476 1
					$html.=$newhtml;
477
				}
478
			}
479
		}
480
481
482 1
		if ($this->sugarbean->object_name == 'Contact' ||
483 1
			$this->sugarbean->object_name == 'Account' ||
484 1
			$this->sugarbean->object_name == 'Lead' ||
485 1
			$this->sugarbean->object_name == 'Prospect') {
486
487
			$html .= "<tr><td width='15%'  scope='row' class='dataLabel'>$lang_optout_primaryemail</td><td width='35%' class='dataField'><select name='optout_primary'><option value=''>{$GLOBALS['app_strings']['LBL_NONE']}</option><option value='false'>{$GLOBALS['app_list_strings']['checkbox_dom']['2']}</option><option value='true'>{$GLOBALS['app_list_strings']['checkbox_dom']['1']}</option></select></td></tr>";
488
489
			}
490 1
		$html .="</table>";
491
492 1
		 $html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td class='buttons'><input onclick='return sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\")' type='submit' id='update_button' name='Update' value='{$lang_update}' class='button'>&nbsp;<input onclick='javascript:toggleMassUpdateForm();' type='button' id='cancel_button' name='Cancel' value='{$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL']}' class='button'>";
493
		// TODO: allow ACL access for Delete to be set false always for users
494
//		if($this->sugarbean->ACLAccess('Delete', true) && $this->sugarbean->object_name != 'User') {
495
//			global $app_list_strings;
496
//			$html .=" <input id='delete_button' type='submit' name='Delete' value='{$lang_delete}' onclick='return confirm(\"{$lang_confirm}\") && sListView.send_mass_update(\"selected\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\", 1)' class='button'>";
497
//		}
498
499
		// only for My Inbox views - to allow CSRs to have an "Archive" emails feature to get the email "out" of their inbox.
500 1
		if($this->sugarbean->object_name == 'Email'
501 1
		&& (isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']))
502 1
		&& (isset($_REQUEST['type']) && !empty($_REQUEST['type']) && $_REQUEST['type'] == 'inbound')) {
503
			$html .=<<<eoq
504
			<input type='button' name='archive' value="{$lang_archive}" class='button' onClick='setArchived();'>
505
			<input type='hidden' name='ie_assigned_user_id' value="{$current_user->id}">
506
			<input type='hidden' name='ie_type' value="inbound">
507
eoq;
508
		}
509
510 1
		$html .= "</td></tr></table></div></div>";
511
512
		$html .= <<<EOJS
513
<script>
514
function toggleMassUpdateForm(){
515
    document.getElementById('massupdate_form').style.display = 'none';
516
}
517 1
</script>
518
EOJS;
519
520 1
		if($field_count > 0)
521
		{
522 1
			return $html;
523
		}else{
524
			//If no fields are found, render either a form that still permits Mass Update deletes or just display a message that no fields are available
525
			$html = "<div id='massupdate_form' style='display:none;'><table width='100%' cellpadding='0' cellspacing='0' border='0' class='formHeader h3Row'><tr><td nowrap><h3><span>" . $app_strings['LBL_MASS_UPDATE']."</h3></td></tr></table>";
526
			if($this->sugarbean->ACLAccess('Delete', true) && !$hideDeleteIfNoFieldsAvailable){
527
				$html .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td><input type='submit' name='Delete' value='$lang_delete' onclick=\"return confirm('{$lang_confirm}')\" class='button'></td></tr></table></div>";
528
			}else{
529
				$html .= $app_strings['LBL_NO_MASS_UPDATE_FIELDS_AVAILABLE'] . "</div>";
530
			}
531
			return $html;
532
		}
533
	}
534
535
	function getFunctionValue($focus, $vardef){
536
		$function = $vardef['function'];
537
	    if(is_array($function) && isset($function['name'])){
538
	    	$function = $vardef['function']['name'];
539
	    }else{
540
	       	$function = $vardef['function'];
541
	    }
542
		if(!empty($vardef['function']['returns']) && $vardef['function']['returns'] == 'html'){
543
			if(!empty($vardef['function']['include'])){
544
				require_once($vardef['function']['include']);
545
			}
546
			return call_user_func($function, $focus, $vardef['name'], '', 'MassUpdate');
547
		}else{
548
			return call_user_func($function, $focus, $vardef['name'], '', 'MassUpdate');
549
		}
550
	}
551
552
	/**
553
	  * Returns end of the massupdate form
554
	  */
555 1
	function endMassUpdateForm(){
556 1
		return '</form>';
557
	}
558
559
	/**
560
	  * Decides which popup HTML code is needed for mass updating
561
	  * @param displayname Name to display in the popup window
562
	  * @param field name of the field to update
563
	  */
564 1
	function handleRelationship($displayname, $field)
565
	{
566 1
		$ret_val = '';
567 1
		if(isset($field['module']))
568
		{
569 1
			if ($field['name'] == 'reports_to_name' && ($field['module'] == 'Users' || $field['module'] == 'Employee') )
570 1
			    return $this->addUserName($displayname, $field['name'], $field['id_name'], $field['module']);
571
572
		    switch($field['module'])
573
			{
574
				case 'Accounts':
575
					$ret_val = $this->addAccountID($displayname, $field['name'], $field['id_name']);
576
					break;
577
				case 'Contacts':
578
					$ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Contacts");
579
					break;
580
				case 'Users':
581
					$ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Users");
582
					break;
583
				case 'Employee':
584
					$ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Employee");
585
					break;
586
				case 'Releases':
587
					$ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], "Releases");
588
					break;
589
				default:
590
					if(!empty($field['massupdate'])){
591
						$ret_val = $this->addGenericModuleID($displayname, $field['name'], $field['id_name'], $field['module']);
592
					}
593
					break;
594
			}
595
		}
596
597 1
		return $ret_val;
598
	}
599
	/**
600
	  * Add a parent selection popup window
601
	  * @param displayname Name to display in the popup window
602
	  * @param field_name name of the field
603
	  */
604
	function addParent($displayname, $field){
605
		global $app_strings, $app_list_strings;
606
607
		///////////////////////////////////////
608
		///
609
		/// SETUP POPUP
610
611
		$popup_request_data = array(
612
		'call_back_function' => 'set_return',
613
		'form_name' => 'MassUpdate',
614
		'field_to_name_array' => array(
615
			'id' => "parent_id",
616
			'name' => "parent_name",
617
			),
618
			);
619
620
			$json = getJSONobj();
621
			$encoded_popup_request_data = $json->encode($popup_request_data);
622
623
            $qsName = array(
624
			            'form' => 'MassUpdate',
625
						'method' => 'query',
626
                        'modules' => array("Accounts"),
627
                        'group' => 'or',
628
						'field_list' => array('name', 'id'),
629
						'populate_list' => array("mass_parent_name", "mass_parent_id"),
630
						'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
631
						'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
632
                $qsName = $json->encode($qsName);
633
634
			//
635
			///////////////////////////////////////
636
637
			$change_parent_button = "<span class='id-ff'><button title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."'  type='button' class='button' value='".$app_strings['LBL_SELECT_BUTTON_LABEL']
638
			."' name='button_parent_name' onclick='open_popup(document.MassUpdate.{$field['type_name']}.value, 600, 400, \"\", true, false, {$encoded_popup_request_data});'>
639
			".SugarThemeRegistry::current()->getImage("id-ff-select", '', null, null, ".png", $app_strings['LBL_ID_FF_SELECT'])."
640
			</button></span>";
641
			$parent_type = $field['parent_type'];
642
            $parent_types = $app_list_strings[$parent_type];
643
            $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
644
            foreach($disabled_parent_types as $disabled_parent_type) {
645
			    unset($parent_types[$disabled_parent_type]);
646
            }
647
			$types = get_select_options_with_id($parent_types, '');
648
			//BS Fix Bug 17110
649
			$pattern = "/\n<OPTION.*".$app_strings['LBL_NONE']."<\/OPTION>/";
650
			$types = preg_replace($pattern, "", $types);
651
			// End Fix
652
653
            $json = getJSONobj();
654
            $disabled_parent_types = $json->encode($disabled_parent_types);
655
656
			return <<<EOHTML
657
<td width="15%" scope="row">{$displayname} </td>
658
<td>
659
    <table width='100%' border='0' cellspacing='0' cellpadding='0'>
660
    <tr>
661
        <td valign='top'>
662
            <select name='{$field['type_name']}' id='mass_{$field['type_name']}'>
663
                $types
664
            </select>
665
        </td>
666
        <td valign='top'>
667
			<input name='{$field['id_name']}' id='mass_{$field['id_name']}' type='hidden' value=''>
668
			<input name='parent_name' id='mass_parent_name' class='sqsEnabled' autocomplete='off'
669
                type='text' value=''>
670
            $change_parent_button
671
        </td>
672
    </tr>
673
    </table>
674
</td>
675
<script type="text/javascript">
676
<!--
677
var disabledModules='{$disabled_parent_types}';
678
if(typeof sqs_objects == 'undefined'){
679
    var sqs_objects = new Array;
680
}
681
sqs_objects['MassUpdate_parent_name'] = $qsName;
682
registerSingleSmartInputListener(document.getElementById('mass_parent_name'));
683
addToValidateBinaryDependency('MassUpdate', 'parent_name', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','parent_id');
684
685
document.getElementById('mass_{$field['type_name']}').onchange = function()
686
{
687
    document.MassUpdate.parent_name.value="";
688
    document.MassUpdate.parent_id.value="";
689
690
	new_module = document.forms["MassUpdate"].elements["parent_type"].value;
691
692
	if(typeof(disabledModules[new_module]) != 'undefined') {
693
		sqs_objects["MassUpdate_parent_name"]["disable"] = true;
694
		document.forms["MassUpdate"].elements["parent_name"].readOnly = true;
695
	} else {
696
		sqs_objects["MassUpdate_parent_name"]["disable"] = false;
697
		document.forms["MassUpdate"].elements["parent_name"].readOnly = false;
698
	}
699
	sqs_objects["MassUpdate_parent_name"]["modules"] = new Array(new_module);
700
    enableQS(false);
701
702
    checkParentType(document.MassUpdate.parent_type.value, document.MassUpdate.button_parent_name);
703
}
704
-->
705
</script>
706
EOHTML;
707
	}
708
709
	/**
710
	  * Add a generic input type='text' field
711
	  * @param displayname Name to display in the popup window
712
	  * @param field_name name of the field
713
	  */
714
	function addInputType($displayname, $varname){
715
		//letrium ltd
716
		$displayname = addslashes($displayname);
717
		$html = <<<EOQ
718
	<td scope="row" width="20%">$displayname</td>
719
	<td class='dataField' width="30%"><input type="text" name='$varname' size="12" id='{$varname}' maxlength='10' value=""></td>
720
	<script> addToValidate('MassUpdate','$varname','int',false,'$displayname');</script>
721
EOQ;
722
		return $html;
723
724
	}
725
726
    /**
727
	  * Add a generic widget to lookup Users.
728
	  * @param displayname Name to display in the popup window
729
	  * @param varname name of the variable
730
	  * @param id_name name of the id in vardef
731
	  * @param mod_type name of the module, either "Contact" or "Releases" currently
732
	  */
733 1
	function addUserName($displayname, $varname, $id_name='', $mod_type){
734 1
		global $app_strings;
735
736 1
		if(empty($id_name))
737
		$id_name = strtolower($mod_type)."_id";
738
739
		///////////////////////////////////////
740
		///
741
		/// SETUP POPUP
742 1
        $reportsDisplayName = showFullName() ? 'name' : 'user_name';
743
		$popup_request_data = array(
744 1
			'call_back_function' => 'set_return',
745 1
			'form_name' => 'MassUpdate',
746
			'field_to_name_array' => array(
747 1
				'id' => "{$id_name}",
748 1
				"$reportsDisplayName" => "{$varname}",
749
				),
750
				);
751
752 1
				$json = getJSONobj();
753 1
				$encoded_popup_request_data = $json->encode($popup_request_data);
754
755
                $qsName = array(
756 1
			            'form' => 'MassUpdate',
757 1
						'method' => 'get_user_array',
758 1
                        'modules' => array("{$mod_type}"),
759 1
                        'group' => 'or',
760
						'field_list' => array('user_name', 'id'),
761 1
						'populate_list' => array("mass_{$varname}", "mass_{$id_name}"),
762
						'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
763 1
						'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
764 1
                $qsName = $json->encode($qsName);
765
				//
766
				///////////////////////////////////////
767
768
            return <<<EOHTML
769 1
<td width='15%'  scope='row' class='dataLabel'>$displayname</td>
770
<td width='35%' class='dataField'>
771 1
    <input name='{$varname}' id='mass_{$varname}' class='sqsEnabled' autocomplete='off' type='text' value=''>
772 1
    <input name='{$id_name}' id='mass_{$id_name}' type='hidden' value=''>&nbsp;
773 1
    <input title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}'
774 1
        type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name='button'
775 1
        onclick='open_popup("$mod_type", 600, 400, "", true, false, {$encoded_popup_request_data});'
776
        />
777
</td>
778
<script type="text/javascript">
779
<!--
780
if(typeof sqs_objects == 'undefined'){
781
    var sqs_objects = new Array;
782
}
783 1
sqs_objects['MassUpdate_{$varname}'] = $qsName;
784 1
registerSingleSmartInputListener(document.getElementById('mass_{$varname}'));
785 1
addToValidateBinaryDependency('MassUpdate', '{$varname}', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','{$id_name}');
786
-->
787 1
</script>
788
EOHTML;
789
	}
790
791
792
	/**
793
	  * Add a generic module popup selection popup window HTML code.
794
	  * Currently supports Contact and Releases
795
	  * @param displayname Name to display in the popup window
796
	  * @param varname name of the variable
797
	  * @param id_name name of the id in vardef
798
	  * @param mod_type name of the module, either "Contact" or "Releases" currently
799
	  */
800
	function addGenericModuleID($displayname, $varname, $id_name='', $mod_type){
801
		global $app_strings;
802
803
		if(empty($id_name))
804
		$id_name = strtolower($mod_type)."_id";
805
806
		///////////////////////////////////////
807
		///
808
		/// SETUP POPUP
809
810
		$popup_request_data = array(
811
			'call_back_function' => 'set_return',
812
			'form_name' => 'MassUpdate',
813
			'field_to_name_array' => array(
814
				'id' => "{$id_name}",
815
				'name' => "{$varname}",
816
				),
817
				);
818
819
				$json = getJSONobj();
820
				$encoded_popup_request_data = $json->encode($popup_request_data);
821
822
                $qsName = array(
823
			            'form' => 'MassUpdate',
824
						'method' => 'query',
825
                        'modules' => array("{$mod_type}"),
826
                        'group' => 'or',
827
						'field_list' => array('name', 'id'),
828
						'populate_list' => array("mass_{$varname}", "mass_{$id_name}"),
829
						'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
830
						'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
831
                $qsName = $json->encode($qsName);
832
				$img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
833
				//
834
				///////////////////////////////////////
835
836
            return <<<EOHTML
837
<td width='15%'  scope='row' class='dataLabel'>$displayname</td>
838
<td width='35%' class='dataField'>
839
    <input name='{$varname}' id='mass_{$varname}' class='sqsEnabled' autocomplete='off' type='text' value=''>
840
    <input name='{$id_name}' id='mass_{$id_name}' type='hidden' value=''>
841
	<span class="id-ff multiple">
842
    <button title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}'
843
        type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name='button'
844
        onclick='open_popup("$mod_type", 600, 400, "", true, false, {$encoded_popup_request_data});'
845
        /><img alt="$img" src="$img"></button></span>
846
</td>
847
<script type="text/javascript">
848
<!--
849
if(typeof sqs_objects == 'undefined'){
850
    var sqs_objects = new Array;
851
}
852
sqs_objects['MassUpdate_{$varname}'] = $qsName;
853
registerSingleSmartInputListener(document.getElementById('mass_{$varname}'));
854
addToValidateBinaryDependency('MassUpdate', '{$varname}', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','{$id_name}');
855
-->
856
</script>
857
EOHTML;
858
	}
859
	/**
860
	  * Add Account selection popup window HTML code
861
	  * @param displayname Name to display in the popup window
862
	  * @param varname name of the variable
863
	  * @param id_name name of the id in vardef
864
	  */
865
	function addAccountID($displayname, $varname, $id_name=''){
866
		global $app_strings;
867
868
		$json = getJSONobj();
869
870
		if(empty($id_name))
871
		$id_name = "account_id";
872
873
		///////////////////////////////////////
874
		///
875
		/// SETUP POPUP
876
877
		$popup_request_data = array(
878
			'call_back_function' => 'set_return',
879
			'form_name' => 'MassUpdate',
880
			'field_to_name_array' => array(
881
				'id' => "{$id_name}",
882
				'name' => "{$varname}",
883
				),
884
				);
885
886
				$encoded_popup_request_data = $json->encode($popup_request_data);
887
888
				//
889
				///////////////////////////////////////
890
891
				$qsParent = array(
892
							'form' => 'MassUpdate',
893
							'method' => 'query',
894
							'modules' => array('Accounts'),
895
							'group' => 'or',
896
							'field_list' => array('name', 'id'),
897
							'populate_list' => array('parent_name', 'parent_id'),
898
							'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
899
							'order' => 'name',
900
							'limit' => '30',
901
							'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
902
							);
903
							$qsParent['populate_list'] = array('mass_'. $varname, 'mass_' . $id_name);
904
							$img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
905
							$html = '<td scope="row">' . $displayname . " </td>\n"
906
							. '<td><input class="sqsEnabled" type="text" autocomplete="off" id="mass_' . $varname .'" name="' . $varname . '" value="" /><input id="mass_' . $id_name . '" type="hidden" name="'
907
							. $id_name . '" value="" />&nbsp;<span class="id-ff multiple"><button type="button" name="btn1" class="button" title="'
908
							. $app_strings['LBL_SELECT_BUTTON_LABEL'] . '"  value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" onclick='
909
							. "'open_popup(\"Accounts\",600,400,\"\",true,false,{$encoded_popup_request_data});' /><img alt=\"$img\" src=\"$img\"></button></span></td>\n";
910
							$html .= '<script type="text/javascript" language="javascript">if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'MassUpdate_' . $varname . '\'] = ' .
911
							$json->encode($qsParent) . '; registerSingleSmartInputListener(document.getElementById(\'mass_' . $varname . '\'));
912
					addToValidateBinaryDependency(\'MassUpdate\', \''.$varname.'\', \'alpha\', false, \'' . $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ACCOUNT'] . '\',\''.$id_name.'\');
913
					</script>';
914
915
							return $html;
916
	}
917
918
	/**
919
	  * Add AssignedUser popup window HTML code
920
	  * @param displayname Name to display in the popup window
921
	  * @param varname name of the variable
922
	  */
923
	function addAssignedUserID($displayname, $varname){
924
		global $app_strings;
925
926
		$json = getJSONobj();
927
928
		$popup_request_data = array(
929
		'call_back_function' => 'set_return',
930
		'form_name' => 'MassUpdate',
931
		'field_to_name_array' => array(
932
			'id' => 'assigned_user_id',
933
			'user_name' => 'assigned_user_name',
934
			),
935
			);
936
			$encoded_popup_request_data = $json->encode($popup_request_data);
937
			$qsUser = array(
938
			            'form' => 'MassUpdate',
939
						'method' => 'get_user_array', // special method
940
						'field_list' => array('user_name', 'id'),
941
						'populate_list' => array('assigned_user_name', 'assigned_user_id'),
942
						'conditions' => array(array('name'=>'user_name','op'=>'like_custom','end'=>'%','value'=>'')),
943
						'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
944
945
						$qsUser['populate_list'] = array('mass_assigned_user_name', 'mass_assigned_user_id');
946
						$img = SugarThemeRegistry::current()->getImageURL("id-ff-select.png");
947
						$html = <<<EOQ
948
		<td width="15%" scope="row">$displayname</td>
949
		<td ><input class="sqsEnabled" autocomplete="off" id="mass_assigned_user_name" name='assigned_user_name' type="text" value=""><input id='mass_assigned_user_id' name='assigned_user_id' type="hidden" value="" />
950
		<span class="id-ff multiple"><button id="mass_assigned_user_name_btn" title="{$app_strings['LBL_SELECT_BUTTON_TITLE']}" type="button" class="button" value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name=btn1
951
				onclick='open_popup("Users", 600, 400, "", true, false, $encoded_popup_request_data);' /><img src="$img"></button></span>
952
		</td>
953
EOQ;
954
						$html .= '<script type="text/javascript" language="javascript">if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}sqs_objects[\'MassUpdate_assigned_user_name\'] = ' .
955
						$json->encode($qsUser) . '; registerSingleSmartInputListener(document.getElementById(\'mass_assigned_user_name\'));
956
				addToValidateBinaryDependency(\'MassUpdate\', \'assigned_user_name\', \'alpha\', false, \'' . $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'] . '\',\'assigned_user_id\');
957
				</script>';
958
959
						return $html;
960
	}
961
	/**
962
	  * Add Status selection popup window HTML code
963
	  * @param displayname Name to display in the popup window
964
	  * @param varname name of the variable
965
	  * @param options array of options for status
966
	  */
967 1
	function addStatus($displayname, $varname, $options){
968 1
		global $app_strings, $app_list_strings;
969
970
		// cn: added "mass_" to the id tag to differentiate from the status id in StoreQuery
971 1
		$html = '<td scope="row" width="15%">'.$displayname.'</td><td>';
972 1
		if(is_array($options)){
973 1
			if(!isset($options['']) && !isset($options['0'])){
974 1
			   $new_options = array();
975 1
			   $new_options[''] = '';
976 1
			   foreach($options as $key=>$value) {
977 1
			   	   $new_options[$key] = $value;
978
			   }
979 1
			   $options = $new_options;
980
			}
981 1
            $options = get_select_options_with_id_separate_key(
982
                $options,
983
                $options,
984 1
                '__SugarMassUpdateClearField__',
985 1
                true
986
            );
987 1
			$html .= '<select id="mass_'.$varname.'" name="'.$varname.'">'.$options.'</select>';
988
		}else{
989
			$html .= $options;
990
		}
991 1
		$html .= '</td>';
992 1
		return $html;
993
	}
994
995
/**
996
	  * Add Status selection popup window HTML code
997
	  * @param displayname Name to display in the popup window
998
	  * @param varname name of the variable
999
	  * @param options array of options for status
1000
	  */
1001 1
	function addBool($displayname, $varname){
1002 1
		global $app_strings, $app_list_strings;
1003 1
		return $this->addStatus($displayname, $varname, $app_list_strings['checkbox_dom']);
1004
	}
1005
	function addStatusMulti($displayname, $varname, $options){
1006
		global $app_strings, $app_list_strings;
1007
1008
		if(!isset($options['']) && !isset($options['0'])){
1009
		   $new_options = array();
1010
		   $new_options[''] = '';
1011
		   foreach($options as $key=>$value) {
1012
		   	   $new_options[$key] = $value;
1013
		   }
1014
		   $options = $new_options;
1015
		}
1016
		$options = get_select_options_with_id_separate_key($options, $options, '', true);;
1017
1018
		// cn: added "mass_" to the id tag to differentiate from the status id in StoreQuery
1019
		$html = '<td scope="row" width="15%">'.$displayname.'</td>
1020
			 <td><select id="mass_'.$varname.'" name="'.$varname.'[]" size="5" MULTIPLE>'.$options.'</select></td>';
1021
		return $html;
1022
	}
1023
	/**
1024
	  * Add Date selection popup window HTML code
1025
	  * @param displayname Name to display in the popup window
1026
	  * @param varname name of the variable
1027
	  */
1028
	function addDate($displayname, $varname){
1029
		global $timedate;
1030
		//letrium ltd
1031
		$displayname = addslashes($displayname);
1032
		$userformat = '('. $timedate->get_user_date_format().')';
1033
		$cal_dateformat = $timedate->get_cal_date_format();
1034
		global $app_strings, $app_list_strings, $theme;
1035
1036
		$javascriptend = <<<EOQ
1037
		 <script type="text/javascript">
1038
		Calendar.setup ({
1039
			inputField : "${varname}jscal_field", daFormat : "$cal_dateformat", ifFormat : "$cal_dateformat", showsTime : false, button : "${varname}jscal_trigger", singleClick : true, step : 1, weekNumbers:false
1040
		});
1041
		</script>
1042
EOQ;
1043
        $jscalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
1044
		$html = <<<EOQ
1045
	<td scope="row" width="20%">$displayname</td>
1046
	<td class='dataField' width="30%"><input onblur="parseDate(this, '$cal_dateformat')" type="text" name='$varname' size="12" id='{$varname}jscal_field' maxlength='10' value="">
1047
    <img src="$jscalendarImage" id="{$varname}jscal_trigger" align="absmiddle" title="{$app_strings['LBL_MASSUPDATE_DATE']}" alt='{$app_strings['LBL_MASSUPDATE_DATE']}'>&nbsp;<span class="dateFormat">$userformat</span>
1048
	$javascriptend</td>
1049
	<script> addToValidate('MassUpdate','$varname','date',false,'$displayname');</script>
1050
EOQ;
1051
		return $html;
1052
1053
	}
1054
1055
	function addRadioenumItem($name, $value, $output) {
1056
		$_output = '';
1057
		$_output .= '<label>';
1058
		$_output .= '<input type="radio" name="'
1059
	        . $name . '" value="'
1060
	        . $value. '"';
1061
1062
	    $_output .= ' />' . ($output == '' ? $GLOBALS['app_strings']['LBL_LINK_NONE'] : $output);
1063
	    $_output .= '</label><br />';
1064
	    return $_output;
1065
	}
1066
1067
	function addRadioenum($displayname, $varname, $options){
1068
		 foreach ($options as $_key=>$_val){
1069
            $_html_result[] = $this->addRadioenumItem($varname, $_key, $_val);
1070
        }
1071
1072
		$html = '<td scope="row" width="15%">'.$displayname.'</td>
1073
			 <td>'.implode("\n",$_html_result).'</td>';
1074
		return $html;
1075
	}
1076
	/**
1077
	  * Add Datetime selection popup window HTML code
1078
	  * @param displayname Name to display in the popup window
1079
	  * @param varname name of the variable
1080
	  */
1081
	function addDatetime($displayname, $varname){
1082
		global $timedate;
1083
		$userformat = $timedate->get_user_time_format();
1084
		$cal_dateformat = $timedate->get_cal_date_format();
1085
		global $app_strings, $app_list_strings, $theme;
1086
		$jscalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
1087
1088
		$javascriptend = <<<EOQ
1089
		 <script type="text/javascript">
1090
		Calendar.setup ({
1091
			inputField : "{$varname}_date",
1092
			daFormat : "$cal_dateformat",
1093
			ifFormat : "$cal_dateformat",
1094
			showsTime : false,
1095
			button : "{$varname}_trigger",
1096
			singleClick : true,
1097
			step : 1,
1098
			weekNumbers:false
1099
		});
1100
		</script>
1101
EOQ;
1102
        $dtscript = getVersionedScript('include/SugarFields/Fields/Datetimecombo/Datetimecombo.js');
1103
		$html = <<<EOQ
1104
		<td scope="row" width="20%">$displayname</td>
1105
		<td class='dataField' width="30%"><input onblur="parseDate(this, '$cal_dateformat')" type="text" name='$varname' size="12" id='{$varname}_date' maxlength='10' value="">
1106
		<img border="0" src="$jscalendarImage" alt='{$app_strings['LBL_MASSUPDATE_DATE']}' id="{$varname}_trigger" title="{$app_strings['LBL_MASSUPDATE_DATE']}"  align="absmiddle">&nbsp;$javascriptend
1107
1108
		<span id="{$varname}_time_section"></span>
1109
		</td>
1110
		<input type="hidden" id="{$varname}" name="{$varname}">
1111
		$dtscript
1112
		<script type="text/javascript">
1113
		var combo_{$varname} = new Datetimecombo(" ", "$varname", "$userformat", '','','',1);
1114
		//Render the remaining widget fields
1115
		text = combo_{$varname}.html('');
1116
		document.getElementById('{$varname}_time_section').innerHTML = text;
1117
1118
		//Call eval on the update function to handle updates to calendar picker object
1119
		eval(combo_{$varname}.jsscript(''));
1120
1121
		function update_{$varname}_available() {
1122
		      YAHOO.util.Event.onAvailable("{$varname}_date", this.handleOnAvailable, this);
1123
		}
1124
1125
		update_{$varname}_available.prototype.handleOnAvailable = function(me) {
1126
			Calendar.setup ({
1127
			onClose : update_{$varname},
1128
			inputField : "{$varname}_date",
1129
			daFormat : "$cal_dateformat",
1130
			ifFormat : "$cal_dateformat",
1131
			button : "{$varname}_trigger",
1132
			singleClick : true,
1133
			step : 1,
1134
			weekNumbers:false
1135
			});
1136
1137
			//Call update for first time to round hours and minute values
1138
			combo_{$varname}.update(false);
1139
		}
1140
1141
		var obj_{$varname} = new update_{$varname}_available();
1142
		</script>
1143
1144
		<script> addToValidate('MassUpdate','{$varname}_date','date',false,'$displayname');
1145
		addToValidateBinaryDependency('MassUpdate', '{$varname}_hours', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1146
		addToValidateBinaryDependency('MassUpdate', '{$varname}_minutes', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1147
		addToValidateBinaryDependency('MassUpdate', '{$varname}_meridiem', 'alpha', false, "{$app_strings['ERR_MISSING_REQUIRED_FIELDS']}", '{$varname}_date');
1148
		</script>
1149
1150
EOQ;
1151
		return $html;
1152
	}
1153
1154
	function date_to_dateTime($field, $value) {
1155
		global $timedate;
1156
	    //Check if none was set
1157
        if (isset($this->sugarbean->field_defs[$field]['group'])) {
1158
            $group =  $this->sugarbean->field_defs[$field]['group'];
1159
            if (isset($this->sugarbean->field_defs[$group."_flag"]) && isset($_POST[$group."_flag"])
1160
                && $_POST[$group."_flag"] == 1) {
1161
                return "";
1162
            }
1163
        }
1164
1165
        $oldDateTime = $this->sugarbean->$field;
1166
        $oldTime = explode(" ", $oldDateTime);
1167
        if (isset($oldTime[1])) {
1168
        	$oldTime = $oldTime[1];
1169
        } else {
1170
        	$oldTime = $timedate->now();
1171
        }
1172
        $oldTime = explode(" ", $oldTime);
1173
        if (isset($oldTime[1])) {
1174
        	$oldTime = $oldTime[1];
1175
        } else {
1176
        	$oldTime = $oldTime[0];
1177
        }
1178
        $value = explode(" ", $value);
1179
        $value = $value[0];
1180
	    return $value." ".$oldTime;
1181
	}
1182
1183
	function checkClearField($field, $value) {
1184
	    if ($value == 1 && strpos($field, '_flag')) {
1185
	        $fName = substr($field, -5);
1186
            if (isset($this->sugarbean->field_defs[$field]['group'])) {
1187
                $group =  $this->sugarbean->field_defs[$field]['group'];
1188
                if (isset($this->sugarbean->field_defs[$group])) {
1189
                    $_POST[$group] = "";
1190
                }
1191
            }
1192
	    }
1193
	}
1194
1195
    function generateSearchWhere($module, $query) {//this function is similar with function prepareSearchForm() in view.list.php
1196
        $seed = loadBean($module);
0 ignored issues
show
Deprecated Code introduced by
The function loadBean() has been deprecated with message: use SugarModule::loadBean() instead

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
1197
        $this->use_old_search = true;
1198
        if(file_exists('modules/'.$module.'/SearchForm.html')){
1199
            if(file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
1200
                require_once('include/SearchForm/SearchForm.php');
1201
                $searchForm = new SearchForm($module, $seed);
1202
            }
1203
            elseif(!empty($_SESSION['export_where'])) { //bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
1204
            //So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
1205
                $where = $_SESSION['export_where'];
1206
                $whereArr = explode (" ", trim($where));
1207
                if ($whereArr[0] == trim('where')) {
1208
                    $whereClean = array_shift($whereArr);
1209
                }
1210
                $this->where_clauses = implode(" ", $whereArr);
1211
                return;
1212
            }
1213
            else {
1214
                $this->where_clauses = '';
1215
                return;
1216
            }
1217
        }
1218
        else{
1219
            $this->use_old_search = false;
1220
            require_once('include/SearchForm/SearchForm2.php');
1221
1222
            if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
1223
                require('custom/modules/'.$module.'/metadata/metafiles.php');
1224
            }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
1225
                require('modules/'.$module.'/metadata/metafiles.php');
1226
            }
1227
1228
            $searchFields = $this->getSearchFields($module);
1229
            $searchdefs = $this->getSearchDefs($module);
1230
1231
            if(empty($searchdefs) || empty($searchFields)) {
1232
               $this->where_clauses = ''; //for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
1233
               return;
1234
            }
1235
1236
            $searchForm = new SearchForm($seed, $module);
1237
            $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl');
0 ignored issues
show
The call to SearchForm::setup() has too many arguments starting with $searchdefs.

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...
1238
        }
1239
	/* bug 31271: using false to not add all bean fields since some beans - like SavedReports
1240
	   can have fields named 'module' etc. which may break the query */
1241
        $query = sugar_unserialize(base64_decode($query));
1242
        $searchForm->populateFromArray($query, null, true);
1243
        $this->searchFields = $searchForm->searchFields;
1244
        $where_clauses = $searchForm->generateSearchWhere(true, $module);
1245
        if (count($where_clauses) > 0 ) {
1246
            $this->where_clauses = '('. implode(' ) AND ( ', $where_clauses) . ')';
1247
            $GLOBALS['log']->info("MassUpdate Where Clause: {$this->where_clauses}");
1248
        } else {
1249
            $this->where_clauses = '';
1250
        }
1251
    }
1252
1253
    protected function getSearchDefs($module, $metafiles = array())
1254
    {
1255
        if (file_exists('custom/modules/'.$module.'/metadata/searchdefs.php'))
1256
        {
1257
            require('custom/modules/'.$module.'/metadata/searchdefs.php');
1258
        }
1259
        elseif (!empty($metafiles[$module]['searchdefs']))
1260
        {
1261
            require($metafiles[$module]['searchdefs']);
1262
        }
1263
        elseif (file_exists('modules/'.$module.'/metadata/searchdefs.php'))
1264
        {
1265
            require('modules/'.$module.'/metadata/searchdefs.php');
1266
        }
1267
1268
        return isset($searchdefs) ? $searchdefs : array();
0 ignored issues
show
The variable $searchdefs seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
1269
    }
1270
1271
    protected function getSearchFields($module, $metafiles = array())
1272
    {
1273
        if (file_exists('custom/modules/' . $module . '/metadata/SearchFields.php'))
1274
        {
1275
            require('custom/modules/' . $module . '/metadata/SearchFields.php');
1276
        }
1277
        elseif(!empty($metafiles[$module]['searchfields']))
1278
        {
1279
            require($metafiles[$module]['searchfields']);
1280
        }
1281
        elseif(file_exists('modules/'.$module.'/metadata/SearchFields.php'))
1282
        {
1283
            require('modules/'.$module.'/metadata/SearchFields.php');
1284
        }
1285
1286
        return isset($searchFields) ? $searchFields : array();
0 ignored issues
show
The variable $searchFields seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
1287
    }
1288
    /**
1289
     * This is kinda a hack how it is implimented, but will tell us whether or not a focus has
1290
     * fields for Mass Update
1291
     *
1292
     * @return bool
1293
     */
1294
    public function doMassUpdateFieldsExistForFocus()
1295
    {
1296 4
        static $banned = array('date_modified'=>1, 'date_entered'=>1, 'created_by'=>1, 'modified_user_id'=>1, 'deleted'=>1,'modified_by_name'=>1,);
1297 4
        foreach($this->sugarbean->field_defs as $field) {
1298 4
            if(!isset($banned[$field['name']]) && (!isset($field['massupdate']) || !empty($field['massupdate']))){
1299 4
                if(isset($field['type']) && $field['type'] == 'relate' && isset($field['id_name']) && $field['id_name'] == 'assigned_user_id')
1300 2
                    $field['type'] = 'assigned_user_name';
1301 4
                if(isset($field['custom_type']))$field['type'] = $field['custom_type'];
1302 4
                if(isset($field['type']))
1303
                {
1304 4
                    switch($field["type"]){
1305 4
                    case "relate":
1306 4
                    case "parent":
1307 4
                    case "int":
1308 4
                    case "contact_id":
1309 4
                    case "assigned_user_name":
1310 4
                    case "account_id":
1311 4
                    case "account_name":
1312 4
                    case "bool":
1313 4
                    case "enum":
1314 4
                    case "multienum":
1315 4
                    case "radioenum":
1316 4
                    case "datetimecombo":
1317 4
                    case "datetime":
1318 4
                    case "date":
1319 4
                        return true;
1320 4
                        break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
1321
                    }
1322
                }
1323
            }
1324
        }
1325
1326
        return false;
1327
    }
1328
1329
     /**
1330
     * Have to be overridden in children
1331
     * @param string $displayname field label
1332
     * @param string $field field name
1333
     * @param bool $even even or odd
1334
     * @return string html field data
1335
     */
1336
    protected function addDefault($displayname,  $field, & $even)
1337
    {
1338 1
        return '';
1339
    }
1340 1
}
1341
1342
?>
1343