@@ -81,11 +81,17 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function __construct() |
| 83 | 83 | { |
| 84 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 84 | + if ($this->debug > 0) |
|
| 85 | + { |
|
| 86 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 87 | + } |
|
| 85 | 88 | |
| 86 | 89 | parent::__construct(); // calling the parent constructor |
| 87 | 90 | |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 91 | + if ($this->debug > 0) |
|
| 92 | + { |
|
| 93 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 94 | + } |
|
| 89 | 95 | } |
| 90 | 96 | |
| 91 | 97 | /** |
@@ -115,7 +121,10 @@ discard block |
||
| 115 | 121 | function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
| 116 | 122 | { |
| 117 | 123 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 118 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
| 124 | + if (!is_array($messages)) |
|
| 125 | + { |
|
| 126 | + $messages = $messages ? (array)$messages : array(); |
|
| 127 | + } |
|
| 119 | 128 | |
| 120 | 129 | if ($this->debug > 1 || $this->debug == 'update') |
| 121 | 130 | { |
@@ -135,10 +144,13 @@ discard block |
||
| 135 | 144 | |
| 136 | 145 | $status_reset_to_unknown = false; |
| 137 | 146 | |
| 138 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
| 147 | + if (($new_event = !$event['id'])) |
|
| 148 | + { |
|
| 149 | + // some defaults for new entries |
|
| 139 | 150 | { |
| 140 | 151 | // if no owner given, set user to owner |
| 141 | 152 | if (!$event['owner']) $event['owner'] = $this->user; |
| 153 | + } |
|
| 142 | 154 | // set owner as participant if none is given |
| 143 | 155 | if (!is_array($event['participants']) || !count($event['participants'])) |
| 144 | 156 | { |
@@ -178,7 +190,10 @@ discard block |
||
| 178 | 190 | // check category based ACL |
| 179 | 191 | if ($event['category']) |
| 180 | 192 | { |
| 181 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 193 | + if (!is_array($event['category'])) |
|
| 194 | + { |
|
| 195 | + $event['category'] = explode(',',$event['category']); |
|
| 196 | + } |
|
| 182 | 197 | if (!$old_event || !isset($old_event['category'])) |
| 183 | 198 | { |
| 184 | 199 | $old_event['category'] = array(); |
@@ -231,18 +246,28 @@ discard block |
||
| 231 | 246 | $types_with_quantity = array(); |
| 232 | 247 | foreach($this->resources as $type => $data) |
| 233 | 248 | { |
| 234 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 249 | + if ($data['max_quantity']) |
|
| 250 | + { |
|
| 251 | + $types_with_quantity[] = $type; |
|
| 252 | + } |
|
| 235 | 253 | } |
| 236 | 254 | // get all NOT rejected participants and evtl. their quantity |
| 237 | 255 | $quantity = $users = array(); |
| 238 | 256 | foreach($event['participants'] as $uid => $status) |
| 239 | 257 | { |
| 240 | 258 | calendar_so::split_status($status,$q,$r); |
| 241 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 259 | + if ($status[0] == 'R') |
|
| 260 | + { |
|
| 261 | + continue; |
|
| 262 | + } |
|
| 263 | + // ignore rejected participants |
|
| 242 | 264 | |
| 243 | - if ($uid < 0) // group, check it's members too |
|
| 265 | + if ($uid < 0) |
|
| 266 | + { |
|
| 267 | + // group, check it's members too |
|
| 244 | 268 | { |
| 245 | 269 | $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
| 270 | + } |
|
| 246 | 271 | $users = array_unique($users); |
| 247 | 272 | } |
| 248 | 273 | $users[] = $uid; |
@@ -273,10 +298,13 @@ discard block |
||
| 273 | 298 | { |
| 274 | 299 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 275 | 300 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 276 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 301 | + $overlap['non_blocking']) |
|
| 302 | + { |
|
| 303 | + // that's a non_blocking event |
|
| 277 | 304 | { |
| 278 | 305 | continue; |
| 279 | 306 | } |
| 307 | + } |
|
| 280 | 308 | if ($this->debug > 3 || $this->debug == 'update') |
| 281 | 309 | { |
| 282 | 310 | $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
@@ -414,7 +442,10 @@ discard block |
||
| 414 | 442 | $types_with_quantity = array(); |
| 415 | 443 | foreach($this->resources as $type => $data) |
| 416 | 444 | { |
| 417 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 445 | + if ($data['max_quantity']) |
|
| 446 | + { |
|
| 447 | + $types_with_quantity[] = $type; |
|
| 448 | + } |
|
| 418 | 449 | } |
| 419 | 450 | // get all NOT rejected participants and evtl. their quantity |
| 420 | 451 | $quantity = $users = array(); |
@@ -422,12 +453,19 @@ discard block |
||
| 422 | 453 | { |
| 423 | 454 | $q = $r = null; |
| 424 | 455 | calendar_so::split_status($status,$q,$r); |
| 425 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 456 | + if ($status[0] == 'R') |
|
| 457 | + { |
|
| 458 | + continue; |
|
| 459 | + } |
|
| 460 | + // ignore rejected participants |
|
| 426 | 461 | |
| 427 | - if ($uid < 0) // group, check it's members too |
|
| 462 | + if ($uid < 0) |
|
| 463 | + { |
|
| 464 | + // group, check it's members too |
|
| 428 | 465 | { |
| 429 | 466 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
| 430 | 467 | } |
| 468 | + } |
|
| 431 | 469 | $users[] = $uid; |
| 432 | 470 | if (in_array($uid[0],$types_with_quantity)) |
| 433 | 471 | { |
@@ -458,18 +496,24 @@ discard block |
||
| 458 | 496 | $startts = $date->format('ts'); |
| 459 | 497 | |
| 460 | 498 | // skip past events or recurrences |
| 461 | - if ($startts+$duration < $this->now_su) continue; |
|
| 499 | + if ($startts+$duration < $this->now_su) |
|
| 500 | + { |
|
| 501 | + continue; |
|
| 502 | + } |
|
| 462 | 503 | |
| 463 | 504 | // abort check if configured limits are exceeded |
| 464 | 505 | if ($event['recur_type'] && |
| 465 | 506 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 466 | 507 | microtime(true) > $start+$max_check_time || // max check time exceeded |
| 467 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
| 508 | + $startts > $this->config['horizont'])) |
|
| 509 | + { |
|
| 510 | + // we are behind horizon for which recurrences are rendered |
|
| 468 | 511 | { |
| 469 | 512 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 470 | 513 | { |
| 471 | 514 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 472 | 515 | $checked, microtime(true)-$start, $date); |
| 516 | + } |
|
| 473 | 517 | } |
| 474 | 518 | $checked_excluding = $date; |
| 475 | 519 | break; |
@@ -493,10 +537,13 @@ discard block |
||
| 493 | 537 | { |
| 494 | 538 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 495 | 539 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 496 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 540 | + $overlap['non_blocking']) |
|
| 541 | + { |
|
| 542 | + // that's a non_blocking event |
|
| 497 | 543 | { |
| 498 | 544 | continue; |
| 499 | 545 | } |
| 546 | + } |
|
| 500 | 547 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 501 | 548 | { |
| 502 | 549 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -617,7 +664,11 @@ discard block |
||
| 617 | 664 | */ |
| 618 | 665 | public function check_acl_invite($uid) |
| 619 | 666 | { |
| 620 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 667 | + if (!is_numeric($uid)) |
|
| 668 | + { |
|
| 669 | + return true; |
|
| 670 | + } |
|
| 671 | + // nothing implemented for resources so far |
|
| 621 | 672 | |
| 622 | 673 | if (!$this->require_acl_invite) |
| 623 | 674 | { |
@@ -958,14 +1009,20 @@ discard block |
||
| 958 | 1009 | $startdate = new egw_time($event['start']); |
| 959 | 1010 | $enddate = new egw_time($event['end']); |
| 960 | 1011 | $modified = new egw_time($event['modified']); |
| 961 | - if ($old_event) $olddate = new egw_time($old_event['start']); |
|
| 1012 | + if ($old_event) |
|
| 1013 | + { |
|
| 1014 | + $olddate = new egw_time($old_event['start']); |
|
| 1015 | + } |
|
| 962 | 1016 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 963 | 1017 | $owner_prefs = $ics = null; |
| 964 | 1018 | foreach($to_notify as $userid => $statusid) |
| 965 | 1019 | { |
| 966 | 1020 | $res_info = $quantity = $role = null; |
| 967 | 1021 | calendar_so::split_status($statusid, $quantity, $role); |
| 968 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 1022 | + if ($this->debug > 0) |
|
| 1023 | + { |
|
| 1024 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 1025 | + } |
|
| 969 | 1026 | |
| 970 | 1027 | if (!is_numeric($userid)) |
| 971 | 1028 | { |
@@ -984,7 +1041,11 @@ discard block |
||
| 984 | 1041 | |
| 985 | 1042 | if (!isset($userid)) |
| 986 | 1043 | { |
| 987 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 1044 | + if (empty($res_info['email'])) |
|
| 1045 | + { |
|
| 1046 | + continue; |
|
| 1047 | + } |
|
| 1048 | + // no way to notify |
|
| 988 | 1049 | // check if event-owner wants non-EGroupware users notified |
| 989 | 1050 | if (is_null($owner_prefs)) |
| 990 | 1051 | { |
@@ -1049,11 +1110,20 @@ discard block |
||
| 1049 | 1110 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 1050 | 1111 | $action, $event_arr, $disinvited); |
| 1051 | 1112 | $details['to-fullname'] = $fullname; |
| 1052 | - if (isset($tfn)) $details['to-firstname'] = $tfn; |
|
| 1053 | - if (isset($tln)) $details['to-lastname'] = $tln; |
|
| 1113 | + if (isset($tfn)) |
|
| 1114 | + { |
|
| 1115 | + $details['to-firstname'] = $tfn; |
|
| 1116 | + } |
|
| 1117 | + if (isset($tln)) |
|
| 1118 | + { |
|
| 1119 | + $details['to-lastname'] = $tln; |
|
| 1120 | + } |
|
| 1054 | 1121 | |
| 1055 | 1122 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 1056 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1123 | + if (!isset($part_prefs['common']['tz'])) |
|
| 1124 | + { |
|
| 1125 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1126 | + } |
|
| 1057 | 1127 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 1058 | 1128 | $timeformat = $part_prefs['common']['timeformat']; |
| 1059 | 1129 | switch($timeformat) |
@@ -1088,9 +1158,12 @@ discard block |
||
| 1088 | 1158 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 1089 | 1159 | { |
| 1090 | 1160 | case 'ical': |
| 1091 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1161 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 1162 | + { |
|
| 1163 | + // need different ical for organizer notification |
|
| 1092 | 1164 | { |
| 1093 | 1165 | $calendar_ical = new calendar_ical(); |
| 1166 | + } |
|
| 1094 | 1167 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 1095 | 1168 | // we need to pass $event[id] so iCal class reads event again, |
| 1096 | 1169 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1104,7 +1177,10 @@ discard block |
||
| 1104 | 1177 | 'encoding' => '8bit', |
| 1105 | 1178 | 'type' => 'text/calendar; method='.$method, |
| 1106 | 1179 | ); |
| 1107 | - if ($m_type != $msg_type) unset($ics); |
|
| 1180 | + if ($m_type != $msg_type) |
|
| 1181 | + { |
|
| 1182 | + unset($ics); |
|
| 1183 | + } |
|
| 1108 | 1184 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 1109 | 1185 | // fall through |
| 1110 | 1186 | case 'extended': |
@@ -1155,7 +1231,9 @@ discard block |
||
| 1155 | 1231 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 1156 | 1232 | $notification->set_popuplinks(array($details['link_arr'])); |
| 1157 | 1233 | |
| 1158 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1234 | + if(is_array($attachment)) |
|
| 1235 | + { |
|
| 1236 | +$notification->set_attachments(array($attachment)); } |
|
| 1159 | 1237 | $notification->send(); |
| 1160 | 1238 | } |
| 1161 | 1239 | catch (Exception $exception) { |
@@ -1182,7 +1260,10 @@ discard block |
||
| 1182 | 1260 | translation::init(); |
| 1183 | 1261 | } |
| 1184 | 1262 | // restore timezone, in case we had to reset it to server-timezone |
| 1185 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1263 | + if ($restore_tz) |
|
| 1264 | + { |
|
| 1265 | + date_default_timezone_set($restore_tz); |
|
| 1266 | + } |
|
| 1186 | 1267 | |
| 1187 | 1268 | return true; |
| 1188 | 1269 | } |
@@ -1217,10 +1298,13 @@ discard block |
||
| 1217 | 1298 | { |
| 1218 | 1299 | $to_notify = $event['participants']; |
| 1219 | 1300 | } |
| 1220 | - elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1301 | + elseif ($this->check_perms(EGW_ACL_READ,$event)) |
|
| 1302 | + { |
|
| 1303 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1221 | 1304 | { |
| 1222 | 1305 | $to_notify[$alarm['owner']] = 'A'; |
| 1223 | 1306 | } |
| 1307 | + } |
|
| 1224 | 1308 | else |
| 1225 | 1309 | { |
| 1226 | 1310 | return False; // no rights |
@@ -1270,7 +1354,10 @@ discard block |
||
| 1270 | 1354 | if ($event['id']) |
| 1271 | 1355 | { |
| 1272 | 1356 | // invalidate the read-cache if it contains the event we store now |
| 1273 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1357 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1358 | + { |
|
| 1359 | + self::$cached_event = array(); |
|
| 1360 | + } |
|
| 1274 | 1361 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
| 1275 | 1362 | } |
| 1276 | 1363 | else |
@@ -1278,7 +1365,10 @@ discard block |
||
| 1278 | 1365 | $old_event = null; |
| 1279 | 1366 | } |
| 1280 | 1367 | |
| 1281 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1368 | + if (!isset($event['whole_day'])) |
|
| 1369 | + { |
|
| 1370 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1371 | + } |
|
| 1282 | 1372 | $save_event = $event; |
| 1283 | 1373 | if ($event['whole_day']) |
| 1284 | 1374 | { |
@@ -1319,7 +1409,10 @@ discard block |
||
| 1319 | 1409 | foreach($timestamps as $ts) |
| 1320 | 1410 | { |
| 1321 | 1411 | // we convert here from user-time to timestamps in server-time! |
| 1322 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1412 | + if (isset($event[$ts])) |
|
| 1413 | + { |
|
| 1414 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1415 | + } |
|
| 1323 | 1416 | } |
| 1324 | 1417 | // convert tzid name to integer tz_id, of set user default |
| 1325 | 1418 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1369,7 +1462,10 @@ discard block |
||
| 1369 | 1462 | if (!isset($event['alarm'][$id])) |
| 1370 | 1463 | { |
| 1371 | 1464 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1372 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1465 | + if ($alarm['time'] < time()) |
|
| 1466 | + { |
|
| 1467 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1468 | + } |
|
| 1373 | 1469 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1374 | 1470 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1375 | 1471 | $old_event['participants'][$alarm['owner']]; |
@@ -1405,7 +1501,10 @@ discard block |
||
| 1405 | 1501 | unset($save_event['participants']); |
| 1406 | 1502 | $this->set_recurrences($save_event, $set_recurrences_start); |
| 1407 | 1503 | } |
| 1408 | - if ($updateTS) $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
| 1504 | + if ($updateTS) |
|
| 1505 | + { |
|
| 1506 | + $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
| 1507 | + } |
|
| 1409 | 1508 | |
| 1410 | 1509 | // create links for new participants from addressbook, if configured |
| 1411 | 1510 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
@@ -1423,7 +1522,10 @@ discard block |
||
| 1423 | 1522 | |
| 1424 | 1523 | // Update history |
| 1425 | 1524 | $tracking = new calendar_tracking($this); |
| 1426 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1525 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1526 | + { |
|
| 1527 | + $event['id']=$cal_id; |
|
| 1528 | + } |
|
| 1427 | 1529 | $tracking->track($event, $old_event); |
| 1428 | 1530 | |
| 1429 | 1531 | return $cal_id; |
@@ -1440,9 +1542,12 @@ discard block |
||
| 1440 | 1542 | */ |
| 1441 | 1543 | function check_status_perms($uid,$event) |
| 1442 | 1544 | { |
| 1443 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1545 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1546 | + { |
|
| 1547 | + // for contact we use the owner of the event |
|
| 1444 | 1548 | { |
| 1445 | 1549 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1550 | + } |
|
| 1446 | 1551 | |
| 1447 | 1552 | return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']); |
| 1448 | 1553 | } |
@@ -1453,13 +1558,19 @@ discard block |
||
| 1453 | 1558 | return $access; |
| 1454 | 1559 | } |
| 1455 | 1560 | // no access or denied access because of category acl --> regular check |
| 1456 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1561 | + if (!is_numeric($uid)) |
|
| 1562 | + { |
|
| 1563 | + // this is eg. for resources (r123) |
|
| 1457 | 1564 | { |
| 1458 | 1565 | $resource = $this->resource_info($uid); |
| 1566 | + } |
|
| 1459 | 1567 | |
| 1460 | 1568 | return EGW_ACL_EDIT & $resource['rights']; |
| 1461 | 1569 | } |
| 1462 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1570 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1571 | + { |
|
| 1572 | + return false; |
|
| 1573 | + } |
|
| 1463 | 1574 | |
| 1464 | 1575 | // regular user and groups (need to check memberships too) |
| 1465 | 1576 | if (!isset($event['participants'][$uid])) |
@@ -1483,7 +1594,10 @@ discard block |
||
| 1483 | 1594 | */ |
| 1484 | 1595 | function check_cat_acl($right,$event) |
| 1485 | 1596 | { |
| 1486 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1597 | + if (!is_array($event)) |
|
| 1598 | + { |
|
| 1599 | + $event = $this->read($event); |
|
| 1600 | + } |
|
| 1487 | 1601 | |
| 1488 | 1602 | $ret = null; |
| 1489 | 1603 | if ($event['category']) |
@@ -1540,7 +1654,10 @@ discard block |
||
| 1540 | 1654 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1541 | 1655 | { |
| 1542 | 1656 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1543 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1657 | + if (!isset(self::$cat_rights_cache)) |
|
| 1658 | + { |
|
| 1659 | + self::get_cat_rights($cat_id); |
|
| 1660 | + } |
|
| 1544 | 1661 | |
| 1545 | 1662 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1546 | 1663 | { |
@@ -1552,7 +1669,10 @@ discard block |
||
| 1552 | 1669 | else |
| 1553 | 1670 | { |
| 1554 | 1671 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1555 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1672 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1673 | + { |
|
| 1674 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1675 | + } |
|
| 1556 | 1676 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1557 | 1677 | } |
| 1558 | 1678 | egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1585,7 +1705,10 @@ discard block |
||
| 1585 | 1705 | foreach($cat_rights as $uid => $value) |
| 1586 | 1706 | { |
| 1587 | 1707 | $all |= $value; |
| 1588 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1708 | + if (in_array($uid,$memberships)) |
|
| 1709 | + { |
|
| 1710 | + $own |= $value; |
|
| 1711 | + } |
|
| 1589 | 1712 | } |
| 1590 | 1713 | } |
| 1591 | 1714 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1632,13 +1755,16 @@ discard block |
||
| 1632 | 1755 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1633 | 1756 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1634 | 1757 | { |
| 1635 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1758 | + if ($status == 'R') |
|
| 1759 | + { |
|
| 1760 | + // remove alarms belonging to rejected participants |
|
| 1636 | 1761 | { |
| 1637 | 1762 | foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1638 | 1763 | { |
| 1639 | 1764 | if ((string)$alarm['owner'] === (string)$uid) |
| 1640 | 1765 | { |
| 1641 | 1766 | $this->so->delete_alarm($id); |
| 1767 | + } |
|
| 1642 | 1768 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1643 | 1769 | } |
| 1644 | 1770 | } |
@@ -1656,8 +1782,15 @@ discard block |
||
| 1656 | 1782 | ); |
| 1657 | 1783 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1658 | 1784 | { |
| 1659 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1660 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1785 | + if (!is_array($event)) |
|
| 1786 | + { |
|
| 1787 | + $event = $this->read($cal_id); |
|
| 1788 | + } |
|
| 1789 | + if (isset($recur_date)) |
|
| 1790 | + { |
|
| 1791 | + $event = $this->read($event['id'],$recur_date); |
|
| 1792 | + } |
|
| 1793 | + //re-read the actually edited recurring event |
|
| 1661 | 1794 | $this->send_update($status2msg[$status],$event['participants'],$event); |
| 1662 | 1795 | } |
| 1663 | 1796 | |
@@ -1680,12 +1813,16 @@ discard block |
||
| 1680 | 1813 | */ |
| 1681 | 1814 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1682 | 1815 | { |
| 1683 | - if (!isset($new_event['participants'])) return; |
|
| 1816 | + if (!isset($new_event['participants'])) |
|
| 1817 | + { |
|
| 1818 | + return; |
|
| 1819 | + } |
|
| 1684 | 1820 | |
| 1685 | 1821 | // check the old list against the new list |
| 1686 | 1822 | foreach ($old_event['participants'] as $userid => $status) |
| 1687 | - { |
|
| 1688 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1823 | + { |
|
| 1824 | + if (!isset($new_event['participants'][$userid])) |
|
| 1825 | + { |
|
| 1689 | 1826 | // Attendee will be deleted this way |
| 1690 | 1827 | $new_event['participants'][$userid] = 'G'; |
| 1691 | 1828 | } |
@@ -1769,7 +1906,10 @@ discard block |
||
| 1769 | 1906 | } |
| 1770 | 1907 | else |
| 1771 | 1908 | { |
| 1772 | - if (!($exception = $this->read($id))) continue; |
|
| 1909 | + if (!($exception = $this->read($id))) |
|
| 1910 | + { |
|
| 1911 | + continue; |
|
| 1912 | + } |
|
| 1773 | 1913 | $exception['uid'] = common::generate_uid('calendar', $id); |
| 1774 | 1914 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1775 | 1915 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1840,7 +1980,10 @@ discard block |
||
| 1840 | 1980 | $event_arr = $this->event2array($event); |
| 1841 | 1981 | foreach($event_arr as $key => $val) |
| 1842 | 1982 | { |
| 1843 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1983 | + if ($key == 'recur_type') |
|
| 1984 | + { |
|
| 1985 | + $key = 'repetition'; |
|
| 1986 | + } |
|
| 1844 | 1987 | $details[$key] = $val['data']; |
| 1845 | 1988 | } |
| 1846 | 1989 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -2013,7 +2156,10 @@ discard block |
||
| 2013 | 2156 | */ |
| 2014 | 2157 | function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null) |
| 2015 | 2158 | { |
| 2016 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 2159 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 2160 | + { |
|
| 2161 | + return; |
|
| 2162 | + } |
|
| 2017 | 2163 | |
| 2018 | 2164 | $time = new egw_time($event['start']); |
| 2019 | 2165 | if(!is_array($event['alarm'])) |
@@ -2091,7 +2237,10 @@ discard block |
||
| 2091 | 2237 | if (is_array($old_event) || $old_event > 0) |
| 2092 | 2238 | { |
| 2093 | 2239 | // preserve categories without users read access |
| 2094 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2240 | + if (!is_array($old_event)) |
|
| 2241 | + { |
|
| 2242 | + $old_event = $this->read($old_event); |
|
| 2243 | + } |
|
| 2095 | 2244 | $old_categories = explode(',',$old_event['category']); |
| 2096 | 2245 | $old_cats_preserve = array(); |
| 2097 | 2246 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2182,7 +2331,10 @@ discard block |
||
| 2182 | 2331 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 2183 | 2332 | } |
| 2184 | 2333 | |
| 2185 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2334 | + if (!isset($event['recurrence'])) |
|
| 2335 | + { |
|
| 2336 | + $event['recurrence'] = 0; |
|
| 2337 | + } |
|
| 2186 | 2338 | |
| 2187 | 2339 | if ($filter == 'master') |
| 2188 | 2340 | { |
@@ -2236,19 +2388,26 @@ discard block |
||
| 2236 | 2388 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2237 | 2389 | } |
| 2238 | 2390 | } |
| 2239 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2391 | + } |
|
| 2392 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2240 | 2393 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2241 | 2394 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2242 | 2395 | { |
| 2243 | 2396 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2244 | 2397 | } |
| 2245 | 2398 | } |
| 2246 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2399 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2400 | + { |
|
| 2401 | + return $matchingEvents; |
|
| 2402 | + } |
|
| 2247 | 2403 | } |
| 2248 | 2404 | unset($event['id']); |
| 2249 | 2405 | |
| 2250 | 2406 | // No chance to find a master without [U]ID |
| 2251 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2407 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2408 | + { |
|
| 2409 | + return $matchingEvents; |
|
| 2410 | + } |
|
| 2252 | 2411 | |
| 2253 | 2412 | // only query calendars of users, we have READ-grants from |
| 2254 | 2413 | $users = array(); |
@@ -2257,17 +2416,23 @@ discard block |
||
| 2257 | 2416 | $user = trim($user); |
| 2258 | 2417 | if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user)) |
| 2259 | 2418 | { |
| 2260 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2419 | + if ($user && !in_array($user,$users)) |
|
| 2420 | + { |
|
| 2421 | + // already added? |
|
| 2261 | 2422 | { |
| 2262 | 2423 | $users[] = $user; |
| 2263 | 2424 | } |
| 2425 | + } |
|
| 2264 | 2426 | } |
| 2265 | 2427 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2266 | 2428 | { |
| 2267 | 2429 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2268 | 2430 | } |
| 2269 | 2431 | // the further code is only for real users |
| 2270 | - if (!is_numeric($user)) continue; |
|
| 2432 | + if (!is_numeric($user)) |
|
| 2433 | + { |
|
| 2434 | + continue; |
|
| 2435 | + } |
|
| 2271 | 2436 | |
| 2272 | 2437 | // for groups we have to include the members |
| 2273 | 2438 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2347,7 +2512,10 @@ discard block |
||
| 2347 | 2512 | } |
| 2348 | 2513 | foreach ($matchFields as $key) |
| 2349 | 2514 | { |
| 2350 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2515 | + if (isset($event[$key])) |
|
| 2516 | + { |
|
| 2517 | + $query['cal_'.$key] = $event[$key]; |
|
| 2518 | + } |
|
| 2351 | 2519 | } |
| 2352 | 2520 | } |
| 2353 | 2521 | |
@@ -2387,7 +2555,10 @@ discard block |
||
| 2387 | 2555 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2388 | 2556 | } |
| 2389 | 2557 | |
| 2390 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2558 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2559 | + { |
|
| 2560 | + continue; |
|
| 2561 | + } |
|
| 2391 | 2562 | |
| 2392 | 2563 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2393 | 2564 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2554,13 +2725,16 @@ discard block |
||
| 2554 | 2725 | foreach ($event['participants'] as $attendee => $status) |
| 2555 | 2726 | { |
| 2556 | 2727 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2557 | - $attendee != $egwEvent['owner']) // || |
|
| 2728 | + $attendee != $egwEvent['owner']) |
|
| 2729 | + { |
|
| 2730 | + // || |
|
| 2558 | 2731 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2559 | 2732 | { |
| 2560 | 2733 | if ($this->log) |
| 2561 | 2734 | { |
| 2562 | 2735 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2563 | 2736 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2737 | + } |
|
| 2564 | 2738 | } |
| 2565 | 2739 | continue 2; |
| 2566 | 2740 | } |
@@ -2882,7 +3056,10 @@ discard block |
||
| 2882 | 3056 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2883 | 3057 | { |
| 2884 | 3058 | // we convert here from server-time to timestamps in user-time! |
| 2885 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3059 | + if (isset($event[$ts])) |
|
| 3060 | + { |
|
| 3061 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3062 | + } |
|
| 2886 | 3063 | } |
| 2887 | 3064 | // same with the recur exceptions |
| 2888 | 3065 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2910,9 +3087,12 @@ discard block |
||
| 2910 | 3087 | */ |
| 2911 | 3088 | function purge($age) |
| 2912 | 3089 | { |
| 2913 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 3090 | + if (is_numeric($age) && $age > 0) |
|
| 3091 | + { |
|
| 3092 | + // just make sure bogus values dont delete everything |
|
| 2914 | 3093 | { |
| 2915 | 3094 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2916 | 3095 | } |
| 3096 | + } |
|
| 2917 | 3097 | } |
| 2918 | 3098 | } |