@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | 18 | // types of messsages send by calendar_boupdate::send_update |
| 19 | -define('MSG_DELETED',0); |
|
| 20 | -define('MSG_MODIFIED',1); |
|
| 21 | -define('MSG_ADDED',2); |
|
| 22 | -define('MSG_REJECTED',3); |
|
| 23 | -define('MSG_TENTATIVE',4); |
|
| 24 | -define('MSG_ACCEPTED',5); |
|
| 25 | -define('MSG_ALARM',6); |
|
| 26 | -define('MSG_DISINVITE',7); |
|
| 27 | -define('MSG_DELEGATED',8); |
|
| 19 | +define('MSG_DELETED', 0); |
|
| 20 | +define('MSG_MODIFIED', 1); |
|
| 21 | +define('MSG_ADDED', 2); |
|
| 22 | +define('MSG_REJECTED', 3); |
|
| 23 | +define('MSG_TENTATIVE', 4); |
|
| 24 | +define('MSG_ACCEPTED', 5); |
|
| 25 | +define('MSG_ALARM', 6); |
|
| 26 | +define('MSG_DISINVITE', 7); |
|
| 27 | +define('MSG_DELEGATED', 8); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Class to access AND manipulate all calendar data (business object) |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
| 89 | 89 | |
| 90 | - parent::__construct(); // calling the parent constructor |
|
| 90 | + parent::__construct(); // calling the parent constructor |
|
| 91 | 91 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 92 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -116,16 +116,16 @@ discard block |
||
| 116 | 116 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
| 117 | 117 | * ++++++++ ++++++++ |
| 118 | 118 | */ |
| 119 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
| 119 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
| 120 | 120 | { |
| 121 | - unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
| 121 | + unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
| 122 | 122 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 123 | 123 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
| 124 | 124 | |
| 125 | 125 | if ($this->debug > 1 || $this->debug == 'update') |
| 126 | 126 | { |
| 127 | 127 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
| 128 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
| 128 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
| 129 | 129 | } |
| 130 | 130 | // check some minimum requirements: |
| 131 | 131 | // - new events need start, end and title |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // check if user has the permission to update / create the event |
| 156 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 157 | - $new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) && |
|
| 158 | - !$this->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 156 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 157 | + $new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) && |
|
| 158 | + !$this->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 159 | 159 | { |
| 160 | - $messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner'])); |
|
| 160 | + $messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner'])); |
|
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | if ($new_event) |
@@ -166,24 +166,24 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | else |
| 168 | 168 | { |
| 169 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
| 169 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // do we need to check, if user is allowed to invite the invited participants |
| 173 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
| 173 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
| 174 | 174 | { |
| 175 | 175 | // report removed participants back to user |
| 176 | - foreach($removed as $key => $account_id) |
|
| 176 | + foreach ($removed as $key => $account_id) |
|
| 177 | 177 | { |
| 178 | 178 | $removed[$key] = $this->participant_name($account_id); |
| 179 | 179 | } |
| 180 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
| 181 | - ': '.implode(', ',$removed); |
|
| 180 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
| 181 | + ': '.implode(', ', $removed); |
|
| 182 | 182 | } |
| 183 | 183 | // check category based ACL |
| 184 | 184 | if ($event['category']) |
| 185 | 185 | { |
| 186 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 186 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
| 187 | 187 | if (!$old_event || !isset($old_event['category'])) |
| 188 | 188 | { |
| 189 | 189 | $old_event['category'] = array(); |
@@ -192,38 +192,38 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $old_event['category'] = explode(',', $old_event['category']); |
| 194 | 194 | } |
| 195 | - foreach($event['category'] as $key => $cat_id) |
|
| 195 | + foreach ($event['category'] as $key => $cat_id) |
|
| 196 | 196 | { |
| 197 | 197 | // check if user is allowed to update event categories |
| 198 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
| 199 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
| 198 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
| 199 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
| 200 | 200 | { |
| 201 | 201 | unset($event['category'][$key]); |
| 202 | 202 | // report removed category to user |
| 203 | 203 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
| 204 | - continue; // no further check, as cat was removed |
|
| 204 | + continue; // no further check, as cat was removed |
|
| 205 | 205 | } |
| 206 | 206 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
| 207 | 207 | if (!$status_reset_to_unknown && |
| 208 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
| 208 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
| 209 | 209 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
| 210 | 210 | { |
| 211 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 211 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 212 | 212 | { |
| 213 | 213 | $q = $r = null; |
| 214 | - calendar_so::split_status($status,$q,$r); |
|
| 214 | + calendar_so::split_status($status, $q, $r); |
|
| 215 | 215 | if ($status != 'U') |
| 216 | 216 | { |
| 217 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 217 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 218 | 218 | // todo: report reset status to user |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - $status_reset_to_unknown = true; // once is enough |
|
| 221 | + $status_reset_to_unknown = true; // once is enough |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | if ($removed_cats) |
| 225 | 225 | { |
| 226 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
| 226 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
| 227 | 227 | } |
| 228 | 228 | if ($status_reset_to_unknown) |
| 229 | 229 | { |
@@ -259,30 +259,30 @@ discard block |
||
| 259 | 259 | $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); |
| 260 | 260 | //error_log("new $cal_id=". array2string($event)); |
| 261 | 261 | |
| 262 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
| 262 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
| 263 | 263 | { |
| 264 | 264 | // Restored, bring back links |
| 265 | 265 | Link::restore('calendar', $cal_id); |
| 266 | 266 | } |
| 267 | 267 | if ($this->log_file) |
| 268 | 268 | { |
| 269 | - $this->log2file($event2save,$event,$old_event); |
|
| 269 | + $this->log2file($event2save, $event, $old_event); |
|
| 270 | 270 | } |
| 271 | 271 | // send notifications |
| 272 | - if(!$skip_notification) |
|
| 272 | + if (!$skip_notification) |
|
| 273 | 273 | { |
| 274 | 274 | if ($new_event) |
| 275 | 275 | { |
| 276 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
| 276 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
| 277 | 277 | } |
| 278 | 278 | else // update existing event |
| 279 | 279 | { |
| 280 | - $this->check4update($event,$old_event); |
|
| 280 | + $this->check4update($event, $old_event); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // notify the link-class about the update, as other apps may be subscribt to it |
| 285 | - Link::notify_update('calendar',$cal_id,$event); |
|
| 285 | + Link::notify_update('calendar', $cal_id, $event); |
|
| 286 | 286 | |
| 287 | 287 | return $cal_id; |
| 288 | 288 | } |
@@ -300,27 +300,27 @@ discard block |
||
| 300 | 300 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
| 301 | 301 | * @return array or events |
| 302 | 302 | */ |
| 303 | - function conflicts(array $event, &$checked_excluding=null) |
|
| 303 | + function conflicts(array $event, &$checked_excluding = null) |
|
| 304 | 304 | { |
| 305 | 305 | $types_with_quantity = array(); |
| 306 | - foreach($this->resources as $type => $data) |
|
| 306 | + foreach ($this->resources as $type => $data) |
|
| 307 | 307 | { |
| 308 | 308 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
| 309 | 309 | } |
| 310 | 310 | // get all NOT rejected participants and evtl. their quantity |
| 311 | 311 | $quantity = $users = array(); |
| 312 | - foreach($event['participants'] as $uid => $status) |
|
| 312 | + foreach ($event['participants'] as $uid => $status) |
|
| 313 | 313 | { |
| 314 | 314 | $q = $role = null; |
| 315 | 315 | calendar_so::split_status($status, $q, $role); |
| 316 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 316 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 317 | 317 | |
| 318 | 318 | if ($uid < 0) // group, check it's members too |
| 319 | 319 | { |
| 320 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
| 320 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
| 321 | 321 | } |
| 322 | 322 | $users[] = $uid; |
| 323 | - if (in_array($uid[0],$types_with_quantity)) |
|
| 323 | + if (in_array($uid[0], $types_with_quantity)) |
|
| 324 | 324 | { |
| 325 | 325 | $quantity[$uid] = $q; |
| 326 | 326 | } |
@@ -343,58 +343,58 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | $checked = 0; |
| 345 | 345 | $start = microtime(true); |
| 346 | - $duration = $event['end']-$event['start']; |
|
| 347 | - foreach($recurences as $date) |
|
| 346 | + $duration = $event['end'] - $event['start']; |
|
| 347 | + foreach ($recurences as $date) |
|
| 348 | 348 | { |
| 349 | 349 | $startts = $date->format('ts'); |
| 350 | 350 | |
| 351 | 351 | // skip past events or recurrences |
| 352 | - if ($startts+$duration < $this->now_su) continue; |
|
| 352 | + if ($startts + $duration < $this->now_su) continue; |
|
| 353 | 353 | |
| 354 | 354 | // abort check if configured limits are exceeded |
| 355 | 355 | if ($event['recur_type'] && |
| 356 | 356 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 357 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
| 357 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
| 358 | 358 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
| 359 | 359 | { |
| 360 | 360 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 361 | 361 | { |
| 362 | 362 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 363 | - $checked, microtime(true)-$start, $date); |
|
| 363 | + $checked, microtime(true) - $start, $date); |
|
| 364 | 364 | } |
| 365 | 365 | $checked_excluding = $date; |
| 366 | 366 | break; |
| 367 | 367 | } |
| 368 | - $overlapping_events =& $this->search(array( |
|
| 368 | + $overlapping_events = & $this->search(array( |
|
| 369 | 369 | 'start' => $startts, |
| 370 | - 'end' => $startts+$duration, |
|
| 370 | + 'end' => $startts + $duration, |
|
| 371 | 371 | 'users' => $users, |
| 372 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 373 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
| 372 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 373 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
| 374 | 374 | 'query' => array( |
| 375 | 375 | 'cal_non_blocking' => 0, |
| 376 | 376 | ), |
| 377 | - 'no_integration' => true, // do NOT use integration of other apps |
|
| 377 | + 'no_integration' => true, // do NOT use integration of other apps |
|
| 378 | 378 | )); |
| 379 | 379 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 380 | 380 | { |
| 381 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
| 381 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
| 382 | 382 | } |
| 383 | - foreach((array) $overlapping_events as $k => $overlap) |
|
| 383 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
| 384 | 384 | { |
| 385 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 386 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 385 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 386 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 387 | 387 | $overlap['non_blocking']) // that's a non_blocking event |
| 388 | 388 | { |
| 389 | 389 | continue; |
| 390 | 390 | } |
| 391 | 391 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 392 | 392 | { |
| 393 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
| 393 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
| 394 | 394 | } |
| 395 | 395 | // check if the overlap is with a rejected participant or within the allowed quantity |
| 396 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
| 397 | - foreach($common_parts as $n => $uid) |
|
| 396 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
| 397 | + foreach ($common_parts as $n => $uid) |
|
| 398 | 398 | { |
| 399 | 399 | $status = $overlap['participants'][$uid]; |
| 400 | 400 | calendar_so::split_status($status, $q, $role); |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | unset($common_parts[$n]); |
| 404 | 404 | continue; |
| 405 | 405 | } |
| 406 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
| 406 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
| 407 | 407 | { |
| 408 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 408 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 409 | 409 | } |
| 410 | 410 | if (!isset($max_quantity[$uid])) |
| 411 | 411 | { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $quantity[$uid] += $q; |
| 416 | 416 | if ($quantity[$uid] <= $max_quantity[$uid]) |
| 417 | 417 | { |
| 418 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
| 418 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
| 419 | 419 | unset($common_parts[$n]); |
| 420 | 420 | continue; |
| 421 | 421 | } |
@@ -425,22 +425,22 @@ discard block |
||
| 425 | 425 | { |
| 426 | 426 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 427 | 427 | { |
| 428 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
| 428 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
| 429 | 429 | } |
| 430 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
| 430 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
| 435 | 435 | // check if we are withing the allowed quantity and if not add all events using that resource |
| 436 | 436 | // seems this function is doing very strange things, it gives empty conflicts |
| 437 | - foreach($max_quantity as $uid => $max) |
|
| 437 | + foreach ($max_quantity as $uid => $max) |
|
| 438 | 438 | { |
| 439 | 439 | if ($quantity[$uid] > $max) |
| 440 | 440 | { |
| 441 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 441 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 442 | 442 | { |
| 443 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
| 443 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | if (count($conflicts)) |
| 450 | 450 | { |
| 451 | - foreach($conflicts as $key => $conflict) |
|
| 451 | + foreach ($conflicts as $key => $conflict) |
|
| 452 | 452 | { |
| 453 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 454 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
| 453 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 454 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
| 455 | 455 | { |
| 456 | 456 | $conflicts[$key] = array( |
| 457 | 457 | 'id' => $conflict['id'], |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | } |
| 465 | 465 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 466 | 466 | { |
| 467 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
| 467 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | return $conflicts; |
@@ -476,22 +476,22 @@ discard block |
||
| 476 | 476 | * @param array $old_event =null old event with already invited participants |
| 477 | 477 | * @return array removed participants because of missing invite grants |
| 478 | 478 | */ |
| 479 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
| 479 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
| 480 | 480 | { |
| 481 | 481 | if (!$this->require_acl_invite) |
| 482 | 482 | { |
| 483 | - return array(); // nothing to check, everyone can invite everyone else |
|
| 483 | + return array(); // nothing to check, everyone can invite everyone else |
|
| 484 | 484 | } |
| 485 | 485 | if ($event['id'] && is_null($old_event)) |
| 486 | 486 | { |
| 487 | 487 | $old_event = $this->read($event['id']); |
| 488 | 488 | } |
| 489 | 489 | $removed = array(); |
| 490 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
| 490 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
| 491 | 491 | { |
| 492 | 492 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
| 493 | 493 | { |
| 494 | - unset($event['participants'][$uid]); // remove participant |
|
| 494 | + unset($event['participants'][$uid]); // remove participant |
|
| 495 | 495 | $removed[] = $uid; |
| 496 | 496 | } |
| 497 | 497 | } |
@@ -507,19 +507,19 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | public function check_acl_invite($uid) |
| 509 | 509 | { |
| 510 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 510 | + if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 511 | 511 | |
| 512 | 512 | if (!$this->require_acl_invite) |
| 513 | 513 | { |
| 514 | - $ret = true; // no grant required |
|
| 514 | + $ret = true; // no grant required |
|
| 515 | 515 | } |
| 516 | 516 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
| 517 | 517 | { |
| 518 | - $ret = true; // grant only required for groups |
|
| 518 | + $ret = true; // grant only required for groups |
|
| 519 | 519 | } |
| 520 | 520 | else |
| 521 | 521 | { |
| 522 | - $ret = $this->check_perms(self::ACL_INVITE,0,$uid); |
|
| 522 | + $ret = $this->check_perms(self::ACL_INVITE, 0, $uid); |
|
| 523 | 523 | } |
| 524 | 524 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
| 525 | 525 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param array $old_event the event before the update |
| 534 | 534 | * @todo check if there is a real change, not assume every save is a change |
| 535 | 535 | */ |
| 536 | - function check4update($new_event,$old_event) |
|
| 536 | + function check4update($new_event, $old_event) |
|
| 537 | 537 | { |
| 538 | 538 | //error_log(__METHOD__."($new_event[title])"); |
| 539 | 539 | $modified = $added = $deleted = array(); |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
| 542 | 542 | |
| 543 | 543 | // Find modified and deleted participants ... |
| 544 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
| 544 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
| 545 | 545 | { |
| 546 | - if(isset($new_event['participants'][$old_userid])) |
|
| 546 | + if (isset($new_event['participants'][$old_userid])) |
|
| 547 | 547 | { |
| 548 | 548 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
| 549 | 549 | } |
@@ -553,27 +553,27 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | // Find new participants ... |
| 556 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
| 556 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
| 557 | 557 | { |
| 558 | - if(!isset($old_event['participants'][$new_userid])) |
|
| 558 | + if (!isset($old_event['participants'][$new_userid])) |
|
| 559 | 559 | { |
| 560 | 560 | $added[$new_userid] = 'U'; |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
| 564 | - if(count($added) || count($modified) || count($deleted)) |
|
| 564 | + if (count($added) || count($modified) || count($deleted)) |
|
| 565 | 565 | { |
| 566 | - if(count($added)) |
|
| 566 | + if (count($added)) |
|
| 567 | 567 | { |
| 568 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
| 568 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
| 569 | 569 | } |
| 570 | - if(count($modified)) |
|
| 570 | + if (count($modified)) |
|
| 571 | 571 | { |
| 572 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
| 572 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
| 573 | 573 | } |
| 574 | - if(count($deleted)) |
|
| 574 | + if (count($deleted)) |
|
| 575 | 575 | { |
| 576 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
| 576 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | } |
@@ -590,11 +590,11 @@ discard block |
||
| 590 | 590 | * @param string $status of current user |
| 591 | 591 | * @return boolean true = update requested, false otherwise |
| 592 | 592 | */ |
| 593 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
| 593 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
| 594 | 594 | { |
| 595 | 595 | if ($msg_type == MSG_ALARM) |
| 596 | 596 | { |
| 597 | - return True; // always True for now |
|
| 597 | + return True; // always True for now |
|
| 598 | 598 | } |
| 599 | 599 | $want_update = 0; |
| 600 | 600 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | // |
| 603 | 603 | $msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED; |
| 604 | 604 | |
| 605 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
| 605 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
| 606 | 606 | { |
| 607 | 607 | case 'responses': |
| 608 | 608 | ++$want_update; |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | default: |
| 617 | 617 | if (is_array($new_event) && is_array($old_event)) |
| 618 | 618 | { |
| 619 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
| 620 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
| 619 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
| 620 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
| 621 | 621 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
| 622 | 622 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
| 623 | 623 | { |
@@ -637,13 +637,13 @@ discard block |
||
| 637 | 637 | if (!is_numeric($userid) && $role == 'CHAIR' && |
| 638 | 638 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
| 639 | 639 | { |
| 640 | - switch($msg_type) |
|
| 640 | + switch ($msg_type) |
|
| 641 | 641 | { |
| 642 | 642 | case MSG_DELETED: // treat deleting event as rejection to organizer |
| 643 | 643 | $msg_type = MSG_REJECTED; |
| 644 | 644 | break; |
| 645 | 645 | case MSG_ADDED: // new events use added, but organizer needs status |
| 646 | - switch($status[0]) |
|
| 646 | + switch ($status[0]) |
|
| 647 | 647 | { |
| 648 | 648 | case 'A': $msg_type = MSG_ACCEPTED; break; |
| 649 | 649 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | * @param string $role ='REQ-PARTICIPANT' |
| 669 | 669 | * @return boolean true if user requested to be notified, false if not |
| 670 | 670 | */ |
| 671 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
| 671 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
| 672 | 672 | { |
| 673 | 673 | // check if email is from a user |
| 674 | 674 | if (is_numeric($user_or_email)) |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | ) |
| 693 | 693 | ); |
| 694 | 694 | } |
| 695 | - switch($ical_method) |
|
| 695 | + switch ($ical_method) |
|
| 696 | 696 | { |
| 697 | 697 | default: |
| 698 | 698 | case 'REQUEST': |
@@ -717,9 +717,9 @@ discard block |
||
| 717 | 717 | * @param string& $action=null on return verbose name |
| 718 | 718 | * @param string& $msg=null on return notification message |
| 719 | 719 | */ |
| 720 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
| 720 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
| 721 | 721 | { |
| 722 | - switch($msg_type) |
|
| 722 | + switch ($msg_type) |
|
| 723 | 723 | { |
| 724 | 724 | case MSG_DELETED: |
| 725 | 725 | $action = 'Canceled'; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | $msg = $this->cal_prefs['notify'.$pref]; |
| 772 | 772 | if (empty($msg)) |
| 773 | 773 | { |
| 774 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 774 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 775 | 775 | } |
| 776 | 776 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
| 777 | 777 | return $method; |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | * @param int $user =0 User who started the notify, default current user |
| 788 | 788 | * @return bool true/false |
| 789 | 789 | */ |
| 790 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
| 790 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
| 791 | 791 | { |
| 792 | 792 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
| 793 | 793 | if (!is_array($to_notify)) |
@@ -799,11 +799,11 @@ discard block |
||
| 799 | 799 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
| 800 | 800 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
| 801 | 801 | { |
| 802 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 802 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
| 806 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 806 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 807 | 807 | { |
| 808 | 808 | return False; |
| 809 | 809 | } |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | $restore_tz = $tz; |
| 814 | 814 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
| 815 | 815 | } |
| 816 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 816 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 817 | 817 | |
| 818 | 818 | if (!$user) |
| 819 | 819 | { |
@@ -829,16 +829,16 @@ discard block |
||
| 829 | 829 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
| 830 | 830 | |
| 831 | 831 | // add all group-members to the notification, unless they are already participants |
| 832 | - foreach($to_notify as $userid => $statusid) |
|
| 832 | + foreach ($to_notify as $userid => $statusid) |
|
| 833 | 833 | { |
| 834 | 834 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
| 835 | 835 | ($members = $GLOBALS['egw']->accounts->members($userid, true))) |
| 836 | 836 | { |
| 837 | - foreach($members as $member) |
|
| 837 | + foreach ($members as $member) |
|
| 838 | 838 | { |
| 839 | 839 | if (!isset($to_notify[$member])) |
| 840 | 840 | { |
| 841 | - $to_notify[$member] = 'G'; // Group-invitation |
|
| 841 | + $to_notify[$member] = 'G'; // Group-invitation |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
| 851 | 851 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 852 | 852 | $owner_prefs = $ics = null; |
| 853 | - foreach($to_notify as $userid => $statusid) |
|
| 853 | + foreach ($to_notify as $userid => $statusid) |
|
| 854 | 854 | { |
| 855 | 855 | $res_info = $quantity = $role = null; |
| 856 | 856 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -873,14 +873,14 @@ discard block |
||
| 873 | 873 | |
| 874 | 874 | if (!isset($userid)) |
| 875 | 875 | { |
| 876 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 876 | + if (empty($res_info['email'])) continue; // no way to notify |
|
| 877 | 877 | // check if event-owner wants non-EGroupware users notified |
| 878 | 878 | if (is_null($owner_prefs)) |
| 879 | 879 | { |
| 880 | 880 | $preferences = new Api\Preferences($owner); |
| 881 | 881 | $owner_prefs = $preferences->read_repository(); |
| 882 | 882 | } |
| 883 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 883 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 884 | 884 | (empty($owner_prefs['calendar']['notify_externals']) || |
| 885 | 885 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
| 886 | 886 | { |
@@ -892,12 +892,12 @@ discard block |
||
| 892 | 892 | |
| 893 | 893 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
| 894 | 894 | { |
| 895 | - continue; // dont notify rejected participants or groups |
|
| 895 | + continue; // dont notify rejected participants or groups |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 898 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 899 | 899 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
| 900 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
| 900 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
| 901 | 901 | $msg_type == MSG_ALARM) |
| 902 | 902 | { |
| 903 | 903 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -906,8 +906,8 @@ discard block |
||
| 906 | 906 | $preferences = new Api\Preferences($userid); |
| 907 | 907 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
| 908 | 908 | $fullname = Api\Accounts::username($userid); |
| 909 | - $tfn = Api\Accounts::id2name($userid,'account_firstname'); |
|
| 910 | - $tln = Api\Accounts::id2name($userid,'account_lastname'); |
|
| 909 | + $tfn = Api\Accounts::id2name($userid, 'account_firstname'); |
|
| 910 | + $tln = Api\Accounts::id2name($userid, 'account_lastname'); |
|
| 911 | 911 | } |
| 912 | 912 | else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
| 913 | 913 | { |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | } |
| 919 | 919 | $part_prefs = $owner_prefs; |
| 920 | 920 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
| 921 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 921 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 922 | 922 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
| 923 | 923 | } |
| 924 | 924 | $m_type = $msg_type; |
@@ -943,14 +943,14 @@ discard block |
||
| 943 | 943 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 944 | 944 | $action, $event_arr, $disinvited); |
| 945 | 945 | $details['to-fullname'] = $fullname; |
| 946 | - $details['to-firstname'] = isset($tfn)? $tfn: ''; |
|
| 947 | - $details['to-lastname'] = isset($tln)? $tln: ''; |
|
| 946 | + $details['to-firstname'] = isset($tfn) ? $tfn : ''; |
|
| 947 | + $details['to-lastname'] = isset($tln) ? $tln : ''; |
|
| 948 | 948 | |
| 949 | 949 | // 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 |
| 950 | 950 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
| 951 | 951 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 952 | 952 | $timeformat = $part_prefs['common']['timeformat']; |
| 953 | - switch($timeformat) |
|
| 953 | + switch ($timeformat) |
|
| 954 | 954 | { |
| 955 | 955 | case '24': |
| 956 | 956 | $timeformat = 'H:i'; |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | $timeformat = 'h:i a'; |
| 960 | 960 | break; |
| 961 | 961 | } |
| 962 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
| 962 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
| 963 | 963 | |
| 964 | 964 | $startdate->setTimezone($timezone); |
| 965 | 965 | $details['startdate'] = $startdate->format($timeformat); |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $details['enddate'] = $enddate->format($timeformat); |
| 969 | 969 | |
| 970 | 970 | $modified->setTimezone($timezone); |
| 971 | - $details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']); |
|
| 971 | + $details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']); |
|
| 972 | 972 | |
| 973 | 973 | if ($old_event != False) |
| 974 | 974 | { |
@@ -977,15 +977,14 @@ discard block |
||
| 977 | 977 | } |
| 978 | 978 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
| 979 | 979 | |
| 980 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 980 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 981 | 981 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
| 982 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 982 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 983 | 983 | { |
| 984 | - case 'ical': |
|
| 985 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 984 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 986 | 985 | { |
| 987 | 986 | $calendar_ical = new calendar_ical(); |
| 988 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 987 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 989 | 988 | // we need to pass $event[id] so iCal class reads event again, |
| 990 | 989 | // as event is in user TZ, but iCal class expects server TZ! |
| 991 | 990 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1004,11 +1003,11 @@ discard block |
||
| 1004 | 1003 | case 'extended': |
| 1005 | 1004 | |
| 1006 | 1005 | $details_body = lang('Event Details follow').":\n"; |
| 1007 | - foreach($event_arr as $key => $val) |
|
| 1006 | + foreach ($event_arr as $key => $val) |
|
| 1008 | 1007 | { |
| 1009 | - if(!empty($details[$key])) |
|
| 1008 | + if (!empty($details[$key])) |
|
| 1010 | 1009 | { |
| 1011 | - switch($key) |
|
| 1010 | + switch ($key) |
|
| 1012 | 1011 | { |
| 1013 | 1012 | case 'access': |
| 1014 | 1013 | case 'priority': |
@@ -1017,7 +1016,7 @@ discard block |
||
| 1017 | 1016 | case 'title': |
| 1018 | 1017 | break; |
| 1019 | 1018 | default: |
| 1020 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
| 1019 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
| 1021 | 1020 | break; |
| 1022 | 1021 | } |
| 1023 | 1022 | } |
@@ -1025,7 +1024,7 @@ discard block |
||
| 1025 | 1024 | break; |
| 1026 | 1025 | } |
| 1027 | 1026 | // send via notification_app |
| 1028 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1027 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1029 | 1028 | { |
| 1030 | 1029 | try { |
| 1031 | 1030 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1049,9 +1048,9 @@ discard block |
||
| 1049 | 1048 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 1050 | 1049 | $notification->set_popuplinks(array($details['link_arr'])); |
| 1051 | 1050 | |
| 1052 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1051 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1053 | 1052 | $notification->send(); |
| 1054 | - foreach(notifications::errors(true) as $error) |
|
| 1053 | + foreach (notifications::errors(true) as $error) |
|
| 1055 | 1054 | { |
| 1056 | 1055 | error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error"); |
| 1057 | 1056 | } |
@@ -1090,14 +1089,14 @@ discard block |
||
| 1090 | 1089 | return true; |
| 1091 | 1090 | } |
| 1092 | 1091 | |
| 1093 | - function get_update_message($event,$added) |
|
| 1092 | + function get_update_message($event, $added) |
|
| 1094 | 1093 | { |
| 1095 | 1094 | $nul = null; |
| 1096 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
| 1095 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
| 1097 | 1096 | |
| 1098 | 1097 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
| 1099 | 1098 | |
| 1100 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 1099 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | 1102 | /** |
@@ -1111,37 +1110,37 @@ discard block |
||
| 1111 | 1110 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
| 1112 | 1111 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
| 1113 | 1112 | |
| 1114 | - $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1115 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
| 1113 | + $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1114 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
| 1116 | 1115 | { |
| 1117 | - return False; // event not found |
|
| 1116 | + return False; // event not found |
|
| 1118 | 1117 | } |
| 1119 | 1118 | if ($alarm['all']) |
| 1120 | 1119 | { |
| 1121 | 1120 | $to_notify = $event['participants']; |
| 1122 | 1121 | } |
| 1123 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1122 | + elseif ($this->check_perms(Acl::READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1124 | 1123 | { |
| 1125 | 1124 | $to_notify[$alarm['owner']] = 'A'; |
| 1126 | 1125 | } |
| 1127 | 1126 | else |
| 1128 | 1127 | { |
| 1129 | - return False; // no rights |
|
| 1128 | + return False; // no rights |
|
| 1130 | 1129 | } |
| 1131 | 1130 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
| 1132 | 1131 | Api\Translation::add_app('calendar'); |
| 1133 | 1132 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
| 1134 | 1133 | |
| 1135 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
| 1134 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
| 1136 | 1135 | |
| 1137 | 1136 | // create a new alarm for recuring events for the next event, if one exists |
| 1138 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
| 1137 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
| 1139 | 1138 | { |
| 1140 | 1139 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
| 1141 | 1140 | unset($alarm['times']); |
| 1142 | 1141 | unset($alarm['next']); |
| 1143 | 1142 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
| 1144 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1143 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1145 | 1144 | } |
| 1146 | 1145 | return $ret; |
| 1147 | 1146 | } |
@@ -1157,14 +1156,14 @@ discard block |
||
| 1157 | 1156 | * Please note: you should ALLWAYS update timestamps, as they are required for sync! |
| 1158 | 1157 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
| 1159 | 1158 | */ |
| 1160 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
| 1159 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
| 1161 | 1160 | { |
| 1162 | 1161 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
| 1163 | 1162 | |
| 1164 | 1163 | // check if user has the permission to update / create the event |
| 1165 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 1166 | - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && |
|
| 1167 | - !$this->check_perms(Acl::ADD,0,$event['owner']))) |
|
| 1164 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 1165 | + !$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) && |
|
| 1166 | + !$this->check_perms(Acl::ADD, 0, $event['owner']))) |
|
| 1168 | 1167 | { |
| 1169 | 1168 | return false; |
| 1170 | 1169 | } |
@@ -1185,7 +1184,7 @@ discard block |
||
| 1185 | 1184 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
| 1186 | 1185 | { |
| 1187 | 1186 | $event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
| 1188 | - $event['recur_enddate']->setTime(23,59,59); |
|
| 1187 | + $event['recur_enddate']->setTime(23, 59, 59); |
|
| 1189 | 1188 | $rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName()); |
| 1190 | 1189 | $rrule->rewind(); |
| 1191 | 1190 | $enddate = $rrule->current(); |
@@ -1244,19 +1243,19 @@ discard block |
||
| 1244 | 1243 | |
| 1245 | 1244 | $event['recur_enddate'] = $save_event['recur_enddate'] = $time; |
| 1246 | 1245 | } |
| 1247 | - $timestamps = array('modified','created'); |
|
| 1246 | + $timestamps = array('modified', 'created'); |
|
| 1248 | 1247 | // all-day events are handled in server time |
| 1249 | 1248 | // $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName(); |
| 1250 | 1249 | } |
| 1251 | 1250 | else |
| 1252 | 1251 | { |
| 1253 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
| 1252 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
| 1254 | 1253 | } |
| 1255 | 1254 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
| 1256 | - foreach($timestamps as $ts) |
|
| 1255 | + foreach ($timestamps as $ts) |
|
| 1257 | 1256 | { |
| 1258 | 1257 | // we convert here from user-time to timestamps in server-time! |
| 1259 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1258 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
| 1260 | 1259 | } |
| 1261 | 1260 | // convert tzid name to integer tz_id, of set user default |
| 1262 | 1261 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1266,7 +1265,7 @@ discard block |
||
| 1266 | 1265 | // same with the recur exceptions |
| 1267 | 1266 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 1268 | 1267 | { |
| 1269 | - foreach($event['recur_exception'] as &$date) |
|
| 1268 | + foreach ($event['recur_exception'] as &$date) |
|
| 1270 | 1269 | { |
| 1271 | 1270 | if ($event['whole_day']) |
| 1272 | 1271 | { |
@@ -1275,7 +1274,7 @@ discard block |
||
| 1275 | 1274 | } |
| 1276 | 1275 | else |
| 1277 | 1276 | { |
| 1278 | - $date = $this->date2ts($date,true); |
|
| 1277 | + $date = $this->date2ts($date, true); |
|
| 1279 | 1278 | } |
| 1280 | 1279 | } |
| 1281 | 1280 | unset($date); |
@@ -1283,7 +1282,7 @@ discard block |
||
| 1283 | 1282 | // same with the alarms |
| 1284 | 1283 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
| 1285 | 1284 | { |
| 1286 | - foreach($event['alarm'] as $id => &$alarm) |
|
| 1285 | + foreach ($event['alarm'] as $id => &$alarm) |
|
| 1287 | 1286 | { |
| 1288 | 1287 | // remove alarms belonging to not longer existing or rejected participants |
| 1289 | 1288 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1301,15 +1300,14 @@ discard block |
||
| 1301 | 1300 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
| 1302 | 1301 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
| 1303 | 1302 | { |
| 1304 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
| 1303 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
| 1305 | 1304 | { |
| 1306 | 1305 | if (!isset($event['alarm'][$id])) |
| 1307 | 1306 | { |
| 1308 | 1307 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1309 | 1308 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
| 1310 | 1309 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1311 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
| 1312 | - $old_event['participants'][$alarm['owner']]; |
|
| 1310 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
| 1313 | 1311 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
| 1314 | 1312 | { |
| 1315 | 1313 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1338,7 +1336,7 @@ discard block |
||
| 1338 | 1336 | } |
| 1339 | 1337 | $set_recurrences = $old_event ? abs($event['recur_enddate'] - $old_event['recur_enddate']) > 1 : false; |
| 1340 | 1338 | $set_recurrences_start = 0; |
| 1341 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1339 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1342 | 1340 | { |
| 1343 | 1341 | $save_event['id'] = $cal_id; |
| 1344 | 1342 | // unset participants to enforce the default stati for all added recurrences |
@@ -1349,7 +1347,7 @@ discard block |
||
| 1349 | 1347 | // create links for new participants from addressbook, if configured |
| 1350 | 1348 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
| 1351 | 1349 | { |
| 1352 | - foreach($event['participants'] as $uid => $status) |
|
| 1350 | + foreach ($event['participants'] as $uid => $status) |
|
| 1353 | 1351 | { |
| 1354 | 1352 | $user_type = $user_id = null; |
| 1355 | 1353 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1362,7 +1360,7 @@ discard block |
||
| 1362 | 1360 | |
| 1363 | 1361 | // Update history |
| 1364 | 1362 | $tracking = new calendar_tracking($this); |
| 1365 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1363 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
| 1366 | 1364 | $tracking->track($event, $old_event); |
| 1367 | 1365 | |
| 1368 | 1366 | return $cal_id; |
@@ -1377,16 +1375,16 @@ discard block |
||
| 1377 | 1375 | * @param array|int $event event array or id of the event |
| 1378 | 1376 | * @return boolean |
| 1379 | 1377 | */ |
| 1380 | - function check_status_perms($uid,$event) |
|
| 1378 | + function check_status_perms($uid, $event) |
|
| 1381 | 1379 | { |
| 1382 | 1380 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
| 1383 | 1381 | { |
| 1384 | 1382 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1385 | 1383 | |
| 1386 | - return $this->check_perms(Acl::EDIT,0,$event['owner']); |
|
| 1384 | + return $this->check_perms(Acl::EDIT, 0, $event['owner']); |
|
| 1387 | 1385 | } |
| 1388 | 1386 | // check if we have a category Acl for the event or not (null) |
| 1389 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
| 1387 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
| 1390 | 1388 | if (!is_null($access)) |
| 1391 | 1389 | { |
| 1392 | 1390 | return $access; |
@@ -1396,17 +1394,17 @@ discard block |
||
| 1396 | 1394 | { |
| 1397 | 1395 | $resource = $this->resource_info($uid); |
| 1398 | 1396 | |
| 1399 | - return Acl::EDIT & $resource['rights']; |
|
| 1397 | + return Acl::EDIT&$resource['rights']; |
|
| 1400 | 1398 | } |
| 1401 | 1399 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1402 | 1400 | |
| 1403 | 1401 | // regular user and groups (need to check memberships too) |
| 1404 | 1402 | if (!isset($event['participants'][$uid])) |
| 1405 | 1403 | { |
| 1406 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
| 1404 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
| 1407 | 1405 | } |
| 1408 | 1406 | $memberships[] = $uid; |
| 1409 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid); |
|
| 1407 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid); |
|
| 1410 | 1408 | } |
| 1411 | 1409 | |
| 1412 | 1410 | /** |
@@ -1420,16 +1418,16 @@ discard block |
||
| 1420 | 1418 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1421 | 1419 | * null = cat has no acl |
| 1422 | 1420 | */ |
| 1423 | - function check_cat_acl($right,$event) |
|
| 1421 | + function check_cat_acl($right, $event) |
|
| 1424 | 1422 | { |
| 1425 | 1423 | if (!is_array($event)) $event = $this->read($event); |
| 1426 | 1424 | |
| 1427 | 1425 | $ret = null; |
| 1428 | 1426 | if ($event['category']) |
| 1429 | 1427 | { |
| 1430 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
| 1428 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
| 1431 | 1429 | { |
| 1432 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
| 1430 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
| 1433 | 1431 | if ($access === true) |
| 1434 | 1432 | { |
| 1435 | 1433 | $ret = true; |
@@ -1437,7 +1435,7 @@ discard block |
||
| 1437 | 1435 | } |
| 1438 | 1436 | if ($access === false) |
| 1439 | 1437 | { |
| 1440 | - $ret = false; // cat denies access --> check further cats |
|
| 1438 | + $ret = false; // cat denies access --> check further cats |
|
| 1441 | 1439 | } |
| 1442 | 1440 | } |
| 1443 | 1441 | } |
@@ -1458,12 +1456,12 @@ discard block |
||
| 1458 | 1456 | * @param int $cat_id =null null to return array with all cats |
| 1459 | 1457 | * @return array with account_id => right pairs |
| 1460 | 1458 | */ |
| 1461 | - public static function get_cat_rights($cat_id=null) |
|
| 1459 | + public static function get_cat_rights($cat_id = null) |
|
| 1462 | 1460 | { |
| 1463 | 1461 | if (!isset(self::$cat_rights_cache)) |
| 1464 | 1462 | { |
| 1465 | - self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights', |
|
| 1466 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
| 1463 | + self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights', |
|
| 1464 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
| 1467 | 1465 | } |
| 1468 | 1466 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
| 1469 | 1467 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1476,7 +1474,7 @@ discard block |
||
| 1476 | 1474 | * @param int $user |
| 1477 | 1475 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
| 1478 | 1476 | */ |
| 1479 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
| 1477 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
| 1480 | 1478 | { |
| 1481 | 1479 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1482 | 1480 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1486,15 +1484,15 @@ discard block |
||
| 1486 | 1484 | if ($rights) |
| 1487 | 1485 | { |
| 1488 | 1486 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
| 1489 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
| 1487 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
| 1490 | 1488 | } |
| 1491 | 1489 | else |
| 1492 | 1490 | { |
| 1493 | 1491 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1494 | 1492 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
| 1495 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
| 1493 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
| 1496 | 1494 | } |
| 1497 | - Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
| 1495 | + Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
| 1498 | 1496 | } |
| 1499 | 1497 | } |
| 1500 | 1498 | |
@@ -1505,9 +1503,9 @@ discard block |
||
| 1505 | 1503 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1506 | 1504 | * null = cat has no acl |
| 1507 | 1505 | */ |
| 1508 | - public static function has_cat_right($right,$cat_id,$user) |
|
| 1506 | + public static function has_cat_right($right, $cat_id, $user) |
|
| 1509 | 1507 | { |
| 1510 | - static $cache=null; |
|
| 1508 | + static $cache = null; |
|
| 1511 | 1509 | |
| 1512 | 1510 | if (!isset($cache[$cat_id])) |
| 1513 | 1511 | { |
@@ -1515,21 +1513,21 @@ discard block |
||
| 1515 | 1513 | $cat_rights = self::get_cat_rights($cat_id); |
| 1516 | 1514 | if (!is_null($cat_rights)) |
| 1517 | 1515 | { |
| 1518 | - static $memberships=null; |
|
| 1516 | + static $memberships = null; |
|
| 1519 | 1517 | if (is_null($memberships)) |
| 1520 | 1518 | { |
| 1521 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
| 1519 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 1522 | 1520 | $memberships[] = $user; |
| 1523 | 1521 | } |
| 1524 | - foreach($cat_rights as $uid => $value) |
|
| 1522 | + foreach ($cat_rights as $uid => $value) |
|
| 1525 | 1523 | { |
| 1526 | 1524 | $all |= $value; |
| 1527 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1525 | + if (in_array($uid, $memberships)) $own |= $value; |
|
| 1528 | 1526 | } |
| 1529 | 1527 | } |
| 1530 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
| 1528 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
| 1531 | 1529 | { |
| 1532 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
| 1530 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
| 1533 | 1531 | } |
| 1534 | 1532 | } |
| 1535 | 1533 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1549,13 +1547,13 @@ discard block |
||
| 1549 | 1547 | * @param boolean $skip_notification =false true: do not send notification messages |
| 1550 | 1548 | * @return int number of changed recurrences |
| 1551 | 1549 | */ |
| 1552 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
| 1550 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
| 1553 | 1551 | { |
| 1554 | 1552 | unset($updateTS); |
| 1555 | 1553 | |
| 1556 | 1554 | $cal_id = is_array($event) ? $event['id'] : $event; |
| 1557 | 1555 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
| 1558 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
| 1556 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
| 1559 | 1557 | { |
| 1560 | 1558 | return false; |
| 1561 | 1559 | } |
@@ -1564,16 +1562,16 @@ discard block |
||
| 1564 | 1562 | if ($this->log) |
| 1565 | 1563 | { |
| 1566 | 1564 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1567 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
| 1565 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
| 1568 | 1566 | } |
| 1569 | 1567 | $old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server'); |
| 1570 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
| 1571 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
| 1572 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
| 1568 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
| 1569 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
| 1570 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
| 1573 | 1571 | { |
| 1574 | 1572 | if ($status == 'R') // remove alarms belonging to rejected participants |
| 1575 | 1573 | { |
| 1576 | - foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1574 | + foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1577 | 1575 | { |
| 1578 | 1576 | if ((string)$alarm['owner'] === (string)$uid) |
| 1579 | 1577 | { |
@@ -1592,8 +1590,8 @@ discard block |
||
| 1592 | 1590 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1593 | 1591 | { |
| 1594 | 1592 | if (!is_array($event)) $event = $this->read($cal_id); |
| 1595 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1596 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
| 1593 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
| 1594 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
| 1597 | 1595 | } |
| 1598 | 1596 | |
| 1599 | 1597 | // Update history |
@@ -1613,14 +1611,14 @@ discard block |
||
| 1613 | 1611 | * @param int $recur_date =0 date to change, or 0 = all since now |
| 1614 | 1612 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
| 1615 | 1613 | */ |
| 1616 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
| 1614 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
| 1617 | 1615 | { |
| 1618 | 1616 | if (!isset($new_event['participants'])) return; |
| 1619 | 1617 | |
| 1620 | 1618 | // check the old list against the new list |
| 1621 | 1619 | foreach ($old_event['participants'] as $userid => $status) |
| 1622 | 1620 | { |
| 1623 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1621 | + if (!isset($new_event['participants'][$userid])) { |
|
| 1624 | 1622 | // Attendee will be deleted this way |
| 1625 | 1623 | $new_event['participants'][$userid] = 'G'; |
| 1626 | 1624 | } |
@@ -1633,7 +1631,7 @@ discard block |
||
| 1633 | 1631 | // write the changes |
| 1634 | 1632 | foreach ($new_event['participants'] as $userid => $status) |
| 1635 | 1633 | { |
| 1636 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
| 1634 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
| 1637 | 1635 | } |
| 1638 | 1636 | } |
| 1639 | 1637 | |
@@ -1648,43 +1646,43 @@ discard block |
||
| 1648 | 1646 | * @param int &$exceptions_kept=null on return number of kept exceptions |
| 1649 | 1647 | * @return boolean true on success, false on error (usually permission denied) |
| 1650 | 1648 | */ |
| 1651 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
| 1652 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
| 1649 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
| 1650 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
| 1653 | 1651 | { |
| 1654 | 1652 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
| 1655 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
| 1656 | - !$ignore_acl && !$this->check_perms(Acl::DELETE,$event)) |
|
| 1653 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
| 1654 | + !$ignore_acl && !$this->check_perms(Acl::DELETE, $event)) |
|
| 1657 | 1655 | { |
| 1658 | 1656 | return false; |
| 1659 | 1657 | } |
| 1660 | 1658 | |
| 1661 | 1659 | // Don't send notification if the event has already been deleted |
| 1662 | - if(!$event['deleted'] && !$skip_notification) |
|
| 1660 | + if (!$event['deleted'] && !$skip_notification) |
|
| 1663 | 1661 | { |
| 1664 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
| 1662 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
| 1665 | 1663 | } |
| 1666 | 1664 | |
| 1667 | 1665 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
| 1668 | 1666 | { |
| 1669 | 1667 | $config = Api\Config::read('phpgwapi'); |
| 1670 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1668 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1671 | 1669 | { |
| 1672 | 1670 | $this->so->delete($cal_id); |
| 1673 | 1671 | |
| 1674 | 1672 | // delete all links to the event |
| 1675 | - Link::unlink(0,'calendar',$cal_id); |
|
| 1673 | + Link::unlink(0, 'calendar', $cal_id); |
|
| 1676 | 1674 | } |
| 1677 | 1675 | elseif ($config['calendar_delete_history']) |
| 1678 | 1676 | { |
| 1679 | 1677 | // mark all links to the event as deleted, but keep them |
| 1680 | - Link::unlink(0,'calendar',$cal_id,'','','',true); |
|
| 1678 | + Link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
| 1681 | 1679 | |
| 1682 | 1680 | $event['deleted'] = $this->now; |
| 1683 | 1681 | $this->save($event, $ignore_acl); |
| 1684 | 1682 | // Actually delete alarms |
| 1685 | 1683 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1686 | 1684 | { |
| 1687 | - foreach($event['alarm'] as $id => $alarm) |
|
| 1685 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 1688 | 1686 | { |
| 1689 | 1687 | $this->delete_alarm($id); |
| 1690 | 1688 | } |
@@ -1706,7 +1704,7 @@ discard block |
||
| 1706 | 1704 | if (!($exception = $this->read($id))) continue; |
| 1707 | 1705 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1708 | 1706 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1709 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
| 1707 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
| 1710 | 1708 | ++$exceptions_kept; |
| 1711 | 1709 | } |
| 1712 | 1710 | } |
@@ -1718,9 +1716,9 @@ discard block |
||
| 1718 | 1716 | if ($event['alarm']) |
| 1719 | 1717 | { |
| 1720 | 1718 | $next_recurrance = null; |
| 1721 | - foreach($event['alarm'] as &$alarm) |
|
| 1719 | + foreach ($event['alarm'] as &$alarm) |
|
| 1722 | 1720 | { |
| 1723 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
| 1721 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
| 1724 | 1722 | { |
| 1725 | 1723 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
| 1726 | 1724 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1728,12 +1726,12 @@ discard block |
||
| 1728 | 1726 | { |
| 1729 | 1727 | $checkdate = $recur_date; |
| 1730 | 1728 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
| 1731 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
| 1729 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
| 1732 | 1730 | { |
| 1733 | 1731 | $next_recurrance = $this->date2ts($e['start']); |
| 1734 | 1732 | } |
| 1735 | 1733 | } |
| 1736 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1734 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1737 | 1735 | $alarm['cal_id'] = $cal_id; |
| 1738 | 1736 | unset($alarm['times']); |
| 1739 | 1737 | unset($alarm['next']); |
@@ -1747,7 +1745,7 @@ discard block |
||
| 1747 | 1745 | $event = $this->read($cal_id); |
| 1748 | 1746 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
| 1749 | 1747 | $event['recur_exception'][] = $recur_date; |
| 1750 | - $this->save($event);// updates the content-history |
|
| 1748 | + $this->save($event); // updates the content-history |
|
| 1751 | 1749 | } |
| 1752 | 1750 | if ($event['reference']) |
| 1753 | 1751 | { |
@@ -1765,19 +1763,19 @@ discard block |
||
| 1765 | 1763 | * @param array $disinvited |
| 1766 | 1764 | * @return array |
| 1767 | 1765 | */ |
| 1768 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
| 1766 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
| 1769 | 1767 | { |
| 1770 | 1768 | $details = array( // event-details for the notify-msg |
| 1771 | 1769 | 'id' => $event['id'], |
| 1772 | 1770 | 'action' => lang($action), |
| 1773 | 1771 | ); |
| 1774 | 1772 | $event_arr = $this->event2array($event); |
| 1775 | - foreach($event_arr as $key => $val) |
|
| 1773 | + foreach ($event_arr as $key => $val) |
|
| 1776 | 1774 | { |
| 1777 | 1775 | if ($key == 'recur_type') $key = 'repetition'; |
| 1778 | 1776 | $details[$key] = $val['data']; |
| 1779 | 1777 | } |
| 1780 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
| 1778 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
| 1781 | 1779 | |
| 1782 | 1780 | $event_arr['link']['field'] = lang('URL'); |
| 1783 | 1781 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1798,7 +1796,7 @@ discard block |
||
| 1798 | 1796 | */ |
| 1799 | 1797 | $link_arr = array(); |
| 1800 | 1798 | $link_arr['text'] = $event['title']; |
| 1801 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1799 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1802 | 1800 | 'cal_id' => $event['id'], |
| 1803 | 1801 | 'date' => $eventStart_arr['full'], |
| 1804 | 1802 | 'ajax' => true |
@@ -1807,11 +1805,11 @@ discard block |
||
| 1807 | 1805 | $details['link_arr'] = $link_arr; |
| 1808 | 1806 | |
| 1809 | 1807 | $dis = array(); |
| 1810 | - foreach($disinvited as $uid) |
|
| 1808 | + foreach ($disinvited as $uid) |
|
| 1811 | 1809 | { |
| 1812 | 1810 | $dis[] = $this->participant_name($uid); |
| 1813 | 1811 | } |
| 1814 | - $details['disinvited'] = implode(', ',$dis); |
|
| 1812 | + $details['disinvited'] = implode(', ', $dis); |
|
| 1815 | 1813 | return $details; |
| 1816 | 1814 | } |
| 1817 | 1815 | |
@@ -1835,13 +1833,13 @@ discard block |
||
| 1835 | 1833 | 'data' => $event['description'] |
| 1836 | 1834 | ); |
| 1837 | 1835 | |
| 1838 | - foreach(explode(',',$event['category']) as $cat_id) |
|
| 1836 | + foreach (explode(',', $event['category']) as $cat_id) |
|
| 1839 | 1837 | { |
| 1840 | 1838 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1841 | 1839 | } |
| 1842 | 1840 | $var['category'] = Array( |
| 1843 | 1841 | 'field' => lang('Category'), |
| 1844 | - 'data' => implode(', ',$cat_string) |
|
| 1842 | + 'data' => implode(', ', $cat_string) |
|
| 1845 | 1843 | ); |
| 1846 | 1844 | |
| 1847 | 1845 | $var['location'] = Array( |
@@ -1887,7 +1885,7 @@ discard block |
||
| 1887 | 1885 | |
| 1888 | 1886 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
| 1889 | 1887 | { |
| 1890 | - $participants = $this->participants($event,true); |
|
| 1888 | + $participants = $this->participants($event, true); |
|
| 1891 | 1889 | } |
| 1892 | 1890 | $var['participants'] = Array( |
| 1893 | 1891 | 'field' => lang('Participants'), |
@@ -1910,26 +1908,26 @@ discard block |
||
| 1910 | 1908 | * @param array $old_event =null event-data in the DB before calling save |
| 1911 | 1909 | * @param string $type ='update' |
| 1912 | 1910 | */ |
| 1913 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
| 1911 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
| 1914 | 1912 | { |
| 1915 | - if (!($f = fopen($this->log_file,'a'))) |
|
| 1913 | + if (!($f = fopen($this->log_file, 'a'))) |
|
| 1916 | 1914 | { |
| 1917 | 1915 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
| 1918 | 1916 | return false; |
| 1919 | 1917 | } |
| 1920 | - fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1921 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
| 1922 | - foreach(array('start','end') as $name) |
|
| 1918 | + fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1919 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
| 1920 | + foreach (array('start', 'end') as $name) |
|
| 1923 | 1921 | { |
| 1924 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1925 | - $this->format_date($event_saved[$name]) .' / '. |
|
| 1922 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1923 | + $this->format_date($event_saved[$name]).' / '. |
|
| 1926 | 1924 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
| 1927 | 1925 | } |
| 1928 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
| 1926 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
| 1929 | 1927 | { |
| 1930 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
| 1928 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
| 1931 | 1929 | } |
| 1932 | - fwrite($f,"\n"); |
|
| 1930 | + fwrite($f, "\n"); |
|
| 1933 | 1931 | fclose($f); |
| 1934 | 1932 | |
| 1935 | 1933 | return true; |
@@ -1950,14 +1948,14 @@ discard block |
||
| 1950 | 1948 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 1951 | 1949 | |
| 1952 | 1950 | $time = new Api\DateTime($event['start']); |
| 1953 | - if(!is_array($event['alarm'])) |
|
| 1951 | + if (!is_array($event['alarm'])) |
|
| 1954 | 1952 | { |
| 1955 | 1953 | $event['alarm'] = $this->so->read_alarms($event['id']); |
| 1956 | 1954 | } |
| 1957 | 1955 | |
| 1958 | - foreach($event['alarm'] as &$alarm) |
|
| 1956 | + foreach ($event['alarm'] as &$alarm) |
|
| 1959 | 1957 | { |
| 1960 | - if($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1958 | + if ($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1961 | 1959 | { |
| 1962 | 1960 | calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts')); |
| 1963 | 1961 | } |
@@ -1977,14 +1975,14 @@ discard block |
||
| 1977 | 1975 | * @param boolean $update_modified =true call update modified, default true |
| 1978 | 1976 | * @return string id of the alarm, or false on error (eg. no perms) |
| 1979 | 1977 | */ |
| 1980 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 1978 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 1981 | 1979 | { |
| 1982 | - if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1980 | + if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1983 | 1981 | { |
| 1984 | 1982 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
| 1985 | - return false; // no rights to add the alarm |
|
| 1983 | + return false; // no rights to add the alarm |
|
| 1986 | 1984 | } |
| 1987 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
| 1985 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
| 1988 | 1986 | |
| 1989 | 1987 | return $this->so->save_alarm($cal_id, $alarm, $update_modified); |
| 1990 | 1988 | } |
@@ -1997,11 +1995,11 @@ discard block |
||
| 1997 | 1995 | */ |
| 1998 | 1996 | function delete_alarm($id) |
| 1999 | 1997 | { |
| 2000 | - list(,$cal_id) = explode(':',$id); |
|
| 1998 | + list(,$cal_id) = explode(':', $id); |
|
| 2001 | 1999 | |
| 2002 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2000 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2003 | 2001 | { |
| 2004 | - return false; // no rights to delete the alarm |
|
| 2002 | + return false; // no rights to delete the alarm |
|
| 2005 | 2003 | } |
| 2006 | 2004 | |
| 2007 | 2005 | return $this->so->delete_alarm($id); |
@@ -2016,13 +2014,13 @@ discard block |
||
| 2016 | 2014 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
| 2017 | 2015 | * @return array category ids (found, added and preserved categories) |
| 2018 | 2016 | */ |
| 2019 | - function find_or_add_categories($catname_list, $old_event=null) |
|
| 2017 | + function find_or_add_categories($catname_list, $old_event = null) |
|
| 2020 | 2018 | { |
| 2021 | 2019 | if (is_array($old_event) || $old_event > 0) |
| 2022 | 2020 | { |
| 2023 | 2021 | // preserve categories without users read access |
| 2024 | 2022 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
| 2025 | - $old_categories = explode(',',$old_event['category']); |
|
| 2023 | + $old_categories = explode(',', $old_event['category']); |
|
| 2026 | 2024 | $old_cats_preserve = array(); |
| 2027 | 2025 | if (is_array($old_categories) && count($old_categories) > 0) |
| 2028 | 2026 | { |
@@ -2076,7 +2074,7 @@ discard block |
||
| 2076 | 2074 | { |
| 2077 | 2075 | if (!is_array($cat_id_list)) |
| 2078 | 2076 | { |
| 2079 | - $cat_id_list = explode(',',$cat_id_list); |
|
| 2077 | + $cat_id_list = explode(',', $cat_id_list); |
|
| 2080 | 2078 | } |
| 2081 | 2079 | $cat_list = array(); |
| 2082 | 2080 | foreach ($cat_id_list as $cat_id) |
@@ -2101,7 +2099,7 @@ discard block |
||
| 2101 | 2099 | * master -> try to find a releated series master |
| 2102 | 2100 | * @return array calendar_ids of matching entries |
| 2103 | 2101 | */ |
| 2104 | - function find_event($event, $filter='exact') |
|
| 2102 | + function find_event($event, $filter = 'exact') |
|
| 2105 | 2103 | { |
| 2106 | 2104 | $matchingEvents = array(); |
| 2107 | 2105 | $query = array(); |
@@ -2109,14 +2107,14 @@ discard block |
||
| 2109 | 2107 | if ($this->log) |
| 2110 | 2108 | { |
| 2111 | 2109 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2112 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
| 2110 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
| 2113 | 2111 | } |
| 2114 | 2112 | |
| 2115 | 2113 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
| 2116 | 2114 | |
| 2117 | 2115 | if ($filter == 'master') |
| 2118 | 2116 | { |
| 2119 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
| 2117 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
| 2120 | 2118 | $query['cal_recurrence'] = 0; |
| 2121 | 2119 | } |
| 2122 | 2120 | elseif ($filter == 'exact') |
@@ -2137,14 +2135,14 @@ discard block |
||
| 2137 | 2135 | if ($this->log) |
| 2138 | 2136 | { |
| 2139 | 2137 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2140 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
| 2138 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
| 2141 | 2139 | } |
| 2142 | 2140 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
| 2143 | 2141 | { |
| 2144 | 2142 | if ($this->log) |
| 2145 | 2143 | { |
| 2146 | 2144 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2147 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2145 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2148 | 2146 | } |
| 2149 | 2147 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
| 2150 | 2148 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2163,7 +2161,7 @@ discard block |
||
| 2163 | 2161 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
| 2164 | 2162 | if (in_array($event['recurrence'], $exceptions)) |
| 2165 | 2163 | { |
| 2166 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
| 2164 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
| 2167 | 2165 | } |
| 2168 | 2166 | } |
| 2169 | 2167 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2182,19 +2180,19 @@ discard block |
||
| 2182 | 2180 | |
| 2183 | 2181 | // only query calendars of users, we have READ-grants from |
| 2184 | 2182 | $users = array(); |
| 2185 | - foreach(array_keys($this->grants) as $user) |
|
| 2183 | + foreach (array_keys($this->grants) as $user) |
|
| 2186 | 2184 | { |
| 2187 | 2185 | $user = trim($user); |
| 2188 | - if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
|
| 2186 | + if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user)) |
|
| 2189 | 2187 | { |
| 2190 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2188 | + if ($user && !in_array($user, $users)) // already added? |
|
| 2191 | 2189 | { |
| 2192 | 2190 | $users[] = $user; |
| 2193 | 2191 | } |
| 2194 | 2192 | } |
| 2195 | 2193 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2196 | 2194 | { |
| 2197 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2195 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2198 | 2196 | } |
| 2199 | 2197 | // the further code is only for real users |
| 2200 | 2198 | if (!is_numeric($user)) continue; |
@@ -2205,7 +2203,7 @@ discard block |
||
| 2205 | 2203 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 2206 | 2204 | if (is_array($members)) |
| 2207 | 2205 | { |
| 2208 | - foreach($members as $member) |
|
| 2206 | + foreach ($members as $member) |
|
| 2209 | 2207 | { |
| 2210 | 2208 | // use only members which gave the user a read-grant |
| 2211 | 2209 | if (!in_array($member, $users) && |
@@ -2221,7 +2219,7 @@ discard block |
||
| 2221 | 2219 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 2222 | 2220 | if (is_array($memberships)) |
| 2223 | 2221 | { |
| 2224 | - foreach($memberships as $group) |
|
| 2222 | + foreach ($memberships as $group) |
|
| 2225 | 2223 | { |
| 2226 | 2224 | if (!in_array($group, $users)) |
| 2227 | 2225 | { |
@@ -2247,24 +2245,24 @@ discard block |
||
| 2247 | 2245 | |
| 2248 | 2246 | // check length with some tolerance |
| 2249 | 2247 | $length = $event['end'] - $event['start'] - $delta; |
| 2250 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
| 2248 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
| 2251 | 2249 | $length += 2 * $delta; |
| 2252 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
| 2253 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
| 2254 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
| 2250 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
| 2251 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
| 2252 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
| 2255 | 2253 | } |
| 2256 | 2254 | elseif (isset($event['start'])) |
| 2257 | 2255 | { |
| 2258 | 2256 | if ($filter == 'relax') |
| 2259 | 2257 | { |
| 2260 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
| 2261 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
| 2258 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
| 2259 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
| 2262 | 2260 | } |
| 2263 | 2261 | else |
| 2264 | 2262 | { |
| 2265 | 2263 | // we accept a tiny tolerance |
| 2266 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
| 2267 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
| 2264 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
| 2265 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
| 2268 | 2266 | } |
| 2269 | 2267 | } |
| 2270 | 2268 | if ($filter == 'relax') |
@@ -2287,14 +2285,14 @@ discard block |
||
| 2287 | 2285 | if ($this->log) |
| 2288 | 2286 | { |
| 2289 | 2287 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2290 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
| 2288 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
| 2291 | 2289 | } |
| 2292 | 2290 | } |
| 2293 | 2291 | |
| 2294 | 2292 | if ($this->log) |
| 2295 | 2293 | { |
| 2296 | 2294 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2297 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
| 2295 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
| 2298 | 2296 | } |
| 2299 | 2297 | if (!count($users) || !($foundEvents = |
| 2300 | 2298 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2302,19 +2300,19 @@ discard block |
||
| 2302 | 2300 | if ($this->log) |
| 2303 | 2301 | { |
| 2304 | 2302 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2305 | - "[NO MATCH]\n",3,$this->logfile); |
|
| 2303 | + "[NO MATCH]\n", 3, $this->logfile); |
|
| 2306 | 2304 | } |
| 2307 | 2305 | return $matchingEvents; |
| 2308 | 2306 | } |
| 2309 | 2307 | |
| 2310 | 2308 | $pseudos = array(); |
| 2311 | 2309 | |
| 2312 | - foreach($foundEvents as $egwEvent) |
|
| 2310 | + foreach ($foundEvents as $egwEvent) |
|
| 2313 | 2311 | { |
| 2314 | 2312 | if ($this->log) |
| 2315 | 2313 | { |
| 2316 | 2314 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2317 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2315 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2318 | 2316 | } |
| 2319 | 2317 | |
| 2320 | 2318 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2388,7 +2386,7 @@ discard block |
||
| 2388 | 2386 | if (in_array($event['recurrence'], $exceptions)) |
| 2389 | 2387 | { |
| 2390 | 2388 | // We found a pseudo exception |
| 2391 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
| 2389 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
| 2392 | 2390 | break; |
| 2393 | 2391 | } |
| 2394 | 2392 | } |
@@ -2406,7 +2404,7 @@ discard block |
||
| 2406 | 2404 | if ($this->log) |
| 2407 | 2405 | { |
| 2408 | 2406 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2409 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
| 2407 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
| 2410 | 2408 | } |
| 2411 | 2409 | continue; |
| 2412 | 2410 | } |
@@ -2418,7 +2416,7 @@ discard block |
||
| 2418 | 2416 | if ($this->log) |
| 2419 | 2417 | { |
| 2420 | 2418 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2421 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
| 2419 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
| 2422 | 2420 | } |
| 2423 | 2421 | continue; |
| 2424 | 2422 | } |
@@ -2439,8 +2437,8 @@ discard block |
||
| 2439 | 2437 | if ($this->log) |
| 2440 | 2438 | { |
| 2441 | 2439 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2442 | - "() event[$key] differ: '" . $event[$key] . |
|
| 2443 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
| 2440 | + "() event[$key] differ: '".$event[$key]. |
|
| 2441 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
| 2444 | 2442 | } |
| 2445 | 2443 | continue 2; // next foundEvent |
| 2446 | 2444 | } |
@@ -2458,7 +2456,7 @@ discard block |
||
| 2458 | 2456 | if ($this->log) |
| 2459 | 2457 | { |
| 2460 | 2458 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2461 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
| 2459 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
| 2462 | 2460 | } |
| 2463 | 2461 | continue 2; |
| 2464 | 2462 | } |
@@ -2470,7 +2468,7 @@ discard block |
||
| 2470 | 2468 | { |
| 2471 | 2469 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2472 | 2470 | '() event has additional categories:' |
| 2473 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
| 2471 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
| 2474 | 2472 | } |
| 2475 | 2473 | continue; |
| 2476 | 2474 | } |
@@ -2490,7 +2488,7 @@ discard block |
||
| 2490 | 2488 | if ($this->log) |
| 2491 | 2489 | { |
| 2492 | 2490 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2493 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
| 2491 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
| 2494 | 2492 | } |
| 2495 | 2493 | continue 2; |
| 2496 | 2494 | } |
@@ -2513,8 +2511,8 @@ discard block |
||
| 2513 | 2511 | if ($this->log) |
| 2514 | 2512 | { |
| 2515 | 2513 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2516 | - '() missing event[participants]: ' . |
|
| 2517 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
| 2514 | + '() missing event[participants]: '. |
|
| 2515 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
| 2518 | 2516 | } |
| 2519 | 2517 | continue; |
| 2520 | 2518 | } |
@@ -2526,7 +2524,7 @@ discard block |
||
| 2526 | 2524 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
| 2527 | 2525 | { |
| 2528 | 2526 | // We found a pseudo Exception |
| 2529 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
| 2527 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
| 2530 | 2528 | continue; |
| 2531 | 2529 | } |
| 2532 | 2530 | } |
@@ -2548,7 +2546,7 @@ discard block |
||
| 2548 | 2546 | if ($this->log) |
| 2549 | 2547 | { |
| 2550 | 2548 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2551 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
| 2549 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
| 2552 | 2550 | } |
| 2553 | 2551 | continue 2; |
| 2554 | 2552 | } |
@@ -2558,8 +2556,8 @@ discard block |
||
| 2558 | 2556 | if ($this->log) |
| 2559 | 2557 | { |
| 2560 | 2558 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2561 | - '() missing event[recur_exception]: ' . |
|
| 2562 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
| 2559 | + '() missing event[recur_exception]: '. |
|
| 2560 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
| 2563 | 2561 | } |
| 2564 | 2562 | continue; |
| 2565 | 2563 | } |
@@ -2574,8 +2572,8 @@ discard block |
||
| 2574 | 2572 | if ($this->log) |
| 2575 | 2573 | { |
| 2576 | 2574 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2577 | - "() events[$key] differ: " . $event[$key] . |
|
| 2578 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
| 2575 | + "() events[$key] differ: ".$event[$key]. |
|
| 2576 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
| 2579 | 2577 | } |
| 2580 | 2578 | continue 2; |
| 2581 | 2579 | } |
@@ -2591,7 +2589,7 @@ discard block |
||
| 2591 | 2589 | if ($this->log) |
| 2592 | 2590 | { |
| 2593 | 2591 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2594 | - "() new exception for series found.\n",3,$this->logfile); |
|
| 2592 | + "() new exception for series found.\n", 3, $this->logfile); |
|
| 2595 | 2593 | } |
| 2596 | 2594 | $matchingEvents = array(); |
| 2597 | 2595 | } |
@@ -2602,7 +2600,7 @@ discard block |
||
| 2602 | 2600 | if ($this->log) |
| 2603 | 2601 | { |
| 2604 | 2602 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2605 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
| 2603 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
| 2606 | 2604 | } |
| 2607 | 2605 | return $matches; |
| 2608 | 2606 | } |
@@ -2675,7 +2673,7 @@ discard block |
||
| 2675 | 2673 | if ($this->log) |
| 2676 | 2674 | { |
| 2677 | 2675 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2678 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
| 2676 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
| 2679 | 2677 | } |
| 2680 | 2678 | $type = 'SERIES-EXCEPTION'; |
| 2681 | 2679 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2696,7 +2694,7 @@ discard block |
||
| 2696 | 2694 | } |
| 2697 | 2695 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
| 2698 | 2696 | { |
| 2699 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2697 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2700 | 2698 | $recurrence_event = $master_event; |
| 2701 | 2699 | $recurrence_event['start'] = $event['start']; |
| 2702 | 2700 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2713,8 +2711,8 @@ discard block |
||
| 2713 | 2711 | if ($this->log) |
| 2714 | 2712 | { |
| 2715 | 2713 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2716 | - '() try occurrence ' . $egw_rrule->current() |
|
| 2717 | - . " ($occurrence)\n",3,$this->logfile); |
|
| 2714 | + '() try occurrence '.$egw_rrule->current() |
|
| 2715 | + . " ($occurrence)\n", 3, $this->logfile); |
|
| 2718 | 2716 | } |
| 2719 | 2717 | if ($event['start'] == $occurrence) |
| 2720 | 2718 | { |
@@ -2747,8 +2745,8 @@ discard block |
||
| 2747 | 2745 | // default if we cannot find a proof for a fundamental change |
| 2748 | 2746 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
| 2749 | 2747 | // check for changed data |
| 2750 | - foreach (array('start','end','uid','title','location','description', |
|
| 2751 | - 'priority','public','special','non_blocking') as $key) |
|
| 2748 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
| 2749 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
| 2752 | 2750 | { |
| 2753 | 2751 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
| 2754 | 2752 | { |
@@ -2806,10 +2804,10 @@ discard block |
||
| 2806 | 2804 | * @param &$event the event we are working on |
| 2807 | 2805 | * |
| 2808 | 2806 | */ |
| 2809 | - function server2usertime (&$event) |
|
| 2807 | + function server2usertime(&$event) |
|
| 2810 | 2808 | { |
| 2811 | 2809 | // we run all dates through date2usertime, to adjust to user-time |
| 2812 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
| 2810 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
| 2813 | 2811 | { |
| 2814 | 2812 | // we convert here from server-time to timestamps in user-time! |
| 2815 | 2813 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2817,7 +2815,7 @@ discard block |
||
| 2817 | 2815 | // same with the recur exceptions |
| 2818 | 2816 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 2819 | 2817 | { |
| 2820 | - foreach($event['recur_exception'] as $n => $date) |
|
| 2818 | + foreach ($event['recur_exception'] as $n => $date) |
|
| 2821 | 2819 | { |
| 2822 | 2820 | $event['recur_exception'][$n] = $this->date2usertime($date); |
| 2823 | 2821 | } |
@@ -2825,7 +2823,7 @@ discard block |
||
| 2825 | 2823 | // same with the alarms |
| 2826 | 2824 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 2827 | 2825 | { |
| 2828 | - foreach($event['alarm'] as $id => $alarm) |
|
| 2826 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 2829 | 2827 | { |
| 2830 | 2828 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2831 | 2829 | } |
@@ -2842,7 +2840,7 @@ discard block |
||
| 2842 | 2840 | { |
| 2843 | 2841 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
| 2844 | 2842 | { |
| 2845 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
| 2843 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
| 2846 | 2844 | } |
| 2847 | 2845 | } |
| 2848 | 2846 | } |