@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for calendar |
19 | 19 | */ |
20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
20 | +class calendar_import_csv extends importexport_basic_import_csv { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * actions wich could be done to data entries |
24 | 24 | */ |
25 | - protected static $actions = array( 'none', 'update', 'insert' ); |
|
25 | + protected static $actions = array('none', 'update', 'insert'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * conditions for actions |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Set up tracker |
46 | 46 | */ |
47 | - protected function init(importexport_definition &$definition) |
|
47 | + protected function init(importexport_definition&$definition) |
|
48 | 48 | { |
49 | 49 | // fetch the addressbook bo |
50 | - $this->bo= new calendar_boupdate(); |
|
50 | + $this->bo = new calendar_boupdate(); |
|
51 | 51 | |
52 | 52 | // Get the tracker for changes |
53 | 53 | $this->tracking = new calendar_tracking(); |
54 | 54 | |
55 | 55 | // Used for participants |
56 | - $this->status_map = array_flip(array_map('lang',$this->bo->verbose_status)); |
|
56 | + $this->status_map = array_flip(array_map('lang', $this->bo->verbose_status)); |
|
57 | 57 | $this->role_map = array_flip($this->bo->roles); |
58 | 58 | |
59 | 59 | $this->lookups = array( |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return boolean success |
78 | 78 | */ |
79 | - public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
|
79 | + public function import_record(\importexport_iface_egw_record&$record, &$import_csv) |
|
80 | 80 | { |
81 | 81 | // set eventOwner |
82 | - $options =& $this->definition->plugin_options; |
|
82 | + $options = & $this->definition->plugin_options; |
|
83 | 83 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
84 | 84 | |
85 | 85 | // Set owner, unless it's supposed to come from CSV file |
86 | - if($options['owner_from_csv']) { |
|
87 | - if(!is_numeric($record['owner'])) { |
|
86 | + if ($options['owner_from_csv']) { |
|
87 | + if (!is_numeric($record['owner'])) { |
|
88 | 88 | $this->errors[$import_csv->get_current_position()] = lang( |
89 | 89 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
90 | 90 | $record->owner, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Handle errors in length or start/end date |
102 | - if($record->start > $record->end) |
|
102 | + if ($record->start > $record->end) |
|
103 | 103 | { |
104 | 104 | $record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60; |
105 | 105 | $this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!'); |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | if ($record->participants && !is_array($record->participants)) { |
110 | 110 | // Importing participants in human friendly format: |
111 | 111 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
112 | - preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
|
112 | + preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants); |
|
113 | 113 | $p_participants = array(); |
114 | 114 | $missing = array(); |
115 | 115 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
116 | - foreach($names as $key => $name) { |
|
116 | + foreach ($names as $key => $name) { |
|
117 | 117 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
118 | 118 | |
119 | 119 | // Search for direct account name, then user in accounts first |
@@ -121,26 +121,26 @@ discard block |
||
121 | 121 | $id = importexport_helper_functions::account_name2id($name); |
122 | 122 | |
123 | 123 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | - $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
|
126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
124 | + if (!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | + $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1)); |
|
126 | + if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
127 | 127 | } |
128 | - if(!$id) |
|
128 | + if (!$id) |
|
129 | 129 | { |
130 | 130 | // Use calendar's registered resources to find participant |
131 | - foreach($this->bo->resources as $resource) |
|
131 | + foreach ($this->bo->resources as $resource) |
|
132 | 132 | { |
133 | 133 | // Can't search for email |
134 | - if($resource['app'] == 'email') continue; |
|
134 | + if ($resource['app'] == 'email') continue; |
|
135 | 135 | // Special resource search, since it does special stuff in link_query |
136 | - if($resource['app'] == 'resources') |
|
136 | + if ($resource['app'] == 'resources') |
|
137 | 137 | { |
138 | - if(!$this->resource_so) |
|
138 | + if (!$this->resource_so) |
|
139 | 139 | { |
140 | 140 | $this->resource_so = new resources_so(); |
141 | 141 | } |
142 | - $result = $this->resource_so->search($search,'res_id'); |
|
143 | - if(count($result) >= 1) { |
|
142 | + $result = $this->resource_so->search($search, 'res_id'); |
|
143 | + if (count($result) >= 1) { |
|
144 | 144 | $id = $resource['type'].$result[0]['res_id']; |
145 | 145 | break; |
146 | 146 | } |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | $link_options = array(); |
152 | 152 | $result = Link::query($resource['app'], $search, $link_options); |
153 | 153 | |
154 | - if($result) |
|
154 | + if ($result) |
|
155 | 155 | { |
156 | - $id = $resource['type'] . key($result); |
|
156 | + $id = $resource['type'].key($result); |
|
157 | 157 | break; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | - if($id) { |
|
162 | + if ($id) { |
|
163 | 163 | $p_participants[$id] = calendar_so::combine_status( |
164 | 164 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
165 | 165 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -170,47 +170,47 @@ discard block |
||
170 | 170 | { |
171 | 171 | $missing[] = $name; |
172 | 172 | } |
173 | - if(count($missing) > 0) |
|
173 | + if (count($missing) > 0) |
|
174 | 174 | { |
175 | - $this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' . |
|
176 | - lang('Contact not found!') . '<br />'.implode(", ",$missing); |
|
175 | + $this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '. |
|
176 | + lang('Contact not found!').'<br />'.implode(", ", $missing); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | $record->participants = $p_participants; |
180 | 180 | } |
181 | 181 | |
182 | - if($record->recurrence) |
|
182 | + if ($record->recurrence) |
|
183 | 183 | { |
184 | - list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2); |
|
184 | + list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2); |
|
185 | 185 | $record->recur_interval = trim($record->recur_interval); |
186 | - $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence'])); |
|
186 | + $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence'])); |
|
187 | 187 | unset($record->recurrence); |
188 | 188 | } |
189 | 189 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
190 | 190 | |
191 | - if ( $options['conditions'] ) { |
|
192 | - foreach ( $options['conditions'] as $condition ) { |
|
191 | + if ($options['conditions']) { |
|
192 | + foreach ($options['conditions'] as $condition) { |
|
193 | 193 | $records = array(); |
194 | - switch ( $condition['type'] ) { |
|
194 | + switch ($condition['type']) { |
|
195 | 195 | // exists |
196 | 196 | case 'exists' : |
197 | 197 | // Check for that record |
198 | 198 | $result = $this->exists($record, $condition, $records); |
199 | 199 | |
200 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
200 | + if (is_array($records) && count($records) >= 1) { |
|
201 | 201 | // apply action to all records matching this exists condition |
202 | 202 | $action = $condition['true']; |
203 | - foreach ( (array)$records as $event ) { |
|
203 | + foreach ((array)$records as $event) { |
|
204 | 204 | $record->id = $event['id']; |
205 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
206 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
207 | - $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
|
205 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
206 | + if (!is_array($record->category)) $record->category = explode(',', $record->category); |
|
207 | + $record->category = implode(',', array_unique(array_merge($record->category, $event['category']))); |
|
208 | 208 | } |
209 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
209 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
210 | 210 | } |
211 | 211 | } else { |
212 | 212 | $action = $condition['false']; |
213 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
213 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
214 | 214 | } |
215 | 215 | break; |
216 | 216 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | } else { |
225 | 225 | // unconditional insert |
226 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
226 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $success; |
@@ -238,14 +238,14 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
241 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array()) |
|
242 | 242 | { |
243 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
243 | + if ($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
244 | 244 | $event = $this->bo->read($record->__get($condition['string'])); |
245 | 245 | $records = array($event); |
246 | 246 | } |
247 | 247 | |
248 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
248 | + if (is_array($records) && count($records) >= 1) { |
|
249 | 249 | return true; |
250 | 250 | } |
251 | 251 | return false; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param array $_data record data for the action |
259 | 259 | * @return bool success or not |
260 | 260 | */ |
261 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
261 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) |
|
262 | 262 | { |
263 | 263 | $_data = $record->get_record_array(); |
264 | 264 | switch ($_action) { |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $old = $this->bo->read($_data['id']); |
270 | 270 | |
271 | 271 | // Don't change a user account into a record |
272 | - if(!$this->definition->plugin_options['change_owner']) { |
|
272 | + if (!$this->definition->plugin_options['change_owner']) { |
|
273 | 273 | // Don't change owner of an existing record |
274 | 274 | unset($_data['owner']); |
275 | 275 | } |
@@ -277,30 +277,30 @@ discard block |
||
277 | 277 | // Merge to deal with fields not in import record |
278 | 278 | $_data = array_merge($old, $_data); |
279 | 279 | $changed = $this->tracking->changed_fields($_data, $old); |
280 | - if(count($changed) == 0) { |
|
280 | + if (count($changed) == 0) { |
|
281 | 281 | return true; |
282 | 282 | } |
283 | 283 | // Fall through |
284 | 284 | case 'insert' : |
285 | - if($_action == 'insert') { |
|
285 | + if ($_action == 'insert') { |
|
286 | 286 | // Backend doesn't like inserting with ID specified, can overwrite existing |
287 | 287 | unset($_data['id']); |
288 | 288 | } |
289 | 289 | // Make sure participants are set |
290 | - if(!$_data['participants']) { |
|
290 | + if (!$_data['participants']) { |
|
291 | 291 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
292 | 292 | $_data['participants'] = array( |
293 | 293 | $user => 'U' |
294 | 294 | ); |
295 | 295 | } |
296 | - if ( $this->dry_run ) { |
|
296 | + if ($this->dry_run) { |
|
297 | 297 | //print_r($_data); |
298 | 298 | // User is interested in conflict checks, do so for dry run |
299 | 299 | // Otherwise, conflicts are just ignored and imported anyway |
300 | - if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
300 | + if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
301 | 301 | { |
302 | 302 | $conflicts = $this->bo->conflicts($_data); |
303 | - if($conflicts) |
|
303 | + if ($conflicts) |
|
304 | 304 | { |
305 | 305 | $this->conflict_warning($record_num, $conflicts); |
306 | 306 | $this->results['skipped']++; |
@@ -311,15 +311,15 @@ discard block |
||
311 | 311 | return true; |
312 | 312 | } else { |
313 | 313 | $messages = null; |
314 | - $result = $this->bo->update( $_data, |
|
314 | + $result = $this->bo->update($_data, |
|
315 | 315 | !$this->definition->plugin_options['skip_conflicts'], |
316 | 316 | true, $this->is_admin, true, $messages, |
317 | 317 | $this->definition->plugin_options['no_notification'] |
318 | 318 | ); |
319 | - if(!$result) |
|
319 | + if (!$result) |
|
320 | 320 | { |
321 | - $this->errors[$record_num] = lang('Unable to save') . "\n" . |
|
322 | - implode("\n",$messages); |
|
321 | + $this->errors[$record_num] = lang('Unable to save')."\n". |
|
322 | + implode("\n", $messages); |
|
323 | 323 | } |
324 | 324 | else if (is_array($result)) |
325 | 325 | { |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | */ |
350 | 350 | protected function conflict_warning($record_num, &$conflicts) |
351 | 351 | { |
352 | - $this->warnings[$record_num] = lang('Conflicts') . ':'; |
|
353 | - foreach($conflicts as $conflict) |
|
352 | + $this->warnings[$record_num] = lang('Conflicts').':'; |
|
353 | + foreach ($conflicts as $conflict) |
|
354 | 354 | { |
355 | - $this->warnings[$record_num] .= "<br />\n" . egw_time::to($conflict['start']) . "\t" . $conflict['title']; |
|
355 | + $this->warnings[$record_num] .= "<br />\n".egw_time::to($conflict['start'])."\t".$conflict['title']; |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param egw_record $row_entry |
390 | 390 | */ |
391 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
391 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
392 | 392 | { |
393 | - $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true)); |
|
393 | + $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true)); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | } // end of iface_export_plugin |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // types of messsages send by calendar_boupdate::send_update |
15 | -define('MSG_DELETED',0); |
|
16 | -define('MSG_MODIFIED',1); |
|
17 | -define('MSG_ADDED',2); |
|
18 | -define('MSG_REJECTED',3); |
|
19 | -define('MSG_TENTATIVE',4); |
|
20 | -define('MSG_ACCEPTED',5); |
|
21 | -define('MSG_ALARM',6); |
|
22 | -define('MSG_DISINVITE',7); |
|
23 | -define('MSG_DELEGATED',8); |
|
15 | +define('MSG_DELETED', 0); |
|
16 | +define('MSG_MODIFIED', 1); |
|
17 | +define('MSG_ADDED', 2); |
|
18 | +define('MSG_REJECTED', 3); |
|
19 | +define('MSG_TENTATIVE', 4); |
|
20 | +define('MSG_ACCEPTED', 5); |
|
21 | +define('MSG_ALARM', 6); |
|
22 | +define('MSG_DISINVITE', 7); |
|
23 | +define('MSG_DELEGATED', 8); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Class to access AND manipulate all calendar data (business object) |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function __construct() |
83 | 83 | { |
84 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
84 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
85 | 85 | |
86 | - parent::__construct(); // calling the parent constructor |
|
86 | + parent::__construct(); // calling the parent constructor |
|
87 | 87 | |
88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
88 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
113 | 113 | * ++++++++ ++++++++ |
114 | 114 | */ |
115 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
115 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
116 | 116 | { |
117 | 117 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
118 | 118 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if ($this->debug > 1 || $this->debug == 'update') |
121 | 121 | { |
122 | 122 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
123 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
123 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
124 | 124 | } |
125 | 125 | // check some minimum requirements: |
126 | 126 | // - new events need start, end and title |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // check if user has the permission to update / create the event |
151 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT,$event['id']) || |
|
152 | - $new_event && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner'])) && |
|
153 | - !$this->check_perms(EGW_ACL_ADD,0,$event['owner'])) |
|
151 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT, $event['id']) || |
|
152 | + $new_event && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner'])) && |
|
153 | + !$this->check_perms(EGW_ACL_ADD, 0, $event['owner'])) |
|
154 | 154 | { |
155 | - $messages[] = lang('Access to calendar of %1 denied!',common::grab_owner_name($event['owner'])); |
|
155 | + $messages[] = lang('Access to calendar of %1 denied!', common::grab_owner_name($event['owner'])); |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if ($new_event) |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
164 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // do we need to check, if user is allowed to invite the invited participants |
168 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
168 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
169 | 169 | { |
170 | 170 | // report removed participants back to user |
171 | - foreach($removed as $key => $account_id) |
|
171 | + foreach ($removed as $key => $account_id) |
|
172 | 172 | { |
173 | 173 | $removed[$key] = $this->participant_name($account_id); |
174 | 174 | } |
175 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
176 | - ': '.implode(', ',$removed); |
|
175 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
176 | + ': '.implode(', ', $removed); |
|
177 | 177 | } |
178 | 178 | // check category based ACL |
179 | 179 | if ($event['category']) |
180 | 180 | { |
181 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
181 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
182 | 182 | if (!$old_event || !isset($old_event['category'])) |
183 | 183 | { |
184 | 184 | $old_event['category'] = array(); |
@@ -187,38 +187,38 @@ discard block |
||
187 | 187 | { |
188 | 188 | $old_event['category'] = explode(',', $old_event['category']); |
189 | 189 | } |
190 | - foreach($event['category'] as $key => $cat_id) |
|
190 | + foreach ($event['category'] as $key => $cat_id) |
|
191 | 191 | { |
192 | 192 | // check if user is allowed to update event categories |
193 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
194 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
193 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
194 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
195 | 195 | { |
196 | 196 | unset($event['category'][$key]); |
197 | 197 | // report removed category to user |
198 | 198 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
199 | - continue; // no further check, as cat was removed |
|
199 | + continue; // no further check, as cat was removed |
|
200 | 200 | } |
201 | 201 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
202 | 202 | if (!$status_reset_to_unknown && |
203 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
203 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
204 | 204 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
205 | 205 | { |
206 | - foreach((array)$event['participants'] as $uid => $status) |
|
206 | + foreach ((array)$event['participants'] as $uid => $status) |
|
207 | 207 | { |
208 | 208 | $q = $r = null; |
209 | - calendar_so::split_status($status,$q,$r); |
|
209 | + calendar_so::split_status($status, $q, $r); |
|
210 | 210 | if ($status != 'U') |
211 | 211 | { |
212 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
212 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
213 | 213 | // todo: report reset status to user |
214 | 214 | } |
215 | 215 | } |
216 | - $status_reset_to_unknown = true; // once is enough |
|
216 | + $status_reset_to_unknown = true; // once is enough |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | if ($removed_cats) |
220 | 220 | { |
221 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
221 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
222 | 222 | } |
223 | 223 | if ($status_reset_to_unknown) |
224 | 224 | { |
@@ -229,61 +229,61 @@ discard block |
||
229 | 229 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end'])) |
230 | 230 | { |
231 | 231 | $types_with_quantity = array(); |
232 | - foreach($this->resources as $type => $data) |
|
232 | + foreach ($this->resources as $type => $data) |
|
233 | 233 | { |
234 | 234 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
235 | 235 | } |
236 | 236 | // get all NOT rejected participants and evtl. their quantity |
237 | 237 | $quantity = $users = array(); |
238 | - foreach($event['participants'] as $uid => $status) |
|
238 | + foreach ($event['participants'] as $uid => $status) |
|
239 | 239 | { |
240 | - calendar_so::split_status($status,$q,$r); |
|
241 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
240 | + calendar_so::split_status($status, $q, $r); |
|
241 | + if ($status[0] == 'R') continue; // ignore rejected participants |
|
242 | 242 | |
243 | 243 | if ($uid < 0) // group, check it's members too |
244 | 244 | { |
245 | - $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
|
245 | + $users += (array)$GLOBALS['egw']->accounts->members($uid, true); |
|
246 | 246 | $users = array_unique($users); |
247 | 247 | } |
248 | 248 | $users[] = $uid; |
249 | - if (in_array($uid[0],$types_with_quantity)) |
|
249 | + if (in_array($uid[0], $types_with_quantity)) |
|
250 | 250 | { |
251 | 251 | $quantity[$uid] = $q; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | //$start = microtime(true); |
255 | - $overlapping_events =& $this->search(array( |
|
255 | + $overlapping_events = & $this->search(array( |
|
256 | 256 | 'start' => $event['start'], |
257 | 257 | 'end' => $event['end'], |
258 | 258 | 'users' => $users, |
259 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
260 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
259 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
260 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
261 | 261 | 'query' => array( |
262 | 262 | 'cal_non_blocking' => 0, |
263 | 263 | ), |
264 | - 'no_integration' => true, // do NOT use integration of other apps |
|
264 | + 'no_integration' => true, // do NOT use integration of other apps |
|
265 | 265 | )); |
266 | 266 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
267 | 267 | if ($this->debug > 2 || $this->debug == 'update') |
268 | 268 | { |
269 | - $this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$event['start'],$event['end']); |
|
269 | + $this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $event['start'], $event['end']); |
|
270 | 270 | } |
271 | 271 | $max_quantity = $possible_quantity_conflicts = $conflicts = array(); |
272 | - foreach((array) $overlapping_events as $k => $overlap) |
|
272 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
273 | 273 | { |
274 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
275 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
274 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
275 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
276 | 276 | $overlap['non_blocking']) // that's a non_blocking event |
277 | 277 | { |
278 | 278 | continue; |
279 | 279 | } |
280 | 280 | if ($this->debug > 3 || $this->debug == 'update') |
281 | 281 | { |
282 | - $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
|
282 | + $this->debug_message('calendar_boupdate::update() checking overlapping event %1', false, $overlap); |
|
283 | 283 | } |
284 | 284 | // check if the overlap is with a rejected participant or within the allowed quantity |
285 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
286 | - foreach($common_parts as $n => $uid) |
|
285 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
286 | + foreach ($common_parts as $n => $uid) |
|
287 | 287 | { |
288 | 288 | $status = $overlap['participants'][$uid]; |
289 | 289 | calendar_so::split_status($status, $q, $r); |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | unset($common_parts[$n]); |
293 | 293 | continue; |
294 | 294 | } |
295 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
295 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
296 | 296 | { |
297 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
297 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
298 | 298 | } |
299 | 299 | if (!isset($max_quantity[$uid])) |
300 | 300 | { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $quantity[$uid] += $q; |
305 | 305 | if ($quantity[$uid] <= $max_quantity[$uid]) |
306 | 306 | { |
307 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
307 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
308 | 308 | unset($common_parts[$n]); |
309 | 309 | continue; |
310 | 310 | } |
@@ -314,20 +314,20 @@ discard block |
||
314 | 314 | { |
315 | 315 | if ($this->debug > 3 || $this->debug == 'update') |
316 | 316 | { |
317 | - $this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1',false,$common_parts); |
|
317 | + $this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1', false, $common_parts); |
|
318 | 318 | } |
319 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
319 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | // check if we are withing the allowed quantity and if not add all events using that resource |
323 | 323 | // seems this function is doing very strange things, it gives empty conflicts |
324 | - foreach($max_quantity as $uid => $max) |
|
324 | + foreach ($max_quantity as $uid => $max) |
|
325 | 325 | { |
326 | 326 | if ($quantity[$uid] > $max) |
327 | 327 | { |
328 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
328 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
329 | 329 | { |
330 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
330 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | } |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | |
336 | 336 | if (count($conflicts)) |
337 | 337 | { |
338 | - foreach($conflicts as $key => $conflict) |
|
338 | + foreach ($conflicts as $key => $conflict) |
|
339 | 339 | { |
340 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
341 | - if (!$this->check_perms(EGW_ACL_READ,$conflict)) |
|
340 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
341 | + if (!$this->check_perms(EGW_ACL_READ, $conflict)) |
|
342 | 342 | { |
343 | 343 | $conflicts[$key] = array( |
344 | 344 | 'id' => $conflict['id'], |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | if ($this->debug > 2 || $this->debug == 'update') |
353 | 353 | { |
354 | - $this->debug_message('calendar_boupdate::update() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
354 | + $this->debug_message('calendar_boupdate::update() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
355 | 355 | } |
356 | 356 | return $conflicts; |
357 | 357 | } |
@@ -365,33 +365,33 @@ discard block |
||
365 | 365 | return $cal_id; |
366 | 366 | } |
367 | 367 | |
368 | - $event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies |
|
368 | + $event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies |
|
369 | 369 | //echo "new $cal_id="; _debug_array($event); |
370 | 370 | |
371 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
371 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
372 | 372 | { |
373 | 373 | // Restored, bring back links |
374 | 374 | egw_link::restore('calendar', $cal_id); |
375 | 375 | } |
376 | 376 | if ($this->log_file) |
377 | 377 | { |
378 | - $this->log2file($event2save,$event,$old_event); |
|
378 | + $this->log2file($event2save, $event, $old_event); |
|
379 | 379 | } |
380 | 380 | // send notifications |
381 | - if(!$skip_notification) |
|
381 | + if (!$skip_notification) |
|
382 | 382 | { |
383 | 383 | if ($new_event) |
384 | 384 | { |
385 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
385 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
386 | 386 | } |
387 | 387 | else // update existing event |
388 | 388 | { |
389 | - $this->check4update($event,$old_event); |
|
389 | + $this->check4update($event, $old_event); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | // notify the link-class about the update, as other apps may be subscribt to it |
394 | - egw_link::notify_update('calendar',$cal_id,$event); |
|
394 | + egw_link::notify_update('calendar', $cal_id, $event); |
|
395 | 395 | |
396 | 396 | return $cal_id; |
397 | 397 | } |
@@ -409,27 +409,27 @@ discard block |
||
409 | 409 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
410 | 410 | * @return array or events |
411 | 411 | */ |
412 | - function conflicts(array $event, &$checked_excluding=null) |
|
412 | + function conflicts(array $event, &$checked_excluding = null) |
|
413 | 413 | { |
414 | 414 | $types_with_quantity = array(); |
415 | - foreach($this->resources as $type => $data) |
|
415 | + foreach ($this->resources as $type => $data) |
|
416 | 416 | { |
417 | 417 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
418 | 418 | } |
419 | 419 | // get all NOT rejected participants and evtl. their quantity |
420 | 420 | $quantity = $users = array(); |
421 | - foreach($event['participants'] as $uid => $status) |
|
421 | + foreach ($event['participants'] as $uid => $status) |
|
422 | 422 | { |
423 | 423 | $q = $r = null; |
424 | - calendar_so::split_status($status,$q,$r); |
|
425 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
424 | + calendar_so::split_status($status, $q, $r); |
|
425 | + if ($status[0] == 'R') continue; // ignore rejected participants |
|
426 | 426 | |
427 | 427 | if ($uid < 0) // group, check it's members too |
428 | 428 | { |
429 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
429 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
430 | 430 | } |
431 | 431 | $users[] = $uid; |
432 | - if (in_array($uid[0],$types_with_quantity)) |
|
432 | + if (in_array($uid[0], $types_with_quantity)) |
|
433 | 433 | { |
434 | 434 | $quantity[$uid] = $q; |
435 | 435 | } |
@@ -452,58 +452,58 @@ discard block |
||
452 | 452 | } |
453 | 453 | $checked = 0; |
454 | 454 | $start = microtime(true); |
455 | - $duration = $event['end']-$event['start']; |
|
456 | - foreach($recurences as $date) |
|
455 | + $duration = $event['end'] - $event['start']; |
|
456 | + foreach ($recurences as $date) |
|
457 | 457 | { |
458 | 458 | $startts = $date->format('ts'); |
459 | 459 | |
460 | 460 | // skip past events or recurrences |
461 | - if ($startts+$duration < $this->now_su) continue; |
|
461 | + if ($startts + $duration < $this->now_su) continue; |
|
462 | 462 | |
463 | 463 | // abort check if configured limits are exceeded |
464 | 464 | if ($event['recur_type'] && |
465 | 465 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
466 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
466 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
467 | 467 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
468 | 468 | { |
469 | 469 | if ($this->debug > 2 || $this->debug == 'conflicts') |
470 | 470 | { |
471 | 471 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
472 | - $checked, microtime(true)-$start, $date); |
|
472 | + $checked, microtime(true) - $start, $date); |
|
473 | 473 | } |
474 | 474 | $checked_excluding = $date; |
475 | 475 | break; |
476 | 476 | } |
477 | - $overlapping_events =& $this->search(array( |
|
477 | + $overlapping_events = & $this->search(array( |
|
478 | 478 | 'start' => $startts, |
479 | - 'end' => $startts+$duration, |
|
479 | + 'end' => $startts + $duration, |
|
480 | 480 | 'users' => $users, |
481 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
482 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
481 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
482 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
483 | 483 | 'query' => array( |
484 | 484 | 'cal_non_blocking' => 0, |
485 | 485 | ), |
486 | - 'no_integration' => true, // do NOT use integration of other apps |
|
486 | + 'no_integration' => true, // do NOT use integration of other apps |
|
487 | 487 | )); |
488 | 488 | if ($this->debug > 2 || $this->debug == 'conflicts') |
489 | 489 | { |
490 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
490 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
491 | 491 | } |
492 | - foreach((array) $overlapping_events as $k => $overlap) |
|
492 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
493 | 493 | { |
494 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
495 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
494 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
495 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
496 | 496 | $overlap['non_blocking']) // that's a non_blocking event |
497 | 497 | { |
498 | 498 | continue; |
499 | 499 | } |
500 | 500 | if ($this->debug > 3 || $this->debug == 'conflicts') |
501 | 501 | { |
502 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
502 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
503 | 503 | } |
504 | 504 | // check if the overlap is with a rejected participant or within the allowed quantity |
505 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
506 | - foreach($common_parts as $n => $uid) |
|
505 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
506 | + foreach ($common_parts as $n => $uid) |
|
507 | 507 | { |
508 | 508 | $status = $overlap['participants'][$uid]; |
509 | 509 | calendar_so::split_status($status, $q, $r); |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | unset($common_parts[$n]); |
513 | 513 | continue; |
514 | 514 | } |
515 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
515 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
516 | 516 | { |
517 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
517 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
518 | 518 | } |
519 | 519 | if (!isset($max_quantity[$uid])) |
520 | 520 | { |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $quantity[$uid] += $q; |
525 | 525 | if ($quantity[$uid] <= $max_quantity[$uid]) |
526 | 526 | { |
527 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
527 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
528 | 528 | unset($common_parts[$n]); |
529 | 529 | continue; |
530 | 530 | } |
@@ -534,22 +534,22 @@ discard block |
||
534 | 534 | { |
535 | 535 | if ($this->debug > 3 || $this->debug == 'conflicts') |
536 | 536 | { |
537 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
537 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
538 | 538 | } |
539 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
539 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
543 | 543 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
544 | 544 | // check if we are withing the allowed quantity and if not add all events using that resource |
545 | 545 | // seems this function is doing very strange things, it gives empty conflicts |
546 | - foreach($max_quantity as $uid => $max) |
|
546 | + foreach ($max_quantity as $uid => $max) |
|
547 | 547 | { |
548 | 548 | if ($quantity[$uid] > $max) |
549 | 549 | { |
550 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
550 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
551 | 551 | { |
552 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
552 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | |
558 | 558 | if (count($conflicts)) |
559 | 559 | { |
560 | - foreach($conflicts as $key => $conflict) |
|
560 | + foreach ($conflicts as $key => $conflict) |
|
561 | 561 | { |
562 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
563 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
562 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
563 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
564 | 564 | { |
565 | 565 | $conflicts[$key] = array( |
566 | 566 | 'id' => $conflict['id'], |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | } |
574 | 574 | if ($this->debug > 2 || $this->debug == 'conflicts') |
575 | 575 | { |
576 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
576 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | return $conflicts; |
@@ -586,22 +586,22 @@ discard block |
||
586 | 586 | * @param array $old_event =null old event with already invited participants |
587 | 587 | * @return array removed participants because of missing invite grants |
588 | 588 | */ |
589 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
589 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
590 | 590 | { |
591 | 591 | if (!$this->require_acl_invite) |
592 | 592 | { |
593 | - return array(); // nothing to check, everyone can invite everyone else |
|
593 | + return array(); // nothing to check, everyone can invite everyone else |
|
594 | 594 | } |
595 | 595 | if ($event['id'] && is_null($old_event)) |
596 | 596 | { |
597 | 597 | $old_event = $this->read($event['id']); |
598 | 598 | } |
599 | 599 | $removed = array(); |
600 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
600 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
601 | 601 | { |
602 | 602 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
603 | 603 | { |
604 | - unset($event['participants'][$uid]); // remove participant |
|
604 | + unset($event['participants'][$uid]); // remove participant |
|
605 | 605 | $removed[] = $uid; |
606 | 606 | } |
607 | 607 | } |
@@ -617,19 +617,19 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public function check_acl_invite($uid) |
619 | 619 | { |
620 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
620 | + if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
621 | 621 | |
622 | 622 | if (!$this->require_acl_invite) |
623 | 623 | { |
624 | - $ret = true; // no grant required |
|
624 | + $ret = true; // no grant required |
|
625 | 625 | } |
626 | 626 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
627 | 627 | { |
628 | - $ret = true; // grant only required for groups |
|
628 | + $ret = true; // grant only required for groups |
|
629 | 629 | } |
630 | 630 | else |
631 | 631 | { |
632 | - $ret = $this->check_perms(EGW_ACL_INVITE,0,$uid); |
|
632 | + $ret = $this->check_perms(EGW_ACL_INVITE, 0, $uid); |
|
633 | 633 | } |
634 | 634 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
635 | 635 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * @param array $old_event the event before the update |
644 | 644 | * @todo check if there is a real change, not assume every save is a change |
645 | 645 | */ |
646 | - function check4update($new_event,$old_event) |
|
646 | + function check4update($new_event, $old_event) |
|
647 | 647 | { |
648 | 648 | //error_log(__METHOD__."($new_event[title])"); |
649 | 649 | $modified = $added = $deleted = array(); |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
652 | 652 | |
653 | 653 | // Find modified and deleted participants ... |
654 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
654 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
655 | 655 | { |
656 | - if(isset($new_event['participants'][$old_userid])) |
|
656 | + if (isset($new_event['participants'][$old_userid])) |
|
657 | 657 | { |
658 | 658 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
659 | 659 | } |
@@ -663,27 +663,27 @@ discard block |
||
663 | 663 | } |
664 | 664 | } |
665 | 665 | // Find new participants ... |
666 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
666 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
667 | 667 | { |
668 | - if(!isset($old_event['participants'][$new_userid])) |
|
668 | + if (!isset($old_event['participants'][$new_userid])) |
|
669 | 669 | { |
670 | 670 | $added[$new_userid] = 'U'; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
674 | - if(count($added) || count($modified) || count($deleted)) |
|
674 | + if (count($added) || count($modified) || count($deleted)) |
|
675 | 675 | { |
676 | - if(count($added)) |
|
676 | + if (count($added)) |
|
677 | 677 | { |
678 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
678 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
679 | 679 | } |
680 | - if(count($modified)) |
|
680 | + if (count($modified)) |
|
681 | 681 | { |
682 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
682 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
683 | 683 | } |
684 | - if(count($deleted)) |
|
684 | + if (count($deleted)) |
|
685 | 685 | { |
686 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
686 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | } |
@@ -700,11 +700,11 @@ discard block |
||
700 | 700 | * @param string $status of current user |
701 | 701 | * @return boolean true = update requested, false otherwise |
702 | 702 | */ |
703 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
703 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
704 | 704 | { |
705 | 705 | if ($msg_type == MSG_ALARM) |
706 | 706 | { |
707 | - return True; // always True for now |
|
707 | + return True; // always True for now |
|
708 | 708 | } |
709 | 709 | $want_update = 0; |
710 | 710 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | // |
713 | 713 | $msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED; |
714 | 714 | |
715 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
715 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
716 | 716 | { |
717 | 717 | case 'responses': |
718 | 718 | ++$want_update; |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | default: |
727 | 727 | if (is_array($new_event) && is_array($old_event)) |
728 | 728 | { |
729 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
730 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
729 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
730 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
731 | 731 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
732 | 732 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
733 | 733 | { |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | if (!is_numeric($userid) && $role == 'CHAIR' && |
748 | 748 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
749 | 749 | { |
750 | - switch($msg_type) |
|
750 | + switch ($msg_type) |
|
751 | 751 | { |
752 | 752 | case MSG_DELETED: // treat deleting event as rejection to organizer |
753 | 753 | $msg_type = MSG_REJECTED; |
754 | 754 | break; |
755 | 755 | case MSG_ADDED: // new events use added, but organizer needs status |
756 | - switch($status[0]) |
|
756 | + switch ($status[0]) |
|
757 | 757 | { |
758 | 758 | case 'A': $msg_type = MSG_ACCEPTED; break; |
759 | 759 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @param string $role ='REQ-PARTICIPANT' |
779 | 779 | * @return boolean true if user requested to be notified, false if not |
780 | 780 | */ |
781 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
781 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
782 | 782 | { |
783 | 783 | // check if email is from a user |
784 | 784 | if (is_numeric($user_or_email)) |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | ) |
803 | 803 | ); |
804 | 804 | } |
805 | - switch($ical_method) |
|
805 | + switch ($ical_method) |
|
806 | 806 | { |
807 | 807 | default: |
808 | 808 | case 'REQUEST': |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * @param string& $action=null on return verbose name |
828 | 828 | * @param string& $msg=null on return notification message |
829 | 829 | */ |
830 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
830 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
831 | 831 | { |
832 | - switch($msg_type) |
|
832 | + switch ($msg_type) |
|
833 | 833 | { |
834 | 834 | case MSG_DELETED: |
835 | 835 | $action = 'Canceled'; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | $msg = $this->cal_prefs['notify'.$pref]; |
882 | 882 | if (empty($msg)) |
883 | 883 | { |
884 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
884 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
885 | 885 | } |
886 | 886 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
887 | 887 | return $method; |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * @param int $user =0 User who started the notify, default current user |
898 | 898 | * @return bool true/false |
899 | 899 | */ |
900 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
900 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
901 | 901 | { |
902 | 902 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
903 | 903 | if (!is_array($to_notify)) |
@@ -909,11 +909,11 @@ discard block |
||
909 | 909 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
910 | 910 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
911 | 911 | { |
912 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
912 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
916 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
916 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
917 | 917 | { |
918 | 918 | return False; |
919 | 919 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | $restore_tz = $tz; |
924 | 924 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
925 | 925 | } |
926 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
926 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
927 | 927 | |
928 | 928 | if (!$user) |
929 | 929 | { |
@@ -939,17 +939,17 @@ discard block |
||
939 | 939 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
940 | 940 | |
941 | 941 | // add all group-members to the notification, unless they are already participants |
942 | - foreach($to_notify as $userid => $statusid) |
|
942 | + foreach ($to_notify as $userid => $statusid) |
|
943 | 943 | { |
944 | 944 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
945 | 945 | ($members = $GLOBALS['egw']->accounts->member($userid))) |
946 | 946 | { |
947 | - foreach($members as $member) |
|
947 | + foreach ($members as $member) |
|
948 | 948 | { |
949 | 949 | $member = $member['account_id']; |
950 | 950 | if (!isset($to_notify[$member])) |
951 | 951 | { |
952 | - $to_notify[$member] = 'G'; // Group-invitation |
|
952 | + $to_notify[$member] = 'G'; // Group-invitation |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | } |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | if ($old_event) $olddate = new egw_time($old_event['start']); |
962 | 962 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
963 | 963 | $owner_prefs = $ics = null; |
964 | - foreach($to_notify as $userid => $statusid) |
|
964 | + foreach ($to_notify as $userid => $statusid) |
|
965 | 965 | { |
966 | 966 | $res_info = $quantity = $role = null; |
967 | 967 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -984,14 +984,14 @@ discard block |
||
984 | 984 | |
985 | 985 | if (!isset($userid)) |
986 | 986 | { |
987 | - if (empty($res_info['email'])) continue; // no way to notify |
|
987 | + if (empty($res_info['email'])) continue; // no way to notify |
|
988 | 988 | // check if event-owner wants non-EGroupware users notified |
989 | 989 | if (is_null($owner_prefs)) |
990 | 990 | { |
991 | 991 | $preferences = new preferences($owner); |
992 | 992 | $owner_prefs = $preferences->read_repository(); |
993 | 993 | } |
994 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
994 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
995 | 995 | (empty($owner_prefs['calendar']['notify_externals']) || |
996 | 996 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
997 | 997 | { |
@@ -1003,12 +1003,12 @@ discard block |
||
1003 | 1003 | |
1004 | 1004 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
1005 | 1005 | { |
1006 | - continue; // dont notify rejected participants or groups |
|
1006 | + continue; // dont notify rejected participants or groups |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
1009 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
1010 | 1010 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
1011 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
1011 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
1012 | 1012 | $msg_type == MSG_ALARM) |
1013 | 1013 | { |
1014 | 1014 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | { |
1017 | 1017 | $preferences = new preferences($userid); |
1018 | 1018 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
1019 | - $GLOBALS['egw']->accounts->get_account_name($userid,$lid,$tfn,$tln); |
|
1020 | - $fullname = common::display_fullname('',$tfn,$tln); |
|
1019 | + $GLOBALS['egw']->accounts->get_account_name($userid, $lid, $tfn, $tln); |
|
1020 | + $fullname = common::display_fullname('', $tfn, $tln); |
|
1021 | 1021 | } |
1022 | 1022 | else // external email address: use preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
1023 | 1023 | { |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | $part_prefs = $owner_prefs; |
1030 | 1030 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
1031 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
1031 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
1032 | 1032 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
1033 | 1033 | } |
1034 | 1034 | $m_type = $msg_type; |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
1057 | 1057 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
1058 | 1058 | $timeformat = $part_prefs['common']['timeformat']; |
1059 | - switch($timeformat) |
|
1059 | + switch ($timeformat) |
|
1060 | 1060 | { |
1061 | 1061 | case '24': |
1062 | 1062 | $timeformat = 'H:i'; |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $timeformat = 'h:i a'; |
1066 | 1066 | break; |
1067 | 1067 | } |
1068 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
1068 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
1069 | 1069 | |
1070 | 1070 | $startdate->setTimezone($timezone); |
1071 | 1071 | $details['startdate'] = $startdate->format($timeformat); |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | $details['enddate'] = $enddate->format($timeformat); |
1075 | 1075 | |
1076 | 1076 | $modified->setTimezone($timezone); |
1077 | - $details['updated'] = $modified->format($timeformat) . ', ' . common::grab_owner_name($event['modifier']); |
|
1077 | + $details['updated'] = $modified->format($timeformat).', '.common::grab_owner_name($event['modifier']); |
|
1078 | 1078 | |
1079 | 1079 | if ($old_event != False) |
1080 | 1080 | { |
@@ -1083,15 +1083,14 @@ discard block |
||
1083 | 1083 | } |
1084 | 1084 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
1085 | 1085 | |
1086 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
1086 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
1087 | 1087 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
1088 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
1088 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
1089 | 1089 | { |
1090 | - case 'ical': |
|
1091 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1090 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1092 | 1091 | { |
1093 | 1092 | $calendar_ical = new calendar_ical(); |
1094 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
1093 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
1095 | 1094 | // we need to pass $event[id] so iCal class reads event again, |
1096 | 1095 | // as event is in user TZ, but iCal class expects server TZ! |
1097 | 1096 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1110,11 +1109,11 @@ discard block |
||
1110 | 1109 | case 'extended': |
1111 | 1110 | |
1112 | 1111 | $details_body = lang('Event Details follow').":\n"; |
1113 | - foreach($event_arr as $key => $val) |
|
1112 | + foreach ($event_arr as $key => $val) |
|
1114 | 1113 | { |
1115 | - if(!empty($details[$key])) |
|
1114 | + if (!empty($details[$key])) |
|
1116 | 1115 | { |
1117 | - switch($key) |
|
1116 | + switch ($key) |
|
1118 | 1117 | { |
1119 | 1118 | case 'access': |
1120 | 1119 | case 'priority': |
@@ -1123,7 +1122,7 @@ discard block |
||
1123 | 1122 | case 'title': |
1124 | 1123 | break; |
1125 | 1124 | default: |
1126 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
1125 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
1127 | 1126 | break; |
1128 | 1127 | } |
1129 | 1128 | } |
@@ -1131,7 +1130,7 @@ discard block |
||
1131 | 1130 | break; |
1132 | 1131 | } |
1133 | 1132 | // send via notification_app |
1134 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
1133 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
1135 | 1134 | { |
1136 | 1135 | try { |
1137 | 1136 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1155,7 +1154,7 @@ discard block |
||
1155 | 1154 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
1156 | 1155 | $notification->set_popuplinks(array($details['link_arr'])); |
1157 | 1156 | |
1158 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1157 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1159 | 1158 | $notification->send(); |
1160 | 1159 | } |
1161 | 1160 | catch (Exception $exception) { |
@@ -1187,14 +1186,14 @@ discard block |
||
1187 | 1186 | return true; |
1188 | 1187 | } |
1189 | 1188 | |
1190 | - function get_update_message($event,$added) |
|
1189 | + function get_update_message($event, $added) |
|
1191 | 1190 | { |
1192 | 1191 | $nul = null; |
1193 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
1192 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
1194 | 1193 | |
1195 | 1194 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
1196 | 1195 | |
1197 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
1196 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
1198 | 1197 | } |
1199 | 1198 | |
1200 | 1199 | /** |
@@ -1208,37 +1207,37 @@ discard block |
||
1208 | 1207 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
1209 | 1208 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
1210 | 1209 | |
1211 | - $event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1212 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
1210 | + $event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1211 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
1213 | 1212 | { |
1214 | - return False; // event not found |
|
1213 | + return False; // event not found |
|
1215 | 1214 | } |
1216 | 1215 | if ($alarm['all']) |
1217 | 1216 | { |
1218 | 1217 | $to_notify = $event['participants']; |
1219 | 1218 | } |
1220 | - elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1219 | + elseif ($this->check_perms(EGW_ACL_READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
1221 | 1220 | { |
1222 | 1221 | $to_notify[$alarm['owner']] = 'A'; |
1223 | 1222 | } |
1224 | 1223 | else |
1225 | 1224 | { |
1226 | - return False; // no rights |
|
1225 | + return False; // no rights |
|
1227 | 1226 | } |
1228 | 1227 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
1229 | 1228 | translation::add_app('calendar'); |
1230 | 1229 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
1231 | 1230 | |
1232 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
1231 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
1233 | 1232 | |
1234 | 1233 | // create a new alarm for recuring events for the next event, if one exists |
1235 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
1234 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
1236 | 1235 | { |
1237 | 1236 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
1238 | 1237 | unset($alarm['times']); |
1239 | 1238 | unset($alarm['next']); |
1240 | 1239 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
1241 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1240 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1242 | 1241 | } |
1243 | 1242 | return $ret; |
1244 | 1243 | } |
@@ -1254,15 +1253,15 @@ discard block |
||
1254 | 1253 | * DEPRECATED: we allways (have to) update timestamp, as they are required for sync! |
1255 | 1254 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
1256 | 1255 | */ |
1257 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
1256 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
1258 | 1257 | { |
1259 | 1258 | unset($updateTS); |
1260 | 1259 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
1261 | 1260 | |
1262 | 1261 | // check if user has the permission to update / create the event |
1263 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT,$event['id']) || |
|
1264 | - !$event['id'] && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner']) && |
|
1265 | - !$this->check_perms(EGW_ACL_ADD,0,$event['owner']))) |
|
1262 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT, $event['id']) || |
|
1263 | + !$event['id'] && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner']) && |
|
1264 | + !$this->check_perms(EGW_ACL_ADD, 0, $event['owner']))) |
|
1266 | 1265 | { |
1267 | 1266 | return false; |
1268 | 1267 | } |
@@ -1307,19 +1306,19 @@ discard block |
||
1307 | 1306 | $time->setUser(); |
1308 | 1307 | $save_event['recur_enddate'] = egw_time::to($time, 'ts'); |
1309 | 1308 | } |
1310 | - $timestamps = array('modified','created'); |
|
1309 | + $timestamps = array('modified', 'created'); |
|
1311 | 1310 | // all-day events are handled in server time |
1312 | 1311 | $event['tzid'] = $save_event['tzid'] = egw_time::$server_timezone->getName(); |
1313 | 1312 | } |
1314 | 1313 | else |
1315 | 1314 | { |
1316 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
1315 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
1317 | 1316 | } |
1318 | 1317 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
1319 | - foreach($timestamps as $ts) |
|
1318 | + foreach ($timestamps as $ts) |
|
1320 | 1319 | { |
1321 | 1320 | // we convert here from user-time to timestamps in server-time! |
1322 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1321 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
1323 | 1322 | } |
1324 | 1323 | // convert tzid name to integer tz_id, of set user default |
1325 | 1324 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1329,7 +1328,7 @@ discard block |
||
1329 | 1328 | // same with the recur exceptions |
1330 | 1329 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
1331 | 1330 | { |
1332 | - foreach($event['recur_exception'] as &$date) |
|
1331 | + foreach ($event['recur_exception'] as &$date) |
|
1333 | 1332 | { |
1334 | 1333 | if ($event['whole_day']) |
1335 | 1334 | { |
@@ -1338,7 +1337,7 @@ discard block |
||
1338 | 1337 | } |
1339 | 1338 | else |
1340 | 1339 | { |
1341 | - $date = $this->date2ts($date,true); |
|
1340 | + $date = $this->date2ts($date, true); |
|
1342 | 1341 | } |
1343 | 1342 | } |
1344 | 1343 | unset($date); |
@@ -1346,7 +1345,7 @@ discard block |
||
1346 | 1345 | // same with the alarms |
1347 | 1346 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
1348 | 1347 | { |
1349 | - foreach($event['alarm'] as $id => &$alarm) |
|
1348 | + foreach ($event['alarm'] as $id => &$alarm) |
|
1350 | 1349 | { |
1351 | 1350 | // remove alarms belonging to not longer existing or rejected participants |
1352 | 1351 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1364,15 +1363,14 @@ discard block |
||
1364 | 1363 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
1365 | 1364 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
1366 | 1365 | { |
1367 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
1366 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
1368 | 1367 | { |
1369 | 1368 | if (!isset($event['alarm'][$id])) |
1370 | 1369 | { |
1371 | 1370 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1372 | 1371 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
1373 | 1372 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1374 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
1375 | - $old_event['participants'][$alarm['owner']]; |
|
1373 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
1376 | 1374 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
1377 | 1375 | { |
1378 | 1376 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1398,7 +1396,7 @@ discard block |
||
1398 | 1396 | } |
1399 | 1397 | $set_recurrences = false; |
1400 | 1398 | $set_recurrences_start = 0; |
1401 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1399 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1402 | 1400 | { |
1403 | 1401 | $save_event['id'] = $cal_id; |
1404 | 1402 | // unset participants to enforce the default stati for all added recurrences |
@@ -1410,7 +1408,7 @@ discard block |
||
1410 | 1408 | // create links for new participants from addressbook, if configured |
1411 | 1409 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
1412 | 1410 | { |
1413 | - foreach($event['participants'] as $uid => $status) |
|
1411 | + foreach ($event['participants'] as $uid => $status) |
|
1414 | 1412 | { |
1415 | 1413 | $user_type = $user_id = null; |
1416 | 1414 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1423,7 +1421,7 @@ discard block |
||
1423 | 1421 | |
1424 | 1422 | // Update history |
1425 | 1423 | $tracking = new calendar_tracking($this); |
1426 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1424 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
1427 | 1425 | $tracking->track($event, $old_event); |
1428 | 1426 | |
1429 | 1427 | return $cal_id; |
@@ -1438,16 +1436,16 @@ discard block |
||
1438 | 1436 | * @param array|int $event event array or id of the event |
1439 | 1437 | * @return boolean |
1440 | 1438 | */ |
1441 | - function check_status_perms($uid,$event) |
|
1439 | + function check_status_perms($uid, $event) |
|
1442 | 1440 | { |
1443 | 1441 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
1444 | 1442 | { |
1445 | 1443 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1446 | 1444 | |
1447 | - return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']); |
|
1445 | + return $this->check_perms(EGW_ACL_EDIT, 0, $event['owner']); |
|
1448 | 1446 | } |
1449 | 1447 | // check if we have a category acl for the event or not (null) |
1450 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
1448 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
1451 | 1449 | if (!is_null($access)) |
1452 | 1450 | { |
1453 | 1451 | return $access; |
@@ -1457,17 +1455,17 @@ discard block |
||
1457 | 1455 | { |
1458 | 1456 | $resource = $this->resource_info($uid); |
1459 | 1457 | |
1460 | - return EGW_ACL_EDIT & $resource['rights']; |
|
1458 | + return EGW_ACL_EDIT&$resource['rights']; |
|
1461 | 1459 | } |
1462 | 1460 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1463 | 1461 | |
1464 | 1462 | // regular user and groups (need to check memberships too) |
1465 | 1463 | if (!isset($event['participants'][$uid])) |
1466 | 1464 | { |
1467 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
1465 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
1468 | 1466 | } |
1469 | 1467 | $memberships[] = $uid; |
1470 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT,0,$uid); |
|
1468 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT, 0, $uid); |
|
1471 | 1469 | } |
1472 | 1470 | |
1473 | 1471 | /** |
@@ -1481,16 +1479,16 @@ discard block |
||
1481 | 1479 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1482 | 1480 | * null = cat has no acl |
1483 | 1481 | */ |
1484 | - function check_cat_acl($right,$event) |
|
1482 | + function check_cat_acl($right, $event) |
|
1485 | 1483 | { |
1486 | 1484 | if (!is_array($event)) $event = $this->read($event); |
1487 | 1485 | |
1488 | 1486 | $ret = null; |
1489 | 1487 | if ($event['category']) |
1490 | 1488 | { |
1491 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
1489 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
1492 | 1490 | { |
1493 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
1491 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
1494 | 1492 | if ($access === true) |
1495 | 1493 | { |
1496 | 1494 | $ret = true; |
@@ -1498,7 +1496,7 @@ discard block |
||
1498 | 1496 | } |
1499 | 1497 | if ($access === false) |
1500 | 1498 | { |
1501 | - $ret = false; // cat denies access --> check further cats |
|
1499 | + $ret = false; // cat denies access --> check further cats |
|
1502 | 1500 | } |
1503 | 1501 | } |
1504 | 1502 | } |
@@ -1519,12 +1517,12 @@ discard block |
||
1519 | 1517 | * @param int $cat_id =null null to return array with all cats |
1520 | 1518 | * @return array with account_id => right pairs |
1521 | 1519 | */ |
1522 | - public static function get_cat_rights($cat_id=null) |
|
1520 | + public static function get_cat_rights($cat_id = null) |
|
1523 | 1521 | { |
1524 | 1522 | if (!isset(self::$cat_rights_cache)) |
1525 | 1523 | { |
1526 | - self::$cat_rights_cache = egw_cache::getSession('calendar','cat_rights', |
|
1527 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
1524 | + self::$cat_rights_cache = egw_cache::getSession('calendar', 'cat_rights', |
|
1525 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
1528 | 1526 | } |
1529 | 1527 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
1530 | 1528 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1537,7 +1535,7 @@ discard block |
||
1537 | 1535 | * @param int $user |
1538 | 1536 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
1539 | 1537 | */ |
1540 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
1538 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
1541 | 1539 | { |
1542 | 1540 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1543 | 1541 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1547,15 +1545,15 @@ discard block |
||
1547 | 1545 | if ($rights) |
1548 | 1546 | { |
1549 | 1547 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
1550 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
1548 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
1551 | 1549 | } |
1552 | 1550 | else |
1553 | 1551 | { |
1554 | 1552 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1555 | 1553 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
1556 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
1554 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
1557 | 1555 | } |
1558 | - egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
1556 | + egw_cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
1559 | 1557 | } |
1560 | 1558 | } |
1561 | 1559 | |
@@ -1566,9 +1564,9 @@ discard block |
||
1566 | 1564 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1567 | 1565 | * null = cat has no acl |
1568 | 1566 | */ |
1569 | - public static function has_cat_right($right,$cat_id,$user) |
|
1567 | + public static function has_cat_right($right, $cat_id, $user) |
|
1570 | 1568 | { |
1571 | - static $cache=null; |
|
1569 | + static $cache = null; |
|
1572 | 1570 | |
1573 | 1571 | if (!isset($cache[$cat_id])) |
1574 | 1572 | { |
@@ -1576,21 +1574,21 @@ discard block |
||
1576 | 1574 | $cat_rights = self::get_cat_rights($cat_id); |
1577 | 1575 | if (!is_null($cat_rights)) |
1578 | 1576 | { |
1579 | - static $memberships=null; |
|
1577 | + static $memberships = null; |
|
1580 | 1578 | if (is_null($memberships)) |
1581 | 1579 | { |
1582 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
1580 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
1583 | 1581 | $memberships[] = $user; |
1584 | 1582 | } |
1585 | - foreach($cat_rights as $uid => $value) |
|
1583 | + foreach ($cat_rights as $uid => $value) |
|
1586 | 1584 | { |
1587 | 1585 | $all |= $value; |
1588 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1586 | + if (in_array($uid, $memberships)) $own |= $value; |
|
1589 | 1587 | } |
1590 | 1588 | } |
1591 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
1589 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
1592 | 1590 | { |
1593 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
1591 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
1594 | 1592 | } |
1595 | 1593 | } |
1596 | 1594 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1610,13 +1608,13 @@ discard block |
||
1610 | 1608 | * @param boolean $skip_notification =false true: do not send notification messages |
1611 | 1609 | * @return int number of changed recurrences |
1612 | 1610 | */ |
1613 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
1611 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
1614 | 1612 | { |
1615 | 1613 | unset($updateTS); |
1616 | 1614 | |
1617 | 1615 | $cal_id = is_array($event) ? $event['id'] : $event; |
1618 | 1616 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
1619 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
1617 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
1620 | 1618 | { |
1621 | 1619 | return false; |
1622 | 1620 | } |
@@ -1625,16 +1623,16 @@ discard block |
||
1625 | 1623 | if ($this->log) |
1626 | 1624 | { |
1627 | 1625 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1628 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
1626 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
1629 | 1627 | } |
1630 | 1628 | $old_event = $this->read($cal_id, $recur_date, false, 'server'); |
1631 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
1632 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
1633 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
1629 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
1630 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
1631 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
1634 | 1632 | { |
1635 | 1633 | if ($status == 'R') // remove alarms belonging to rejected participants |
1636 | 1634 | { |
1637 | - foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1635 | + foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1638 | 1636 | { |
1639 | 1637 | if ((string)$alarm['owner'] === (string)$uid) |
1640 | 1638 | { |
@@ -1657,8 +1655,8 @@ discard block |
||
1657 | 1655 | if (isset($status2msg[$status]) && !$skip_notification) |
1658 | 1656 | { |
1659 | 1657 | if (!is_array($event)) $event = $this->read($cal_id); |
1660 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1661 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
1658 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
1659 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
1662 | 1660 | } |
1663 | 1661 | |
1664 | 1662 | // Update history |
@@ -1678,14 +1676,14 @@ discard block |
||
1678 | 1676 | * @param int $recur_date =0 date to change, or 0 = all since now |
1679 | 1677 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
1680 | 1678 | */ |
1681 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
1679 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
1682 | 1680 | { |
1683 | 1681 | if (!isset($new_event['participants'])) return; |
1684 | 1682 | |
1685 | 1683 | // check the old list against the new list |
1686 | 1684 | foreach ($old_event['participants'] as $userid => $status) |
1687 | 1685 | { |
1688 | - if (!isset($new_event['participants'][$userid])){ |
|
1686 | + if (!isset($new_event['participants'][$userid])) { |
|
1689 | 1687 | // Attendee will be deleted this way |
1690 | 1688 | $new_event['participants'][$userid] = 'G'; |
1691 | 1689 | } |
@@ -1698,7 +1696,7 @@ discard block |
||
1698 | 1696 | // write the changes |
1699 | 1697 | foreach ($new_event['participants'] as $userid => $status) |
1700 | 1698 | { |
1701 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
1699 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
1702 | 1700 | } |
1703 | 1701 | } |
1704 | 1702 | |
@@ -1713,43 +1711,43 @@ discard block |
||
1713 | 1711 | * @param int &$exceptions_kept=null on return number of kept exceptions |
1714 | 1712 | * @return boolean true on success, false on error (usually permission denied) |
1715 | 1713 | */ |
1716 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
1717 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
1714 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
1715 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
1718 | 1716 | { |
1719 | 1717 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
1720 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
1721 | - !$ignore_acl && !$this->check_perms(EGW_ACL_DELETE,$event)) |
|
1718 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
1719 | + !$ignore_acl && !$this->check_perms(EGW_ACL_DELETE, $event)) |
|
1722 | 1720 | { |
1723 | 1721 | return false; |
1724 | 1722 | } |
1725 | 1723 | |
1726 | 1724 | // Don't send notification if the event has already been deleted |
1727 | - if(!$event['deleted'] && !$skip_notification) |
|
1725 | + if (!$event['deleted'] && !$skip_notification) |
|
1728 | 1726 | { |
1729 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
1727 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
1730 | 1728 | } |
1731 | 1729 | |
1732 | 1730 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
1733 | 1731 | { |
1734 | 1732 | $config = config::read('phpgwapi'); |
1735 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
1733 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
1736 | 1734 | { |
1737 | 1735 | $this->so->delete($cal_id); |
1738 | 1736 | |
1739 | 1737 | // delete all links to the event |
1740 | - egw_link::unlink(0,'calendar',$cal_id); |
|
1738 | + egw_link::unlink(0, 'calendar', $cal_id); |
|
1741 | 1739 | } |
1742 | 1740 | elseif ($config['calendar_delete_history']) |
1743 | 1741 | { |
1744 | 1742 | // mark all links to the event as deleted, but keep them |
1745 | - egw_link::unlink(0,'calendar',$cal_id,'','','',true); |
|
1743 | + egw_link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
1746 | 1744 | |
1747 | 1745 | $event['deleted'] = $this->now; |
1748 | 1746 | $this->save($event, $ignore_acl); |
1749 | 1747 | // Actually delete alarms |
1750 | 1748 | if (isset($event['alarm']) && is_array($event['alarm'])) |
1751 | 1749 | { |
1752 | - foreach($event['alarm'] as $id => $alarm) |
|
1750 | + foreach ($event['alarm'] as $id => $alarm) |
|
1753 | 1751 | { |
1754 | 1752 | $this->delete_alarm($id); |
1755 | 1753 | } |
@@ -1772,7 +1770,7 @@ discard block |
||
1772 | 1770 | if (!($exception = $this->read($id))) continue; |
1773 | 1771 | $exception['uid'] = common::generate_uid('calendar', $id); |
1774 | 1772 | $exception['reference'] = $exception['recurrence'] = 0; |
1775 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
1773 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
1776 | 1774 | ++$exceptions_kept; |
1777 | 1775 | } |
1778 | 1776 | } |
@@ -1784,9 +1782,9 @@ discard block |
||
1784 | 1782 | if ($event['alarm']) |
1785 | 1783 | { |
1786 | 1784 | $next_recurrance = null; |
1787 | - foreach($event['alarm'] as &$alarm) |
|
1785 | + foreach ($event['alarm'] as &$alarm) |
|
1788 | 1786 | { |
1789 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
1787 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
1790 | 1788 | { |
1791 | 1789 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
1792 | 1790 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1794,12 +1792,12 @@ discard block |
||
1794 | 1792 | { |
1795 | 1793 | $checkdate = $recur_date; |
1796 | 1794 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
1797 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
1795 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
1798 | 1796 | { |
1799 | 1797 | $next_recurrance = $this->date2ts($e['start']); |
1800 | 1798 | } |
1801 | 1799 | } |
1802 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1800 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1803 | 1801 | $alarm['cal_id'] = $cal_id; |
1804 | 1802 | unset($alarm['times']); |
1805 | 1803 | unset($alarm['next']); |
@@ -1813,7 +1811,7 @@ discard block |
||
1813 | 1811 | $event = $this->read($cal_id); |
1814 | 1812 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
1815 | 1813 | $event['recur_exception'][] = $recur_date; |
1816 | - $this->save($event);// updates the content-history |
|
1814 | + $this->save($event); // updates the content-history |
|
1817 | 1815 | } |
1818 | 1816 | if ($event['reference']) |
1819 | 1817 | { |
@@ -1831,19 +1829,19 @@ discard block |
||
1831 | 1829 | * @param array $disinvited |
1832 | 1830 | * @return array |
1833 | 1831 | */ |
1834 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
1832 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
1835 | 1833 | { |
1836 | 1834 | $details = array( // event-details for the notify-msg |
1837 | 1835 | 'id' => $event['id'], |
1838 | 1836 | 'action' => lang($action), |
1839 | 1837 | ); |
1840 | 1838 | $event_arr = $this->event2array($event); |
1841 | - foreach($event_arr as $key => $val) |
|
1839 | + foreach ($event_arr as $key => $val) |
|
1842 | 1840 | { |
1843 | 1841 | if ($key == 'recur_type') $key = 'repetition'; |
1844 | 1842 | $details[$key] = $val['data']; |
1845 | 1843 | } |
1846 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
1844 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
1847 | 1845 | |
1848 | 1846 | $event_arr['link']['field'] = lang('URL'); |
1849 | 1847 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1864,7 +1862,7 @@ discard block |
||
1864 | 1862 | */ |
1865 | 1863 | $link_arr = array(); |
1866 | 1864 | $link_arr['text'] = $event['title']; |
1867 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
1865 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
1868 | 1866 | 'cal_id' => $event['id'], |
1869 | 1867 | 'date' => $eventStart_arr['full'], |
1870 | 1868 | ); |
@@ -1872,11 +1870,11 @@ discard block |
||
1872 | 1870 | $details['link_arr'] = $link_arr; |
1873 | 1871 | |
1874 | 1872 | $dis = array(); |
1875 | - foreach($disinvited as $uid) |
|
1873 | + foreach ($disinvited as $uid) |
|
1876 | 1874 | { |
1877 | 1875 | $dis[] = $this->participant_name($uid); |
1878 | 1876 | } |
1879 | - $details['disinvited'] = implode(', ',$dis); |
|
1877 | + $details['disinvited'] = implode(', ', $dis); |
|
1880 | 1878 | return $details; |
1881 | 1879 | } |
1882 | 1880 | |
@@ -1900,14 +1898,14 @@ discard block |
||
1900 | 1898 | 'data' => $event['description'] |
1901 | 1899 | ); |
1902 | 1900 | |
1903 | - foreach(explode(',',$event['category']) as $cat_id) |
|
1901 | + foreach (explode(',', $event['category']) as $cat_id) |
|
1904 | 1902 | { |
1905 | 1903 | list($cat) = $GLOBALS['egw']->categories->return_single($cat_id); |
1906 | 1904 | $cat_string[] = stripslashes($cat['name']); |
1907 | 1905 | } |
1908 | 1906 | $var['category'] = Array( |
1909 | 1907 | 'field' => lang('Category'), |
1910 | - 'data' => implode(', ',$cat_string) |
|
1908 | + 'data' => implode(', ', $cat_string) |
|
1911 | 1909 | ); |
1912 | 1910 | |
1913 | 1911 | $var['location'] = Array( |
@@ -1953,7 +1951,7 @@ discard block |
||
1953 | 1951 | |
1954 | 1952 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
1955 | 1953 | { |
1956 | - $participants = $this->participants($event,true); |
|
1954 | + $participants = $this->participants($event, true); |
|
1957 | 1955 | } |
1958 | 1956 | $var['participants'] = Array( |
1959 | 1957 | 'field' => lang('Participants'), |
@@ -1976,26 +1974,26 @@ discard block |
||
1976 | 1974 | * @param array $old_event =null event-data in the DB before calling save |
1977 | 1975 | * @param string $type ='update' |
1978 | 1976 | */ |
1979 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
1977 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
1980 | 1978 | { |
1981 | - if (!($f = fopen($this->log_file,'a'))) |
|
1979 | + if (!($f = fopen($this->log_file, 'a'))) |
|
1982 | 1980 | { |
1983 | 1981 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
1984 | 1982 | return false; |
1985 | 1983 | } |
1986 | - fwrite($f,$type.': '.common::grab_owner_name($this->user).': '.date('r')."\n"); |
|
1987 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
1988 | - foreach(array('start','end') as $name) |
|
1984 | + fwrite($f, $type.': '.common::grab_owner_name($this->user).': '.date('r')."\n"); |
|
1985 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
1986 | + foreach (array('start', 'end') as $name) |
|
1989 | 1987 | { |
1990 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1991 | - $this->format_date($event_saved[$name]) .' / '. |
|
1988 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1989 | + $this->format_date($event_saved[$name]).' / '. |
|
1992 | 1990 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
1993 | 1991 | } |
1994 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
1992 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
1995 | 1993 | { |
1996 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
1994 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
1997 | 1995 | } |
1998 | - fwrite($f,"\n"); |
|
1996 | + fwrite($f, "\n"); |
|
1999 | 1997 | fclose($f); |
2000 | 1998 | |
2001 | 1999 | return true; |
@@ -2016,14 +2014,14 @@ discard block |
||
2016 | 2014 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
2017 | 2015 | |
2018 | 2016 | $time = new egw_time($event['start']); |
2019 | - if(!is_array($event['alarm'])) |
|
2017 | + if (!is_array($event['alarm'])) |
|
2020 | 2018 | { |
2021 | 2019 | $event['alarm'] = $this->so->read_alarms($event['id']); |
2022 | 2020 | } |
2023 | 2021 | |
2024 | - foreach($event['alarm'] as $id => &$alarm) |
|
2022 | + foreach ($event['alarm'] as $id => &$alarm) |
|
2025 | 2023 | { |
2026 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
2024 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
2027 | 2025 | { |
2028 | 2026 | calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts')); |
2029 | 2027 | } |
@@ -2043,14 +2041,14 @@ discard block |
||
2043 | 2041 | * @param boolean $update_modified =true call update modified, default true |
2044 | 2042 | * @return string id of the alarm, or false on error (eg. no perms) |
2045 | 2043 | */ |
2046 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
2044 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
2047 | 2045 | { |
2048 | - if (!$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
2046 | + if (!$cal_id || !$this->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
2049 | 2047 | { |
2050 | 2048 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
2051 | - return false; // no rights to add the alarm |
|
2049 | + return false; // no rights to add the alarm |
|
2052 | 2050 | } |
2053 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
2051 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
2054 | 2052 | |
2055 | 2053 | $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); |
2056 | 2054 | |
@@ -2065,11 +2063,11 @@ discard block |
||
2065 | 2063 | */ |
2066 | 2064 | function delete_alarm($id) |
2067 | 2065 | { |
2068 | - list(,$cal_id) = explode(':',$id); |
|
2066 | + list(,$cal_id) = explode(':', $id); |
|
2069 | 2067 | |
2070 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
2068 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
2071 | 2069 | { |
2072 | - return false; // no rights to delete the alarm |
|
2070 | + return false; // no rights to delete the alarm |
|
2073 | 2071 | } |
2074 | 2072 | |
2075 | 2073 | $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); |
@@ -2086,13 +2084,13 @@ discard block |
||
2086 | 2084 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
2087 | 2085 | * @return array category ids (found, added and preserved categories) |
2088 | 2086 | */ |
2089 | - function find_or_add_categories($catname_list, $old_event=null) |
|
2087 | + function find_or_add_categories($catname_list, $old_event = null) |
|
2090 | 2088 | { |
2091 | 2089 | if (is_array($old_event) || $old_event > 0) |
2092 | 2090 | { |
2093 | 2091 | // preserve categories without users read access |
2094 | 2092 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
2095 | - $old_categories = explode(',',$old_event['category']); |
|
2093 | + $old_categories = explode(',', $old_event['category']); |
|
2096 | 2094 | $old_cats_preserve = array(); |
2097 | 2095 | if (is_array($old_categories) && count($old_categories) > 0) |
2098 | 2096 | { |
@@ -2146,7 +2144,7 @@ discard block |
||
2146 | 2144 | { |
2147 | 2145 | if (!is_array($cat_id_list)) |
2148 | 2146 | { |
2149 | - $cat_id_list = explode(',',$cat_id_list); |
|
2147 | + $cat_id_list = explode(',', $cat_id_list); |
|
2150 | 2148 | } |
2151 | 2149 | $cat_list = array(); |
2152 | 2150 | foreach ($cat_id_list as $cat_id) |
@@ -2171,7 +2169,7 @@ discard block |
||
2171 | 2169 | * master -> try to find a releated series master |
2172 | 2170 | * @return array calendar_ids of matching entries |
2173 | 2171 | */ |
2174 | - function find_event($event, $filter='exact') |
|
2172 | + function find_event($event, $filter = 'exact') |
|
2175 | 2173 | { |
2176 | 2174 | $matchingEvents = array(); |
2177 | 2175 | $query = array(); |
@@ -2179,14 +2177,14 @@ discard block |
||
2179 | 2177 | if ($this->log) |
2180 | 2178 | { |
2181 | 2179 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2182 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
2180 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
2183 | 2181 | } |
2184 | 2182 | |
2185 | 2183 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
2186 | 2184 | |
2187 | 2185 | if ($filter == 'master') |
2188 | 2186 | { |
2189 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
2187 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
2190 | 2188 | $query['cal_recurrence'] = 0; |
2191 | 2189 | } |
2192 | 2190 | elseif ($filter == 'exact') |
@@ -2207,14 +2205,14 @@ discard block |
||
2207 | 2205 | if ($this->log) |
2208 | 2206 | { |
2209 | 2207 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2210 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
2208 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
2211 | 2209 | } |
2212 | 2210 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
2213 | 2211 | { |
2214 | 2212 | if ($this->log) |
2215 | 2213 | { |
2216 | 2214 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2217 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2215 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2218 | 2216 | } |
2219 | 2217 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
2220 | 2218 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2233,7 +2231,7 @@ discard block |
||
2233 | 2231 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
2234 | 2232 | if (in_array($event['recurrence'], $exceptions)) |
2235 | 2233 | { |
2236 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
2234 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
2237 | 2235 | } |
2238 | 2236 | } |
2239 | 2237 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2252,19 +2250,19 @@ discard block |
||
2252 | 2250 | |
2253 | 2251 | // only query calendars of users, we have READ-grants from |
2254 | 2252 | $users = array(); |
2255 | - foreach(array_keys($this->grants) as $user) |
|
2253 | + foreach (array_keys($this->grants) as $user) |
|
2256 | 2254 | { |
2257 | 2255 | $user = trim($user); |
2258 | - if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user)) |
|
2256 | + if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY, 0, $user)) |
|
2259 | 2257 | { |
2260 | - if ($user && !in_array($user,$users)) // already added? |
|
2258 | + if ($user && !in_array($user, $users)) // already added? |
|
2261 | 2259 | { |
2262 | 2260 | $users[] = $user; |
2263 | 2261 | } |
2264 | 2262 | } |
2265 | 2263 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2266 | 2264 | { |
2267 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2265 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2268 | 2266 | } |
2269 | 2267 | // the further code is only for real users |
2270 | 2268 | if (!is_numeric($user)) continue; |
@@ -2275,11 +2273,11 @@ discard block |
||
2275 | 2273 | $members = $GLOBALS['egw']->accounts->member($user); |
2276 | 2274 | if (is_array($members)) |
2277 | 2275 | { |
2278 | - foreach($members as $member) |
|
2276 | + foreach ($members as $member) |
|
2279 | 2277 | { |
2280 | 2278 | // use only members which gave the user a read-grant |
2281 | - if (!in_array($member['account_id'],$users) && |
|
2282 | - $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY,0,$member['account_id'])) |
|
2279 | + if (!in_array($member['account_id'], $users) && |
|
2280 | + $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $member['account_id'])) |
|
2283 | 2281 | { |
2284 | 2282 | $users[] = $member['account_id']; |
2285 | 2283 | } |
@@ -2291,9 +2289,9 @@ discard block |
||
2291 | 2289 | $memberships = $GLOBALS['egw']->accounts->membership($user); |
2292 | 2290 | if (is_array($memberships)) |
2293 | 2291 | { |
2294 | - foreach($memberships as $group) |
|
2292 | + foreach ($memberships as $group) |
|
2295 | 2293 | { |
2296 | - if (!in_array($group['account_id'],$users)) |
|
2294 | + if (!in_array($group['account_id'], $users)) |
|
2297 | 2295 | { |
2298 | 2296 | $users[] = $group['account_id']; |
2299 | 2297 | } |
@@ -2317,24 +2315,24 @@ discard block |
||
2317 | 2315 | |
2318 | 2316 | // check length with some tolerance |
2319 | 2317 | $length = $event['end'] - $event['start'] - $delta; |
2320 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
2318 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
2321 | 2319 | $length += 2 * $delta; |
2322 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
2323 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
2324 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
2320 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
2321 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
2322 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
2325 | 2323 | } |
2326 | 2324 | elseif (isset($event['start'])) |
2327 | 2325 | { |
2328 | 2326 | if ($filter == 'relax') |
2329 | 2327 | { |
2330 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
2331 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
2328 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
2329 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
2332 | 2330 | } |
2333 | 2331 | else |
2334 | 2332 | { |
2335 | 2333 | // we accept a tiny tolerance |
2336 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
2337 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
2334 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
2335 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
2338 | 2336 | } |
2339 | 2337 | } |
2340 | 2338 | if ($filter == 'relax') |
@@ -2357,14 +2355,14 @@ discard block |
||
2357 | 2355 | if ($this->log) |
2358 | 2356 | { |
2359 | 2357 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2360 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
2358 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
2361 | 2359 | } |
2362 | 2360 | } |
2363 | 2361 | |
2364 | 2362 | if ($this->log) |
2365 | 2363 | { |
2366 | 2364 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2367 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
2365 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
2368 | 2366 | } |
2369 | 2367 | if (!count($users) || !($foundEvents = |
2370 | 2368 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2372,19 +2370,19 @@ discard block |
||
2372 | 2370 | if ($this->log) |
2373 | 2371 | { |
2374 | 2372 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2375 | - "[NO MATCH]\n",3,$this->logfile); |
|
2373 | + "[NO MATCH]\n", 3, $this->logfile); |
|
2376 | 2374 | } |
2377 | 2375 | return $matchingEvents; |
2378 | 2376 | } |
2379 | 2377 | |
2380 | 2378 | $pseudos = array(); |
2381 | 2379 | |
2382 | - foreach($foundEvents as $egwEvent) |
|
2380 | + foreach ($foundEvents as $egwEvent) |
|
2383 | 2381 | { |
2384 | 2382 | if ($this->log) |
2385 | 2383 | { |
2386 | 2384 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2387 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2385 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2388 | 2386 | } |
2389 | 2387 | |
2390 | 2388 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2458,7 +2456,7 @@ discard block |
||
2458 | 2456 | if (in_array($event['recurrence'], $exceptions)) |
2459 | 2457 | { |
2460 | 2458 | // We found a pseudo exception |
2461 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
2459 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
2462 | 2460 | break; |
2463 | 2461 | } |
2464 | 2462 | } |
@@ -2476,7 +2474,7 @@ discard block |
||
2476 | 2474 | if ($this->log) |
2477 | 2475 | { |
2478 | 2476 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2479 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
2477 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
2480 | 2478 | } |
2481 | 2479 | continue; |
2482 | 2480 | } |
@@ -2488,7 +2486,7 @@ discard block |
||
2488 | 2486 | if ($this->log) |
2489 | 2487 | { |
2490 | 2488 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2491 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
2489 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
2492 | 2490 | } |
2493 | 2491 | continue; |
2494 | 2492 | } |
@@ -2509,8 +2507,8 @@ discard block |
||
2509 | 2507 | if ($this->log) |
2510 | 2508 | { |
2511 | 2509 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2512 | - "() event[$key] differ: '" . $event[$key] . |
|
2513 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
2510 | + "() event[$key] differ: '".$event[$key]. |
|
2511 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
2514 | 2512 | } |
2515 | 2513 | continue 2; // next foundEvent |
2516 | 2514 | } |
@@ -2528,7 +2526,7 @@ discard block |
||
2528 | 2526 | if ($this->log) |
2529 | 2527 | { |
2530 | 2528 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2531 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
2529 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
2532 | 2530 | } |
2533 | 2531 | continue 2; |
2534 | 2532 | } |
@@ -2540,7 +2538,7 @@ discard block |
||
2540 | 2538 | { |
2541 | 2539 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2542 | 2540 | '() event has additional categories:' |
2543 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
2541 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
2544 | 2542 | } |
2545 | 2543 | continue; |
2546 | 2544 | } |
@@ -2560,7 +2558,7 @@ discard block |
||
2560 | 2558 | if ($this->log) |
2561 | 2559 | { |
2562 | 2560 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2563 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
2561 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
2564 | 2562 | } |
2565 | 2563 | continue 2; |
2566 | 2564 | } |
@@ -2583,8 +2581,8 @@ discard block |
||
2583 | 2581 | if ($this->log) |
2584 | 2582 | { |
2585 | 2583 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2586 | - '() missing event[participants]: ' . |
|
2587 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
2584 | + '() missing event[participants]: '. |
|
2585 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
2588 | 2586 | } |
2589 | 2587 | continue; |
2590 | 2588 | } |
@@ -2596,7 +2594,7 @@ discard block |
||
2596 | 2594 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
2597 | 2595 | { |
2598 | 2596 | // We found a pseudo Exception |
2599 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
2597 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
2600 | 2598 | continue; |
2601 | 2599 | } |
2602 | 2600 | } |
@@ -2618,7 +2616,7 @@ discard block |
||
2618 | 2616 | if ($this->log) |
2619 | 2617 | { |
2620 | 2618 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2621 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
2619 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
2622 | 2620 | } |
2623 | 2621 | continue 2; |
2624 | 2622 | } |
@@ -2628,8 +2626,8 @@ discard block |
||
2628 | 2626 | if ($this->log) |
2629 | 2627 | { |
2630 | 2628 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2631 | - '() missing event[recur_exception]: ' . |
|
2632 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
2629 | + '() missing event[recur_exception]: '. |
|
2630 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
2633 | 2631 | } |
2634 | 2632 | continue; |
2635 | 2633 | } |
@@ -2644,8 +2642,8 @@ discard block |
||
2644 | 2642 | if ($this->log) |
2645 | 2643 | { |
2646 | 2644 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2647 | - "() events[$key] differ: " . $event[$key] . |
|
2648 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
2645 | + "() events[$key] differ: ".$event[$key]. |
|
2646 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
2649 | 2647 | } |
2650 | 2648 | continue 2; |
2651 | 2649 | } |
@@ -2661,7 +2659,7 @@ discard block |
||
2661 | 2659 | if ($this->log) |
2662 | 2660 | { |
2663 | 2661 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2664 | - "() new exception for series found.\n",3,$this->logfile); |
|
2662 | + "() new exception for series found.\n", 3, $this->logfile); |
|
2665 | 2663 | } |
2666 | 2664 | $matchingEvents = array(); |
2667 | 2665 | } |
@@ -2672,7 +2670,7 @@ discard block |
||
2672 | 2670 | if ($this->log) |
2673 | 2671 | { |
2674 | 2672 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2675 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
2673 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
2676 | 2674 | } |
2677 | 2675 | return $matches; |
2678 | 2676 | } |
@@ -2745,7 +2743,7 @@ discard block |
||
2745 | 2743 | if ($this->log) |
2746 | 2744 | { |
2747 | 2745 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2748 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
2746 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
2749 | 2747 | } |
2750 | 2748 | $type = 'SERIES-EXCEPTION'; |
2751 | 2749 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2766,7 +2764,7 @@ discard block |
||
2766 | 2764 | } |
2767 | 2765 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
2768 | 2766 | { |
2769 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2767 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2770 | 2768 | $recurrence_event = $master_event; |
2771 | 2769 | $recurrence_event['start'] = $event['start']; |
2772 | 2770 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2783,8 +2781,8 @@ discard block |
||
2783 | 2781 | if ($this->log) |
2784 | 2782 | { |
2785 | 2783 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2786 | - '() try occurrence ' . $egw_rrule->current() |
|
2787 | - . " ($occurrence)\n",3,$this->logfile); |
|
2784 | + '() try occurrence '.$egw_rrule->current() |
|
2785 | + . " ($occurrence)\n", 3, $this->logfile); |
|
2788 | 2786 | } |
2789 | 2787 | if ($event['start'] == $occurrence) |
2790 | 2788 | { |
@@ -2817,8 +2815,8 @@ discard block |
||
2817 | 2815 | // default if we cannot find a proof for a fundamental change |
2818 | 2816 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
2819 | 2817 | // check for changed data |
2820 | - foreach (array('start','end','uid','title','location','description', |
|
2821 | - 'priority','public','special','non_blocking') as $key) |
|
2818 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
2819 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
2822 | 2820 | { |
2823 | 2821 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
2824 | 2822 | { |
@@ -2876,10 +2874,10 @@ discard block |
||
2876 | 2874 | * @param &$event the event we are working on |
2877 | 2875 | * |
2878 | 2876 | */ |
2879 | - function server2usertime (&$event) |
|
2877 | + function server2usertime(&$event) |
|
2880 | 2878 | { |
2881 | 2879 | // we run all dates through date2usertime, to adjust to user-time |
2882 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
2880 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
2883 | 2881 | { |
2884 | 2882 | // we convert here from server-time to timestamps in user-time! |
2885 | 2883 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2887,7 +2885,7 @@ discard block |
||
2887 | 2885 | // same with the recur exceptions |
2888 | 2886 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
2889 | 2887 | { |
2890 | - foreach($event['recur_exception'] as $n => $date) |
|
2888 | + foreach ($event['recur_exception'] as $n => $date) |
|
2891 | 2889 | { |
2892 | 2890 | $event['recur_exception'][$n] = $this->date2usertime($date); |
2893 | 2891 | } |
@@ -2895,7 +2893,7 @@ discard block |
||
2895 | 2893 | // same with the alarms |
2896 | 2894 | if (isset($event['alarm']) && is_array($event['alarm'])) |
2897 | 2895 | { |
2898 | - foreach($event['alarm'] as $id => $alarm) |
|
2896 | + foreach ($event['alarm'] as $id => $alarm) |
|
2899 | 2897 | { |
2900 | 2898 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
2901 | 2899 | } |
@@ -2912,7 +2910,7 @@ discard block |
||
2912 | 2910 | { |
2913 | 2911 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
2914 | 2912 | { |
2915 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
2913 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
2916 | 2914 | } |
2917 | 2915 | } |
2918 | 2916 | } |
@@ -81,11 +81,17 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function __construct() |
83 | 83 | { |
84 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
84 | + if ($this->debug > 0) |
|
85 | + { |
|
86 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
87 | + } |
|
85 | 88 | |
86 | 89 | parent::__construct(); // calling the parent constructor |
87 | 90 | |
88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
91 | + if ($this->debug > 0) |
|
92 | + { |
|
93 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
94 | + } |
|
89 | 95 | } |
90 | 96 | |
91 | 97 | /** |
@@ -115,7 +121,10 @@ discard block |
||
115 | 121 | function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
116 | 122 | { |
117 | 123 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
118 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
124 | + if (!is_array($messages)) |
|
125 | + { |
|
126 | + $messages = $messages ? (array)$messages : array(); |
|
127 | + } |
|
119 | 128 | |
120 | 129 | if ($this->debug > 1 || $this->debug == 'update') |
121 | 130 | { |
@@ -135,10 +144,13 @@ discard block |
||
135 | 144 | |
136 | 145 | $status_reset_to_unknown = false; |
137 | 146 | |
138 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
147 | + if (($new_event = !$event['id'])) |
|
148 | + { |
|
149 | + // some defaults for new entries |
|
139 | 150 | { |
140 | 151 | // if no owner given, set user to owner |
141 | 152 | if (!$event['owner']) $event['owner'] = $this->user; |
153 | + } |
|
142 | 154 | // set owner as participant if none is given |
143 | 155 | if (!is_array($event['participants']) || !count($event['participants'])) |
144 | 156 | { |
@@ -178,7 +190,10 @@ discard block |
||
178 | 190 | // check category based ACL |
179 | 191 | if ($event['category']) |
180 | 192 | { |
181 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
193 | + if (!is_array($event['category'])) |
|
194 | + { |
|
195 | + $event['category'] = explode(',',$event['category']); |
|
196 | + } |
|
182 | 197 | if (!$old_event || !isset($old_event['category'])) |
183 | 198 | { |
184 | 199 | $old_event['category'] = array(); |
@@ -231,18 +246,28 @@ discard block |
||
231 | 246 | $types_with_quantity = array(); |
232 | 247 | foreach($this->resources as $type => $data) |
233 | 248 | { |
234 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
249 | + if ($data['max_quantity']) |
|
250 | + { |
|
251 | + $types_with_quantity[] = $type; |
|
252 | + } |
|
235 | 253 | } |
236 | 254 | // get all NOT rejected participants and evtl. their quantity |
237 | 255 | $quantity = $users = array(); |
238 | 256 | foreach($event['participants'] as $uid => $status) |
239 | 257 | { |
240 | 258 | calendar_so::split_status($status,$q,$r); |
241 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
259 | + if ($status[0] == 'R') |
|
260 | + { |
|
261 | + continue; |
|
262 | + } |
|
263 | + // ignore rejected participants |
|
242 | 264 | |
243 | - if ($uid < 0) // group, check it's members too |
|
265 | + if ($uid < 0) |
|
266 | + { |
|
267 | + // group, check it's members too |
|
244 | 268 | { |
245 | 269 | $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
270 | + } |
|
246 | 271 | $users = array_unique($users); |
247 | 272 | } |
248 | 273 | $users[] = $uid; |
@@ -273,10 +298,13 @@ discard block |
||
273 | 298 | { |
274 | 299 | if ($overlap['id'] == $event['id'] || // that's the event itself |
275 | 300 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
276 | - $overlap['non_blocking']) // that's a non_blocking event |
|
301 | + $overlap['non_blocking']) |
|
302 | + { |
|
303 | + // that's a non_blocking event |
|
277 | 304 | { |
278 | 305 | continue; |
279 | 306 | } |
307 | + } |
|
280 | 308 | if ($this->debug > 3 || $this->debug == 'update') |
281 | 309 | { |
282 | 310 | $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
@@ -414,7 +442,10 @@ discard block |
||
414 | 442 | $types_with_quantity = array(); |
415 | 443 | foreach($this->resources as $type => $data) |
416 | 444 | { |
417 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
445 | + if ($data['max_quantity']) |
|
446 | + { |
|
447 | + $types_with_quantity[] = $type; |
|
448 | + } |
|
418 | 449 | } |
419 | 450 | // get all NOT rejected participants and evtl. their quantity |
420 | 451 | $quantity = $users = array(); |
@@ -422,12 +453,19 @@ discard block |
||
422 | 453 | { |
423 | 454 | $q = $r = null; |
424 | 455 | calendar_so::split_status($status,$q,$r); |
425 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
456 | + if ($status[0] == 'R') |
|
457 | + { |
|
458 | + continue; |
|
459 | + } |
|
460 | + // ignore rejected participants |
|
426 | 461 | |
427 | - if ($uid < 0) // group, check it's members too |
|
462 | + if ($uid < 0) |
|
463 | + { |
|
464 | + // group, check it's members too |
|
428 | 465 | { |
429 | 466 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
430 | 467 | } |
468 | + } |
|
431 | 469 | $users[] = $uid; |
432 | 470 | if (in_array($uid[0],$types_with_quantity)) |
433 | 471 | { |
@@ -458,18 +496,24 @@ discard block |
||
458 | 496 | $startts = $date->format('ts'); |
459 | 497 | |
460 | 498 | // skip past events or recurrences |
461 | - if ($startts+$duration < $this->now_su) continue; |
|
499 | + if ($startts+$duration < $this->now_su) |
|
500 | + { |
|
501 | + continue; |
|
502 | + } |
|
462 | 503 | |
463 | 504 | // abort check if configured limits are exceeded |
464 | 505 | if ($event['recur_type'] && |
465 | 506 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
466 | 507 | microtime(true) > $start+$max_check_time || // max check time exceeded |
467 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
508 | + $startts > $this->config['horizont'])) |
|
509 | + { |
|
510 | + // we are behind horizon for which recurrences are rendered |
|
468 | 511 | { |
469 | 512 | if ($this->debug > 2 || $this->debug == 'conflicts') |
470 | 513 | { |
471 | 514 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
472 | 515 | $checked, microtime(true)-$start, $date); |
516 | + } |
|
473 | 517 | } |
474 | 518 | $checked_excluding = $date; |
475 | 519 | break; |
@@ -493,10 +537,13 @@ discard block |
||
493 | 537 | { |
494 | 538 | if ($overlap['id'] == $event['id'] || // that's the event itself |
495 | 539 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
496 | - $overlap['non_blocking']) // that's a non_blocking event |
|
540 | + $overlap['non_blocking']) |
|
541 | + { |
|
542 | + // that's a non_blocking event |
|
497 | 543 | { |
498 | 544 | continue; |
499 | 545 | } |
546 | + } |
|
500 | 547 | if ($this->debug > 3 || $this->debug == 'conflicts') |
501 | 548 | { |
502 | 549 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -617,7 +664,11 @@ discard block |
||
617 | 664 | */ |
618 | 665 | public function check_acl_invite($uid) |
619 | 666 | { |
620 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
667 | + if (!is_numeric($uid)) |
|
668 | + { |
|
669 | + return true; |
|
670 | + } |
|
671 | + // nothing implemented for resources so far |
|
621 | 672 | |
622 | 673 | if (!$this->require_acl_invite) |
623 | 674 | { |
@@ -958,14 +1009,20 @@ discard block |
||
958 | 1009 | $startdate = new egw_time($event['start']); |
959 | 1010 | $enddate = new egw_time($event['end']); |
960 | 1011 | $modified = new egw_time($event['modified']); |
961 | - if ($old_event) $olddate = new egw_time($old_event['start']); |
|
1012 | + if ($old_event) |
|
1013 | + { |
|
1014 | + $olddate = new egw_time($old_event['start']); |
|
1015 | + } |
|
962 | 1016 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
963 | 1017 | $owner_prefs = $ics = null; |
964 | 1018 | foreach($to_notify as $userid => $statusid) |
965 | 1019 | { |
966 | 1020 | $res_info = $quantity = $role = null; |
967 | 1021 | calendar_so::split_status($statusid, $quantity, $role); |
968 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
1022 | + if ($this->debug > 0) |
|
1023 | + { |
|
1024 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
1025 | + } |
|
969 | 1026 | |
970 | 1027 | if (!is_numeric($userid)) |
971 | 1028 | { |
@@ -984,7 +1041,11 @@ discard block |
||
984 | 1041 | |
985 | 1042 | if (!isset($userid)) |
986 | 1043 | { |
987 | - if (empty($res_info['email'])) continue; // no way to notify |
|
1044 | + if (empty($res_info['email'])) |
|
1045 | + { |
|
1046 | + continue; |
|
1047 | + } |
|
1048 | + // no way to notify |
|
988 | 1049 | // check if event-owner wants non-EGroupware users notified |
989 | 1050 | if (is_null($owner_prefs)) |
990 | 1051 | { |
@@ -1049,11 +1110,20 @@ discard block |
||
1049 | 1110 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
1050 | 1111 | $action, $event_arr, $disinvited); |
1051 | 1112 | $details['to-fullname'] = $fullname; |
1052 | - if (isset($tfn)) $details['to-firstname'] = $tfn; |
|
1053 | - if (isset($tln)) $details['to-lastname'] = $tln; |
|
1113 | + if (isset($tfn)) |
|
1114 | + { |
|
1115 | + $details['to-firstname'] = $tfn; |
|
1116 | + } |
|
1117 | + if (isset($tln)) |
|
1118 | + { |
|
1119 | + $details['to-lastname'] = $tln; |
|
1120 | + } |
|
1054 | 1121 | |
1055 | 1122 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
1056 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
1123 | + if (!isset($part_prefs['common']['tz'])) |
|
1124 | + { |
|
1125 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
1126 | + } |
|
1057 | 1127 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
1058 | 1128 | $timeformat = $part_prefs['common']['timeformat']; |
1059 | 1129 | switch($timeformat) |
@@ -1088,9 +1158,12 @@ discard block |
||
1088 | 1158 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
1089 | 1159 | { |
1090 | 1160 | case 'ical': |
1091 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1161 | + if (is_null($ics) || $m_type != $msg_type) |
|
1162 | + { |
|
1163 | + // need different ical for organizer notification |
|
1092 | 1164 | { |
1093 | 1165 | $calendar_ical = new calendar_ical(); |
1166 | + } |
|
1094 | 1167 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
1095 | 1168 | // we need to pass $event[id] so iCal class reads event again, |
1096 | 1169 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1104,7 +1177,10 @@ discard block |
||
1104 | 1177 | 'encoding' => '8bit', |
1105 | 1178 | 'type' => 'text/calendar; method='.$method, |
1106 | 1179 | ); |
1107 | - if ($m_type != $msg_type) unset($ics); |
|
1180 | + if ($m_type != $msg_type) |
|
1181 | + { |
|
1182 | + unset($ics); |
|
1183 | + } |
|
1108 | 1184 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
1109 | 1185 | // fall through |
1110 | 1186 | case 'extended': |
@@ -1155,7 +1231,9 @@ discard block |
||
1155 | 1231 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
1156 | 1232 | $notification->set_popuplinks(array($details['link_arr'])); |
1157 | 1233 | |
1158 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1234 | + if(is_array($attachment)) |
|
1235 | + { |
|
1236 | +$notification->set_attachments(array($attachment)); } |
|
1159 | 1237 | $notification->send(); |
1160 | 1238 | } |
1161 | 1239 | catch (Exception $exception) { |
@@ -1182,7 +1260,10 @@ discard block |
||
1182 | 1260 | translation::init(); |
1183 | 1261 | } |
1184 | 1262 | // restore timezone, in case we had to reset it to server-timezone |
1185 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
1263 | + if ($restore_tz) |
|
1264 | + { |
|
1265 | + date_default_timezone_set($restore_tz); |
|
1266 | + } |
|
1186 | 1267 | |
1187 | 1268 | return true; |
1188 | 1269 | } |
@@ -1217,10 +1298,13 @@ discard block |
||
1217 | 1298 | { |
1218 | 1299 | $to_notify = $event['participants']; |
1219 | 1300 | } |
1220 | - elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1301 | + elseif ($this->check_perms(EGW_ACL_READ,$event)) |
|
1302 | + { |
|
1303 | + // checks agains $this->owner set to $alarm[owner] |
|
1221 | 1304 | { |
1222 | 1305 | $to_notify[$alarm['owner']] = 'A'; |
1223 | 1306 | } |
1307 | + } |
|
1224 | 1308 | else |
1225 | 1309 | { |
1226 | 1310 | return False; // no rights |
@@ -1270,7 +1354,10 @@ discard block |
||
1270 | 1354 | if ($event['id']) |
1271 | 1355 | { |
1272 | 1356 | // invalidate the read-cache if it contains the event we store now |
1273 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
1357 | + if ($event['id'] == self::$cached_event['id']) |
|
1358 | + { |
|
1359 | + self::$cached_event = array(); |
|
1360 | + } |
|
1274 | 1361 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
1275 | 1362 | } |
1276 | 1363 | else |
@@ -1278,7 +1365,10 @@ discard block |
||
1278 | 1365 | $old_event = null; |
1279 | 1366 | } |
1280 | 1367 | |
1281 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
1368 | + if (!isset($event['whole_day'])) |
|
1369 | + { |
|
1370 | + $event['whole_day'] = $this->isWholeDay($event); |
|
1371 | + } |
|
1282 | 1372 | $save_event = $event; |
1283 | 1373 | if ($event['whole_day']) |
1284 | 1374 | { |
@@ -1319,7 +1409,10 @@ discard block |
||
1319 | 1409 | foreach($timestamps as $ts) |
1320 | 1410 | { |
1321 | 1411 | // we convert here from user-time to timestamps in server-time! |
1322 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1412 | + if (isset($event[$ts])) |
|
1413 | + { |
|
1414 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1415 | + } |
|
1323 | 1416 | } |
1324 | 1417 | // convert tzid name to integer tz_id, of set user default |
1325 | 1418 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1369,7 +1462,10 @@ discard block |
||
1369 | 1462 | if (!isset($event['alarm'][$id])) |
1370 | 1463 | { |
1371 | 1464 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1372 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
1465 | + if ($alarm['time'] < time()) |
|
1466 | + { |
|
1467 | + calendar_so::shift_alarm($event, $alarm); |
|
1468 | + } |
|
1373 | 1469 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1374 | 1470 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
1375 | 1471 | $old_event['participants'][$alarm['owner']]; |
@@ -1405,7 +1501,10 @@ discard block |
||
1405 | 1501 | unset($save_event['participants']); |
1406 | 1502 | $this->set_recurrences($save_event, $set_recurrences_start); |
1407 | 1503 | } |
1408 | - if ($updateTS) $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
1504 | + if ($updateTS) |
|
1505 | + { |
|
1506 | + $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
1507 | + } |
|
1409 | 1508 | |
1410 | 1509 | // create links for new participants from addressbook, if configured |
1411 | 1510 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
@@ -1423,7 +1522,10 @@ discard block |
||
1423 | 1522 | |
1424 | 1523 | // Update history |
1425 | 1524 | $tracking = new calendar_tracking($this); |
1426 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1525 | + if (empty($event['id']) && !empty($cal_id)) |
|
1526 | + { |
|
1527 | + $event['id']=$cal_id; |
|
1528 | + } |
|
1427 | 1529 | $tracking->track($event, $old_event); |
1428 | 1530 | |
1429 | 1531 | return $cal_id; |
@@ -1440,9 +1542,12 @@ discard block |
||
1440 | 1542 | */ |
1441 | 1543 | function check_status_perms($uid,$event) |
1442 | 1544 | { |
1443 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
1545 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
1546 | + { |
|
1547 | + // for contact we use the owner of the event |
|
1444 | 1548 | { |
1445 | 1549 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1550 | + } |
|
1446 | 1551 | |
1447 | 1552 | return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']); |
1448 | 1553 | } |
@@ -1453,13 +1558,19 @@ discard block |
||
1453 | 1558 | return $access; |
1454 | 1559 | } |
1455 | 1560 | // no access or denied access because of category acl --> regular check |
1456 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
1561 | + if (!is_numeric($uid)) |
|
1562 | + { |
|
1563 | + // this is eg. for resources (r123) |
|
1457 | 1564 | { |
1458 | 1565 | $resource = $this->resource_info($uid); |
1566 | + } |
|
1459 | 1567 | |
1460 | 1568 | return EGW_ACL_EDIT & $resource['rights']; |
1461 | 1569 | } |
1462 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
1570 | + if (!is_array($event) && !($event = $this->read($event))) |
|
1571 | + { |
|
1572 | + return false; |
|
1573 | + } |
|
1463 | 1574 | |
1464 | 1575 | // regular user and groups (need to check memberships too) |
1465 | 1576 | if (!isset($event['participants'][$uid])) |
@@ -1483,7 +1594,10 @@ discard block |
||
1483 | 1594 | */ |
1484 | 1595 | function check_cat_acl($right,$event) |
1485 | 1596 | { |
1486 | - if (!is_array($event)) $event = $this->read($event); |
|
1597 | + if (!is_array($event)) |
|
1598 | + { |
|
1599 | + $event = $this->read($event); |
|
1600 | + } |
|
1487 | 1601 | |
1488 | 1602 | $ret = null; |
1489 | 1603 | if ($event['category']) |
@@ -1540,7 +1654,10 @@ discard block |
||
1540 | 1654 | public static function set_cat_rights($cat_id,$user,$rights) |
1541 | 1655 | { |
1542 | 1656 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1543 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
1657 | + if (!isset(self::$cat_rights_cache)) |
|
1658 | + { |
|
1659 | + self::get_cat_rights($cat_id); |
|
1660 | + } |
|
1544 | 1661 | |
1545 | 1662 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
1546 | 1663 | { |
@@ -1552,7 +1669,10 @@ discard block |
||
1552 | 1669 | else |
1553 | 1670 | { |
1554 | 1671 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1555 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1672 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
1673 | + { |
|
1674 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1675 | + } |
|
1556 | 1676 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
1557 | 1677 | } |
1558 | 1678 | egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1585,7 +1705,10 @@ discard block |
||
1585 | 1705 | foreach($cat_rights as $uid => $value) |
1586 | 1706 | { |
1587 | 1707 | $all |= $value; |
1588 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1708 | + if (in_array($uid,$memberships)) |
|
1709 | + { |
|
1710 | + $own |= $value; |
|
1711 | + } |
|
1589 | 1712 | } |
1590 | 1713 | } |
1591 | 1714 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1632,13 +1755,16 @@ discard block |
||
1632 | 1755 | is_numeric($uid)?$uid:substr($uid,1),$status, |
1633 | 1756 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
1634 | 1757 | { |
1635 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
1758 | + if ($status == 'R') |
|
1759 | + { |
|
1760 | + // remove alarms belonging to rejected participants |
|
1636 | 1761 | { |
1637 | 1762 | foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
1638 | 1763 | { |
1639 | 1764 | if ((string)$alarm['owner'] === (string)$uid) |
1640 | 1765 | { |
1641 | 1766 | $this->so->delete_alarm($id); |
1767 | + } |
|
1642 | 1768 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
1643 | 1769 | } |
1644 | 1770 | } |
@@ -1656,8 +1782,15 @@ discard block |
||
1656 | 1782 | ); |
1657 | 1783 | if (isset($status2msg[$status]) && !$skip_notification) |
1658 | 1784 | { |
1659 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
1660 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1785 | + if (!is_array($event)) |
|
1786 | + { |
|
1787 | + $event = $this->read($cal_id); |
|
1788 | + } |
|
1789 | + if (isset($recur_date)) |
|
1790 | + { |
|
1791 | + $event = $this->read($event['id'],$recur_date); |
|
1792 | + } |
|
1793 | + //re-read the actually edited recurring event |
|
1661 | 1794 | $this->send_update($status2msg[$status],$event['participants'],$event); |
1662 | 1795 | } |
1663 | 1796 | |
@@ -1680,12 +1813,16 @@ discard block |
||
1680 | 1813 | */ |
1681 | 1814 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
1682 | 1815 | { |
1683 | - if (!isset($new_event['participants'])) return; |
|
1816 | + if (!isset($new_event['participants'])) |
|
1817 | + { |
|
1818 | + return; |
|
1819 | + } |
|
1684 | 1820 | |
1685 | 1821 | // check the old list against the new list |
1686 | 1822 | foreach ($old_event['participants'] as $userid => $status) |
1687 | - { |
|
1688 | - if (!isset($new_event['participants'][$userid])){ |
|
1823 | + { |
|
1824 | + if (!isset($new_event['participants'][$userid])) |
|
1825 | + { |
|
1689 | 1826 | // Attendee will be deleted this way |
1690 | 1827 | $new_event['participants'][$userid] = 'G'; |
1691 | 1828 | } |
@@ -1769,7 +1906,10 @@ discard block |
||
1769 | 1906 | } |
1770 | 1907 | else |
1771 | 1908 | { |
1772 | - if (!($exception = $this->read($id))) continue; |
|
1909 | + if (!($exception = $this->read($id))) |
|
1910 | + { |
|
1911 | + continue; |
|
1912 | + } |
|
1773 | 1913 | $exception['uid'] = common::generate_uid('calendar', $id); |
1774 | 1914 | $exception['reference'] = $exception['recurrence'] = 0; |
1775 | 1915 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1840,7 +1980,10 @@ discard block |
||
1840 | 1980 | $event_arr = $this->event2array($event); |
1841 | 1981 | foreach($event_arr as $key => $val) |
1842 | 1982 | { |
1843 | - if ($key == 'recur_type') $key = 'repetition'; |
|
1983 | + if ($key == 'recur_type') |
|
1984 | + { |
|
1985 | + $key = 'repetition'; |
|
1986 | + } |
|
1844 | 1987 | $details[$key] = $val['data']; |
1845 | 1988 | } |
1846 | 1989 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -2013,7 +2156,10 @@ discard block |
||
2013 | 2156 | */ |
2014 | 2157 | function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null) |
2015 | 2158 | { |
2016 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
2159 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
2160 | + { |
|
2161 | + return; |
|
2162 | + } |
|
2017 | 2163 | |
2018 | 2164 | $time = new egw_time($event['start']); |
2019 | 2165 | if(!is_array($event['alarm'])) |
@@ -2091,7 +2237,10 @@ discard block |
||
2091 | 2237 | if (is_array($old_event) || $old_event > 0) |
2092 | 2238 | { |
2093 | 2239 | // preserve categories without users read access |
2094 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
2240 | + if (!is_array($old_event)) |
|
2241 | + { |
|
2242 | + $old_event = $this->read($old_event); |
|
2243 | + } |
|
2095 | 2244 | $old_categories = explode(',',$old_event['category']); |
2096 | 2245 | $old_cats_preserve = array(); |
2097 | 2246 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2182,7 +2331,10 @@ discard block |
||
2182 | 2331 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
2183 | 2332 | } |
2184 | 2333 | |
2185 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
2334 | + if (!isset($event['recurrence'])) |
|
2335 | + { |
|
2336 | + $event['recurrence'] = 0; |
|
2337 | + } |
|
2186 | 2338 | |
2187 | 2339 | if ($filter == 'master') |
2188 | 2340 | { |
@@ -2236,19 +2388,26 @@ discard block |
||
2236 | 2388 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
2237 | 2389 | } |
2238 | 2390 | } |
2239 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
2391 | + } |
|
2392 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
2240 | 2393 | $event['recur_type'] == $egwEvent['recur_type'] && |
2241 | 2394 | strpos($egwEvent['title'], $event['title']) === 0)) |
2242 | 2395 | { |
2243 | 2396 | $matchingEvents[] = $egwEvent['id']; // we found the event |
2244 | 2397 | } |
2245 | 2398 | } |
2246 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
2399 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
2400 | + { |
|
2401 | + return $matchingEvents; |
|
2402 | + } |
|
2247 | 2403 | } |
2248 | 2404 | unset($event['id']); |
2249 | 2405 | |
2250 | 2406 | // No chance to find a master without [U]ID |
2251 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
2407 | + if ($filter == 'master' && empty($event['uid'])) |
|
2408 | + { |
|
2409 | + return $matchingEvents; |
|
2410 | + } |
|
2252 | 2411 | |
2253 | 2412 | // only query calendars of users, we have READ-grants from |
2254 | 2413 | $users = array(); |
@@ -2257,17 +2416,23 @@ discard block |
||
2257 | 2416 | $user = trim($user); |
2258 | 2417 | if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user)) |
2259 | 2418 | { |
2260 | - if ($user && !in_array($user,$users)) // already added? |
|
2419 | + if ($user && !in_array($user,$users)) |
|
2420 | + { |
|
2421 | + // already added? |
|
2261 | 2422 | { |
2262 | 2423 | $users[] = $user; |
2263 | 2424 | } |
2425 | + } |
|
2264 | 2426 | } |
2265 | 2427 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2266 | 2428 | { |
2267 | 2429 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
2268 | 2430 | } |
2269 | 2431 | // the further code is only for real users |
2270 | - if (!is_numeric($user)) continue; |
|
2432 | + if (!is_numeric($user)) |
|
2433 | + { |
|
2434 | + continue; |
|
2435 | + } |
|
2271 | 2436 | |
2272 | 2437 | // for groups we have to include the members |
2273 | 2438 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2347,7 +2512,10 @@ discard block |
||
2347 | 2512 | } |
2348 | 2513 | foreach ($matchFields as $key) |
2349 | 2514 | { |
2350 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
2515 | + if (isset($event[$key])) |
|
2516 | + { |
|
2517 | + $query['cal_'.$key] = $event[$key]; |
|
2518 | + } |
|
2351 | 2519 | } |
2352 | 2520 | } |
2353 | 2521 | |
@@ -2387,7 +2555,10 @@ discard block |
||
2387 | 2555 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
2388 | 2556 | } |
2389 | 2557 | |
2390 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
2558 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
2559 | + { |
|
2560 | + continue; |
|
2561 | + } |
|
2391 | 2562 | |
2392 | 2563 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
2393 | 2564 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2554,13 +2725,16 @@ discard block |
||
2554 | 2725 | foreach ($event['participants'] as $attendee => $status) |
2555 | 2726 | { |
2556 | 2727 | if (!isset($egwEvent['participants'][$attendee]) && |
2557 | - $attendee != $egwEvent['owner']) // || |
|
2728 | + $attendee != $egwEvent['owner']) |
|
2729 | + { |
|
2730 | + // || |
|
2558 | 2731 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
2559 | 2732 | { |
2560 | 2733 | if ($this->log) |
2561 | 2734 | { |
2562 | 2735 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2563 | 2736 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
2737 | + } |
|
2564 | 2738 | } |
2565 | 2739 | continue 2; |
2566 | 2740 | } |
@@ -2882,7 +3056,10 @@ discard block |
||
2882 | 3056 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
2883 | 3057 | { |
2884 | 3058 | // we convert here from server-time to timestamps in user-time! |
2885 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
3059 | + if (isset($event[$ts])) |
|
3060 | + { |
|
3061 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
3062 | + } |
|
2886 | 3063 | } |
2887 | 3064 | // same with the recur exceptions |
2888 | 3065 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2910,9 +3087,12 @@ discard block |
||
2910 | 3087 | */ |
2911 | 3088 | function purge($age) |
2912 | 3089 | { |
2913 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
3090 | + if (is_numeric($age) && $age > 0) |
|
3091 | + { |
|
3092 | + // just make sure bogus values dont delete everything |
|
2914 | 3093 | { |
2915 | 3094 | $this->so->purge(time() - 365*24*3600*(float)$age); |
2916 | 3095 | } |
3096 | + } |
|
2917 | 3097 | } |
2918 | 3098 | } |