1 | <?php |
---|
2 | class ui_mobilecalendar { |
---|
3 | |
---|
4 | var $bo; |
---|
5 | var $cat; |
---|
6 | var $link_tpl; |
---|
7 | |
---|
8 | var $public_functions = array( |
---|
9 | 'add' => true, |
---|
10 | 'init_schedule' => true, |
---|
11 | 'add_participants' => true, |
---|
12 | 'add_participant' => true, |
---|
13 | 'edit' => true, |
---|
14 | 'update' =>true, |
---|
15 | 'overlap' => true, |
---|
16 | 'index' => true |
---|
17 | ); |
---|
18 | |
---|
19 | function ui_mobilecalendar() { |
---|
20 | $this->bo = CreateObject('calendar.bocalendar',1); |
---|
21 | $this->cat = &$this->bo->cat; |
---|
22 | $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
23 | |
---|
24 | $this->link_tpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
25 | $this->link_tpl->set_unknowns('remove'); |
---|
26 | $this->link_tpl->set_file( |
---|
27 | Array( |
---|
28 | 'link_picture' => 'link_pict.tpl' |
---|
29 | ) |
---|
30 | ); |
---|
31 | $this->link_tpl->set_block('link_picture','link_pict','link_pict'); |
---|
32 | $this->link_tpl->set_block('link_picture','pict','pict'); |
---|
33 | $this->link_tpl->set_block('link_picture','link_open','link_open'); |
---|
34 | $this->link_tpl->set_block('link_picture','link_close','link_close'); |
---|
35 | $this->link_tpl->set_block('link_picture','link_text','link_text'); |
---|
36 | } |
---|
37 | |
---|
38 | function index() { |
---|
39 | $GLOBALS['phpgw']->redirect_link('calendar.php'); |
---|
40 | } |
---|
41 | |
---|
42 | function page($_page='',$params='') |
---|
43 | { |
---|
44 | if($_page == '') |
---|
45 | { |
---|
46 | $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); |
---|
47 | $_page = $page_[0]; |
---|
48 | |
---|
49 | if ($_page=='planner_cat' || $_page=='planner_user') |
---|
50 | { |
---|
51 | $_page = 'planner'; |
---|
52 | } |
---|
53 | elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) |
---|
54 | { |
---|
55 | $_page = 'month'; |
---|
56 | $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); |
---|
57 | $GLOBALS['phpgw']->preferences->save_repository(); |
---|
58 | } |
---|
59 | } |
---|
60 | if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || |
---|
61 | strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... |
---|
62 | { |
---|
63 | $page_app = 'calendar'; |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | $page_app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
68 | } |
---|
69 | if (is_array($params)) |
---|
70 | { |
---|
71 | $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page; |
---|
72 | } |
---|
73 | else |
---|
74 | { |
---|
75 | $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params; |
---|
76 | } |
---|
77 | return $GLOBALS['phpgw']->link('/index.php',$params); |
---|
78 | } |
---|
79 | |
---|
80 | function init_schedule() { |
---|
81 | $_SESSION['mobile_calendar'] = NULL; |
---|
82 | $this->add_participants(); |
---|
83 | } |
---|
84 | |
---|
85 | function add_participants() { |
---|
86 | |
---|
87 | $ui_cc = CreateObject('mobile.ui_mobilecc'); |
---|
88 | $ui_cc->contacts_list(true); |
---|
89 | } |
---|
90 | |
---|
91 | function add_participant() { |
---|
92 | |
---|
93 | $participants = $_SESSION["mobile_calendar"]; |
---|
94 | |
---|
95 | if(!is_array($participants)) |
---|
96 | $participants = array(); |
---|
97 | |
---|
98 | $participants[$_GET['user']] = $_GET['cn']; |
---|
99 | |
---|
100 | $_SESSION["mobile_calendar"] = $participants; |
---|
101 | |
---|
102 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
103 | $p->set_file(Array('continue' => 'keep_add_participants.tpl')); |
---|
104 | $p->set_block('continue','body'); |
---|
105 | $p->set_var('lang_add_participants',lang('keep add participants')); |
---|
106 | $p->set_var('lang_continue',lang('continue scheduling')); |
---|
107 | $p->pfp('out','body'); |
---|
108 | } |
---|
109 | |
---|
110 | function add($cd=0,$readsess=0) |
---|
111 | { |
---|
112 | if(!$this->bo->check_perms(PHPGW_ACL_ADD)) |
---|
113 | { |
---|
114 | $this->index(); |
---|
115 | } |
---|
116 | |
---|
117 | if($readsess) |
---|
118 | { |
---|
119 | $event = $this->bo->restore_from_appsession; |
---|
120 | if(!$event['owner']) |
---|
121 | { |
---|
122 | $this->bo->add_attribute('owner',$this->bo->owner); |
---|
123 | } |
---|
124 | $can_edit = True; |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | $this->bo->event_init(); |
---|
129 | $this->bo->add_attribute('id',0); |
---|
130 | |
---|
131 | $can_edit = True; |
---|
132 | $participants = (string)(get_var('participants',array('GET'),FALSE)); |
---|
133 | $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); |
---|
134 | $startmin = (int)(get_var('minute',array('GET'),0)); |
---|
135 | $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength']; |
---|
136 | $endhour = $starthour + $this->bo->normalizeminutes($endmin); |
---|
137 | |
---|
138 | $subject = (string)(get_var('title',array('GET'),0)); |
---|
139 | if ($subject != '0') |
---|
140 | { |
---|
141 | $description = (string)(get_var('description',array('GET'),0)); |
---|
142 | $location = (string)(get_var('location',array('GET'),0)); |
---|
143 | } |
---|
144 | else |
---|
145 | unset($subject); |
---|
146 | |
---|
147 | $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); |
---|
148 | $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0); |
---|
149 | $this->bo->set_title($subject); |
---|
150 | $this->bo->set_description($description); |
---|
151 | $this->bo->add_attribute('location',$location); |
---|
152 | $this->bo->set_ex_participants(''); |
---|
153 | $this->bo->add_attribute('uid',''); |
---|
154 | $this->bo->add_attribute('priority',2); |
---|
155 | if(@$this->bo->prefs['calendar']['default_private']) |
---|
156 | { |
---|
157 | $this->bo->set_class(False); |
---|
158 | } |
---|
159 | else |
---|
160 | { |
---|
161 | $this->bo->set_class(True); |
---|
162 | } |
---|
163 | |
---|
164 | $this->bo->add_attribute('participants','A',$this->bo->owner); |
---|
165 | $this->bo->set_recur_none(); |
---|
166 | $event = $this->bo->get_cached_event(); |
---|
167 | |
---|
168 | } |
---|
169 | $this->edit_form( |
---|
170 | Array( |
---|
171 | 'event' => $event, |
---|
172 | 'cd' => $cd |
---|
173 | ) |
---|
174 | ); |
---|
175 | //$GLOBALS['phpgw']->common->phpgw_footer(); |
---|
176 | } |
---|
177 | |
---|
178 | function edit($params='') |
---|
179 | { |
---|
180 | if($this->debug) |
---|
181 | { |
---|
182 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
183 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
184 | } |
---|
185 | |
---|
186 | if(isset($_GET['readsess'])) |
---|
187 | { |
---|
188 | $params['readsess'] = $_GET['readsess']; |
---|
189 | $params['cd'] = 0; |
---|
190 | } |
---|
191 | |
---|
192 | if($this->debug) |
---|
193 | { |
---|
194 | echo '<!-- params[readsess] = '.$params['readsess'].' -->'."\n"; |
---|
195 | echo '<!-- params[cd] = '.$params['cd'].' -->'."\n"; |
---|
196 | } |
---|
197 | |
---|
198 | if($params != '' && @is_array($params) && @isset($params['readsess'])) |
---|
199 | { |
---|
200 | $can_edit = True; |
---|
201 | $this->edit_form( |
---|
202 | Array( |
---|
203 | 'event' => $this->bo->restore_from_appsession(), |
---|
204 | 'cd' => $params['cd'] |
---|
205 | ) |
---|
206 | ); |
---|
207 | } |
---|
208 | elseif(isset($_GET['cal_id'])) |
---|
209 | { |
---|
210 | $cal_id = (int)$_GET['cal_id']; |
---|
211 | $event = $this->bo->read_entry($cal_id); |
---|
212 | |
---|
213 | if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) |
---|
214 | { |
---|
215 | Header('Location: '.$this->page('view','&cal_id='.$cal_id)); |
---|
216 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
217 | } |
---|
218 | if(@isset($_POST['edit_type']) && $_POST['edit_type'] == 'single') |
---|
219 | { |
---|
220 | $event['id'] = 0; |
---|
221 | $this->bo->set_recur_date($event,$_POST['date']); |
---|
222 | $event['recur_type'] = MCAL_RECUR_NONE; |
---|
223 | $event['recur_interval'] = 0; |
---|
224 | $event['recur_data'] = 0; |
---|
225 | $event['recur_enddate']['month'] = 0; |
---|
226 | $event['recur_enddate']['mday'] = 0; |
---|
227 | $event['recur_enddate']['year'] = 0; |
---|
228 | $event['recur_exception'] = array(); |
---|
229 | } |
---|
230 | $this->edit_form( |
---|
231 | Array( |
---|
232 | 'event' => $event, |
---|
233 | 'cd' => $cd |
---|
234 | ) |
---|
235 | ); |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | function update() { |
---|
240 | $params = array(); |
---|
241 | $params['from_mobile'] = true; |
---|
242 | $this->bo->update($params); |
---|
243 | } |
---|
244 | |
---|
245 | function edit_form($param) |
---|
246 | { |
---|
247 | if(!is_array($param)) |
---|
248 | { |
---|
249 | $this->index(); |
---|
250 | } |
---|
251 | |
---|
252 | if(isset($param['event'])) |
---|
253 | { |
---|
254 | $event = $param['event']; |
---|
255 | } |
---|
256 | |
---|
257 | $hourformat = substr($this->bo->users_timeformat,0,1); |
---|
258 | |
---|
259 | // $sb = CreateObject('phpgwapi.sbox'); |
---|
260 | $sb = CreateObject('phpgwapi.sbox2'); |
---|
261 | $jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!! |
---|
262 | |
---|
263 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
264 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
265 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
266 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
267 | $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event'); |
---|
268 | //$GLOBALS['phpgw']->common->phpgw_header(); |
---|
269 | |
---|
270 | $p = &$GLOBALS['phpgw']->template; |
---|
271 | $p->set_file( |
---|
272 | Array( |
---|
273 | 'edit' => 'edit.tpl', |
---|
274 | 'form_button' => 'form_button_script.tpl' |
---|
275 | ) |
---|
276 | ); |
---|
277 | $p->set_block('edit','edit_entry','edit_entry'); |
---|
278 | $p->set_block('edit','list','list'); |
---|
279 | $p->set_block('edit','hr','hr'); |
---|
280 | |
---|
281 | $vars = Array( |
---|
282 | 'font' => $this->theme['font'], |
---|
283 | 'bg_color' => $this->theme['bg_text'], |
---|
284 | 'action_url' => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update')), |
---|
285 | 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), |
---|
286 | 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" |
---|
287 | . '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n" |
---|
288 | . '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n" |
---|
289 | . ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n": |
---|
290 | (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')) |
---|
291 | . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? |
---|
292 | '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''), |
---|
293 | 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):''), |
---|
294 | 'row_owner' => '<input type="hidden" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'">' |
---|
295 | ); |
---|
296 | |
---|
297 | $p->set_var($vars); |
---|
298 | |
---|
299 | // Brief Description |
---|
300 | $var['title'] = Array( |
---|
301 | 'tr_color' => $this->theme['th_bg'], |
---|
302 | 'field' => lang('Title'), |
---|
303 | 'data' => '<input name="cal[title]" size="15" maxlength="80" value="'.$event['title'].'">' |
---|
304 | ); |
---|
305 | |
---|
306 | // Location |
---|
307 | $var['location'] = Array( |
---|
308 | 'field' => lang('Location'), |
---|
309 | 'data' => '<input name="cal[location]" size="15" maxlength="255" value="'.$event['location'].'">' |
---|
310 | ); |
---|
311 | |
---|
312 | // Date |
---|
313 | |
---|
314 | $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
315 | $var['startdate'] = Array( |
---|
316 | 'field' => lang('Start Date'), |
---|
317 | |
---|
318 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
319 | $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), |
---|
320 | $sb->getMonths('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), |
---|
321 | $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')), |
---|
322 | true |
---|
323 | ) |
---|
324 | |
---|
325 | // 'data' => $jscal->input('start[str]',$start) |
---|
326 | ); |
---|
327 | |
---|
328 | // Time |
---|
329 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
330 | { |
---|
331 | $str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
332 | . '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
333 | } |
---|
334 | $var['starttime'] = Array( |
---|
335 | 'field' => lang('Start Time'), |
---|
336 | 'data' => '<input name="start[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($start,$hourformat).'" maxlength="2">:<input name="start[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($start,'i').'" maxlength="2">'."\n".$str |
---|
337 | ); |
---|
338 | |
---|
339 | // End Date |
---|
340 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
341 | $var['enddate'] = Array( |
---|
342 | 'field' => lang('End Date'), |
---|
343 | |
---|
344 | 'data' => $GLOBALS['phpgw']->common->dateformatorder( |
---|
345 | $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), |
---|
346 | $sb->getMonths('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), |
---|
347 | $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')),true |
---|
348 | ) |
---|
349 | |
---|
350 | // 'data' => $jscal->input('end[str]',$end) |
---|
351 | ); |
---|
352 | |
---|
353 | // End Time |
---|
354 | if ($this->bo->prefs['common']['timeformat'] == '12') |
---|
355 | { |
---|
356 | $str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n" |
---|
357 | . '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n"; |
---|
358 | } |
---|
359 | $var['endtime'] = Array( |
---|
360 | 'field' => lang('End Time'), |
---|
361 | 'data' => '<input name="end[hour]" size="2" VALUE="'.$GLOBALS['phpgw']->common->show_date($end,$hourformat).'" maxlength="2">:<input name="end[min]" size="2" value="'.$GLOBALS['phpgw']->common->show_date($end,'i').'" maxlength="2">'."\n".$str |
---|
362 | ); |
---|
363 | |
---|
364 | |
---|
365 | $participants = $_SESSION['mobile_calendar']; |
---|
366 | $str = " "; |
---|
367 | foreach($participants as $id => $nome) { |
---|
368 | $str.="<option value='$id' selected>$nome</option>"; |
---|
369 | } |
---|
370 | |
---|
371 | |
---|
372 | $var['participants'] = array |
---|
373 | ( |
---|
374 | 'field' => lang('Participants'), |
---|
375 | 'data' => " |
---|
376 | <select id='user_list' name='participants[]' style='width: 220px' multiple size='5'>".$str."</select></center> |
---|
377 | <script src='../calendar/templates/celepar/js/edit.js' type='text/javascript'></script> |
---|
378 | " |
---|
379 | ); |
---|
380 | |
---|
381 | |
---|
382 | /*$var['owner'] = Array( |
---|
383 | 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), |
---|
384 | 'data' => '<input type="checkbox" name="participants[]" value="'.$event['owner'].$event['participants'][$event['owner']].'" checked read-only="true">' |
---|
385 | );*/ |
---|
386 | |
---|
387 | |
---|
388 | if (!isset($this->fields)) |
---|
389 | { |
---|
390 | $this->custom_fields = CreateObject('calendar.bocustom_fields'); |
---|
391 | $this->fields = &$this->custom_fields->fields; |
---|
392 | $this->stock_fields = &$this->custom_fields->stock_fields; |
---|
393 | } |
---|
394 | $preserved = False; |
---|
395 | foreach($this->fields as $field => $data) |
---|
396 | { |
---|
397 | /*if($field=='owner') |
---|
398 | $p->set_var('display',"visibility:hidden"); |
---|
399 | else |
---|
400 | $p->set_var('display'," ");*/ |
---|
401 | if (!$data['disabled']) |
---|
402 | { |
---|
403 | if (isset($var[$field])) |
---|
404 | { |
---|
405 | switch($field) |
---|
406 | { |
---|
407 | case 'startdate': |
---|
408 | $this->output_template_array($p,'row','list',$var['startdate']); |
---|
409 | $this->output_template_array($p,'row','list',$var['starttime']); |
---|
410 | break; |
---|
411 | case 'enddate': |
---|
412 | $this->output_template_array($p,'row','list',$var['enddate']); |
---|
413 | $this->output_template_array($p,'row','list',$var['endtime']); |
---|
414 | break; |
---|
415 | default: |
---|
416 | $this->output_template_array($p,'row','list',$var[$field]); |
---|
417 | } |
---|
418 | } |
---|
419 | elseif (!isset($this->stock_fields[$field])) // Custom field |
---|
420 | { |
---|
421 | $lang = lang($name = substr($field,1)); |
---|
422 | $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)). |
---|
423 | ' MAXLENGTH='.($data['length'] ? $data['length'] : 255); |
---|
424 | $v = array( |
---|
425 | 'field' => $lang == $name.'*' ? $name : $lang, |
---|
426 | 'data' => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">' |
---|
427 | ); |
---|
428 | if ($data['title']) |
---|
429 | { |
---|
430 | $v['tr_color'] = $this->theme['th_bg']; |
---|
431 | } |
---|
432 | if (!$data['length'] && $data['title']) |
---|
433 | { |
---|
434 | $p->set_var('tr_color',$this->theme['th_bg']); |
---|
435 | $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>'); |
---|
436 | $p->parse('row','hr',True); |
---|
437 | } |
---|
438 | else |
---|
439 | { |
---|
440 | $this->output_template_array($p,'row','list',$v); |
---|
441 | } |
---|
442 | } |
---|
443 | } |
---|
444 | else // preserve disabled fields |
---|
445 | { |
---|
446 | switch ($field) |
---|
447 | { |
---|
448 | case 'owner': |
---|
449 | $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A'; |
---|
450 | break; |
---|
451 | case 'recure_type': |
---|
452 | foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field) |
---|
453 | { |
---|
454 | $preserved[$field] = $event[$field]; |
---|
455 | } |
---|
456 | break; |
---|
457 | case 'startdate': |
---|
458 | case 'enddate': |
---|
459 | $field = substr($field,0,-4); |
---|
460 | default: |
---|
461 | $preserved[$field] = $event[$field]; |
---|
462 | } |
---|
463 | } |
---|
464 | } |
---|
465 | unset($var); |
---|
466 | if (is_array($preserved)) |
---|
467 | { |
---|
468 | //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n"; |
---|
469 | $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n"); |
---|
470 | } |
---|
471 | $p->set_var('submit_button',lang('Save')); |
---|
472 | |
---|
473 | |
---|
474 | |
---|
475 | $delete_button = $cancel_button = ''; |
---|
476 | if ($event['id'] > 0) |
---|
477 | { |
---|
478 | $var = Array( |
---|
479 | 'action_url_button' => $this->page('delete','&cal_id='.$event['id']), |
---|
480 | 'action_text_button' => lang('Delete'), |
---|
481 | 'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"", |
---|
482 | 'action_extra_field' => '' |
---|
483 | ); |
---|
484 | $p->set_var($var); |
---|
485 | $delete_button = $p->fp('out','form_button'); |
---|
486 | } |
---|
487 | $p->set_var('delete_button',$delete_button); |
---|
488 | |
---|
489 | if ($this->bo->return_to) |
---|
490 | { |
---|
491 | $var = Array( |
---|
492 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), |
---|
493 | 'action_text_button' => lang('Cancel'), |
---|
494 | 'action_confirm_button' => '', |
---|
495 | 'action_extra_field' => '' |
---|
496 | ); |
---|
497 | $p->set_var($var); |
---|
498 | $cancel_button = $p->fp('out','form_button'); |
---|
499 | } |
---|
500 | |
---|
501 | $p->set_var('lang_add_participants',lang("keep add participants")); |
---|
502 | |
---|
503 | $p->set_var('cancel_button',$cancel_button); |
---|
504 | $p->pparse('out','edit_entry'); |
---|
505 | |
---|
506 | } |
---|
507 | |
---|
508 | function get_organizations($context, $selected='', $recursive = false) |
---|
509 | { |
---|
510 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
511 | |
---|
512 | return ($recursive ? |
---|
513 | $s->get_organizations($context, $selected, false ,false) : |
---|
514 | $s->get_sectors($selected, false, false)); |
---|
515 | } |
---|
516 | |
---|
517 | function output_template_array(&$p,$row,$list,$var) |
---|
518 | { |
---|
519 | if (!isset($var['hidden_vars'])) |
---|
520 | { |
---|
521 | $var['hidden_vars'] = ''; |
---|
522 | } |
---|
523 | if (!isset($var['tr_color'])) |
---|
524 | { |
---|
525 | $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color(); |
---|
526 | } |
---|
527 | $p->set_var($var); |
---|
528 | $p->parse($row,$list,True); |
---|
529 | } |
---|
530 | |
---|
531 | function overlap($params) { |
---|
532 | ini_set("display_errors","1"); |
---|
533 | if(!is_array($params)) |
---|
534 | { |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | $overlapping_events = $params['o_events']; |
---|
539 | $event = $params['this_event']; |
---|
540 | } |
---|
541 | |
---|
542 | $month = $event['start']['month']; |
---|
543 | $mday = $event['start']['mday']; |
---|
544 | $year = $event['start']['year']; |
---|
545 | |
---|
546 | $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
547 | $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
548 | |
---|
549 | $overlap = ''; |
---|
550 | for($i=0;$i<count($overlapping_events);$i++) |
---|
551 | { |
---|
552 | $overlapped_event = $this->bo->read_entry($overlapping_events[$i],True); |
---|
553 | $overlap .= '<li>'.$this->link_to_entry($overlapped_event,$month,$mday,$year); |
---|
554 | $overlap .= '<ul>'; |
---|
555 | foreach($overlapped_event['participants'] as $id => $status) |
---|
556 | { |
---|
557 | $conflict = isset($event['participants'][$id]); |
---|
558 | $overlap .= '<li>'.($conflict?'<b>':''). |
---|
559 | $GLOBALS['phpgw']->common->grab_owner_name($id). |
---|
560 | ($conflict?'</b> - '.lang('Scheduling conflict'):'')."</li>\n"; |
---|
561 | } |
---|
562 | $overlap .= "</ul>\n"; |
---|
563 | } |
---|
564 | |
---|
565 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
566 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
567 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
568 | $GLOBALS['phpgw_info']['flags']['noappfooter'] = True; |
---|
569 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['calendar']['title'].' - '.lang('Scheduling Conflict'); |
---|
570 | //$GLOBALS['phpgw']->common->phpgw_header(); |
---|
571 | |
---|
572 | $p = $GLOBALS['phpgw']->template; |
---|
573 | $p->set_file( |
---|
574 | Array( |
---|
575 | 'overlap' => 'overlap.tpl', |
---|
576 | 'form_button' => 'form_button_script.tpl' |
---|
577 | ) |
---|
578 | ); |
---|
579 | |
---|
580 | $var = Array( |
---|
581 | 'color' => $this->theme['bg_text'], |
---|
582 | 'overlap_title' => lang('Scheduling Conflict'), |
---|
583 | '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)), |
---|
584 | 'overlap_list' => $overlap |
---|
585 | ); |
---|
586 | $p->set_var($var); |
---|
587 | |
---|
588 | $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); |
---|
589 | $var = Array( |
---|
590 | 'action_url_button' => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.update','readsess'=>1)), |
---|
591 | 'action_text_button' => lang('Ignore Conflict'), |
---|
592 | 'action_confirm_button' => '', |
---|
593 | 'action_extra_field' => '' |
---|
594 | ); |
---|
595 | $this->output_template_array($p,'resubmit_button','form_button',$var); |
---|
596 | |
---|
597 | $var = Array( |
---|
598 | 'action_url_button' => $GLOBALS['phpgw']->link('/mobile/index.php',Array('menuaction'=>'mobile.ui_mobilecalendar.edit','readsess'=>1,'date'=>$date)), |
---|
599 | 'action_text_button' => lang('Re-Edit Event'), |
---|
600 | 'action_confirm_button' => '', |
---|
601 | 'action_extra_field' => '' |
---|
602 | ); |
---|
603 | $this->output_template_array($p,'reedit_button','form_button',$var); |
---|
604 | $p->pparse('out','overlap'); |
---|
605 | } |
---|
606 | |
---|
607 | function link_to_entry($event,$month,$day,$year) |
---|
608 | { |
---|
609 | $str = ''; |
---|
610 | $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
611 | $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); |
---|
612 | |
---|
613 | $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
614 | $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
615 | $rawdate = mktime(0,0,0,$month,$day,$year); |
---|
616 | $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
617 | $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
618 | if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime) |
---|
619 | { |
---|
620 | $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
621 | } |
---|
622 | elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60) |
---|
623 | { |
---|
624 | $time = '[ '.lang('All Day').' ]'; |
---|
625 | } |
---|
626 | elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime) |
---|
627 | { |
---|
628 | if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE) |
---|
629 | { |
---|
630 | $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); |
---|
631 | } |
---|
632 | else |
---|
633 | { |
---|
634 | $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); |
---|
635 | } |
---|
636 | |
---|
637 | if($endtime >= ($rawdate_offset + 86400)) |
---|
638 | { |
---|
639 | $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat); |
---|
640 | } |
---|
641 | else |
---|
642 | { |
---|
643 | $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat); |
---|
644 | } |
---|
645 | $time = $start_time.'-'.$end_time; |
---|
646 | } |
---|
647 | else |
---|
648 | { |
---|
649 | $time = ''; |
---|
650 | } |
---|
651 | |
---|
652 | $texttitle = $texttime = $textdesc = $textlocation = $textstatus = ''; |
---|
653 | |
---|
654 | |
---|
655 | |
---|
656 | if(!$is_private) |
---|
657 | { |
---|
658 | //$text .= $this->bo->display_status($event['users_status']); |
---|
659 | |
---|
660 | // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation |
---|
661 | $textstatus=$this->bo->display_status($event['users_status']); |
---|
662 | |
---|
663 | } |
---|
664 | |
---|
665 | /* |
---|
666 | $text = '<nobr> '.$time.' </nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text. |
---|
667 | (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':''). |
---|
668 | $GLOBALS['phpgw']->browser->br; |
---|
669 | */ |
---|
670 | |
---|
671 | $texttime=$time; |
---|
672 | $texttitle=$this->bo->get_short_field($event,$is_private,'title'); |
---|
673 | $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):''); |
---|
674 | // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set |
---|
675 | $textlocation=$this->bo->get_short_field($event,$is_private,'location'); |
---|
676 | |
---|
677 | if ($viewable) |
---|
678 | { |
---|
679 | $date = sprintf('%04d%02d%02d',$year,$month,$day); |
---|
680 | $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); |
---|
681 | $this->link_tpl->set_var('lang_view',lang('View this entry')); |
---|
682 | $this->link_tpl->set_var('desc', $textdesc); |
---|
683 | $this->link_tpl->set_var('location', $textlocation); |
---|
684 | $this->link_tpl->parse('picture','link_open',True); |
---|
685 | } |
---|
686 | if (!$is_private) |
---|
687 | { |
---|
688 | if($event['priority'] == 3) |
---|
689 | { |
---|
690 | $picture[] = Array( |
---|
691 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), |
---|
692 | 'width' => 16, |
---|
693 | 'height'=> 16, |
---|
694 | 'title' => lang('high priority') |
---|
695 | ); |
---|
696 | } |
---|
697 | if($event['recur_type'] == MCAL_RECUR_NONE) |
---|
698 | { |
---|
699 | $picture[] = Array( |
---|
700 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), |
---|
701 | 'width' => 9, |
---|
702 | 'height'=> 9, |
---|
703 | 'title' => lang('single event') |
---|
704 | ); |
---|
705 | } |
---|
706 | else |
---|
707 | { |
---|
708 | $picture[] = Array( |
---|
709 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), |
---|
710 | 'width' => 12, |
---|
711 | 'height'=> 12, |
---|
712 | 'title' => lang('recurring event') |
---|
713 | ); |
---|
714 | } |
---|
715 | } |
---|
716 | $participants = $this->planner_participants($event['participants']); |
---|
717 | if(count($event['participants']) > 1) |
---|
718 | { |
---|
719 | $picture[] = Array( |
---|
720 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), |
---|
721 | 'width' => 14, |
---|
722 | 'height'=> 14, |
---|
723 | 'title' => $participants |
---|
724 | ); |
---|
725 | } |
---|
726 | else |
---|
727 | { |
---|
728 | $picture[] = Array( |
---|
729 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), |
---|
730 | 'width' => 14, |
---|
731 | 'height'=> 14, |
---|
732 | 'title' => $participants |
---|
733 | ); |
---|
734 | } |
---|
735 | if($event['public'] == 0) |
---|
736 | { |
---|
737 | $picture[] = Array( |
---|
738 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), |
---|
739 | 'width' => 13, |
---|
740 | 'height'=> 13, |
---|
741 | 'title' => lang('private') |
---|
742 | ); |
---|
743 | } |
---|
744 | if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
---|
745 | { |
---|
746 | // if the alarm is to go off the day before the event |
---|
747 | // the icon does not show up because of 'alarm_today' |
---|
748 | // - TOM |
---|
749 | if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) |
---|
750 | { |
---|
751 | $picture[] = Array( |
---|
752 | 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), |
---|
753 | 'width' => 13, |
---|
754 | 'height'=> 13, |
---|
755 | 'title' => lang('alarm') |
---|
756 | ); |
---|
757 | } |
---|
758 | } |
---|
759 | |
---|
760 | $description = $this->bo->get_short_field($event,$is_private,'description'); |
---|
761 | for($i=0;$i<count($picture);$i++) |
---|
762 | { |
---|
763 | $var = Array( |
---|
764 | 'pic_image' => $picture[$i]['pict'], |
---|
765 | 'width' => $picture[$i]['width'], |
---|
766 | 'height' => $picture[$i]['height'], |
---|
767 | 'title' => $picture[$i]['title'] |
---|
768 | ); |
---|
769 | $this->output_template_array($this->link_tpl,'picture','pict',$var); |
---|
770 | } |
---|
771 | if ($texttitle) |
---|
772 | { |
---|
773 | $var = Array( |
---|
774 | // 'text' => $text, |
---|
775 | 'time'=> $texttime, |
---|
776 | 'title'=> $texttitle, |
---|
777 | 'users_status'=>$textstatus, |
---|
778 | 'desc'=> $textdesc, |
---|
779 | 'location'=> "<br><b>Local:</b> ".$textlocation |
---|
780 | ); |
---|
781 | $this->output_template_array($this->link_tpl,'picture','link_text',$var); |
---|
782 | } |
---|
783 | |
---|
784 | if ($viewable) |
---|
785 | { |
---|
786 | $this->link_tpl->parse('picture','link_close',True); |
---|
787 | } |
---|
788 | $str = $this->link_tpl->fp('out','link_pict'); |
---|
789 | $this->link_tpl->set_var('picture',''); |
---|
790 | $this->link_tpl->set_var('out',''); |
---|
791 | // unset($p); |
---|
792 | return $str; |
---|
793 | } |
---|
794 | |
---|
795 | |
---|
796 | function planner_participants($parts) |
---|
797 | { |
---|
798 | static $id2lid; |
---|
799 | |
---|
800 | $names = ''; |
---|
801 | while (list($id,$status) = each($parts)) |
---|
802 | { |
---|
803 | $status = substr($this->bo->get_long_status($status),0,1); |
---|
804 | |
---|
805 | if (!isset($id2lid[$id])) |
---|
806 | { |
---|
807 | $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
808 | } |
---|
809 | if (strlen($names)) |
---|
810 | { |
---|
811 | $names .= ",\n"; |
---|
812 | } |
---|
813 | $names .= $id2lid[$id]." ($status)"; |
---|
814 | } |
---|
815 | if($this->debug) |
---|
816 | { |
---|
817 | echo '<!-- Inside participants() : '.$names.' -->'."\n"; |
---|
818 | } |
---|
819 | return $names; |
---|
820 | } |
---|
821 | |
---|
822 | |
---|
823 | } |
---|
824 | |
---|
825 | |
---|
826 | |
---|
827 | ?> |
---|