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 | global $timedate; |
||
44 | |||
45 | class CalendarGrid { |
||
46 | |||
47 | protected $cal; // Calendar object |
||
48 | public $style = ""; // style of calendar (basic or advanced); advanced contains time slots |
||
49 | protected $today_ts; // timestamp of today |
||
50 | protected $weekdays; // string array of names of week days |
||
51 | protected $startday; // first day of week |
||
52 | protected $scrollable; // scrolling in calendar |
||
53 | protected $time_step = 30; // time step |
||
54 | protected $time_format; // user time format |
||
55 | protected $date_time_format; // user date time format |
||
56 | protected $scroll_height; // height of scrollable div |
||
57 | |||
58 | /** |
||
59 | * constructor |
||
60 | * @param Calendar $cal |
||
61 | */ |
||
62 | function __construct(Calendar $cal){ |
||
63 | global $current_user; |
||
64 | $this->cal = $cal; |
||
65 | $today = $GLOBALS['timedate']->getNow(true)->get_day_begin(); |
||
66 | $this->today_ts = $today->format('U') + $today->getOffset(); |
||
67 | $this->startday = $current_user->get_first_day_of_week(); |
||
68 | |||
69 | $weekdays = array(); |
||
70 | for($i = 0; $i < 7; $i++){ |
||
71 | $j = $i + $this->startday; |
||
72 | if($j >= 7) |
||
73 | $j = $j - 7; |
||
74 | $weekdays[$i] = $GLOBALS['app_list_strings']['dom_cal_day_short'][$j+1]; |
||
75 | } |
||
76 | |||
77 | $this->weekdays = $weekdays; |
||
78 | |||
79 | $this->scrollable = false; |
||
80 | if (!($this->cal->isPrint() && $this->cal->view == 'day')) { |
||
81 | if(in_array($this->cal->view,array('day','week'))){ |
||
82 | $this->scrollable = true; |
||
83 | if($this->cal->time_step < 30) |
||
84 | $this->scroll_height = 480; |
||
85 | else |
||
86 | $this->scroll_height = $this->cal->celcount * 15 + 1; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | $this->time_step = $this->cal->time_step; |
||
91 | $this->time_format = $GLOBALS['timedate']->get_time_format(); |
||
92 | $this->date_time_format = $GLOBALS['timedate']->get_date_time_format(); |
||
93 | |||
94 | $this->style = $this->cal->style; |
||
95 | } |
||
96 | |||
97 | |||
98 | /** Get html of calendar grid |
||
99 | * @return string |
||
100 | */ |
||
101 | public function display(){ |
||
102 | $action = "display_".strtolower($this->cal->view); |
||
103 | return $this->$action(); |
||
104 | } |
||
105 | |||
106 | /** Get html of time column |
||
107 | * @param integer $start timestamp |
||
108 | * @return string |
||
109 | */ |
||
110 | protected function get_time_column($start){ |
||
111 | $str = ""; |
||
112 | $head_content = " "; |
||
113 | if($this->cal->view == 'month'){ |
||
114 | if($this->startday == 0) |
||
115 | $wf = 1; |
||
116 | else |
||
117 | $wf = 0; |
||
118 | $head_content = "<a href='".ajaxLink("index.php?module=Calendar&action=index&view=week&hour=0&day=".$GLOBALS['timedate']->fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W')."</a>"; |
||
119 | } |
||
120 | $str .= "<div class='left_col'>"; |
||
121 | //if(!$this->scrollable) |
||
122 | // $str .= "<div class='col_head'>".$head_content."</div>"; |
||
123 | $cell_number = 0; |
||
124 | $first_cell = $this->cal->scroll_slot; |
||
125 | $last_cell = $first_cell + $this->cal->celcount - 1; |
||
126 | for($i = 0; $i < 24; $i++){ |
||
127 | for($j = 0; $j < 60; $j += $this->time_step){ |
||
128 | if($j == 0){ |
||
129 | $innerText = $GLOBALS['timedate']->fromTimestamp($start + $i * 3600)->format($this->time_format); |
||
130 | }else{ |
||
131 | $innerText = " "; |
||
132 | } |
||
133 | if($j == 60 - $this->time_step && $this->time_step < 60){ |
||
134 | $class = " odd_border"; |
||
135 | }else{ |
||
136 | $class = ""; |
||
137 | } |
||
138 | if ($this->scrollable || ($cell_number >= $first_cell && $cell_number <= $last_cell)) |
||
139 | { |
||
140 | $str .= "<div class='left_slot".$class."'>".$innerText."</div>"; |
||
141 | } |
||
142 | $cell_number++; |
||
143 | } |
||
144 | } |
||
145 | $str .= "</div>"; |
||
146 | return $str; |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * Get html of day slots column |
||
151 | * @param integer $start timestamp |
||
152 | * @param integer $day number of day in week |
||
153 | * @param string $suffix suffix for id of time slot used in shared view |
||
154 | * @return string |
||
155 | */ |
||
156 | protected function get_day_column($start,$day = 0,$suffix = ""){ |
||
157 | $curr_time = $start; |
||
158 | $str = ""; |
||
159 | $str .= "<div class='col'>"; |
||
160 | //$str .= $this->get_day_head($start,$day); |
||
161 | $cell_number = 0; |
||
162 | $first_cell = $this->cal->scroll_slot; |
||
163 | $last_cell = $first_cell + $this->cal->celcount - 1; |
||
164 | for($i = 0; $i < 24; $i++){ |
||
165 | for($j = 0; $j < 60; $j += $this->time_step){ |
||
166 | $timestr = $GLOBALS['timedate']->fromTimestamp($curr_time)->format($this->time_format); |
||
167 | if($j == 60 - $this->time_step && $this->time_step < 60){ |
||
168 | $class = " odd_border"; |
||
169 | }else{ |
||
170 | $class = ""; |
||
171 | } |
||
172 | if ($this->scrollable || ($cell_number >= $first_cell && $cell_number <= $last_cell)) |
||
173 | { |
||
174 | $str .= "<div id='t_".$curr_time.$suffix."' class='slot".$class."' time='".$timestr."' datetime='".$GLOBALS['timedate']->fromTimestamp($curr_time)->format($this->date_time_format)."'></div>"; |
||
175 | } |
||
176 | $cell_number++; |
||
177 | $curr_time += $this->time_step*60; |
||
178 | } |
||
179 | } |
||
180 | $str .= "</div>"; |
||
181 | return $str; |
||
182 | } |
||
183 | |||
184 | public function display_mobile(){ |
||
185 | |||
186 | global $mod_strings; |
||
187 | |||
188 | $str = "<div class='mobile_calendar_container'>"; |
||
189 | |||
190 | foreach($this->cal->items as $cal_item){ |
||
191 | |||
192 | if(date("Y-m-d", $cal_item['ts_start']) >= date("Y-m-d", $this->today_ts)){ |
||
193 | $agenda_array[$cal_item['ts_start']][] = $cal_item; |
||
194 | ksort($agenda_array); |
||
195 | } |
||
196 | } |
||
197 | |||
198 | $days = array_keys($agenda_array); |
||
199 | |||
200 | if($days){ |
||
0 ignored issues
–
show
|
|||
201 | foreach($days as $day){ |
||
202 | |||
203 | $agenda_array[$day] = $this->mobile_sort_items($agenda_array[$day]); |
||
204 | |||
205 | if($day == $this->today_ts){ |
||
206 | $str .= "<div class='mobile_calendar_title today'><b>Today</b> " . date("D dS, M Y", $agenda_array[$day][0]['ts_start']) . "</div>"; |
||
207 | }else{ |
||
208 | $str .= "<div class='mobile_calendar_title'>" . date("D dS, M Y", $agenda_array[$day][0]['ts_start']) . "</div>"; |
||
209 | } |
||
210 | |||
211 | $i = 0; |
||
212 | |||
213 | while($i < count($agenda_array[$day])){ |
||
214 | |||
215 | $day_item = $agenda_array[$day][$i]; |
||
216 | |||
217 | $str .= $this->mobile_display_items($day_item); |
||
218 | |||
219 | $i++; |
||
220 | } |
||
221 | |||
222 | } |
||
223 | }else{ |
||
224 | $str .= "<div class='mobile_calendar_title no_items'>" . $mod_strings['LBL_NO_ITEMS_MOBILE'] . "</div>"; |
||
225 | } |
||
226 | |||
227 | |||
228 | |||
229 | |||
230 | $str .= "</div>"; |
||
231 | return $str; |
||
232 | |||
233 | } |
||
234 | |||
235 | function mobile_display_items($day_item){ |
||
236 | |||
237 | $end_time = $this->mobile_get_end_time($day_item); |
||
238 | $status_color = $this->mobile_get_status_colour($day_item['status']); |
||
239 | $type_color = $this->mobile_get_type_colour($day_item['type']); |
||
240 | |||
241 | $display = ""; |
||
242 | |||
243 | $display .= "<div class='mobile_calendar_item'>"; |
||
244 | |||
245 | $display .= "<div class='mobile_calendar_item_left' >"; |
||
246 | |||
247 | $display .= "<div class='mobile_calendar_item_left_type' style='background-color:" . $type_color .";'>"; |
||
248 | $display .= ucfirst($day_item['type']); |
||
249 | $display .= "</div>"; |
||
250 | |||
251 | $display .= "<div class='mobile_calendar_item_left_date'>"; |
||
252 | $display .= "<div class='mobile_calendar_item_left_time'>" . $day_item['time_start'] . "</div>"; |
||
253 | $display .= "<div class='mobile_calendar_item_left_time'>" . $end_time . "</div>"; |
||
254 | $display .= "</div>"; |
||
255 | |||
256 | $display .= "<div class='mobile_calendar_item_left_status' style='background-color:" . $status_color ."';>"; |
||
257 | $display .= $day_item['status']; |
||
258 | $display .= "</div>"; |
||
259 | |||
260 | $display .= "</div>"; |
||
261 | |||
262 | $display .= "<div class='mobile_calendar_item_center'>"; |
||
263 | $display .= "<p class='mobile_calendar_item_name'>" . $day_item['name'] . "</p>"; |
||
264 | $display .= "<p class='mobile_calendar_item_desc'>" . $day_item['description'] . "</p>"; |
||
265 | $display .= "</div>"; |
||
266 | |||
267 | |||
268 | if($day_item['type'] == "task"){ |
||
269 | $display .= "<div class='mobile_calendar_item_edit'>"; |
||
270 | $display .= "<a class='button' module_name ='" . ucfirst($day_item['type']) ."s' href='index.php?action=EditView&module=Tasks&return_module=Calendar&return_action=index&record=" . $day_item['record'] . "'>Edit</a>"; |
||
271 | $display .= "</div>"; |
||
272 | $display .= "</div>"; |
||
273 | }else{ |
||
274 | $display .= "<div class='mobile_calendar_item_edit'>"; |
||
275 | $display .= "<a class='button' href='#' module_name ='" . ucfirst($day_item['type']) ."s' record = '" . $day_item['record'] ."' onclick=CAL.load_form(this.getAttribute('module_name'),this.getAttribute('record'),true);>Edit</a>"; |
||
276 | $display .= "</div>"; |
||
277 | $display .= "</div>"; |
||
278 | } |
||
279 | |||
280 | return $display; |
||
281 | } |
||
282 | |||
283 | function mobile_get_end_time($day_item){ |
||
284 | $start_time = DateTime::createFromFormat("H:i",$day_item['time_start']); |
||
285 | $start_time->modify('+' . $day_item['duration_minutes'] .'minutes'); |
||
286 | return $start_time->format("H:i"); |
||
287 | } |
||
288 | |||
289 | |||
290 | function mobile_get_type_colour($type){ |
||
291 | switch ($type) { |
||
292 | case "meeting": |
||
293 | $colour = "#D2E5FC"; |
||
294 | break; |
||
295 | case "call": |
||
296 | $colour = "#FCDCDC"; |
||
297 | break; |
||
298 | case "task": |
||
299 | $colour = "#B1F5AE"; |
||
300 | break; |
||
301 | default: |
||
302 | $colour = "#777777"; |
||
303 | break; |
||
304 | } |
||
305 | return $colour; |
||
306 | } |
||
307 | |||
308 | function mobile_get_status_colour($type){ |
||
309 | switch ($type) { |
||
310 | case "Held": |
||
311 | case "Completed": |
||
312 | $colour = "green"; |
||
313 | break; |
||
314 | case "Planned": |
||
315 | case "Not Started": |
||
316 | case "In Progress": |
||
317 | $colour = "#1B4B94"; |
||
318 | break; |
||
319 | case "Not Held": |
||
320 | case "Deferred": |
||
321 | $colour = "red"; |
||
322 | break; |
||
323 | default: |
||
324 | $colour = "#777777"; |
||
325 | break; |
||
326 | } |
||
327 | return $colour; |
||
328 | } |
||
329 | |||
330 | function mobile_sort_items($agenda_array){ |
||
331 | $times = ""; |
||
332 | |||
333 | foreach ($agenda_array as $key => $row) { |
||
334 | $times[$key] = $row['timestamp']; |
||
335 | } |
||
336 | |||
337 | array_multisort($times, SORT_ASC, $agenda_array); |
||
338 | |||
339 | return $agenda_array; |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * Get html of basic cell |
||
344 | * @param integer $start timestamp |
||
345 | * @param integer $height slot height |
||
346 | * @param string $prefix prefix for id of slot used in shared view |
||
0 ignored issues
–
show
There is no parameter named
$prefix . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
347 | * @return string |
||
348 | */ |
||
349 | protected function get_basic_cell($start,$height = 80,$suffix = ""){ |
||
350 | $str = ""; |
||
351 | $dt = $GLOBALS['timedate']->fromTimestamp($start)->get("+8 hours"); |
||
352 | $str .= "<div class='col'>"; |
||
353 | $str .= "<div class='basic_slot' id='b_".$start.$suffix."' style='height: ".$height."px;' time='' datetime='".$dt->format($this->date_time_format)."'></div>"; |
||
354 | $str .= "</div>"; |
||
355 | return $str; |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * Get html of basic week grid |
||
360 | * @param integer $start timestamp |
||
361 | * @param string $prefix prefix for id of slot used in shared view |
||
0 ignored issues
–
show
There is no parameter named
$prefix . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
362 | * @return string |
||
363 | */ |
||
364 | protected function get_basic_row($start,$cols = 7,$suffix = ""){ |
||
365 | |||
366 | $height = 20; |
||
367 | $str = ""; |
||
368 | $head_content = " "; |
||
369 | if($this->cal->view == 'month' || $this->cal->style == "basic"){ |
||
370 | $wf = 0; |
||
371 | if($this->startday == 0) |
||
372 | $wf = 1; |
||
373 | $head_content = $GLOBALS['timedate']->fromTimestamp($start + $wf*3600*24)->format('W'); |
||
374 | $head_content = "<a href='".ajaxLink("index.php?module=Calendar&action=index&view=week&hour=0&day=".$GLOBALS['timedate']->fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$head_content."</a>"; |
||
375 | } |
||
376 | $left_col = ($this->style != 'basic' || $this->cal->view == 'month'); |
||
377 | |||
378 | $attr = ""; |
||
379 | if($this->cal->style != "basic") |
||
380 | $attr = " id='cal-multiday-bar'"; |
||
381 | |||
382 | $str .= "<div>"; |
||
383 | if($cols > 1){ |
||
384 | $str .= "<div>"; |
||
385 | if($left_col){ |
||
386 | $str .= "<div class='left_col'>"; |
||
387 | $str .= "<div class='col_head'>".$head_content."</div>"; |
||
388 | $str .= "</div>"; |
||
389 | } |
||
390 | |||
391 | $str .= "<div class='week'>"; |
||
392 | for($d = 0; $d < $cols; $d++){ |
||
393 | $curr_time = $start + $d * 86400; |
||
394 | $str .= "<div class='col'>"; |
||
395 | $str .= $this->get_day_head($curr_time,$d,true); |
||
396 | $str .= "</div>"; |
||
397 | } |
||
398 | $str .= "</div>"; |
||
399 | $str .= "<br style='clear: left;'/>"; |
||
400 | $str .= "</div>"; |
||
401 | } |
||
402 | $str .= "<div class='cal-basic' ".$attr.">"; |
||
403 | if($left_col){ |
||
404 | $str .= "<div class='left_col'>"; |
||
405 | $str .= "<div class='left_basic_slot' style='height: ".$height."px;'> </div>"; |
||
406 | $str .= "</div>"; |
||
407 | } |
||
408 | $str .= "<div class='week'>"; |
||
409 | for($d = 0; $d < $cols; $d++){ |
||
410 | $curr_time = $start + $d*86400; |
||
411 | $str .= $this->get_basic_cell($curr_time,$height,$suffix); |
||
412 | } |
||
413 | $str .= "</div>"; |
||
414 | $str .= "<div style='clear: left;'></div>"; |
||
415 | $str .= "</div>"; |
||
416 | $str .= "</div>"; |
||
417 | |||
418 | return $str; |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * Get html of day head |
||
423 | * @param integer $start timestamp |
||
424 | * @param integer $day number of day in week |
||
425 | * @param bulean $force force display header |
||
426 | * @return string |
||
427 | */ |
||
428 | protected function get_day_head($start,$day = 0,$force = false){ |
||
429 | $str = ""; |
||
430 | if($force){ |
||
431 | $headstyle = ""; |
||
432 | if($this->today_ts == $start) |
||
433 | $headstyle = " today"; |
||
434 | $str .= "<div class='col_head".$headstyle."'><a href='".ajaxLink("index.php?module=Calendar&action=index&view=day&hour=0&day=".$GLOBALS['timedate']->fromTimestamp($start)->format('j')."&month=".$GLOBALS['timedate']->fromTimestamp($start)->format('n')."&year=".$GLOBALS['timedate']->fromTimestamp($start)->format('Y'))."'>".$this->weekdays[$day]." ".$GLOBALS['timedate']->fromTimestamp($start)->format('d')."</a></div>"; |
||
435 | } |
||
436 | return $str; |
||
437 | } |
||
438 | |||
439 | /** |
||
440 | * Get html of week calendar grid |
||
441 | * @return string |
||
442 | */ |
||
443 | protected function display_week(){ |
||
444 | |||
445 | $basic = $this->style == "basic"; |
||
446 | $week_start_ts = $this->cal->grid_start_ts; |
||
447 | |||
448 | $str = ""; |
||
449 | $str .= "<div id='cal-grid' style='visibility: hidden;'>"; |
||
450 | $str .= $this->get_basic_row($week_start_ts); |
||
451 | if(!$basic){ |
||
452 | $str .= "<div id='cal-scrollable' style='clear: both; height: ".$this->scroll_height."px;'>"; |
||
453 | $str .= $this->get_time_column($week_start_ts); |
||
454 | $str .= "<div class='week'>"; |
||
455 | for($d = 0; $d < 7; $d++){ |
||
456 | $curr_time = $week_start_ts + $d*86400; |
||
457 | $str .= $this->get_day_column($curr_time); |
||
458 | } |
||
459 | $str .= "</div>"; |
||
460 | $str .= "<div style='clear: left;'></div>"; |
||
461 | $str .= "</div>"; |
||
462 | } |
||
463 | $str .= "</div>"; |
||
464 | |||
465 | return $str; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * Get html of day calendar grid |
||
470 | * @return string |
||
471 | */ |
||
472 | protected function display_day(){ |
||
473 | |||
474 | $basic = $this->style == "basic"; |
||
475 | $day_start_ts = $this->cal->grid_start_ts; |
||
476 | |||
477 | $str = ""; |
||
478 | $str .= "<div id='cal-grid' style='visibility: hidden;'>"; |
||
479 | $str .= $this->get_basic_row($day_start_ts,1); |
||
480 | if(!$basic){ |
||
481 | $str .= "<div id='cal-scrollable' style='height: ".$this->scroll_height."px;'>"; |
||
482 | $str .= $this->get_time_column($day_start_ts); |
||
483 | $d = 0; |
||
484 | $curr_time = $day_start_ts + $d*86400; |
||
485 | $str .= "<div class='week'>"; |
||
486 | $str .= $this->get_day_column($curr_time); |
||
487 | $str .= "</div>"; |
||
488 | $str .= "<div style='clear: left;'></div>"; |
||
489 | $str .= "</div>"; |
||
490 | } |
||
491 | $str .= "</div>"; |
||
492 | |||
493 | return $str; |
||
494 | } |
||
495 | |||
496 | /** |
||
497 | * Get html of month calendar grid |
||
498 | * @return string |
||
499 | */ |
||
500 | protected function display_month(){ |
||
501 | |||
502 | $basic = $this->style == "basic"; |
||
503 | $week_start_ts = $this->cal->grid_start_ts; |
||
504 | $current_date = $this->cal->date_time; |
||
505 | $month_start = $current_date->get_day_by_index_this_month(0); |
||
506 | $month_end = $month_start->get("+".$month_start->format('t')." days"); |
||
507 | $week_start = CalendarUtils::get_first_day_of_week($month_start); |
||
508 | $month_end_ts = $month_end->format('U') + $month_end->getOffset(); |
||
509 | |||
510 | $str = ""; |
||
511 | $str .= "<div id='cal-grid' style='visibility: hidden;'>"; |
||
512 | $curr_time_global = $week_start_ts; |
||
513 | $w = 0; |
||
514 | while($curr_time_global < $month_end_ts){ |
||
515 | if($basic){ |
||
516 | $str .= $this->get_basic_row($curr_time_global); |
||
517 | }else{ |
||
518 | $str .= $this->get_time_column($curr_time_global); |
||
519 | $str .= "<div class='week'>"; |
||
520 | for($d = 0; $d < 7; $d++){ |
||
521 | $curr_time = $week_start_ts + $d*86400 + $w*60*60*24*7; |
||
522 | $str .= $this->get_day_column($curr_time,$d); |
||
523 | } |
||
524 | $str .= "</div>"; |
||
525 | $str .= "<div style='clear: left;'></div>"; |
||
526 | } |
||
527 | $curr_time_global += 60*60*24*7; |
||
528 | $w++; |
||
529 | } |
||
530 | $str .= "</div>"; |
||
531 | |||
532 | return $str; |
||
533 | } |
||
534 | |||
535 | /** |
||
536 | * Get html of week shared grid |
||
537 | * @return string |
||
538 | */ |
||
539 | protected function display_shared(){ |
||
540 | |||
541 | $basic = $this->style == "basic"; |
||
542 | $week_start_ts = $this->cal->grid_start_ts; |
||
543 | |||
544 | $str = ""; |
||
545 | $str .= "<div id='cal-grid' style='visibility: hidden;'>"; |
||
546 | $user_number = 0; |
||
547 | |||
548 | $shared_user = new User(); |
||
549 | foreach($this->cal->shared_ids as $member_id){ |
||
550 | |||
551 | $user_number_str = "_".$user_number; |
||
552 | |||
553 | $shared_user->retrieve($member_id); |
||
554 | $str .= "<div style='clear: both;'></div>"; |
||
555 | $str .= "<div class='monthCalBody'><h5 class='calSharedUser'>".$shared_user->full_name."</h5></div>"; |
||
556 | $str .= "<div user_id='".$member_id."' user_name='".$shared_user->user_name."'>"; |
||
557 | |||
558 | $str .= $this->get_basic_row($week_start_ts,7,$user_number_str); |
||
559 | if(!$basic){ |
||
560 | $str .= $this->get_time_column($week_start_ts); |
||
561 | $str .= "<div class='week'>"; |
||
562 | for($d = 0; $d < 7; $d++){ |
||
563 | $curr_time = $week_start_ts + $d*86400; |
||
564 | $str .= $this->get_day_column($curr_time,$d,$user_number_str); |
||
565 | } |
||
566 | $str .= "</div>"; |
||
567 | $str .= "</div>"; |
||
568 | } |
||
569 | $user_number++; |
||
570 | } |
||
571 | $str .= "</div>"; |
||
572 | |||
573 | return $str; |
||
574 | } |
||
575 | |||
576 | /** |
||
577 | * Get html of year calendar |
||
578 | * @return string |
||
579 | */ |
||
580 | protected function display_year(){ |
||
581 | |||
582 | $weekEnd1 = 0 - $this->startday; |
||
583 | $weekEnd2 = -1 - $this->startday; |
||
584 | if($weekEnd1 < 0) |
||
585 | $weekEnd1 += 7; |
||
586 | if($weekEnd2 < 0) |
||
587 | $weekEnd2 += 7; |
||
588 | |||
589 | $year_start = $GLOBALS['timedate']->fromString($this->cal->date_time->year.'-01-01'); |
||
590 | |||
591 | $str = ""; |
||
592 | $str .= '<table id="daily_cal_table" cellspacing="1" cellpadding="0" border="0" width="100%">'; |
||
593 | |||
594 | for($m = 0; $m < 12; $m++){ |
||
595 | |||
596 | $month_start = $year_start->get("+".$m." months"); |
||
597 | $month_start_ts = $month_start->format('U') + $month_start->getOffset(); |
||
598 | $month_end = $month_start->get("+".$month_start->format('t')." days"); |
||
599 | $week_start = CalendarUtils::get_first_day_of_week($month_start); |
||
600 | $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz |
||
601 | $month_end_ts = $month_end->format('U') + $month_end->getOffset(); |
||
602 | $table_id = "daily_cal_table".$m; //bug 47471 |
||
603 | |||
604 | if($m % 3 == 0) |
||
605 | $str .= "<tr>"; |
||
606 | $str .= '<td class="yearCalBodyMonth" align="center" valign="top" scope="row">'; |
||
607 | $str .= '<a class="yearCalBodyMonthLink" href="'.ajaxLink('index.php?module=Calendar&action=index&view=month&&hour=0&day=1&month='.($m+1).'&year='.$GLOBALS['timedate']->fromTimestamp($month_start_ts)->format('Y')).'">'.$GLOBALS['app_list_strings']['dom_cal_month_long'][$m+1].'</a>'; |
||
608 | $str .= '<table id="'. $table_id. '" cellspacing="1" cellpadding="0" border="0" width="100%">'; |
||
609 | $str .= '<tr class="monthCalBodyTH">'; |
||
610 | for($d = 0; $d < 7; $d++) |
||
611 | $str .= '<th width="14%">'.$this->weekdays[$d].'</th>'; |
||
612 | $str .= '</tr>'; |
||
613 | $curr_time_global = $week_start_ts; |
||
614 | $w = 0; |
||
615 | while($curr_time_global < $month_end_ts){ |
||
616 | $str .= '<tr class="monthViewDayHeight yearViewDayHeight">'; |
||
617 | for($d = 0; $d < 7; $d++){ |
||
618 | $curr_time = $week_start_ts + $d*86400 + $w*60*60*24*7; |
||
619 | |||
620 | if($curr_time < $month_start_ts || $curr_time >= $month_end_ts) |
||
621 | $monC = ""; |
||
622 | else |
||
623 | $monC = '<a href="'.ajaxLink('index.php?module=Calendar&action=index&view=day&hour=0&day='.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('j').'&month='.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('n').'&year='.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('Y')) .'">'.$GLOBALS['timedate']->fromTimestamp($curr_time)->format('j').'</a>'; |
||
624 | |||
625 | if($d == $weekEnd1 || $d == $weekEnd2) |
||
626 | $str .= "<td class='weekEnd monthCalBodyWeekEnd'>"; |
||
627 | else |
||
628 | $str .= "<td class='monthCalBodyWeekDay'>"; |
||
629 | |||
630 | $str .= $monC; |
||
631 | $str .= "</td>"; |
||
632 | } |
||
633 | $str .= "</tr>"; |
||
634 | $curr_time_global += 60*60*24*7; |
||
635 | $w++; |
||
636 | } |
||
637 | $str .= '</table>'; |
||
638 | $str .= '</td>'; |
||
639 | if(($m - 2) % 3 == 0) |
||
640 | $str .= "</tr>"; |
||
641 | } |
||
642 | $str .= "</table>"; |
||
643 | |||
644 | return $str; |
||
645 | } |
||
646 | } |
||
647 | |||
648 | ?> |
||
649 |
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
empty(..)
or! empty(...)
instead.