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 | 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 | |||
43 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
||
44 | * All Rights Reserved. |
||
45 | * Contributor(s): ______________________________________.. |
||
46 | ********************************************************************************/ |
||
47 | |||
48 | 1 | require_once('include/SugarObjects/templates/person/Person.php'); |
|
49 | // Contact is used to store customer information. |
||
50 | class Contact extends Person { |
||
51 | var $field_name_map; |
||
52 | // Stored fields |
||
53 | var $id; |
||
54 | var $name = ''; |
||
55 | var $lead_source; |
||
56 | var $date_entered; |
||
57 | var $date_modified; |
||
58 | var $modified_user_id; |
||
59 | var $assigned_user_id; |
||
60 | var $created_by; |
||
61 | var $created_by_name; |
||
62 | var $modified_by_name; |
||
63 | |||
64 | var $description; |
||
65 | var $salutation; |
||
66 | var $first_name; |
||
67 | var $last_name; |
||
68 | var $title; |
||
69 | var $department; |
||
70 | var $birthdate; |
||
71 | var $reports_to_id; |
||
72 | var $do_not_call; |
||
73 | var $phone_home; |
||
74 | var $phone_mobile; |
||
75 | var $phone_work; |
||
76 | var $phone_other; |
||
77 | var $phone_fax; |
||
78 | var $email1; |
||
79 | var $email_and_name1; |
||
80 | var $email_and_name2; |
||
81 | var $email2; |
||
82 | var $assistant; |
||
83 | var $assistant_phone; |
||
84 | var $email_opt_out; |
||
85 | var $primary_address_street; |
||
86 | var $primary_address_city; |
||
87 | var $primary_address_state; |
||
88 | var $primary_address_postalcode; |
||
89 | var $primary_address_country; |
||
90 | var $alt_address_street; |
||
91 | var $alt_address_city; |
||
92 | var $alt_address_state; |
||
93 | var $alt_address_postalcode; |
||
94 | var $alt_address_country; |
||
95 | var $portal_name; |
||
96 | var $portal_app; |
||
97 | var $portal_active; |
||
98 | var $contacts_users_id; |
||
99 | // These are for related fields |
||
100 | var $bug_id; |
||
101 | var $account_name; |
||
102 | var $account_id; |
||
103 | var $report_to_name; |
||
104 | var $opportunity_role; |
||
105 | var $opportunity_rel_id; |
||
106 | var $opportunity_id; |
||
107 | var $case_role; |
||
108 | var $case_rel_id; |
||
109 | var $case_id; |
||
110 | var $task_id; |
||
111 | var $note_id; |
||
112 | var $meeting_id; |
||
113 | var $call_id; |
||
114 | var $email_id; |
||
115 | var $assigned_user_name; |
||
116 | var $accept_status; |
||
117 | var $accept_status_id; |
||
118 | var $accept_status_name; |
||
119 | var $alt_address_street_2; |
||
120 | var $alt_address_street_3; |
||
121 | var $opportunity_role_id; |
||
122 | var $portal_password; |
||
123 | var $primary_address_street_2; |
||
124 | var $primary_address_street_3; |
||
125 | var $campaign_id; |
||
126 | var $sync_contact; |
||
127 | var $full_name; // l10n localized name |
||
128 | var $invalid_email; |
||
129 | var $table_name = "contacts"; |
||
130 | var $rel_account_table = "accounts_contacts"; |
||
131 | //This is needed for upgrade. This table definition moved to Opportunity module. |
||
132 | var $rel_opportunity_table = "opportunities_contacts"; |
||
133 | |||
134 | var $object_name = "Contact"; |
||
135 | var $module_dir = 'Contacts'; |
||
136 | var $emailAddress; |
||
137 | var $new_schema = true; |
||
138 | var $importable = true; |
||
139 | |||
140 | // This is used to retrieve related fields from form posts. |
||
141 | var $additional_column_fields = Array('bug_id', 'assigned_user_name', 'account_name', 'account_id', 'opportunity_id', 'case_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id' |
||
142 | ); |
||
143 | |||
144 | var $relationship_fields = Array('account_id'=> 'accounts','bug_id' => 'bugs', 'call_id'=>'calls','case_id'=>'cases','email_id'=>'emails', |
||
145 | 'meeting_id'=>'meetings','note_id'=>'notes','task_id'=>'tasks', 'opportunity_id'=>'opportunities', 'contacts_users_id' => 'user_sync' |
||
146 | ); |
||
147 | |||
148 | 63 | public function __construct() { |
|
149 | 63 | parent::__construct(); |
|
150 | 63 | } |
|
151 | |||
152 | /** |
||
153 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
||
154 | */ |
||
155 | public function Contact(){ |
||
156 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
157 | if(isset($GLOBALS['log'])) { |
||
158 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
159 | } |
||
160 | else { |
||
161 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
162 | } |
||
163 | self::__construct(); |
||
164 | } |
||
165 | |||
166 | |||
167 | 1 | function add_list_count_joins(&$query, $where) |
|
168 | { |
||
169 | // accounts.name |
||
170 | 1 | if(stristr($where, "accounts.name")) |
|
171 | { |
||
172 | // add a join to the accounts table. |
||
173 | $query .= " |
||
174 | LEFT JOIN accounts_contacts |
||
175 | ON contacts.id=accounts_contacts.contact_id |
||
176 | LEFT JOIN accounts |
||
177 | ON accounts_contacts.account_id=accounts.id |
||
178 | 1 | "; |
|
179 | } |
||
180 | 1 | $custom_join = $this->getCustomJoin(); |
|
181 | 1 | $query .= $custom_join['join']; |
|
182 | |||
183 | |||
184 | 1 | } |
|
185 | |||
186 | 1 | function listviewACLHelper(){ |
|
187 | 1 | $array_assign = parent::listviewACLHelper(); |
|
188 | 1 | $is_owner = false; |
|
189 | //MFH BUG 18281; JChi #15255 |
||
190 | 1 | $is_owner = !empty($this->assigned_user_id) && $this->assigned_user_id == $GLOBALS['current_user']->id; |
|
191 | 1 | if(!ACLController::moduleSupportsACL('Accounts') || ACLController::checkAccess('Accounts', 'view', $is_owner)){ |
|
192 | 1 | $array_assign['ACCOUNT'] = 'a'; |
|
193 | }else{ |
||
194 | $array_assign['ACCOUNT'] = 'span'; |
||
195 | |||
196 | } |
||
197 | 1 | return $array_assign; |
|
198 | } |
||
199 | |||
200 | function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
||
201 | { |
||
202 | //if this is from "contact address popup" action, then process popup list query |
||
203 | if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'ContactAddressPopup'){ |
||
204 | return $this->address_popup_create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect, $ifListForExport); |
||
0 ignored issues
–
show
|
|||
205 | |||
206 | }else{ |
||
207 | //any other action goes to parent function in sugarbean |
||
208 | if(strpos($order_by,'sync_contact') !== false){ |
||
209 | //we have found that the user is ordering by the sync_contact field, it would be troublesome to sort by this field |
||
210 | //and perhaps a performance issue, so just remove it |
||
211 | $order_by = ''; |
||
212 | } |
||
213 | return parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect, $ifListForExport); |
||
214 | } |
||
215 | |||
216 | |||
217 | } |
||
218 | |||
219 | |||
220 | |||
221 | 1 | function address_popup_create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false) |
|
222 | { |
||
223 | //if this is any action that is not the contact address popup, then go to parent function in sugarbean |
||
224 | 1 | if(isset($_REQUEST['action']) && $_REQUEST['action'] !== 'ContactAddressPopup'){ |
|
225 | return parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect); |
||
226 | } |
||
227 | |||
228 | 1 | $custom_join = $this->getCustomJoin(); |
|
229 | // MFH - BUG #14208 creates alias name for select |
||
230 | 1 | $select_query = "SELECT "; |
|
231 | 1 | $select_query .= db_concat($this->table_name,array('first_name','last_name')) . " name, "; |
|
0 ignored issues
–
show
The function
db_concat() has been deprecated with message: use DBManager::concat() 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. ![]() |
|||
232 | $select_query .= " |
||
233 | 1 | $this->table_name.*, |
|
234 | accounts.name as account_name, |
||
235 | accounts.id as account_id, |
||
236 | accounts.assigned_user_id account_id_owner, |
||
237 | 1 | users.user_name as assigned_user_name "; |
|
238 | 1 | $select_query .= $custom_join['select']; |
|
239 | 1 | $ret_array['select'] = $select_query; |
|
240 | |||
241 | $from_query = " |
||
242 | 1 | FROM contacts "; |
|
243 | |||
244 | $from_query .= "LEFT JOIN users |
||
245 | ON contacts.assigned_user_id=users.id |
||
246 | LEFT JOIN accounts_contacts |
||
247 | ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0 |
||
248 | LEFT JOIN accounts |
||
249 | 1 | ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 "; |
|
250 | 1 | $from_query .= "LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 "; |
|
251 | 1 | $from_query .= "LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) "; |
|
252 | 1 | $from_query .= $custom_join['join']; |
|
253 | 1 | $ret_array['from'] = $from_query; |
|
254 | 1 | $ret_array['from_min'] = 'from contacts'; |
|
255 | |||
256 | 1 | $where_auto = '1=1'; |
|
257 | 1 | if($show_deleted == 0){ |
|
258 | 1 | $where_auto = " $this->table_name.deleted=0 "; |
|
259 | //$where_auto .= " AND accounts.deleted=0 "; |
||
260 | }else if($show_deleted == 1){ |
||
261 | $where_auto = " $this->table_name.deleted=1 "; |
||
262 | } |
||
263 | |||
264 | |||
265 | 1 | if($where != ""){ |
|
266 | 1 | $where_query = "where ($where) AND ".$where_auto; |
|
267 | }else{ |
||
268 | 1 | $where_query = "where ".$where_auto; |
|
269 | } |
||
270 | |||
271 | |||
272 | 1 | $ret_array['where'] = $where_query; |
|
273 | 1 | $ret_array['order_by'] = ''; |
|
274 | |||
275 | //process order by and add if it's not empty |
||
276 | 1 | $order_by = $this->process_order_by($order_by); |
|
277 | 1 | if (!empty($order_by)) { |
|
278 | $ret_array['order_by'] = ' ORDER BY ' . $order_by; |
||
279 | } |
||
280 | |||
281 | 1 | if($return_array) |
|
282 | { |
||
283 | return $ret_array; |
||
284 | } |
||
285 | |||
286 | 1 | return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; |
|
287 | |||
288 | } |
||
289 | |||
290 | |||
291 | |||
292 | |||
293 | 1 | function create_export_query($order_by, $where, $relate_link_join='') |
|
294 | { |
||
295 | 1 | $custom_join = $this->getCustomJoin(true, true, $where); |
|
296 | 1 | $custom_join['join'] .= $relate_link_join; |
|
297 | $query = "SELECT |
||
298 | contacts.*, |
||
299 | email_addresses.email_address email_address, |
||
300 | '' email_addresses_non_primary, " . // email_addresses_non_primary needed for get_field_order_mapping() |
||
301 | "accounts.name as account_name, |
||
302 | 1 | users.user_name as assigned_user_name "; |
|
303 | 1 | $query .= $custom_join['select']; |
|
304 | 1 | $query .= " FROM contacts "; |
|
305 | $query .= "LEFT JOIN users |
||
306 | 1 | ON contacts.assigned_user_id=users.id "; |
|
307 | $query .= "LEFT JOIN accounts_contacts |
||
308 | ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0)) |
||
309 | LEFT JOIN accounts |
||
310 | 1 | ON accounts_contacts.account_id=accounts.id "; |
|
311 | |||
312 | //join email address table too. |
||
313 | 1 | $query .= ' LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module=\'Contacts\' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 '; |
|
314 | 1 | $query .= ' LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id ' ; |
|
315 | |||
316 | 1 | $query .= $custom_join['join']; |
|
317 | |||
318 | $where_auto = "( accounts.deleted IS NULL OR accounts.deleted=0 ) |
||
319 | 1 | AND contacts.deleted=0 "; |
|
320 | |||
321 | 1 | if($where != "") |
|
322 | 1 | $query .= "where ($where) AND ".$where_auto; |
|
323 | else |
||
324 | 1 | $query .= "where ".$where_auto; |
|
325 | |||
326 | 1 | $order_by = $this->process_order_by($order_by); |
|
327 | 1 | if (!empty($order_by)) { |
|
328 | $query .= ' ORDER BY ' . $order_by; |
||
329 | } |
||
330 | |||
331 | 1 | return $query; |
|
332 | } |
||
333 | |||
334 | 2 | function fill_in_additional_list_fields() { |
|
335 | 2 | parent::fill_in_additional_list_fields(); |
|
336 | 2 | $this->_create_proper_name_field(); |
|
337 | // cn: bug 8586 - l10n names for Contacts in Email TO: field |
||
338 | 2 | $this->email_and_name1 = "{$this->full_name} <".$this->email1.">"; |
|
339 | 2 | $this->email_and_name2 = "{$this->full_name} <".$this->email2.">"; |
|
340 | |||
341 | 2 | if($this->force_load_details == true) { |
|
0 ignored issues
–
show
|
|||
342 | $this->fill_in_additional_detail_fields(); |
||
343 | } |
||
344 | 2 | } |
|
345 | |||
346 | 1 | function fill_in_additional_detail_fields() { |
|
347 | 1 | parent::fill_in_additional_detail_fields(); |
|
348 | 1 | if(empty($this->id)) return; |
|
349 | |||
350 | 1 | global $locale, $app_list_strings, $current_user; |
|
351 | |||
352 | // retrieve the account information and the information about the person the contact reports to. |
||
353 | $query = "SELECT acc.id, acc.name, con_reports_to.first_name, con_reports_to.last_name |
||
354 | from contacts |
||
355 | 1 | left join accounts_contacts a_c on a_c.contact_id = '".$this->id."' and a_c.deleted=0 |
|
356 | left join accounts acc on a_c.account_id = acc.id and acc.deleted=0 |
||
357 | left join contacts con_reports_to on con_reports_to.id = contacts.reports_to_id |
||
358 | 1 | where contacts.id = '".$this->id."'"; |
|
359 | // Bug 43196 - If a contact is related to multiple accounts, make sure we pull the one we are looking for |
||
360 | // Bug 44730 was introduced due to this, fix is to simply clear any whitespaces around the account_id first |
||
361 | |||
362 | 1 | $clean_account_id = trim($this->account_id); |
|
363 | |||
364 | 1 | if ( !empty($clean_account_id) ) { |
|
365 | $query .= " and acc.id = '{$this->account_id}'"; |
||
366 | } |
||
367 | |||
368 | 1 | $query .= " ORDER BY a_c.date_modified DESC"; |
|
369 | |||
370 | 1 | $result = $this->db->query($query,true," Error filling in additional detail fields: "); |
|
371 | |||
372 | // Get the id and the name. |
||
373 | 1 | $row = $this->db->fetchByAssoc($result); |
|
374 | |||
375 | 1 | if($row != null) |
|
376 | { |
||
377 | $this->account_name = $row['name']; |
||
378 | $this->account_id = $row['id']; |
||
379 | $this->report_to_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'],'','','',null,true); |
||
380 | } |
||
381 | else |
||
382 | { |
||
383 | 1 | $this->account_name = ''; |
|
384 | 1 | $this->account_id = ''; |
|
385 | 1 | $this->report_to_name = ''; |
|
386 | } |
||
387 | 1 | $this->load_contacts_users_relationship(); |
|
388 | /** concating this here because newly created Contacts do not have a |
||
389 | * 'name' attribute constructed to pass onto related items, such as Tasks |
||
390 | * Notes, etc. |
||
391 | */ |
||
392 | 1 | $this->name = $locale->getLocaleFormattedName($this->first_name, $this->last_name); |
|
393 | 1 | if(!empty($this->contacts_users_id)) { |
|
394 | $this->sync_contact = true; |
||
395 | } |
||
396 | |||
397 | 1 | if(!empty($this->portal_active) && $this->portal_active == 1) { |
|
398 | $this->portal_active = true; |
||
399 | } |
||
400 | // Set campaign name if there is a campaign id |
||
401 | 1 | if( !empty($this->campaign_id)){ |
|
402 | |||
403 | $camp = new Campaign(); |
||
404 | $where = "campaigns.id='{$this->campaign_id}'"; |
||
405 | $campaign_list = $camp->get_full_list("campaigns.name", $where, true); |
||
406 | $this->campaign_name = $campaign_list[0]->name; |
||
407 | } |
||
408 | 1 | } |
|
409 | |||
410 | /** |
||
411 | loads the contacts_users relationship to populate a checkbox |
||
412 | where a user can select if they would like to sync a particular |
||
413 | contact to Outlook |
||
414 | */ |
||
415 | 2 | function load_contacts_users_relationship(){ |
|
416 | 2 | global $current_user; |
|
417 | |||
418 | 2 | $this->load_relationship("user_sync"); |
|
419 | |||
420 | 2 | $beanIDs = $this->user_sync->get(); |
|
421 | |||
422 | 2 | if( in_array($current_user->id, $beanIDs) ) |
|
423 | { |
||
424 | $this->contacts_users_id = $current_user->id; |
||
425 | } |
||
426 | 2 | } |
|
427 | |||
428 | 1 | function get_list_view_data($filter_fields = array()) { |
|
429 | |||
430 | 1 | $temp_array = parent::get_list_view_data(); |
|
431 | |||
432 | 1 | if($filter_fields && !empty($filter_fields['sync_contact'])){ |
|
0 ignored issues
–
show
The expression
$filter_fields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
433 | $this->load_contacts_users_relationship(); |
||
434 | $temp_array['SYNC_CONTACT'] = !empty($this->contacts_users_id) ? 1 : 0; |
||
435 | } |
||
436 | |||
437 | 1 | $temp_array['EMAIL_AND_NAME1'] = "{$this->full_name} <".$temp_array['EMAIL1'].">"; |
|
438 | |||
439 | 1 | return $temp_array; |
|
440 | } |
||
441 | |||
442 | /** |
||
443 | builds a generic search based on the query string using or |
||
444 | do not include any $this-> because this is called on without having the class instantiated |
||
445 | */ |
||
446 | 2 | function build_generic_where_clause ($the_query_string) |
|
447 | { |
||
448 | 2 | $where_clauses = Array(); |
|
449 | 2 | $the_query_string = $this->db->quote($the_query_string); |
|
450 | |||
451 | 2 | array_push($where_clauses, "contacts.last_name like '$the_query_string%'"); |
|
452 | 2 | array_push($where_clauses, "contacts.first_name like '$the_query_string%'"); |
|
453 | 2 | array_push($where_clauses, "accounts.name like '$the_query_string%'"); |
|
454 | 2 | array_push($where_clauses, "contacts.assistant like '$the_query_string%'"); |
|
455 | 2 | array_push($where_clauses, "ea.email_address like '$the_query_string%'"); |
|
456 | |||
457 | 2 | if (is_numeric($the_query_string)) |
|
458 | { |
||
459 | 2 | array_push($where_clauses, "contacts.phone_home like '%$the_query_string%'"); |
|
460 | 2 | array_push($where_clauses, "contacts.phone_mobile like '%$the_query_string%'"); |
|
461 | 2 | array_push($where_clauses, "contacts.phone_work like '%$the_query_string%'"); |
|
462 | 2 | array_push($where_clauses, "contacts.phone_other like '%$the_query_string%'"); |
|
463 | 2 | array_push($where_clauses, "contacts.phone_fax like '%$the_query_string%'"); |
|
464 | 2 | array_push($where_clauses, "contacts.assistant_phone like '%$the_query_string%'"); |
|
465 | } |
||
466 | |||
467 | 2 | $the_where = ""; |
|
468 | 2 | foreach($where_clauses as $clause) |
|
469 | { |
||
470 | 2 | if($the_where != "") $the_where .= " or "; |
|
471 | 2 | $the_where .= $clause; |
|
472 | } |
||
473 | |||
474 | |||
475 | 2 | return $the_where; |
|
476 | } |
||
477 | |||
478 | 1 | function set_notification_body($xtpl, $contact) |
|
479 | { |
||
480 | 1 | global $locale; |
|
481 | |||
482 | 1 | $xtpl->assign("CONTACT_NAME", trim($locale->getLocaleFormattedName($contact->first_name, $contact->last_name))); |
|
483 | 1 | $xtpl->assign("CONTACT_DESCRIPTION", $contact->description); |
|
484 | |||
485 | 1 | return $xtpl; |
|
486 | } |
||
487 | |||
488 | function get_contact_id_by_email($email) |
||
489 | { |
||
490 | $email = trim($email); |
||
491 | if(empty($email)){ |
||
492 | //email is empty, no need to query, return null |
||
493 | return null; |
||
494 | } |
||
495 | |||
496 | $where_clause = "(email1='$email' OR email2='$email') AND deleted=0"; |
||
497 | |||
498 | $query = "SELECT id FROM $this->table_name WHERE $where_clause"; |
||
499 | $GLOBALS['log']->debug("Retrieve $this->object_name: ".$query); |
||
500 | $result = $this->db->getOne($query, true, "Retrieving record $where_clause:"); |
||
501 | |||
502 | return empty($result)?null:$result; |
||
503 | } |
||
504 | |||
505 | 1 | function save_relationship_changes($is_update, $exclude = array()) { |
|
506 | |||
507 | //if account_id was replaced unlink the previous account_id. |
||
508 | //this rel_fields_before_value is populated by sugarbean during the retrieve call. |
||
509 | 1 | if (!empty($this->account_id) and !empty($this->rel_fields_before_value['account_id']) and |
|
510 | 1 | (trim($this->account_id) != trim($this->rel_fields_before_value['account_id']))) { |
|
511 | //unlink the old record. |
||
512 | $this->load_relationship('accounts'); |
||
513 | $this->accounts->delete($this->id,$this->rel_fields_before_value['account_id']); |
||
514 | } |
||
515 | 1 | parent::save_relationship_changes($is_update); |
|
516 | 1 | } |
|
517 | |||
518 | 63 | function bean_implements($interface) |
|
519 | { |
||
520 | switch($interface){ |
||
521 | 63 | case 'ACL':return true; |
|
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. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the 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. ![]() |
|||
522 | } |
||
523 | 1 | return false; |
|
524 | } |
||
525 | |||
526 | 1 | function get_unlinked_email_query($type=array()) |
|
527 | { |
||
528 | 1 | return get_unlinked_email_query($type, $this); |
|
529 | } |
||
530 | |||
531 | /** |
||
532 | * used by import to add a list of users |
||
533 | * |
||
534 | * Parameter can be one of the following: |
||
535 | * - string 'all': add this contact for all users |
||
536 | * - comma deliminated lists of teams and/or users |
||
537 | * |
||
538 | * @param string $list_of_user |
||
0 ignored issues
–
show
There is no parameter named
$list_of_user . Did you maybe mean $list_of_users ?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit. Consider the following example. The parameter /**
* @param array $germany
* @param array $ireland
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was changed, but the annotation was not. ![]() |
|||
539 | */ |
||
540 | 1 | function process_sync_to_outlook($list_of_users) |
|
541 | { |
||
542 | 1 | static $focus_user; |
|
543 | |||
544 | // cache this object since we'll be reusing it a bunch |
||
545 | 1 | if ( !($focus_user instanceof User) ) { |
|
546 | |||
547 | 1 | $focus_user = new User(); |
|
548 | } |
||
549 | |||
550 | |||
551 | 1 | if ( empty($list_of_users) ) { |
|
552 | return; |
||
553 | } |
||
554 | 1 | if ( !isset($this->users) ) { |
|
555 | 1 | $this->load_relationship('user_sync'); |
|
556 | } |
||
557 | |||
558 | 1 | if ( strtolower($list_of_users) == 'all' ) { |
|
559 | // add all non-deleted users |
||
560 | 1 | $sql = "SELECT id FROM users WHERE deleted=0 AND is_group=0 AND portal_only=0"; |
|
561 | 1 | $result=$this->db->query($sql); |
|
562 | 1 | while ( $hash = $this->db->fetchByAssoc($result) ) { |
|
563 | 1 | $this->user_sync->add($hash['id']); |
|
564 | } |
||
565 | } |
||
566 | else { |
||
567 | 1 | $theList = explode(",",$list_of_users); |
|
568 | 1 | foreach ($theList as $eachItem) { |
|
569 | 1 | if ( ($user_id = $focus_user->retrieve_user_id($eachItem)) |
|
570 | 1 | || $focus_user->retrieve($eachItem)) { |
|
571 | // it is a user, add user |
||
572 | 1 | $this->user_sync->add($user_id ? $user_id : $focus_user->id); |
|
573 | 1 | return; |
|
574 | } |
||
575 | } |
||
576 | } |
||
577 | 1 | } |
|
578 | } |
||
579 |
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.