1
|
|
|
<?php |
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
3
|
|
|
/********************************************************************************* |
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
6
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
20
|
|
|
* details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25
|
|
|
* 02110-1301 USA. |
26
|
|
|
* |
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
29
|
|
|
* |
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
33
|
|
|
* |
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39
|
|
|
********************************************************************************/ |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
class SugarWidgetFieldMultiEnum extends SugarWidgetFieldEnum { |
44
|
|
|
public function queryFilternot_one_of(&$layout_def) { |
45
|
|
|
$arr = array (); |
46
|
|
|
foreach ($layout_def['input_name0'] as $value) { |
47
|
|
|
array_push($arr, "'".$GLOBALS['db']->quote($value)."'"); |
48
|
|
|
} |
49
|
|
|
$reporter = $this->layout_manager->getAttribute("reporter"); |
50
|
|
|
|
51
|
|
|
$col_name = $this->_get_column_select($layout_def) . " NOT LIKE " ; |
52
|
|
|
$arr_count = count($arr); |
53
|
|
|
$query = ""; |
54
|
|
|
foreach($arr as $key=>$val) { |
55
|
|
|
$query .= $col_name; |
56
|
|
|
$value = preg_replace("/^'/", "'%", $val, 1); |
57
|
|
|
$value = preg_replace("/'$/", "%'", $value, 1); |
58
|
|
|
$query .= $value; |
59
|
|
|
if ($key != ($arr_count - 1)) |
60
|
|
|
$query.= " OR " ; |
61
|
|
|
} |
62
|
|
|
return '('.$query.')'; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function queryFilterone_of(&$layout_def) { |
66
|
|
|
//Fix for inaccurate filtering of contacts in Contacts dashlet on multiselects. |
67
|
|
|
$arr = array(); |
68
|
|
|
foreach ($layout_def['input_name0'] as $value) { |
69
|
|
|
if($value != ""){ |
70
|
|
|
array_push($arr, "'".$GLOBALS['db']->quote($value)."'"); |
71
|
|
|
}else{ |
72
|
|
|
array_push($arr, "'^^'"); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
$reporter = $this->layout_manager->getAttribute("reporter"); |
76
|
|
|
|
77
|
|
|
$col_name = $this->_get_column_select($layout_def) . " LIKE " ; |
78
|
|
|
$arr_count = count($arr); |
79
|
|
|
$query = ""; |
80
|
|
|
foreach($arr as $key=>$val) { |
81
|
|
|
$query .= $col_name; |
82
|
|
|
$value = preg_replace("/^'/", "'%", $val, 1); |
83
|
|
|
$value = preg_replace("/'$/", "%'", $value, 1); |
84
|
|
|
$query .= $value; |
85
|
|
|
if ($key != ($arr_count - 1)) |
86
|
|
|
$query.= " OR " ; |
87
|
|
|
} |
88
|
|
|
return '('.$query.')'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function queryFilteris($layout_def) { |
92
|
|
|
$input_name0 = $layout_def['input_name0']; |
93
|
|
|
if (is_array($layout_def['input_name0'])) { |
94
|
|
|
$input_name0 = $layout_def['input_name0'][0]; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
// Bug 40022 |
98
|
|
|
// IS filter doesn't add the carets (^) to multienum custom field values |
99
|
|
|
$input_name0 = $this->encodeMultienumCustom($layout_def, $input_name0); |
100
|
|
|
|
101
|
|
|
return $this->_get_column_select($layout_def)." = ".$this->reporter->db->quoted($input_name0)."\n"; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function queryFilteris_not($layout_def) { |
105
|
|
|
$input_name0 = $layout_def['input_name0']; |
106
|
|
|
if (is_array($layout_def['input_name0'])) { |
107
|
|
|
$input_name0 = $layout_def['input_name0'][0]; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
// Bug 50549 |
111
|
|
|
// IS NOT filter doesn't add the carets (^) to multienum custom field values |
112
|
|
|
$input_name0 = $this->encodeMultienumCustom($layout_def, $input_name0); |
113
|
|
|
|
114
|
|
|
return $this->_get_column_select($layout_def)." <> ".$this->reporter->db->quoted($input_name0)."\n"; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Returns an OrderBy query for multi-select. We treat multi-select the same as a normal field because |
119
|
|
|
* the values stored in the database are in the format ^A^,^B^,^C^ though not necessarily in that order. |
120
|
|
|
* @param $layout_def |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function queryOrderBy($layout_def) { |
124
|
|
|
return SugarWidgetReportField::queryOrderBy($layout_def); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Function checks if the multienum field is custom, and escapes it with carets (^) if it is |
129
|
|
|
* @param array $layout_def field layout definition |
130
|
|
|
* @param string $value value to be escaped |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
private function encodeMultienumCustom($layout_def, $value) { |
134
|
|
|
$field_def = $this->reporter->getFieldDefFromLayoutDef($layout_def); |
|
|
|
|
135
|
|
|
// Check if it is a custom field |
136
|
|
|
if (!empty($field_def['source']) && ($field_def['source'] == 'custom_fields' || ($field_def['source'] == 'non-db' && !empty($field_def['ext2']) && !empty($field_def['id']))) && !empty($field_def['real_table'])) |
137
|
|
|
{ |
138
|
|
|
$value = encodeMultienumValue(array($value)); |
139
|
|
|
} |
140
|
|
|
return $value; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
?> |
144
|
|
|
|
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.