This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
||
3 | /********************************************************************************* |
||
4 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
6 | |||
7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
8 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or modify it under |
||
11 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
12 | * Free Software Foundation with the addition of the following permission added |
||
13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
16 | * |
||
17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
20 | * details. |
||
21 | * |
||
22 | * You should have received a copy of the GNU Affero General Public License along with |
||
23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
25 | * 02110-1301 USA. |
||
26 | * |
||
27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
29 | * |
||
30 | * The interactive user interfaces in modified source and object code versions |
||
31 | * of this program must display Appropriate Legal Notices, as required under |
||
32 | * Section 5 of the GNU Affero General Public License version 3. |
||
33 | * |
||
34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
35 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
39 | ********************************************************************************/ |
||
40 | |||
41 | /********************************************************************************* |
||
42 | |||
43 | * Description: |
||
44 | ********************************************************************************/ |
||
45 | |||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | |||
53 | class Controller extends SugarBean { |
||
54 | |||
55 | var $focus; |
||
56 | var $type; //defines id this is a new list order or existing, or delete |
||
57 | // New, Save, Delete |
||
58 | |||
59 | public function __construct() { |
||
60 | parent::__construct(); |
||
61 | |||
62 | $this->disable_row_level_security =true; |
||
63 | |||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @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 |
||
68 | */ |
||
69 | public function Controller(){ |
||
70 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
71 | if(isset($GLOBALS['log'])) { |
||
72 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
73 | } |
||
74 | else { |
||
75 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
76 | } |
||
77 | self::__construct(); |
||
78 | } |
||
79 | |||
80 | |||
81 | function init(& $seed_object, $type){ |
||
82 | |||
83 | $this->focus = & $seed_object; |
||
84 | $this->type = $type; |
||
85 | |||
86 | //end function Controller |
||
87 | } |
||
88 | |||
89 | function change_component_order($magnitude, $direction, $parent_id=""){ |
||
90 | |||
91 | if(!empty($this->type) && $this->type=="Save"){ |
||
92 | |||
93 | //safety check |
||
94 | $wall_test = $this->check_wall($magnitude, $direction, $parent_id); |
||
95 | |||
96 | if($wall_test==false){ |
||
0 ignored issues
–
show
|
|||
97 | return; |
||
98 | } |
||
99 | |||
100 | |||
101 | if($direction=="Left"){ |
||
102 | if($this->focus->controller_def['list_x']=="Y"){ |
||
103 | $new_x = $this->focus->list_order_x -1; |
||
104 | $affected_x = $this->focus->list_order_x; |
||
105 | } else { |
||
106 | $new_x = ""; |
||
107 | $affected_x = ""; |
||
108 | } |
||
109 | if($this->focus->controller_def['list_y']=="Y"){ |
||
110 | |||
111 | $new_y = $this->focus->list_order_y; |
||
112 | $affected_y = $this->focus->list_order_y; |
||
113 | } else { |
||
114 | $new_y = ""; |
||
115 | $affected_y = ""; |
||
116 | } |
||
117 | |||
118 | $affected_id = $this->get_affected_id($parent_id, $new_x, $new_y); |
||
119 | //end if direction Left |
||
120 | } |
||
121 | if($direction=="Right"){ |
||
122 | |||
123 | if($this->focus->controller_def['list_x']=="Y"){ |
||
124 | $new_x = $this->focus->list_order_x + 1; |
||
125 | $affected_x = $this->focus->list_order_x; |
||
126 | } else { |
||
127 | $new_x = ""; |
||
128 | $affected_x = ""; |
||
129 | } |
||
130 | if($this->focus->controller_def['list_y']=="Y"){ |
||
131 | $new_y = $this->focus->list_order_y; |
||
132 | $affected_y = $this->focus->list_order_y; |
||
133 | } else { |
||
134 | $new_y = ""; |
||
135 | $affected_y = ""; |
||
136 | } |
||
137 | $affected_id = $this->get_affected_id($parent_id, $new_x, $new_y); |
||
138 | //end if direction Right |
||
139 | } |
||
140 | |||
141 | if($direction=="Up"){ |
||
142 | if($this->focus->controller_def['list_x']=="Y"){ |
||
143 | $new_x = $this->focus->list_order_x; |
||
144 | $affected_x = $this->focus->list_order_x; |
||
145 | } else { |
||
146 | $new_x = ""; |
||
147 | $affected_x = ""; |
||
148 | } |
||
149 | if($this->focus->controller_def['list_y']=="Y"){ |
||
150 | |||
151 | $new_y = $this->focus->list_order_y - 1; |
||
152 | $affected_y = $this->focus->list_order_y; |
||
153 | } else { |
||
154 | $new_y = ""; |
||
155 | $affected_y = ""; |
||
156 | } |
||
157 | |||
158 | $affected_id = $this->get_affected_id($parent_id, $new_x, $new_y); |
||
159 | |||
160 | //end if direction Up |
||
161 | } |
||
162 | if($direction=="Down"){ |
||
163 | |||
164 | if($this->focus->controller_def['list_x']=="Y"){ |
||
165 | $new_x = $this->focus->list_order_x; |
||
166 | $affected_x = $this->focus->list_order_x; |
||
167 | } else { |
||
168 | $new_x = ""; |
||
169 | $affected_x = ""; |
||
170 | } |
||
171 | if($this->focus->controller_def['list_y']=="Y"){ |
||
172 | |||
173 | $new_y = $this->focus->list_order_y + 1; |
||
174 | $affected_y = $this->focus->list_order_y; |
||
175 | } else { |
||
176 | $new_y = ""; |
||
177 | $affected_y = ""; |
||
178 | } |
||
179 | $affected_id = $this->get_affected_id($parent_id, $new_x, $new_y); |
||
180 | //end if direction Down |
||
181 | } |
||
182 | |||
183 | //This takes care of the component being pushed out of its position |
||
184 | $this->update_affected_order($affected_id, $affected_x, $affected_y); |
||
185 | |||
186 | //This takes care of the new positions for itself |
||
187 | if($this->focus->controller_def['list_x']=="Y"){ |
||
188 | $this->focus->list_order_x = $new_x; |
||
189 | } |
||
190 | |||
191 | if($this->focus->controller_def['list_y']=="Y"){ |
||
192 | $this->focus->list_order_y = $new_y; |
||
193 | } |
||
194 | |||
195 | } else { |
||
196 | //this is a new component, set the x or y value to the max + 1 |
||
197 | |||
198 | $query = "SELECT MAX(".$this->focus->controller_def['start_var'].") max_start from ".$this->focus->table_name." |
||
199 | WHERE ".$this->focus->controller_def['parent_var']."='$parent_id' |
||
200 | AND ".$this->focus->table_name.".deleted='0' |
||
201 | "; |
||
202 | $result = $this->db->query($query,true," Error capturing max start order: "); |
||
203 | $row = $this->db->fetchByAssoc($result); |
||
204 | |||
205 | if(!is_null($row['max_start'])){ |
||
206 | |||
207 | if($this->focus->controller_def['start_axis']=="x") { |
||
208 | $this->focus->list_order_x = $row['max_start'] + 1; |
||
209 | if($this->focus->controller_def['list_y']=="Y") $this->focus->list_order_y = 0; |
||
210 | } |
||
211 | |||
212 | if($this->focus->controller_def['start_axis']=="y") { |
||
213 | $this->focus->list_order_y = $row['max_start'] + 1; |
||
214 | if($this->focus->controller_def['list_x']=="Y") $this->focus->list_order_x = 0; |
||
215 | } |
||
216 | |||
217 | } else { |
||
218 | //first row |
||
219 | if($this->focus->controller_def['list_x']=="Y") $this->focus->list_order_x = 0; |
||
220 | if($this->focus->controller_def['list_y']=="Y") $this->focus->list_order_y = 0; |
||
221 | |||
222 | //end if else to check if this is first entry |
||
223 | } |
||
224 | //end if else on whether this is a new entry |
||
225 | } |
||
226 | //end function change_component_order |
||
227 | } |
||
228 | |||
229 | function update_affected_order($affected_id, $affected_new_x="", $affected_new_y=""){ |
||
230 | |||
231 | $query = "UPDATE ".$this->focus->table_name." SET"; |
||
232 | |||
233 | if($this->focus->controller_def['list_x']=="Y"){ |
||
234 | $query .= " list_order_x='$affected_new_x'"; |
||
235 | } |
||
236 | if($this->focus->controller_def['list_y']=="Y"){ |
||
237 | |||
238 | if($this->focus->controller_def['list_x']=="Y"){ |
||
239 | $query .= " , "; |
||
240 | } |
||
241 | $query .= " list_order_y='$affected_new_y'"; |
||
242 | } |
||
243 | |||
244 | $query .= " WHERE id='$affected_id'"; |
||
245 | $query .= " AND ".$this->focus->table_name.".deleted='0'"; |
||
246 | $result = $this->db->query($query,true," Error updating affected order id: "); |
||
247 | //end function update_affected_order |
||
248 | } |
||
249 | |||
250 | function get_affected_id($parent_id, $list_order_x="", $list_order_y=""){ |
||
251 | |||
252 | $query = " SELECT id from ".$this->focus->table_name." |
||
253 | WHERE ".$this->focus->controller_def['parent_var']."='$parent_id' |
||
254 | AND ".$this->focus->table_name.".deleted='0' |
||
255 | "; |
||
256 | |||
257 | if($this->focus->controller_def['list_x']=="Y"){ |
||
258 | $query .= " AND list_order_x='$list_order_x' "; |
||
259 | } |
||
260 | |||
261 | if($this->focus->controller_def['list_y']=="Y"){ |
||
262 | $query .= " AND list_order_y='$list_order_y' "; |
||
263 | } |
||
264 | |||
265 | //echo $query."<BR>"; |
||
266 | $result = $this->db->query($query,true," Error capturing affected id: "); |
||
267 | $row = $this->db->fetchByAssoc($result); |
||
268 | |||
269 | return $row['id']; |
||
270 | |||
271 | //end function get_affected_id |
||
272 | } |
||
273 | |||
274 | |||
275 | /////////////Wall Functions//////////////////// |
||
276 | |||
277 | |||
278 | function check_wall($magnitude, $direction, $parent_id){ |
||
279 | |||
280 | //TODO: jgreen - this is only single axis check_wall mechanism, will need to upgrade this to double axis |
||
281 | //This function determines if you can't move the direction you want, because you are at the edge |
||
282 | |||
283 | |||
284 | //If down or Right, then check max list_order value |
||
285 | if($direction=="Down" || $direction =="Right"){ |
||
286 | |||
287 | $query = "SELECT MAX(".$this->focus->controller_def['start_var'].") max_start from ".$this->focus->table_name." |
||
288 | WHERE ".$this->focus->controller_def['parent_var']."='$parent_id' |
||
289 | AND ".$this->focus->table_name.".deleted='0' |
||
290 | "; |
||
291 | $result = $this->db->query($query,true," Error capturing max start order: "); |
||
292 | $row = $this->db->fetchByAssoc($result); |
||
293 | |||
294 | if($this->focus->controller_def['start_axis']=="x") { |
||
295 | if($row['max_start'] == $this->focus->list_order_x){ |
||
296 | return false; |
||
297 | } |
||
298 | } |
||
299 | if($this->focus->controller_def['start_axis']=="y") { |
||
300 | if($row['max_start'] == $this->focus->list_order_y){ |
||
301 | return false; |
||
302 | } |
||
303 | } |
||
304 | //end if up or right |
||
305 | } |
||
306 | |||
307 | //If up or left, then simply check the 0 value |
||
308 | if($direction=="Up" || $direction =="Left"){ |
||
309 | if($this->focus->controller_def['start_axis']=="x") { |
||
310 | if($this->focus->list_order_x==0){ |
||
311 | return false; |
||
312 | } |
||
313 | } |
||
314 | if($this->focus->controller_def['start_axis']=="y") { |
||
315 | if($this->focus->list_order_y==0){ |
||
316 | return false; |
||
317 | } |
||
318 | } |
||
319 | |||
320 | //end if down or left |
||
321 | } |
||
322 | |||
323 | //If you get here, then you are not at the wall and can change order |
||
324 | return true; |
||
325 | |||
326 | //end function check_wall |
||
327 | } |
||
328 | |||
329 | //End Wall Functions///////////////////////// |
||
330 | |||
331 | //Delete adjust functions//////////////////// |
||
332 | |||
333 | |||
334 | function delete_adjust_order($parent_id){ |
||
335 | |||
336 | |||
337 | //Currently handles single axis motion only!!!!!!!!! |
||
338 | //TODO: jgreen - Add dual axis motion |
||
339 | |||
340 | //adjust along start_axis |
||
341 | $variable_name = $this->focus->controller_def['start_var']; |
||
342 | $current_position = $this->focus->$variable_name; |
||
343 | |||
344 | $query = "UPDATE ".$this->focus->table_name." "; |
||
345 | $query .= "SET ".$this->focus->controller_def['start_var']." = ".$this->focus->controller_def['start_var']." - 1 "; |
||
346 | $query .= "WHERE ".$this->focus->controller_def['start_var']." > ".$current_position." AND deleted=0 "; |
||
347 | $query .= "AND ".$this->focus->controller_def['parent_var']." = '".$parent_id."'"; |
||
348 | |||
349 | $result = $this->db->query($query,true," Error updating the delete_adjust_order: "); |
||
350 | //end delete_adjust_order |
||
351 | } |
||
352 | //End Delete Functions///////////////////////// |
||
353 | //end class Controller |
||
354 | } |
||
355 | |||
356 | ?> |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.