1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Calendar * |
---|
4 | * http://www.eGroupWare.org * |
---|
5 | * Maintained and further developed by RalfBecker@outdoor-training.de * |
---|
6 | * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> * |
---|
7 | * http://www.radix.net/~cknudsen * |
---|
8 | * Originaly modified by Mark Peters <skeeter@phpgroupware.org> * |
---|
9 | * -------------------------------------------- * |
---|
10 | * This program is free software; you can redistribute it and/or modify it * |
---|
11 | * under the terms of the GNU General Public License as published by the * |
---|
12 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
13 | * option) any later version. * |
---|
14 | \**************************************************************************/ |
---|
15 | |
---|
16 | |
---|
17 | class uicalendar |
---|
18 | { |
---|
19 | var $template; |
---|
20 | var $template_dir; |
---|
21 | |
---|
22 | var $bo; |
---|
23 | var $cat; |
---|
24 | |
---|
25 | var $holidays; |
---|
26 | var $holiday_color; |
---|
27 | |
---|
28 | var $debug = False; |
---|
29 | //var $debug = True; |
---|
30 | |
---|
31 | var $cat_id; |
---|
32 | var $theme; |
---|
33 | var $link_tpl; |
---|
34 | |
---|
35 | // planner related variables |
---|
36 | var $planner_header; |
---|
37 | var $planner_rows; |
---|
38 | |
---|
39 | var $planner_group_members; |
---|
40 | |
---|
41 | var $planner_firstday; |
---|
42 | var $planner_lastday; |
---|
43 | var $planner_days; |
---|
44 | |
---|
45 | var $planner_end_month; |
---|
46 | var $planner_end_year; |
---|
47 | var $planner_days_in_end_month; |
---|
48 | |
---|
49 | var $planner_intervals = array( // conversation hour and interval depending on intervals_per_day |
---|
50 | // 1 1 1 1 1 1 1 1 1 1 2 2 2 2 |
---|
51 | // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 |
---|
52 | '1' => array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), // 0=0-23h |
---|
53 | '2' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0), // 0=0-12h, 1=12-23h |
---|
54 | '3' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2), // 0=0-12h, 2=12-18h, 3=18-23h |
---|
55 | '4' => array(0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3) // 0=0-7, 7-12h, 3=12-18h, 4=18-23h |
---|
56 | ); |
---|
57 | |
---|
58 | var $public_functions = array( |
---|
59 | 'mini_calendar' => True, |
---|
60 | 'index' => True, |
---|
61 | 'month' => True, |
---|
62 | 'get_month' => True, |
---|
63 | 'week' => True, |
---|
64 | 'get_week' => True, |
---|
65 | 'year' => True, |
---|
66 | 'view' => True, |
---|
67 | //'suggest' => True, |
---|
68 | 'send_suggest_owner' => True, |
---|
69 | 'edit' => True, |
---|
70 | 'export' => True, |
---|
71 | 'export_all' => True, |
---|
72 | 'reinstate_list' => True, |
---|
73 | 'reinstate' => True, |
---|
74 | 'add' => True, |
---|
75 | 'delete' => True, |
---|
76 | 'preferences' => True, |
---|
77 | 'day' => True, |
---|
78 | 'edit_status' => True, |
---|
79 | 'set_action' => True, |
---|
80 | 'planner' => True, |
---|
81 | 'modify_ext_partlist' => True, |
---|
82 | 'matrixselect' => True, |
---|
83 | 'viewmatrix' => True, |
---|
84 | 'search' => True, |
---|
85 | 'header' => True, |
---|
86 | 'footer' => True, |
---|
87 | 'css' => True, |
---|
88 | 'accounts_popup' => True, |
---|
89 | 'disponibility' => True |
---|
90 | ); |
---|
91 | |
---|
92 | function uicalendar() |
---|
93 | { |
---|
94 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
95 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
96 | $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar'; |
---|
97 | include_once( dirname(__FILE__).'/../../header.inc.php' ); |
---|
98 | |
---|
99 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
100 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
101 | |
---|
102 | $this->theme = $GLOBALS['phpgw_info']['theme']; |
---|
103 | |
---|
104 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
105 | $this->cat = &$this->bo->cat; |
---|
106 | |
---|
107 | print_debug('BO Owner',$this->bo->owner); |
---|
108 | |
---|
109 | $this->template = $GLOBALS['phpgw']->template; |
---|
110 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
111 | |
---|
112 | $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06']; |
---|
113 | |
---|
114 | $this->cat_id = $this->bo->cat_id; |
---|
115 | |
---|
116 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
117 | $this->link_tpl->set_unknowns('remove'); |
---|
118 | $this->link_tpl->set_file( |
---|
119 | Array( |
---|
120 | 'link_picture' => 'link_pict.tpl' |
---|
121 | ) |
---|
122 | ); |
---|
123 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
124 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
125 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
126 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
127 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
128 | |
---|
129 | /*************** EVENTO **************************/ |
---|
130 | /* Este bloco de codigo foi adicionado pois os eventos de agendamento (exibicao do mes) para impressao serao tratados em outro template |
---|
131 | (event_link.tpl) */ |
---|
132 | |
---|
133 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
134 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
135 | $this->event_tpl->set_unknowns('remove'); |
---|
136 | $this->event_tpl->set_file( |
---|
137 | Array( |
---|
138 | 'link_event' => 'event_link.tpl' |
---|
139 | ) |
---|
140 | ); |
---|
141 | $this->event_tpl->set_block('link_event','link_event_pict','link_event_pict'); |
---|
142 | $this->event_tpl->set_block('link_event','event_pict','event_pict'); |
---|
143 | $this->event_tpl->set_block('link_event','link_event_open','link_event_open'); |
---|
144 | $this->event_tpl->set_block('link_event','link_event_close','link_event_close'); |
---|
145 | $this->event_tpl->set_block('link_event','link_event_text','link_event_text'); |
---|
146 | |
---|
147 | |
---|
148 | /*************************************************/ |
---|
149 | |
---|
150 | if($this->bo->use_session) |
---|
151 | { |
---|
152 | // save return-fkt for add, view, ... |
---|
153 | list(,,$fkt) = explode('.',$_GET['menuaction']); |
---|
154 | if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') |
---|
155 | { |
---|
156 | $this->bo->return_to = $_GET['menuaction']. |
---|
157 | sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); |
---|
158 | } |
---|
159 | $this->bo->save_sessiondata(); |
---|
160 | } |
---|
161 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
162 | |
---|
163 | print_debug('UI',$this->_debug_sqsof()); |
---|
164 | |
---|
165 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
166 | { |
---|
167 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
168 | } |
---|
169 | $this->html = &$GLOBALS['phpgw']->html; |
---|
170 | } |
---|
171 | |
---|
172 | /* Public functions */ |
---|
173 | |
---|
174 | function mini_calendar($params) |
---|
175 | { |
---|
176 | static $mini_cal_tpl; |
---|
177 | if(!is_array($params)) |
---|
178 | { |
---|
179 | return; |
---|
180 | } |
---|
181 | |
---|
182 | if($params['month'] == 0) |
---|
183 | { |
---|
184 | $params['month'] = 12; |
---|
185 | $params['year'] = $params['year'] - 1; |
---|
186 | } |
---|
187 | elseif($params['month'] == 13) |
---|
188 | { |
---|
189 | $params['month'] = 1; |
---|
190 | $params['year'] = $params['year'] + 1; |
---|
191 | } |
---|
192 | |
---|
193 | $this->bo->store_to_cache( |
---|
194 | Array( |
---|
195 | 'smonth' => $params['month'], |
---|
196 | 'sday' => 1, |
---|
197 | 'syear' => $params['year'] |
---|
198 | ) |
---|
199 | ); |
---|
200 | |
---|
201 | $params['link'] = (!isset($params['link'])?'':$params['link']); |
---|
202 | $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); |
---|
203 | $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); |
---|
204 | |
---|
205 | $this->bo->read_holidays($params['year']); |
---|
206 | |
---|
207 | $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); |
---|
208 | $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); |
---|
209 | $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); |
---|
210 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); |
---|
211 | $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); |
---|
212 | |
---|
213 | $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); |
---|
214 | |
---|
215 | print_debug('mini_calendar:monthstart',$monthstart); |
---|
216 | print_debug('mini_calendar:weekstarttime',date('Ymd H:i:s',$weekstarttime)); |
---|
217 | |
---|
218 | if(!is_object($mini_cal_tpl)) |
---|
219 | { |
---|
220 | $mini_cal_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
221 | $mini_cal_tpl->set_unknowns('remove'); |
---|
222 | $mini_cal_tpl->set_file( |
---|
223 | Array( |
---|
224 | 'mini_calendar' => 'mini_cal.tpl' |
---|
225 | ) |
---|
226 | ); |
---|
227 | $mini_cal_tpl->set_block('mini_calendar','mini_cal','mini_cal'); |
---|
228 | $mini_cal_tpl->set_block('mini_calendar','mini_week','mini_week'); |
---|
229 | $mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day'); |
---|
230 | } |
---|
231 | |
---|
232 | |
---|
233 | if($this->bo->printer_friendly == False) |
---|
234 | { |
---|
235 | //NDEE $month = '<a href="' . $this->page('month','&month='.$GLOBALS['phpgw']->common->show_date($date['raw'],'m').'&year='.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y')). '" class="_minicalendar">' . lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>'; |
---|
236 | $month = '<a href="' . $this->page('month','&month='.$GLOBALS['phpgw']->common->show_date($date['raw'],'m').'&year='.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y')). '">' . lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y').'</a>'; |
---|
237 | } |
---|
238 | else |
---|
239 | { |
---|
240 | $month = lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y'); |
---|
241 | } |
---|
242 | |
---|
243 | $var = Array( |
---|
244 | 'cal_img_root' => $GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'), |
---|
245 | 'bgcolor' => $this->theme['bg_color'], |
---|
246 | 'bgcolor1' => $this->theme['bg_color'], |
---|
247 | 'month' => $month, |
---|
248 | 'bgcolor2' => $this->theme['cal_dayview'], |
---|
249 | 'holiday_color' => $this->holiday_color |
---|
250 | ); |
---|
251 | |
---|
252 | $mini_cal_tpl->set_var($var); |
---|
253 | |
---|
254 | switch(strtolower($params['buttons'])) |
---|
255 | { |
---|
256 | case 'right': |
---|
257 | $var = Array( |
---|
258 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
259 | ); |
---|
260 | break; |
---|
261 | case 'left': |
---|
262 | $var = Array( |
---|
263 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>' |
---|
264 | ); |
---|
265 | break; |
---|
266 | case 'both': |
---|
267 | $var = Array( |
---|
268 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>', |
---|
269 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
270 | ); |
---|
271 | break; |
---|
272 | case 'none': |
---|
273 | default: |
---|
274 | $var = Array( |
---|
275 | 'prevmonth' => '', |
---|
276 | 'nextmonth' => '' |
---|
277 | ); |
---|
278 | break; |
---|
279 | } |
---|
280 | $mini_cal_tpl->set_var($var); |
---|
281 | |
---|
282 | if(!$mini_cal_tpl->get_var('daynames')) |
---|
283 | { |
---|
284 | for($i=0;$i<7;++$i) |
---|
285 | { |
---|
286 | $var = Array( |
---|
287 | 'dayname' => '<b>' . lang($GLOBALS['phpgw']->datetime->days_short[$i]) . '</b>', |
---|
288 | 'day_image' => '' |
---|
289 | ); |
---|
290 | $this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var); |
---|
291 | } |
---|
292 | } |
---|
293 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
294 | unset($date); |
---|
295 | for($i=$weekstarttime + $GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) |
---|
296 | { |
---|
297 | unset($var); |
---|
298 | $daily = $this->set_week_array($i - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
299 | foreach($daily as $date => $day_params) |
---|
300 | { |
---|
301 | print_debug('Mini-Cal Date',$date); |
---|
302 | $year = (int)(substr($date,0,4)); |
---|
303 | $month = (int)(substr($date,4,2)); |
---|
304 | $day = (int)(substr($date,6,2)); |
---|
305 | $str = ''; |
---|
306 | if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) |
---|
307 | { |
---|
308 | if(!$this->bo->printer_friendly && $params['link']) |
---|
309 | { |
---|
310 | //NDEE: class def what for? |
---|
311 | $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'">'.$day.'</a>'; |
---|
312 | } |
---|
313 | else |
---|
314 | { |
---|
315 | |
---|
316 | //NDEE: printer-friendly (mini-calendar) |
---|
317 | $str = $day; |
---|
318 | } |
---|
319 | |
---|
320 | } |
---|
321 | else |
---|
322 | { |
---|
323 | $day_params['day_image'] = ''; |
---|
324 | } |
---|
325 | $var[] = Array( |
---|
326 | 'day_image' => $day_params['day_image'], |
---|
327 | 'dayname' => $str |
---|
328 | ); |
---|
329 | } |
---|
330 | $var_count = count($var); |
---|
331 | for($l=0;$l<$var_count;++$l) |
---|
332 | { |
---|
333 | $this->output_template_array($mini_cal_tpl,'monthweek_day','mini_day',$var[$l]); |
---|
334 | } |
---|
335 | $mini_cal_tpl->parse('display_monthweek','mini_week',True); |
---|
336 | $mini_cal_tpl->set_var('dayname',''); |
---|
337 | $mini_cal_tpl->set_var('monthweek_day',''); |
---|
338 | } |
---|
339 | |
---|
340 | $return_value = $mini_cal_tpl->fp('out','mini_cal'); |
---|
341 | $mini_cal_tpl->set_var('display_monthweek',''); |
---|
342 | // $mini_cal_tpl->set_var('daynames',''); |
---|
343 | // unset($p); |
---|
344 | return $return_value; |
---|
345 | } |
---|
346 | |
---|
347 | function index($params='') |
---|
348 | { |
---|
349 | if (!$params) |
---|
350 | { |
---|
351 | foreach(array('date','year','month','day') as $field) |
---|
352 | { |
---|
353 | if (isset($_GET[$field])) |
---|
354 | { |
---|
355 | $params[$field] = $_GET[$field]; |
---|
356 | } |
---|
357 | } |
---|
358 | } |
---|
359 | $GLOBALS['phpgw']->redirect($this->page('',$params)); |
---|
360 | |
---|
361 | } |
---|
362 | |
---|
363 | |
---|
364 | |
---|
365 | // NDEE: printer-friendly |
---|
366 | |
---|
367 | function printer_friendly($body,$app_header='') |
---|
368 | { |
---|
369 | $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
370 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
371 | { |
---|
372 | $_SESSION['calendar']['cals'] = $this->bo->list_cals(); |
---|
373 | } |
---|
374 | |
---|
375 | if($this->bo->printer_friendly || $_GET['plain'] == 'True') |
---|
376 | { |
---|
377 | $new_body = '<html>'."\n" |
---|
378 | .'<head>'."\n" |
---|
379 | .'<SCRIPT type="text/javascript"> |
---|
380 | window.onbeforeunload = function() { |
---|
381 | return \'Gostaria realmente de fechar essa janela ?\'; |
---|
382 | } |
---|
383 | </SCRIPT>' |
---|
384 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app.css" type=text/css rel=StyleSheet>'."\n" |
---|
385 | .'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/app_print.css" type=text/css rel=StyleSheet media="print">'."\n" |
---|
386 | .'</head> |
---|
387 | <table id="calendar_print_main" class="calendar_print_main"> |
---|
388 | <tr> |
---|
389 | <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> |
---|
390 | </tr> |
---|
391 | |
---|
392 | <tr> |
---|
393 | <td> |
---|
394 | <br/> |
---|
395 | <br/> |
---|
396 | <div> |
---|
397 | <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta página"> |
---|
398 | </div> |
---|
399 | </td> |
---|
400 | </tr> |
---|
401 | </table></body>'."\n" |
---|
402 | .'</html>'."\n"; |
---|
403 | //$new_body = utf8_decode($new_body); |
---|
404 | } |
---|
405 | else |
---|
406 | { |
---|
407 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
408 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
409 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
410 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
411 | if ($app_header && $this->always_app_header) |
---|
412 | { |
---|
413 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header; |
---|
414 | } |
---|
415 | |
---|
416 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
417 | |
---|
418 | $new_body = $this->bo->debug_string.$body; |
---|
419 | } |
---|
420 | |
---|
421 | |
---|
422 | |
---|
423 | |
---|
424 | return $new_body; |
---|
425 | } |
---|
426 | |
---|
427 | function month() |
---|
428 | { |
---|
429 | echo $this->printer_friendly($this->get_month(),lang('Monthview')); |
---|
430 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
431 | } |
---|
432 | |
---|
433 | function get_month() |
---|
434 | { |
---|
435 | $this->bo->read_holidays(); |
---|
436 | |
---|
437 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
438 | |
---|
439 | $next = $this->bo->month + 1; |
---|
440 | $prev = $this->bo->month - 1; |
---|
441 | $nextyear = $this->bo->year; |
---|
442 | $prevyear = $this->bo->year; |
---|
443 | if ($this->bo->month == 12) |
---|
444 | { |
---|
445 | $next = 1; |
---|
446 | $nextyear = $nextyear + 1; |
---|
447 | } |
---|
448 | elseif ($this->bo->month == 1) |
---|
449 | { |
---|
450 | $prev = 12; |
---|
451 | $prevyear = $prevyear - 1; |
---|
452 | } |
---|
453 | |
---|
454 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
455 | { |
---|
456 | $minical_prev = $this->mini_calendar( |
---|
457 | Array( |
---|
458 | 'day' => 1, |
---|
459 | 'month' => $this->bo->month - 1, |
---|
460 | 'year' => $this->bo->year, |
---|
461 | 'link' => 'day', |
---|
462 | 'outside_month' => False |
---|
463 | ) |
---|
464 | ); |
---|
465 | |
---|
466 | $minical_next = $this->mini_calendar( |
---|
467 | Array( |
---|
468 | 'day' => 1, |
---|
469 | 'month' => $this->bo->month + 1, |
---|
470 | 'year' => $this->bo->year, |
---|
471 | 'link' => 'day', |
---|
472 | 'outside_month' => False |
---|
473 | ) |
---|
474 | ); |
---|
475 | } |
---|
476 | else |
---|
477 | { |
---|
478 | $minical_prev = ''; |
---|
479 | $minical_next = ''; |
---|
480 | } |
---|
481 | |
---|
482 | if($_POST['year']) { |
---|
483 | |
---|
484 | } |
---|
485 | |
---|
486 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
487 | $mes_hoje = (int)substr($hoje,4,2); |
---|
488 | $sday = 1; |
---|
489 | if($_POST['day']) { |
---|
490 | $day_ini = (int)$_POST['day']; |
---|
491 | } |
---|
492 | elseif($_GET['sday']){ |
---|
493 | if($_GET['month'] == $mes_hoje) |
---|
494 | { |
---|
495 | $day_ini = $this->bo->day; |
---|
496 | } |
---|
497 | |
---|
498 | else |
---|
499 | { |
---|
500 | $day_ini = (int)$_GET['sday']; |
---|
501 | } |
---|
502 | } |
---|
503 | elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) ) |
---|
504 | { |
---|
505 | $day_ini = (int)substr($hoje,6,2); |
---|
506 | } |
---|
507 | else |
---|
508 | { |
---|
509 | $day_ini = $this->bo->day; |
---|
510 | } |
---|
511 | if($_POST['qtd_dias']) |
---|
512 | { |
---|
513 | $num_dias = (int)$_POST['qtd_dias']; |
---|
514 | } |
---|
515 | else |
---|
516 | { |
---|
517 | $num_dias = 0; |
---|
518 | } |
---|
519 | |
---|
520 | if (!$this->bo->printer_friendly) |
---|
521 | { |
---|
522 | $printer = ''; |
---|
523 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
524 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
525 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; |
---|
526 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
527 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param). |
---|
528 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
529 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
530 | //linha abaixo foi adicionada para exibir a pagina do mes em tela |
---|
531 | $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
532 | } |
---|
533 | else |
---|
534 | { |
---|
535 | $printer = '<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">'; |
---|
536 | $prev_month_link = ''; |
---|
537 | $next_month_link = ''; |
---|
538 | $print = ''; |
---|
539 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
540 | //linha abaixo foi adicionada para exibir a pagina do mes para impressao |
---|
541 | $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
542 | } |
---|
543 | |
---|
544 | $this->bo->read_holidays(); |
---|
545 | |
---|
546 | $var = Array( |
---|
547 | 'printer_friendly' => $printer, |
---|
548 | 'bg_text' => $this->theme['bg_text'], |
---|
549 | 'small_calendar_prev' => $minical_prev, |
---|
550 | 'prev_month_link' => $prev_month_link, |
---|
551 | 'month_identifier' => lang(strftime("%B",$m)).' '.$this->bo->year, |
---|
552 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
553 | 'next_month_link' => $next_month_link, |
---|
554 | 'small_calendar_next' => $minical_next, |
---|
555 | //'large_month' => $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), |
---|
556 | 'large_month' => $large_month, |
---|
557 | 'print' => $print |
---|
558 | ); |
---|
559 | |
---|
560 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
561 | $p->set_unknowns('remove'); |
---|
562 | // Alteracao que desvincula o template para tela do template de impressao do mes (month_print teve que ser criado); |
---|
563 | if($print != '') |
---|
564 | { |
---|
565 | $p->set_file( |
---|
566 | Array( |
---|
567 | 'index_t' => 'index.tpl' |
---|
568 | ) |
---|
569 | ); |
---|
570 | }else { |
---|
571 | $p->set_file( |
---|
572 | Array( |
---|
573 | 'index_t' => 'month_print.tpl' |
---|
574 | ) |
---|
575 | ); |
---|
576 | } |
---|
577 | $p->set_var($var); |
---|
578 | return $p->fp('out','index_t'); |
---|
579 | } |
---|
580 | |
---|
581 | function week() |
---|
582 | { |
---|
583 | echo $this->printer_friendly($this->get_week(),lang('Weekview')); |
---|
584 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
585 | } |
---|
586 | |
---|
587 | function get_week() |
---|
588 | { |
---|
589 | $this->bo->read_holidays(); |
---|
590 | |
---|
591 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
592 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
593 | |
---|
594 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
595 | { |
---|
596 | $minical_this = $this->mini_calendar( |
---|
597 | Array( |
---|
598 | 'day' => $this->bo->day, |
---|
599 | 'month' => $this->bo->month, |
---|
600 | 'year' => $this->bo->year, |
---|
601 | 'link' => 'day', |
---|
602 | 'butons' => 'none', |
---|
603 | 'outside_month' => False |
---|
604 | ) |
---|
605 | ); |
---|
606 | $minical_prev = $this->mini_calendar( |
---|
607 | Array( |
---|
608 | 'day' => $this->bo->day, |
---|
609 | 'month' => $this->bo->month - 1, |
---|
610 | 'year' => $this->bo->year, |
---|
611 | 'link' => 'day', |
---|
612 | 'butons' => 'left', |
---|
613 | 'outside_month' => False |
---|
614 | ) |
---|
615 | ); |
---|
616 | $minical_next = $this->mini_calendar( |
---|
617 | Array( |
---|
618 | 'day' => $this->bo->day, |
---|
619 | 'month' => $this->bo->month + 1, |
---|
620 | 'year' => $this->bo->year, |
---|
621 | 'link' => 'day', |
---|
622 | 'butons' => 'right', |
---|
623 | 'outside_month' => False |
---|
624 | ) |
---|
625 | ); |
---|
626 | } |
---|
627 | else |
---|
628 | { |
---|
629 | |
---|
630 | //NDEE: printer-friendly what? |
---|
631 | $minical_this = ''; |
---|
632 | $minical_prev = ''; |
---|
633 | $minical_next = ''; |
---|
634 | } |
---|
635 | |
---|
636 | if (!$this->bo->printer_friendly) |
---|
637 | { |
---|
638 | |
---|
639 | $printer = ''; |
---|
640 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
641 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
642 | $print = '<a href="'.$this->page('week','&friendly=1&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
643 | } |
---|
644 | else |
---|
645 | { |
---|
646 | |
---|
647 | //NDEE: printer-friendly (weekly-view) |
---|
648 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
649 | $prev_week_link = ''; |
---|
650 | $next_week_link = ''; |
---|
651 | $print = ''; |
---|
652 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
653 | } |
---|
654 | |
---|
655 | $var = Array( |
---|
656 | 'printer_friendly' => $print, |
---|
657 | 'bg_text' => $this->theme['bg_text'], |
---|
658 | 'small_calendar_prev' => $minical_prev, |
---|
659 | 'prev_week_link' => $prev_week_link, |
---|
660 | 'small_calendar_this' => $minical_this, |
---|
661 | 'week_identifier' => $this->bo->get_week_label(), |
---|
662 | 'next_week_link' => $next_week_link, |
---|
663 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
664 | 'small_calendar_next' => $minical_next, |
---|
665 | 'week_display' => $this->display_weekly( |
---|
666 | Array( |
---|
667 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
668 | 'showyear' => true, |
---|
669 | 'owners' => $this->bo->owner |
---|
670 | ) |
---|
671 | ), |
---|
672 | 'print' => $print |
---|
673 | ); |
---|
674 | //todo |
---|
675 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
676 | $p->set_file( |
---|
677 | Array( |
---|
678 | 'week_t' => 'week.tpl' |
---|
679 | ) |
---|
680 | ); |
---|
681 | $p->set_var($var); |
---|
682 | return $p->fp('out','week_t'); |
---|
683 | |
---|
684 | } |
---|
685 | |
---|
686 | function year() |
---|
687 | { |
---|
688 | if ($_GET['plain'] == "True") |
---|
689 | { |
---|
690 | |
---|
691 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
692 | } |
---|
693 | else |
---|
694 | { |
---|
695 | |
---|
696 | if($this->bo->printer_friendly) |
---|
697 | { |
---|
698 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
699 | } |
---|
700 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
701 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
702 | } |
---|
703 | } |
---|
704 | |
---|
705 | function get_year() |
---|
706 | { |
---|
707 | if(!$this->bo->printer_friendly) |
---|
708 | { |
---|
709 | $print = ''; |
---|
710 | $left_link = '<a href="'.$this->page('year','&year='.($this->bo->year - 1)).'"><<</a>'; |
---|
711 | $right_link = '<a href="'.$this->page('year','&year='.($this->bo->year + 1)).'">>></a>'; |
---|
712 | $link = 'day'; |
---|
713 | $printer = '<a href="'.$this->page('year','&friendly=1&year='.$this->bo->year).'" target="cal_printer_friendly" onMouseOver="window.status = '."'".lang('Generate printer-friendly version')."'".'">['.lang('Printer Friendly').']</a>'; |
---|
714 | } |
---|
715 | else |
---|
716 | { |
---|
717 | //NDEE: printer-friendly (year-view) |
---|
718 | $print = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
719 | $left_link = ''; |
---|
720 | $right_link = ''; |
---|
721 | $link = ''; |
---|
722 | $printer = ''; |
---|
723 | } |
---|
724 | |
---|
725 | $var = Array( |
---|
726 | 'print' => $print, |
---|
727 | 'left_link' => $left_link, |
---|
728 | 'font' => $this->theme['font'], |
---|
729 | 'year_text' => $this->bo->year, |
---|
730 | 'right_link'=> $right_link, |
---|
731 | 'printer_friendly'=> $printer |
---|
732 | ); |
---|
733 | |
---|
734 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
735 | $p->set_file( |
---|
736 | Array( |
---|
737 | 'year_t' => 'year.tpl' |
---|
738 | ) |
---|
739 | ); |
---|
740 | $p->set_block('year_t','year','year'); |
---|
741 | $p->set_block('year_t','month','month_handle'); |
---|
742 | $p->set_block('year_t','month_sep','month_sep_handle'); |
---|
743 | $p->set_var($var); |
---|
744 | |
---|
745 | for($i=1;$i<=12;++$i) |
---|
746 | { |
---|
747 | if(($i % 3) == 1) |
---|
748 | { |
---|
749 | $p->parse('row','month_sep',True); |
---|
750 | } |
---|
751 | $p->set_var('mini_month',$this->mini_calendar( |
---|
752 | Array( |
---|
753 | 'day' => 1, |
---|
754 | 'month' => $i, |
---|
755 | 'year' => $this->bo->year, |
---|
756 | 'link' => $link, |
---|
757 | 'buttons' => 'none', |
---|
758 | 'outside_month' => False |
---|
759 | ) |
---|
760 | ) |
---|
761 | ); |
---|
762 | $p->parse('row','month',True); |
---|
763 | $p->set_var('mini_month',''); |
---|
764 | } |
---|
765 | return $p->fp('out','year_t'); |
---|
766 | } |
---|
767 | |
---|
768 | function view($vcal_id=0,$cal_date=0) |
---|
769 | { |
---|
770 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
771 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
772 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View'); |
---|
773 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
774 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
775 | |
---|
776 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
777 | |
---|
778 | $date = $cal_date ? $cal_date : 0; |
---|
779 | $date = $date ? $date : (int)$_GET['date']; |
---|
780 | |
---|
781 | // First, make sure they have permission to this entry |
---|
782 | if ($cal_id < 1) |
---|
783 | { |
---|
784 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
785 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
786 | } |
---|
787 | |
---|
788 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) |
---|
789 | { |
---|
790 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
791 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
792 | } |
---|
793 | |
---|
794 | $event = $this->bo->read_entry($cal_id); |
---|
795 | |
---|
796 | if(!isset($event['id'])) |
---|
797 | { |
---|
798 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
799 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
800 | } |
---|
801 | |
---|
802 | $this->bo->repeating_events = Array(); |
---|
803 | $this->bo->cached_events = Array(); |
---|
804 | $this->bo->repeating_events[0] = $event; |
---|
805 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
806 | $this->bo->check_repeating_events($datetime); |
---|
807 | $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); |
---|
808 | if(is_array($this->bo->cached_events[$check_date][0]) && |
---|
809 | $this->bo->cached_events[$check_date][0]['id'] == $event['id']) |
---|
810 | { |
---|
811 | $starttime = $this->bo->maketime($event['start']); |
---|
812 | $endtime = $this->bo->maketime($event['end']); |
---|
813 | $event['start']['month'] = $this->bo->month; |
---|
814 | $event['start']['mday'] = $this->bo->day; |
---|
815 | $event['start']['year'] = $this->bo->year; |
---|
816 | $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); |
---|
817 | $event['end']['month'] = date('m',$temp_end); |
---|
818 | $event['end']['mday'] = date('d',$temp_end); |
---|
819 | $event['end']['year'] = date('Y',$temp_end); |
---|
820 | } |
---|
821 | |
---|
822 | if(!$this->view_event($event,True)) |
---|
823 | { |
---|
824 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
825 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
826 | } |
---|
827 | |
---|
828 | $p = $GLOBALS['phpgw']->template; |
---|
829 | $p->set_file( |
---|
830 | Array( |
---|
831 | 'form_button' => 'form_button_script.tpl' |
---|
832 | ) |
---|
833 | ); |
---|
834 | |
---|
835 | $p->set_file(Array('form_button' => 'form_button_script.tpl' )); |
---|
836 | |
---|
837 | $button_left = $button_center = $button_right = $button_right_suggestion = ''; |
---|
838 | |
---|
839 | if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
840 | { |
---|
841 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
842 | { |
---|
843 | $var = Array( |
---|
844 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
845 | // added date to the action parameteres so we can add an exception to an edited event |
---|
846 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id.'&date='.$date), |
---|
847 | 'action_text_button' => lang('Edit Single'), |
---|
848 | 'action_confirm_button' => '', |
---|
849 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
850 | 'edit_type' => 'single', |
---|
851 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
852 | )) |
---|
853 | ); |
---|
854 | $p->set_var($var); |
---|
855 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
856 | |
---|
857 | $var = Array( |
---|
858 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
859 | 'action_text_button' => lang('Edit Series'), |
---|
860 | 'action_confirm_button' => '', |
---|
861 | 'action_extra_field' => $this->html->input_hidden('edit_type','series') |
---|
862 | ); |
---|
863 | $p->set_var($var); |
---|
864 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
865 | } |
---|
866 | else |
---|
867 | { |
---|
868 | $var = Array( |
---|
869 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
870 | 'action_text_button' => lang('Edit'), |
---|
871 | 'action_confirm_button' => '', |
---|
872 | 'action_extra_field' => '' |
---|
873 | ); |
---|
874 | $p->set_var($var); |
---|
875 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
876 | } |
---|
877 | |
---|
878 | $var = Array( |
---|
879 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
880 | 'action_text_button' => lang('Alarm Management'), |
---|
881 | 'action_confirm_button' => '', |
---|
882 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
883 | 'cal_id' => $cal_id, |
---|
884 | 'return_to' => $this->bo->return_to |
---|
885 | )) |
---|
886 | ); |
---|
887 | $p->set_var($var); |
---|
888 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
889 | } |
---|
890 | |
---|
891 | if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) |
---|
892 | { |
---|
893 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
894 | { |
---|
895 | $var = Array( |
---|
896 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
897 | 'action_text_button' => lang('Delete Single'), |
---|
898 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?\\nThis will delete this entry for all users.')."')\"", |
---|
899 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
900 | 'delete_type' => 'single', |
---|
901 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
902 | )) |
---|
903 | ); |
---|
904 | $p->set_var($var); |
---|
905 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
906 | |
---|
907 | $var = Array( |
---|
908 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
909 | 'action_text_button' => lang('Delete Series'), |
---|
910 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
911 | 'action_extra_field' => $this->html->input_hidden('delete_type','series') |
---|
912 | ); |
---|
913 | $p->set_var($var); |
---|
914 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
915 | |
---|
916 | if($event['recur_exception']) |
---|
917 | { |
---|
918 | $var = Array( |
---|
919 | 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), |
---|
920 | 'action_text_button' => lang('Reinstate'), |
---|
921 | 'action_confirm_button' => '', |
---|
922 | 'action_extra_field' => '' |
---|
923 | ); |
---|
924 | $p->set_var($var); |
---|
925 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
926 | } |
---|
927 | } |
---|
928 | else |
---|
929 | { |
---|
930 | $var = Array( |
---|
931 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
932 | 'action_text_button' => lang('Delete'), |
---|
933 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
934 | 'action_extra_field' => '' |
---|
935 | ); |
---|
936 | $p->set_var($var); |
---|
937 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
938 | } |
---|
939 | } |
---|
940 | else |
---|
941 | { |
---|
942 | // allow me (who I am logged in as) to set up an alarm |
---|
943 | // if I am a participant, but not the owner |
---|
944 | reset($event['participants']); |
---|
945 | while (list($user,$short_status) = each($event['participants'])) |
---|
946 | { |
---|
947 | if ($GLOBALS['phpgw_info']['user']['account_id'] == $user) |
---|
948 | { |
---|
949 | $var = Array( |
---|
950 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
951 | 'action_text_button' => lang('Alarm Management'), |
---|
952 | 'action_confirm_button' => '', |
---|
953 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
954 | 'cal_id' => $cal_id, |
---|
955 | 'return_to' => $this->bo->return_to |
---|
956 | )) |
---|
957 | ); |
---|
958 | $p->set_var($var); |
---|
959 | echo $p->fp('out','form_button'); |
---|
960 | } |
---|
961 | } |
---|
962 | } |
---|
963 | $uid = $event['uid']; |
---|
964 | $owner = $event['owner']; |
---|
965 | $title = $event['title']; |
---|
966 | $description = rtrim(utf8_encode($event['description'])); |
---|
967 | $location = $event['location']; |
---|
968 | $start = $event['start']; |
---|
969 | $end = $event['end']; |
---|
970 | |
---|
971 | $p->set_var( 'suggestion', $this->build_suggestion( $event , $GLOBALS['phpgw_info']['user']['account_id']) ); |
---|
972 | |
---|
973 | $var = Array( |
---|
974 | 'action_url_button' => $this->page('export'), |
---|
975 | 'action_text_button' => lang('Export'), |
---|
976 | 'action_confirm_button' => '', |
---|
977 | 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) |
---|
978 | ); |
---|
979 | $p->set_var($var); |
---|
980 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
981 | |
---|
982 | if ($this->bo->return_to) |
---|
983 | { |
---|
984 | $var = Array( |
---|
985 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
986 | 'action_text_button' => lang('Done'), |
---|
987 | 'action_confirm_button' => '', |
---|
988 | 'action_extra_field' => '' |
---|
989 | ); |
---|
990 | $p->set_var($var); |
---|
991 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
992 | } |
---|
993 | |
---|
994 | if($_SESSION['phpgw_info']['expressomail']['user']['account_id'] != $owner){ |
---|
995 | $label_suggest = lang('Suggest new hour'); |
---|
996 | $button_right_suggestion = "<td><input type=\"button\" style=\"height: 16px; width: 110px; font-size: 10px;\" value=\"" . $label_suggest . "\"onclick=\"show_suggestion()\";</td>"; |
---|
997 | |
---|
998 | $p->set_var(array( |
---|
999 | 'button_left' => $button_left, |
---|
1000 | 'button_center' => $button_center, |
---|
1001 | 'button_right' => $button_right, |
---|
1002 | 'button_right_suggestion' => $button_right_suggestion |
---|
1003 | )); |
---|
1004 | }else{ |
---|
1005 | $p->set_var(array( |
---|
1006 | 'button_left' => $button_left, |
---|
1007 | 'button_center' => $button_center, |
---|
1008 | 'button_right' => $button_right, |
---|
1009 | )); |
---|
1010 | } |
---|
1011 | $p->pfp('phpgw_body','view_event'); |
---|
1012 | |
---|
1013 | $GLOBALS['phpgw']->hooks->process(array( |
---|
1014 | 'location' => 'calendar_view', |
---|
1015 | 'cal_id' => $cal_id |
---|
1016 | )); |
---|
1017 | |
---|
1018 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1019 | } |
---|
1020 | |
---|
1021 | function build_suggestion( $event , $user = false ) |
---|
1022 | { |
---|
1023 | $p = $GLOBALS['phpgw']->template; |
---|
1024 | |
---|
1025 | $p->set_file( |
---|
1026 | Array( |
---|
1027 | 'suggestion' => 'suggestion.tpl' |
---|
1028 | ) |
---|
1029 | ); |
---|
1030 | |
---|
1031 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
1032 | $exParticipants = new exParticipants(); |
---|
1033 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
1034 | |
---|
1035 | $cal_id = $event['id']; |
---|
1036 | $uid = $event['uid']; |
---|
1037 | $owner = $event['owner']; |
---|
1038 | $title = $event['title']; |
---|
1039 | $description = rtrim(utf8_encode($event['description'])); |
---|
1040 | $location = $event['location']; |
---|
1041 | $start = $event['start']; |
---|
1042 | $end = $event['end']; |
---|
1043 | |
---|
1044 | if( $owner == -2 ) |
---|
1045 | { |
---|
1046 | $to = $event['organizer']; |
---|
1047 | $mail = array(); |
---|
1048 | |
---|
1049 | if( preg_match ('(<([^>]*@[^>]*)>)', $to, $mail ) ) |
---|
1050 | $to = $mail[1]; |
---|
1051 | } |
---|
1052 | else |
---|
1053 | { |
---|
1054 | $preferences = CreateObject('phpgwapi.preferences',$owner); |
---|
1055 | $to = $preferences->email_address($owner); |
---|
1056 | } |
---|
1057 | |
---|
1058 | |
---|
1059 | if(((int)$start['month']) < 10 && strlen($start['month']) == 1) |
---|
1060 | $mes = "0" . $start['month']; |
---|
1061 | else |
---|
1062 | $mes = $start['month']; |
---|
1063 | |
---|
1064 | if(((int)$start['mday']) < 10 && strlen($start['mday']) == 1) |
---|
1065 | $dia = "0" . $start['mday']; |
---|
1066 | else |
---|
1067 | $dia = $start['mday']; |
---|
1068 | |
---|
1069 | if(((int)$start['hour']) < 10 && strlen($start['hour']) == 1) |
---|
1070 | $hor = "0" . $start['hour']; |
---|
1071 | else |
---|
1072 | $hor = $start['hour']; |
---|
1073 | |
---|
1074 | if(((int)$start['min']) < 10 && strlen($start['min']) == 1) |
---|
1075 | $min = "0" . $start['min']; |
---|
1076 | else |
---|
1077 | $min = $start['min']; |
---|
1078 | |
---|
1079 | if(((int)$end['month']) < 10 && strlen($end['month']) == 1) |
---|
1080 | $end['month'] = "0" . $end['month']; |
---|
1081 | |
---|
1082 | if(((int)$end['mday']) < 10 && strlen($end['mday']) == 1) |
---|
1083 | $end['mday'] = "0" . $end['mday']; |
---|
1084 | |
---|
1085 | if(((int)$end['hour']) < 10 && strlen($end['hour']) == 1) |
---|
1086 | $end['hour'] = "0" . $end['hour']; |
---|
1087 | |
---|
1088 | if(((int)$end['min']) < 10 && strlen($end['min']) == 1) |
---|
1089 | $end['min'] = "0" . $end['min']; |
---|
1090 | |
---|
1091 | $start_date = $dia . "/" . $mes . "/" . $start['year']; |
---|
1092 | $start_hour = $hor . ":" . $min; |
---|
1093 | $end_date = $end['mday'] . "/" . $mes . "/" . $start['year']; |
---|
1094 | $end_hour = $end['hour'] . ":" . $end['min']; |
---|
1095 | |
---|
1096 | $notify_message = lang('suggest new hour'); |
---|
1097 | $start_h = substr($start_hour, 0, strpos($start_hour, ":")); |
---|
1098 | $start_m = substr($start_hour, strpos($start_hour, ":")+1); |
---|
1099 | $end_h = substr($end_hour, 0, strpos($end_hour, ":")); |
---|
1100 | $end_m = substr($end_hour, strpos($end_hour, ":")+1); |
---|
1101 | |
---|
1102 | $p->set_var('notify_message', $notify_message); |
---|
1103 | $p->set_var('action_form', $this->page('send_suggest_owner')); |
---|
1104 | $p->set_var('lang_start_hour', lang('Start hour')); |
---|
1105 | $p->set_var('lang_end_hour', lang('End hour')); |
---|
1106 | $p->set_var('lang_start_date', lang('Start date')); |
---|
1107 | $p->set_var('lang_end_date', lang('End date')); |
---|
1108 | $p->set_var('lang_suggest_new_hour', lang('Suggest new hour')); |
---|
1109 | $p->set_var('cal_id', $cal_id); |
---|
1110 | $p->set_var('to', $to); |
---|
1111 | $p->set_var('title', $title); |
---|
1112 | $p->set_var('description', $description); |
---|
1113 | $p->set_var('uid', $uid); |
---|
1114 | $p->set_var('location', $location); |
---|
1115 | $p->set_var('ex_participants', $exParticipants->getParticipantsMailsString()); |
---|
1116 | $p->set_var('start_date', $start_date); |
---|
1117 | $p->set_var('start_hour', $start_h); |
---|
1118 | $p->set_var('start_minute', $start_m); |
---|
1119 | $p->set_var('end_date', $end_date); |
---|
1120 | $p->set_var('end_hour', $end_h); |
---|
1121 | $p->set_var('end_minute', $end_m); |
---|
1122 | $p->set_var('url', $GLOBALS['phpgw_info']['server']['webserver_url']); |
---|
1123 | $p->set_var('user', $user); |
---|
1124 | |
---|
1125 | return $p->fp( 'suggestion', 'suggestion' ); |
---|
1126 | } |
---|
1127 | |
---|
1128 | /** |
---|
1129 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
1130 | * @abstract: método que envia a sugestão para o criador do compromisso. |
---|
1131 | * @author Prognus Software Livre (http://www.prognus.com.br) |
---|
1132 | */ |
---|
1133 | function send_suggest_owner() |
---|
1134 | { |
---|
1135 | $array_data_inicio = explode('/',$_POST['data_inicio']); |
---|
1136 | $array_data_final = explode('/',$_POST['data_final']); |
---|
1137 | $hora_inicio = $_POST['hora_inicio']; |
---|
1138 | $minuto_inicio = $_POST['minuto_inicio']; |
---|
1139 | $hora_final = $_POST['hora_final']; |
---|
1140 | $minuto_final = $_POST['minuto_final']; |
---|
1141 | |
---|
1142 | $vars = $_GET['cal_id']; |
---|
1143 | $array_vars = explode(";", $vars); |
---|
1144 | $cal_id = $array_vars[0]; |
---|
1145 | $to = $array_vars[1]; |
---|
1146 | $title_ = $array_vars[2]; |
---|
1147 | $description_ = $array_vars[3]; |
---|
1148 | $uid = $array_vars[4]; |
---|
1149 | $location = $array_vars[5]; |
---|
1150 | $ex_participants = $array_vars[6]; |
---|
1151 | $user = $array_vars[7]; |
---|
1152 | $time_suggest = array('hora_inicio' => $hora_inicio, 'hora_final' => $hora_final, 'minuto_inicio' => $minuto_inicio, 'minuto_final' => $minuto_final); |
---|
1153 | |
---|
1154 | $cal_id = $this->bo->send_suggestion_external_owner($cal_id, $uid, $to, $time_suggest, $array_data_inicio, $array_data_final, $title_, $description_, $location, $ex_participants,$user); |
---|
1155 | |
---|
1156 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
1157 | |
---|
1158 | } |
---|
1159 | |
---|
1160 | |
---|
1161 | function edit($params='') |
---|
1162 | { |
---|
1163 | if($this->debug) |
---|
1164 | { |
---|
1165 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
1166 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
1167 | } |
---|
1168 | |
---|
1169 | if(isset($_GET['readsess'])) |
---|
1170 | { |
---|
1171 | $params['readsess'] = $_GET['readsess']; |
---|
1172 | $params['cd'] = 0; |
---|
1173 | } |
---|
1174 | |
---|
1175 | if($this->debug) |
---|
1176 | { |
---|
1177 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
1178 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
1179 | } |
---|
1180 | |
---|
1181 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
1182 | { |
---|
1183 | $can_edit = True; |
---|
1184 | $this->edit_form( |
---|
1185 | Array( |
---|
1186 | 'event' => $this->bo->restore_from_appsession(), |
---|
1187 | 'cd' => $params['cd'] |
---|
1188 | ) |
---|
1189 | ); |
---|
1190 | } |
---|
1191 | elseif(isset($_GET['cal_id'])) |
---|
1192 | { |
---|
1193 | $cal_id = (int)$_GET['cal_id']; |
---|
1194 | $event = $this->bo->read_entry($cal_id); |
---|
1195 | |
---|
1196 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
1197 | { |
---|
1198 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
1199 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1200 | } |
---|
1201 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
1202 | { |
---|
1203 | $event['id'] = 0; |
---|
1204 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
1205 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
1206 | $event['recur_interval'] = 0; |
---|
1207 | $event['recur_data'] = 0; |
---|
1208 | $event['recur_enddate']['month'] = 0; |
---|
1209 | $event['recur_enddate']['mday'] = 0; |
---|
1210 | $event['recur_enddate']['year'] = 0; |
---|
1211 | $event['recur_exception'] = array(); |
---|
1212 | } |
---|
1213 | $plain = $_GET['plain']; |
---|
1214 | |
---|
1215 | $this->edit_form( |
---|
1216 | Array( |
---|
1217 | 'event' => $event, |
---|
1218 | 'cd' => $cd, |
---|
1219 | 'plain' => $plain, |
---|
1220 | 'date' => $_GET['date'] |
---|
1221 | ) |
---|
1222 | ); |
---|
1223 | } |
---|
1224 | } |
---|
1225 | |
---|
1226 | function export_all() |
---|
1227 | { |
---|
1228 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
1229 | srand((double)microtime()*1000000); |
---|
1230 | $random_number = rand(100000000,999999999); |
---|
1231 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
1232 | $filename = $temp_path . $newfilename; |
---|
1233 | $attach_fd = fopen($filename,"w+"); |
---|
1234 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
1235 | foreach($event_ids as $key => $id) |
---|
1236 | { |
---|
1237 | $event[$key]=$this->bo->read_entry($id); |
---|
1238 | } |
---|
1239 | include_once('class.bocalendar.inc.php'); |
---|
1240 | $cal = new bocalendar; |
---|
1241 | $tmpattach=$cal->create_vcard($event); |
---|
1242 | fwrite($attach_fd,$tmpattach); |
---|
1243 | header ("Content-Type: text/plain"); |
---|
1244 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
1245 | header('Content-Length: ' . filesize($filename)); |
---|
1246 | header("Content-disposition: attachment; filename="."export.ics"); |
---|
1247 | readfile($filename); |
---|
1248 | fclose($attach_fd); |
---|
1249 | } |
---|
1250 | |
---|
1251 | function export($vcal_id=0) |
---|
1252 | { |
---|
1253 | $extern = true; |
---|
1254 | $method = 'PUBLISH'; |
---|
1255 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
1256 | srand((double)microtime()*1000000); |
---|
1257 | $random_number = rand(100000000,999999999); |
---|
1258 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
1259 | $filename = $temp_path . $newfilename; |
---|
1260 | $attach_fd = fopen($filename,"w+"); |
---|
1261 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
1262 | $event[0] = $this->bo->read_entry($cal_id); |
---|
1263 | |
---|
1264 | include_once('class.bocalendar.inc.php'); |
---|
1265 | $cal = new bocalendar; |
---|
1266 | $tmpattach=$cal->create_vcard($event, $method, $extern); |
---|
1267 | fwrite($attach_fd,$tmpattach); |
---|
1268 | header ("Content-Type: text/plain"); |
---|
1269 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
1270 | header('Content-Length: ' . filesize($filename)); |
---|
1271 | header("Content-disposition: attachment; filename="."export.ics"); |
---|
1272 | readfile($filename); |
---|
1273 | fclose($attach_fd); |
---|
1274 | } |
---|
1275 | |
---|
1276 | function reinstate_list($params='') |
---|
1277 | { |
---|
1278 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
1279 | { |
---|
1280 | $this->no_edit(); |
---|
1281 | } |
---|
1282 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1283 | { |
---|
1284 | $this->index(); |
---|
1285 | } |
---|
1286 | |
---|
1287 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1288 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1289 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Reinstate'); |
---|
1290 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1291 | |
---|
1292 | $cal_id = get_var('cal_id',array('GET'),$params['cal_id']); |
---|
1293 | |
---|
1294 | if ($cal_id < 1) |
---|
1295 | { |
---|
1296 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
1297 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1298 | } |
---|
1299 | |
---|
1300 | if(!$this->bo->check_perms(PHPGW_ACL_READ)) |
---|
1301 | { |
---|
1302 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
1303 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1304 | } |
---|
1305 | |
---|
1306 | $event = $this->bo->read_entry($cal_id); |
---|
1307 | |
---|
1308 | if(!isset($event['id'])) |
---|
1309 | { |
---|
1310 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
1311 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1312 | } |
---|
1313 | elseif(!isset($event['recur_exception'])) |
---|
1314 | { |
---|
1315 | echo '<center>'.lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n"; |
---|
1316 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1317 | } |
---|
1318 | |
---|
1319 | if(!$this->view_event($event,True)) |
---|
1320 | { |
---|
1321 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
1322 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1323 | } |
---|
1324 | |
---|
1325 | $p = &$GLOBALS['phpgw']->template; |
---|
1326 | $p->set_file( |
---|
1327 | Array( |
---|
1328 | 'form_button' => 'form_button_script.tpl' |
---|
1329 | ) |
---|
1330 | ); |
---|
1331 | |
---|
1332 | $str = ''; |
---|
1333 | |
---|
1334 | $event_count = count($event['recur_exception']); |
---|
1335 | for($i=0;$i<$event_count;++$i) |
---|
1336 | { |
---|
1337 | $str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n"; |
---|
1338 | } |
---|
1339 | $this->output_template_array($p,'row','list',array( |
---|
1340 | 'field' => lang('Exceptions'), |
---|
1341 | 'data' => '<select name="reinstate_index[]" multiple size="5">'."\n".$str.'</select>' |
---|
1342 | )); |
---|
1343 | |
---|
1344 | $var = Array( |
---|
1345 | 'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id), |
---|
1346 | 'action_text_button' => lang('Reinstate'), |
---|
1347 | 'action_confirm_button' => '', |
---|
1348 | 'action_extra_field' => '' |
---|
1349 | ); |
---|
1350 | $p->set_var($var); |
---|
1351 | $button_left = '<td>'.$p->fp('out','form_button').'</td>'; |
---|
1352 | |
---|
1353 | $var = Array( |
---|
1354 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
1355 | 'action_text_button' => lang('Cancel'), |
---|
1356 | 'action_confirm_button' => '', |
---|
1357 | 'action_extra_field' => '' |
---|
1358 | ); |
---|
1359 | $p->set_var($var); |
---|
1360 | $button_left .= '<td>'.$p->fp('out','form_button').'</td>'; |
---|
1361 | |
---|
1362 | $p->set_var('button_left',$button_left); |
---|
1363 | $p->pfp('phpgw_body','view_event'); |
---|
1364 | } |
---|
1365 | |
---|
1366 | function reinstate($params='') |
---|
1367 | { |
---|
1368 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
1369 | { |
---|
1370 | $this->no_edit(); |
---|
1371 | } |
---|
1372 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1373 | { |
---|
1374 | $this->index(); |
---|
1375 | } |
---|
1376 | $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : ''); |
---|
1377 | $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id); |
---|
1378 | |
---|
1379 | $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : ''); |
---|
1380 | $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index); |
---|
1381 | if($this->debug) |
---|
1382 | { |
---|
1383 | echo '<!-- Calling bo->reinstate -->'."\n"; |
---|
1384 | } |
---|
1385 | $cd = $this->bo->reinstate( |
---|
1386 | Array( |
---|
1387 | 'cal_id' => $cal_id, |
---|
1388 | 'reinstate_index' => $reinstate_index |
---|
1389 | ) |
---|
1390 | ); |
---|
1391 | if($this->debug) |
---|
1392 | { |
---|
1393 | echo '<!-- Return Value = '.$cd.' -->'."\n"; |
---|
1394 | } |
---|
1395 | if ($this->bo->return_to) |
---|
1396 | { |
---|
1397 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
1398 | } |
---|
1399 | else |
---|
1400 | { |
---|
1401 | Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); |
---|
1402 | } |
---|
1403 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1404 | } |
---|
1405 | |
---|
1406 | function add($cd=0,$readsess=0) |
---|
1407 | { |
---|
1408 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1409 | { |
---|
1410 | $this->index(); |
---|
1411 | } |
---|
1412 | |
---|
1413 | if($readsess) |
---|
1414 | { |
---|
1415 | $event = $this->bo->restore_from_appsession; |
---|
1416 | if(!$event['owner']) |
---|
1417 | { |
---|
1418 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
1419 | } |
---|
1420 | $can_edit = True; |
---|
1421 | } |
---|
1422 | else |
---|
1423 | { |
---|
1424 | $this->bo->event_init(); |
---|
1425 | $this->bo->add_attribute('id',0); |
---|
1426 | |
---|
1427 | $can_edit = True; |
---|
1428 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
1429 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
1430 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
1431 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
1432 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
1433 | |
---|
1434 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
1435 | if ($subject != '0') |
---|
1436 | { |
---|
1437 | $description = (string)(get_var('description',array('GET'),0)); |
---|
1438 | $location = (string)(get_var('location',array('GET'),0)); |
---|
1439 | } |
---|
1440 | else |
---|
1441 | unset($subject); |
---|
1442 | |
---|
1443 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
1444 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
1445 | $this->bo->set_title($subject); |
---|
1446 | $this->bo->set_description($description); |
---|
1447 | $this->bo->add_attribute('location',$location); |
---|
1448 | $this->bo->set_ex_participants(''); |
---|
1449 | $this->bo->add_attribute('uid',''); |
---|
1450 | $this->bo->add_attribute('priority',2); |
---|
1451 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
1452 | { |
---|
1453 | $this->bo->set_class(False); |
---|
1454 | } |
---|
1455 | else |
---|
1456 | { |
---|
1457 | $this->bo->set_class(True); |
---|
1458 | } |
---|
1459 | // Add participants |
---|
1460 | $participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); |
---|
1461 | $participants_count = count($participants); |
---|
1462 | for($_f_part=0; $_f_part<$participants_count; ++$_f_part) |
---|
1463 | { |
---|
1464 | $this->bo->add_attribute('participants','A',$participants[$_f_part]); |
---|
1465 | } |
---|
1466 | // Add misc |
---|
1467 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
1468 | $this->bo->set_recur_none(); |
---|
1469 | $event = $this->bo->get_cached_event(); |
---|
1470 | |
---|
1471 | } |
---|
1472 | $this->edit_form( |
---|
1473 | Array( |
---|
1474 | 'event' => $event, |
---|
1475 | 'cd' => $cd, |
---|
1476 | 'plain' => $_GET['plain'] |
---|
1477 | ) |
---|
1478 | ); |
---|
1479 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1480 | } |
---|
1481 | |
---|
1482 | function delete() |
---|
1483 | { |
---|
1484 | if(!isset($_GET['cal_id'])) |
---|
1485 | { |
---|
1486 | Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); |
---|
1487 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1488 | } |
---|
1489 | |
---|
1490 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); |
---|
1491 | if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id'])) |
---|
1492 | { |
---|
1493 | if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') |
---|
1494 | { |
---|
1495 | $date = $_POST['date']; |
---|
1496 | $cd = $this->bo->delete_single( |
---|
1497 | Array( |
---|
1498 | 'id' => $cal_id, |
---|
1499 | 'year' => substr($date,0,4), |
---|
1500 | 'month' => substr($date,4,2), |
---|
1501 | 'day' => substr($date,6,2) |
---|
1502 | ) |
---|
1503 | ); |
---|
1504 | } |
---|
1505 | elseif((isset($_POST['delete_type']) && $_POST['delete_type'] == 'series') || !isset($_POST['delete_type'])) |
---|
1506 | { |
---|
1507 | $cd = $this->bo->delete_entry($cal_id); |
---|
1508 | $this->bo->expunge(); |
---|
1509 | } |
---|
1510 | } |
---|
1511 | else |
---|
1512 | { |
---|
1513 | $cd = ''; |
---|
1514 | } |
---|
1515 | if ($this->bo->return_to) |
---|
1516 | { |
---|
1517 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
1518 | } |
---|
1519 | else |
---|
1520 | { |
---|
1521 | Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); |
---|
1522 | } |
---|
1523 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1524 | } |
---|
1525 | |
---|
1526 | |
---|
1527 | |
---|
1528 | function getLdap() |
---|
1529 | { |
---|
1530 | include_once('../phpgwapi/inc/class.common.inc.php'); |
---|
1531 | $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; |
---|
1532 | $common = new common(); |
---|
1533 | |
---|
1534 | if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && |
---|
1535 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && |
---|
1536 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) |
---|
1537 | { |
---|
1538 | $ldap = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], |
---|
1539 | $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], |
---|
1540 | $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); |
---|
1541 | } |
---|
1542 | else |
---|
1543 | { |
---|
1544 | $ldap = $common->ldapConnect(); |
---|
1545 | } |
---|
1546 | |
---|
1547 | return $ldap; |
---|
1548 | } |
---|
1549 | |
---|
1550 | |
---|
1551 | |
---|
1552 | function disponibility($params) { |
---|
1553 | |
---|
1554 | if(!isset($_SESSION['phpgw_info']['expresso']['expressoAdmin'])) { |
---|
1555 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
1556 | $c->read_repository(); |
---|
1557 | $current_config = $c->config_data; |
---|
1558 | |
---|
1559 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
1560 | |
---|
1561 | $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
1562 | $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
1563 | $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
1564 | $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; |
---|
1565 | $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; |
---|
1566 | $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; |
---|
1567 | } |
---|
1568 | $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma |
---|
1569 | $participants= array(); |
---|
1570 | $participants_splited = explode(",",$str_participants); |
---|
1571 | |
---|
1572 | |
---|
1573 | $ldap = $this->getLdap(); |
---|
1574 | foreach ($participants_splited as $participant) |
---|
1575 | { |
---|
1576 | $participant = substr($participant,0,strlen($participant)-1); |
---|
1577 | |
---|
1578 | $entry = array(); |
---|
1579 | $extern_contact = false; |
---|
1580 | |
---|
1581 | $justthese = array('accountStatus'); |
---|
1582 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uidNumber=".(int)$participant."))"; |
---|
1583 | $search = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); |
---|
1584 | $entry = ldap_get_entries($ldap, $search); |
---|
1585 | |
---|
1586 | if($entry[0]['accountstatus'][0] == "false") |
---|
1587 | $extern_contact = true; |
---|
1588 | |
---|
1589 | |
---|
1590 | $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); |
---|
1591 | |
---|
1592 | if($acct_type=='g') { |
---|
1593 | $bo_groups = CreateObject('expressoAdmin1_2.group'); |
---|
1594 | $users = $bo_groups->get_info($participant); |
---|
1595 | foreach($users['memberuid_info'] as $user) { |
---|
1596 | if($user['type']==u){ |
---|
1597 | if (!$user['uidnumber']){ |
---|
1598 | continue; |
---|
1599 | } |
---|
1600 | $participants[$user['uidnumber']] = 'U'; |
---|
1601 | } |
---|
1602 | } |
---|
1603 | } |
---|
1604 | else |
---|
1605 | { |
---|
1606 | if($extern_contact) |
---|
1607 | { |
---|
1608 | $participants[$participant] = 'I'; |
---|
1609 | continue; |
---|
1610 | } |
---|
1611 | |
---|
1612 | if (!$participant) |
---|
1613 | continue; |
---|
1614 | |
---|
1615 | $participants[$participant] = 'U'; |
---|
1616 | } |
---|
1617 | } |
---|
1618 | |
---|
1619 | $date = explode("/",$_GET['date']); |
---|
1620 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$date[1],$date[0],$date[2]) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
1621 | |
---|
1622 | echo $this->print_disponibility( |
---|
1623 | Array( |
---|
1624 | 'date' => $freetime, |
---|
1625 | 'starttime' => $this->bo->splittime('000000',False), |
---|
1626 | 'endtime' => 0, |
---|
1627 | 'participants' => $participants |
---|
1628 | ) |
---|
1629 | ); |
---|
1630 | |
---|
1631 | |
---|
1632 | } |
---|
1633 | |
---|
1634 | function print_disponibility($param) { |
---|
1635 | |
---|
1636 | $str = "<html><head> |
---|
1637 | <script type='text/javascript'> |
---|
1638 | |
---|
1639 | var start = null; |
---|
1640 | var end = null; |
---|
1641 | function set_time(hour,minute) { |
---|
1642 | //alert(start); |
---|
1643 | if(start == null) { |
---|
1644 | start = new Array(); |
---|
1645 | start[0] = hour; |
---|
1646 | start[1] = minute; |
---|
1647 | paint_interval(start,start,'#009ACD',true); |
---|
1648 | } |
---|
1649 | else if (end == null) { |
---|
1650 | end = new Array(); |
---|
1651 | end[0] = hour; |
---|
1652 | end[1] = minute; |
---|
1653 | if(is_lower(start,end)) |
---|
1654 | paint_interval(start,end,'#009ACD',true); |
---|
1655 | else { |
---|
1656 | paint_interval(end,start,'#009ACD',true); |
---|
1657 | temp = start; |
---|
1658 | start = end; |
---|
1659 | end = temp; |
---|
1660 | paint_interval(end,end,'#FFFFFF',false); |
---|
1661 | } |
---|
1662 | parent.document.getElementById('start_hour').value=start[0]; |
---|
1663 | parent.document.getElementById('start_minute').value=start[1]; |
---|
1664 | parent.document.getElementById('end_hour').value=end[0]; |
---|
1665 | parent.document.getElementById('end_minute').value=end[1]; |
---|
1666 | |
---|
1667 | } |
---|
1668 | else { |
---|
1669 | end = null; |
---|
1670 | start = new Array(); |
---|
1671 | start[0] = hour; |
---|
1672 | start[1] = minute; |
---|
1673 | repaint(); |
---|
1674 | |
---|
1675 | paint_interval(start,start,'#009ACD',true); |
---|
1676 | } |
---|
1677 | } |
---|
1678 | function paint_column(name_array,color,force) { |
---|
1679 | name = name_array[0]+'-'+name_array[1]; |
---|
1680 | if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {//firefox |
---|
1681 | for(var i in document.getElementsByName(name)) { |
---|
1682 | document.getElementsByName(name)[i].bgColor=color; |
---|
1683 | if(document.getElementsByName(name)[i].nodeType==1) { |
---|
1684 | if(document.getElementsByName(name)[i].innerHTML.indexOf('>-<')==-1 || force==true) |
---|
1685 | document.getElementsByName(name)[i].bgColor=color; |
---|
1686 | else |
---|
1687 | document.getElementsByName(name)[i].bgColor='".$this->theme['bg11']."'; |
---|
1688 | } |
---|
1689 | } |
---|
1690 | } |
---|
1691 | else {//I.E |
---|
1692 | cells = document.getElementsByTagName('td'); |
---|
1693 | for(var i=0;i<cells.length;i++) { |
---|
1694 | if(cells.item(i).name==name) { //getElementsByName in I.E is bugged |
---|
1695 | cells.item(i).bgColor=color; |
---|
1696 | if(cells.item(i).nodeType==1) { |
---|
1697 | if(cells.item(i).innerHTML.indexOf('>-<')==-1 || force==true) |
---|
1698 | cells.item(i).bgColor=color; |
---|
1699 | else |
---|
1700 | cells.item(i).bgColor='".$this->theme['bg11']."'; |
---|
1701 | } |
---|
1702 | } |
---|
1703 | } |
---|
1704 | } |
---|
1705 | } |
---|
1706 | |
---|
1707 | function repaint() { |
---|
1708 | temp_start = new Array(); |
---|
1709 | temp_start[0] = 8; |
---|
1710 | temp_start[1] = 0; |
---|
1711 | temp_end = new Array(); |
---|
1712 | temp_end[0] = 19; |
---|
1713 | temp_end[1] = 0; |
---|
1714 | paint_interval(temp_start,temp_end,'#FFFFFF',false); |
---|
1715 | } |
---|
1716 | |
---|
1717 | //Considera sempre name1 <= name2 |
---|
1718 | function paint_interval(name1,name2,color,force) { |
---|
1719 | paint_column(name1,color,force); |
---|
1720 | if(name1[0]!=name2[0] || name1[1]!=name2[1]) { |
---|
1721 | paint_column(name1,color,force); |
---|
1722 | tempHour = name1[0]; |
---|
1723 | tempMinute = name1[1]; |
---|
1724 | while(tempHour<name2[0]) { |
---|
1725 | if(tempHour==name1[0] && tempMinute!=0) |
---|
1726 | temp_start = tempMinute/30; |
---|
1727 | else |
---|
1728 | temp_start = 0; |
---|
1729 | for(i=temp_start;i<60/30;i++) { |
---|
1730 | temp_column = new Array(); |
---|
1731 | temp_column[0] = tempHour; |
---|
1732 | temp_column[1] = i*30; |
---|
1733 | paint_column(temp_column,color,force); |
---|
1734 | } |
---|
1735 | tempHour++; |
---|
1736 | } |
---|
1737 | for(i=0;i<name2[1];i+=30) { |
---|
1738 | temp_column = new Array(); |
---|
1739 | temp_column[0] = name2[0]; |
---|
1740 | temp_column[1] = i; |
---|
1741 | paint_column(temp_column,color,force); |
---|
1742 | } |
---|
1743 | } |
---|
1744 | } |
---|
1745 | |
---|
1746 | function is_lower(array1,array2) { |
---|
1747 | if(array1[0]<array2[0]) |
---|
1748 | return true; |
---|
1749 | else if(array1[0]>array2[0]) |
---|
1750 | return false; |
---|
1751 | else { |
---|
1752 | if(array1[1]<array2[1]) |
---|
1753 | return true; |
---|
1754 | else |
---|
1755 | return false; |
---|
1756 | } |
---|
1757 | } |
---|
1758 | </script></head><body> |
---|
1759 | "; |
---|
1760 | |
---|
1761 | $extra_ = ""; |
---|
1762 | |
---|
1763 | $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; |
---|
1764 | |
---|
1765 | |
---|
1766 | if(!is_array($param)) |
---|
1767 | { |
---|
1768 | $this->index(); |
---|
1769 | } |
---|
1770 | |
---|
1771 | $date = $param['date']; |
---|
1772 | $starttime = $param['starttime']; |
---|
1773 | $endtime = $param['endtime']; |
---|
1774 | $participants = $param['participants']; |
---|
1775 | foreach($participants as $part => $nul) |
---|
1776 | { |
---|
1777 | $extra_ = ""; |
---|
1778 | |
---|
1779 | if($nul == 'I') |
---|
1780 | $extra_ = "(externalI)"; |
---|
1781 | |
---|
1782 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
1783 | $participants[$part].= $extra_; |
---|
1784 | // Much better for processor :) |
---|
1785 | $participants_id[] .= $part; |
---|
1786 | } |
---|
1787 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
1788 | |
---|
1789 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
1790 | { |
---|
1791 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
1792 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
1793 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
1794 | } |
---|
1795 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
1796 | $interval = (int)(60 / $increment); |
---|
1797 | |
---|
1798 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
1799 | |
---|
1800 | $str .= '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
1801 | . ', '.$this->bo->long_date($date).'<br>' |
---|
1802 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((10 * $interval) + 1).'">' |
---|
1803 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
1804 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
1805 | for($i=8;$i<19;++$i) |
---|
1806 | { |
---|
1807 | for($j=0;$j<$interval;++$j) |
---|
1808 | { |
---|
1809 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
1810 | |
---|
1811 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'" onclick="set_time('.$i.','.($j*$increment).')" style="cursor:hand;cursor:pointer"> |
---|
1812 | <font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' . $k." </font></td>\n"; |
---|
1813 | } |
---|
1814 | } |
---|
1815 | $str .= '</tr>' |
---|
1816 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
1817 | if(!$endtime) |
---|
1818 | { |
---|
1819 | $endtime = $starttime; |
---|
1820 | } |
---|
1821 | $owner = $this->bo->owner; |
---|
1822 | foreach($participants as $part => $fullname) |
---|
1823 | { |
---|
1824 | $external = false; |
---|
1825 | if(strpos($fullname,"(externalI)")) |
---|
1826 | { |
---|
1827 | $tmp_name = str_replace("(externalI)","",$fullname); |
---|
1828 | $fullname = $tmp_name; |
---|
1829 | $external = true; |
---|
1830 | } |
---|
1831 | |
---|
1832 | $str .= '<tr align="center">' |
---|
1833 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
1834 | |
---|
1835 | $this->bo->cached_events = Array(); |
---|
1836 | $this->bo->so->owner = $part; |
---|
1837 | $this->bo->so->open_box($part); |
---|
1838 | $this->bo->store_to_cache( |
---|
1839 | Array( |
---|
1840 | 'syear' => $date['year'], |
---|
1841 | 'smonth'=> $date['month'], |
---|
1842 | 'sday' => $date['day'], |
---|
1843 | 'eyear' => 0, |
---|
1844 | 'emonth'=> 0, |
---|
1845 | 'eday' => $date['day'] + 1 |
---|
1846 | ) |
---|
1847 | ); |
---|
1848 | |
---|
1849 | if($external) |
---|
1850 | { |
---|
1851 | $str .= '<td height="1" align="center" colspan="22" bgcolor="'.$this->theme['bg_color'].'" color="#999999">' .lang('Agenda not available') .'</td>'; |
---|
1852 | $str .= '</tr>' |
---|
1853 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
1854 | continue; |
---|
1855 | } |
---|
1856 | |
---|
1857 | if(!$this->bo->cached_events[$date['full']]) |
---|
1858 | { |
---|
1859 | for($j=8;$j<19;++$j) |
---|
1860 | { |
---|
1861 | for($k=0;$k<$interval;++$k) |
---|
1862 | { |
---|
1863 | // $helper_name = $k* |
---|
1864 | $str .= '<td name="'.$j.'-'.($k*$increment).'" height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
1865 | } |
---|
1866 | $str .= "\n"; |
---|
1867 | } |
---|
1868 | } |
---|
1869 | else |
---|
1870 | { |
---|
1871 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
1872 | for($h=8;$h<19;++$h) |
---|
1873 | { |
---|
1874 | $hour = $h * 10000; |
---|
1875 | for($m=0;$m<$interval;++$m) |
---|
1876 | { |
---|
1877 | $index = ($hour + (($m * $increment) * 100)); |
---|
1878 | switch($time_slice[$index]['marker']) |
---|
1879 | { |
---|
1880 | case ' ': |
---|
1881 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
1882 | //$extra = ''; |
---|
1883 | break; |
---|
1884 | case '-': |
---|
1885 | $time_slice[$index]['marker'] = "#"; |
---|
1886 | $time_slice[$index]['color'] = $this->theme['bg11']; |
---|
1887 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
1888 | //$extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
1889 | break; |
---|
1890 | } |
---|
1891 | $str .= '<td name="'.$h.'-'.($m*$increment).'" bgcolor="'.$time_slice[$index]['color'].'" color="#999999"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$time_slice[$index]['marker'].'</font></td>'; |
---|
1892 | } |
---|
1893 | $str .= "\n"; |
---|
1894 | } |
---|
1895 | } |
---|
1896 | $str .= '</tr>' |
---|
1897 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
1898 | } |
---|
1899 | $this->bo->owner = $owner; |
---|
1900 | $this->bo->so->owner = $owner; |
---|
1901 | $this->bo->so->open_box($owner); |
---|
1902 | $str.= "</table></center> \n </td></tr> |
---|
1903 | <tr><td onclick=\"parent.document.getElementById('disponibility').style.display='none'\" style='cursor:hand;cursor:pointer' align='center'>Fechar mapa</td></tr> |
---|
1904 | </table></body>"; |
---|
1905 | return $str; |
---|
1906 | } |
---|
1907 | |
---|
1908 | function day() |
---|
1909 | { |
---|
1910 | |
---|
1911 | $this->bo->read_holidays(); |
---|
1912 | |
---|
1913 | if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) |
---|
1914 | { |
---|
1915 | $minical = $this->mini_calendar( |
---|
1916 | Array( |
---|
1917 | 'day' => $this->bo->day, |
---|
1918 | 'month' => $this->bo->month, |
---|
1919 | 'year' => $this->bo->year, |
---|
1920 | 'link' => 'day' |
---|
1921 | ) |
---|
1922 | ); |
---|
1923 | } |
---|
1924 | else |
---|
1925 | { |
---|
1926 | |
---|
1927 | //NDEE: printer-friendly (what?) |
---|
1928 | $minical = ''; |
---|
1929 | } |
---|
1930 | |
---|
1931 | if (!$this->bo->printer_friendly) |
---|
1932 | { |
---|
1933 | $printer = ''; |
---|
1934 | $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; |
---|
1935 | // $print = '<a href="'.$this->page('day'.$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
1936 | |
---|
1937 | //Adiciona modo que o mesmo abra uma nova janela nos navegadores IE e FF |
---|
1938 | $print = "<a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('day'.$param). |
---|
1939 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
1940 | lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
1941 | |
---|
1942 | } |
---|
1943 | else |
---|
1944 | { |
---|
1945 | |
---|
1946 | //NDEE: printer-friendly (daily-view) |
---|
1947 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
1948 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
1949 | $print = ''; |
---|
1950 | } |
---|
1951 | |
---|
1952 | $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); |
---|
1953 | $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1954 | |
---|
1955 | $p = $GLOBALS['phpgw']->template; |
---|
1956 | $p->set_file( |
---|
1957 | Array( |
---|
1958 | 'day_t' => 'day.tpl' |
---|
1959 | ) |
---|
1960 | ); |
---|
1961 | $p->set_block('day_t','day','day'); |
---|
1962 | $p->set_block('day_t','day_event','day_event'); |
---|
1963 | |
---|
1964 | $todos = $this->get_todos($todo_label); |
---|
1965 | $var = Array( |
---|
1966 | 'printer_friendly' => $printer, |
---|
1967 | 'bg_text' => $this->theme['bg_text'], |
---|
1968 | 'daily_events' => $this->print_day( |
---|
1969 | Array( |
---|
1970 | 'year' => $this->bo->year, |
---|
1971 | 'month' => $this->bo->month, |
---|
1972 | 'day' => $this->bo->day |
---|
1973 | ) |
---|
1974 | ), |
---|
1975 | 'small_calendar' => $minical, |
---|
1976 | 'date' => $this->bo->long_date($now), |
---|
1977 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
1978 | 'print' => $print, |
---|
1979 | 'lang_todos' => $todo_label, |
---|
1980 | 'todos' => $this->bo->printer_friendly ? $todos : |
---|
1981 | |
---|
1982 | //NDEE: todo's layout |
---|
1983 | "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" |
---|
1984 | ); |
---|
1985 | |
---|
1986 | $p->set_var($var); |
---|
1987 | $p->parse('day_events','day_event'); |
---|
1988 | print $this->printer_friendly($p->fp('out','day'),lang('Dayview')); |
---|
1989 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1990 | } |
---|
1991 | |
---|
1992 | function get_todos(&$todo_label) |
---|
1993 | { |
---|
1994 | $todos_from_hook = $GLOBALS['phpgw']->hooks->process(array( |
---|
1995 | 'location' => 'calendar_include_todos', |
---|
1996 | 'year' => $this->bo->year, |
---|
1997 | 'month' => $this->bo->month, |
---|
1998 | 'day' => $this->bo->day, |
---|
1999 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
2000 | )); |
---|
2001 | |
---|
2002 | if(is_array($todo_label)) |
---|
2003 | { |
---|
2004 | list($label,$showall)=$todo_label; |
---|
2005 | } |
---|
2006 | else |
---|
2007 | { |
---|
2008 | $label=$todo_label; |
---|
2009 | $showall=true; |
---|
2010 | } |
---|
2011 | $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
---|
2012 | if($maxshow<=0) |
---|
2013 | { |
---|
2014 | $maxshow=10; |
---|
2015 | } |
---|
2016 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
---|
2017 | |
---|
2018 | $content = $todo_label = ''; |
---|
2019 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
---|
2020 | { |
---|
2021 | $todo_label = !empty($label)?$label:lang("open ToDo's:"); |
---|
2022 | |
---|
2023 | foreach($todos_from_hook as $todos) |
---|
2024 | { |
---|
2025 | $i = 0; |
---|
2026 | if (is_array($todos) && count($todos)) |
---|
2027 | { |
---|
2028 | foreach($todos as $todo) |
---|
2029 | { |
---|
2030 | if(!$showall && ($i++>$maxshow)) |
---|
2031 | { |
---|
2032 | break; |
---|
2033 | } |
---|
2034 | $icons = ''; |
---|
2035 | foreach($todo['icons'] as $name => $app) |
---|
2036 | { |
---|
2037 | $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); |
---|
2038 | } |
---|
2039 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
---|
2040 | |
---|
2041 | //NDEE <tr starts here |
---|
2042 | $content .= " <tr id=\"debug\" class=\"$class\">\n <td valign=\"top\" width=\"15%\"nowrap>". |
---|
2043 | ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). |
---|
2044 | "</td>\n <td>".($this->bo->printer_friendly?$todo['title']: |
---|
2045 | $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."</td>\n </tr>\n"; |
---|
2046 | } |
---|
2047 | } |
---|
2048 | } |
---|
2049 | } |
---|
2050 | if (!empty($content)) |
---|
2051 | { |
---|
2052 | return "<table border=\"0\" width=\"100%\">\n$content</table>\n"; |
---|
2053 | } |
---|
2054 | return False; |
---|
2055 | } |
---|
2056 | |
---|
2057 | function edit_status() |
---|
2058 | { |
---|
2059 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2060 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2061 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
2062 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
2063 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status'); |
---|
2064 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2065 | |
---|
2066 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
2067 | |
---|
2068 | reset($event['participants']); |
---|
2069 | |
---|
2070 | if(!$event['participants'][$this->bo->owner]) |
---|
2071 | { |
---|
2072 | echo '<center>'.lang('The user %1 is not participating in this event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>'; |
---|
2073 | return; |
---|
2074 | } |
---|
2075 | |
---|
2076 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
2077 | { |
---|
2078 | $this->no_edit(); |
---|
2079 | return; |
---|
2080 | } |
---|
2081 | |
---|
2082 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
2083 | echo $this->timematrix( |
---|
2084 | Array( |
---|
2085 | 'date' => $freetime, |
---|
2086 | 'starttime' => $this->bo->splittime('000000',False), |
---|
2087 | 'endtime' => 0, |
---|
2088 | 'participants' => $event['participants'] |
---|
2089 | ) |
---|
2090 | ).'<br>'; |
---|
2091 | |
---|
2092 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
2093 | $this->view_event($event); |
---|
2094 | $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event'); |
---|
2095 | |
---|
2096 | echo $this->get_response($event['id']); |
---|
2097 | } |
---|
2098 | |
---|
2099 | function confirm_action($duplicated_action) |
---|
2100 | { |
---|
2101 | if($_GET['response'] == 1) |
---|
2102 | { |
---|
2103 | if(!$duplicated_action) |
---|
2104 | $notify_message = lang('The commitment was accepted successfully!'); |
---|
2105 | else |
---|
2106 | $notify_message = lang('This commitment has already been accepted!'); |
---|
2107 | } |
---|
2108 | else if($_GET['response'] == 2) |
---|
2109 | { |
---|
2110 | if(!$duplicated_action) |
---|
2111 | $notify_message = lang('The commitment was rejected successfully!'); |
---|
2112 | else |
---|
2113 | $notify_message = lang('This commitment has already been rejected!'); |
---|
2114 | } |
---|
2115 | else if($_GET['response'] == 3) |
---|
2116 | { |
---|
2117 | if(!$duplicated_action) |
---|
2118 | $notify_message = lang('The commitment was tentatived successfully!'); |
---|
2119 | else |
---|
2120 | $notify_message = lang('This commitment has already been tentatived!'); |
---|
2121 | } |
---|
2122 | |
---|
2123 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
2124 | $body1->set_file(Array('calendar' => 'confirm.tpl')); |
---|
2125 | $body1->set_block('calendar','list'); |
---|
2126 | $var = Array( 'notify_message' => $notify_message); |
---|
2127 | $body1->set_var($var); |
---|
2128 | $tmpbody1 = $body1->pfp('out','list'); |
---|
2129 | } |
---|
2130 | function set_action() |
---|
2131 | { |
---|
2132 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
2133 | { |
---|
2134 | $this->no_edit(); |
---|
2135 | return; |
---|
2136 | } |
---|
2137 | |
---|
2138 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action'],(int)$_GET['user']); |
---|
2139 | |
---|
2140 | if(isset($_GET['response'])) |
---|
2141 | { |
---|
2142 | $this->confirm_action($confirm_status); |
---|
2143 | $GLOBALS['phpgw']->common->phpgw_exit(False); |
---|
2144 | } |
---|
2145 | else |
---|
2146 | { |
---|
2147 | if ($this->bo->return_to) |
---|
2148 | { |
---|
2149 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
2150 | } |
---|
2151 | else |
---|
2152 | { |
---|
2153 | Header('Location: '.$this->page('','')); |
---|
2154 | } |
---|
2155 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
2156 | } |
---|
2157 | |
---|
2158 | } |
---|
2159 | function planner() |
---|
2160 | { |
---|
2161 | if(floor(phpversion()) < 4) |
---|
2162 | { |
---|
2163 | return; |
---|
2164 | } |
---|
2165 | $home = strstr($_SERVER['PHP_SELF'],'home') !== False; |
---|
2166 | // generate header and set global/member variables |
---|
2167 | // |
---|
2168 | $this->planner_prepare($home); |
---|
2169 | |
---|
2170 | // process events within selected interval |
---|
2171 | // |
---|
2172 | $this->planner_process_interval(); |
---|
2173 | |
---|
2174 | // generate the planner view |
---|
2175 | // |
---|
2176 | if (!$home) |
---|
2177 | { |
---|
2178 | echo '<p>'.$this->planner_print_rows(); |
---|
2179 | } |
---|
2180 | else |
---|
2181 | { |
---|
2182 | return $this->planner_print_rows(); |
---|
2183 | } |
---|
2184 | } |
---|
2185 | |
---|
2186 | function set_planner_group_members() |
---|
2187 | { |
---|
2188 | $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); |
---|
2189 | |
---|
2190 | if ($type == 'g') // display schedule of all group members |
---|
2191 | { |
---|
2192 | $members = array(); |
---|
2193 | $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); |
---|
2194 | while (list(,$id) = each($ids)) |
---|
2195 | { |
---|
2196 | if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) |
---|
2197 | { |
---|
2198 | $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; |
---|
2199 | } |
---|
2200 | } |
---|
2201 | ksort($members); |
---|
2202 | $this->planner_group_members = $members; |
---|
2203 | } |
---|
2204 | else |
---|
2205 | { |
---|
2206 | $this->planner_group_members = array( |
---|
2207 | $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner |
---|
2208 | ); |
---|
2209 | } |
---|
2210 | } |
---|
2211 | |
---|
2212 | /** |
---|
2213 | * planner_prepare - prepare the planner view |
---|
2214 | * |
---|
2215 | * - sets global environment variables |
---|
2216 | * - initializes class member variables used in multiple planner related functions |
---|
2217 | * - generates header lines for the planner view (month, calendar week, days) |
---|
2218 | */ |
---|
2219 | function planner_prepare($no_header = False) |
---|
2220 | { |
---|
2221 | // set some globals |
---|
2222 | // |
---|
2223 | if (!$no_header) |
---|
2224 | { |
---|
2225 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2226 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2227 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); |
---|
2228 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2229 | $this->header(); |
---|
2230 | } |
---|
2231 | |
---|
2232 | // intervals_per_day can be configured in preferences now :-) |
---|
2233 | // |
---|
2234 | if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) |
---|
2235 | { |
---|
2236 | $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); |
---|
2237 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
2238 | $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; |
---|
2239 | } |
---|
2240 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2241 | $this->bo->save_sessiondata(); // need to save $this->bo->save_owner |
---|
2242 | |
---|
2243 | // set title for table and rows of planner view |
---|
2244 | // |
---|
2245 | if ($this->bo->sortby == 'category') |
---|
2246 | { |
---|
2247 | $title = lang('Category'); |
---|
2248 | } |
---|
2249 | else |
---|
2250 | { |
---|
2251 | $title = lang('User'); |
---|
2252 | |
---|
2253 | $this->set_planner_group_members(); |
---|
2254 | } |
---|
2255 | |
---|
2256 | // create/initialize variables directly used for HTML code generation |
---|
2257 | // |
---|
2258 | $this->planner_header = array(); |
---|
2259 | $this->planner_rows = array(); |
---|
2260 | |
---|
2261 | // generate header lines with days and associated months |
---|
2262 | // |
---|
2263 | $hdr = &$this->planner_header; |
---|
2264 | $hdr[0]['0'] = $title; |
---|
2265 | $hdr[0]['.0'] = 'rowspan="3"'; |
---|
2266 | |
---|
2267 | $this->planner_days = 0; // reset |
---|
2268 | |
---|
2269 | $m = $this->bo->month; |
---|
2270 | $y = $this->bo->year; |
---|
2271 | $this->bo->read_holidays($y); |
---|
2272 | for ($i=1; $i<=$this->bo->num_months; ++$i,++$m) |
---|
2273 | { |
---|
2274 | if ($m == 13) |
---|
2275 | { |
---|
2276 | $m = 1; $y++; // "wrap-around" into new year |
---|
2277 | $this->bo->read_holidays($y); |
---|
2278 | } |
---|
2279 | $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); |
---|
2280 | |
---|
2281 | $d = mktime(0,0,0,$m,1,$y); |
---|
2282 | $month = lang(date('F', $d)).strftime(' %Y', $d); |
---|
2283 | $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; |
---|
2284 | $cols = $days * $intervals_per_day; |
---|
2285 | |
---|
2286 | $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; |
---|
2287 | $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); |
---|
2288 | $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); |
---|
2289 | $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); |
---|
2290 | $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); |
---|
2291 | $hdr[0][$i] = "<b><a href=\"$prev_link\"><<</a>   $month   <a href=\"$next_link\">>></a></b>"; |
---|
2292 | |
---|
2293 | $add_owner = array(); // if no add-rights on the showed cal use own cal |
---|
2294 | if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || |
---|
2295 | !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) |
---|
2296 | { |
---|
2297 | $add_owner = array( |
---|
2298 | 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
2299 | ); |
---|
2300 | } |
---|
2301 | for ($d=1; $d<=$days; ++$d) |
---|
2302 | { |
---|
2303 | $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); |
---|
2304 | $index = $d + $this->planner_days; |
---|
2305 | |
---|
2306 | $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; |
---|
2307 | |
---|
2308 | // highlight today, saturday, sunday and holidays |
---|
2309 | // |
---|
2310 | $color = $this->theme['row_off']; |
---|
2311 | $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); |
---|
2312 | $date = sprintf("%04d%02d%02d",$y,$m,$d); |
---|
2313 | if ($date == date('Ymd')) |
---|
2314 | { |
---|
2315 | $color = $GLOBALS['phpgw_info']['theme']['cal_today']; |
---|
2316 | } |
---|
2317 | elseif ($this->bo->cached_holidays[$date]) |
---|
2318 | { |
---|
2319 | $color = $this->bo->holiday_color; |
---|
2320 | $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; |
---|
2321 | } |
---|
2322 | elseif ($dow == 0 || $dow == 6) |
---|
2323 | { |
---|
2324 | $color = $this->bo->theme['th_bg']; |
---|
2325 | } |
---|
2326 | |
---|
2327 | $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; |
---|
2328 | |
---|
2329 | $hdr[2][$index] = '<a href="'.$this->html->link('/index.php', |
---|
2330 | array( |
---|
2331 | 'menuaction' => 'calendar.uicalendar.add', |
---|
2332 | 'date' => $date |
---|
2333 | ) + $add_owner |
---|
2334 | ).'">'.$dayname.'<br>'.$d.'</a>'; |
---|
2335 | } |
---|
2336 | $this->planner_days += $days; |
---|
2337 | } |
---|
2338 | |
---|
2339 | // create/initialize member variables describing the time interval to be displayed |
---|
2340 | // |
---|
2341 | $this->planner_end_month = $m - 1; |
---|
2342 | $this->planner_end_year = $y; |
---|
2343 | $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); |
---|
2344 | $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); |
---|
2345 | $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); |
---|
2346 | |
---|
2347 | // generate line with calendar weeks in observed interval |
---|
2348 | // |
---|
2349 | $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
2350 | $w = date('W', $d); |
---|
2351 | if ($w == 'W') // php < 4.1 |
---|
2352 | { |
---|
2353 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
2354 | } |
---|
2355 | $offset = (7-date('w', $d)+1)%7; |
---|
2356 | $offset = $offset == 0 ? 7 : $offset; |
---|
2357 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
2358 | |
---|
2359 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; |
---|
2360 | $hdr[1][$w] = ''; |
---|
2361 | if ($offset >= 3) |
---|
2362 | { |
---|
2363 | |
---|
2364 | //NDEE: style! (groupplanner) |
---|
2365 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
2366 | } |
---|
2367 | $days_left = $this->planner_days - $offset; |
---|
2368 | |
---|
2369 | $colspan = 7 * $intervals_per_day; |
---|
2370 | while ($days_left > 0) |
---|
2371 | { |
---|
2372 | $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; |
---|
2373 | $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each |
---|
2374 | $w = date('W', $d); |
---|
2375 | if ($w == 'W') // php < 4.1 |
---|
2376 | { |
---|
2377 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
2378 | } |
---|
2379 | $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? |
---|
2380 | |
---|
2381 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
2382 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; |
---|
2383 | $hdr[1][$w] = ''; |
---|
2384 | if ($days_left >= 3) |
---|
2385 | { |
---|
2386 | |
---|
2387 | //NDEE: style! (groupplanner) |
---|
2388 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
2389 | } |
---|
2390 | |
---|
2391 | $days_left -= 7; |
---|
2392 | } |
---|
2393 | return $hdr; |
---|
2394 | } |
---|
2395 | |
---|
2396 | /** |
---|
2397 | * planner_update_row - update a row of the planner view |
---|
2398 | * |
---|
2399 | * parameters are: |
---|
2400 | * - index (e.g. user id, category id, ...) of the row |
---|
2401 | * - name/title of the row (e.g. user name, category name) |
---|
2402 | * - the event to be integrated |
---|
2403 | * - list of categories associated with the event |
---|
2404 | * - first and last cell of the row |
---|
2405 | */ |
---|
2406 | function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) |
---|
2407 | { |
---|
2408 | $rows = &$this->planner_rows; |
---|
2409 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2410 | $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
2411 | |
---|
2412 | $view = $this->html->link('/index.php', |
---|
2413 | array( |
---|
2414 | 'menuaction' => 'calendar.uicalendar.view', |
---|
2415 | 'cal_id' => $event['id'], |
---|
2416 | 'date' => date('Ymd',$this->bo->maketime($event['start'])) |
---|
2417 | ) |
---|
2418 | ); |
---|
2419 | |
---|
2420 | // check how many lines are needed for this "row" (currently: user or category) |
---|
2421 | $i = 0; |
---|
2422 | do { |
---|
2423 | ++$i; |
---|
2424 | |
---|
2425 | $k = $index.'_'.$i; |
---|
2426 | $ka = '.nr_'.$k; |
---|
2427 | |
---|
2428 | if (!isset($rows[$k])) |
---|
2429 | { |
---|
2430 | if ($i > 1) // further line - no name |
---|
2431 | { |
---|
2432 | $rows[$k] = array(); |
---|
2433 | $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; |
---|
2434 | } |
---|
2435 | else |
---|
2436 | { |
---|
2437 | $rows[$k]['_name'] = $name; |
---|
2438 | } |
---|
2439 | $rows[$ka] = 0; |
---|
2440 | } |
---|
2441 | $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row |
---|
2442 | |
---|
2443 | $row = &$rows[$k]; |
---|
2444 | $akt_cell = &$rows[$ka]; |
---|
2445 | } while ($akt_cell > $start_cell); |
---|
2446 | |
---|
2447 | $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start'])); |
---|
2448 | if ($akt_cell < $start_cell) |
---|
2449 | { |
---|
2450 | $row[$id.'_1'] = ' '; |
---|
2451 | $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; |
---|
2452 | } |
---|
2453 | $opt = &$row['.'.$id.'_2']; |
---|
2454 | $cel = &$row[$id.'_2']; |
---|
2455 | |
---|
2456 | // if possible, display information about event within cells representing it |
---|
2457 | // |
---|
2458 | if ($start_cell < $end_cell) |
---|
2459 | { |
---|
2460 | $colspan = $end_cell - $start_cell; |
---|
2461 | $opt .= "colspan=".(1 + $colspan); |
---|
2462 | |
---|
2463 | if (!$is_private) |
---|
2464 | { |
---|
2465 | $max_chars = (int)(3*$colspan/$intervals_per_day-2); |
---|
2466 | |
---|
2467 | $min_chars = 3; // minimum for max_chars to display -> this should be configurable |
---|
2468 | if ($max_chars >= $min_chars) |
---|
2469 | { |
---|
2470 | $len_title = strlen($event['title']); |
---|
2471 | |
---|
2472 | if ($len_title <= $max_chars) |
---|
2473 | { |
---|
2474 | $title = $event['title']; |
---|
2475 | $max_chars -= $len_title + 3; // 3 chars for separator: " - " |
---|
2476 | $len_descr = strlen($event['description']); |
---|
2477 | |
---|
2478 | if ($len_descr > 0 && $len_descr <= $max_chars) |
---|
2479 | { |
---|
2480 | $event['print_description'] = 'yes'; |
---|
2481 | } |
---|
2482 | } |
---|
2483 | else |
---|
2484 | { |
---|
2485 | $has_amp = strpos($event['title'],'&'); |
---|
2486 | |
---|
2487 | //NDEE: event title gets cut here |
---|
2488 | $title = substr($event['title'], 0 , $max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...'; |
---|
2489 | } |
---|
2490 | $event['print_title'] = 'yes'; |
---|
2491 | } |
---|
2492 | } |
---|
2493 | } |
---|
2494 | |
---|
2495 | if ($bgcolor=$cat['color']) |
---|
2496 | { |
---|
2497 | $opt .= ' bgcolor="'.$bgcolor.'"'; |
---|
2498 | } |
---|
2499 | if (!$is_private) |
---|
2500 | { |
---|
2501 | $opt .= ' title="'.lang('Title').": ".$event['title']." | "; |
---|
2502 | if ($event['description']) |
---|
2503 | { |
---|
2504 | $opt .= "\n".lang('Description').": ".$event['description']." | "; |
---|
2505 | } |
---|
2506 | } |
---|
2507 | else |
---|
2508 | { |
---|
2509 | $opt .= ' title="'.lang('You do not have permission to read this record!'); |
---|
2510 | } |
---|
2511 | |
---|
2512 | $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
2513 | $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
2514 | $opt .= "\n".lang('Start Date/Time').": ".$start." | ".lang('End Date/Time').": ".$end." | "; |
---|
2515 | |
---|
2516 | if ($event['location'] && !$is_private) |
---|
2517 | { |
---|
2518 | $opt .= " \n".lang('Location').": ".$event['location']; |
---|
2519 | } |
---|
2520 | |
---|
2521 | if (!$is_private) |
---|
2522 | { |
---|
2523 | $opt .= '" onClick="location=\''.$view.'\'"'; |
---|
2524 | $cel = '<a href="'.$view.'">'; |
---|
2525 | } |
---|
2526 | else |
---|
2527 | { |
---|
2528 | $opt .= '"'; |
---|
2529 | $cel = ''; |
---|
2530 | } |
---|
2531 | $opt .= ' class="planner-cell"'; |
---|
2532 | |
---|
2533 | if ($event['priority'] == 3) |
---|
2534 | { |
---|
2535 | $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); |
---|
2536 | } |
---|
2537 | if ($event['recur_type']) |
---|
2538 | { |
---|
2539 | $cel .= $this->html->image('calendar','recur.gif','','border="0"'); |
---|
2540 | } |
---|
2541 | $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); |
---|
2542 | $cel .= '</a>'; |
---|
2543 | |
---|
2544 | if (isset($event['print_title']) && $event['print_title'] == 'yes') |
---|
2545 | { |
---|
2546 | |
---|
2547 | //NDEE: style! where? |
---|
2548 | $cel .= '<font size="-2"> '.$title.' </font>'; |
---|
2549 | } |
---|
2550 | if (isset($event['print_description']) && $event['print_description'] == 'yes') |
---|
2551 | { |
---|
2552 | |
---|
2553 | //NDEE: style! where ? |
---|
2554 | $cel .= '<font size="-2"> - '.$event['description'].' </font>'; |
---|
2555 | } |
---|
2556 | |
---|
2557 | $akt_cell = $end_cell + 1; |
---|
2558 | |
---|
2559 | return $rows; |
---|
2560 | } |
---|
2561 | |
---|
2562 | function planner_process_event($event) |
---|
2563 | { |
---|
2564 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2565 | $interval = $this->planner_intervals[$intervals_per_day]; |
---|
2566 | $last_cell = $intervals_per_day * $this->planner_days - 1; |
---|
2567 | |
---|
2568 | $rows = &$this->planner_rows; |
---|
2569 | |
---|
2570 | // caluculate start and end of event |
---|
2571 | // |
---|
2572 | $event_start = (int)(date('Ymd',mktime( |
---|
2573 | 0,0,0, |
---|
2574 | $event['start']['month'], |
---|
2575 | $event['start']['mday'], |
---|
2576 | $event['start']['year'] |
---|
2577 | ))); |
---|
2578 | $event_end = (int)(date('Ymd',mktime( |
---|
2579 | 0,0,0, |
---|
2580 | $event['end']['month'], |
---|
2581 | $event['end']['mday'], |
---|
2582 | $event['end']['year'] |
---|
2583 | ))); |
---|
2584 | |
---|
2585 | // calculate first cell of event within observed interval |
---|
2586 | // |
---|
2587 | if ($event_start >= $this->planner_firstday) |
---|
2588 | { |
---|
2589 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); |
---|
2590 | |
---|
2591 | $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; |
---|
2592 | } |
---|
2593 | else |
---|
2594 | { |
---|
2595 | $start_cell = 0; |
---|
2596 | } |
---|
2597 | |
---|
2598 | // calculate last cell of event within observed interval |
---|
2599 | // |
---|
2600 | if ($event_end <= $this->planner_lastday) |
---|
2601 | { |
---|
2602 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); |
---|
2603 | $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; |
---|
2604 | if ($end_cell == $start_cell && $end_cell < $last_cell) |
---|
2605 | { |
---|
2606 | ++$end_cell; // min. width 1 interval |
---|
2607 | } |
---|
2608 | } |
---|
2609 | else |
---|
2610 | { |
---|
2611 | $end_cell = $last_cell; |
---|
2612 | } |
---|
2613 | // get the categories associated with event |
---|
2614 | // |
---|
2615 | if ($c = $event['category']) |
---|
2616 | { |
---|
2617 | list($cat) = $this->planner_category($event['category']); |
---|
2618 | if ($cat['parent']) |
---|
2619 | { |
---|
2620 | list($pcat) = $this->planner_category($c = $cat['parent']); |
---|
2621 | } |
---|
2622 | else |
---|
2623 | { |
---|
2624 | $pcat = $cat; |
---|
2625 | } |
---|
2626 | } |
---|
2627 | else |
---|
2628 | { |
---|
2629 | $cat = $pcat = array( 'name' => lang('none')); |
---|
2630 | } |
---|
2631 | |
---|
2632 | // add the event to it`s associated row(s) |
---|
2633 | // |
---|
2634 | if ($this->bo->sortby == 'category') |
---|
2635 | { |
---|
2636 | // event needs to show up in it`s category`s row |
---|
2637 | // |
---|
2638 | $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); |
---|
2639 | } |
---|
2640 | elseif ($this->bo->sortby == 'user') |
---|
2641 | { |
---|
2642 | // event needs to show up in rows of all participants that are also owners |
---|
2643 | // |
---|
2644 | reset($this->planner_group_members); |
---|
2645 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
2646 | { |
---|
2647 | $status = $event['participants'][$id]; |
---|
2648 | |
---|
2649 | if (isset($status) && $status != 'R') |
---|
2650 | { |
---|
2651 | $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); |
---|
2652 | } |
---|
2653 | } |
---|
2654 | } |
---|
2655 | } |
---|
2656 | |
---|
2657 | function planner_pad_rows() |
---|
2658 | { |
---|
2659 | $rows = &$this->planner_rows; |
---|
2660 | |
---|
2661 | if ($this->bo->sortby == 'user') |
---|
2662 | { |
---|
2663 | // add empty rows for users that do not participante in any event |
---|
2664 | // |
---|
2665 | reset($this->planner_group_members); |
---|
2666 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
2667 | { |
---|
2668 | $k = $user_name.'_1'; |
---|
2669 | $ka = '.nr_'.$k; |
---|
2670 | |
---|
2671 | if (!isset($rows[$k])) |
---|
2672 | { |
---|
2673 | $rows[$k]['_name'] = $user_name; |
---|
2674 | $rows[$k]['._name'] .= ' nowrap'; |
---|
2675 | $rows[$ka] = 0; |
---|
2676 | } |
---|
2677 | } |
---|
2678 | } |
---|
2679 | |
---|
2680 | // fill the remaining cols |
---|
2681 | // |
---|
2682 | $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; |
---|
2683 | |
---|
2684 | ksort($rows); |
---|
2685 | while (list($k,$r) = each($rows)) |
---|
2686 | { |
---|
2687 | if (is_array($r)) |
---|
2688 | { |
---|
2689 | $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; |
---|
2690 | $row = &$rows[$k]; |
---|
2691 | $akt_cell = &$rows['.nr_'.$k]; |
---|
2692 | if ($akt_cell < $last_cell) |
---|
2693 | { |
---|
2694 | $row['3'] = ' '; |
---|
2695 | $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; |
---|
2696 | } |
---|
2697 | } |
---|
2698 | } |
---|
2699 | } |
---|
2700 | |
---|
2701 | function planner_print_rows() |
---|
2702 | { |
---|
2703 | $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; |
---|
2704 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2705 | |
---|
2706 | if ($this->debug) |
---|
2707 | { |
---|
2708 | _debug_array($this->planner_rows); |
---|
2709 | reset($this->planner_rows); |
---|
2710 | } |
---|
2711 | return $this->html->table( |
---|
2712 | array( |
---|
2713 | '_hdr0' => $this->planner_header[0], |
---|
2714 | '._hdr0' => $bgcolor, |
---|
2715 | '_hdr1' => $this->planner_header[1], |
---|
2716 | '._hdr1' => $bgcolor, |
---|
2717 | '_hdr2' => $this->planner_header[2], |
---|
2718 | '._hdr2' => $bgcolor |
---|
2719 | )+$this->planner_rows, |
---|
2720 | 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); |
---|
2721 | } |
---|
2722 | |
---|
2723 | function planner_process_interval() |
---|
2724 | { |
---|
2725 | // generate duplicate free list of events within observed interval |
---|
2726 | // |
---|
2727 | $this->bo->store_to_cache( |
---|
2728 | Array( |
---|
2729 | 'syear' => $this->bo->year, |
---|
2730 | 'smonth' => $this->bo->month, |
---|
2731 | 'sday' => 1, |
---|
2732 | 'eyear' => $this->planner_end_year, |
---|
2733 | 'emonth' => $this->planner_end_month, |
---|
2734 | 'eday' => $this->planner_days_in_end_month |
---|
2735 | ) |
---|
2736 | ); |
---|
2737 | $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); |
---|
2738 | |
---|
2739 | // process all events within observed interval |
---|
2740 | // |
---|
2741 | for($v=$this->planner_firstday;$v<=$this->planner_lastday;++$v) |
---|
2742 | { |
---|
2743 | $daily = $this->bo->cached_events[$v]; |
---|
2744 | |
---|
2745 | print_debug('For Date',$v); |
---|
2746 | print_debug('Count of items',count($daily)); |
---|
2747 | |
---|
2748 | // process all events on day $v |
---|
2749 | // |
---|
2750 | if (is_array($daily)) foreach($daily as $event) |
---|
2751 | { |
---|
2752 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
2753 | { |
---|
2754 | $this->bo->set_recur_date($event,$v); |
---|
2755 | } |
---|
2756 | if (!$this->bo->rejected_no_show($event)) |
---|
2757 | { |
---|
2758 | $this->planner_process_event($event); |
---|
2759 | } |
---|
2760 | } |
---|
2761 | } |
---|
2762 | $this->planner_pad_rows(); |
---|
2763 | } |
---|
2764 | |
---|
2765 | function matrixselect() |
---|
2766 | { |
---|
2767 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
2768 | |
---|
2769 | $sb = CreateObject('phpgwapi.sbox'); |
---|
2770 | |
---|
2771 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2772 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2773 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
2774 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2775 | |
---|
2776 | $p = &$GLOBALS['phpgw']->template; |
---|
2777 | $p->set_file( |
---|
2778 | Array( |
---|
2779 | 'mq' => 'matrix_query.tpl', |
---|
2780 | 'form_button' => 'form_button_script.tpl' |
---|
2781 | ) |
---|
2782 | ); |
---|
2783 | $p->set_block('mq','matrix_query','matrix_query'); |
---|
2784 | $p->set_block('mq','list','list'); |
---|
2785 | |
---|
2786 | $p->set_var(array( |
---|
2787 | 'title' => lang('Daily Matrix View'), |
---|
2788 | 'th_bg' => $this->theme['th_bg'], |
---|
2789 | 'action_url' => $this->page('viewmatrix') |
---|
2790 | )); |
---|
2791 | |
---|
2792 | // Date |
---|
2793 | $var[] = Array( |
---|
2794 | 'field' => lang('Date'), |
---|
2795 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
2796 | $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')), |
---|
2797 | $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')), |
---|
2798 | $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d')) |
---|
2799 | ) |
---|
2800 | ); |
---|
2801 | |
---|
2802 | // View type |
---|
2803 | $var[] = Array( |
---|
2804 | 'field' => lang('View'), |
---|
2805 | 'data' => '<select name="matrixtype">'."\n" |
---|
2806 | . '<option value="free/busy" selected>'.lang('free/busy').'</option>'."\n" |
---|
2807 | . '<option value="weekly">'.lang('Weekly').'</option>'."\n" |
---|
2808 | . '</select>'."\n" |
---|
2809 | ); |
---|
2810 | |
---|
2811 | // Participants |
---|
2812 | $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); |
---|
2813 | $users = Array(); |
---|
2814 | $accounts_count = count($accounts); |
---|
2815 | for($i=0;$i<$accounts_count;++$i) |
---|
2816 | { |
---|
2817 | $user = $accounts[$i]; |
---|
2818 | if(!isset($users[$user])) |
---|
2819 | { |
---|
2820 | $users[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user); |
---|
2821 | if($GLOBALS['phpgw']->accounts->get_type($user) == 'g') |
---|
2822 | { |
---|
2823 | $group_members = $GLOBALS['phpgw']->acl->get_ids_for_location($user,1,'phpgw_group'); |
---|
2824 | if($group_members != False) |
---|
2825 | { |
---|
2826 | $group_members_count = count($group_members); |
---|
2827 | for($j=0;$j<$group_members_count;++$j) |
---|
2828 | { |
---|
2829 | if(!isset($users[$group_members[$j]])) |
---|
2830 | { |
---|
2831 | $users[$group_members[$j]] = $GLOBALS['phpgw']->common->grab_owner_name($group_members[$j]); |
---|
2832 | } |
---|
2833 | } |
---|
2834 | } |
---|
2835 | } |
---|
2836 | } |
---|
2837 | } |
---|
2838 | |
---|
2839 | $num_users = count($users); |
---|
2840 | |
---|
2841 | if ($num_users > 50) |
---|
2842 | { |
---|
2843 | $size = 15; |
---|
2844 | } |
---|
2845 | elseif ($num_users > 5) |
---|
2846 | { |
---|
2847 | $size = 5; |
---|
2848 | } |
---|
2849 | else |
---|
2850 | { |
---|
2851 | $size = $num_users; |
---|
2852 | } |
---|
2853 | $str = ''; |
---|
2854 | @asort($users); |
---|
2855 | @reset($users); |
---|
2856 | while ($user = each($users)) |
---|
2857 | { |
---|
2858 | if(($GLOBALS['phpgw']->accounts->exists($user[0]) && $this->bo->check_perms(PHPGW_ACL_READ,0,$user[0])) || $GLOBALS['phpgw']->accounts->get_type($user[0]) == 'g') |
---|
2859 | { |
---|
2860 | $str .= ' <option value="'.$user[0].'">('.$GLOBALS['phpgw']->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n"; |
---|
2861 | } |
---|
2862 | } |
---|
2863 | $var[] = Array( |
---|
2864 | 'field' => lang('Participants'), |
---|
2865 | 'data' => "\n".' <select name="participants[]" multiple size="'.$size.'">'."\n".$str.' </select>'."\n" |
---|
2866 | ); |
---|
2867 | |
---|
2868 | $var_count = count($var); |
---|
2869 | for($i=0;$i<$var_count;++$i) |
---|
2870 | { |
---|
2871 | $this->output_template_array($p,'rows','list',$var[$i]); |
---|
2872 | } |
---|
2873 | |
---|
2874 | $vars = Array( |
---|
2875 | 'submit_button' => lang('View'), |
---|
2876 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
2877 | 'action_text_button' => lang('Cancel'), |
---|
2878 | 'action_confirm_button' => '', |
---|
2879 | 'action_extra_field' => '' |
---|
2880 | ); |
---|
2881 | |
---|
2882 | $p->set_var($vars); |
---|
2883 | $p->parse('cancel_button','form_button'); |
---|
2884 | $p->pparse('out','matrix_query'); |
---|
2885 | } |
---|
2886 | |
---|
2887 | function viewmatrix() |
---|
2888 | { |
---|
2889 | if ($_POST['cancel']) |
---|
2890 | { |
---|
2891 | $this->index(); |
---|
2892 | } |
---|
2893 | $participants = $_POST['participants']; |
---|
2894 | $parts = Array(); |
---|
2895 | $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); |
---|
2896 | |
---|
2897 | if (is_array($participants)) |
---|
2898 | { |
---|
2899 | foreach($participants as $participant) |
---|
2900 | { |
---|
2901 | switch ($GLOBALS['phpgw']->accounts->get_type($participant)) |
---|
2902 | { |
---|
2903 | case 'g': |
---|
2904 | if ($members = $acct->member((int)$participant)) |
---|
2905 | { |
---|
2906 | foreach($members as $member) |
---|
2907 | { |
---|
2908 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id'])) |
---|
2909 | { |
---|
2910 | $parts[$member['account_id']] = True; |
---|
2911 | } |
---|
2912 | } |
---|
2913 | } |
---|
2914 | break; |
---|
2915 | case 'u': |
---|
2916 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant)) |
---|
2917 | { |
---|
2918 | $parts[$participant] = 1; |
---|
2919 | } |
---|
2920 | break; |
---|
2921 | } |
---|
2922 | } |
---|
2923 | unset($acct); |
---|
2924 | } |
---|
2925 | $participants = array_keys($parts); // get id's as values and a numeric index |
---|
2926 | |
---|
2927 | // Defined - into session - who participates |
---|
2928 | $GLOBALS['phpgw']->session->appsession("participants", NULL, implode(";", $participants)); |
---|
2929 | |
---|
2930 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2931 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2932 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
2933 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2934 | |
---|
2935 | switch($_POST['matrixtype']) |
---|
2936 | { |
---|
2937 | case 'free/busy': |
---|
2938 | $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); |
---|
2939 | echo '<br>'.$this->timematrix( |
---|
2940 | Array( |
---|
2941 | 'date' => $freetime, |
---|
2942 | 'starttime' => $this->bo->splittime('000000',False), |
---|
2943 | 'endtime' => 0, |
---|
2944 | 'participants' => $parts |
---|
2945 | ) |
---|
2946 | ); |
---|
2947 | break; |
---|
2948 | case 'weekly': |
---|
2949 | echo '<br>'.$this->display_weekly( |
---|
2950 | Array( |
---|
2951 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
2952 | 'showyear' => true, |
---|
2953 | 'owners' => $participants |
---|
2954 | ) |
---|
2955 | ); |
---|
2956 | break; |
---|
2957 | } |
---|
2958 | echo "\n<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n"; |
---|
2959 | echo ' <table cellpadding="5"><tr><td>'."\n"; |
---|
2960 | echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
2961 | echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
2962 | echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
2963 | echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\n"; |
---|
2964 | foreach($participants as $part) |
---|
2965 | { |
---|
2966 | echo ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n"; |
---|
2967 | } |
---|
2968 | echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n"; |
---|
2969 | echo ' </td><td>'."\n"; |
---|
2970 | echo ' <input type="submit" name="cancel" value="'.lang('Cancel').'">'."\n"; |
---|
2971 | echo ' </td></tr></table>'."\n"; |
---|
2972 | echo '</form>'."\n"; |
---|
2973 | } |
---|
2974 | |
---|
2975 | function search() |
---|
2976 | { |
---|
2977 | if (empty($_POST['keywords'])) |
---|
2978 | { |
---|
2979 | // If we reach this, it is because they didn't search for anything |
---|
2980 | // or they used one of the selectboxes (year, month, week) in the search-result |
---|
2981 | // attempt to send them back to where they came from. |
---|
2982 | |
---|
2983 | $vars['menuaction'] = isset($_POST['from']) && $_POST['from'] != 'calendar.uicalendar.search' ? |
---|
2984 | $_POST['from'] : 'calendar.uicalendar.index'; |
---|
2985 | |
---|
2986 | foreach(array('date','year','month','day') as $field) |
---|
2987 | { |
---|
2988 | if (isset($_POST[$field])) |
---|
2989 | { |
---|
2990 | $vars[$field] = $_POST[$field]; |
---|
2991 | } |
---|
2992 | } |
---|
2993 | |
---|
2994 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2995 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2996 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
2997 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2998 | |
---|
2999 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
3000 | return; |
---|
3001 | //$GLOBALS['phpgw']->redirect_link('/index.php',$vars); |
---|
3002 | } |
---|
3003 | |
---|
3004 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
3005 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
3006 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
3007 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
3008 | |
---|
3009 | $error = ''; |
---|
3010 | |
---|
3011 | $matches = 0; |
---|
3012 | |
---|
3013 | // There is currently a problem searching in with repeated events. |
---|
3014 | // It spits back out the date it was entered. I would like to to say that |
---|
3015 | // it is a repeated event. |
---|
3016 | |
---|
3017 | // This has been solved by the little icon indicator for recurring events. |
---|
3018 | |
---|
3019 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
3020 | foreach($event_ids as $key => $id) |
---|
3021 | { |
---|
3022 | $event = $this->bo->read_entry($id); |
---|
3023 | |
---|
3024 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$event)) |
---|
3025 | { |
---|
3026 | continue; |
---|
3027 | } |
---|
3028 | |
---|
3029 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3030 | |
---|
3031 | $info[strval($event['id'])] = array( |
---|
3032 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
3033 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
3034 | 'link' => $this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']) |
---|
3035 | ); |
---|
3036 | |
---|
3037 | } |
---|
3038 | $matches = count($event_ids); |
---|
3039 | |
---|
3040 | if ($matches == 1) |
---|
3041 | { |
---|
3042 | $quantity = lang('1 match found').'.'; |
---|
3043 | } |
---|
3044 | elseif ($matches > 0) |
---|
3045 | { |
---|
3046 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
3047 | } |
---|
3048 | else |
---|
3049 | { |
---|
3050 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
3051 | return; |
---|
3052 | } |
---|
3053 | |
---|
3054 | $p = $GLOBALS['phpgw']->template; |
---|
3055 | $p->set_file( |
---|
3056 | Array( |
---|
3057 | 'search_form' => 'search.tpl' |
---|
3058 | ) |
---|
3059 | ); |
---|
3060 | $p->set_block('search_form','search','search'); |
---|
3061 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
3062 | $p->set_block('search_form','search_list','search_list'); |
---|
3063 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
3064 | |
---|
3065 | $var = Array( |
---|
3066 | 'th_bg' => $this->theme['th_bg'], |
---|
3067 | 'search_text' => lang('Search Results'), |
---|
3068 | 'quantity' => $quantity |
---|
3069 | ); |
---|
3070 | $p->set_var($var); |
---|
3071 | |
---|
3072 | if($matches > 0) |
---|
3073 | { |
---|
3074 | $p->parse('rows','search_list_header',True); |
---|
3075 | } |
---|
3076 | foreach($info as $id => $data) |
---|
3077 | { |
---|
3078 | $p->set_var($data); |
---|
3079 | $p->parse('rows','search_list',True); |
---|
3080 | } |
---|
3081 | |
---|
3082 | if($matches > 0) |
---|
3083 | { |
---|
3084 | $p->parse('rows','search_list_footer',True); |
---|
3085 | } |
---|
3086 | |
---|
3087 | $p->pparse('out','search'); |
---|
3088 | } |
---|
3089 | |
---|
3090 | /* Private functions */ |
---|
3091 | function _debug_sqsof() |
---|
3092 | { |
---|
3093 | $data = array( |
---|
3094 | 'filter' => $this->bo->filter, |
---|
3095 | 'cat_id' => $this->bo->cat_id, |
---|
3096 | 'owner' => $this->bo->owner, |
---|
3097 | 'year' => $this->bo->year, |
---|
3098 | 'month' => $this->bo->month, |
---|
3099 | 'day' => $this->bo->day, |
---|
3100 | 'sortby' => $this->bo->sortby, |
---|
3101 | 'num_months' => $this->bo->num_months |
---|
3102 | ); |
---|
3103 | Return _debug_array($data,False); |
---|
3104 | } |
---|
3105 | |
---|
3106 | function output_template_array(&$p,$row,$list,$var) |
---|
3107 | { |
---|
3108 | if (!isset($var['hidden_vars'])) |
---|
3109 | { |
---|
3110 | $var['hidden_vars'] = ''; |
---|
3111 | } |
---|
3112 | if (!isset($var['tr_color'])) |
---|
3113 | { |
---|
3114 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
3115 | } |
---|
3116 | $p->set_var($var); |
---|
3117 | $p->parse($row,$list,True); |
---|
3118 | } |
---|
3119 | |
---|
3120 | function page($_page='',$params='') |
---|
3121 | { |
---|
3122 | if($_page == '') |
---|
3123 | { |
---|
3124 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
3125 | $_page = $page_[0]; |
---|
3126 | |
---|
3127 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
3128 | { |
---|
3129 | $_page = 'planner'; |
---|
3130 | } |
---|
3131 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
3132 | { |
---|
3133 | $_page = 'month'; |
---|
3134 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
3135 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
3136 | } |
---|
3137 | } |
---|
3138 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
3139 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
3140 | { |
---|
3141 | $page_app = 'calendar'; |
---|
3142 | } |
---|
3143 | else |
---|
3144 | { |
---|
3145 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
3146 | } |
---|
3147 | if (is_array($params)) |
---|
3148 | { |
---|
3149 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
3150 | } |
---|
3151 | else |
---|
3152 | { |
---|
3153 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
3154 | } |
---|
3155 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
3156 | } |
---|
3157 | |
---|
3158 | function header() |
---|
3159 | { |
---|
3160 | $cols = 8; |
---|
3161 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
3162 | { |
---|
3163 | ++$cols; |
---|
3164 | } |
---|
3165 | |
---|
3166 | $tpl = $GLOBALS['phpgw']->template; |
---|
3167 | $tpl->set_unknowns('remove'); |
---|
3168 | |
---|
3169 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
3170 | { |
---|
3171 | $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php'; |
---|
3172 | } |
---|
3173 | |
---|
3174 | include($file); |
---|
3175 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
3176 | if($refer[2] != 'view') { |
---|
3177 | $header = $tpl->fp('out','head'); |
---|
3178 | unset($tpl); |
---|
3179 | echo $header; |
---|
3180 | } |
---|
3181 | unset($tpl); |
---|
3182 | } |
---|
3183 | |
---|
3184 | function footer() |
---|
3185 | { |
---|
3186 | $menuaction = $_GET['menuaction']; |
---|
3187 | list(,,$method) = explode('.',$menuaction); |
---|
3188 | |
---|
3189 | if (@$this->bo->printer_friendly) |
---|
3190 | { |
---|
3191 | return; |
---|
3192 | } |
---|
3193 | |
---|
3194 | $p = $GLOBALS['phpgw']->template; |
---|
3195 | |
---|
3196 | $p->set_file( |
---|
3197 | Array( |
---|
3198 | 'footer' => 'footer.tpl', |
---|
3199 | 'form_button' => 'form_button_script.tpl' |
---|
3200 | ) |
---|
3201 | ); |
---|
3202 | $p->set_block('footer','footer_table','footer_table'); |
---|
3203 | $p->set_block('footer','footer_row','footer_row'); |
---|
3204 | $p->set_block('footer','blank_row','blank_row'); |
---|
3205 | $p->set_block('footer','num_dias','num_dias'); |
---|
3206 | |
---|
3207 | $m = $this->bo->month; |
---|
3208 | $y = $this->bo->year; |
---|
3209 | |
---|
3210 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
3211 | $mes_hoje = (int)substr($hoje,4,2); |
---|
3212 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
3213 | if($_GET['sday']) |
---|
3214 | { |
---|
3215 | if($_GET['month'] == $mes_hoje) |
---|
3216 | { |
---|
3217 | $day = $this->bo->day; |
---|
3218 | } |
---|
3219 | else |
---|
3220 | { |
---|
3221 | $day = $_GET['sday']; |
---|
3222 | } |
---|
3223 | } |
---|
3224 | else |
---|
3225 | { |
---|
3226 | $day = $this->bo->day; |
---|
3227 | $dia_ini = $day; |
---|
3228 | } |
---|
3229 | if($mes_footer == $mes_hoje) |
---|
3230 | { |
---|
3231 | $dia_ini = (int)substr($hoje,6,2); |
---|
3232 | $day = $dia_ini; |
---|
3233 | } |
---|
3234 | /********************************************************************************************/ |
---|
3235 | /* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */ |
---|
3236 | $str_ini = ''; |
---|
3237 | for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); ++$i) |
---|
3238 | { |
---|
3239 | $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3240 | } |
---|
3241 | $str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; |
---|
3242 | for ($i = 1; $i <= 45; ++$i) |
---|
3243 | { |
---|
3244 | $str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3245 | } |
---|
3246 | $display = ''; |
---|
3247 | $display_view = ''; |
---|
3248 | if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') ) |
---|
3249 | { |
---|
3250 | $display = 'none'; |
---|
3251 | } |
---|
3252 | else if( ($menuaction == 'calendar.uicalendar.view') ) |
---|
3253 | { |
---|
3254 | $display = 'none'; |
---|
3255 | $display_view = 'none'; |
---|
3256 | } |
---|
3257 | $var = Array( |
---|
3258 | 'acao' => $this->page($method,''), |
---|
3259 | 'formname' => 'SelectDay', |
---|
3260 | 'formonchange' => 'document.SelectDay.submit()', |
---|
3261 | 'day_ini_label' => lang('print starting in'), |
---|
3262 | 'num_dias_label' => lang('quantity of days'), |
---|
3263 | 'tip' => lang('empty prints from the day chosen below to the end of the current month'), |
---|
3264 | 'day_ini_name' => 'day', |
---|
3265 | 'num_dias_name' => 'qtd_dias', |
---|
3266 | 'row_ini' => $str_ini, |
---|
3267 | 'row_qtd' => $str_qtd, |
---|
3268 | 'display' => $display, |
---|
3269 | 'display_view' => $display_view, |
---|
3270 | 'go' => lang('Go!') |
---|
3271 | ); |
---|
3272 | $this->output_template_array($p,'table_row','num_dias',$var); |
---|
3273 | |
---|
3274 | /********************************************************************************************/ |
---|
3275 | |
---|
3276 | $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y)); |
---|
3277 | $y--; |
---|
3278 | |
---|
3279 | $str = ''; |
---|
3280 | for ($i = 0; $i < 20; ++$i) |
---|
3281 | { |
---|
3282 | ++$m; |
---|
3283 | if ($m > 12) |
---|
3284 | { |
---|
3285 | $m = 1; |
---|
3286 | ++$y; |
---|
3287 | } |
---|
3288 | $d = mktime(0,0,0,$m,1,$y); |
---|
3289 | $d_ymd = date('Ymd',$d); |
---|
3290 | $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n"; |
---|
3291 | } |
---|
3292 | |
---|
3293 | $var = Array( |
---|
3294 | 'action_url' => $this->page($method,''), |
---|
3295 | 'form_name' => 'SelectMonth', |
---|
3296 | 'label' => lang('Month'), |
---|
3297 | 'form_label' => 'date', |
---|
3298 | 'form_onchange' => 'document.SelectMonth.submit()', |
---|
3299 | 'row' => $str, |
---|
3300 | 'dia_ini' => $dia_ini, |
---|
3301 | 'go' => lang('Go!') |
---|
3302 | ); |
---|
3303 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3304 | |
---|
3305 | if($menuaction == 'calendar.uicalendar.week') |
---|
3306 | { |
---|
3307 | unset($thisdate); |
---|
3308 | $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3309 | $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3310 | |
---|
3311 | $str = ''; |
---|
3312 | for ($i = -7; $i <= 7; ++$i) |
---|
3313 | { |
---|
3314 | $begin = $sun + (7*24*60*60 * $i) + 12*60*60; // we use midday, that changes in daylight-saveing does not effect us |
---|
3315 | $end = $begin + 6*24*60*60; |
---|
3316 | // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); |
---|
3317 | $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>' |
---|
3318 | . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' |
---|
3319 | . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) |
---|
3320 | . '</option>' . "\n"; |
---|
3321 | } |
---|
3322 | |
---|
3323 | $var = Array( |
---|
3324 | 'action_url' => $this->page($method,''), |
---|
3325 | 'form_name' => 'SelectWeek', |
---|
3326 | 'label' => lang('Week'), |
---|
3327 | 'form_label' => 'date', |
---|
3328 | 'form_onchange' => 'document.SelectWeek.submit()', |
---|
3329 | 'row' => $str, |
---|
3330 | 'go' => lang('Go!') |
---|
3331 | ); |
---|
3332 | |
---|
3333 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3334 | } |
---|
3335 | |
---|
3336 | $str = ''; |
---|
3337 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); ++$i) |
---|
3338 | { |
---|
3339 | $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3340 | } |
---|
3341 | |
---|
3342 | $var = Array( |
---|
3343 | 'action_url' => $this->page($method,''), |
---|
3344 | 'form_name' => 'SelectYear', |
---|
3345 | 'label' => lang('Year'), |
---|
3346 | 'form_label' => 'year', |
---|
3347 | 'form_onchange' => 'document.SelectYear.submit()', |
---|
3348 | 'row' => $str, |
---|
3349 | 'go' => lang('Go!') |
---|
3350 | ); |
---|
3351 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3352 | |
---|
3353 | if($menuaction == 'calendar.uicalendar.planner') |
---|
3354 | { |
---|
3355 | $str = ''; |
---|
3356 | $date_str = ''; |
---|
3357 | |
---|
3358 | if(isset($_GET['date']) && $_GET['date']) |
---|
3359 | { |
---|
3360 | $date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n"; |
---|
3361 | } |
---|
3362 | $date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
3363 | $date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
3364 | $date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
3365 | |
---|
3366 | for($i=1; $i<=6; ++$i) |
---|
3367 | { |
---|
3368 | $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3369 | } |
---|
3370 | |
---|
3371 | $var = Array( |
---|
3372 | 'action_url' => $this->page($method,''), |
---|
3373 | 'form_name' => 'SelectNumberOfMonths', |
---|
3374 | 'label' => lang('Number of Months'), |
---|
3375 | 'hidden_vars' => $date_str, |
---|
3376 | 'form_label' => 'num_months', |
---|
3377 | 'form_onchange' => 'document.SelectNumberOfMonths.submit()', |
---|
3378 | 'action_extra_field' => $date_str, |
---|
3379 | 'row' => $str, |
---|
3380 | 'go' => lang('Go!') |
---|
3381 | ); |
---|
3382 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3383 | } |
---|
3384 | |
---|
3385 | $var = Array( |
---|
3386 | 'submit_button' => lang('Submit'), |
---|
3387 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), |
---|
3388 | 'action_text_button' => lang('Import'), |
---|
3389 | 'action_confirm_button' => '', |
---|
3390 | 'action_extra_field' => '' |
---|
3391 | ); |
---|
3392 | $this->output_template_array($p,'b_row','form_button',$var); |
---|
3393 | |
---|
3394 | $var = Array( |
---|
3395 | 'submit_button' => lang('Submit'), |
---|
3396 | 'action_url' => $this->page($method,''), |
---|
3397 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.export_all'), |
---|
3398 | 'action_text_button' => lang('Export all'), |
---|
3399 | 'action_confirm_button' => '', |
---|
3400 | 'action_extra_field' => '' |
---|
3401 | ); |
---|
3402 | $this->output_template_array($p,'b_row2','form_button',$var); |
---|
3403 | |
---|
3404 | $p->parse('table_row','blank_row',True); |
---|
3405 | |
---|
3406 | $p->pparse('out','footer_table'); |
---|
3407 | unset($p); |
---|
3408 | } |
---|
3409 | |
---|
3410 | function css() |
---|
3411 | { |
---|
3412 | $GLOBALS['phpgw']->browser->browser(); |
---|
3413 | if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') |
---|
3414 | { |
---|
3415 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8); |
---|
3416 | } |
---|
3417 | else |
---|
3418 | { |
---|
3419 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7); |
---|
3420 | } |
---|
3421 | |
---|
3422 | // moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04] |
---|
3423 | /* |
---|
3424 | return 'A.minicalendar { color: #000000; font-size: 72%; font-family: '.$this->theme['font'].' }'."\n" |
---|
3425 | . ' A.bminicalendar { color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3426 | . ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: '.$this->theme['font'].' }'."\n" |
---|
3427 | . ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family '.$this->theme['font'].' }'."\n" |
---|
3428 | . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: x-small '.$this->theme['font'].' }'."\n" |
---|
3429 | . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3430 | . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: x-small '.$this->theme['font'].' }'."\n" |
---|
3431 | . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3432 | . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3433 | . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3434 | . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3435 | . ' .time { background: '.$this->theme['th_bg'].'; color: '.$this->theme['bg_text'].'; font: bold 100% '.$this->theme['font'].'; width: '.$time_width.'%; vertical-align: middle; text-align: right; }'."\n" |
---|
3436 | . ' .tablecell { width: 80px; height: 80px }'."\n" |
---|
3437 | . ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }'; |
---|
3438 | */ |
---|
3439 | } |
---|
3440 | |
---|
3441 | function no_edit() |
---|
3442 | { |
---|
3443 | if(!isset($GLOBALS['phpgw_info']['flags']['noheader'])) |
---|
3444 | { |
---|
3445 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
3446 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
3447 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
3448 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
3449 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Permission denied'); |
---|
3450 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
3451 | } |
---|
3452 | echo '<center>You do not have permission to edit this appointment!</center>'; |
---|
3453 | return; |
---|
3454 | } |
---|
3455 | |
---|
3456 | function link_to_entry($event,$month,$day,$year) |
---|
3457 | { |
---|
3458 | $str = ''; |
---|
3459 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3460 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3461 | |
---|
3462 | if(!$viewable && $event['type'] == 'E' && !$event['public']){ |
---|
3463 | return ""; |
---|
3464 | } |
---|
3465 | |
---|
3466 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3467 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3468 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
3469 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3470 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3471 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
3472 | { |
---|
3473 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3474 | } |
---|
3475 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
3476 | { |
---|
3477 | $time = '[ '.lang('All Day').' ]'; |
---|
3478 | } |
---|
3479 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
3480 | { |
---|
3481 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
3482 | { |
---|
3483 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
3484 | } |
---|
3485 | else |
---|
3486 | { |
---|
3487 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3488 | } |
---|
3489 | |
---|
3490 | |
---|
3491 | // if($endtime >= ($rawdate_offset + 86400 )) |
---|
3492 | // { |
---|
3493 | // $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
3494 | // } |
---|
3495 | // else |
---|
3496 | // { |
---|
3497 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
3498 | // } |
---|
3499 | $time = $start_time.'-'.$end_time; |
---|
3500 | } |
---|
3501 | else |
---|
3502 | { |
---|
3503 | $time = ''; |
---|
3504 | } |
---|
3505 | |
---|
3506 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
3507 | |
---|
3508 | |
---|
3509 | |
---|
3510 | if(!$is_private) |
---|
3511 | { |
---|
3512 | //$text .= $this->bo->display_status($event['users_status']); |
---|
3513 | |
---|
3514 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
3515 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
3516 | |
---|
3517 | } |
---|
3518 | |
---|
3519 | /* |
---|
3520 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
3521 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
3522 | $GLOBALS['phpgw']->browser->br; |
---|
3523 | */ |
---|
3524 | |
---|
3525 | $texttime=$time; |
---|
3526 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
3527 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
3528 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
3529 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
3530 | |
---|
3531 | if ($viewable) |
---|
3532 | { |
---|
3533 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
3534 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
3535 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
3536 | $this->link_tpl->set_var('desc', $textdesc); |
---|
3537 | $this->link_tpl->set_var('location', $textlocation); |
---|
3538 | $this->link_tpl->parse('picture','link_open',True); |
---|
3539 | } |
---|
3540 | if (!$is_private) |
---|
3541 | { |
---|
3542 | if($event['priority'] == 3) |
---|
3543 | { |
---|
3544 | $picture[] = Array( |
---|
3545 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
3546 | 'width' => 16, |
---|
3547 | 'height'=> 16, |
---|
3548 | 'title' => lang('high priority') |
---|
3549 | ); |
---|
3550 | } |
---|
3551 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
3552 | { |
---|
3553 | $picture[] = Array( |
---|
3554 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
3555 | 'width' => 9, |
---|
3556 | 'height'=> 9, |
---|
3557 | 'title' => lang('single event') |
---|
3558 | ); |
---|
3559 | } |
---|
3560 | else |
---|
3561 | { |
---|
3562 | $picture[] = Array( |
---|
3563 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
3564 | 'width' => 12, |
---|
3565 | 'height'=> 12, |
---|
3566 | 'title' => lang('recurring event') |
---|
3567 | ); |
---|
3568 | } |
---|
3569 | } |
---|
3570 | $participants = $this->planner_participants($event['participants']); |
---|
3571 | if(count($event['participants']) > 1) |
---|
3572 | { |
---|
3573 | $picture[] = Array( |
---|
3574 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
3575 | 'width' => 14, |
---|
3576 | 'height'=> 14, |
---|
3577 | 'title' => $participants |
---|
3578 | ); |
---|
3579 | } |
---|
3580 | else |
---|
3581 | { |
---|
3582 | $picture[] = Array( |
---|
3583 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
3584 | 'width' => 14, |
---|
3585 | 'height'=> 14, |
---|
3586 | 'title' => $participants |
---|
3587 | ); |
---|
3588 | } |
---|
3589 | if($event['public'] == 0) |
---|
3590 | { |
---|
3591 | $picture[] = Array( |
---|
3592 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
3593 | 'width' => 13, |
---|
3594 | 'height'=> 13, |
---|
3595 | 'title' => lang('private') |
---|
3596 | ); |
---|
3597 | } |
---|
3598 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
3599 | { |
---|
3600 | // if the alarm is to go off the day before the event |
---|
3601 | // the icon does not show up because of 'alarm_today' |
---|
3602 | // - TOM |
---|
3603 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
3604 | { |
---|
3605 | $picture[] = Array( |
---|
3606 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
3607 | 'width' => 13, |
---|
3608 | 'height'=> 13, |
---|
3609 | 'title' => lang('alarm') |
---|
3610 | ); |
---|
3611 | } |
---|
3612 | } |
---|
3613 | |
---|
3614 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
3615 | $picture_count = count($picture); |
---|
3616 | for($i=0;$i<$picture_count;++$i) |
---|
3617 | { |
---|
3618 | $var = Array( |
---|
3619 | 'pic_image' => $picture[$i]['pict'], |
---|
3620 | 'width' => $picture[$i]['width'], |
---|
3621 | 'height' => $picture[$i]['height'], |
---|
3622 | 'title' => $picture[$i]['title'] |
---|
3623 | ); |
---|
3624 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
3625 | } |
---|
3626 | if ($texttitle) |
---|
3627 | { |
---|
3628 | $var = Array( |
---|
3629 | // 'text' => $text, |
---|
3630 | 'time'=> $texttime, |
---|
3631 | 'title'=> $texttitle, |
---|
3632 | 'users_status'=>$textstatus, |
---|
3633 | 'desc'=> $textdesc, |
---|
3634 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
3635 | ); |
---|
3636 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
3637 | } |
---|
3638 | |
---|
3639 | if ($viewable) |
---|
3640 | { |
---|
3641 | $this->link_tpl->parse('picture','link_close',True); |
---|
3642 | } |
---|
3643 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
3644 | $this->link_tpl->set_var('picture',''); |
---|
3645 | $this->link_tpl->set_var('out',''); |
---|
3646 | // unset($p); |
---|
3647 | return $str; |
---|
3648 | } |
---|
3649 | |
---|
3650 | /*****************************************************************************************/ |
---|
3651 | /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao; |
---|
3652 | utiliza o template event_link.tpl*/ |
---|
3653 | |
---|
3654 | function link_to_month_entry($event,$month,$day,$year) |
---|
3655 | { |
---|
3656 | $str = ''; |
---|
3657 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3658 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3659 | |
---|
3660 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3661 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3662 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
3663 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3664 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3665 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
3666 | { |
---|
3667 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3668 | } |
---|
3669 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
3670 | { |
---|
3671 | $time = '[ '.lang('All Day').' ]'; |
---|
3672 | } |
---|
3673 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
3674 | { |
---|
3675 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
3676 | { |
---|
3677 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
3678 | } |
---|
3679 | else |
---|
3680 | { |
---|
3681 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3682 | } |
---|
3683 | |
---|
3684 | if($endtime >= ($rawdate_offset + 86400)) |
---|
3685 | { |
---|
3686 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
3687 | } |
---|
3688 | else |
---|
3689 | { |
---|
3690 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
3691 | } |
---|
3692 | $time = $start_time.' - '.$end_time; |
---|
3693 | } |
---|
3694 | else |
---|
3695 | { |
---|
3696 | $time = ''; |
---|
3697 | } |
---|
3698 | |
---|
3699 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
3700 | |
---|
3701 | |
---|
3702 | |
---|
3703 | if(!$is_private) |
---|
3704 | { |
---|
3705 | //$text .= $this->bo->display_status($event['users_status']); |
---|
3706 | |
---|
3707 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
3708 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
3709 | |
---|
3710 | } |
---|
3711 | |
---|
3712 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
3713 | |
---|
3714 | $texttime=$time; |
---|
3715 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
3716 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
3717 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
3718 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
3719 | |
---|
3720 | if ($viewable) |
---|
3721 | { |
---|
3722 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
3723 | $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
3724 | $this->event_tpl->set_var('lang_view',lang('View this entry')); |
---|
3725 | $this->event_tpl->set_var('desc', $textdesc); |
---|
3726 | $this->event_tpl->set_var('location', $textlocation); |
---|
3727 | $this->event_tpl->parse('picture','link_event_open',True); |
---|
3728 | } |
---|
3729 | if (!$is_private) |
---|
3730 | { |
---|
3731 | if($event['priority'] == 3) |
---|
3732 | { |
---|
3733 | $picture[] = Array( |
---|
3734 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
3735 | 'width' => 16, |
---|
3736 | 'height'=> 16, |
---|
3737 | 'title' => lang('high priority') |
---|
3738 | ); |
---|
3739 | } |
---|
3740 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
3741 | { |
---|
3742 | $picture[] = Array( |
---|
3743 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
3744 | 'width' => 9, |
---|
3745 | 'height'=> 9, |
---|
3746 | 'title' => lang('single event') |
---|
3747 | ); |
---|
3748 | } |
---|
3749 | else |
---|
3750 | { |
---|
3751 | $picture[] = Array( |
---|
3752 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
3753 | 'width' => 12, |
---|
3754 | 'height'=> 12, |
---|
3755 | 'title' => lang('recurring event') |
---|
3756 | ); |
---|
3757 | } |
---|
3758 | } |
---|
3759 | |
---|
3760 | $participants = $this->planner_participants($event['participants']); |
---|
3761 | if(count($event['participants']) > 1) |
---|
3762 | { |
---|
3763 | $picture[] = Array( |
---|
3764 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
3765 | 'width' => 14, |
---|
3766 | 'height'=> 14, |
---|
3767 | 'title' => $participants |
---|
3768 | ); |
---|
3769 | } |
---|
3770 | else |
---|
3771 | { |
---|
3772 | $picture[] = Array( |
---|
3773 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
3774 | 'width' => 14, |
---|
3775 | 'height'=> 14, |
---|
3776 | 'title' => $participants |
---|
3777 | ); |
---|
3778 | } |
---|
3779 | if($event['public'] == 0) |
---|
3780 | { |
---|
3781 | $picture[] = Array( |
---|
3782 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
3783 | 'width' => 13, |
---|
3784 | 'height'=> 13, |
---|
3785 | 'title' => lang('private') |
---|
3786 | ); |
---|
3787 | } |
---|
3788 | |
---|
3789 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
3790 | { |
---|
3791 | // if the alarm is to go off the day before the event |
---|
3792 | // the icon does not show up because of 'alarm_today' |
---|
3793 | // - TOM |
---|
3794 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
3795 | { |
---|
3796 | $picture[] = Array( |
---|
3797 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
3798 | 'width' => 13, |
---|
3799 | 'height'=> 13, |
---|
3800 | 'title' => lang('alarm') |
---|
3801 | ); |
---|
3802 | } |
---|
3803 | } |
---|
3804 | |
---|
3805 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
3806 | $picture_count = count($picture); |
---|
3807 | for($i=0;$i<$picture_count;++$i) |
---|
3808 | { |
---|
3809 | $var = Array( |
---|
3810 | 'pic_image' => $picture[$i]['pict'], |
---|
3811 | 'width' => $picture[$i]['width'], |
---|
3812 | 'height' => $picture[$i]['height'], |
---|
3813 | 'title' => $picture[$i]['title'] |
---|
3814 | ); |
---|
3815 | $this->output_template_array($this->event_tpl,'picture','event_pict',$var); |
---|
3816 | } |
---|
3817 | if ($texttitle) |
---|
3818 | { |
---|
3819 | $var = Array( |
---|
3820 | // 'text' => $text, |
---|
3821 | 'time'=> $texttime, |
---|
3822 | 'title'=> $texttitle, |
---|
3823 | 'users_status'=>$textstatus, |
---|
3824 | 'desc'=> $textdesc, |
---|
3825 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
3826 | ); |
---|
3827 | $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); |
---|
3828 | } |
---|
3829 | |
---|
3830 | if ($viewable) |
---|
3831 | { |
---|
3832 | $this->event_tpl->parse('picture','link_event_close',True); |
---|
3833 | } |
---|
3834 | $str = $this->event_tpl->fp('out','link_event_pict'); |
---|
3835 | $this->event_tpl->set_var('picture',''); |
---|
3836 | $this->event_tpl->set_var('out',''); |
---|
3837 | // unset($p); |
---|
3838 | return $str; |
---|
3839 | } |
---|
3840 | |
---|
3841 | /*****************************************************************************************/ |
---|
3842 | function normDec($num) |
---|
3843 | { |
---|
3844 | if ($num > 9) |
---|
3845 | return $num; |
---|
3846 | else |
---|
3847 | return "0".$num; |
---|
3848 | } |
---|
3849 | function overlap($params) |
---|
3850 | { |
---|
3851 | if(!is_array($params)) |
---|
3852 | { |
---|
3853 | } |
---|
3854 | else |
---|
3855 | { |
---|
3856 | $overlapping_events = $params['o_events']; |
---|
3857 | |
---|
3858 | if( is_string( $overlapping_events )) |
---|
3859 | $overlapping_events = explode( ';', $overlapping_events ); |
---|
3860 | |
---|
3861 | $event = $params['this_event']; |
---|
3862 | |
---|
3863 | if( is_string( $event ) ) |
---|
3864 | $event = $this->bo->read_entry( $event ); |
---|
3865 | |
---|
3866 | if( !$event ) |
---|
3867 | $event = $this->bo->restore_from_appsession(); |
---|
3868 | } |
---|
3869 | |
---|
3870 | $month = $event['start']['month']; |
---|
3871 | $mday = $event['start']['mday']; |
---|
3872 | $year = $event['start']['year']; |
---|
3873 | |
---|
3874 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3875 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3876 | |
---|
3877 | $overlap = ''; |
---|
3878 | $overlapping_events_count = count($overlapping_events); |
---|
3879 | for($i=0;$i<$overlapping_events_count;++$i) |
---|
3880 | { |
---|
3881 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
3882 | foreach($overlapped_event['participants'] as $id => $status) |
---|
3883 | { |
---|
3884 | $conflict = isset($event['participants'][$id]); |
---|
3885 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
3886 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
3887 | ($conflict?'</b> - '.lang('Scheduling conflict'):'').'</li>'; |
---|
3888 | } |
---|
3889 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
3890 | $overlap .= '<ul><font size="1"><span>'. |
---|
3891 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
3892 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
3893 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
3894 | $this->normDec($overlapped_event['end']['min']). |
---|
3895 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
3896 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
3897 | else |
---|
3898 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year).'"</ul><br>'; |
---|
3899 | } |
---|
3900 | |
---|
3901 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
3902 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
3903 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
3904 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
3905 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
3906 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
3907 | |
---|
3908 | $porig = $GLOBALS['phpgw']->template; |
---|
3909 | |
---|
3910 | $GLOBALS['phpgw']->template->root = dirname(__FILE__).'/../templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/'; |
---|
3911 | |
---|
3912 | $p = $GLOBALS['phpgw']->template; |
---|
3913 | $p->set_file( |
---|
3914 | Array( |
---|
3915 | 'overlap' => 'overlap.tpl', |
---|
3916 | 'form_button' => 'form_button_script.tpl' |
---|
3917 | ) |
---|
3918 | ); |
---|
3919 | |
---|
3920 | $var = Array( |
---|
3921 | 'color' => $this->theme['bg_text'], |
---|
3922 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
3923 | 'overlap_text' => lang('Your suggested time of <B> %1 - %2 </B> conflicts with the following existing calendar entries:',$GLOBALS['phpgw']->common->show_date($start),$GLOBALS['phpgw']->common->show_date($end)), |
---|
3924 | 'overlap_list' => $overlap |
---|
3925 | ); |
---|
3926 | $p->set_var($var); |
---|
3927 | |
---|
3928 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
3929 | |
---|
3930 | $var = Array( |
---|
3931 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 'calendar.uicalendar.index')), |
---|
3932 | 'action_text_button' => lang('Cancel'), |
---|
3933 | 'action_confirm_button' => '', |
---|
3934 | 'action_extra_field' => '', |
---|
3935 | 'button_id' => 'cancel_button' |
---|
3936 | ); |
---|
3937 | $this->output_template_array($p,'cancel_button','form_button',$var); |
---|
3938 | |
---|
3939 | $var = Array( |
---|
3940 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), |
---|
3941 | 'action_text_button' => lang('Ignore Conflict'), |
---|
3942 | 'action_confirm_button' => '', |
---|
3943 | 'action_extra_field' => '', |
---|
3944 | 'button_id' => 'ignore_button' |
---|
3945 | ); |
---|
3946 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
3947 | |
---|
3948 | if( $event['owner'] == -2 || $event['id'] != 0 ) |
---|
3949 | { |
---|
3950 | $p->set_var( 'suggestion', $this->build_suggestion( $event , $params['this_account']) ); |
---|
3951 | |
---|
3952 | $var = Array( |
---|
3953 | 'action_url_button' => '', |
---|
3954 | 'action_text_button' => lang('Suggest new hour'), |
---|
3955 | 'action_confirm_button' => 'onsubmit="javascript: return false;" onclick="javascript: return show_suggestion();"', |
---|
3956 | 'action_extra_field' => '', |
---|
3957 | 'button_id' => 'redit_button' |
---|
3958 | ); |
---|
3959 | } |
---|
3960 | else |
---|
3961 | { |
---|
3962 | $p->set_var( 'suggestion', '' ); |
---|
3963 | |
---|
3964 | $var = Array( |
---|
3965 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), |
---|
3966 | 'action_text_button' => lang('Re-Edit Event'), |
---|
3967 | 'action_confirm_button' => '', |
---|
3968 | 'action_extra_field' => '', |
---|
3969 | 'button_id' => 'redit_button' |
---|
3970 | ); |
---|
3971 | } |
---|
3972 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
3973 | $p->pparse('out','overlap'); |
---|
3974 | //return 'OLA'; |
---|
3975 | } |
---|
3976 | |
---|
3977 | function planner_participants($parts) |
---|
3978 | { |
---|
3979 | static $id2lid; |
---|
3980 | |
---|
3981 | $names = ''; |
---|
3982 | while (list($id,$status) = each($parts)) |
---|
3983 | { |
---|
3984 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
3985 | |
---|
3986 | if (!isset($id2lid[$id])) |
---|
3987 | { |
---|
3988 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
3989 | } |
---|
3990 | if (strlen($names)) |
---|
3991 | { |
---|
3992 | $names .= ",\n"; |
---|
3993 | } |
---|
3994 | $names .= $id2lid[$id]." ($status)"; |
---|
3995 | } |
---|
3996 | if($this->debug) |
---|
3997 | { |
---|
3998 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
3999 | } |
---|
4000 | return $names; |
---|
4001 | } |
---|
4002 | |
---|
4003 | function planner_category($ids) |
---|
4004 | { |
---|
4005 | static $cats; |
---|
4006 | if(!is_array($ids)) |
---|
4007 | { |
---|
4008 | if (strpos($ids,',')) |
---|
4009 | { |
---|
4010 | $id_array = explode(',',$ids); |
---|
4011 | } |
---|
4012 | else |
---|
4013 | { |
---|
4014 | $id_array[0] = $ids; |
---|
4015 | } |
---|
4016 | } |
---|
4017 | @reset($id_array); |
---|
4018 | $ret_val = Array(); |
---|
4019 | while(list($index,$id) = each($id_array)) |
---|
4020 | { |
---|
4021 | if (!isset($cats[$id])) |
---|
4022 | { |
---|
4023 | $cat_arr = $this->cat->return_single( $id ); |
---|
4024 | $cats[$id] = $cat_arr[0]; |
---|
4025 | $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); |
---|
4026 | } |
---|
4027 | $ret_val[] = $cats[$id]; |
---|
4028 | } |
---|
4029 | return $ret_val; |
---|
4030 | } |
---|
4031 | |
---|
4032 | function week_header($month,$year,$display_name = False) |
---|
4033 | { |
---|
4034 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
4035 | |
---|
4036 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4037 | $p->set_unknowns('remove'); |
---|
4038 | $p->set_file( |
---|
4039 | Array ( |
---|
4040 | 'month_header' => 'month_header.tpl' |
---|
4041 | ) |
---|
4042 | ); |
---|
4043 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
4044 | $p->set_block('month_header','column_title','column_title'); |
---|
4045 | |
---|
4046 | $var = Array( |
---|
4047 | 'bgcolor' => $this->theme['th_bg'], |
---|
4048 | 'font_color' => $this->theme['th_text'] |
---|
4049 | ); |
---|
4050 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
4051 | { |
---|
4052 | $var = Array( |
---|
4053 | 'bgcolor' => '', |
---|
4054 | 'font_color' => '' |
---|
4055 | ); |
---|
4056 | } |
---|
4057 | $p->set_var($var); |
---|
4058 | |
---|
4059 | $p->set_var('col_width','14'); |
---|
4060 | if($display_name == True) |
---|
4061 | { |
---|
4062 | $p->set_var('col_title',lang('name')); |
---|
4063 | $p->parse('column_header','column_title',True); |
---|
4064 | $p->set_var('col_width','12'); |
---|
4065 | } |
---|
4066 | |
---|
4067 | for($i=0;$i<7;++$i) |
---|
4068 | { |
---|
4069 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
4070 | $p->parse('column_header','column_title',True); |
---|
4071 | } |
---|
4072 | return $p->fp('out','monthly_header'); |
---|
4073 | } |
---|
4074 | |
---|
4075 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
4076 | { |
---|
4077 | if($owner == 0) |
---|
4078 | { |
---|
4079 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
4080 | } |
---|
4081 | |
---|
4082 | $temp_owner = $this->bo->owner; |
---|
4083 | |
---|
4084 | $str = ''; |
---|
4085 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4086 | $p->set_unknowns('keep'); |
---|
4087 | |
---|
4088 | $p->set_file( |
---|
4089 | Array( |
---|
4090 | 'month_header' => 'month_header.tpl', |
---|
4091 | 'month_day' => 'month_day.tpl' |
---|
4092 | ) |
---|
4093 | ); |
---|
4094 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
4095 | $p->set_block('month_header','month_column','month_column'); |
---|
4096 | $p->set_block('month_day','month_daily','month_daily'); |
---|
4097 | $p->set_block('month_day','day_event','day_event'); |
---|
4098 | $p->set_block('month_day','event','event'); |
---|
4099 | |
---|
4100 | $p->set_var('extra',''); |
---|
4101 | $p->set_var('col_width','14'); |
---|
4102 | if($display_name) |
---|
4103 | { |
---|
4104 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
4105 | $p->parse('column_header','month_column',True); |
---|
4106 | $p->set_var('col_width','12'); |
---|
4107 | } |
---|
4108 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
4109 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
4110 | foreach($daily as $date => $day_params) |
---|
4111 | { |
---|
4112 | $year = (int)substr($date,0,4); |
---|
4113 | $month = (int)substr($date,4,2); |
---|
4114 | $day = (int)substr($date,6,2); |
---|
4115 | |
---|
4116 | $var = Array( |
---|
4117 | 'column_data' => '', |
---|
4118 | 'extra' => '' |
---|
4119 | ); |
---|
4120 | $p->set_var($var); |
---|
4121 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
4122 | { |
---|
4123 | if ($day_params['new_event']) |
---|
4124 | { |
---|
4125 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
4126 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
4127 | . '</a>'; |
---|
4128 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
4129 | } |
---|
4130 | else |
---|
4131 | { |
---|
4132 | $new_event_link = ''; |
---|
4133 | $day_number = $day; |
---|
4134 | } |
---|
4135 | |
---|
4136 | $var = Array( |
---|
4137 | 'extra' => $day_params['extra'], |
---|
4138 | 'new_event_link'=> $new_event_link, |
---|
4139 | 'day_number' => $day_number |
---|
4140 | ); |
---|
4141 | if($day_params['week']) |
---|
4142 | { |
---|
4143 | |
---|
4144 | //NDEE: style! m_w_table in month_day.tpl |
---|
4145 | // week-hilite |
---|
4146 | //$var['new_event_link'] .= '<font size="-2"> '. |
---|
4147 | $var['new_event_link'] .= ' '. |
---|
4148 | (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'"><span id="calendar_weekinfo" class="calendar_weekinfo">' .$day_params['week'].'</span></a>' : '<span id="calendar_weekinfo" class="calendar_weekinfo">'.$day_params['week'].'</span>'); |
---|
4149 | } |
---|
4150 | |
---|
4151 | $p->set_var($var); |
---|
4152 | |
---|
4153 | if(@$day_params['holidays']) |
---|
4154 | { |
---|
4155 | foreach($day_params['holidays'] as $key => $value) |
---|
4156 | { |
---|
4157 | $var = Array( |
---|
4158 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
4159 | ); |
---|
4160 | $this->output_template_array($p,'daily_events','event',$var); |
---|
4161 | } |
---|
4162 | } |
---|
4163 | |
---|
4164 | if($day_params['appts']) |
---|
4165 | { |
---|
4166 | $var = Array( |
---|
4167 | 'week_day_font_size' => '2', |
---|
4168 | 'events' => '' |
---|
4169 | ); |
---|
4170 | $p->set_var($var); |
---|
4171 | $events = $this->bo->cached_events[$date]; |
---|
4172 | foreach($events as $event) |
---|
4173 | { |
---|
4174 | if ($this->bo->rejected_no_show($event)) |
---|
4175 | { |
---|
4176 | continue; // user does not want to see rejected events |
---|
4177 | } |
---|
4178 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
4179 | $p->parse('events','event',True); |
---|
4180 | $p->set_var('day_events',''); |
---|
4181 | } |
---|
4182 | } |
---|
4183 | $p->parse('daily_events','day_event',True); |
---|
4184 | $p->parse('column_data','month_daily',True); |
---|
4185 | $p->set_var('daily_events',''); |
---|
4186 | $p->set_var('events',''); |
---|
4187 | /* if($day_params['week']) |
---|
4188 | { |
---|
4189 | $var = Array( |
---|
4190 | 'week_day_font_size' => '-2', |
---|
4191 | 'events' => (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'">' .$day_params['week'].'</a>':$day_params['week']) |
---|
4192 | ); |
---|
4193 | $this->output_template_array($p,'column_data','day_event',$var); |
---|
4194 | $p->set_var('events',''); |
---|
4195 | } */ |
---|
4196 | } |
---|
4197 | $p->parse('column_header','month_column',True); |
---|
4198 | $p->set_var('column_data',''); |
---|
4199 | } |
---|
4200 | $this->bo->owner = $temp_owner; |
---|
4201 | return $p->fp('out','monthly_header'); |
---|
4202 | } |
---|
4203 | |
---|
4204 | /***************************************************************************************/ |
---|
4205 | /*As funcoes abaixo |
---|
4206 | month_week_header() |
---|
4207 | month_display_week() |
---|
4208 | display_month_print() |
---|
4209 | month_day_of_week() - esta foi criada mas parte do codigo e de outra funcao da API (day_of_week()); |
---|
4210 | |
---|
4211 | foram duplicadas e modificadas para atender aas modificacoes do layout de impressao mensal da agenda de eventos; |
---|
4212 | TODO: otimizar o codigo |
---|
4213 | |
---|
4214 | Rommel Cysne |
---|
4215 | */ |
---|
4216 | |
---|
4217 | function month_week_header($month,$year,$display_name = False) |
---|
4218 | { |
---|
4219 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
4220 | $p->set_unknowns('remove'); |
---|
4221 | } |
---|
4222 | |
---|
4223 | |
---|
4224 | function month_day_of_week($year,$month,$day) |
---|
4225 | { |
---|
4226 | $dia = Array( |
---|
4227 | 0 => 'Domingo', |
---|
4228 | 1 => 'Segunda', |
---|
4229 | 2 => 'Terça', |
---|
4230 | 3 => 'Quarta', |
---|
4231 | 4 => 'Quinta', |
---|
4232 | 5 => 'Sexta', |
---|
4233 | 6 => 'Sábado' |
---|
4234 | ); |
---|
4235 | |
---|
4236 | if($month > 2) |
---|
4237 | { |
---|
4238 | $month -= 2; |
---|
4239 | } |
---|
4240 | else |
---|
4241 | { |
---|
4242 | $month += 10; |
---|
4243 | $year--; |
---|
4244 | } |
---|
4245 | $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); |
---|
4246 | |
---|
4247 | $month_day = ($day - 7 * floor($day / 7)); //retorna o numero do dia da semana (Ex: domingo eh dia 0, terca eh 2); |
---|
4248 | $weekday = $dia[$month_day]; //retorna o nome do dia da semana de acordo com seu numero; |
---|
4249 | |
---|
4250 | return ($weekday); |
---|
4251 | |
---|
4252 | } |
---|
4253 | |
---|
4254 | function month_display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
4255 | { |
---|
4256 | if($owner == 0) |
---|
4257 | { |
---|
4258 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
4259 | } |
---|
4260 | |
---|
4261 | $temp_owner = $this->bo->owner; |
---|
4262 | |
---|
4263 | $str = ''; |
---|
4264 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4265 | $p->set_unknowns('keep'); |
---|
4266 | |
---|
4267 | $p->set_file( |
---|
4268 | Array( |
---|
4269 | 'month_header' => 'month_header_print.tpl', |
---|
4270 | 'month_day' => 'month_day_print.tpl' |
---|
4271 | ) |
---|
4272 | ); |
---|
4273 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
4274 | $p->set_block('month_header','month_column','month_column'); |
---|
4275 | $p->set_block('month_day','month_daily','month_daily'); |
---|
4276 | $p->set_block('month_day','day_event','day_event'); |
---|
4277 | $p->set_block('month_day','event','event'); |
---|
4278 | |
---|
4279 | $p->set_var('extra',''); |
---|
4280 | $p->set_var('col_width','14'); |
---|
4281 | |
---|
4282 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
4283 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
4284 | |
---|
4285 | foreach($daily as $date => $day_params) |
---|
4286 | { |
---|
4287 | $year = (int)substr($date,0,4); |
---|
4288 | $month = (int)substr($date,4,2); |
---|
4289 | $day = (int)substr($date,6,2); |
---|
4290 | $var = Array( |
---|
4291 | 'column_data' => '', |
---|
4292 | 'extra' => '' |
---|
4293 | ); |
---|
4294 | $p->set_var($var); |
---|
4295 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
4296 | { |
---|
4297 | $new_event_link = ''; |
---|
4298 | $day_num = $day; |
---|
4299 | $dia_semana = $this->month_day_of_week($year,$month,$day_num); |
---|
4300 | $id_aux = mktime(0,0,0,$month,$day,$year); |
---|
4301 | $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); |
---|
4302 | $day_number = $month_identifier . " - " . $dia_semana . ", " . $day_num; |
---|
4303 | |
---|
4304 | $var = Array( |
---|
4305 | 'extra' => $day_params['extra'], |
---|
4306 | 'new_event_link'=> $new_event_link, |
---|
4307 | 'day_number' => $day_number |
---|
4308 | ); |
---|
4309 | |
---|
4310 | $p->set_var($var); |
---|
4311 | |
---|
4312 | if($day_params['appts']) |
---|
4313 | { |
---|
4314 | $var = Array( |
---|
4315 | 'week_day_font_size' => '2', |
---|
4316 | 'events' => '' |
---|
4317 | ); |
---|
4318 | $p->set_var($var); |
---|
4319 | $events = $this->bo->cached_events[$date]; |
---|
4320 | foreach($events as $event) |
---|
4321 | { |
---|
4322 | if ($this->bo->rejected_no_show($event)) |
---|
4323 | { |
---|
4324 | continue; // user does not want to see rejected events |
---|
4325 | } |
---|
4326 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
4327 | $p->parse('events','event',True); |
---|
4328 | $p->set_var('day_events',''); |
---|
4329 | } |
---|
4330 | } |
---|
4331 | $p->parse('daily_events','day_event',True); |
---|
4332 | $p->parse('column_data','month_daily',True); |
---|
4333 | $p->set_var('daily_events',''); |
---|
4334 | $p->set_var('events',''); |
---|
4335 | |
---|
4336 | } |
---|
4337 | $p->parse('column_header','month_column',True); |
---|
4338 | $p->set_var('column_data',''); |
---|
4339 | } |
---|
4340 | $this->bo->owner = $temp_owner; |
---|
4341 | return $p->fp('out','monthly_header'); |
---|
4342 | |
---|
4343 | } |
---|
4344 | |
---|
4345 | function display_month_print($month,$year,$showyear,$owner=0) |
---|
4346 | { |
---|
4347 | if($this->debug) |
---|
4348 | { |
---|
4349 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
4350 | } |
---|
4351 | |
---|
4352 | /* $this->bo->store_to_cache( |
---|
4353 | Array( |
---|
4354 | 'syear' => $year, |
---|
4355 | 'smonth'=> $month, |
---|
4356 | 'sday' => 1 |
---|
4357 | ) |
---|
4358 | ); |
---|
4359 | */ |
---|
4360 | $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; |
---|
4361 | $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; |
---|
4362 | |
---|
4363 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
4364 | // $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4365 | |
---|
4366 | if($num_dias != 0) |
---|
4367 | { |
---|
4368 | //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; |
---|
4369 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias-1,$year))); |
---|
4370 | } |
---|
4371 | else |
---|
4372 | { |
---|
4373 | //se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente; |
---|
4374 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4375 | } |
---|
4376 | |
---|
4377 | if($day_ini != 0) |
---|
4378 | { |
---|
4379 | //o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente; |
---|
4380 | $start = mktime(0,0,0,$month,$day_ini,$year); |
---|
4381 | } |
---|
4382 | else |
---|
4383 | { |
---|
4384 | //se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente; |
---|
4385 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
4386 | } |
---|
4387 | //$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15); |
---|
4388 | $start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd'; |
---|
4389 | $saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao; |
---|
4390 | $eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao; |
---|
4391 | //A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo |
---|
4392 | //especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela. |
---|
4393 | //A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo |
---|
4394 | //atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves |
---|
4395 | //do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, |
---|
4396 | //function store_to_cache($params); |
---|
4397 | $this->bo->store_to_cache( |
---|
4398 | Array( |
---|
4399 | 'syear' => $year,//ano atual |
---|
4400 | 'smonth'=> $saux,//mes inicial |
---|
4401 | 'emonth'=> $eaux,//mes final |
---|
4402 | 'sday' => 1 |
---|
4403 | )); |
---|
4404 | |
---|
4405 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4406 | $p->set_unknowns('keep'); |
---|
4407 | |
---|
4408 | $p->set_file( |
---|
4409 | Array( |
---|
4410 | 'week' => 'month_day_print.tpl' |
---|
4411 | ) |
---|
4412 | ); |
---|
4413 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4414 | $p->set_block('week','event','event'); |
---|
4415 | |
---|
4416 | $var = Array( |
---|
4417 | 'cols' => 1, |
---|
4418 | 'day_events'=> '' //$this->month_week_header($month,$year,False) |
---|
4419 | ); |
---|
4420 | // $this->output_template_array($p,'row','event',$var); |
---|
4421 | |
---|
4422 | $cellcolor = $this->theme['row_on']; |
---|
4423 | |
---|
4424 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
4425 | { |
---|
4426 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
4427 | $var = Array( |
---|
4428 | 'day_events' => $this->month_display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
4429 | ); |
---|
4430 | $this->output_template_array($p,'row','event',$var); |
---|
4431 | } |
---|
4432 | return $p->fp('out','m_w_table'); |
---|
4433 | } |
---|
4434 | |
---|
4435 | |
---|
4436 | /***************************************************************************************/ |
---|
4437 | |
---|
4438 | function display_month($month,$year,$showyear,$owner=0) |
---|
4439 | { |
---|
4440 | if($this->debug) |
---|
4441 | { |
---|
4442 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
4443 | } |
---|
4444 | |
---|
4445 | $this->bo->store_to_cache( |
---|
4446 | Array( |
---|
4447 | 'syear' => $year, |
---|
4448 | 'smonth'=> $month, |
---|
4449 | 'sday' => 1 |
---|
4450 | ) |
---|
4451 | ); |
---|
4452 | |
---|
4453 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
4454 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4455 | |
---|
4456 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
4457 | |
---|
4458 | if($this->debug) |
---|
4459 | { |
---|
4460 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
4461 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
4462 | } |
---|
4463 | |
---|
4464 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4465 | $p->set_unknowns('keep'); |
---|
4466 | |
---|
4467 | $p->set_file( |
---|
4468 | Array( |
---|
4469 | 'week' => 'month_day.tpl' |
---|
4470 | ) |
---|
4471 | ); |
---|
4472 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4473 | $p->set_block('week','event','event'); |
---|
4474 | |
---|
4475 | $var = Array( |
---|
4476 | 'cols' => 1, |
---|
4477 | 'day_events'=> $this->week_header($month,$year,False) |
---|
4478 | ); |
---|
4479 | $this->output_template_array($p,'row','event',$var); |
---|
4480 | |
---|
4481 | $cellcolor = $this->theme['row_on']; |
---|
4482 | |
---|
4483 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
4484 | { |
---|
4485 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
4486 | $var = Array( |
---|
4487 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
4488 | ); |
---|
4489 | $this->output_template_array($p,'row','event',$var); |
---|
4490 | } |
---|
4491 | return $p->fp('out','m_w_table'); |
---|
4492 | } |
---|
4493 | |
---|
4494 | function display_weekly($params) |
---|
4495 | { |
---|
4496 | if(!is_array($params)) |
---|
4497 | { |
---|
4498 | $this->index(); |
---|
4499 | } |
---|
4500 | |
---|
4501 | $year = substr($params['date'],0,4); |
---|
4502 | $month = substr($params['date'],4,2); |
---|
4503 | $day = substr($params['date'],6,2); |
---|
4504 | $showyear = $params['showyear']; |
---|
4505 | $owners = $params['owners']; |
---|
4506 | |
---|
4507 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4508 | $p->set_unknowns('keep'); |
---|
4509 | |
---|
4510 | $p->set_file( |
---|
4511 | Array( |
---|
4512 | 'week' => 'month_day.tpl' |
---|
4513 | ) |
---|
4514 | ); |
---|
4515 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4516 | $p->set_block('week','event','event'); |
---|
4517 | |
---|
4518 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
4519 | |
---|
4520 | $cellcolor = $this->theme['row_off']; |
---|
4521 | |
---|
4522 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
4523 | |
---|
4524 | if(is_array($owners)) |
---|
4525 | { |
---|
4526 | $display_name = True; |
---|
4527 | $counter = count($owners); |
---|
4528 | $owners_array = $owners; |
---|
4529 | $cols = 8; |
---|
4530 | } |
---|
4531 | else |
---|
4532 | { |
---|
4533 | $display_name = False; |
---|
4534 | $counter = 1; |
---|
4535 | $owners_array[0] = $owners; |
---|
4536 | $cols = 7; |
---|
4537 | } |
---|
4538 | $var = Array( |
---|
4539 | 'cols' => $cols, |
---|
4540 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
4541 | ); |
---|
4542 | $this->output_template_array($p,'row','event',$var); |
---|
4543 | |
---|
4544 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
4545 | $tstop = $tstart + 604800; |
---|
4546 | $original_owner = $this->bo->so->owner; |
---|
4547 | for($i=0;$i<$counter;++$i) |
---|
4548 | { |
---|
4549 | $this->bo->so->owner = $owners_array[$i]; |
---|
4550 | $this->bo->so->open_box($owners_array[$i]); |
---|
4551 | $this->bo->store_to_cache( |
---|
4552 | Array( |
---|
4553 | 'syear' => date('Y',$tstart), |
---|
4554 | 'smonth' => date('m',$tstart), |
---|
4555 | 'sday' => date('d',$tstart), |
---|
4556 | 'eyear' => date('Y',$tstop), |
---|
4557 | 'emonth' => date('m',$tstop), |
---|
4558 | 'eday' => date('d',$tstop) |
---|
4559 | ) |
---|
4560 | ); |
---|
4561 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i])); |
---|
4562 | $p->parse('row','event',True); |
---|
4563 | } |
---|
4564 | $this->bo->so->owner = $original_owner; |
---|
4565 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
4566 | return $p->fp('out','m_w_table'); |
---|
4567 | } |
---|
4568 | |
---|
4569 | function view_event($event,$alarms=False) |
---|
4570 | { |
---|
4571 | if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) |
---|
4572 | { |
---|
4573 | return False; |
---|
4574 | } |
---|
4575 | |
---|
4576 | $p = &$GLOBALS['phpgw']->template; |
---|
4577 | |
---|
4578 | $p->set_file( |
---|
4579 | Array( |
---|
4580 | 'view' => 'view.tpl' |
---|
4581 | ) |
---|
4582 | ); |
---|
4583 | $p->set_block('view','view_event','view_event'); |
---|
4584 | $p->set_block('view','list','list'); |
---|
4585 | $p->set_block('view','hr','hr'); |
---|
4586 | |
---|
4587 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
4588 | $langp = array(); |
---|
4589 | $langp['ACCEPTED'] = lang('Accepted'); |
---|
4590 | $langp['DECLINED'] = lang('Declined'); |
---|
4591 | $langp['TENTATIVE'] = lang('Tentative'); |
---|
4592 | $langp['DELEGATED'] = lang('Delegated'); |
---|
4593 | $langp['NO ANSWER'] = lang('No answer'); |
---|
4594 | $exParticipants = new exParticipants($langp); |
---|
4595 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
4596 | $event['ex_participants'] = $exParticipants->getParticipantsView(); |
---|
4597 | |
---|
4598 | $vars = $this->bo->event2array($event); |
---|
4599 | |
---|
4600 | $vars['title']['tr_color'] = $this->theme['th_bg']; |
---|
4601 | |
---|
4602 | foreach($vars['participants']['data'] as $user => $str) |
---|
4603 | { |
---|
4604 | if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && preg_match('/^(.*) \((.*)\)$/',$str,$parts)) |
---|
4605 | { |
---|
4606 | $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; |
---|
4607 | } |
---|
4608 | } |
---|
4609 | $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); |
---|
4610 | foreach($vars as $var) |
---|
4611 | { |
---|
4612 | if (strlen($var['data'])) |
---|
4613 | { |
---|
4614 | $this->output_template_array($p,'row','list',$var); |
---|
4615 | } |
---|
4616 | } |
---|
4617 | |
---|
4618 | if($alarms && count($event['alarm'])) |
---|
4619 | { |
---|
4620 | $p->set_var('th_bg',$this->theme['th_bg']); |
---|
4621 | $p->set_var('hr_text',lang('Alarms')); |
---|
4622 | $p->parse('row','hr',True); |
---|
4623 | foreach($event['alarm'] as $key => $alarm) |
---|
4624 | { |
---|
4625 | if (($this->bo->so->owner == $alarm['owner']) || ($this->bo->so->cal->event['owner'] == $this->bo->so->owner)) // Show only alert from user who is requesting or alert owner |
---|
4626 | { |
---|
4627 | $icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'" width="13" height="13">'; |
---|
4628 | $var = Array( |
---|
4629 | 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), |
---|
4630 | 'data' => lang('Email Notification for %1',$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner'])) |
---|
4631 | ); |
---|
4632 | $this->output_template_array($p,'row','list',$var); |
---|
4633 | } |
---|
4634 | } |
---|
4635 | } |
---|
4636 | return True; |
---|
4637 | } |
---|
4638 | |
---|
4639 | function nm_on_off() |
---|
4640 | { |
---|
4641 | if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) |
---|
4642 | { |
---|
4643 | return '_on'; |
---|
4644 | } |
---|
4645 | return '_off'; |
---|
4646 | } |
---|
4647 | |
---|
4648 | function slot_num($time,$set_day_start=0,$set_day_end=0) |
---|
4649 | { |
---|
4650 | static $day_start, $day_end, $interval=0; |
---|
4651 | |
---|
4652 | if ($set_day_start) $day_start = $set_day_start; |
---|
4653 | if ($set_day_end) $day_end = $set_day_end; |
---|
4654 | if (!$interval) $interval = 60*$this->bo->prefs['calendar']['interval']; |
---|
4655 | |
---|
4656 | if ($time > $day_end) |
---|
4657 | { |
---|
4658 | $time = $day_end; |
---|
4659 | } |
---|
4660 | $slot = (int)(($time - $day_start) / $interval); |
---|
4661 | |
---|
4662 | return $slot < 0 ? 0 : 1+$slot; |
---|
4663 | } |
---|
4664 | |
---|
4665 | function print_day($params) |
---|
4666 | { |
---|
4667 | if(!is_array($params)) |
---|
4668 | { |
---|
4669 | $this->index(); |
---|
4670 | } |
---|
4671 | |
---|
4672 | print_debug('in print_day()'); |
---|
4673 | |
---|
4674 | $this->bo->store_to_cache( |
---|
4675 | Array( |
---|
4676 | 'syear' => $params['year'], |
---|
4677 | 'smonth' => $params['month'], |
---|
4678 | 'sday' => $params['day'], |
---|
4679 | 'eyear' => $params['year'], |
---|
4680 | 'emonth' => $params['month'], |
---|
4681 | 'eday' => $params['day'] |
---|
4682 | ) |
---|
4683 | ); |
---|
4684 | |
---|
4685 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4686 | $p->set_unknowns('keep'); |
---|
4687 | |
---|
4688 | $tpl = 'day_cal.tpl'; |
---|
4689 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
4690 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
4691 | { |
---|
4692 | $tpl = 'day_list.tpl'; |
---|
4693 | } |
---|
4694 | $templates = Array( |
---|
4695 | 'day_cal' => $tpl |
---|
4696 | ); |
---|
4697 | |
---|
4698 | $p->set_file($templates); |
---|
4699 | $p->set_block('day_cal','day','day'); |
---|
4700 | $p->set_block('day_cal','day_row','day_row'); |
---|
4701 | $p->set_block('day_cal','day_event_on','day_event_on'); |
---|
4702 | $p->set_block('day_cal','day_event_off','day_event_off'); |
---|
4703 | $p->set_block('day_cal','day_event_holiday','day_event_holiday'); |
---|
4704 | $p->set_block('day_cal','day_time','day_time'); |
---|
4705 | |
---|
4706 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
4707 | |
---|
4708 | $day_start = mktime((int)($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']); |
---|
4709 | $day_end = mktime((int)($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); |
---|
4710 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
4711 | print_debug('Date to Eval',$date_to_eval); |
---|
4712 | $events_to_show = array(); |
---|
4713 | if($daily[$date_to_eval]['appts']) |
---|
4714 | { |
---|
4715 | $events = $this->bo->cached_events[$date_to_eval]; |
---|
4716 | print_debug('Date',$date_to_eval); |
---|
4717 | print_debug('Count',count($events)); |
---|
4718 | foreach($events as $event) |
---|
4719 | { |
---|
4720 | if ($this->bo->rejected_no_show($event)) |
---|
4721 | { |
---|
4722 | continue; // user does not want to see rejected events |
---|
4723 | } |
---|
4724 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
4725 | { |
---|
4726 | $this->bo->set_recur_date($event,$date_to_eval); |
---|
4727 | } |
---|
4728 | $events_to_show[] = array( |
---|
4729 | 'starttime' => $this->bo->maketime($event['start']), |
---|
4730 | 'endtime' => $this->bo->maketime($event['end']), |
---|
4731 | 'content' => $this->link_to_entry($event,$params['month'],$params['day'],$params['year']) |
---|
4732 | ); |
---|
4733 | } |
---|
4734 | } |
---|
4735 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
4736 | $other = $GLOBALS['phpgw']->hooks->process(array( |
---|
4737 | 'location' => 'calendar_include_events', |
---|
4738 | 'year' => $params['year'], |
---|
4739 | 'month' => $params['month'], |
---|
4740 | 'day' => $params['day'], |
---|
4741 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
4742 | )); |
---|
4743 | |
---|
4744 | if (is_array($other)) |
---|
4745 | { |
---|
4746 | foreach($other as $evts) |
---|
4747 | { |
---|
4748 | if (is_array($evts)) |
---|
4749 | { |
---|
4750 | $events_to_show = array_merge($events_to_show,$evts); |
---|
4751 | } |
---|
4752 | } |
---|
4753 | usort($events_to_show,create_function('$a,$b','return $a[\'starttime\']-$b[\'starttime\'];')); |
---|
4754 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
4755 | } |
---|
4756 | |
---|
4757 | if (count($events_to_show)) |
---|
4758 | { |
---|
4759 | $last_slot_end = -1; |
---|
4760 | foreach($events_to_show as $event) |
---|
4761 | { |
---|
4762 | $slot = $this->slot_num($event['starttime'],$day_start,$day_end); |
---|
4763 | $slot_end = isset($event['endtime']) ? $this->slot_num($event['endtime']-1) : $slot; // -1 to not occupy eg. the 18.00 slot for a 17-18h date |
---|
4764 | |
---|
4765 | if ($slot <= $last_slot_end) |
---|
4766 | { |
---|
4767 | $slot = $last_slot; |
---|
4768 | $slot_end = max($last_slot_end,$slot_end); |
---|
4769 | } |
---|
4770 | $rows[$slot] .= $event['content']; |
---|
4771 | |
---|
4772 | print_debug('slot',$slot); |
---|
4773 | print_debug('row',$rows[$slot]); |
---|
4774 | |
---|
4775 | $row_span[$slot] = 1 + $slot_end - $slot; |
---|
4776 | |
---|
4777 | $last_slot = $slot; |
---|
4778 | $last_slot_end = $slot_end; |
---|
4779 | print_debug('Time',$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['start']) - $GLOBALS['phpgw']->datetime->tz_offset).' - '.$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['end']) - $GLOBALS['phpgw']->datetime->tz_offset)); |
---|
4780 | print_debug('Slot',$slot); |
---|
4781 | } |
---|
4782 | //echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n"; |
---|
4783 | } |
---|
4784 | $holiday_names = $daily[$date_to_eval]['holidays']; |
---|
4785 | if(!$holiday_names) |
---|
4786 | { |
---|
4787 | $row_to_print = $this->nm_on_off(); |
---|
4788 | } |
---|
4789 | else |
---|
4790 | { |
---|
4791 | $row_to_print = '_holiday'; |
---|
4792 | foreach($holiday_names as $name) |
---|
4793 | { |
---|
4794 | $rows[0] = '<center>'.$name.'</center>' . $rows[0]; |
---|
4795 | } |
---|
4796 | } |
---|
4797 | $last_slot = $this->slot_num($day_end,$day_start,$day_end); |
---|
4798 | $rowspan = 0; |
---|
4799 | for ($slot = 0; $slot <= $last_slot; ++$slot) |
---|
4800 | { |
---|
4801 | $p->set_var('extras',''); |
---|
4802 | if ($rowspan > 1) |
---|
4803 | { |
---|
4804 | $p->set_var('event',''); |
---|
4805 | $rowspan--; |
---|
4806 | } |
---|
4807 | elseif (!isset($rows[$slot])) |
---|
4808 | { |
---|
4809 | $p->set_var('event',' '); |
---|
4810 | $row_to_print = $this->nm_on_off(); |
---|
4811 | $p->parse('event','day_event'.$row_to_print); |
---|
4812 | } |
---|
4813 | else |
---|
4814 | { |
---|
4815 | $rowspan = (int)$row_span[$slot]; |
---|
4816 | if ($rowspan > 1) |
---|
4817 | { |
---|
4818 | $p->set_var('extras',' rowspan="'.$rowspan.'"'); |
---|
4819 | } |
---|
4820 | $p->set_var('event',$rows[$slot]); |
---|
4821 | $row_to_print = $this->nm_on_off(); |
---|
4822 | $p->parse('event','day_event'.$row_to_print); |
---|
4823 | } |
---|
4824 | $open_link = $close_link = ''; |
---|
4825 | $time = ' '; |
---|
4826 | |
---|
4827 | if (0 < $slot && $slot < $last_slot) // normal time-slot not before or after day_start/end |
---|
4828 | { |
---|
4829 | $time = $day_start + ($slot-1) * 60 * $this->bo->prefs['calendar']['interval']; |
---|
4830 | $hour = date('H',$time); |
---|
4831 | $min = date('i',$time); |
---|
4832 | $time = $GLOBALS['phpgw']->common->formattime($hour,$min); |
---|
4833 | |
---|
4834 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
4835 | { |
---|
4836 | $open_link = ' <a href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">'; |
---|
4837 | $close_link = '</a> '; |
---|
4838 | } |
---|
4839 | } |
---|
4840 | $p->set_var(Array( |
---|
4841 | 'open_link' => $open_link, |
---|
4842 | 'time' => $time, |
---|
4843 | 'close_link' => $close_link, |
---|
4844 | 'tr_color' => '' // dummy to stop output_template_array to set it |
---|
4845 | )); |
---|
4846 | $p->parse('time','day_time'); |
---|
4847 | |
---|
4848 | $p->parse('row','day_row',True); |
---|
4849 | } |
---|
4850 | return $p->fp('out','day'); |
---|
4851 | } // end function |
---|
4852 | |
---|
4853 | function timematrix($param) |
---|
4854 | { |
---|
4855 | if(!is_array($param)) |
---|
4856 | { |
---|
4857 | $this->index(); |
---|
4858 | } |
---|
4859 | |
---|
4860 | $date = $param['date']; |
---|
4861 | $starttime = $param['starttime']; |
---|
4862 | $endtime = $param['endtime']; |
---|
4863 | $participants = $param['participants']; |
---|
4864 | foreach($participants as $part => $nul) |
---|
4865 | { |
---|
4866 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
4867 | // Much better for processor :) |
---|
4868 | $participants_id[] .= $part; |
---|
4869 | } |
---|
4870 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
4871 | |
---|
4872 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
4873 | { |
---|
4874 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
4875 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
4876 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
4877 | } |
---|
4878 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
4879 | $interval = (int)(60 / $increment); |
---|
4880 | |
---|
4881 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
4882 | |
---|
4883 | $str = '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
4884 | . ', '.$this->bo->long_date($date).'<br>' |
---|
4885 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">' |
---|
4886 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
4887 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
4888 | for($i=0;$i<24;++$i) |
---|
4889 | { |
---|
4890 | for($j=0;$j<$interval;++$j) |
---|
4891 | { |
---|
4892 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
4893 | |
---|
4894 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'"><font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' |
---|
4895 | . '<a href="'.$this->page('add','&date='.$date['full'].'&hour='.$i.'&minute='.($increment * $j))."\" onMouseOver=\"window.status='".$i.':'.(($increment * $j)<=9?'0':'').($increment * $j)."'; return true;\">" |
---|
4896 | . $k."</a> </font></td>\n"; |
---|
4897 | } |
---|
4898 | } |
---|
4899 | $str .= '</tr>' |
---|
4900 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
4901 | if(!$endtime) |
---|
4902 | { |
---|
4903 | $endtime = $starttime; |
---|
4904 | } |
---|
4905 | $owner = $this->bo->owner; |
---|
4906 | foreach($participants as $part => $fullname) |
---|
4907 | { |
---|
4908 | $str .= '<tr align="center">' |
---|
4909 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
4910 | |
---|
4911 | $this->bo->cached_events = Array(); |
---|
4912 | $this->bo->so->owner = $part; |
---|
4913 | $this->bo->so->open_box($part); |
---|
4914 | $this->bo->store_to_cache( |
---|
4915 | Array( |
---|
4916 | 'syear' => $date['year'], |
---|
4917 | 'smonth'=> $date['month'], |
---|
4918 | 'sday' => $date['day'], |
---|
4919 | 'eyear' => 0, |
---|
4920 | 'emonth'=> 0, |
---|
4921 | 'eday' => $date['day'] + 1 |
---|
4922 | ) |
---|
4923 | ); |
---|
4924 | |
---|
4925 | if(!$this->bo->cached_events[$date['full']]) |
---|
4926 | { |
---|
4927 | for($j=0;$j<24;++$j) |
---|
4928 | { |
---|
4929 | for($k=0;$k<$interval;++$k) |
---|
4930 | { |
---|
4931 | $str .= '<td height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
4932 | } |
---|
4933 | $str .= "\n"; |
---|
4934 | } |
---|
4935 | } |
---|
4936 | else |
---|
4937 | { |
---|
4938 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
4939 | for($h=0;$h<24;++$h) |
---|
4940 | { |
---|
4941 | $hour = $h * 10000; |
---|
4942 | for($m=0;$m<$interval;$m++) |
---|
4943 | { |
---|
4944 | $index = ($hour + (($m * $increment) * 100)); |
---|
4945 | switch($time_slice[$index]['marker']) |
---|
4946 | { |
---|
4947 | case ' ': |
---|
4948 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
4949 | $extra = ''; |
---|
4950 | break; |
---|
4951 | case '-': |
---|
4952 | $time_slice[$index]['color'] = $this->theme['bg01']; |
---|
4953 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
4954 | $extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
4955 | break; |
---|
4956 | } |
---|
4957 | $str .= '<td bgcolor="'.$time_slice[$index]['color'].'" color="#999999"'.$extra.'><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$time_slice[$index]['marker'].'</font></td>'; |
---|
4958 | } |
---|
4959 | $str .= "\n"; |
---|
4960 | } |
---|
4961 | } |
---|
4962 | $str .= '</tr>' |
---|
4963 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
4964 | } |
---|
4965 | $this->bo->owner = $owner; |
---|
4966 | $this->bo->so->owner = $owner; |
---|
4967 | $this->bo->so->open_box($owner); |
---|
4968 | return $str.'</table></center>'."\n"; |
---|
4969 | } |
---|
4970 | |
---|
4971 | function get_response($cal_id) |
---|
4972 | { |
---|
4973 | $p = &$GLOBALS['phpgw']->template; |
---|
4974 | $p->set_file( |
---|
4975 | Array( |
---|
4976 | 'form_button' => 'form_button_script.tpl' |
---|
4977 | ) |
---|
4978 | ); |
---|
4979 | |
---|
4980 | $ev = $this->bo->get_cached_event(); |
---|
4981 | $response_choices = Array( |
---|
4982 | ACCEPTED => lang('Accept'), |
---|
4983 | REJECTED => lang('Reject'), |
---|
4984 | TENTATIVE => lang('Tentative') |
---|
4985 | ); |
---|
4986 | $str = ''; |
---|
4987 | while(list($param,$text) = each($response_choices)) |
---|
4988 | { |
---|
4989 | $var = Array( |
---|
4990 | 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user='.$this->bo->owner), |
---|
4991 | 'action_text_button' => ' '.$text.' ', |
---|
4992 | 'action_confirm_button' => '', |
---|
4993 | 'action_extra_field' => '' |
---|
4994 | ); |
---|
4995 | $p->set_var($var); |
---|
4996 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
4997 | } |
---|
4998 | if ($this->bo->return_to) |
---|
4999 | { |
---|
5000 | $var = Array( |
---|
5001 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
5002 | 'action_text_button' => lang('cancel'), |
---|
5003 | 'action_confirm_button' => '', |
---|
5004 | 'action_extra_field' => '' |
---|
5005 | ); |
---|
5006 | $p->set_var($var); |
---|
5007 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
5008 | } |
---|
5009 | $str = '<td><b>'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":</b></td>\n".$str; |
---|
5010 | |
---|
5011 | return '<table width="100%"><tr align="center">'."\n".$str.'</tr></table>'."\n"; |
---|
5012 | } |
---|
5013 | |
---|
5014 | function accounts_popup() |
---|
5015 | { |
---|
5016 | $GLOBALS['phpgw']->accounts->accounts_popup('calendar'); |
---|
5017 | |
---|
5018 | } |
---|
5019 | |
---|
5020 | function edit_form($param) |
---|
5021 | { |
---|
5022 | $sHValue = '<option></option> |
---|
5023 | <option value="07:00">07:00</option> |
---|
5024 | <option value="07:30">07:30</option> |
---|
5025 | <option value="08:00">08:00</option> |
---|
5026 | <option value="08:30">08:30</option> |
---|
5027 | <option value="09:00">09:00</option> |
---|
5028 | <option value="09:30">09:30</option> |
---|
5029 | <option value="10:00">10:00</option> |
---|
5030 | <option value="10:30">10:30</option> |
---|
5031 | <option value="11:00">11:00</option> |
---|
5032 | <option value="11:30">11:30</option> |
---|
5033 | <option value="12:00">12:00</option> |
---|
5034 | <option value="12:30">12:30</option> |
---|
5035 | <option value="13:00">13:00</option> |
---|
5036 | <option value="13:30">13:30</option> |
---|
5037 | <option value="14:00">14:00</option> |
---|
5038 | <option value="14:30">14:30</option> |
---|
5039 | <option value="15:00">15:00</option> |
---|
5040 | <option value="15:30">15:30</option> |
---|
5041 | <option value="16:00">16:00</option> |
---|
5042 | <option value="16:30">16:30</option> |
---|
5043 | <option value="17:00">17:00</option> |
---|
5044 | <option value="17:30">17:30</option> |
---|
5045 | <option value="18:00">18:00</option> |
---|
5046 | <option value="18:30">18:30</option> |
---|
5047 | <option value="19:00">19:00</option> |
---|
5048 | <option value="19:30">19:30</option> |
---|
5049 | <option value="20:00">20:00</option> |
---|
5050 | <option value="20:30">20:30</option> |
---|
5051 | <option value="21:00">21:00</option> |
---|
5052 | <option value="21:30">21:30</option> |
---|
5053 | <option value="22:00">22:00</option>'; |
---|
5054 | |
---|
5055 | if(!is_array($param)) |
---|
5056 | { |
---|
5057 | $this->index(); |
---|
5058 | } |
---|
5059 | |
---|
5060 | if(isset($param['event'])) |
---|
5061 | { |
---|
5062 | $event = $param['event']; |
---|
5063 | } |
---|
5064 | |
---|
5065 | include_once(dirname(__FILE__).'/class.ex_participants.inc.php'); |
---|
5066 | $langp = array(); |
---|
5067 | $langp['ACCEPTED'] = lang('Accepted'); |
---|
5068 | $langp['DECLINED'] = lang('Declined'); |
---|
5069 | $langp['TENTATIVE'] = lang('Tentative'); |
---|
5070 | $langp['DELEGATED'] = lang('Delegated'); |
---|
5071 | $langp['NO ANSWER'] = lang('No answer'); |
---|
5072 | $exParticipants = new exParticipants($langp); |
---|
5073 | $exParticipants->setParticipantsBySerializable($event['ex_participants']); |
---|
5074 | $event['ex_participants'] = $exParticipants->getParticipantsMailsString(); |
---|
5075 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
5076 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
5077 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
5078 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
5079 | |
---|
5080 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
5081 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
5082 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
5083 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
5084 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
5085 | if ($param['plain'] != "True"){ |
---|
5086 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
5087 | } |
---|
5088 | else{ |
---|
5089 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
5090 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
5091 | } |
---|
5092 | |
---|
5093 | $p = &$GLOBALS['phpgw']->template; |
---|
5094 | $p->set_file( |
---|
5095 | Array( |
---|
5096 | 'edit' => 'edit.tpl', |
---|
5097 | 'form_button' => 'form_button_script.tpl' |
---|
5098 | ) |
---|
5099 | ); |
---|
5100 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
5101 | $p->set_block('edit','list','list'); |
---|
5102 | $p->set_block('edit','hr','hr'); |
---|
5103 | $p->set_var('lang_set_participants', lang('set the participants')); |
---|
5104 | $vars = Array( |
---|
5105 | 'font' => $this->theme['font'], |
---|
5106 | 'bg_color' => $this->theme['bg_text'], |
---|
5107 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), |
---|
5108 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
5109 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
5110 | . '<input type="hidden" name="cal[date]" value="'.$param['date'].'">'."\n" |
---|
5111 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
5112 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
5113 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
5114 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
5115 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
5116 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
5117 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
5118 | ); |
---|
5119 | |
---|
5120 | $p->set_var($vars); |
---|
5121 | |
---|
5122 | // Brief Description |
---|
5123 | $var['title'] = Array( |
---|
5124 | 'tr_color' => $this->theme['th_bg'], |
---|
5125 | 'field' => lang('Title'), |
---|
5126 | 'data' => '<input name="cal[title]" size="45" maxlength="80" value="'.$event['title'].'">' |
---|
5127 | ); |
---|
5128 | |
---|
5129 | // Full Description |
---|
5130 | $var['description'] = Array( |
---|
5131 | 'field' => lang('Full Description'), |
---|
5132 | 'data' => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' |
---|
5133 | ); |
---|
5134 | |
---|
5135 | // Display Categories |
---|
5136 | if(strpos($event['category'],',')) |
---|
5137 | { |
---|
5138 | $temp_cats = explode(',',$event['category']); |
---|
5139 | @reset($temp_cats); |
---|
5140 | while(list($key,$value) = each($temp_cats)) |
---|
5141 | { |
---|
5142 | $check_cats[] = (int)$value; |
---|
5143 | } |
---|
5144 | } |
---|
5145 | elseif($event['category']) |
---|
5146 | { |
---|
5147 | $check_cats[] = (int)$event['category']; |
---|
5148 | } |
---|
5149 | else |
---|
5150 | { |
---|
5151 | $check_cats[] = 0; |
---|
5152 | } |
---|
5153 | $var['category'] = Array( |
---|
5154 | 'field' => lang('Category'), |
---|
5155 | 'data' => '<select name="categories[]" onchange="javascript:updateTitleField(this)" multiple size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
5156 | ); |
---|
5157 | |
---|
5158 | // Location |
---|
5159 | $var['location'] = Array( |
---|
5160 | 'field' => lang('Location'), |
---|
5161 | 'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">' |
---|
5162 | ); |
---|
5163 | |
---|
5164 | // Date |
---|
5165 | |
---|
5166 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5167 | $var['startdate'] = Array( |
---|
5168 | 'field' => lang('Start Date'), |
---|
5169 | /* |
---|
5170 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
5171 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
5172 | $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
5173 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) |
---|
5174 | ) |
---|
5175 | */ |
---|
5176 | 'data' => $jscal->input('start[str]',$start) |
---|
5177 | ); |
---|
5178 | |
---|
5179 | // Time |
---|
5180 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
5181 | { |
---|
5182 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
5183 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
5184 | } |
---|
5185 | $var['starttime'] = Array( |
---|
5186 | 'field' => lang('Start Time'), |
---|
5187 | 'data' => '<input name="start[hour]" id="start_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" id="start_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2"> <select name="sStartHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str |
---|
5188 | ); |
---|
5189 | |
---|
5190 | // End Date |
---|
5191 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5192 | $var['enddate'] = Array( |
---|
5193 | 'field' => lang('End Date'), |
---|
5194 | /* |
---|
5195 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
5196 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
5197 | $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
5198 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) |
---|
5199 | ) |
---|
5200 | */ |
---|
5201 | 'data' => $jscal->input('end[str]',$end) |
---|
5202 | ); |
---|
5203 | |
---|
5204 | // End Time |
---|
5205 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
5206 | { |
---|
5207 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
5208 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
5209 | } |
---|
5210 | $var['endtime'] = Array( |
---|
5211 | 'field' => lang('End Time'), |
---|
5212 | 'data' => '<input name="end[hour]" id="end_hour" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" id="end_minute" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2"> <select name="sEndHour" onchange="javascript:sChangeHour(this);">'.$sHValue.'</select>'."\n".$str |
---|
5213 | ); |
---|
5214 | |
---|
5215 | // Priority |
---|
5216 | $var['priority'] = Array( |
---|
5217 | 'field' => lang('Priority'), |
---|
5218 | 'data' => $sb->getPriority('cal[priority]',$event['priority']) |
---|
5219 | ); |
---|
5220 | |
---|
5221 | // Access |
---|
5222 | $var['access'] = Array( |
---|
5223 | 'field' => lang('Type'), |
---|
5224 | 'data' => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>' |
---|
5225 | ); //event['public'] |
---|
5226 | |
---|
5227 | // Participants |
---|
5228 | if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) |
---|
5229 | { |
---|
5230 | switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']) |
---|
5231 | { |
---|
5232 | case 'popup': |
---|
5233 | while (is_array($event['participants']) && list($id) = each($event['participants'])) |
---|
5234 | { |
---|
5235 | if($id != (int)$event['owner']) |
---|
5236 | { |
---|
5237 | $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) |
---|
5238 | .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . ' ('. $id.')</option>' . "\n"; |
---|
5239 | } |
---|
5240 | } |
---|
5241 | $var['participants'] = array |
---|
5242 | ( |
---|
5243 | 'field' => '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n" |
---|
5244 | . '<input type="hidden" name="accountid" value="' . $accountid . '">', |
---|
5245 | 'data' => "\n".' <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>' |
---|
5246 | ); |
---|
5247 | break; |
---|
5248 | default: |
---|
5249 | foreach($event['participants'] as $id => $participant) |
---|
5250 | { |
---|
5251 | if (($id != $event['owner']) && ($id != "")) |
---|
5252 | { |
---|
5253 | $GLOBALS['phpgw']->accounts->get_account_name($id, $lid, $fname, $lname); |
---|
5254 | $cn = $fname.' '.$lname; |
---|
5255 | $option = ' <option value="' . $id.$participant . '">'.$cn.'</option>'."\n"; |
---|
5256 | $str .= $option; |
---|
5257 | } |
---|
5258 | } |
---|
5259 | $str = utf8_decode($str); |
---|
5260 | $footer_ext_participantes = '<br> '.lang("The email addresses must be separated by ','"); |
---|
5261 | |
---|
5262 | $var['participants'] = array |
---|
5263 | ( |
---|
5264 | 'field' => lang('Participants'), |
---|
5265 | 'data' => " |
---|
5266 | <table width='100%' border='0'> |
---|
5267 | <tr> |
---|
5268 | <td width='30%'> |
---|
5269 | <center>Participantes</center> |
---|
5270 | </td> |
---|
5271 | <td width='8%' > </td> |
---|
5272 | <td width='40%'> </td> |
---|
5273 | </tr> |
---|
5274 | <tr> |
---|
5275 | <td width='30%'> |
---|
5276 | <center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center> |
---|
5277 | </td> |
---|
5278 | <td width='8%'> |
---|
5279 | <center> |
---|
5280 | <table width='100%' border='0'> |
---|
5281 | <tr height='5'><td> </td></tr> |
---|
5282 | <tr><td align='center'> |
---|
5283 | <button type='button' onClick='javascript:openListUsers(340,533, " |
---|
5284 | .$event['owner']. |
---|
5285 | ")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' > Adicionar</button> |
---|
5286 | </td> |
---|
5287 | </tr> |
---|
5288 | <tr height='5'><td> </td></tr> |
---|
5289 | <tr><td align='center'> |
---|
5290 | <button type='button' onClick='javascript:rem()'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/rem.png' style='vertical-align: middle;' > Remover</button> |
---|
5291 | </td> |
---|
5292 | </tr> |
---|
5293 | </table> |
---|
5294 | </center> |
---|
5295 | </td> |
---|
5296 | <td width='40%'> </td> |
---|
5297 | </tr> |
---|
5298 | </table> |
---|
5299 | " |
---|
5300 | ); |
---|
5301 | // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. |
---|
5302 | if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { |
---|
5303 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
5304 | |
---|
5305 | if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ |
---|
5306 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
5307 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
5308 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
5309 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
5310 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
5311 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
5312 | $user_context = array(); |
---|
5313 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
5314 | if($i) |
---|
5315 | $user_context[] = $dn_part; |
---|
5316 | } |
---|
5317 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
5318 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
5319 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
5320 | // Fim |
---|
5321 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
5322 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
5323 | //$combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
5324 | $footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail."); |
---|
5325 | //Caso o minimo de caracteres para a busca nao tenha sido preenchido ele sera por padrao = 3 |
---|
5326 | if(!$GLOBALS['phpgw_info']['server']['min_num_characters']){ |
---|
5327 | $GLOBALS['phpgw_info']['server']['min_num_characters'] = 0; |
---|
5328 | } |
---|
5329 | |
---|
5330 | if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ |
---|
5331 | $context = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$context); |
---|
5332 | $context = utf8_decode($context); |
---|
5333 | $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; |
---|
5334 | }else{ |
---|
5335 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
5336 | $combo_org = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''",$combo_org); |
---|
5337 | $combo_org = utf8_decode($combo_org); |
---|
5338 | } |
---|
5339 | |
---|
5340 | if ($param['plain'] != "True"){ |
---|
5341 | |
---|
5342 | // Begin load array lang |
---|
5343 | ob_start(); |
---|
5344 | //@include($module_name.'/inc/load_lang.php'); |
---|
5345 | $load_lang_vars = ob_get_contents(); |
---|
5346 | ob_end_clean(); |
---|
5347 | // End load array_lang |
---|
5348 | } |
---|
5349 | |
---|
5350 | $var['participants'] = array |
---|
5351 | ( |
---|
5352 | 'field' => ' |
---|
5353 | <script src="calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'].'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'> |
---|
5354 | <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe> |
---|
5355 | </div> |
---|
5356 | '.lang('Participants'), |
---|
5357 | 'data' => |
---|
5358 | '<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . |
---|
5359 | '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . |
---|
5360 | '<input type="hidden" id="txt_users" value="'.lang("Users").'">' . |
---|
5361 | '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . |
---|
5362 | '<input type="hidden" id="txt_shared_accounts" value="'.lang("shared accounts").'">' . |
---|
5363 | '<input type="hidden" id="txt_min_search" value="'.lang("Your search argument must be longer than 4 characters.").'">' . |
---|
5364 | '<input type="hidden" id="txt_none_result" value="'.lang("None result was found.").'">' . |
---|
5365 | '<input type="hidden" id="txt_Select_a_name" value="'.lang("Select a name").'">' . |
---|
5366 | '<input type="hidden" id="txt_Close" value="'.lang("Close").'">' . |
---|
5367 | '<input type="hidden" id="txt_More_than_%1_results._Please,_try_to_refine_your_search" value="'.lang("More than %1 results. Please, try to refine your search",'%1').'">' . |
---|
5368 | '<input type="hidden" id="txt_The_results_were_found_in_the_Global_Catalog" value="'.lang("The results were found in the Global Catalog").'">' . |
---|
5369 | '<table width="100%" border="0">'. |
---|
5370 | '<tr>'. |
---|
5371 | '<td width="25%"><br>'. |
---|
5372 | '<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" > '.lang("Add").'</button>'. |
---|
5373 | ' <button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" > '.lang("Remove").'</button>'. |
---|
5374 | '<br><br> <b>'.lang("Event's participants").'</b><br>'. |
---|
5375 | ' <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. |
---|
5376 | '</td>'. |
---|
5377 | '<td width="30px" valign="middle" align="center"> '. |
---|
5378 | '</td>'. |
---|
5379 | '<td valign="bottom">'. |
---|
5380 | ' '.lang("Organization").': '. |
---|
5381 | ' <select name="org_context" id="combo_org">'.$combo_org.'</select>'. |
---|
5382 | ' <br>'. |
---|
5383 | ' <font color="red"><span id="cal_span_searching"> </span></font>'. |
---|
5384 | ' <br>'.lang("Search for").':'. |
---|
5385 | ' <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeypress="return optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\', event);"><br>'. |
---|
5386 | ' <b>'.lang("Available users and groups").'</b><br>'. |
---|
5387 | ' <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. |
---|
5388 | '</td>'. |
---|
5389 | '</tr>'. |
---|
5390 | '<tr>' . |
---|
5391 | '<td>' . |
---|
5392 | '<button onclick="javascript:show_disponibility();" id="time_map" type="button">Mapa de disponibilidade</button><br>' . |
---|
5393 | '<b>'.lang("Can have users and groups that doesn't appears on the map").'</b><br>' . |
---|
5394 | '<td>' . |
---|
5395 | '</tr>' . |
---|
5396 | '</table>'. |
---|
5397 | '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. |
---|
5398 | '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'. |
---|
5399 | "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/finder.js' type='text/javascript'></script>" . |
---|
5400 | "<script src='calendar/templates/".$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']."/js/edit_exmail.js' type='text/javascript'></script>" . |
---|
5401 | $load_lang_vars. |
---|
5402 | "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". |
---|
5403 | "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". |
---|
5404 | "<script type='text/javascript'>" . |
---|
5405 | "var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". |
---|
5406 | "</script> " |
---|
5407 | ); |
---|
5408 | } |
---|
5409 | } |
---|
5410 | |
---|
5411 | $var['participants']['data'] .= '<a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . |
---|
5412 | " of this system").'" name="a_ext_participants" onClick="javascript:showExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants"><b>'.lang("Inform").' '.lang("external participants").'</b> <img align="top" ' . |
---|
5413 | 'src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif"></a><table id="tbl_ext_participants" width="100%" border="0" style="display:none">'. |
---|
5414 | '<tr>'. |
---|
5415 | '<td>'. |
---|
5416 | ' <b>'.lang("external participants").'</b> <img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' . |
---|
5417 | ' <a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a> '. |
---|
5418 | '</td>'. |
---|
5419 | '</tr>'. |
---|
5420 | '<tr>'. |
---|
5421 | '<td>'. |
---|
5422 | ' >> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. |
---|
5423 | ' <br> <input type="hidden" name="h_exParticipants" id="h_exParticipants" value="'.$exParticipants->getParticipantsSerializable().'" /> |
---|
5424 | <textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br> '. |
---|
5425 | $footer_ext_participantes. |
---|
5426 | '</tr>'. |
---|
5427 | '</table>'; |
---|
5428 | break; |
---|
5429 | |
---|
5430 | } |
---|
5431 | if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) |
---|
5432 | { |
---|
5433 | $checked = ' checked'; |
---|
5434 | } |
---|
5435 | else |
---|
5436 | { |
---|
5437 | $checked = ''; |
---|
5438 | } |
---|
5439 | $var['owner'] = Array( |
---|
5440 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
5441 | 'data' => '<input type="checkbox" id="usuarioParticipa" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>' |
---|
5442 | ); |
---|
5443 | } |
---|
5444 | |
---|
5445 | // Reminder |
---|
5446 | // The user must use "Alarm Management" to change/modify an alarm |
---|
5447 | // so only display the email reminder fields if this is a new event |
---|
5448 | // i.e. not editing an existing event |
---|
5449 | |
---|
5450 | if ($event['id'] == 0) { |
---|
5451 | // get defaults |
---|
5452 | $days = $this->bo->prefs['calendar']['default_email_days']; |
---|
5453 | $hours = $this->bo->prefs['calendar']['default_email_hours']; |
---|
5454 | $min = $this->bo->prefs['calendar']['default_email_min']; |
---|
5455 | if (count($event['alarm']) > 1) |
---|
5456 | { |
---|
5457 | // this should not happen because when creating a new event |
---|
5458 | // only 1 alarm is displayed on the screen |
---|
5459 | // if the user wants more than 1 alarm they should |
---|
5460 | // use "Alarm Management" |
---|
5461 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
5462 | } |
---|
5463 | // if there was an error pick up what the user entered |
---|
5464 | if (@isset($event['alarm'])) |
---|
5465 | { |
---|
5466 | @reset($event['alarm']); |
---|
5467 | // just get the first one see above!!! |
---|
5468 | list($key,$alarm) = @each($event['alarm']); |
---|
5469 | |
---|
5470 | |
---|
5471 | //if abaixo trata o caso de um evento repetido nao ter uma data final; |
---|
5472 | //se isto acontecer, nao havera alarmes definidos; |
---|
5473 | //$alarm['time'] recebe $start para $days, $hours e $min ficarem iguais a 0 |
---|
5474 | if(!$alarm['time']) { |
---|
5475 | $alarm['time'] = $start; |
---|
5476 | } |
---|
5477 | |
---|
5478 | $diff = $start - $alarm['time']; |
---|
5479 | $days = (int)($diff / (24*3600)); |
---|
5480 | $hours = (int)(($diff - ($days * 24 * 3600))/3600); |
---|
5481 | $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); |
---|
5482 | |
---|
5483 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') { |
---|
5484 | $days = $diff; |
---|
5485 | } |
---|
5486 | } |
---|
5487 | |
---|
5488 | // days |
---|
5489 | $dout = '<select name="cal[alarmdays]">'."\n"; |
---|
5490 | for($i=0;$i<32;++$i) |
---|
5491 | { |
---|
5492 | $dout .= '<option value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5493 | } |
---|
5494 | $dout .= '</select>'."\n".' '.lang('days').' '; |
---|
5495 | // hours |
---|
5496 | $hout = '<select name="cal[alarmhours]">'."\n"; |
---|
5497 | for($i=0;$i<25;++$i) |
---|
5498 | { |
---|
5499 | $hout .= '<option value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5500 | } |
---|
5501 | $hout .= '</select>'."\n".' '.lang('hours').' '; |
---|
5502 | // minutes |
---|
5503 | $mout = '<select name="cal[alarmminutes]">'."\n"; |
---|
5504 | for($i=0;$i<61;++$i) |
---|
5505 | { |
---|
5506 | $mout .= '<option value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5507 | } |
---|
5508 | $mout .= '</select>'."\n".' '.lang('minutes').' '; |
---|
5509 | |
---|
5510 | $var['alarm'] = Array( |
---|
5511 | 'field' => lang('Alarm'), |
---|
5512 | 'data' => $dout.$hout.$mout.lang('before the event') |
---|
5513 | ); |
---|
5514 | |
---|
5515 | } |
---|
5516 | |
---|
5517 | // Repeat Type |
---|
5518 | $str = ''; |
---|
5519 | foreach($this->bo->rpt_type as $type => $label) |
---|
5520 | { |
---|
5521 | $str .= '<option value="'.$type.'"'.($event['recur_type']==$type?' selected':'').'>'.lang($label).'</option>'; |
---|
5522 | } |
---|
5523 | $var['recure_type'] = Array( |
---|
5524 | 'field' => lang('Repeat Type'), |
---|
5525 | 'data' => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" |
---|
5526 | ); |
---|
5527 | |
---|
5528 | if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) |
---|
5529 | { |
---|
5530 | $checked = ' checked'; |
---|
5531 | $recur_end = $this->bo->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5532 | } |
---|
5533 | else |
---|
5534 | { |
---|
5535 | $checked = ''; |
---|
5536 | $recur_end = $this->bo->maketime($event['start']) + 86400 - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5537 | } |
---|
5538 | |
---|
5539 | $var['recure_enddate'] = Array( |
---|
5540 | 'field' => lang('Repeat End Date'), |
---|
5541 | 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. |
---|
5542 | /* |
---|
5543 | $GLOBALS['phpgw']->common->dateformatorder( |
---|
5544 | $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')), |
---|
5545 | $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')), |
---|
5546 | $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d')) |
---|
5547 | ) |
---|
5548 | */ |
---|
5549 | $jscal->input('recur_enddate[str]',$recur_end) |
---|
5550 | ); |
---|
5551 | |
---|
5552 | $i = 0; $boxes = ''; |
---|
5553 | foreach ($this->bo->rpt_day as $mask => $name) |
---|
5554 | { |
---|
5555 | $boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? ' checked' : '').'> '.lang($name)."\n"; |
---|
5556 | if (++$i == 5) $boxes .= '<br>'; |
---|
5557 | } |
---|
5558 | $var['recure_day'] = Array( |
---|
5559 | 'field' => lang('Repeat Day').'<br>'.lang('(required for weekly recursivity)'), |
---|
5560 | 'data' => $boxes |
---|
5561 | ); |
---|
5562 | |
---|
5563 | $var['recure_interval'] = Array( |
---|
5564 | 'field' => lang('Interval'), |
---|
5565 | 'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="'.$event['recur_interval'].'">' |
---|
5566 | ); |
---|
5567 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
5568 | |
---|
5569 | if (!isset($this->fields)) |
---|
5570 | { |
---|
5571 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
5572 | $this->fields = &$this->custom_fields->fields; |
---|
5573 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
5574 | } |
---|
5575 | $this->output_template_array($p,'row','list',$var['access']); |
---|
5576 | unset($var['access']); |
---|
5577 | |
---|
5578 | $preserved = False; |
---|
5579 | foreach($this->fields as $field => $data) |
---|
5580 | { |
---|
5581 | if (!$data['disabled']) |
---|
5582 | { |
---|
5583 | if (isset($var[$field])) |
---|
5584 | { |
---|
5585 | switch($field) |
---|
5586 | { |
---|
5587 | case 'startdate': |
---|
5588 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
5589 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
5590 | break; |
---|
5591 | case 'enddate': |
---|
5592 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
5593 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
5594 | break; |
---|
5595 | case 'recure_type': |
---|
5596 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
5597 | $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
5598 | $p->parse('row','hr',True); |
---|
5599 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
5600 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
5601 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
5602 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
5603 | break; |
---|
5604 | default: |
---|
5605 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
5606 | } |
---|
5607 | } |
---|
5608 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
5609 | { |
---|
5610 | $lang = lang($name = substr($field,1)); |
---|
5611 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
5612 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
5613 | $v = array( |
---|
5614 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
5615 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
5616 | ); |
---|
5617 | if ($data['title']) |
---|
5618 | { |
---|
5619 | $v['tr_color'] = $this->theme['th_bg']; |
---|
5620 | } |
---|
5621 | if (!$data['length'] && $data['title']) |
---|
5622 | { |
---|
5623 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
5624 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
5625 | $p->parse('row','hr',True); |
---|
5626 | } |
---|
5627 | else |
---|
5628 | { |
---|
5629 | $this->output_template_array($p,'row','list',$v); |
---|
5630 | } |
---|
5631 | } |
---|
5632 | } |
---|
5633 | else // preserve disabled fields |
---|
5634 | { |
---|
5635 | switch ($field) |
---|
5636 | { |
---|
5637 | case 'owner': |
---|
5638 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
5639 | break; |
---|
5640 | case 'recure_type': |
---|
5641 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
5642 | { |
---|
5643 | $preserved[$field] = $event[$field]; |
---|
5644 | } |
---|
5645 | break; |
---|
5646 | case 'startdate': |
---|
5647 | case 'enddate': |
---|
5648 | $field = substr($field,0,-4); |
---|
5649 | default: |
---|
5650 | $preserved[$field] = $event[$field]; |
---|
5651 | } |
---|
5652 | } |
---|
5653 | } |
---|
5654 | unset($var); |
---|
5655 | if (is_array($preserved)) |
---|
5656 | { |
---|
5657 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
5658 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
5659 | } |
---|
5660 | $p->set_var('submit_button',lang('Save')); |
---|
5661 | |
---|
5662 | $delete_button = $cancel_button = ''; |
---|
5663 | if ($event['id'] > 0) |
---|
5664 | { |
---|
5665 | $var = Array( |
---|
5666 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
5667 | 'action_text_button' => lang('Delete'), |
---|
5668 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
5669 | 'action_extra_field' => '', |
---|
5670 | 'button_id' => 'delete_button' |
---|
5671 | ); |
---|
5672 | $p->set_var($var); |
---|
5673 | $delete_button = $p->fp('out','form_button'); |
---|
5674 | } |
---|
5675 | $p->set_var('delete_button',$delete_button); |
---|
5676 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
5677 | |
---|
5678 | if ($this->bo->return_to) |
---|
5679 | { |
---|
5680 | $var = Array( |
---|
5681 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
5682 | 'action_text_button' => lang('Cancel'), |
---|
5683 | 'action_confirm_button' => '', |
---|
5684 | 'action_extra_field' => '', |
---|
5685 | 'button_id' => 'cancel_button' |
---|
5686 | ); |
---|
5687 | $p->set_var($var); |
---|
5688 | $cancel_button = $p->fp('out','form_button'); |
---|
5689 | } |
---|
5690 | $p->set_var('cancel_button',$cancel_button); |
---|
5691 | $p->pparse('out','edit_entry'); |
---|
5692 | } |
---|
5693 | |
---|
5694 | // modify list of an event's external participants (i.e. non pgpgw users) |
---|
5695 | // |
---|
5696 | function modify_ext_partlist() |
---|
5697 | { |
---|
5698 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
5699 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
5700 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
5701 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
5702 | |
---|
5703 | $total_contacts = 0; |
---|
5704 | $participant = array(); |
---|
5705 | $control_data= array(); |
---|
5706 | |
---|
5707 | $control_data['action'] = ''; |
---|
5708 | $control_data['delete'] = array(); |
---|
5709 | $control_data['part'] = array(); |
---|
5710 | |
---|
5711 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
5712 | $p->set_file( |
---|
5713 | Array( |
---|
5714 | 'T_edit_partlist' => 'edit_partlist.tpl', |
---|
5715 | 'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl' |
---|
5716 | ) |
---|
5717 | ); |
---|
5718 | |
---|
5719 | $p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg'); |
---|
5720 | $p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist'); |
---|
5721 | $p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none'); |
---|
5722 | $p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn'); |
---|
5723 | |
---|
5724 | global $query_addr; |
---|
5725 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
5726 | $addy = $sb->getAddress('addr','',$query_addr); |
---|
5727 | |
---|
5728 | $add_ext = $addy['doSearchFkt']; |
---|
5729 | $add_ext .= $addy['addr_title']!=lang('Address Book')?$addy['addr_title']:''; |
---|
5730 | $add_ext .= " ".$addy['addr'].$addy['addr_nojs']; |
---|
5731 | |
---|
5732 | $p->set_var('text_add_name',$add_ext); |
---|
5733 | |
---|
5734 | if(isset($_GET['part']) && $_GET['part']) |
---|
5735 | { |
---|
5736 | $control_data['part'] = preg_split('/,/', $_GET['part']); |
---|
5737 | } |
---|
5738 | else |
---|
5739 | { |
---|
5740 | $control_data['part'] = $_POST['participant']; |
---|
5741 | $control_data['action'] = $_POST['action']; |
---|
5742 | $control_data['delete'] = $_POST['delete']; |
---|
5743 | } |
---|
5744 | |
---|
5745 | $control_data_count = count($control_data['part']); |
---|
5746 | for ($i=0; $i<$control_data_count; ++$i) |
---|
5747 | { |
---|
5748 | $id = $control_data['part'][$i]; |
---|
5749 | list($contact) = $this->read_contact($id); |
---|
5750 | |
---|
5751 | $participant[$id] = array(); |
---|
5752 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
5753 | } |
---|
5754 | |
---|
5755 | if ($control_data['action'] == lang('Delete selected contacts')) |
---|
5756 | { |
---|
5757 | $control_data_count = count($control_data['delete']); |
---|
5758 | for ($i=0; $i<$control_data_count; ++$i) |
---|
5759 | { |
---|
5760 | $id = $control_data['delete'][$i]; |
---|
5761 | unset($participant[$id]); |
---|
5762 | } |
---|
5763 | } |
---|
5764 | |
---|
5765 | if ($control_data['action'] == lang('Add Contact')) |
---|
5766 | { |
---|
5767 | $id = $_POST['id_addr']; |
---|
5768 | if (isset($id) && (int)$id != 0) |
---|
5769 | { |
---|
5770 | list($contact) = $this->read_contact($id); |
---|
5771 | $participant[$id] = array(); |
---|
5772 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
5773 | } |
---|
5774 | } |
---|
5775 | |
---|
5776 | // create list of currently selected contacts |
---|
5777 | // |
---|
5778 | while(list($id,$contact) = each($participant)) |
---|
5779 | { |
---|
5780 | $p->set_var('hidden_delete_name','participant[]'); |
---|
5781 | $p->set_var('hidden_delete_value',$id); |
---|
5782 | $p->set_var('ckbox_delete_name','delete[]'); |
---|
5783 | $p->set_var('ckbox_delete_value',$id); |
---|
5784 | $p->set_var('ckbox_delete_participant',$contact['name']); |
---|
5785 | $p->parse('V_partlist','B_partlist',True); |
---|
5786 | ++$total_contacts; |
---|
5787 | } |
---|
5788 | |
---|
5789 | if ($total_contacts == 0) |
---|
5790 | { |
---|
5791 | // no contacts have been selected |
---|
5792 | // => clear the delete form, remove delete button and show the none block |
---|
5793 | // |
---|
5794 | $p->set_var('V_partlist',''); |
---|
5795 | $p->set_var('V_delete_btn',''); |
---|
5796 | $p->set_var('text_none',lang('None')); |
---|
5797 | $p->parse('V_participants_none','B_participants_none'); |
---|
5798 | } |
---|
5799 | else |
---|
5800 | { |
---|
5801 | // at least one contact has been selected |
---|
5802 | // => clear the none block, fill the delete form and add delete button |
---|
5803 | // |
---|
5804 | $p->set_var('V_participants_none',''); |
---|
5805 | $p->set_var('btn_delete_name','action'); |
---|
5806 | $p->set_var('btn_delete_value',lang('Delete selected contacts')); |
---|
5807 | $p->parse('V_delete_btn','B_delete_btn'); |
---|
5808 | } |
---|
5809 | |
---|
5810 | $body_tags = 'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color'] |
---|
5811 | . '" alink="'.$GLOBALS['phpgw_info']['theme']['alink'] |
---|
5812 | . '" link="'.$GLOBALS['phpgw_info']['theme']['link'] |
---|
5813 | .'" vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"'; |
---|
5814 | |
---|
5815 | $form_action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify')); |
---|
5816 | |
---|
5817 | $charset = lang('charset'); |
---|
5818 | $p->set_var('charset',$charset); |
---|
5819 | $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] |
---|
5820 | . ' - ' .lang('External Participants')); |
---|
5821 | $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); |
---|
5822 | $p->set_var('body_tags',$body_tags); |
---|
5823 | $p->set_var('form_method','POST'); |
---|
5824 | $p->set_var('form_action',$form_action); |
---|
5825 | $p->set_var('text_add_contact',lang('External Participants')); |
---|
5826 | $p->set_var('text_contacts_selected',lang('Selected contacts (%1)',$total_contacts)); |
---|
5827 | $p->set_var('btn_add_name','action'); |
---|
5828 | $p->set_var('btn_add_value',lang('Add Contact')); |
---|
5829 | $p->set_var('btn_done_name','done'); |
---|
5830 | $p->set_var('btn_done_value',lang('Done')); |
---|
5831 | $p->set_var('btn_done_js','copyback()'); |
---|
5832 | $p->set_var('form1_name','ext_form'); |
---|
5833 | |
---|
5834 | $p->pfp('out','T_edit_partlist'); |
---|
5835 | } |
---|
5836 | |
---|
5837 | function read_contact($id) |
---|
5838 | { |
---|
5839 | $query_fields = Array( |
---|
5840 | 'n_given' => 'n_given', |
---|
5841 | 'n_family' => 'n_family', |
---|
5842 | 'email' => 'email', |
---|
5843 | 'email_home' => 'email_home' |
---|
5844 | ); |
---|
5845 | |
---|
5846 | /* |
---|
5847 | if ($this->rights & PHPGW_ACL_READ) |
---|
5848 | { |
---|
5849 | return $this->contacts->read_single_entry($id,$fields); |
---|
5850 | } |
---|
5851 | else |
---|
5852 | { |
---|
5853 | $rtrn = array(0 => array('No access' => 'No access')); |
---|
5854 | return $rtrn; |
---|
5855 | } |
---|
5856 | */ |
---|
5857 | |
---|
5858 | $contacts = CreateObject('phpgwapi.contacts', False); |
---|
5859 | return $contacts->read_single_entry($id,$query_fields); |
---|
5860 | } |
---|
5861 | |
---|
5862 | function build_part_list(&$users,$accounts,$owner) |
---|
5863 | { |
---|
5864 | if(!is_array($accounts)) |
---|
5865 | { |
---|
5866 | return; |
---|
5867 | } |
---|
5868 | foreach($accounts as $id) |
---|
5869 | { |
---|
5870 | $id = (int)$id; |
---|
5871 | if($id == $owner) |
---|
5872 | { |
---|
5873 | continue; |
---|
5874 | } |
---|
5875 | elseif(!isset($users[$id])) |
---|
5876 | { |
---|
5877 | if($GLOBALS['phpgw']->accounts->exists($id) == True) |
---|
5878 | { |
---|
5879 | $users[$id] = Array( |
---|
5880 | 'name' => $GLOBALS['phpgw']->common->grab_owner_name($id), |
---|
5881 | 'type' => $GLOBALS['phpgw']->accounts->get_type($id) |
---|
5882 | ); |
---|
5883 | } |
---|
5884 | if($GLOBALS['phpgw']->accounts->get_type($id) == 'g') |
---|
5885 | { |
---|
5886 | //$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner); |
---|
5887 | } |
---|
5888 | } |
---|
5889 | } |
---|
5890 | if (!function_exists('strcmp_name')) |
---|
5891 | { |
---|
5892 | function strcmp_name($arr1,$arr2) |
---|
5893 | { |
---|
5894 | if ($diff = strcmp($arr1['type'],$arr2['type'])) |
---|
5895 | { |
---|
5896 | return $diff; // groups before users |
---|
5897 | } |
---|
5898 | return strnatcasecmp($arr1['name'],$arr2['name']); |
---|
5899 | } |
---|
5900 | } |
---|
5901 | uasort($users,'strcmp_name'); |
---|
5902 | } |
---|
5903 | |
---|
5904 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
5905 | { |
---|
5906 | $data = date("m"); |
---|
5907 | for ($j=0,$datetime=$startdate;$j<7;++$j,$datetime += 86400) |
---|
5908 | { |
---|
5909 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
5910 | print_debug('set_week_array : Date ',$date); |
---|
5911 | |
---|
5912 | if($events = $this->bo->cached_events[$date]) |
---|
5913 | { |
---|
5914 | print_debug('Date',$date); |
---|
5915 | print_debug('Appointments Found',count($events)); |
---|
5916 | |
---|
5917 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
5918 | { |
---|
5919 | $appts = False; |
---|
5920 | foreach($events as $event) // check for a not-rejected event |
---|
5921 | { |
---|
5922 | if (!$this->bo->rejected_no_show($event)) |
---|
5923 | { |
---|
5924 | $appts = True; |
---|
5925 | break; |
---|
5926 | } |
---|
5927 | } |
---|
5928 | } |
---|
5929 | else |
---|
5930 | { |
---|
5931 | $appts = True; |
---|
5932 | } |
---|
5933 | } |
---|
5934 | else |
---|
5935 | { |
---|
5936 | $appts = False; |
---|
5937 | } |
---|
5938 | |
---|
5939 | $holidays = $this->bo->cached_holidays[$date]; |
---|
5940 | if($weekly) |
---|
5941 | { |
---|
5942 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
5943 | } |
---|
5944 | |
---|
5945 | $day_image = ''; |
---|
5946 | if($holidays) |
---|
5947 | { |
---|
5948 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
5949 | $class = ($appts?'b':'').'minicalhol'; |
---|
5950 | if ($date == $this->bo->today) |
---|
5951 | { |
---|
5952 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
5953 | } |
---|
5954 | } |
---|
5955 | elseif ($date != $this->bo->today) |
---|
5956 | { |
---|
5957 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
5958 | $class = ($appts?'b':'').'minicalendar'; |
---|
5959 | } |
---|
5960 | else |
---|
5961 | { |
---|
5962 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
5963 | $class = ($appts?'b':'').'minicalendar'; |
---|
5964 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
5965 | } |
---|
5966 | |
---|
5967 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
5968 | { |
---|
5969 | $extra = ''; |
---|
5970 | } |
---|
5971 | |
---|
5972 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
5973 | { |
---|
5974 | $new_event = True; |
---|
5975 | } |
---|
5976 | else |
---|
5977 | { |
---|
5978 | $new_event = False; |
---|
5979 | } |
---|
5980 | $holiday_name = Array(); |
---|
5981 | if($holidays) |
---|
5982 | { |
---|
5983 | $holidays_count = count($holidays); |
---|
5984 | for($k=0;$k<$holidays_count;++$k) |
---|
5985 | { |
---|
5986 | $holiday_name[] = $holidays[$k]['name']; |
---|
5987 | } |
---|
5988 | } |
---|
5989 | $week = ''; |
---|
5990 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
5991 | { |
---|
5992 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
5993 | } |
---|
5994 | $daily[$date] = Array( |
---|
5995 | 'extra' => $extra, |
---|
5996 | 'new_event' => $new_event, |
---|
5997 | 'holidays' => $holiday_name, |
---|
5998 | 'appts' => $appts, |
---|
5999 | 'week' => $week, |
---|
6000 | 'day_image' => $day_image, |
---|
6001 | 'class' => $class |
---|
6002 | ); |
---|
6003 | } |
---|
6004 | |
---|
6005 | if($this->debug) |
---|
6006 | { |
---|
6007 | _debug_array($daily); |
---|
6008 | } |
---|
6009 | |
---|
6010 | return $daily; |
---|
6011 | } |
---|
6012 | |
---|
6013 | function get_organizations($context, $selected='', $recursive = false) |
---|
6014 | { |
---|
6015 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
6016 | |
---|
6017 | return ($recursive ? |
---|
6018 | $s->get_organizations($context, $selected, false ,false) : |
---|
6019 | $s->get_sectors($selected, false, false)); |
---|
6020 | } |
---|
6021 | } |
---|
6022 | ?> |
---|