1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - infolog * |
---|
4 | * http://www.eGroupWare.org * |
---|
5 | * Maintained and further developed by RalfBecker@outdoor-training.de * |
---|
6 | * Based on Webinfolog 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 | if (@$GLOBALS['phpgw_info']['flags']['included_classes']['soinfolog_']) |
---|
18 | { |
---|
19 | return; |
---|
20 | } |
---|
21 | |
---|
22 | $GLOBALS['phpgw_info']['flags']['included_classes']['soinfolog_'] = True; |
---|
23 | |
---|
24 | class soinfolog_ extends soinfolog__ |
---|
25 | { |
---|
26 | var $deleted_events = Array(); |
---|
27 | |
---|
28 | var $cal_event; |
---|
29 | var $today = Array('raw','day','month','year','full','dow','dm','bd'); |
---|
30 | |
---|
31 | |
---|
32 | function soinfolog_() |
---|
33 | { |
---|
34 | $this->soinfolog__(); |
---|
35 | |
---|
36 | if (!is_object($GLOBALS['phpgw']->asyncservice)) |
---|
37 | { |
---|
38 | $GLOBALS['phpgw']->asyncservice = CreateObject('phpgwapi.asyncservice'); |
---|
39 | } |
---|
40 | $this->async = &$GLOBALS['phpgw']->asyncservice; |
---|
41 | } |
---|
42 | |
---|
43 | function open($infolog='',$user='',$passwd='',$options='') |
---|
44 | { |
---|
45 | if($user=='') |
---|
46 | { |
---|
47 | // settype($user,'integer'); |
---|
48 | $this->user = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
49 | } |
---|
50 | elseif(is_int($user)) |
---|
51 | { |
---|
52 | $this->user = $user; |
---|
53 | } |
---|
54 | elseif(is_string($user)) |
---|
55 | { |
---|
56 | $this->user = $GLOBALS['phpgw']->accounts->name2id($user); |
---|
57 | } |
---|
58 | |
---|
59 | $this->stream = $GLOBALS['phpgw']->db; |
---|
60 | return $this->stream; |
---|
61 | } |
---|
62 | |
---|
63 | function popen($infolog='',$user='',$passwd='',$options='') |
---|
64 | { |
---|
65 | return $this->open($infolog,$user,$passwd,$options); |
---|
66 | } |
---|
67 | |
---|
68 | function reopen($infolog,$options='') |
---|
69 | { |
---|
70 | return $this->stream; |
---|
71 | } |
---|
72 | |
---|
73 | function close($options='') |
---|
74 | { |
---|
75 | return True; |
---|
76 | } |
---|
77 | |
---|
78 | function create_infolog($infolog='') |
---|
79 | { |
---|
80 | return $infolog; |
---|
81 | } |
---|
82 | |
---|
83 | function rename_infolog($old_name='',$new_name='') |
---|
84 | { |
---|
85 | return $new_name; |
---|
86 | } |
---|
87 | |
---|
88 | function delete_infolog($infolog='') |
---|
89 | { |
---|
90 | $this->stream->query('SELECT info_id FROM phpgw_infolog WHERE info_id='.(int)$infolog,__LINE__,__FILE__); |
---|
91 | if($this->stream->num_rows()) |
---|
92 | { |
---|
93 | while($this->stream->next_record()) |
---|
94 | { |
---|
95 | $this->delete_event((int)$this->stream->f('info_id')); |
---|
96 | } |
---|
97 | $this->expunge(); |
---|
98 | } |
---|
99 | //$this->stream->lock(array('phpgw_cal_user')); |
---|
100 | //$this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_login='.(int)$infolog,__LINE__,__FILE__); |
---|
101 | //$this->stream->unlock(); |
---|
102 | |
---|
103 | return $infolog; |
---|
104 | } |
---|
105 | |
---|
106 | /*! |
---|
107 | @function read_alarms |
---|
108 | @abstract read the alarms of a infolog-event specified by $info_id |
---|
109 | @returns array of alarms with alarm-id as key |
---|
110 | @note the alarm-id is a string of 'cal:'.$info_id.':'.$alarm_nr, it is used as the job-id too |
---|
111 | */ |
---|
112 | function read_alarms($info_id) |
---|
113 | { |
---|
114 | $alarms = array(); |
---|
115 | |
---|
116 | if ($jobs = $this->async->read('cal:'.(int)$info_id.':%')) |
---|
117 | { |
---|
118 | foreach($jobs as $id => $job) |
---|
119 | { |
---|
120 | $alarm = $job['data']; // text, enabled |
---|
121 | $alarm['id'] = $id; |
---|
122 | $alarm['time'] = $job['next']; |
---|
123 | |
---|
124 | $alarms[$id] = $alarm; |
---|
125 | } |
---|
126 | } |
---|
127 | return $alarms; |
---|
128 | } |
---|
129 | |
---|
130 | /*! |
---|
131 | @function read_alarm |
---|
132 | @abstract read a single alarm specified by it's $id |
---|
133 | @returns array with data of the alarm |
---|
134 | @note the alarm-id is a string of 'cal:'.$info_id.':'.$alarm_nr, it is used as the job-id too |
---|
135 | */ |
---|
136 | function read_alarm($id) |
---|
137 | { |
---|
138 | if (!($jobs = $this->async->read($id))) |
---|
139 | { |
---|
140 | return False; |
---|
141 | } |
---|
142 | list($id,$job) = each($jobs); |
---|
143 | $alarm = $job['data']; // text, enabled |
---|
144 | $alarm['id'] = $id; |
---|
145 | $alarm['time'] = $job['next']; |
---|
146 | |
---|
147 | //echo "<p>read_alarm('$id')="; print_r($alarm); echo "</p>\n"; |
---|
148 | return $alarm; |
---|
149 | } |
---|
150 | |
---|
151 | /* Funcao save_alarm modificada para gerar alarmes repetidos, caso seja marcado um evento igualmente repetido. A funcao recebe qual o tipo |
---|
152 | de repeticao escolhido pelo usuario (diario, semanal, mensal, anual) e insere alarmes nas respectivas repeticoes do evento. */ |
---|
153 | /*! |
---|
154 | @function save_alarm |
---|
155 | @abstract saves a new or updated alarm |
---|
156 | @syntax save_alarm($info_id,$alarm,$id=False) |
---|
157 | @param $info_id Id of the infolog-entry |
---|
158 | @param $alarm array with fields: text, owner, enabled, .. |
---|
159 | @returns the id of the alarm |
---|
160 | */ |
---|
161 | function save_alarm($info_id,$alarm) |
---|
162 | { |
---|
163 | |
---|
164 | if (!($id = $alarm['id'])) |
---|
165 | { |
---|
166 | $alarm['time'] -= $GLOBALS['phpgw']->datetime->tz_offset; // time should be stored in server timezone |
---|
167 | $alarms = $this->read_alarms($info_id); // find a free alarm# |
---|
168 | |
---|
169 | if($alarm['repeat'] == 1) // repeticao do tipo "Diariamente"; |
---|
170 | { |
---|
171 | $n = 0; |
---|
172 | |
---|
173 | while(@isset($alarms[$id])); |
---|
174 | { |
---|
175 | |
---|
176 | $init_alarm = $alarm['init_rept']; |
---|
177 | $end_alarm = $alarm['end_rept']; |
---|
178 | |
---|
179 | if($end_alarm != 0) |
---|
180 | { |
---|
181 | while($init_alarm <= $end_alarm) |
---|
182 | { |
---|
183 | $id = 'cal:'.(int)$info_id.':'.$n; |
---|
184 | $n++; |
---|
185 | |
---|
186 | $alarm['info_id'] = $info_id; // we need the back-reference |
---|
187 | |
---|
188 | unset($alarm['repeat']); |
---|
189 | unset($alarm['init_rept']); |
---|
190 | unset($alarm['end_rept']); |
---|
191 | unset($alarm['rpt_wdays']); |
---|
192 | |
---|
193 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
194 | { |
---|
195 | return False; |
---|
196 | } |
---|
197 | |
---|
198 | $alarm['time'] += 86400; |
---|
199 | $init_alarm += 86400; |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | }elseif($alarm['repeat'] == 2) { // repeticao do tipo "Semanalmente"; |
---|
205 | |
---|
206 | $n = 0; |
---|
207 | |
---|
208 | $init_alarm = $data_atual = $alarm['init_rept']; |
---|
209 | $end_alarm = $alarm['end_rept']; |
---|
210 | |
---|
211 | $rpt_alarm_wdays = $alarm['rpt_wdays']; |
---|
212 | |
---|
213 | $divisor = 64; |
---|
214 | $quociente = 0; |
---|
215 | $resto = 0; |
---|
216 | |
---|
217 | $dia_semana = date("w",$init_alarm); |
---|
218 | |
---|
219 | switch($dia_semana) |
---|
220 | { |
---|
221 | case 0: |
---|
222 | $dia = array( |
---|
223 | 0 => 'domingo', |
---|
224 | 1 => 'segunda', |
---|
225 | 2 => 'terca', |
---|
226 | 3 => 'quarta', |
---|
227 | 4 => 'quinta', |
---|
228 | 5 => 'sexta', |
---|
229 | 6 => 'sabado' |
---|
230 | ); |
---|
231 | break; |
---|
232 | case 1: |
---|
233 | $dia = array( |
---|
234 | 0 => 'segunda', |
---|
235 | 1 => 'terca', |
---|
236 | 2 => 'quarta', |
---|
237 | 3 => 'quinta', |
---|
238 | 4 => 'sexta', |
---|
239 | 5 => 'sabado', |
---|
240 | 6 => 'domingo' |
---|
241 | ); |
---|
242 | break; |
---|
243 | case 2: |
---|
244 | $dia = array( |
---|
245 | 0 => 'terca', |
---|
246 | 1 => 'quarta', |
---|
247 | 2 => 'quinta', |
---|
248 | 3 => 'sexta', |
---|
249 | 4 => 'sabado', |
---|
250 | 5 => 'domingo', |
---|
251 | 6 => 'segunda' |
---|
252 | ); |
---|
253 | break; |
---|
254 | case 3: |
---|
255 | $dia = array( |
---|
256 | 0 => 'quarta', |
---|
257 | 1 => 'quinta', |
---|
258 | 2 => 'sexta', |
---|
259 | 3 => 'sabado', |
---|
260 | 4 => 'domingo', |
---|
261 | 5 => 'segunda', |
---|
262 | 6 => 'terca' |
---|
263 | ); |
---|
264 | break; |
---|
265 | case 4: |
---|
266 | $dia = array( |
---|
267 | 0 => 'quinta', |
---|
268 | 1 => 'sexta', |
---|
269 | 2 => 'sabado', |
---|
270 | 3 => 'domingo', |
---|
271 | 4 => 'segunda', |
---|
272 | 5 => 'terca', |
---|
273 | 6 => 'quarta' |
---|
274 | ); |
---|
275 | break; |
---|
276 | case 5: |
---|
277 | $dia = array( |
---|
278 | 0 => 'sexta', |
---|
279 | 1 => 'sabado', |
---|
280 | 2 => 'domingo', |
---|
281 | 3 => 'segunda', |
---|
282 | 4 => 'terca', |
---|
283 | 5 => 'quarta', |
---|
284 | 6 => 'quinta' |
---|
285 | ); |
---|
286 | break; |
---|
287 | case 6: |
---|
288 | $dia = array( |
---|
289 | 0 => 'sabado', |
---|
290 | 1 => 'domingo', |
---|
291 | 2 => 'segunda', |
---|
292 | 3 => 'terca', |
---|
293 | 4 => 'quarta', |
---|
294 | 5 => 'quinta', |
---|
295 | 6 => 'sexta' |
---|
296 | ); |
---|
297 | break; |
---|
298 | } |
---|
299 | |
---|
300 | |
---|
301 | $dias_semana = array( |
---|
302 | 64 => 'sabado', |
---|
303 | 32 => 'sexta', |
---|
304 | 16 => 'quinta', |
---|
305 | 8 => 'quarta', |
---|
306 | 4 => 'terca', |
---|
307 | 2 => 'segunda', |
---|
308 | 1 => 'domingo' |
---|
309 | ); |
---|
310 | |
---|
311 | $result = array(); |
---|
312 | do |
---|
313 | { |
---|
314 | |
---|
315 | $resto = ($rpt_alarm_wdays % $divisor); |
---|
316 | $quociente = floor($rpt_alarm_wdays / $divisor); |
---|
317 | |
---|
318 | if($quociente == 1) |
---|
319 | { |
---|
320 | $result[] = $dias_semana[$divisor]; |
---|
321 | |
---|
322 | $divisor = $divisor / 2; |
---|
323 | $rpt_alarm_wdays = $resto; |
---|
324 | |
---|
325 | }else { |
---|
326 | |
---|
327 | while($rpt_alarm_wdays < $divisor) |
---|
328 | { |
---|
329 | $divisor = $divisor / 2; |
---|
330 | } |
---|
331 | |
---|
332 | $resto = ($rpt_alarm_wdays % $divisor); |
---|
333 | $quociente = floor($rpt_alarm_wdays / $divisor); |
---|
334 | |
---|
335 | if($quociente == 1) |
---|
336 | { |
---|
337 | |
---|
338 | $result[] = $dias_semana[$divisor]; |
---|
339 | |
---|
340 | $divisor = $divisor / 2; |
---|
341 | $rpt_alarm_wdays = $resto; |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | } |
---|
346 | while($resto != 0); |
---|
347 | |
---|
348 | krsort($result); |
---|
349 | |
---|
350 | $week_num = 0; |
---|
351 | $y = 0; |
---|
352 | |
---|
353 | while(@isset($alarms[$id])); |
---|
354 | { |
---|
355 | |
---|
356 | if($end_alarm != 0) |
---|
357 | { |
---|
358 | |
---|
359 | while($data_atual <= $end_alarm) |
---|
360 | { |
---|
361 | |
---|
362 | foreach($dia as $index => $value) |
---|
363 | { |
---|
364 | if(in_array($value,$result)) |
---|
365 | { |
---|
366 | |
---|
367 | $nova_data = $init_alarm + (86400 * ($index + (7 * $y))); |
---|
368 | |
---|
369 | if($nova_data == $init_alarm){ |
---|
370 | |
---|
371 | continue; |
---|
372 | } |
---|
373 | |
---|
374 | $id = 'cal:'.(int)$info_id.':'.$n; |
---|
375 | $n++; |
---|
376 | |
---|
377 | $alarm['info_id'] = $info_id; // we need the back-reference |
---|
378 | |
---|
379 | unset($alarm['repeat']); |
---|
380 | unset($alarm['init_rept']); |
---|
381 | unset($alarm['end_rept']); |
---|
382 | unset($alarm['rpt_wdays']); |
---|
383 | |
---|
384 | $data_atual = $nova_data; |
---|
385 | |
---|
386 | if($data_atual > $end_alarm){ |
---|
387 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
388 | { |
---|
389 | return False; |
---|
390 | } |
---|
391 | break; |
---|
392 | } |
---|
393 | |
---|
394 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
395 | { |
---|
396 | return False; |
---|
397 | } |
---|
398 | $alarm['time'] = $nova_data - $alarm['offset'] - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
399 | } |
---|
400 | } |
---|
401 | $y++; |
---|
402 | } |
---|
403 | } |
---|
404 | } |
---|
405 | |
---|
406 | }elseif($alarm['repeat'] == 3) { // repeticao do tipo "Mensalmente (por data)"; |
---|
407 | |
---|
408 | $n = 0; |
---|
409 | |
---|
410 | $init_alarm = $alarm['init_rept']; |
---|
411 | $end_alarm = $alarm['end_rept']; |
---|
412 | |
---|
413 | while(@isset($alarms[$id])); |
---|
414 | { |
---|
415 | |
---|
416 | if($end_alarm != 0) |
---|
417 | { |
---|
418 | while($init_alarm <= $end_alarm) |
---|
419 | { |
---|
420 | |
---|
421 | $next_month = date("n",$init_alarm) + 1; |
---|
422 | $next_alarm = mktime(date("G",$alarm['time']),date("i",$alarm['time']),date("s",$alarm['time']),$next_month,date("j",$alarm['time']),date("Y",$alarm['time'])); |
---|
423 | |
---|
424 | $id = 'cal:'.(int)$info_id.':'.$n; |
---|
425 | $n++; |
---|
426 | |
---|
427 | $alarm['info_id'] = $info_id; // we need the back-reference |
---|
428 | |
---|
429 | unset($alarm['repeat']); |
---|
430 | unset($alarm['init_rept']); |
---|
431 | unset($alarm['end_rept']); |
---|
432 | unset($alarm['rpt_wdays']); |
---|
433 | |
---|
434 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
435 | { |
---|
436 | return False; |
---|
437 | } |
---|
438 | |
---|
439 | $alarm['time'] = $next_alarm; |
---|
440 | $init_alarm = $next_alarm; |
---|
441 | |
---|
442 | } |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | }elseif($alarm['repeat'] == 5) { // repeticao do tipo "Anualmente"; |
---|
447 | |
---|
448 | $n = 0; |
---|
449 | |
---|
450 | $init_alarm = $alarm['init_rept']; |
---|
451 | $end_alarm = $alarm['end_rept']; |
---|
452 | |
---|
453 | while(@isset($alarms[$id])); |
---|
454 | { |
---|
455 | |
---|
456 | |
---|
457 | if($end_alarm != 0) |
---|
458 | { |
---|
459 | while($init_alarm < $end_alarm) |
---|
460 | { |
---|
461 | |
---|
462 | $next_year = date("Y",$init_alarm) + 1; |
---|
463 | $next_alarm = mktime(date("G",$alarm['time']),date("i",$alarm['time']),date("s",$alarm['time']),date("n",$alarm['time']),date("j",$alarm['time']),$next_year); |
---|
464 | |
---|
465 | $id = 'cal:'.(int)$info_id.':'.$n; |
---|
466 | $n++; |
---|
467 | |
---|
468 | $alarm['info_id'] = $info_id; // we need the back-reference |
---|
469 | |
---|
470 | unset($alarm['repeat']); |
---|
471 | unset($alarm['init_rept']); |
---|
472 | unset($alarm['end_rept']); |
---|
473 | unset($alarm['rpt_wdays']); |
---|
474 | |
---|
475 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
476 | { |
---|
477 | return False; |
---|
478 | } |
---|
479 | |
---|
480 | $alarm['time'] = $next_alarm; |
---|
481 | $init_alarm = $next_alarm; |
---|
482 | } |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | }else { |
---|
487 | $alarm['time'] -= $GLOBALS['phpgw']->datetime->tz_offset; // time should be stored in server timezone |
---|
488 | $n = count($alarms); |
---|
489 | while(@isset($alarms[$id])); |
---|
490 | { |
---|
491 | |
---|
492 | $id = 'cal:'.(int)$info_id.':'.$n; |
---|
493 | |
---|
494 | unset($alarm['repeat']); |
---|
495 | unset($alarm['init_rept']); |
---|
496 | unset($alarm['end_rept']); |
---|
497 | unset($alarm['rpt_wdays']); |
---|
498 | |
---|
499 | $alarm['info_id'] = $info_id; // we need the back-reference |
---|
500 | if (!$this->async->set_timer($alarm['time'],$id,'infolog.boinfolog.send_alarm',$alarm)) |
---|
501 | { |
---|
502 | return False; |
---|
503 | } |
---|
504 | |
---|
505 | ++$n; |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | } |
---|
510 | else |
---|
511 | { |
---|
512 | $this->async->cancel_timer($id); |
---|
513 | } |
---|
514 | $alarm['time'] -= $GLOBALS['phpgw']->datetime->tz_offset; // time should be stored in server timezone |
---|
515 | return $id; |
---|
516 | } |
---|
517 | |
---|
518 | /*! |
---|
519 | @function delete_alarms($info_id) |
---|
520 | @abstract delete all alarms of a infolog-entry |
---|
521 | @returns the number of alarms deleted |
---|
522 | */ |
---|
523 | function delete_alarms($info_id) |
---|
524 | { |
---|
525 | $alarms = $this->read_alarms($info_id); |
---|
526 | |
---|
527 | foreach($alarms as $id => $alarm) |
---|
528 | { |
---|
529 | $this->async->cancel_timer($id); |
---|
530 | } |
---|
531 | return count($alarms); |
---|
532 | } |
---|
533 | |
---|
534 | /*! |
---|
535 | @function delete_alarm($id) |
---|
536 | @abstract delete one alarms identified by its id |
---|
537 | @returns the number of alarms deleted |
---|
538 | */ |
---|
539 | function delete_alarm($id) |
---|
540 | { |
---|
541 | return $this->async->cancel_timer($id); |
---|
542 | } |
---|
543 | |
---|
544 | function fetch_event($event_id,$options='') |
---|
545 | { |
---|
546 | if(!isset($this->stream)) |
---|
547 | { |
---|
548 | return False; |
---|
549 | } |
---|
550 | |
---|
551 | $event_id = (int)$event_id; |
---|
552 | |
---|
553 | $this->stream->lock(array('phpgw_infolog'/* OLD-ALARM,'phpgw_cal_alarm'*/)); |
---|
554 | |
---|
555 | $this->stream->query('SELECT * FROM phpgw_infolog WHERE info_id='.$event_id,__LINE__,__FILE__); |
---|
556 | |
---|
557 | if($this->stream->num_rows() > 0) |
---|
558 | { |
---|
559 | $this->event_init(); |
---|
560 | //echo "<br>aqui paso"."SELECT * FROM phpgw_infolog WHERE info_id='".$event_id; |
---|
561 | //echo "<br>Aa".__LINE__.",".__FILE__; |
---|
562 | $this->stream->next_record(); |
---|
563 | // Load the infolog event data from the db into $event structure |
---|
564 | // Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference |
---|
565 | $this->add_attribute('owner',(int)$this->stream->f('owner')); |
---|
566 | $this->add_attribute('id',(int)$this->stream->f('info_id')); |
---|
567 | $this->add_attribute('type',$this->stream->f('info_type')); |
---|
568 | $this->set_class((int)$this->stream->f('info_access')); |
---|
569 | $this->set_category($this->stream->f('info_cat')); |
---|
570 | $this->set_title(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('info_subject')))); |
---|
571 | $this->set_description(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('info_des')))); |
---|
572 | $this->set_ex_participants(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('info_custom_from')))); |
---|
573 | $this->add_attribute('uid',$GLOBALS['phpgw']->strip_html($this->stream->f('info_uid'))); |
---|
574 | $this->add_attribute('location',stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('info_location')))); |
---|
575 | $this->add_attribute('reference',(int)$this->stream->f('info_status')); |
---|
576 | |
---|
577 | // This is the preferred method once everything is normalized... |
---|
578 | //$this->event->alarm = (int)$this->stream->f('alarm'); |
---|
579 | // But until then, do it this way... |
---|
580 | //Legacy Support (New) |
---|
581 | |
---|
582 | $datetime = $GLOBALS['phpgw']->datetime->localdates($this->stream->f('datetime')); |
---|
583 | $this->set_start($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); |
---|
584 | |
---|
585 | $datetime = $GLOBALS['phpgw']->datetime->localdates($this->stream->f('mdatetime')); |
---|
586 | $this->set_date('modtime',$datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); |
---|
587 | |
---|
588 | $datetime = $GLOBALS['phpgw']->datetime->localdates($this->stream->f('edatetime')); |
---|
589 | $this->set_end($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); |
---|
590 | |
---|
591 | //Legacy Support |
---|
592 | $this->add_attribute('priority',(int)$this->stream->f('priority')); |
---|
593 | if($this->stream->f('cal_group') || $this->stream->f('groups') != 'NULL') |
---|
594 | { |
---|
595 | $groups = explode(',',$this->stream->f('groups')); |
---|
596 | for($j=1;$j<count($groups) - 1;$j++) |
---|
597 | { |
---|
598 | $this->add_attribute('groups',$groups[$j],$j-1); |
---|
599 | } |
---|
600 | } |
---|
601 | |
---|
602 | |
---|
603 | |
---|
604 | |
---|
605 | } |
---|
606 | else |
---|
607 | { |
---|
608 | $this->event = False; |
---|
609 | } |
---|
610 | |
---|
611 | $this->stream->unlock(); |
---|
612 | |
---|
613 | if ($this->event) |
---|
614 | { |
---|
615 | $this->event['alarm'] = $this->read_alarms($event_id); |
---|
616 | |
---|
617 | if($this->event['reference']) |
---|
618 | { |
---|
619 | $this->event['alarm'] += $this->read_alarms($event_id); |
---|
620 | } |
---|
621 | } |
---|
622 | echo "<br>aqui pasollll". $this->event."<br>"; |
---|
623 | return $this->event; |
---|
624 | } |
---|
625 | |
---|
626 | function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0,$extra='',$tz_offset=0,$owner_id=0) |
---|
627 | { |
---|
628 | |
---|
629 | echo "entro?"; |
---|
630 | if(!isset($this->stream)) |
---|
631 | { |
---|
632 | return False; |
---|
633 | } |
---|
634 | |
---|
635 | $datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - $tz_offset; |
---|
636 | |
---|
637 | $user_where = ' AND (phpgw_infolog.info_owner in ('; |
---|
638 | if(is_array($owner_id) && count($owner_id)) |
---|
639 | { |
---|
640 | $user_where .= implode(',',$owner_id); |
---|
641 | } |
---|
642 | else |
---|
643 | { |
---|
644 | $user_where .= $this->user; |
---|
645 | } |
---|
646 | $member_groups = $GLOBALS['phpgw']->accounts->membership($this->user); |
---|
647 | @reset($member_groups); |
---|
648 | while($member_groups != False && list($key,$group_info) = each($member_groups)) |
---|
649 | { |
---|
650 | $member[] = $group_info['account_id']; |
---|
651 | } |
---|
652 | @reset($member); |
---|
653 | // $user_where .= ','.implode(',',$member); |
---|
654 | $user_where .= ')) '; |
---|
655 | |
---|
656 | if($this->debug) |
---|
657 | { |
---|
658 | echo '<!-- '.$user_where.' -->'."\n"; |
---|
659 | } |
---|
660 | |
---|
661 | // $startDate = 'AND ( ( (phpgw_cal.datetime >= '.$datetime.') '; |
---|
662 | |
---|
663 | $enddate = ''; |
---|
664 | /*if($endYear != 0 && $endMonth != 0 && $endDay != 0) |
---|
665 | { |
---|
666 | $edatetime = mktime(23,59,59,(int)$endMonth,(int)$endDay,(int)$endYear) - $tz_offset; |
---|
667 | $endDate .= 'AND (phpgw_cal.edatetime <= '.$edatetime.') ) ' |
---|
668 | . 'OR ( (phpgw_cal.datetime <= '.$datetime.') ' |
---|
669 | . 'AND (phpgw_cal.edatetime >= '.$edatetime.') ) ' |
---|
670 | . 'OR ( (phpgw_cal.datetime >= '.$datetime.') ' |
---|
671 | . 'AND (phpgw_cal.datetime <= '.$edatetime.') ' |
---|
672 | . 'AND (phpgw_cal.edatetime >= '.$edatetime.') ) ' |
---|
673 | . 'OR ( (phpgw_cal.datetime <= '.$datetime.') ' |
---|
674 | . 'AND (phpgw_cal.edatetime >= '.$datetime.') ' |
---|
675 | . 'AND (phpgw_cal.edatetime <= '.$edatetime.') '; |
---|
676 | }*/ |
---|
677 | $endDate .= ') ) '; |
---|
678 | |
---|
679 | $order_by = 'ORDER BY phpgw_infolog.info_datemodified ASC, phpgw_infolog.priority ASC'; |
---|
680 | if($this->debug) |
---|
681 | { |
---|
682 | echo "SQL : ".$user_where.$startDate.$endDate.$extra."<br>\n"; |
---|
683 | } |
---|
684 | |
---|
685 | return $this->get_event_ids(False,$user_where.$startDate.$endDate.$extra.$order_by); |
---|
686 | } |
---|
687 | |
---|
688 | function append_event() |
---|
689 | { |
---|
690 | $this->save_event($this->event); |
---|
691 | $this->send_update(MSG_ADDED,$this->event->participants,'',$this->event); |
---|
692 | return $this->event['id']; |
---|
693 | } |
---|
694 | |
---|
695 | function store_event() |
---|
696 | { |
---|
697 | return $this->save_event(&$this->event); |
---|
698 | } |
---|
699 | |
---|
700 | function delete_event($event_id) |
---|
701 | { |
---|
702 | $this->deleted_events[] = $event_id; |
---|
703 | } |
---|
704 | |
---|
705 | function snooze($event_id) |
---|
706 | { |
---|
707 | //Turn off an alarm for an event |
---|
708 | //Returns true. |
---|
709 | } |
---|
710 | |
---|
711 | function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') |
---|
712 | { |
---|
713 | //Return a list of events that has an alarm triggered at the given datetime |
---|
714 | //Returns an array of event ID's |
---|
715 | } |
---|
716 | |
---|
717 | // The function definition doesn't look correct... |
---|
718 | // Need more information for this function |
---|
719 | function next_recurrence($weekstart,$next) |
---|
720 | { |
---|
721 | // return next_recurrence (int stream, int weekstart, array next); |
---|
722 | } |
---|
723 | |
---|
724 | function expunge() |
---|
725 | { |
---|
726 | if(count($this->deleted_events) <= 0) |
---|
727 | { |
---|
728 | return 1; |
---|
729 | } |
---|
730 | $this_event = $this->event; |
---|
731 | $locks = Array( |
---|
732 | 'phpgw_infolog' |
---|
733 | // OLD-ALARM 'phpgw_cal_alarm' |
---|
734 | ); |
---|
735 | $this->stream->lock($locks); |
---|
736 | foreach($this->deleted_events as $info_id) |
---|
737 | { |
---|
738 | foreach ($locks as $table) |
---|
739 | { |
---|
740 | $this->stream->query('DELETE FROM '.$table.' WHERE info_id='.$info_id,__LINE__,__FILE__); |
---|
741 | } |
---|
742 | } |
---|
743 | $this->stream->unlock(); |
---|
744 | |
---|
745 | foreach($this->deleted_events as $info_id) |
---|
746 | { |
---|
747 | $this->delete_alarms($info_id); |
---|
748 | } |
---|
749 | $this->deleted_events = array(); |
---|
750 | |
---|
751 | $this->event = $this_event; |
---|
752 | return 1; |
---|
753 | } |
---|
754 | |
---|
755 | /***************** Local functions for SQL based infolog *****************/ |
---|
756 | |
---|
757 | function get_event_ids($search_repeats=False,$extra='',$search_extra=False) |
---|
758 | { |
---|
759 | $from = $where = ' '; |
---|
760 | /*if($search_repeats) |
---|
761 | { |
---|
762 | $from = ', phpgw_cal_repeats '; |
---|
763 | $where = 'AND (phpgw_cal_repeats.info_id = phpgw_cal.info_id) '; |
---|
764 | } |
---|
765 | if($search_extra) |
---|
766 | { |
---|
767 | $from .= 'LEFT JOIN phpgw_cal_extra ON phpgw_cal_extra.info_id = phpgw_cal.info_id '; |
---|
768 | }*/ |
---|
769 | |
---|
770 | $sql = 'SELECT DISTINCT info_id, info_type, |
---|
771 | info_from,info_subject,info_owner,info_datemodified,info_startdate, info_enddate,info_uid, |
---|
772 | info_priority ' |
---|
773 | . 'FROM phpgw_infolog' |
---|
774 | . $from; |
---|
775 | //. 'WHERE (phpgw_cal_user.info_id = phpgw_cal.info_id) ' |
---|
776 | //. $where . $extra; |
---|
777 | |
---|
778 | //echo "SQL : ".$sql ."<br>\n"; |
---|
779 | |
---|
780 | if($this->debug) |
---|
781 | { |
---|
782 | echo "FULL SQL : ".$sql."<br>\n"; |
---|
783 | } |
---|
784 | |
---|
785 | $this->stream->query($sql,__LINE__,__FILE__); |
---|
786 | |
---|
787 | $retval = Array(); |
---|
788 | if($this->stream->num_rows() == 0) |
---|
789 | { |
---|
790 | if($this->debug) |
---|
791 | { |
---|
792 | echo "No records found!<br>\n"; |
---|
793 | } |
---|
794 | return $retval; |
---|
795 | } |
---|
796 | |
---|
797 | while($this->stream->next_record()) |
---|
798 | { |
---|
799 | $retval[] = (int)$this->stream->f('info_id'); |
---|
800 | } |
---|
801 | if($this->debug) |
---|
802 | { |
---|
803 | echo "Records found!<br>\n"; |
---|
804 | } |
---|
805 | return $retval; |
---|
806 | } |
---|
807 | |
---|
808 | function save_event(&$event) |
---|
809 | { |
---|
810 | |
---|
811 | $edatetime = mktime(23,59,59,(int)$endMonth,(int)$endDay,(int)$endYear) - $tz_offset; |
---|
812 | |
---|
813 | $GLOBALS['infolog']->boinfolog = CreateObject('infolog.boinfolog'); |
---|
814 | |
---|
815 | $locks = Array( |
---|
816 | 'phpgw_infolog' |
---|
817 | // OLD-ALARM 'phpgw_cal_alarm' |
---|
818 | ); |
---|
819 | $this->stream->lock($locks); |
---|
820 | if($event['id'] == 0) |
---|
821 | { |
---|
822 | if(!$event['uid']) |
---|
823 | { |
---|
824 | if ($GLOBALS['phpgw_info']['server']['hostname'] != '') |
---|
825 | { |
---|
826 | $id_suffix = $GLOBALS['phpgw_info']['server']['hostname']; |
---|
827 | } |
---|
828 | else |
---|
829 | { |
---|
830 | $id_suffix = $GLOBALS['phpgw']->common->randomstring(3).'local'; |
---|
831 | } |
---|
832 | $parts = Array( |
---|
833 | 0 => 'title', |
---|
834 | 1 => 'description', |
---|
835 | 2 => 'ex_participants' |
---|
836 | ); |
---|
837 | @reset($parts); |
---|
838 | while(list($key,$field) = each($parts)) |
---|
839 | { |
---|
840 | $part[$key] = substr($GLOBALS['phpgw']->crypto->encrypt($event[$field]),0,20); |
---|
841 | if(!$GLOBALS['phpgw']->crypto->enabled) |
---|
842 | { |
---|
843 | $part[$key] = bin2hex(unserialize($part[$key])); |
---|
844 | } |
---|
845 | } |
---|
846 | $event['uid'] = $part[0].'-'.$part[1].'@'.$id_suffix; |
---|
847 | } |
---|
848 | |
---|
849 | |
---|
850 | |
---|
851 | |
---|
852 | $this->stream->query('INSERT INTO phpgw_infolog(info_type,info_from,info_addr,info_subject,info_des,info_owner,info_responsible,info_cat,info_datemodified) ' |
---|
853 | . "values('".$event['title']."','". $event['participants']."','','". $this->stream->db_addslashes($event['description1'])."','". $this->stream->db_addslashes($event['description'])."',". $event['owner'].",'". $event['owner']."',0,".$edatetime.")",__LINE__,__FILE__); |
---|
854 | $event['id'] = $this->stream->get_last_insert_id('phpgw_cal','info_id'); |
---|
855 | $last_status = true; |
---|
856 | } |
---|
857 | |
---|
858 | $date = $this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
859 | $enddate = $this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
860 | $today = time() - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
861 | |
---|
862 | if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
863 | { |
---|
864 | $type = 'M'; |
---|
865 | } |
---|
866 | else |
---|
867 | { |
---|
868 | if ($event['type'] == 'hourAppointment') |
---|
869 | $type = 'H'; |
---|
870 | else if($event['type'] == 'privateHiddenFields'){ |
---|
871 | $type = 'P'; |
---|
872 | }else |
---|
873 | $type = 'E'; |
---|
874 | } |
---|
875 | |
---|
876 | $sql = 'UPDATE phpgw_cal SET ' |
---|
877 | . 'owner='.(int)$event['owner'].', ' |
---|
878 | . 'datetime='.(int)$date.', ' |
---|
879 | . 'mdatetime='.(int)$today.', ' |
---|
880 | . 'edatetime='.(int)$enddate.', ' |
---|
881 | . 'priority='.(int)$event['priority'].', ' |
---|
882 | . "category='".$this->stream->db_addslashes($event['category'])."', " |
---|
883 | . "cal_type='".$this->stream->db_addslashes($type)."', " |
---|
884 | . 'is_public='.(int)$event['public'].', ' |
---|
885 | . "title='".$this->stream->db_addslashes($event['title'])."', " |
---|
886 | . "description='".$this->stream->db_addslashes($event['description'])."', " |
---|
887 | . "ex_participants='".$this->stream->db_addslashes($event['ex_participants'])."', " |
---|
888 | . "location='".$this->stream->db_addslashes($event['location'])."', " |
---|
889 | . ($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."', ":'') |
---|
890 | . 'reference='.(int)$event['reference'].' ' |
---|
891 | . ',last_status = '.($last_status ? "'N'" : "'U'").',last_update = '.time()."000". ' ' |
---|
892 | . 'WHERE info_id='.(int)$event['id']; |
---|
893 | |
---|
894 | $this->stream->query($sql,__LINE__,__FILE__); |
---|
895 | |
---|
896 | $this->stream->query('DELETE FROM phpgw_infolog WHERE info_id='.(int)$event['id'],__LINE__,__FILE__); |
---|
897 | |
---|
898 | @reset($event['participants']); |
---|
899 | /*while (list($key,$value) = @each($event['participants'])) |
---|
900 | { |
---|
901 | if((int)$key == $event['owner']) |
---|
902 | { |
---|
903 | $value = 'A'; |
---|
904 | } |
---|
905 | $this->stream->query('INSERT INTO phpgw_cal_user(info_id,cal_login,cal_status) ' |
---|
906 | . 'VALUES('.(int)$event['id'].','.(int)$key.",'".$this->stream->db_addslashes($value)."')",__LINE__,__FILE__); |
---|
907 | }*/ |
---|
908 | |
---|
909 | /*if($event['recur_type'] != MCAL_RECUR_NONE) |
---|
910 | { |
---|
911 | if($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) |
---|
912 | { |
---|
913 | $end = $this->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
914 | } |
---|
915 | else |
---|
916 | { |
---|
917 | $end = 0; |
---|
918 | } |
---|
919 | |
---|
920 | $this->stream->query('SELECT count(info_id) FROM phpgw_cal_repeats WHERE info_id='.(int)$event['id'],__LINE__,__FILE__); |
---|
921 | $this->stream->next_record(); |
---|
922 | $num_rows = $this->stream->f(0); |
---|
923 | if($num_rows == 0) |
---|
924 | { |
---|
925 | $this->stream->query('INSERT INTO phpgw_cal_repeats(info_id,recur_type,recur_enddate,recur_data,recur_interval) ' |
---|
926 | .'VALUES('.(int)$event['id'].','.$event['recur_type'].','.(int)$end.','.$event['recur_data'].','.$event['recur_interval'].')',__LINE__,__FILE__); |
---|
927 | } |
---|
928 | else |
---|
929 | { |
---|
930 | $this->stream->query('UPDATE phpgw_cal_repeats ' |
---|
931 | . 'SET recur_type='.$event['recur_type'].', ' |
---|
932 | . 'recur_enddate='.(int)$end.', ' |
---|
933 | . 'recur_data='.$event['recur_data'].', ' |
---|
934 | . 'recur_interval='.$event['recur_interval'].', ' |
---|
935 | . "recur_exception='".(count($event['recur_exception'])>1?implode(',',$event['recur_exception']):(count($event['recur_exception'])==1?$event['recur_exception'][0]:''))."' " |
---|
936 | . 'WHERE info_id='.$event['id'],__LINE__,__FILE__); |
---|
937 | } |
---|
938 | |
---|
939 | } |
---|
940 | else |
---|
941 | { |
---|
942 | $this->stream->query('DELETE FROM phpgw_cal_repeats WHERE info_id='.$event['id'],__LINE__,__FILE__); |
---|
943 | }*/ |
---|
944 | // Custom fields |
---|
945 | /*$this->stream->query('DELETE FROM phpgw_cal_extra WHERE info_id='.$event['id'],__LINE__,__FILE__); |
---|
946 | |
---|
947 | foreach($event as $name => $value) |
---|
948 | { |
---|
949 | if ($name[0] == '#' && strlen($value)) |
---|
950 | { |
---|
951 | $this->stream->query('INSERT INTO phpgw_cal_extra (info_id,cal_extra_name,cal_extra_value) ' |
---|
952 | . 'VALUES('.$event['id'].",'".addslashes(substr($name,1))."','".addslashes($value)."')",__LINE__,__FILE__); |
---|
953 | } |
---|
954 | }*/ |
---|
955 | /* |
---|
956 | $alarmcount = count($event['alarm']); |
---|
957 | if ($alarmcount > 1) |
---|
958 | { |
---|
959 | // this should never happen, $event['alarm'] should only be set |
---|
960 | // if creating a new event and uiinfolog only sets up 1 alarm |
---|
961 | // the user must use "Alarm Management" to create/establish multiple |
---|
962 | // alarms or to edit/change an alarm |
---|
963 | echo '<!-- how did this happen, too many alarms -->'."\n"; |
---|
964 | $this->stream->unlock(); |
---|
965 | return True; |
---|
966 | } |
---|
967 | |
---|
968 | if ($alarmcount == 1) |
---|
969 | { |
---|
970 | |
---|
971 | list($key,$alarm) = @each($event['alarm']); |
---|
972 | |
---|
973 | $this->stream->query('INSERT INTO phpgw_cal_alarm(info_id,cal_owner,cal_time,cal_text,alarm_enabled) VALUES('.$event['id'].','.$event['owner'].','.$alarm['time'].",'".$alarm['text']."',".$alarm['enabled'].')',__LINE__,__FILE__); |
---|
974 | $this->stream->query('SELECT LAST_INSERT_ID()'); |
---|
975 | $this->stream->next_record(); |
---|
976 | $alarm['id'] = $this->stream->f(0); |
---|
977 | } |
---|
978 | */ |
---|
979 | print_debug('Event Saved: ID #',$event['id']); |
---|
980 | |
---|
981 | $this->stream->unlock(); |
---|
982 | |
---|
983 | if (is_array($event['alarm'])) |
---|
984 | { |
---|
985 | foreach ($event['alarm'] as $alarm) // this are all new alarms |
---|
986 | { |
---|
987 | $this->save_alarm($event['id'],$alarm); |
---|
988 | } |
---|
989 | } |
---|
990 | $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; |
---|
991 | $this->event = $event; |
---|
992 | return True; |
---|
993 | } |
---|
994 | |
---|
995 | function get_alarm($info_id) |
---|
996 | { |
---|
997 | /* OLD-ALARM |
---|
998 | $this->stream->query('SELECT cal_time, cal_text FROM phpgw_cal_alarm WHERE info_id='.$id.' AND cal_owner='.$this->user,__LINE__,__FILE__); |
---|
999 | if($this->stream->num_rows()) |
---|
1000 | { |
---|
1001 | while($this->stream->next_record()) |
---|
1002 | { |
---|
1003 | $alarm[$this->stream->f('cal_time')] = $this->stream->f('cal_text'); |
---|
1004 | } |
---|
1005 | @reset($alarm); |
---|
1006 | return $alarm; |
---|
1007 | } |
---|
1008 | else |
---|
1009 | { |
---|
1010 | return False; |
---|
1011 | } |
---|
1012 | */ |
---|
1013 | $alarms = $this->read_alarms($info_id); |
---|
1014 | $ret = False; |
---|
1015 | |
---|
1016 | foreach($alarms as $alarm) |
---|
1017 | { |
---|
1018 | if ($alarm['owner'] == $this->user || !$alarm['owner']) |
---|
1019 | { |
---|
1020 | $ret[$alarm['time']] = $alarm['text']; |
---|
1021 | } |
---|
1022 | } |
---|
1023 | return $ret; |
---|
1024 | } |
---|
1025 | |
---|
1026 | function set_status($id,$owner,$status) |
---|
1027 | { |
---|
1028 | $status_code_short = Array( |
---|
1029 | REJECTED => 'R', |
---|
1030 | NO_RESPONSE => 'U', |
---|
1031 | TENTATIVE => 'T', |
---|
1032 | ACCEPTED => 'A' |
---|
1033 | ); |
---|
1034 | |
---|
1035 | $this->stream->query("UPDATE phpgw_infolog SET info_status='".$status_code_short[$status]."' WHERE info_id=".$id." AND info_owner=".$owner,__LINE__,__FILE__); |
---|
1036 | /* OLD-ALARM |
---|
1037 | if ($status == 'R') |
---|
1038 | { |
---|
1039 | $this->stream->query('UPDATE phpgw_cal_alarm set alarm_enabled=0 where info_id='.$id.' and cal_owner='.$owner,__LINE__,__FILE__); |
---|
1040 | } |
---|
1041 | */ |
---|
1042 | return True; |
---|
1043 | } |
---|
1044 | |
---|
1045 | // End of ICal style support....... |
---|
1046 | |
---|
1047 | function group_search($owner=0) |
---|
1048 | { |
---|
1049 | $owner = ($owner==$GLOBALS['phpgw_info']['user']['account_id']?0:$owner); |
---|
1050 | /*$groups = substr($GLOBALS['phpgw']->common->sql_search('phpgw_cal.groups',(int)$owner),4); |
---|
1051 | if (!$groups) |
---|
1052 | { |
---|
1053 | return ''; |
---|
1054 | } |
---|
1055 | else |
---|
1056 | { |
---|
1057 | return "(phpgw_cal.is_public=2 AND (". $groups .')) '; |
---|
1058 | }*/ |
---|
1059 | return ''; |
---|
1060 | } |
---|
1061 | |
---|
1062 | function splittime_($time) |
---|
1063 | { |
---|
1064 | $temp = array('hour','minute','second','ampm'); |
---|
1065 | $time = strrev($time); |
---|
1066 | $second = (int)strrev(substr($time,0,2)); |
---|
1067 | $minute = (int)strrev(substr($time,2,2)); |
---|
1068 | $hour = (int)strrev(substr($time,4)); |
---|
1069 | $temp['second'] = (int)$second; |
---|
1070 | $temp['minute'] = (int)$minute; |
---|
1071 | $temp['hour'] = (int)$hour; |
---|
1072 | $temp['ampm'] = ' '; |
---|
1073 | |
---|
1074 | return $temp; |
---|
1075 | } |
---|
1076 | |
---|
1077 | function date_to_epoch($d) |
---|
1078 | { |
---|
1079 | return $this->localdates(mktime(0,0,0,(int)(substr($d,4,2)),(int)(substr($d,6,2)),(int)(substr($d,0,4)))); |
---|
1080 | } |
---|
1081 | |
---|
1082 | function list_dirty_events($lastmod=-1,$repeats=false) |
---|
1083 | { |
---|
1084 | /*if(!isset($this->stream)) |
---|
1085 | { |
---|
1086 | return False; |
---|
1087 | } |
---|
1088 | $lastmod = (int) $lastmod; |
---|
1089 | $repeats = (bool) $repeats; |
---|
1090 | |
---|
1091 | $user_where = " AND phpgw_cal_user.cal_login = $this->user"; |
---|
1092 | |
---|
1093 | $member_groups = $GLOBALS['phpgw']->accounts->membership($this->user); |
---|
1094 | @reset($member_groups); |
---|
1095 | while($member_groups != False && list($key,$group_info) = each($member_groups)) |
---|
1096 | { |
---|
1097 | $member[] = $group_info['account_id']; |
---|
1098 | } |
---|
1099 | @reset($member); |
---|
1100 | // $user_where .= ','.implode(',',$member); |
---|
1101 | //$user_where .= ')) '; |
---|
1102 | |
---|
1103 | if($this->debug) |
---|
1104 | { |
---|
1105 | echo '<!-- '.$user_where.' -->'."\n"; |
---|
1106 | } |
---|
1107 | |
---|
1108 | if($lastmod > 0) |
---|
1109 | { |
---|
1110 | $wheremod = "AND mdatetime = $lastmod"; |
---|
1111 | } |
---|
1112 | |
---|
1113 | $order_by = ' ORDER BY phpgw_cal.info_id ASC'; |
---|
1114 | if($this->debug) |
---|
1115 | { |
---|
1116 | echo "SQL : ".$user_where.$wheremod.$extra."<br>\n"; |
---|
1117 | } |
---|
1118 | return $this->get_event_ids($repeats,$user_where.$wheremod.$extra.$order_by);*/ |
---|
1119 | return ''; |
---|
1120 | } |
---|
1121 | |
---|
1122 | /* OLD-ALARM |
---|
1123 | function add_alarm($eventid,$alarm,$owner) |
---|
1124 | { |
---|
1125 | $this->stream->query('INSERT INTO phpgw_cal_alarm(info_id,cal_owner,cal_time,cal_text,alarm_enabled) VALUES('.$eventid.','.$owner.','.$alarm['time'].",'".$alarm['text']."',1)",__LINE__,__FILE__); |
---|
1126 | $this->stream->query('SELECT LAST_INSERT_ID()'); |
---|
1127 | $this->stream->next_record(); |
---|
1128 | return($this->stream->f(0)); |
---|
1129 | } |
---|
1130 | function delete_alarm($alarmid) |
---|
1131 | { |
---|
1132 | $this->stream->query('DELETE FROM phpgw_cal_alarm WHERE alarm_id='.$alarmid,__LINE__,__FILE__); |
---|
1133 | } |
---|
1134 | */ |
---|
1135 | } |
---|