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 | 'screen_delegate_event' => True, |
---|
60 | 'delegate_event' => True, |
---|
61 | 'mini_calendar' => True, |
---|
62 | 'index' => True, |
---|
63 | 'month' => True, |
---|
64 | 'get_month' => True, |
---|
65 | 'week' => True, |
---|
66 | 'get_week' => True, |
---|
67 | 'year' => True, |
---|
68 | 'view' => 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']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
95 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
96 | |
---|
97 | $this->theme = $GLOBALS['phpgw_info']['theme']; |
---|
98 | |
---|
99 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
100 | $this->cat = &$this->bo->cat; |
---|
101 | |
---|
102 | print_debug('BO Owner',$this->bo->owner); |
---|
103 | |
---|
104 | $this->template = $GLOBALS['phpgw']->template; |
---|
105 | $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('calendar'); |
---|
106 | |
---|
107 | $this->holiday_color = (substr($this->theme['bg06'],0,1)=='#'?'':'#').$this->theme['bg06']; |
---|
108 | |
---|
109 | $this->cat_id = $this->bo->cat_id; |
---|
110 | |
---|
111 | $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
112 | $this->link_tpl->set_unknowns('remove'); |
---|
113 | $this->link_tpl->set_file( |
---|
114 | Array( |
---|
115 | 'link_picture' => 'link_pict.tpl' |
---|
116 | ) |
---|
117 | ); |
---|
118 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
119 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
120 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
121 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
122 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
123 | |
---|
124 | /*************** EVENTO **************************/ |
---|
125 | /* Este bloco de codigo foi adicionado pois os eventos de agendamento (exibicao do mes) para impressao serao tratados em outro template |
---|
126 | (event_link.tpl) */ |
---|
127 | |
---|
128 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
129 | $this->event_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
130 | $this->event_tpl->set_unknowns('remove'); |
---|
131 | $this->event_tpl->set_file( |
---|
132 | Array( |
---|
133 | 'link_event' => 'event_link.tpl' |
---|
134 | ) |
---|
135 | ); |
---|
136 | $this->event_tpl->set_block('link_event','link_event_pict','link_event_pict'); |
---|
137 | $this->event_tpl->set_block('link_event','event_pict','event_pict'); |
---|
138 | $this->event_tpl->set_block('link_event','link_event_open','link_event_open'); |
---|
139 | $this->event_tpl->set_block('link_event','link_event_close','link_event_close'); |
---|
140 | $this->event_tpl->set_block('link_event','link_event_text','link_event_text'); |
---|
141 | |
---|
142 | |
---|
143 | /*************************************************/ |
---|
144 | |
---|
145 | if($this->bo->use_session) |
---|
146 | { |
---|
147 | // save return-fkt for add, view, ... |
---|
148 | list(,,$fkt) = explode('.',$_GET['menuaction']); |
---|
149 | if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') |
---|
150 | { |
---|
151 | $this->bo->return_to = $_GET['menuaction']. |
---|
152 | sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); |
---|
153 | } |
---|
154 | $this->bo->save_sessiondata(); |
---|
155 | } |
---|
156 | $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots'; |
---|
157 | |
---|
158 | print_debug('UI',$this->_debug_sqsof()); |
---|
159 | |
---|
160 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
161 | { |
---|
162 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
163 | } |
---|
164 | $this->html = &$GLOBALS['phpgw']->html; |
---|
165 | } |
---|
166 | |
---|
167 | function screen_delegate_event($params=NULL) { |
---|
168 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
169 | |
---|
170 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
171 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
172 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
173 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
174 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
175 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
176 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Calendar - Edit') : lang('Calendar - Add'); |
---|
177 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
178 | |
---|
179 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
180 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
181 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
182 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
183 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
184 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
185 | $user_context = array(); |
---|
186 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
187 | if($i) |
---|
188 | $user_context[] = $dn_part; |
---|
189 | } |
---|
190 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
191 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
192 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
193 | // Fim |
---|
194 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
195 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
196 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
197 | |
---|
198 | $var = array( |
---|
199 | "module_name" => $module_name, |
---|
200 | "lang_loading" => lang("Loading"), |
---|
201 | "lang_searching" => lang("Searching"), |
---|
202 | "lang_users" => lang("Users"), |
---|
203 | "lang_groups" => lang("Groups"), |
---|
204 | "recursive" => ($recursive)?"":"search", |
---|
205 | "options" => $combo_org, |
---|
206 | "id_event" => $_REQUEST["id_event"], |
---|
207 | "eventArray" => $_REQUEST["eventArray"], |
---|
208 | "delegator" => $_REQUEST["delegator"], |
---|
209 | "lang_avaliable_users" => lang("Available Users and Groups"), |
---|
210 | "lang_search_for" => lang("Search for"), |
---|
211 | "lang_ou" => lang("Organization"), |
---|
212 | "min_num_characters" => $GLOBALS['phpgw_info']['server']['min_num_characters'], |
---|
213 | "date" => $_REQUEST["date"], |
---|
214 | "eventDelegation" => 1, |
---|
215 | "Delegate" => lang("Delegate"), |
---|
216 | 'url_template' => 'calendar/templates/'.$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set'] |
---|
217 | ); |
---|
218 | |
---|
219 | if(isset($_REQUEST["error"])) |
---|
220 | { |
---|
221 | if($_REQUEST["error"] == 999){ |
---|
222 | $var['error_msg'] = lang("Problems delegating. Make sure you have selected a user to delegate the appointment."); |
---|
223 | }else { |
---|
224 | $var['error_msg'] = lang("Problems delegating. Make sure you haven't delegated to a person that was also invited to the meeting"); |
---|
225 | } |
---|
226 | } |
---|
227 | |
---|
228 | $template = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
229 | $template->set_file( |
---|
230 | array( |
---|
231 | "screen"=>"delegate.tpl" |
---|
232 | ) |
---|
233 | ); |
---|
234 | $template->set_var($var); |
---|
235 | print $template->fp('out','screen'); |
---|
236 | } |
---|
237 | |
---|
238 | |
---|
239 | function delegate_event($params=NULL) { |
---|
240 | $ldap = CreateObject('expressoMail1_2.ldap_functions'); |
---|
241 | $delegated = $ldap->uid2uidnumber($_REQUEST['delegated']); |
---|
242 | |
---|
243 | try { |
---|
244 | $this->bo->delegar($_REQUEST['delegator'],$ldap->uid2uidnumber($_REQUEST['delegated'])/*$delegated*/,$_REQUEST['event']); |
---|
245 | header("Location: index.php?menuaction=calendar.uicalendar.day&date=".$_REQUEST['date']); |
---|
246 | }catch(Exception $e) { |
---|
247 | if($e->getMessage() == '999') { |
---|
248 | header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=999"); |
---|
249 | }else { |
---|
250 | header("Location: index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event=". $_REQUEST["event"]."&delegator=".$_REQUEST["delegator"]."&date=".$_REQUEST["date"]."&error=1"); |
---|
251 | } |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | /* Public functions */ |
---|
256 | |
---|
257 | function mini_calendar($params) |
---|
258 | { |
---|
259 | static $mini_cal_tpl; |
---|
260 | if(!is_array($params)) |
---|
261 | { |
---|
262 | return; |
---|
263 | } |
---|
264 | |
---|
265 | if($params['month'] == 0) |
---|
266 | { |
---|
267 | $params['month'] = 12; |
---|
268 | $params['year'] = $params['year'] - 1; |
---|
269 | } |
---|
270 | elseif($params['month'] == 13) |
---|
271 | { |
---|
272 | $params['month'] = 1; |
---|
273 | $params['year'] = $params['year'] + 1; |
---|
274 | } |
---|
275 | |
---|
276 | $this->bo->store_to_cache( |
---|
277 | Array( |
---|
278 | 'smonth' => $params['month'], |
---|
279 | 'sday' => 1, |
---|
280 | 'syear' => $params['year'] |
---|
281 | ) |
---|
282 | ); |
---|
283 | |
---|
284 | $params['link'] = (!isset($params['link'])?'':$params['link']); |
---|
285 | $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); |
---|
286 | $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); |
---|
287 | |
---|
288 | $this->bo->read_holidays($params['year']); |
---|
289 | |
---|
290 | $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); |
---|
291 | $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); |
---|
292 | $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); |
---|
293 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); |
---|
294 | $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); |
---|
295 | |
---|
296 | $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); |
---|
297 | |
---|
298 | print_debug('mini_calendar:monthstart',$monthstart); |
---|
299 | print_debug('mini_calendar:weekstarttime',date('Ymd H:i:s',$weekstarttime)); |
---|
300 | |
---|
301 | if(!is_object($mini_cal_tpl)) |
---|
302 | { |
---|
303 | $mini_cal_tpl = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
304 | $mini_cal_tpl->set_unknowns('remove'); |
---|
305 | $mini_cal_tpl->set_file( |
---|
306 | Array( |
---|
307 | 'mini_calendar' => 'mini_cal.tpl' |
---|
308 | ) |
---|
309 | ); |
---|
310 | $mini_cal_tpl->set_block('mini_calendar','mini_cal','mini_cal'); |
---|
311 | $mini_cal_tpl->set_block('mini_calendar','mini_week','mini_week'); |
---|
312 | $mini_cal_tpl->set_block('mini_calendar','mini_day','mini_day'); |
---|
313 | } |
---|
314 | |
---|
315 | |
---|
316 | if($this->bo->printer_friendly == False) |
---|
317 | { |
---|
318 | //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>'; |
---|
319 | $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>'; |
---|
320 | } |
---|
321 | else |
---|
322 | { |
---|
323 | $month = lang($GLOBALS['phpgw']->common->show_date($date['raw'],'F')).' '.$GLOBALS['phpgw']->common->show_date($date['raw'],'Y'); |
---|
324 | } |
---|
325 | |
---|
326 | $var = Array( |
---|
327 | 'cal_img_root' => $GLOBALS['phpgw']->common->image('calendar','mini-calendar-bar'), |
---|
328 | 'bgcolor' => $this->theme['bg_color'], |
---|
329 | 'bgcolor1' => $this->theme['bg_color'], |
---|
330 | 'month' => $month, |
---|
331 | 'bgcolor2' => $this->theme['cal_dayview'], |
---|
332 | 'holiday_color' => $this->holiday_color |
---|
333 | ); |
---|
334 | |
---|
335 | $mini_cal_tpl->set_var($var); |
---|
336 | |
---|
337 | switch(strtolower($params['buttons'])) |
---|
338 | { |
---|
339 | case 'right': |
---|
340 | $var = Array( |
---|
341 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
342 | ); |
---|
343 | break; |
---|
344 | case 'left': |
---|
345 | $var = Array( |
---|
346 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>' |
---|
347 | ); |
---|
348 | break; |
---|
349 | case 'both': |
---|
350 | $var = Array( |
---|
351 | 'prevmonth' => '<a href="'.$this->page('month','&date='.$month_ago).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','left').'" border="0"></a>', |
---|
352 | 'nextmonth' => '<a href="'.$this->page('month','&date='.$month_ahead).'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','right').'" border="0"></a>' |
---|
353 | ); |
---|
354 | break; |
---|
355 | case 'none': |
---|
356 | default: |
---|
357 | $var = Array( |
---|
358 | 'prevmonth' => '', |
---|
359 | 'nextmonth' => '' |
---|
360 | ); |
---|
361 | break; |
---|
362 | } |
---|
363 | $mini_cal_tpl->set_var($var); |
---|
364 | |
---|
365 | if(!$mini_cal_tpl->get_var('daynames')) |
---|
366 | { |
---|
367 | for($i=0;$i<7;$i++) |
---|
368 | { |
---|
369 | $var = Array( |
---|
370 | 'dayname' => '<b>' . lang($GLOBALS['phpgw']->datetime->days_short[$i]) . '</b>', |
---|
371 | 'day_image' => '' |
---|
372 | ); |
---|
373 | $this->output_template_array($mini_cal_tpl,'daynames','mini_day',$var); |
---|
374 | } |
---|
375 | } |
---|
376 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
377 | unset($date); |
---|
378 | for($i=$weekstarttime + $GLOBALS['phpgw']->datetime->tz_offset;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) |
---|
379 | { |
---|
380 | unset($var); |
---|
381 | $daily = $this->set_week_array($i - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
382 | foreach($daily as $date => $day_params) |
---|
383 | { |
---|
384 | print_debug('Mini-Cal Date',$date); |
---|
385 | $year = (int)(substr($date,0,4)); |
---|
386 | $month = (int)(substr($date,4,2)); |
---|
387 | $day = (int)(substr($date,6,2)); |
---|
388 | $str = ''; |
---|
389 | if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) |
---|
390 | { |
---|
391 | if(!$this->bo->printer_friendly && $params['link']) |
---|
392 | { |
---|
393 | //NDEE: class def what for? |
---|
394 | $str = '<a href="'.$this->page($params['link'],'&date='.$date).'" class="'.$day_params['class'].'">'.$day.'</a>'; |
---|
395 | } |
---|
396 | else |
---|
397 | { |
---|
398 | |
---|
399 | //NDEE: printer-friendly (mini-calendar) |
---|
400 | $str = $day; |
---|
401 | } |
---|
402 | |
---|
403 | } |
---|
404 | else |
---|
405 | { |
---|
406 | $day_params['day_image'] = ''; |
---|
407 | } |
---|
408 | $var[] = Array( |
---|
409 | 'day_image' => $day_params['day_image'], |
---|
410 | 'dayname' => $str |
---|
411 | ); |
---|
412 | } |
---|
413 | for($l=0;$l<count($var);$l++) |
---|
414 | { |
---|
415 | $this->output_template_array($mini_cal_tpl,'monthweek_day','mini_day',$var[$l]); |
---|
416 | } |
---|
417 | $mini_cal_tpl->parse('display_monthweek','mini_week',True); |
---|
418 | $mini_cal_tpl->set_var('dayname',''); |
---|
419 | $mini_cal_tpl->set_var('monthweek_day',''); |
---|
420 | } |
---|
421 | |
---|
422 | $return_value = $mini_cal_tpl->fp('out','mini_cal'); |
---|
423 | $mini_cal_tpl->set_var('display_monthweek',''); |
---|
424 | // $mini_cal_tpl->set_var('daynames',''); |
---|
425 | // unset($p); |
---|
426 | return $return_value; |
---|
427 | } |
---|
428 | |
---|
429 | function index($params='') |
---|
430 | { |
---|
431 | if (!$params) |
---|
432 | { |
---|
433 | foreach(array('date','year','month','day') as $field) |
---|
434 | { |
---|
435 | if (isset($_GET[$field])) |
---|
436 | { |
---|
437 | $params[$field] = $_GET[$field]; |
---|
438 | } |
---|
439 | } |
---|
440 | } |
---|
441 | $GLOBALS['phpgw']->redirect($this->page('',$params)); |
---|
442 | |
---|
443 | } |
---|
444 | |
---|
445 | |
---|
446 | |
---|
447 | // NDEE: printer-friendly |
---|
448 | |
---|
449 | function printer_friendly($body,$app_header='') |
---|
450 | { |
---|
451 | $_SESSION['calendar']['categories'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True'); |
---|
452 | if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) |
---|
453 | $_SESSION['calendar']['cals'] = $this->bo->list_cals(); |
---|
454 | |
---|
455 | if($this->bo->printer_friendly || $_GET['plain'] == 'True') |
---|
456 | { |
---|
457 | $new_body = '<html>'."\n" |
---|
458 | .'<head>'."\n" |
---|
459 | .'<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" |
---|
460 | .'<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" |
---|
461 | .'</head> |
---|
462 | <table id="calendar_print_main" class="calendar_print_main"> |
---|
463 | <tr> |
---|
464 | <td id="calendar_print_content" class="calendar_print_content">'.$body.'</td> |
---|
465 | </tr> |
---|
466 | <tr> |
---|
467 | <td> |
---|
468 | <div> |
---|
469 | <input class=button type="button" onClick="javascript:this.style.visibility=\'hidden\';window.print();window.close();" value="Imprimir esta página"> |
---|
470 | </div> |
---|
471 | </td> |
---|
472 | </tr> |
---|
473 | </table></body>'."\n" |
---|
474 | .'</html>'."\n"; |
---|
475 | //$new_body = utf8_decode($new_body); |
---|
476 | } |
---|
477 | else |
---|
478 | { |
---|
479 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
480 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
481 | unset($GLOBALS['phpgw_info']['flags']['noappheader']); |
---|
482 | unset($GLOBALS['phpgw_info']['flags']['noappfooter']); |
---|
483 | if ($app_header && $this->always_app_header) |
---|
484 | { |
---|
485 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.$app_header; |
---|
486 | } |
---|
487 | |
---|
488 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
489 | $new_body = $this->bo->debug_string.$body; |
---|
490 | |
---|
491 | } |
---|
492 | return $new_body; |
---|
493 | } |
---|
494 | |
---|
495 | function month() |
---|
496 | { |
---|
497 | echo $this->printer_friendly($this->get_month(),lang('Monthview')); |
---|
498 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
499 | } |
---|
500 | |
---|
501 | function get_month() |
---|
502 | { |
---|
503 | $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
504 | |
---|
505 | $next = $this->bo->month + 1; |
---|
506 | $prev = $this->bo->month - 1; |
---|
507 | $nextyear = $this->bo->year; |
---|
508 | $prevyear = $this->bo->year; |
---|
509 | if ($this->bo->month == 12) |
---|
510 | { |
---|
511 | $next = 1; |
---|
512 | $nextyear = $nextyear + 1; |
---|
513 | } |
---|
514 | elseif ($this->bo->month == 1) |
---|
515 | { |
---|
516 | $prev = 12; |
---|
517 | $prevyear = $prevyear - 1; |
---|
518 | } |
---|
519 | |
---|
520 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
521 | { |
---|
522 | $minical_prev = $this->mini_calendar( |
---|
523 | Array( |
---|
524 | 'day' => 1, |
---|
525 | 'month' => $this->bo->month - 1, |
---|
526 | 'year' => $this->bo->year, |
---|
527 | 'link' => 'day', |
---|
528 | 'outside_month' => False |
---|
529 | ) |
---|
530 | ); |
---|
531 | |
---|
532 | $minical_next = $this->mini_calendar( |
---|
533 | Array( |
---|
534 | 'day' => 1, |
---|
535 | 'month' => $this->bo->month + 1, |
---|
536 | 'year' => $this->bo->year, |
---|
537 | 'link' => 'day', |
---|
538 | 'outside_month' => False |
---|
539 | ) |
---|
540 | ); |
---|
541 | } |
---|
542 | else |
---|
543 | { |
---|
544 | $minical_prev = ''; |
---|
545 | $minical_next = ''; |
---|
546 | } |
---|
547 | |
---|
548 | if($_POST['year']) { |
---|
549 | |
---|
550 | } |
---|
551 | |
---|
552 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
553 | $mes_hoje = (int)substr($hoje,4,2); |
---|
554 | $sday = 1; |
---|
555 | if($_POST['day']) { |
---|
556 | $day_ini = (int)$_POST['day']; |
---|
557 | } |
---|
558 | elseif($_GET['sday']){ |
---|
559 | if($_GET['month'] == $mes_hoje) |
---|
560 | { |
---|
561 | $day_ini = $this->bo->day; |
---|
562 | } |
---|
563 | |
---|
564 | else |
---|
565 | { |
---|
566 | $day_ini = (int)$_GET['sday']; |
---|
567 | } |
---|
568 | } |
---|
569 | elseif( ($_POST['dia_ini']) && ($_POST['dia_ini'] == $this->bo->day) ) |
---|
570 | { |
---|
571 | $day_ini = (int)substr($hoje,6,2); |
---|
572 | } |
---|
573 | else |
---|
574 | { |
---|
575 | $day_ini = $this->bo->day; |
---|
576 | } |
---|
577 | if($_POST['qtd_dias']) |
---|
578 | { |
---|
579 | $num_dias = (int)$_POST['qtd_dias']; |
---|
580 | } |
---|
581 | else |
---|
582 | { |
---|
583 | $num_dias = 0; |
---|
584 | } |
---|
585 | |
---|
586 | if (!$this->bo->printer_friendly) |
---|
587 | { |
---|
588 | $printer = ''; |
---|
589 | $prev_month_link = '<a href="'.$this->page('month','&year='.$prevyear.'&month='.$prev.'&sday='.$sday).'"><<</a>'; |
---|
590 | $next_month_link = '<a href="'.$this->page('month','&year='.$nextyear.'&month='.$next.'&sday='.$sday).'">>></a>'; |
---|
591 | $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'.'&day_ini='.$day_ini.'&num_dias='.$num_dias; |
---|
592 | //$param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; |
---|
593 | $print = lang('Printer Friendly').": <a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param.'&classic_print=1'). |
---|
594 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
595 | lang('columns')."'\">[".lang('columns')."]</a> | <a href='javascript:void(0)' onClick=\"javascript:window.open('".$this->page('month'.$param.'&classic_print=0'). |
---|
596 | "','','width=600,height=600,toolbar=no,scrollbars=yes,resizable=no');\" onMouseOver=\"window.status = '". |
---|
597 | lang('lines')."'\">[".lang('lines')."]</a>"; |
---|
598 | //linha abaixo foi adicionada para exibir a pagina do mes em tela |
---|
599 | $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | $printer = '<body bgcolor="'.$phpgw_info['theme']['bg_color'].'">'; |
---|
604 | $prev_month_link = ''; |
---|
605 | $next_month_link = ''; |
---|
606 | $print = ''; |
---|
607 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
608 | //linha abaixo foi adicionada para exibir a pagina do mes para impressao |
---|
609 | |
---|
610 | if($_GET['classic_print']==1) |
---|
611 | $large_month = $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
612 | else |
---|
613 | $large_month = $this->display_month_print($this->bo->month,$this->bo->year,True,$this->bo->owner); |
---|
614 | } |
---|
615 | |
---|
616 | $this->bo->read_holidays(); |
---|
617 | |
---|
618 | $var = Array( |
---|
619 | 'printer_friendly' => $printer, |
---|
620 | 'bg_text' => $this->theme['bg_text'], |
---|
621 | 'small_calendar_prev' => $minical_prev, |
---|
622 | 'prev_month_link' => $prev_month_link, |
---|
623 | 'month_identifier' => lang(strftime("%B",$m)).' '.$this->bo->year, |
---|
624 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
625 | 'next_month_link' => $next_month_link, |
---|
626 | 'small_calendar_next' => $minical_next, |
---|
627 | //'large_month' => $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), |
---|
628 | 'large_month' => $large_month, |
---|
629 | 'print' => $print |
---|
630 | ); |
---|
631 | |
---|
632 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
633 | $p->set_unknowns('remove'); |
---|
634 | // Alteracao que desvincula o template para tela do template de impressao do mes (month_print teve que ser criado); |
---|
635 | if($print != '') |
---|
636 | { |
---|
637 | $p->set_file( |
---|
638 | Array( |
---|
639 | 'index_t' => 'index.tpl' |
---|
640 | ) |
---|
641 | ); |
---|
642 | }else { |
---|
643 | $p->set_file( |
---|
644 | Array( |
---|
645 | 'index_t' => 'month_print.tpl' |
---|
646 | ) |
---|
647 | ); |
---|
648 | } |
---|
649 | $p->set_var($var); |
---|
650 | return $p->fp('out','index_t'); |
---|
651 | } |
---|
652 | |
---|
653 | function week() |
---|
654 | { |
---|
655 | echo $this->printer_friendly($this->get_week(),lang('Weekview')); |
---|
656 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
657 | } |
---|
658 | |
---|
659 | function get_week() |
---|
660 | { |
---|
661 | $this->bo->read_holidays(); |
---|
662 | |
---|
663 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); |
---|
664 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); |
---|
665 | |
---|
666 | if (isset($this->bo->prefs['calendar']['display_minicals']) && $this->bo->prefs['calendar']['display_minicals'] == "1" && !$this->bo->printer_friendly) |
---|
667 | { |
---|
668 | $minical_this = $this->mini_calendar( |
---|
669 | Array( |
---|
670 | 'day' => $this->bo->day, |
---|
671 | 'month' => $this->bo->month, |
---|
672 | 'year' => $this->bo->year, |
---|
673 | 'link' => 'day', |
---|
674 | 'butons' => 'none', |
---|
675 | 'outside_month' => False |
---|
676 | ) |
---|
677 | ); |
---|
678 | $minical_prev = $this->mini_calendar( |
---|
679 | Array( |
---|
680 | 'day' => $this->bo->day, |
---|
681 | 'month' => $this->bo->month - 1, |
---|
682 | 'year' => $this->bo->year, |
---|
683 | 'link' => 'day', |
---|
684 | 'butons' => 'left', |
---|
685 | 'outside_month' => False |
---|
686 | ) |
---|
687 | ); |
---|
688 | $minical_next = $this->mini_calendar( |
---|
689 | Array( |
---|
690 | 'day' => $this->bo->day, |
---|
691 | 'month' => $this->bo->month + 1, |
---|
692 | 'year' => $this->bo->year, |
---|
693 | 'link' => 'day', |
---|
694 | 'butons' => 'right', |
---|
695 | 'outside_month' => False |
---|
696 | ) |
---|
697 | ); |
---|
698 | } |
---|
699 | else |
---|
700 | { |
---|
701 | |
---|
702 | //NDEE: printer-friendly what? |
---|
703 | $minical_this = ''; |
---|
704 | $minical_prev = ''; |
---|
705 | $minical_next = ''; |
---|
706 | } |
---|
707 | |
---|
708 | if (!$this->bo->printer_friendly) |
---|
709 | { |
---|
710 | $printer = ''; |
---|
711 | $prev_week_link = '<a href="'.$this->page('week','&date='.$prev['full']).'"><<</a>'; |
---|
712 | $next_week_link = '<a href="'.$this->page('week','&date='.$next['full']).'">>></a>'; |
---|
713 | $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>'; |
---|
714 | } |
---|
715 | else |
---|
716 | { |
---|
717 | |
---|
718 | //NDEE: printer-friendly (weekly-view) |
---|
719 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
720 | $prev_week_link = ''; |
---|
721 | $next_week_link = ''; |
---|
722 | $print = ''; |
---|
723 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
724 | } |
---|
725 | |
---|
726 | $var = Array( |
---|
727 | 'printer_friendly' => $print, |
---|
728 | 'bg_text' => $this->theme['bg_text'], |
---|
729 | 'small_calendar_prev' => $minical_prev, |
---|
730 | 'prev_week_link' => $prev_week_link, |
---|
731 | 'small_calendar_this' => $minical_this, |
---|
732 | 'week_identifier' => $this->bo->get_week_label(), |
---|
733 | 'next_week_link' => $next_week_link, |
---|
734 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
735 | 'small_calendar_next' => $minical_next, |
---|
736 | 'week_display' => $this->display_weekly( |
---|
737 | Array( |
---|
738 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
739 | 'showyear' => true, |
---|
740 | 'owners' => $this->bo->owner |
---|
741 | ) |
---|
742 | ), |
---|
743 | 'print' => $print |
---|
744 | ); |
---|
745 | //todo |
---|
746 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
747 | $p->set_file( |
---|
748 | Array( |
---|
749 | 'week_t' => 'week.tpl' |
---|
750 | ) |
---|
751 | ); |
---|
752 | $p->set_var($var); |
---|
753 | return $p->fp('out','week_t'); |
---|
754 | |
---|
755 | } |
---|
756 | |
---|
757 | function year() |
---|
758 | { |
---|
759 | if ($_GET['plain'] == "True") |
---|
760 | { |
---|
761 | |
---|
762 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
763 | } |
---|
764 | else |
---|
765 | { |
---|
766 | |
---|
767 | if($this->bo->printer_friendly) |
---|
768 | { |
---|
769 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
770 | } |
---|
771 | echo $this->printer_friendly($this->get_year(),lang('Yearview')); |
---|
772 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
773 | } |
---|
774 | } |
---|
775 | |
---|
776 | function get_year() |
---|
777 | { |
---|
778 | if(!$this->bo->printer_friendly) |
---|
779 | { |
---|
780 | $print = ''; |
---|
781 | $left_link = '<a href="'.$this->page('year','&year='.($this->bo->year - 1)).'"><<</a>'; |
---|
782 | $right_link = '<a href="'.$this->page('year','&year='.($this->bo->year + 1)).'">>></a>'; |
---|
783 | $link = 'day'; |
---|
784 | $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>'; |
---|
785 | } |
---|
786 | else |
---|
787 | { |
---|
788 | //NDEE: printer-friendly (year-view) |
---|
789 | $print = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
790 | $left_link = ''; |
---|
791 | $right_link = ''; |
---|
792 | $link = ''; |
---|
793 | $printer = ''; |
---|
794 | } |
---|
795 | |
---|
796 | $var = Array( |
---|
797 | 'print' => $print, |
---|
798 | 'left_link' => $left_link, |
---|
799 | 'font' => $this->theme['font'], |
---|
800 | 'year_text' => $this->bo->year, |
---|
801 | 'right_link'=> $right_link, |
---|
802 | 'printer_friendly'=> $printer |
---|
803 | ); |
---|
804 | |
---|
805 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
806 | $p->set_file( |
---|
807 | Array( |
---|
808 | 'year_t' => 'year.tpl' |
---|
809 | ) |
---|
810 | ); |
---|
811 | $p->set_block('year_t','year','year'); |
---|
812 | $p->set_block('year_t','month','month_handle'); |
---|
813 | $p->set_block('year_t','month_sep','month_sep_handle'); |
---|
814 | $p->set_var($var); |
---|
815 | |
---|
816 | for($i=1;$i<=12;$i++) |
---|
817 | { |
---|
818 | if(($i % 3) == 1) |
---|
819 | { |
---|
820 | $p->parse('row','month_sep',True); |
---|
821 | } |
---|
822 | $p->set_var('mini_month',$this->mini_calendar( |
---|
823 | Array( |
---|
824 | 'day' => 1, |
---|
825 | 'month' => $i, |
---|
826 | 'year' => $this->bo->year, |
---|
827 | 'link' => $link, |
---|
828 | 'buttons' => 'none', |
---|
829 | 'outside_month' => False |
---|
830 | ) |
---|
831 | ) |
---|
832 | ); |
---|
833 | $p->parse('row','month',True); |
---|
834 | $p->set_var('mini_month',''); |
---|
835 | } |
---|
836 | return $p->fp('out','year_t'); |
---|
837 | } |
---|
838 | |
---|
839 | function view($vcal_id=0,$cal_date=0) |
---|
840 | { |
---|
841 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
842 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
843 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('View'); |
---|
844 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
845 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
846 | |
---|
847 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
848 | |
---|
849 | $date = $cal_date ? $cal_date : 0; |
---|
850 | $date = $date ? $date : (int)$_GET['date']; |
---|
851 | |
---|
852 | // First, make sure they have permission to this entry |
---|
853 | if ($cal_id < 1) |
---|
854 | { |
---|
855 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
856 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
857 | } |
---|
858 | |
---|
859 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) |
---|
860 | { |
---|
861 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
862 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
863 | } |
---|
864 | |
---|
865 | $event = $this->bo->read_entry($cal_id); |
---|
866 | |
---|
867 | if(!isset($event['id'])) |
---|
868 | { |
---|
869 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
870 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
871 | } |
---|
872 | |
---|
873 | $this->bo->repeating_events = Array(); |
---|
874 | $this->bo->cached_events = Array(); |
---|
875 | $this->bo->repeating_events[0] = $event; |
---|
876 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
877 | $this->bo->check_repeating_events($datetime); |
---|
878 | $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); |
---|
879 | if(is_array($this->bo->cached_events[$check_date][0]) && |
---|
880 | $this->bo->cached_events[$check_date][0]['id'] == $event['id']) |
---|
881 | { |
---|
882 | $starttime = $this->bo->maketime($event['start']); |
---|
883 | $endtime = $this->bo->maketime($event['end']); |
---|
884 | $event['start']['month'] = $this->bo->month; |
---|
885 | $event['start']['mday'] = $this->bo->day; |
---|
886 | $event['start']['year'] = $this->bo->year; |
---|
887 | $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); |
---|
888 | $event['end']['month'] = date('m',$temp_end); |
---|
889 | $event['end']['mday'] = date('d',$temp_end); |
---|
890 | $event['end']['year'] = date('Y',$temp_end); |
---|
891 | } |
---|
892 | |
---|
893 | if(!$this->view_event($event,True)) |
---|
894 | { |
---|
895 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
896 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
897 | } |
---|
898 | |
---|
899 | $p = $GLOBALS['phpgw']->template; |
---|
900 | $p->set_file( |
---|
901 | Array( |
---|
902 | 'form_button' => 'form_button_script.tpl' |
---|
903 | ) |
---|
904 | ); |
---|
905 | |
---|
906 | $button_left = $button_center = $button_right = ''; |
---|
907 | |
---|
908 | if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
909 | { |
---|
910 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
911 | { |
---|
912 | $var = Array( |
---|
913 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
914 | 'action_text_button' => lang('Edit Single'), |
---|
915 | 'action_confirm_button' => '', |
---|
916 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
917 | 'edit_type' => 'single', |
---|
918 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
919 | )) |
---|
920 | ); |
---|
921 | $p->set_var($var); |
---|
922 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
923 | |
---|
924 | $var = Array( |
---|
925 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
926 | 'action_text_button' => lang('Edit Series'), |
---|
927 | 'action_confirm_button' => '', |
---|
928 | 'action_extra_field' => $this->html->input_hidden('edit_type','series') |
---|
929 | ); |
---|
930 | $p->set_var($var); |
---|
931 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
932 | } |
---|
933 | else |
---|
934 | { |
---|
935 | $var = Array( |
---|
936 | 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), |
---|
937 | 'action_text_button' => lang('Edit'), |
---|
938 | 'action_confirm_button' => '', |
---|
939 | 'action_extra_field' => '' |
---|
940 | ); |
---|
941 | $p->set_var($var); |
---|
942 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
943 | } |
---|
944 | |
---|
945 | $var = Array( |
---|
946 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
947 | 'action_text_button' => lang('Alarm Management'), |
---|
948 | 'action_confirm_button' => '', |
---|
949 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
950 | 'cal_id' => $cal_id, |
---|
951 | 'return_to' => $this->bo->return_to |
---|
952 | )) |
---|
953 | ); |
---|
954 | $p->set_var($var); |
---|
955 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
956 | } |
---|
957 | |
---|
958 | if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) |
---|
959 | { |
---|
960 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
961 | { |
---|
962 | $var = Array( |
---|
963 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
964 | 'action_text_button' => lang('Delete Single'), |
---|
965 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this single occurence?').'\\n'.lang('This will delete this entry for all users.')."')\"", |
---|
966 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
967 | 'delete_type' => 'single', |
---|
968 | 'date' => sprintf('%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day) |
---|
969 | )) |
---|
970 | ); |
---|
971 | $p->set_var($var); |
---|
972 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
973 | |
---|
974 | $var = Array( |
---|
975 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
976 | 'action_text_button' => lang('Delete Series'), |
---|
977 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
978 | 'action_extra_field' => $this->html->input_hidden('delete_type','series') |
---|
979 | ); |
---|
980 | $p->set_var($var); |
---|
981 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
982 | |
---|
983 | if($event['recur_exception']) |
---|
984 | { |
---|
985 | $var = Array( |
---|
986 | 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), |
---|
987 | 'action_text_button' => lang('Reinstate'), |
---|
988 | 'action_confirm_button' => '', |
---|
989 | 'action_extra_field' => '' |
---|
990 | ); |
---|
991 | $p->set_var($var); |
---|
992 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
993 | } |
---|
994 | } |
---|
995 | else |
---|
996 | { |
---|
997 | $var = Array( |
---|
998 | 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), |
---|
999 | 'action_text_button' => lang('Delete'), |
---|
1000 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
1001 | 'action_extra_field' => '' |
---|
1002 | ); |
---|
1003 | $p->set_var($var); |
---|
1004 | $button_right .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
1005 | } |
---|
1006 | } |
---|
1007 | else |
---|
1008 | { |
---|
1009 | // allow me (who I am logged in as) to set up an alarm |
---|
1010 | // if I am a participant, but not the owner |
---|
1011 | reset($event['participants']); |
---|
1012 | while (list($user,$short_status) = each($event['participants'])) |
---|
1013 | { |
---|
1014 | if ($GLOBALS['phpgw_info']['user']['account_id'] == $user) |
---|
1015 | { |
---|
1016 | $var = Array( |
---|
1017 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), |
---|
1018 | 'action_text_button' => lang('Alarm Management'), |
---|
1019 | 'action_confirm_button' => '', |
---|
1020 | 'action_extra_field' => $this->html->input_hidden(array( |
---|
1021 | 'cal_id' => $cal_id, |
---|
1022 | 'return_to' => $this->bo->return_to |
---|
1023 | )) |
---|
1024 | ); |
---|
1025 | $p->set_var($var); |
---|
1026 | echo $p->fp('out','form_button'); |
---|
1027 | } |
---|
1028 | } |
---|
1029 | } |
---|
1030 | |
---|
1031 | $var = Array( |
---|
1032 | 'action_url_button' => $this->page('export'), |
---|
1033 | 'action_text_button' => lang('Export'), |
---|
1034 | 'action_confirm_button' => '', |
---|
1035 | 'action_extra_field' => $this->html->input_hidden('cal_id',$cal_id) |
---|
1036 | ); |
---|
1037 | $p->set_var($var); |
---|
1038 | $button_center .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
1039 | |
---|
1040 | if ($this->bo->return_to) |
---|
1041 | { |
---|
1042 | $var = Array( |
---|
1043 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
1044 | 'action_text_button' => lang('Done'), |
---|
1045 | 'action_confirm_button' => '', |
---|
1046 | 'action_extra_field' => '' |
---|
1047 | ); |
---|
1048 | $p->set_var($var); |
---|
1049 | $button_left .= '<td>'.$p->fp('button','form_button').'</td>'; |
---|
1050 | } |
---|
1051 | $p->set_var(array( |
---|
1052 | 'button_left' => $button_left, |
---|
1053 | 'button_center' => $button_center, |
---|
1054 | 'button_right' => $button_right |
---|
1055 | )); |
---|
1056 | $p->pfp('phpgw_body','view_event'); |
---|
1057 | |
---|
1058 | $GLOBALS['phpgw']->hooks->process(array( |
---|
1059 | 'location' => 'calendar_view', |
---|
1060 | 'cal_id' => $cal_id |
---|
1061 | )); |
---|
1062 | |
---|
1063 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1064 | } |
---|
1065 | |
---|
1066 | function edit($params='') |
---|
1067 | { |
---|
1068 | if($this->debug) |
---|
1069 | { |
---|
1070 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
1071 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
1072 | } |
---|
1073 | |
---|
1074 | if(isset($_GET['readsess'])) |
---|
1075 | { |
---|
1076 | $params['readsess'] = $_GET['readsess']; |
---|
1077 | $params['cd'] = 0; |
---|
1078 | } |
---|
1079 | |
---|
1080 | if($this->debug) |
---|
1081 | { |
---|
1082 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
1083 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
1084 | } |
---|
1085 | |
---|
1086 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
1087 | { |
---|
1088 | $can_edit = True; |
---|
1089 | $this->edit_form( |
---|
1090 | Array( |
---|
1091 | 'event' => $this->bo->restore_from_appsession(), |
---|
1092 | 'cd' => $params['cd'] |
---|
1093 | ) |
---|
1094 | ); |
---|
1095 | } |
---|
1096 | elseif(isset($_GET['cal_id'])) |
---|
1097 | { |
---|
1098 | $cal_id = (int)$_GET['cal_id']; |
---|
1099 | $event = $this->bo->read_entry($cal_id); |
---|
1100 | |
---|
1101 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
1102 | { |
---|
1103 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
1104 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1105 | } |
---|
1106 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
1107 | { |
---|
1108 | $event['id'] = 0; |
---|
1109 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
1110 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
1111 | $event['recur_interval'] = 0; |
---|
1112 | $event['recur_data'] = 0; |
---|
1113 | $event['recur_enddate']['month'] = 0; |
---|
1114 | $event['recur_enddate']['mday'] = 0; |
---|
1115 | $event['recur_enddate']['year'] = 0; |
---|
1116 | $event['recur_exception'] = array(); |
---|
1117 | } |
---|
1118 | $plain = $_GET['plain']; |
---|
1119 | |
---|
1120 | $this->edit_form( |
---|
1121 | Array( |
---|
1122 | 'event' => $event, |
---|
1123 | 'cd' => $cd, |
---|
1124 | 'plain' => $plain |
---|
1125 | ) |
---|
1126 | ); |
---|
1127 | } |
---|
1128 | } |
---|
1129 | |
---|
1130 | function export_all() |
---|
1131 | { |
---|
1132 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
1133 | srand((double)microtime()*1000000); |
---|
1134 | $random_number = rand(100000000,999999999); |
---|
1135 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
1136 | $filename = $temp_path . $newfilename; |
---|
1137 | $attach_fd = fopen($filename,"w+"); |
---|
1138 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
1139 | foreach($event_ids as $key => $id) |
---|
1140 | { |
---|
1141 | $event[$key]=$this->bo->read_entry($id); |
---|
1142 | } |
---|
1143 | include_once('class.bocalendar.inc.php'); |
---|
1144 | $cal = new bocalendar; |
---|
1145 | $tmpattach=$cal->create_vcard($event); |
---|
1146 | fwrite($attach_fd,$tmpattach); |
---|
1147 | header ("Content-Type: text/plain"); |
---|
1148 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
1149 | header('Content-Length: ' . filesize($filename)); |
---|
1150 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
1151 | readfile($filename); |
---|
1152 | fclose($attach_fd); |
---|
1153 | } |
---|
1154 | |
---|
1155 | function export($vcal_id=0) |
---|
1156 | { |
---|
1157 | $temp_path = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
1158 | srand((double)microtime()*1000000); |
---|
1159 | $random_number = rand(100000000,999999999); |
---|
1160 | $newfilename = md5(time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
1161 | $filename = $temp_path . $newfilename; |
---|
1162 | $attach_fd = fopen($filename,"w+"); |
---|
1163 | $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); |
---|
1164 | $event[0] = $this->bo->read_entry($cal_id); |
---|
1165 | include_once('class.bocalendar.inc.php'); |
---|
1166 | $cal = new bocalendar; |
---|
1167 | $tmpattach=$cal->create_vcard($event); |
---|
1168 | fwrite($attach_fd,$tmpattach); |
---|
1169 | header ("Content-Type: text/plain"); |
---|
1170 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
1171 | header('Content-Length: ' . filesize($filename)); |
---|
1172 | header("Content-disposition: attachment; filename="."export.vcard"); |
---|
1173 | readfile($filename); |
---|
1174 | fclose($attach_fd); |
---|
1175 | } |
---|
1176 | |
---|
1177 | function reinstate_list($params='') |
---|
1178 | { |
---|
1179 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
1180 | { |
---|
1181 | $this->no_edit(); |
---|
1182 | } |
---|
1183 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1184 | { |
---|
1185 | $this->index(); |
---|
1186 | } |
---|
1187 | |
---|
1188 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1189 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1190 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Reinstate'); |
---|
1191 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1192 | |
---|
1193 | $cal_id = get_var('cal_id',array('GET'),$params['cal_id']); |
---|
1194 | |
---|
1195 | if ($cal_id < 1) |
---|
1196 | { |
---|
1197 | echo '<center>'.lang('Invalid entry id.').'</center>'."\n"; |
---|
1198 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1199 | } |
---|
1200 | |
---|
1201 | if(!$this->bo->check_perms(PHPGW_ACL_READ)) |
---|
1202 | { |
---|
1203 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'."\n"; |
---|
1204 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1205 | } |
---|
1206 | |
---|
1207 | $event = $this->bo->read_entry($cal_id); |
---|
1208 | |
---|
1209 | if(!isset($event['id'])) |
---|
1210 | { |
---|
1211 | echo '<center>'.lang('Sorry, this event does not exist').'.'.'</center>'."\n"; |
---|
1212 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1213 | } |
---|
1214 | elseif(!isset($event['recur_exception'])) |
---|
1215 | { |
---|
1216 | echo '<center>'.lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n"; |
---|
1217 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1218 | } |
---|
1219 | |
---|
1220 | if(!$this->view_event($event,True)) |
---|
1221 | { |
---|
1222 | echo '<center>'.lang('You do not have permission to read this record!').'</center>'; |
---|
1223 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
1224 | } |
---|
1225 | |
---|
1226 | $p = &$GLOBALS['phpgw']->template; |
---|
1227 | $p->set_file( |
---|
1228 | Array( |
---|
1229 | 'form_button' => 'form_button_script.tpl' |
---|
1230 | ) |
---|
1231 | ); |
---|
1232 | |
---|
1233 | $str = ''; |
---|
1234 | |
---|
1235 | for($i=0;$i<count($event['recur_exception']);$i++) |
---|
1236 | { |
---|
1237 | $str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n"; |
---|
1238 | } |
---|
1239 | $this->output_template_array($p,'row','list',array( |
---|
1240 | 'field' => lang('Exceptions'), |
---|
1241 | 'data' => '<select name="reinstate_index[]" multiple size="5">'."\n".$str.'</select>' |
---|
1242 | )); |
---|
1243 | |
---|
1244 | $var = Array( |
---|
1245 | 'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id), |
---|
1246 | 'action_text_button' => lang('Reinstate'), |
---|
1247 | 'action_confirm_button' => '', |
---|
1248 | 'action_extra_field' => '' |
---|
1249 | ); |
---|
1250 | $p->set_var($var); |
---|
1251 | $button_left = '<td>'.$p->fp('out','form_button').'</td>'; |
---|
1252 | |
---|
1253 | $var = Array( |
---|
1254 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
1255 | 'action_text_button' => lang('Cancel'), |
---|
1256 | 'action_confirm_button' => '', |
---|
1257 | 'action_extra_field' => '' |
---|
1258 | ); |
---|
1259 | $p->set_var($var); |
---|
1260 | $button_left .= '<td>'.$p->fp('out','form_button').'</td>'; |
---|
1261 | |
---|
1262 | $p->set_var('button_left',$button_left); |
---|
1263 | $p->pfp('phpgw_body','view_event'); |
---|
1264 | } |
---|
1265 | |
---|
1266 | function reinstate($params='') |
---|
1267 | { |
---|
1268 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
1269 | { |
---|
1270 | $this->no_edit(); |
---|
1271 | } |
---|
1272 | elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1273 | { |
---|
1274 | $this->index(); |
---|
1275 | } |
---|
1276 | $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : ''); |
---|
1277 | $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id); |
---|
1278 | |
---|
1279 | $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : ''); |
---|
1280 | $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index); |
---|
1281 | if($this->debug) |
---|
1282 | { |
---|
1283 | echo '<!-- Calling bo->reinstate -->'."\n"; |
---|
1284 | } |
---|
1285 | $cd = $this->bo->reinstate( |
---|
1286 | Array( |
---|
1287 | 'cal_id' => $cal_id, |
---|
1288 | 'reinstate_index' => $reinstate_index |
---|
1289 | ) |
---|
1290 | ); |
---|
1291 | if($this->debug) |
---|
1292 | { |
---|
1293 | echo '<!-- Return Value = '.$cd.' -->'."\n"; |
---|
1294 | } |
---|
1295 | if ($this->bo->return_to) |
---|
1296 | { |
---|
1297 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
1298 | } |
---|
1299 | else |
---|
1300 | { |
---|
1301 | Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); |
---|
1302 | } |
---|
1303 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1304 | } |
---|
1305 | |
---|
1306 | function add($cd=0,$readsess=0) |
---|
1307 | { |
---|
1308 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
1309 | { |
---|
1310 | $this->index(); |
---|
1311 | } |
---|
1312 | |
---|
1313 | if($readsess) |
---|
1314 | { |
---|
1315 | $event = $this->bo->restore_from_appsession; |
---|
1316 | if(!$event['owner']) |
---|
1317 | { |
---|
1318 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
1319 | } |
---|
1320 | $can_edit = True; |
---|
1321 | } |
---|
1322 | else |
---|
1323 | { |
---|
1324 | $this->bo->event_init(); |
---|
1325 | $this->bo->add_attribute('id',0); |
---|
1326 | |
---|
1327 | $can_edit = True; |
---|
1328 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
1329 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
1330 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
1331 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
1332 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
1333 | |
---|
1334 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
1335 | if ($subject != '0') |
---|
1336 | { |
---|
1337 | $description = (string)(get_var('description',array('GET'),0)); |
---|
1338 | $location = (string)(get_var('location',array('GET'),0)); |
---|
1339 | } |
---|
1340 | else |
---|
1341 | unset($subject); |
---|
1342 | |
---|
1343 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
1344 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
1345 | $this->bo->set_title($subject); |
---|
1346 | $this->bo->set_description($description); |
---|
1347 | $this->bo->add_attribute('location',$location); |
---|
1348 | $this->bo->set_ex_participants(''); |
---|
1349 | $this->bo->add_attribute('uid',''); |
---|
1350 | $this->bo->add_attribute('priority',2); |
---|
1351 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
1352 | { |
---|
1353 | $this->bo->set_class(False); |
---|
1354 | } |
---|
1355 | else |
---|
1356 | { |
---|
1357 | $this->bo->set_class(True); |
---|
1358 | } |
---|
1359 | // Add participants |
---|
1360 | //$participants = explode(";", $GLOBALS['phpgw']->session->appsession("participants") ); |
---|
1361 | //for($_f_part=0; $_f_part<count($participants); $_f_part++) |
---|
1362 | //{ |
---|
1363 | // $this->bo->add_attribute('participants','A',$participants[$_f_part]); |
---|
1364 | //} |
---|
1365 | // Add misc |
---|
1366 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
1367 | $this->bo->set_recur_none(); |
---|
1368 | $event = $this->bo->get_cached_event(); |
---|
1369 | |
---|
1370 | } |
---|
1371 | $this->edit_form( |
---|
1372 | Array( |
---|
1373 | 'event' => $event, |
---|
1374 | 'cd' => $cd, |
---|
1375 | 'plain' => $_GET['plain'] |
---|
1376 | ) |
---|
1377 | ); |
---|
1378 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1379 | } |
---|
1380 | |
---|
1381 | function delete() |
---|
1382 | { |
---|
1383 | if(!isset($_GET['cal_id'])) |
---|
1384 | { |
---|
1385 | Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); |
---|
1386 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1387 | } |
---|
1388 | |
---|
1389 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); |
---|
1390 | if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id'])) |
---|
1391 | { |
---|
1392 | if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') |
---|
1393 | { |
---|
1394 | $date = $_POST['date']; |
---|
1395 | $cd = $this->bo->delete_single( |
---|
1396 | Array( |
---|
1397 | 'id' => $cal_id, |
---|
1398 | 'year' => substr($date,0,4), |
---|
1399 | 'month' => substr($date,4,2), |
---|
1400 | 'day' => substr($date,6,2) |
---|
1401 | ) |
---|
1402 | ); |
---|
1403 | } |
---|
1404 | elseif((isset($_POST['delete_type']) && $_POST['delete_type'] == 'series') || !isset($_POST['delete_type'])) |
---|
1405 | { |
---|
1406 | $cd = $this->bo->delete_entry($cal_id); |
---|
1407 | $this->bo->expunge(); |
---|
1408 | } |
---|
1409 | } |
---|
1410 | else |
---|
1411 | { |
---|
1412 | $cd = ''; |
---|
1413 | } |
---|
1414 | if ($this->bo->return_to) |
---|
1415 | { |
---|
1416 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
1417 | } |
---|
1418 | else |
---|
1419 | { |
---|
1420 | Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); |
---|
1421 | } |
---|
1422 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1423 | } |
---|
1424 | |
---|
1425 | function disponibility($params) { |
---|
1426 | |
---|
1427 | if(!isset($_SESSION['phpgw_info']['expresso']['expressoAdmin'])) { |
---|
1428 | $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); |
---|
1429 | $c->read_repository(); |
---|
1430 | $current_config = $c->config_data; |
---|
1431 | |
---|
1432 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
1433 | |
---|
1434 | $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
1435 | $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
1436 | $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
1437 | $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; |
---|
1438 | $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; |
---|
1439 | $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; |
---|
1440 | } |
---|
1441 | $str_participants = substr($_GET['participants'],0,strlen($_GET['participants'])-1); //remove the last comma |
---|
1442 | $participants= array(); |
---|
1443 | |
---|
1444 | $participants_splited = explode(",",$str_participants); |
---|
1445 | foreach($participants_splited as $participant) { |
---|
1446 | $participant = substr($participant,0,strlen($participant)-1); |
---|
1447 | $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$participant); |
---|
1448 | if($acct_type=='g') { |
---|
1449 | $bo_groups = CreateObject('expressoAdmin1_2.group'); |
---|
1450 | $users = $bo_groups->get_info($participant); |
---|
1451 | foreach($users['memberuid_info'] as $user) { |
---|
1452 | if($user['type']==u) |
---|
1453 | $participants[$user['uidnumber']] = 'U'; |
---|
1454 | } |
---|
1455 | } |
---|
1456 | else { |
---|
1457 | $participants[$participant] = 'U'; |
---|
1458 | } |
---|
1459 | } |
---|
1460 | |
---|
1461 | $date = explode("/",$_GET['date']); |
---|
1462 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$date[1],$date[0],$date[2]) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
1463 | |
---|
1464 | echo $this->print_disponibility( |
---|
1465 | Array( |
---|
1466 | 'date' => $freetime, |
---|
1467 | 'starttime' => $this->bo->splittime('000000',False), |
---|
1468 | 'endtime' => 0, |
---|
1469 | 'participants' => $participants |
---|
1470 | ) |
---|
1471 | ); |
---|
1472 | |
---|
1473 | |
---|
1474 | } |
---|
1475 | |
---|
1476 | function print_disponibility($param) { |
---|
1477 | |
---|
1478 | $str = "<html><head> |
---|
1479 | <script type='text/javascript'> |
---|
1480 | |
---|
1481 | var start = null; |
---|
1482 | var end = null; |
---|
1483 | function set_time(hour,minute) { |
---|
1484 | //alert(start); |
---|
1485 | if(start == null) { |
---|
1486 | start = new Array(); |
---|
1487 | start[0] = hour; |
---|
1488 | start[1] = minute; |
---|
1489 | paint_interval(start,start,'#009ACD',true); |
---|
1490 | } |
---|
1491 | else if (end == null) { |
---|
1492 | end = new Array(); |
---|
1493 | end[0] = hour; |
---|
1494 | end[1] = minute; |
---|
1495 | if(is_lower(start,end)) |
---|
1496 | paint_interval(start,end,'#009ACD',true); |
---|
1497 | else { |
---|
1498 | paint_interval(end,start,'#009ACD',true); |
---|
1499 | temp = start; |
---|
1500 | start = end; |
---|
1501 | end = temp; |
---|
1502 | paint_interval(end,end,'#FFFFFF',false); |
---|
1503 | } |
---|
1504 | parent.document.getElementById('start_hour').value=start[0]; |
---|
1505 | parent.document.getElementById('start_minute').value=start[1]; |
---|
1506 | parent.document.getElementById('end_hour').value=end[0]; |
---|
1507 | parent.document.getElementById('end_minute').value=end[1]; |
---|
1508 | |
---|
1509 | } |
---|
1510 | else { |
---|
1511 | end = null; |
---|
1512 | start = new Array(); |
---|
1513 | start[0] = hour; |
---|
1514 | start[1] = minute; |
---|
1515 | repaint(); |
---|
1516 | |
---|
1517 | paint_interval(start,start,'#009ACD',true); |
---|
1518 | } |
---|
1519 | } |
---|
1520 | function paint_column(name_array,color,force) { |
---|
1521 | name = name_array[0]+'-'+name_array[1]; |
---|
1522 | if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {//firefox |
---|
1523 | for(var i in document.getElementsByName(name)) { |
---|
1524 | document.getElementsByName(name)[i].bgColor=color; |
---|
1525 | if(document.getElementsByName(name)[i].nodeType==1) { |
---|
1526 | if(document.getElementsByName(name)[i].innerHTML.indexOf('>-<')==-1 || force==true) |
---|
1527 | document.getElementsByName(name)[i].bgColor=color; |
---|
1528 | else |
---|
1529 | document.getElementsByName(name)[i].bgColor='".$this->theme['bg11']."'; |
---|
1530 | } |
---|
1531 | } |
---|
1532 | } |
---|
1533 | else {//I.E |
---|
1534 | cells = document.getElementsByTagName('td'); |
---|
1535 | for(var i=0;i<cells.length;i++) { |
---|
1536 | if(cells.item(i).name==name) { //getElementsByName in I.E is bugged |
---|
1537 | cells.item(i).bgColor=color; |
---|
1538 | if(cells.item(i).nodeType==1) { |
---|
1539 | if(cells.item(i).innerHTML.indexOf('>-<')==-1 || force==true) |
---|
1540 | cells.item(i).bgColor=color; |
---|
1541 | else |
---|
1542 | cells.item(i).bgColor='".$this->theme['bg11']."'; |
---|
1543 | } |
---|
1544 | } |
---|
1545 | } |
---|
1546 | } |
---|
1547 | } |
---|
1548 | |
---|
1549 | function repaint() { |
---|
1550 | temp_start = new Array(); |
---|
1551 | temp_start[0] = 8; |
---|
1552 | temp_start[1] = 0; |
---|
1553 | temp_end = new Array(); |
---|
1554 | temp_end[0] = 19; |
---|
1555 | temp_end[1] = 0; |
---|
1556 | paint_interval(temp_start,temp_end,'#FFFFFF',false); |
---|
1557 | } |
---|
1558 | |
---|
1559 | //Considera sempre name1 <= name2 |
---|
1560 | function paint_interval(name1,name2,color,force) { |
---|
1561 | paint_column(name1,color,force); |
---|
1562 | if(name1[0]!=name2[0] || name1[1]!=name2[1]) { |
---|
1563 | paint_column(name1,color,force); |
---|
1564 | tempHour = name1[0]; |
---|
1565 | tempMinute = name1[1]; |
---|
1566 | while(tempHour<name2[0]) { |
---|
1567 | if(tempHour==name1[0] && tempMinute!=0) |
---|
1568 | temp_start = tempMinute/30; |
---|
1569 | else |
---|
1570 | temp_start = 0; |
---|
1571 | for(i=temp_start;i<60/30;i++) { |
---|
1572 | temp_column = new Array(); |
---|
1573 | temp_column[0] = tempHour; |
---|
1574 | temp_column[1] = i*30; |
---|
1575 | paint_column(temp_column,color,force); |
---|
1576 | } |
---|
1577 | tempHour++; |
---|
1578 | } |
---|
1579 | for(i=0;i<name2[1];i+=30) { |
---|
1580 | temp_column = new Array(); |
---|
1581 | temp_column[0] = name2[0]; |
---|
1582 | temp_column[1] = i; |
---|
1583 | paint_column(temp_column,color,force); |
---|
1584 | } |
---|
1585 | } |
---|
1586 | } |
---|
1587 | |
---|
1588 | function is_lower(array1,array2) { |
---|
1589 | if(array1[0]<array2[0]) |
---|
1590 | return true; |
---|
1591 | else if(array1[0]>array2[0]) |
---|
1592 | return false; |
---|
1593 | else { |
---|
1594 | if(array1[1]<array2[1]) |
---|
1595 | return true; |
---|
1596 | else |
---|
1597 | return false; |
---|
1598 | } |
---|
1599 | } |
---|
1600 | </script></head><body> |
---|
1601 | "; |
---|
1602 | |
---|
1603 | $str.= "<table border=\'1\' bgcolor=\"#FFFFFF\" width=\"100%\" height=\"100%\"><tr><td>"; |
---|
1604 | |
---|
1605 | |
---|
1606 | if(!is_array($param)) |
---|
1607 | { |
---|
1608 | $this->index(); |
---|
1609 | } |
---|
1610 | |
---|
1611 | $date = $param['date']; |
---|
1612 | $starttime = $param['starttime']; |
---|
1613 | $endtime = $param['endtime']; |
---|
1614 | $participants = $param['participants']; |
---|
1615 | foreach($participants as $part => $nul) |
---|
1616 | { |
---|
1617 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
1618 | // Much better for processor :) |
---|
1619 | $participants_id[] .= $part; |
---|
1620 | } |
---|
1621 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
1622 | |
---|
1623 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
1624 | { |
---|
1625 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
1626 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
1627 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
1628 | } |
---|
1629 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
1630 | $interval = (int)(60 / $increment); |
---|
1631 | |
---|
1632 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
1633 | |
---|
1634 | $str .= '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
1635 | . ', '.$this->bo->long_date($date).'<br>' |
---|
1636 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((10 * $interval) + 1).'">' |
---|
1637 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
1638 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
1639 | for($i=8;$i<19;$i++) |
---|
1640 | { |
---|
1641 | for($j=0;$j<$interval;$j++) |
---|
1642 | { |
---|
1643 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
1644 | |
---|
1645 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'" onclick="set_time('.$i.','.($j*$increment).')" style="cursor:hand;cursor:pointer"> |
---|
1646 | <font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' . $k." </font></td>\n"; |
---|
1647 | } |
---|
1648 | } |
---|
1649 | $str .= '</tr>' |
---|
1650 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
1651 | if(!$endtime) |
---|
1652 | { |
---|
1653 | $endtime = $starttime; |
---|
1654 | } |
---|
1655 | $owner = $this->bo->owner; |
---|
1656 | foreach($participants as $part => $fullname) |
---|
1657 | { |
---|
1658 | $str .= '<tr align="center">' |
---|
1659 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
1660 | |
---|
1661 | $this->bo->cached_events = Array(); |
---|
1662 | $this->bo->so->owner = $part; |
---|
1663 | $this->bo->so->open_box($part); |
---|
1664 | $this->bo->store_to_cache( |
---|
1665 | Array( |
---|
1666 | 'syear' => $date['year'], |
---|
1667 | 'smonth'=> $date['month'], |
---|
1668 | 'sday' => $date['day'], |
---|
1669 | 'eyear' => 0, |
---|
1670 | 'emonth'=> 0, |
---|
1671 | 'eday' => $date['day'] + 1 |
---|
1672 | ) |
---|
1673 | ); |
---|
1674 | |
---|
1675 | if(!$this->bo->cached_events[$date['full']]) |
---|
1676 | { |
---|
1677 | for($j=8;$j<19;$j++) |
---|
1678 | { |
---|
1679 | for($k=0;$k<$interval;$k++) |
---|
1680 | { |
---|
1681 | // $helper_name = $k* |
---|
1682 | $str .= '<td name="'.$j.'-'.($k*$increment).'" height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
1683 | } |
---|
1684 | $str .= "\n"; |
---|
1685 | } |
---|
1686 | } |
---|
1687 | else |
---|
1688 | { |
---|
1689 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
1690 | for($h=8;$h<19;$h++) |
---|
1691 | { |
---|
1692 | $hour = $h * 10000; |
---|
1693 | for($m=0;$m<$interval;$m++) |
---|
1694 | { |
---|
1695 | $index = ($hour + (($m * $increment) * 100)); |
---|
1696 | switch($time_slice[$index]['marker']) |
---|
1697 | { |
---|
1698 | case ' ': |
---|
1699 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
1700 | //$extra = ''; |
---|
1701 | break; |
---|
1702 | case '-': |
---|
1703 | $time_slice[$index]['color'] = $this->theme['bg11']; |
---|
1704 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
1705 | //$extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
1706 | break; |
---|
1707 | } |
---|
1708 | $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>'; |
---|
1709 | } |
---|
1710 | $str .= "\n"; |
---|
1711 | } |
---|
1712 | } |
---|
1713 | $str .= '</tr>' |
---|
1714 | . '<tr><td height="1" colspan="'.((11 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
1715 | } |
---|
1716 | $this->bo->owner = $owner; |
---|
1717 | $this->bo->so->owner = $owner; |
---|
1718 | $this->bo->so->open_box($owner); |
---|
1719 | $str.= "</table></center> \n </td></tr> |
---|
1720 | <tr><td onclick=\"parent.document.getElementById('disponibility').style.display='none'\" style='cursor:hand;cursor:pointer' align='center'>Fechar mapa</td></tr> |
---|
1721 | </table></body>"; |
---|
1722 | return $str; |
---|
1723 | } |
---|
1724 | |
---|
1725 | function day() |
---|
1726 | { |
---|
1727 | $this->bo->read_holidays(); |
---|
1728 | |
---|
1729 | $next = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 1,$this->bo->year); |
---|
1730 | $prev = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 1,$this->bo->year); |
---|
1731 | |
---|
1732 | if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) |
---|
1733 | { |
---|
1734 | $minical = $this->mini_calendar( |
---|
1735 | Array( |
---|
1736 | 'day' => $this->bo->day, |
---|
1737 | 'month' => $this->bo->month, |
---|
1738 | 'year' => $this->bo->year, |
---|
1739 | 'link' => 'day' |
---|
1740 | ) |
---|
1741 | ); |
---|
1742 | } |
---|
1743 | else |
---|
1744 | { |
---|
1745 | |
---|
1746 | //NDEE: printer-friendly (what?) |
---|
1747 | $minical = ''; |
---|
1748 | } |
---|
1749 | |
---|
1750 | if (!$this->bo->printer_friendly) |
---|
1751 | { |
---|
1752 | $printer = ''; |
---|
1753 | $prev_day_link = '<a href="'.$this->page('day','&date='.$prev['full']).'"><<</a>'; |
---|
1754 | $next_day_link = '<a href="'.$this->page('day','&date='.$next['full']).'">>></a>'; |
---|
1755 | $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; |
---|
1756 | $print = '<a href="'.$this->page('day'.$param)."\" TARGET=\"cal_printer_friendly\" onMouseOver=\"window.status = '".lang('Generate printer-friendly version')."'\">[".lang('Printer Friendly').']</a>'; |
---|
1757 | } |
---|
1758 | else |
---|
1759 | { |
---|
1760 | |
---|
1761 | //NDEE: printer-friendly (daily-view) |
---|
1762 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
1763 | $printer = '<body bgcolor="'.$this->theme['bg_color'].'">'; |
---|
1764 | $print = ''; |
---|
1765 | } |
---|
1766 | |
---|
1767 | $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); |
---|
1768 | $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1769 | |
---|
1770 | $p = $GLOBALS['phpgw']->template; |
---|
1771 | $p->set_file( |
---|
1772 | Array( |
---|
1773 | 'day_t' => 'day.tpl' |
---|
1774 | ) |
---|
1775 | ); |
---|
1776 | $p->set_block('day_t','day','day'); |
---|
1777 | $p->set_block('day_t','day_event','day_event'); |
---|
1778 | |
---|
1779 | $todos = $this->get_todos($todo_label); |
---|
1780 | $var = Array( |
---|
1781 | 'printer_friendly' => $printer, |
---|
1782 | 'bg_text' => $this->theme['bg_text'], |
---|
1783 | 'daily_events' => $this->print_day( |
---|
1784 | Array( |
---|
1785 | 'year' => $this->bo->year, |
---|
1786 | 'month' => $this->bo->month, |
---|
1787 | 'day' => $this->bo->day |
---|
1788 | ) |
---|
1789 | ), |
---|
1790 | 'small_calendar' => $minical, |
---|
1791 | 'date' => $this->bo->long_date($now), |
---|
1792 | 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), |
---|
1793 | 'prev_day_link' => $prev_day_link, |
---|
1794 | 'next_day_link' => $next_day_link, |
---|
1795 | 'print' => $print, |
---|
1796 | 'lang_todos' => $todo_label, |
---|
1797 | 'todos' => $this->bo->printer_friendly ? $todos : |
---|
1798 | |
---|
1799 | //NDEE: todo's layout |
---|
1800 | "<div style=\"overflow: auto; max-height: 200px\">\n$todos</div>\n" |
---|
1801 | ); |
---|
1802 | |
---|
1803 | $p->set_var($var); |
---|
1804 | $p->parse('day_events','day_event'); |
---|
1805 | print $this->printer_friendly($p->fp('out','day'),lang('Dayview')); |
---|
1806 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1807 | } |
---|
1808 | |
---|
1809 | function get_todos(&$todo_label) |
---|
1810 | { |
---|
1811 | $todos_from_hook = $GLOBALS['phpgw']->hooks->process(array( |
---|
1812 | 'location' => 'calendar_include_todos', |
---|
1813 | 'year' => $this->bo->year, |
---|
1814 | 'month' => $this->bo->month, |
---|
1815 | 'day' => $this->bo->day, |
---|
1816 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
1817 | )); |
---|
1818 | |
---|
1819 | if(is_array($todo_label)) |
---|
1820 | { |
---|
1821 | list($label,$showall)=$todo_label; |
---|
1822 | } |
---|
1823 | else |
---|
1824 | { |
---|
1825 | $label=$todo_label; |
---|
1826 | $showall=true; |
---|
1827 | } |
---|
1828 | $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
---|
1829 | if($maxshow<=0) |
---|
1830 | { |
---|
1831 | $maxshow=10; |
---|
1832 | } |
---|
1833 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
---|
1834 | |
---|
1835 | $content = $todo_label = ''; |
---|
1836 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
---|
1837 | { |
---|
1838 | $todo_label = !empty($label)?$label:lang("open ToDo's:"); |
---|
1839 | |
---|
1840 | foreach($todos_from_hook as $todos) |
---|
1841 | { |
---|
1842 | $i = 0; |
---|
1843 | if (is_array($todos) && count($todos)) |
---|
1844 | { |
---|
1845 | foreach($todos as $todo) |
---|
1846 | { |
---|
1847 | if(!$showall && ($i++>$maxshow)) |
---|
1848 | { |
---|
1849 | break; |
---|
1850 | } |
---|
1851 | $icons = ''; |
---|
1852 | foreach($todo['icons'] as $name => $app) |
---|
1853 | { |
---|
1854 | $icons .= ($icons?' ':'').$GLOBALS['phpgw']->html->image($app,$name,lang($name),'border="0" width="15" height="15"'); |
---|
1855 | } |
---|
1856 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
---|
1857 | |
---|
1858 | //NDEE <tr starts here |
---|
1859 | $content .= " <tr id=\"debug\" class=\"$class\">\n <td valign=\"top\" width=\"15%\"nowrap>". |
---|
1860 | ($this->bo->printer_friendly?$icons:$GLOBALS['phpgw']->html->a_href($icons,$todo['view'])). |
---|
1861 | "</td>\n <td>".($this->bo->printer_friendly?$todo['title']: |
---|
1862 | $GLOBALS['phpgw']->html->a_href($todo['title'],$todo['view']))."</td>\n </tr>\n"; |
---|
1863 | } |
---|
1864 | } |
---|
1865 | } |
---|
1866 | } |
---|
1867 | if (!empty($content)) |
---|
1868 | { |
---|
1869 | return "<table border=\"0\" width=\"100%\">\n$content</table>\n"; |
---|
1870 | } |
---|
1871 | return False; |
---|
1872 | } |
---|
1873 | |
---|
1874 | function edit_status() |
---|
1875 | { |
---|
1876 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1877 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1878 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
1879 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
1880 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Change Status'); |
---|
1881 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1882 | |
---|
1883 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
1884 | |
---|
1885 | reset($event['participants']); |
---|
1886 | |
---|
1887 | if(!$event['participants'][$this->bo->owner]) |
---|
1888 | { |
---|
1889 | echo '<center>'.lang('The user %1 is not participating in this event!',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)).'</center>'; |
---|
1890 | return; |
---|
1891 | } |
---|
1892 | |
---|
1893 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
1894 | { |
---|
1895 | $this->no_edit(); |
---|
1896 | return; |
---|
1897 | } |
---|
1898 | |
---|
1899 | $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
1900 | echo $this->timematrix( |
---|
1901 | Array( |
---|
1902 | 'date' => $freetime, |
---|
1903 | 'starttime' => $this->bo->splittime('000000',False), |
---|
1904 | 'endtime' => 0, |
---|
1905 | 'participants' => $event['participants'] |
---|
1906 | ) |
---|
1907 | ).'<br>'; |
---|
1908 | |
---|
1909 | $event = $this->bo->read_entry($_GET['cal_id']); |
---|
1910 | $this->view_event($event); |
---|
1911 | $GLOBALS['phpgw']->template->pfp('phpgw_body','view_event'); |
---|
1912 | |
---|
1913 | echo $this->get_response($event['id']); |
---|
1914 | } |
---|
1915 | |
---|
1916 | function confirm_action($duplicated_action) |
---|
1917 | { |
---|
1918 | if($_GET['response'] == 1) |
---|
1919 | { |
---|
1920 | if(!$duplicated_action) |
---|
1921 | $notify_message = lang('The commitment was accepted successfully!'); |
---|
1922 | else |
---|
1923 | $notify_message = lang('This commitment has already been accepted!'); |
---|
1924 | } |
---|
1925 | else |
---|
1926 | { |
---|
1927 | if(!$duplicated_action) |
---|
1928 | $notify_message = lang('The commitment was rejected successfully!'); |
---|
1929 | else |
---|
1930 | $notify_message = lang('This commitment has already been rejected!'); |
---|
1931 | } |
---|
1932 | |
---|
1933 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
1934 | $body1->set_file(Array('calendar' => 'confirm.tpl')); |
---|
1935 | $body1->set_block('calendar','list'); |
---|
1936 | $var = Array( 'notify_message' => $notify_message); |
---|
1937 | $body1->set_var($var); |
---|
1938 | $tmpbody1 = $body1->pfp('out','list'); |
---|
1939 | } |
---|
1940 | |
---|
1941 | function confirm_conflict($user_id,$event,$overlapping_events) |
---|
1942 | { |
---|
1943 | if(!$overlapping_events){ |
---|
1944 | $notify_message = lang('This event conflicts with your other event.'); |
---|
1945 | |
---|
1946 | $action_ignore = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'response' => 1,'user_id' => $user_id, 'ignore_conflict' => 1)); |
---|
1947 | $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); |
---|
1948 | |
---|
1949 | $body1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
1950 | $body1->set_file(Array('calendar' => 'conflict.tpl')); |
---|
1951 | $body1->set_block('calendar','list'); |
---|
1952 | $var = Array( 'notify_message' => $notify_message, |
---|
1953 | 'action_url' => $action_url, |
---|
1954 | 'ignore_conflict' => 'Ignorar Conflito', |
---|
1955 | 'reject_event' => 'Rejeitar Evento', |
---|
1956 | 'action_reject' => $action_reject, |
---|
1957 | 'action_ignore' => $action_ignore); |
---|
1958 | $body1->set_var($var); |
---|
1959 | $tmpbody1 = $body1->pfp('out','list'); |
---|
1960 | } |
---|
1961 | else |
---|
1962 | { |
---|
1963 | $month = $event['start']['month']; |
---|
1964 | $mday = $event['start']['mday']; |
---|
1965 | $year = $event['start']['year']; |
---|
1966 | |
---|
1967 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1968 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
1969 | |
---|
1970 | $overlap = ''; |
---|
1971 | for($i=0;$i<count($overlapping_events);$i++) |
---|
1972 | { |
---|
1973 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
1974 | foreach($overlapped_event['participants'] as $id => $status) |
---|
1975 | { |
---|
1976 | $conflict = isset($event['participants'][$user_id]); |
---|
1977 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
1978 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
1979 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; |
---|
1980 | } |
---|
1981 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
1982 | $overlap .= '<ul><font size="1"><span>'. |
---|
1983 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
1984 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
1985 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
1986 | $this->normDec($overlapped_event['end']['min']). |
---|
1987 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
1988 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
1989 | else |
---|
1990 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>"; |
---|
1991 | } |
---|
1992 | |
---|
1993 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1994 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1995 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
1996 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
1997 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
1998 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1999 | |
---|
2000 | $p = $GLOBALS['phpgw']->template; |
---|
2001 | $p->set_file( |
---|
2002 | Array( |
---|
2003 | 'overlap' => 'overlap.tpl', |
---|
2004 | 'form_button' => 'form_button_script.tpl' |
---|
2005 | ) |
---|
2006 | ); |
---|
2007 | |
---|
2008 | $var = Array( |
---|
2009 | 'color' => $this->theme['bg_text'], |
---|
2010 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
2011 | '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)), |
---|
2012 | 'overlap_list' => $overlap |
---|
2013 | ); |
---|
2014 | $p->set_var($var); |
---|
2015 | |
---|
2016 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
2017 | $var = Array( |
---|
2018 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 3, 'user_id' => $user_id, 'ignore_conflict' => 1)), |
---|
2019 | 'action_text_button' => lang('Ignore Conflict'), |
---|
2020 | 'action_confirm_button' => '', |
---|
2021 | 'action_extra_field' => '', |
---|
2022 | 'button_id' => 'ignore_button' |
---|
2023 | ); |
---|
2024 | $action_reject = $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0, 'response' => 0)); |
---|
2025 | |
---|
2026 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
2027 | |
---|
2028 | $var = Array( |
---|
2029 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.set_action','cal_id' => $event[id], 'action' => 0)), |
---|
2030 | 'action_text_button' => lang('Reject'), |
---|
2031 | 'action_confirm_button' => '', |
---|
2032 | 'action_extra_field' => '', |
---|
2033 | 'button_id' => 'redit_button' |
---|
2034 | ); |
---|
2035 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
2036 | $p->pparse('out','overlap'); |
---|
2037 | } |
---|
2038 | } |
---|
2039 | |
---|
2040 | function set_action() |
---|
2041 | { |
---|
2042 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) |
---|
2043 | { |
---|
2044 | $this->no_edit(); |
---|
2045 | return; |
---|
2046 | } |
---|
2047 | |
---|
2048 | $overlapping_events = false; |
---|
2049 | $event = $this->bo->read_entry((int)$_GET['cal_id']); |
---|
2050 | if((!$_GET['response'] == 0 && !$_GET['ignore_conflict'] == 1) || |
---|
2051 | (!isset($_GET['response']) && $_GET['action'] == 3 && !$_GET['ignore_conflict'] == 1)) |
---|
2052 | { |
---|
2053 | if($event['id']) |
---|
2054 | { |
---|
2055 | $event_ids[] = $event['id']; |
---|
2056 | } |
---|
2057 | if($event['reference']) |
---|
2058 | { |
---|
2059 | $event_ids[] = $event['reference']; |
---|
2060 | } |
---|
2061 | |
---|
2062 | $event['participants'] = Array($_SESSION['phpgw_info']['expressomail']['user']['account_id'] => $event['participants'][$_SESSION['phpgw_info']['expressomail']['user']['account_id']]); |
---|
2063 | |
---|
2064 | $overlapping_events = $this->bo->overlap( |
---|
2065 | $this->bo->maketime($event['start']), |
---|
2066 | $this->bo->maketime($event['end']), |
---|
2067 | $event['participants'], |
---|
2068 | $event['owner'], |
---|
2069 | $event_ids |
---|
2070 | ); |
---|
2071 | } |
---|
2072 | |
---|
2073 | if(isset($_GET['response'])) |
---|
2074 | { |
---|
2075 | if($overlapping_events) |
---|
2076 | { |
---|
2077 | $this->confirm_conflict($_GET['user_id'],$event); |
---|
2078 | }else |
---|
2079 | { |
---|
2080 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); |
---|
2081 | $this->confirm_action($confirm_status); |
---|
2082 | $GLOBALS['phpgw']->common->phpgw_exit(False); |
---|
2083 | } |
---|
2084 | }else |
---|
2085 | { |
---|
2086 | if($overlapping_events) |
---|
2087 | { |
---|
2088 | $this->confirm_conflict($_GET['user_id'],$event,$overlapping_events); |
---|
2089 | }else |
---|
2090 | { |
---|
2091 | $confirm_status = $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']); |
---|
2092 | if ($this->bo->return_to) |
---|
2093 | { |
---|
2094 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); |
---|
2095 | } |
---|
2096 | else |
---|
2097 | { |
---|
2098 | Header('Location: '.$this->page('','')); |
---|
2099 | } |
---|
2100 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
2101 | } |
---|
2102 | } |
---|
2103 | |
---|
2104 | |
---|
2105 | } |
---|
2106 | function planner() |
---|
2107 | { |
---|
2108 | if(floor(phpversion()) < 4) |
---|
2109 | { |
---|
2110 | return; |
---|
2111 | } |
---|
2112 | $home = strstr($_SERVER['PHP_SELF'],'home') !== False; |
---|
2113 | // generate header and set global/member variables |
---|
2114 | // |
---|
2115 | $this->planner_prepare($home); |
---|
2116 | |
---|
2117 | // process events within selected interval |
---|
2118 | // |
---|
2119 | $this->planner_process_interval(); |
---|
2120 | |
---|
2121 | // generate the planner view |
---|
2122 | // |
---|
2123 | if (!$home) |
---|
2124 | { |
---|
2125 | echo '<p>'.$this->planner_print_rows(); |
---|
2126 | } |
---|
2127 | else |
---|
2128 | { |
---|
2129 | return $this->planner_print_rows(); |
---|
2130 | } |
---|
2131 | } |
---|
2132 | |
---|
2133 | function set_planner_group_members() |
---|
2134 | { |
---|
2135 | $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); |
---|
2136 | |
---|
2137 | if ($type == 'g') // display schedule of all group members |
---|
2138 | { |
---|
2139 | $members = array(); |
---|
2140 | $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); |
---|
2141 | while (list(,$id) = each($ids)) |
---|
2142 | { |
---|
2143 | if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) |
---|
2144 | { |
---|
2145 | $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; |
---|
2146 | } |
---|
2147 | } |
---|
2148 | ksort($members); |
---|
2149 | $this->planner_group_members = $members; |
---|
2150 | } |
---|
2151 | else |
---|
2152 | { |
---|
2153 | $this->planner_group_members = array( |
---|
2154 | $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner |
---|
2155 | ); |
---|
2156 | } |
---|
2157 | } |
---|
2158 | |
---|
2159 | /** |
---|
2160 | * planner_prepare - prepare the planner view |
---|
2161 | * |
---|
2162 | * - sets global environment variables |
---|
2163 | * - initializes class member variables used in multiple planner related functions |
---|
2164 | * - generates header lines for the planner view (month, calendar week, days) |
---|
2165 | */ |
---|
2166 | function planner_prepare($no_header = False) |
---|
2167 | { |
---|
2168 | // set some globals |
---|
2169 | // |
---|
2170 | if (!$no_header) |
---|
2171 | { |
---|
2172 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2173 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2174 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Group Planner'); |
---|
2175 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2176 | } |
---|
2177 | |
---|
2178 | // intervals_per_day can be configured in preferences now :-) |
---|
2179 | // |
---|
2180 | if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) |
---|
2181 | { |
---|
2182 | $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); |
---|
2183 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
2184 | $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; |
---|
2185 | } |
---|
2186 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2187 | $this->bo->save_sessiondata(); // need to save $this->bo->save_owner |
---|
2188 | |
---|
2189 | // set title for table and rows of planner view |
---|
2190 | // |
---|
2191 | if ($this->bo->sortby == 'category') |
---|
2192 | { |
---|
2193 | $title = lang('Category'); |
---|
2194 | } |
---|
2195 | else |
---|
2196 | { |
---|
2197 | $title = lang('User'); |
---|
2198 | |
---|
2199 | $this->set_planner_group_members(); |
---|
2200 | } |
---|
2201 | |
---|
2202 | // create/initialize variables directly used for HTML code generation |
---|
2203 | // |
---|
2204 | $this->planner_header = array(); |
---|
2205 | $this->planner_rows = array(); |
---|
2206 | |
---|
2207 | // generate header lines with days and associated months |
---|
2208 | // |
---|
2209 | $hdr = &$this->planner_header; |
---|
2210 | $hdr[0]['0'] = $title; |
---|
2211 | $hdr[0]['.0'] = 'rowspan="3"'; |
---|
2212 | |
---|
2213 | $this->planner_days = 0; // reset |
---|
2214 | |
---|
2215 | $m = $this->bo->month; |
---|
2216 | $y = $this->bo->year; |
---|
2217 | $this->bo->read_holidays($y); |
---|
2218 | for ($i=1; $i<=$this->bo->num_months; $i++,$m++) |
---|
2219 | { |
---|
2220 | if ($m == 13) |
---|
2221 | { |
---|
2222 | $m = 1; $y++; // "wrap-around" into new year |
---|
2223 | $this->bo->read_holidays($y); |
---|
2224 | } |
---|
2225 | $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); |
---|
2226 | |
---|
2227 | $d = mktime(0,0,0,$m,1,$y); |
---|
2228 | $month = lang(date('F', $d)).strftime(' %Y', $d); |
---|
2229 | $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; |
---|
2230 | $cols = $days * $intervals_per_day; |
---|
2231 | |
---|
2232 | $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; |
---|
2233 | $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); |
---|
2234 | $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); |
---|
2235 | $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); |
---|
2236 | $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); |
---|
2237 | $hdr[0][$i] = "<b><a href=\"$prev_link\"><<</a>   $month   <a href=\"$next_link\">>></a></b>"; |
---|
2238 | |
---|
2239 | $add_owner = array(); // if no add-rights on the showed cal use own cal |
---|
2240 | if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || |
---|
2241 | !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) |
---|
2242 | { |
---|
2243 | $add_owner = array( |
---|
2244 | 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] |
---|
2245 | ); |
---|
2246 | } |
---|
2247 | for ($d=1; $d<=$days; $d++) |
---|
2248 | { |
---|
2249 | $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); |
---|
2250 | $index = $d + $this->planner_days; |
---|
2251 | |
---|
2252 | $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; |
---|
2253 | |
---|
2254 | // highlight today, saturday, sunday and holidays |
---|
2255 | // |
---|
2256 | $color = $this->theme['row_off']; |
---|
2257 | $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); |
---|
2258 | $date = sprintf("%04d%02d%02d",$y,$m,$d); |
---|
2259 | if ($date == date('Ymd')) |
---|
2260 | { |
---|
2261 | $color = $GLOBALS['phpgw_info']['theme']['cal_today']; |
---|
2262 | } |
---|
2263 | elseif ($this->bo->cached_holidays[$date]) |
---|
2264 | { |
---|
2265 | $color = $this->bo->holiday_color; |
---|
2266 | $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; |
---|
2267 | } |
---|
2268 | elseif ($dow == 0 || $dow == 6) |
---|
2269 | { |
---|
2270 | $color = $this->bo->theme['th_bg']; |
---|
2271 | } |
---|
2272 | |
---|
2273 | $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; |
---|
2274 | |
---|
2275 | $hdr[2][$index] = '<a href="'.$this->html->link('/index.php', |
---|
2276 | array( |
---|
2277 | 'menuaction' => 'calendar.uicalendar.add', |
---|
2278 | 'date' => $date |
---|
2279 | ) + $add_owner |
---|
2280 | ).'">'.$dayname.'<br>'.$d.'</a>'; |
---|
2281 | } |
---|
2282 | $this->planner_days += $days; |
---|
2283 | } |
---|
2284 | |
---|
2285 | // create/initialize member variables describing the time interval to be displayed |
---|
2286 | // |
---|
2287 | $this->planner_end_month = $m - 1; |
---|
2288 | $this->planner_end_year = $y; |
---|
2289 | $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); |
---|
2290 | $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); |
---|
2291 | $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); |
---|
2292 | |
---|
2293 | // generate line with calendar weeks in observed interval |
---|
2294 | // |
---|
2295 | $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); |
---|
2296 | $w = date('W', $d); |
---|
2297 | if ($w == 'W') // php < 4.1 |
---|
2298 | { |
---|
2299 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
2300 | } |
---|
2301 | $offset = (7-date('w', $d)+1)%7; |
---|
2302 | $offset = $offset == 0 ? 7 : $offset; |
---|
2303 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
2304 | |
---|
2305 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; |
---|
2306 | $hdr[1][$w] = ''; |
---|
2307 | if ($offset >= 3) |
---|
2308 | { |
---|
2309 | |
---|
2310 | //NDEE: style! (groupplanner) |
---|
2311 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
2312 | } |
---|
2313 | $days_left = $this->planner_days - $offset; |
---|
2314 | |
---|
2315 | $colspan = 7 * $intervals_per_day; |
---|
2316 | while ($days_left > 0) |
---|
2317 | { |
---|
2318 | $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; |
---|
2319 | $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each |
---|
2320 | $w = date('W', $d); |
---|
2321 | if ($w == 'W') // php < 4.1 |
---|
2322 | { |
---|
2323 | $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic |
---|
2324 | } |
---|
2325 | $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? |
---|
2326 | |
---|
2327 | $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; |
---|
2328 | $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; |
---|
2329 | $hdr[1][$w] = ''; |
---|
2330 | if ($days_left >= 3) |
---|
2331 | { |
---|
2332 | |
---|
2333 | //NDEE: style! (groupplanner) |
---|
2334 | $hdr[1][$w] .= '<font size="-2"> '.lang('week').' '.$w.' </font>'; |
---|
2335 | } |
---|
2336 | |
---|
2337 | $days_left -= 7; |
---|
2338 | } |
---|
2339 | return $hdr; |
---|
2340 | } |
---|
2341 | |
---|
2342 | /** |
---|
2343 | * planner_update_row - update a row of the planner view |
---|
2344 | * |
---|
2345 | * parameters are: |
---|
2346 | * - index (e.g. user id, category id, ...) of the row |
---|
2347 | * - name/title of the row (e.g. user name, category name) |
---|
2348 | * - the event to be integrated |
---|
2349 | * - list of categories associated with the event |
---|
2350 | * - first and last cell of the row |
---|
2351 | */ |
---|
2352 | function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) |
---|
2353 | { |
---|
2354 | $rows = &$this->planner_rows; |
---|
2355 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2356 | $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
2357 | |
---|
2358 | $view = $this->html->link('/index.php', |
---|
2359 | array( |
---|
2360 | 'menuaction' => 'calendar.uicalendar.view', |
---|
2361 | 'cal_id' => $event['id'], |
---|
2362 | 'date' => date('Ymd',$this->bo->maketime($event['start'])) |
---|
2363 | ) |
---|
2364 | ); |
---|
2365 | |
---|
2366 | // check how many lines are needed for this "row" (currently: user or category) |
---|
2367 | $i = 0; |
---|
2368 | do { |
---|
2369 | ++$i; |
---|
2370 | |
---|
2371 | $k = $index.'_'.$i; |
---|
2372 | $ka = '.nr_'.$k; |
---|
2373 | |
---|
2374 | if (!isset($rows[$k])) |
---|
2375 | { |
---|
2376 | if ($i > 1) // further line - no name |
---|
2377 | { |
---|
2378 | $rows[$k] = array(); |
---|
2379 | $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; |
---|
2380 | } |
---|
2381 | else |
---|
2382 | { |
---|
2383 | $rows[$k]['_name'] = $name; |
---|
2384 | } |
---|
2385 | $rows[$ka] = 0; |
---|
2386 | } |
---|
2387 | $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row |
---|
2388 | |
---|
2389 | $row = &$rows[$k]; |
---|
2390 | $akt_cell = &$rows[$ka]; |
---|
2391 | } while ($akt_cell > $start_cell); |
---|
2392 | |
---|
2393 | $id = $event['id'].'-'.date('Ymd',$this->bo->maketime($event['start'])); |
---|
2394 | if ($akt_cell < $start_cell) |
---|
2395 | { |
---|
2396 | $row[$id.'_1'] = ' '; |
---|
2397 | $row['.'.$id.'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; |
---|
2398 | } |
---|
2399 | $opt = &$row['.'.$id.'_2']; |
---|
2400 | $cel = &$row[$id.'_2']; |
---|
2401 | |
---|
2402 | // if possible, display information about event within cells representing it |
---|
2403 | // |
---|
2404 | if ($start_cell < $end_cell) |
---|
2405 | { |
---|
2406 | $colspan = $end_cell - $start_cell; |
---|
2407 | $opt .= "colspan=".(1 + $colspan); |
---|
2408 | |
---|
2409 | if (!$is_private) |
---|
2410 | { |
---|
2411 | $max_chars = (int)(3*$colspan/$intervals_per_day-2); |
---|
2412 | |
---|
2413 | $min_chars = 3; // minimum for max_chars to display -> this should be configurable |
---|
2414 | if ($max_chars >= $min_chars) |
---|
2415 | { |
---|
2416 | $len_title = strlen($event['title']); |
---|
2417 | |
---|
2418 | if ($len_title <= $max_chars) |
---|
2419 | { |
---|
2420 | $title = $event['title']; |
---|
2421 | $max_chars -= $len_title + 3; // 3 chars for separator: " - " |
---|
2422 | $len_descr = strlen($event['description']); |
---|
2423 | |
---|
2424 | if ($len_descr > 0 && $len_descr <= $max_chars) |
---|
2425 | { |
---|
2426 | $event['print_description'] = 'yes'; |
---|
2427 | } |
---|
2428 | } |
---|
2429 | else |
---|
2430 | { |
---|
2431 | $has_amp = strpos($event['title'],'&'); |
---|
2432 | |
---|
2433 | //NDEE: event title gets cut here |
---|
2434 | $title = substr($event['title'], 0 , $max_chars-1+($has_amp!==False&&$has_amp<$max_chars?4:0)).'...'; |
---|
2435 | } |
---|
2436 | $event['print_title'] = 'yes'; |
---|
2437 | } |
---|
2438 | } |
---|
2439 | } |
---|
2440 | |
---|
2441 | if ($bgcolor=$cat['color']) |
---|
2442 | { |
---|
2443 | $opt .= ' bgcolor="'.$bgcolor.'"'; |
---|
2444 | } |
---|
2445 | if (!$is_private) |
---|
2446 | { |
---|
2447 | $opt .= ' title="'.lang('Title').": ".$event['title']; |
---|
2448 | if ($event['description']) |
---|
2449 | { |
---|
2450 | $opt .= "\n".lang('Description').": ".$event['description']; |
---|
2451 | } |
---|
2452 | } |
---|
2453 | else |
---|
2454 | { |
---|
2455 | $opt .= ' title="'.lang('You do not have permission to read this record!'); |
---|
2456 | } |
---|
2457 | |
---|
2458 | $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
2459 | $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
2460 | $opt .= "\n".lang('Start Date/Time').": ".$start."\n".lang('End Date/Time').": ".$end; |
---|
2461 | |
---|
2462 | if ($event['location'] && !$is_private) |
---|
2463 | { |
---|
2464 | $opt .= " \n".lang('Location').": ".$event['location']; |
---|
2465 | } |
---|
2466 | |
---|
2467 | if (!$is_private) |
---|
2468 | { |
---|
2469 | $opt .= '" onClick="location=\''.$view.'\'"'; |
---|
2470 | $cel = '<a href="'.$view.'">'; |
---|
2471 | } |
---|
2472 | else |
---|
2473 | { |
---|
2474 | $opt .= '"'; |
---|
2475 | $cel = ''; |
---|
2476 | } |
---|
2477 | $opt .= ' class="planner-cell"'; |
---|
2478 | |
---|
2479 | if ($event['priority'] == 3) |
---|
2480 | { |
---|
2481 | $cel .= $this->html->image('calendar','mini-calendar-bar.gif','','border="0"'); |
---|
2482 | } |
---|
2483 | if ($event['recur_type']) |
---|
2484 | { |
---|
2485 | $cel .= $this->html->image('calendar','recur.gif','','border="0"'); |
---|
2486 | } |
---|
2487 | $cel .= $this->html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); |
---|
2488 | $cel .= '</a>'; |
---|
2489 | |
---|
2490 | if (isset($event['print_title']) && $event['print_title'] == 'yes') |
---|
2491 | { |
---|
2492 | |
---|
2493 | //NDEE: style! where? |
---|
2494 | $cel .= '<font size="-2"> '.$title.' </font>'; |
---|
2495 | } |
---|
2496 | if (isset($event['print_description']) && $event['print_description'] == 'yes') |
---|
2497 | { |
---|
2498 | |
---|
2499 | //NDEE: style! where ? |
---|
2500 | $cel .= '<font size="-2"> - '.$event['description'].' </font>'; |
---|
2501 | } |
---|
2502 | |
---|
2503 | $akt_cell = $end_cell + 1; |
---|
2504 | |
---|
2505 | return $rows; |
---|
2506 | } |
---|
2507 | |
---|
2508 | function planner_process_event($event) |
---|
2509 | { |
---|
2510 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2511 | $interval = $this->planner_intervals[$intervals_per_day]; |
---|
2512 | $last_cell = $intervals_per_day * $this->planner_days - 1; |
---|
2513 | |
---|
2514 | $rows = &$this->planner_rows; |
---|
2515 | |
---|
2516 | // caluculate start and end of event |
---|
2517 | // |
---|
2518 | $event_start = (int)(date('Ymd',mktime( |
---|
2519 | 0,0,0, |
---|
2520 | $event['start']['month'], |
---|
2521 | $event['start']['mday'], |
---|
2522 | $event['start']['year'] |
---|
2523 | ))); |
---|
2524 | $event_end = (int)(date('Ymd',mktime( |
---|
2525 | 0,0,0, |
---|
2526 | $event['end']['month'], |
---|
2527 | $event['end']['mday'], |
---|
2528 | $event['end']['year'] |
---|
2529 | ))); |
---|
2530 | |
---|
2531 | // calculate first cell of event within observed interval |
---|
2532 | // |
---|
2533 | if ($event_start >= $this->planner_firstday) |
---|
2534 | { |
---|
2535 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); |
---|
2536 | |
---|
2537 | $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; |
---|
2538 | } |
---|
2539 | else |
---|
2540 | { |
---|
2541 | $start_cell = 0; |
---|
2542 | } |
---|
2543 | |
---|
2544 | // calculate last cell of event within observed interval |
---|
2545 | // |
---|
2546 | if ($event_end <= $this->planner_lastday) |
---|
2547 | { |
---|
2548 | $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); |
---|
2549 | $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; |
---|
2550 | if ($end_cell == $start_cell && $end_cell < $last_cell) |
---|
2551 | { |
---|
2552 | $end_cell++; // min. width 1 interval |
---|
2553 | } |
---|
2554 | } |
---|
2555 | else |
---|
2556 | { |
---|
2557 | $end_cell = $last_cell; |
---|
2558 | } |
---|
2559 | // get the categories associated with event |
---|
2560 | // |
---|
2561 | if ($c = $event['category']) |
---|
2562 | { |
---|
2563 | list($cat) = $this->planner_category($event['category']); |
---|
2564 | if ($cat['parent']) |
---|
2565 | { |
---|
2566 | list($pcat) = $this->planner_category($c = $cat['parent']); |
---|
2567 | } |
---|
2568 | else |
---|
2569 | { |
---|
2570 | $pcat = $cat; |
---|
2571 | } |
---|
2572 | } |
---|
2573 | else |
---|
2574 | { |
---|
2575 | $cat = $pcat = array( 'name' => lang('none')); |
---|
2576 | } |
---|
2577 | |
---|
2578 | // add the event to it`s associated row(s) |
---|
2579 | // |
---|
2580 | if ($this->bo->sortby == 'category') |
---|
2581 | { |
---|
2582 | // event needs to show up in it`s category`s row |
---|
2583 | // |
---|
2584 | $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); |
---|
2585 | } |
---|
2586 | elseif ($this->bo->sortby == 'user') |
---|
2587 | { |
---|
2588 | // event needs to show up in rows of all participants that are also owners |
---|
2589 | // |
---|
2590 | reset($this->planner_group_members); |
---|
2591 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
2592 | { |
---|
2593 | $status = $event['participants'][$id]; |
---|
2594 | |
---|
2595 | if (isset($status) && $status != 'R') |
---|
2596 | { |
---|
2597 | $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); |
---|
2598 | } |
---|
2599 | } |
---|
2600 | } |
---|
2601 | } |
---|
2602 | |
---|
2603 | function planner_pad_rows() |
---|
2604 | { |
---|
2605 | $rows = &$this->planner_rows; |
---|
2606 | |
---|
2607 | if ($this->bo->sortby == 'user') |
---|
2608 | { |
---|
2609 | // add empty rows for users that do not participante in any event |
---|
2610 | // |
---|
2611 | reset($this->planner_group_members); |
---|
2612 | while(list($user_name,$id) = each($this->planner_group_members)) |
---|
2613 | { |
---|
2614 | $k = $user_name.'_1'; |
---|
2615 | $ka = '.nr_'.$k; |
---|
2616 | |
---|
2617 | if (!isset($rows[$k])) |
---|
2618 | { |
---|
2619 | $rows[$k]['_name'] = $user_name; |
---|
2620 | $rows[$k]['._name'] .= ' nowrap'; |
---|
2621 | $rows[$ka] = 0; |
---|
2622 | } |
---|
2623 | } |
---|
2624 | } |
---|
2625 | |
---|
2626 | // fill the remaining cols |
---|
2627 | // |
---|
2628 | $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; |
---|
2629 | |
---|
2630 | ksort($rows); |
---|
2631 | while (list($k,$r) = each($rows)) |
---|
2632 | { |
---|
2633 | if (is_array($r)) |
---|
2634 | { |
---|
2635 | $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; |
---|
2636 | $row = &$rows[$k]; |
---|
2637 | $akt_cell = &$rows['.nr_'.$k]; |
---|
2638 | if ($akt_cell < $last_cell) |
---|
2639 | { |
---|
2640 | $row['3'] = ' '; |
---|
2641 | $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; |
---|
2642 | } |
---|
2643 | } |
---|
2644 | } |
---|
2645 | } |
---|
2646 | |
---|
2647 | function planner_print_rows() |
---|
2648 | { |
---|
2649 | $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; |
---|
2650 | $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; |
---|
2651 | |
---|
2652 | if ($this->debug) |
---|
2653 | { |
---|
2654 | _debug_array($this->planner_rows); |
---|
2655 | reset($this->planner_rows); |
---|
2656 | } |
---|
2657 | return $this->html->table( |
---|
2658 | array( |
---|
2659 | '_hdr0' => $this->planner_header[0], |
---|
2660 | '._hdr0' => $bgcolor, |
---|
2661 | '_hdr1' => $this->planner_header[1], |
---|
2662 | '._hdr1' => $bgcolor, |
---|
2663 | '_hdr2' => $this->planner_header[2], |
---|
2664 | '._hdr2' => $bgcolor |
---|
2665 | )+$this->planner_rows, |
---|
2666 | 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); |
---|
2667 | } |
---|
2668 | |
---|
2669 | function planner_process_interval() |
---|
2670 | { |
---|
2671 | // generate duplicate free list of events within observed interval |
---|
2672 | // |
---|
2673 | $this->bo->store_to_cache( |
---|
2674 | Array( |
---|
2675 | 'syear' => $this->bo->year, |
---|
2676 | 'smonth' => $this->bo->month, |
---|
2677 | 'sday' => 1, |
---|
2678 | 'eyear' => $this->planner_end_year, |
---|
2679 | 'emonth' => $this->planner_end_month, |
---|
2680 | 'eday' => $this->planner_days_in_end_month |
---|
2681 | ) |
---|
2682 | ); |
---|
2683 | $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); |
---|
2684 | |
---|
2685 | // process all events within observed interval |
---|
2686 | // |
---|
2687 | for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) |
---|
2688 | { |
---|
2689 | $daily = $this->bo->cached_events[$v]; |
---|
2690 | |
---|
2691 | print_debug('For Date',$v); |
---|
2692 | print_debug('Count of items',count($daily)); |
---|
2693 | |
---|
2694 | // process all events on day $v |
---|
2695 | // |
---|
2696 | if (is_array($daily)) foreach($daily as $event) |
---|
2697 | { |
---|
2698 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
2699 | { |
---|
2700 | $this->bo->set_recur_date($event,$v); |
---|
2701 | } |
---|
2702 | if (!$this->bo->rejected_no_show($event)) |
---|
2703 | { |
---|
2704 | $this->planner_process_event($event); |
---|
2705 | } |
---|
2706 | } |
---|
2707 | } |
---|
2708 | $this->planner_pad_rows(); |
---|
2709 | } |
---|
2710 | |
---|
2711 | function matrixselect() |
---|
2712 | { |
---|
2713 | $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
2714 | |
---|
2715 | $sb = CreateObject('phpgwapi.sbox'); |
---|
2716 | |
---|
2717 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2718 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2719 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
2720 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2721 | |
---|
2722 | $p = &$GLOBALS['phpgw']->template; |
---|
2723 | $p->set_file( |
---|
2724 | Array( |
---|
2725 | 'mq' => 'matrix_query.tpl', |
---|
2726 | 'form_button' => 'form_button_script.tpl' |
---|
2727 | ) |
---|
2728 | ); |
---|
2729 | $p->set_block('mq','matrix_query','matrix_query'); |
---|
2730 | $p->set_block('mq','list','list'); |
---|
2731 | |
---|
2732 | $p->set_var(array( |
---|
2733 | 'title' => lang('Daily Matrix View'), |
---|
2734 | 'th_bg' => $this->theme['th_bg'], |
---|
2735 | 'action_url' => $this->page('viewmatrix') |
---|
2736 | )); |
---|
2737 | |
---|
2738 | // Date |
---|
2739 | $var[] = Array( |
---|
2740 | 'field' => lang('Date'), |
---|
2741 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
2742 | $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')), |
---|
2743 | $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')), |
---|
2744 | $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d')) |
---|
2745 | ) |
---|
2746 | ); |
---|
2747 | |
---|
2748 | // View type |
---|
2749 | $var[] = Array( |
---|
2750 | 'field' => lang('View'), |
---|
2751 | 'data' => '<select name="matrixtype">'."\n" |
---|
2752 | . '<option value="free/busy" selected>'.lang('free/busy').'</option>'."\n" |
---|
2753 | . '<option value="weekly">'.lang('Weekly').'</option>'."\n" |
---|
2754 | . '</select>'."\n" |
---|
2755 | ); |
---|
2756 | |
---|
2757 | // Participants |
---|
2758 | $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); |
---|
2759 | $users = Array(); |
---|
2760 | for($i=0;$i<count($accounts);$i++) |
---|
2761 | { |
---|
2762 | $user = $accounts[$i]; |
---|
2763 | if(!isset($users[$user])) |
---|
2764 | { |
---|
2765 | $users[$user] = $GLOBALS['phpgw']->common->grab_owner_name($user); |
---|
2766 | if($GLOBALS['phpgw']->accounts->get_type($user) == 'g') |
---|
2767 | { |
---|
2768 | $group_members = $GLOBALS['phpgw']->acl->get_ids_for_location($user,1,'phpgw_group'); |
---|
2769 | if($group_members != False) |
---|
2770 | { |
---|
2771 | for($j=0;$j<count($group_members);$j++) |
---|
2772 | { |
---|
2773 | if(!isset($users[$group_members[$j]])) |
---|
2774 | { |
---|
2775 | $users[$group_members[$j]] = $GLOBALS['phpgw']->common->grab_owner_name($group_members[$j]); |
---|
2776 | } |
---|
2777 | } |
---|
2778 | } |
---|
2779 | } |
---|
2780 | } |
---|
2781 | } |
---|
2782 | |
---|
2783 | $num_users = count($users); |
---|
2784 | |
---|
2785 | if ($num_users > 50) |
---|
2786 | { |
---|
2787 | $size = 15; |
---|
2788 | } |
---|
2789 | elseif ($num_users > 5) |
---|
2790 | { |
---|
2791 | $size = 5; |
---|
2792 | } |
---|
2793 | else |
---|
2794 | { |
---|
2795 | $size = $num_users; |
---|
2796 | } |
---|
2797 | $str = ''; |
---|
2798 | @asort($users); |
---|
2799 | @reset($users); |
---|
2800 | while ($user = each($users)) |
---|
2801 | { |
---|
2802 | 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') |
---|
2803 | { |
---|
2804 | $str .= ' <option value="'.$user[0].'">('.$GLOBALS['phpgw']->accounts->get_type($user[0]).') '.$user[1].'</option>'."\n"; |
---|
2805 | } |
---|
2806 | } |
---|
2807 | $var[] = Array( |
---|
2808 | 'field' => lang('Participants'), |
---|
2809 | 'data' => "\n".' <select name="participants[]" multiple size="'.$size.'">'."\n".$str.' </select>'."\n" |
---|
2810 | ); |
---|
2811 | |
---|
2812 | for($i=0;$i<count($var);$i++) |
---|
2813 | { |
---|
2814 | $this->output_template_array($p,'rows','list',$var[$i]); |
---|
2815 | } |
---|
2816 | |
---|
2817 | $vars = Array( |
---|
2818 | 'submit_button' => lang('View'), |
---|
2819 | 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), |
---|
2820 | 'action_text_button' => lang('Cancel'), |
---|
2821 | 'action_confirm_button' => '', |
---|
2822 | 'action_extra_field' => '' |
---|
2823 | ); |
---|
2824 | |
---|
2825 | $p->set_var($vars); |
---|
2826 | $p->parse('cancel_button','form_button'); |
---|
2827 | $p->pparse('out','matrix_query'); |
---|
2828 | } |
---|
2829 | |
---|
2830 | function viewmatrix() |
---|
2831 | { |
---|
2832 | if ($_POST['cancel']) |
---|
2833 | { |
---|
2834 | $this->index(); |
---|
2835 | } |
---|
2836 | $participants = $_POST['participants']; |
---|
2837 | $parts = Array(); |
---|
2838 | $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); |
---|
2839 | |
---|
2840 | if (is_array($participants)) |
---|
2841 | { |
---|
2842 | foreach($participants as $participant) |
---|
2843 | { |
---|
2844 | switch ($GLOBALS['phpgw']->accounts->get_type($participant)) |
---|
2845 | { |
---|
2846 | case 'g': |
---|
2847 | if ($members = $acct->member((int)$participant)) |
---|
2848 | { |
---|
2849 | foreach($members as $member) |
---|
2850 | { |
---|
2851 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id'])) |
---|
2852 | { |
---|
2853 | $parts[$member['account_id']] = True; |
---|
2854 | } |
---|
2855 | } |
---|
2856 | } |
---|
2857 | break; |
---|
2858 | case 'u': |
---|
2859 | if($this->bo->check_perms(PHPGW_ACL_READ,0,$participant)) |
---|
2860 | { |
---|
2861 | $parts[$participant] = 1; |
---|
2862 | } |
---|
2863 | break; |
---|
2864 | } |
---|
2865 | } |
---|
2866 | unset($acct); |
---|
2867 | } |
---|
2868 | $participants = array_keys($parts); // get id's as values and a numeric index |
---|
2869 | |
---|
2870 | // Defined - into session - who participates |
---|
2871 | $GLOBALS['phpgw']->session->appsession("participants", NULL, implode(";", $participants)); |
---|
2872 | |
---|
2873 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2874 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2875 | if ($this->always_app_header) $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Matrixview'); |
---|
2876 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2877 | |
---|
2878 | switch($_POST['matrixtype']) |
---|
2879 | { |
---|
2880 | case 'free/busy': |
---|
2881 | $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); |
---|
2882 | echo '<br>'.$this->timematrix( |
---|
2883 | Array( |
---|
2884 | 'date' => $freetime, |
---|
2885 | 'starttime' => $this->bo->splittime('000000',False), |
---|
2886 | 'endtime' => 0, |
---|
2887 | 'participants' => $parts |
---|
2888 | ) |
---|
2889 | ); |
---|
2890 | break; |
---|
2891 | case 'weekly': |
---|
2892 | echo '<br>'.$this->display_weekly( |
---|
2893 | Array( |
---|
2894 | 'date' => sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day), |
---|
2895 | 'showyear' => true, |
---|
2896 | 'owners' => $participants |
---|
2897 | ) |
---|
2898 | ); |
---|
2899 | break; |
---|
2900 | } |
---|
2901 | echo "\n<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n"; |
---|
2902 | echo ' <table cellpadding="5"><tr><td>'."\n"; |
---|
2903 | echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
2904 | echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
2905 | echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
2906 | echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\n"; |
---|
2907 | foreach($participants as $part) |
---|
2908 | { |
---|
2909 | echo ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n"; |
---|
2910 | } |
---|
2911 | echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n"; |
---|
2912 | echo ' </td><td>'."\n"; |
---|
2913 | echo ' <input type="submit" name="cancel" value="'.lang('Cancel').'">'."\n"; |
---|
2914 | echo ' </td></tr></table>'."\n"; |
---|
2915 | echo '</form>'."\n"; |
---|
2916 | } |
---|
2917 | |
---|
2918 | function search() |
---|
2919 | { |
---|
2920 | if (empty($_POST['keywords'])) |
---|
2921 | { |
---|
2922 | // If we reach this, it is because they didn't search for anything |
---|
2923 | // or they used one of the selectboxes (year, month, week) in the search-result |
---|
2924 | // attempt to send them back to where they came from. |
---|
2925 | |
---|
2926 | $vars['menuaction'] = isset($_POST['from']) && $_POST['from'] != 'calendar.uicalendar.search' ? |
---|
2927 | $_POST['from'] : 'calendar.uicalendar.index'; |
---|
2928 | |
---|
2929 | foreach(array('date','year','month','day') as $field) |
---|
2930 | { |
---|
2931 | if (isset($_POST[$field])) |
---|
2932 | { |
---|
2933 | $vars[$field] = $_POST[$field]; |
---|
2934 | } |
---|
2935 | } |
---|
2936 | $GLOBALS['phpgw']->redirect_link('/index.php',$vars); |
---|
2937 | } |
---|
2938 | |
---|
2939 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
2940 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
2941 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Search Results'); |
---|
2942 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
2943 | |
---|
2944 | $error = ''; |
---|
2945 | |
---|
2946 | $matches = 0; |
---|
2947 | |
---|
2948 | // There is currently a problem searching in with repeated events. |
---|
2949 | // It spits back out the date it was entered. I would like to to say that |
---|
2950 | // it is a repeated event. |
---|
2951 | |
---|
2952 | // This has been solved by the little icon indicator for recurring events. |
---|
2953 | |
---|
2954 | $event_ids = $this->bo->search_keywords($_POST['keywords']); |
---|
2955 | foreach($event_ids as $key => $id) |
---|
2956 | { |
---|
2957 | $event = $this->bo->read_entry($id); |
---|
2958 | |
---|
2959 | if(!$this->bo->check_perms(PHPGW_ACL_READ,$event)) |
---|
2960 | { |
---|
2961 | continue; |
---|
2962 | } |
---|
2963 | |
---|
2964 | $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
2965 | |
---|
2966 | $info[strval($event['id'])] = array( |
---|
2967 | 'tr_color' => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(), |
---|
2968 | 'date' => $GLOBALS['phpgw']->common->show_date($datetime), |
---|
2969 | 'link' => $this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']) |
---|
2970 | ); |
---|
2971 | |
---|
2972 | } |
---|
2973 | $matches = count($event_ids); |
---|
2974 | |
---|
2975 | if ($matches == 1) |
---|
2976 | { |
---|
2977 | $quantity = lang('1 match found').'.'; |
---|
2978 | } |
---|
2979 | elseif ($matches > 0) |
---|
2980 | { |
---|
2981 | $quantity = lang('%1 matches found',$matches).'.'; |
---|
2982 | } |
---|
2983 | else |
---|
2984 | { |
---|
2985 | echo '<b>'.lang('Error').':</b>'.lang('no matches found'); |
---|
2986 | return; |
---|
2987 | } |
---|
2988 | |
---|
2989 | $p = $GLOBALS['phpgw']->template; |
---|
2990 | $p->set_file( |
---|
2991 | Array( |
---|
2992 | 'search_form' => 'search.tpl' |
---|
2993 | ) |
---|
2994 | ); |
---|
2995 | $p->set_block('search_form','search','search'); |
---|
2996 | $p->set_block('search_form','search_list_header','search_list_header'); |
---|
2997 | $p->set_block('search_form','search_list','search_list'); |
---|
2998 | $p->set_block('search_form','search_list_footer','search_list_footer'); |
---|
2999 | |
---|
3000 | $var = Array( |
---|
3001 | 'th_bg' => $this->theme['th_bg'], |
---|
3002 | 'search_text' => lang('Search Results'), |
---|
3003 | 'quantity' => $quantity |
---|
3004 | ); |
---|
3005 | $p->set_var($var); |
---|
3006 | |
---|
3007 | if($matches > 0) |
---|
3008 | { |
---|
3009 | $p->parse('rows','search_list_header',True); |
---|
3010 | } |
---|
3011 | foreach($info as $id => $data) |
---|
3012 | { |
---|
3013 | $p->set_var($data); |
---|
3014 | $p->parse('rows','search_list',True); |
---|
3015 | } |
---|
3016 | |
---|
3017 | if($matches > 0) |
---|
3018 | { |
---|
3019 | $p->parse('rows','search_list_footer',True); |
---|
3020 | } |
---|
3021 | |
---|
3022 | $p->pparse('out','search'); |
---|
3023 | } |
---|
3024 | |
---|
3025 | /* Private functions */ |
---|
3026 | function _debug_sqsof() |
---|
3027 | { |
---|
3028 | $data = array( |
---|
3029 | 'filter' => $this->bo->filter, |
---|
3030 | 'cat_id' => $this->bo->cat_id, |
---|
3031 | 'owner' => $this->bo->owner, |
---|
3032 | 'year' => $this->bo->year, |
---|
3033 | 'month' => $this->bo->month, |
---|
3034 | 'day' => $this->bo->day, |
---|
3035 | 'sortby' => $this->bo->sortby, |
---|
3036 | 'num_months' => $this->bo->num_months |
---|
3037 | ); |
---|
3038 | Return _debug_array($data,False); |
---|
3039 | } |
---|
3040 | |
---|
3041 | function output_template_array(&$p,$row,$list,$var) |
---|
3042 | { |
---|
3043 | if (!isset($var['hidden_vars'])) |
---|
3044 | { |
---|
3045 | $var['hidden_vars'] = ''; |
---|
3046 | } |
---|
3047 | if (!isset($var['tr_color'])) |
---|
3048 | { |
---|
3049 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
3050 | } |
---|
3051 | $p->set_var($var); |
---|
3052 | $p->parse($row,$list,True); |
---|
3053 | } |
---|
3054 | |
---|
3055 | function page($_page='',$params='') |
---|
3056 | { |
---|
3057 | if($_page == '') |
---|
3058 | { |
---|
3059 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
3060 | $_page = $page_[0]; |
---|
3061 | |
---|
3062 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
3063 | { |
---|
3064 | $_page = 'planner'; |
---|
3065 | } |
---|
3066 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
3067 | { |
---|
3068 | $_page = 'month'; |
---|
3069 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
3070 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
3071 | } |
---|
3072 | } |
---|
3073 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
3074 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
3075 | { |
---|
3076 | $page_app = 'calendar'; |
---|
3077 | } |
---|
3078 | else |
---|
3079 | { |
---|
3080 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
3081 | } |
---|
3082 | if (is_array($params)) |
---|
3083 | { |
---|
3084 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
3085 | } |
---|
3086 | else |
---|
3087 | { |
---|
3088 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
3089 | } |
---|
3090 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
3091 | } |
---|
3092 | |
---|
3093 | function header() |
---|
3094 | { |
---|
3095 | $cols = 8; |
---|
3096 | if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True) |
---|
3097 | { |
---|
3098 | $cols++; |
---|
3099 | } |
---|
3100 | |
---|
3101 | $tpl = $GLOBALS['phpgw']->template; |
---|
3102 | $tpl->set_unknowns('remove'); |
---|
3103 | |
---|
3104 | if (!file_exists($file = $this->template_dir.'/header.inc.php')) |
---|
3105 | { |
---|
3106 | $file = PHPGW_SERVER_ROOT . '/calendar/templates/default/header.inc.php'; |
---|
3107 | } |
---|
3108 | |
---|
3109 | include($file); |
---|
3110 | $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); |
---|
3111 | if($refer[2] != 'view') { |
---|
3112 | $header = $tpl->fp('out','head'); |
---|
3113 | unset($tpl); |
---|
3114 | echo $header; |
---|
3115 | } |
---|
3116 | unset($tpl); |
---|
3117 | } |
---|
3118 | |
---|
3119 | function footer() |
---|
3120 | { |
---|
3121 | $menuaction = $_GET['menuaction']; |
---|
3122 | list(,,$method) = explode('.',$menuaction); |
---|
3123 | |
---|
3124 | if (@$this->bo->printer_friendly) |
---|
3125 | { |
---|
3126 | return; |
---|
3127 | } |
---|
3128 | |
---|
3129 | $p = $GLOBALS['phpgw']->template; |
---|
3130 | |
---|
3131 | $p->set_file( |
---|
3132 | Array( |
---|
3133 | 'footer' => 'footer.tpl', |
---|
3134 | 'form_button' => 'form_button_script.tpl' |
---|
3135 | ) |
---|
3136 | ); |
---|
3137 | $p->set_block('footer','footer_table','footer_table'); |
---|
3138 | $p->set_block('footer','footer_row','footer_row'); |
---|
3139 | $p->set_block('footer','blank_row','blank_row'); |
---|
3140 | $p->set_block('footer','num_dias','num_dias'); |
---|
3141 | |
---|
3142 | $m = $this->bo->month; |
---|
3143 | $y = $this->bo->year; |
---|
3144 | |
---|
3145 | $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow); |
---|
3146 | $mes_hoje = (int)substr($hoje,4,2); |
---|
3147 | $mes_footer = (int)substr($_POST['date'],4,2); |
---|
3148 | if($_GET['sday']) |
---|
3149 | { |
---|
3150 | if($_GET['month'] == $mes_hoje) |
---|
3151 | { |
---|
3152 | $day = $this->bo->day; |
---|
3153 | } |
---|
3154 | else |
---|
3155 | { |
---|
3156 | $day = $_GET['sday']; |
---|
3157 | } |
---|
3158 | } |
---|
3159 | else |
---|
3160 | { |
---|
3161 | $day = $this->bo->day; |
---|
3162 | $dia_ini = $day; |
---|
3163 | } |
---|
3164 | if($mes_footer == $mes_hoje) |
---|
3165 | { |
---|
3166 | $dia_ini = (int)substr($hoje,6,2); |
---|
3167 | $day = $dia_ini; |
---|
3168 | } |
---|
3169 | /********************************************************************************************/ |
---|
3170 | /* Bloco adicionado para receber o dia a partir do qual a versao para impressao sera gerada */ |
---|
3171 | $str_ini = ''; |
---|
3172 | for ($i = 1; $i <= ($GLOBALS['phpgw']->datetime->days_in_month($m, $y)); $i++) |
---|
3173 | { |
---|
3174 | $str_ini .= '<option value="'.$i.'"'.($i == $day?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3175 | } |
---|
3176 | $str_qtd = '<option value="'.''.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.''.'</option>'."\n"; |
---|
3177 | for ($i = 1; $i <= 45; $i++) |
---|
3178 | { |
---|
3179 | $str_qtd .= '<option value="'.$i.'"'.($i == $_POST['qtd_dias']?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3180 | } |
---|
3181 | $display = ''; |
---|
3182 | $display_view = ''; |
---|
3183 | if ( ($menuaction == 'calendar.uicalendar.week') || ($menuaction == 'calendar.uicalendar.day') ) |
---|
3184 | { |
---|
3185 | $display = 'none'; |
---|
3186 | } |
---|
3187 | else if( ($menuaction == 'calendar.uicalendar.view') ) |
---|
3188 | { |
---|
3189 | $display = 'none'; |
---|
3190 | $display_view = 'none'; |
---|
3191 | } |
---|
3192 | $var = Array( |
---|
3193 | 'acao' => $this->page($method,''), |
---|
3194 | 'formname' => 'SelectDay', |
---|
3195 | 'formonchange' => 'document.SelectDay.submit()', |
---|
3196 | 'day_ini_label' => lang('print starting in'), |
---|
3197 | 'num_dias_label' => lang('quantity of days'), |
---|
3198 | 'tip' => lang('empty prints from the day chosen below to the end of the current month'), |
---|
3199 | 'day_ini_name' => 'day', |
---|
3200 | 'num_dias_name' => 'qtd_dias', |
---|
3201 | 'row_ini' => $str_ini, |
---|
3202 | 'row_qtd' => $str_qtd, |
---|
3203 | 'display' => $display, |
---|
3204 | 'display_view' => $display_view, |
---|
3205 | 'go' => lang('Go!') |
---|
3206 | ); |
---|
3207 | $this->output_template_array($p,'table_row','num_dias',$var); |
---|
3208 | |
---|
3209 | /********************************************************************************************/ |
---|
3210 | |
---|
3211 | $thisdate = date('Ymd',mktime(0,0,0,$m,1,$y)); |
---|
3212 | $y--; |
---|
3213 | |
---|
3214 | $str = ''; |
---|
3215 | for ($i = 0; $i < 20; $i++) |
---|
3216 | { |
---|
3217 | $m++; |
---|
3218 | if ($m > 12) |
---|
3219 | { |
---|
3220 | $m = 1; |
---|
3221 | $y++; |
---|
3222 | } |
---|
3223 | $d = mktime(0,0,0,$m,1,$y); |
---|
3224 | $d_ymd = date('Ymd',$d); |
---|
3225 | $str .= '<option value="'.$d_ymd.'"'.($d_ymd == $thisdate?' selected':'').'>'.lang(date('F', $d)).strftime(' %Y', $d).'</option>'."\n"; |
---|
3226 | } |
---|
3227 | |
---|
3228 | $var = Array( |
---|
3229 | 'action_url' => $this->page($method,''), |
---|
3230 | 'form_name' => 'SelectMonth', |
---|
3231 | 'label' => lang('Month'), |
---|
3232 | 'form_label' => 'date', |
---|
3233 | 'form_onchange' => 'document.SelectMonth.submit()', |
---|
3234 | 'row' => $str, |
---|
3235 | 'dia_ini' => $dia_ini, |
---|
3236 | 'go' => lang('Go!') |
---|
3237 | ); |
---|
3238 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3239 | |
---|
3240 | if($menuaction == 'calendar.uicalendar.week') |
---|
3241 | { |
---|
3242 | unset($thisdate); |
---|
3243 | $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3244 | $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3245 | |
---|
3246 | $str = ''; |
---|
3247 | for ($i = -7; $i <= 7; $i++) |
---|
3248 | { |
---|
3249 | $begin = $sun + (7*24*60*60 * $i) + 12*60*60; // we use midday, that changes in daylight-saveing does not effect us |
---|
3250 | $end = $begin + 6*24*60*60; |
---|
3251 | // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); |
---|
3252 | $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate+12*60*60 && $end >= $thisdate+12*60*60 ? ' selected':'').'>' |
---|
3253 | . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' |
---|
3254 | . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) |
---|
3255 | . '</option>' . "\n"; |
---|
3256 | } |
---|
3257 | |
---|
3258 | $var = Array( |
---|
3259 | 'action_url' => $this->page($method,''), |
---|
3260 | 'form_name' => 'SelectWeek', |
---|
3261 | 'label' => lang('Week'), |
---|
3262 | 'form_label' => 'date', |
---|
3263 | 'form_onchange' => 'document.SelectWeek.submit()', |
---|
3264 | 'row' => $str, |
---|
3265 | 'go' => lang('Go!') |
---|
3266 | ); |
---|
3267 | |
---|
3268 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3269 | } |
---|
3270 | |
---|
3271 | $str = ''; |
---|
3272 | for ($i = ($this->bo->year - 3); $i < ($this->bo->year + 3); $i++) |
---|
3273 | { |
---|
3274 | $str .= '<option value="'.$i.'"'.($i == $this->bo->year?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3275 | } |
---|
3276 | |
---|
3277 | $var = Array( |
---|
3278 | 'action_url' => $this->page($method,''), |
---|
3279 | 'form_name' => 'SelectYear', |
---|
3280 | 'label' => lang('Year'), |
---|
3281 | 'form_label' => 'year', |
---|
3282 | 'form_onchange' => 'document.SelectYear.submit()', |
---|
3283 | 'row' => $str, |
---|
3284 | 'go' => lang('Go!') |
---|
3285 | ); |
---|
3286 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3287 | |
---|
3288 | if($menuaction == 'calendar.uicalendar.planner') |
---|
3289 | { |
---|
3290 | $str = ''; |
---|
3291 | $date_str = ''; |
---|
3292 | |
---|
3293 | if(isset($_GET['date']) && $_GET['date']) |
---|
3294 | { |
---|
3295 | $date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n"; |
---|
3296 | } |
---|
3297 | $date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n"; |
---|
3298 | $date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n"; |
---|
3299 | $date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n"; |
---|
3300 | |
---|
3301 | for($i=1; $i<=6; $i++) |
---|
3302 | { |
---|
3303 | $str .= '<option value="'.$i.'"'.($i == $this->bo->num_months?' selected':'').'>'.$i.'</option>'."\n"; |
---|
3304 | } |
---|
3305 | |
---|
3306 | $var = Array( |
---|
3307 | 'action_url' => $this->page($method,''), |
---|
3308 | 'form_name' => 'SelectNumberOfMonths', |
---|
3309 | 'label' => lang('Number of Months'), |
---|
3310 | 'hidden_vars' => $date_str, |
---|
3311 | 'form_label' => 'num_months', |
---|
3312 | 'form_onchange' => 'document.SelectNumberOfMonths.submit()', |
---|
3313 | 'action_extra_field' => $date_str, |
---|
3314 | 'row' => $str, |
---|
3315 | 'go' => lang('Go!') |
---|
3316 | ); |
---|
3317 | $this->output_template_array($p,'table_row','footer_row',$var); |
---|
3318 | } |
---|
3319 | |
---|
3320 | $var = Array( |
---|
3321 | 'submit_button' => lang('Submit'), |
---|
3322 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), |
---|
3323 | 'action_text_button' => lang('Import'), |
---|
3324 | 'action_confirm_button' => '', |
---|
3325 | 'action_extra_field' => '' |
---|
3326 | ); |
---|
3327 | $this->output_template_array($p,'b_row','form_button',$var); |
---|
3328 | |
---|
3329 | $var = Array( |
---|
3330 | 'submit_button' => lang('Submit'), |
---|
3331 | 'action_url' => $this->page($method,''), |
---|
3332 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.export_all'), |
---|
3333 | 'action_text_button' => lang('Export all'), |
---|
3334 | 'action_confirm_button' => '', |
---|
3335 | 'action_extra_field' => '' |
---|
3336 | ); |
---|
3337 | $this->output_template_array($p,'b_row2','form_button',$var); |
---|
3338 | |
---|
3339 | $p->parse('table_row','blank_row',True); |
---|
3340 | |
---|
3341 | $p->pparse('out','footer_table'); |
---|
3342 | unset($p); |
---|
3343 | } |
---|
3344 | |
---|
3345 | function css() |
---|
3346 | { |
---|
3347 | $GLOBALS['phpgw']->browser->browser(); |
---|
3348 | if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') |
---|
3349 | { |
---|
3350 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8); |
---|
3351 | } |
---|
3352 | else |
---|
3353 | { |
---|
3354 | $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7); |
---|
3355 | } |
---|
3356 | |
---|
3357 | // moved to app.css in templates/default for future separation of code and style [NDEE 10.03.04] |
---|
3358 | /* |
---|
3359 | return 'A.minicalendar { color: #000000; font-size: 72%; font-family: '.$this->theme['font'].' }'."\n" |
---|
3360 | . ' A.bminicalendar { color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3361 | . ' A.minicalendargrey { color: #999999; font-size: 8px; font-family: '.$this->theme['font'].' }'."\n" |
---|
3362 | . ' A.bminicalendargrey { color: #336699; font-style: italic; font-size:8px; font-family '.$this->theme['font'].' }'."\n" |
---|
3363 | . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: x-small '.$this->theme['font'].' }'."\n" |
---|
3364 | . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3365 | . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: x-small '.$this->theme['font'].' }'."\n" |
---|
3366 | . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold x-small '.$this->theme['font'].' }'."\n" |
---|
3367 | . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3368 | . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3369 | . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100% '.$this->theme['font'].'; vertical-align: middle }'."\n" |
---|
3370 | . ' .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" |
---|
3371 | . ' .tablecell { width: 80px; height: 80px }'."\n" |
---|
3372 | . ' .planner-cell { cursor:pointer; cursor:hand; border: thin solid black; }'; |
---|
3373 | */ |
---|
3374 | } |
---|
3375 | |
---|
3376 | function no_edit() |
---|
3377 | { |
---|
3378 | if(!isset($GLOBALS['phpgw_info']['flags']['noheader'])) |
---|
3379 | { |
---|
3380 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
3381 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
3382 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
3383 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
3384 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Permission denied'); |
---|
3385 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
3386 | } |
---|
3387 | echo '<center>You do not have permission to edit this appointment!</center>'; |
---|
3388 | return; |
---|
3389 | } |
---|
3390 | |
---|
3391 | function link_to_entry($event,$month,$day,$year) |
---|
3392 | { |
---|
3393 | $str = ''; |
---|
3394 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3395 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3396 | |
---|
3397 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3398 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3399 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
3400 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3401 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3402 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
3403 | { |
---|
3404 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3405 | } |
---|
3406 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
3407 | { |
---|
3408 | $time = '[ '.lang('All Day').' ]'; |
---|
3409 | } |
---|
3410 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
3411 | { |
---|
3412 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
3413 | { |
---|
3414 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
3415 | } |
---|
3416 | else |
---|
3417 | { |
---|
3418 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3419 | } |
---|
3420 | |
---|
3421 | if($endtime >= ($rawdate_offset + 86400)) |
---|
3422 | { |
---|
3423 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
3424 | } |
---|
3425 | else |
---|
3426 | { |
---|
3427 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
3428 | } |
---|
3429 | $time = $start_time.'-'.$end_time; |
---|
3430 | } |
---|
3431 | else |
---|
3432 | { |
---|
3433 | $time = ''; |
---|
3434 | } |
---|
3435 | |
---|
3436 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
3437 | |
---|
3438 | |
---|
3439 | |
---|
3440 | if(!$is_private) |
---|
3441 | { |
---|
3442 | //$text .= $this->bo->display_status($event['users_status']); |
---|
3443 | |
---|
3444 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
3445 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
3446 | |
---|
3447 | } |
---|
3448 | |
---|
3449 | /* |
---|
3450 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
3451 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
3452 | $GLOBALS['phpgw']->browser->br; |
---|
3453 | */ |
---|
3454 | |
---|
3455 | $texttime=$time; |
---|
3456 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
3457 | |
---|
3458 | $account_name = $_POST['user'] ? |
---|
3459 | $_POST['user'] : |
---|
3460 | ($_GET['account_name'] ? |
---|
3461 | $_GET['account_name'] : ''); |
---|
3462 | |
---|
3463 | $accounts = CreateObject('phpgwapi.accounts'); |
---|
3464 | $accountId = $accounts->name2id($account_name); |
---|
3465 | |
---|
3466 | $prefs = CreateObject('phpgwapi.preferences', $accountId); |
---|
3467 | $account_prefs = $prefs->read(); |
---|
3468 | |
---|
3469 | $titleView = $account_prefs['calendar']['title_view']; |
---|
3470 | if($titleView == "1"){ |
---|
3471 | $textdesc = ''; |
---|
3472 | }else{ |
---|
3473 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
3474 | } |
---|
3475 | |
---|
3476 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
3477 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
3478 | |
---|
3479 | if ($viewable) |
---|
3480 | { |
---|
3481 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
3482 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
3483 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
3484 | $this->link_tpl->set_var('desc', $textdesc); |
---|
3485 | $this->link_tpl->set_var('location', $textlocation); |
---|
3486 | $this->link_tpl->parse('picture','link_open',True); |
---|
3487 | } |
---|
3488 | if (!$is_private) |
---|
3489 | { |
---|
3490 | if($event['priority'] == 3) |
---|
3491 | { |
---|
3492 | $picture[] = Array( |
---|
3493 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
3494 | 'width' => 16, |
---|
3495 | 'height'=> 16, |
---|
3496 | 'title' => lang('high priority') |
---|
3497 | ); |
---|
3498 | } |
---|
3499 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
3500 | { |
---|
3501 | $picture[] = Array( |
---|
3502 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
3503 | 'width' => 9, |
---|
3504 | 'height'=> 9, |
---|
3505 | 'title' => lang('single event') |
---|
3506 | ); |
---|
3507 | } |
---|
3508 | else |
---|
3509 | { |
---|
3510 | $picture[] = Array( |
---|
3511 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
3512 | 'width' => 12, |
---|
3513 | 'height'=> 12, |
---|
3514 | 'title' => lang('recurring event') |
---|
3515 | ); |
---|
3516 | } |
---|
3517 | } |
---|
3518 | $participants = $this->planner_participants($event['participants']); |
---|
3519 | if(count($event['participants']) > 1) |
---|
3520 | { |
---|
3521 | $picture[] = Array( |
---|
3522 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
3523 | 'width' => 14, |
---|
3524 | 'height'=> 14, |
---|
3525 | 'title' => $participants |
---|
3526 | ); |
---|
3527 | } |
---|
3528 | else |
---|
3529 | { |
---|
3530 | $picture[] = Array( |
---|
3531 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
3532 | 'width' => 14, |
---|
3533 | 'height'=> 14, |
---|
3534 | 'title' => $participants |
---|
3535 | ); |
---|
3536 | } |
---|
3537 | if($event['public'] == 0) |
---|
3538 | { |
---|
3539 | $picture[] = Array( |
---|
3540 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
3541 | 'width' => 13, |
---|
3542 | 'height'=> 13, |
---|
3543 | 'title' => lang('private') |
---|
3544 | ); |
---|
3545 | } |
---|
3546 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
3547 | { |
---|
3548 | // if the alarm is to go off the day before the event |
---|
3549 | // the icon does not show up because of 'alarm_today' |
---|
3550 | // - TOM |
---|
3551 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
3552 | { |
---|
3553 | $picture[] = Array( |
---|
3554 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
3555 | 'width' => 13, |
---|
3556 | 'height'=> 13, |
---|
3557 | 'title' => lang('alarm') |
---|
3558 | ); |
---|
3559 | } |
---|
3560 | } |
---|
3561 | |
---|
3562 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
3563 | for($i=0;$i<count($picture);$i++) |
---|
3564 | { |
---|
3565 | $var = Array( |
---|
3566 | 'pic_image' => $picture[$i]['pict'], |
---|
3567 | 'width' => $picture[$i]['width'], |
---|
3568 | 'height' => $picture[$i]['height'], |
---|
3569 | 'title' => $picture[$i]['title'] |
---|
3570 | ); |
---|
3571 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
3572 | } |
---|
3573 | if ($texttitle) |
---|
3574 | { |
---|
3575 | $var = Array( |
---|
3576 | // 'text' => $text, |
---|
3577 | 'time'=> $texttime, |
---|
3578 | 'title'=> $texttitle, |
---|
3579 | 'users_status'=>$textstatus, |
---|
3580 | 'desc'=> $textdesc, |
---|
3581 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
3582 | ); |
---|
3583 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
3584 | } |
---|
3585 | |
---|
3586 | if ($viewable) |
---|
3587 | { |
---|
3588 | $this->link_tpl->parse('picture','link_close',True); |
---|
3589 | } |
---|
3590 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
3591 | $this->link_tpl->set_var('picture',''); |
---|
3592 | $this->link_tpl->set_var('out',''); |
---|
3593 | // unset($p); |
---|
3594 | return $str; |
---|
3595 | } |
---|
3596 | |
---|
3597 | /*****************************************************************************************/ |
---|
3598 | /*Funcao foi duplicada e alterada para tratar os eventos de agendamento (exibicao do mes) para impressao; |
---|
3599 | utiliza o template event_link.tpl*/ |
---|
3600 | |
---|
3601 | function link_to_month_entry($event,$month,$day,$year) |
---|
3602 | { |
---|
3603 | $str = ''; |
---|
3604 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3605 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
3606 | |
---|
3607 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3608 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3609 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
3610 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3611 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3612 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
3613 | { |
---|
3614 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3615 | } |
---|
3616 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
3617 | { |
---|
3618 | $time = '[ '.lang('All Day').' ]'; |
---|
3619 | } |
---|
3620 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
3621 | { |
---|
3622 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
3623 | { |
---|
3624 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
3625 | } |
---|
3626 | else |
---|
3627 | { |
---|
3628 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
3629 | } |
---|
3630 | |
---|
3631 | if($endtime >= ($rawdate_offset + 86400)) |
---|
3632 | { |
---|
3633 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
3634 | } |
---|
3635 | else |
---|
3636 | { |
---|
3637 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
3638 | } |
---|
3639 | $time = $start_time.' - '.$end_time; |
---|
3640 | } |
---|
3641 | else |
---|
3642 | { |
---|
3643 | $time = ''; |
---|
3644 | } |
---|
3645 | |
---|
3646 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
3647 | |
---|
3648 | |
---|
3649 | |
---|
3650 | if(!$is_private) |
---|
3651 | { |
---|
3652 | //$text .= $this->bo->display_status($event['users_status']); |
---|
3653 | |
---|
3654 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
3655 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
3656 | |
---|
3657 | } |
---|
3658 | |
---|
3659 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
3660 | |
---|
3661 | $texttime=$time; |
---|
3662 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
3663 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
3664 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
3665 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
3666 | |
---|
3667 | if ($viewable) |
---|
3668 | { |
---|
3669 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
3670 | $this->event_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
3671 | $this->event_tpl->set_var('lang_view',lang('View this entry')); |
---|
3672 | $this->event_tpl->set_var('desc', $textdesc); |
---|
3673 | $this->event_tpl->set_var('location', $textlocation); |
---|
3674 | $this->event_tpl->parse('picture','link_event_open',True); |
---|
3675 | } |
---|
3676 | if (!$is_private) |
---|
3677 | { |
---|
3678 | if($event['priority'] == 3) |
---|
3679 | { |
---|
3680 | $picture[] = Array( |
---|
3681 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
3682 | 'width' => 16, |
---|
3683 | 'height'=> 16, |
---|
3684 | 'title' => lang('high priority') |
---|
3685 | ); |
---|
3686 | } |
---|
3687 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
3688 | { |
---|
3689 | $picture[] = Array( |
---|
3690 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
3691 | 'width' => 9, |
---|
3692 | 'height'=> 9, |
---|
3693 | 'title' => lang('single event') |
---|
3694 | ); |
---|
3695 | } |
---|
3696 | else |
---|
3697 | { |
---|
3698 | $picture[] = Array( |
---|
3699 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
3700 | 'width' => 12, |
---|
3701 | 'height'=> 12, |
---|
3702 | 'title' => lang('recurring event') |
---|
3703 | ); |
---|
3704 | } |
---|
3705 | } |
---|
3706 | $participants = $this->planner_participants($event['participants']); |
---|
3707 | if(count($event['participants']) > 1) |
---|
3708 | { |
---|
3709 | $picture[] = Array( |
---|
3710 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
3711 | 'width' => 14, |
---|
3712 | 'height'=> 14, |
---|
3713 | 'title' => $participants |
---|
3714 | ); |
---|
3715 | } |
---|
3716 | else |
---|
3717 | { |
---|
3718 | $picture[] = Array( |
---|
3719 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
3720 | 'width' => 14, |
---|
3721 | 'height'=> 14, |
---|
3722 | 'title' => $participants |
---|
3723 | ); |
---|
3724 | } |
---|
3725 | if($event['public'] == 0) |
---|
3726 | { |
---|
3727 | $picture[] = Array( |
---|
3728 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
3729 | 'width' => 13, |
---|
3730 | 'height'=> 13, |
---|
3731 | 'title' => lang('private') |
---|
3732 | ); |
---|
3733 | } |
---|
3734 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
3735 | { |
---|
3736 | // if the alarm is to go off the day before the event |
---|
3737 | // the icon does not show up because of 'alarm_today' |
---|
3738 | // - TOM |
---|
3739 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
3740 | { |
---|
3741 | $picture[] = Array( |
---|
3742 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
3743 | 'width' => 13, |
---|
3744 | 'height'=> 13, |
---|
3745 | 'title' => lang('alarm') |
---|
3746 | ); |
---|
3747 | } |
---|
3748 | } |
---|
3749 | |
---|
3750 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
3751 | for($i=0;$i<count($picture);$i++) |
---|
3752 | { |
---|
3753 | $var = Array( |
---|
3754 | 'pic_image' => $picture[$i]['pict'], |
---|
3755 | 'width' => $picture[$i]['width'], |
---|
3756 | 'height' => $picture[$i]['height'], |
---|
3757 | 'title' => $picture[$i]['title'] |
---|
3758 | ); |
---|
3759 | $this->output_template_array($this->event_tpl,'picture','event_pict',$var); |
---|
3760 | } |
---|
3761 | if ($texttitle) |
---|
3762 | { |
---|
3763 | $var = Array( |
---|
3764 | // 'text' => $text, |
---|
3765 | 'time'=> $texttime, |
---|
3766 | 'title'=> $texttitle, |
---|
3767 | 'users_status'=>$textstatus, |
---|
3768 | 'desc'=> $textdesc, |
---|
3769 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
3770 | ); |
---|
3771 | $this->output_template_array($this->event_tpl,'picture','link_event_text',$var); |
---|
3772 | } |
---|
3773 | |
---|
3774 | if ($viewable) |
---|
3775 | { |
---|
3776 | $this->event_tpl->parse('picture','link_event_close',True); |
---|
3777 | } |
---|
3778 | $str = $this->event_tpl->fp('out','link_event_pict'); |
---|
3779 | $this->event_tpl->set_var('picture',''); |
---|
3780 | $this->event_tpl->set_var('out',''); |
---|
3781 | // unset($p); |
---|
3782 | return $str; |
---|
3783 | } |
---|
3784 | |
---|
3785 | /*****************************************************************************************/ |
---|
3786 | function normDec($num) |
---|
3787 | { |
---|
3788 | if ($num > 9) |
---|
3789 | return $num; |
---|
3790 | else |
---|
3791 | return "0".$num; |
---|
3792 | } |
---|
3793 | function overlap($params) |
---|
3794 | { |
---|
3795 | if(!is_array($params)) |
---|
3796 | { |
---|
3797 | } |
---|
3798 | else |
---|
3799 | { |
---|
3800 | $overlapping_events = $params['o_events']; |
---|
3801 | $event = $params['this_event']; |
---|
3802 | } |
---|
3803 | |
---|
3804 | $month = $event['start']['month']; |
---|
3805 | $mday = $event['start']['mday']; |
---|
3806 | $year = $event['start']['year']; |
---|
3807 | |
---|
3808 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3809 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3810 | |
---|
3811 | $overlap = ''; |
---|
3812 | for($i=0;$i<count($overlapping_events);$i++) |
---|
3813 | { |
---|
3814 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
3815 | foreach($overlapped_event['participants'] as $id => $status) |
---|
3816 | { |
---|
3817 | $conflict = isset($event['participants'][$id]); |
---|
3818 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
3819 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
3820 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>"; |
---|
3821 | } |
---|
3822 | if ($this->bo->prefs['calendar']['hide_event_conflict']) |
---|
3823 | $overlap .= '<ul><font size="1"><span>'. |
---|
3824 | $this->normDec($overlapped_event['start']['hour']).":". |
---|
3825 | $this->normDec($overlapped_event['start']['min'])."-". |
---|
3826 | $this->normDec($overlapped_event['end']['hour']).":". |
---|
3827 | $this->normDec($overlapped_event['end']['min']). |
---|
3828 | '<br><b>'.lang('title').": ".lang("Hidden"). |
---|
3829 | '</b><br>'.lang('description').": ".lang("Hidden").'<br></span></ul><br>'; |
---|
3830 | else |
---|
3831 | $overlap .= '<ul>'.$this->link_to_entry($overlapped_event,$month,$mday,$year)."</ul><br>"; |
---|
3832 | } |
---|
3833 | |
---|
3834 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
3835 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
3836 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
3837 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
3838 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
3839 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
3840 | |
---|
3841 | $p = $GLOBALS['phpgw']->template; |
---|
3842 | $p->set_file( |
---|
3843 | Array( |
---|
3844 | 'overlap' => 'overlap.tpl', |
---|
3845 | 'form_button' => 'form_button_script.tpl' |
---|
3846 | ) |
---|
3847 | ); |
---|
3848 | |
---|
3849 | $var = Array( |
---|
3850 | 'color' => $this->theme['bg_text'], |
---|
3851 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
3852 | '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)), |
---|
3853 | 'overlap_list' => $overlap |
---|
3854 | ); |
---|
3855 | $p->set_var($var); |
---|
3856 | |
---|
3857 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
3858 | $var = Array( |
---|
3859 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), |
---|
3860 | 'action_text_button' => lang('Ignore Conflict'), |
---|
3861 | 'action_confirm_button' => '', |
---|
3862 | 'action_extra_field' => '', |
---|
3863 | 'button_id' => 'ignore_button' |
---|
3864 | ); |
---|
3865 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
3866 | |
---|
3867 | $var = Array( |
---|
3868 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), |
---|
3869 | 'action_text_button' => lang('Re-Edit Event'), |
---|
3870 | 'action_confirm_button' => '', |
---|
3871 | 'action_extra_field' => '', |
---|
3872 | 'button_id' => 'redit_button' |
---|
3873 | ); |
---|
3874 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
3875 | $p->pparse('out','overlap'); |
---|
3876 | } |
---|
3877 | |
---|
3878 | function planner_participants($parts) |
---|
3879 | { |
---|
3880 | static $id2lid; |
---|
3881 | |
---|
3882 | $names = ''; |
---|
3883 | while (list($id,$status) = each($parts)) |
---|
3884 | { |
---|
3885 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
3886 | |
---|
3887 | if (!isset($id2lid[$id])) |
---|
3888 | { |
---|
3889 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
3890 | } |
---|
3891 | if (strlen($names)) |
---|
3892 | { |
---|
3893 | $names .= ",\n"; |
---|
3894 | } |
---|
3895 | $names .= $id2lid[$id]." ($status)"; |
---|
3896 | } |
---|
3897 | if($this->debug) |
---|
3898 | { |
---|
3899 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
3900 | } |
---|
3901 | return $names; |
---|
3902 | } |
---|
3903 | |
---|
3904 | function planner_category($ids) |
---|
3905 | { |
---|
3906 | static $cats; |
---|
3907 | if(!is_array($ids)) |
---|
3908 | { |
---|
3909 | if (strpos($ids,',')) |
---|
3910 | { |
---|
3911 | $id_array = explode(',',$ids); |
---|
3912 | } |
---|
3913 | else |
---|
3914 | { |
---|
3915 | $id_array[0] = $ids; |
---|
3916 | } |
---|
3917 | } |
---|
3918 | @reset($id_array); |
---|
3919 | $ret_val = Array(); |
---|
3920 | while(list($index,$id) = each($id_array)) |
---|
3921 | { |
---|
3922 | if (!isset($cats[$id])) |
---|
3923 | { |
---|
3924 | $cat_arr = $this->cat->return_single( $id ); |
---|
3925 | $cats[$id] = $cat_arr[0]; |
---|
3926 | $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); |
---|
3927 | } |
---|
3928 | $ret_val[] = $cats[$id]; |
---|
3929 | } |
---|
3930 | return $ret_val; |
---|
3931 | } |
---|
3932 | |
---|
3933 | function week_header($month,$year,$display_name = False) |
---|
3934 | { |
---|
3935 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
3936 | |
---|
3937 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
3938 | $p->set_unknowns('remove'); |
---|
3939 | $p->set_file( |
---|
3940 | Array ( |
---|
3941 | 'month_header' => 'month_header.tpl' |
---|
3942 | ) |
---|
3943 | ); |
---|
3944 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
3945 | $p->set_block('month_header','column_title','column_title'); |
---|
3946 | |
---|
3947 | $var = Array( |
---|
3948 | 'bgcolor' => $this->theme['th_bg'], |
---|
3949 | 'font_color' => $this->theme['th_text'] |
---|
3950 | ); |
---|
3951 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
3952 | { |
---|
3953 | $var = Array( |
---|
3954 | 'bgcolor' => '', |
---|
3955 | 'font_color' => '' |
---|
3956 | ); |
---|
3957 | } |
---|
3958 | $p->set_var($var); |
---|
3959 | |
---|
3960 | $p->set_var('col_width','14'); |
---|
3961 | if($display_name == True) |
---|
3962 | { |
---|
3963 | $p->set_var('col_title',lang('name')); |
---|
3964 | $p->parse('column_header','column_title',True); |
---|
3965 | $p->set_var('col_width','12'); |
---|
3966 | } |
---|
3967 | |
---|
3968 | for($i=0;$i<7;$i++) |
---|
3969 | { |
---|
3970 | $p->set_var('col_title',lang($GLOBALS['phpgw']->datetime->days[$i])); |
---|
3971 | $p->parse('column_header','column_title',True); |
---|
3972 | } |
---|
3973 | return $p->fp('out','monthly_header'); |
---|
3974 | } |
---|
3975 | |
---|
3976 | function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
3977 | { |
---|
3978 | if($owner == 0) |
---|
3979 | { |
---|
3980 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
3981 | } |
---|
3982 | |
---|
3983 | $temp_owner = $this->bo->owner; |
---|
3984 | |
---|
3985 | $str = ''; |
---|
3986 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
3987 | $p->set_unknowns('keep'); |
---|
3988 | |
---|
3989 | $p->set_file( |
---|
3990 | Array( |
---|
3991 | 'month_header' => 'month_header.tpl', |
---|
3992 | 'month_day' => 'month_day.tpl' |
---|
3993 | ) |
---|
3994 | ); |
---|
3995 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
3996 | $p->set_block('month_header','month_column','month_column'); |
---|
3997 | $p->set_block('month_day','month_daily','month_daily'); |
---|
3998 | $p->set_block('month_day','day_event','day_event'); |
---|
3999 | $p->set_block('month_day','event','event'); |
---|
4000 | |
---|
4001 | $p->set_var('extra',''); |
---|
4002 | $p->set_var('col_width','14'); |
---|
4003 | if($display_name) |
---|
4004 | { |
---|
4005 | $p->set_var('column_data',$GLOBALS['phpgw']->common->grab_owner_name($owner)); |
---|
4006 | $p->parse('column_header','month_column',True); |
---|
4007 | $p->set_var('col_width','12'); |
---|
4008 | } |
---|
4009 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
4010 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
4011 | foreach($daily as $date => $day_params) |
---|
4012 | { |
---|
4013 | $year = (int)substr($date,0,4); |
---|
4014 | $month = (int)substr($date,4,2); |
---|
4015 | $day = (int)substr($date,6,2); |
---|
4016 | $var = Array( |
---|
4017 | 'column_data' => '', |
---|
4018 | 'extra' => '' |
---|
4019 | ); |
---|
4020 | $p->set_var($var); |
---|
4021 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
4022 | { |
---|
4023 | if ($day_params['new_event']) |
---|
4024 | { |
---|
4025 | $new_event_link = ' <a href="'.$this->page('add','&date='.$date).'">' |
---|
4026 | . '<img src="'.$GLOBALS['phpgw']->common->image('calendar','new3').'" width="10" height="10" title="'.lang('New Entry').'" border="0" align="center">' |
---|
4027 | . '</a>'; |
---|
4028 | $day_number = '<a href="'.$this->page('day','&date='.$date).'">'.$day.'</a>'; |
---|
4029 | } |
---|
4030 | else |
---|
4031 | { |
---|
4032 | $new_event_link = ''; |
---|
4033 | $day_number = $day; |
---|
4034 | } |
---|
4035 | |
---|
4036 | $var = Array( |
---|
4037 | 'extra' => $day_params['extra'], |
---|
4038 | 'new_event_link'=> $new_event_link, |
---|
4039 | 'day_number' => $day_number |
---|
4040 | ); |
---|
4041 | if($day_params['week']) |
---|
4042 | { |
---|
4043 | |
---|
4044 | //NDEE: style! m_w_table in month_day.tpl |
---|
4045 | // week-hilite |
---|
4046 | //$var['new_event_link'] .= '<font size="-2"> '. |
---|
4047 | $var['new_event_link'] .= ' '. |
---|
4048 | (!$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>'); |
---|
4049 | } |
---|
4050 | |
---|
4051 | $p->set_var($var); |
---|
4052 | |
---|
4053 | if(@$day_params['holidays']) |
---|
4054 | { |
---|
4055 | foreach($day_params['holidays'] as $key => $value) |
---|
4056 | { |
---|
4057 | $var = Array( |
---|
4058 | 'day_events' => '<font face="'.$this->theme['font'].'" size="-1">'.$value.'</font>'.$GLOBALS['phpgw']->browser->br |
---|
4059 | ); |
---|
4060 | $this->output_template_array($p,'daily_events','event',$var); |
---|
4061 | } |
---|
4062 | } |
---|
4063 | |
---|
4064 | if($day_params['appts']) |
---|
4065 | { |
---|
4066 | $var = Array( |
---|
4067 | 'week_day_font_size' => '2', |
---|
4068 | 'events' => '' |
---|
4069 | ); |
---|
4070 | $p->set_var($var); |
---|
4071 | $events = $this->bo->cached_events[$date]; |
---|
4072 | foreach($events as $event) |
---|
4073 | { |
---|
4074 | if ($this->bo->rejected_no_show($event)) |
---|
4075 | { |
---|
4076 | continue; // user does not want to see rejected events |
---|
4077 | } |
---|
4078 | $p->set_var('day_events',$this->link_to_entry($event,$month,$day,$year)); |
---|
4079 | $p->parse('events','event',True); |
---|
4080 | $p->set_var('day_events',''); |
---|
4081 | } |
---|
4082 | } |
---|
4083 | $p->parse('daily_events','day_event',True); |
---|
4084 | $p->parse('column_data','month_daily',True); |
---|
4085 | $p->set_var('daily_events',''); |
---|
4086 | $p->set_var('events',''); |
---|
4087 | /* if($day_params['week']) |
---|
4088 | { |
---|
4089 | $var = Array( |
---|
4090 | 'week_day_font_size' => '-2', |
---|
4091 | 'events' => (!$this->bo->printer_friendly?'<a href="'.$this->page('week','&date='.$date).'">' .$day_params['week'].'</a>':$day_params['week']) |
---|
4092 | ); |
---|
4093 | $this->output_template_array($p,'column_data','day_event',$var); |
---|
4094 | $p->set_var('events',''); |
---|
4095 | } */ |
---|
4096 | } |
---|
4097 | $p->parse('column_header','month_column',True); |
---|
4098 | $p->set_var('column_data',''); |
---|
4099 | } |
---|
4100 | $this->bo->owner = $temp_owner; |
---|
4101 | return $p->fp('out','monthly_header'); |
---|
4102 | } |
---|
4103 | |
---|
4104 | /***************************************************************************************/ |
---|
4105 | /*As funcoes abaixo |
---|
4106 | month_week_header() |
---|
4107 | month_display_week() |
---|
4108 | display_month_print() |
---|
4109 | month_day_of_week() - esta foi criada mas parte do codigo e de outra funcao da API (day_of_week()); |
---|
4110 | |
---|
4111 | foram duplicadas e modificadas para atender aas modificacoes do layout de impressao mensal da agenda de eventos; |
---|
4112 | TODO: otimizar o codigo |
---|
4113 | |
---|
4114 | Rommel Cysne |
---|
4115 | */ |
---|
4116 | |
---|
4117 | function month_week_header($month,$year,$display_name = False) |
---|
4118 | { |
---|
4119 | $this->weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($year,$month,1); |
---|
4120 | $p->set_unknowns('remove'); |
---|
4121 | } |
---|
4122 | |
---|
4123 | |
---|
4124 | function month_day_of_week($year,$month,$day) |
---|
4125 | { |
---|
4126 | $dia = Array( |
---|
4127 | 0 => 'Domingo', |
---|
4128 | 1 => 'Segunda', |
---|
4129 | 2 => 'Terça', |
---|
4130 | 3 => 'Quarta', |
---|
4131 | 4 => 'Quinta', |
---|
4132 | 5 => 'Sexta', |
---|
4133 | 6 => 'Sábado' |
---|
4134 | ); |
---|
4135 | |
---|
4136 | if($month > 2) |
---|
4137 | { |
---|
4138 | $month -= 2; |
---|
4139 | } |
---|
4140 | else |
---|
4141 | { |
---|
4142 | $month += 10; |
---|
4143 | $year--; |
---|
4144 | } |
---|
4145 | $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); |
---|
4146 | |
---|
4147 | $month_day = ($day - 7 * floor($day / 7)); //retorna o numero do dia da semana (Ex: domingo eh dia 0, terca eh 2); |
---|
4148 | $weekday = $dia[$month_day]; //retorna o nome do dia da semana de acordo com seu numero; |
---|
4149 | |
---|
4150 | return ($weekday); |
---|
4151 | |
---|
4152 | } |
---|
4153 | |
---|
4154 | function month_display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) |
---|
4155 | { |
---|
4156 | if($owner == 0) |
---|
4157 | { |
---|
4158 | $owner = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
4159 | } |
---|
4160 | |
---|
4161 | $temp_owner = $this->bo->owner; |
---|
4162 | |
---|
4163 | $str = ''; |
---|
4164 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4165 | $p->set_unknowns('keep'); |
---|
4166 | |
---|
4167 | $p->set_file( |
---|
4168 | Array( |
---|
4169 | 'month_header' => 'month_header_print.tpl', |
---|
4170 | 'month_day' => 'month_day_print.tpl' |
---|
4171 | ) |
---|
4172 | ); |
---|
4173 | $p->set_block('month_header','monthly_header','monthly_header'); |
---|
4174 | $p->set_block('month_header','month_column','month_column'); |
---|
4175 | $p->set_block('month_day','month_daily','month_daily'); |
---|
4176 | $p->set_block('month_day','day_event','day_event'); |
---|
4177 | $p->set_block('month_day','event','event'); |
---|
4178 | |
---|
4179 | $p->set_var('extra',''); |
---|
4180 | $p->set_var('col_width','14'); |
---|
4181 | |
---|
4182 | $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); |
---|
4183 | $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); |
---|
4184 | |
---|
4185 | foreach($daily as $date => $day_params) |
---|
4186 | { |
---|
4187 | $year = (int)substr($date,0,4); |
---|
4188 | $month = (int)substr($date,4,2); |
---|
4189 | $day = (int)substr($date,6,2); |
---|
4190 | $var = Array( |
---|
4191 | 'column_data' => '', |
---|
4192 | 'extra' => '' |
---|
4193 | ); |
---|
4194 | $p->set_var($var); |
---|
4195 | if ($weekly || ($date >= $monthstart && $date <= $monthend)) |
---|
4196 | { |
---|
4197 | $new_event_link = ''; |
---|
4198 | $day_num = $day; |
---|
4199 | $dia_semana = $this->month_day_of_week($year,$month,$day_num); |
---|
4200 | $id_aux = mktime(0,0,0,$month,$day,$year); |
---|
4201 | $month_identifier = substr(lang(strftime("%B",$id_aux)),0,3); |
---|
4202 | $day_number = $month_identifier . " - " . $dia_semana . ", " . $day_num; |
---|
4203 | |
---|
4204 | $var = Array( |
---|
4205 | 'extra' => $day_params['extra'], |
---|
4206 | 'new_event_link'=> $new_event_link, |
---|
4207 | 'day_number' => $day_number |
---|
4208 | ); |
---|
4209 | |
---|
4210 | $p->set_var($var); |
---|
4211 | |
---|
4212 | if($day_params['appts']) |
---|
4213 | { |
---|
4214 | $var = Array( |
---|
4215 | 'week_day_font_size' => '2', |
---|
4216 | 'events' => '' |
---|
4217 | ); |
---|
4218 | $p->set_var($var); |
---|
4219 | $events = $this->bo->cached_events[$date]; |
---|
4220 | foreach($events as $event) |
---|
4221 | { |
---|
4222 | if ($this->bo->rejected_no_show($event)) |
---|
4223 | { |
---|
4224 | continue; // user does not want to see rejected events |
---|
4225 | } |
---|
4226 | $p->set_var('day_events',$this->link_to_month_entry($event,$month,$day,$year)); |
---|
4227 | $p->parse('events','event',True); |
---|
4228 | $p->set_var('day_events',''); |
---|
4229 | } |
---|
4230 | } |
---|
4231 | $p->parse('daily_events','day_event',True); |
---|
4232 | $p->parse('column_data','month_daily',True); |
---|
4233 | $p->set_var('daily_events',''); |
---|
4234 | $p->set_var('events',''); |
---|
4235 | } |
---|
4236 | $p->parse('column_header','month_column',True); |
---|
4237 | $p->set_var('column_data',''); |
---|
4238 | } |
---|
4239 | $this->bo->owner = $temp_owner; |
---|
4240 | return $p->fp('out','monthly_header'); |
---|
4241 | |
---|
4242 | } |
---|
4243 | |
---|
4244 | function display_month_print($month,$year,$showyear,$owner=0) |
---|
4245 | { |
---|
4246 | if($this->debug) |
---|
4247 | { |
---|
4248 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
4249 | } |
---|
4250 | |
---|
4251 | /* $this->bo->store_to_cache( |
---|
4252 | Array( |
---|
4253 | 'syear' => $year, |
---|
4254 | 'smonth'=> $month, |
---|
4255 | 'sday' => 1 |
---|
4256 | ) |
---|
4257 | ); |
---|
4258 | */ |
---|
4259 | $day_ini = $_GET['day_ini'];// dia do inicio da impressao; o padrao e o dia atual; |
---|
4260 | $num_dias = $_GET['num_dias'];// quantidade de dias a partir do dia inicial; |
---|
4261 | |
---|
4262 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
4263 | // $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4264 | |
---|
4265 | if($num_dias != 0) |
---|
4266 | { |
---|
4267 | //se a qtde de dias for informada, a data final para impressao considera a soma $day_ini+$num_dias; |
---|
4268 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month,$day_ini+$num_dias,$year))); |
---|
4269 | } |
---|
4270 | else |
---|
4271 | { |
---|
4272 | //se a qtde de dias nao for informada, a data final para impressao vai ate o fim do mes corrente; |
---|
4273 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4274 | } |
---|
4275 | |
---|
4276 | if($day_ini != 0) |
---|
4277 | { |
---|
4278 | //o dia de inicio para impressao passa a ser o informado em $day_ini do mes corrente; |
---|
4279 | $start = mktime(0,0,0,$month,$day_ini,$year); |
---|
4280 | } |
---|
4281 | else |
---|
4282 | { |
---|
4283 | //se nao for informado o dia para inicio da impressao, esta comeca no dia 1 do mes corrente; |
---|
4284 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
4285 | } |
---|
4286 | //$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 15); |
---|
4287 | $start_d = (int)(date('Ymd',$start));//variavel auxiliar que recebe a data inicial de impressao no formato 'Ymd'; |
---|
4288 | $saux = (int)(substr($start_d,4,2));//variavel auxiliar que recebe o mes do inicio da impressao; |
---|
4289 | $eaux = (int)(substr($monthend,4,2)) + 1;//variavel auxiliar que recebe o mes do fim da impressao; |
---|
4290 | //A funcao store_to_cache devolve todos os eventos existentes de determinado usuario em um periodo de tempo |
---|
4291 | //especifico. Originalmente, na impressao mensal, esse periodo de tempo era o mes corrente exibido na tela. |
---|
4292 | //A mudanca consiste no fato de que uma nova variavel ($saux) e enviada com o mes de inicio do periodo |
---|
4293 | //atraves do indice 'smonth' e uma segunda variavel ($eaux) envia o mes final do periodo de tempo atraves |
---|
4294 | //do indice 'emonth'. Vide mais comentarios sobre esses valores em class.bocalendar.inc.php, |
---|
4295 | //function store_to_cache($params); |
---|
4296 | $this->bo->store_to_cache( |
---|
4297 | Array( |
---|
4298 | 'syear' => $year,//ano atual |
---|
4299 | 'smonth'=> $saux,//mes inicial |
---|
4300 | 'emonth'=> $eaux,//mes final |
---|
4301 | 'sday' => 1 |
---|
4302 | )); |
---|
4303 | |
---|
4304 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4305 | $p->set_unknowns('keep'); |
---|
4306 | |
---|
4307 | $p->set_file( |
---|
4308 | Array( |
---|
4309 | 'week' => 'month_day_print.tpl' |
---|
4310 | ) |
---|
4311 | ); |
---|
4312 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4313 | $p->set_block('week','event','event'); |
---|
4314 | |
---|
4315 | $var = Array( |
---|
4316 | 'cols' => 1, |
---|
4317 | 'day_events'=> '' //$this->month_week_header($month,$year,False) |
---|
4318 | ); |
---|
4319 | // $this->output_template_array($p,'row','event',$var); |
---|
4320 | |
---|
4321 | $cellcolor = $this->theme['row_on']; |
---|
4322 | |
---|
4323 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
4324 | { |
---|
4325 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
4326 | $var = Array( |
---|
4327 | 'day_events' => $this->month_display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
4328 | ); |
---|
4329 | $this->output_template_array($p,'row','event',$var); |
---|
4330 | } |
---|
4331 | return $p->fp('out','m_w_table'); |
---|
4332 | } |
---|
4333 | |
---|
4334 | |
---|
4335 | /***************************************************************************************/ |
---|
4336 | |
---|
4337 | function display_month($month,$year,$showyear,$owner=0) |
---|
4338 | { |
---|
4339 | if($this->debug) |
---|
4340 | { |
---|
4341 | echo '<!-- datetime:gmtdate = '.$GLOBALS['phpgw']->datetime->cv_gmtdate.' -->'."\n"; |
---|
4342 | } |
---|
4343 | |
---|
4344 | $this->bo->store_to_cache( |
---|
4345 | Array( |
---|
4346 | 'syear' => $year, |
---|
4347 | 'smonth'=> $month, |
---|
4348 | 'sday' => 1 |
---|
4349 | ) |
---|
4350 | ); |
---|
4351 | |
---|
4352 | $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year))); |
---|
4353 | $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); |
---|
4354 | |
---|
4355 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); |
---|
4356 | |
---|
4357 | if($this->debug) |
---|
4358 | { |
---|
4359 | echo '<!-- display_month:monthstart = '.$monthstart.' -->'."\n"; |
---|
4360 | echo '<!-- display_month:start = '.date('Ymd H:i:s',$start).' -->'."\n"; |
---|
4361 | } |
---|
4362 | |
---|
4363 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4364 | $p->set_unknowns('keep'); |
---|
4365 | |
---|
4366 | $p->set_file( |
---|
4367 | Array( |
---|
4368 | 'week' => 'month_day.tpl' |
---|
4369 | ) |
---|
4370 | ); |
---|
4371 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4372 | $p->set_block('week','event','event'); |
---|
4373 | |
---|
4374 | $var = Array( |
---|
4375 | 'cols' => 1, |
---|
4376 | 'day_events'=> $this->week_header($month,$year,False) |
---|
4377 | ); |
---|
4378 | $this->output_template_array($p,'row','event',$var); |
---|
4379 | |
---|
4380 | $cellcolor = $this->theme['row_on']; |
---|
4381 | |
---|
4382 | for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800) |
---|
4383 | { |
---|
4384 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
4385 | $var = Array( |
---|
4386 | 'day_events' => $this->display_week($i,False,$cellcolor,False,$owner,$monthstart,$monthend) |
---|
4387 | ); |
---|
4388 | $this->output_template_array($p,'row','event',$var); |
---|
4389 | } |
---|
4390 | return $p->fp('out','m_w_table'); |
---|
4391 | } |
---|
4392 | |
---|
4393 | function display_weekly($params) |
---|
4394 | { |
---|
4395 | if(!is_array($params)) |
---|
4396 | { |
---|
4397 | $this->index(); |
---|
4398 | } |
---|
4399 | |
---|
4400 | $year = substr($params['date'],0,4); |
---|
4401 | $month = substr($params['date'],4,2); |
---|
4402 | $day = substr($params['date'],6,2); |
---|
4403 | $showyear = $params['showyear']; |
---|
4404 | $owners = $params['owners']; |
---|
4405 | |
---|
4406 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4407 | $p->set_unknowns('keep'); |
---|
4408 | |
---|
4409 | $p->set_file( |
---|
4410 | Array( |
---|
4411 | 'week' => 'month_day.tpl' |
---|
4412 | ) |
---|
4413 | ); |
---|
4414 | $p->set_block('week','m_w_table','m_w_table'); |
---|
4415 | $p->set_block('week','event','event'); |
---|
4416 | |
---|
4417 | $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
4418 | |
---|
4419 | $cellcolor = $this->theme['row_off']; |
---|
4420 | |
---|
4421 | $true_printer_friendly = $this->bo->printer_friendly; |
---|
4422 | |
---|
4423 | if(is_array($owners)) |
---|
4424 | { |
---|
4425 | $display_name = True; |
---|
4426 | $counter = count($owners); |
---|
4427 | $owners_array = $owners; |
---|
4428 | $cols = 8; |
---|
4429 | } |
---|
4430 | else |
---|
4431 | { |
---|
4432 | $display_name = False; |
---|
4433 | $counter = 1; |
---|
4434 | $owners_array[0] = $owners; |
---|
4435 | $cols = 7; |
---|
4436 | } |
---|
4437 | $var = Array( |
---|
4438 | 'cols' => $cols, |
---|
4439 | 'day_events' => $this->week_header($month,$year,$display_name) |
---|
4440 | ); |
---|
4441 | $this->output_template_array($p,'row','event',$var); |
---|
4442 | |
---|
4443 | $tstart = $start - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
4444 | $tstop = $tstart + 604800; |
---|
4445 | $original_owner = $this->bo->so->owner; |
---|
4446 | for($i=0;$i<$counter;$i++) |
---|
4447 | { |
---|
4448 | $this->bo->so->owner = $owners_array[$i]; |
---|
4449 | $this->bo->so->open_box($owners_array[$i]); |
---|
4450 | $this->bo->store_to_cache( |
---|
4451 | Array( |
---|
4452 | 'syear' => date('Y',$tstart), |
---|
4453 | 'smonth' => date('m',$tstart), |
---|
4454 | 'sday' => date('d',$tstart), |
---|
4455 | 'eyear' => date('Y',$tstop), |
---|
4456 | 'emonth' => date('m',$tstop), |
---|
4457 | 'eday' => date('d',$tstop) |
---|
4458 | ) |
---|
4459 | ); |
---|
4460 | $p->set_var('day_events',$this->display_week($start,True,$cellcolor,$display_name,$owners_array[$i])); |
---|
4461 | $p->parse('row','event',True); |
---|
4462 | } |
---|
4463 | $this->bo->so->owner = $original_owner; |
---|
4464 | $this->bo->printer_friendly = $true_printer_friendly; |
---|
4465 | return $p->fp('out','m_w_table'); |
---|
4466 | } |
---|
4467 | |
---|
4468 | function view_event($event,$alarms=False) |
---|
4469 | { |
---|
4470 | if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) |
---|
4471 | { |
---|
4472 | return False; |
---|
4473 | } |
---|
4474 | |
---|
4475 | $p = &$GLOBALS['phpgw']->template; |
---|
4476 | |
---|
4477 | $p->set_file( |
---|
4478 | Array( |
---|
4479 | 'view' => 'view.tpl' |
---|
4480 | ) |
---|
4481 | ); |
---|
4482 | $p->set_block('view','view_event','view_event'); |
---|
4483 | $p->set_block('view','list','list'); |
---|
4484 | $p->set_block('view','hr','hr'); |
---|
4485 | |
---|
4486 | $vars = $this->bo->event2array($event); |
---|
4487 | |
---|
4488 | $vars['title']['tr_color'] = $this->theme['th_bg']; |
---|
4489 | |
---|
4490 | foreach($vars['participants']['data'] as $user => $str) |
---|
4491 | { |
---|
4492 | if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*) \((.*)\)$',$str,$parts)) |
---|
4493 | { |
---|
4494 | $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; |
---|
4495 | $vars['participants']['data'][$user].=' (<a href=\'index.php?menuaction=calendar.uicalendar.screen_delegate_event&id_event='.$event['id'].'&delegator='.$user.'&date='.$_REQUEST["date"].'&eventArray='.$event.'\'>'.lang("Delegate event").'</a>)'; |
---|
4496 | //system('echo "event: '.$event['start'].'" >>/tmp/controle'); |
---|
4497 | } |
---|
4498 | } |
---|
4499 | $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); |
---|
4500 | foreach($vars as $var) |
---|
4501 | { |
---|
4502 | if (strlen($var['data'])) |
---|
4503 | { |
---|
4504 | $this->output_template_array($p,'row','list',$var); |
---|
4505 | } |
---|
4506 | } |
---|
4507 | |
---|
4508 | if($alarms && count($event['alarm'])) |
---|
4509 | { |
---|
4510 | $p->set_var('th_bg',$this->theme['th_bg']); |
---|
4511 | $p->set_var('hr_text',lang('Alarms')); |
---|
4512 | $p->parse('row','hr',True); |
---|
4513 | foreach($event['alarm'] as $key => $alarm) |
---|
4514 | { |
---|
4515 | 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 |
---|
4516 | { |
---|
4517 | $icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled':'disabled')).'" width="13" height="13">'; |
---|
4518 | $var = Array( |
---|
4519 | 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), |
---|
4520 | 'data' => lang('Email Notification for %1',$GLOBALS['phpgw']->common->grab_owner_name($alarm['owner'])) |
---|
4521 | ); |
---|
4522 | $this->output_template_array($p,'row','list',$var); |
---|
4523 | } |
---|
4524 | } |
---|
4525 | } |
---|
4526 | return True; |
---|
4527 | } |
---|
4528 | |
---|
4529 | function nm_on_off() |
---|
4530 | { |
---|
4531 | if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) |
---|
4532 | { |
---|
4533 | return '_on'; |
---|
4534 | } |
---|
4535 | return '_off'; |
---|
4536 | } |
---|
4537 | |
---|
4538 | function slot_num($time,$set_day_start=0,$set_day_end=0) |
---|
4539 | { |
---|
4540 | static $day_start, $day_end, $interval=0; |
---|
4541 | |
---|
4542 | if ($set_day_start) $day_start = $set_day_start; |
---|
4543 | if ($set_day_end) $day_end = $set_day_end; |
---|
4544 | if (!$interval) $interval = 60*$this->bo->prefs['calendar']['interval']; |
---|
4545 | |
---|
4546 | if ($time > $day_end) |
---|
4547 | { |
---|
4548 | $time = $day_end; |
---|
4549 | } |
---|
4550 | $slot = (int)(($time - $day_start) / $interval); |
---|
4551 | |
---|
4552 | return $slot < 0 ? 0 : 1+$slot; |
---|
4553 | } |
---|
4554 | |
---|
4555 | function print_day($params) |
---|
4556 | { |
---|
4557 | if(!is_array($params)) |
---|
4558 | { |
---|
4559 | $this->index(); |
---|
4560 | } |
---|
4561 | |
---|
4562 | print_debug('in print_day()'); |
---|
4563 | |
---|
4564 | $this->bo->store_to_cache( |
---|
4565 | Array( |
---|
4566 | 'syear' => $params['year'], |
---|
4567 | 'smonth' => $params['month'], |
---|
4568 | 'sday' => $params['day'], |
---|
4569 | 'eyear' => $params['year'], |
---|
4570 | 'emonth' => $params['month'], |
---|
4571 | 'eday' => $params['day'] |
---|
4572 | ) |
---|
4573 | ); |
---|
4574 | |
---|
4575 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
4576 | $p->set_unknowns('keep'); |
---|
4577 | |
---|
4578 | $tpl = 'day_cal.tpl'; |
---|
4579 | if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && |
---|
4580 | $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') |
---|
4581 | { |
---|
4582 | $tpl = 'day_list.tpl'; |
---|
4583 | } |
---|
4584 | $templates = Array( |
---|
4585 | 'day_cal' => $tpl |
---|
4586 | ); |
---|
4587 | |
---|
4588 | $p->set_file($templates); |
---|
4589 | $p->set_block('day_cal','day','day'); |
---|
4590 | $p->set_block('day_cal','day_row','day_row'); |
---|
4591 | $p->set_block('day_cal','day_event_on','day_event_on'); |
---|
4592 | $p->set_block('day_cal','day_event_off','day_event_off'); |
---|
4593 | $p->set_block('day_cal','day_event_holiday','day_event_holiday'); |
---|
4594 | $p->set_block('day_cal','day_time','day_time'); |
---|
4595 | |
---|
4596 | $date_to_eval = sprintf("%04d%02d%02d",$params['year'],$params['month'],$params['day']); |
---|
4597 | |
---|
4598 | $day_start = mktime((int)($this->bo->prefs['calendar']['workdaystarts']),0,0,$params['month'],$params['day'],$params['year']); |
---|
4599 | $day_end = mktime((int)($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); |
---|
4600 | $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); |
---|
4601 | print_debug('Date to Eval',$date_to_eval); |
---|
4602 | $events_to_show = array(); |
---|
4603 | if($daily[$date_to_eval]['appts']) |
---|
4604 | { |
---|
4605 | $events = $this->bo->cached_events[$date_to_eval]; |
---|
4606 | print_debug('Date',$date_to_eval); |
---|
4607 | print_debug('Count',count($events)); |
---|
4608 | foreach($events as $event) |
---|
4609 | { |
---|
4610 | if ($this->bo->rejected_no_show($event)) |
---|
4611 | { |
---|
4612 | continue; // user does not want to see rejected events |
---|
4613 | } |
---|
4614 | if ($event['recur_type']) // calculate start- + end-datetime for recuring events |
---|
4615 | { |
---|
4616 | $this->bo->set_recur_date($event,$date_to_eval); |
---|
4617 | } |
---|
4618 | $events_to_show[] = array( |
---|
4619 | 'starttime' => $this->bo->maketime($event['start']), |
---|
4620 | 'endtime' => $this->bo->maketime($event['end']), |
---|
4621 | 'content' => $this->link_to_entry($event,$params['month'],$params['day'],$params['year']) |
---|
4622 | ); |
---|
4623 | } |
---|
4624 | } |
---|
4625 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
4626 | $other = $GLOBALS['phpgw']->hooks->process(array( |
---|
4627 | 'location' => 'calendar_include_events', |
---|
4628 | 'year' => $params['year'], |
---|
4629 | 'month' => $params['month'], |
---|
4630 | 'day' => $params['day'], |
---|
4631 | 'owner' => $this->bo->owner // num. id of the user, not necessary current user |
---|
4632 | )); |
---|
4633 | |
---|
4634 | if (is_array($other)) |
---|
4635 | { |
---|
4636 | foreach($other as $evts) |
---|
4637 | { |
---|
4638 | if (is_array($evts)) |
---|
4639 | { |
---|
4640 | $events_to_show = array_merge($events_to_show,$evts); |
---|
4641 | } |
---|
4642 | } |
---|
4643 | usort($events_to_show,create_function('$a,$b','return $a[\'starttime\']-$b[\'starttime\'];')); |
---|
4644 | //echo "events_to_show=<pre>"; print_r($events_to_show); echo "</pre>\n"; |
---|
4645 | } |
---|
4646 | |
---|
4647 | if (count($events_to_show)) |
---|
4648 | { |
---|
4649 | $last_slot_end = -1; |
---|
4650 | foreach($events_to_show as $event) |
---|
4651 | { |
---|
4652 | $slot = $this->slot_num($event['starttime'],$day_start,$day_end); |
---|
4653 | $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 |
---|
4654 | |
---|
4655 | if ($slot <= $last_slot_end) |
---|
4656 | { |
---|
4657 | $slot = $last_slot; |
---|
4658 | $slot_end = max($last_slot_end,$slot_end); |
---|
4659 | } |
---|
4660 | $rows[$slot] .= $event['content']; |
---|
4661 | |
---|
4662 | print_debug('slot',$slot); |
---|
4663 | print_debug('row',$rows[$slot]); |
---|
4664 | |
---|
4665 | $row_span[$slot] = 1 + $slot_end - $slot; |
---|
4666 | |
---|
4667 | $last_slot = $slot; |
---|
4668 | $last_slot_end = $slot_end; |
---|
4669 | 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)); |
---|
4670 | print_debug('Slot',$slot); |
---|
4671 | } |
---|
4672 | //echo "rows=<pre>"; print_r($rows); echo "<br>row_span="; print_r($row_span); echo "</pre>\n"; |
---|
4673 | } |
---|
4674 | $holiday_names = $daily[$date_to_eval]['holidays']; |
---|
4675 | if(!$holiday_names) |
---|
4676 | { |
---|
4677 | $row_to_print = $this->nm_on_off(); |
---|
4678 | } |
---|
4679 | else |
---|
4680 | { |
---|
4681 | $row_to_print = '_holiday'; |
---|
4682 | foreach($holiday_names as $name) |
---|
4683 | { |
---|
4684 | $rows[0] = '<center>'.$name.'</center>' . $rows[0]; |
---|
4685 | } |
---|
4686 | } |
---|
4687 | $last_slot = $this->slot_num($day_end,$day_start,$day_end); |
---|
4688 | $rowspan = 0; |
---|
4689 | for ($slot = 0; $slot <= $last_slot; ++$slot) |
---|
4690 | { |
---|
4691 | $p->set_var('extras',''); |
---|
4692 | if ($rowspan > 1) |
---|
4693 | { |
---|
4694 | $p->set_var('event',''); |
---|
4695 | $rowspan--; |
---|
4696 | } |
---|
4697 | elseif (!isset($rows[$slot])) |
---|
4698 | { |
---|
4699 | $p->set_var('event',' '); |
---|
4700 | $row_to_print = $this->nm_on_off(); |
---|
4701 | $p->parse('event','day_event'.$row_to_print); |
---|
4702 | } |
---|
4703 | else |
---|
4704 | { |
---|
4705 | $rowspan = (int)$row_span[$slot]; |
---|
4706 | if ($rowspan > 1) |
---|
4707 | { |
---|
4708 | $p->set_var('extras',' rowspan="'.$rowspan.'"'); |
---|
4709 | } |
---|
4710 | $p->set_var('event',$rows[$slot]); |
---|
4711 | $row_to_print = $this->nm_on_off(); |
---|
4712 | $p->parse('event','day_event'.$row_to_print); |
---|
4713 | } |
---|
4714 | $open_link = $close_link = ''; |
---|
4715 | $time = ' '; |
---|
4716 | |
---|
4717 | if (0 < $slot && $slot < $last_slot) // normal time-slot not before or after day_start/end |
---|
4718 | { |
---|
4719 | $time = $day_start + ($slot-1) * 60 * $this->bo->prefs['calendar']['interval']; |
---|
4720 | $hour = date('H',$time); |
---|
4721 | $min = date('i',$time); |
---|
4722 | $time = $GLOBALS['phpgw']->common->formattime($hour,$min); |
---|
4723 | |
---|
4724 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
4725 | { |
---|
4726 | $open_link = ' <a href="'.$this->page('add',"&date=$date_to_eval&hour=$hour&minute=$min").'">'; |
---|
4727 | $close_link = '</a> '; |
---|
4728 | } |
---|
4729 | } |
---|
4730 | $p->set_var(Array( |
---|
4731 | 'open_link' => $open_link, |
---|
4732 | 'time' => $time, |
---|
4733 | 'close_link' => $close_link, |
---|
4734 | 'tr_color' => '' // dummy to stop output_template_array to set it |
---|
4735 | )); |
---|
4736 | $p->parse('time','day_time'); |
---|
4737 | |
---|
4738 | $p->parse('row','day_row',True); |
---|
4739 | } |
---|
4740 | return $p->fp('out','day'); |
---|
4741 | } // end function |
---|
4742 | |
---|
4743 | function timematrix($param) |
---|
4744 | { |
---|
4745 | if(!is_array($param)) |
---|
4746 | { |
---|
4747 | $this->index(); |
---|
4748 | } |
---|
4749 | |
---|
4750 | $date = $param['date']; |
---|
4751 | $starttime = $param['starttime']; |
---|
4752 | $endtime = $param['endtime']; |
---|
4753 | $participants = $param['participants']; |
---|
4754 | foreach($participants as $part => $nul) |
---|
4755 | { |
---|
4756 | $participants[$part] = $GLOBALS['phpgw']->common->grab_owner_name($part); |
---|
4757 | // Much better for processor :) |
---|
4758 | $participants_id[] .= $part; |
---|
4759 | } |
---|
4760 | uasort($participants,'strnatcasecmp'); // sort them after their fullname |
---|
4761 | |
---|
4762 | if(!isset($this->bo->prefs['calendar']['interval'])) |
---|
4763 | { |
---|
4764 | $this->bo->prefs['calendar']['interval'] = 15; |
---|
4765 | $GLOBALS['phpgw']->preferences->add('calendar','interval',15); |
---|
4766 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
4767 | } |
---|
4768 | $increment = $this->bo->prefs['calendar']['interval']; |
---|
4769 | $interval = (int)(60 / $increment); |
---|
4770 | |
---|
4771 | $pix = $GLOBALS['phpgw']->common->image('calendar','pix'); |
---|
4772 | |
---|
4773 | $str = '<center>'.lang($GLOBALS['phpgw']->common->show_date($date['raw'],'l')) |
---|
4774 | . ', '.$this->bo->long_date($date).'<br>' |
---|
4775 | . '<table width="85%" border="0" cellspacing="0" cellpadding="0" cols="'.((24 * $interval) + 1).'">' |
---|
4776 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>' |
---|
4777 | . '<tr><td width="15%"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.lang('Participant').'</font></td>'; |
---|
4778 | for($i=0;$i<24;$i++) |
---|
4779 | { |
---|
4780 | for($j=0;$j<$interval;$j++) |
---|
4781 | { |
---|
4782 | $k = ($j == 0 ? sprintf('%02d',$i).'<br>':'').sprintf('%02d',$j*$increment); |
---|
4783 | |
---|
4784 | $str .= '<td align="left" bgcolor="'.$this->theme['bg_color'].'"><font color="'.$phpgw_info['theme']['bg_text'].'" face="'.$this->theme['font'].'" size="-2">' |
---|
4785 | . '<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;\">" |
---|
4786 | . $k."</a> </font></td>\n"; |
---|
4787 | } |
---|
4788 | } |
---|
4789 | $str .= '</tr>' |
---|
4790 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="black"><img src="'.$pix.'"></td></tr>'; |
---|
4791 | if(!$endtime) |
---|
4792 | { |
---|
4793 | $endtime = $starttime; |
---|
4794 | } |
---|
4795 | $owner = $this->bo->owner; |
---|
4796 | foreach($participants as $part => $fullname) |
---|
4797 | { |
---|
4798 | $str .= '<tr align="center">' |
---|
4799 | . '<td width="15%" align="left"><font color="'.$this->theme['bg_text'].'" face="'.$this->theme['font'].'" size="-2">'.$fullname.'</font></td>'; |
---|
4800 | |
---|
4801 | $this->bo->cached_events = Array(); |
---|
4802 | $this->bo->so->owner = $part; |
---|
4803 | $this->bo->so->open_box($part); |
---|
4804 | $this->bo->store_to_cache( |
---|
4805 | Array( |
---|
4806 | 'syear' => $date['year'], |
---|
4807 | 'smonth'=> $date['month'], |
---|
4808 | 'sday' => $date['day'], |
---|
4809 | 'eyear' => 0, |
---|
4810 | 'emonth'=> 0, |
---|
4811 | 'eday' => $date['day'] + 1 |
---|
4812 | ) |
---|
4813 | ); |
---|
4814 | |
---|
4815 | if(!$this->bo->cached_events[$date['full']]) |
---|
4816 | { |
---|
4817 | for($j=0;$j<24;$j++) |
---|
4818 | { |
---|
4819 | for($k=0;$k<$interval;$k++) |
---|
4820 | { |
---|
4821 | $str .= '<td height="1" align="left" bgcolor="'.$this->theme['bg_color'].'" color="#999999"> </td>'; |
---|
4822 | } |
---|
4823 | $str .= "\n"; |
---|
4824 | } |
---|
4825 | } |
---|
4826 | else |
---|
4827 | { |
---|
4828 | $time_slice = $this->bo->prepare_matrix($interval,$increment,$part,$date['full']); |
---|
4829 | for($h=0;$h<24;$h++) |
---|
4830 | { |
---|
4831 | $hour = $h * 10000; |
---|
4832 | for($m=0;$m<$interval;$m++) |
---|
4833 | { |
---|
4834 | $index = ($hour + (($m * $increment) * 100)); |
---|
4835 | switch($time_slice[$index]['marker']) |
---|
4836 | { |
---|
4837 | case ' ': |
---|
4838 | $time_slice[$index]['color'] = $this->theme['bg_color']; |
---|
4839 | $extra = ''; |
---|
4840 | break; |
---|
4841 | case '-': |
---|
4842 | $time_slice[$index]['color'] = $this->theme['bg01']; |
---|
4843 | $link = $this->page('view','&cal_id='.$time_slice[$index]['id'].'&date='.$date['full']); |
---|
4844 | $extra =' title="'.$time_slice[$index]['description'].'" onClick="location.href=\''.$link.'\';" style="cursor:pointer; cursor:hand;"'; |
---|
4845 | break; |
---|
4846 | } |
---|
4847 | $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>'; |
---|
4848 | } |
---|
4849 | $str .= "\n"; |
---|
4850 | } |
---|
4851 | } |
---|
4852 | $str .= '</tr>' |
---|
4853 | . '<tr><td height="1" colspan="'.((24 * $interval) + 1).'" bgcolor="#999999"><img src="'.$pix.'"></td></tr>'; |
---|
4854 | } |
---|
4855 | $this->bo->owner = $owner; |
---|
4856 | $this->bo->so->owner = $owner; |
---|
4857 | $this->bo->so->open_box($owner); |
---|
4858 | return $str.'</table></center>'."\n"; |
---|
4859 | } |
---|
4860 | |
---|
4861 | function get_response($cal_id) |
---|
4862 | { |
---|
4863 | $p = &$GLOBALS['phpgw']->template; |
---|
4864 | $p->set_file( |
---|
4865 | Array( |
---|
4866 | 'form_button' => 'form_button_script.tpl' |
---|
4867 | ) |
---|
4868 | ); |
---|
4869 | |
---|
4870 | $ev = $this->bo->get_cached_event(); |
---|
4871 | $response_choices = Array( |
---|
4872 | ACCEPTED => lang('Accept'), |
---|
4873 | REJECTED => lang('Reject'), |
---|
4874 | TENTATIVE => lang('Tentative') |
---|
4875 | ); |
---|
4876 | $str = ''; |
---|
4877 | while(list($param,$text) = each($response_choices)) |
---|
4878 | { |
---|
4879 | $var = Array( |
---|
4880 | 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), |
---|
4881 | 'action_text_button' => ' '.$text.' ', |
---|
4882 | 'action_confirm_button' => '', |
---|
4883 | 'action_extra_field' => '' |
---|
4884 | ); |
---|
4885 | $p->set_var($var); |
---|
4886 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
4887 | } |
---|
4888 | if ($this->bo->return_to) |
---|
4889 | { |
---|
4890 | $var = Array( |
---|
4891 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
4892 | 'action_text_button' => lang('cancel'), |
---|
4893 | 'action_confirm_button' => '', |
---|
4894 | 'action_extra_field' => '' |
---|
4895 | ); |
---|
4896 | $p->set_var($var); |
---|
4897 | $str .= '<td>'.$p->fp('out','form_button').'</td>'."\n"; |
---|
4898 | } |
---|
4899 | $str = '<td><b>'.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":</b></td>\n".$str; |
---|
4900 | |
---|
4901 | return '<table width="100%"><tr align="center">'."\n".$str.'</tr></table>'."\n"; |
---|
4902 | } |
---|
4903 | |
---|
4904 | function accounts_popup() |
---|
4905 | { |
---|
4906 | $GLOBALS['phpgw']->accounts->accounts_popup('calendar'); |
---|
4907 | |
---|
4908 | } |
---|
4909 | |
---|
4910 | function edit_form($param) |
---|
4911 | { |
---|
4912 | if(!is_array($param)) |
---|
4913 | { |
---|
4914 | $this->index(); |
---|
4915 | } |
---|
4916 | |
---|
4917 | if(isset($param['event'])) |
---|
4918 | { |
---|
4919 | $event = $param['event']; |
---|
4920 | } |
---|
4921 | |
---|
4922 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
4923 | |
---|
4924 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
4925 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
4926 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
4927 | |
---|
4928 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
4929 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
4930 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
4931 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
4932 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
4933 | if ($param['plain'] != "True"){ |
---|
4934 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
4935 | } |
---|
4936 | else{ |
---|
4937 | $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8"; |
---|
4938 | $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8"; |
---|
4939 | } |
---|
4940 | |
---|
4941 | $p = &$GLOBALS['phpgw']->template; |
---|
4942 | $p->set_file( |
---|
4943 | Array( |
---|
4944 | 'edit' => 'edit.tpl', |
---|
4945 | 'form_button' => 'form_button_script.tpl' |
---|
4946 | ) |
---|
4947 | ); |
---|
4948 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
4949 | $p->set_block('edit','list','list'); |
---|
4950 | $p->set_block('edit','hr','hr'); |
---|
4951 | |
---|
4952 | $vars = Array( |
---|
4953 | 'font' => $this->theme['font'], |
---|
4954 | 'bg_color' => $this->theme['bg_text'], |
---|
4955 | 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), |
---|
4956 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
4957 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
4958 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
4959 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
4960 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
4961 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
4962 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
4963 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
4964 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') |
---|
4965 | ); |
---|
4966 | |
---|
4967 | $p->set_var($vars); |
---|
4968 | |
---|
4969 | // Brief Description |
---|
4970 | $var['title'] = Array( |
---|
4971 | 'tr_color' => $this->theme['th_bg'], |
---|
4972 | 'field' => lang('Title'), |
---|
4973 | 'data' => '<input name="cal[title]" size="45" maxlength="80" value="'.$event['title'].'">' |
---|
4974 | ); |
---|
4975 | |
---|
4976 | // Full Description |
---|
4977 | $var['description'] = Array( |
---|
4978 | 'field' => lang('Full Description'), |
---|
4979 | 'data' => '<textarea name="cal[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['description'].'</textarea>' |
---|
4980 | ); |
---|
4981 | |
---|
4982 | // Display Categories |
---|
4983 | if(strpos($event['category'],',')) |
---|
4984 | { |
---|
4985 | $temp_cats = explode(',',$event['category']); |
---|
4986 | @reset($temp_cats); |
---|
4987 | while(list($key,$value) = each($temp_cats)) |
---|
4988 | { |
---|
4989 | $check_cats[] = (int)$value; |
---|
4990 | } |
---|
4991 | } |
---|
4992 | elseif($event['category']) |
---|
4993 | { |
---|
4994 | $check_cats[] = (int)$event['category']; |
---|
4995 | } |
---|
4996 | else |
---|
4997 | { |
---|
4998 | $check_cats[] = 0; |
---|
4999 | } |
---|
5000 | $var['category'] = Array( |
---|
5001 | 'field' => lang('Category'), |
---|
5002 | 'data' => '<select name="categories[]" onchange="javascript:updateTitleField(this)" multiple size="5">'.$this->cat->formated_list('select','all',$check_cats,True).'</select>' |
---|
5003 | ); |
---|
5004 | |
---|
5005 | // Location |
---|
5006 | $var['location'] = Array( |
---|
5007 | 'field' => lang('Location'), |
---|
5008 | 'data' => '<input name="cal[location]" size="45" maxlength="255" value="'.$event['location'].'">' |
---|
5009 | ); |
---|
5010 | |
---|
5011 | // Date |
---|
5012 | |
---|
5013 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5014 | $var['startdate'] = Array( |
---|
5015 | 'field' => lang('Start Date'), |
---|
5016 | /* |
---|
5017 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
5018 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
5019 | $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
5020 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) |
---|
5021 | ) |
---|
5022 | */ |
---|
5023 | 'data' => $jscal->input('start[str]',$start) |
---|
5024 | ); |
---|
5025 | |
---|
5026 | // Time |
---|
5027 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
5028 | { |
---|
5029 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
5030 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
5031 | } |
---|
5032 | $var['starttime'] = Array( |
---|
5033 | 'field' => lang('Start Time'), |
---|
5034 | '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">'."\n".$str |
---|
5035 | ); |
---|
5036 | |
---|
5037 | // End Date |
---|
5038 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5039 | $var['enddate'] = Array( |
---|
5040 | 'field' => lang('End Date'), |
---|
5041 | /* |
---|
5042 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
5043 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
5044 | $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
5045 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) |
---|
5046 | ) |
---|
5047 | */ |
---|
5048 | 'data' => $jscal->input('end[str]',$end) |
---|
5049 | ); |
---|
5050 | |
---|
5051 | // End Time |
---|
5052 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
5053 | { |
---|
5054 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
5055 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
5056 | } |
---|
5057 | $var['endtime'] = Array( |
---|
5058 | 'field' => lang('End Time'), |
---|
5059 | '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">'."\n".$str |
---|
5060 | ); |
---|
5061 | |
---|
5062 | // Priority |
---|
5063 | $var['priority'] = Array( |
---|
5064 | 'field' => lang('Priority'), |
---|
5065 | 'data' => $sb->getPriority('cal[priority]',$event['priority']) |
---|
5066 | ); |
---|
5067 | |
---|
5068 | // Access |
---|
5069 | $var['access'] = Array( |
---|
5070 | 'field' => lang('Type'), |
---|
5071 | '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>' |
---|
5072 | ); //event['public'] |
---|
5073 | |
---|
5074 | // Participants |
---|
5075 | if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) |
---|
5076 | { |
---|
5077 | switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']) |
---|
5078 | { |
---|
5079 | case 'popup': |
---|
5080 | while (is_array($event['participants']) && list($id) = each($event['participants'])) |
---|
5081 | { |
---|
5082 | if($id != (int)$event['owner']) |
---|
5083 | { |
---|
5084 | $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) |
---|
5085 | .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n"; |
---|
5086 | } |
---|
5087 | } |
---|
5088 | $var['participants'] = array |
---|
5089 | ( |
---|
5090 | 'field' => '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n" |
---|
5091 | . '<input type="hidden" name="accountid" value="' . $accountid . '">', |
---|
5092 | 'data' => "\n".' <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>' |
---|
5093 | ); |
---|
5094 | break; |
---|
5095 | default: |
---|
5096 | foreach($event['participants'] as $id => $participant) |
---|
5097 | { |
---|
5098 | if (($id != $event['owner']) && ($id != "")) |
---|
5099 | { |
---|
5100 | $GLOBALS['phpgw']->accounts->get_account_name($id, $lid, $fname, $lname); |
---|
5101 | $cn = $fname.' '.$lname; |
---|
5102 | $option = ' <option value="' . $id.$participant . '">'.$cn.'</option>'."\n"; |
---|
5103 | $str .= $option; |
---|
5104 | } |
---|
5105 | } |
---|
5106 | $str = utf8_decode($str); |
---|
5107 | $footer_ext_participantes = '<br> '.lang("The email addresses must be separated by ','"); |
---|
5108 | |
---|
5109 | $var['participants'] = array |
---|
5110 | ( |
---|
5111 | 'field' => lang('Participants'), |
---|
5112 | 'data' => " |
---|
5113 | <table width='100%' border='0'> |
---|
5114 | <tr> |
---|
5115 | <td width='30%'> |
---|
5116 | <center>Participantes</center> |
---|
5117 | </td> |
---|
5118 | <td width='8%' > </td> |
---|
5119 | <td width='40%'> </td> |
---|
5120 | </tr> |
---|
5121 | <tr> |
---|
5122 | <td width='30%'> |
---|
5123 | <center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center> |
---|
5124 | </td> |
---|
5125 | <td width='8%'> |
---|
5126 | <center> |
---|
5127 | <table width='100%' border='0'> |
---|
5128 | <tr height='5'><td> </td></tr> |
---|
5129 | <tr><td align='center'> |
---|
5130 | <button type='button' onClick='javascript:openListUsers(340,533, " |
---|
5131 | .$event['owner']. |
---|
5132 | ")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' > Adicionar</button> |
---|
5133 | </td> |
---|
5134 | </tr> |
---|
5135 | <tr height='5'><td> </td></tr> |
---|
5136 | <tr><td align='center'> |
---|
5137 | <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> |
---|
5138 | </td> |
---|
5139 | </tr> |
---|
5140 | </table> |
---|
5141 | </center> |
---|
5142 | </td> |
---|
5143 | <td width='40%'> </td> |
---|
5144 | </tr> |
---|
5145 | </table> |
---|
5146 | <script src='calendar/js/edit.js' type='text/javascript'></script> |
---|
5147 | " |
---|
5148 | ); |
---|
5149 | // if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. |
---|
5150 | if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) { |
---|
5151 | $module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail'])); |
---|
5152 | |
---|
5153 | if($GLOBALS['phpgw_info']['user']['apps'][$module_name]){ |
---|
5154 | $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); |
---|
5155 | $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user']; |
---|
5156 | $_SESSION['phpgw_info']['expressomail']['user']['owner'] = $event['owner']; |
---|
5157 | $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server']; |
---|
5158 | $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; |
---|
5159 | $context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
5160 | $user_context = array(); |
---|
5161 | foreach(explode(",",$GLOBALS['phpgw_info']['user']['account_dn']) as $i => $dn_part){ |
---|
5162 | if($i) |
---|
5163 | $user_context[] = $dn_part; |
---|
5164 | } |
---|
5165 | // Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N. |
---|
5166 | $user_ou = explode(",",str_replace($context,"",implode(",",$user_context))); |
---|
5167 | $user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context)); |
---|
5168 | // Fim |
---|
5169 | // Verifica o tipo da visualização da árvore LDAP, configurado no admin da Agenda |
---|
5170 | $recursive = $GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '1' ? true : false; |
---|
5171 | //$combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
5172 | $footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail."); |
---|
5173 | //Caso o minimo de caracteres para a busca nao tenha sido preenchido ele sera por padrao = 3 |
---|
5174 | if(!$GLOBALS['phpgw_info']['server']['min_num_characters']){ |
---|
5175 | $GLOBALS['phpgw_info']['server']['min_num_characters'] = 0; |
---|
5176 | } |
---|
5177 | |
---|
5178 | if ($GLOBALS['phpgw_info']['server']['cal_type_tree_participants'] == '3'){ |
---|
5179 | $combo_org = '<option value='.$context.'>'.strtoupper($context).'</option>'; |
---|
5180 | }else{ |
---|
5181 | $combo_org = $this->get_organizations(trim(strtolower($context)),$user_context, $recursive); |
---|
5182 | } |
---|
5183 | |
---|
5184 | if ($param['plain'] != "True"){ |
---|
5185 | |
---|
5186 | // Begin load array lang |
---|
5187 | ob_start(); |
---|
5188 | //@include($module_name.'/inc/load_lang.php'); |
---|
5189 | $load_lang_vars = ob_get_contents(); |
---|
5190 | ob_end_clean(); |
---|
5191 | // End load array_lang |
---|
5192 | } |
---|
5193 | |
---|
5194 | $var['participants'] = array |
---|
5195 | ( |
---|
5196 | 'field' => ' |
---|
5197 | <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\'> |
---|
5198 | <iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe> |
---|
5199 | </div> |
---|
5200 | '.lang('Participants'), |
---|
5201 | 'data' => ' |
---|
5202 | <input type="hidden" id="txt_loading" value="'.lang("Loading").'">' . |
---|
5203 | '<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' . |
---|
5204 | '<input type="hidden" id="txt_users" value="'.lang("Users").'">' . |
---|
5205 | '<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' . |
---|
5206 | '<table width="100%" border="0">'. |
---|
5207 | '<tr>'. |
---|
5208 | '<td width="25%"><br><br>'. |
---|
5209 | '<br><br> <b>'.lang("Event's participants").'</b><br>'. |
---|
5210 | ' <select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'. |
---|
5211 | '</td>'. |
---|
5212 | '<td width="30px" valign="middle" align="center"> '. |
---|
5213 | '</td>'. |
---|
5214 | '<td valign="bottom">'. |
---|
5215 | ' '.lang("Organization").': '. |
---|
5216 | ' <select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\');">'.$combo_org.'</select>'. |
---|
5217 | ' <br>'. |
---|
5218 | ' <font color="red"><span id="cal_span_searching"> </span></font>'. |
---|
5219 | ' <br>'.lang("Search for").':'. |
---|
5220 | ' <input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\')"><br>'. |
---|
5221 | ' <b>'.lang("Available users and groups").'</b><br>'. |
---|
5222 | ' <select id="user_list_in" style="width: 300px" multiple size="13"></select>'. |
---|
5223 | '</td>'. |
---|
5224 | '</tr>'. |
---|
5225 | '<tr>'. |
---|
5226 | '<td width="25%">'. |
---|
5227 | '<button type="button" id="time_map" onClick="javascript:show_disponibility();">'.lang("Disponibility map").'</button>'. |
---|
5228 | '</td>'. |
---|
5229 | '<td width="30px" valign="middle" align="center"> '. |
---|
5230 | '</td>'. |
---|
5231 | '<td valign="bottom">'. |
---|
5232 | '<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>'. |
---|
5233 | ' <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>'. |
---|
5234 | '</td>'. |
---|
5235 | '</tr>'. |
---|
5236 | '</table>'. |
---|
5237 | '<script type="text/javascript" src="phpgwapi/js/wz_dragdrop/wz_dragdrop.js"></script>'. |
---|
5238 | '<script type="text/javascript" src="phpgwapi/js/dJSWin/dJSWin.js"></script>'. |
---|
5239 | "<script src='calendar/js/edit_exmail.js' type='text/javascript'></script>" . |
---|
5240 | $load_lang_vars. |
---|
5241 | "<script src='".$module_name."/js/connector.js' type='text/javascript'></script>". |
---|
5242 | "<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ". |
---|
5243 | "<script type='text/javascript'>" . |
---|
5244 | "var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". |
---|
5245 | "</script> " |
---|
5246 | ); |
---|
5247 | } |
---|
5248 | } |
---|
5249 | |
---|
5250 | $var['participants']['data'] .= '<br /><a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" . |
---|
5251 | " 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" ' . |
---|
5252 | '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">'. |
---|
5253 | '<tr>'. |
---|
5254 | '<td>'. |
---|
5255 | ' <b>'.lang("external participants").'</b> <img align="top" src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/sent.gif">' . |
---|
5256 | ' <a title="'.lang("Close").'" name="b_ext_participants" onClick="javascript:hideExParticipants(this,\''.$module_name.'\')" href="#a_ext_participants">['.lang("Close").']</a> '. |
---|
5257 | '</td>'. |
---|
5258 | '</tr>'. |
---|
5259 | '<tr>'. |
---|
5260 | '<td>'. |
---|
5261 | ' >> '.lang("It types below the email addresses, if you want to invite other people out of this system").':'. |
---|
5262 | ' <br><textarea name="ex_participants" id="ex_participants" cols="70" rows="2">'.$event['ex_participants'].'</textarea><br> '. |
---|
5263 | $footer_ext_participantes. |
---|
5264 | '</tr>'. |
---|
5265 | '</table>'; |
---|
5266 | break; |
---|
5267 | |
---|
5268 | } |
---|
5269 | if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) |
---|
5270 | { |
---|
5271 | $checked = ' checked'; |
---|
5272 | } |
---|
5273 | else |
---|
5274 | { |
---|
5275 | $checked = ''; |
---|
5276 | } |
---|
5277 | $var['owner'] = Array( |
---|
5278 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
5279 | 'data' => '<input type="checkbox" id="usuarioParticipa" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'"'.$checked.'>' |
---|
5280 | ); |
---|
5281 | } |
---|
5282 | |
---|
5283 | // Reminder |
---|
5284 | // The user must use "Alarm Management" to change/modify an alarm |
---|
5285 | // so only display the email reminder fields if this is a new event |
---|
5286 | // i.e. not editing an existing event |
---|
5287 | |
---|
5288 | if ($event['id'] == 0) { |
---|
5289 | // get defaults |
---|
5290 | $days = $this->bo->prefs['calendar']['default_email_days']; |
---|
5291 | $hours = $this->bo->prefs['calendar']['default_email_hours']; |
---|
5292 | $min = $this->bo->prefs['calendar']['default_email_min']; |
---|
5293 | if (count($event['alarm']) > 1) |
---|
5294 | { |
---|
5295 | // this should not happen because when creating a new event |
---|
5296 | // only 1 alarm is displayed on the screen |
---|
5297 | // if the user wants more than 1 alarm they should |
---|
5298 | // use "Alarm Management" |
---|
5299 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
5300 | } |
---|
5301 | // if there was an error pick up what the user entered |
---|
5302 | if (@isset($event['alarm'])) |
---|
5303 | { |
---|
5304 | @reset($event['alarm']); |
---|
5305 | // just get the first one see above!!! |
---|
5306 | list($key,$alarm) = @each($event['alarm']); |
---|
5307 | |
---|
5308 | |
---|
5309 | //if abaixo trata o caso de um evento repetido nao ter uma data final; |
---|
5310 | //se isto acontecer, nao havera alarmes definidos; |
---|
5311 | //$alarm['time'] recebe $start para $days, $hours e $min ficarem iguais a 0 |
---|
5312 | if(!$alarm['time']) { |
---|
5313 | $alarm['time'] = $start; |
---|
5314 | } |
---|
5315 | |
---|
5316 | $diff = $start - $alarm['time']; |
---|
5317 | $days = (int)($diff / (24*3600)); |
---|
5318 | $hours = (int)(($diff - ($days * 24 * 3600))/3600); |
---|
5319 | $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); |
---|
5320 | |
---|
5321 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') { |
---|
5322 | $days = $diff; |
---|
5323 | } |
---|
5324 | } |
---|
5325 | |
---|
5326 | // days |
---|
5327 | $dout = '<select name="cal[alarmdays]">'."\n"; |
---|
5328 | for($i=0;$i<32;$i++) |
---|
5329 | { |
---|
5330 | $dout .= '<option value="'.$i.'"'.($i==$days?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5331 | } |
---|
5332 | $dout .= '</select>'."\n".' '.lang('days').' '; |
---|
5333 | // hours |
---|
5334 | $hout = '<select name="cal[alarmhours]">'."\n"; |
---|
5335 | for($i=0;$i<25;$i++) |
---|
5336 | { |
---|
5337 | $hout .= '<option value="'.$i.'"'.($i==$hours?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5338 | } |
---|
5339 | $hout .= '</select>'."\n".' '.lang('hours').' '; |
---|
5340 | // minutes |
---|
5341 | $mout = '<select name="cal[alarmminutes]">'."\n"; |
---|
5342 | for($i=0;$i<61;$i++) |
---|
5343 | { |
---|
5344 | $mout .= '<option value="'.$i.'"'.($i==$min?' selected':'').'>'.$i.'</option>'."\n"; |
---|
5345 | } |
---|
5346 | $mout .= '</select>'."\n".' '.lang('minutes').' '; |
---|
5347 | |
---|
5348 | $var['alarm'] = Array( |
---|
5349 | 'field' => lang('Alarm'), |
---|
5350 | 'data' => $dout.$hout.$mout.lang('before the event') |
---|
5351 | ); |
---|
5352 | |
---|
5353 | } |
---|
5354 | |
---|
5355 | // Repeat Type |
---|
5356 | $str = ''; |
---|
5357 | foreach($this->bo->rpt_type as $type => $label) |
---|
5358 | { |
---|
5359 | $str .= '<option value="'.$type.'"'.($event['recur_type']==$type?' selected':'').'>'.lang($label).'</option>'; |
---|
5360 | } |
---|
5361 | $var['recure_type'] = Array( |
---|
5362 | 'field' => lang('Repeat Type'), |
---|
5363 | 'data' => '<select name="cal[recur_type]">'."\n".$str.'</select>'."\n" |
---|
5364 | ); |
---|
5365 | |
---|
5366 | if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) |
---|
5367 | { |
---|
5368 | $checked = ' checked'; |
---|
5369 | $recur_end = $this->bo->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5370 | } |
---|
5371 | else |
---|
5372 | { |
---|
5373 | $checked = ''; |
---|
5374 | $recur_end = $this->bo->maketime($event['start']) + 86400 - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
5375 | } |
---|
5376 | |
---|
5377 | $var['recure_enddate'] = Array( |
---|
5378 | 'field' => lang('Repeat End Date'), |
---|
5379 | 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. |
---|
5380 | /* |
---|
5381 | $GLOBALS['phpgw']->common->dateformatorder( |
---|
5382 | $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')), |
---|
5383 | $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')), |
---|
5384 | $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d')) |
---|
5385 | ) |
---|
5386 | */ |
---|
5387 | $jscal->input('recur_enddate[str]',$recur_end) |
---|
5388 | ); |
---|
5389 | |
---|
5390 | $i = 0; $boxes = ''; |
---|
5391 | foreach ($this->bo->rpt_day as $mask => $name) |
---|
5392 | { |
---|
5393 | $boxes .= '<input type="checkbox" name="cal[rpt_day][]" value="'.$mask.'"'.($event['recur_data'] & $mask ? ' checked' : '').'> '.lang($name)."\n"; |
---|
5394 | if (++$i == 5) $boxes .= '<br>'; |
---|
5395 | } |
---|
5396 | $var['recure_day'] = Array( |
---|
5397 | 'field' => lang('Repeat Day').'<br>'.lang('(required for weekly recursivity)'), |
---|
5398 | 'data' => $boxes |
---|
5399 | ); |
---|
5400 | |
---|
5401 | $var['recure_interval'] = Array( |
---|
5402 | 'field' => lang('Interval'), |
---|
5403 | 'data' => '<input name="cal[recur_interval]" size="4" maxlength="4" value="'.$event['recur_interval'].'">' |
---|
5404 | ); |
---|
5405 | // $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>')); |
---|
5406 | |
---|
5407 | if (!isset($this->fields)) |
---|
5408 | { |
---|
5409 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
5410 | $this->fields = &$this->custom_fields->fields; |
---|
5411 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
5412 | } |
---|
5413 | $this->output_template_array($p,'row','list',$var['access']); |
---|
5414 | unset($var['access']); |
---|
5415 | |
---|
5416 | $preserved = False; |
---|
5417 | foreach($this->fields as $field => $data) |
---|
5418 | { |
---|
5419 | if (!$data['disabled']) |
---|
5420 | { |
---|
5421 | if (isset($var[$field])) |
---|
5422 | { |
---|
5423 | switch($field) |
---|
5424 | { |
---|
5425 | case 'startdate': |
---|
5426 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
5427 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
5428 | break; |
---|
5429 | case 'enddate': |
---|
5430 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
5431 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
5432 | break; |
---|
5433 | case 'recure_type': |
---|
5434 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
5435 | $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>'); |
---|
5436 | $p->parse('row','hr',True); |
---|
5437 | $this->output_template_array($p,'row','list',$var['recure_type']); |
---|
5438 | $this->output_template_array($p,'row','list',$var['recure_enddate']); |
---|
5439 | $this->output_template_array($p,'row','list',$var['recure_day']); |
---|
5440 | $this->output_template_array($p,'row','list',$var['recure_interval']); |
---|
5441 | break; |
---|
5442 | default: |
---|
5443 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
5444 | } |
---|
5445 | } |
---|
5446 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
5447 | { |
---|
5448 | $lang = lang($name = substr($field,1)); |
---|
5449 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
5450 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
5451 | $v = array( |
---|
5452 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
5453 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
5454 | ); |
---|
5455 | if ($data['title']) |
---|
5456 | { |
---|
5457 | $v['tr_color'] = $this->theme['th_bg']; |
---|
5458 | } |
---|
5459 | if (!$data['length'] && $data['title']) |
---|
5460 | { |
---|
5461 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
5462 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
5463 | $p->parse('row','hr',True); |
---|
5464 | } |
---|
5465 | else |
---|
5466 | { |
---|
5467 | $this->output_template_array($p,'row','list',$v); |
---|
5468 | } |
---|
5469 | } |
---|
5470 | } |
---|
5471 | else // preserve disabled fields |
---|
5472 | { |
---|
5473 | switch ($field) |
---|
5474 | { |
---|
5475 | case 'owner': |
---|
5476 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
5477 | break; |
---|
5478 | case 'recure_type': |
---|
5479 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
5480 | { |
---|
5481 | $preserved[$field] = $event[$field]; |
---|
5482 | } |
---|
5483 | break; |
---|
5484 | case 'startdate': |
---|
5485 | case 'enddate': |
---|
5486 | $field = substr($field,0,-4); |
---|
5487 | default: |
---|
5488 | $preserved[$field] = $event[$field]; |
---|
5489 | } |
---|
5490 | } |
---|
5491 | } |
---|
5492 | unset($var); |
---|
5493 | if (is_array($preserved)) |
---|
5494 | { |
---|
5495 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
5496 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
5497 | } |
---|
5498 | $p->set_var('submit_button',lang('Save')); |
---|
5499 | |
---|
5500 | $delete_button = $cancel_button = ''; |
---|
5501 | if ($event['id'] > 0) |
---|
5502 | { |
---|
5503 | $var = Array( |
---|
5504 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
5505 | 'action_text_button' => lang('Delete'), |
---|
5506 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
5507 | 'action_extra_field' => '', |
---|
5508 | 'button_id' => 'delete_button' |
---|
5509 | ); |
---|
5510 | $p->set_var($var); |
---|
5511 | $delete_button = $p->fp('out','form_button'); |
---|
5512 | } |
---|
5513 | $p->set_var('delete_button',$delete_button); |
---|
5514 | $p->set_var('alert_msg',lang('Required field (category) is empty')); |
---|
5515 | |
---|
5516 | if ($this->bo->return_to) |
---|
5517 | { |
---|
5518 | $var = Array( |
---|
5519 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
5520 | 'action_text_button' => lang('Cancel'), |
---|
5521 | 'action_confirm_button' => '', |
---|
5522 | 'action_extra_field' => '', |
---|
5523 | 'button_id' => 'cancel_button' |
---|
5524 | ); |
---|
5525 | $p->set_var($var); |
---|
5526 | $cancel_button = $p->fp('out','form_button'); |
---|
5527 | } |
---|
5528 | $p->set_var('cancel_button',$cancel_button); |
---|
5529 | $p->pparse('out','edit_entry'); |
---|
5530 | } |
---|
5531 | |
---|
5532 | // modify list of an event's external participants (i.e. non pgpgw users) |
---|
5533 | // |
---|
5534 | function modify_ext_partlist() |
---|
5535 | { |
---|
5536 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
5537 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
5538 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
5539 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
5540 | |
---|
5541 | $total_contacts = 0; |
---|
5542 | $participant = array(); |
---|
5543 | $control_data= array(); |
---|
5544 | |
---|
5545 | $control_data['action'] = ''; |
---|
5546 | $control_data['delete'] = array(); |
---|
5547 | $control_data['part'] = array(); |
---|
5548 | |
---|
5549 | $p = CreateObject('phpgwapi.Template',$this->template_dir); |
---|
5550 | $p->set_file( |
---|
5551 | Array( |
---|
5552 | 'T_edit_partlist' => 'edit_partlist.tpl', |
---|
5553 | 'T_edit_partlist_blocks' => 'edit_partlist_blocks.tpl' |
---|
5554 | ) |
---|
5555 | ); |
---|
5556 | |
---|
5557 | $p->set_block('T_edit_partlist_blocks','B_alert_msg','V_alert_msg'); |
---|
5558 | $p->set_block('T_edit_partlist_blocks','B_partlist','V_partlist'); |
---|
5559 | $p->set_block('T_edit_partlist_blocks','B_participants_none','V_participants_none'); |
---|
5560 | $p->set_block('T_edit_partlist_blocks','B_delete_btn','V_delete_btn'); |
---|
5561 | |
---|
5562 | global $query_addr; |
---|
5563 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
5564 | $addy = $sb->getAddress('addr','',$query_addr); |
---|
5565 | |
---|
5566 | $add_ext = $addy['doSearchFkt']; |
---|
5567 | $add_ext .= $addy['addr_title']!=lang('Address Book')?$addy['addr_title']:''; |
---|
5568 | $add_ext .= " ".$addy['addr'].$addy['addr_nojs']; |
---|
5569 | |
---|
5570 | $p->set_var('text_add_name',$add_ext); |
---|
5571 | |
---|
5572 | if(isset($_GET['part']) && $_GET['part']) |
---|
5573 | { |
---|
5574 | $control_data['part'] = split(",", $_GET['part']); |
---|
5575 | } |
---|
5576 | else |
---|
5577 | { |
---|
5578 | $control_data['part'] = $_POST['participant']; |
---|
5579 | $control_data['action'] = $_POST['action']; |
---|
5580 | $control_data['delete'] = $_POST['delete']; |
---|
5581 | } |
---|
5582 | |
---|
5583 | for ($i=0; $i<count($control_data['part']); $i++) |
---|
5584 | { |
---|
5585 | $id = $control_data['part'][$i]; |
---|
5586 | list($contact) = $this->read_contact($id); |
---|
5587 | |
---|
5588 | $participant[$id] = array(); |
---|
5589 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
5590 | } |
---|
5591 | |
---|
5592 | if ($control_data['action'] == lang('Delete selected contacts')) |
---|
5593 | { |
---|
5594 | for ($i=0; $i<count($control_data['delete']); $i++) |
---|
5595 | { |
---|
5596 | $id = $control_data['delete'][$i]; |
---|
5597 | unset($participant[$id]); |
---|
5598 | } |
---|
5599 | } |
---|
5600 | |
---|
5601 | if ($control_data['action'] == lang('Add Contact')) |
---|
5602 | { |
---|
5603 | $id = $_POST['id_addr']; |
---|
5604 | if (isset($id) && (int)$id != 0) |
---|
5605 | { |
---|
5606 | list($contact) = $this->read_contact($id); |
---|
5607 | $participant[$id] = array(); |
---|
5608 | $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; |
---|
5609 | } |
---|
5610 | } |
---|
5611 | |
---|
5612 | // create list of currently selected contacts |
---|
5613 | // |
---|
5614 | while(list($id,$contact) = each($participant)) |
---|
5615 | { |
---|
5616 | $p->set_var('hidden_delete_name','participant[]'); |
---|
5617 | $p->set_var('hidden_delete_value',$id); |
---|
5618 | $p->set_var('ckbox_delete_name','delete[]'); |
---|
5619 | $p->set_var('ckbox_delete_value',$id); |
---|
5620 | $p->set_var('ckbox_delete_participant',$contact['name']); |
---|
5621 | $p->parse('V_partlist','B_partlist',True); |
---|
5622 | $total_contacts++; |
---|
5623 | } |
---|
5624 | |
---|
5625 | if ($total_contacts == 0) |
---|
5626 | { |
---|
5627 | // no contacts have been selected |
---|
5628 | // => clear the delete form, remove delete button and show the none block |
---|
5629 | // |
---|
5630 | $p->set_var('V_partlist',''); |
---|
5631 | $p->set_var('V_delete_btn',''); |
---|
5632 | $p->set_var('text_none',lang('None')); |
---|
5633 | $p->parse('V_participants_none','B_participants_none'); |
---|
5634 | } |
---|
5635 | else |
---|
5636 | { |
---|
5637 | // at least one contact has been selected |
---|
5638 | // => clear the none block, fill the delete form and add delete button |
---|
5639 | // |
---|
5640 | $p->set_var('V_participants_none',''); |
---|
5641 | $p->set_var('btn_delete_name','action'); |
---|
5642 | $p->set_var('btn_delete_value',lang('Delete selected contacts')); |
---|
5643 | $p->parse('V_delete_btn','B_delete_btn'); |
---|
5644 | } |
---|
5645 | |
---|
5646 | $body_tags = 'bgcolor="'.$GLOBALS['phpgw_info']['theme']['bg_color'] |
---|
5647 | . '" alink="'.$GLOBALS['phpgw_info']['theme']['alink'] |
---|
5648 | . '" link="'.$GLOBALS['phpgw_info']['theme']['link'] |
---|
5649 | .'" vlink="'.$GLOBALS['phpgw_info']['theme']['vlink'].'"'; |
---|
5650 | |
---|
5651 | $form_action = $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'calendar.uicalendar.modify')); |
---|
5652 | |
---|
5653 | $charset = lang('charset'); |
---|
5654 | $p->set_var('charset',$charset); |
---|
5655 | $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] |
---|
5656 | . ' - ' .lang('External Participants')); |
---|
5657 | $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); |
---|
5658 | $p->set_var('body_tags',$body_tags); |
---|
5659 | $p->set_var('form_method','POST'); |
---|
5660 | $p->set_var('form_action',$form_action); |
---|
5661 | $p->set_var('text_add_contact',lang('External Participants')); |
---|
5662 | $p->set_var('text_contacts_selected',lang('Selected contacts (%1)',$total_contacts)); |
---|
5663 | $p->set_var('btn_add_name','action'); |
---|
5664 | $p->set_var('btn_add_value',lang('Add Contact')); |
---|
5665 | $p->set_var('btn_done_name','done'); |
---|
5666 | $p->set_var('btn_done_value',lang('Done')); |
---|
5667 | $p->set_var('btn_done_js','copyback()'); |
---|
5668 | $p->set_var('form1_name','ext_form'); |
---|
5669 | |
---|
5670 | $p->pfp('out','T_edit_partlist'); |
---|
5671 | } |
---|
5672 | |
---|
5673 | function read_contact($id) |
---|
5674 | { |
---|
5675 | $query_fields = Array( |
---|
5676 | 'n_given' => 'n_given', |
---|
5677 | 'n_family' => 'n_family', |
---|
5678 | 'email' => 'email', |
---|
5679 | 'email_home' => 'email_home' |
---|
5680 | ); |
---|
5681 | |
---|
5682 | /* |
---|
5683 | if ($this->rights & PHPGW_ACL_READ) |
---|
5684 | { |
---|
5685 | return $this->contacts->read_single_entry($id,$fields); |
---|
5686 | } |
---|
5687 | else |
---|
5688 | { |
---|
5689 | $rtrn = array(0 => array('No access' => 'No access')); |
---|
5690 | return $rtrn; |
---|
5691 | } |
---|
5692 | */ |
---|
5693 | |
---|
5694 | $contacts = CreateObject('phpgwapi.contacts', False); |
---|
5695 | return $contacts->read_single_entry($id,$query_fields); |
---|
5696 | } |
---|
5697 | |
---|
5698 | function build_part_list(&$users,$accounts,$owner) |
---|
5699 | { |
---|
5700 | if(!is_array($accounts)) |
---|
5701 | { |
---|
5702 | return; |
---|
5703 | } |
---|
5704 | foreach($accounts as $id) |
---|
5705 | { |
---|
5706 | $id = (int)$id; |
---|
5707 | if($id == $owner) |
---|
5708 | { |
---|
5709 | continue; |
---|
5710 | } |
---|
5711 | elseif(!isset($users[$id])) |
---|
5712 | { |
---|
5713 | if($GLOBALS['phpgw']->accounts->exists($id) == True) |
---|
5714 | { |
---|
5715 | $users[$id] = Array( |
---|
5716 | 'name' => $GLOBALS['phpgw']->common->grab_owner_name($id), |
---|
5717 | 'type' => $GLOBALS['phpgw']->accounts->get_type($id) |
---|
5718 | ); |
---|
5719 | } |
---|
5720 | if($GLOBALS['phpgw']->accounts->get_type($id) == 'g') |
---|
5721 | { |
---|
5722 | //$this->build_part_list($users,$GLOBALS['phpgw']->acl->get_ids_for_location($id,1,'phpgw_group'),$owner); |
---|
5723 | } |
---|
5724 | } |
---|
5725 | } |
---|
5726 | if (!function_exists('strcmp_name')) |
---|
5727 | { |
---|
5728 | function strcmp_name($arr1,$arr2) |
---|
5729 | { |
---|
5730 | if ($diff = strcmp($arr1['type'],$arr2['type'])) |
---|
5731 | { |
---|
5732 | return $diff; // groups before users |
---|
5733 | } |
---|
5734 | return strnatcasecmp($arr1['name'],$arr2['name']); |
---|
5735 | } |
---|
5736 | } |
---|
5737 | uasort($users,'strcmp_name'); |
---|
5738 | } |
---|
5739 | |
---|
5740 | function set_week_array($startdate,$cellcolor,$weekly) |
---|
5741 | { |
---|
5742 | $data = date("m"); |
---|
5743 | for ($j=0,$datetime=$startdate;$j<7;$j++,$datetime += 86400) |
---|
5744 | { |
---|
5745 | $date = date('Ymd',$datetime + (60 * 60 * 2)); // +2h to be save when switching to and from dst, $datetime is alreay + TZ-Offset |
---|
5746 | print_debug('set_week_array : Date ',$date); |
---|
5747 | |
---|
5748 | if($events = $this->bo->cached_events[$date]) |
---|
5749 | { |
---|
5750 | print_debug('Date',$date); |
---|
5751 | print_debug('Appointments Found',count($events)); |
---|
5752 | |
---|
5753 | if (!$this->bo->prefs['calendar']['show_rejected']) |
---|
5754 | { |
---|
5755 | $appts = False; |
---|
5756 | foreach($events as $event) // check for a not-rejected event |
---|
5757 | { |
---|
5758 | if (!$this->bo->rejected_no_show($event)) |
---|
5759 | { |
---|
5760 | $appts = True; |
---|
5761 | break; |
---|
5762 | } |
---|
5763 | } |
---|
5764 | } |
---|
5765 | else |
---|
5766 | { |
---|
5767 | $appts = True; |
---|
5768 | } |
---|
5769 | } |
---|
5770 | else |
---|
5771 | { |
---|
5772 | $appts = False; |
---|
5773 | } |
---|
5774 | |
---|
5775 | $holidays = $this->bo->cached_holidays[$date]; |
---|
5776 | if($weekly) |
---|
5777 | { |
---|
5778 | $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); |
---|
5779 | } |
---|
5780 | |
---|
5781 | $day_image = ''; |
---|
5782 | if($holidays) |
---|
5783 | { |
---|
5784 | $extra = ' bgcolor="'.$this->bo->holiday_color.'"'; |
---|
5785 | $class = ($appts?'b':'').'minicalhol'; |
---|
5786 | if ($date == $this->bo->today) |
---|
5787 | { |
---|
5788 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
5789 | } |
---|
5790 | } |
---|
5791 | elseif ($date != $this->bo->today) |
---|
5792 | { |
---|
5793 | $extra = ' bgcolor="'.$cellcolor.'"'; |
---|
5794 | $class = ($appts?'b':'').'minicalendar'; |
---|
5795 | } |
---|
5796 | else |
---|
5797 | { |
---|
5798 | $extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"'; |
---|
5799 | $class = ($appts?'b':'').'minicalendar'; |
---|
5800 | $day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block').'"'; |
---|
5801 | } |
---|
5802 | |
---|
5803 | if($this->bo->printer_friendly && @$this->bo->prefs['calendar']['print_black_white']) |
---|
5804 | { |
---|
5805 | $extra = ''; |
---|
5806 | } |
---|
5807 | |
---|
5808 | if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
5809 | { |
---|
5810 | $new_event = True; |
---|
5811 | } |
---|
5812 | else |
---|
5813 | { |
---|
5814 | $new_event = False; |
---|
5815 | } |
---|
5816 | $holiday_name = Array(); |
---|
5817 | if($holidays) |
---|
5818 | { |
---|
5819 | for($k=0;$k<count($holidays);$k++) |
---|
5820 | { |
---|
5821 | $holiday_name[] = $holidays[$k]['name']; |
---|
5822 | } |
---|
5823 | } |
---|
5824 | $week = ''; |
---|
5825 | if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) |
---|
5826 | { |
---|
5827 | $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); |
---|
5828 | } |
---|
5829 | $daily[$date] = Array( |
---|
5830 | 'extra' => $extra, |
---|
5831 | 'new_event' => $new_event, |
---|
5832 | 'holidays' => $holiday_name, |
---|
5833 | 'appts' => $appts, |
---|
5834 | 'week' => $week, |
---|
5835 | 'day_image' => $day_image, |
---|
5836 | 'class' => $class |
---|
5837 | ); |
---|
5838 | } |
---|
5839 | |
---|
5840 | if($this->debug) |
---|
5841 | { |
---|
5842 | _debug_array($daily); |
---|
5843 | } |
---|
5844 | |
---|
5845 | return $daily; |
---|
5846 | } |
---|
5847 | |
---|
5848 | function get_organizations($context, $selected='', $recursive = false) |
---|
5849 | { |
---|
5850 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
5851 | |
---|
5852 | return ($recursive ? |
---|
5853 | $s->get_organizations($context, $selected, false ,false) : |
---|
5854 | $s->get_sectors($selected, false, false)); |
---|
5855 | } |
---|
5856 | } |
---|
5857 | ?> |
---|