@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var locktime in seconds |
56 | 56 | */ |
57 | - var $locktime_default=1; |
|
57 | + var $locktime_default = 1; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Constructor |
61 | 61 | */ |
62 | 62 | function __construct() |
63 | 63 | { |
64 | - parent::__construct(true); // call the parent's constructor |
|
64 | + parent::__construct(true); // call the parent's constructor |
|
65 | 65 | |
66 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
66 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
67 | 67 | { |
68 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
68 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -77,11 +77,10 @@ discard block |
||
77 | 77 | function &default_add_event() |
78 | 78 | { |
79 | 79 | $extra_participants = $_GET['participants'] ? |
80 | - (!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) : |
|
81 | - array(); |
|
80 | + (!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array(); |
|
82 | 81 | |
83 | 82 | // if participant is a contact, add its link title as title |
84 | - foreach($extra_participants as $uid) |
|
83 | + foreach ($extra_participants as $uid) |
|
85 | 84 | { |
86 | 85 | if ($uid[0] == 'c') |
87 | 86 | { |
@@ -93,14 +92,14 @@ discard block |
||
93 | 92 | if (isset($_GET['owner'])) |
94 | 93 | { |
95 | 94 | $owner = $_GET['owner']; |
96 | - if(!is_array($owner) && strpos($owner, ',')) |
|
95 | + if (!is_array($owner) && strpos($owner, ',')) |
|
97 | 96 | { |
98 | - $owner = explode(',',$owner); |
|
97 | + $owner = explode(',', $owner); |
|
99 | 98 | } |
100 | - if(is_array($owner)) |
|
99 | + if (is_array($owner)) |
|
101 | 100 | { |
102 | 101 | // old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0' |
103 | - if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
102 | + if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
104 | 103 | { |
105 | 104 | $extra_participants += $owner; |
106 | 105 | } |
@@ -118,18 +117,18 @@ discard block |
||
118 | 117 | } |
119 | 118 | |
120 | 119 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
121 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
120 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
122 | 121 | { |
123 | 122 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
124 | 123 | { |
125 | - if(!is_array($owner)) |
|
124 | + if (!is_array($owner)) |
|
126 | 125 | { |
127 | - $owner = explode(',',$owner); |
|
126 | + $owner = explode(',', $owner); |
|
128 | 127 | } |
129 | 128 | // if we come from ressources we don't need any users selected in calendar |
130 | 129 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
131 | 130 | { |
132 | - foreach($owner as $uid) |
|
131 | + foreach ($owner as $uid) |
|
133 | 132 | { |
134 | 133 | $extra_participants[] = $uid; |
135 | 134 | } |
@@ -139,77 +138,77 @@ discard block |
||
139 | 138 | } |
140 | 139 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
141 | 140 | |
142 | - if(isset($_GET['start'])) |
|
141 | + if (isset($_GET['start'])) |
|
143 | 142 | { |
144 | 143 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
145 | 144 | } |
146 | 145 | else |
147 | 146 | { |
148 | 147 | $start = $this->bo->date2ts(array( |
149 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
150 | - 'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
151 | - 'minute' => (int) $_GET['minute'], |
|
148 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
149 | + 'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
150 | + 'minute' => (int)$_GET['minute'], |
|
152 | 151 | )); |
153 | 152 | } |
154 | 153 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
155 | 154 | |
156 | 155 | $participant_types['u'] = $participant_types = $participants = array(); |
157 | - foreach($extra_participants as $uid) |
|
156 | + foreach ($extra_participants as $uid) |
|
158 | 157 | { |
159 | - if (isset($participants[$uid])) continue; // already included |
|
158 | + if (isset($participants[$uid])) continue; // already included |
|
160 | 159 | |
161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
160 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
162 | 161 | |
163 | 162 | if (is_numeric($uid)) |
164 | 163 | { |
165 | 164 | $participants[$uid] = $participant_types['u'][$uid] = |
166 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
167 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
165 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
166 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
168 | 167 | } |
169 | 168 | elseif (is_array($this->bo->resources[$uid[0]])) |
170 | 169 | { |
171 | 170 | // Expand mailing lists |
172 | - if($uid[0] == 'l') |
|
171 | + if ($uid[0] == 'l') |
|
173 | 172 | { |
174 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
173 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
175 | 174 | { |
176 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
177 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
175 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
176 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
178 | 177 | } |
179 | 178 | continue; |
180 | 179 | } |
181 | 180 | // if contact is a user, use the user instead (as the GUI) |
182 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
181 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
183 | 182 | { |
184 | 183 | $uid = $account_id; |
185 | 184 | $participants[$uid] = $participant_types['u'][$uid] = |
186 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
187 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
185 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
186 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
188 | 187 | continue; |
189 | 188 | } |
190 | 189 | $res_data = $this->bo->resources[$uid[0]]; |
191 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
192 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
190 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
191 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
193 | 192 | { |
194 | 193 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
195 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
194 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
196 | 195 | } |
197 | 196 | } |
198 | 197 | } |
199 | 198 | if (!$participants) // if all participants got removed, include current user |
200 | 199 | { |
201 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
200 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
202 | 201 | } |
203 | - if(isset($_GET['cat_id'])) |
|
202 | + if (isset($_GET['cat_id'])) |
|
204 | 203 | { |
205 | - $cat_id = explode(',',$_GET['cat_id']); |
|
206 | - foreach($cat_id as &$cat) |
|
204 | + $cat_id = explode(',', $_GET['cat_id']); |
|
205 | + foreach ($cat_id as &$cat) |
|
207 | 206 | { |
208 | 207 | $cat = (int)$cat; |
209 | 208 | } |
210 | 209 | } |
211 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
212 | - if(isset($_GET['end'])) |
|
210 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
211 | + if (isset($_GET['end'])) |
|
213 | 212 | { |
214 | 213 | $end = Api\DateTime::to($_GET['end'], 'ts'); |
215 | 214 | $duration = $end - $start; |
@@ -227,9 +226,9 @@ discard block |
||
227 | 226 | if ((string)$this->cal_prefs[$alarm_pref] !== '') |
228 | 227 | { |
229 | 228 | $offset = 60 * $this->cal_prefs[$alarm_pref]; |
230 | - $alarms[1] = array( |
|
229 | + $alarms[1] = array( |
|
231 | 230 | 'default' => 1, |
232 | - 'offset' => $offset , |
|
231 | + 'offset' => $offset, |
|
233 | 232 | 'time' => $start - $offset, |
234 | 233 | 'all' => false, |
235 | 234 | 'owner' => $owner, |
@@ -244,7 +243,7 @@ discard block |
||
244 | 243 | 'start' => $start, |
245 | 244 | 'end' => $end, |
246 | 245 | 'tzid' => $this->bo->common_prefs['tz'], |
247 | - 'priority' => 2, // normal |
|
246 | + 'priority' => 2, // normal |
|
248 | 247 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
249 | 248 | 'alarm' => $alarms, |
250 | 249 | 'recur_exception' => array(), |
@@ -263,7 +262,7 @@ discard block |
||
263 | 262 | { |
264 | 263 | if (!is_array($content)) // redirect from etemplate, if POST empty |
265 | 264 | { |
266 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
265 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
267 | 266 | } |
268 | 267 | // clear notification errors |
269 | 268 | notifications::errors(true); |
@@ -277,22 +276,22 @@ discard block |
||
277 | 276 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
278 | 277 | |
279 | 278 | list($button) = @each($content['button']); |
280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
279 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
281 | 280 | unset($content['button']); unset($content['action']); |
282 | 281 | |
283 | 282 | $view = $content['view']; |
284 | 283 | if ($button == 'ical') |
285 | 284 | { |
286 | - $msg = $this->export($content['id'],true); |
|
285 | + $msg = $this->export($content['id'], true); |
|
287 | 286 | } |
288 | 287 | // delete a recur-exception |
289 | 288 | if ($content['recur_exception']['delete_exception']) |
290 | 289 | { |
291 | 290 | list($date) = each($content['recur_exception']['delete_exception']); |
292 | 291 | // eT2 converts time to |
293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
292 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
294 | 293 | unset($content['recur_exception']['delete_exception']); |
295 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
294 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
296 | 295 | { |
297 | 296 | // propagate the exception to a single event |
298 | 297 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -302,7 +301,7 @@ discard block |
||
302 | 301 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
303 | 302 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
304 | 303 | $exception['reference'] = $exception['recurrence'] = 0; |
305 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
304 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
306 | 305 | break; |
307 | 306 | } |
308 | 307 | unset($content['recur_exception'][$key]); |
@@ -343,7 +342,7 @@ discard block |
||
343 | 342 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
344 | 343 | if ((string)$def_alarm === '') |
345 | 344 | { |
346 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
345 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
347 | 346 | } |
348 | 347 | else |
349 | 348 | { |
@@ -365,7 +364,7 @@ discard block |
||
365 | 364 | $offset = 60 * $def_alarm; |
366 | 365 | array_unshift($content['alarm'], array( |
367 | 366 | 'default' => 1, |
368 | - 'offset' => $offset , |
|
367 | + 'offset' => $offset, |
|
369 | 368 | 'time' => $content['start'] - $offset, |
370 | 369 | 'all' => false, |
371 | 370 | 'owner' => 0, |
@@ -378,7 +377,7 @@ discard block |
||
378 | 377 | unset($event['alarm']['delete_alarm']); |
379 | 378 | unset($event['duration']); |
380 | 379 | |
381 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
380 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
382 | 381 | { |
383 | 382 | // no conversation necessary, event is already in the right format |
384 | 383 | } |
@@ -398,7 +397,7 @@ discard block |
||
398 | 397 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
399 | 398 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
400 | 399 | { |
401 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
400 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
402 | 401 | } |
403 | 402 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
404 | 403 | { |
@@ -410,9 +409,9 @@ discard block |
||
410 | 409 | |
411 | 410 | $event['participants'] = $event['participant_types'] = array(); |
412 | 411 | |
413 | - foreach($content['participants'] as $key => $data) |
|
412 | + foreach ($content['participants'] as $key => $data) |
|
414 | 413 | { |
415 | - switch($key) |
|
414 | + switch ($key) |
|
416 | 415 | { |
417 | 416 | case 'delete': // handled in default |
418 | 417 | case 'quantity': // handled in new_resource |
@@ -421,7 +420,7 @@ discard block |
||
421 | 420 | case 'status_date': |
422 | 421 | break; |
423 | 422 | case 'participant': |
424 | - foreach($data as $participant) |
|
423 | + foreach ($data as $participant) |
|
425 | 424 | { |
426 | 425 | if (is_null($participant)) |
427 | 426 | { |
@@ -430,17 +429,17 @@ discard block |
||
430 | 429 | |
431 | 430 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
432 | 431 | $email = array(); |
433 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
432 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
434 | 433 | { |
435 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
436 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
434 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
435 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
437 | 436 | { |
438 | 437 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
439 | 438 | } |
440 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
439 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
441 | 440 | 'email' => $email[2], |
442 | 441 | 'email_home' => $email[2], |
443 | - ),true,'','','',false,'OR'))) |
|
442 | + ), true, '', '', '', false, 'OR'))) |
|
444 | 443 | { |
445 | 444 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
446 | 445 | } |
@@ -451,7 +450,7 @@ discard block |
||
451 | 450 | } |
452 | 451 | else |
453 | 452 | { |
454 | - if(is_numeric($participant)) |
|
453 | + if (is_numeric($participant)) |
|
455 | 454 | { |
456 | 455 | $uid = $participant; |
457 | 456 | $id = $participant; |
@@ -460,12 +459,12 @@ discard block |
||
460 | 459 | else |
461 | 460 | { |
462 | 461 | $uid = $participant; |
463 | - $id = substr($participant,1); |
|
462 | + $id = substr($participant, 1); |
|
464 | 463 | $resource = $this->bo->resources[$participant[0]]; |
465 | 464 | } |
466 | - if(!$this->bo->check_acl_invite($uid)) |
|
465 | + if (!$this->bo->check_acl_invite($uid)) |
|
467 | 466 | { |
468 | - if(!$msg_permission_denied_added) |
|
467 | + if (!$msg_permission_denied_added) |
|
469 | 468 | { |
470 | 469 | $msg .= lang('Permission denied!'); |
471 | 470 | $msg_permission_denied_added = true; |
@@ -475,20 +474,19 @@ discard block |
||
475 | 474 | |
476 | 475 | $type = $resource['type']; |
477 | 476 | $status = isset($this->bo->resources[$type]['new_status']) ? |
478 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
479 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
477 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
480 | 478 | |
481 | 479 | // Expand mailing lists |
482 | - if($type == 'l') |
|
480 | + if ($type == 'l') |
|
483 | 481 | { |
484 | 482 | // Ignore ACL here, allow inviting anyone in the list |
485 | - foreach($this->bo->enum_mailing_list($participant, true) as $contact) |
|
483 | + foreach ($this->bo->enum_mailing_list($participant, true) as $contact) |
|
486 | 484 | { |
487 | 485 | // Mailing lists can contain users, so allow for that possibility |
488 | 486 | $_type = is_numeric($contact) ? '' : $contact[0]; |
489 | - $_uid = is_numeric($contact) ? $contact : substr($contact,1); |
|
487 | + $_uid = is_numeric($contact) ? $contact : substr($contact, 1); |
|
490 | 488 | $event['participants'][$contact] = $event['participant_types'][$_type][$_uid] = |
491 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
489 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
492 | 490 | } |
493 | 491 | continue; |
494 | 492 | } |
@@ -498,8 +496,8 @@ discard block |
||
498 | 496 | // todo check real availability = maximum - already booked quantity |
499 | 497 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
500 | 498 | { |
501 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
502 | - foreach(array('quantity','resource','role') as $n) |
|
499 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
500 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
503 | 501 | { |
504 | 502 | $event['participants'][$n] = $content['participants'][$n]; |
505 | 503 | } |
@@ -508,7 +506,7 @@ discard block |
||
508 | 506 | else |
509 | 507 | { |
510 | 508 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
511 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
509 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
512 | 510 | } |
513 | 511 | } |
514 | 512 | } |
@@ -522,15 +520,15 @@ discard block |
||
522 | 520 | break; |
523 | 521 | |
524 | 522 | default: // existing participant row |
525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
523 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
526 | 524 | $quantity = $status = $role = null; |
527 | - foreach(array('uid','status','quantity','role') as $name) |
|
525 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
528 | 526 | { |
529 | 527 | $$name = $data[$name]; |
530 | 528 | } |
531 | 529 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
532 | 530 | { |
533 | - $uid = false; // entry has been deleted |
|
531 | + $uid = false; // entry has been deleted |
|
534 | 532 | } |
535 | 533 | elseif ($uid) |
536 | 534 | { |
@@ -541,27 +539,27 @@ discard block |
||
541 | 539 | } |
542 | 540 | else |
543 | 541 | { |
544 | - $id = substr($uid,1); |
|
542 | + $id = substr($uid, 1); |
|
545 | 543 | $type = $uid[0]; |
546 | 544 | } |
547 | 545 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
548 | 546 | { |
549 | 547 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
550 | 548 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
551 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
549 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
552 | 550 | { |
553 | 551 | // Update main window |
554 | 552 | $d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone); |
555 | 553 | $client_updated = $this->update_client($event['id'], $d); |
556 | 554 | |
557 | 555 | // refreshing the calendar-view with the changed participant-status |
558 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
556 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
559 | 557 | { |
560 | 558 | $msg = lang('Status for all future scheduled days changed'); |
561 | 559 | } |
562 | 560 | else |
563 | 561 | { |
564 | - if(isset($content['edit_single'])) |
|
562 | + if (isset($content['edit_single'])) |
|
565 | 563 | { |
566 | 564 | $msg = lang('Status for this particular day changed'); |
567 | 565 | // prevent accidentally creating a real exception afterwards |
@@ -582,7 +580,7 @@ discard block |
||
582 | 580 | if ($status == 'R' && $event['alarm']) |
583 | 581 | { |
584 | 582 | // remove from bo->set_status deleted alarms of rejected users from UI too |
585 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
583 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
586 | 584 | { |
587 | 585 | if ((string)$alarm['owner'] === (string)$uid) |
588 | 586 | { |
@@ -595,7 +593,7 @@ discard block |
||
595 | 593 | if ($uid && $status != 'G') |
596 | 594 | { |
597 | 595 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
598 | - calendar_so::combine_status($status,$quantity,$role); |
|
596 | + calendar_so::combine_status($status, $quantity, $role); |
|
599 | 597 | } |
600 | 598 | } |
601 | 599 | break; |
@@ -614,26 +612,26 @@ discard block |
||
614 | 612 | 'tabs' => $content['tabs'], |
615 | 613 | 'template' => $content['template'], |
616 | 614 | ); |
617 | - $noerror=true; |
|
615 | + $noerror = true; |
|
618 | 616 | |
619 | 617 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
620 | 618 | |
621 | 619 | $ignore_conflicts = $status_reset_to_unknown = false; |
622 | 620 | |
623 | - switch((string)$button) |
|
621 | + switch ((string)$button) |
|
624 | 622 | { |
625 | 623 | case 'ignore': |
626 | 624 | $ignore_conflicts = true; |
627 | - $button = $event['button_was']; // save or apply |
|
625 | + $button = $event['button_was']; // save or apply |
|
628 | 626 | unset($event['button_was']); |
629 | 627 | break; |
630 | 628 | |
631 | 629 | } |
632 | 630 | |
633 | - switch((string)$button) |
|
631 | + switch ((string)$button) |
|
634 | 632 | { |
635 | 633 | case 'exception': // create an exception in a recuring event |
636 | - $msg = $this->_create_exception($event,$preserv); |
|
634 | + $msg = $this->_create_exception($event, $preserv); |
|
637 | 635 | break; |
638 | 636 | |
639 | 637 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -644,29 +642,29 @@ discard block |
||
644 | 642 | unset($event['recurrence']); |
645 | 643 | unset($preserv['recurrence']); |
646 | 644 | unset($event['recur_exception']); |
647 | - unset($event['edit_single']); // in case it has been set |
|
645 | + unset($event['edit_single']); // in case it has been set |
|
648 | 646 | unset($event['modified']); |
649 | 647 | unset($event['modifier']); |
650 | 648 | unset($event['caldav_name']); |
651 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
649 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner']; |
|
652 | 650 | |
653 | 651 | // Clear participant stati |
654 | - foreach($event['participant_types'] as $type => &$participants) |
|
652 | + foreach ($event['participant_types'] as $type => &$participants) |
|
655 | 653 | { |
656 | - foreach($participants as $id => &$p_response) |
|
654 | + foreach ($participants as $id => &$p_response) |
|
657 | 655 | { |
658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
656 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
659 | 657 | calendar_so::split_status($p_response, $quantity, $role); |
660 | 658 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
661 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
662 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
659 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
660 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
663 | 661 | } |
664 | 662 | } |
665 | 663 | |
666 | 664 | // Copy alarms |
667 | 665 | if (is_array($event['alarm'])) |
668 | 666 | { |
669 | - foreach($event['alarm'] as $n => &$alarm) |
|
667 | + foreach ($event['alarm'] as $n => &$alarm) |
|
670 | 668 | { |
671 | 669 | unset($alarm['id']); |
672 | 670 | unset($alarm['cal_id']); |
@@ -676,7 +674,7 @@ discard block |
||
676 | 674 | // Get links to be copied |
677 | 675 | // With no ID, $content['link_to']['to_id'] is used |
678 | 676 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
679 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
677 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
680 | 678 | { |
681 | 679 | if ($link['app'] != Link::VFS_APPNAME) |
682 | 680 | { |
@@ -692,7 +690,7 @@ discard block |
||
692 | 690 | } |
693 | 691 | unset($link); |
694 | 692 | $preserv['view'] = $preserv['edit_single'] = false; |
695 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
693 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry'))); |
|
696 | 694 | $event['title'] = lang('Copy of:').' '.$event['title']; |
697 | 695 | break; |
698 | 696 | |
@@ -702,7 +700,7 @@ discard block |
||
702 | 700 | case 'print': |
703 | 701 | case 'apply': |
704 | 702 | case 'infolog': |
705 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
703 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
706 | 704 | { |
707 | 705 | $msg = lang('Permission denied'); |
708 | 706 | $button = ''; |
@@ -720,7 +718,7 @@ discard block |
||
720 | 718 | $button = ''; |
721 | 719 | break; |
722 | 720 | } |
723 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
721 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
724 | 722 | { |
725 | 723 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
726 | 724 | $button = ''; |
@@ -750,14 +748,14 @@ discard block |
||
750 | 748 | $event['reference'] = $event['id']; |
751 | 749 | $event['recurrence'] = $content['edit_single']; |
752 | 750 | unset($event['id']); |
753 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
751 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
754 | 752 | if (!is_array($conflicts) && $conflicts) |
755 | 753 | { |
756 | 754 | // now we need to add the original start as recur-execption to the series |
757 | 755 | $recur_event = $this->bo->read($event['reference']); |
758 | 756 | $recur_event['recur_exception'][] = $content['edit_single']; |
759 | 757 | // check if we need to move the alarms, because they are next on that exception |
760 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
758 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
761 | 759 | { |
762 | 760 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
763 | 761 | { |
@@ -773,17 +771,17 @@ discard block |
||
773 | 771 | } |
774 | 772 | } |
775 | 773 | } |
776 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
777 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
778 | - $this->bo->update($recur_event,true); // no conflict check here |
|
774 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
775 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
776 | + $this->bo->update($recur_event, true); // no conflict check here |
|
779 | 777 | |
780 | 778 | // Save links |
781 | - if($content['links']) |
|
779 | + if ($content['links']) |
|
782 | 780 | { |
783 | 781 | Link::link('calendar', $event['id'], $content['links']['to_id']); |
784 | 782 | } |
785 | 783 | |
786 | - if(Api\Json\Response::isJSONResponse()) |
|
784 | + if (Api\Json\Response::isJSONResponse()) |
|
787 | 785 | { |
788 | 786 | // Sending null will trigger a removal of the original |
789 | 787 | // for that date |
@@ -791,7 +789,7 @@ discard block |
||
791 | 789 | } |
792 | 790 | |
793 | 791 | unset($recur_event); |
794 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
792 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
795 | 793 | unset($preserv['edit_single']); |
796 | 794 | } |
797 | 795 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -822,8 +820,8 @@ discard block |
||
822 | 820 | { |
823 | 821 | $offset = $off2; |
824 | 822 | } |
825 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
826 | - if($msg) |
|
823 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
824 | + if ($msg) |
|
827 | 825 | { |
828 | 826 | $noerror = false; |
829 | 827 | } |
@@ -836,10 +834,10 @@ discard block |
||
836 | 834 | $event['whole_day'] != $old_event['whole_day']) |
837 | 835 | { |
838 | 836 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
839 | - foreach((array)$event['participants'] as $uid => $status) |
|
837 | + foreach ((array)$event['participants'] as $uid => $status) |
|
840 | 838 | { |
841 | 839 | $q = $r = null; |
842 | - calendar_so::split_status($status,$q,$r); |
|
840 | + calendar_so::split_status($status, $q, $r); |
|
843 | 841 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
844 | 842 | { |
845 | 843 | $preferences = new Api\Preferences($uid); |
@@ -852,7 +850,7 @@ discard block |
||
852 | 850 | if ($sameday) break; |
853 | 851 | default: |
854 | 852 | $status_reset_to_unknown = true; |
855 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
853 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
856 | 854 | // todo: report reset status to user |
857 | 855 | } |
858 | 856 | } |
@@ -870,43 +868,43 @@ discard block |
||
870 | 868 | } |
871 | 869 | // Adding participants needs to be done as an edit, in case we |
872 | 870 | // have participants visible in seperate calendars |
873 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
871 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
874 | 872 | { |
875 | 873 | $update_type = 'edit'; |
876 | 874 | } |
877 | 875 | // Changing category may affect event filtering |
878 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
876 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
879 | 877 | { |
880 | 878 | $update_type = 'edit'; |
881 | 879 | } |
882 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
880 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
883 | 881 | unset($event['ignore']); |
884 | 882 | } |
885 | 883 | if (is_array($conflicts)) |
886 | 884 | { |
887 | - $event['button_was'] = $button; // remember for ignore |
|
888 | - return $this->conflicts($event,$conflicts,$preserv); |
|
885 | + $event['button_was'] = $button; // remember for ignore |
|
886 | + return $this->conflicts($event, $conflicts, $preserv); |
|
889 | 887 | } |
890 | 888 | |
891 | 889 | // Event spans multiple days, need an edit to make sure they all get updated |
892 | 890 | // We could check old date, as removing from days could still be an update |
893 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
891 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
894 | 892 | { |
895 | 893 | $update_type = 'edit'; |
896 | 894 | } |
897 | 895 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
898 | 896 | if ($messages) |
899 | 897 | { |
900 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
898 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
901 | 899 | } |
902 | 900 | if ($conflicts === 0) |
903 | 901 | { |
904 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
905 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
906 | - htmlspecialchars(Egw::link('/index.php',array( |
|
902 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
903 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
904 | + htmlspecialchars(Egw::link('/index.php', array( |
|
907 | 905 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
908 | 906 | 'cal_id' => $content['id'], |
909 | - ))).'">','</a>'); |
|
907 | + ))).'">', '</a>'); |
|
910 | 908 | $noerror = false; |
911 | 909 | } |
912 | 910 | elseif ($conflicts > 0) |
@@ -928,19 +926,19 @@ discard block |
||
928 | 926 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
929 | 927 | if ($alarm['time'] < $this->bo->now_su) |
930 | 928 | { |
931 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
929 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
932 | 930 | { |
933 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
931 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
934 | 932 | } |
935 | 933 | else |
936 | 934 | { |
937 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
935 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
938 | 936 | } |
939 | 937 | } |
940 | 938 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
941 | 939 | elseif ($event_time < $event['start']) |
942 | 940 | { |
943 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
941 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
944 | 942 | } |
945 | 943 | if ($alarm) |
946 | 944 | { |
@@ -949,9 +947,9 @@ discard block |
||
949 | 947 | } |
950 | 948 | } |
951 | 949 | // attach all future exceptions to the new series |
952 | - $events =& $this->bo->search(array( |
|
950 | + $events = & $this->bo->search(array( |
|
953 | 951 | 'query' => array('cal_uid' => $old_event['uid']), |
954 | - 'filter' => 'owner', // return all possible entries |
|
952 | + 'filter' => 'owner', // return all possible entries |
|
955 | 953 | 'daywise' => false, |
956 | 954 | 'date_format' => 'ts', |
957 | 955 | )); |
@@ -962,7 +960,7 @@ discard block |
||
962 | 960 | $exception['recurrence'] += $offset; |
963 | 961 | $exception['reference'] = $event['id']; |
964 | 962 | $exception['uid'] = $event['uid']; |
965 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
963 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
966 | 964 | } |
967 | 965 | } |
968 | 966 | } |
@@ -970,12 +968,12 @@ discard block |
||
970 | 968 | $message = lang('Event saved'); |
971 | 969 | if ($status_reset_to_unknown) |
972 | 970 | { |
973 | - foreach((array)$event['participants'] as $uid => $status) |
|
971 | + foreach ((array)$event['participants'] as $uid => $status) |
|
974 | 972 | { |
975 | 973 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
976 | 974 | { |
977 | - calendar_so::split_status($status,$q,$r); |
|
978 | - $status = calendar_so::combine_status('U',$q,$r); |
|
975 | + calendar_so::split_status($status, $q, $r); |
|
976 | + $status = calendar_so::combine_status('U', $q, $r); |
|
979 | 977 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
980 | 978 | } |
981 | 979 | } |
@@ -983,17 +981,17 @@ discard block |
||
983 | 981 | } |
984 | 982 | |
985 | 983 | $response = Api\Json\Response::get(); |
986 | - if($response && $update_type != 'delete') |
|
984 | + if ($response && $update_type != 'delete') |
|
987 | 985 | { |
988 | 986 | $client_updated = $this->update_client($event['id']); |
989 | 987 | } |
990 | 988 | |
991 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
989 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
992 | 990 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
993 | 991 | // writing links for new entry, existing ones are handled by the widget itself |
994 | 992 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
995 | 993 | { |
996 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
994 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
997 | 995 | } |
998 | 996 | } |
999 | 997 | else |
@@ -1003,7 +1001,7 @@ discard block |
||
1003 | 1001 | break; |
1004 | 1002 | |
1005 | 1003 | case 'cancel': |
1006 | - if($content['cancel_needs_refresh']) |
|
1004 | + if ($content['cancel_needs_refresh']) |
|
1007 | 1005 | { |
1008 | 1006 | Framework::refresh_opener($msg, 'calendar'); |
1009 | 1007 | } |
@@ -1041,7 +1039,7 @@ discard block |
||
1041 | 1039 | { |
1042 | 1040 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
1043 | 1041 | } |
1044 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1042 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
1045 | 1043 | { |
1046 | 1044 | $alarm = array( |
1047 | 1045 | 'offset' => $offset, |
@@ -1055,13 +1053,13 @@ discard block |
||
1055 | 1053 | } |
1056 | 1054 | elseif ($event['id']) // save the alarm immediatly |
1057 | 1055 | { |
1058 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1056 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
1059 | 1057 | { |
1060 | 1058 | $alarm['id'] = $alarm_id; |
1061 | 1059 | $event['alarm'][$alarm_id] = $alarm; |
1062 | 1060 | |
1063 | 1061 | $msg = lang('Alarm added'); |
1064 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1062 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
1065 | 1063 | } |
1066 | 1064 | else |
1067 | 1065 | { |
@@ -1070,7 +1068,7 @@ discard block |
||
1070 | 1068 | } |
1071 | 1069 | else |
1072 | 1070 | { |
1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1071 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1074 | 1072 | $event['alarm'][$alarm['id']] = $alarm; |
1075 | 1073 | } |
1076 | 1074 | } |
@@ -1087,32 +1085,32 @@ discard block |
||
1087 | 1085 | } |
1088 | 1086 | // New event, send data before updating so it's there |
1089 | 1087 | $response = Api\Json\Response::get(); |
1090 | - if($response && !$content['id'] && $event['id']) |
|
1088 | + if ($response && !$content['id'] && $event['id']) |
|
1091 | 1089 | { |
1092 | 1090 | $client_updated = $this->update_client($event['id']); |
1093 | 1091 | } |
1094 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
1092 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
1095 | 1093 | { |
1096 | 1094 | if ($content['lock_token']) // remove an existing lock |
1097 | 1095 | { |
1098 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
1096 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
1099 | 1097 | } |
1100 | 1098 | if ($content['no_popup']) |
1101 | 1099 | { |
1102 | - Egw::redirect_link('/index.php',array( |
|
1100 | + Egw::redirect_link('/index.php', array( |
|
1103 | 1101 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1104 | 1102 | 'msg' => $msg, |
1105 | 1103 | 'ajax' => 'true' |
1106 | 1104 | )); |
1107 | 1105 | } |
1108 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1106 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1109 | 1107 | { |
1110 | - Framework::refresh_opener($msg,'calendar'); |
|
1108 | + Framework::refresh_opener($msg, 'calendar'); |
|
1111 | 1109 | } |
1112 | 1110 | else |
1113 | 1111 | { |
1114 | 1112 | Framework::refresh_opener($msg, 'calendar', |
1115 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
1113 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
1116 | 1114 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
1117 | 1115 | ); |
1118 | 1116 | } |
@@ -1120,7 +1118,7 @@ discard block |
||
1120 | 1118 | exit(); |
1121 | 1119 | } |
1122 | 1120 | unset($event['no_notifications']); |
1123 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1121 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1124 | 1122 | } |
1125 | 1123 | |
1126 | 1124 | /** |
@@ -1132,7 +1130,7 @@ discard block |
||
1132 | 1130 | * @param array &$preserv |
1133 | 1131 | * @return string message that exception was created |
1134 | 1132 | */ |
1135 | - function _create_exception(&$event,&$preserv) |
|
1133 | + function _create_exception(&$event, &$preserv) |
|
1136 | 1134 | { |
1137 | 1135 | // In some cases where the user makes the first day an exception, actual_date may be missing |
1138 | 1136 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1142,25 +1140,25 @@ discard block |
||
1142 | 1140 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
1143 | 1141 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
1144 | 1142 | $event['recur_type'] = MCAL_RECUR_NONE; |
1145 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
1143 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
1146 | 1144 | { |
1147 | 1145 | unset($event[$name]); |
1148 | 1146 | } |
1149 | 1147 | // add all alarms as new alarms to execption |
1150 | 1148 | $event['alarm'] = array_values((array)$event['alarm']); |
1151 | - foreach($event['alarm'] as &$alarm) |
|
1149 | + foreach ($event['alarm'] as &$alarm) |
|
1152 | 1150 | { |
1153 | 1151 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
1154 | 1152 | } |
1155 | 1153 | |
1156 | 1154 | // Copy links |
1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1155 | + if (!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1158 | 1156 | $event['link_to']['to_app'] = 'calendar'; |
1159 | 1157 | $event['link_to']['to_id'] = 0; |
1160 | 1158 | |
1161 | - foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1159 | + foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1162 | 1160 | { |
1163 | - if(!$link['id']) continue; |
|
1161 | + if (!$link['id']) continue; |
|
1164 | 1162 | if ($link['app'] != Link::VFS_APPNAME) |
1165 | 1163 | { |
1166 | 1164 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1176,7 +1174,7 @@ discard block |
||
1176 | 1174 | |
1177 | 1175 | $event['links'] = $event['link_to']; |
1178 | 1176 | |
1179 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
1177 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
1180 | 1178 | { |
1181 | 1179 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
1182 | 1180 | } |
@@ -1203,14 +1201,14 @@ discard block |
||
1203 | 1201 | { |
1204 | 1202 | $msg = false; |
1205 | 1203 | |
1206 | - if(!$as_of_date ) |
|
1204 | + if (!$as_of_date) |
|
1207 | 1205 | { |
1208 | 1206 | $as_of_date = time(); |
1209 | 1207 | } |
1210 | 1208 | |
1211 | 1209 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
1212 | 1210 | |
1213 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1211 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1214 | 1212 | { |
1215 | 1213 | $msg = lang("Error: You can't shift a series from the past!"); |
1216 | 1214 | return $msg; |
@@ -1223,11 +1221,11 @@ discard block |
||
1223 | 1221 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
1224 | 1222 | |
1225 | 1223 | // base start-date of new series on actual / clicked date |
1226 | - $event['start'] = $as_of_date ; |
|
1224 | + $event['start'] = $as_of_date; |
|
1227 | 1225 | |
1228 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
1226 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
1229 | 1227 | // Adjust for requested date in the past |
1230 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
1228 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
1231 | 1229 | ) |
1232 | 1230 | { |
1233 | 1231 | |
@@ -1247,17 +1245,17 @@ discard block |
||
1247 | 1245 | $rriter->next_no_exception(); |
1248 | 1246 | $occurrence = $rriter->current(); |
1249 | 1247 | } |
1250 | - while ($rriter->valid() && ( |
|
1248 | + while ($rriter->valid() && ( |
|
1251 | 1249 | Api\DateTime::to($occurrence, 'ts') <= time() || |
1252 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
1250 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
1253 | 1251 | ) && ($last = $occurrence)); |
1254 | 1252 | |
1255 | 1253 | |
1256 | 1254 | // Make sure as_of_date is still valid, may have to move forward |
1257 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
1255 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
1258 | 1256 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
1259 | 1257 | { |
1260 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
1258 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
1261 | 1259 | } |
1262 | 1260 | |
1263 | 1261 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1265,7 +1263,7 @@ discard block |
||
1265 | 1263 | { |
1266 | 1264 | $event['end'] = $event['start'] + $duration; |
1267 | 1265 | } |
1268 | - elseif($event['end'] < $event['start']) |
|
1266 | + elseif ($event['end'] < $event['start']) |
|
1269 | 1267 | { |
1270 | 1268 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
1271 | 1269 | } |
@@ -1274,7 +1272,7 @@ discard block |
||
1274 | 1272 | $event['participants'] = $old_event['participants']; |
1275 | 1273 | foreach ($old_event['recur_exception'] as $key => $exdate) |
1276 | 1274 | { |
1277 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
1275 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
1278 | 1276 | { |
1279 | 1277 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
1280 | 1278 | unset($old_event['recur_exception'][$key]); |
@@ -1288,18 +1286,18 @@ discard block |
||
1288 | 1286 | } |
1289 | 1287 | $last->setTime(0, 0, 0); |
1290 | 1288 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
1291 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
1289 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
1292 | 1290 | { |
1293 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1294 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
1295 | - htmlspecialchars(Egw::link('/index.php',array( |
|
1291 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1292 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
1293 | + htmlspecialchars(Egw::link('/index.php', array( |
|
1296 | 1294 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1297 | 1295 | 'cal_id' => $event['id'], |
1298 | - ))).'">','</a>'); |
|
1296 | + ))).'">', '</a>'); |
|
1299 | 1297 | $event = $orig_event; |
1300 | 1298 | } |
1301 | 1299 | } |
1302 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
1300 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
1303 | 1301 | return $msg; |
1304 | 1302 | } |
1305 | 1303 | |
@@ -1310,18 +1308,18 @@ discard block |
||
1310 | 1308 | * @param boolean $added |
1311 | 1309 | * @return string javascript window.open command |
1312 | 1310 | */ |
1313 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
1311 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
1314 | 1312 | { |
1315 | 1313 | $to = array(); |
1316 | 1314 | |
1317 | - foreach($event['participants'] as $uid => $status) |
|
1315 | + foreach ($event['participants'] as $uid => $status) |
|
1318 | 1316 | { |
1319 | 1317 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1320 | 1318 | if (empty($status)) continue; |
1321 | - if(!is_array($status)) |
|
1319 | + if (!is_array($status)) |
|
1322 | 1320 | { |
1323 | 1321 | $quantity = $role = null; |
1324 | - calendar_so::split_status($status,$quantity,$role); |
|
1322 | + calendar_so::split_status($status, $quantity, $role); |
|
1325 | 1323 | $status = array( |
1326 | 1324 | 'status' => $status, |
1327 | 1325 | 'uid' => $uid, |
@@ -1332,32 +1330,32 @@ discard block |
||
1332 | 1330 | |
1333 | 1331 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1334 | 1332 | { |
1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1333 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
1336 | 1334 | |
1337 | 1335 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
1338 | 1336 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
1339 | 1337 | |
1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1338 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
1341 | 1339 | } |
1342 | 1340 | elseif ($uid < 0) |
1343 | 1341 | { |
1344 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
1342 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
1345 | 1343 | { |
1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1344 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
1347 | 1345 | |
1348 | 1346 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
1349 | 1347 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
1350 | 1348 | |
1351 | 1349 | // dont add groupmembers if they already rejected the event, or are the current user |
1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1350 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1353 | 1351 | } |
1354 | 1352 | } |
1355 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1353 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1356 | 1354 | { |
1357 | 1355 | $to[] = $info['email']; |
1358 | 1356 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1359 | 1357 | } |
1360 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
1358 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
1361 | 1359 | { |
1362 | 1360 | $to[] = $info['email']; |
1363 | 1361 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1366,7 +1364,7 @@ discard block |
||
1366 | 1364 | // prefer event description over standard notification text |
1367 | 1365 | if (empty($event['description'])) |
1368 | 1366 | { |
1369 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1367 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1370 | 1368 | } |
1371 | 1369 | else |
1372 | 1370 | { |
@@ -1381,12 +1379,12 @@ discard block |
||
1381 | 1379 | $boical = new calendar_ical(); |
1382 | 1380 | // we need to pass $event[id] so iCal class reads event again, |
1383 | 1381 | // as event is in user TZ, but iCal class expects server TZ! |
1384 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
1382 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
1385 | 1383 | |
1386 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
1387 | - if(($f = fopen($ics_file,'w'))) |
|
1384 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
1385 | + if (($f = fopen($ics_file, 'w'))) |
|
1388 | 1386 | { |
1389 | - fwrite($f,$ics); |
|
1387 | + fwrite($f, $ics); |
|
1390 | 1388 | fclose($f); |
1391 | 1389 | } |
1392 | 1390 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1397,10 +1395,10 @@ discard block |
||
1397 | 1395 | 'preset[body]' => $body, |
1398 | 1396 | 'preset[name]' => 'event.ics', |
1399 | 1397 | 'preset[file]' => $ics_file, |
1400 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
1398 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
1401 | 1399 | 'preset[size]' => filesize($ics_file), |
1402 | 1400 | ); |
1403 | - $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
|
1401 | + $vars[$asrequest ? 'preset[to]' : 'preset[bcc]'] = $to; |
|
1404 | 1402 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
1405 | 1403 | $response = Api\Json\Response::get(); |
1406 | 1404 | $response->call('app.calendar.custom_mail', $vars); |
@@ -1454,7 +1452,7 @@ discard block |
||
1454 | 1452 | * @param mixed $link_to_id ='' from or for the link-widget |
1455 | 1453 | * @param string $msg_type =null default automatic detect, if it contains "error" |
1456 | 1454 | */ |
1457 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
1455 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
1458 | 1456 | { |
1459 | 1457 | $sel_options = array( |
1460 | 1458 | 'recur_type' => &$this->bo->recur_types, |
@@ -1478,8 +1476,8 @@ discard block |
||
1478 | 1476 | 'no_popup' => isset($_GET['no_popup']), |
1479 | 1477 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
1480 | 1478 | ); |
1481 | - $cal_id = (int) $_GET['cal_id']; |
|
1482 | - if($_GET['action']) |
|
1479 | + $cal_id = (int)$_GET['cal_id']; |
|
1480 | + if ($_GET['action']) |
|
1483 | 1481 | { |
1484 | 1482 | $event = $this->bo->read($cal_id); |
1485 | 1483 | $event['action'] = $_GET['action']; |
@@ -1497,14 +1495,14 @@ discard block |
||
1497 | 1495 | { |
1498 | 1496 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
1499 | 1497 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
1500 | - $event =& $this->default_add_event(); |
|
1498 | + $event = & $this->default_add_event(); |
|
1501 | 1499 | } |
1502 | 1500 | if (!empty($_GET['ical_data']) && |
1503 | 1501 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
1504 | 1502 | { |
1505 | 1503 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
1506 | 1504 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
1507 | - $event =& $this->default_add_event(); |
|
1505 | + $event = & $this->default_add_event(); |
|
1508 | 1506 | } |
1509 | 1507 | if (!empty($_GET['ical'])) |
1510 | 1508 | { |
@@ -1513,14 +1511,14 @@ discard block |
||
1513 | 1511 | { |
1514 | 1512 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
1515 | 1513 | $msg = lang('Error: importing the iCal'); |
1516 | - $event =& $this->default_add_event(); |
|
1514 | + $event = & $this->default_add_event(); |
|
1517 | 1515 | } |
1518 | 1516 | else |
1519 | 1517 | { |
1520 | 1518 | if (count($events) > 1) |
1521 | 1519 | { |
1522 | 1520 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
1523 | - $msg_type = 'notice'; // no not hide automatic |
|
1521 | + $msg_type = 'notice'; // no not hide automatic |
|
1524 | 1522 | } |
1525 | 1523 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
1526 | 1524 | $this->bo->db2data($events, 'ts'); |
@@ -1533,7 +1531,7 @@ discard block |
||
1533 | 1531 | else |
1534 | 1532 | { |
1535 | 1533 | $event['participant_types'] = array(); |
1536 | - foreach($event['participants'] as $uid => $status) |
|
1534 | + foreach ($event['participants'] as $uid => $status) |
|
1537 | 1535 | { |
1538 | 1536 | $user_type = $user_id = null; |
1539 | 1537 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1554,15 +1552,15 @@ discard block |
||
1554 | 1552 | } |
1555 | 1553 | else |
1556 | 1554 | { |
1557 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
1555 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
1558 | 1556 | exit(); |
1559 | 1557 | } |
1560 | 1558 | } |
1561 | - $event =& $this->default_add_event(); |
|
1559 | + $event = & $this->default_add_event(); |
|
1562 | 1560 | } |
1563 | 1561 | else |
1564 | 1562 | { |
1565 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1563 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1566 | 1564 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1567 | 1565 | { |
1568 | 1566 | if (empty($event['whole_day'])) |
@@ -1575,10 +1573,10 @@ discard block |
||
1575 | 1573 | $date->setUser(); |
1576 | 1574 | } |
1577 | 1575 | $event = $this->bo->read($cal_id, $date, true); |
1578 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1576 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1579 | 1577 | if ($_GET['exception']) |
1580 | 1578 | { |
1581 | - $msg = $this->_create_exception($event,$preserv); |
|
1579 | + $msg = $this->_create_exception($event, $preserv); |
|
1582 | 1580 | } |
1583 | 1581 | else |
1584 | 1582 | { |
@@ -1587,9 +1585,9 @@ discard block |
||
1587 | 1585 | } |
1588 | 1586 | } |
1589 | 1587 | // set new start and end if given by $_GET |
1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1588 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
1589 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
1590 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1593 | 1591 | // check if the event is the whole day |
1594 | 1592 | $start = $this->bo->date2array($event['start']); |
1595 | 1593 | $end = $this->bo->date2array($event['end']); |
@@ -1599,30 +1597,30 @@ discard block |
||
1599 | 1597 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
1600 | 1598 | { |
1601 | 1599 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
1602 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1600 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1603 | 1601 | { |
1604 | 1602 | $link_id = $link_ids[$n]; |
1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1603 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
1606 | 1604 | { |
1607 | 1605 | continue; |
1608 | 1606 | } |
1609 | - if(!$n) |
|
1607 | + if (!$n) |
|
1610 | 1608 | { |
1611 | - $event['title'] = Link::title($link_app,$link_id); |
|
1609 | + $event['title'] = Link::title($link_app, $link_id); |
|
1612 | 1610 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
1613 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
1611 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
1614 | 1612 | { |
1615 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
1613 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
1616 | 1614 | { |
1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1615 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
1618 | 1616 | } |
1619 | 1617 | unset($set['link_app']); |
1620 | 1618 | unset($set['link_id']); |
1621 | 1619 | |
1622 | - $event = array_merge($event,$set); |
|
1620 | + $event = array_merge($event, $set); |
|
1623 | 1621 | } |
1624 | 1622 | } |
1625 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
1623 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
1626 | 1624 | } |
1627 | 1625 | } |
1628 | 1626 | } |
@@ -1632,45 +1630,45 @@ discard block |
||
1632 | 1630 | { |
1633 | 1631 | $etpl->read($preserv['template'] = 'calendar.edit'); |
1634 | 1632 | } |
1635 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
1633 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
1636 | 1634 | //echo "view=$view, event="; _debug_array($event); |
1637 | 1635 | // shared locking of entries to edit |
1638 | 1636 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
1639 | 1637 | { |
1640 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
1638 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
1641 | 1639 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1642 | 1640 | |
1643 | 1641 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
1644 | 1642 | { |
1645 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
1643 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
1646 | 1644 | } |
1647 | 1645 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1648 | 1646 | { |
1649 | 1647 | $msg .= ' '.lang('This entry is currently opened by %1!', |
1650 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
1648 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
1651 | 1649 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
1652 | 1650 | } |
1653 | - elseif($lock) |
|
1651 | + elseif ($lock) |
|
1654 | 1652 | { |
1655 | 1653 | $preserv['lock_token'] = $lock['token']; |
1656 | 1654 | } |
1657 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
1655 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
1658 | 1656 | { |
1659 | 1657 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
1660 | 1658 | } |
1661 | 1659 | else |
1662 | 1660 | { |
1663 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1661 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1664 | 1662 | $view = true; |
1665 | 1663 | } |
1666 | 1664 | } |
1667 | - $content = array_merge($event,array( |
|
1665 | + $content = array_merge($event, array( |
|
1668 | 1666 | 'cal_id' => $event['id'], |
1669 | 1667 | 'link_to' => array( |
1670 | 1668 | 'to_id' => $link_to_id, |
1671 | 1669 | 'to_app' => 'calendar', |
1672 | 1670 | ), |
1673 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1671 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1674 | 1672 | 'tabs' => $preserv['tabs'], |
1675 | 1673 | 'view' => $view, |
1676 | 1674 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1682,11 +1680,11 @@ discard block |
||
1682 | 1680 | $row = 3; |
1683 | 1681 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1684 | 1682 | // preserve some ui elements, if set eg. under error-conditions |
1685 | - foreach(array('quantity','resource','role') as $n) |
|
1683 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
1686 | 1684 | { |
1687 | 1685 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
1688 | 1686 | } |
1689 | - foreach($event['participant_types'] as $type => $participants) |
|
1687 | + foreach ($event['participant_types'] as $type => $participants) |
|
1690 | 1688 | { |
1691 | 1689 | $name = 'accounts'; |
1692 | 1690 | if (isset($this->bo->resources[$type])) |
@@ -1695,17 +1693,17 @@ discard block |
||
1695 | 1693 | } |
1696 | 1694 | // sort participants (in there group/app) by title |
1697 | 1695 | uksort($participants, array($this, 'uid_title_cmp')); |
1698 | - foreach($participants as $id => $status) |
|
1696 | + foreach ($participants as $id => $status) |
|
1699 | 1697 | { |
1700 | 1698 | $uid = $type == 'u' ? $id : $type.$id; |
1701 | 1699 | $quantity = $role = null; |
1702 | - calendar_so::split_status($status,$quantity,$role); |
|
1700 | + calendar_so::split_status($status, $quantity, $role); |
|
1703 | 1701 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1704 | 1702 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
1705 | 1703 | 'uid' => $uid, |
1706 | 1704 | 'status' => $status, |
1707 | 1705 | 'old_status' => $status, |
1708 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1706 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1709 | 1707 | 'role' => $role, |
1710 | 1708 | ); |
1711 | 1709 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1714,33 +1712,33 @@ discard block |
||
1714 | 1712 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
1715 | 1713 | } |
1716 | 1714 | // allow third party apps to use categories for roles |
1717 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
1715 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
1718 | 1716 | { |
1719 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
1717 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
1720 | 1718 | } |
1721 | 1719 | else |
1722 | 1720 | { |
1723 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
1721 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
1724 | 1722 | } |
1725 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
1723 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
1726 | 1724 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1727 | 1725 | |
1728 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
1726 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
1729 | 1727 | $readonlys['participants'][$row]['status'] = $no_status; |
1730 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
1728 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
1731 | 1729 | $readonlys['participants']['delete'][$uid] = true; |
1732 | 1730 | // todo: make the participants available as links with email as title |
1733 | 1731 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1734 | 1732 | // enumerate group-invitations, so people can accept/reject them |
1735 | 1733 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
1736 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
1734 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
1737 | 1735 | { |
1738 | 1736 | $sel_options['status']['G'] = lang('Select one'); |
1739 | 1737 | // sort members by title |
1740 | 1738 | usort($members, array($this, 'uid_title_cmp')); |
1741 | - foreach($members as $member) |
|
1739 | + foreach ($members as $member) |
|
1742 | 1740 | { |
1743 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
1741 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
1744 | 1742 | { |
1745 | 1743 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1746 | 1744 | 'app' => 'Group invitation', |
@@ -1749,7 +1747,7 @@ discard block |
||
1749 | 1747 | ); |
1750 | 1748 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
1751 | 1749 | // read access is enough to invite participants, but you need edit rights to change status |
1752 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
1750 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
1753 | 1751 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
1754 | 1752 | } |
1755 | 1753 | } |
@@ -1757,37 +1755,37 @@ discard block |
||
1757 | 1755 | } |
1758 | 1756 | // resouces / apps we shedule, atm. resources and addressbook |
1759 | 1757 | $content['participants']['cal_resources'] = ''; |
1760 | - foreach($this->bo->resources as $data) |
|
1758 | + foreach ($this->bo->resources as $data) |
|
1761 | 1759 | { |
1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1760 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1763 | 1761 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1764 | 1762 | } |
1765 | 1763 | } |
1766 | 1764 | $content['participants']['status_date'] = $preserv['actual_date']; |
1767 | - $preserved = array_merge($preserv,$content); |
|
1765 | + $preserved = array_merge($preserv, $content); |
|
1768 | 1766 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
1769 | 1767 | if ($event['alarm']) |
1770 | 1768 | { |
1771 | 1769 | // makes keys of the alarm-array starting with 1 |
1772 | 1770 | $content['alarm'] = array(false); |
1773 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
1771 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
1774 | 1772 | { |
1775 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
1773 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
1776 | 1774 | { |
1777 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1775 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1778 | 1776 | } |
1779 | - $alarm['all'] = (int) $alarm['all']; |
|
1777 | + $alarm['all'] = (int)$alarm['all']; |
|
1780 | 1778 | // fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise |
1781 | 1779 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1782 | 1780 | $after = false; |
1783 | - if($alarm['offset'] < 0) |
|
1781 | + if ($alarm['offset'] < 0) |
|
1784 | 1782 | { |
1785 | 1783 | $after = true; |
1786 | 1784 | $alarm['offset'] = -1 * $alarm['offset']; |
1787 | 1785 | } |
1788 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
1789 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
1790 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
1786 | + $days = (int)($alarm['offset'] / DAY_s); |
|
1787 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
1788 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
1791 | 1789 | $label = array(); |
1792 | 1790 | if ($days) $label[] = $days.' '.lang('days'); |
1793 | 1791 | if ($hours) $label[] = $hours.' '.lang('hours'); |
@@ -1798,11 +1796,11 @@ discard block |
||
1798 | 1796 | } |
1799 | 1797 | else |
1800 | 1798 | { |
1801 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
1799 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
1802 | 1800 | } |
1803 | 1801 | $content['alarm'][] = $alarm; |
1804 | 1802 | |
1805 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
1803 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
1806 | 1804 | } |
1807 | 1805 | if (count($content['alarm']) == 1) |
1808 | 1806 | { |
@@ -1817,20 +1815,20 @@ discard block |
||
1817 | 1815 | |
1818 | 1816 | if ($view) |
1819 | 1817 | { |
1820 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1818 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1821 | 1819 | $readonlys['button[cancel]'] = $readonlys['action'] = |
1822 | 1820 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
1823 | 1821 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
1824 | 1822 | |
1825 | 1823 | $content['participants']['no_add'] = true; |
1826 | 1824 | |
1827 | - if(!$event['whole_day']) |
|
1825 | + if (!$event['whole_day']) |
|
1828 | 1826 | { |
1829 | 1827 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
1830 | 1828 | } |
1831 | 1829 | |
1832 | 1830 | // respect category permissions |
1833 | - if(!empty($event['category'])) |
|
1831 | + if (!empty($event['category'])) |
|
1834 | 1832 | { |
1835 | 1833 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
1836 | 1834 | } |
@@ -1841,7 +1839,7 @@ discard block |
||
1841 | 1839 | |
1842 | 1840 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1843 | 1841 | { |
1844 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1842 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1845 | 1843 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
1846 | 1844 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
1847 | 1845 | } |
@@ -1851,9 +1849,9 @@ discard block |
||
1851 | 1849 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
1852 | 1850 | } |
1853 | 1851 | } |
1854 | - if($content['category'] && !is_array($content['category'])) |
|
1852 | + if ($content['category'] && !is_array($content['category'])) |
|
1855 | 1853 | { |
1856 | - $content['category'] = explode(',',$event['category']); |
|
1854 | + $content['category'] = explode(',', $event['category']); |
|
1857 | 1855 | } |
1858 | 1856 | // disabling the custom fields tab, if there are none |
1859 | 1857 | $readonlys['tabs'] = array( |
@@ -1870,13 +1868,13 @@ discard block |
||
1870 | 1868 | { |
1871 | 1869 | $readonlys['action'] = true; |
1872 | 1870 | } |
1873 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
1871 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
1874 | 1872 | { |
1875 | 1873 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1876 | 1874 | } |
1877 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
1875 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
1878 | 1876 | |
1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1877 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1880 | 1878 | { |
1881 | 1879 | $sel_options['owner'][0] = lang('All participants'); |
1882 | 1880 | } |
@@ -1884,26 +1882,26 @@ discard block |
||
1884 | 1882 | { |
1885 | 1883 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
1886 | 1884 | } |
1887 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
1885 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
1888 | 1886 | { |
1889 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
1887 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
1890 | 1888 | { |
1891 | 1889 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
1892 | 1890 | } |
1893 | 1891 | } |
1894 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1892 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1895 | 1893 | if (!$event['id']) |
1896 | 1894 | { |
1897 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
1895 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
1898 | 1896 | } |
1899 | 1897 | if ($preserved['no_popup']) |
1900 | 1898 | { |
1901 | 1899 | // If not a popup, load the normal calendar interface on cancel |
1902 | - $etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1900 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1903 | 1901 | } |
1904 | 1902 | |
1905 | 1903 | // Allow admins to restore deleted events |
1906 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
1904 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
1907 | 1905 | { |
1908 | 1906 | $content['deleted'] = $preserved['deleted'] = null; |
1909 | 1907 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1915,7 +1913,7 @@ discard block |
||
1915 | 1913 | // Setup history tab |
1916 | 1914 | $this->setup_history($content, $sel_options); |
1917 | 1915 | |
1918 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
1916 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
1919 | 1917 | . (!$event['id'] ? lang('Add') |
1920 | 1918 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
1921 | 1919 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1925,15 +1923,15 @@ discard block |
||
1925 | 1923 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
1926 | 1924 | |
1927 | 1925 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1928 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1926 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1929 | 1927 | { |
1930 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1928 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1931 | 1929 | $content['button']['save'] = true; |
1932 | - $this->process_edit(array_merge($content,$preserved)); |
|
1930 | + $this->process_edit(array_merge($content, $preserved)); |
|
1933 | 1931 | } |
1934 | 1932 | else |
1935 | 1933 | { |
1936 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
1934 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
1937 | 1935 | } |
1938 | 1936 | } |
1939 | 1937 | |
@@ -1943,14 +1941,14 @@ discard block |
||
1943 | 1941 | * @param int $id |
1944 | 1942 | * @param string $token |
1945 | 1943 | */ |
1946 | - function ajax_unlock($id,$token) |
|
1944 | + function ajax_unlock($id, $token) |
|
1947 | 1945 | { |
1948 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
1946 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
1949 | 1947 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1950 | 1948 | |
1951 | 1949 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
1952 | 1950 | { |
1953 | - Vfs::unlock($lock_path,$token,false); |
|
1951 | + Vfs::unlock($lock_path, $token, false); |
|
1954 | 1952 | } |
1955 | 1953 | } |
1956 | 1954 | |
@@ -1962,17 +1960,17 @@ discard block |
||
1962 | 1960 | * are called by new mail-app; and we intend to use the stuff passed on by session |
1963 | 1961 | * @param string $msg = null |
1964 | 1962 | */ |
1965 | - function meeting(array $event=null, $msg=null) |
|
1963 | + function meeting(array $event = null, $msg = null) |
|
1966 | 1964 | { |
1967 | 1965 | $user = $GLOBALS['egw_info']['user']['account_id']; |
1968 | 1966 | $readonlys['button[apply]'] = true; |
1969 | - $_usesession=!is_array($event); |
|
1967 | + $_usesession = !is_array($event); |
|
1970 | 1968 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
1971 | 1969 | //are called by new mail-app; and we intend to use the stuff passed on by session |
1972 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
1970 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
1973 | 1971 | { |
1974 | - $event=null; // set to null |
|
1975 | - $_usesession=true; // trigger session read |
|
1972 | + $event = null; // set to null |
|
1973 | + $_usesession = true; // trigger session read |
|
1976 | 1974 | } |
1977 | 1975 | if (!is_array($event)) |
1978 | 1976 | { |
@@ -2002,7 +2000,7 @@ discard block |
||
2002 | 2000 | if (($existing_event = $this->bo->read($event['uid'], $event['recurrence'], false, 'ts', null, true)) && // true = read the exception |
2003 | 2001 | !$existing_event['deleted']) |
2004 | 2002 | { |
2005 | - switch(strtolower($ical_method)) |
|
2003 | + switch (strtolower($ical_method)) |
|
2006 | 2004 | { |
2007 | 2005 | case 'reply': |
2008 | 2006 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -2056,25 +2054,25 @@ discard block |
||
2056 | 2054 | } |
2057 | 2055 | else // event not in calendar |
2058 | 2056 | { |
2059 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2057 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2060 | 2058 | } |
2061 | 2059 | $event['participant_types'] = array(); |
2062 | - foreach($event['participants'] as $uid => $status) |
|
2060 | + foreach ($event['participants'] as $uid => $status) |
|
2063 | 2061 | { |
2064 | 2062 | $user_type = $user_id = null; |
2065 | 2063 | calendar_so::split_user($uid, $user_type, $user_id); |
2066 | 2064 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
2067 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2065 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2068 | 2066 | } |
2069 | 2067 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
2070 | 2068 | $event['recure'] = $this->bo->recure2string($event); |
2071 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
2069 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
2072 | 2070 | |
2073 | 2071 | // EGroupware event has been deleted, dont let user resurect it by accepting again |
2074 | 2072 | if ($existing_event && $existing_event['deleted'] && strtolower($ical_method) !== 'cancel') |
2075 | 2073 | { |
2076 | 2074 | // check if this is an EGroupware event or has an external organizer |
2077 | - foreach($existing_event['participants'] as $uid => $status) |
|
2075 | + foreach ($existing_event['participants'] as $uid => $status) |
|
2078 | 2076 | { |
2079 | 2077 | $quantity = $role = null; |
2080 | 2078 | calendar_so::split_status($status, $quantity, $role); |
@@ -2105,23 +2103,23 @@ discard block |
||
2105 | 2103 | // clear notification errors |
2106 | 2104 | notifications::errors(true); |
2107 | 2105 | |
2108 | - switch($button) |
|
2106 | + switch ($button) |
|
2109 | 2107 | { |
2110 | 2108 | case 'reject': |
2111 | 2109 | if (!$event['id']) |
2112 | 2110 | { |
2113 | 2111 | // send reply to organizer |
2114 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
2115 | - break; // no need to store rejected event |
|
2112 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
2113 | + break; // no need to store rejected event |
|
2116 | 2114 | } |
2117 | 2115 | // fall-through |
2118 | 2116 | case 'accept': |
2119 | 2117 | case 'tentativ': |
2120 | - $status = strtoupper($button[0]); // A, R or T |
|
2118 | + $status = strtoupper($button[0]); // A, R or T |
|
2121 | 2119 | if (!$event['id']) |
2122 | 2120 | { |
2123 | 2121 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
2124 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
2122 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
2125 | 2123 | { |
2126 | 2124 | // --> make organize a participant with role chair and current user the owner |
2127 | 2125 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2129,7 +2127,7 @@ discard block |
||
2129 | 2127 | $event['owner'] = $this->user; |
2130 | 2128 | } |
2131 | 2129 | // store event without notifications! |
2132 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2130 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2133 | 2131 | { |
2134 | 2132 | $msg[] = lang('Event saved'); |
2135 | 2133 | } |
@@ -2143,7 +2141,7 @@ discard block |
||
2143 | 2141 | elseif (self::event_changed($event, $event['old'])) |
2144 | 2142 | { |
2145 | 2143 | // check if we are allowed to update the event |
2146 | - if($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2144 | + if ($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2147 | 2145 | { |
2148 | 2146 | if ($event['recurrence'] && !$event['old']['reference'] && ($recur_event = $this->bo->read($event['id']))) |
2149 | 2147 | { |
@@ -2151,9 +2149,9 @@ discard block |
||
2151 | 2149 | $recur_event['recur_exception'][] = $event['recurrence']; |
2152 | 2150 | // check if we need to move the alarms, because they are next on that exception |
2153 | 2151 | $this->bo->check_move_alarms($recur_event, null, $event['recurrence']); |
2154 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2155 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2156 | - $this->bo->update($recur_event, $ignore_conflicts=true, true, false, true, $msg, true); |
|
2152 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2153 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2154 | + $this->bo->update($recur_event, $ignore_conflicts = true, true, false, true, $msg, true); |
|
2157 | 2155 | |
2158 | 2156 | // then we need to create the exception as new event |
2159 | 2157 | unset($event['id']); |
@@ -2168,7 +2166,7 @@ discard block |
||
2168 | 2166 | } |
2169 | 2167 | unset($event['old']); |
2170 | 2168 | |
2171 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2169 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2172 | 2170 | { |
2173 | 2171 | $msg[] = lang('Event saved'); |
2174 | 2172 | } |
@@ -2218,7 +2216,7 @@ discard block |
||
2218 | 2216 | Framework::message(implode("\n", (array)$msg)); |
2219 | 2217 | $readonlys['button[edit]'] = !$event['id']; |
2220 | 2218 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
2221 | - switch(strtolower($ical_method)) |
|
2219 | + switch (strtolower($ical_method)) |
|
2222 | 2220 | { |
2223 | 2221 | case 'reply': |
2224 | 2222 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2232,7 +2230,7 @@ discard block |
||
2232 | 2230 | break; |
2233 | 2231 | } |
2234 | 2232 | $tpl = new Etemplate('calendar.meeting'); |
2235 | - $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event+array( |
|
2233 | + $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event + array( |
|
2236 | 2234 | 'old' => $existing_event, |
2237 | 2235 | ), 2); |
2238 | 2236 | } |
@@ -2252,11 +2250,11 @@ discard block |
||
2252 | 2250 | 'recur_type', 'recur_data', 'recur_interval', 'recur_exception'); |
2253 | 2251 | |
2254 | 2252 | // only compare certain fields, taking account unset, null or '' values |
2255 | - $event = array_intersect_key($_event+array('recur_exception'=>array()), array_flip($keys_to_check)); |
|
2253 | + $event = array_intersect_key($_event + array('recur_exception'=>array()), array_flip($keys_to_check)); |
|
2256 | 2254 | $old = array_intersect_key(array_diff($_old, array(null, '')), array_flip($keys_to_check)); |
2257 | 2255 | |
2258 | 2256 | // keep the status of existing participants (users) |
2259 | - foreach($old['participants'] as $uid => $status) |
|
2257 | + foreach ($old['participants'] as $uid => $status) |
|
2260 | 2258 | { |
2261 | 2259 | if (is_numeric($uid) && $uid > 0) |
2262 | 2260 | { |
@@ -2276,37 +2274,37 @@ discard block |
||
2276 | 2274 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
2277 | 2275 | * @param array $preserv data to preserv |
2278 | 2276 | */ |
2279 | - function conflicts($event,$conflicts,$preserv) |
|
2277 | + function conflicts($event, $conflicts, $preserv) |
|
2280 | 2278 | { |
2281 | 2279 | $etpl = new Etemplate('calendar.conflicts'); |
2282 | 2280 | $allConflicts = array(); |
2283 | 2281 | |
2284 | - foreach($conflicts as $k => $conflict) |
|
2282 | + foreach ($conflicts as $k => $conflict) |
|
2285 | 2283 | { |
2286 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
2284 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
2287 | 2285 | |
2288 | 2286 | $conflicts[$k] += array( |
2289 | 2287 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
2290 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
2291 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
2292 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
2293 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
2294 | - ),true,true)), // show group invitations too |
|
2288 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
2289 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
2290 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
2291 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
2292 | + ), true, true)), // show group invitations too |
|
2295 | 2293 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
2296 | 2294 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
2297 | 2295 | ); |
2298 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
2296 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
2299 | 2297 | } |
2300 | 2298 | $content = $event + array( |
2301 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2299 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2302 | 2300 | ); |
2303 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
2301 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
2304 | 2302 | $resources_config = Api\Config::read('resources'); |
2305 | 2303 | $readonlys = array(); |
2306 | 2304 | |
2307 | 2305 | foreach (array_keys($allConflicts) as $pId) |
2308 | 2306 | { |
2309 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2307 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
2310 | 2308 | { |
2311 | 2309 | |
2312 | 2310 | switch ($resources_config['ignoreconflicts']) |
@@ -2326,7 +2324,7 @@ discard block |
||
2326 | 2324 | } |
2327 | 2325 | } |
2328 | 2326 | } |
2329 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
2327 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
2330 | 2328 | } |
2331 | 2329 | |
2332 | 2330 | /** |
@@ -2344,7 +2342,7 @@ discard block |
||
2344 | 2342 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
2345 | 2343 | |
2346 | 2344 | // convert start/end date-time values to timestamps |
2347 | - foreach(array('start', 'end') as $name) |
|
2345 | + foreach (array('start', 'end') as $name) |
|
2348 | 2346 | { |
2349 | 2347 | if (!empty($edit_content[$name])) |
2350 | 2348 | { |
@@ -2374,7 +2372,7 @@ discard block |
||
2374 | 2372 | 'recur_type' => $edit_content['recur_type'], |
2375 | 2373 | 'participants' => array(), |
2376 | 2374 | ); |
2377 | - foreach($edit_content['participants'] as $key => $data) |
|
2375 | + foreach ($edit_content['participants'] as $key => $data) |
|
2378 | 2376 | { |
2379 | 2377 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
2380 | 2378 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2389,21 +2387,21 @@ discard block |
||
2389 | 2387 | // default search parameters |
2390 | 2388 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
2391 | 2389 | $content['end_time'] = $this->cal_prefs['workdayends']; |
2392 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
2390 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
2393 | 2391 | { |
2394 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2392 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2395 | 2393 | } |
2396 | 2394 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
2397 | 2395 | |
2398 | 2396 | $content['search_window'] = 7 * DAY_s; |
2399 | 2397 | |
2400 | 2398 | // store content in session |
2401 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
2399 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
2402 | 2400 | |
2403 | 2401 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
2404 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
2402 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
2405 | 2403 | |
2406 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
2404 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
2407 | 2405 | |
2408 | 2406 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
2409 | 2407 | |
@@ -2426,26 +2424,26 @@ discard block |
||
2426 | 2424 | { |
2427 | 2425 | $etpl = new Etemplate('calendar.freetimesearch'); |
2428 | 2426 | $sel_options['search_window'] = array( |
2429 | - 7*DAY_s => lang('one week'), |
|
2430 | - 14*DAY_s => lang('two weeks'), |
|
2431 | - 31*DAY_s => lang('one month'), |
|
2432 | - 92*DAY_s => lang('three month'), |
|
2433 | - 365*DAY_s => lang('one year'), |
|
2427 | + 7 * DAY_s => lang('one week'), |
|
2428 | + 14 * DAY_s => lang('two weeks'), |
|
2429 | + 31 * DAY_s => lang('one month'), |
|
2430 | + 92 * DAY_s => lang('three month'), |
|
2431 | + 365 * DAY_s => lang('one year'), |
|
2434 | 2432 | ); |
2435 | 2433 | if (!is_array($content)) |
2436 | 2434 | { |
2437 | 2435 | // get content from session (and delete it immediatly) |
2438 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2439 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2436 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2437 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2440 | 2438 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
2441 | 2439 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
2442 | 2440 | $sTime = $content['start_time']; |
2443 | 2441 | $eTime = $content['end_time']; |
2444 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
2445 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
2442 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
2443 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
2446 | 2444 | |
2447 | 2445 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
2448 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
2446 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
2449 | 2447 | { |
2450 | 2448 | if ($window > $content['duration']) |
2451 | 2449 | { |
@@ -2472,19 +2470,19 @@ discard block |
||
2472 | 2470 | { |
2473 | 2471 | $content['msg'] .= lang('Only the initial date of that recurring event is checked!'); |
2474 | 2472 | } |
2475 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
2476 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
2473 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
2474 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
2477 | 2475 | |
2478 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
2476 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
2479 | 2477 | |
2480 | 2478 | $sel_options['duration'] = $this->durations; |
2481 | 2479 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
2482 | 2480 | |
2483 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
2481 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
2484 | 2482 | 'participants' => $content['participants'], |
2485 | 2483 | 'cal_id' => $content['cal_id'], |
2486 | 2484 | 'recur_type' => $content['recur_type'], |
2487 | - ),2); |
|
2485 | + ), 2); |
|
2488 | 2486 | } |
2489 | 2487 | |
2490 | 2488 | /** |
@@ -2497,15 +2495,15 @@ discard block |
||
2497 | 2495 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
2498 | 2496 | * @return array of free time-slots: array with start and end values |
2499 | 2497 | */ |
2500 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
2498 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
2501 | 2499 | { |
2502 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2500 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
2503 | 2501 | |
2504 | 2502 | $busy = $this->bo->search(array( |
2505 | 2503 | 'start' => $start, |
2506 | 2504 | 'end' => $end, |
2507 | 2505 | 'users' => $participants, |
2508 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2506 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2509 | 2507 | )); |
2510 | 2508 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
2511 | 2509 | 'start' => $end, |
@@ -2514,15 +2512,15 @@ discard block |
||
2514 | 2512 | $ft_start = $start; |
2515 | 2513 | $freetime = array(); |
2516 | 2514 | $n = 0; |
2517 | - foreach($busy as $event) |
|
2515 | + foreach ($busy as $event) |
|
2518 | 2516 | { |
2519 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2517 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2520 | 2518 | |
2521 | 2519 | if ($event['non_blocking']) continue; // ignore non_blocking events |
2522 | 2520 | |
2523 | 2521 | // check if from all wanted participants at least one has a not rejected status in found event |
2524 | 2522 | $non_rejected_found = false; |
2525 | - foreach($participants as $uid) |
|
2523 | + foreach ($participants as $uid) |
|
2526 | 2524 | { |
2527 | 2525 | $status = $event['participants'][$uid]; |
2528 | 2526 | $quantity = $role = null; |
@@ -2541,10 +2539,10 @@ discard block |
||
2541 | 2539 | |
2542 | 2540 | if ($this->debug) |
2543 | 2541 | { |
2544 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
2542 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
2545 | 2543 | echo "event[title]=$event[title]<br>\n"; |
2546 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
2547 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
2544 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
2545 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
2548 | 2546 | } |
2549 | 2547 | // $events ends before our actual position ==> ignore it |
2550 | 2548 | if ($event['end'] < $ft_start) |
@@ -2568,11 +2566,11 @@ discard block |
||
2568 | 2566 | 'start' => $ft_start, |
2569 | 2567 | 'end' => $ft_end, |
2570 | 2568 | ); |
2571 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2569 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
2572 | 2570 | } |
2573 | 2571 | $ft_start = $event['end']; |
2574 | 2572 | } |
2575 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2573 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
2576 | 2574 | |
2577 | 2575 | return $freetime; |
2578 | 2576 | } |
@@ -2592,46 +2590,46 @@ discard block |
||
2592 | 2590 | */ |
2593 | 2591 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2594 | 2592 | { |
2595 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2593 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
2596 | 2594 | |
2597 | 2595 | $freetime_daywise = array(); |
2598 | 2596 | if (!is_array($sel_options)) $sel_options = array(); |
2599 | 2597 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2600 | 2598 | |
2601 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
2602 | - $end_time = (int) $_end_time; |
|
2599 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
2600 | + $end_time = (int)$_end_time; |
|
2603 | 2601 | |
2604 | 2602 | // ignore the end_time, if duration would never fit |
2605 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
2603 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
2606 | 2604 | { |
2607 | 2605 | $end_time = 0; |
2608 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2606 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
2609 | 2607 | } |
2610 | 2608 | $n = 0; |
2611 | - foreach($freetime as $ft) |
|
2609 | + foreach ($freetime as $ft) |
|
2612 | 2610 | { |
2613 | 2611 | $adaybegin = $this->bo->date2array($ft['start']); |
2614 | 2612 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
2615 | 2613 | unset($adaybegin['raw']); |
2616 | 2614 | $daybegin = $this->bo->date2ts($adaybegin); |
2617 | 2615 | |
2618 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
2616 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
2619 | 2617 | { |
2620 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
2621 | - $mcal_dow = pow(2,$dow); |
|
2622 | - if (!($weekdays & $mcal_dow)) |
|
2618 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
2619 | + $mcal_dow = pow(2, $dow); |
|
2620 | + if (!($weekdays&$mcal_dow)) |
|
2623 | 2621 | { |
2624 | 2622 | //echo "wrong day of week $dow<br>\n"; |
2625 | - continue; // wrong day of week |
|
2623 | + continue; // wrong day of week |
|
2626 | 2624 | } |
2627 | 2625 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2628 | 2626 | |
2629 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2627 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
2630 | 2628 | { |
2631 | - $start = $daybegin + $start_time*HOUR_s; |
|
2629 | + $start = $daybegin + $start_time * HOUR_s; |
|
2632 | 2630 | } |
2633 | 2631 | // if end_time given use it, else the original slot's end |
2634 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
2632 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
2635 | 2633 | if ($end > $ft['end']) $end = $ft['end']; |
2636 | 2634 | |
2637 | 2635 | // slot to small for duration |
@@ -2645,11 +2643,11 @@ discard block |
||
2645 | 2643 | 'end' => $end, |
2646 | 2644 | ); |
2647 | 2645 | $times = array(); |
2648 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
2646 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
2649 | 2647 | { |
2650 | 2648 | $e = $s + $duration; |
2651 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
2652 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
2649 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
2650 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
2653 | 2651 | } |
2654 | 2652 | $sel_options[$n.'start'] = $times; |
2655 | 2653 | } |
@@ -2664,13 +2662,13 @@ discard block |
||
2664 | 2662 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
2665 | 2663 | * @return string error-msg if $return_error |
2666 | 2664 | */ |
2667 | - function export($content=0,$return_error=false) |
|
2665 | + function export($content = 0, $return_error = false) |
|
2668 | 2666 | { |
2669 | 2667 | $boical = new calendar_ical(); |
2670 | 2668 | #error_log(__METHOD__.print_r($content,true)); |
2671 | 2669 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
2672 | 2670 | { |
2673 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
2671 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
2674 | 2672 | { |
2675 | 2673 | $msg = lang('Permission denied'); |
2676 | 2674 | |
@@ -2678,20 +2676,20 @@ discard block |
||
2678 | 2676 | } |
2679 | 2677 | else |
2680 | 2678 | { |
2681 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
2679 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
2682 | 2680 | echo $ical; |
2683 | 2681 | common::egw_exit(); |
2684 | 2682 | } |
2685 | 2683 | } |
2686 | 2684 | if (is_array($content)) |
2687 | 2685 | { |
2688 | - $events =& $this->bo->search(array( |
|
2686 | + $events = & $this->bo->search(array( |
|
2689 | 2687 | 'start' => $content['start'], |
2690 | 2688 | 'end' => $content['end'], |
2691 | 2689 | 'enum_recuring' => false, |
2692 | 2690 | 'daywise' => false, |
2693 | 2691 | 'owner' => $this->owner, |
2694 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
2692 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
2695 | 2693 | )); |
2696 | 2694 | if (!$events) |
2697 | 2695 | { |
@@ -2699,8 +2697,8 @@ discard block |
||
2699 | 2697 | } |
2700 | 2698 | else |
2701 | 2699 | { |
2702 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
2703 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
2700 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
2701 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
2704 | 2702 | echo $ical; |
2705 | 2703 | common::egw_exit(); |
2706 | 2704 | } |
@@ -2716,9 +2714,9 @@ discard block |
||
2716 | 2714 | } |
2717 | 2715 | $content['msg'] = $msg; |
2718 | 2716 | |
2719 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
2717 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
2720 | 2718 | $etpl = new etemplate_new('calendar.export'); |
2721 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
2719 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
2722 | 2720 | } |
2723 | 2721 | |
2724 | 2722 | /** |
@@ -2726,7 +2724,7 @@ discard block |
||
2726 | 2724 | * |
2727 | 2725 | * @param array $_content |
2728 | 2726 | */ |
2729 | - function cat_acl(array $_content=null) |
|
2727 | + function cat_acl(array $_content = null) |
|
2730 | 2728 | { |
2731 | 2729 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
2732 | 2730 | { |
@@ -2738,15 +2736,15 @@ discard block |
||
2738 | 2736 | unset($_content['button']); |
2739 | 2737 | if ($button != 'cancel') // store changed Acl |
2740 | 2738 | { |
2741 | - foreach($_content as $data) |
|
2739 | + foreach ($_content as $data) |
|
2742 | 2740 | { |
2743 | 2741 | if (!($cat_id = $data['cat_id'])) continue; |
2744 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
2742 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
2745 | 2743 | { |
2746 | 2744 | $rights = 0; |
2747 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2748 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2749 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2745 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2746 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2747 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
2750 | 2748 | } |
2751 | 2749 | } |
2752 | 2750 | } |
@@ -2758,20 +2756,20 @@ discard block |
||
2758 | 2756 | ), 'admin'); |
2759 | 2757 | } |
2760 | 2758 | } |
2761 | - $content= $preserv = array(); |
|
2759 | + $content = $preserv = array(); |
|
2762 | 2760 | $n = 1; |
2763 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2761 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2764 | 2762 | { |
2765 | - $cat_id = substr($Lcat_id,1); |
|
2763 | + $cat_id = substr($Lcat_id, 1); |
|
2766 | 2764 | $row = array( |
2767 | 2765 | 'cat_id' => $cat_id, |
2768 | 2766 | 'add' => array(), |
2769 | 2767 | 'status' => array(), |
2770 | 2768 | ); |
2771 | - foreach($data as $account_id => $rights) |
|
2769 | + foreach ($data as $account_id => $rights) |
|
2772 | 2770 | { |
2773 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2774 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2771 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2772 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2775 | 2773 | } |
2776 | 2774 | $content[$n] = $row; |
2777 | 2775 | $preserv[$n] = array( |
@@ -2787,7 +2785,7 @@ discard block |
||
2787 | 2785 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
2788 | 2786 | $tmp = new Etemplate('calendar.cat_acl'); |
2789 | 2787 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
2790 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
2788 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
2791 | 2789 | } |
2792 | 2790 | |
2793 | 2791 | /** |
@@ -2837,18 +2835,18 @@ discard block |
||
2837 | 2835 | |
2838 | 2836 | |
2839 | 2837 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
2840 | - if($content['recur_type'] || $content['recurrence']) |
|
2838 | + if ($content['recur_type'] || $content['recurrence']) |
|
2841 | 2839 | { |
2842 | 2840 | $content['history']['filter'] = array( |
2843 | 2841 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
2844 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
2845 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
2842 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
2843 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
2846 | 2844 | ); |
2847 | 2845 | } |
2848 | 2846 | |
2849 | 2847 | // Translate labels |
2850 | 2848 | $tracking = new calendar_tracking(); |
2851 | - foreach($tracking->field2label as $field => $label) |
|
2849 | + foreach ($tracking->field2label as $field => $label) |
|
2852 | 2850 | { |
2853 | 2851 | $sel_options[$status][$field] = lang($label); |
2854 | 2852 | } |
@@ -2867,44 +2865,44 @@ discard block |
||
2867 | 2865 | * which particular instance was dragged |
2868 | 2866 | * @return string XML response if no error occurs |
2869 | 2867 | */ |
2870 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
2868 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
2871 | 2869 | { |
2872 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
2870 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
2873 | 2871 | $ignore_conflicts = false; |
2874 | 2872 | |
2875 | 2873 | // we do not allow dragging into another users calendar ATM |
2876 | - if($targetOwner < 0) |
|
2874 | + if ($targetOwner < 0) |
|
2877 | 2875 | { |
2878 | 2876 | $targetOwner = array($targetOwner); |
2879 | 2877 | } |
2880 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2878 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2881 | 2879 | { |
2882 | 2880 | $targetOwner = $calendarOwner; |
2883 | 2881 | } |
2884 | 2882 | // But you may be viewing multiple users, or a group calendar and |
2885 | 2883 | // dragging your event - dragging across calendars does not change owner |
2886 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2884 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2887 | 2885 | { |
2888 | 2886 | $return = true; |
2889 | - foreach($targetOwner as $owner) |
|
2887 | + foreach ($targetOwner as $owner) |
|
2890 | 2888 | { |
2891 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
2889 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
2892 | 2890 | { |
2893 | 2891 | $return = false; |
2894 | 2892 | break; |
2895 | 2893 | } |
2896 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
2894 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
2897 | 2895 | { |
2898 | 2896 | $return = false; |
2899 | 2897 | break; |
2900 | 2898 | } |
2901 | 2899 | } |
2902 | - if($return) return; |
|
2900 | + if ($return) return; |
|
2903 | 2901 | } |
2904 | - $old_event=$event=$this->bo->read($eventId); |
|
2902 | + $old_event = $event = $this->bo->read($eventId); |
|
2905 | 2903 | if (!$durationT) |
2906 | 2904 | { |
2907 | - $duration=$event['end']-$event['start']; |
|
2905 | + $duration = $event['end'] - $event['start']; |
|
2908 | 2906 | } |
2909 | 2907 | // Drag a normal event to whole day non-blocking |
2910 | 2908 | else if ($durationT == 'whole_day') |
@@ -2912,7 +2910,7 @@ discard block |
||
2912 | 2910 | $event['whole_day'] = true; |
2913 | 2911 | $event['non_blocking'] = true; |
2914 | 2912 | // Make duration whole days, less 1 second |
2915 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
2913 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
2916 | 2914 | } |
2917 | 2915 | else |
2918 | 2916 | { |
@@ -2925,19 +2923,19 @@ discard block |
||
2925 | 2923 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
2926 | 2924 | if (!empty($event['whole_day'])) |
2927 | 2925 | { |
2928 | - $d =& $this->bo->so->startOfDay($d); |
|
2926 | + $d = & $this->bo->so->startOfDay($d); |
|
2929 | 2927 | $d->setUser(); |
2930 | 2928 | } |
2931 | 2929 | $event = $this->bo->read($eventId, $d, true); |
2932 | 2930 | |
2933 | 2931 | // For DnD, create an exception if they gave the date |
2934 | 2932 | $preserv = null; |
2935 | - $this->_create_exception($event,$preserv); |
|
2933 | + $this->_create_exception($event, $preserv); |
|
2936 | 2934 | unset($event['id']); |
2937 | 2935 | $links = $event['link_to']['to_id']; |
2938 | 2936 | |
2939 | 2937 | $messages = null; |
2940 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
2938 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
2941 | 2939 | if (!is_array($conflicts) && $conflicts) |
2942 | 2940 | { |
2943 | 2941 | // now we need to add the original start as recur-execption to the series |
@@ -2945,28 +2943,28 @@ discard block |
||
2945 | 2943 | $recur_event['recur_exception'][] = $d->format('ts'); |
2946 | 2944 | // check if we need to move the alarms, because they are next on that exception |
2947 | 2945 | $this->bo->check_move_alarms($recur_event, null, $d); |
2948 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2949 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2950 | - $this->bo->update($recur_event,true); // no conflict check here |
|
2946 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2947 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2948 | + $this->bo->update($recur_event, true); // no conflict check here |
|
2951 | 2949 | |
2952 | 2950 | // Sending null will trigger a removal of the original for that date |
2953 | 2951 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
2954 | 2952 | |
2955 | 2953 | unset($recur_event); |
2956 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
2954 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
2957 | 2955 | unset($preserv['edit_single']); |
2958 | 2956 | } |
2959 | 2957 | } |
2960 | 2958 | |
2961 | 2959 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
2962 | 2960 | $event['start'] = $d->format('ts'); |
2963 | - $event['end'] = $event['start']+$duration; |
|
2961 | + $event['end'] = $event['start'] + $duration; |
|
2964 | 2962 | |
2965 | 2963 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
2966 | 2964 | { |
2967 | 2965 | // calculate offset against clicked recurrance, |
2968 | 2966 | // depending on which is smaller |
2969 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
2967 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
2970 | 2968 | $event['start'] = $old_event['start'] + $offset; |
2971 | 2969 | $event['duration'] = $duration; |
2972 | 2970 | |
@@ -2977,31 +2975,31 @@ discard block |
||
2977 | 2975 | // Can't handle conflict. Just ignore it. |
2978 | 2976 | $ignore_conflicts = true; |
2979 | 2977 | } |
2980 | - if(!$event['recur_type']) |
|
2978 | + if (!$event['recur_type']) |
|
2981 | 2979 | { |
2982 | 2980 | $this->bo->check_move_alarms($event, $old_event); |
2983 | 2981 | } |
2984 | 2982 | |
2985 | 2983 | // Drag a whole day to a time |
2986 | - if($durationT && $durationT != 'whole_day') |
|
2984 | + if ($durationT && $durationT != 'whole_day') |
|
2987 | 2985 | { |
2988 | 2986 | $event['whole_day'] = ($duration == DAY_s); |
2989 | 2987 | $event['non_blocking'] = false; |
2990 | 2988 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
2991 | 2989 | // so save the change now, and then let the conflict check happen. |
2992 | 2990 | $message = null; |
2993 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
2991 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
2994 | 2992 | |
2995 | 2993 | // Whole day non blocking with DAY_s would add a day |
2996 | - if($duration==DAY_s) $duration=0; |
|
2994 | + if ($duration == DAY_s) $duration = 0; |
|
2997 | 2995 | } |
2998 | 2996 | |
2999 | 2997 | $status_reset_to_unknown = false; |
3000 | 2998 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
3001 | - foreach((array)$event['participants'] as $uid => $status) |
|
2999 | + foreach ((array)$event['participants'] as $uid => $status) |
|
3002 | 3000 | { |
3003 | 3001 | $q = $r = null; |
3004 | - calendar_so::split_status($status,$q,$r); |
|
3002 | + calendar_so::split_status($status, $q, $r); |
|
3005 | 3003 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
3006 | 3004 | { |
3007 | 3005 | $preferences = new Api\Preferences($uid); |
@@ -3014,29 +3012,29 @@ discard block |
||
3014 | 3012 | if ($sameday) break; |
3015 | 3013 | default: |
3016 | 3014 | $status_reset_to_unknown = true; |
3017 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
3015 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
3018 | 3016 | // todo: report reset status to user |
3019 | 3017 | } |
3020 | 3018 | } |
3021 | 3019 | } |
3022 | 3020 | |
3023 | 3021 | $message = false; |
3024 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
3022 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
3025 | 3023 | |
3026 | 3024 | // Save links |
3027 | - if($links) |
|
3025 | + if ($links) |
|
3028 | 3026 | { |
3029 | 3027 | Link::link('calendar', $event['id'], $links); |
3030 | 3028 | } |
3031 | 3029 | |
3032 | - $this->update_client($event['id'],$d); |
|
3030 | + $this->update_client($event['id'], $d); |
|
3033 | 3031 | $response = Api\Json\Response::get(); |
3034 | - if(!is_array($conflicts) && $conflicts) |
|
3032 | + if (!is_array($conflicts) && $conflicts) |
|
3035 | 3033 | { |
3036 | - if(is_int($conflicts)) |
|
3034 | + if (is_int($conflicts)) |
|
3037 | 3035 | { |
3038 | 3036 | $event['id'] = $conflicts; |
3039 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3037 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3040 | 3038 | } |
3041 | 3039 | } |
3042 | 3040 | else if ($conflicts) |
@@ -3049,21 +3047,21 @@ discard block |
||
3049 | 3047 | .'&end='.$event['end'] |
3050 | 3048 | .'&non_interactive=true' |
3051 | 3049 | .'&cancel_needs_refresh=true', |
3052 | - '',750,410); |
|
3050 | + '', 750, 410); |
|
3053 | 3051 | } |
3054 | 3052 | else if ($message) |
3055 | 3053 | { |
3056 | - $response->call('egw.message', implode('<br />', $message)); |
|
3054 | + $response->call('egw.message', implode('<br />', $message)); |
|
3057 | 3055 | } |
3058 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
3056 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
3059 | 3057 | if ($status_reset_to_unknown) |
3060 | 3058 | { |
3061 | - foreach((array)$event['participants'] as $uid => $status) |
|
3059 | + foreach ((array)$event['participants'] as $uid => $status) |
|
3062 | 3060 | { |
3063 | 3061 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
3064 | 3062 | { |
3065 | - calendar_so::split_status($status,$q,$r); |
|
3066 | - $status = calendar_so::combine_status('U',$q,$r); |
|
3063 | + calendar_so::split_status($status, $q, $r); |
|
3064 | + $status = calendar_so::combine_status('U', $q, $r); |
|
3067 | 3065 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
3068 | 3066 | } |
3069 | 3067 | } |
@@ -3080,7 +3078,7 @@ discard block |
||
3080 | 3078 | { |
3081 | 3079 | list($eventId, $date) = explode(':', $_eventId); |
3082 | 3080 | $event = $this->bo->read($eventId); |
3083 | - if($date) |
|
3081 | + if ($date) |
|
3084 | 3082 | { |
3085 | 3083 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3086 | 3084 | } |
@@ -3090,29 +3088,29 @@ discard block |
||
3090 | 3088 | { |
3091 | 3089 | if (!empty($event['whole_day'])) |
3092 | 3090 | { |
3093 | - $d =& $this->bo->so->startOfDay($date); |
|
3091 | + $d = & $this->bo->so->startOfDay($date); |
|
3094 | 3092 | $d->setUser(); |
3095 | 3093 | } |
3096 | 3094 | $event = $this->bo->read($eventId, $d, true); |
3097 | 3095 | $date = $d->format('ts'); |
3098 | 3096 | } |
3099 | - if($event['participants'][$uid]) |
|
3097 | + if ($event['participants'][$uid]) |
|
3100 | 3098 | { |
3101 | 3099 | $q = $r = null; |
3102 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3103 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3104 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3100 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3101 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3102 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3105 | 3103 | } |
3106 | 3104 | else |
3107 | 3105 | { |
3108 | 3106 | // Group membership |
3109 | - foreach(array_keys($event['participants']) as $id) |
|
3107 | + foreach (array_keys($event['participants']) as $id) |
|
3110 | 3108 | { |
3111 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
3109 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
3112 | 3110 | { |
3113 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3114 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3115 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3111 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3112 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3113 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3116 | 3114 | break; |
3117 | 3115 | } |
3118 | 3116 | } |
@@ -3120,7 +3118,7 @@ discard block |
||
3120 | 3118 | |
3121 | 3119 | // Directly update stored data. If event is still visible, it will |
3122 | 3120 | // be notified & update itself. |
3123 | - $this->update_client($eventId,$d); |
|
3121 | + $this->update_client($eventId, $d); |
|
3124 | 3122 | } |
3125 | 3123 | |
3126 | 3124 | /** |
@@ -3128,8 +3126,8 @@ discard block |
||
3128 | 3126 | */ |
3129 | 3127 | public function ajax_delete($eventId) |
3130 | 3128 | { |
3131 | - list($id, $date) = explode(':',$eventId); |
|
3132 | - $event=$this->bo->read($id); |
|
3129 | + list($id, $date) = explode(':', $eventId); |
|
3130 | + $event = $this->bo->read($id); |
|
3133 | 3131 | $response = Api\Json\Response::get(); |
3134 | 3132 | |
3135 | 3133 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -3142,11 +3140,11 @@ discard block |
||
3142 | 3140 | { |
3143 | 3141 | $msg = lang('Event deleted'); |
3144 | 3142 | } |
3145 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
3143 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
3146 | 3144 | } |
3147 | 3145 | else |
3148 | 3146 | { |
3149 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
3147 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
3150 | 3148 | } |
3151 | 3149 | } |
3152 | 3150 | |
@@ -3159,10 +3157,10 @@ discard block |
||
3159 | 3157 | */ |
3160 | 3158 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
3161 | 3159 | { |
3162 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
3160 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
3163 | 3161 | |
3164 | 3162 | $event = $this->bo->read($eventId); |
3165 | - if($date) |
|
3163 | + if ($date) |
|
3166 | 3164 | { |
3167 | 3165 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3168 | 3166 | } |
@@ -3172,17 +3170,17 @@ discard block |
||
3172 | 3170 | { |
3173 | 3171 | if (!empty($event['whole_day'])) |
3174 | 3172 | { |
3175 | - $d =& $this->bo->so->startOfDay($date); |
|
3173 | + $d = & $this->bo->so->startOfDay($date); |
|
3176 | 3174 | $d->setUser(); |
3177 | 3175 | } |
3178 | 3176 | $event = $this->bo->read($eventId, $d, true); |
3179 | 3177 | // For DnD, create an exception if they gave the date |
3180 | 3178 | $preserv = null; |
3181 | - $this->_create_exception($event,$preserv); |
|
3179 | + $this->_create_exception($event, $preserv); |
|
3182 | 3180 | unset($event['id']); |
3183 | 3181 | |
3184 | 3182 | $messages = null; |
3185 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
3183 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
3186 | 3184 | if (!is_array($conflicts) && $conflicts) |
3187 | 3185 | { |
3188 | 3186 | // now we need to add the original start as recur-execption to the series |
@@ -3190,28 +3188,28 @@ discard block |
||
3190 | 3188 | $recur_event['recur_exception'][] = $d->format('ts'); |
3191 | 3189 | // check if we need to move the alarms, because they are next on that exception |
3192 | 3190 | $this->bo->check_move_alarms($recur_event, null, $d); |
3193 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3194 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3195 | - $this->bo->update($recur_event,true); // no conflict check here |
|
3191 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3192 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3193 | + $this->bo->update($recur_event, true); // no conflict check here |
|
3196 | 3194 | |
3197 | 3195 | // Sending null will trigger a removal of the original for that date |
3198 | 3196 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
3199 | 3197 | |
3200 | 3198 | unset($recur_event); |
3201 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3199 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3202 | 3200 | unset($preserv['edit_single']); |
3203 | 3201 | } |
3204 | 3202 | } |
3205 | - foreach($remove as $participant) |
|
3203 | + foreach ($remove as $participant) |
|
3206 | 3204 | { |
3207 | 3205 | unset($event['participants'][$participant]); |
3208 | 3206 | } |
3209 | - foreach($invite as $participant) |
|
3207 | + foreach ($invite as $participant) |
|
3210 | 3208 | { |
3211 | 3209 | $event['participants'][$participant] = 'U'; |
3212 | 3210 | } |
3213 | 3211 | $message = null; |
3214 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
3212 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
3215 | 3213 | |
3216 | 3214 | $response = Api\Json\Response::get(); |
3217 | 3215 | |
@@ -3219,8 +3217,8 @@ discard block |
||
3219 | 3217 | { |
3220 | 3218 | // Save it anyway, was done with explicit user interaction, |
3221 | 3219 | // and if we don't we lose the invite |
3222 | - $this->bo->update($event,true); // no conflict check here |
|
3223 | - $this->update_client($event['id'],$d); |
|
3220 | + $this->bo->update($event, true); // no conflict check here |
|
3221 | + $this->update_client($event['id'], $d); |
|
3224 | 3222 | $response->call( |
3225 | 3223 | 'egw_openWindowCentered2', |
3226 | 3224 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3229,22 +3227,22 @@ discard block |
||
3229 | 3227 | .'&end='.$event['end'] |
3230 | 3228 | .'&non_interactive=true' |
3231 | 3229 | .'&cancel_needs_refresh=true', |
3232 | - '',750,410); |
|
3230 | + '', 750, 410); |
|
3233 | 3231 | } |
3234 | 3232 | else if ($message) |
3235 | 3233 | { |
3236 | - $response->call('egw.message', implode('<br />', $message)); |
|
3234 | + $response->call('egw.message', implode('<br />', $message)); |
|
3237 | 3235 | } |
3238 | - if($conflicts) |
|
3236 | + if ($conflicts) |
|
3239 | 3237 | { |
3240 | - $this->update_client($event['id'],$d); |
|
3241 | - if(is_int($conflicts)) |
|
3238 | + $this->update_client($event['id'], $d); |
|
3239 | + if (is_int($conflicts)) |
|
3242 | 3240 | { |
3243 | 3241 | $event['id'] = $conflicts; |
3244 | 3242 | } |
3245 | - if($event['id']) |
|
3243 | + if ($event['id']) |
|
3246 | 3244 | { |
3247 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3245 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3248 | 3246 | } |
3249 | 3247 | } |
3250 | 3248 | } |
@@ -3255,13 +3253,13 @@ discard block |
||
3255 | 3253 | * @param array $mailContent = null mail content |
3256 | 3254 | * @return array |
3257 | 3255 | */ |
3258 | - function mail_import(array $mailContent=null) |
|
3256 | + function mail_import(array $mailContent = null) |
|
3259 | 3257 | { |
3260 | 3258 | // It would get called from compose as a popup with egw_data |
3261 | 3259 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
3262 | 3260 | { |
3263 | 3261 | // get raw mail data |
3264 | - Link::get_data ($_GET['egw_data']); |
|
3262 | + Link::get_data($_GET['egw_data']); |
|
3265 | 3263 | return false; |
3266 | 3264 | } |
3267 | 3265 | |
@@ -3271,7 +3269,7 @@ discard block |
||
3271 | 3269 | $AB = new Api\Contacts(); |
3272 | 3270 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
3273 | 3271 | |
3274 | - $participants[0] = array ( |
|
3272 | + $participants[0] = array( |
|
3275 | 3273 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
3276 | 3274 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
3277 | 3275 | 'status' => 'A', |
@@ -3279,23 +3277,23 @@ discard block |
||
3279 | 3277 | 'app' => 'User', |
3280 | 3278 | 'role' => 'REQ-PARTICIPANT' |
3281 | 3279 | ); |
3282 | - foreach($mailContent['addresses'] as $address) |
|
3280 | + foreach ($mailContent['addresses'] as $address) |
|
3283 | 3281 | { |
3284 | 3282 | // Get available contacts from the email |
3285 | 3283 | $contacts = $AB->search(array( |
3286 | 3284 | 'email' => $address['email'], |
3287 | 3285 | 'email_home' => $address['email'] |
3288 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
3286 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
3289 | 3287 | if (is_array($contacts)) |
3290 | 3288 | { |
3291 | - foreach($contacts as $account) |
|
3289 | + foreach ($contacts as $account) |
|
3292 | 3290 | { |
3293 | 3291 | $accounts[] = $account['account_id']; |
3294 | 3292 | } |
3295 | 3293 | } |
3296 | 3294 | else |
3297 | 3295 | { |
3298 | - $participants []= array ( |
|
3296 | + $participants [] = array( |
|
3299 | 3297 | 'app' => 'email', |
3300 | 3298 | 'uid' => 'e'.$address['email'], |
3301 | 3299 | 'status' => 'U', |
@@ -3303,7 +3301,7 @@ discard block |
||
3303 | 3301 | ); |
3304 | 3302 | } |
3305 | 3303 | } |
3306 | - $participants = array_merge($participants , array( |
|
3304 | + $participants = array_merge($participants, array( |
|
3307 | 3305 | "participant" => $accounts, |
3308 | 3306 | "role" => "REQ-PARTICIPANT", |
3309 | 3307 | "add" => "pressed" |
@@ -3327,14 +3325,14 @@ discard block |
||
3327 | 3325 | { |
3328 | 3326 | foreach ($mailContent['attachments'] as $attachment) |
3329 | 3327 | { |
3330 | - if($attachment['egw_data']) |
|
3328 | + if ($attachment['egw_data']) |
|
3331 | 3329 | { |
3332 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
3330 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
3333 | 3331 | } |
3334 | - else if(is_readable($attachment['tmp_name']) || |
|
3332 | + else if (is_readable($attachment['tmp_name']) || |
|
3335 | 3333 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
3336 | 3334 | { |
3337 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
3335 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
3338 | 3336 | } |
3339 | 3337 | } |
3340 | 3338 | } |