@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | |
14 | 14 | if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
15 | 15 | { |
16 | - define('ACL_TYPE_IDENTIFER','***ACL***'); |
|
16 | + define('ACL_TYPE_IDENTIFER', '***ACL***'); |
|
17 | 17 | } |
18 | 18 | |
19 | -define('HOUR_s',60*60); |
|
20 | -define('DAY_s',24*HOUR_s); |
|
21 | -define('WEEK_s',7*DAY_s); |
|
19 | +define('HOUR_s', 60 * 60); |
|
20 | +define('DAY_s', 24 * HOUR_s); |
|
21 | +define('WEEK_s', 7 * DAY_s); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Gives read access to the calendar, but all events the user is not participating are private! |
25 | 25 | * Used by addressbook. |
26 | 26 | */ |
27 | -define('EGW_ACL_READ_FOR_PARTICIPANTS',EGW_ACL_CUSTOM_1); |
|
28 | -define('EGW_ACL_FREEBUSY',EGW_ACL_CUSTOM_2); |
|
27 | +define('EGW_ACL_READ_FOR_PARTICIPANTS', EGW_ACL_CUSTOM_1); |
|
28 | +define('EGW_ACL_FREEBUSY', EGW_ACL_CUSTOM_2); |
|
29 | 29 | /** |
30 | 30 | * Allows to invite an other user (if configured to be used!) |
31 | 31 | */ |
32 | -define('EGW_ACL_INVITE',EGW_ACL_CUSTOM_3); |
|
32 | +define('EGW_ACL_INVITE', EGW_ACL_CUSTOM_3); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * 4 = function-calls to exported conversation-functions like date2ts, date2array, ... |
65 | 65 | * 5 = function-calls to private functions |
66 | 66 | */ |
67 | - var $debug=false; |
|
67 | + var $debug = false; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @var int $now timestamp in server-time |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @var int $user nummerical id of the current user-id |
96 | 96 | */ |
97 | - var $user=0; |
|
97 | + var $user = 0; |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs |
101 | 101 | */ |
102 | - var $grants=array(); |
|
102 | + var $grants = array(); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor |
@@ -225,25 +225,25 @@ discard block |
||
225 | 225 | */ |
226 | 226 | function __construct() |
227 | 227 | { |
228 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
228 | + if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True); |
|
229 | 229 | |
230 | 230 | $this->so = new calendar_so(); |
231 | 231 | $this->datetime = $GLOBALS['egw']->datetime; |
232 | 232 | |
233 | - $this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common']; |
|
234 | - $this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
233 | + $this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common']; |
|
234 | + $this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
235 | 235 | |
236 | 236 | $this->now = time(); |
237 | - $this->now_su = egw_time::server2user($this->now,'ts'); |
|
237 | + $this->now_su = egw_time::server2user($this->now, 'ts'); |
|
238 | 238 | |
239 | 239 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
240 | 240 | |
241 | 241 | $this->grants = $GLOBALS['egw']->acl->get_grants('calendar'); |
242 | 242 | |
243 | - if (!is_array($this->resources = $GLOBALS['egw']->session->appsession('resources','calendar'))) |
|
243 | + if (!is_array($this->resources = $GLOBALS['egw']->session->appsession('resources', 'calendar'))) |
|
244 | 244 | { |
245 | 245 | $this->resources = array(); |
246 | - foreach($GLOBALS['egw']->hooks->process('calendar_resources') as $app => $data) |
|
246 | + foreach ($GLOBALS['egw']->hooks->process('calendar_resources') as $app => $data) |
|
247 | 247 | { |
248 | 248 | if ($data && $data['type']) |
249 | 249 | { |
@@ -259,19 +259,19 @@ discard block |
||
259 | 259 | 'type' => '', |
260 | 260 | 'app' => 'home-accounts', |
261 | 261 | ); |
262 | - $GLOBALS['egw']->session->appsession('resources','calendar',$this->resources); |
|
262 | + $GLOBALS['egw']->session->appsession('resources', 'calendar', $this->resources); |
|
263 | 263 | } |
264 | 264 | //echo "registered resources="; _debug_array($this->resources); |
265 | 265 | |
266 | - $this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
267 | - $this->calview_no_consolidate = ($GLOBALS['egw_info']['server']['calview_no_consolidate']?$GLOBALS['egw_info']['server']['calview_no_consolidate']:5); |
|
266 | + $this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
267 | + $this->calview_no_consolidate = ($GLOBALS['egw_info']['server']['calview_no_consolidate'] ? $GLOBALS['egw_info']['server']['calview_no_consolidate'] : 5); |
|
268 | 268 | $this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite']; |
269 | 269 | |
270 | - $this->categories = new categories($this->user,'calendar'); |
|
270 | + $this->categories = new categories($this->user, 'calendar'); |
|
271 | 271 | |
272 | 272 | $this->customfields = config::get_customfields('calendar'); |
273 | 273 | |
274 | - foreach($this->alarms as $secs => &$label) |
|
274 | + foreach ($this->alarms as $secs => &$label) |
|
275 | 275 | { |
276 | 276 | $label = self::secs2label($secs); |
277 | 277 | } |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | { |
288 | 288 | if ($secs <= 3600) |
289 | 289 | { |
290 | - $label = lang('%1 minutes', $secs/60); |
|
290 | + $label = lang('%1 minutes', $secs / 60); |
|
291 | 291 | } |
292 | - elseif($secs <= 86400) |
|
292 | + elseif ($secs <= 86400) |
|
293 | 293 | { |
294 | - $label = lang('%1 hours', $secs/3600); |
|
294 | + $label = lang('%1 hours', $secs / 3600); |
|
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - $label = lang('%1 days', $secs/86400); |
|
298 | + $label = lang('%1 days', $secs / 86400); |
|
299 | 299 | } |
300 | 300 | return $label; |
301 | 301 | } |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | if (!$ids) return null; |
312 | 312 | |
313 | 313 | $data = array(); |
314 | - foreach((array)$ids as $id) |
|
314 | + foreach ((array)$ids as $id) |
|
315 | 315 | { |
316 | 316 | $email = $id; |
317 | 317 | $name = ''; |
318 | 318 | $matches = null; |
319 | - if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches)) |
|
319 | + if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches)) |
|
320 | 320 | { |
321 | 321 | $name = $matches[1]; |
322 | 322 | $email = $matches[2]; |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | function enum_groups(&$event) |
342 | 342 | { |
343 | 343 | $added = 0; |
344 | - foreach(array_keys($event['participants']) as $uid) |
|
344 | + foreach (array_keys($event['participants']) as $uid) |
|
345 | 345 | { |
346 | 346 | if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' && |
347 | 347 | ($members = $GLOBALS['egw']->accounts->member($uid))) |
348 | 348 | { |
349 | - foreach($members as $member) |
|
349 | + foreach ($members as $member) |
|
350 | 350 | { |
351 | 351 | $member = $member['account_id']; |
352 | 352 | if (!isset($event['participants'][$member])) |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search |
370 | 370 | * @return array of user-ids |
371 | 371 | */ |
372 | - private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true) |
|
372 | + private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true) |
|
373 | 373 | { |
374 | 374 | if (!is_array($_users)) |
375 | 375 | { |
@@ -377,19 +377,19 @@ discard block |
||
377 | 377 | } |
378 | 378 | // only query calendars of users, we have READ-grants from |
379 | 379 | $users = array(); |
380 | - foreach($_users as $user) |
|
380 | + foreach ($_users as $user) |
|
381 | 381 | { |
382 | 382 | $user = trim($user); |
383 | - if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$user)) |
|
383 | + if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? EGW_ACL_FREEBUSY : 0), 0, $user)) |
|
384 | 384 | { |
385 | - if ($user && !in_array($user,$users)) // already added? |
|
385 | + if ($user && !in_array($user, $users)) // already added? |
|
386 | 386 | { |
387 | 387 | $users[] = $user; |
388 | 388 | } |
389 | 389 | } |
390 | 390 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
391 | 391 | { |
392 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
392 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
393 | 393 | } |
394 | 394 | // the further code is only for real users |
395 | 395 | if (!is_numeric($user)) continue; |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $members = $GLOBALS['egw']->accounts->member($user); |
403 | 403 | if (is_array($members)) |
404 | 404 | { |
405 | - foreach($members as $member) |
|
405 | + foreach ($members as $member) |
|
406 | 406 | { |
407 | 407 | // use only members which gave the user a read-grant |
408 | - if (!in_array($member['account_id'],$users) && |
|
409 | - ($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$member['account_id']))) |
|
408 | + if (!in_array($member['account_id'], $users) && |
|
409 | + ($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy ? EGW_ACL_FREEBUSY : 0), 0, $member['account_id']))) |
|
410 | 410 | { |
411 | 411 | $users[] = $member['account_id']; |
412 | 412 | } |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | $memberships = $GLOBALS['egw']->accounts->membership($user); |
419 | 419 | if (is_array($memberships)) |
420 | 420 | { |
421 | - foreach($memberships as $group) |
|
421 | + foreach ($memberships as $group) |
|
422 | 422 | { |
423 | - if (!in_array($group['account_id'],$users)) |
|
423 | + if (!in_array($group['account_id'], $users)) |
|
424 | 424 | { |
425 | 425 | $users[] = $group['account_id']; |
426 | 426 | } |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param) |
462 | 462 | * or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given |
463 | 463 | */ |
464 | - function &search($params,$sql_filter=null) |
|
464 | + function &search($params, $sql_filter = null) |
|
465 | 465 | { |
466 | 466 | $params_in = $params; |
467 | 467 | |
468 | - $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
468 | + $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
469 | 469 | |
470 | 470 | // check if any resource wants to hook into |
471 | - foreach($this->resources as $data) |
|
471 | + foreach ($this->resources as $data) |
|
472 | 472 | { |
473 | 473 | if (isset($data['search_filter'])) |
474 | 474 | { |
475 | - $params = ExecMethod($data['search_filter'],$params); |
|
475 | + $params = ExecMethod($data['search_filter'], $params); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | if (!empty($params['query'])) |
491 | 491 | { |
492 | 492 | $params['private_grants'] = array(); |
493 | - foreach($this->grants as $user => $rights) |
|
493 | + foreach ($this->grants as $user => $rights) |
|
494 | 494 | { |
495 | - if ($rights & EGW_ACL_PRIVATE) $params['private_grants'][] = $user; |
|
495 | + if ($rights&EGW_ACL_PRIVATE) $params['private_grants'][] = $user; |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
@@ -518,49 +518,49 @@ discard block |
||
518 | 518 | $params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring']; |
519 | 519 | $cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0; |
520 | 520 | $filter = isset($params['filter']) ? $params['filter'] : 'all'; |
521 | - $offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false; |
|
521 | + $offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false; |
|
522 | 522 | // socal::search() returns rejected group-invitations, as only the user not also the group is rejected |
523 | 523 | // as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed |
524 | 524 | $users_in = (array)$params_in['users']; |
525 | - $remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) && |
|
525 | + $remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) && |
|
526 | 526 | count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null; |
527 | 527 | //error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user)); |
528 | 528 | |
529 | 529 | if ($this->debug && ($this->debug > 1 || $this->debug == 'search')) |
530 | 530 | { |
531 | 531 | $this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)', |
532 | - True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']); |
|
532 | + True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']); |
|
533 | 533 | } |
534 | 534 | // date2ts(,true) converts to server time, db2data converts again to user-time |
535 | - $events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null, |
|
536 | - $users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user); |
|
535 | + $events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null, |
|
536 | + $users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user); |
|
537 | 537 | |
538 | 538 | if (isset($params['cols'])) |
539 | 539 | { |
540 | 540 | return $events; |
541 | 541 | } |
542 | 542 | $this->total = $this->so->total; |
543 | - $this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
543 | + $this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
544 | 544 | |
545 | 545 | //echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n"; |
546 | - foreach($events as $id => $event) |
|
546 | + foreach ($events as $id => $event) |
|
547 | 547 | { |
548 | 548 | if ($params['enum_groups'] && $this->enum_groups($event)) |
549 | 549 | { |
550 | 550 | $events[$id] = $event; |
551 | 551 | } |
552 | 552 | $matches = null; |
553 | - if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches)) |
|
553 | + if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches)) |
|
554 | 554 | { |
555 | - $is_private = self::integration_get_private($matches[1],$matches[2],$event); |
|
555 | + $is_private = self::integration_get_private($matches[1], $matches[2], $event); |
|
556 | 556 | } |
557 | 557 | else |
558 | 558 | { |
559 | - $is_private = !$this->check_perms(EGW_ACL_READ,$event); |
|
559 | + $is_private = !$this->check_perms(EGW_ACL_READ, $event); |
|
560 | 560 | } |
561 | 561 | if ($is_private || (!$event['public'] && $filter == 'hideprivate')) |
562 | 562 | { |
563 | - $this->clear_private_infos($events[$id],$users); |
|
563 | + $this->clear_private_infos($events[$id], $users); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
@@ -568,18 +568,18 @@ discard block |
||
568 | 568 | { |
569 | 569 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
570 | 570 | { |
571 | - $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
|
571 | + $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events); |
|
572 | 572 | } |
573 | 573 | // create empty entries for each day in the reported time |
574 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
574 | + for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
575 | 575 | { |
576 | 576 | $daysEvents[$this->date2string($ts)] = array(); |
577 | 577 | } |
578 | - foreach($events as $k => $event) |
|
578 | + foreach ($events as $k => $event) |
|
579 | 579 | { |
580 | - $e_start = max($this->date2ts($event['start']),$start); |
|
580 | + $e_start = max($this->date2ts($event['start']), $start); |
|
581 | 581 | // $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59 |
582 | - $e_end = min($this->date2ts($event['end'])-1,$end); |
|
582 | + $e_end = min($this->date2ts($event['end']) - 1, $end); |
|
583 | 583 | |
584 | 584 | // add event to each day in the reported time |
585 | 585 | $ts = $e_start; |
@@ -588,23 +588,23 @@ discard block |
||
588 | 588 | $ymd = null; |
589 | 589 | while ($ts <= $e_end) |
590 | 590 | { |
591 | - $daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k]; |
|
592 | - $ts = strtotime("+1 day",$ts); |
|
591 | + $daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k]; |
|
592 | + $ts = strtotime("+1 day", $ts); |
|
593 | 593 | } |
594 | 594 | if ($ymd != ($last = $this->date2string($e_end))) |
595 | 595 | { |
596 | - $daysEvents[$last][] =& $events[$k]; |
|
596 | + $daysEvents[$last][] = & $events[$k]; |
|
597 | 597 | } |
598 | 598 | } |
599 | - $events =& $daysEvents; |
|
599 | + $events = & $daysEvents; |
|
600 | 600 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
601 | 601 | { |
602 | - $this->debug_message('socalendar::search daywise events=%1',False,$events); |
|
602 | + $this->debug_message('socalendar::search daywise events=%1', False, $events); |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | if ($this->debug && ($this->debug > 0 || $this->debug == 'search')) |
606 | 606 | { |
607 | - $this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events); |
|
607 | + $this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events); |
|
608 | 608 | } |
609 | 609 | //error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace()); |
610 | 610 | return $events; |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | * @param string $part |
618 | 618 | * @return array |
619 | 619 | */ |
620 | - static function integration_get_data($app,$part=null) |
|
620 | + static function integration_get_data($app, $part = null) |
|
621 | 621 | { |
622 | - static $integration_data=null; |
|
622 | + static $integration_data = null; |
|
623 | 623 | |
624 | 624 | if (!isset($integration_data)) |
625 | 625 | { |
@@ -641,14 +641,14 @@ discard block |
||
641 | 641 | * @param int|string $id |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - static function integration_get_private($app,$id,$event) |
|
644 | + static function integration_get_private($app, $id, $event) |
|
645 | 645 | { |
646 | - $app_data = self::integration_get_data($app,'is_private'); |
|
646 | + $app_data = self::integration_get_data($app, 'is_private'); |
|
647 | 647 | |
648 | 648 | // no method, fall back to link title |
649 | 649 | if (is_null($app_data)) |
650 | 650 | { |
651 | - $is_private = !egw_link::title($app,$id); |
|
651 | + $is_private = !egw_link::title($app, $id); |
|
652 | 652 | } |
653 | 653 | // boolean value to make all events of $app public (false) or private (true) |
654 | 654 | elseif (is_bool($app_data)) |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | } |
658 | 658 | else |
659 | 659 | { |
660 | - $is_private = (bool)ExecMethod2($app_data,$id,$event); |
|
660 | + $is_private = (bool)ExecMethod2($app_data, $id, $event); |
|
661 | 661 | } |
662 | 662 | //echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n"; |
663 | 663 | return $is_private; |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @param array &$event |
672 | 672 | * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar |
673 | 673 | */ |
674 | - function clear_private_infos(&$event,$allowed_participants = array()) |
|
674 | + function clear_private_infos(&$event, $allowed_participants = array()) |
|
675 | 675 | { |
676 | 676 | if ($event == false) return; |
677 | 677 | if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
@@ -687,19 +687,19 @@ discard block |
||
687 | 687 | 'owner' => $event['owner'], |
688 | 688 | 'uid' => $event['uid'], |
689 | 689 | 'etag' => $event['etag'], |
690 | - 'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)), |
|
690 | + 'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)), |
|
691 | 691 | 'public'=> 0, |
692 | - 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
692 | + 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
693 | 693 | 'non_blocking' => $event['non_blocking'], |
694 | 694 | 'caldav_name' => $event['caldav_name'], |
695 | 695 | // we need full recurrence information, as they are relevant free/busy information |
696 | - )+($event['recur_type'] ? array( |
|
696 | + ) + ($event['recur_type'] ? array( |
|
697 | 697 | 'recur_type' => $event['recur_type'], |
698 | 698 | 'recur_interval' => $event['recur_interval'], |
699 | 699 | 'recur_data' => $event['recur_data'], |
700 | 700 | 'recur_enddate' => $event['recur_enddate'], |
701 | 701 | 'recur_exception'=> $event['recur_exception'], |
702 | - ):array( |
|
702 | + ) : array( |
|
703 | 703 | 'reference' => $event['reference'], |
704 | 704 | 'recurrence' => $event['recurrence'], |
705 | 705 | )); |
@@ -713,15 +713,15 @@ discard block |
||
713 | 713 | */ |
714 | 714 | function check_move_horizont($_new_horizont) |
715 | 715 | { |
716 | - if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
716 | + if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
717 | 717 | { |
718 | - $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']); |
|
718 | + $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']); |
|
719 | 719 | } |
720 | - $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
|
720 | + $new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates |
|
721 | 721 | |
722 | 722 | if ($new_horizont <= $this->config['horizont']) // no move necessary |
723 | 723 | { |
724 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
|
724 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']); |
|
725 | 725 | return; |
726 | 726 | } |
727 | 727 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
@@ -729,15 +729,15 @@ discard block |
||
729 | 729 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
730 | 730 | } |
731 | 731 | if (empty($maxdays)) $maxdays = 1000; // old default |
732 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
732 | + if ($new_horizont > time() + $maxdays * DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
733 | 733 | { |
734 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
|
735 | - $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont,true), $maxdays); |
|
734 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays); |
|
735 | + $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont, true), $maxdays); |
|
736 | 736 | return; |
737 | 737 | } |
738 | - if ($new_horizont < time()+31*DAY_s) |
|
738 | + if ($new_horizont < time() + 31 * DAY_s) |
|
739 | 739 | { |
740 | - $new_horizont = time()+31*DAY_s; |
|
740 | + $new_horizont = time() + 31 * DAY_s; |
|
741 | 741 | } |
742 | 742 | $old_horizont = $this->config['horizont']; |
743 | 743 | $this->config['horizont'] = $new_horizont; |
@@ -745,21 +745,21 @@ discard block |
||
745 | 745 | // create further recurrences for all recurring and not yet (at the old horizont) ended events |
746 | 746 | if (($recuring = $this->so->unfinished_recuring($old_horizont))) |
747 | 747 | { |
748 | - @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
749 | - foreach($this->read(array_keys($recuring)) as $cal_id => $event) |
|
748 | + @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
749 | + foreach ($this->read(array_keys($recuring)) as $cal_id => $event) |
|
750 | 750 | { |
751 | 751 | if ($this->debug == 'check_move_horizont') |
752 | 752 | { |
753 | - $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont); |
|
753 | + $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont); |
|
754 | 754 | } |
755 | 755 | // insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past |
756 | - $this->set_recurrences($event,egw_time::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time! |
|
756 | + $this->set_recurrences($event, egw_time::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time! |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | // update the horizont |
760 | - config::save_value('horizont',$this->config['horizont'],'calendar'); |
|
760 | + config::save_value('horizont', $this->config['horizont'], 'calendar'); |
|
761 | 761 | |
762 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
762 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -770,11 +770,11 @@ discard block |
||
770 | 770 | * @param array $event |
771 | 771 | * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
772 | 772 | */ |
773 | - function set_recurrences($event,$start=0) |
|
773 | + function set_recurrences($event, $start = 0) |
|
774 | 774 | { |
775 | - if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
775 | + if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
776 | 776 | { |
777 | - $this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start); |
|
777 | + $this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start); |
|
778 | 778 | } |
779 | 779 | // check if the caller gave us enough information and if not read it from the DB |
780 | 780 | if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end'])) |
@@ -793,27 +793,27 @@ discard block |
||
793 | 793 | if (!$start) $start = $event['start']; |
794 | 794 | |
795 | 795 | $events = array(); |
796 | - $this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events); |
|
796 | + $this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events); |
|
797 | 797 | |
798 | 798 | $exceptions = array(); |
799 | - foreach((array)$event['recur_exception'] as $exception) |
|
799 | + foreach ((array)$event['recur_exception'] as $exception) |
|
800 | 800 | { |
801 | - $exceptions[] = egw_time::to($exception, true); // true = date |
|
801 | + $exceptions[] = egw_time::to($exception, true); // true = date |
|
802 | 802 | } |
803 | 803 | //error_log(__METHOD__."(".array2string($event).", $start) exceptions=".array2string($exceptions)); |
804 | - foreach($events as $event) |
|
804 | + foreach ($events as $event) |
|
805 | 805 | { |
806 | 806 | $is_exception = in_array(egw_time::to($event['start'], true), $exceptions); |
807 | - $start = $this->date2ts($event['start'],true); |
|
807 | + $start = $this->date2ts($event['start'], true); |
|
808 | 808 | if ($event['whole_day']) |
809 | 809 | { |
810 | 810 | $time = $this->so->startOfDay(new egw_time($event['end'], egw_time::$user_timezone)); |
811 | 811 | $time->setTime(23, 59, 59); |
812 | - $end = $this->date2ts($time,true); |
|
812 | + $end = $this->date2ts($time, true); |
|
813 | 813 | } |
814 | 814 | else |
815 | 815 | { |
816 | - $end = $this->date2ts($event['end'],true); |
|
816 | + $end = $this->date2ts($event['end'], true); |
|
817 | 817 | } |
818 | 818 | //error_log(__METHOD__."() start=".egw_time::to($start).", is_exception=".array2string($is_exception)); |
819 | 819 | $this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception); |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * @param array &$events array of event-arrays (reference) |
830 | 830 | * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
831 | 831 | */ |
832 | - function db2data(&$events,$date_format='ts') |
|
832 | + function db2data(&$events, $date_format = 'ts') |
|
833 | 833 | { |
834 | 834 | if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
835 | 835 | foreach ($events as &$event) |
@@ -842,65 +842,65 @@ discard block |
||
842 | 842 | // database returns timestamps as string, convert them to integer |
843 | 843 | // to avoid misinterpretation by egw_time as Ymd string |
844 | 844 | // (this will fail on 32bit systems for times > 2038!) |
845 | - $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls egw_time |
|
845 | + $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls egw_time |
|
846 | 846 | $event['end'] = (int)$event['end']; |
847 | 847 | $event['whole_day'] = self::isWholeDay($event); |
848 | 848 | if ($event['whole_day'] && $date_format != 'server') |
849 | 849 | { |
850 | 850 | // Adjust dates to user TZ |
851 | - $stime =& $this->so->startOfDay(new egw_time((int)$event['start'], egw_time::$server_timezone), $event['tzid']); |
|
851 | + $stime = & $this->so->startOfDay(new egw_time((int)$event['start'], egw_time::$server_timezone), $event['tzid']); |
|
852 | 852 | $event['start'] = egw_time::to($stime, $date_format); |
853 | - $time =& $this->so->startOfDay(new egw_time((int)$event['end'], egw_time::$server_timezone), $event['tzid']); |
|
853 | + $time = & $this->so->startOfDay(new egw_time((int)$event['end'], egw_time::$server_timezone), $event['tzid']); |
|
854 | 854 | $time->setTime(23, 59, 59); |
855 | 855 | $event['end'] = egw_time::to($time, $date_format); |
856 | 856 | if (!empty($event['recurrence'])) |
857 | 857 | { |
858 | - $time =& $this->so->startOfDay(new egw_time((int)$event['recurrence'], egw_time::$server_timezone), $event['tzid']); |
|
858 | + $time = & $this->so->startOfDay(new egw_time((int)$event['recurrence'], egw_time::$server_timezone), $event['tzid']); |
|
859 | 859 | $event['recurrence'] = egw_time::to($time, $date_format); |
860 | 860 | } |
861 | 861 | if (!empty($event['recur_enddate'])) |
862 | 862 | { |
863 | - $time =& $this->so->startOfDay(new egw_time((int)$event['recur_enddate'], egw_time::$server_timezone), $event['tzid']); |
|
863 | + $time = & $this->so->startOfDay(new egw_time((int)$event['recur_enddate'], egw_time::$server_timezone), $event['tzid']); |
|
864 | 864 | $time->setTime(23, 59, 59); |
865 | 865 | $event['recur_enddate'] = egw_time::to($time, $date_format); |
866 | 866 | } |
867 | - $timestamps = array('modified','created'); |
|
867 | + $timestamps = array('modified', 'created'); |
|
868 | 868 | } |
869 | 869 | else |
870 | 870 | { |
871 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
871 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
872 | 872 | } |
873 | 873 | // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! |
874 | 874 | foreach ($timestamps as $ts) |
875 | 875 | { |
876 | 876 | if (!empty($event[$ts])) |
877 | 877 | { |
878 | - $event[$ts] = $this->date2usertime((int)$event[$ts],$date_format); |
|
878 | + $event[$ts] = $this->date2usertime((int)$event[$ts], $date_format); |
|
879 | 879 | } |
880 | 880 | } |
881 | 881 | // same with the recur exceptions |
882 | 882 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
883 | 883 | { |
884 | - foreach($event['recur_exception'] as &$date) |
|
884 | + foreach ($event['recur_exception'] as &$date) |
|
885 | 885 | { |
886 | 886 | if ($event['whole_day'] && $date_format != 'server') |
887 | 887 | { |
888 | 888 | // Adjust dates to user TZ |
889 | - $time =& $this->so->startOfDay(new egw_time((int)$date, egw_time::$server_timezone), $event['tzid']); |
|
889 | + $time = & $this->so->startOfDay(new egw_time((int)$date, egw_time::$server_timezone), $event['tzid']); |
|
890 | 890 | $date = egw_time::to($time, $date_format); |
891 | 891 | } |
892 | 892 | else |
893 | 893 | { |
894 | - $date = $this->date2usertime((int)$date,$date_format); |
|
894 | + $date = $this->date2usertime((int)$date, $date_format); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | } |
898 | 898 | // same with the alarms |
899 | 899 | if (isset($event['alarm']) && is_array($event['alarm'])) |
900 | 900 | { |
901 | - foreach($event['alarm'] as &$alarm) |
|
901 | + foreach ($event['alarm'] as &$alarm) |
|
902 | 902 | { |
903 | - $alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format); |
|
903 | + $alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format); |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | } |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
914 | 914 | * @return mixed depending of $date_format |
915 | 915 | */ |
916 | - function date2usertime($ts,$date_format='ts') |
|
916 | + function date2usertime($ts, $date_format = 'ts') |
|
917 | 917 | { |
918 | 918 | if (empty($ts) || $date_format == 'server') return $ts; |
919 | 919 | |
920 | - return egw_time::server2user($ts,$date_format); |
|
920 | + return egw_time::server2user($ts, $date_format); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | * but call clear_private_infos() with the given users |
932 | 932 | * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found |
933 | 933 | */ |
934 | - function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
|
934 | + function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null) |
|
935 | 935 | { |
936 | 936 | if (!$ids) return false; |
937 | 937 | |
@@ -940,21 +940,21 @@ discard block |
||
940 | 940 | $return = null; |
941 | 941 | |
942 | 942 | $check = $clear_private_infos_users ? EGW_ACL_FREEBUSY : EGW_ACL_READ; |
943 | - if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date))) |
|
943 | + if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date))) |
|
944 | 944 | { |
945 | 945 | if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids || |
946 | 946 | self::$cached_event_date_format != $date_format || |
947 | 947 | self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date) |
948 | 948 | { |
949 | - $events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0); |
|
949 | + $events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0); |
|
950 | 950 | |
951 | 951 | if ($events) |
952 | 952 | { |
953 | - $this->db2data($events,$date_format); |
|
953 | + $this->db2data($events, $date_format); |
|
954 | 954 | |
955 | 955 | if (is_array($ids)) |
956 | 956 | { |
957 | - $return =& $events; |
|
957 | + $return = & $events; |
|
958 | 958 | } |
959 | 959 | else |
960 | 960 | { |
@@ -970,13 +970,13 @@ discard block |
||
970 | 970 | $return = self::$cached_event; |
971 | 971 | } |
972 | 972 | } |
973 | - if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(EGW_ACL_READ,$return)) |
|
973 | + if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(EGW_ACL_READ, $return)) |
|
974 | 974 | { |
975 | 975 | $this->clear_private_infos($return, (array)$clear_private_infos_users); |
976 | 976 | } |
977 | 977 | if ($this->debug && ($this->debug > 1 || $this->debug == 'read')) |
978 | 978 | { |
979 | - $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return); |
|
979 | + $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return); |
|
980 | 980 | } |
981 | 981 | return $return; |
982 | 982 | } |
@@ -994,17 +994,17 @@ discard block |
||
994 | 994 | * @param array $events where the repetions get inserted |
995 | 995 | * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
996 | 996 | */ |
997 | - function insert_all_recurrences($event,$_start,$end,&$events) |
|
997 | + function insert_all_recurrences($event, $_start, $end, &$events) |
|
998 | 998 | { |
999 | - if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
999 | + if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
1000 | 1000 | { |
1001 | - $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end); |
|
1001 | + $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end); |
|
1002 | 1002 | } |
1003 | 1003 | $end_in = $end; |
1004 | 1004 | |
1005 | 1005 | $start = $this->date2ts($_start); |
1006 | 1006 | $event_start_ts = $this->date2ts($event['start']); |
1007 | - $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
1007 | + $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
1008 | 1008 | |
1009 | 1009 | // if $end is before recur_enddate, use it instead |
1010 | 1010 | if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end)) |
@@ -1016,27 +1016,27 @@ discard block |
||
1016 | 1016 | // unset exceptions, as we need to add them as recurrence too, but marked as exception |
1017 | 1017 | unset($event['recur_exception']); |
1018 | 1018 | // loop over all recurrences and insert them, if they are after $start |
1019 | - $rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo |
|
1020 | - foreach($rrule as $time) |
|
1019 | + $rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo |
|
1020 | + foreach ($rrule as $time) |
|
1021 | 1021 | { |
1022 | - $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
1023 | - if (($ts = $this->date2ts($time)) < $start-$event_length) |
|
1022 | + $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
1023 | + if (($ts = $this->date2ts($time)) < $start - $event_length) |
|
1024 | 1024 | { |
1025 | 1025 | //echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n"; |
1026 | - continue; // to early or original event (returned by interator too) |
|
1026 | + continue; // to early or original event (returned by interator too) |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | $ts_end = $ts + $event_length; |
1030 | 1030 | // adjust ts_end for whole day events in case it does not fit due to |
1031 | 1031 | // spans over summer/wintertime adjusted days |
1032 | - if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
1032 | + if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
1033 | 1033 | !($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59)) |
1034 | 1034 | { |
1035 | 1035 | $arr_end['hour'] = 23; |
1036 | 1036 | $arr_end['minute'] = 59; |
1037 | 1037 | $arr_end['second'] = 59; |
1038 | 1038 | $ts_end_guess = $this->date2ts($arr_end); |
1039 | - if($ts_end_guess - $ts_end > DAY_s/2) |
|
1039 | + if ($ts_end_guess - $ts_end > DAY_s / 2) |
|
1040 | 1040 | { |
1041 | 1041 | $ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future |
1042 | 1042 | } |
@@ -1050,11 +1050,11 @@ discard block |
||
1050 | 1050 | $event['end'] = $ts_end; |
1051 | 1051 | $events[] = $event; |
1052 | 1052 | } |
1053 | - if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
1053 | + if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
1054 | 1054 | { |
1055 | 1055 | $event['start'] = $event_start_ts; |
1056 | 1056 | $event['end'] = $event_start_ts + $event_length; |
1057 | - $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events); |
|
1057 | + $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events); |
|
1058 | 1058 | } |
1059 | 1059 | } |
1060 | 1060 | |
@@ -1065,18 +1065,18 @@ discard block |
||
1065 | 1065 | * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd |
1066 | 1066 | * @param int|string $date_ymd of the date of the event |
1067 | 1067 | */ |
1068 | - function add_adjusted_event(&$events,$event,$date_ymd) |
|
1068 | + function add_adjusted_event(&$events, $event, $date_ymd) |
|
1069 | 1069 | { |
1070 | 1070 | $event_in = $event; |
1071 | 1071 | // calculate the new start- and end-time |
1072 | 1072 | $length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']); |
1073 | 1073 | $event_start_arr = $this->date2array($event['start']); |
1074 | 1074 | |
1075 | - $date_arr = $this->date2array((string) $date_ymd); |
|
1075 | + $date_arr = $this->date2array((string)$date_ymd); |
|
1076 | 1076 | $date_arr['hour'] = $event_start_arr['hour']; |
1077 | 1077 | $date_arr['minute'] = $event_start_arr['minute']; |
1078 | 1078 | $date_arr['second'] = $event_start_arr['second']; |
1079 | - unset($date_arr['raw']); // else date2ts would use it |
|
1079 | + unset($date_arr['raw']); // else date2ts would use it |
|
1080 | 1080 | $event['start'] = $this->date2ts($date_arr); |
1081 | 1081 | $event['end'] = $event['start'] + $length_s; |
1082 | 1082 | |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | |
1085 | 1085 | if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event')) |
1086 | 1086 | { |
1087 | - $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event); |
|
1087 | + $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event); |
|
1088 | 1088 | } |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1108,22 +1108,22 @@ discard block |
||
1108 | 1108 | { |
1109 | 1109 | $info = array( |
1110 | 1110 | 'res_id' => $uid, |
1111 | - 'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'), |
|
1112 | - 'name' => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' . |
|
1113 | - $GLOBALS['egw']->accounts->id2name($uid,'account_lastname')), |
|
1111 | + 'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'), |
|
1112 | + 'name' => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
|
1113 | + $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')), |
|
1114 | 1114 | 'type' => $GLOBALS['egw']->accounts->get_type($uid), |
1115 | 1115 | 'app' => 'accounts', |
1116 | 1116 | ); |
1117 | 1117 | } |
1118 | 1118 | else |
1119 | 1119 | { |
1120 | - list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false; |
|
1120 | + list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false; |
|
1121 | 1121 | if ($info) |
1122 | 1122 | { |
1123 | 1123 | $info['type'] = $uid[0]; |
1124 | 1124 | if (!$info['email'] && $info['responsible']) |
1125 | 1125 | { |
1126 | - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); |
|
1126 | + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email'); |
|
1127 | 1127 | } |
1128 | 1128 | $info['app'] = $this->resources[$uid[0]]['app']; |
1129 | 1129 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | } |
1133 | 1133 | if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info')) |
1134 | 1134 | { |
1135 | - $this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]); |
|
1135 | + $this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]); |
|
1136 | 1136 | } |
1137 | 1137 | return $res_info_cache[$uid]; |
1138 | 1138 | } |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | * @param int $user =null for which user to check, default current user |
1154 | 1154 | * @return boolean true permission granted, false for permission denied or null if event not found |
1155 | 1155 | */ |
1156 | - function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
|
1156 | + function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null) |
|
1157 | 1157 | { |
1158 | 1158 | if (!$user) $user = $this->user; |
1159 | 1159 | if ($user == $this->user) |
@@ -1162,13 +1162,13 @@ discard block |
||
1162 | 1162 | } |
1163 | 1163 | else |
1164 | 1164 | { |
1165 | - $grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user); |
|
1165 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | if ($other && !is_numeric($other)) |
1169 | 1169 | { |
1170 | 1170 | $resource = $this->resource_info($other); |
1171 | - return $needed & $resource['rights']; |
|
1171 | + return $needed&$resource['rights']; |
|
1172 | 1172 | } |
1173 | 1173 | if (is_int($event) && $event == 0) |
1174 | 1174 | { |
@@ -1178,15 +1178,15 @@ discard block |
||
1178 | 1178 | { |
1179 | 1179 | if (!is_array($event)) |
1180 | 1180 | { |
1181 | - $event = $this->read($event,$date_to_read,true,$date_format); // = no ACL check !!! |
|
1181 | + $event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!! |
|
1182 | 1182 | } |
1183 | 1183 | if (!is_array($event)) |
1184 | 1184 | { |
1185 | 1185 | if ($this->xmlrpc) |
1186 | 1186 | { |
1187 | - $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']); |
|
1187 | + $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']); |
|
1188 | 1188 | } |
1189 | - return null; // event not found |
|
1189 | + return null; // event not found |
|
1190 | 1190 | } |
1191 | 1191 | $owner = $event['owner']; |
1192 | 1192 | $private = !$event['public']; |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | $grant = $grants[$owner]; |
1195 | 1195 | |
1196 | 1196 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
1197 | - if ($grant & ~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY; |
|
1197 | + if ($grant&~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY; |
|
1198 | 1198 | |
1199 | 1199 | if (is_array($event) && ($needed == EGW_ACL_READ || $needed == EGW_ACL_FREEBUSY)) |
1200 | 1200 | { |
@@ -1203,15 +1203,15 @@ discard block |
||
1203 | 1203 | // |
1204 | 1204 | if ($event['participants'] && is_array($event['participants'])) |
1205 | 1205 | { |
1206 | - foreach(array_keys($event['participants']) as $uid) |
|
1206 | + foreach (array_keys($event['participants']) as $uid) |
|
1207 | 1207 | { |
1208 | - if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true))) |
|
1208 | + if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true))) |
|
1209 | 1209 | { |
1210 | 1210 | // if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant |
1211 | - $grant |= EGW_ACL_FREEBUSY | EGW_ACL_READ | EGW_ACL_PRIVATE; |
|
1211 | + $grant |= EGW_ACL_FREEBUSY|EGW_ACL_READ|EGW_ACL_PRIVATE; |
|
1212 | 1212 | break; |
1213 | 1213 | } |
1214 | - elseif ($grants[$uid] & EGW_ACL_READ) |
|
1214 | + elseif ($grants[$uid]&EGW_ACL_READ) |
|
1215 | 1215 | { |
1216 | 1216 | // if we have a READ grant from a participant, we dont give an implicit privat grant too |
1217 | 1217 | $grant |= EGW_ACL_READ; |
@@ -1230,12 +1230,12 @@ discard block |
||
1230 | 1230 | } |
1231 | 1231 | if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == EGW_ACL_ADD) |
1232 | 1232 | { |
1233 | - $access = False; // a group can't be the owner of an event |
|
1233 | + $access = False; // a group can't be the owner of an event |
|
1234 | 1234 | } |
1235 | 1235 | else |
1236 | 1236 | { |
1237 | - $access = $user == $owner || $grant & $needed |
|
1238 | - && ($needed == EGW_ACL_FREEBUSY || !$private || $grant & EGW_ACL_PRIVATE); |
|
1237 | + $access = $user == $owner || $grant&$needed |
|
1238 | + && ($needed == EGW_ACL_FREEBUSY || !$private || $grant&EGW_ACL_PRIVATE); |
|
1239 | 1239 | } |
1240 | 1240 | // do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled |
1241 | 1241 | if ($access && $needed == EGW_ACL_DELETE && $event['deleted'] && |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms')) |
1248 | 1248 | { |
1249 | - $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access); |
|
1249 | + $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access); |
|
1250 | 1250 | } |
1251 | 1251 | //error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access)); |
1252 | 1252 | return $access; |
@@ -1261,9 +1261,9 @@ discard block |
||
1261 | 1261 | * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' |
1262 | 1262 | * @param boolean $user2server =False conversion between user- and server-time; default False == Off |
1263 | 1263 | */ |
1264 | - static function date2ts($date,$user2server=False) |
|
1264 | + static function date2ts($date, $user2server = False) |
|
1265 | 1265 | { |
1266 | - return $user2server ? egw_time::user2server($date,'ts') : egw_time::to($date,'ts'); |
|
1266 | + return $user2server ? egw_time::user2server($date, 'ts') : egw_time::to($date, 'ts'); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
@@ -1273,9 +1273,9 @@ discard block |
||
1273 | 1273 | * @param boolean $server2user conversation between user- and server-time default False == Off |
1274 | 1274 | * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string) |
1275 | 1275 | */ |
1276 | - static function date2array($date,$server2user=False) |
|
1276 | + static function date2array($date, $server2user = False) |
|
1277 | 1277 | { |
1278 | - return $server2user ? egw_time::server2user($date,'array') : egw_time::to($date,'array'); |
|
1278 | + return $server2user ? egw_time::server2user($date, 'array') : egw_time::to($date, 'array'); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | /** |
@@ -1286,9 +1286,9 @@ discard block |
||
1286 | 1286 | * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100) |
1287 | 1287 | * @return string date formatted according to $format |
1288 | 1288 | */ |
1289 | - static function date2string($date,$server2user=False,$format='Ymd') |
|
1289 | + static function date2string($date, $server2user = False, $format = 'Ymd') |
|
1290 | 1290 | { |
1291 | - return $server2user ? egw_time::server2user($date,$format) : egw_time::to($date,$format); |
|
1291 | + return $server2user ? egw_time::server2user($date, $format) : egw_time::to($date, $format); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | /** |
@@ -1298,9 +1298,9 @@ discard block |
||
1298 | 1298 | * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only |
1299 | 1299 | * @return string the formated date (incl. time) |
1300 | 1300 | */ |
1301 | - static function format_date($date,$format='') |
|
1301 | + static function format_date($date, $format = '') |
|
1302 | 1302 | { |
1303 | - return egw_time::to($date,$format); |
|
1303 | + return egw_time::to($date, $format); |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | * @param mixed $param a variable number of parameters, to be inserted in $msg |
1323 | 1323 | * arrays get serialized with print_r() ! |
1324 | 1324 | */ |
1325 | - static function debug_message($msg,$backtrace=True) |
|
1325 | + static function debug_message($msg, $backtrace = True) |
|
1326 | 1326 | { |
1327 | 1327 | static $acl2string = array( |
1328 | 1328 | 0 => 'ACL-UNKNOWN', |
@@ -1333,22 +1333,22 @@ discard block |
||
1333 | 1333 | EGW_ACL_PRIVATE => 'ACL_PRIVATE', |
1334 | 1334 | EGW_ACL_FREEBUSY => 'ACL_FREEBUSY', |
1335 | 1335 | ); |
1336 | - for($i = 2; $i < func_num_args(); ++$i) |
|
1336 | + for ($i = 2; $i < func_num_args(); ++$i) |
|
1337 | 1337 | { |
1338 | 1338 | $param = func_get_arg($i); |
1339 | 1339 | |
1340 | 1340 | if (is_null($param)) |
1341 | 1341 | { |
1342 | - $param='NULL'; |
|
1342 | + $param = 'NULL'; |
|
1343 | 1343 | } |
1344 | 1344 | else |
1345 | 1345 | { |
1346 | - switch(gettype($param)) |
|
1346 | + switch (gettype($param)) |
|
1347 | 1347 | { |
1348 | 1348 | case 'string': |
1349 | - if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER) |
|
1349 | + if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER) |
|
1350 | 1350 | { |
1351 | - $param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER)); |
|
1351 | + $param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER)); |
|
1352 | 1352 | $param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)"; |
1353 | 1353 | } |
1354 | 1354 | else |
@@ -1370,11 +1370,11 @@ discard block |
||
1370 | 1370 | $param = $param ? 'True' : 'False'; |
1371 | 1371 | break; |
1372 | 1372 | case 'integer': |
1373 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
1373 | + if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)"; |
|
1374 | 1374 | break; |
1375 | 1375 | } |
1376 | 1376 | } |
1377 | - $msg = str_replace('%'.($i-1),$param,$msg); |
|
1377 | + $msg = str_replace('%'.($i - 1), $param, $msg); |
|
1378 | 1378 | } |
1379 | 1379 | error_log($msg); |
1380 | 1380 | if ($backtrace) error_log(function_backtrace(1)); |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
1390 | 1390 | * @return string with formated date |
1391 | 1391 | */ |
1392 | - function long_date($_first,$last=0,$display_time=false,$display_day=false) |
|
1392 | + function long_date($_first, $last = 0, $display_time = false, $display_day = false) |
|
1393 | 1393 | { |
1394 | 1394 | $first = $this->date2array($_first); |
1395 | 1395 | if ($last) |
@@ -1404,27 +1404,27 @@ discard block |
||
1404 | 1404 | |
1405 | 1405 | if ($display_day) |
1406 | 1406 | { |
1407 | - $range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
1407 | + $range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
1408 | 1408 | } |
1409 | 1409 | for ($i = 0; $i < 5; $i += 2) |
1410 | 1410 | { |
1411 | - switch($datefmt[$i]) |
|
1411 | + switch ($datefmt[$i]) |
|
1412 | 1412 | { |
1413 | 1413 | case 'd': |
1414 | - $range .= $first['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
1414 | + $range .= $first['day'].($datefmt[1] == '.' ? '.' : ''); |
|
1415 | 1415 | if ($first['month'] != $last['month'] || $first['year'] != $last['year']) |
1416 | 1416 | { |
1417 | 1417 | if (!$month_before_day) |
1418 | 1418 | { |
1419 | - $range .= ' '.lang(strftime('%B',$first['raw'])); |
|
1419 | + $range .= ' '.lang(strftime('%B', $first['raw'])); |
|
1420 | 1420 | } |
1421 | 1421 | if ($first['year'] != $last['year'] && $datefmt[0] != 'Y') |
1422 | 1422 | { |
1423 | - $range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year']; |
|
1423 | + $range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year']; |
|
1424 | 1424 | } |
1425 | 1425 | if ($display_time) |
1426 | 1426 | { |
1427 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
1427 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
1428 | 1428 | } |
1429 | 1429 | if (!$last) |
1430 | 1430 | { |
@@ -1434,43 +1434,43 @@ discard block |
||
1434 | 1434 | |
1435 | 1435 | if ($first['year'] != $last['year'] && $datefmt[0] == 'Y') |
1436 | 1436 | { |
1437 | - $range .= $last['year'] . ', '; |
|
1437 | + $range .= $last['year'].', '; |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | if ($month_before_day) |
1441 | 1441 | { |
1442 | - $range .= lang(strftime('%B',$last['raw'])); |
|
1442 | + $range .= lang(strftime('%B', $last['raw'])); |
|
1443 | 1443 | } |
1444 | 1444 | } |
1445 | 1445 | else |
1446 | 1446 | { |
1447 | 1447 | if ($display_time) |
1448 | 1448 | { |
1449 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
1449 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
1450 | 1450 | } |
1451 | 1451 | $range .= ' - '; |
1452 | 1452 | } |
1453 | - $range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
1453 | + $range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : ''); |
|
1454 | 1454 | break; |
1455 | 1455 | case 'm': |
1456 | 1456 | case 'M': |
1457 | - $range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' '; |
|
1457 | + $range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' '; |
|
1458 | 1458 | break; |
1459 | 1459 | case 'Y': |
1460 | 1460 | if ($datefmt[0] != 'm') |
1461 | 1461 | { |
1462 | - $range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
1462 | + $range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
1463 | 1463 | } |
1464 | 1464 | break; |
1465 | 1465 | } |
1466 | 1466 | } |
1467 | 1467 | if ($display_time && $last) |
1468 | 1468 | { |
1469 | - $range .= ' '.adodb_date($timefmt,$last['raw']); |
|
1469 | + $range .= ' '.adodb_date($timefmt, $last['raw']); |
|
1470 | 1470 | } |
1471 | 1471 | if ($datefmt[4] == 'Y' && $datefmt[0] == 'm') |
1472 | 1472 | { |
1473 | - $range .= ', ' . $last['year']; |
|
1473 | + $range .= ', '.$last['year']; |
|
1474 | 1474 | } |
1475 | 1475 | return $range; |
1476 | 1476 | } |
@@ -1482,25 +1482,25 @@ discard block |
||
1482 | 1482 | * @param int $end_m end time in minutes since 0h |
1483 | 1483 | * @param boolean $both =false display the end-time too, duration is always displayed |
1484 | 1484 | */ |
1485 | - function timespan($start_m,$end_m,$both=false) |
|
1485 | + function timespan($start_m, $end_m, $both = false) |
|
1486 | 1486 | { |
1487 | 1487 | $duration = $end_m - $start_m; |
1488 | - if ($end_m == 24*60-1) ++$duration; |
|
1489 | - $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
1488 | + if ($end_m == 24 * 60 - 1) ++$duration; |
|
1489 | + $duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
1490 | 1490 | |
1491 | - $timespan = $t = common::formattime(sprintf('%02d',$start_m/60),sprintf('%02d',$start_m%60)); |
|
1491 | + $timespan = $t = common::formattime(sprintf('%02d', $start_m / 60), sprintf('%02d', $start_m % 60)); |
|
1492 | 1492 | |
1493 | 1493 | if ($both) // end-time too |
1494 | 1494 | { |
1495 | - $timespan .= ' - '.common::formattime(sprintf('%02d',$end_m/60),sprintf('%02d',$end_m%60)); |
|
1495 | + $timespan .= ' - '.common::formattime(sprintf('%02d', $end_m / 60), sprintf('%02d', $end_m % 60)); |
|
1496 | 1496 | // dont double am/pm if they are the same in both times |
1497 | - if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
|
1497 | + if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2)) |
|
1498 | 1498 | { |
1499 | - $timespan = str_replace($t,substr($t,0,-3),$timespan); |
|
1499 | + $timespan = str_replace($t, substr($t, 0, -3), $timespan); |
|
1500 | 1500 | } |
1501 | 1501 | $timespan .= ':'; |
1502 | 1502 | } |
1503 | - return $timespan . ' ' . $duration; |
|
1503 | + return $timespan.' '.$duration; |
|
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | /** |
@@ -1511,13 +1511,13 @@ discard block |
||
1511 | 1511 | * @param boolean $append_email =false append email (Name <email>) |
1512 | 1512 | * @return string with name |
1513 | 1513 | */ |
1514 | - function participant_name($id,$use_type=false, $append_email=false) |
|
1514 | + function participant_name($id, $use_type = false, $append_email = false) |
|
1515 | 1515 | { |
1516 | 1516 | static $id2lid = array(); |
1517 | 1517 | static $id2email = array(); |
1518 | 1518 | |
1519 | 1519 | if ($use_type && $use_type != 'u') $id = $use_type.$id; |
1520 | - if($id === 0 || $id === '0') $id = $this->user; |
|
1520 | + if ($id === 0 || $id === '0') $id = $this->user; |
|
1521 | 1521 | |
1522 | 1522 | if (!isset($id2lid[$id])) |
1523 | 1523 | { |
@@ -1533,7 +1533,7 @@ discard block |
||
1533 | 1533 | else |
1534 | 1534 | { |
1535 | 1535 | $id2lid[$id] = common::grab_owner_name($id); |
1536 | - $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email'); |
|
1536 | + $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email'); |
|
1537 | 1537 | } |
1538 | 1538 | } |
1539 | 1539 | return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : ''); |
@@ -1547,37 +1547,37 @@ discard block |
||
1547 | 1547 | * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
1548 | 1548 | * @return array with id / names with status pairs |
1549 | 1549 | */ |
1550 | - function participants($event,$long_status=false,$show_group_invitation=false) |
|
1550 | + function participants($event, $long_status = false, $show_group_invitation = false) |
|
1551 | 1551 | { |
1552 | 1552 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
1553 | 1553 | $names = array(); |
1554 | - foreach((array)$event['participants'] as $id => $status) |
|
1554 | + foreach ((array)$event['participants'] as $id => $status) |
|
1555 | 1555 | { |
1556 | 1556 | if (!is_string($status)) continue; |
1557 | 1557 | $quantity = $role = null; |
1558 | - calendar_so::split_status($status,$quantity,$role); |
|
1558 | + calendar_so::split_status($status, $quantity, $role); |
|
1559 | 1559 | |
1560 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
1560 | + if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
1561 | 1561 | |
1562 | 1562 | $lang_status = lang($this->verbose_status[$status]); |
1563 | 1563 | if (!$long_status) |
1564 | 1564 | { |
1565 | - switch($status[0]) |
|
1565 | + switch ($status[0]) |
|
1566 | 1566 | { |
1567 | 1567 | case 'A': // accepted |
1568 | - $status = html::image('calendar','accepted',$lang_status); |
|
1568 | + $status = html::image('calendar', 'accepted', $lang_status); |
|
1569 | 1569 | break; |
1570 | 1570 | case 'R': // rejected |
1571 | - $status = html::image('calendar','rejected',$lang_status); |
|
1571 | + $status = html::image('calendar', 'rejected', $lang_status); |
|
1572 | 1572 | break; |
1573 | 1573 | case 'T': // tentative |
1574 | - $status = html::image('calendar','tentative',$lang_status); |
|
1574 | + $status = html::image('calendar', 'tentative', $lang_status); |
|
1575 | 1575 | break; |
1576 | 1576 | case 'U': // no response = unknown |
1577 | - $status = html::image('calendar','needs-action',$lang_status); |
|
1577 | + $status = html::image('calendar', 'needs-action', $lang_status); |
|
1578 | 1578 | break; |
1579 | 1579 | case 'D': // delegated |
1580 | - $status = html::image('calendar','forward',$lang_status); |
|
1580 | + $status = html::image('calendar', 'forward', $lang_status); |
|
1581 | 1581 | break; |
1582 | 1582 | case 'G': // group invitation |
1583 | 1583 | // Todo: Image, seems not to be used |
@@ -1599,13 +1599,13 @@ discard block |
||
1599 | 1599 | $role = lang($this->roles[$role]); |
1600 | 1600 | } |
1601 | 1601 | // allow to use cats as roles (beside regular iCal ones) |
1602 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
1602 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
1603 | 1603 | { |
1604 | 1604 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
1605 | 1605 | } |
1606 | 1606 | else |
1607 | 1607 | { |
1608 | - $role = lang(str_replace('X-','',$role)); |
|
1608 | + $role = lang(str_replace('X-', '', $role)); |
|
1609 | 1609 | } |
1610 | 1610 | $names[$id] .= ' '.$role; |
1611 | 1611 | } |
@@ -1622,13 +1622,13 @@ discard block |
||
1622 | 1622 | * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
1623 | 1623 | * @return array with id / names |
1624 | 1624 | */ |
1625 | - function categories($category,&$color) |
|
1625 | + function categories($category, &$color) |
|
1626 | 1626 | { |
1627 | 1627 | static $id2cat = array(); |
1628 | 1628 | $cats = array(); |
1629 | 1629 | $color = 0; |
1630 | 1630 | |
1631 | - foreach(explode(',',$category) as $cat_id) |
|
1631 | + foreach (explode(',', $category) as $cat_id) |
|
1632 | 1632 | { |
1633 | 1633 | if (!$cat_id) continue; |
1634 | 1634 | |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | { |
1644 | 1644 | $color = $cat['data']['color']; |
1645 | 1645 | } |
1646 | - elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
1646 | + elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
1647 | 1647 | { |
1648 | 1648 | $color = $parts[1]; |
1649 | 1649 | } |
@@ -1655,12 +1655,12 @@ discard block |
||
1655 | 1655 | /** |
1656 | 1656 | * This is called only by list_cals(). It was moved here to remove fatal error in php5 beta4 |
1657 | 1657 | */ |
1658 | - private static function _list_cals_add($id,&$users,&$groups) |
|
1658 | + private static function _list_cals_add($id, &$users, &$groups) |
|
1659 | 1659 | { |
1660 | 1660 | $name = common::grab_owner_name($id); |
1661 | 1661 | if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id))) |
1662 | 1662 | { |
1663 | - return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
1663 | + return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
1664 | 1664 | } |
1665 | 1665 | if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g') |
1666 | 1666 | { |
@@ -1672,7 +1672,7 @@ discard block |
||
1672 | 1672 | } |
1673 | 1673 | $arr[$id] = array( |
1674 | 1674 | 'grantor' => $id, |
1675 | - 'value' => ($type == 'g' ? 'g_' : '') . $id, |
|
1675 | + 'value' => ($type == 'g' ? 'g_' : '').$id, |
|
1676 | 1676 | 'name' => $name, |
1677 | 1677 | 'sname' => $egw_name |
1678 | 1678 | ); |
@@ -1694,26 +1694,26 @@ discard block |
||
1694 | 1694 | * @param int $user account_id of user to generate list for |
1695 | 1695 | * @param array $grants =null calendar grants from user, or null to query them from acl class |
1696 | 1696 | */ |
1697 | - public static function list_calendars($user, array $grants=null) |
|
1697 | + public static function list_calendars($user, array $grants = null) |
|
1698 | 1698 | { |
1699 | 1699 | if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
1700 | 1700 | |
1701 | 1701 | $users = $groups = array(); |
1702 | - foreach(array_keys($grants) as $id) |
|
1702 | + foreach (array_keys($grants) as $id) |
|
1703 | 1703 | { |
1704 | - self::_list_cals_add($id,$users,$groups); |
|
1704 | + self::_list_cals_add($id, $users, $groups); |
|
1705 | 1705 | } |
1706 | 1706 | if (($memberships = $GLOBALS['egw']->accounts->membership($user))) |
1707 | 1707 | { |
1708 | - foreach($memberships as $group_info) |
|
1708 | + foreach ($memberships as $group_info) |
|
1709 | 1709 | { |
1710 | - self::_list_cals_add($group_info['account_id'],$users,$groups); |
|
1710 | + self::_list_cals_add($group_info['account_id'], $users, $groups); |
|
1711 | 1711 | |
1712 | - if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group_info['account_id'],EGW_ACL_READ,'calendar'))) |
|
1712 | + if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group_info['account_id'], EGW_ACL_READ, 'calendar'))) |
|
1713 | 1713 | { |
1714 | - foreach($account_perms as $id) |
|
1714 | + foreach ($account_perms as $id) |
|
1715 | 1715 | { |
1716 | - self::_list_cals_add($id,$users,$groups); |
|
1716 | + self::_list_cals_add($id, $users, $groups); |
|
1717 | 1717 | } |
1718 | 1718 | } |
1719 | 1719 | } |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | usort($users, array(__CLASS__, 'name_cmp')); |
1722 | 1722 | usort($groups, array(__CLASS__, 'name_cmp')); |
1723 | 1723 | |
1724 | - return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
1724 | + return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | /** |
@@ -1764,13 +1764,13 @@ discard block |
||
1764 | 1764 | * dow: day of week, 0=sunday, .., 6= saturday |
1765 | 1765 | * observande_rule: boolean |
1766 | 1766 | */ |
1767 | - function read_holidays($year=0) |
|
1767 | + function read_holidays($year = 0) |
|
1768 | 1768 | { |
1769 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
1769 | + if (!$year) $year = (int)date('Y', $this->now_su); |
|
1770 | 1770 | |
1771 | 1771 | if (!$this->cached_holidays) // try reading the holidays from the session |
1772 | 1772 | { |
1773 | - $this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar'); |
|
1773 | + $this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays', 'calendar'); |
|
1774 | 1774 | } |
1775 | 1775 | if (!isset($this->cached_holidays[$year])) |
1776 | 1776 | { |
@@ -1789,46 +1789,46 @@ discard block |
||
1789 | 1789 | 'n_family' => "!''", |
1790 | 1790 | 'bday' => "!''", |
1791 | 1791 | ); |
1792 | - $bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'), |
|
1793 | - 'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter); |
|
1792 | + $bdays = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'), |
|
1793 | + 'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter); |
|
1794 | 1794 | // search accounts too, if not stored in contacts repository |
1795 | 1795 | $extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) && |
1796 | 1796 | !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']; |
1797 | - if ($extra_accounts_search && ($bdays2 =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'), |
|
1798 | - 'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter+array('owner' => 0)))) |
|
1797 | + if ($extra_accounts_search && ($bdays2 = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'), |
|
1798 | + 'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter + array('owner' => 0)))) |
|
1799 | 1799 | { |
1800 | - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); |
|
1800 | + $bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2); |
|
1801 | 1801 | } |
1802 | 1802 | if ($bdays) |
1803 | 1803 | { |
1804 | 1804 | // sort by month and day only |
1805 | - usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];')); |
|
1806 | - foreach($bdays as $pers) |
|
1805 | + usort($bdays, create_function('$a,$b', 'return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];')); |
|
1806 | + foreach ($bdays as $pers) |
|
1807 | 1807 | { |
1808 | - if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00') |
|
1808 | + if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00') |
|
1809 | 1809 | { |
1810 | 1810 | //error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers)); |
1811 | 1811 | continue; |
1812 | 1812 | } |
1813 | - list($y,$m,$d) = explode('-',$pers['bday']); |
|
1814 | - if ($y > $year) continue; // not yet born |
|
1815 | - $this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array( |
|
1813 | + list($y, $m, $d) = explode('-', $pers['bday']); |
|
1814 | + if ($y > $year) continue; // not yet born |
|
1815 | + $this->cached_holidays[$year][sprintf('%04d%02d%02d', $year, $m, $d)][] = array( |
|
1816 | 1816 | 'day' => $d, |
1817 | 1817 | 'month' => $m, |
1818 | 1818 | 'occurence' => 0, |
1819 | 1819 | 'name' => lang('Birthday').' '.($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']).' '.$pers['n_middle'].' '. |
1820 | 1820 | $pers['n_family'].($y && !$GLOBALS['egw_info']['server']['hide_birthdays'] ? ' ('.$y.')' : ''), |
1821 | - 'birthyear' => $y, // this can be used to identify birthdays from holidays |
|
1821 | + 'birthyear' => $y, // this can be used to identify birthdays from holidays |
|
1822 | 1822 | ); |
1823 | 1823 | } |
1824 | 1824 | } |
1825 | 1825 | } |
1826 | 1826 | // store holidays and birthdays in the session |
1827 | - $this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar',$this->cached_holidays); |
|
1827 | + $this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays', 'calendar', $this->cached_holidays); |
|
1828 | 1828 | } |
1829 | - if ((int) $this->debug >= 2 || $this->debug == 'read_holidays') |
|
1829 | + if ((int)$this->debug >= 2 || $this->debug == 'read_holidays') |
|
1830 | 1830 | { |
1831 | - $this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$this->cached_holidays[$year]); |
|
1831 | + $this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $this->cached_holidays[$year]); |
|
1832 | 1832 | } |
1833 | 1833 | return $this->cached_holidays[$year]; |
1834 | 1834 | } |
@@ -1839,10 +1839,10 @@ discard block |
||
1839 | 1839 | * @param type $event |
1840 | 1840 | * @return array array of selected calendar fields |
1841 | 1841 | */ |
1842 | - function get_link_options ($event = array()) |
|
1842 | + function get_link_options($event = array()) |
|
1843 | 1843 | { |
1844 | - unset($event); // not used, but required by function signature |
|
1845 | - $options = array ( |
|
1844 | + unset($event); // not used, but required by function signature |
|
1845 | + $options = array( |
|
1846 | 1846 | 'end' => lang('End date'), |
1847 | 1847 | 'id' => lang('ID'), |
1848 | 1848 | 'owner' => lang('Event owner'), |
@@ -1869,7 +1869,7 @@ discard block |
||
1869 | 1869 | list($id, $recur) = explode('-', $event, 2); |
1870 | 1870 | $event = $this->read($id, $recur); |
1871 | 1871 | } |
1872 | - else if (!is_array($event) && (int) $event > 0) |
|
1872 | + else if (!is_array($event) && (int)$event > 0) |
|
1873 | 1873 | { |
1874 | 1874 | $event = $this->read($event); |
1875 | 1875 | } |
@@ -1877,7 +1877,7 @@ discard block |
||
1877 | 1877 | { |
1878 | 1878 | return $event; |
1879 | 1879 | } |
1880 | - $type = explode(',',$this->cal_prefs['link_title']); |
|
1880 | + $type = explode(',', $this->cal_prefs['link_title']); |
|
1881 | 1881 | if (is_array($type)) |
1882 | 1882 | { |
1883 | 1883 | foreach ($type as &$val) |
@@ -1903,10 +1903,10 @@ discard block |
||
1903 | 1903 | $extra_fields [] = $event[$val]; |
1904 | 1904 | } |
1905 | 1905 | } |
1906 | - $str_fields = implode(', ',$extra_fields); |
|
1907 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
1906 | + $str_fields = implode(', ', $extra_fields); |
|
1907 | + if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : ''); |
|
1908 | 1908 | } |
1909 | - return $this->format_date($event['start']) . ': ' . $event['title']; |
|
1909 | + return $this->format_date($event['start']).': '.$event['title']; |
|
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | /** |
@@ -1925,10 +1925,10 @@ discard block |
||
1925 | 1925 | 'offset' => $options['start'], |
1926 | 1926 | 'order' => 'cal_start DESC', |
1927 | 1927 | ); |
1928 | - if($options['num_rows']) { |
|
1928 | + if ($options['num_rows']) { |
|
1929 | 1929 | $query['num_rows'] = $options['num_rows']; |
1930 | 1930 | } |
1931 | - foreach((array) $this->search($query) as $event) |
|
1931 | + foreach ((array)$this->search($query) as $event) |
|
1932 | 1932 | { |
1933 | 1933 | $result[$event['id']] = $this->link_title($event); |
1934 | 1934 | } |
@@ -1945,11 +1945,11 @@ discard block |
||
1945 | 1945 | * @param int $user =null for which user to check, default current user |
1946 | 1946 | * @return boolean true if access is granted or false otherwise |
1947 | 1947 | */ |
1948 | - function file_access($id,$check,$rel_path,$user=null) |
|
1948 | + function file_access($id, $check, $rel_path, $user = null) |
|
1949 | 1949 | { |
1950 | - unset($rel_path); // not used, but required by function signature |
|
1950 | + unset($rel_path); // not used, but required by function signature |
|
1951 | 1951 | |
1952 | - return $this->check_perms($check,$id,0,'ts',null,$user); |
|
1952 | + return $this->check_perms($check, $id, 0, 'ts', null, $user); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | /** |
@@ -1959,47 +1959,47 @@ discard block |
||
1959 | 1959 | */ |
1960 | 1960 | function check_set_default_prefs() |
1961 | 1961 | { |
1962 | - if ($this->cal_prefs['interval'] && ($set = $GLOBALS['egw']->session->appsession('default_prefs_set','calendar'))) |
|
1962 | + if ($this->cal_prefs['interval'] && ($set = $GLOBALS['egw']->session->appsession('default_prefs_set', 'calendar'))) |
|
1963 | 1963 | { |
1964 | 1964 | return; |
1965 | 1965 | } |
1966 | - $GLOBALS['egw']->session->appsession('default_prefs_set','calendar','set'); |
|
1966 | + $GLOBALS['egw']->session->appsession('default_prefs_set', 'calendar', 'set'); |
|
1967 | 1967 | |
1968 | - $default_prefs =& $GLOBALS['egw']->preferences->default['calendar']; |
|
1969 | - $forced_prefs =& $GLOBALS['egw']->preferences->forced['calendar']; |
|
1968 | + $default_prefs = & $GLOBALS['egw']->preferences->default['calendar']; |
|
1969 | + $forced_prefs = & $GLOBALS['egw']->preferences->forced['calendar']; |
|
1970 | 1970 | |
1971 | 1971 | if (!($planner_start_with_group = $GLOBALS['egw']->accounts->name2id('Default'))) |
1972 | 1972 | { |
1973 | 1973 | $planner_start_with_group = '0'; |
1974 | 1974 | } |
1975 | - $subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
1975 | + $subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
1976 | 1976 | $values = array( |
1977 | - 'notifyAdded' => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'), |
|
1978 | - 'notifyCanceled' => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'), |
|
1979 | - 'notifyModified' => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'), |
|
1980 | - 'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'), |
|
1981 | - 'notifyResponse' => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'), |
|
1982 | - 'notifyAlarm' => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'), |
|
1977 | + 'notifyAdded' => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'), |
|
1978 | + 'notifyCanceled' => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'), |
|
1979 | + 'notifyModified' => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'), |
|
1980 | + 'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'), |
|
1981 | + 'notifyResponse' => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'), |
|
1982 | + 'notifyAlarm' => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'), |
|
1983 | 1983 | 'planner_start_with_group' => $planner_start_with_group, |
1984 | 1984 | 'interval' => 30, |
1985 | 1985 | ); |
1986 | - foreach($values as $var => $default) |
|
1986 | + foreach ($values as $var => $default) |
|
1987 | 1987 | { |
1988 | - $type = substr($var,0,6) == 'notify' ? 'forced' : 'default'; |
|
1988 | + $type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default'; |
|
1989 | 1989 | |
1990 | 1990 | // only set, if neither default nor forced pref exists |
1991 | 1991 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
1992 | 1992 | { |
1993 | - $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
|
1994 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
1993 | + $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too |
|
1994 | + if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced'); |
|
1995 | 1995 | $this->cal_prefs[$var] = $default; |
1996 | 1996 | $need_save = True; |
1997 | 1997 | } |
1998 | 1998 | } |
1999 | 1999 | if ($need_save) |
2000 | 2000 | { |
2001 | - $GLOBALS['egw']->preferences->save_repository(False,'default'); |
|
2002 | - $GLOBALS['egw']->preferences->save_repository(False,'forced'); |
|
2001 | + $GLOBALS['egw']->preferences->save_repository(False, 'default'); |
|
2002 | + $GLOBALS['egw']->preferences->save_repository(False, 'forced'); |
|
2003 | 2003 | } |
2004 | 2004 | } |
2005 | 2005 | |
@@ -2009,7 +2009,7 @@ discard block |
||
2009 | 2009 | * @param int|string $user account_id or account_lid |
2010 | 2010 | * @param string $pw =null password |
2011 | 2011 | */ |
2012 | - static function freebusy_url($user='',$pw=null) |
|
2012 | + static function freebusy_url($user = '', $pw = null) |
|
2013 | 2013 | { |
2014 | 2014 | if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
2015 | 2015 | |
@@ -2022,8 +2022,8 @@ discard block |
||
2022 | 2022 | elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2) |
2023 | 2023 | { |
2024 | 2024 | $credentials = $GLOBALS['egw_info']['user']['account_lid'] |
2025 | - . ':' . $GLOBALS['egw_info']['user']['passwd']; |
|
2026 | - $credentials = '&cred=' . base64_encode($credentials); |
|
2025 | + . ':'.$GLOBALS['egw_info']['user']['passwd']; |
|
2026 | + $credentials = '&cred='.base64_encode($credentials); |
|
2027 | 2027 | } |
2028 | 2028 | return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ? |
2029 | 2029 | ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : ''). |
@@ -2055,11 +2055,11 @@ discard block |
||
2055 | 2055 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
2056 | 2056 | * @return string|boolean string with etag or false |
2057 | 2057 | */ |
2058 | - function get_etag($entry, &$schedule_tag=null) |
|
2058 | + function get_etag($entry, &$schedule_tag = null) |
|
2059 | 2059 | { |
2060 | 2060 | if (!is_array($entry)) |
2061 | 2061 | { |
2062 | - list($id,$recur_date) = explode(':',$entry); |
|
2062 | + list($id, $recur_date) = explode(':', $entry); |
|
2063 | 2063 | $entry = $this->read($id, $recur_date, true, 'server'); |
2064 | 2064 | } |
2065 | 2065 | $etag = $schedule_tag = $entry['id'].':'.$entry['etag']; |
@@ -2077,15 +2077,15 @@ discard block |
||
2077 | 2077 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
2078 | 2078 | * @return integer |
2079 | 2079 | */ |
2080 | - public function get_ctag($user, $filter='owner', $master_only=false) |
|
2080 | + public function get_ctag($user, $filter = 'owner', $master_only = false) |
|
2081 | 2081 | { |
2082 | 2082 | if ($this->debug > 1) $startime = microtime(true); |
2083 | 2083 | |
2084 | 2084 | // resolve users to add memberships for users and members for groups |
2085 | 2085 | $users = $this->resolve_users($user); |
2086 | - $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
2086 | + $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
2087 | 2087 | |
2088 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter') = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
2088 | + if ($this->debug > 1) error_log(__METHOD__."($user, '$filter') = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs"); |
|
2089 | 2089 | return $ctag; |
2090 | 2090 | } |
2091 | 2091 | |
@@ -2105,7 +2105,7 @@ discard block |
||
2105 | 2105 | |
2106 | 2106 | $content = array( |
2107 | 2107 | 'info_cat' => $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $calendar['category']), |
2108 | - 'info_priority' => $calendar['priority'] , |
|
2108 | + 'info_priority' => $calendar['priority'], |
|
2109 | 2109 | 'info_public' => $calendar['public'] != 'private', |
2110 | 2110 | 'info_subject' => $calendar['title'], |
2111 | 2111 | 'info_des' => $calendar['description'], |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | $content['link_app'][] = $calendar['info_link']['app']; |
2121 | 2121 | $content['link_id'][] = $calendar['info_link']['id']; |
2122 | 2122 | // Copy claendar's links |
2123 | - foreach(egw_link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link) |
|
2123 | + foreach (egw_link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link) |
|
2124 | 2124 | { |
2125 | 2125 | if ($link['app'] != egw_link::VFS_APPNAME) |
2126 | 2126 | { |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | } |
2134 | 2134 | } |
2135 | 2135 | // Copy same custom fields |
2136 | - foreach(array_keys(config::get_customfields('infolog')) as $name) |
|
2136 | + foreach (array_keys(config::get_customfields('infolog')) as $name) |
|
2137 | 2137 | { |
2138 | 2138 | if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
2139 | 2139 | } |
@@ -2151,20 +2151,20 @@ discard block |
||
2151 | 2151 | function timesheet_set($data) |
2152 | 2152 | { |
2153 | 2153 | $set = array(); |
2154 | - list($id,$recurrence) = explode(':',$data['id']); |
|
2155 | - if ((int)$id && ($event = $this->read($id,$recurrence))) |
|
2154 | + list($id, $recurrence) = explode(':', $data['id']); |
|
2155 | + if ((int)$id && ($event = $this->read($id, $recurrence))) |
|
2156 | 2156 | { |
2157 | 2157 | $set['ts_start'] = $event['start']; |
2158 | 2158 | $set['ts_title'] = $this->link_title($event); |
2159 | - $set['start_time'] = egw_time::to($event['start'],'H:i'); |
|
2159 | + $set['start_time'] = egw_time::to($event['start'], 'H:i'); |
|
2160 | 2160 | $set['ts_description'] = $event['description']; |
2161 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
2161 | + if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
2162 | 2162 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
2163 | 2163 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
2164 | - $set['end_time'] = null; // unset end-time |
|
2164 | + $set['end_time'] = null; // unset end-time |
|
2165 | 2165 | $set['cat_id'] = (int)$event['category']; |
2166 | 2166 | |
2167 | - foreach(egw_link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link) |
|
2167 | + foreach (egw_link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link) |
|
2168 | 2168 | { |
2169 | 2169 | if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME) |
2170 | 2170 | { |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | |
83 | 83 | // Register table plugins |
84 | 84 | $this->table_plugins['participant'] = 'participant'; |
85 | - for($i = 0; $i < 7; $i++) |
|
85 | + for ($i = 0; $i < 7; $i++) |
|
86 | 86 | { |
87 | 87 | $this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin'; |
88 | 88 | } |
89 | - for($i = 1; $i <= 31; $i++) { |
|
89 | + for ($i = 1; $i <= 31; $i++) { |
|
90 | 90 | $this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31) |
91 | 91 | } |
92 | - foreach(self::$relative as $day) { |
|
92 | + foreach (self::$relative as $day) { |
|
93 | 93 | $this->table_plugins[$day] = 'day'; // Current day |
94 | 94 | } |
95 | - $this->query = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
95 | + $this->query = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
96 | 96 | $this->query['users'] = explode(',', $this->query['owner']); |
97 | 97 | $this->query['num_rows'] = -1; |
98 | 98 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * @param string $charset=null charset to override default set by mimetype or export charset |
114 | 114 | * @return string|boolean merged document or false on error |
115 | 115 | */ |
116 | - function merge_string($content,$ids,$err,$mimetype,$fix) |
|
116 | + function merge_string($content, $ids, $err, $mimetype, $fix) |
|
117 | 117 | { |
118 | 118 | // Handle merging a list of events into a document with range instead of pagerepeat |
119 | - if(strpos($content, '$$pagerepeat') === false && strpos($content, '{{pagerepeat') === false && count($ids) > 1) |
|
119 | + if (strpos($content, '$$pagerepeat') === false && strpos($content, '{{pagerepeat') === false && count($ids) > 1) |
|
120 | 120 | { |
121 | 121 | // Merging more than one something will fail without pagerepeat |
122 | 122 | if (is_array($ids) && $ids[0]['id']) |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | $events = $ids; |
126 | 126 | $ids = array('start' => PHP_INT_MAX, 'end' => 0); |
127 | 127 | $this->ids = array(); |
128 | - foreach($events as $event) { |
|
129 | - if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'],'ts'); |
|
130 | - if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'],'ts'); |
|
128 | + foreach ($events as $event) { |
|
129 | + if ($event['start'] && egw_time::to($event['start'], 'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'], 'ts'); |
|
130 | + if ($event['end'] && egw_time::to($event['end'], 'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'], 'ts'); |
|
131 | 131 | // Keep ids for future use |
132 | 132 | $this->ids[] = $event['id']; |
133 | 133 | } |
134 | 134 | $ids = array($ids); |
135 | 135 | } |
136 | 136 | } |
137 | - return parent::merge_string($content, $ids, $err, $mimetype,$fix); |
|
137 | + return parent::merge_string($content, $ids, $err, $mimetype, $fix); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | * @param string &$content=null content to create some replacements only if they are used |
145 | 145 | * @return array|boolean |
146 | 146 | */ |
147 | - protected function get_replacements($id,&$content=null) |
|
147 | + protected function get_replacements($id, &$content = null) |
|
148 | 148 | { |
149 | 149 | $prefix = ''; |
150 | 150 | // List events ? |
151 | - if(is_array($id) && !$id['id'] && !$id[0]['id']) |
|
151 | + if (is_array($id) && !$id['id'] && !$id[0]['id']) |
|
152 | 152 | { |
153 | 153 | $events = $this->bo->search($this->query + $id + array( |
154 | 154 | 'offset' => 0, |
155 | 155 | 'order' => 'cal_start', |
156 | 156 | 'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null |
157 | 157 | )); |
158 | - if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
158 | + if (strpos($content, '$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
159 | 159 | { |
160 | - array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
160 | + array_unshift($events, false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
161 | 161 | $prefix = 'calendar/%d'; |
162 | 162 | } |
163 | 163 | } |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $events = $id; |
168 | 168 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
169 | 169 | $this->ids = array(); |
170 | - foreach($events as $event) { |
|
171 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
172 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
170 | + foreach ($events as $event) { |
|
171 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
172 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
173 | 173 | // Keep ids for future use |
174 | - $this->ids[] = $event['id']; |
|
174 | + $this->ids[] = $event['id']; |
|
175 | 175 | } |
176 | 176 | $id = array($id); |
177 | 177 | } |
@@ -183,20 +183,20 @@ discard block |
||
183 | 183 | // as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions |
184 | 184 | if (bo_merge::hasExportLimit($this->export_limit) && !bo_merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit) |
185 | 185 | { |
186 | - $err = lang('No rights to export more than %1 entries!',(int)$this->export_limit); |
|
186 | + $err = lang('No rights to export more than %1 entries!', (int)$this->export_limit); |
|
187 | 187 | throw new egw_exception_wrong_userinput($err); |
188 | 188 | } |
189 | 189 | $replacements = array(); |
190 | 190 | $n = 0; |
191 | - foreach($events as $event) |
|
191 | + foreach ($events as $event) |
|
192 | 192 | { |
193 | - $values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content); |
|
194 | - if(is_array($id) && $id['start']) |
|
193 | + $values = $this->calendar_replacements($event, sprintf($prefix, ++$n), $content); |
|
194 | + if (is_array($id) && $id['start']) |
|
195 | 195 | { |
196 | - foreach(self::$range_tags as $key => $format) |
|
196 | + foreach (self::$range_tags as $key => $format) |
|
197 | 197 | { |
198 | 198 | $value = date($format, $key == 'end' ? $id['end'] : $id['start']); |
199 | - if($key == 'month') $value = lang($value); |
|
199 | + if ($key == 'month') $value = lang($value); |
|
200 | 200 | $values["$\$range/$key$$"] = $value; |
201 | 201 | } |
202 | 202 | } |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @param boolean $last_event_too=false also include information about the last event |
213 | 213 | * @return array |
214 | 214 | */ |
215 | - public function calendar_replacements($id,$prefix = '', &$content = '') |
|
215 | + public function calendar_replacements($id, $prefix = '', &$content = '') |
|
216 | 216 | { |
217 | 217 | $replacements = array(); |
218 | - if(!is_array($id) || !$id['start']) { |
|
218 | + if (!is_array($id) || !$id['start']) { |
|
219 | 219 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
220 | 220 | } else { |
221 | 221 | $event = $id; |
@@ -228,68 +228,68 @@ discard block |
||
228 | 228 | importexport_export_csv::convert($record, $types, 'calendar'); |
229 | 229 | |
230 | 230 | $array = $record->get_record_array(); |
231 | - foreach($array as $key => $value) |
|
231 | + foreach ($array as $key => $value) |
|
232 | 232 | { |
233 | - $replacements['$$'.($prefix?$prefix.'/':'').$key.'$$'] = $value; |
|
233 | + $replacements['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
234 | 234 | } |
235 | 235 | |
236 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id']; |
|
237 | - foreach($this->bo->event2array($event) as $name => $data) |
|
236 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_id'.'$$'] = $event['id']; |
|
237 | + foreach ($this->bo->event2array($event) as $name => $data) |
|
238 | 238 | { |
239 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
240 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
239 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
240 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
241 | 241 | } |
242 | 242 | // Add seperate lists of participants by type |
243 | - if(strpos($content, 'calendar_participants/')!== false) |
|
243 | + if (strpos($content, 'calendar_participants/') !== false) |
|
244 | 244 | { |
245 | 245 | $types = array(); |
246 | - foreach($this->bo->resources as $resource) |
|
246 | + foreach ($this->bo->resources as $resource) |
|
247 | 247 | { |
248 | 248 | $types[$resource['app']] = array(); |
249 | 249 | } |
250 | - foreach($event['participants'] as $uid => $status) |
|
250 | + foreach ($event['participants'] as $uid => $status) |
|
251 | 251 | { |
252 | 252 | $type = $this->bo->resources[$uid[0]]['app']; |
253 | - if($type == 'home-accounts') |
|
253 | + if ($type == 'home-accounts') |
|
254 | 254 | { |
255 | 255 | $type = ($GLOBALS['egw']->accounts->get_type($uid) == 'g' ? 'group' : 'account'); |
256 | 256 | } |
257 | 257 | $types[$type][] = $this->bo->participant_name($uid); |
258 | 258 | } |
259 | - foreach($types as $t_id => $type) |
|
259 | + foreach ($types as $t_id => $type) |
|
260 | 260 | { |
261 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type); |
|
261 | + $replacements['$$'.($prefix ? $prefix.'/' : '')."calendar_participants/{$t_id}$$"] = implode(', ', $type); |
|
262 | 262 | } |
263 | 263 | } |
264 | - if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$']) |
|
264 | + if (!$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$']) |
|
265 | 265 | { |
266 | 266 | // Need to set it to '' if not set or previous record may be used |
267 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'] = ''; |
|
267 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'] = ''; |
|
268 | 268 | } |
269 | - foreach(array('start','end') as $what) |
|
269 | + foreach (array('start', 'end') as $what) |
|
270 | 270 | { |
271 | - foreach(array( |
|
271 | + foreach (array( |
|
272 | 272 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
273 | 273 | 'day' => 'l', |
274 | - 'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
274 | + 'time' => (date('Ymd', $event['start']) != date('Ymd', $event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '').($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
275 | 275 | ) as $name => $format) |
276 | 276 | { |
277 | - $value = egw_time::to($event[$what],$format); |
|
277 | + $value = egw_time::to($event[$what], $format); |
|
278 | 278 | if ($format == 'l') $value = lang($value); |
279 | - $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; |
|
279 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$what.$name.'$$'] = $value; |
|
280 | 280 | } |
281 | 281 | } |
282 | - $duration = ($event['end'] - $event['start'])/60; |
|
283 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
282 | + $duration = ($event['end'] - $event['start']) / 60; |
|
283 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
284 | 284 | |
285 | 285 | // Add in contact stuff for owner |
286 | - if (strpos($content,'$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'],'person_id'))) |
|
286 | + if (strpos($content, '$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'], 'person_id'))) |
|
287 | 287 | { |
288 | - $replacements += $this->contact_replacements($user,($prefix ? $prefix.'/':'').'calendar_owner'); |
|
289 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'],'account_primary_group')); |
|
288 | + $replacements += $this->contact_replacements($user, ($prefix ? $prefix.'/' : '').'calendar_owner'); |
|
289 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_primary_group')); |
|
290 | 290 | } |
291 | 291 | |
292 | - if($content && strpos($content, '$$#') !== FALSE) |
|
292 | + if ($content && strpos($content, '$$#') !== FALSE) |
|
293 | 293 | { |
294 | 294 | $this->cf_link_to_expand($event, $content, $replacements); |
295 | 295 | } |
@@ -315,77 +315,77 @@ discard block |
||
315 | 315 | * @param string $repeat Text being repeated for each entry |
316 | 316 | * @return array |
317 | 317 | */ |
318 | - public function day_plugin($plugin,$date,$n,$repeat) |
|
318 | + public function day_plugin($plugin, $date, $n, $repeat) |
|
319 | 319 | { |
320 | 320 | static $days = null; |
321 | - if(is_array($date) && !$date['start']) { |
|
321 | + if (is_array($date) && !$date['start']) { |
|
322 | 322 | // List of IDs |
323 | - if($date[0]['start']) { |
|
323 | + if ($date[0]['start']) { |
|
324 | 324 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
325 | - foreach($date as $event) { |
|
326 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
327 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
325 | + foreach ($date as $event) { |
|
326 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
327 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
328 | 328 | } |
329 | 329 | $date = $id; |
330 | 330 | } else { |
331 | 331 | $event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null); |
332 | - if(date('l',$event['start']) != $plugin) return array(); |
|
332 | + if (date('l', $event['start']) != $plugin) return array(); |
|
333 | 333 | $date = $event['start']; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | $_date = $date['start'] ? $date['start'] : $date; |
338 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
338 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
339 | 339 | |
340 | 340 | $events = $this->bo->search($this->query + array( |
341 | - 'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
342 | - 'end' => $date['end'] ? $date['end'] : mktime(23,59,59,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
341 | + 'start' => $date['end'] ? $date['start'] : mktime(0, 0, 0, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
342 | + 'end' => $date['end'] ? $date['end'] : mktime(23, 59, 59, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
343 | 343 | 'offset' => 0, |
344 | 344 | 'num_rows' => 20, |
345 | 345 | 'order' => 'cal_start', |
346 | 346 | 'daywise' => true, |
347 | - 'cfs' => array(), // read all custom-fields |
|
347 | + 'cfs' => array(), // read all custom-fields |
|
348 | 348 | )); |
349 | 349 | |
350 | 350 | if (true) $days = array(); |
351 | 351 | $replacements = array(); |
352 | 352 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
353 | - foreach($events as $day => $list) |
|
353 | + foreach ($events as $day => $list) |
|
354 | 354 | { |
355 | - foreach($list as $event) |
|
355 | + foreach ($list as $event) |
|
356 | 356 | { |
357 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
357 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
358 | 358 | $start = egw_time::to($event['start'], 'array'); |
359 | 359 | $end = egw_time::to($event['end'], 'array'); |
360 | 360 | $replacements = $this->calendar_replacements($event); |
361 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
362 | - $dow = date('l',$event['start']); |
|
361 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
362 | + $dow = date('l', $event['start']); |
|
363 | 363 | } else { |
364 | 364 | $dow = date('l', strtotime($day)); |
365 | 365 | // Fancy date+time formatting for multi-day events |
366 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
367 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
366 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
367 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
368 | 368 | } |
369 | 369 | |
370 | - $days[date('Ymd',$_date)][$dow][] = $replacements; |
|
370 | + $days[date('Ymd', $_date)][$dow][] = $replacements; |
|
371 | 371 | } |
372 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
372 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
373 | 373 | $date_marker = array( |
374 | 374 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
375 | 375 | '$$day/name$$' => lang(date('l', strtotime($day))) |
376 | 376 | ); |
377 | - if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) { |
|
377 | + if (!is_array($days[date('Ymd', $_date)][date('l', strtotime($day))])) { |
|
378 | 378 | $blank = $this->calendar_replacements(array()); |
379 | - foreach($blank as &$value) |
|
379 | + foreach ($blank as &$value) |
|
380 | 380 | { |
381 | 381 | $value = ''; |
382 | 382 | } |
383 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][] = $blank; |
|
383 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][] = $blank; |
|
384 | 384 | } |
385 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][0] += $date_marker; |
|
385 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][0] += $date_marker; |
|
386 | 386 | } |
387 | 387 | } |
388 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
388 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -399,27 +399,27 @@ discard block |
||
399 | 399 | * @param string $repeat Text being repeated for each entry |
400 | 400 | * @return array |
401 | 401 | */ |
402 | - public function day($plugin,$id,$n,$repeat) |
|
402 | + public function day($plugin, $id, $n, $repeat) |
|
403 | 403 | { |
404 | 404 | static $days = null; |
405 | 405 | |
406 | 406 | // Figure out which day |
407 | - list($type, $which) = explode('_',$plugin); |
|
408 | - if($type == 'day' && $which) |
|
407 | + list($type, $which) = explode('_', $plugin); |
|
408 | + if ($type == 'day' && $which) |
|
409 | 409 | { |
410 | - if($id[0]['start']) |
|
410 | + if ($id[0]['start']) |
|
411 | 411 | { |
412 | 412 | $dates = array('start' => PHP_INT_MAX, 'end' => 0); |
413 | - foreach($id as $event) { |
|
414 | - if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
415 | - if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
413 | + foreach ($id as $event) { |
|
414 | + if ($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
415 | + if ($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
416 | 416 | } |
417 | 417 | $id = $dates; |
418 | 418 | } |
419 | 419 | $arr = $this->bo->date2array($id['start']); |
420 | 420 | $arr['day'] = $which; |
421 | 421 | $date = $this->bo->date2ts($arr); |
422 | - if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
422 | + if (is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
423 | 423 | } |
424 | 424 | elseif ($plugin == 'selected') |
425 | 425 | { |
@@ -429,64 +429,64 @@ discard block |
||
429 | 429 | { |
430 | 430 | $date = strtotime($plugin); |
431 | 431 | } |
432 | - if($type == 'day' && is_array($id) && !$id['start']) { |
|
432 | + if ($type == 'day' && is_array($id) && !$id['start']) { |
|
433 | 433 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
434 | - if($which && date('d',$event['start']) != $which) return array(); |
|
435 | - if(date('Ymd',$date) != date('Ymd', $event['start'])) return array(); |
|
434 | + if ($which && date('d', $event['start']) != $which) return array(); |
|
435 | + if (date('Ymd', $date) != date('Ymd', $event['start'])) return array(); |
|
436 | 436 | return $n == 0 ? $this->calendar_replacements($event) : array(); |
437 | 437 | } |
438 | 438 | |
439 | 439 | // Use start for cache, in case of multiple months |
440 | 440 | $_date = $id['start'] ? $id['start'] : $date; |
441 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
441 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
442 | 442 | |
443 | 443 | $events = $this->bo->search($this->query + array( |
444 | 444 | 'start' => $date, |
445 | - 'end' => mktime(23,59,59,date('m',$date),date('d',$date),date('Y',$date)), |
|
445 | + 'end' => mktime(23, 59, 59, date('m', $date), date('d', $date), date('Y', $date)), |
|
446 | 446 | 'offset' => 0, |
447 | 447 | 'num_rows' => 20, |
448 | 448 | 'order' => 'cal_start', |
449 | 449 | 'daywise' => true, |
450 | - 'cfs' => array(), // read all custom-fields |
|
450 | + 'cfs' => array(), // read all custom-fields |
|
451 | 451 | )); |
452 | 452 | |
453 | 453 | $replacements = array(); |
454 | 454 | if (true) $days = array(); |
455 | 455 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
456 | - foreach($events as $day => $list) |
|
456 | + foreach ($events as $day => $list) |
|
457 | 457 | { |
458 | - foreach($list as $event) |
|
458 | + foreach ($list as $event) |
|
459 | 459 | { |
460 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
460 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
461 | 461 | $start = egw_time::to($event['start'], 'array'); |
462 | 462 | $end = egw_time::to($event['end'], 'array'); |
463 | 463 | $replacements = $this->calendar_replacements($event); |
464 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
464 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
465 | 465 | //$dow = date('l',$event['start']); |
466 | 466 | } else { |
467 | 467 | // Fancy date+time formatting for multi-day events |
468 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
469 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
468 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
469 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
470 | 470 | } |
471 | - $days[date('Ymd',$_date)][$plugin][] = $replacements; |
|
471 | + $days[date('Ymd', $_date)][$plugin][] = $replacements; |
|
472 | 472 | } |
473 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
473 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
474 | 474 | $date_marker = array( |
475 | 475 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
476 | 476 | '$$day/name$$' => lang(date('l', strtotime($day))) |
477 | 477 | ); |
478 | - if(!is_array($days[date('Ymd',$_date)][$plugin])) { |
|
478 | + if (!is_array($days[date('Ymd', $_date)][$plugin])) { |
|
479 | 479 | $blank = $this->calendar_replacements(array()); |
480 | - foreach($blank as &$value) |
|
480 | + foreach ($blank as &$value) |
|
481 | 481 | { |
482 | 482 | $value = ''; |
483 | 483 | } |
484 | - $days[date('Ymd',$_date)][$plugin][] = $blank; |
|
484 | + $days[date('Ymd', $_date)][$plugin][] = $blank; |
|
485 | 485 | } |
486 | - $days[date('Ymd',$_date)][$plugin][0] += $date_marker; |
|
486 | + $days[date('Ymd', $_date)][$plugin][0] += $date_marker; |
|
487 | 487 | } |
488 | 488 | } |
489 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
489 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -499,30 +499,30 @@ discard block |
||
499 | 499 | * @param int $n |
500 | 500 | * @return array |
501 | 501 | */ |
502 | - public function participant($plugin,$id,$n) |
|
502 | + public function participant($plugin, $id, $n) |
|
503 | 503 | { |
504 | - unset($plugin); // not used, but required by function signature |
|
504 | + unset($plugin); // not used, but required by function signature |
|
505 | 505 | |
506 | - if(!is_array($id) || !$id['start']) { |
|
506 | + if (!is_array($id) || !$id['start']) { |
|
507 | 507 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
508 | 508 | } else { |
509 | 509 | $event = $id; |
510 | 510 | } |
511 | 511 | |
512 | - if(!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
512 | + if (!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
513 | 513 | |
514 | 514 | $participant = null; |
515 | 515 | $status = null; |
516 | 516 | $i = -1; |
517 | - foreach($event['participants'] as $participant => $status) { |
|
518 | - if(++$i == $n) break; |
|
517 | + foreach ($event['participants'] as $participant => $status) { |
|
518 | + if (++$i == $n) break; |
|
519 | 519 | } |
520 | 520 | |
521 | - if(!$participant) return array(); |
|
521 | + if (!$participant) return array(); |
|
522 | 522 | |
523 | 523 | // Add some common information |
524 | 524 | $quantity = $role = null; |
525 | - calendar_so::split_status($status,$quantity,$role); |
|
525 | + calendar_so::split_status($status, $quantity, $role); |
|
526 | 526 | if ($role != 'REQ-PARTICIPANT') |
527 | 527 | { |
528 | 528 | if (isset($this->bo->roles[$role])) |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | $role = lang($this->bo->roles[$role]); |
531 | 531 | } |
532 | 532 | // allow to use cats as roles (beside regular iCal ones) |
533 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
533 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
534 | 534 | { |
535 | 535 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
536 | 536 | } |
537 | 537 | else |
538 | 538 | { |
539 | - $role = lang(str_replace('X-','',$role)); |
|
539 | + $role = lang(str_replace('X-', '', $role)); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | $info = array( |
@@ -549,26 +549,26 @@ discard block |
||
549 | 549 | switch ($participant[0]) |
550 | 550 | { |
551 | 551 | case 'c': |
552 | - $replacements = $this->contact_replacements(substr($participant,1),''); |
|
552 | + $replacements = $this->contact_replacements(substr($participant, 1), ''); |
|
553 | 553 | break; |
554 | 554 | case 'r': |
555 | 555 | if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo'); |
556 | - if (($resource = self::$resources->read(substr($participant,1)))) |
|
556 | + if (($resource = self::$resources->read(substr($participant, 1)))) |
|
557 | 557 | { |
558 | - foreach($resource as $name => $value) |
|
558 | + foreach ($resource as $name => $value) |
|
559 | 559 | { |
560 | 560 | $replacements['$$'.$name.'$$'] = $value; |
561 | 561 | } |
562 | 562 | } |
563 | 563 | break; |
564 | 564 | default: |
565 | - if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant,'person_id'))) |
|
565 | + if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant, 'person_id'))) |
|
566 | 566 | { |
567 | - $replacements = $this->contact_replacements($contact,''); |
|
567 | + $replacements = $this->contact_replacements($contact, ''); |
|
568 | 568 | } |
569 | 569 | break; |
570 | 570 | } |
571 | - foreach($info as $name => $value) |
|
571 | + foreach ($info as $name => $value) |
|
572 | 572 | { |
573 | 573 | $replacements['$$'.$name.'$$'] = $value; |
574 | 574 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>"; |
591 | 591 | |
592 | 592 | $n = 0; |
593 | - foreach(array( |
|
593 | + foreach (array( |
|
594 | 594 | 'calendar_id' => lang('Calendar ID'), |
595 | 595 | 'calendar_title' => lang('Title'), |
596 | 596 | 'calendar_description' => lang('Description'), |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | 'calendar_owner' => lang('Owner'), |
614 | 614 | ) as $name => $label) |
615 | 615 | { |
616 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
616 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
617 | 617 | { |
618 | 618 | echo "</tr>\n"; |
619 | 619 | $n++; |
@@ -626,13 +626,13 @@ discard block |
||
626 | 626 | |
627 | 627 | echo '<tr><td colspan="4"><h3>'.lang('Range fields').":</h3></td></tr>"; |
628 | 628 | echo '<tr><td colspan="4">'.lang('If you select a range (month, week, etc) instead of a list of entries, these extra fields are available').'</td></tr>'; |
629 | - foreach(array_keys(self::$range_tags) as $name) |
|
629 | + foreach (array_keys(self::$range_tags) as $name) |
|
630 | 630 | { |
631 | 631 | echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n"; |
632 | 632 | } |
633 | 633 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
634 | 634 | $custom = config::get_customfields('calendar'); |
635 | - foreach($custom as $name => $field) |
|
635 | + foreach ($custom as $name => $field) |
|
636 | 636 | { |
637 | 637 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
638 | 638 | } |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | echo '<tr><td colspan="4"><h3>'.lang('Participants').":</h3></td></tr>"; |
642 | 642 | echo '<tr><td>{{calendar_participants/account}}</td><td colspan="3">'.lang('Accounts')."</td></tr>\n"; |
643 | 643 | echo '<tr><td>{{calendar_participants/group}}</td><td colspan="3">'.lang('Groups')."</td></tr>\n"; |
644 | - foreach($this->bo->resources as $resource) |
|
644 | + foreach ($this->bo->resources as $resource) |
|
645 | 645 | { |
646 | - if($resource['type']) |
|
646 | + if ($resource['type']) |
|
647 | 647 | { |
648 | 648 | echo '<tr><td>{{calendar_participants/'.$resource['app'].'}}</td><td colspan="3">'.lang($resource['app'])."</td></tr>\n"; |
649 | 649 | } |
@@ -660,19 +660,19 @@ discard block |
||
660 | 660 | echo '<tr style="vertical-align:top"><td colspan="2"><table >'; |
661 | 661 | echo '<tr><td><h3>'.lang('Day of week tables').":</h3></td></tr>"; |
662 | 662 | $days = array(); |
663 | - for($i = 0; $i < 7; $i++) |
|
663 | + for ($i = 0; $i < 7; $i++) |
|
664 | 664 | { |
665 | - $days[date('N',strtotime("+$i days"))] = date('l',strtotime("+$i days")); |
|
665 | + $days[date('N', strtotime("+$i days"))] = date('l', strtotime("+$i days")); |
|
666 | 666 | } |
667 | 667 | ksort($days); |
668 | - foreach($days as $day) |
|
668 | + foreach ($days as $day) |
|
669 | 669 | { |
670 | - echo '<tr><td>{{table/'.$day. '}} ... {{endtable}}</td></tr>'; |
|
670 | + echo '<tr><td>{{table/'.$day.'}} ... {{endtable}}</td></tr>'; |
|
671 | 671 | } |
672 | 672 | echo '</table></td><td colspan="2"><table >'; |
673 | 673 | echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>"; |
674 | - foreach(self::$relative as $value) { |
|
675 | - echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>'; |
|
674 | + foreach (self::$relative as $value) { |
|
675 | + echo '<tr><td>{{table/'.$value.'}} ... {{endtable}}</td></tr>'; |
|
676 | 676 | } |
677 | 677 | echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>'; |
678 | 678 | echo '</table></td></tr>'; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>'; |
681 | 681 | |
682 | 682 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
683 | - foreach(array( |
|
683 | + foreach (array( |
|
684 | 684 | 'link' => lang('HTML link to the current record'), |
685 | 685 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
686 | 686 | 'attachments' => lang('List of files linked to the current record'), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | unset($country); |
60 | 60 | unset($this->country_array[' ']); |
61 | 61 | // try to translate them and sort alphabetic |
62 | - foreach($this->country_array as $k => $name) |
|
62 | + foreach ($this->country_array as $k => $name) |
|
63 | 63 | { |
64 | 64 | if (($translated = lang($name)) != $name.'*') |
65 | 65 | { |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | |
73 | 73 | function hour_formated_text($name, $selected = 0) |
74 | 74 | { |
75 | - $s = '<select name="' . $name . '">'; |
|
75 | + $s = '<select name="'.$name.'">'; |
|
76 | 76 | $t_s[$selected] = ' selected'; |
77 | 77 | |
78 | - for ($i=0; $i<24; $i++) |
|
78 | + for ($i = 0; $i < 24; $i++) |
|
79 | 79 | { |
80 | - $s .= '<option value="' . $i . '"' . $t_s[$i] . '>' |
|
81 | - . $GLOBALS['phpgw']->common->formattime($i+1,"00") . '</option>' . "\n"; |
|
80 | + $s .= '<option value="'.$i.'"'.$t_s[$i].'>' |
|
81 | + . $GLOBALS['phpgw']->common->formattime($i + 1, "00").'</option>'."\n"; |
|
82 | 82 | } |
83 | 83 | $s .= "</select>"; |
84 | 84 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | |
88 | 88 | function hour_text($name, $selected = 0) |
89 | 89 | { |
90 | - $s = '<select name="' . $name . '">'; |
|
90 | + $s = '<select name="'.$name.'">'; |
|
91 | 91 | $t_s[$selected] = " selected"; |
92 | - for ($i=1; $i<13; $i++) |
|
92 | + for ($i = 1; $i < 13; $i++) |
|
93 | 93 | { |
94 | - $s .= '<option value="' . $i . '"' . $t_s[$i] . '>' |
|
95 | - . $i . '</option>'; |
|
94 | + $s .= '<option value="'.$i.'"'.$t_s[$i].'>' |
|
95 | + . $i.'</option>'; |
|
96 | 96 | $s .= "\n"; |
97 | 97 | } |
98 | 98 | $s .= "</select>"; |
@@ -103,52 +103,52 @@ discard block |
||
103 | 103 | // I would like to add a increment feature |
104 | 104 | function sec_minute_text($name, $selected = 0) |
105 | 105 | { |
106 | - $s = '<select name="' . $name . '">'; |
|
106 | + $s = '<select name="'.$name.'">'; |
|
107 | 107 | $t_s[$selected] = " selected"; |
108 | 108 | |
109 | - for ($i=0; $i<60; $i++) |
|
109 | + for ($i = 0; $i < 60; $i++) |
|
110 | 110 | { |
111 | - $s .= '<option value="' . $i . '"' . $t_s[sprintf("%02d",$i)] . '>' . sprintf("%02d",$i) . '</option>'; |
|
111 | + $s .= '<option value="'.$i.'"'.$t_s[sprintf("%02d", $i)].'>'.sprintf("%02d", $i).'</option>'; |
|
112 | 112 | $s .= "\n"; |
113 | 113 | } |
114 | 114 | $s .= "</select>"; |
115 | 115 | return $s; |
116 | 116 | } |
117 | 117 | |
118 | - function ap_text($name,$selected) |
|
118 | + function ap_text($name, $selected) |
|
119 | 119 | { |
120 | 120 | $selected = strtolower($selected); |
121 | 121 | $t[$selected] = " selected"; |
122 | - $s = '<select name="' . $name . '">' |
|
123 | - . ' <option value="am"' . $t['am'] . '>am</option>' |
|
124 | - . ' <option value="pm"' . $t['pm'] . '>pm</option>'; |
|
122 | + $s = '<select name="'.$name.'">' |
|
123 | + . ' <option value="am"'.$t['am'].'>am</option>' |
|
124 | + . ' <option value="pm"'.$t['pm'].'>pm</option>'; |
|
125 | 125 | $s .= '</select>'; |
126 | 126 | return $s; |
127 | 127 | } |
128 | 128 | |
129 | - function full_time($hour_name,$hour_selected,$min_name,$min_selected,$sec_name,$sec_selected,$ap_name,$ap_selected) |
|
129 | + function full_time($hour_name, $hour_selected, $min_name, $min_selected, $sec_name, $sec_selected, $ap_name, $ap_selected) |
|
130 | 130 | { |
131 | 131 | // This needs to be changed to support there time format preferences |
132 | - $s = $this->hour_text($hour_name,$hour_selected) |
|
133 | - . $this->sec_minute_text($min_name,$min_selected) |
|
134 | - . $this->sec_minute_text($sec_name,$sec_selected) |
|
135 | - . $this->ap_text($ap_name,$ap_selected); |
|
132 | + $s = $this->hour_text($hour_name, $hour_selected) |
|
133 | + . $this->sec_minute_text($min_name, $min_selected) |
|
134 | + . $this->sec_minute_text($sec_name, $sec_selected) |
|
135 | + . $this->ap_text($ap_name, $ap_selected); |
|
136 | 136 | return $s; |
137 | 137 | } |
138 | 138 | |
139 | - function getWeekdays($name, $selected=0) |
|
139 | + function getWeekdays($name, $selected = 0) |
|
140 | 140 | { |
141 | 141 | $out = ''; |
142 | - for($i=0;$i<count($this->weekdays);$i++) |
|
142 | + for ($i = 0; $i < count($this->weekdays); $i++) |
|
143 | 143 | { |
144 | - $out .= '<option value="'.$i.'"'.($selected!=$i?'':' selected').'>'.($this->weekdays[$i]!=''?lang($this->weekdays[$i]):'').'</option>'."\n"; |
|
144 | + $out .= '<option value="'.$i.'"'.($selected != $i ? '' : ' selected').'>'.($this->weekdays[$i] != '' ? lang($this->weekdays[$i]) : '').'</option>'."\n"; |
|
145 | 145 | } |
146 | 146 | return '<select name="'.$name.'">'."\n".$out.'</select>'."\n"; |
147 | 147 | } |
148 | 148 | |
149 | 149 | function nr2weekday($selected = 0) |
150 | 150 | { |
151 | - for($i=0;$i<count($this->weekdays);$i++) |
|
151 | + for ($i = 0; $i < count($this->weekdays); $i++) |
|
152 | 152 | { |
153 | 153 | if ($selected > 0 && $selected == $i) |
154 | 154 | { |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - function getMonthText($name, $selected=0) |
|
160 | + function getMonthText($name, $selected = 0) |
|
161 | 161 | { |
162 | 162 | $out = ''; |
163 | 163 | $c_monthnames = count($this->monthnames); |
164 | - for($i=0;$i<$c_monthnames;$i++) |
|
164 | + for ($i = 0; $i < $c_monthnames; $i++) |
|
165 | 165 | { |
166 | - $out .= '<option value="'.$i.'"'.($selected!=$i?'':' selected').'>'.($this->monthnames[$i]!=''?lang($this->monthnames[$i]):'').'</option>'."\n"; |
|
166 | + $out .= '<option value="'.$i.'"'.($selected != $i ? '' : ' selected').'>'.($this->monthnames[$i] != '' ? lang($this->monthnames[$i]) : '').'</option>'."\n"; |
|
167 | 167 | } |
168 | 168 | return '<select name="'.$name.'">'."\n".$out.'</select>'."\n"; |
169 | 169 | } |
170 | 170 | |
171 | - function getDays($name, $selected=0) |
|
171 | + function getDays($name, $selected = 0) |
|
172 | 172 | { |
173 | 173 | $out = ''; |
174 | 174 | |
175 | - for($i=0;$i<32;$i++) |
|
175 | + for ($i = 0; $i < 32; $i++) |
|
176 | 176 | { |
177 | - $out .= '<option value="'.($i?$i:'').'"'.($selected!=$i?'':' selected').'>'.($i?$i:'').'</option>'."\n"; |
|
177 | + $out .= '<option value="'.($i ? $i : '').'"'.($selected != $i ? '' : ' selected').'>'.($i ? $i : '').'</option>'."\n"; |
|
178 | 178 | } |
179 | 179 | return '<select name="'.$name.'">'."\n".$out.'</select>'."\n"; |
180 | 180 | } |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | $out .= '></option>'."\n"; |
204 | 204 | |
205 | 205 | // We need to add some good error checking here. |
206 | - for ($i=$startYear;$i<$endyear; $i++) |
|
206 | + for ($i = $startYear; $i < $endyear; $i++) |
|
207 | 207 | { |
208 | 208 | $out .= '<option value="'.$i.'"'; |
209 | - if ($selected==$i) |
|
209 | + if ($selected == $i) |
|
210 | 210 | { |
211 | 211 | $out .= ' SELECTED'; |
212 | 212 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | return $out; |
218 | 218 | } |
219 | 219 | |
220 | - function getPercentage($name, $selected=0) |
|
220 | + function getPercentage($name, $selected = 0) |
|
221 | 221 | { |
222 | 222 | $out = "<select name=\"$name\">\n"; |
223 | 223 | |
224 | - for($i=0;$i<101;$i=$i+10) |
|
224 | + for ($i = 0; $i < 101; $i = $i + 10) |
|
225 | 225 | { |
226 | 226 | $out .= "<option value=\"$i\""; |
227 | - if($selected==$i) |
|
227 | + if ($selected == $i) |
|
228 | 228 | { |
229 | 229 | $out .= " SELECTED"; |
230 | 230 | } |
@@ -235,17 +235,17 @@ discard block |
||
235 | 235 | return $out; |
236 | 236 | } |
237 | 237 | |
238 | - function getPriority($name, $selected=2) |
|
238 | + function getPriority($name, $selected = 2) |
|
239 | 239 | { |
240 | - $arr = array('','low','normal','high'); |
|
241 | - $out = '<select name="' . $name . '">'; |
|
240 | + $arr = array('', 'low', 'normal', 'high'); |
|
241 | + $out = '<select name="'.$name.'">'; |
|
242 | 242 | |
243 | - for($i=1;$i<count($arr);$i++) |
|
243 | + for ($i = 1; $i < count($arr); $i++) |
|
244 | 244 | { |
245 | 245 | $out .= "<option value=\""; |
246 | 246 | $out .= $i; |
247 | 247 | $out .= "\""; |
248 | - if ($selected==$i) |
|
248 | + if ($selected == $i) |
|
249 | 249 | { |
250 | 250 | $out .= ' SELECTED'; |
251 | 251 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | return $out; |
258 | 258 | } |
259 | 259 | |
260 | - function getAccessList($name, $selected="private") |
|
260 | + function getAccessList($name, $selected = "private") |
|
261 | 261 | { |
262 | 262 | $arr = array( |
263 | 263 | "private" => "Private", |
@@ -265,35 +265,35 @@ discard block |
||
265 | 265 | "group" => "Group public" |
266 | 266 | ); |
267 | 267 | |
268 | - if (strpos($selected,",") !== false) |
|
268 | + if (strpos($selected, ",") !== false) |
|
269 | 269 | { |
270 | 270 | $selected = "group"; |
271 | 271 | } |
272 | 272 | |
273 | 273 | $out = "<select name=\"$name\">\n"; |
274 | 274 | |
275 | - for(reset($arr);current($arr);next($arr)) |
|
275 | + for (reset($arr); current($arr); next($arr)) |
|
276 | 276 | { |
277 | - $out .= '<option value="' . key($arr) . '"'; |
|
278 | - if($selected==key($arr)) |
|
277 | + $out .= '<option value="'.key($arr).'"'; |
|
278 | + if ($selected == key($arr)) |
|
279 | 279 | { |
280 | 280 | $out .= " SELECTED"; |
281 | 281 | } |
282 | - $out .= ">" . pos($arr) . "</option>\n"; |
|
282 | + $out .= ">".pos($arr)."</option>\n"; |
|
283 | 283 | } |
284 | 284 | $out .= "</select>\n"; |
285 | 285 | return $out; |
286 | 286 | } |
287 | 287 | |
288 | - function getGroups($groups, $selected="", $name="n_groups[]") |
|
288 | + function getGroups($groups, $selected = "", $name = "n_groups[]") |
|
289 | 289 | { |
290 | - $out = '<select name="' . $name . '" multiple>'; |
|
291 | - while (list($null,$group) = each($groups)) |
|
290 | + $out = '<select name="'.$name.'" multiple>'; |
|
291 | + while (list($null, $group) = each($groups)) |
|
292 | 292 | { |
293 | - $out .= '<option value="' . $group['account_id'] . '"'; |
|
294 | - if(@is_array($selected)) |
|
293 | + $out .= '<option value="'.$group['account_id'].'"'; |
|
294 | + if (@is_array($selected)) |
|
295 | 295 | { |
296 | - for($i=0;$i<count($selected);$i++) |
|
296 | + for ($i = 0; $i < count($selected); $i++) |
|
297 | 297 | { |
298 | 298 | if ($group['account_id'] == $selected[$i]) |
299 | 299 | { |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | } |
303 | 303 | } |
304 | 304 | } |
305 | - elseif (ereg("," . $group['account_id'] . ",", $selected)) |
|
305 | + elseif (ereg(",".$group['account_id'].",", $selected)) |
|
306 | 306 | { |
307 | 307 | $out .= " SELECTED"; |
308 | 308 | } |
309 | - $out .= ">" . $group['account_name'] . "</option>\n"; |
|
309 | + $out .= ">".$group['account_name']."</option>\n"; |
|
310 | 310 | } |
311 | 311 | $out .= "</select>\n"; |
312 | 312 | |
@@ -371,29 +371,29 @@ discard block |
||
371 | 371 | 'WY' => 'Wyoming' |
372 | 372 | ); |
373 | 373 | |
374 | - while (list($sn,$ln) = each($states)) |
|
374 | + while (list($sn, $ln) = each($states)) |
|
375 | 375 | { |
376 | - $s .= '<option value="' . $sn . '"'; |
|
376 | + $s .= '<option value="'.$sn.'"'; |
|
377 | 377 | if ($selected == $sn) |
378 | 378 | { |
379 | 379 | $s .= ' selected'; |
380 | 380 | } |
381 | - $s .= '>' . $ln . '</option>'; |
|
381 | + $s .= '>'.$ln.'</option>'; |
|
382 | 382 | } |
383 | - return '<select name="' . $name . '">' . $s . '</select>'; |
|
383 | + return '<select name="'.$name.'">'.$s.'</select>'; |
|
384 | 384 | } |
385 | 385 | |
386 | - function form_select($selected,$name='') |
|
386 | + function form_select($selected, $name = '') |
|
387 | 387 | { |
388 | - if($name=='') |
|
388 | + if ($name == '') |
|
389 | 389 | { |
390 | 390 | $name = 'country'; |
391 | 391 | } |
392 | 392 | $str = '<select name="'.$name.'">'."\n" |
393 | - . ' <option value=" "'.($selected == ' '?' selected':'').'>'.lang('Select One').'</option>'."\n"; |
|
394 | - foreach($this->country_array as $key => $value) |
|
393 | + . ' <option value=" "'.($selected == ' ' ? ' selected' : '').'>'.lang('Select One').'</option>'."\n"; |
|
394 | + foreach ($this->country_array as $key => $value) |
|
395 | 395 | { |
396 | - $str .= ' <option value="'.$key.'"'.($selected == $key?' selected':'') . '>'.$value.'</option>'."\n"; |
|
396 | + $str .= ' <option value="'.$key.'"'.($selected == $key ? ' selected' : '').'>'.$value.'</option>'."\n"; |
|
397 | 397 | } |
398 | 398 | $str .= '</select>'."\n"; |
399 | 399 | return $str; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $id ='' |
139 | 139 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
140 | 140 | */ |
141 | - function propfind($path,&$options,&$files,$user,$id='') |
|
141 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
142 | 142 | { |
143 | 143 | if ($this->debug) |
144 | 144 | { |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | 'enum_recuring' => false, |
165 | 165 | 'daywise' => false, |
166 | 166 | 'date_format' => 'server', |
167 | - 'no_total' => true, // we need no total number of rows (saves extra query) |
|
168 | - 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
167 | + 'no_total' => true, // we need no total number of rows (saves extra query) |
|
168 | + 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
169 | 169 | ); |
170 | - foreach(array( |
|
170 | + foreach (array( |
|
171 | 171 | 'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'], |
172 | 172 | 'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'], |
173 | 173 | ) as $name => $value) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT; |
178 | 178 | } |
179 | - $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
|
179 | + $filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value); |
|
180 | 180 | } |
181 | 181 | if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
182 | 182 | { |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | $filter['filter'] = 'owner'; |
189 | 189 | } |
190 | 190 | // scheduling inbox, shows only not yet accepted or rejected events |
191 | - elseif (substr($path,-7) == '/inbox/') |
|
191 | + elseif (substr($path, -7) == '/inbox/') |
|
192 | 192 | { |
193 | 193 | $filter['filter'] = 'unknown'; |
194 | - $filter['start'] = $this->bo->now; // only return future invitations |
|
194 | + $filter['start'] = $this->bo->now; // only return future invitations |
|
195 | 195 | } |
196 | 196 | // ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now |
197 | - elseif (substr($path,-8) == '/outbox/') |
|
197 | + elseif (substr($path, -8) == '/outbox/') |
|
198 | 198 | { |
199 | 199 | return true; |
200 | 200 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // when trying to request not supported components, eg. VTODO on a calendar collection |
212 | 212 | return true; |
213 | 213 | } |
214 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
214 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
215 | 215 | |
216 | 216 | if ($this->debug > 1) |
217 | 217 | { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | $this->sync_collection_token = null; |
230 | 230 | |
231 | - $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
231 | + $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
232 | 232 | $filter['sync-collection'] = true; |
233 | 233 | // no end-date / limit into the future, as unchanged entries would never be transferted later on |
234 | 234 | unset($filter['end']); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | if (isset($nresults)) |
238 | 238 | { |
239 | - unset($filter['no_total']); // we need the total! |
|
239 | + unset($filter['no_total']); // we need the total! |
|
240 | 240 | $files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults)); |
241 | 241 | |
242 | 242 | // hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first) |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
246 | 246 | { |
247 | 247 | --$this->sync_collection_token; |
248 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
248 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | else |
252 | 252 | { |
253 | 253 | // return iterator, calling ourself to return result in chunks |
254 | - $files['files'] = new groupdav_propfind_iterator($this,$path,$filter,$files['files']); |
|
254 | + $files['files'] = new groupdav_propfind_iterator($this, $path, $filter, $files['files']); |
|
255 | 255 | } |
256 | 256 | if (isset($_GET['download'])) |
257 | 257 | { |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | html::content_header('calendar.ics', 'text/calendar'); |
272 | 272 | |
273 | 273 | $n = 0; |
274 | - foreach($files as $file) |
|
274 | + foreach ($files as $file) |
|
275 | 275 | { |
276 | - if (!$n++) continue; // first entry is collection itself |
|
276 | + if (!$n++) continue; // first entry is collection itself |
|
277 | 277 | |
278 | 278 | $icalendar = $file['props']['calendar-data']['val']; |
279 | 279 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | echo substr($icalendar, 0, $start); |
298 | 298 | } |
299 | 299 | } |
300 | - echo substr($icalendar, $start, $end-$start); |
|
300 | + echo substr($icalendar, $start, $end - $start); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | if ($icalendar && $end) |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | * @param array|boolean $start =false false=return all or array(start,num) |
316 | 316 | * @return array with "files" array with values for keys path and props |
317 | 317 | */ |
318 | - function propfind_callback($path,array $filter,$start=false) |
|
318 | + function propfind_callback($path, array $filter, $start = false) |
|
319 | 319 | { |
320 | 320 | if ($this->debug) $starttime = microtime(true); |
321 | 321 | |
322 | 322 | $calendar_data = $this->groupdav->prop_requested('calendar-data', groupdav::CALDAV, true); |
323 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
323 | + if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
324 | 324 | |
325 | 325 | $files = array(); |
326 | 326 | |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | $requested_multiget_ids = (array)$filter['query'][self::$path_attr]; |
333 | 333 | $sync_collection = $filter['sync-collection']; |
334 | 334 | |
335 | - $events =& $this->bo->search($filter); |
|
335 | + $events = & $this->bo->search($filter); |
|
336 | 336 | |
337 | 337 | if ($events) |
338 | 338 | { |
339 | - foreach($events as $event) |
|
339 | + foreach ($events as $event) |
|
340 | 340 | { |
341 | 341 | // remove event from requested multiget ids, to be able to report not found urls |
342 | 342 | if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | unset($requested_multiget_ids[$k]); |
345 | 345 | } |
346 | 346 | // sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations |
347 | - if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R','X')))) |
|
347 | + if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R', 'X')))) |
|
348 | 348 | { |
349 | 349 | $files[] = array('path' => $path.urldecode($this->get_path($event))); |
350 | 350 | continue; |
@@ -372,10 +372,9 @@ discard block |
||
372 | 372 | { |
373 | 373 | $content = $this->iCal($event, $filter['users'], |
374 | 374 | strpos($path, '/inbox/') !== false ? 'REQUEST' : null, |
375 | - !isset($calendar_data['children']['expand']) ? false : |
|
376 | - ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true)); |
|
375 | + !isset($calendar_data['children']['expand']) ? false : ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true)); |
|
377 | 376 | $props['getcontentlength'] = bytes($content); |
378 | - $props['calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data',$content); |
|
377 | + $props['calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', $content); |
|
379 | 378 | } |
380 | 379 | /* Calendarserver reports new events with schedule-changes: action: create, which iCal request |
381 | 380 | * adding it, unfortunately does not lead to showing the new event in the users inbox |
@@ -394,7 +393,7 @@ discard block |
||
394 | 393 | // report not found multiget urls |
395 | 394 | if ($requested_multiget_ids) |
396 | 395 | { |
397 | - foreach($requested_multiget_ids as $id) |
|
396 | + foreach ($requested_multiget_ids as $id) |
|
398 | 397 | { |
399 | 398 | $files[] = array('path' => $path.$id.self::$path_extension); |
400 | 399 | } |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | private function _created_updated_by_prop($user, $time) |
431 | 430 | { |
432 | 431 | $props = array(); |
433 | - foreach(array( |
|
432 | + foreach (array( |
|
434 | 433 | 'first-name' => 'account_firstname', |
435 | 434 | 'last-name' => 'account_lastname', |
436 | 435 | 'href' => 'account_email', |
@@ -473,23 +472,23 @@ discard block |
||
473 | 472 | $cal_end = $cal_filters['end']; unset($cal_filters['end']); |
474 | 473 | $num_filters = count($cal_filters); |
475 | 474 | |
476 | - foreach($options['filters'] as $filter) |
|
475 | + foreach ($options['filters'] as $filter) |
|
477 | 476 | { |
478 | - switch($filter['name']) |
|
477 | + switch ($filter['name']) |
|
479 | 478 | { |
480 | 479 | case 'comp-filter': |
481 | 480 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
482 | 481 | |
483 | - switch($filter['attrs']['name']) |
|
482 | + switch ($filter['attrs']['name']) |
|
484 | 483 | { |
485 | 484 | case 'VTODO': |
486 | - return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
485 | + return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
487 | 486 | // todos are handled by the infolog handler |
488 | 487 | //$infolog_handler = new groupdav_infolog(); |
489 | 488 | //return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method); |
490 | 489 | case 'VCALENDAR': |
491 | 490 | case 'VEVENT': |
492 | - break; // that's our default anyway |
|
491 | + break; // that's our default anyway |
|
493 | 492 | } |
494 | 493 | break; |
495 | 494 | case 'prop-filter': |
@@ -512,14 +511,14 @@ discard block |
||
512 | 511 | if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
513 | 512 | break; |
514 | 513 | case 'time-range': |
515 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
514 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
516 | 515 | if (!empty($filter['attrs']['start'])) |
517 | 516 | { |
518 | 517 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
519 | 518 | } |
520 | 519 | if (!empty($filter['attrs']['end'])) |
521 | 520 | { |
522 | - $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
521 | + $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
523 | 522 | } |
524 | 523 | break; |
525 | 524 | default: |
@@ -540,9 +539,9 @@ discard block |
||
540 | 539 | <B:nresults>10</B:nresults> |
541 | 540 | </B:limit> |
542 | 541 | */ |
543 | - foreach((array)$options['other'] as $option) |
|
542 | + foreach ((array)$options['other'] as $option) |
|
544 | 543 | { |
545 | - switch($option['name']) |
|
544 | + switch ($option['name']) |
|
546 | 545 | { |
547 | 546 | case 'nresults': |
548 | 547 | $nresults = (int)$option['data']; |
@@ -551,7 +550,7 @@ discard block |
||
551 | 550 | case 'limit': |
552 | 551 | break; |
553 | 552 | case 'href': |
554 | - break; // from addressbook-multiget, handled below |
|
553 | + break; // from addressbook-multiget, handled below |
|
555 | 554 | // rfc 6578 sync-report |
556 | 555 | case 'sync-token': |
557 | 556 | if (!empty($option['data'])) |
@@ -559,7 +558,7 @@ discard block |
||
559 | 558 | $parts = explode('/', $option['data']); |
560 | 559 | $sync_token = array_pop($parts); |
561 | 560 | $cal_filters['query'][] = 'cal_modified>'.(int)$sync_token; |
562 | - $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
561 | + $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
563 | 562 | // no standard time-range! |
564 | 563 | unset($cal_filters['start']); |
565 | 564 | } |
@@ -588,25 +587,25 @@ discard block |
||
588 | 587 | if ($id) |
589 | 588 | { |
590 | 589 | $cal_filters['query'][self::$path_attr] = groupdav_handler::$path_extension ? |
591 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
590 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
592 | 591 | } |
593 | 592 | else // fetch all given url's |
594 | 593 | { |
595 | - foreach($options['other'] as $option) |
|
594 | + foreach ($options['other'] as $option) |
|
596 | 595 | { |
597 | 596 | if ($option['name'] == 'href') |
598 | 597 | { |
599 | - $parts = explode('/',$option['data']); |
|
598 | + $parts = explode('/', $option['data']); |
|
600 | 599 | if (($id = urldecode(array_pop($parts)))) |
601 | 600 | { |
602 | 601 | $cal_filters['query'][self::$path_attr][] = groupdav_handler::$path_extension ? |
603 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
602 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
604 | 603 | } |
605 | 604 | } |
606 | 605 | } |
607 | 606 | } |
608 | 607 | |
609 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
608 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters)); |
|
610 | 609 | } |
611 | 610 | return true; |
612 | 611 | } |
@@ -619,9 +618,9 @@ discard block |
||
619 | 618 | * @param int $user =null account_id |
620 | 619 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
621 | 620 | */ |
622 | - function get(&$options,$id,$user=null) |
|
621 | + function get(&$options, $id, $user = null) |
|
623 | 622 | { |
624 | - if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id))) |
|
623 | + if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id))) |
|
625 | 624 | { |
626 | 625 | return $event; |
627 | 626 | } |
@@ -649,7 +648,7 @@ discard block |
||
649 | 648 | * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences |
650 | 649 | * @return string |
651 | 650 | */ |
652 | - private function iCal(array $event,$user=null, $method=null, $expand=false) |
|
651 | + private function iCal(array $event, $user = null, $method = null, $expand = false) |
|
653 | 652 | { |
654 | 653 | static $handler = null; |
655 | 654 | if (is_null($handler)) $handler = $this->_get_handler(); |
@@ -673,11 +672,11 @@ discard block |
||
673 | 672 | if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
674 | 673 | if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
675 | 674 | } |
676 | - $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
|
675 | + $events = & self::get_series($event['uid'], $this->bo, $expand, $user); |
|
677 | 676 | } |
678 | - elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
|
677 | + elseif (!$this->client_shared_uid_exceptions && $event['reference']) |
|
679 | 678 | { |
680 | - $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
679 | + $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
681 | 680 | } |
682 | 681 | return $handler->exportVCal($events, '2.0', $method); |
683 | 682 | } |
@@ -693,20 +692,20 @@ discard block |
||
693 | 692 | * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in |
694 | 693 | * @return array |
695 | 694 | */ |
696 | - private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
|
695 | + private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null) |
|
697 | 696 | { |
698 | 697 | if (is_null($bo)) $bo = new calendar_bopdate(); |
699 | 698 | |
700 | 699 | $params = array( |
701 | 700 | 'query' => array('cal_uid' => $uid), |
702 | - 'filter' => 'owner', // return all possible entries |
|
701 | + 'filter' => 'owner', // return all possible entries |
|
703 | 702 | 'daywise' => false, |
704 | 703 | 'date_format' => 'server', |
705 | - 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
704 | + 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
706 | 705 | ); |
707 | 706 | if (is_array($expand)) $params += $expand; |
708 | 707 | |
709 | - if (!($events =& $bo->search($params))) |
|
708 | + if (!($events = & $bo->search($params))) |
|
710 | 709 | { |
711 | 710 | return array(); |
712 | 711 | } |
@@ -714,12 +713,12 @@ discard block |
||
714 | 713 | // find master, which is not always first event, eg. when first event is an exception |
715 | 714 | $master = null; |
716 | 715 | $exceptions = array(); |
717 | - foreach($events as $k => &$recurrence) |
|
716 | + foreach ($events as $k => &$recurrence) |
|
718 | 717 | { |
719 | 718 | if ($recurrence['recur_type']) |
720 | 719 | { |
721 | 720 | $master = $recurrence; |
722 | - $exceptions =& $master['recur_exception']; |
|
721 | + $exceptions = & $master['recur_exception']; |
|
723 | 722 | unset($events[$k]); |
724 | 723 | break; |
725 | 724 | } |
@@ -727,7 +726,7 @@ discard block |
||
727 | 726 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
728 | 727 | if (!isset($master)) $master = $bo->read($uid); |
729 | 728 | |
730 | - foreach($events as $k => &$recurrence) |
|
729 | + foreach ($events as $k => &$recurrence) |
|
731 | 730 | { |
732 | 731 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); |
733 | 732 | if (!$master || $recurrence['id'] != $master['id']) // real exception |
@@ -749,16 +748,16 @@ discard block |
||
749 | 748 | // at least Lightning "understands" EXDATE as exception from what's included |
750 | 749 | // in the whole resource / VCALENDAR component |
751 | 750 | // not removing it causes Lightning to remove the exception itself |
752 | - if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false) |
|
751 | + if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false) |
|
753 | 752 | { |
754 | 753 | unset($exceptions[$e]); |
755 | 754 | } |
756 | - continue; // nothing to change |
|
755 | + continue; // nothing to change |
|
757 | 756 | } |
758 | 757 | // alarms are reported on recurrences --> move them to master |
759 | 758 | if ($master) |
760 | 759 | { |
761 | - foreach($recurrence['alarm'] as $alarm) |
|
760 | + foreach ($recurrence['alarm'] as $alarm) |
|
762 | 761 | { |
763 | 762 | $master['alarm'][] = $alarm; |
764 | 763 | } |
@@ -768,14 +767,14 @@ discard block |
||
768 | 767 | if (!$expand && $master && $master['participants'] == $recurrence['participants']) |
769 | 768 | { |
770 | 769 | //error_log('NO exception: '.array2string($recurrence)); |
771 | - unset($events[$k]); // no exception --> remove it |
|
770 | + unset($events[$k]); // no exception --> remove it |
|
772 | 771 | continue; |
773 | 772 | } |
774 | 773 | // this is a virtual exception now (no extra event/cal_id in DB) |
775 | 774 | //error_log('virtual exception: '.array2string($recurrence)); |
776 | 775 | $recurrence['recurrence'] = $recurrence['start']; |
777 | 776 | if ($master) $recurrence['reference'] = $master['id']; |
778 | - $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
777 | + $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
779 | 778 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
780 | 779 | } |
781 | 780 | // only add master if we are not expanding and current user participates in master (and not just some exceptions) |
@@ -809,23 +808,23 @@ discard block |
||
809 | 808 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
810 | 809 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
811 | 810 | */ |
812 | - function put(&$options,$id,$user=null,$prefix=null) |
|
811 | + function put(&$options, $id, $user = null, $prefix = null) |
|
813 | 812 | { |
814 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
813 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
815 | 814 | |
816 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
815 | + if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
817 | 816 | |
818 | 817 | // fix for iCal4OL using WinHTTP only supporting a certain header length |
819 | 818 | if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
820 | 819 | { |
821 | 820 | $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE']; |
822 | 821 | } |
823 | - $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
824 | - $oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access, |
|
825 | - isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
822 | + $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
823 | + $oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access, |
|
824 | + isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
826 | 825 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
827 | 826 | { |
828 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
827 | + if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace()); |
|
829 | 828 | return $oldEvent; |
830 | 829 | } |
831 | 830 | |
@@ -856,7 +855,7 @@ discard block |
||
856 | 855 | switch (strtolower($key)) |
857 | 856 | { |
858 | 857 | case 'charset': |
859 | - $charset = strtoupper(substr($value,1,-1)); |
|
858 | + $charset = strtoupper(substr($value, 1, -1)); |
|
860 | 859 | } |
861 | 860 | } |
862 | 861 | } |
@@ -912,7 +911,7 @@ discard block |
||
912 | 911 | if (($events = $handler->icaltoegw($vCalendar))) |
913 | 912 | { |
914 | 913 | $modified = 0; |
915 | - foreach($events as $n => $event) |
|
914 | + foreach ($events as $n => $event) |
|
916 | 915 | { |
917 | 916 | // for recurrances of event series, we need to read correct recurrence (or if series master is no first event) |
918 | 917 | if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series)) |
@@ -923,7 +922,7 @@ discard block |
||
923 | 922 | $series = self::get_series($event['uid'], $this->bo); |
924 | 923 | //foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent)); |
925 | 924 | } |
926 | - foreach($series as $oldEvent) |
|
925 | + foreach ($series as $oldEvent) |
|
927 | 926 | { |
928 | 927 | if ($oldEvent['recurrence'] == $event['recurrence']) break; |
929 | 928 | } |
@@ -988,9 +987,9 @@ discard block |
||
988 | 987 | isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']])) |
989 | 988 | { |
990 | 989 | // just update etag in database |
991 | - $GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array( |
|
990 | + $GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array( |
|
992 | 991 | 'cal_id' => $eventId, |
993 | - ),__LINE__,__FILE__,'calendar'); |
|
992 | + ), __LINE__, __FILE__, 'calendar'); |
|
994 | 993 | } |
995 | 994 | } |
996 | 995 | } |
@@ -1037,9 +1036,9 @@ discard block |
||
1037 | 1036 | * @param int $user =null account_id of owner, default null |
1038 | 1037 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1039 | 1038 | */ |
1040 | - function post(&$options,$id,$user=null) |
|
1039 | + function post(&$options, $id, $user = null) |
|
1041 | 1040 | { |
1042 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1041 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
1043 | 1042 | |
1044 | 1043 | $vCalendar = htmlspecialchars_decode($options['content']); |
1045 | 1044 | $charset = null; |
@@ -1056,13 +1055,13 @@ discard block |
||
1056 | 1055 | switch (strtolower($key)) |
1057 | 1056 | { |
1058 | 1057 | case 'charset': |
1059 | - $charset = strtoupper(substr($value,1,-1)); |
|
1058 | + $charset = strtoupper(substr($value, 1, -1)); |
|
1060 | 1059 | } |
1061 | 1060 | } |
1062 | 1061 | } |
1063 | 1062 | } |
1064 | 1063 | |
1065 | - if (substr($options['path'],-8) == '/outbox/') |
|
1064 | + if (substr($options['path'], -8) == '/outbox/') |
|
1066 | 1065 | { |
1067 | 1066 | if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar)) |
1068 | 1067 | { |
@@ -1113,7 +1112,7 @@ discard block |
||
1113 | 1112 | */ |
1114 | 1113 | protected function outbox_freebusy_request($ical, $charset, $user, array &$options) |
1115 | 1114 | { |
1116 | - unset($options); // not used, but required by function signature |
|
1115 | + unset($options); // not used, but required by function signature |
|
1117 | 1116 | |
1118 | 1117 | $vcal = new Horde_Icalendar(); |
1119 | 1118 | if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset)) |
@@ -1126,7 +1125,7 @@ discard block |
||
1126 | 1125 | |
1127 | 1126 | $handler = $this->_get_handler(); |
1128 | 1127 | $handler->setSupportedFields('groupdav'); |
1129 | - $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1128 | + $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1130 | 1129 | if (!($component = $vcal->getComponent(0)) || |
1131 | 1130 | !($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->groupdav->current_user_principal, 'Horde_Icalendar_Vfreebusy'))) |
1132 | 1131 | { |
@@ -1151,13 +1150,13 @@ discard block |
||
1151 | 1150 | $xml->startDocument('1.0', 'UTF-8'); |
1152 | 1151 | $xml->startElementNs('C', 'schedule-response', groupdav::CALDAV); |
1153 | 1152 | |
1154 | - foreach(array_keys($event['participants']) as $uid) |
|
1153 | + foreach (array_keys($event['participants']) as $uid) |
|
1155 | 1154 | { |
1156 | 1155 | $xml->startElementNs('C', 'response', null); |
1157 | 1156 | |
1158 | 1157 | $xml->startElementNs('C', 'recipient', null); |
1159 | - $xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees)); |
|
1160 | - $xml->endElement(); // recipient |
|
1158 | + $xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees)); |
|
1159 | + $xml->endElement(); // recipient |
|
1161 | 1160 | |
1162 | 1161 | $xml->writeElementNs('C', 'request-status', null, '2.0;Success'); |
1163 | 1162 | $xml->writeElementNs('C', 'calendar-data', null, |
@@ -1165,13 +1164,13 @@ discard block |
||
1165 | 1164 | 'UID' => $event['uid'], |
1166 | 1165 | 'ORGANIZER' => $organizer, |
1167 | 1166 | 'ATTENDEE' => $attendee, |
1168 | - )+(empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1167 | + ) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1169 | 1168 | 'X-CALENDARSERVER-MASK-UID' => $mask_uid, |
1170 | 1169 | )))); |
1171 | 1170 | |
1172 | - $xml->endElement(); // response |
|
1171 | + $xml->endElement(); // response |
|
1173 | 1172 | } |
1174 | - $xml->endElement(); // schedule-response |
|
1173 | + $xml->endElement(); // schedule-response |
|
1175 | 1174 | $xml->endDocument(); |
1176 | 1175 | echo $xml->outputMemory(); |
1177 | 1176 | |
@@ -1186,14 +1185,14 @@ discard block |
||
1186 | 1185 | * @param int $user account_id |
1187 | 1186 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1188 | 1187 | */ |
1189 | - function free_busy_report($path,$options,$user) |
|
1188 | + function free_busy_report($path, $options, $user) |
|
1190 | 1189 | { |
1191 | - unset($path); // unused, but required by function signature |
|
1190 | + unset($path); // unused, but required by function signature |
|
1192 | 1191 | if (!$this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user)) |
1193 | 1192 | { |
1194 | 1193 | return '403 Forbidden'; |
1195 | 1194 | } |
1196 | - foreach($options['other'] as $filter) |
|
1195 | + foreach ($options['other'] as $filter) |
|
1197 | 1196 | { |
1198 | 1197 | if ($filter['name'] == 'time-range') |
1199 | 1198 | { |
@@ -1205,7 +1204,7 @@ discard block |
||
1205 | 1204 | header('Content-Type: text/calendar'); |
1206 | 1205 | echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array()); |
1207 | 1206 | |
1208 | - common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1207 | + common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1209 | 1208 | } |
1210 | 1209 | |
1211 | 1210 | /** |
@@ -1217,7 +1216,7 @@ discard block |
||
1217 | 1216 | * @param int $user =null owner of the collection, default current user |
1218 | 1217 | * @return array with privileges |
1219 | 1218 | */ |
1220 | - public function current_user_privileges($path, $user=null) |
|
1219 | + public function current_user_privileges($path, $user = null) |
|
1221 | 1220 | { |
1222 | 1221 | $privileges = parent::current_user_privileges($path, $user); |
1223 | 1222 | //error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges)); |
@@ -1260,7 +1259,7 @@ discard block |
||
1260 | 1259 | |
1261 | 1260 | // get array with orginal recurrences indexed by recurrence-id |
1262 | 1261 | $org_recurrences = $exceptions = array(); |
1263 | - foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
|
1262 | + foreach (self::get_series($events[0]['uid'], $bo) as $k => $event) |
|
1264 | 1263 | { |
1265 | 1264 | if (!$k) $master = $event; |
1266 | 1265 | if ($event['recurrence']) |
@@ -1270,13 +1269,13 @@ discard block |
||
1270 | 1269 | } |
1271 | 1270 | |
1272 | 1271 | // assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master |
1273 | - foreach($events as $k => &$recurrence) |
|
1272 | + foreach ($events as $k => &$recurrence) |
|
1274 | 1273 | { |
1275 | 1274 | if (!$recurrence['recurrence']) |
1276 | 1275 | { |
1277 | 1276 | // master |
1278 | 1277 | $recurrence['id'] = $master['id']; |
1279 | - $master =& $events[$k]; |
|
1278 | + $master = & $events[$k]; |
|
1280 | 1279 | continue; |
1281 | 1280 | } |
1282 | 1281 | |
@@ -1300,12 +1299,12 @@ discard block |
||
1300 | 1299 | $master['recur_exception'] = array_merge($exceptions, $master['recur_exception']); |
1301 | 1300 | |
1302 | 1301 | // delete not longer existing recurrences |
1303 | - foreach($org_recurrences as $org_recurrence) |
|
1302 | + foreach ($org_recurrences as $org_recurrence) |
|
1304 | 1303 | { |
1305 | 1304 | if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
1306 | 1305 | { |
1307 | 1306 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
1308 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1307 | + $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1309 | 1308 | } |
1310 | 1309 | else // virtual recurrence |
1311 | 1310 | { |
@@ -1326,25 +1325,25 @@ discard block |
||
1326 | 1325 | * @param int $id |
1327 | 1326 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1328 | 1327 | */ |
1329 | - function delete(&$options,$id) |
|
1328 | + function delete(&$options, $id) |
|
1330 | 1329 | { |
1331 | 1330 | if (strpos($options['path'], '/inbox/') !== false) |
1332 | 1331 | { |
1333 | - return true; // simply ignore DELETE in inbox for now |
|
1332 | + return true; // simply ignore DELETE in inbox for now |
|
1334 | 1333 | } |
1335 | - $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1336 | - if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access) |
|
1334 | + $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1335 | + if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access) |
|
1337 | 1336 | { |
1338 | 1337 | if (!$return_no_access) |
1339 | 1338 | { |
1340 | 1339 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
1341 | 1340 | $ret = '403 Forbidden'; |
1342 | 1341 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
1343 | - foreach(array_keys($event['participants']) as $uid) |
|
1342 | + foreach (array_keys($event['participants']) as $uid) |
|
1344 | 1343 | { |
1345 | 1344 | if ($this->bo->user == $uid || in_array($uid, $memberships)) |
1346 | 1345 | { |
1347 | - $this->bo->set_status($event,$this->bo->user, 'R'); |
|
1346 | + $this->bo->set_status($event, $this->bo->user, 'R'); |
|
1348 | 1347 | $ret = true; |
1349 | 1348 | break; |
1350 | 1349 | } |
@@ -1359,7 +1358,7 @@ discard block |
||
1359 | 1358 | { |
1360 | 1359 | $ret = $this->bo->delete($event['id']); |
1361 | 1360 | } |
1362 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1361 | + if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1363 | 1362 | return $ret; |
1364 | 1363 | } |
1365 | 1364 | |
@@ -1374,12 +1373,12 @@ discard block |
||
1374 | 1373 | */ |
1375 | 1374 | function read($id) |
1376 | 1375 | { |
1377 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
1376 | + if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column; |
|
1378 | 1377 | |
1379 | 1378 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
1380 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1379 | + if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1381 | 1380 | |
1382 | - if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server')) && |
|
1381 | + if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY, $event, 0, 'server')) && |
|
1383 | 1382 | // above can be true, if current user is not in master but just a recurrence |
1384 | 1383 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
1385 | 1384 | { |
@@ -1415,11 +1414,11 @@ discard block |
||
1415 | 1414 | * |
1416 | 1415 | * @return string |
1417 | 1416 | */ |
1418 | - public function getctag($path,$user) |
|
1417 | + public function getctag($path, $user) |
|
1419 | 1418 | { |
1420 | - $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1419 | + $ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1421 | 1420 | |
1422 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1421 | + if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag"); |
|
1423 | 1422 | |
1424 | 1423 | return $ctag; |
1425 | 1424 | } |
@@ -1431,7 +1430,7 @@ discard block |
||
1431 | 1430 | * @param string $schedule_tag =null on return schedule-tag |
1432 | 1431 | * @return string|boolean string with etag or false |
1433 | 1432 | */ |
1434 | - function get_etag($entry, &$schedule_tag=null) |
|
1433 | + function get_etag($entry, &$schedule_tag = null) |
|
1435 | 1434 | { |
1436 | 1435 | $etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions); |
1437 | 1436 | |
@@ -1449,7 +1448,7 @@ discard block |
||
1449 | 1448 | * @param int|string $retval |
1450 | 1449 | * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header) |
1451 | 1450 | */ |
1452 | - function put_response_headers($entry, $path, $retval, $path_attr_is_name=true) |
|
1451 | + function put_response_headers($entry, $path, $retval, $path_attr_is_name = true) |
|
1453 | 1452 | { |
1454 | 1453 | $schedule_tag = null; |
1455 | 1454 | $etag = $this->get_etag($entry, $schedule_tag); |
@@ -1468,14 +1467,14 @@ discard block |
||
1468 | 1467 | * @param array|int $event event-array or id |
1469 | 1468 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1470 | 1469 | */ |
1471 | - function check_access($acl,$event) |
|
1470 | + function check_access($acl, $event) |
|
1472 | 1471 | { |
1473 | 1472 | if ($acl == EGW_ACL_READ) |
1474 | 1473 | { |
1475 | 1474 | // we need at least EGW_ACL_FREEBUSY to get some information |
1476 | 1475 | $acl = EGW_ACL_FREEBUSY; |
1477 | 1476 | } |
1478 | - return $this->bo->check_perms($acl,$event,0,'server'); |
|
1477 | + return $this->bo->check_perms($acl, $event, 0, 'server'); |
|
1479 | 1478 | } |
1480 | 1479 | |
1481 | 1480 | /** |
@@ -1488,53 +1487,53 @@ discard block |
||
1488 | 1487 | * @param string $path =null path of the collection |
1489 | 1488 | * @return array |
1490 | 1489 | */ |
1491 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null) |
|
1490 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null) |
|
1492 | 1491 | { |
1493 | - unset($base_uri); // unused, but required by function signature |
|
1492 | + unset($base_uri); // unused, but required by function signature |
|
1494 | 1493 | if (!isset($props['calendar-description'])) |
1495 | 1494 | { |
1496 | 1495 | // default calendar description: can be overwritten via PROPPATCH, in which case it's already set |
1497 | - $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname); |
|
1496 | + $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-description', $displayname); |
|
1498 | 1497 | } |
1499 | 1498 | $supported_components = array( |
1500 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')), |
|
1501 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')), |
|
1499 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VCALENDAR')), |
|
1500 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VEVENT')), |
|
1502 | 1501 | ); |
1503 | 1502 | // outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations |
1504 | - if (substr($path,-8) == '/outbox/') |
|
1503 | + if (substr($path, -8) == '/outbox/') |
|
1505 | 1504 | { |
1506 | - $supported_components[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VFREEBUSY')); |
|
1505 | + $supported_components[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VFREEBUSY')); |
|
1507 | 1506 | } |
1508 | 1507 | $props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, |
1509 | - 'supported-calendar-component-set',$supported_components); |
|
1508 | + 'supported-calendar-component-set', $supported_components); |
|
1510 | 1509 | // supported reports |
1511 | 1510 | $props['supported-report-set'] = array( |
1512 | - 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1513 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1514 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-query',''))))), |
|
1515 | - 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1516 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1517 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget',''))))), |
|
1518 | - 'free-busy-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1519 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1520 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'free-busy-query',''))))), |
|
1511 | + 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1512 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1513 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-query', ''))))), |
|
1514 | + 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1515 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1516 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-multiget', ''))))), |
|
1517 | + 'free-busy-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1518 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1519 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'free-busy-query', ''))))), |
|
1521 | 1520 | ); |
1522 | 1521 | // rfc 6578 sync-collection report for everything but outbox |
1523 | 1522 | // only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
1524 | 1523 | if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history']) |
1525 | 1524 | { |
1526 | - $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1527 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1528 | - HTTP_WebDAV_Server::mkprop('sync-collection',''))))); |
|
1525 | + $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1526 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1527 | + HTTP_WebDAV_Server::mkprop('sync-collection', ''))))); |
|
1529 | 1528 | } |
1530 | - $props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-data',array( |
|
1531 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1532 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1529 | + $props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'supported-calendar-data', array( |
|
1530 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1531 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1533 | 1532 | |
1534 | 1533 | // get timezone of calendar |
1535 | 1534 | if ($this->groupdav->prop_requested('calendar-timezone')) |
1536 | 1535 | { |
1537 | - $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone', |
|
1536 | + $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-timezone', |
|
1538 | 1537 | calendar_timezones::user_timezone($user)); |
1539 | 1538 | } |
1540 | 1539 | return $props; |
@@ -1548,9 +1547,9 @@ discard block |
||
1548 | 1547 | private function _get_handler() |
1549 | 1548 | { |
1550 | 1549 | $handler = new calendar_ical(); |
1551 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
1552 | - $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1553 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
1550 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
1551 | + $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1552 | + if ($this->debug > 1) error_log("ical Handler called: ".$this->agent); |
|
1554 | 1553 | return $handler; |
1555 | 1554 | } |
1556 | 1555 | |
@@ -1565,7 +1564,7 @@ discard block |
||
1565 | 1564 | $pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set']; |
1566 | 1565 | $calendar_home_set = $pref ? explode(',', $pref) : array(); |
1567 | 1566 | // replace symbolic id's with real nummeric id's |
1568 | - foreach(array( |
|
1567 | + foreach (array( |
|
1569 | 1568 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
1570 | 1569 | ) as $sym => $id) |
1571 | 1570 | { |
@@ -1574,11 +1573,11 @@ discard block |
||
1574 | 1573 | $calendar_home_set[$key] = $id; |
1575 | 1574 | } |
1576 | 1575 | } |
1577 | - foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1576 | + foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1578 | 1577 | { |
1579 | 1578 | $id = $entry['grantor']; |
1580 | - if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1581 | - (in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) && |
|
1579 | + if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1580 | + (in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) && |
|
1582 | 1581 | is_numeric($id) && ($owner = $this->accounts->id2name($id))) |
1583 | 1582 | { |
1584 | 1583 | $shared[$id] = 'calendar-'.$owner; |
@@ -1587,11 +1586,11 @@ discard block |
||
1587 | 1586 | // shared locations and resources |
1588 | 1587 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
1589 | 1588 | { |
1590 | - foreach(array('locations','resources') as $res) |
|
1589 | + foreach (array('locations', 'resources') as $res) |
|
1591 | 1590 | { |
1592 | 1591 | if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res])) |
1593 | 1592 | { |
1594 | - foreach(explode(',', $pref) as $res_id) |
|
1593 | + foreach (explode(',', $pref) as $res_id) |
|
1595 | 1594 | { |
1596 | 1595 | $is_location = $res == 'locations'; |
1597 | 1596 | $shared['r'.$res_id] = str_replace('s/', '-', groupdav_principals::resource2name($res_id, $is_location)); |
@@ -1621,7 +1620,7 @@ discard block |
||
1621 | 1620 | { |
1622 | 1621 | $calendars[$entry['grantor']] = $entry['name']; |
1623 | 1622 | } |
1624 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
1623 | + if ($user > 0) unset($calendars[$user]); // skip current user |
|
1625 | 1624 | } |
1626 | 1625 | |
1627 | 1626 | $settings = array(); |
@@ -1629,7 +1628,7 @@ discard block |
||
1629 | 1628 | 'type' => 'multiselect', |
1630 | 1629 | 'label' => 'Calendars to sync in addition to personal calendar', |
1631 | 1630 | 'name' => 'calendar-home-set', |
1632 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1631 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1633 | 1632 | 'values' => $calendars, |
1634 | 1633 | 'xmlrpc' => True, |
1635 | 1634 | 'admin' => False, |
@@ -1655,7 +1654,7 @@ discard block |
||
1655 | 1654 | if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = groupdav_principals::get_resources())) |
1656 | 1655 | { |
1657 | 1656 | $resources = $locations = array(); |
1658 | - foreach($all_resources as $resource) |
|
1657 | + foreach ($all_resources as $resource) |
|
1659 | 1658 | { |
1660 | 1659 | if (groupdav_principals::resource_is_location($resource)) |
1661 | 1660 | { |
@@ -1666,7 +1665,7 @@ discard block |
||
1666 | 1665 | $resources[$resource['res_id']] = $resource['name']; |
1667 | 1666 | } |
1668 | 1667 | } |
1669 | - foreach(array( |
|
1668 | + foreach (array( |
|
1670 | 1669 | 'locations' => $locations, |
1671 | 1670 | 'resources' => $resources, |
1672 | 1671 | ) as $name => $options) |
@@ -1679,7 +1678,7 @@ discard block |
||
1679 | 1678 | 'label' => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')), |
1680 | 1679 | 'no_lang'=> true, |
1681 | 1680 | 'name' => 'calendar-home-set-'.$name, |
1682 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1681 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1683 | 1682 | 'values' => $options, |
1684 | 1683 | 'xmlrpc' => True, |
1685 | 1684 | 'admin' => False, |
@@ -53,39 +53,39 @@ discard block |
||
53 | 53 | |
54 | 54 | function boholiday() |
55 | 55 | { |
56 | - $this->so =& CreateObject('calendar.soholiday'); |
|
57 | - |
|
58 | - $this->start = (int)get_var('start',array('POST','GET')); |
|
59 | - $this->query = get_var('query',array('POST','GET')); |
|
60 | - $this->sort = get_var('sort',array('POST','GET')); |
|
61 | - $this->order = get_var('order',array('POST','GET')); |
|
62 | - $this->id = get_var('id',array('POST','GET')); |
|
63 | - $this->year = get_var('year',array('POST','GET'),date('Y')); |
|
64 | - $this->locale = get_var('locale',array('POST','GET')); |
|
56 | + $this->so = & CreateObject('calendar.soholiday'); |
|
57 | + |
|
58 | + $this->start = (int)get_var('start', array('POST', 'GET')); |
|
59 | + $this->query = get_var('query', array('POST', 'GET')); |
|
60 | + $this->sort = get_var('sort', array('POST', 'GET')); |
|
61 | + $this->order = get_var('order', array('POST', 'GET')); |
|
62 | + $this->id = get_var('id', array('POST', 'GET')); |
|
63 | + $this->year = get_var('year', array('POST', 'GET'), date('Y')); |
|
64 | + $this->locale = get_var('locale', array('POST', 'GET')); |
|
65 | 65 | if ($this->locale) |
66 | 66 | { |
67 | 67 | $this->locales[] = $this->locale; |
68 | 68 | } |
69 | 69 | |
70 | - if($this->debug) |
|
70 | + if ($this->debug) |
|
71 | 71 | { |
72 | 72 | echo '<-- Locale = '.$this->locales[0].' -->'."\n"; |
73 | 73 | } |
74 | 74 | |
75 | - $this->total = $this->so->holiday_total($this->locales[0],$this->query,$this->year); |
|
75 | + $this->total = $this->so->holiday_total($this->locales[0], $this->query, $this->year); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /* Begin Calendar functions */ |
79 | - function read_entry($id=0) |
|
79 | + function read_entry($id = 0) |
|
80 | 80 | { |
81 | - if($this->debug) |
|
81 | + if ($this->debug) |
|
82 | 82 | { |
83 | 83 | echo "BO : Reading Holiday ID : ".$id."<br>\n"; |
84 | 84 | } |
85 | 85 | |
86 | - if(!$id) |
|
86 | + if (!$id) |
|
87 | 87 | { |
88 | - if(!$this->id) |
|
88 | + if (!$this->id) |
|
89 | 89 | { |
90 | 90 | return Array(); |
91 | 91 | } |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | return $this->so->read_holiday($id); |
99 | 99 | } |
100 | 100 | |
101 | - function delete_holiday($id=0) |
|
101 | + function delete_holiday($id = 0) |
|
102 | 102 | { |
103 | - if(!$id) |
|
103 | + if (!$id) |
|
104 | 104 | { |
105 | - if($this->id) |
|
105 | + if ($this->id) |
|
106 | 106 | { |
107 | 107 | $id = $this->id; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - $this->ui =& CreateObject('calendar.uiholiday'); |
|
112 | - if($id) |
|
111 | + $this->ui = & CreateObject('calendar.uiholiday'); |
|
112 | + if ($id) |
|
113 | 113 | { |
114 | 114 | $this->so->delete_holiday($id); |
115 | 115 | $this->ui->edit_locale(); |
@@ -120,45 +120,45 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - function delete_locale($locale='') |
|
123 | + function delete_locale($locale = '') |
|
124 | 124 | { |
125 | - if(!$locale) |
|
125 | + if (!$locale) |
|
126 | 126 | { |
127 | - if($this->locales[0]) |
|
127 | + if ($this->locales[0]) |
|
128 | 128 | { |
129 | 129 | $locale = $this->locales[0]; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - if($locale) |
|
133 | + if ($locale) |
|
134 | 134 | { |
135 | 135 | $this->so->delete_locale($locale); |
136 | 136 | } |
137 | - $this->ui =& CreateObject('calendar.uiholiday'); |
|
137 | + $this->ui = & CreateObject('calendar.uiholiday'); |
|
138 | 138 | $this->ui->admin(); |
139 | 139 | } |
140 | 140 | |
141 | 141 | function accept_holiday() |
142 | 142 | { |
143 | - $send_back_to = str_replace('submitlocale','holiday_admin',$_SERVER['HTTP_REFERER']); |
|
144 | - if(!@$this->locales[0]) |
|
143 | + $send_back_to = str_replace('submitlocale', 'holiday_admin', $_SERVER['HTTP_REFERER']); |
|
144 | + if (!@$this->locales[0]) |
|
145 | 145 | { |
146 | 146 | Header('Location: '.$send_back_to); |
147 | 147 | } |
148 | 148 | |
149 | - $send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to); |
|
149 | + $send_back_to = str_replace('&locale='.$this->locales[0], '', $send_back_to); |
|
150 | 150 | $file = './holidays.'.$this->locales[0]; |
151 | - if(!file_exists($file) && count($_POST['name'])) |
|
151 | + if (!file_exists($file) && count($_POST['name'])) |
|
152 | 152 | { |
153 | - $fp = fopen($file,'w'); |
|
154 | - fwrite($fp,"charset\t".$GLOBALS['egw']->translation->charset()."\n"); |
|
153 | + $fp = fopen($file, 'w'); |
|
154 | + fwrite($fp, "charset\t".$GLOBALS['egw']->translation->charset()."\n"); |
|
155 | 155 | |
156 | 156 | $holidays = array(); |
157 | - foreach($_POST['name'] as $i => $name) |
|
157 | + foreach ($_POST['name'] as $i => $name) |
|
158 | 158 | { |
159 | 159 | $holiday = array( |
160 | 160 | 'locale' => $_POST['locale'], |
161 | - 'name' => str_replace('\\','',$name), |
|
161 | + 'name' => str_replace('\\', '', $name), |
|
162 | 162 | 'day' => $_POST['day'][$i], |
163 | 163 | 'month' => $_POST['month'][$i], |
164 | 164 | 'occurence' => $_POST['occurence'][$i], |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | ); |
168 | 168 | } |
169 | 169 | // sort holidays by year / occurence: |
170 | - usort($holidays,'_holiday_cmp'); |
|
170 | + usort($holidays, '_holiday_cmp'); |
|
171 | 171 | |
172 | 172 | $last_year = -1; |
173 | - foreach($holidays as $holiday) |
|
173 | + foreach ($holidays as $holiday) |
|
174 | 174 | { |
175 | 175 | $year = $holiday['occurence'] <= 0 ? 0 : $holiday['occurence']; |
176 | 176 | if ($year != $last_year) |
@@ -178,46 +178,46 @@ discard block |
||
178 | 178 | echo "\n".($year ? $year : 'regular (year=0)').":\n"; |
179 | 179 | $last_year = $year; |
180 | 180 | } |
181 | - fwrite($fp,"$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n"); |
|
181 | + fwrite($fp, "$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n"); |
|
182 | 182 | } |
183 | 183 | fclose($fp); |
184 | 184 | } |
185 | 185 | Header('Location: '.$send_back_to); |
186 | 186 | } |
187 | 187 | |
188 | - function get_holiday_list($locale='', $sort='', $order='', $query='', $total='', $year=0) |
|
188 | + function get_holiday_list($locale = '', $sort = '', $order = '', $query = '', $total = '', $year = 0) |
|
189 | 189 | { |
190 | - $locale = ($locale?$locale:$this->locales[0]); |
|
191 | - $sort = ($sort?$sort:$this->sort); |
|
192 | - $order = ($order?$order:$this->order); |
|
193 | - $query = ($query?$query:$this->query); |
|
194 | - $year = ($$year?$$year:$this->year); |
|
195 | - return $this->so->read_holidays($locale,$query,$order,$year); |
|
190 | + $locale = ($locale ? $locale : $this->locales[0]); |
|
191 | + $sort = ($sort ? $sort : $this->sort); |
|
192 | + $order = ($order ? $order : $this->order); |
|
193 | + $query = ($query ? $query : $this->query); |
|
194 | + $year = ($$year ? $$year : $this->year); |
|
195 | + return $this->so->read_holidays($locale, $query, $order, $year); |
|
196 | 196 | } |
197 | 197 | |
198 | - function get_locale_list($sort='', $order='', $query='') |
|
198 | + function get_locale_list($sort = '', $order = '', $query = '') |
|
199 | 199 | { |
200 | - $sort = ($sort?$sort:$this->sort); |
|
201 | - $order = ($order?$order:$this->order); |
|
202 | - $query = ($query?$query:$this->query); |
|
203 | - return $this->so->get_locale_list($sort,$order,$query); |
|
200 | + $sort = ($sort ? $sort : $this->sort); |
|
201 | + $order = ($order ? $order : $this->order); |
|
202 | + $query = ($query ? $query : $this->query); |
|
203 | + return $this->so->get_locale_list($sort, $order, $query); |
|
204 | 204 | } |
205 | 205 | |
206 | - function prepare_read_holidays($year=0,$owner=0) |
|
206 | + function prepare_read_holidays($year = 0, $owner = 0) |
|
207 | 207 | { |
208 | - $this->year = (isset($year) && $year > 0?$year:$GLOBALS['egw']->common->show_date(time() - $GLOBALS['egw']->datetime->tz_offset,'Y')); |
|
209 | - $this->owner = ($owner?$owner:$GLOBALS['egw_info']['user']['account_id']); |
|
208 | + $this->year = (isset($year) && $year > 0 ? $year : $GLOBALS['egw']->common->show_date(time() - $GLOBALS['egw']->datetime->tz_offset, 'Y')); |
|
209 | + $this->owner = ($owner ? $owner : $GLOBALS['egw_info']['user']['account_id']); |
|
210 | 210 | |
211 | - if($this->debug) |
|
211 | + if ($this->debug) |
|
212 | 212 | { |
213 | 213 | echo 'Setting Year to : '.$this->year.'<br>'."\n"; |
214 | 214 | } |
215 | 215 | |
216 | - if(@$GLOBALS['egw_info']['user']['preferences']['common']['country']) |
|
216 | + if (@$GLOBALS['egw_info']['user']['preferences']['common']['country']) |
|
217 | 217 | { |
218 | 218 | $this->locales[] = $GLOBALS['egw_info']['user']['preferences']['common']['country']; |
219 | 219 | } |
220 | - elseif(@$GLOBALS['egw_info']['user']['preferences']['calendar']['locale']) |
|
220 | + elseif (@$GLOBALS['egw_info']['user']['preferences']['calendar']['locale']) |
|
221 | 221 | { |
222 | 222 | $this->locales[] = $GLOBALS['egw_info']['user']['preferences']['calendar']['locale']; |
223 | 223 | } |
@@ -226,45 +226,45 @@ discard block |
||
226 | 226 | $this->locales[] = 'US'; |
227 | 227 | } |
228 | 228 | |
229 | - if($this->owner != $GLOBALS['egw_info']['user']['account_id']) |
|
229 | + if ($this->owner != $GLOBALS['egw_info']['user']['account_id']) |
|
230 | 230 | { |
231 | - $owner_pref =& CreateObject('phpgwapi.preferences',$owner); |
|
231 | + $owner_pref = & CreateObject('phpgwapi.preferences', $owner); |
|
232 | 232 | $owner_prefs = $owner_pref->read_repository(); |
233 | - if(@$owner_prefs['common']['country']) |
|
233 | + if (@$owner_prefs['common']['country']) |
|
234 | 234 | { |
235 | 235 | $this->locales[] = $owner_prefs['common']['country']; |
236 | 236 | } |
237 | - elseif(@$owner_prefs['calendar']['locale']) |
|
237 | + elseif (@$owner_prefs['calendar']['locale']) |
|
238 | 238 | { |
239 | 239 | $this->locales[] = $owner_prefs['calendar']['locale']; |
240 | 240 | } |
241 | 241 | unset($owner_pref); |
242 | 242 | } |
243 | 243 | |
244 | - if($GLOBALS['egw_info']['server']['auto_load_holidays'] == True && $this->locales) |
|
244 | + if ($GLOBALS['egw_info']['server']['auto_load_holidays'] == True && $this->locales) |
|
245 | 245 | { |
246 | - foreach($this->locales as $local) |
|
246 | + foreach ($this->locales as $local) |
|
247 | 247 | { |
248 | 248 | $this->auto_load_holidays($local, $year); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - function auto_load_holidays($locale, $year=0) |
|
253 | + function auto_load_holidays($locale, $year = 0) |
|
254 | 254 | { |
255 | 255 | //error_log(__METHOD__."('$locale', $year)"); |
256 | - if (!egw_cache::getInstance(__CLASS__, $locale.'-'.$year) && // check if autoload has been tried for this locale and year |
|
256 | + if (!egw_cache::getInstance(__CLASS__, $locale.'-'.$year) && // check if autoload has been tried for this locale and year |
|
257 | 257 | (!($total_year = $this->so->holiday_total($locale, '', $year)) || |
258 | 258 | // automatic try load new holidays, if there are no irregular ones for queried year |
259 | 259 | $total_year == $this->so->holiday_total($locale, '', 1901))) |
260 | 260 | { |
261 | 261 | //error_log(__METHOD__."('$locale', $year) attemption autoload ..."); |
262 | - egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 864000); // do NOT try again for 10 days |
|
262 | + egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 864000); // do NOT try again for 10 days |
|
263 | 263 | @set_time_limit(0); |
264 | 264 | |
265 | 265 | /* get the file that contains the calendar events for your locale */ |
266 | 266 | /* "http://www.egroupware.org/cal/holidays.US.csv"; */ |
267 | - if(isset($GLOBALS['egw_info']['server']['holidays_url_path']) && $GLOBALS['egw_info']['server']['holidays_url_path'] != 'localhost') |
|
267 | + if (isset($GLOBALS['egw_info']['server']['holidays_url_path']) && $GLOBALS['egw_info']['server']['holidays_url_path'] != 'localhost') |
|
268 | 268 | { |
269 | 269 | $load_from = $GLOBALS['egw_info']['server']['holidays_url_path']; |
270 | 270 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | { |
273 | 273 | if ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/') |
274 | 274 | { |
275 | - $server_host = ($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url']; |
|
275 | + $server_host = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url']; |
|
276 | 276 | } |
277 | 277 | else |
278 | 278 | { |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | $load_from = $server_host.'/calendar/egroupware.org'; |
282 | 282 | } |
283 | 283 | // echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale).'.csv'."<br>\n"; |
284 | - if($GLOBALS['egw_info']['server']['holidays_url_path'] == 'localhost') |
|
284 | + if ($GLOBALS['egw_info']['server']['holidays_url_path'] == 'localhost') |
|
285 | 285 | { |
286 | 286 | $lines = file(EGW_SERVER_ROOT.'/calendar/egroupware.org/holidays.'.strtoupper($locale).'.csv'); |
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
290 | - $lines = file($url=$load_from.'/holidays.'.strtoupper($locale).'.csv', 0, egw_framework::proxy_context()); |
|
290 | + $lines = file($url = $load_from.'/holidays.'.strtoupper($locale).'.csv', 0, egw_framework::proxy_context()); |
|
291 | 291 | //error_log(__METHOD__."('$locale', $year) file('$url')=".array2string($lines)); |
292 | 292 | } |
293 | 293 | if (!$lines) |
@@ -295,21 +295,21 @@ discard block |
||
295 | 295 | return false; |
296 | 296 | } |
297 | 297 | // reading the holidayfile from egroupware.org via network::gethttpsocketfile contains all the headers! |
298 | - foreach($lines as $line) |
|
298 | + foreach ($lines as $line) |
|
299 | 299 | { |
300 | - $fields = preg_split("/[\t\n ]+/",$line); |
|
300 | + $fields = preg_split("/[\t\n ]+/", $line); |
|
301 | 301 | |
302 | 302 | if ($fields[0] == 'charset' && $fields[1]) |
303 | 303 | { |
304 | - $lines = translation::convert($lines,$fields[1]); |
|
304 | + $lines = translation::convert($lines, $fields[1]); |
|
305 | 305 | break; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | foreach ($lines as $line) |
309 | 309 | { |
310 | 310 | // echo 'Line #'.$i.' : '.$lines[$i]."<br>\n"; |
311 | - $holiday = explode("\t",$line); |
|
312 | - if(count($holiday) == 7) |
|
311 | + $holiday = explode("\t", $line); |
|
312 | + if (count($holiday) == 7) |
|
313 | 313 | { |
314 | 314 | $holiday['locale'] = $holiday[0]; |
315 | 315 | $holiday['name'] = $GLOBALS['egw']->db->db_addslashes($holiday[1]); |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | |
333 | 333 | function add() |
334 | 334 | { |
335 | - if(@$_POST['submit']) |
|
335 | + if (@$_POST['submit']) |
|
336 | 336 | { |
337 | 337 | $holiday = $_POST['holiday']; |
338 | 338 | |
339 | - if(empty($holiday['mday'])) |
|
339 | + if (empty($holiday['mday'])) |
|
340 | 340 | { |
341 | 341 | $holiday['mday'] = 0; |
342 | 342 | } |
343 | - if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='') |
|
343 | + if (!isset($this->bo->locales[0]) || $this->bo->locales[0] == '') |
|
344 | 344 | { |
345 | 345 | $this->bo->locales[0] = $holiday['locale']; |
346 | 346 | } |
347 | - elseif(!isset($holiday['locale']) || $holiday['locale']=='') |
|
347 | + elseif (!isset($holiday['locale']) || $holiday['locale'] == '') |
|
348 | 348 | { |
349 | 349 | $holiday['locale'] = $this->bo->locales[0]; |
350 | 350 | } |
351 | - if(!isset($holiday['hol_id'])) |
|
351 | + if (!isset($holiday['hol_id'])) |
|
352 | 352 | { |
353 | 353 | $holiday['hol_id'] = $this->bo->id; |
354 | 354 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | { |
360 | 360 | $errors[] = lang('You need to set either a day or a occurence !!!'); |
361 | 361 | } |
362 | - if($holiday['year'] && $holiday['occurence']) |
|
362 | + if ($holiday['year'] && $holiday['occurence']) |
|
363 | 363 | { |
364 | 364 | $errors[] = lang('You can only set a year or a occurence !!!'); |
365 | 365 | } |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | |
372 | 372 | // Still need to put some validation in here..... |
373 | 373 | |
374 | - $this->ui =& CreateObject('calendar.uiholiday'); |
|
374 | + $this->ui = & CreateObject('calendar.uiholiday'); |
|
375 | 375 | |
376 | 376 | if (is_array($errors)) |
377 | 377 | { |
378 | 378 | $holiday['month'] = $holiday['month_num']; |
379 | 379 | $holiday['day'] = $holiday['mday']; |
380 | - $this->ui->edit_holiday($errors,$holiday); |
|
380 | + $this->ui->edit_holiday($errors, $holiday); |
|
381 | 381 | } |
382 | 382 | else |
383 | 383 | { |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | function sort_holidays_by_date($holidays) |
391 | 391 | { |
392 | 392 | $c_holidays = count($holidays); |
393 | - for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++) |
|
393 | + for ($outer_loop = 0; $outer_loop < ($c_holidays - 1); $outer_loop++) |
|
394 | 394 | { |
395 | - for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++) |
|
395 | + for ($inner_loop = $outer_loop; $inner_loop < $c_holidays; $inner_loop++) |
|
396 | 396 | { |
397 | - if($holidays[$outer_loop]['date'] > $holidays[$inner_loop]['date']) |
|
397 | + if ($holidays[$outer_loop]['date'] > $holidays[$inner_loop]['date']) |
|
398 | 398 | { |
399 | 399 | $temp = $holidays[$inner_loop]; |
400 | 400 | $holidays[$inner_loop] = $holidays[$outer_loop]; |
@@ -408,38 +408,38 @@ discard block |
||
408 | 408 | function set_holidays_to_date($holidays) |
409 | 409 | { |
410 | 410 | $new_holidays = Array(); |
411 | - for($i=0;$i<count($holidays);$i++) |
|
411 | + for ($i = 0; $i < count($holidays); $i++) |
|
412 | 412 | { |
413 | 413 | // echo "Setting Holidays Date : ".date('Ymd',$holidays[$i]['date'])."<br>\n"; |
414 | - $new_holidays[date('Ymd',$holidays[$i]['date'])][] = $holidays[$i]; |
|
414 | + $new_holidays[date('Ymd', $holidays[$i]['date'])][] = $holidays[$i]; |
|
415 | 415 | } |
416 | 416 | return $new_holidays; |
417 | 417 | } |
418 | 418 | |
419 | 419 | function read_holiday() |
420 | 420 | { |
421 | - if(isset($this->cached_holidays)) |
|
421 | + if (isset($this->cached_holidays)) |
|
422 | 422 | { |
423 | 423 | return $this->cached_holidays; |
424 | 424 | } |
425 | - $holidays = $this->so->read_holidays($this->locales,'','',$this->year); |
|
425 | + $holidays = $this->so->read_holidays($this->locales, '', '', $this->year); |
|
426 | 426 | |
427 | - if(count($holidays) == 0) |
|
427 | + if (count($holidays) == 0) |
|
428 | 428 | { |
429 | 429 | return $holidays; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $temp_locale = $GLOBALS['egw_info']['user']['preferences']['common']['country']; |
433 | - foreach($holidays as $i => $holiday) |
|
433 | + foreach ($holidays as $i => $holiday) |
|
434 | 434 | { |
435 | - if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale']) |
|
435 | + if ($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale']) |
|
436 | 436 | { |
437 | - if(is_object($holidaycalc)) |
|
437 | + if (is_object($holidaycalc)) |
|
438 | 438 | { |
439 | 439 | unset($holidaycalc); |
440 | 440 | } |
441 | 441 | $GLOBALS['egw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale']; |
442 | - $holidaycalc =& CreateObject('calendar.holidaycalc'); |
|
442 | + $holidaycalc = & CreateObject('calendar.holidaycalc'); |
|
443 | 443 | } |
444 | 444 | $holidays[$i]['date'] = $holidaycalc->calculate_date($holiday, $holidays, $this->year); |
445 | 445 | } |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | |
454 | 454 | function check_admin() |
455 | 455 | { |
456 | - if(!@$GLOBALS['egw_info']['user']['apps']['admin']) |
|
456 | + if (!@$GLOBALS['egw_info']['user']['apps']['admin']) |
|
457 | 457 | { |
458 | - Header('Location: ' . $GLOBALS['egw']->link('/index.php')); |
|
458 | + Header('Location: '.$GLOBALS['egw']->link('/index.php')); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | return false; |
467 | 467 | } |
468 | 468 | $monthnames = array( |
469 | - '','January','February','March','April','May','June', |
|
470 | - 'July','August','September','October','November','December' |
|
469 | + '', 'January', 'February', 'March', 'April', 'May', 'June', |
|
470 | + 'July', 'August', 'September', 'October', 'November', 'December' |
|
471 | 471 | ); |
472 | 472 | $month = $holiday['month'] ? lang($monthnames[$holiday['month']]) : ''; |
473 | 473 | |
@@ -475,14 +475,14 @@ discard block |
||
475 | 475 | { |
476 | 476 | $occ = $holiday['occurence'] == 99 ? lang('last') : $holiday['occurence'].'.'; |
477 | 477 | |
478 | - $dow_str = Array(lang('Sun'),lang('Mon'),lang('Tue'),lang('Wed'),lang('Thu'),lang('Fri'),lang('Sat')); |
|
478 | + $dow_str = Array(lang('Sun'), lang('Mon'), lang('Tue'), lang('Wed'), lang('Thu'), lang('Fri'), lang('Sat')); |
|
479 | 479 | $dow = $dow_str[$holiday['dow']]; |
480 | 480 | |
481 | - $str = lang('%1 %2 in %3',$occ,$dow,$month); |
|
481 | + $str = lang('%1 %2 in %3', $occ, $dow, $month); |
|
482 | 482 | } |
483 | 483 | else |
484 | 484 | { |
485 | - $str = $GLOBALS['egw']->common->dateformatorder($holiday['occurence']>1900?$holiday['occurence']:'',$month,$holiday[day]); |
|
485 | + $str = $GLOBALS['egw']->common->dateformatorder($holiday['occurence'] > 1900 ? $holiday['occurence'] : '', $month, $holiday[day]); |
|
486 | 486 | } |
487 | 487 | if ($holiday['observance_rule']) |
488 | 488 | { |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - function _holiday_cmp($a,$b) |
|
495 | + function _holiday_cmp($a, $b) |
|
496 | 496 | { |
497 | 497 | if (($year_diff = ($a['occurence'] <= 0 ? 0 : $a['occurence']) - ($b['occurence'] <= 0 ? 0 : $b['occurence']))) |
498 | 498 | { |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class holidaycalc |
23 | 23 | { |
24 | - function add($holiday,&$holidays,$year,$day_offset=0) |
|
24 | + function add($holiday, &$holidays, $year, $day_offset = 0) |
|
25 | 25 | { |
26 | 26 | if ($day_offset) |
27 | 27 | { |
28 | 28 | $holiday['name'] .= ' (Observed)'; |
29 | 29 | } |
30 | - $holiday['date'] = mktime(0,0,0,$holiday['month'],$holiday['day']+$day_offset,$year); |
|
31 | - foreach(array('day'=>'d','month'=>'m','occurence'=>'Y') as $key => $frmt) |
|
30 | + $holiday['date'] = mktime(0, 0, 0, $holiday['month'], $holiday['day'] + $day_offset, $year); |
|
31 | + foreach (array('day'=>'d', 'month'=>'m', 'occurence'=>'Y') as $key => $frmt) |
|
32 | 32 | { |
33 | - $holiday[$key] = date($frmt,$holiday['date']); |
|
33 | + $holiday[$key] = date($frmt, $holiday['date']); |
|
34 | 34 | } |
35 | 35 | $holiday['obervance_rule'] = 0; |
36 | 36 | |
37 | - $holidays[]= $holiday; |
|
37 | + $holidays[] = $holiday; |
|
38 | 38 | |
39 | 39 | //echo "<p>holidaycalc::add(,,$year,,$day_offset)=".print_r($holiday,True)."</p>"; |
40 | 40 | } |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | { |
44 | 44 | //echo "<p>holidaycalc::calculate_date(".print_r($holiday,True).",,$year,)</p>"; |
45 | 45 | |
46 | - if($holiday['day'] == 0 && $holiday['occurence'] != 0) |
|
46 | + if ($holiday['day'] == 0 && $holiday['occurence'] != 0) |
|
47 | 47 | { |
48 | - if($holiday['occurence'] != 99) |
|
48 | + if ($holiday['occurence'] != 99) |
|
49 | 49 | { |
50 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year,$holiday['month'],1); |
|
50 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year, $holiday['month'], 1); |
|
51 | 51 | $day = (((7 * $holiday['occurence']) - 6) + ((($holiday['dow'] + 7) - $dow) % 7)); |
52 | 52 | $day += ($day < 1 ? 7 : 0); |
53 | 53 | |
54 | 54 | // Sometimes the 5th occurance of a weekday (ie the 5th monday) |
55 | 55 | // can spill over to the next month. This prevents that. |
56 | - $ld = $GLOBALS['egw']->datetime->days_in_month($holiday['month'],$year); |
|
56 | + $ld = $GLOBALS['egw']->datetime->days_in_month($holiday['month'], $year); |
|
57 | 57 | if ($day > $ld) |
58 | 58 | { |
59 | 59 | return; |
@@ -61,49 +61,49 @@ discard block |
||
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
64 | - $ld = $GLOBALS['egw']->datetime->days_in_month($holiday['month'],$year); |
|
65 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year,$holiday['month'],$ld); |
|
66 | - $day = $ld - (($dow + 7) - $holiday['dow']) % 7 ; |
|
64 | + $ld = $GLOBALS['egw']->datetime->days_in_month($holiday['month'], $year); |
|
65 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year, $holiday['month'], $ld); |
|
66 | + $day = $ld - (($dow + 7) - $holiday['dow']) % 7; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | else |
70 | 70 | { |
71 | 71 | $day = $holiday['day']; |
72 | - if($holiday['observance_rule'] == True) |
|
72 | + if ($holiday['observance_rule'] == True) |
|
73 | 73 | { |
74 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year,$holiday['month'],$day); |
|
74 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year, $holiday['month'], $day); |
|
75 | 75 | // This now calulates Observed holidays and creates a new entry for them. |
76 | 76 | |
77 | 77 | // 0 = sundays are observed on monday (+1), 6 = saturdays are observed on fridays (-1) |
78 | - if($dow == 0 || $dow == 6) |
|
78 | + if ($dow == 0 || $dow == 6) |
|
79 | 79 | { |
80 | - $this->add($holiday,$holidays,$year,$dow == 0 ? 1 : -1); |
|
80 | + $this->add($holiday, $holidays, $year, $dow == 0 ? 1 : -1); |
|
81 | 81 | } |
82 | 82 | if ($holiday['month'] == 1 && $day == 1) |
83 | 83 | { |
84 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year+1,$holiday['month'],$day); |
|
84 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year + 1, $holiday['month'], $day); |
|
85 | 85 | // checking if next year's newyear might be observed in this year |
86 | 86 | if ($dow == 6) |
87 | 87 | { |
88 | - $this->add($holiday,$holidays,$year+1,-1); |
|
88 | + $this->add($holiday, $holidays, $year + 1, -1); |
|
89 | 89 | } |
90 | 90 | // add the next years newyear, to show it in a week- or month-view |
91 | - $this->add($holiday,$holidays,$year+1); |
|
91 | + $this->add($holiday, $holidays, $year + 1); |
|
92 | 92 | } |
93 | 93 | // checking if last year's new year's eve might be observed in this year |
94 | 94 | if ($holiday['month'] == 12 && $day == 31) |
95 | 95 | { |
96 | - $dow = $GLOBALS['egw']->datetime->day_of_week($year-1,$holiday['month'],$day); |
|
96 | + $dow = $GLOBALS['egw']->datetime->day_of_week($year - 1, $holiday['month'], $day); |
|
97 | 97 | if ($dow == 0) |
98 | 98 | { |
99 | - $this->add($holiday,$holidays,$year-1,1); |
|
99 | + $this->add($holiday, $holidays, $year - 1, 1); |
|
100 | 100 | } |
101 | 101 | // add the last years new year's eve, to show it in a week- or month-view |
102 | - $this->add($holiday,$holidays,$year-1); |
|
102 | + $this->add($holiday, $holidays, $year - 1); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | - $date = mktime(0,0,0,$holiday['month'],$day,$year); |
|
106 | + $date = mktime(0, 0, 0, $holiday['month'], $day, $year); |
|
107 | 107 | |
108 | 108 | return $date; |
109 | 109 | } |
@@ -11,24 +11,24 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | include_once('../../phpgwapi/inc/common_functions.inc.php'); |
14 | -check_load_extension('gd',true); // true = throw exception if not loadable |
|
14 | +check_load_extension('gd', true); // true = throw exception if not loadable |
|
15 | 15 | |
16 | -foreach(array('width'=>1,'height'=>1,'color1'=>'000080','color2'=>'ffffff') as $name => $default) |
|
16 | +foreach (array('width'=>1, 'height'=>1, 'color1'=>'000080', 'color2'=>'ffffff') as $name => $default) |
|
17 | 17 | { |
18 | 18 | $$name = isset($_GET[$name]) ? $_GET[$name] : $default; |
19 | 19 | } |
20 | 20 | |
21 | -foreach(array('color1','color2') as $name) |
|
21 | +foreach (array('color1', 'color2') as $name) |
|
22 | 22 | { |
23 | - preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or |
|
23 | + preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/', $$name, $rgb) or |
|
24 | 24 | die("Wrong value '".htmlspecialchars($$name)."' for $name, should be something like #80FFFF' !!!"); |
25 | 25 | |
26 | - $$name = array('r'=>hexdec($rgb[1]),'g'=>hexdec($rgb[2]),'b'=>hexdec($rgb[3])); |
|
26 | + $$name = array('r'=>hexdec($rgb[1]), 'g'=>hexdec($rgb[2]), 'b'=>hexdec($rgb[3])); |
|
27 | 27 | } |
28 | -$image = @imagecreate(abs($width),abs($height)) |
|
28 | +$image = @imagecreate(abs($width), abs($height)) |
|
29 | 29 | or die("Cannot Initialize new GD image stream"); |
30 | 30 | |
31 | -$length = max($width,$height); |
|
31 | +$length = max($width, $height); |
|
32 | 32 | $dist = $length / 256; |
33 | 33 | if ($dist < 1) $dist = 1; |
34 | 34 | $anz = round($length / $dist); |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | $rgb = $color1; |
41 | 41 | for ($l = 0; $l < $length; $l += $dist) |
42 | 42 | { |
43 | - $color = imagecolorallocate($image,(int)$rgb['r'],(int)$rgb['g'],(int)$rgb['b']); |
|
44 | - foreach($rgb as $c => $val) |
|
43 | + $color = imagecolorallocate($image, (int)$rgb['r'], (int)$rgb['g'], (int)$rgb['b']); |
|
44 | + foreach ($rgb as $c => $val) |
|
45 | 45 | { |
46 | 46 | $rgb[$c] += $c_step[$c]; |
47 | 47 | } |
48 | 48 | if ($width > $height) |
49 | 49 | { |
50 | - imagefilledrectangle($image,(int)$l,0,(int) ($l+$dist),$height-1,$color); |
|
50 | + imagefilledrectangle($image, (int)$l, 0, (int)($l + $dist), $height - 1, $color); |
|
51 | 51 | } |
52 | 52 | else |
53 | 53 | { |
54 | - imagefilledrectangle($image,0,(int)$l,$width-1,(int) ($l+$dist),$color); |
|
54 | + imagefilledrectangle($image, 0, (int)$l, $width - 1, (int)($l + $dist), $color); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // allow caching for 7 days |
59 | 59 | header('Cache-Control: public'); |
60 | -header('Expires: ' . gmdate('D, d M Y H:i:s', time()+7*24*60*60) . ' GMT'); |
|
60 | +header('Expires: '.gmdate('D, d M Y H:i:s', time() + 7 * 24 * 60 * 60).' GMT'); |
|
61 | 61 | |
62 | 62 | if (function_exists('imagegif')) |
63 | 63 | { |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for calendar |
19 | 19 | */ |
20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
20 | +class calendar_import_csv extends importexport_basic_import_csv { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * actions wich could be done to data entries |
24 | 24 | */ |
25 | - protected static $actions = array( 'none', 'update', 'insert' ); |
|
25 | + protected static $actions = array('none', 'update', 'insert'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * conditions for actions |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Set up tracker |
46 | 46 | */ |
47 | - protected function init(importexport_definition &$definition) |
|
47 | + protected function init(importexport_definition&$definition) |
|
48 | 48 | { |
49 | 49 | // fetch the addressbook bo |
50 | - $this->bo= new calendar_boupdate(); |
|
50 | + $this->bo = new calendar_boupdate(); |
|
51 | 51 | |
52 | 52 | // Get the tracker for changes |
53 | 53 | $this->tracking = new calendar_tracking(); |
54 | 54 | |
55 | 55 | // Used for participants |
56 | - $this->status_map = array_flip(array_map('lang',$this->bo->verbose_status)); |
|
56 | + $this->status_map = array_flip(array_map('lang', $this->bo->verbose_status)); |
|
57 | 57 | $this->role_map = array_flip($this->bo->roles); |
58 | 58 | |
59 | 59 | $this->lookups = array( |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return boolean success |
78 | 78 | */ |
79 | - public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
|
79 | + public function import_record(\importexport_iface_egw_record&$record, &$import_csv) |
|
80 | 80 | { |
81 | 81 | // set eventOwner |
82 | - $options =& $this->definition->plugin_options; |
|
82 | + $options = & $this->definition->plugin_options; |
|
83 | 83 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
84 | 84 | |
85 | 85 | // Set owner, unless it's supposed to come from CSV file |
86 | - if($options['owner_from_csv']) { |
|
87 | - if(!is_numeric($record['owner'])) { |
|
86 | + if ($options['owner_from_csv']) { |
|
87 | + if (!is_numeric($record['owner'])) { |
|
88 | 88 | $this->errors[$import_csv->get_current_position()] = lang( |
89 | 89 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
90 | 90 | $record->owner, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Handle errors in length or start/end date |
102 | - if($record->start > $record->end) |
|
102 | + if ($record->start > $record->end) |
|
103 | 103 | { |
104 | 104 | $record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60; |
105 | 105 | $this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!'); |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | if ($record->participants && !is_array($record->participants)) { |
110 | 110 | // Importing participants in human friendly format: |
111 | 111 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
112 | - preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
|
112 | + preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants); |
|
113 | 113 | $p_participants = array(); |
114 | 114 | $missing = array(); |
115 | 115 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
116 | - foreach($names as $key => $name) { |
|
116 | + foreach ($names as $key => $name) { |
|
117 | 117 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
118 | 118 | |
119 | 119 | // Search for direct account name, then user in accounts first |
@@ -121,26 +121,26 @@ discard block |
||
121 | 121 | $id = importexport_helper_functions::account_name2id($name); |
122 | 122 | |
123 | 123 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | - $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
|
126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
124 | + if (!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | + $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1)); |
|
126 | + if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
127 | 127 | } |
128 | - if(!$id) |
|
128 | + if (!$id) |
|
129 | 129 | { |
130 | 130 | // Use calendar's registered resources to find participant |
131 | - foreach($this->bo->resources as $resource) |
|
131 | + foreach ($this->bo->resources as $resource) |
|
132 | 132 | { |
133 | 133 | // Can't search for email |
134 | - if($resource['app'] == 'email') continue; |
|
134 | + if ($resource['app'] == 'email') continue; |
|
135 | 135 | // Special resource search, since it does special stuff in link_query |
136 | - if($resource['app'] == 'resources') |
|
136 | + if ($resource['app'] == 'resources') |
|
137 | 137 | { |
138 | - if(!$this->resource_so) |
|
138 | + if (!$this->resource_so) |
|
139 | 139 | { |
140 | 140 | $this->resource_so = new resources_so(); |
141 | 141 | } |
142 | - $result = $this->resource_so->search($search,'res_id'); |
|
143 | - if(count($result) >= 1) { |
|
142 | + $result = $this->resource_so->search($search, 'res_id'); |
|
143 | + if (count($result) >= 1) { |
|
144 | 144 | $id = $resource['type'].$result[0]['res_id']; |
145 | 145 | break; |
146 | 146 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | // Search app via link query |
151 | 151 | $result = egw_link::query($resource['app'], $search, $options); |
152 | 152 | |
153 | - if($result) |
|
153 | + if ($result) |
|
154 | 154 | { |
155 | - $id = $resource['type'] . key($result); |
|
155 | + $id = $resource['type'].key($result); |
|
156 | 156 | break; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | - if($id) { |
|
161 | + if ($id) { |
|
162 | 162 | $p_participants[$id] = calendar_so::combine_status( |
163 | 163 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
164 | 164 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -169,47 +169,47 @@ discard block |
||
169 | 169 | { |
170 | 170 | $missing[] = $name; |
171 | 171 | } |
172 | - if(count($missing) > 0) |
|
172 | + if (count($missing) > 0) |
|
173 | 173 | { |
174 | - $this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' . |
|
175 | - lang('Contact not found!') . '<br />'.implode(", ",$missing); |
|
174 | + $this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '. |
|
175 | + lang('Contact not found!').'<br />'.implode(", ", $missing); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | $record->participants = $p_participants; |
179 | 179 | } |
180 | 180 | |
181 | - if($record->recurrence) |
|
181 | + if ($record->recurrence) |
|
182 | 182 | { |
183 | - list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2); |
|
183 | + list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2); |
|
184 | 184 | $record->recur_interval = trim($record->recur_interval); |
185 | - $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$lookups['recurrence'])); |
|
185 | + $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $lookups['recurrence'])); |
|
186 | 186 | unset($record->recurrence); |
187 | 187 | } |
188 | 188 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
189 | 189 | |
190 | - if ( $options['conditions'] ) { |
|
191 | - foreach ( $options['conditions'] as $condition ) { |
|
190 | + if ($options['conditions']) { |
|
191 | + foreach ($options['conditions'] as $condition) { |
|
192 | 192 | $records = array(); |
193 | - switch ( $condition['type'] ) { |
|
193 | + switch ($condition['type']) { |
|
194 | 194 | // exists |
195 | 195 | case 'exists' : |
196 | 196 | // Check for that record |
197 | 197 | $result = $this->exists($record, $condition, $records); |
198 | 198 | |
199 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
199 | + if (is_array($records) && count($records) >= 1) { |
|
200 | 200 | // apply action to all records matching this exists condition |
201 | 201 | $action = $condition['true']; |
202 | - foreach ( (array)$records as $event ) { |
|
202 | + foreach ((array)$records as $event) { |
|
203 | 203 | $record->id = $event['id']; |
204 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
205 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
206 | - $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
|
204 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
205 | + if (!is_array($record->category)) $record->category = explode(',', $record->category); |
|
206 | + $record->category = implode(',', array_unique(array_merge($record->category, $event['category']))); |
|
207 | 207 | } |
208 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
208 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
209 | 209 | } |
210 | 210 | } else { |
211 | 211 | $action = $condition['false']; |
212 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
212 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
213 | 213 | } |
214 | 214 | break; |
215 | 215 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | } else { |
224 | 224 | // unconditional insert |
225 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
225 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $success; |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
240 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array()) |
|
241 | 241 | { |
242 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
242 | + if ($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
243 | 243 | $event = $this->bo->read($record->__get($condition['string'])); |
244 | 244 | $records = array($event); |
245 | 245 | } |
246 | 246 | |
247 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
247 | + if (is_array($records) && count($records) >= 1) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | return false; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param array $_data record data for the action |
258 | 258 | * @return bool success or not |
259 | 259 | */ |
260 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
260 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) |
|
261 | 261 | { |
262 | 262 | $_data = $record->get_record_array(); |
263 | 263 | switch ($_action) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $old = $this->bo->read($_data['id']); |
269 | 269 | |
270 | 270 | // Don't change a user account into a record |
271 | - if(!$this->definition->plugin_options['change_owner']) { |
|
271 | + if (!$this->definition->plugin_options['change_owner']) { |
|
272 | 272 | // Don't change owner of an existing record |
273 | 273 | unset($_data['owner']); |
274 | 274 | } |
@@ -276,29 +276,29 @@ discard block |
||
276 | 276 | // Merge to deal with fields not in import record |
277 | 277 | $_data = array_merge($old, $_data); |
278 | 278 | $changed = $this->tracking->changed_fields($_data, $old); |
279 | - if(count($changed) == 0) { |
|
279 | + if (count($changed) == 0) { |
|
280 | 280 | return true; |
281 | 281 | } |
282 | 282 | // Fall through |
283 | 283 | case 'insert' : |
284 | - if($_action == 'insert') { |
|
284 | + if ($_action == 'insert') { |
|
285 | 285 | // Backend doesn't like inserting with ID specified, can overwrite existing |
286 | 286 | unset($_data['id']); |
287 | 287 | } |
288 | 288 | // Make sure participants are set |
289 | - if(!$_data['participants']) { |
|
289 | + if (!$_data['participants']) { |
|
290 | 290 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
291 | 291 | $_data['participants'] = array( |
292 | 292 | $user => 'U' |
293 | 293 | ); |
294 | 294 | } |
295 | - if ( $this->dry_run ) { |
|
295 | + if ($this->dry_run) { |
|
296 | 296 | //print_r($_data); |
297 | 297 | $this->results[$_action]++; |
298 | 298 | return true; |
299 | 299 | } else { |
300 | - $result = $this->bo->save( $_data, $this->is_admin); |
|
301 | - if(!$result) { |
|
300 | + $result = $this->bo->save($_data, $this->is_admin); |
|
301 | + if (!$result) { |
|
302 | 302 | $this->errors[$record_num] = lang('Unable to save'); |
303 | 303 | } else { |
304 | 304 | $this->results[$_action]++; |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param egw_record $row_entry |
347 | 347 | */ |
348 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
348 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
349 | 349 | { |
350 | - $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true)); |
|
350 | + $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true)); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } // end of iface_export_plugin |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @var mixed |
34 | 34 | */ |
35 | - var $debug=false; |
|
35 | + var $debug = false; |
|
36 | 36 | /** |
37 | 37 | * Filternames |
38 | 38 | * |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param array $set_states=null to manualy set / change one of the states, default NULL = use $_REQUEST |
52 | 52 | */ |
53 | - function __construct($set_states=null) |
|
53 | + function __construct($set_states = null) |
|
54 | 54 | { |
55 | - parent::__construct(true,$set_states); // call the parent's constructor |
|
55 | + parent::__construct(true, $set_states); // call the parent's constructor |
|
56 | 56 | |
57 | 57 | $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Listview'). |
58 | 58 | // for a single owner we add it's name to the app-header |
59 | - (count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : ''); |
|
59 | + (count(explode(',', $this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : ''); |
|
60 | 60 | |
61 | - foreach($this->date_filters as $name => $label) |
|
61 | + foreach ($this->date_filters as $name => $label) |
|
62 | 62 | { |
63 | 63 | $this->date_filters[$name] = lang($label); |
64 | 64 | } |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | 'multiple' => 0, |
83 | 83 | 'view' => $this->bo->cal_prefs['mainscreen_showevents'], |
84 | 84 | )); |
85 | - egw_session::appsession('calendar_list','calendar',''); // in case there's already something set |
|
85 | + egw_session::appsession('calendar_list', 'calendar', ''); // in case there's already something set |
|
86 | 86 | |
87 | - return $this->listview(null,'',true); |
|
87 | + return $this->listview(null, '', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Show the listview |
92 | 92 | */ |
93 | - function listview($content=null,$msg='',$home=false) |
|
93 | + function listview($content = null, $msg = '', $home = false) |
|
94 | 94 | { |
95 | 95 | if ($_GET['msg']) $msg .= $_GET['msg']; |
96 | 96 | if ($this->group_warning) $msg .= $this->group_warning; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $etpl = new etemplate_new('calendar.list'); |
99 | 99 | |
100 | 100 | // Handle merge from sidebox |
101 | - if($_GET['merge']) |
|
101 | + if ($_GET['merge']) |
|
102 | 102 | { |
103 | 103 | $content['nm']['action'] = 'document_'.$_GET['merge']; |
104 | 104 | $content['nm']['select_all'] = true; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | if (is_array($content)) |
108 | 108 | { |
109 | 109 | // handle a single button like actions |
110 | - foreach(array('delete','timesheet','document') as $button) |
|
110 | + foreach (array('delete', 'timesheet', 'document') as $button) |
|
111 | 111 | { |
112 | 112 | if ($content['nm']['rows'][$button]) |
113 | 113 | { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if ($content['nm']['action']) |
121 | 121 | { |
122 | 122 | // Allow merge using the date range filter |
123 | - if(strpos($content['nm']['action'],'document') !== false && |
|
123 | + if (strpos($content['nm']['action'], 'document') !== false && |
|
124 | 124 | !count($content['nm']['selected']) && !$content['nm']['select_all']) { |
125 | 125 | $content['nm']['selected'][] = $this->get_merge_range($content['nm']); |
126 | 126 | } |
@@ -130,42 +130,42 @@ discard block |
||
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
134 | - $success,$failed,$action_msg,'calendar_list',$msg, $content['nm']['checkboxes']['no_notifications'])) |
|
133 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
134 | + $success, $failed, $action_msg, 'calendar_list', $msg, $content['nm']['checkboxes']['no_notifications'])) |
|
135 | 135 | { |
136 | - $msg .= lang('%1 event(s) %2',$success,$action_msg); |
|
136 | + $msg .= lang('%1 event(s) %2', $success, $action_msg); |
|
137 | 137 | } |
138 | - elseif(is_null($msg)) |
|
138 | + elseif (is_null($msg)) |
|
139 | 139 | { |
140 | - $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
140 | + $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | $content = array( |
146 | - 'nm' => egw_session::appsession('calendar_list','calendar'), |
|
146 | + 'nm' => egw_session::appsession('calendar_list', 'calendar'), |
|
147 | 147 | ); |
148 | 148 | if (!is_array($content['nm'])) |
149 | 149 | { |
150 | 150 | $content['nm'] = array( |
151 | 151 | 'get_rows' => 'calendar.calendar_uilist.get_rows', |
152 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
153 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
154 | - 'no_cat' => True, // I disable the cat-selectbox |
|
152 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
153 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
154 | + 'no_cat' => True, // I disable the cat-selectbox |
|
155 | 155 | 'filter' => 'after', |
156 | - 'order' => 'cal_start',// IO name of the column to sort after (optional for the sortheaders) |
|
157 | - 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' |
|
156 | + 'order' => 'cal_start', // IO name of the column to sort after (optional for the sortheaders) |
|
157 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
158 | 158 | 'default_cols' => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id', |
159 | 159 | 'filter_onchange' => "app.calendar.filter_change", |
160 | 160 | 'header_left' => 'calendar.list.dates', |
161 | - 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
161 | + 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
162 | 162 | 'row_modified' => 'modified', |
163 | 163 | 'favorites' => true |
164 | 164 | ); |
165 | 165 | } |
166 | 166 | $content['nm']['actions'] = $this->get_actions(); |
167 | 167 | |
168 | - if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters))) |
|
168 | + if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters))) |
|
169 | 169 | { |
170 | 170 | $content['nm']['filter'] = $_GET['filter']; |
171 | 171 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) && |
178 | 178 | !empty($json_data['request']['parameters'][0])) |
179 | 179 | { |
180 | - parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
180 | + parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
181 | 181 | if (isset($params['keywords'])) // new search => set filters so every match is shown |
182 | 182 | { |
183 | 183 | $this->adjust_for_search($params['keywords'], $content['nm']); |
@@ -185,22 +185,22 @@ discard block |
||
185 | 185 | } |
186 | 186 | if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
187 | 187 | { |
188 | - $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
|
188 | + $this->adjust_for_search($_REQUEST['keywords'], $content['nm']); |
|
189 | 189 | } |
190 | 190 | $sel_options['filter'] = &$this->date_filters; |
191 | 191 | |
192 | 192 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
193 | - $sel_options['category'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,calendar',$no_lang,false,$value['cat_id']); |
|
193 | + $sel_options['category'] = array('' => lang('all')) + etemplate_widget_menupopup::typeOptions('select-cat', ',,calendar', $no_lang, false, $value['cat_id']); |
|
194 | 194 | // Prevent double encoding - widget does this on its own, but we're just grabbing the options |
195 | - foreach($sel_options['category'] as &$label) |
|
195 | + foreach ($sel_options['category'] as &$label) |
|
196 | 196 | { |
197 | - if(!is_array($label)) |
|
197 | + if (!is_array($label)) |
|
198 | 198 | { |
199 | - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); |
|
199 | + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); |
|
200 | 200 | } |
201 | - elseif($label['label']) |
|
201 | + elseif ($label['label']) |
|
202 | 202 | { |
203 | - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); |
|
203 | + $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8'); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '') |
209 | 209 | { |
210 | 210 | $content['css'] .= '<style type="text/css">@media screen { .listDescription { max-height: '. |
211 | - (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35). // dono why em is not real lines |
|
211 | + (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines |
|
212 | 212 | 'em; overflow: auto; }}</style>'; |
213 | 213 | } |
214 | 214 | |
215 | - if($msg) |
|
215 | + if ($msg) |
|
216 | 216 | { |
217 | 217 | egw_framework::message($msg); |
218 | 218 | } |
219 | - $html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,$readonlys,array(),$home ? -1 : 0); |
|
219 | + $html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, $readonlys, array(), $home ? -1 : 0); |
|
220 | 220 | |
221 | 221 | // Not sure why this has to be echoed instead of appended, but that's what works. |
222 | 222 | //echo calendar_uiviews::edit_series(); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | /** |
228 | 228 | * set filter for search, so that everything is shown |
229 | 229 | */ |
230 | - function adjust_for_search($keywords,&$params) |
|
230 | + function adjust_for_search($keywords, &$params) |
|
231 | 231 | { |
232 | 232 | $params['search'] = $keywords; |
233 | 233 | $params['start'] = 0; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param array &$rows returned rows/events |
254 | 254 | * @param array &$readonlys eg. to disable buttons based on acl |
255 | 255 | */ |
256 | - function get_rows(&$params,&$rows,&$readonlys) |
|
256 | + function get_rows(&$params, &$rows, &$readonlys) |
|
257 | 257 | { |
258 | 258 | //echo "uilist::get_rows() params="; _debug_array($params); |
259 | 259 | if (isset($_GET['listview_days']) && is_numeric($_GET['listview_days'])) |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $this->manage_states(array('date' => $this->bo->date2string($params['startdate']))); |
278 | 278 | } |
279 | 279 | } |
280 | - $old_params = egw_session::appsession('calendar_list','calendar'); |
|
280 | + $old_params = egw_session::appsession('calendar_list', 'calendar'); |
|
281 | 281 | if (is_array($old_params)) |
282 | 282 | { |
283 | 283 | if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly |
@@ -287,58 +287,58 @@ discard block |
||
287 | 287 | } |
288 | 288 | if ($old_params['search'] != $params['search']) |
289 | 289 | { |
290 | - $this->adjust_for_search($params['search'],$params); |
|
290 | + $this->adjust_for_search($params['search'], $params); |
|
291 | 291 | } |
292 | 292 | } |
293 | - if (!$params['csv_export']) egw_session::appsession('calendar_list','calendar',$params); |
|
293 | + if (!$params['csv_export']) egw_session::appsession('calendar_list', 'calendar', $params); |
|
294 | 294 | |
295 | 295 | // do we need to query custom fields and which |
296 | 296 | // Check stored preference if selectcols isn't available (ie: first call) |
297 | 297 | $select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows']; |
298 | - if(!is_array($params['selectcols'])) |
|
298 | + if (!is_array($params['selectcols'])) |
|
299 | 299 | { |
300 | - $select_cols = explode(',',$select_cols); |
|
300 | + $select_cols = explode(',', $select_cols); |
|
301 | 301 | } |
302 | - if (in_array('cfs',$select_cols)) |
|
302 | + if (in_array('cfs', $select_cols)) |
|
303 | 303 | { |
304 | 304 | $cfs = array(); |
305 | - foreach($select_cols as $col) |
|
305 | + foreach ($select_cols as $col) |
|
306 | 306 | { |
307 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
307 | + if ($col[0] == '#') $cfs[] = substr($col, 1); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | $search_params = array( |
311 | - 'cat_id' => $this->cat_id ? explode(',',$this->cat_id) : 0, |
|
311 | + 'cat_id' => $this->cat_id ? explode(',', $this->cat_id) : 0, |
|
312 | 312 | 'filter' => $this->filter, |
313 | 313 | 'query' => $params['search'], |
314 | - 'offset' => (int) $params['start'], |
|
314 | + 'offset' => (int)$params['start'], |
|
315 | 315 | 'num_rows'=> $params['num_rows'], |
316 | 316 | 'order' => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start', |
317 | 317 | 'cfs' => $params['csv_export'] ? array() : $cfs, |
318 | 318 | ); |
319 | - switch($params['filter']) |
|
319 | + switch ($params['filter']) |
|
320 | 320 | { |
321 | 321 | case 'all': |
322 | 322 | break; |
323 | 323 | case 'before': |
324 | 324 | $search_params['end'] = $this->date; |
325 | - $label = lang('Before %1',$this->bo->long_date($this->date)); |
|
325 | + $label = lang('Before %1', $this->bo->long_date($this->date)); |
|
326 | 326 | break; |
327 | 327 | case 'custom': |
328 | 328 | $this->first = $search_params['start'] = $params['startdate']; |
329 | - $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1; |
|
330 | - $label = $this->bo->long_date($this->first,$this->last); |
|
329 | + $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1; |
|
330 | + $label = $this->bo->long_date($this->first, $this->last); |
|
331 | 331 | break; |
332 | 332 | case 'fixed': |
333 | 333 | if ($this->listview_days == 5 || $this->listview_days == 7) // weekview |
334 | 334 | { |
335 | - $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day); |
|
335 | + $this->first = $this->datetime->get_weekday_start($this->year, $this->month, $this->day); |
|
336 | 336 | $this->last = $this->bo->date2array($this->first); |
337 | - $this->last['day'] += (int) $this->listview_days - 1; |
|
337 | + $this->last['day'] += (int)$this->listview_days - 1; |
|
338 | 338 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
339 | 339 | unset($this->last['raw']); |
340 | 340 | $this->last = $this->bo->date2ts($this->last); |
341 | - $this->date_filters['fixed'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last); |
|
341 | + $this->date_filters['fixed'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last); |
|
342 | 342 | $params['startdate'] = $search_params['start'] = $this->first; |
343 | 343 | $params['enddate'] = $search_params['end'] = $this->last; |
344 | 344 | break; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $this->first = $this->bo->date2ts($this->first); |
354 | 354 | $this->last = $this->bo->date2ts($this->last); |
355 | 355 | $this->last--; |
356 | - $this->date_filters['fixed'] = $label = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
|
356 | + $this->date_filters['fixed'] = $label = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year; |
|
357 | 357 | $params['startdate'] = $search_params['start'] = $this->first; |
358 | 358 | $params['enddate'] = $search_params['end'] = $this->last; |
359 | 359 | break; |
@@ -361,24 +361,24 @@ discard block |
||
361 | 361 | // fall through to after given date |
362 | 362 | case 'after': |
363 | 363 | default: |
364 | - $label = lang('After %1',$this->bo->long_date($this->date)); |
|
364 | + $label = lang('After %1', $this->bo->long_date($this->date)); |
|
365 | 365 | $search_params['start'] = $this->date; |
366 | 366 | break; |
367 | 367 | } |
368 | - if ((int) $params['col_filter']['participant']) |
|
368 | + if ((int)$params['col_filter']['participant']) |
|
369 | 369 | { |
370 | - $search_params['users'] = (int) $params['col_filter']['participant']; |
|
370 | + $search_params['users'] = (int)$params['col_filter']['participant']; |
|
371 | 371 | } |
372 | - elseif(empty($params['search'])) // active search displays entries from all users |
|
372 | + elseif (empty($params['search'])) // active search displays entries from all users |
|
373 | 373 | { |
374 | - $search_params['users'] = explode(',',$this->owner); |
|
374 | + $search_params['users'] = explode(',', $this->owner); |
|
375 | 375 | } |
376 | 376 | if ($params['col_filter']) |
377 | 377 | { |
378 | 378 | $col_filter = array(); |
379 | - foreach($params['col_filter'] as $name => $val) |
|
379 | + foreach ($params['col_filter'] as $name => $val) |
|
380 | 380 | { |
381 | - if (!in_array($name, array('participant','row_id')) && (string)$val !== '') |
|
381 | + if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '') |
|
382 | 382 | { |
383 | 383 | $col_filter[$name] = $val; |
384 | 384 | } |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | $rows['sel_options']['filter'] = $this->date_filters; |
393 | 393 | $rows['sel_options']['filter'][$params['filter']] = $label; |
394 | 394 | } |
395 | - foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
395 | + foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
396 | 396 | { |
397 | - if (!$this->bo->check_perms(EGW_ACL_EDIT,$event)) |
|
397 | + if (!$this->bo->check_perms(EGW_ACL_EDIT, $event)) |
|
398 | 398 | { |
399 | 399 | $event['class'] .= 'rowNoEdit '; |
400 | 400 | } |
401 | 401 | |
402 | 402 | // Delete disabled for other applications |
403 | - if (!$this->bo->check_perms(EGW_ACL_DELETE,$event) || !is_numeric($event['id'])) |
|
403 | + if (!$this->bo->check_perms(EGW_ACL_DELETE, $event) || !is_numeric($event['id'])) |
|
404 | 404 | { |
405 | 405 | $event['class'] .= 'rowNoDelete '; |
406 | 406 | } |
@@ -414,39 +414,39 @@ discard block |
||
414 | 414 | $event['recure'] = $this->bo->recure2string($event); |
415 | 415 | if ($params['csv_export']) |
416 | 416 | { |
417 | - $event['participants'] = implode(",\n",$this->bo->participants($event,true)); |
|
417 | + $event['participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
418 | 418 | } |
419 | 419 | else |
420 | 420 | { |
421 | - $event['parts'] = implode(",\n",$this->bo->participants($event,true)); |
|
421 | + $event['parts'] = implode(",\n", $this->bo->participants($event, true)); |
|
422 | 422 | $event['date'] = $this->bo->date2string($event['start']); |
423 | 423 | } |
424 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
425 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
424 | + if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
425 | + if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
426 | 426 | |
427 | 427 | // respect category permissions |
428 | - if(!empty($event['category'])) |
|
428 | + if (!empty($event['category'])) |
|
429 | 429 | { |
430 | 430 | $event['category'] = $this->categories->check_list(EGW_ACL_READ, $event['category']); |
431 | 431 | } |
432 | 432 | |
433 | - if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches)) |
|
433 | + if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches)) |
|
434 | 434 | { |
435 | 435 | $app = $matches[1]; |
436 | 436 | $app_id = $matches[2]; |
437 | 437 | $icons = array(); |
438 | - if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event))) |
|
438 | + if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event))) |
|
439 | 439 | { |
440 | - $icons[] = html::image('calendar','private'); |
|
440 | + $icons[] = html::image('calendar', 'private'); |
|
441 | 441 | } |
442 | 442 | else |
443 | 443 | { |
444 | - $icons = calendar_uiviews::integration_get_icons($app,$app_id,$event); |
|
444 | + $icons = calendar_uiviews::integration_get_icons($app, $app_id, $event); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | else |
448 | 448 | { |
449 | - $is_private = !$this->bo->check_perms(EGW_ACL_READ,$event); |
|
449 | + $is_private = !$this->bo->check_perms(EGW_ACL_READ, $event); |
|
450 | 450 | } |
451 | 451 | if ($is_private) |
452 | 452 | { |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | $event['app_id'] = $event['id']; |
458 | 458 | |
459 | 459 | // Edit link |
460 | - if($app && $app_id) |
|
460 | + if ($app && $app_id) |
|
461 | 461 | { |
462 | - $popup = calendar_uiviews::integration_get_popup($app,$app_id); |
|
462 | + $popup = calendar_uiviews::integration_get_popup($app, $app_id); |
|
463 | 463 | |
464 | 464 | // Need to strip off 'onclick' |
465 | 465 | $event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup); |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | // populate js_integration_data, if not already set |
471 | 471 | if (!isset($js_integration_data[$app])) |
472 | 472 | { |
473 | - $js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link'); |
|
473 | + $js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link'); |
|
474 | 474 | if (!is_array($js_integration_data[$app]) || !isset($js_integration_data[$app]['edit'])) |
475 | 475 | { |
476 | 476 | $js_integration_data[$app]['edit'] = egw_link::get_registry($app, 'edit'); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | } |
487 | 487 | else |
488 | 488 | { |
489 | - $view_link = egw::link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit','cal_id'=>$event['id'],'date'=>$this->bo->date2string($event['start']))); |
|
489 | + $view_link = egw::link('/index.php', array('menuaction'=>'calendar.calendar_uiforms.edit', 'cal_id'=>$event['id'], 'date'=>$this->bo->date2string($event['start']))); |
|
490 | 490 | $event['edit_link'] = $this->popup($view_link).'; return false;'; |
491 | 491 | } |
492 | 492 | |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | $event['row_id'] = $event['id'].($event['recur_type'] ? ':'.$event['recur_date'] : ''); |
495 | 495 | |
496 | 496 | // Format start and end with timezone |
497 | - foreach(array('start','end') as $time) |
|
497 | + foreach (array('start', 'end') as $time) |
|
498 | 498 | { |
499 | - $event[$time] = egw_time::to($event[$time],'Y-m-d\TH:i:s\Z'); |
|
499 | + $event[$time] = egw_time::to($event[$time], 'Y-m-d\TH:i:s\Z'); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | $rows[] = $event; |
@@ -506,19 +506,19 @@ discard block |
||
506 | 506 | // set js_calendar_integration object, to use it in app.js cal_open() function |
507 | 507 | $params['js_integration_data'] = json_encode($js_integration_data); |
508 | 508 | |
509 | - $wv=0; |
|
510 | - $dv=0; |
|
509 | + $wv = 0; |
|
510 | + $dv = 0; |
|
511 | 511 | $params['options-selectcols']['week'] = lang('Week'); |
512 | 512 | $params['options-selectcols']['weekday'] = lang('Weekday'); |
513 | - if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,') |
|
513 | + if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,') |
|
514 | 514 | { |
515 | - $rows['format'] = '32'; // prefix date with week-number |
|
516 | - $wv=1; |
|
515 | + $rows['format'] = '32'; // prefix date with week-number |
|
516 | + $wv = 1; |
|
517 | 517 | } |
518 | - if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE)) |
|
518 | + if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE)) |
|
519 | 519 | { |
520 | 520 | $rows['format'] = '16'; |
521 | - $dv=1; |
|
521 | + $dv = 1; |
|
522 | 522 | } |
523 | 523 | if ($wv && $dv) |
524 | 524 | { |
@@ -545,35 +545,35 @@ discard block |
||
545 | 545 | * @param string/array $session_name 'calendar_list' |
546 | 546 | * @return boolean true if all actions succeded, false otherwise |
547 | 547 | */ |
548 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
|
548 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false) |
|
549 | 549 | { |
550 | 550 | //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)"); |
551 | 551 | $success = $failed = 0; |
552 | 552 | $msg = null; |
553 | 553 | |
554 | 554 | // Split out combined values |
555 | - if(strpos($action, 'status') !== false) |
|
555 | + if (strpos($action, 'status') !== false) |
|
556 | 556 | { |
557 | 557 | list($action, $status) = explode('-', $action); |
558 | 558 | } |
559 | 559 | elseif (strpos($action, '_') !== false) |
560 | 560 | { |
561 | - list($action, $settings) = explode('_', $action,2); |
|
561 | + list($action, $settings) = explode('_', $action, 2); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | if ($use_all) |
565 | 565 | { |
566 | 566 | // get the whole selection |
567 | - $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar'); |
|
568 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
569 | - $query['num_rows'] = -1; // all |
|
570 | - $this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document'))); // true = only return the id's |
|
567 | + $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name, 'calendar'); |
|
568 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
569 | + $query['num_rows'] = -1; // all |
|
570 | + $this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's |
|
571 | 571 | // Get rid of any extras (rows that aren't events) |
572 | - if(in_array($action,array('ical','document'))) |
|
572 | + if (in_array($action, array('ical', 'document'))) |
|
573 | 573 | { |
574 | - foreach($checked as $key => $event) |
|
574 | + foreach ($checked as $key => $event) |
|
575 | 575 | { |
576 | - if(!is_numeric($key)) |
|
576 | + if (!is_numeric($key)) |
|
577 | 577 | { |
578 | 578 | unset($checked[$key]); |
579 | 579 | } |
@@ -581,26 +581,26 @@ discard block |
||
581 | 581 | } |
582 | 582 | } |
583 | 583 | // for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id |
584 | - elseif($action == 'document') |
|
584 | + elseif ($action == 'document') |
|
585 | 585 | { |
586 | - $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar'); |
|
587 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
588 | - $this->get_rows($query,$events,$readonlys); |
|
589 | - foreach($events as $key => $event) |
|
586 | + $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name, 'calendar'); |
|
587 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
588 | + $this->get_rows($query, $events, $readonlys); |
|
589 | + foreach ($events as $key => $event) |
|
590 | 590 | { |
591 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
591 | + if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
592 | 592 | } |
593 | 593 | $checked = array_values($events); // Clear keys |
594 | 594 | } |
595 | 595 | |
596 | 596 | // Actions where one action is done to the group |
597 | - switch($action) |
|
597 | + switch ($action) |
|
598 | 598 | { |
599 | 599 | case 'ical': |
600 | 600 | // compile list of unique cal_id's, as iCal should contain whole series, not recurrences |
601 | 601 | // calendar_ical->exportVCal needs to read events again, to get them in server-time |
602 | 602 | $ids = array(); |
603 | - foreach($checked as $id) |
|
603 | + foreach ($checked as $id) |
|
604 | 604 | { |
605 | 605 | if (is_array($id)) $id = $id['id']; |
606 | 606 | // get rid of recurrences, doublicate series and calendar-integration events |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | } |
611 | 611 | } |
612 | 612 | $boical = new calendar_ical(); |
613 | - $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
613 | + $ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
614 | 614 | html::content_header('event.ics', 'text/calendar', bytes($ical)); |
615 | 615 | echo $ical; |
616 | 616 | common::egw_exit(); |
@@ -624,18 +624,18 @@ discard block |
||
624 | 624 | } |
625 | 625 | |
626 | 626 | // Actions where the action is applied to each entry |
627 | - if(strpos($action, 'timesheet') !== false) |
|
627 | + if (strpos($action, 'timesheet') !== false) |
|
628 | 628 | { |
629 | 629 | $timesheet_bo = new timesheet_bo(); |
630 | 630 | } |
631 | - foreach($checked as &$id) |
|
631 | + foreach ($checked as &$id) |
|
632 | 632 | { |
633 | 633 | $recur_date = $app = $app_id = null; |
634 | - if(is_array($id) && $id['id']) |
|
634 | + if (is_array($id) && $id['id']) |
|
635 | 635 | { |
636 | 636 | $id = $id['id']; |
637 | 637 | } |
638 | - if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches)) |
|
638 | + if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches)) |
|
639 | 639 | { |
640 | 640 | $app = $matches[1]; |
641 | 641 | $app_id = $matches[2]; |
@@ -643,27 +643,27 @@ discard block |
||
643 | 643 | } |
644 | 644 | else |
645 | 645 | { |
646 | - list($id,$recur_date) = explode(':',$id); |
|
646 | + list($id, $recur_date) = explode(':', $id); |
|
647 | 647 | } |
648 | - switch($action) |
|
648 | + switch ($action) |
|
649 | 649 | { |
650 | 650 | case 'delete': |
651 | 651 | $action_msg = lang('deleted'); |
652 | - if($settings == 'series') |
|
652 | + if ($settings == 'series') |
|
653 | 653 | { |
654 | 654 | // Delete the whole thing |
655 | 655 | $recur_date = 0; |
656 | 656 | } |
657 | - if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) |
|
657 | + if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification)) |
|
658 | 658 | { |
659 | 659 | $success++; |
660 | - if(!$recur_date && $settings == 'series') |
|
660 | + if (!$recur_date && $settings == 'series') |
|
661 | 661 | { |
662 | 662 | // If there are multiple events in a series selected, the next one could purge |
663 | - foreach($checked as $key => $c_id) |
|
663 | + foreach ($checked as $key => $c_id) |
|
664 | 664 | { |
665 | - list($c_id,$recur_date) = explode(':',$c_id); |
|
666 | - if($c_id == $id) |
|
665 | + list($c_id, $recur_date) = explode(':', $c_id); |
|
666 | + if ($c_id == $id) |
|
667 | 667 | { |
668 | 668 | unset($checked[$key]); |
669 | 669 | } |
@@ -677,16 +677,16 @@ discard block |
||
677 | 677 | break; |
678 | 678 | case 'undelete': |
679 | 679 | $action_msg = lang('recovered'); |
680 | - if($settings == 'series') |
|
680 | + if ($settings == 'series') |
|
681 | 681 | { |
682 | 682 | // unDelete the whole thing |
683 | 683 | $recur_date = 0; |
684 | 684 | } |
685 | - if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) && |
|
685 | + if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT, $id) && |
|
686 | 686 | is_array($event) && $event['deleted']) |
687 | 687 | { |
688 | 688 | $event['deleted'] = null; |
689 | - if($this->bo->save($event)) |
|
689 | + if ($this->bo->save($event)) |
|
690 | 690 | { |
691 | 691 | $success++; |
692 | 692 | break; |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | break; |
697 | 697 | case 'status': |
698 | 698 | $action_msg = lang('Status changed'); |
699 | - if($id && ($event = $this->bo->read($id, $recur_date))) |
|
699 | + if ($id && ($event = $this->bo->read($id, $recur_date))) |
|
700 | 700 | { |
701 | 701 | $old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']]; |
702 | 702 | calendar_so::split_status($old_status, $quantity, $role); |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | { |
705 | 705 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
706 | 706 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
707 | - if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date, |
|
708 | - false,true,$skip_notification)) |
|
707 | + if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date, |
|
708 | + false, true, $skip_notification)) |
|
709 | 709 | { |
710 | 710 | $success++; |
711 | 711 | //$msg = lang('Status changed'); |
@@ -722,19 +722,19 @@ discard block |
||
722 | 722 | } |
723 | 723 | break; |
724 | 724 | case 'timesheet-add': |
725 | - if($id && !$app) |
|
725 | + if ($id && !$app) |
|
726 | 726 | { |
727 | 727 | $event = $this->bo->read($id, $recur_date); |
728 | 728 | } |
729 | 729 | elseif ($app) |
730 | 730 | { |
731 | - $query = egw_session::appsession('calendar_list','calendar'); |
|
731 | + $query = egw_session::appsession('calendar_list', 'calendar'); |
|
732 | 732 | $query['query'] = $app_id; |
733 | 733 | $query['search'] = $app_id; |
734 | 734 | $result = $this->bo->search($query); |
735 | 735 | $event = $result[$app.$app_id]; |
736 | 736 | } |
737 | - if(!$event) |
|
737 | + if (!$event) |
|
738 | 738 | { |
739 | 739 | $failed++; |
740 | 740 | continue; |
@@ -751,16 +751,16 @@ discard block |
||
751 | 751 | ); |
752 | 752 | |
753 | 753 | // Add global categories |
754 | - $categories = explode(',',$event['category']); |
|
754 | + $categories = explode(',', $event['category']); |
|
755 | 755 | $global_categories = array(); |
756 | - foreach($categories as $cat_id) |
|
756 | + foreach ($categories as $cat_id) |
|
757 | 757 | { |
758 | - if($GLOBALS['egw']->categories->is_global($cat_id)) |
|
758 | + if ($GLOBALS['egw']->categories->is_global($cat_id)) |
|
759 | 759 | { |
760 | 760 | $global_categories[] = $cat_id; |
761 | 761 | } |
762 | 762 | } |
763 | - if(count($global_categories)) |
|
763 | + if (count($global_categories)) |
|
764 | 764 | { |
765 | 765 | $timesheet['cat_id'] = implode(',', $global_categories); |
766 | 766 | } |
@@ -780,12 +780,12 @@ discard block |
||
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
783 | - if(!$err) |
|
783 | + if (!$err) |
|
784 | 784 | { |
785 | 785 | $success++; |
786 | 786 | |
787 | 787 | // Can't link to just one of a recurring series of events |
788 | - if(!$recur_date || $app) { |
|
788 | + if (!$recur_date || $app) { |
|
789 | 789 | // Create link |
790 | 790 | $link_id = $app ? $app_id : $id; |
791 | 791 | egw_link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | protected function get_merge_range($nm) |
814 | 814 | { |
815 | 815 | $checked = array(); |
816 | - if($nm['filter'] == 'fixed') |
|
816 | + if ($nm['filter'] == 'fixed') |
|
817 | 817 | { |
818 | 818 | $checked['start'] = $nm['startdate']; |
819 | 819 | $last = $this->bo->date2array($nm['enddate']); |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | } |
823 | 823 | else |
824 | 824 | { |
825 | - switch($nm['filter']) |
|
825 | + switch ($nm['filter']) |
|
826 | 826 | { |
827 | 827 | case 'after': |
828 | 828 | $checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today'); |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | $checked['end'] = $nm['enddate']; |
836 | 836 | break; |
837 | 837 | default: |
838 | - $date = date_create_from_format('Ymd',$this->date); |
|
839 | - $checked['start']= $date->format('U'); |
|
838 | + $date = date_create_from_format('Ymd', $this->date); |
|
839 | + $checked['start'] = $date->format('U'); |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | return $checked; |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | 'allowOnMultiple' => false, |
861 | 861 | 'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id', |
862 | 862 | 'popup' => egw_link::get_registry('calendar', 'view_popup'), |
863 | - 'group' => $group=1, |
|
863 | + 'group' => $group = 1, |
|
864 | 864 | 'onExecute' => 'javaScript:app.calendar.cal_open', |
865 | 865 | 'disableClass' => 'rowNoView', |
866 | 866 | ), |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | 'group' => $group, |
886 | 886 | ), |
887 | 887 | ); |
888 | - $status = array_map('lang',$this->bo->verbose_status); |
|
888 | + $status = array_map('lang', $this->bo->verbose_status); |
|
889 | 889 | unset($status['G']); |
890 | 890 | $actions['status'] = array( |
891 | 891 | 'caption' => 'Change your status', |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | 'children' => $status, |
895 | 895 | 'group' => ++$group, |
896 | 896 | ); |
897 | - ++$group; // integration with other apps: infolog, calendar, filemanager |
|
897 | + ++$group; // integration with other apps: infolog, calendar, filemanager |
|
898 | 898 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
899 | 899 | { |
900 | 900 | $actions['filemanager'] = array( |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | 'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id', |
927 | 927 | 'group' => $group, |
928 | 928 | 'allowOnMultiple' => false, |
929 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
929 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
930 | 930 | 'onExecute' => 'javaScript:app.calendar.cal_fix_app_id', |
931 | 931 | 'popup' => egw_link::get_registry('timesheet', 'add_popup'), |
932 | 932 | ); |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | 'caption' => 'Timesheet', |
936 | 936 | 'group' => $group, |
937 | 937 | 'allowOnMultiple' => 'only', |
938 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
938 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
939 | 939 | ); |
940 | 940 | } |
941 | 941 | $actions['ical'] = array( |
@@ -944,11 +944,11 @@ discard block |
||
944 | 944 | 'group' => ++$group, |
945 | 945 | 'hint' => 'Download this event as iCal', |
946 | 946 | 'disableClass' => 'rowNoView', |
947 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
947 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
948 | 948 | ); |
949 | 949 | $actions['documents'] = calendar_merge::document_action( |
950 | 950 | $this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_', |
951 | - $this->bo->cal_prefs['default_document'],bo_merge::getExportLimit('calendar') |
|
951 | + $this->bo->cal_prefs['default_document'], bo_merge::getExportLimit('calendar') |
|
952 | 952 | ); |
953 | 953 | ++$group; |
954 | 954 | $actions['delete'] = array( |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | 'disableClass' => 'rowNoDelete', |
959 | 959 | ); |
960 | 960 | // Add in deleted for admins |
961 | - if($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
961 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
962 | 962 | { |
963 | 963 | $actions['undelete'] = array( |
964 | 964 | 'caption' => 'Un-delete', |