@@ -15,7 +15,7 @@ |
||
15 | 15 | $setup_info['calendar']['enable'] = 1; |
16 | 16 | $setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index&ajax=true'; |
17 | 17 | |
18 | -$setup_info['calendar']['license'] = 'GPL'; |
|
18 | +$setup_info['calendar']['license'] = 'GPL'; |
|
19 | 19 | $setup_info['calendar']['description'] = |
20 | 20 | 'Powerful group calendar with meeting request system and ACL security.'; |
21 | 21 | $setup_info['calendar']['note'] = |
@@ -50,5 +50,5 @@ |
||
50 | 50 | /* Dependencies for this app to work */ |
51 | 51 | $setup_info['calendar']['depends'][] = array( |
52 | 52 | 'appname' => 'api', |
53 | - 'versions' => Array('17.1') |
|
53 | + 'versions' => array('17.1') |
|
54 | 54 | ); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | 'Arab Standard Time' => 'Asia/Riyadh', |
25 | 25 | 'Arabian Standard Time' => 'Asia/Dubai', |
26 | 26 | 'Arabic Standard Time' => 'Asia/Baghdad', |
27 | - 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', // was 'America/Buenos_Aires', |
|
27 | + 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', // was 'America/Buenos_Aires', |
|
28 | 28 | 'Atlantic Standard Time' => 'America/Halifax', |
29 | 29 | 'Azerbaijan Standard Time' => 'Asia/Baku', |
30 | 30 | 'Azores Standard Time' => 'Atlantic/Azores', |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | 'Greenland Standard Time' => 'America/Godthab', |
60 | 60 | 'Greenwich Standard Time' => 'Atlantic/Reykjavik', |
61 | 61 | 'Hawaiian Standard Time' => 'Pacific/Honolulu', |
62 | - 'India Standard Time' => 'Asia/Kolkata', // Asia/Calcutta is an alias to Asia/Kolkata |
|
62 | + 'India Standard Time' => 'Asia/Kolkata', // Asia/Calcutta is an alias to Asia/Kolkata |
|
63 | 63 | 'Iran Standard Time' => 'Asia/Tehran', |
64 | 64 | 'Israel Standard Time' => 'Asia/Jerusalem', |
65 | 65 | 'Jordan Standard Time' => 'Asia/Amman', |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein', |
199 | 199 | |
200 | 200 | // various aliases collected over time |
201 | - 'America/Creston' => 'America/Dawson_Creek', // not in sqlight DB of Thunderbird version 1.2011n, Dawson Creek is also UTC-7 without DS |
|
201 | + 'America/Creston' => 'America/Dawson_Creek', // not in sqlight DB of Thunderbird version 1.2011n, Dawson Creek is also UTC-7 without DS |
|
202 | 202 | 'Armenian Standard Time' => 'Asia/Yerevan', |
203 | 203 | 'Asia/Katmandu' => 'Asia/Kathmandu', |
204 | 204 | 'Asia/Calcutta' => 'Asia/Kolkata', |
@@ -24,7 +24,7 @@ |
||
24 | 24 | unset($this->export_fields['participants-r']); |
25 | 25 | |
26 | 26 | $custom = Api\Storage\Customfields::get('calendar', true); |
27 | - foreach($custom as $name => $data) { |
|
27 | + foreach ($custom as $name => $data) { |
|
28 | 28 | $this->export_fields['#'.$name] = $data['label']; |
29 | 29 | } |
30 | 30 | } |
@@ -13,7 +13,8 @@ discard block |
||
13 | 13 | |
14 | 14 | class calendar_wizard_export_csv extends importexport_wizard_basic_export_csv |
15 | 15 | { |
16 | - public function __construct() { |
|
16 | + public function __construct() |
|
17 | + { |
|
17 | 18 | parent::__construct(); |
18 | 19 | // Field mapping |
19 | 20 | $bo = new calendar_tracking(); |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | unset($this->export_fields['participants-r']); |
25 | 26 | |
26 | 27 | $custom = Api\Storage\Customfields::get('calendar', true); |
27 | - foreach($custom as $name => $data) { |
|
28 | + foreach($custom as $name => $data) |
|
29 | + { |
|
28 | 30 | $this->export_fields['#'.$name] = $data['label']; |
29 | 31 | } |
30 | 32 | } |
@@ -32,8 +32,8 @@ |
||
32 | 32 | protected static $conditions = array('exists'); |
33 | 33 | |
34 | 34 | /** |
35 | - * For figuring out if an entry has changed |
|
36 | - */ |
|
35 | + * For figuring out if an entry has changed |
|
36 | + */ |
|
37 | 37 | protected $tracking; |
38 | 38 | |
39 | 39 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $this->role_map = array_flip($this->bo->roles); |
58 | 58 | |
59 | 59 | $this->lookups = array( |
60 | - 'priority' => Array( |
|
60 | + 'priority' => array( |
|
61 | 61 | 0 => lang('None'), |
62 | 62 | 1 => lang('Low'), |
63 | 63 | 2 => lang('Normal'), |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
240 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$records = array()) |
|
241 | 241 | { |
242 | 242 | if($record->__get($condition['string']) && $condition['string'] == 'id') { |
243 | 243 | $event = $this->bo->read($record->__get($condition['string'])); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param calendar_egw_record record The egw_record object being imported |
75 | 75 | * @param importexport_iface_import_record import_csv Import object contains current state |
76 | 76 | * |
77 | - * @return boolean success |
|
77 | + * @return null|boolean success |
|
78 | 78 | */ |
79 | 79 | public function import_record(\calendar_egw_record &$record, &$import_csv) |
80 | 80 | { |
@@ -182,8 +182,9 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * Parse participants field into calendar resources |
184 | 184 | * |
185 | - * @param string $participants |
|
186 | 185 | * |
186 | + * @param calendar_egw_record $record |
|
187 | + * @param string $warnings |
|
187 | 188 | * @return array |
188 | 189 | */ |
189 | 190 | protected function parse_participants($record, &$warnings) |
@@ -289,7 +290,6 @@ discard block |
||
289 | 290 | * perform the required action |
290 | 291 | * |
291 | 292 | * @param int $_action one of $this->actions |
292 | - * @param array $_data record data for the action |
|
293 | 293 | * @return bool success or not |
294 | 294 | */ |
295 | 295 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * Alter a row for preview to show multiple participants instead of Array |
425 | 425 | * |
426 | - * @param egw_record $row_entry |
|
426 | + * @param importexport_iface_egw_record $row_entry |
|
427 | 427 | */ |
428 | 428 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
429 | 429 | { |
@@ -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 |
@@ -47,13 +47,13 @@ discard block |
||
47 | 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( |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | public function import_record(\calendar_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,13 +109,13 @@ discard block |
||
109 | 109 | if ($record->participants && !is_array($record->participants)) { |
110 | 110 | $warning = ''; |
111 | 111 | $record->participants = $this->parse_participants($record, $warning); |
112 | - if($warning) |
|
112 | + if ($warning) |
|
113 | 113 | { |
114 | 114 | $this->warnings[$import_csv->get_current_position()] = $warning; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if($record->recurrence) |
|
118 | + if ($record->recurrence) |
|
119 | 119 | { |
120 | 120 | $start = new Api\DateTime($record->start); |
121 | 121 | try |
@@ -130,37 +130,37 @@ discard block |
||
130 | 130 | catch (Exception $e) |
131 | 131 | { |
132 | 132 | // Try old way from export using just recur_type / interval |
133 | - list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2); |
|
133 | + list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2); |
|
134 | 134 | $record->recur_interval = trim($record->recur_interval); |
135 | - $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence'])); |
|
135 | + $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence'])); |
|
136 | 136 | } |
137 | 137 | unset($record->recurrence); |
138 | 138 | } |
139 | 139 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
140 | 140 | |
141 | - if ( $options['conditions'] ) { |
|
142 | - foreach ( $options['conditions'] as $condition ) { |
|
141 | + if ($options['conditions']) { |
|
142 | + foreach ($options['conditions'] as $condition) { |
|
143 | 143 | $records = array(); |
144 | - switch ( $condition['type'] ) { |
|
144 | + switch ($condition['type']) { |
|
145 | 145 | // exists |
146 | 146 | case 'exists' : |
147 | 147 | // Check for that record |
148 | 148 | $result = $this->exists($record, $condition, $records); |
149 | 149 | |
150 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
150 | + if (is_array($records) && count($records) >= 1) { |
|
151 | 151 | // apply action to all records matching this exists condition |
152 | 152 | $action = $condition['true']; |
153 | - foreach ( (array)$records as $event ) { |
|
153 | + foreach ((array)$records as $event) { |
|
154 | 154 | $record->id = $event['id']; |
155 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
156 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
157 | - $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
|
155 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
156 | + if (!is_array($record->category)) $record->category = explode(',', $record->category); |
|
157 | + $record->category = implode(',', array_unique(array_merge($record->category, $event['category']))); |
|
158 | 158 | } |
159 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
159 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
160 | 160 | } |
161 | 161 | } else { |
162 | 162 | $action = $condition['false']; |
163 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
163 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
164 | 164 | } |
165 | 165 | break; |
166 | 166 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | } else { |
175 | 175 | // unconditional insert |
176 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
176 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $success; |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
193 | 193 | $statuses = implode('|', array_keys($this->status_map)); |
194 | 194 | //echo ('/((?<name>.+?)(?: \((?<quantity>[\d]+)\))? \((?<status>'.$statuses.')\)(?: (?<role>[^ ,]+))?)(?:, )?/'); |
195 | - preg_match_all('/((?<name>.+?)(?: \((?<quantity>[\d]+)\))? \((?<status>'.$statuses.')\)(?: (?<role>[^ ,]+))?)(?:, )?/i',$record->participants,$participants); |
|
195 | + preg_match_all('/((?<name>.+?)(?: \((?<quantity>[\d]+)\))? \((?<status>'.$statuses.')\)(?: (?<role>[^ ,]+))?)(?:, )?/i', $record->participants, $participants); |
|
196 | 196 | $p_participants = array(); |
197 | 197 | $missing = array(); |
198 | 198 | |
199 | 199 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
200 | - foreach($names as $key => $name) { |
|
200 | + foreach ($names as $key => $name) { |
|
201 | 201 | //echo (__METHOD__ ." Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
202 | 202 | |
203 | 203 | // Search for direct account name, then user in accounts first |
@@ -205,26 +205,26 @@ discard block |
||
205 | 205 | $id = importexport_helper_functions::account_name2id($name); |
206 | 206 | |
207 | 207 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
208 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
209 | - $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)); |
|
210 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
208 | + if (!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
209 | + $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)); |
|
210 | + if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
211 | 211 | } |
212 | - if(!$id) |
|
212 | + if (!$id) |
|
213 | 213 | { |
214 | 214 | // Use calendar's registered resources to find participant |
215 | - foreach($this->bo->resources as $resource) |
|
215 | + foreach ($this->bo->resources as $resource) |
|
216 | 216 | { |
217 | 217 | // Can't search for email |
218 | - if($resource['app'] == 'email') continue; |
|
218 | + if ($resource['app'] == 'email') continue; |
|
219 | 219 | // Special resource search, since it does special stuff in link_query |
220 | - if($resource['app'] == 'resources') |
|
220 | + if ($resource['app'] == 'resources') |
|
221 | 221 | { |
222 | - if(!$this->resource_so) |
|
222 | + if (!$this->resource_so) |
|
223 | 223 | { |
224 | 224 | $this->resource_so = new resources_so(); |
225 | 225 | } |
226 | - $result = $this->resource_so->search($search,'res_id'); |
|
227 | - if(count($result) >= 1) { |
|
226 | + $result = $this->resource_so->search($search, 'res_id'); |
|
227 | + if (count($result) >= 1) { |
|
228 | 228 | $id = $resource['type'].$result[0]['res_id']; |
229 | 229 | break; |
230 | 230 | } |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | $link_options = array(); |
236 | 236 | $result = Link::query($resource['app'], $search, $link_options); |
237 | 237 | |
238 | - if($result) |
|
238 | + if ($result) |
|
239 | 239 | { |
240 | - $id = $resource['type'] . key($result); |
|
240 | + $id = $resource['type'].key($result); |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | - if($id) { |
|
246 | + if ($id) { |
|
247 | 247 | $p_participants[$id] = calendar_so::combine_status( |
248 | 248 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
249 | 249 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | { |
255 | 255 | $missing[] = $name; |
256 | 256 | } |
257 | - if(count($missing) > 0) |
|
257 | + if (count($missing) > 0) |
|
258 | 258 | { |
259 | - $warnings = $record->title . ' ' . lang('participants') . ': ' . |
|
260 | - lang('Contact not found!') . '<br />'.implode(", ",$missing); |
|
259 | + $warnings = $record->title.' '.lang('participants').': '. |
|
260 | + lang('Contact not found!').'<br />'.implode(", ", $missing); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | return $p_participants; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
276 | 276 | { |
277 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
277 | + if ($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
278 | 278 | $event = $this->bo->read($record->__get($condition['string'])); |
279 | 279 | $records = array($event); |
280 | 280 | } |
281 | 281 | |
282 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
282 | + if (is_array($records) && count($records) >= 1) { |
|
283 | 283 | return true; |
284 | 284 | } |
285 | 285 | return false; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @param array $_data record data for the action |
293 | 293 | * @return bool success or not |
294 | 294 | */ |
295 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
295 | + protected function action($_action, importexport_iface_egw_record &$record, $record_num = 0) |
|
296 | 296 | { |
297 | 297 | $_data = $record->get_record_array(); |
298 | 298 | switch ($_action) { |
@@ -303,41 +303,41 @@ discard block |
||
303 | 303 | $old = $this->bo->read($_data['id']); |
304 | 304 | |
305 | 305 | // Don't change a user account into a record |
306 | - if(!$this->definition->plugin_options['change_owner']) { |
|
306 | + if (!$this->definition->plugin_options['change_owner']) { |
|
307 | 307 | // Don't change owner of an existing record |
308 | 308 | unset($_data['owner']); |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Merge to deal with fields not in import record |
312 | - if($old) |
|
312 | + if ($old) |
|
313 | 313 | { |
314 | 314 | $_data = array_merge($old, $_data); |
315 | 315 | $changed = $this->tracking->changed_fields($_data, $old); |
316 | - if(count($changed) == 0) { |
|
316 | + if (count($changed) == 0) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | // Fall through |
321 | 321 | case 'insert' : |
322 | - if($_action == 'insert') { |
|
322 | + if ($_action == 'insert') { |
|
323 | 323 | // Backend doesn't like inserting with ID specified, can overwrite existing |
324 | 324 | unset($_data['id']); |
325 | 325 | } |
326 | 326 | // Make sure participants are set |
327 | - if(!$_data['participants']) { |
|
327 | + if (!$_data['participants']) { |
|
328 | 328 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
329 | 329 | $_data['participants'] = array( |
330 | 330 | $user => 'U' |
331 | 331 | ); |
332 | 332 | } |
333 | - if ( $this->dry_run ) { |
|
333 | + if ($this->dry_run) { |
|
334 | 334 | //print_r($_data); |
335 | 335 | // User is interested in conflict checks, do so for dry run |
336 | 336 | // Otherwise, conflicts are just ignored and imported anyway |
337 | - if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
337 | + if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
338 | 338 | { |
339 | 339 | $conflicts = $this->bo->conflicts($_data); |
340 | - if($conflicts) |
|
340 | + if ($conflicts) |
|
341 | 341 | { |
342 | 342 | $this->conflict_warning($record_num, $conflicts); |
343 | 343 | $this->results['skipped']++; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | return true; |
349 | 349 | } else { |
350 | 350 | $messages = null; |
351 | - $result = $this->bo->update( $_data, |
|
351 | + $result = $this->bo->update($_data, |
|
352 | 352 | !$this->definition->plugin_options['skip_conflicts'], |
353 | 353 | true, $this->is_admin, true, $messages, |
354 | 354 | $this->definition->plugin_options['no_notification'] |
355 | 355 | ); |
356 | - if(!$result) |
|
356 | + if (!$result) |
|
357 | 357 | { |
358 | - $this->errors[$record_num] = lang('Unable to save') . "\n" . |
|
359 | - implode("\n",$messages); |
|
358 | + $this->errors[$record_num] = lang('Unable to save')."\n". |
|
359 | + implode("\n", $messages); |
|
360 | 360 | } |
361 | 361 | else if (is_array($result)) |
362 | 362 | { |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function conflict_warning($record_num, &$conflicts) |
388 | 388 | { |
389 | - $this->warnings[$record_num] = lang('Conflicts') . ':'; |
|
390 | - foreach($conflicts as $conflict) |
|
389 | + $this->warnings[$record_num] = lang('Conflicts').':'; |
|
390 | + foreach ($conflicts as $conflict) |
|
391 | 391 | { |
392 | - $this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title']; |
|
392 | + $this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title']; |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
429 | 429 | { |
430 | - $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true)); |
|
430 | + $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true)); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | } |
434 | 434 | \ No newline at end of file |
@@ -17,7 +17,8 @@ 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 | 24 | * actions wich could be done to data entries |
@@ -83,8 +84,10 @@ discard block |
||
83 | 84 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
84 | 85 | |
85 | 86 | // Set owner, unless it's supposed to come from CSV file |
86 | - if($options['owner_from_csv']) { |
|
87 | - if(!is_numeric($record['owner'])) { |
|
87 | + if($options['owner_from_csv']) |
|
88 | + { |
|
89 | + if(!is_numeric($record['owner'])) |
|
90 | + { |
|
88 | 91 | $this->errors[$import_csv->get_current_position()] = lang( |
89 | 92 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
90 | 93 | $record->owner, |
@@ -106,7 +109,8 @@ discard block |
||
106 | 109 | } |
107 | 110 | |
108 | 111 | // Parse particpants |
109 | - if ($record->participants && !is_array($record->participants)) { |
|
112 | + if ($record->participants && !is_array($record->participants)) |
|
113 | + { |
|
110 | 114 | $warning = ''; |
111 | 115 | $record->participants = $this->parse_participants($record, $warning); |
112 | 116 | if($warning) |
@@ -138,27 +142,38 @@ discard block |
||
138 | 142 | } |
139 | 143 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
140 | 144 | |
141 | - if ( $options['conditions'] ) { |
|
142 | - foreach ( $options['conditions'] as $condition ) { |
|
145 | + if ( $options['conditions'] ) |
|
146 | + { |
|
147 | + foreach ( $options['conditions'] as $condition ) |
|
148 | + { |
|
143 | 149 | $records = array(); |
144 | - switch ( $condition['type'] ) { |
|
150 | + switch ( $condition['type'] ) |
|
151 | + { |
|
145 | 152 | // exists |
146 | 153 | case 'exists' : |
147 | 154 | // Check for that record |
148 | 155 | $result = $this->exists($record, $condition, $records); |
149 | 156 | |
150 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
157 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
158 | + { |
|
151 | 159 | // apply action to all records matching this exists condition |
152 | 160 | $action = $condition['true']; |
153 | - foreach ( (array)$records as $event ) { |
|
161 | + foreach ( (array)$records as $event ) |
|
162 | + { |
|
154 | 163 | $record->id = $event['id']; |
155 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
156 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
164 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
165 | + { |
|
166 | + if ( !is_array( $record->category ) ) |
|
167 | + { |
|
168 | + $record->category = explode( ',', $record->category ); |
|
169 | + } |
|
157 | 170 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
158 | 171 | } |
159 | 172 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
160 | 173 | } |
161 | - } else { |
|
174 | + } |
|
175 | + else |
|
176 | + { |
|
162 | 177 | $action = $condition['false']; |
163 | 178 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
164 | 179 | } |
@@ -169,9 +184,14 @@ discard block |
||
169 | 184 | die('condition / action not supported!!!'); |
170 | 185 | break; |
171 | 186 | } |
172 | - if ($action['last']) break; |
|
187 | + if ($action['last']) |
|
188 | + { |
|
189 | + break; |
|
190 | + } |
|
173 | 191 | } |
174 | - } else { |
|
192 | + } |
|
193 | + else |
|
194 | + { |
|
175 | 195 | // unconditional insert |
176 | 196 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
177 | 197 | } |
@@ -197,7 +217,8 @@ discard block |
||
197 | 217 | $missing = array(); |
198 | 218 | |
199 | 219 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
200 | - foreach($names as $key => $name) { |
|
220 | + foreach($names as $key => $name) |
|
221 | + { |
|
201 | 222 | //echo (__METHOD__ ." Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
202 | 223 | |
203 | 224 | // Search for direct account name, then user in accounts first |
@@ -205,9 +226,13 @@ discard block |
||
205 | 226 | $id = importexport_helper_functions::account_name2id($name); |
206 | 227 | |
207 | 228 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
208 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
229 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
230 | + { |
|
209 | 231 | $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)); |
210 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
232 | + if($contacts) |
|
233 | + { |
|
234 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
235 | + } |
|
211 | 236 | } |
212 | 237 | if(!$id) |
213 | 238 | { |
@@ -215,7 +240,10 @@ discard block |
||
215 | 240 | foreach($this->bo->resources as $resource) |
216 | 241 | { |
217 | 242 | // Can't search for email |
218 | - if($resource['app'] == 'email') continue; |
|
243 | + if($resource['app'] == 'email') |
|
244 | + { |
|
245 | + continue; |
|
246 | + } |
|
219 | 247 | // Special resource search, since it does special stuff in link_query |
220 | 248 | if($resource['app'] == 'resources') |
221 | 249 | { |
@@ -224,7 +252,8 @@ discard block |
||
224 | 252 | $this->resource_so = new resources_so(); |
225 | 253 | } |
226 | 254 | $result = $this->resource_so->search($search,'res_id'); |
227 | - if(count($result) >= 1) { |
|
255 | + if(count($result) >= 1) |
|
256 | + { |
|
228 | 257 | $id = $resource['type'].$result[0]['res_id']; |
229 | 258 | break; |
230 | 259 | } |
@@ -243,7 +272,8 @@ discard block |
||
243 | 272 | } |
244 | 273 | } |
245 | 274 | } |
246 | - if($id) { |
|
275 | + if($id) |
|
276 | + { |
|
247 | 277 | $p_participants[$id] = calendar_so::combine_status( |
248 | 278 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
249 | 279 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -274,12 +304,14 @@ discard block |
||
274 | 304 | */ |
275 | 305 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
276 | 306 | { |
277 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
307 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
308 | + { |
|
278 | 309 | $event = $this->bo->read($record->__get($condition['string'])); |
279 | 310 | $records = array($event); |
280 | 311 | } |
281 | 312 | |
282 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
313 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
314 | + { |
|
283 | 315 | return true; |
284 | 316 | } |
285 | 317 | return false; |
@@ -295,7 +327,8 @@ discard block |
||
295 | 327 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
296 | 328 | { |
297 | 329 | $_data = $record->get_record_array(); |
298 | - switch ($_action) { |
|
330 | + switch ($_action) |
|
331 | + { |
|
299 | 332 | case 'none' : |
300 | 333 | return true; |
301 | 334 | case 'update' : |
@@ -303,7 +336,8 @@ discard block |
||
303 | 336 | $old = $this->bo->read($_data['id']); |
304 | 337 | |
305 | 338 | // Don't change a user account into a record |
306 | - if(!$this->definition->plugin_options['change_owner']) { |
|
339 | + if(!$this->definition->plugin_options['change_owner']) |
|
340 | + { |
|
307 | 341 | // Don't change owner of an existing record |
308 | 342 | unset($_data['owner']); |
309 | 343 | } |
@@ -313,24 +347,28 @@ discard block |
||
313 | 347 | { |
314 | 348 | $_data = array_merge($old, $_data); |
315 | 349 | $changed = $this->tracking->changed_fields($_data, $old); |
316 | - if(count($changed) == 0) { |
|
350 | + if(count($changed) == 0) |
|
351 | + { |
|
317 | 352 | return true; |
318 | 353 | } |
319 | 354 | } |
320 | 355 | // Fall through |
321 | 356 | case 'insert' : |
322 | - if($_action == 'insert') { |
|
357 | + if($_action == 'insert') |
|
358 | + { |
|
323 | 359 | // Backend doesn't like inserting with ID specified, can overwrite existing |
324 | 360 | unset($_data['id']); |
325 | 361 | } |
326 | 362 | // Make sure participants are set |
327 | - if(!$_data['participants']) { |
|
363 | + if(!$_data['participants']) |
|
364 | + { |
|
328 | 365 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
329 | 366 | $_data['participants'] = array( |
330 | 367 | $user => 'U' |
331 | 368 | ); |
332 | 369 | } |
333 | - if ( $this->dry_run ) { |
|
370 | + if ( $this->dry_run ) |
|
371 | + { |
|
334 | 372 | //print_r($_data); |
335 | 373 | // User is interested in conflict checks, do so for dry run |
336 | 374 | // Otherwise, conflicts are just ignored and imported anyway |
@@ -346,7 +384,9 @@ discard block |
||
346 | 384 | } |
347 | 385 | $this->results[$_action]++; |
348 | 386 | return true; |
349 | - } else { |
|
387 | + } |
|
388 | + else |
|
389 | + { |
|
350 | 390 | $messages = null; |
351 | 391 | $result = $this->bo->update( $_data, |
352 | 392 | !$this->definition->plugin_options['skip_conflicts'], |
@@ -398,7 +438,8 @@ discard block |
||
398 | 438 | * |
399 | 439 | * @return string name |
400 | 440 | */ |
401 | - public static function get_name() { |
|
441 | + public static function get_name() |
|
442 | + { |
|
402 | 443 | return lang('Calendar CSV import'); |
403 | 444 | } |
404 | 445 | |
@@ -407,7 +448,8 @@ discard block |
||
407 | 448 | * |
408 | 449 | * @return string descriprion |
409 | 450 | */ |
410 | - public static function get_description() { |
|
451 | + public static function get_description() |
|
452 | + { |
|
411 | 453 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators."); |
412 | 454 | } |
413 | 455 | |
@@ -416,7 +458,8 @@ discard block |
||
416 | 458 | * |
417 | 459 | * @return string suffix (comma seperated) |
418 | 460 | */ |
419 | - public static function get_filesuffix() { |
|
461 | + public static function get_filesuffix() |
|
462 | + { |
|
420 | 463 | return 'csv'; |
421 | 464 | } |
422 | 465 |
@@ -177,7 +177,7 @@ |
||
177 | 177 | * @param int $cutoffdate =null |
178 | 178 | * @param array $not_uids =null uids NOT to return for meeting requests |
179 | 179 | * @return array |
180 | - */ |
|
180 | + */ |
|
181 | 181 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
182 | 182 | { |
183 | 183 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
@@ -20,8 +20,12 @@ discard block |
||
20 | 20 | */ |
21 | 21 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
22 | 22 | { |
23 | - interface activesync_plugin_write {} |
|
24 | - interface activesync_plugin_meeting_requests {} |
|
23 | + interface activesync_plugin_write |
|
24 | + { |
|
25 | +} |
|
26 | + interface activesync_plugin_meeting_requests |
|
27 | + { |
|
28 | +} |
|
25 | 29 | } |
26 | 30 | |
27 | 31 | /** |
@@ -81,7 +85,10 @@ discard block |
||
81 | 85 | */ |
82 | 86 | public function GetFolderList() |
83 | 87 | { |
84 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
88 | + if (!isset($this->calendar)) |
|
89 | + { |
|
90 | + $this->calendar = new calendar_boupdate(); |
|
91 | + } |
|
85 | 92 | |
86 | 93 | $cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
87 | 94 | $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
@@ -180,13 +187,20 @@ discard block |
||
180 | 187 | */ |
181 | 188 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
182 | 189 | { |
183 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
190 | + if (!isset($this->calendar)) |
|
191 | + { |
|
192 | + $this->calendar = new calendar_boupdate(); |
|
193 | + } |
|
184 | 194 | |
185 | 195 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
186 | 196 | $type = $user = null; |
187 | 197 | $this->backend->splitID($id,$type,$user); |
188 | 198 | |
189 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
199 | + if (!$cutoffdate) |
|
200 | + { |
|
201 | + $cutoffdate = $this->bo->now - 100*24*3600; |
|
202 | + } |
|
203 | + // default three month back -30 breaks all sync recurrences |
|
190 | 204 | |
191 | 205 | $filter = array( |
192 | 206 | 'users' => $user, |
@@ -212,7 +226,10 @@ discard block |
||
212 | 226 | { |
213 | 227 | foreach ($events as $event) |
214 | 228 | { |
215 | - if ($not_uids && in_array($event['uid'], $not_uids)) continue; |
|
229 | + if ($not_uids && in_array($event['uid'], $not_uids)) |
|
230 | + { |
|
231 | + continue; |
|
232 | + } |
|
216 | 233 | $messagelist[] = $this->StatMessage($id, $event); |
217 | 234 | |
218 | 235 | // add virtual exceptions for recuring events too |
@@ -227,7 +244,10 @@ discard block |
||
227 | 244 | } |
228 | 245 | }*/ |
229 | 246 | } |
230 | - if (count($events) < $num_rows) break; |
|
247 | + if (count($events) < $num_rows) |
|
248 | + { |
|
249 | + break; |
|
250 | + } |
|
231 | 251 | } |
232 | 252 | //error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace()); |
233 | 253 | return $messagelist; |
@@ -289,7 +309,10 @@ discard block |
||
289 | 309 | { |
290 | 310 | unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
291 | 311 | |
292 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
312 | + if (!isset($this->calendar)) |
|
313 | + { |
|
314 | + $this->calendar = new calendar_boupdate(); |
|
315 | + } |
|
293 | 316 | |
294 | 317 | if (!($event = $this->calendar->read(abs($id), 0, false, 'server'))) |
295 | 318 | { |
@@ -367,7 +390,10 @@ discard block |
||
367 | 390 | 'created' => 'dtstamp', |
368 | 391 | ) as $key => $attr) |
369 | 392 | { |
370 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
393 | + if (!empty($event[$key])) |
|
394 | + { |
|
395 | + $message->$attr = $event[$key]; |
|
396 | + } |
|
371 | 397 | } |
372 | 398 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
373 | 399 | { |
@@ -379,7 +405,10 @@ discard block |
||
379 | 405 | 'location' => 'location', |
380 | 406 | ) as $key => $attr) |
381 | 407 | { |
382 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
408 | + if (!empty($event[$key])) |
|
409 | + { |
|
410 | + $message->$attr = $event[$key]; |
|
411 | + } |
|
383 | 412 | } |
384 | 413 | $message->organizer = $event['organizer']; |
385 | 414 | |
@@ -414,7 +443,10 @@ discard block |
||
414 | 443 | */ |
415 | 444 | function MeetingResponse($folderid, $requestid, $response) |
416 | 445 | { |
417 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
446 | + if (!isset($this->calendar)) |
|
447 | + { |
|
448 | + $this->calendar = new calendar_boupdate(); |
|
449 | + } |
|
418 | 450 | |
419 | 451 | static $as2status = array( // different from self::$status2as! |
420 | 452 | 1 => 'A', |
@@ -424,9 +456,12 @@ discard block |
||
424 | 456 | $status_in = isset($as2status[$response]) ? $as2status[$response] : 'U'; |
425 | 457 | $uid = $GLOBALS['egw_info']['user']['account_id']; |
426 | 458 | |
427 | - if (!is_numeric($requestid)) // iCal from fmail |
|
459 | + if (!is_numeric($requestid)) |
|
460 | + { |
|
461 | + // iCal from fmail |
|
428 | 462 | { |
429 | 463 | $ical = new calendar_ical(); |
464 | + } |
|
430 | 465 | if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1) |
431 | 466 | { |
432 | 467 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!"); |
@@ -536,7 +571,10 @@ discard block |
||
536 | 571 | { |
537 | 572 | unset($contentParameters); // unused, but required by function signature |
538 | 573 | |
539 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
574 | + if (!isset($this->calendar)) |
|
575 | + { |
|
576 | + $this->calendar = new calendar_boupdate(); |
|
577 | + } |
|
540 | 578 | |
541 | 579 | $old_event = array(); |
542 | 580 | $type = $account = null; |
@@ -551,10 +589,13 @@ discard block |
||
551 | 589 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing"); |
552 | 590 | return false; |
553 | 591 | } |
554 | - if ($recur_date) // virtual exception |
|
592 | + if ($recur_date) |
|
593 | + { |
|
594 | + // virtual exception |
|
555 | 595 | { |
556 | 596 | // @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed |
557 | 597 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
598 | + } |
|
558 | 599 | //error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
559 | 600 | } |
560 | 601 | if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
@@ -564,7 +605,11 @@ discard block |
||
564 | 605 | //error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
565 | 606 | return false; |
566 | 607 | } |
567 | - if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
608 | + if (!$id) |
|
609 | + { |
|
610 | + $old_event['owner'] = $account; |
|
611 | + } |
|
612 | + // we do NOT allow to change the owner of existing events |
|
568 | 613 | |
569 | 614 | $event = $this->message2event($message, $account, $old_event); |
570 | 615 | |
@@ -593,7 +638,10 @@ discard block |
||
593 | 638 | unset($ex_event['etag']); |
594 | 639 | foreach(array_keys($ex_event) as $name) |
595 | 640 | { |
596 | - if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
641 | + if (substr($name,0,6) == 'recur_') |
|
642 | + { |
|
643 | + unset($ex_event[$name]); |
|
644 | + } |
|
597 | 645 | } |
598 | 646 | $ex_event['recur_type'] = calendar_rrule::NONE; |
599 | 647 | |
@@ -646,7 +694,10 @@ discard block |
||
646 | 694 | 'end' => 'endtime', |
647 | 695 | ) as $key => $attr) |
648 | 696 | { |
649 | - if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
|
697 | + if (isset($message->$attr)) |
|
698 | + { |
|
699 | + $event[$key] = Api\DateTime::server2user($message->$attr); |
|
700 | + } |
|
650 | 701 | } |
651 | 702 | // copying strings |
652 | 703 | foreach(array( |
@@ -655,7 +706,10 @@ discard block |
||
655 | 706 | 'location' => 'location', |
656 | 707 | ) as $key => $attr) |
657 | 708 | { |
658 | - if (isset($message->$attr)) $event[$key] = $message->$attr; |
|
709 | + if (isset($message->$attr)) |
|
710 | + { |
|
711 | + $event[$key] = $message->$attr; |
|
712 | + } |
|
659 | 713 | } |
660 | 714 | |
661 | 715 | // only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse |
@@ -674,14 +728,22 @@ discard block |
||
674 | 728 | |
675 | 729 | if (($event['whole_day'] = $message->alldayevent)) |
676 | 730 | { |
677 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
731 | + if ($event['end'] == $event['start']) |
|
732 | + { |
|
733 | + $event['end'] += 24*3600; |
|
734 | + } |
|
735 | + // some clients send equal start&end for 1day |
|
678 | 736 | $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
679 | 737 | } |
680 | 738 | |
681 | 739 | $participants = array(); |
682 | 740 | foreach((array)$message->attendees as $attendee) |
683 | 741 | { |
684 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
742 | + if ($attendee->type == 3) |
|
743 | + { |
|
744 | + continue; |
|
745 | + } |
|
746 | + // we can not identify resources and re-add them anyway later |
|
685 | 747 | |
686 | 748 | $matches = null; |
687 | 749 | if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
@@ -696,7 +758,10 @@ discard block |
||
696 | 758 | //'n_fn' => $attendee->name, // not sure if we want matches without email |
697 | 759 | ); |
698 | 760 | // search addressbook for participant |
699 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
761 | + if (!isset($this->addressbook)) |
|
762 | + { |
|
763 | + $this->addressbook = new Api\Contacts(); |
|
764 | + } |
|
700 | 765 | if ((list($data) = $this->addressbook->search($search, |
701 | 766 | array('id','egw_addressbook.account_id as account_id','n_fn'), |
702 | 767 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
@@ -704,10 +769,13 @@ discard block |
||
704 | 769 | { |
705 | 770 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
706 | 771 | } |
707 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
772 | + elseif($attendee->name === $attendee->email || empty($attendee->name)) |
|
773 | + { |
|
774 | + // dont store empty or email as name |
|
708 | 775 | { |
709 | 776 | $uid = 'e'.$attendee->email; |
710 | 777 | } |
778 | + } |
|
711 | 779 | else // store just the email |
712 | 780 | { |
713 | 781 | $uid = 'e'.$attendee->name.' <'.$attendee->email.'>'; |
@@ -736,7 +804,11 @@ discard block |
||
736 | 804 | $role = 'REQ-PARTICIPANT'; |
737 | 805 | //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
738 | 806 | } |
739 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
807 | + if ($role == 'CHAIR') |
|
808 | + { |
|
809 | + $chair_set = true; |
|
810 | + } |
|
811 | + // by role from existing participant |
|
740 | 812 | |
741 | 813 | if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
742 | 814 | { |
@@ -750,10 +822,13 @@ discard block |
||
750 | 822 | elseif (isset($attendee->attendeetype) && |
751 | 823 | !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
752 | 824 | ($r = array_search($attendee->attendeetype,self::$role2as)) && |
753 | - (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
|
825 | + (int)self::$role2as[$role] != $attendee->attendeetype) |
|
826 | + { |
|
827 | + // if old role gives same type, use old role, as we have a lot more roles then AS |
|
754 | 828 | { |
755 | 829 | $role = $r; |
756 | 830 | } |
831 | + } |
|
757 | 832 | //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
758 | 833 | $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
759 | 834 | } |
@@ -768,12 +843,19 @@ discard block |
||
768 | 843 | // $account is also preserved, as AS does not add him as participant! |
769 | 844 | foreach((array)$event['participant_types'] as $type => $parts) |
770 | 845 | { |
771 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
846 | + if (in_array($type,array('c','e'))) |
|
847 | + { |
|
848 | + continue; |
|
849 | + } |
|
850 | + // they are correctly representable in AS |
|
772 | 851 | |
773 | 852 | foreach($parts as $id => $status) |
774 | 853 | { |
775 | 854 | // accounts are represented correctly, but the event owner which is no participant in AS |
776 | - if ($type == 'u' && $id != $account) continue; |
|
855 | + if ($type == 'u' && $id != $account) |
|
856 | + { |
|
857 | + continue; |
|
858 | + } |
|
777 | 859 | |
778 | 860 | $uid = calendar_so::combine_user($type, $id); |
779 | 861 | if (!isset($participants[$uid])) |
@@ -798,10 +880,13 @@ discard block |
||
798 | 880 | // check if event is recurring and import recur information (incl. timezone) |
799 | 881 | if ($message->recurrence) |
800 | 882 | { |
801 | - if ($message->timezone && !$event['id']) // dont care for timezone, if no new and recurring event |
|
883 | + if ($message->timezone && !$event['id']) |
|
884 | + { |
|
885 | + // dont care for timezone, if no new and recurring event |
|
802 | 886 | { |
803 | 887 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
804 | 888 | } |
889 | + } |
|
805 | 890 | $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
806 | 891 | array_search($message->recurrence->type, self::$recur_type2as); |
807 | 892 | $event['recur_interval'] = $message->recurrence->interval; |
@@ -838,10 +923,13 @@ discard block |
||
838 | 923 | { |
839 | 924 | // calculate enddate from occurences count, as we only support enddate |
840 | 925 | $count = $message->recurrence->occurrences; |
841 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
926 | + foreach(calendar_rrule::event2rrule($event, true) as $rtime) |
|
927 | + { |
|
928 | + // true = timestamps are user time here, because of save! |
|
842 | 929 | { |
843 | 930 | if (--$count <= 0) break; |
844 | 931 | } |
932 | + } |
|
845 | 933 | $event['recur_enddate'] = $rtime->format('ts'); |
846 | 934 | } |
847 | 935 | } |
@@ -856,7 +944,9 @@ discard block |
||
856 | 944 | break; |
857 | 945 | } |
858 | 946 | } |
859 | - if ($alarm !== true) // new alarm |
|
947 | + if ($alarm !== true) |
|
948 | + { |
|
949 | + // new alarm |
|
860 | 950 | { |
861 | 951 | // delete all earlier alarms of that user |
862 | 952 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
@@ -866,6 +956,7 @@ discard block |
||
866 | 956 | if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
867 | 957 | { |
868 | 958 | unset($event['alarm'][$key]); |
959 | + } |
|
869 | 960 | } |
870 | 961 | } |
871 | 962 | $event['alarm'][] = $alarm = array( |
@@ -946,7 +1037,10 @@ discard block |
||
946 | 1037 | { |
947 | 1038 | unset($contentParameters); // not used, but required by function signature |
948 | 1039 | |
949 | - if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
|
1040 | + if (!isset($this->caledar)) |
|
1041 | + { |
|
1042 | + $this->calendar = new calendar_boupdate(); |
|
1043 | + } |
|
950 | 1044 | |
951 | 1045 | $ret = $this->calendar->delete($id); |
952 | 1046 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -1008,7 +1102,10 @@ discard block |
||
1008 | 1102 | */ |
1009 | 1103 | public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment') |
1010 | 1104 | { |
1011 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1105 | + if (!isset($this->calendar)) |
|
1106 | + { |
|
1107 | + $this->calendar = new calendar_boupdate(); |
|
1108 | + } |
|
1012 | 1109 | //error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
1013 | 1110 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
1014 | 1111 | $mimesupport = $contentparameters->GetMimeSupport(); |
@@ -1046,7 +1143,10 @@ discard block |
||
1046 | 1143 | catch(Exception $e) { |
1047 | 1144 | unset($e); |
1048 | 1145 | // z-push (2.3 at least) requires a timezone for recurring events |
1049 | - if ($event['recur_type']) $message->timezone = self::UTC_BLOB; |
|
1146 | + if ($event['recur_type']) |
|
1147 | + { |
|
1148 | + $message->timezone = self::UTC_BLOB; |
|
1149 | + } |
|
1050 | 1150 | } |
1051 | 1151 | |
1052 | 1152 | // copying timestamps (they are already read in servertime, so non tz conversation) |
@@ -1057,7 +1157,10 @@ discard block |
||
1057 | 1157 | 'modified' => 'dtstamp', |
1058 | 1158 | ) as $key => $attr) |
1059 | 1159 | { |
1060 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
1160 | + if (!empty($event[$key])) |
|
1161 | + { |
|
1162 | + $message->$attr = $event[$key]; |
|
1163 | + } |
|
1061 | 1164 | } |
1062 | 1165 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
1063 | 1166 | { |
@@ -1070,7 +1173,10 @@ discard block |
||
1070 | 1173 | 'location' => 'location', |
1071 | 1174 | ) as $key => $attr) |
1072 | 1175 | { |
1073 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
1176 | + if (!empty($event[$key])) |
|
1177 | + { |
|
1178 | + $message->$attr = $event[$key]; |
|
1179 | + } |
|
1074 | 1180 | } |
1075 | 1181 | |
1076 | 1182 | // appoint description |
@@ -1103,7 +1209,10 @@ discard block |
||
1103 | 1209 | foreach($event['participants'] as $uid => $status) |
1104 | 1210 | { |
1105 | 1211 | // AS does NOT want calendar owner as participant |
1106 | - if ($uid == $account) continue; |
|
1212 | + if ($uid == $account) |
|
1213 | + { |
|
1214 | + continue; |
|
1215 | + } |
|
1107 | 1216 | $quantity = $role = null; |
1108 | 1217 | calendar_so::split_status($status, $quantity, $role); |
1109 | 1218 | |
@@ -1120,7 +1229,10 @@ discard block |
||
1120 | 1229 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
1121 | 1230 | ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
1122 | 1231 | |
1123 | - if (!$info) continue; |
|
1232 | + if (!$info) |
|
1233 | + { |
|
1234 | + continue; |
|
1235 | + } |
|
1124 | 1236 | |
1125 | 1237 | if (!$info['email'] && $info['responsible']) |
1126 | 1238 | { |
@@ -1136,10 +1248,17 @@ discard block |
||
1136 | 1248 | $message->organizeremail = $attendee->email; |
1137 | 1249 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
1138 | 1250 | } |
1139 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1251 | + if ($uid[0] == 'r') |
|
1252 | + { |
|
1253 | + $attendee->type = 3; |
|
1254 | + } |
|
1255 | + // 3 = resource |
|
1140 | 1256 | } |
1141 | 1257 | // email must NOT be empty, but MAY be an arbitrary text |
1142 | - if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
1258 | + if (empty($attendee->email)) |
|
1259 | + { |
|
1260 | + $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
1261 | + } |
|
1143 | 1262 | |
1144 | 1263 | $message->attendees[] = $attendee; |
1145 | 1264 | } |
@@ -1174,9 +1293,12 @@ discard block |
||
1174 | 1293 | $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
1175 | 1294 | break; |
1176 | 1295 | } |
1177 | - if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
|
1296 | + if ($rrule->enddate) |
|
1297 | + { |
|
1298 | + // enddate is only a date, but AS needs a time incl. correct starttime! |
|
1178 | 1299 | { |
1179 | 1300 | $enddate = clone $rrule->time; |
1301 | + } |
|
1180 | 1302 | $enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'), |
1181 | 1303 | $rrule->enddate->format('d')); |
1182 | 1304 | $recurrence->until = $enddate->format('server'); |
@@ -1198,12 +1320,19 @@ discard block |
||
1198 | 1320 | { |
1199 | 1321 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
1200 | 1322 | } |
1201 | - if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1323 | + if (count($ex_events)>=1) |
|
1324 | + { |
|
1325 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1326 | + } |
|
1202 | 1327 | |
1203 | 1328 | $message->exceptions = array(); |
1204 | 1329 | foreach($ex_events as $ex_event) |
1205 | 1330 | { |
1206 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1331 | + if ($ex_event['id'] == $event['id']) |
|
1332 | + { |
|
1333 | + continue; |
|
1334 | + } |
|
1335 | + // ignore series master |
|
1207 | 1336 | $exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException'); |
1208 | 1337 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
1209 | 1338 | foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
@@ -1223,7 +1352,10 @@ discard block |
||
1223 | 1352 | { |
1224 | 1353 | if (!empty($exception_time)) |
1225 | 1354 | { |
1226 | - if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
1355 | + if (empty($event['uid'])) |
|
1356 | + { |
|
1357 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
1358 | + } |
|
1227 | 1359 | $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
1228 | 1360 | $exception->deleted = 1; |
1229 | 1361 | $exception->exceptionstarttime = $exception_time; |
@@ -1279,12 +1411,18 @@ discard block |
||
1279 | 1411 | { |
1280 | 1412 | unset($folderid); // not used ($id is unique), but required by function signature |
1281 | 1413 | |
1282 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1414 | + if (!isset($this->calendar)) |
|
1415 | + { |
|
1416 | + $this->calendar = new calendar_boupdate(); |
|
1417 | + } |
|
1283 | 1418 | |
1284 | 1419 | $nul = null; |
1285 | - if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) // last true: $only_master=true |
|
1420 | + if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) |
|
1421 | + { |
|
1422 | + // last true: $only_master=true |
|
1286 | 1423 | { |
1287 | 1424 | $stat = false; |
1425 | + } |
|
1288 | 1426 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
1289 | 1427 | $backup = $this->calendar->debug; |
1290 | 1428 | //$this->calendar->debug = 2; |
@@ -1318,13 +1456,22 @@ discard block |
||
1318 | 1456 | $type = $owner = null; |
1319 | 1457 | $this->backend->splitID($folderid, $type, $owner); |
1320 | 1458 | |
1321 | - if ($type != 'calendar') return false; |
|
1459 | + if ($type != 'calendar') |
|
1460 | + { |
|
1461 | + return false; |
|
1462 | + } |
|
1322 | 1463 | |
1323 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
1464 | + if (!isset($this->calendar)) |
|
1465 | + { |
|
1466 | + $this->calendar = new calendar_boupdate(); |
|
1467 | + } |
|
1324 | 1468 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
1325 | 1469 | $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
1326 | 1470 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
1327 | - if ($syncstate == 0) $syncstate = 1; |
|
1471 | + if ($syncstate == 0) |
|
1472 | + { |
|
1473 | + $syncstate = 1; |
|
1474 | + } |
|
1328 | 1475 | |
1329 | 1476 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'"); |
1330 | 1477 | } |
@@ -1400,10 +1547,16 @@ discard block |
||
1400 | 1547 | 'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0, |
1401 | 1548 | ); |
1402 | 1549 | |
1403 | - if ($tz === 'UTC') return $data; |
|
1550 | + if ($tz === 'UTC') |
|
1551 | + { |
|
1552 | + return $data; |
|
1553 | + } |
|
1404 | 1554 | |
1405 | 1555 | $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
1406 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
1556 | + if (strpos($component, 'VTIMEZONE') === false) |
|
1557 | + { |
|
1558 | + $component = calendar_timezones::tz2id($name,'component'); |
|
1559 | + } |
|
1407 | 1560 | // parse ical timezone defintion |
1408 | 1561 | $ical = self::ical2array($component); |
1409 | 1562 | $standard = $ical['VTIMEZONE']['STANDARD']; |
@@ -1446,11 +1599,17 @@ discard block |
||
1446 | 1599 | $data[$prefix.'week'] = 5; |
1447 | 1600 | } |
1448 | 1601 | // if both start and end use 1SU use week=5 and decrement month |
1449 | - if ($prefix == 'dststart') $start_byday = $matches[1]; |
|
1602 | + if ($prefix == 'dststart') |
|
1603 | + { |
|
1604 | + $start_byday = $matches[1]; |
|
1605 | + } |
|
1450 | 1606 | if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU') |
1451 | 1607 | { |
1452 | 1608 | $data[$prefix.'week'] = 5; |
1453 | - if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
|
1609 | + if ($prefix == 'dstend') |
|
1610 | + { |
|
1611 | + $data[$prefix.'month'] -= 1; |
|
1612 | + } |
|
1454 | 1613 | } |
1455 | 1614 | static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
1456 | 1615 | $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
@@ -1526,7 +1685,10 @@ discard block |
||
1526 | 1685 | static public function ical2array(&$ical,$section=null) |
1527 | 1686 | { |
1528 | 1687 | $arr = array(); |
1529 | - if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
|
1688 | + if (!is_array($ical)) |
|
1689 | + { |
|
1690 | + $ical = preg_split("/[\r\n]+/m", $ical); |
|
1691 | + } |
|
1530 | 1692 | while (($line = array_shift($ical))) |
1531 | 1693 | { |
1532 | 1694 | list($name,$value) = explode(':',$line,2); |
@@ -1536,7 +1698,10 @@ discard block |
||
1536 | 1698 | } |
1537 | 1699 | elseif($name == 'END') |
1538 | 1700 | { |
1539 | - if ($section && $section==$value) return $arr; |
|
1701 | + if ($section && $section==$value) |
|
1702 | + { |
|
1703 | + return $arr; |
|
1704 | + } |
|
1540 | 1705 | break; |
1541 | 1706 | } |
1542 | 1707 | else |
@@ -1567,13 +1732,19 @@ discard block |
||
1567 | 1732 | |
1568 | 1733 | for($n = 0; !isset($cache[$key]); ++$n) |
1569 | 1734 | { |
1570 | - if (!$n) // check users timezone first |
|
1735 | + if (!$n) |
|
1736 | + { |
|
1737 | + // check users timezone first |
|
1571 | 1738 | { |
1572 | 1739 | $tz = Api\DateTime::$user_timezone->getName(); |
1573 | 1740 | } |
1574 | - elseif (!($tz = calendar_timezones::id2tz($n))) // no further timezones to check |
|
1741 | + } |
|
1742 | + elseif (!($tz = calendar_timezones::id2tz($n))) |
|
1743 | + { |
|
1744 | + // no further timezones to check |
|
1575 | 1745 | { |
1576 | 1746 | $cache[$key] = 'UTC'; |
1747 | + } |
|
1577 | 1748 | error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!'); |
1578 | 1749 | break; |
1579 | 1750 | } |
@@ -1637,7 +1808,11 @@ discard block |
||
1637 | 1808 | $account_id = $entry['grantor']; |
1638 | 1809 | $cals[$account_id] = $entry['name']; |
1639 | 1810 | } |
1640 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1811 | + if ($hook_data['account_id'] > 0) |
|
1812 | + { |
|
1813 | + unset($cals[$hook_data['account_id']]); |
|
1814 | + } |
|
1815 | + // skip current user |
|
1641 | 1816 | } |
1642 | 1817 | $cals['G'] = lang('Primary group'); |
1643 | 1818 | $cals['A'] = lang('All'); |
@@ -1665,13 +1840,16 @@ discard block |
||
1665 | 1840 | * |
1666 | 1841 | * You need to comment implements activesync_plugin_write |
1667 | 1842 | */ |
1668 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
1843 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
1844 | +{ |
|
1845 | + // some tests |
|
1669 | 1846 | { |
1670 | 1847 | $GLOBALS['egw_info'] = array( |
1671 | 1848 | 'flags' => array( |
1672 | 1849 | 'currentapp' => 'login' |
1673 | 1850 | ) |
1674 | 1851 | ); |
1852 | +} |
|
1675 | 1853 | require_once('../../header.inc.php'); |
1676 | 1854 | ini_set('display_errors',1); |
1677 | 1855 | error_reporting(E_ALL & ~E_NOTICE); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param int $truncsize |
283 | 283 | * @param int $bodypreference |
284 | 284 | * @param $optionbodypreference |
285 | - * @param bool $mimesupport |
|
285 | + * @param integer $mimesupport |
|
286 | 286 | * @return SyncMail |
287 | 287 | */ |
288 | 288 | function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @param string $id of the folder to delete |
901 | 901 | * |
902 | 902 | * @return |
903 | - * @TODO check what is to be returned |
|
903 | + boolean @TODO check what is to be returned |
|
904 | 904 | */ |
905 | 905 | public function DeleteFolder($parentid, $id) |
906 | 906 | { |
@@ -1596,6 +1596,7 @@ discard block |
||
1596 | 1596 | * Unpack timezone info from Sync |
1597 | 1597 | * |
1598 | 1598 | * copied from backend/ics.php |
1599 | + * @param string $data |
|
1599 | 1600 | */ |
1600 | 1601 | static public function _getTZFromSyncBlob($data) |
1601 | 1602 | { |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
85 | 85 | |
86 | 86 | $cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
87 | - $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
|
87 | + $cals = $cals_pref ? explode(',', $cals_pref) : array('P'); // implicit default of 'P' |
|
88 | 88 | $folderlist = array(); |
89 | 89 | |
90 | 90 | foreach ($this->calendar->list_cals() as $entry) |
91 | 91 | { |
92 | 92 | $account_id = $entry['grantor']; |
93 | - if (in_array('A',$cals) || in_array($account_id,$cals) || |
|
94 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
95 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals)) |
|
93 | + if (in_array('A', $cals) || in_array($account_id, $cals) || |
|
94 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar! |
|
95 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals)) |
|
96 | 96 | { |
97 | 97 | $folderlist[] = $f = array( |
98 | - 'id' => $this->backend->createID('calendar',$account_id), |
|
99 | - 'mod' => $GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'), |
|
98 | + 'id' => $this->backend->createID('calendar', $account_id), |
|
99 | + 'mod' => $GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'), |
|
100 | 100 | 'parent'=> '0', |
101 | 101 | ); |
102 | 102 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $folderObj = new SyncFolder(); |
121 | 121 | $folderObj->serverid = $id; |
122 | 122 | $folderObj->parentid = '0'; |
123 | - $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'); |
|
123 | + $folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'); |
|
124 | 124 | if ($owner == $GLOBALS['egw_info']['user']['account_id']) |
125 | 125 | { |
126 | 126 | $folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | $stat = array( |
156 | 156 | 'id' => $id, |
157 | - 'mod' => $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'), |
|
157 | + 'mod' => $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'), |
|
158 | 158 | 'parent' => '0', |
159 | 159 | ); |
160 | 160 | //error_log(__METHOD__."('$id') folderObj=".array2string($stat)); |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param array $not_uids =null uids NOT to return for meeting requests |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
|
181 | + function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null) |
|
182 | 182 | { |
183 | 183 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
184 | 184 | |
185 | 185 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
186 | 186 | $type = $user = null; |
187 | - $this->backend->splitID($id,$type,$user); |
|
187 | + $this->backend->splitID($id, $type, $user); |
|
188 | 188 | |
189 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
189 | + if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences |
|
190 | 190 | |
191 | 191 | $filter = array( |
192 | 192 | 'users' => $user, |
193 | - 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
193 | + 'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences |
|
194 | 194 | 'enum_recuring' => false, |
195 | 195 | 'daywise' => false, |
196 | 196 | 'date_format' => 'server', |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | 'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default', |
200 | 200 | // @todo return only etag relevant information (seems not to work ...) |
201 | 201 | //'cols' => array('egw_cal.cal_id', 'cal_start', 'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'), |
202 | - 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
202 | + 'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions |
|
203 | 203 | ); |
204 | 204 | |
205 | 205 | $messagelist = array(); |
206 | 206 | // reading events in chunks of 100, to keep memory down for huge calendars |
207 | 207 | $num_rows = 100; |
208 | - for($start=0; ($events = $this->calendar->search($filter+array( |
|
208 | + for ($start = 0; ($events = $this->calendar->search($filter + array( |
|
209 | 209 | 'offset' => $start, |
210 | 210 | 'num_rows' => $num_rows, |
211 | 211 | ))); $start += $num_rows) |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param int $cutoffdate =null |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - function GetMeetingRequests(array $not_uids, $cutoffdate=NULL) |
|
243 | + function GetMeetingRequests(array $not_uids, $cutoffdate = NULL) |
|
244 | 244 | { |
245 | 245 | unset($not_uids, $cutoffdate); |
246 | 246 | return array(); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | function StatMeetingRequest($id) |
268 | 268 | { |
269 | - $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
269 | + $folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar |
|
270 | 270 | |
271 | 271 | $ret = $this->StatMessage($folderid, abs($id)); |
272 | 272 | $ret['id'] = $id; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | * @param bool $mimesupport |
286 | 286 | * @return SyncMail |
287 | 287 | */ |
288 | - function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
|
288 | + function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0) |
|
289 | 289 | { |
290 | - unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
|
290 | + unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
|
291 | 291 | |
292 | 292 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
293 | 293 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | $message = new SyncMail(); |
301 | 301 | $message->read = false; |
302 | 302 | $message->subject = $event['title']; |
303 | - $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
303 | + $message->importance = 1; // 0=Low, 1=Normal, 2=High |
|
304 | 304 | $message->datereceived = $event['created']; |
305 | 305 | $message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email']; |
306 | - $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'). |
|
307 | - ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>'; |
|
306 | + $message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'). |
|
307 | + ' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>'; |
|
308 | 308 | $message->internetcpid = 65001; |
309 | - $message->contentclass="urn:content-classes:message"; |
|
309 | + $message->contentclass = "urn:content-classes:message"; |
|
310 | 310 | |
311 | 311 | $message->meetingrequest = self::meetingRequest($event); |
312 | 312 | $message->messageclass = "IPM.Schedule.Meeting.Request"; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | else |
322 | 322 | { |
323 | 323 | $message->airsyncbasebody = new SyncAirSyncBaseBody(); |
324 | - $message->airsyncbasenativebodytype=1; |
|
324 | + $message->airsyncbasenativebodytype = 1; |
|
325 | 325 | $this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody); |
326 | 326 | } |
327 | 327 | } |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | $as_tz = self::tz2as($event['tzid']); |
357 | 357 | $message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz)); |
358 | 358 | } |
359 | - catch(Exception $e) { |
|
359 | + catch (Exception $e) { |
|
360 | 360 | unset($e); |
361 | 361 | // ignore exception, simply set no timezone, as it is optional |
362 | 362 | } |
363 | 363 | // copying timestamps (they are already read in servertime, so non tz conversation) |
364 | - foreach(array( |
|
364 | + foreach (array( |
|
365 | 365 | 'start' => 'starttime', |
366 | 366 | 'end' => 'endtime', |
367 | 367 | 'created' => 'dtstamp', |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | } |
372 | 372 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
373 | 373 | { |
374 | - ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
374 | + ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
375 | 375 | } |
376 | 376 | // copying strings |
377 | - foreach(array( |
|
377 | + foreach (array( |
|
378 | 378 | 'title' => 'subject', |
379 | 379 | 'location' => 'location', |
380 | 380 | ) as $key => $attr) |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | } |
384 | 384 | $message->organizer = $event['organizer']; |
385 | 385 | |
386 | - $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
386 | + $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
387 | 387 | |
388 | 388 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
389 | 389 | $message->busystatus = $event['non_blocking'] ? 0 : 2; |
390 | 390 | |
391 | 391 | // ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ... |
392 | - $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
392 | + $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception |
|
393 | 393 | |
394 | - $message->responserequested = 1; //0=No, 1=Yes |
|
395 | - $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
394 | + $message->responserequested = 1; //0=No, 1=Yes |
|
395 | + $message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed |
|
396 | 396 | //$message->messagemeetingtype; // email2 |
397 | 397 | |
398 | 398 | // ToDo: alarme: Reminder |
@@ -438,14 +438,14 @@ discard block |
||
438 | 438 | // check if event already exist (invitation of or already imported by other user) |
439 | 439 | if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server'))) |
440 | 440 | { |
441 | - $event = $parsed_event; // create new event from external invitation |
|
441 | + $event = $parsed_event; // create new event from external invitation |
|
442 | 442 | } |
443 | - elseif(!isset($event['participants'][$uid])) |
|
443 | + elseif (!isset($event['participants'][$uid])) |
|
444 | 444 | { |
445 | 445 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event)); |
446 | 446 | // maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ... |
447 | 447 | } |
448 | - elseif($event['deleted']) |
|
448 | + elseif ($event['deleted']) |
|
449 | 449 | { |
450 | 450 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false"); |
451 | 451 | return false; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | else |
469 | 469 | { |
470 | 470 | $event['participants'][$uid] = $status; |
471 | - $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
471 | + $ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS |
|
472 | 472 | } |
473 | 473 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret)); |
474 | 474 | return $ret; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | * @var array |
481 | 481 | */ |
482 | 482 | static $status2as = array( |
483 | - 'U' => 0, // unknown |
|
484 | - 'T' => 2, // tentative |
|
485 | - 'A' => 3, // accepted |
|
486 | - 'R' => 4, // decline |
|
483 | + 'U' => 0, // unknown |
|
484 | + 'T' => 2, // tentative |
|
485 | + 'A' => 3, // accepted |
|
486 | + 'R' => 4, // decline |
|
487 | 487 | // 5 = not responded |
488 | 488 | ); |
489 | 489 | /** |
@@ -492,9 +492,9 @@ discard block |
||
492 | 492 | * @var array |
493 | 493 | */ |
494 | 494 | static $role2as = array( |
495 | - 'REQ-PARTICIPANT' => 1, // required |
|
496 | - 'CHAIR' => 1, // required |
|
497 | - 'OPT-PARTICIPANT' => 2, // optional |
|
495 | + 'REQ-PARTICIPANT' => 1, // required |
|
496 | + 'CHAIR' => 1, // required |
|
497 | + 'OPT-PARTICIPANT' => 2, // optional |
|
498 | 498 | 'NON-PARTICIPANT' => 2, |
499 | 499 | // 3 = ressource |
500 | 500 | ); |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | static $recur_type2as = array( |
507 | 507 | calendar_rrule::DAILY => 0, |
508 | 508 | calendar_rrule::WEEKLY => 1, |
509 | - calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
510 | - calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
509 | + calendar_rrule::MONTHLY_MDAY => 2, // monthly |
|
510 | + calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day |
|
511 | 511 | calendar_rrule::YEARLY => 5, |
512 | 512 | // 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears) |
513 | 513 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function ChangeMessage($folderid, $_id, $message, $contentParameters) |
536 | 536 | { |
537 | - unset($contentParameters); // unused, but required by function signature |
|
537 | + unset($contentParameters); // unused, but required by function signature |
|
538 | 538 | |
539 | 539 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
540 | 540 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account"); |
546 | 546 | |
547 | - list($id,$recur_date) = explode(':', $_id); |
|
547 | + list($id, $recur_date) = explode(':', $_id); |
|
548 | 548 | |
549 | 549 | if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server'))) |
550 | 550 | { |
@@ -557,21 +557,21 @@ discard block |
||
557 | 557 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
558 | 558 | //error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
559 | 559 | } |
560 | - if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
|
560 | + if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0, $account)) |
|
561 | 561 | { |
562 | 562 | // @todo: write in users calendar and make account only a participant |
563 | 563 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!"); |
564 | 564 | //error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
565 | 565 | return false; |
566 | 566 | } |
567 | - if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
567 | + if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
568 | 568 | |
569 | 569 | $event = $this->message2event($message, $account, $old_event); |
570 | 570 | |
571 | 571 | // store event, ignore conflicts and skip notifications, as AS clients do their own notifications |
572 | 572 | $skip_notification = false; |
573 | 573 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
574 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send') |
|
574 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'send') |
|
575 | 575 | { |
576 | 576 | $skip_notification = true; // to avoid double notification from client AND Server |
577 | 577 | } |
@@ -584,16 +584,16 @@ discard block |
||
584 | 584 | // store non-delete exceptions |
585 | 585 | if ($message->exceptions) |
586 | 586 | { |
587 | - foreach($message->exceptions as $exception) |
|
587 | + foreach ($message->exceptions as $exception) |
|
588 | 588 | { |
589 | 589 | if (!$exception->deleted) |
590 | 590 | { |
591 | 591 | $ex_event = $event; |
592 | 592 | unset($ex_event['id']); |
593 | 593 | unset($ex_event['etag']); |
594 | - foreach(array_keys($ex_event) as $name) |
|
594 | + foreach (array_keys($ex_event) as $name) |
|
595 | 595 | { |
596 | - if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
596 | + if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]); |
|
597 | 597 | } |
598 | 598 | $ex_event['recur_type'] = calendar_rrule::NONE; |
599 | 599 | |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | 'user' => $account, |
602 | 602 | 'enum_recuring' => false, |
603 | 603 | 'daywise' => false, |
604 | - 'filter' => 'owner', // return all possible entries |
|
604 | + 'filter' => 'owner', // return all possible entries |
|
605 | 605 | 'query' => array( |
606 | 606 | 'cal_uid' => $event['uid'], |
607 | - 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
607 | + 'cal_recurrence' => $exception->exceptionstarttime, // in servertime |
|
608 | 608 | ), |
609 | 609 | )))) |
610 | 610 | { |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $participants = $event['participants']; |
617 | 617 | } |
618 | 618 | $save_event = $this->message2event($exception, $account, $ex_event); |
619 | - $save_event['participants'] = $participants; // not contained in $exception |
|
619 | + $save_event['participants'] = $participants; // not contained in $exception |
|
620 | 620 | $save_event['reference'] = $event['id']; |
621 | 621 | $save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime); |
622 | 622 | $ex_ok = $this->calendar->save($save_event); |
@@ -638,10 +638,10 @@ discard block |
||
638 | 638 | * @param array $event =array() |
639 | 639 | * @return array |
640 | 640 | */ |
641 | - private function message2event(SyncAppointment $message, $account, $event=array()) |
|
641 | + private function message2event(SyncAppointment $message, $account, $event = array()) |
|
642 | 642 | { |
643 | 643 | // timestamps (created & modified are updated automatically) |
644 | - foreach(array( |
|
644 | + foreach (array( |
|
645 | 645 | 'start' => 'starttime', |
646 | 646 | 'end' => 'endtime', |
647 | 647 | ) as $key => $attr) |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
650 | 650 | } |
651 | 651 | // copying strings |
652 | - foreach(array( |
|
652 | + foreach (array( |
|
653 | 653 | 'title' => 'subject', |
654 | 654 | 'uid' => 'uid', |
655 | 655 | 'location' => 'location', |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $event['description'] = $description; |
666 | 666 | } |
667 | - $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
667 | + $event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential |
|
668 | 668 | |
669 | 669 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
670 | 670 | if (isset($message->busystatus)) |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | |
675 | 675 | if (($event['whole_day'] = $message->alldayevent)) |
676 | 676 | { |
677 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
678 | - $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
677 | + if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day |
|
678 | + $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | $participants = array(); |
682 | - foreach((array)$message->attendees as $attendee) |
|
682 | + foreach ((array)$message->attendees as $attendee) |
|
683 | 683 | { |
684 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
684 | + if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
685 | 685 | |
686 | 686 | $matches = null; |
687 | - if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
|
687 | + if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches)) |
|
688 | 688 | { |
689 | 689 | $uid = $matches[1]; |
690 | 690 | } |
691 | - elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email'))) |
|
691 | + elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email'))) |
|
692 | 692 | { |
693 | 693 | $search = array( |
694 | 694 | 'email' => $attendee->email, |
@@ -698,13 +698,13 @@ discard block |
||
698 | 698 | // search addressbook for participant |
699 | 699 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
700 | 700 | if ((list($data) = $this->addressbook->search($search, |
701 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
701 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
702 | 702 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
703 | - '','',false,'OR'))) |
|
703 | + '', '', false, 'OR'))) |
|
704 | 704 | { |
705 | 705 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
706 | 706 | } |
707 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
707 | + elseif ($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
708 | 708 | { |
709 | 709 | $uid = 'e'.$attendee->email; |
710 | 710 | } |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | //ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
723 | 723 | } |
724 | 724 | // check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set |
725 | - elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) || |
|
726 | - (isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
725 | + elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) || |
|
726 | + (isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>'])))) |
|
727 | 727 | { |
728 | 728 | $status = $event['participants'][$u]; |
729 | 729 | calendar_so::split_status($status, $quantity, $role); |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | $role = 'REQ-PARTICIPANT'; |
737 | 737 | //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
738 | 738 | } |
739 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
739 | + if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
740 | 740 | |
741 | - if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
|
741 | + if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as))) |
|
742 | 742 | { |
743 | 743 | $status = $s; |
744 | 744 | } |
@@ -748,29 +748,29 @@ discard block |
||
748 | 748 | $chair_set = true; |
749 | 749 | } |
750 | 750 | elseif (isset($attendee->attendeetype) && |
751 | - !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
752 | - ($r = array_search($attendee->attendeetype,self::$role2as)) && |
|
751 | + !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
|
752 | + ($r = array_search($attendee->attendeetype, self::$role2as)) && |
|
753 | 753 | (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
754 | 754 | { |
755 | 755 | $role = $r; |
756 | 756 | } |
757 | 757 | //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
758 | - $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
|
758 | + $participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role); |
|
759 | 759 | } |
760 | 760 | // if organizer is not already participant, add him as chair |
761 | - if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid])) |
|
761 | + if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid])) |
|
762 | 762 | { |
763 | 763 | $participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ? |
764 | - 'A' : 'U',1,'CHAIR'); |
|
764 | + 'A' : 'U', 1, 'CHAIR'); |
|
765 | 765 | $chair_set = true; |
766 | 766 | } |
767 | 767 | // preserve all resource types not account, contact or email (eg. resources) for existing events |
768 | 768 | // $account is also preserved, as AS does not add him as participant! |
769 | - foreach((array)$event['participant_types'] as $type => $parts) |
|
769 | + foreach ((array)$event['participant_types'] as $type => $parts) |
|
770 | 770 | { |
771 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
771 | + if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS |
|
772 | 772 | |
773 | - foreach($parts as $id => $status) |
|
773 | + foreach ($parts as $id => $status) |
|
774 | 774 | { |
775 | 775 | // accounts are represented correctly, but the event owner which is no participant in AS |
776 | 776 | if ($type == 'u' && $id != $account) continue; |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | if (!$event['id'] || !$participants || !isset($participants[$account])) |
787 | 787 | { |
788 | 788 | $participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ? |
789 | - 'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
789 | + 'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
790 | 790 | } |
791 | 791 | $event['participants'] = $participants; |
792 | 792 | |
793 | 793 | if (isset($message->categories)) |
794 | 794 | { |
795 | - $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen')); |
|
795 | + $event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen')); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | // check if event is recurring and import recur information (incl. timezone) |
@@ -802,8 +802,7 @@ discard block |
||
802 | 802 | { |
803 | 803 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
804 | 804 | } |
805 | - $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
|
806 | - array_search($message->recurrence->type, self::$recur_type2as); |
|
805 | + $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as); |
|
807 | 806 | $event['recur_interval'] = $message->recurrence->interval; |
808 | 807 | |
809 | 808 | switch ($event['recur_type']) |
@@ -812,7 +811,7 @@ discard block |
||
812 | 811 | // $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date |
813 | 812 | // fall throught |
814 | 813 | case calendar_rrule::WEEKLY: |
815 | - $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
814 | + $event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
816 | 815 | break; |
817 | 816 | case calendar_rrule::MONTHLY_MDAY: |
818 | 817 | // $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date |
@@ -828,7 +827,7 @@ discard block |
||
828 | 827 | $event['recur_exception'] = array(); |
829 | 828 | if ($message->exceptions) |
830 | 829 | { |
831 | - foreach($message->exceptions as $exception) |
|
830 | + foreach ($message->exceptions as $exception) |
|
832 | 831 | { |
833 | 832 | $event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime); |
834 | 833 | } |
@@ -838,7 +837,7 @@ discard block |
||
838 | 837 | { |
839 | 838 | // calculate enddate from occurences count, as we only support enddate |
840 | 839 | $count = $message->recurrence->occurrences; |
841 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
840 | + foreach (calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
842 | 841 | { |
843 | 842 | if (--$count <= 0) break; |
844 | 843 | } |
@@ -848,11 +847,11 @@ discard block |
||
848 | 847 | // only import alarms in own calendar |
849 | 848 | if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id']) |
850 | 849 | { |
851 | - foreach((array)$event['alarm'] as $alarm) |
|
850 | + foreach ((array)$event['alarm'] as $alarm) |
|
852 | 851 | { |
853 | - if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder) |
|
852 | + if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder) |
|
854 | 853 | { |
855 | - $alarm = true; // alarm already exists --> do nothing |
|
854 | + $alarm = true; // alarm already exists --> do nothing |
|
856 | 855 | break; |
857 | 856 | } |
858 | 857 | } |
@@ -861,16 +860,16 @@ discard block |
||
861 | 860 | // delete all earlier alarms of that user |
862 | 861 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
863 | 862 | // --> if a later alarm is returned, user probably modifed an existing alarm |
864 | - foreach((array)$event['alarm'] as $key => $alarm) |
|
863 | + foreach ((array)$event['alarm'] as $key => $alarm) |
|
865 | 864 | { |
866 | - if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
|
865 | + if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder) |
|
867 | 866 | { |
868 | 867 | unset($event['alarm'][$key]); |
869 | 868 | } |
870 | 869 | } |
871 | 870 | $event['alarm'][] = $alarm = array( |
872 | 871 | 'owner' => $account, |
873 | - 'offset' => 60*$message->reminder, |
|
872 | + 'offset' => 60 * $message->reminder, |
|
874 | 873 | ); |
875 | 874 | } |
876 | 875 | } |
@@ -944,7 +943,7 @@ discard block |
||
944 | 943 | */ |
945 | 944 | public function DeleteMessage($folderid, $id, $contentParameters) |
946 | 945 | { |
947 | - unset($contentParameters); // not used, but required by function signature |
|
946 | + unset($contentParameters); // not used, but required by function signature |
|
948 | 947 | |
949 | 948 | if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
950 | 949 | |
@@ -972,7 +971,7 @@ discard block |
||
972 | 971 | */ |
973 | 972 | function SetReadFlag($folderid, $id, $flags, $contentParameters) |
974 | 973 | { |
975 | - unset($contentParameters); // not used, but required by function signature |
|
974 | + unset($contentParameters); // not used, but required by function signature |
|
976 | 975 | |
977 | 976 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, ".array2string($flags)." NOT supported!"); |
978 | 977 | return false; |
@@ -1006,7 +1005,7 @@ discard block |
||
1006 | 1005 | * @param string $class ='SyncAppointment' or 'SyncAppointmentException' |
1007 | 1006 | * @return SyncAppointment|boolean false on error |
1008 | 1007 | */ |
1009 | - public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment') |
|
1008 | + public function GetMessage($folderid, $id, $contentparameters, $class = 'SyncAppointment') |
|
1010 | 1009 | { |
1011 | 1010 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
1012 | 1011 | //error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
@@ -1024,17 +1023,17 @@ discard block |
||
1024 | 1023 | } |
1025 | 1024 | else |
1026 | 1025 | { |
1027 | - list($id,$recur_date) = explode(':',$id); |
|
1028 | - if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account))) |
|
1026 | + list($id, $recur_date) = explode(':', $id); |
|
1027 | + if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account))) |
|
1029 | 1028 | { |
1030 | 1029 | error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false"); |
1031 | 1030 | return false; |
1032 | 1031 | } |
1033 | 1032 | } |
1034 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence'])); |
|
1035 | - foreach((array)$event['recur_exception'] as $ex) |
|
1033 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence'])); |
|
1034 | + foreach ((array)$event['recur_exception'] as $ex) |
|
1036 | 1035 | { |
1037 | - ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s',$ex)); |
|
1036 | + ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s', $ex)); |
|
1038 | 1037 | } |
1039 | 1038 | $message = new $class(); |
1040 | 1039 | |
@@ -1043,14 +1042,14 @@ discard block |
||
1043 | 1042 | $as_tz = self::tz2as($event['tzid']); |
1044 | 1043 | $message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz)); |
1045 | 1044 | } |
1046 | - catch(Exception $e) { |
|
1045 | + catch (Exception $e) { |
|
1047 | 1046 | unset($e); |
1048 | 1047 | // z-push (2.3 at least) requires a timezone for recurring events |
1049 | 1048 | if ($event['recur_type']) $message->timezone = self::UTC_BLOB; |
1050 | 1049 | } |
1051 | 1050 | |
1052 | 1051 | // copying timestamps (they are already read in servertime, so non tz conversation) |
1053 | - foreach(array( |
|
1052 | + foreach (array( |
|
1054 | 1053 | 'start' => 'starttime', |
1055 | 1054 | 'end' => 'endtime', |
1056 | 1055 | 'created' => 'dtstamp', |
@@ -1061,10 +1060,10 @@ discard block |
||
1061 | 1060 | } |
1062 | 1061 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
1063 | 1062 | { |
1064 | - ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
1063 | + ++$message->endtime; // EGw all-day-events are 1 sec shorter! |
|
1065 | 1064 | } |
1066 | 1065 | // copying strings |
1067 | - foreach(array( |
|
1066 | + foreach (array( |
|
1068 | 1067 | 'title' => 'subject', |
1069 | 1068 | 'uid' => 'uid', |
1070 | 1069 | 'location' => 'location', |
@@ -1086,21 +1085,21 @@ discard block |
||
1086 | 1085 | { |
1087 | 1086 | ZLog::Write(LOGLEVEL_DEBUG, "airsyncbasebody!"); |
1088 | 1087 | $message->asbody = new SyncBaseBody(); |
1089 | - $message->nativebodytype=1; |
|
1088 | + $message->nativebodytype = 1; |
|
1090 | 1089 | $this->backend->note2messagenote($event['description'], $bodypreference, $message->asbody); |
1091 | 1090 | } |
1092 | 1091 | } |
1093 | - $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'); |
|
1092 | + $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname'); |
|
1094 | 1093 | // at least iOS calendar crashes, if organizer has no email address (true = generate an email, if user has none) |
1095 | 1094 | $message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email', true); |
1096 | 1095 | |
1097 | - $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
1096 | + $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential |
|
1098 | 1097 | |
1099 | 1098 | // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 |
1100 | 1099 | $message->busystatus = $event['non_blocking'] ? 0 : 2; |
1101 | 1100 | |
1102 | 1101 | $message->attendees = array(); |
1103 | - foreach($event['participants'] as $uid => $status) |
|
1102 | + foreach ($event['participants'] as $uid => $status) |
|
1104 | 1103 | { |
1105 | 1104 | // AS does NOT want calendar owner as participant |
1106 | 1105 | if ($uid == $account) continue; |
@@ -1112,13 +1111,13 @@ discard block |
||
1112 | 1111 | $attendee->attendeetype = (int)self::$role2as[$role]; |
1113 | 1112 | if (is_numeric($uid)) |
1114 | 1113 | { |
1115 | - $attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname'); |
|
1114 | + $attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname'); |
|
1116 | 1115 | $attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email', true); |
1117 | 1116 | } |
1118 | 1117 | else |
1119 | 1118 | { |
1120 | 1119 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
1121 | - ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
|
1120 | + ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false); |
|
1122 | 1121 | |
1123 | 1122 | if (!$info) continue; |
1124 | 1123 | |
@@ -1136,7 +1135,7 @@ discard block |
||
1136 | 1135 | $message->organizeremail = $attendee->email; |
1137 | 1136 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
1138 | 1137 | } |
1139 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1138 | + if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
1140 | 1139 | } |
1141 | 1140 | // email must NOT be empty, but MAY be an arbitrary text |
1142 | 1141 | if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
@@ -1144,7 +1143,7 @@ discard block |
||
1144 | 1143 | $message->attendees[] = $attendee; |
1145 | 1144 | } |
1146 | 1145 | $message->categories = array(); |
1147 | - foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id) |
|
1146 | + foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id) |
|
1148 | 1147 | { |
1149 | 1148 | $message->categories[] = Api\Categories::id2name($cat_id); |
1150 | 1149 | } |
@@ -1153,25 +1152,25 @@ discard block |
||
1153 | 1152 | if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date) |
1154 | 1153 | { |
1155 | 1154 | $message->recurrence = $recurrence = new SyncRecurrence(); |
1156 | - $rrule = calendar_rrule::event2rrule($event,false); // false = timestamps in $event are servertime |
|
1155 | + $rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime |
|
1157 | 1156 | $recurrence->type = (int)self::$recur_type2as[$rrule->type]; |
1158 | 1157 | $recurrence->interval = $rrule->interval; |
1159 | 1158 | switch ($rrule->type) |
1160 | 1159 | { |
1161 | 1160 | case calendar_rrule::MONTHLY_WDAY: |
1162 | 1161 | $recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ? |
1163 | - $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
1162 | + $rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1 |
|
1164 | 1163 | // fall throught |
1165 | 1164 | case calendar_rrule::WEEKLY: |
1166 | - $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
1165 | + $recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa |
|
1167 | 1166 | break; |
1168 | 1167 | case calendar_rrule::MONTHLY_MDAY: |
1169 | - $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
1170 | - $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
1168 | + $recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31 |
|
1169 | + $rrule->monthly_bymonthday : 31; // not -1 for last day of month! |
|
1171 | 1170 | break; |
1172 | 1171 | case calendar_rrule::YEARLY: |
1173 | - $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
1174 | - $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
1172 | + $recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31 |
|
1173 | + $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
|
1175 | 1174 | break; |
1176 | 1175 | } |
1177 | 1176 | if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
@@ -1187,9 +1186,9 @@ discard block |
||
1187 | 1186 | // search real / non-virtual exceptions |
1188 | 1187 | if (!empty($event['uid'])) |
1189 | 1188 | { |
1190 | - $ex_events =& $this->calendar->search(array( |
|
1189 | + $ex_events = & $this->calendar->search(array( |
|
1191 | 1190 | 'query' => array('cal_uid' => $event['uid']), |
1192 | - 'filter' => 'owner', // return all possible entries |
|
1191 | + 'filter' => 'owner', // return all possible entries |
|
1193 | 1192 | 'daywise' => false, |
1194 | 1193 | 'date_format' => 'server', |
1195 | 1194 | )); |
@@ -1198,36 +1197,36 @@ discard block |
||
1198 | 1197 | { |
1199 | 1198 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
1200 | 1199 | } |
1201 | - if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1200 | + if (count($ex_events) >= 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
1202 | 1201 | |
1203 | 1202 | $message->exceptions = array(); |
1204 | - foreach($ex_events as $ex_event) |
|
1203 | + foreach ($ex_events as $ex_event) |
|
1205 | 1204 | { |
1206 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1205 | + if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
1207 | 1206 | $exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException'); |
1208 | 1207 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
1209 | - foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
|
1208 | + foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported) |
|
1210 | 1209 | { |
1211 | - $exception->$not_supported = null; // not allowed in exceptions :-( |
|
1210 | + $exception->$not_supported = null; // not allowed in exceptions :-( |
|
1212 | 1211 | } |
1213 | 1212 | $exception->deleted = 0; |
1214 | - if (($key = array_search($exception_time,$event['recur_exception'])) !== false) |
|
1213 | + if (($key = array_search($exception_time, $event['recur_exception'])) !== false) |
|
1215 | 1214 | { |
1216 | 1215 | unset($event['recur_exception'][$key]); |
1217 | 1216 | } |
1218 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
1217 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1219 | 1218 | $message->exceptions[] = $exception; |
1220 | 1219 | } |
1221 | 1220 | // add rest of exceptions as deleted |
1222 | - foreach($event['recur_exception'] as $exception_time) |
|
1221 | + foreach ($event['recur_exception'] as $exception_time) |
|
1223 | 1222 | { |
1224 | 1223 | if (!empty($exception_time)) |
1225 | 1224 | { |
1226 | 1225 | if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
1227 | - $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
1226 | + $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
|
1228 | 1227 | $exception->deleted = 1; |
1229 | 1228 | $exception->exceptionstarttime = $exception_time; |
1230 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception)); |
|
1229 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception)); |
|
1231 | 1230 | $message->exceptions[] = $exception; |
1232 | 1231 | } |
1233 | 1232 | } |
@@ -1249,12 +1248,12 @@ discard block |
||
1249 | 1248 | // only return alarms if in own calendar |
1250 | 1249 | if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm']) |
1251 | 1250 | { |
1252 | - foreach($event['alarm'] as $alarm) |
|
1251 | + foreach ($event['alarm'] as $alarm) |
|
1253 | 1252 | { |
1254 | 1253 | if ($alarm['all'] || $alarm['owner'] == $account) |
1255 | 1254 | { |
1256 | - $message->reminder = $alarm['offset']/60; // is in minutes, not seconds as in EGw |
|
1257 | - break; // AS supports only one alarm! (we use the next/earliest one) |
|
1255 | + $message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw |
|
1256 | + break; // AS supports only one alarm! (we use the next/earliest one) |
|
1258 | 1257 | } |
1259 | 1258 | } |
1260 | 1259 | } |
@@ -1277,7 +1276,7 @@ discard block |
||
1277 | 1276 | */ |
1278 | 1277 | public function StatMessage($folderid, $id) |
1279 | 1278 | { |
1280 | - unset($folderid); // not used ($id is unique), but required by function signature |
|
1279 | + unset($folderid); // not used ($id is unique), but required by function signature |
|
1281 | 1280 | |
1282 | 1281 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
1283 | 1282 | |
@@ -1288,7 +1287,7 @@ discard block |
||
1288 | 1287 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
1289 | 1288 | $backup = $this->calendar->debug; |
1290 | 1289 | //$this->calendar->debug = 2; |
1291 | - list($id) = explode(':',$id); |
|
1290 | + list($id) = explode(':', $id); |
|
1292 | 1291 | $this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server'); |
1293 | 1292 | $this->calendar->debug = $backup; |
1294 | 1293 | } |
@@ -1322,7 +1321,7 @@ discard block |
||
1322 | 1321 | |
1323 | 1322 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
1324 | 1323 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
1325 | - $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
|
1324 | + $syncstate = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too |
|
1326 | 1325 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
1327 | 1326 | if ($syncstate == 0) $syncstate = 1; |
1328 | 1327 | |
@@ -1402,8 +1401,8 @@ discard block |
||
1402 | 1401 | |
1403 | 1402 | if ($tz === 'UTC') return $data; |
1404 | 1403 | |
1405 | - $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
|
1406 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
1404 | + $name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz; |
|
1405 | + if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component'); |
|
1407 | 1406 | // parse ical timezone defintion |
1408 | 1407 | $ical = self::ical2array($component); |
1409 | 1408 | $standard = $ical['VTIMEZONE']['STANDARD']; |
@@ -1412,11 +1411,11 @@ discard block |
||
1412 | 1411 | if (!isset($standard)) |
1413 | 1412 | { |
1414 | 1413 | $matches = null; |
1415 | - if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches)) |
|
1414 | + if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches)) |
|
1416 | 1415 | { |
1417 | 1416 | $standard = array( |
1418 | - 'TZOFFSETTO' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
1419 | - 'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]), |
|
1417 | + 'TZOFFSETTO' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
1418 | + 'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]), |
|
1420 | 1419 | ); |
1421 | 1420 | unset($daylight); |
1422 | 1421 | } |
@@ -1427,15 +1426,15 @@ discard block |
||
1427 | 1426 | } |
1428 | 1427 | // get bias and dstbias from standard component, which is present in all tz's |
1429 | 1428 | // (dstbias is relative to bias and almost always 60 or 0) |
1430 | - $data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2)); |
|
1431 | - $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']); |
|
1429 | + $data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2)); |
|
1430 | + $data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']); |
|
1432 | 1431 | |
1433 | 1432 | // check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving |
1434 | 1433 | if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE'])) |
1435 | 1434 | { |
1436 | - foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp) |
|
1435 | + foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp) |
|
1437 | 1436 | { |
1438 | - if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches)) |
|
1437 | + if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches)) |
|
1439 | 1438 | { |
1440 | 1439 | $data[$prefix.'month'] = (int)$matches[2]; |
1441 | 1440 | $data[$prefix.'week'] = (int)$matches[1]; |
@@ -1452,20 +1451,20 @@ discard block |
||
1452 | 1451 | $data[$prefix.'week'] = 5; |
1453 | 1452 | if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
1454 | 1453 | } |
1455 | - static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
|
1456 | - $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
|
1454 | + static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6); |
|
1455 | + $data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)]; |
|
1457 | 1456 | } |
1458 | - if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches)) |
|
1457 | + if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches)) |
|
1459 | 1458 | { |
1460 | - $data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60; |
|
1461 | - $data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60; |
|
1462 | - $data[$prefix.'second'] = (int)substr($matches[1],4,2); |
|
1459 | + $data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60; |
|
1460 | + $data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60; |
|
1461 | + $data[$prefix.'second'] = (int)substr($matches[1], 4, 2); |
|
1463 | 1462 | } |
1464 | 1463 | } |
1465 | 1464 | // for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute |
1466 | 1465 | if ($data['dststartmonth'] > $data['dstendmonth']) |
1467 | 1466 | { |
1468 | - $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
1467 | + $start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start; |
|
1469 | 1468 | $end = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $end; |
1470 | 1469 | } |
1471 | 1470 | } |
@@ -1523,20 +1522,20 @@ discard block |
||
1523 | 1522 | * @param string|array $ical lines of ical file |
1524 | 1523 | * @return array with parsed ical components |
1525 | 1524 | */ |
1526 | - static public function ical2array(&$ical,$section=null) |
|
1525 | + static public function ical2array(&$ical, $section = null) |
|
1527 | 1526 | { |
1528 | 1527 | $arr = array(); |
1529 | 1528 | if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
1530 | 1529 | while (($line = array_shift($ical))) |
1531 | 1530 | { |
1532 | - list($name,$value) = explode(':',$line,2); |
|
1531 | + list($name, $value) = explode(':', $line, 2); |
|
1533 | 1532 | if ($name == 'BEGIN') |
1534 | 1533 | { |
1535 | - $arr[$value] = self::ical2array($ical,$value); |
|
1534 | + $arr[$value] = self::ical2array($ical, $value); |
|
1536 | 1535 | } |
1537 | - elseif($name == 'END') |
|
1536 | + elseif ($name == 'END') |
|
1538 | 1537 | { |
1539 | - if ($section && $section==$value) return $arr; |
|
1538 | + if ($section && $section == $value) return $arr; |
|
1540 | 1539 | break; |
1541 | 1540 | } |
1542 | 1541 | else |
@@ -1559,13 +1558,13 @@ discard block |
||
1559 | 1558 | */ |
1560 | 1559 | public static function as2tz(array $data) |
1561 | 1560 | { |
1562 | - static $cache=null; // some caching withing the request |
|
1561 | + static $cache = null; // some caching withing the request |
|
1563 | 1562 | |
1564 | - unset($data['name']); // not used, but can stall the match |
|
1563 | + unset($data['name']); // not used, but can stall the match |
|
1565 | 1564 | |
1566 | 1565 | $key = serialize($data); |
1567 | 1566 | |
1568 | - for($n = 0; !isset($cache[$key]); ++$n) |
|
1567 | + for ($n = 0; !isset($cache[$key]); ++$n) |
|
1569 | 1568 | { |
1570 | 1569 | if (!$n) // check users timezone first |
1571 | 1570 | { |
@@ -1584,7 +1583,7 @@ discard block |
||
1584 | 1583 | break; |
1585 | 1584 | } |
1586 | 1585 | } |
1587 | - catch(Exception $e) { |
|
1586 | + catch (Exception $e) { |
|
1588 | 1587 | unset($e); |
1589 | 1588 | // simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component |
1590 | 1589 | } |
@@ -1599,8 +1598,8 @@ discard block |
||
1599 | 1598 | */ |
1600 | 1599 | static public function _getTZFromSyncBlob($data) |
1601 | 1600 | { |
1602 | - $tz = unpack( "lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" . |
|
1603 | - "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" . |
|
1601 | + $tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/". |
|
1602 | + "lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/". |
|
1604 | 1603 | "ldstbias", $data); |
1605 | 1604 | |
1606 | 1605 | return $tz; |
@@ -1613,7 +1612,7 @@ discard block |
||
1613 | 1612 | */ |
1614 | 1613 | static public function _getSyncBlobFromTZ($tz) |
1615 | 1614 | { |
1616 | - $packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l", |
|
1615 | + $packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l", |
|
1617 | 1616 | $tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"], |
1618 | 1617 | $tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"], |
1619 | 1618 | $tz["dstbias"]); |
@@ -1637,7 +1636,7 @@ discard block |
||
1637 | 1636 | $account_id = $entry['grantor']; |
1638 | 1637 | $cals[$account_id] = $entry['name']; |
1639 | 1638 | } |
1640 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1639 | + if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
1641 | 1640 | } |
1642 | 1641 | $cals['G'] = lang('Primary group'); |
1643 | 1642 | $cals['A'] = lang('All'); |
@@ -1673,7 +1672,7 @@ discard block |
||
1673 | 1672 | ) |
1674 | 1673 | ); |
1675 | 1674 | require_once('../../header.inc.php'); |
1676 | - ini_set('display_errors',1); |
|
1675 | + ini_set('display_errors', 1); |
|
1677 | 1676 | error_reporting(E_ALL & ~E_NOTICE); |
1678 | 1677 | |
1679 | 1678 | echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n"; |
@@ -1688,7 +1687,7 @@ discard block |
||
1688 | 1687 | </script>\n"; |
1689 | 1688 | |
1690 | 1689 | // TZID => AS timezone blobs reported by various devices |
1691 | - foreach(array( |
|
1690 | + foreach (array( |
|
1692 | 1691 | 'Europe/Berlin' => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==', |
1693 | 1692 | 'Europe/Helsinki' => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==', |
1694 | 1693 | 'Asia/Tokyo' => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==', |
@@ -1702,7 +1701,7 @@ discard block |
||
1702 | 1701 | ) as $tz => $sync_blob) |
1703 | 1702 | { |
1704 | 1703 | // get as timezone data for a given timezone |
1705 | - $ical = calendar_timezones::tz2id($tz,'component'); |
|
1704 | + $ical = calendar_timezones::tz2id($tz, 'component'); |
|
1706 | 1705 | //echo "<pre>".print_r($ical,true)."</pre>\n"; |
1707 | 1706 | $ical_tz = $ical; |
1708 | 1707 | $ical_arr = calendar_zpush::ical2array($ical_tz); |
@@ -1719,22 +1718,22 @@ discard block |
||
1719 | 1718 | //echo array2string($matched); |
1720 | 1719 | |
1721 | 1720 | echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n"; |
1722 | - foreach(array('dststart','dstend') as $prefix) |
|
1721 | + foreach (array('dststart', 'dstend') as $prefix) |
|
1723 | 1722 | { |
1724 | 1723 | echo "<td>\n"; |
1725 | - foreach(array($as_tz_org,$as_tz) as $n => $arr) |
|
1724 | + foreach (array($as_tz_org, $as_tz) as $n => $arr) |
|
1726 | 1725 | { |
1727 | 1726 | $parts = array(); |
1728 | - foreach(array('year','month','day','week','hour','minute','second') as $postfix) |
|
1727 | + foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix) |
|
1729 | 1728 | { |
1730 | 1729 | $failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix]; |
1731 | - $parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':''); |
|
1730 | + $parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : ''); |
|
1732 | 1731 | } |
1733 | - echo implode(' ', $parts).(!$n?'<br/>':''); |
|
1732 | + echo implode(' ', $parts).(!$n ? '<br/>' : ''); |
|
1734 | 1733 | } |
1735 | 1734 | echo "</td>\n"; |
1736 | 1735 | } |
1737 | - echo "<td> <br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n"; |
|
1736 | + echo "<td> <br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n"; |
|
1738 | 1737 | } |
1739 | 1738 | echo "</tbody></table>\n"; |
1740 | 1739 | echo "</body></html>\n"; |
@@ -387,11 +387,11 @@ |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
390 | - * gets the icons displayed for a given event |
|
391 | - * |
|
392 | - * @param array $event |
|
393 | - * @return array of 'img' / 'title' pairs |
|
394 | - */ |
|
390 | + * gets the icons displayed for a given event |
|
391 | + * |
|
392 | + * @param array $event |
|
393 | + * @return array of 'img' / 'title' pairs |
|
394 | + */ |
|
395 | 395 | function event_icons($event) |
396 | 396 | { |
397 | 397 | $is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event); |
@@ -517,7 +517,7 @@ |
||
517 | 517 | |
518 | 518 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
519 | 519 | { |
520 | - $file = Array( |
|
520 | + $file = array( |
|
521 | 521 | 'Site configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'), |
522 | 522 | 'Custom Fields'=>Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'), |
523 | 523 | 'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar&ajax=true'), |
@@ -166,7 +166,10 @@ discard block |
||
166 | 166 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
167 | 167 | |
168 | 168 | // make sure the hook for export_limit is registered |
169 | - if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true); |
|
169 | + if (!Api\Hooks::exists('export_limit','calendar')) |
|
170 | + { |
|
171 | + Api\Hooks::read(true); |
|
172 | + } |
|
170 | 173 | } |
171 | 174 | |
172 | 175 | /** |
@@ -279,11 +282,15 @@ discard block |
||
279 | 282 | { |
280 | 283 | // only change the owners of the same resource-type as given in set_state[owner] |
281 | 284 | $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']); |
282 | - if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) |
|
285 | + if ((string)$set_owners[0] === '0') |
|
286 | + { |
|
287 | + // set exactly the specified owners (without the 0) |
|
283 | 288 | { |
284 | 289 | if ($set_states['owner'] === '0,r0') // small fix for resources |
285 | 290 | { |
286 | - $set_states['owner'] = $default; // --> set default, instead of none |
|
291 | + $set_states['owner'] = $default; |
|
292 | + } |
|
293 | + // --> set default, instead of none |
|
287 | 294 | } |
288 | 295 | else |
289 | 296 | { |
@@ -369,7 +376,10 @@ discard block |
||
369 | 376 | } |
370 | 377 | $this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index'; |
371 | 378 | |
372 | - if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
379 | + if ($this->debug > 0 || $this->debug == 'manage_states') |
|
380 | + { |
|
381 | + $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
382 | + } |
|
373 | 383 | // save the states in the session only when we are in calendar |
374 | 384 | if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar') |
375 | 385 | { |
@@ -505,8 +515,11 @@ discard block |
||
505 | 515 | |
506 | 516 | // resources menu hooks |
507 | 517 | foreach ($this->bo->resources as $resource) |
508 | - { |
|
509 | - if(!is_array($resource['cal_sidebox'])) continue; |
|
518 | + { |
|
519 | + if(!is_array($resource['cal_sidebox'])) |
|
520 | + { |
|
521 | + continue; |
|
522 | + } |
|
510 | 523 | $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']); |
511 | 524 | $file = ExecMethod($resource['cal_sidebox']['file'],array( |
512 | 525 | 'menuaction' => $this->view_menuaction, |
@@ -560,7 +573,10 @@ discard block |
||
560 | 573 | $sidebox = new Etemplate('calendar.sidebox'); |
561 | 574 | |
562 | 575 | $cont = $this->cal_prefs['saved_states']; |
563 | - if (!is_array($cont)) $cont = array(); |
|
576 | + if (!is_array($cont)) |
|
577 | + { |
|
578 | + $cont = array(); |
|
579 | + } |
|
564 | 580 | $cont['view'] = $this->view ? $this->view : 'week'; |
565 | 581 | $cont['date'] = $this->date ? $this->date : new Api\DateTime(); |
566 | 582 | $cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner']; |
@@ -593,8 +609,7 @@ discard block |
||
593 | 609 | if (class_exists('EGroupware\\collabora\\Bo') && |
594 | 610 | $GLOBALS['egw_info']['user']['apps']['collabora'] && |
595 | 611 | $discovery = \EGroupware\collabora\Bo::discover() |
596 | - ) |
|
597 | - { |
|
612 | + ) { |
|
598 | 613 | $cont['collabora_enabled'] = true; |
599 | 614 | } |
600 | 615 | } |
@@ -635,7 +650,10 @@ discard block |
||
635 | 650 | */ |
636 | 651 | public function update_client($event_id, Api\DateTime $recurrence_date = null) |
637 | 652 | { |
638 | - if(!$event_id) return false; |
|
653 | + if(!$event_id) |
|
654 | + { |
|
655 | + return false; |
|
656 | + } |
|
639 | 657 | if(is_string($event_id) && strpos($event_id,':') !== FALSE) |
640 | 658 | { |
641 | 659 | list($event_id, $date) = explode(':',$event_id); |
@@ -706,7 +724,10 @@ discard block |
||
706 | 724 | */ |
707 | 725 | public function to_client(&$event) |
708 | 726 | { |
709 | - if(!$event || !is_array($event)) return false; |
|
727 | + if(!$event || !is_array($event)) |
|
728 | + { |
|
729 | + return false; |
|
730 | + } |
|
710 | 731 | |
711 | 732 | if (!$this->bo->check_perms(Acl::EDIT,$event)) |
712 | 733 | { |
@@ -727,8 +748,16 @@ discard block |
||
727 | 748 | |
728 | 749 | $event['recure'] = $this->bo->recure2string($event); |
729 | 750 | |
730 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
731 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
751 | + if (empty($event['description'])) |
|
752 | + { |
|
753 | + $event['description'] = ' '; |
|
754 | + } |
|
755 | + // no description screws the titles horz. alignment |
|
756 | + if (empty($event['location'])) |
|
757 | + { |
|
758 | + $event['location'] = ' '; |
|
759 | + } |
|
760 | + // no location screws the owner horz. alignment |
|
732 | 761 | |
733 | 762 | // respect category permissions |
734 | 763 | if(!empty($event['category'])) |
@@ -817,8 +846,14 @@ discard block |
||
817 | 846 | if(!$timespan) |
818 | 847 | { |
819 | 848 | // Try to make time span into appropriate ranges to match |
820 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
821 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
849 | + if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) |
|
850 | + { |
|
851 | + $template = 'month'; |
|
852 | + } |
|
853 | + if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) |
|
854 | + { |
|
855 | + $template = 'week'; |
|
856 | + } |
|
822 | 857 | //error_log("Detected template $template"); |
823 | 858 | switch ($template) |
824 | 859 | { |
@@ -899,8 +934,7 @@ discard block |
||
899 | 934 | if (class_exists('EGroupware\\collabora\\Bo') && |
900 | 935 | $GLOBALS['egw_info']['user']['apps']['collabora'] && |
901 | 936 | $discovery = \EGroupware\collabora\Bo::discover() |
902 | - ) |
|
903 | - { |
|
937 | + ) { |
|
904 | 938 | $editable_mimes = $discovery; |
905 | 939 | } |
906 | 940 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @var $debug mixed integer level or string function-name |
35 | 35 | */ |
36 | - var $debug=false; |
|
36 | + var $debug = false; |
|
37 | 37 | /** |
38 | 38 | * instance of the bocal or bocalupdate class |
39 | 39 | * |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * @var array $states_to_save all states that will be saved to the user prefs |
129 | 129 | */ |
130 | - var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend'); |
|
130 | + var $states_to_save = array('owner', 'status_filter', 'filter', 'cat_id', 'view', 'sortby', 'planner_view', 'weekend'); |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Constructor |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param boolean $use_boupdate use bocalupdate as parenent instead of bocal |
136 | 136 | * @param array $set_states to manualy set / change one of the states, default NULL = use $_REQUEST |
137 | 137 | */ |
138 | - function __construct($use_boupdate=false,$set_states=NULL) |
|
138 | + function __construct($use_boupdate = false, $set_states = NULL) |
|
139 | 139 | { |
140 | 140 | if ($use_boupdate) |
141 | 141 | { |
@@ -146,27 +146,27 @@ discard block |
||
146 | 146 | $this->bo = new calendar_bo(); |
147 | 147 | } |
148 | 148 | |
149 | - $this->categories = new Api\Categories($this->user,'calendar'); |
|
149 | + $this->categories = new Api\Categories($this->user, 'calendar'); |
|
150 | 150 | |
151 | - $this->common_prefs = &$GLOBALS['egw_info']['user']['preferences']['common']; |
|
151 | + $this->common_prefs = &$GLOBALS['egw_info']['user']['preferences']['common']; |
|
152 | 152 | $this->cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar']; |
153 | 153 | $this->bo->check_set_default_prefs(); |
154 | 154 | |
155 | - $this->wd_start = 60*$this->cal_prefs['workdaystarts']; |
|
156 | - $this->wd_end = 60*$this->cal_prefs['workdayends']; |
|
157 | - $this->interval_m = $this->cal_prefs['interval']; |
|
155 | + $this->wd_start = 60 * $this->cal_prefs['workdaystarts']; |
|
156 | + $this->wd_end = 60 * $this->cal_prefs['workdayends']; |
|
157 | + $this->interval_m = $this->cal_prefs['interval']; |
|
158 | 158 | |
159 | 159 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
160 | 160 | |
161 | 161 | $this->manage_states($set_states); |
162 | 162 | |
163 | - $GLOBALS['uical'] = &$this; // make us available for ExecMethod, else it creates a new instance |
|
163 | + $GLOBALS['uical'] = &$this; // make us available for ExecMethod, else it creates a new instance |
|
164 | 164 | |
165 | 165 | // calendar does not work with hidden sidebox atm. |
166 | 166 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
167 | 167 | |
168 | 168 | // make sure the hook for export_limit is registered |
169 | - if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true); |
|
169 | + if (!Api\Hooks::exists('export_limit', 'calendar')) Api\Hooks::read(true); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -179,21 +179,21 @@ discard block |
||
179 | 179 | function check_owners_access($users = null, &$no_access = array()) |
180 | 180 | { |
181 | 181 | $no_access = $no_access_group = array(); |
182 | - $owner_array = $users ? $users : explode(',',$this->owner); |
|
183 | - foreach($owner_array as $idx => $owner) |
|
182 | + $owner_array = $users ? $users : explode(',', $this->owner); |
|
183 | + foreach ($owner_array as $idx => $owner) |
|
184 | 184 | { |
185 | 185 | $owner = trim($owner); |
186 | 186 | if (is_numeric($owner) && $GLOBALS['egw']->accounts->get_type($owner) == 'g') |
187 | 187 | { |
188 | - foreach($GLOBALS['egw']->accounts->members($owner, true) as $member) |
|
188 | + foreach ($GLOBALS['egw']->accounts->members($owner, true) as $member) |
|
189 | 189 | { |
190 | - if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$member)) |
|
190 | + if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $member)) |
|
191 | 191 | { |
192 | 192 | $no_access_group[$member] = $this->bo->participant_name($member); |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | - elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$owner)) |
|
196 | + elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $owner)) |
|
197 | 197 | { |
198 | 198 | $no_access[$owner] = $this->bo->participant_name($owner); |
199 | 199 | unset($owner_array[$idx]); |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | } |
202 | 202 | if (count($no_access)) |
203 | 203 | { |
204 | - $message = lang('Access denied to the calendar of %1 !!!',implode(', ',$no_access)); |
|
205 | - Framework::message($message,'error'); |
|
206 | - $this->owner = implode(',',$owner_array); |
|
204 | + $message = lang('Access denied to the calendar of %1 !!!', implode(', ', $no_access)); |
|
205 | + Framework::message($message, 'error'); |
|
206 | + $this->owner = implode(',', $owner_array); |
|
207 | 207 | return $message; |
208 | 208 | } |
209 | 209 | if (count($no_access_group)) |
210 | 210 | { |
211 | - $this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group)); |
|
211 | + $this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.', implode(', ', $no_access_group)); |
|
212 | 212 | } |
213 | 213 | return false; |
214 | 214 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * - view: the actual view, where dialogs should return to or which they refresh |
228 | 228 | * @param array $set_states array to manualy set / change one of the states, default NULL = use $_REQUEST |
229 | 229 | */ |
230 | - function manage_states($set_states=NULL) |
|
230 | + function manage_states($set_states = NULL) |
|
231 | 231 | { |
232 | 232 | // retrieve saved states from prefs |
233 | 233 | $states = is_array($this->bo->cal_prefs['saved_states']) ? |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - parse_str(substr($json_data['request']['parameters'][0], 10), $set_states); // cut off "/index.php?" |
|
250 | + parse_str(substr($json_data['request']['parameters'][0], 10), $set_states); // cut off "/index.php?" |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | else |
254 | 254 | { |
255 | - $set_states = substr($_GET['menuaction'],0,9) == 'calendar.' ? $_REQUEST : array(); |
|
255 | + $set_states = substr($_GET['menuaction'], 0, 9) == 'calendar.' ? $_REQUEST : array(); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | if (!$states['date'] && $states['year'] && $states['month'] && $states['day']) |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | $states['date'] = $this->bo->date2string($states); |
261 | 261 | } |
262 | 262 | |
263 | - foreach(array( |
|
263 | + foreach (array( |
|
264 | 264 | 'date' => $this->bo->date2string($this->bo->now_su), |
265 | 265 | 'cat_id' => 0, |
266 | 266 | 'status_filter' => 'default', |
267 | 267 | 'owner' => $this->user, |
268 | 268 | 'save_owner' => 0, |
269 | 269 | 'sortby' => 'category', |
270 | - 'planner_view'=> 'month', // full month |
|
271 | - 'view' => ($this->bo->cal_prefs['defaultcalendar']?$this->bo->cal_prefs['defaultcalendar']:'day'), // use pref, if exists else use the dayview |
|
272 | - 'listview_days'=> '', // no range |
|
270 | + 'planner_view'=> 'month', // full month |
|
271 | + 'view' => ($this->bo->cal_prefs['defaultcalendar'] ? $this->bo->cal_prefs['defaultcalendar'] : 'day'), // use pref, if exists else use the dayview |
|
272 | + 'listview_days'=> '', // no range |
|
273 | 273 | 'test' => 'false', |
274 | 274 | ) as $state => $default) |
275 | 275 | { |
@@ -278,42 +278,42 @@ discard block |
||
278 | 278 | if ($state == 'owner') |
279 | 279 | { |
280 | 280 | // only change the owners of the same resource-type as given in set_state[owner] |
281 | - $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']); |
|
281 | + $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',', $set_states['owner']); |
|
282 | 282 | if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) |
283 | 283 | { |
284 | 284 | if ($set_states['owner'] === '0,r0') // small fix for resources |
285 | 285 | { |
286 | - $set_states['owner'] = $default; // --> set default, instead of none |
|
286 | + $set_states['owner'] = $default; // --> set default, instead of none |
|
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
290 | - $set_states['owner'] = substr($set_states['owner'],2); |
|
290 | + $set_states['owner'] = substr($set_states['owner'], 2); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | else // change only the owners of the given type |
294 | 294 | { |
295 | 295 | $res_type = is_numeric($set_owners[0]) ? false : $set_owners[0][0]; |
296 | 296 | $owners = $states['owner'] ? $states['owner'] : $default; |
297 | - if(!is_array($owners)) |
|
297 | + if (!is_array($owners)) |
|
298 | 298 | { |
299 | - $owners = explode(',',$owners); |
|
299 | + $owners = explode(',', $owners); |
|
300 | 300 | } |
301 | - foreach($owners as $key => $owner) |
|
301 | + foreach ($owners as $key => $owner) |
|
302 | 302 | { |
303 | 303 | if (!$res_type && is_numeric($owner) || $res_type && $owner[0] == $res_type) |
304 | 304 | { |
305 | 305 | unset($owners[$key]); |
306 | 306 | } |
307 | 307 | } |
308 | - if (!$res_type || !in_array($res_type.'0',$set_owners)) |
|
308 | + if (!$res_type || !in_array($res_type.'0', $set_owners)) |
|
309 | 309 | { |
310 | - $owners = array_merge($owners,$set_owners); |
|
310 | + $owners = array_merge($owners, $set_owners); |
|
311 | 311 | } |
312 | - $set_states['owner'] = implode(',',$owners); |
|
312 | + $set_states['owner'] = implode(',', $owners); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | // for the uiforms class (eg. edit), dont store the (new) owner, as it might change the view |
316 | - if (substr($_GET['menuaction'],0,25) == 'calendar.calendar_uiforms') |
|
316 | + if (substr($_GET['menuaction'], 0, 25) == 'calendar.calendar_uiforms') |
|
317 | 317 | { |
318 | 318 | $this->owner = $set_states[$state]; |
319 | 319 | continue; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | if ($state == 'date') |
328 | 328 | { |
329 | 329 | $date_arr = $this->bo->date2array($states['date']); |
330 | - foreach(array('year','month','day') as $name) |
|
330 | + foreach (array('year', 'month', 'day') as $name) |
|
331 | 331 | { |
332 | 332 | $this->$name = $states[$name] = $date_arr[$name]; |
333 | 333 | } |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | $this->$state = $states[$state]; |
336 | 336 | } |
337 | 337 | // remove a given calendar from the view |
338 | - if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners=explode(',',$this->owner))) !== false) |
|
338 | + if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners = explode(',', $this->owner))) !== false) |
|
339 | 339 | { |
340 | 340 | unset($owners[$k]); |
341 | - $this->owner = $states['owner'] = implode(',',$owners); |
|
341 | + $this->owner = $states['owner'] = implode(',', $owners); |
|
342 | 342 | } |
343 | - if(is_array($this->owner)) |
|
343 | + if (is_array($this->owner)) |
|
344 | 344 | { |
345 | - $this->owner = implode(',',$this->owner); |
|
345 | + $this->owner = implode(',', $this->owner); |
|
346 | 346 | } |
347 | - if (substr($this->view,0,8) == 'planner_') |
|
347 | + if (substr($this->view, 0, 8) == 'planner_') |
|
348 | 348 | { |
349 | 349 | $states['sortby'] = $this->sortby = $this->view == 'planner_cat' ? 'category' : 'user'; |
350 | 350 | $states['view'] = $this->view = 'planner'; |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | // set the actual view as return_to |
353 | 353 | if (isset($_GET['menuaction'])) |
354 | 354 | { |
355 | - list(,$class,$func) = explode('.',$_GET['menuaction']); |
|
355 | + list(,$class, $func) = explode('.', $_GET['menuaction']); |
|
356 | 356 | if ($func == 'index') |
357 | 357 | { |
358 | - $func = $this->view; $this->view = 'index'; // switch to the default view |
|
358 | + $func = $this->view; $this->view = 'index'; // switch to the default view |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | else // eg. calendar/index.php |
@@ -369,18 +369,18 @@ discard block |
||
369 | 369 | } |
370 | 370 | $this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index'; |
371 | 371 | |
372 | - if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
372 | + if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3', True, $set_states, $states); |
|
373 | 373 | // save the states in the session only when we are in calendar |
374 | - if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar') |
|
374 | + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'calendar') |
|
375 | 375 | { |
376 | 376 | // save defined states into the user-prefs |
377 | - if(!empty($states) && is_array($states)) |
|
377 | + if (!empty($states) && is_array($states)) |
|
378 | 378 | { |
379 | - $saved_states = array_intersect_key($states,array_flip($this->states_to_save)); |
|
379 | + $saved_states = array_intersect_key($states, array_flip($this->states_to_save)); |
|
380 | 380 | if ($saved_states != $this->cal_prefs['saved_states']) |
381 | 381 | { |
382 | - $GLOBALS['egw']->preferences->add('calendar','saved_states',$saved_states); |
|
383 | - $GLOBALS['egw']->preferences->save_repository(false,'user',true); |
|
382 | + $GLOBALS['egw']->preferences->add('calendar', 'saved_states', $saved_states); |
|
383 | + $GLOBALS['egw']->preferences->save_repository(false, 'user', true); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -394,35 +394,35 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function event_icons($event) |
396 | 396 | { |
397 | - $is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event); |
|
397 | + $is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ, $event); |
|
398 | 398 | |
399 | 399 | $icons = array(); |
400 | 400 | if (!$is_private) |
401 | 401 | { |
402 | - if($event['priority'] == 3) |
|
402 | + if ($event['priority'] == 3) |
|
403 | 403 | { |
404 | - $icons[] = Api\Html::image('calendar','high',lang('high priority')); |
|
404 | + $icons[] = Api\Html::image('calendar', 'high', lang('high priority')); |
|
405 | 405 | } |
406 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
406 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
407 | 407 | { |
408 | - $icons[] = Api\Html::image('calendar','recur',lang('recurring event')); |
|
408 | + $icons[] = Api\Html::image('calendar', 'recur', lang('recurring event')); |
|
409 | 409 | } |
410 | 410 | // icons for single user, multiple users or group(s) and resources |
411 | - foreach(array_keys($event['participants']) as $uid) |
|
411 | + foreach (array_keys($event['participants']) as $uid) |
|
412 | 412 | { |
413 | - if(is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon'])) |
|
413 | + if (is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon'])) |
|
414 | 414 | { |
415 | 415 | if (isset($icons['single']) || $GLOBALS['egw']->accounts->get_type($uid) == 'g') |
416 | 416 | { |
417 | 417 | unset($icons['single']); |
418 | - $icons['multiple'] = Api\Html::image('calendar','users'); |
|
418 | + $icons['multiple'] = Api\Html::image('calendar', 'users'); |
|
419 | 419 | } |
420 | 420 | elseif (!isset($icons['multiple'])) |
421 | 421 | { |
422 | - $icons['single'] = Api\Html::image('calendar','single'); |
|
422 | + $icons['single'] = Api\Html::image('calendar', 'single'); |
|
423 | 423 | } |
424 | 424 | } |
425 | - elseif(!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon'])) |
|
425 | + elseif (!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon'])) |
|
426 | 426 | { |
427 | 427 | $icons[$uid[0]] = Api\Html::image($this->bo->resources[$uid[0]]['app'], |
428 | 428 | ($this->bo->resources[$uid[0]]['icon'] ? $this->bo->resources[$uid[0]]['icon'] : 'navbar'), |
@@ -431,21 +431,21 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
434 | - if($event['non_blocking']) |
|
434 | + if ($event['non_blocking']) |
|
435 | 435 | { |
436 | - $icons[] = Api\Html::image('calendar','nonblocking',lang('non blocking')); |
|
436 | + $icons[] = Api\Html::image('calendar', 'nonblocking', lang('non blocking')); |
|
437 | 437 | } |
438 | - if($event['public'] == 0) |
|
438 | + if ($event['public'] == 0) |
|
439 | 439 | { |
440 | - $icons[] = Api\Html::image('calendar','private',lang('private')); |
|
440 | + $icons[] = Api\Html::image('calendar', 'private', lang('private')); |
|
441 | 441 | } |
442 | - if(isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
|
442 | + if (isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private) |
|
443 | 443 | { |
444 | - $icons[] = Api\Html::image('calendar','alarm',lang('alarm')); |
|
444 | + $icons[] = Api\Html::image('calendar', 'alarm', lang('alarm')); |
|
445 | 445 | } |
446 | - if($event['participants'][$this->user][0] == 'U') |
|
446 | + if ($event['participants'][$this->user][0] == 'U') |
|
447 | 447 | { |
448 | - $icons[] = Api\Html::image('calendar','needs-action',lang('Needs action')); |
|
448 | + $icons[] = Api\Html::image('calendar', 'needs-action', lang('Needs action')); |
|
449 | 449 | } |
450 | 450 | return $icons; |
451 | 451 | } |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * @param array $vars |
461 | 461 | * @return string the link incl. content |
462 | 462 | */ |
463 | - function add_link($content,$date=null,$hour=null,$minute=0,array $vars=null) |
|
463 | + function add_link($content, $date = null, $hour = null, $minute = 0, array $vars = null) |
|
464 | 464 | { |
465 | 465 | $vars['menuaction'] = 'calendar.calendar_uiforms.edit'; |
466 | - $vars['date'] = $date ? $date : $this->date; |
|
466 | + $vars['date'] = $date ? $date : $this->date; |
|
467 | 467 | |
468 | 468 | if (!is_null($hour)) |
469 | 469 | { |
470 | 470 | $vars['hour'] = $hour; |
471 | 471 | $vars['minute'] = $minute; |
472 | 472 | } |
473 | - return Api\Html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute'] |
|
473 | + return Api\Html::a_href($content, '', $vars, ' data-date="'.$vars['date'].'|'.$vars['hour'].'|'.$vars['minute'] |
|
474 | 474 | . '" title="'.Api\Html::htmlspecialchars(lang('Add')).'"'); |
475 | 475 | } |
476 | 476 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | // Magic etemplate2 favorites menu (from framework) |
483 | 483 | display_sidebox('calendar', lang('Favorites'), Framework\Favorites::list_favorites('calendar')); |
484 | 484 | |
485 | - $file = array('menuOpened' => true); // menu open by default |
|
485 | + $file = array('menuOpened' => true); // menu open by default |
|
486 | 486 | |
487 | 487 | // Target for etemplate |
488 | 488 | $file[] = array( |
@@ -495,38 +495,38 @@ discard block |
||
495 | 495 | // Merge print placeholders (selectbox in etemplate) |
496 | 496 | if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']) |
497 | 497 | { |
498 | - $file['Placeholders'] = Egw::link('/index.php','menuaction=calendar.calendar_merge.show_replacements'); |
|
498 | + $file['Placeholders'] = Egw::link('/index.php', 'menuaction=calendar.calendar_merge.show_replacements'); |
|
499 | 499 | } |
500 | 500 | $appname = 'calendar'; |
501 | 501 | $menu_title = lang('Calendar Menu'); |
502 | - display_sidebox($appname,$menu_title,$file); |
|
502 | + display_sidebox($appname, $menu_title, $file); |
|
503 | 503 | |
504 | 504 | $this->sidebox_etemplate(); |
505 | 505 | |
506 | 506 | // resources menu hooks |
507 | 507 | foreach ($this->bo->resources as $resource) |
508 | 508 | { |
509 | - if(!is_array($resource['cal_sidebox'])) continue; |
|
509 | + if (!is_array($resource['cal_sidebox'])) continue; |
|
510 | 510 | $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']); |
511 | - $file = ExecMethod($resource['cal_sidebox']['file'],array( |
|
511 | + $file = ExecMethod($resource['cal_sidebox']['file'], array( |
|
512 | 512 | 'menuaction' => $this->view_menuaction, |
513 | 513 | 'owner' => $this->owner, |
514 | 514 | )); |
515 | - display_sidebox($appname,$menu_title,$file); |
|
515 | + display_sidebox($appname, $menu_title, $file); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
519 | 519 | { |
520 | 520 | $file = Array( |
521 | - 'Site configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'), |
|
522 | - 'Custom Fields'=>Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'), |
|
523 | - 'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar&ajax=true'), |
|
521 | + 'Site configuration'=>Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=calendar&ajax=true'), |
|
522 | + 'Custom Fields'=>Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'), |
|
523 | + 'Global Categories' =>Egw::link('/index.php', 'menuaction=admin.admin_categories.index&appname=calendar&ajax=true'), |
|
524 | 524 | ); |
525 | - $GLOBALS['egw']->framework->sidebox($appname,lang('Admin'),$file,'admin'); |
|
525 | + $GLOBALS['egw']->framework->sidebox($appname, lang('Admin'), $file, 'admin'); |
|
526 | 526 | } |
527 | 527 | display_sidebox('calendar', lang('Utilities'), array('Category report' => "javascript:egw_openWindowCentered2('". |
528 | - Egw::link('/index.php',array('menuaction'=>'calendar.calendar_category_report.index','ajax'=>true),false). |
|
529 | - "','_blank',870,500,'yes')" )); |
|
528 | + Egw::link('/index.php', array('menuaction'=>'calendar.calendar_category_report.index', 'ajax'=>true), false). |
|
529 | + "','_blank',870,500,'yes')")); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -534,15 +534,15 @@ discard block |
||
534 | 534 | */ |
535 | 535 | function sidebox_etemplate($content = array()) |
536 | 536 | { |
537 | - if($content['merge']) |
|
537 | + if ($content['merge']) |
|
538 | 538 | { |
539 | 539 | // View from sidebox is JSON encoded |
540 | - $this->manage_states(array_merge($content,(array)json_decode($content['view'],true))); |
|
541 | - if($content['first']) |
|
540 | + $this->manage_states(array_merge($content, (array)json_decode($content['view'], true))); |
|
541 | + if ($content['first']) |
|
542 | 542 | { |
543 | - $this->first = Api\DateTime::to($content['first'],'ts'); |
|
543 | + $this->first = Api\DateTime::to($content['first'], 'ts'); |
|
544 | 544 | } |
545 | - if($content['last']) |
|
545 | + if ($content['last']) |
|
546 | 546 | { |
547 | 547 | $this->last = new Api\DateTime($content['last']); |
548 | 548 | $this->last->setTime(23, 59, 59); |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | $_GET['merge'] = $content['merge']; |
553 | - if($this->merge()) |
|
553 | + if ($this->merge()) |
|
554 | 554 | { |
555 | - Framework::redirect('/index.php');//, array('menuaction' => 'calendar.calendar_uiviews.index')); |
|
555 | + Framework::redirect('/index.php'); //, array('menuaction' => 'calendar.calendar_uiviews.index')); |
|
556 | 556 | return false; |
557 | 557 | } |
558 | 558 | } |
@@ -563,27 +563,27 @@ discard block |
||
563 | 563 | if (!is_array($cont)) $cont = array(); |
564 | 564 | $cont['view'] = $this->view ? $this->view : 'week'; |
565 | 565 | $cont['date'] = $this->date ? $this->date : new Api\DateTime(); |
566 | - $cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner']; |
|
566 | + $cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',', $this->owner)) : $cont['owner']; |
|
567 | 567 | |
568 | - $cont['year'] = (int)Api\DateTime::to($cont['date'],'Y'); |
|
568 | + $cont['year'] = (int)Api\DateTime::to($cont['date'], 'Y'); |
|
569 | 569 | $cont['holidays'] = $this->bo->read_holidays($cont['year']); |
570 | 570 | |
571 | 571 | $readonlys = array(); |
572 | 572 | $sel_options['status_filter'] = array( |
573 | - array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')), |
|
574 | - array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')), |
|
575 | - array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')), |
|
576 | - array('value' => 'tentative', 'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')), |
|
577 | - array('value' => 'delegated', 'label' => lang('Delegated'), 'title' => lang('Show only delegated events')), |
|
578 | - array('value' => 'rejected', 'label' => lang('Rejected'),'title' => lang('Show only rejected events')), |
|
579 | - array('value' => 'owner', 'label' => lang('Owner too'),'title' => lang('Show also events just owned by selected user')), |
|
580 | - array('value' => 'all', 'label' => lang('All incl. rejected'),'title' => lang('Show all status incl. rejected events')), |
|
581 | - array('value' => 'hideprivate', 'label' => lang('Hide private infos'),'title' => lang('Show all events, as if they were private')), |
|
582 | - array('value' => 'showonlypublic', 'label' => lang('Hide private events'),'title' => lang('Show only events flagged as public, (not checked as private)')), |
|
583 | - array('value' => 'no-enum-groups', 'label' => lang('only group-events'),'title' => lang('Do not include events of group members')), |
|
584 | - array('value' => 'not-unknown', 'label' => lang('No meeting requests'),'title' => lang('Show all status, but unknown')), |
|
573 | + array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')), |
|
574 | + array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')), |
|
575 | + array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')), |
|
576 | + array('value' => 'tentative', 'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')), |
|
577 | + array('value' => 'delegated', 'label' => lang('Delegated'), 'title' => lang('Show only delegated events')), |
|
578 | + array('value' => 'rejected', 'label' => lang('Rejected'), 'title' => lang('Show only rejected events')), |
|
579 | + array('value' => 'owner', 'label' => lang('Owner too'), 'title' => lang('Show also events just owned by selected user')), |
|
580 | + array('value' => 'all', 'label' => lang('All incl. rejected'), 'title' => lang('Show all status incl. rejected events')), |
|
581 | + array('value' => 'hideprivate', 'label' => lang('Hide private infos'), 'title' => lang('Show all events, as if they were private')), |
|
582 | + array('value' => 'showonlypublic', 'label' => lang('Hide private events'), 'title' => lang('Show only events flagged as public, (not checked as private)')), |
|
583 | + array('value' => 'no-enum-groups', 'label' => lang('only group-events'), 'title' => lang('Do not include events of group members')), |
|
584 | + array('value' => 'not-unknown', 'label' => lang('No meeting requests'), 'title' => lang('Show all status, but unknown')), |
|
585 | 585 | ); |
586 | - if($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
586 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
587 | 587 | { |
588 | 588 | $sel_options['status_filter'][] = array('value' => 'deleted', 'label' => lang('Deleted'), 'title' => lang('Show events that have been deleted')); |
589 | 589 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | } |
606 | 606 | if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']) |
607 | 607 | { |
608 | - $sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null,'calendar'); |
|
608 | + $sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null, 'calendar'); |
|
609 | 609 | |
610 | 610 | } |
611 | 611 | else |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | */ |
636 | 636 | public function update_client($event_id, Api\DateTime $recurrence_date = null) |
637 | 637 | { |
638 | - if(!$event_id) return false; |
|
639 | - if(is_string($event_id) && strpos($event_id,':') !== FALSE) |
|
638 | + if (!$event_id) return false; |
|
639 | + if (is_string($event_id) && strpos($event_id, ':') !== FALSE) |
|
640 | 640 | { |
641 | - list($event_id, $date) = explode(':',$event_id); |
|
641 | + list($event_id, $date) = explode(':', $event_id); |
|
642 | 642 | $recurrence_date = new Api\DateTime($date); |
643 | 643 | } |
644 | 644 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | // Check filters to see if they still match, may have to remove |
652 | 652 | // the event because it should no longer be displayed |
653 | 653 | $filter_match = true; |
654 | - if($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' || |
|
654 | + if ($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' || |
|
655 | 655 | $this->cal_prefs['saved_states']['cat_id'])) |
656 | 656 | { |
657 | 657 | $filter_check = array( |
@@ -664,20 +664,20 @@ discard block |
||
664 | 664 | $filter_match = count($this->bo->search($filter_check, $this->bo->so->cal_table.".cal_id = {$event['id']}")) > 0; |
665 | 665 | } |
666 | 666 | |
667 | - if(!$event || !$filter_match) |
|
667 | + if (!$event || !$filter_match) |
|
668 | 668 | { |
669 | 669 | // Sending null will trigger a removal |
670 | 670 | $response->generic('data', array('uid' => 'calendar::'.$event_id, 'data' => null)); |
671 | 671 | return false; |
672 | 672 | } |
673 | 673 | |
674 | - if(!$event['recur_type'] || $recurrence_date) |
|
674 | + if (!$event['recur_type'] || $recurrence_date) |
|
675 | 675 | { |
676 | 676 | $this->to_client($event); |
677 | 677 | $response->generic('data', array('uid' => 'calendar::'.$event['row_id'], 'data' => $event)); |
678 | 678 | } |
679 | 679 | // If it's recurring, try to send the next month or so |
680 | - else if($event['recur_type'] ) |
|
680 | + else if ($event['recur_type']) |
|
681 | 681 | { |
682 | 682 | $this_month = new Api\DateTime('next month'); |
683 | 683 | $rrule = calendar_rrule::event2rrule($event, true); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | $response->generic('data', array('uid' => 'calendar::'.$converted['row_id'], 'data' => $converted)); |
691 | 691 | $rrule->next(); |
692 | 692 | } |
693 | - while ($rrule->valid() && $occurrence <= $this_month ); |
|
693 | + while ($rrule->valid() && $occurrence <= $this_month); |
|
694 | 694 | } |
695 | 695 | return true; |
696 | 696 | } |
@@ -706,15 +706,15 @@ discard block |
||
706 | 706 | */ |
707 | 707 | public function to_client(&$event) |
708 | 708 | { |
709 | - if(!$event || !is_array($event)) return false; |
|
709 | + if (!$event || !is_array($event)) return false; |
|
710 | 710 | |
711 | - if (!$this->bo->check_perms(Acl::EDIT,$event)) |
|
711 | + if (!$this->bo->check_perms(Acl::EDIT, $event)) |
|
712 | 712 | { |
713 | 713 | $event['class'] .= 'rowNoEdit '; |
714 | 714 | } |
715 | 715 | |
716 | 716 | // Delete disabled for other applications |
717 | - if (!$this->bo->check_perms(Acl::DELETE,$event) || !is_numeric($event['id'])) |
|
717 | + if (!$this->bo->check_perms(Acl::DELETE, $event) || !is_numeric($event['id'])) |
|
718 | 718 | { |
719 | 719 | $event['class'] .= 'rowNoDelete '; |
720 | 720 | } |
@@ -727,32 +727,32 @@ discard block |
||
727 | 727 | |
728 | 728 | $event['recure'] = $this->bo->recure2string($event); |
729 | 729 | |
730 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
731 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
730 | + if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
731 | + if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
732 | 732 | |
733 | 733 | // respect category permissions |
734 | - if(!empty($event['category'])) |
|
734 | + if (!empty($event['category'])) |
|
735 | 735 | { |
736 | 736 | $event['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
737 | 737 | } |
738 | 738 | $event['non_blocking'] = (bool)$event['non_blocking']; |
739 | 739 | |
740 | 740 | $matches = null; |
741 | - if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches)) |
|
741 | + if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches)) |
|
742 | 742 | { |
743 | 743 | $app = $matches[1]; |
744 | 744 | $app_id = $matches[2]; |
745 | 745 | $icons = array(); |
746 | - if(!($is_private = calendar_bo::integration_get_private($app,$app_id,$event))) |
|
746 | + if (!($is_private = calendar_bo::integration_get_private($app, $app_id, $event))) |
|
747 | 747 | { |
748 | - $icons = calendar_uiviews::integration_get_icons($app,$app_id,$event); |
|
748 | + $icons = calendar_uiviews::integration_get_icons($app, $app_id, $event); |
|
749 | 749 | } |
750 | 750 | $event['app'] = $app; |
751 | 751 | $event['app_id'] = $app_id; |
752 | 752 | } |
753 | 753 | else |
754 | 754 | { |
755 | - $is_private = !$this->bo->check_perms(Acl::READ,$event); |
|
755 | + $is_private = !$this->bo->check_perms(Acl::READ, $event); |
|
756 | 756 | } |
757 | 757 | if ($is_private) |
758 | 758 | { |
@@ -760,27 +760,27 @@ discard block |
||
760 | 760 | $event['class'] .= 'rowNoView '; |
761 | 761 | } |
762 | 762 | |
763 | - if(!$event['app']) |
|
763 | + if (!$event['app']) |
|
764 | 764 | { |
765 | 765 | $event['app'] = 'calendar'; |
766 | 766 | } |
767 | - if(!$event['app_id']) |
|
767 | + if (!$event['app_id']) |
|
768 | 768 | { |
769 | 769 | $event['app_id'] = $event['id']; |
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
773 | 773 | { |
774 | - $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts'); |
|
774 | + $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts'); |
|
775 | 775 | } |
776 | 776 | // set id for grid |
777 | - $event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts') : ''); |
|
777 | + $event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts') : ''); |
|
778 | 778 | |
779 | 779 | // Set up participant section of tooltip |
780 | - $participants = $this->bo->participants($event,false); |
|
781 | - $event['parts'] = implode("\n",$participants); |
|
780 | + $participants = $this->bo->participants($event, false); |
|
781 | + $event['parts'] = implode("\n", $participants); |
|
782 | 782 | $event['participant_types'] = array(); |
783 | - foreach($participants as $uid => $text) |
|
783 | + foreach ($participants as $uid => $text) |
|
784 | 784 | { |
785 | 785 | $user_type = $user_id = null; |
786 | 786 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | $event['date'] = $this->bo->date2string($event['start']); |
791 | 791 | |
792 | 792 | // Change dates |
793 | - foreach(calendar_egw_record::$types['date-time'] as $field) |
|
793 | + foreach (calendar_egw_record::$types['date-time'] as $field) |
|
794 | 794 | { |
795 | - if(is_int($event[$field])) |
|
795 | + if (is_int($event[$field])) |
|
796 | 796 | { |
797 | 797 | $event[$field] = Api\DateTime::to($event[$field], Api\DateTime::ET2); |
798 | 798 | } |
@@ -812,13 +812,13 @@ discard block |
||
812 | 812 | public function merge($timespan = array()) |
813 | 813 | { |
814 | 814 | // Merge print |
815 | - if($_GET['merge']) |
|
815 | + if ($_GET['merge']) |
|
816 | 816 | { |
817 | - if(!$timespan) |
|
817 | + if (!$timespan) |
|
818 | 818 | { |
819 | 819 | // Try to make time span into appropriate ranges to match |
820 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
821 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
820 | + if (stripos($_GET['merge'], 'month') !== false || stripos($_GET['merge'], lang('month')) !== false) $template = 'month'; |
|
821 | + if (stripos($_GET['merge'], 'week') !== false || stripos($_GET['merge'], lang('week')) !== false) $template = 'week'; |
|
822 | 822 | //error_log("Detected template $template"); |
823 | 823 | switch ($template) |
824 | 824 | { |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | // Trim to _only_ the month, do not pad to week start / end |
827 | 827 | $time = new Api\DateTime($this->date); |
828 | 828 | $timespan = array(array( |
829 | - 'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'),'ts'), |
|
830 | - 'end' => Api\DateTime::to($time->format('Y-m-t 23:59:59'),'ts') |
|
829 | + 'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'), 'ts'), |
|
830 | + 'end' => Api\DateTime::to($time->format('Y-m-t 23:59:59'), 'ts') |
|
831 | 831 | )); |
832 | 832 | break; |
833 | 833 | case 'week': |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | $start = new Api\DateTime($this->first); |
836 | 836 | $t = clone $start; |
837 | 837 | $t->modify('+1 week')->modify('-1 second'); |
838 | - if($t->format('ts') < Api\DateTime::to($this->last,'ts')) |
|
838 | + if ($t->format('ts') < Api\DateTime::to($this->last, 'ts')) |
|
839 | 839 | { |
840 | 840 | do |
841 | 841 | { |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | ); |
846 | 846 | $start->modify('+1 week'); |
847 | 847 | $t->modify('+1 week'); |
848 | - } while( $start->format('ts') < $this->last); |
|
848 | + } while ($start->format('ts') < $this->last); |
|
849 | 849 | break; |
850 | 850 | } |
851 | 851 | // Fall through |
@@ -858,11 +858,11 @@ discard block |
||
858 | 858 | } |
859 | 859 | $document = $_GET['merge']; |
860 | 860 | $merge = new calendar_merge(); |
861 | - if($error = $merge->check_document($document, $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])) |
|
861 | + if ($error = $merge->check_document($document, $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])) |
|
862 | 862 | { |
863 | 863 | return $error; |
864 | 864 | } |
865 | - if(!$error && $this->merge_collabora($document, $timespan)) |
|
865 | + if (!$error && $this->merge_collabora($document, $timespan)) |
|
866 | 866 | { |
867 | 867 | return false; |
868 | 868 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | Framework::refresh_opener($error, 'calendar'); |
876 | 876 | } |
877 | 877 | unset($_GET['merge']); |
878 | - if($error) |
|
878 | + if ($error) |
|
879 | 879 | { |
880 | 880 | // This doesn't give message either, but at least it doesn't give a blank screen |
881 | 881 | Framework::redirect_link('/index.php', array( |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | protected function merge_collabora($document, $timespan) |
889 | 889 | { |
890 | 890 | $file = Api\Vfs::stat($document); |
891 | - if(!$file['mime']) |
|
891 | + if (!$file['mime']) |
|
892 | 892 | { |
893 | 893 | $file['mime'] = Api\Vfs::mime_content_type($document); |
894 | 894 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | 'document' => $document, |
918 | 918 | 'merge' => 'calendar_merge', |
919 | 919 | 'id' => $timespan |
920 | - )),'_blank',false); |
|
920 | + )), '_blank', false); |
|
921 | 921 | return true; |
922 | 922 | } |
923 | 923 |
@@ -1490,13 +1490,13 @@ discard block |
||
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | /** |
1493 | - * Converts a participant into a (readable) user- or resource-name |
|
1494 | - * |
|
1495 | - * @param string|int $id id of user or resource |
|
1496 | - * @param string|boolean $use_type =false type-letter or false |
|
1497 | - * @param boolean $append_email =false append email (Name <email>) |
|
1498 | - * @return string with name |
|
1499 | - */ |
|
1493 | + * Converts a participant into a (readable) user- or resource-name |
|
1494 | + * |
|
1495 | + * @param string|int $id id of user or resource |
|
1496 | + * @param string|boolean $use_type =false type-letter or false |
|
1497 | + * @param boolean $append_email =false append email (Name <email>) |
|
1498 | + * @return string with name |
|
1499 | + */ |
|
1500 | 1500 | function participant_name($id,$use_type=false, $append_email=false) |
1501 | 1501 | { |
1502 | 1502 | static $id2lid = array(); |
@@ -1525,13 +1525,13 @@ discard block |
||
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
1528 | - * Converts participants array of an event into array of (readable) participant-names with status |
|
1529 | - * |
|
1530 | - * @param array $event event-data |
|
1531 | - * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
1532 | - * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
1533 | - * @return array with id / names with status pairs |
|
1534 | - */ |
|
1528 | + * Converts participants array of an event into array of (readable) participant-names with status |
|
1529 | + * |
|
1530 | + * @param array $event event-data |
|
1531 | + * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
1532 | + * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
1533 | + * @return array with id / names with status pairs |
|
1534 | + */ |
|
1535 | 1535 | function participants($event,$long_status=false,$show_group_invitation=false) |
1536 | 1536 | { |
1537 | 1537 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | } |
1602 | 1602 | |
1603 | 1603 | /** |
1604 | - * Converts category string of an event into array of (readable) category-names |
|
1605 | - * |
|
1606 | - * @param string $category cat-id (multiple id's commaseparated) |
|
1607 | - * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
1608 | - * @return array with id / names |
|
1609 | - */ |
|
1604 | + * Converts category string of an event into array of (readable) category-names |
|
1605 | + * |
|
1606 | + * @param string $category cat-id (multiple id's commaseparated) |
|
1607 | + * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
1608 | + * @return array with id / names |
|
1609 | + */ |
|
1610 | 1610 | function categories($category,&$color) |
1611 | 1611 | { |
1612 | 1612 | static $id2cat = array(); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * @var array recur_types translates MCAL recur-types to verbose labels |
124 | 124 | */ |
125 | - var $recur_types = Array( |
|
125 | + var $recur_types = array( |
|
126 | 126 | MCAL_RECUR_NONE => 'No recurrence', |
127 | 127 | MCAL_RECUR_DAILY => 'Daily', |
128 | 128 | MCAL_RECUR_WEEKLY => 'Weekly', |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | * @param string $pattern pattern to search |
1898 | 1898 | * @return array with cal_id - title pairs of the matching entries |
1899 | 1899 | */ |
1900 | - function link_query($pattern, Array &$options = array()) |
|
1900 | + function link_query($pattern, array &$options = array()) |
|
1901 | 1901 | { |
1902 | 1902 | $result = array(); |
1903 | 1903 | $query = array( |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | * or an ExecMethod callback with parameters $id,$event |
633 | 633 | * |
634 | 634 | * @param string $app |
635 | - * @param int|string $id |
|
636 | - * @return string |
|
635 | + * @param string $id |
|
636 | + * @return boolean |
|
637 | 637 | */ |
638 | 638 | static function integration_get_private($app,$id,$event) |
639 | 639 | { |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * This methods operates in usertime, while $this->config['horizont'] is in servertime! |
763 | 763 | * |
764 | 764 | * @param array $event |
765 | - * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
|
765 | + * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
|
766 | 766 | */ |
767 | 767 | function set_recurrences($event,$start=0) |
768 | 768 | { |
@@ -982,10 +982,9 @@ discard block |
||
982 | 982 | * Recurrences get calculated by rrule iterator implemented in calendar_rrule class. |
983 | 983 | * |
984 | 984 | * @param array $event repeating event whos repetions should be inserted |
985 | - * @param mixed $start start-date |
|
985 | + * @param mixed $_start start-date |
|
986 | 986 | * @param mixed $end end-date |
987 | 987 | * @param array $events where the repetions get inserted |
988 | - * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
|
989 | 988 | */ |
990 | 989 | function insert_all_recurrences($event,$_start,$end,&$events) |
991 | 990 | { |
@@ -1139,7 +1138,7 @@ discard block |
||
1139 | 1138 | * even if you have no general read-grant from that user. |
1140 | 1139 | * |
1141 | 1140 | * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE} |
1142 | - * @param mixed $event event as array or the event-id or 0 for a general check |
|
1141 | + * @param integer $event event as array or the event-id or 0 for a general check |
|
1143 | 1142 | * @param int $other uid to check (if event==0) or 0 to check against $this->user |
1144 | 1143 | * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc |
1145 | 1144 | * @param mixed $date_to_read =null date used for reading, internal param for the caching |
@@ -1312,8 +1311,6 @@ discard block |
||
1312 | 1311 | * @param string $msg message with parameters/variables like lang(), eg. '%1' |
1313 | 1312 | * @param boolean $backtrace =True include a function-backtrace, default True=On |
1314 | 1313 | * should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!! |
1315 | - * @param mixed $param a variable number of parameters, to be inserted in $msg |
|
1316 | - * arrays get serialized with print_r() ! |
|
1317 | 1314 | */ |
1318 | 1315 | static function debug_message($msg,$backtrace=True) |
1319 | 1316 | { |
@@ -1378,7 +1375,7 @@ discard block |
||
1378 | 1375 | * Formats one or two dates (range) as long date (full monthname), optionaly with a time |
1379 | 1376 | * |
1380 | 1377 | * @param mixed $_first first date |
1381 | - * @param mixed $last =0 last date if != 0 (default) |
|
1378 | + * @param integer $last =0 last date if != 0 (default) |
|
1382 | 1379 | * @param boolean $display_time =false should a time be displayed too |
1383 | 1380 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
1384 | 1381 | * @return string with formated date |
@@ -1847,7 +1844,6 @@ discard block |
||
1847 | 1844 | * |
1848 | 1845 | * Is called as hook to participate in the linking |
1849 | 1846 | * |
1850 | - * @param int|array $entry int cal_id or array with event |
|
1851 | 1847 | * @param string|boolean string with title, null if not found or false if not read perms |
1852 | 1848 | */ |
1853 | 1849 | function link_title($event) |
@@ -2036,6 +2032,7 @@ discard block |
||
2036 | 2032 | * |
2037 | 2033 | * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions |
2038 | 2034 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
2035 | + * @param string $schedule_tag |
|
2039 | 2036 | * @return string|boolean string with etag or false |
2040 | 2037 | */ |
2041 | 2038 | function get_etag($entry, &$schedule_tag=null) |
@@ -2076,7 +2073,6 @@ discard block |
||
2076 | 2073 | * Hook for infolog to set some extra data and links |
2077 | 2074 | * |
2078 | 2075 | * @param array $data event-array preset by infolog plus |
2079 | - * @param int $data[id] cal_id |
|
2080 | 2076 | * @return array with key => value pairs to set in new event and link_app/link_id arrays |
2081 | 2077 | */ |
2082 | 2078 | function infolog_set($data) |
@@ -2128,7 +2124,6 @@ discard block |
||
2128 | 2124 | * Hook for timesheet to set some extra data and links |
2129 | 2125 | * |
2130 | 2126 | * @param array $data |
2131 | - * @param int $data[id] cal_id:recurrence |
|
2132 | 2127 | * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays |
2133 | 2128 | */ |
2134 | 2129 | function timesheet_set($data) |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | |
18 | 18 | if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
19 | 19 | { |
20 | - define('ACL_TYPE_IDENTIFER','***ACL***'); |
|
20 | + define('ACL_TYPE_IDENTIFER', '***ACL***'); |
|
21 | 21 | } |
22 | 22 | |
23 | -define('HOUR_s',60*60); |
|
24 | -define('DAY_s',24*HOUR_s); |
|
25 | -define('WEEK_s',7*DAY_s); |
|
23 | +define('HOUR_s', 60 * 60); |
|
24 | +define('DAY_s', 24 * HOUR_s); |
|
25 | +define('WEEK_s', 7 * DAY_s); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * 4 = function-calls to exported conversation-functions like date2ts, date2array, ... |
72 | 72 | * 5 = function-calls to private functions |
73 | 73 | */ |
74 | - var $debug=false; |
|
74 | + var $debug = false; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @var int $now timestamp in server-time |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @var int $user nummerical id of the current user-id |
103 | 103 | */ |
104 | - var $user=0; |
|
104 | + var $user = 0; |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs |
108 | 108 | */ |
109 | - var $grants=array(); |
|
109 | + var $grants = array(); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | */ |
220 | 220 | function __construct() |
221 | 221 | { |
222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
222 | + if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True); |
|
223 | 223 | |
224 | 224 | $this->so = new calendar_so(); |
225 | 225 | |
226 | - $this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common']; |
|
227 | - $this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
226 | + $this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common']; |
|
227 | + $this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
228 | 228 | |
229 | 229 | $this->now = time(); |
230 | - $this->now_su = Api\DateTime::server2user($this->now,'ts'); |
|
230 | + $this->now_su = Api\DateTime::server2user($this->now, 'ts'); |
|
231 | 231 | |
232 | 232 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources'))) |
237 | 237 | { |
238 | 238 | $this->resources = array(); |
239 | - foreach(Api\Hooks::process('calendar_resources') as $app => $data) |
|
239 | + foreach (Api\Hooks::process('calendar_resources') as $app => $data) |
|
240 | 240 | { |
241 | 241 | if ($data && $data['type']) |
242 | 242 | { |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | 'app' => 'email', |
250 | 250 | ); |
251 | 251 | $this->resources['l'] = array( |
252 | - 'type' => 'l',// one char type-identifier for this resources |
|
253 | - 'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id |
|
252 | + 'type' => 'l', // one char type-identifier for this resources |
|
253 | + 'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id |
|
254 | 254 | 'app' => 'Distribution list' |
255 | 255 | ); |
256 | 256 | $this->resources[''] = array( |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | } |
262 | 262 | //error_log(__METHOD__ . " registered resources=". array2string($this->resources)); |
263 | 263 | |
264 | - $this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
264 | + $this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
265 | 265 | $this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite']; |
266 | 266 | |
267 | - $this->categories = new Api\Categories($this->user,'calendar'); |
|
267 | + $this->categories = new Api\Categories($this->user, 'calendar'); |
|
268 | 268 | |
269 | 269 | $this->customfields = Api\Storage\Customfields::get('calendar'); |
270 | 270 | |
271 | - foreach($this->alarms as $secs => &$label) |
|
271 | + foreach ($this->alarms as $secs => &$label) |
|
272 | 272 | { |
273 | 273 | $label = self::secs2label($secs); |
274 | 274 | } |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | { |
285 | 285 | if ($secs <= 3600) |
286 | 286 | { |
287 | - $label = lang('%1 minutes', $secs/60); |
|
287 | + $label = lang('%1 minutes', $secs / 60); |
|
288 | 288 | } |
289 | - elseif($secs <= 86400) |
|
289 | + elseif ($secs <= 86400) |
|
290 | 290 | { |
291 | - $label = lang('%1 hours', $secs/3600); |
|
291 | + $label = lang('%1 hours', $secs / 3600); |
|
292 | 292 | } |
293 | 293 | else |
294 | 294 | { |
295 | - $label = lang('%1 days', $secs/86400); |
|
295 | + $label = lang('%1 days', $secs / 86400); |
|
296 | 296 | } |
297 | 297 | return $label; |
298 | 298 | } |
@@ -308,12 +308,12 @@ discard block |
||
308 | 308 | if (!$ids) return null; |
309 | 309 | |
310 | 310 | $data = array(); |
311 | - foreach((array)$ids as $id) |
|
311 | + foreach ((array)$ids as $id) |
|
312 | 312 | { |
313 | 313 | $email = $id; |
314 | 314 | $name = ''; |
315 | 315 | $matches = null; |
316 | - if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches)) |
|
316 | + if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches)) |
|
317 | 317 | { |
318 | 318 | $name = $matches[1]; |
319 | 319 | $email = $matches[2]; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | */ |
338 | 338 | static function mailing_lists($ids) |
339 | 339 | { |
340 | - if(!is_array($ids)) |
|
340 | + if (!is_array($ids)) |
|
341 | 341 | { |
342 | 342 | $ids = array($ids); |
343 | 343 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | // Email list |
347 | 347 | $contacts_obj = new Api\Contacts(); |
348 | 348 | $bo = new calendar_bo(); |
349 | - foreach($ids as $id) |
|
349 | + foreach ($ids as $id) |
|
350 | 350 | { |
351 | 351 | $list = $contacts_obj->read_list((int)$id); |
352 | 352 | |
@@ -373,22 +373,22 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return array |
375 | 375 | */ |
376 | - public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true) |
|
376 | + public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true) |
|
377 | 377 | { |
378 | 378 | $contact_list = array(); |
379 | 379 | $contacts = new Api\Contacts(); |
380 | - if($contacts->check_list((int)substr($id,1), ACL::READ) || (int)substr($id,1) < 0) |
|
380 | + if ($contacts->check_list((int)substr($id, 1), ACL::READ) || (int)substr($id, 1) < 0) |
|
381 | 381 | { |
382 | - $options = array('list' => substr($id,1)); |
|
383 | - $lists = $contacts->search('',true,'','','',false,'AND',false,$options); |
|
384 | - if(!$lists) |
|
382 | + $options = array('list' => substr($id, 1)); |
|
383 | + $lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options); |
|
384 | + if (!$lists) |
|
385 | 385 | { |
386 | 386 | return $contact_list; |
387 | 387 | } |
388 | - foreach($lists as &$contact) |
|
388 | + foreach ($lists as &$contact) |
|
389 | 389 | { |
390 | 390 | // Check for user account |
391 | - if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'],'person_id'))) |
|
391 | + if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'], 'person_id'))) |
|
392 | 392 | { |
393 | 393 | $contact = ''.$account_id; |
394 | 394 | } |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | { |
397 | 397 | $contact = 'c'.$contact['id']; |
398 | 398 | } |
399 | - if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
|
399 | + if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $contact)) |
|
400 | 400 | { |
401 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
401 | + if ($contact && !in_array($contact, $contact_list)) // already added? |
|
402 | 402 | { |
403 | 403 | $contact_list[] = $contact; |
404 | 404 | } |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | function enum_groups(&$event) |
418 | 418 | { |
419 | 419 | $added = 0; |
420 | - foreach(array_keys($event['participants']) as $uid) |
|
420 | + foreach (array_keys($event['participants']) as $uid) |
|
421 | 421 | { |
422 | 422 | if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' && |
423 | 423 | ($members = $GLOBALS['egw']->accounts->members($uid, true))) |
424 | 424 | { |
425 | - foreach($members as $member) |
|
425 | + foreach ($members as $member) |
|
426 | 426 | { |
427 | 427 | if (!isset($event['participants'][$member])) |
428 | 428 | { |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search |
445 | 445 | * @return array of user-ids |
446 | 446 | */ |
447 | - private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true) |
|
447 | + private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true) |
|
448 | 448 | { |
449 | 449 | if (!is_array($_users)) |
450 | 450 | { |
@@ -452,35 +452,35 @@ discard block |
||
452 | 452 | } |
453 | 453 | // only query calendars of users, we have READ-grants from |
454 | 454 | $users = array(); |
455 | - foreach($_users as $user) |
|
455 | + foreach ($_users as $user) |
|
456 | 456 | { |
457 | 457 | $user = trim($user); |
458 | 458 | |
459 | 459 | // Handle email lists |
460 | - if(!is_numeric($user) && $user[0] == 'l') |
|
460 | + if (!is_numeric($user) && $user[0] == 'l') |
|
461 | 461 | { |
462 | - foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
|
462 | + foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
|
463 | 463 | { |
464 | - if ($contact && !in_array($contact,$users)) // already added? |
|
464 | + if ($contact && !in_array($contact, $users)) // already added? |
|
465 | 465 | { |
466 | 466 | $users[] = $contact; |
467 | 467 | } |
468 | 468 | } |
469 | 469 | continue; |
470 | 470 | } |
471 | - if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
|
471 | + if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $user)) |
|
472 | 472 | { |
473 | - if ($user && !in_array($user,$users)) // already added? |
|
473 | + if ($user && !in_array($user, $users)) // already added? |
|
474 | 474 | { |
475 | 475 | // General expansion check |
476 | 476 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
477 | 477 | { |
478 | 478 | $info = $this->resource_info($user); |
479 | - if($info && $info['resources']) |
|
479 | + if ($info && $info['resources']) |
|
480 | 480 | { |
481 | - foreach($info['resources'] as $_user) |
|
481 | + foreach ($info['resources'] as $_user) |
|
482 | 482 | { |
483 | - if($_user && !in_array($_user, $users)) |
|
483 | + if ($_user && !in_array($_user, $users)) |
|
484 | 484 | { |
485 | 485 | $users[] = $_user; |
486 | 486 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | } |
494 | 494 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
495 | 495 | { |
496 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
496 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
497 | 497 | } |
498 | 498 | // the further code is only for real users |
499 | 499 | if (!is_numeric($user)) continue; |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | $members = $GLOBALS['egw']->accounts->members($user, true); |
507 | 507 | if (is_array($members)) |
508 | 508 | { |
509 | - foreach($members as $member) |
|
509 | + foreach ($members as $member) |
|
510 | 510 | { |
511 | 511 | // use only members which gave the user a read-grant |
512 | 512 | if (!in_array($member, $users) && |
513 | - ($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member))) |
|
513 | + ($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $member))) |
|
514 | 514 | { |
515 | 515 | $users[] = $member; |
516 | 516 | } |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
523 | 523 | if (is_array($memberships)) |
524 | 524 | { |
525 | - foreach($memberships as $group) |
|
525 | + foreach ($memberships as $group) |
|
526 | 526 | { |
527 | - if (!in_array($group,$users)) |
|
527 | + if (!in_array($group, $users)) |
|
528 | 528 | { |
529 | 529 | $users[] = $group; |
530 | 530 | } |
@@ -567,18 +567,18 @@ discard block |
||
567 | 567 | * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param) |
568 | 568 | * or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given |
569 | 569 | */ |
570 | - function &search($params,$sql_filter=null) |
|
570 | + function &search($params, $sql_filter = null) |
|
571 | 571 | { |
572 | 572 | $params_in = $params; |
573 | 573 | |
574 | - $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
574 | + $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
575 | 575 | |
576 | 576 | // check if any resource wants to hook into |
577 | - foreach($this->resources as $data) |
|
577 | + foreach ($this->resources as $data) |
|
578 | 578 | { |
579 | 579 | if (isset($data['search_filter'])) |
580 | 580 | { |
581 | - $params = ExecMethod($data['search_filter'],$params); |
|
581 | + $params = ExecMethod($data['search_filter'], $params); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | |
@@ -591,18 +591,18 @@ discard block |
||
591 | 591 | // resolve users to add memberships for users and members for groups |
592 | 592 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
593 | 593 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
594 | - if($params['private_allowed']) |
|
594 | + if ($params['private_allowed']) |
|
595 | 595 | { |
596 | - $params['private_allowed'] = $this->resolve_users($params['private_allowed'],$params['filter'] == 'no-enum-groups',$params['ignore_acl'], empty($params['query'])); |
|
596 | + $params['private_allowed'] = $this->resolve_users($params['private_allowed'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // supply so with private_grants, to not query them again from the database |
600 | 600 | if (!empty($params['query'])) |
601 | 601 | { |
602 | 602 | $params['private_grants'] = array(); |
603 | - foreach($this->grants as $user => $rights) |
|
603 | + foreach ($this->grants as $user => $rights) |
|
604 | 604 | { |
605 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
605 | + if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user; |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
@@ -628,49 +628,49 @@ discard block |
||
628 | 628 | $params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring']; |
629 | 629 | $cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0; |
630 | 630 | $filter = isset($params['filter']) ? $params['filter'] : 'all'; |
631 | - $offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false; |
|
631 | + $offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false; |
|
632 | 632 | // socal::search() returns rejected group-invitations, as only the user not also the group is rejected |
633 | 633 | // as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed |
634 | 634 | $users_in = (array)$params_in['users']; |
635 | - $remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) && |
|
635 | + $remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) && |
|
636 | 636 | count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null; |
637 | 637 | //error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user)); |
638 | 638 | |
639 | 639 | if ($this->debug && ($this->debug > 1 || $this->debug == 'search')) |
640 | 640 | { |
641 | 641 | $this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)', |
642 | - True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']); |
|
642 | + True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']); |
|
643 | 643 | } |
644 | 644 | // date2ts(,true) converts to server time, db2data converts again to user-time |
645 | - $events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null, |
|
646 | - $users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user); |
|
645 | + $events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null, |
|
646 | + $users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user); |
|
647 | 647 | |
648 | 648 | if (isset($params['cols'])) |
649 | 649 | { |
650 | 650 | return $events; |
651 | 651 | } |
652 | 652 | $this->total = $this->so->total; |
653 | - $this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
653 | + $this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
654 | 654 | |
655 | 655 | //echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n"; |
656 | - foreach($events as $id => $event) |
|
656 | + foreach ($events as $id => $event) |
|
657 | 657 | { |
658 | 658 | if ($params['enum_groups'] && $this->enum_groups($event)) |
659 | 659 | { |
660 | 660 | $events[$id] = $event; |
661 | 661 | } |
662 | 662 | $matches = null; |
663 | - if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches)) |
|
663 | + if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches)) |
|
664 | 664 | { |
665 | - $is_private = self::integration_get_private($matches[1],$matches[2],$event); |
|
665 | + $is_private = self::integration_get_private($matches[1], $matches[2], $event); |
|
666 | 666 | } |
667 | 667 | else |
668 | 668 | { |
669 | - $is_private = !$this->check_perms(Acl::READ,$event); |
|
669 | + $is_private = !$this->check_perms(Acl::READ, $event); |
|
670 | 670 | } |
671 | 671 | if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate'))) |
672 | 672 | { |
673 | - $this->clear_private_infos($events[$id],$params['private_allowed'] ? $params['private_allowed'] : $users); |
|
673 | + $this->clear_private_infos($events[$id], $params['private_allowed'] ? $params['private_allowed'] : $users); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
@@ -678,18 +678,18 @@ discard block |
||
678 | 678 | { |
679 | 679 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
680 | 680 | { |
681 | - $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
|
681 | + $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events); |
|
682 | 682 | } |
683 | 683 | // create empty entries for each day in the reported time |
684 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
684 | + for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
685 | 685 | { |
686 | 686 | $daysEvents[$this->date2string($ts)] = array(); |
687 | 687 | } |
688 | - foreach($events as $k => $event) |
|
688 | + foreach ($events as $k => $event) |
|
689 | 689 | { |
690 | - $e_start = max($this->date2ts($event['start']),$start); |
|
690 | + $e_start = max($this->date2ts($event['start']), $start); |
|
691 | 691 | // $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59 |
692 | - $e_end = min($this->date2ts($event['end'])-1,$end); |
|
692 | + $e_end = min($this->date2ts($event['end']) - 1, $end); |
|
693 | 693 | |
694 | 694 | // add event to each day in the reported time |
695 | 695 | $ts = $e_start; |
@@ -698,23 +698,23 @@ discard block |
||
698 | 698 | $ymd = null; |
699 | 699 | while ($ts <= $e_end) |
700 | 700 | { |
701 | - $daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k]; |
|
702 | - $ts = strtotime("+1 day",$ts); |
|
701 | + $daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k]; |
|
702 | + $ts = strtotime("+1 day", $ts); |
|
703 | 703 | } |
704 | 704 | if ($ymd != ($last = $this->date2string($e_end))) |
705 | 705 | { |
706 | - $daysEvents[$last][] =& $events[$k]; |
|
706 | + $daysEvents[$last][] = & $events[$k]; |
|
707 | 707 | } |
708 | 708 | } |
709 | - $events =& $daysEvents; |
|
709 | + $events = & $daysEvents; |
|
710 | 710 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
711 | 711 | { |
712 | - $this->debug_message('socalendar::search daywise events=%1',False,$events); |
|
712 | + $this->debug_message('socalendar::search daywise events=%1', False, $events); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | if ($this->debug && ($this->debug > 0 || $this->debug == 'search')) |
716 | 716 | { |
717 | - $this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events); |
|
717 | + $this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events); |
|
718 | 718 | } |
719 | 719 | //error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace()); |
720 | 720 | return $events; |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | * @param string $part |
728 | 728 | * @return array |
729 | 729 | */ |
730 | - static function integration_get_data($app,$part=null) |
|
730 | + static function integration_get_data($app, $part = null) |
|
731 | 731 | { |
732 | - static $integration_data=null; |
|
732 | + static $integration_data = null; |
|
733 | 733 | |
734 | 734 | if (!isset($integration_data)) |
735 | 735 | { |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * @param int|string $id |
752 | 752 | * @return string |
753 | 753 | */ |
754 | - static function integration_get_private($app,$id,$event) |
|
754 | + static function integration_get_private($app, $id, $event) |
|
755 | 755 | { |
756 | - $app_data = self::integration_get_data($app,'is_private'); |
|
756 | + $app_data = self::integration_get_data($app, 'is_private'); |
|
757 | 757 | |
758 | 758 | // no method, fall back to link title |
759 | 759 | if (is_null($app_data)) |
760 | 760 | { |
761 | - $is_private = !Link::title($app,$id); |
|
761 | + $is_private = !Link::title($app, $id); |
|
762 | 762 | } |
763 | 763 | // boolean value to make all events of $app public (false) or private (true) |
764 | 764 | elseif (is_bool($app_data)) |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } |
768 | 768 | else |
769 | 769 | { |
770 | - $is_private = (bool)ExecMethod2($app_data,$id,$event); |
|
770 | + $is_private = (bool)ExecMethod2($app_data, $id, $event); |
|
771 | 771 | } |
772 | 772 | //echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n"; |
773 | 773 | return $is_private; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | * @param array &$event |
782 | 782 | * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar |
783 | 783 | */ |
784 | - function clear_private_infos(&$event,$allowed_participants = array()) |
|
784 | + function clear_private_infos(&$event, $allowed_participants = array()) |
|
785 | 785 | { |
786 | 786 | if ($event == false) return; |
787 | 787 | if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
@@ -797,19 +797,19 @@ discard block |
||
797 | 797 | 'owner' => $event['owner'], |
798 | 798 | 'uid' => $event['uid'], |
799 | 799 | 'etag' => $event['etag'], |
800 | - 'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)), |
|
800 | + 'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)), |
|
801 | 801 | 'public'=> 0, |
802 | - 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
802 | + 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
803 | 803 | 'non_blocking' => $event['non_blocking'], |
804 | 804 | 'caldav_name' => $event['caldav_name'], |
805 | 805 | // we need full recurrence information, as they are relevant free/busy information |
806 | - )+($event['recur_type'] ? array( |
|
806 | + ) + ($event['recur_type'] ? array( |
|
807 | 807 | 'recur_type' => $event['recur_type'], |
808 | 808 | 'recur_interval' => $event['recur_interval'], |
809 | 809 | 'recur_data' => $event['recur_data'], |
810 | 810 | 'recur_enddate' => $event['recur_enddate'], |
811 | 811 | 'recur_exception'=> $event['recur_exception'], |
812 | - ):array( |
|
812 | + ) : array( |
|
813 | 813 | 'reference' => $event['reference'], |
814 | 814 | 'recurrence' => $event['recurrence'], |
815 | 815 | )); |
@@ -823,15 +823,15 @@ discard block |
||
823 | 823 | */ |
824 | 824 | function check_move_horizont($_new_horizont) |
825 | 825 | { |
826 | - if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
826 | + if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
827 | 827 | { |
828 | - $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']); |
|
828 | + $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']); |
|
829 | 829 | } |
830 | - $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
|
830 | + $new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates |
|
831 | 831 | |
832 | 832 | if ($new_horizont <= $this->config['horizont']) // no move necessary |
833 | 833 | { |
834 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
|
834 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']); |
|
835 | 835 | return; |
836 | 836 | } |
837 | 837 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
@@ -839,15 +839,15 @@ discard block |
||
839 | 839 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
840 | 840 | } |
841 | 841 | if (empty($maxdays)) $maxdays = 1000; // old default |
842 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
842 | + if ($new_horizont > time() + $maxdays * DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
843 | 843 | { |
844 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
|
845 | - $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
|
844 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays); |
|
845 | + $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays); |
|
846 | 846 | return; |
847 | 847 | } |
848 | - if ($new_horizont < time()+31*DAY_s) |
|
848 | + if ($new_horizont < time() + 31 * DAY_s) |
|
849 | 849 | { |
850 | - $new_horizont = time()+31*DAY_s; |
|
850 | + $new_horizont = time() + 31 * DAY_s; |
|
851 | 851 | } |
852 | 852 | $old_horizont = $this->config['horizont']; |
853 | 853 | $this->config['horizont'] = $new_horizont; |
@@ -855,21 +855,21 @@ discard block |
||
855 | 855 | // create further recurrences for all recurring and not yet (at the old horizont) ended events |
856 | 856 | if (($recuring = $this->so->unfinished_recuring($old_horizont))) |
857 | 857 | { |
858 | - @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
859 | - foreach($this->read(array_keys($recuring)) as $cal_id => $event) |
|
858 | + @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
859 | + foreach ($this->read(array_keys($recuring)) as $cal_id => $event) |
|
860 | 860 | { |
861 | 861 | if ($this->debug == 'check_move_horizont') |
862 | 862 | { |
863 | - $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont); |
|
863 | + $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont); |
|
864 | 864 | } |
865 | 865 | // insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past |
866 | - $this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time! |
|
866 | + $this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time! |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | // update the horizont |
870 | - Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
|
870 | + Api\Config::save_value('horizont', $this->config['horizont'], 'calendar'); |
|
871 | 871 | |
872 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
872 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | /** |
@@ -880,11 +880,11 @@ discard block |
||
880 | 880 | * @param array $event |
881 | 881 | * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
882 | 882 | */ |
883 | - function set_recurrences($event,$start=0) |
|
883 | + function set_recurrences($event, $start = 0) |
|
884 | 884 | { |
885 | - if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
885 | + if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
886 | 886 | { |
887 | - $this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start); |
|
887 | + $this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start); |
|
888 | 888 | } |
889 | 889 | // check if the caller gave us enough information and if not read it from the DB |
890 | 890 | if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end'])) |
@@ -904,29 +904,29 @@ discard block |
||
904 | 904 | |
905 | 905 | $events = array(); |
906 | 906 | |
907 | - $this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events); |
|
907 | + $this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events); |
|
908 | 908 | |
909 | 909 | $exceptions = array(); |
910 | - foreach((array)$event['recur_exception'] as $exception) |
|
910 | + foreach ((array)$event['recur_exception'] as $exception) |
|
911 | 911 | { |
912 | - $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
912 | + $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
913 | 913 | } |
914 | - foreach($events as $event) |
|
914 | + foreach ($events as $event) |
|
915 | 915 | { |
916 | 916 | $is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions); |
917 | - $start = $this->date2ts($event['start'],true); |
|
917 | + $start = $this->date2ts($event['start'], true); |
|
918 | 918 | if ($event['whole_day']) |
919 | 919 | { |
920 | 920 | $start = new Api\DateTime($event['start'], Api\DateTime::$server_timezone); |
921 | - $start->setTime(0,0,0); |
|
921 | + $start->setTime(0, 0, 0); |
|
922 | 922 | $start = $start->format('ts'); |
923 | 923 | $time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone)); |
924 | 924 | $time->setTime(23, 59, 59); |
925 | - $end = $this->date2ts($time,true); |
|
925 | + $end = $this->date2ts($time, true); |
|
926 | 926 | } |
927 | 927 | else |
928 | 928 | { |
929 | - $end = $this->date2ts($event['end'],true); |
|
929 | + $end = $this->date2ts($event['end'], true); |
|
930 | 930 | } |
931 | 931 | //error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception)); |
932 | 932 | $this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception); |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * @param array &$events array of event-arrays (reference) |
943 | 943 | * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
944 | 944 | */ |
945 | - function db2data(&$events,$date_format='ts') |
|
945 | + function db2data(&$events, $date_format = 'ts') |
|
946 | 946 | { |
947 | 947 | if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
948 | 948 | foreach ($events as &$event) |
@@ -955,65 +955,65 @@ discard block |
||
955 | 955 | // database returns timestamps as string, convert them to integer |
956 | 956 | // to avoid misinterpretation by Api\DateTime as Ymd string |
957 | 957 | // (this will fail on 32bit systems for times > 2038!) |
958 | - $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
958 | + $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
959 | 959 | $event['end'] = (int)$event['end']; |
960 | 960 | $event['whole_day'] = self::isWholeDay($event); |
961 | 961 | if ($event['whole_day'] && $date_format != 'server') |
962 | 962 | { |
963 | 963 | // Adjust dates to user TZ |
964 | - $stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
964 | + $stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
965 | 965 | $event['start'] = Api\DateTime::to($stime, $date_format); |
966 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
966 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
967 | 967 | $time->setTime(23, 59, 59); |
968 | 968 | $event['end'] = Api\DateTime::to($time, $date_format); |
969 | 969 | if (!empty($event['recurrence'])) |
970 | 970 | { |
971 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
971 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
972 | 972 | $event['recurrence'] = Api\DateTime::to($time, $date_format); |
973 | 973 | } |
974 | 974 | if (!empty($event['recur_enddate'])) |
975 | 975 | { |
976 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
976 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
977 | 977 | $time->setTime(23, 59, 59); |
978 | 978 | $event['recur_enddate'] = Api\DateTime::to($time, $date_format); |
979 | 979 | } |
980 | - $timestamps = array('modified','created','deleted'); |
|
980 | + $timestamps = array('modified', 'created', 'deleted'); |
|
981 | 981 | } |
982 | 982 | else |
983 | 983 | { |
984 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date','deleted'); |
|
984 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date', 'deleted'); |
|
985 | 985 | } |
986 | 986 | // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! |
987 | 987 | foreach ($timestamps as $ts) |
988 | 988 | { |
989 | 989 | if (!empty($event[$ts])) |
990 | 990 | { |
991 | - $event[$ts] = $this->date2usertime((int)$event[$ts],$date_format); |
|
991 | + $event[$ts] = $this->date2usertime((int)$event[$ts], $date_format); |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | // same with the recur exceptions |
995 | 995 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
996 | 996 | { |
997 | - foreach($event['recur_exception'] as &$date) |
|
997 | + foreach ($event['recur_exception'] as &$date) |
|
998 | 998 | { |
999 | 999 | if ($event['whole_day'] && $date_format != 'server') |
1000 | 1000 | { |
1001 | 1001 | // Adjust dates to user TZ |
1002 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
1002 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
1003 | 1003 | $date = Api\DateTime::to($time, $date_format); |
1004 | 1004 | } |
1005 | 1005 | else |
1006 | 1006 | { |
1007 | - $date = $this->date2usertime((int)$date,$date_format); |
|
1007 | + $date = $this->date2usertime((int)$date, $date_format); |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | // same with the alarms |
1012 | 1012 | if (isset($event['alarm']) && is_array($event['alarm'])) |
1013 | 1013 | { |
1014 | - foreach($event['alarm'] as &$alarm) |
|
1014 | + foreach ($event['alarm'] as &$alarm) |
|
1015 | 1015 | { |
1016 | - $alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format); |
|
1016 | + $alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format); |
|
1017 | 1017 | } |
1018 | 1018 | } |
1019 | 1019 | } |
@@ -1026,11 +1026,11 @@ discard block |
||
1026 | 1026 | * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
1027 | 1027 | * @return mixed depending of $date_format |
1028 | 1028 | */ |
1029 | - function date2usertime($ts,$date_format='ts') |
|
1029 | + function date2usertime($ts, $date_format = 'ts') |
|
1030 | 1030 | { |
1031 | 1031 | if (empty($ts) || $date_format == 'server') return $ts; |
1032 | 1032 | |
1033 | - return Api\DateTime::server2user($ts,$date_format); |
|
1033 | + return Api\DateTime::server2user($ts, $date_format); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | * @param boolean $read_recurrence =false true: read the exception, not the series master (only for recur_date && $ids='<uid>'!) |
1046 | 1046 | * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found |
1047 | 1047 | */ |
1048 | - function read($ids,$date=null, $ignore_acl=False, $date_format='ts', $clear_private_infos_users=null, $read_recurrence=false) |
|
1048 | + function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null, $read_recurrence = false) |
|
1049 | 1049 | { |
1050 | 1050 | if (!$ids) return false; |
1051 | 1051 | |
@@ -1054,21 +1054,21 @@ discard block |
||
1054 | 1054 | $return = null; |
1055 | 1055 | |
1056 | 1056 | $check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ; |
1057 | - if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date))) |
|
1057 | + if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date))) |
|
1058 | 1058 | { |
1059 | 1059 | if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids || |
1060 | 1060 | self::$cached_event_date_format != $date_format || $read_recurrence || |
1061 | 1061 | self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date) |
1062 | 1062 | { |
1063 | - $events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0, $read_recurrence); |
|
1063 | + $events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0, $read_recurrence); |
|
1064 | 1064 | |
1065 | 1065 | if ($events) |
1066 | 1066 | { |
1067 | - $this->db2data($events,$date_format); |
|
1067 | + $this->db2data($events, $date_format); |
|
1068 | 1068 | |
1069 | 1069 | if (is_array($ids)) |
1070 | 1070 | { |
1071 | - $return =& $events; |
|
1071 | + $return = & $events; |
|
1072 | 1072 | } |
1073 | 1073 | else |
1074 | 1074 | { |
@@ -1084,13 +1084,13 @@ discard block |
||
1084 | 1084 | $return = self::$cached_event; |
1085 | 1085 | } |
1086 | 1086 | } |
1087 | - if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return)) |
|
1087 | + if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return)) |
|
1088 | 1088 | { |
1089 | 1089 | $this->clear_private_infos($return, (array)$clear_private_infos_users); |
1090 | 1090 | } |
1091 | 1091 | if ($this->debug && ($this->debug > 1 || $this->debug == 'read')) |
1092 | 1092 | { |
1093 | - $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return); |
|
1093 | + $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return); |
|
1094 | 1094 | } |
1095 | 1095 | return $return; |
1096 | 1096 | } |
@@ -1108,17 +1108,17 @@ discard block |
||
1108 | 1108 | * @param array $events where the repetions get inserted |
1109 | 1109 | * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
1110 | 1110 | */ |
1111 | - function insert_all_recurrences($event,$_start,$end,&$events) |
|
1111 | + function insert_all_recurrences($event, $_start, $end, &$events) |
|
1112 | 1112 | { |
1113 | - if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
1113 | + if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
1114 | 1114 | { |
1115 | - $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end); |
|
1115 | + $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end); |
|
1116 | 1116 | } |
1117 | 1117 | $end_in = $end; |
1118 | 1118 | |
1119 | 1119 | $start = $this->date2ts($_start); |
1120 | 1120 | $event_start_ts = $this->date2ts($event['start']); |
1121 | - $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
1121 | + $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
1122 | 1122 | |
1123 | 1123 | // if $end is before recur_enddate, use it instead |
1124 | 1124 | if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end)) |
@@ -1127,40 +1127,39 @@ discard block |
||
1127 | 1127 | // insert at least the event itself, if it's behind the horizont |
1128 | 1128 | $event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end; |
1129 | 1129 | } |
1130 | - $event['recur_enddate'] = is_a($event['recur_enddate'],'DateTime') ? |
|
1131 | - $event['recur_enddate'] : |
|
1132 | - new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
1130 | + $event['recur_enddate'] = is_a($event['recur_enddate'], 'DateTime') ? |
|
1131 | + $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
1133 | 1132 | |
1134 | 1133 | // unset exceptions, as we need to add them as recurrence too, but marked as exception |
1135 | 1134 | unset($event['recur_exception']); |
1136 | 1135 | // loop over all recurrences and insert them, if they are after $start |
1137 | - $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
1138 | - foreach($rrule as $time) |
|
1136 | + $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
1137 | + foreach ($rrule as $time) |
|
1139 | 1138 | { |
1140 | - $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
1141 | - if($event['whole_day']) |
|
1139 | + $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
1140 | + if ($event['whole_day']) |
|
1142 | 1141 | { |
1143 | 1142 | // All day events are processed in server timezone |
1144 | 1143 | $time->setServer(); |
1145 | - $time->setTime(0,0,0); |
|
1144 | + $time->setTime(0, 0, 0); |
|
1146 | 1145 | } |
1147 | - if (($ts = $this->date2ts($time)) < $start-$event_length) |
|
1146 | + if (($ts = $this->date2ts($time)) < $start - $event_length) |
|
1148 | 1147 | { |
1149 | 1148 | //echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n"; |
1150 | - continue; // to early or original event (returned by interator too) |
|
1149 | + continue; // to early or original event (returned by interator too) |
|
1151 | 1150 | } |
1152 | 1151 | |
1153 | 1152 | $ts_end = $ts + $event_length; |
1154 | 1153 | // adjust ts_end for whole day events in case it does not fit due to |
1155 | 1154 | // spans over summer/wintertime adjusted days |
1156 | - if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
1155 | + if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
1157 | 1156 | !($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59)) |
1158 | 1157 | { |
1159 | 1158 | $arr_end['hour'] = 23; |
1160 | 1159 | $arr_end['minute'] = 59; |
1161 | 1160 | $arr_end['second'] = 59; |
1162 | 1161 | $ts_end_guess = $this->date2ts($arr_end); |
1163 | - if($ts_end_guess - $ts_end > DAY_s/2) |
|
1162 | + if ($ts_end_guess - $ts_end > DAY_s / 2) |
|
1164 | 1163 | { |
1165 | 1164 | $ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future |
1166 | 1165 | } |
@@ -1174,11 +1173,11 @@ discard block |
||
1174 | 1173 | $event['end'] = $ts_end; |
1175 | 1174 | $events[] = $event; |
1176 | 1175 | } |
1177 | - if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
1176 | + if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
1178 | 1177 | { |
1179 | 1178 | $event['start'] = $event_start_ts; |
1180 | 1179 | $event['end'] = $event_start_ts + $event_length; |
1181 | - $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events); |
|
1180 | + $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events); |
|
1182 | 1181 | } |
1183 | 1182 | } |
1184 | 1183 | |
@@ -1189,18 +1188,18 @@ discard block |
||
1189 | 1188 | * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd |
1190 | 1189 | * @param int|string $date_ymd of the date of the event |
1191 | 1190 | */ |
1192 | - function add_adjusted_event(&$events,$event,$date_ymd) |
|
1191 | + function add_adjusted_event(&$events, $event, $date_ymd) |
|
1193 | 1192 | { |
1194 | 1193 | $event_in = $event; |
1195 | 1194 | // calculate the new start- and end-time |
1196 | 1195 | $length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']); |
1197 | 1196 | $event_start_arr = $this->date2array($event['start']); |
1198 | 1197 | |
1199 | - $date_arr = $this->date2array((string) $date_ymd); |
|
1198 | + $date_arr = $this->date2array((string)$date_ymd); |
|
1200 | 1199 | $date_arr['hour'] = $event_start_arr['hour']; |
1201 | 1200 | $date_arr['minute'] = $event_start_arr['minute']; |
1202 | 1201 | $date_arr['second'] = $event_start_arr['second']; |
1203 | - unset($date_arr['raw']); // else date2ts would use it |
|
1202 | + unset($date_arr['raw']); // else date2ts would use it |
|
1204 | 1203 | $event['start'] = $this->date2ts($date_arr); |
1205 | 1204 | $event['end'] = $event['start'] + $length_s; |
1206 | 1205 | |
@@ -1208,7 +1207,7 @@ discard block |
||
1208 | 1207 | |
1209 | 1208 | if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event')) |
1210 | 1209 | { |
1211 | - $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event); |
|
1210 | + $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event); |
|
1212 | 1211 | } |
1213 | 1212 | } |
1214 | 1213 | |
@@ -1232,22 +1231,22 @@ discard block |
||
1232 | 1231 | { |
1233 | 1232 | $info = array( |
1234 | 1233 | 'res_id' => $uid, |
1235 | - 'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'), |
|
1236 | - 'name' => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' . |
|
1237 | - $GLOBALS['egw']->accounts->id2name($uid,'account_lastname')), |
|
1234 | + 'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'), |
|
1235 | + 'name' => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
|
1236 | + $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')), |
|
1238 | 1237 | 'type' => $GLOBALS['egw']->accounts->get_type($uid), |
1239 | 1238 | 'app' => 'accounts', |
1240 | 1239 | ); |
1241 | 1240 | } |
1242 | 1241 | else |
1243 | 1242 | { |
1244 | - list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false; |
|
1243 | + list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false; |
|
1245 | 1244 | if ($info) |
1246 | 1245 | { |
1247 | 1246 | $info['type'] = $uid[0]; |
1248 | 1247 | if (!$info['email'] && $info['responsible']) |
1249 | 1248 | { |
1250 | - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); |
|
1249 | + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email'); |
|
1251 | 1250 | } |
1252 | 1251 | $info['app'] = $this->resources[$uid[0]]['app']; |
1253 | 1252 | } |
@@ -1256,7 +1255,7 @@ discard block |
||
1256 | 1255 | } |
1257 | 1256 | if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info')) |
1258 | 1257 | { |
1259 | - $this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]); |
|
1258 | + $this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]); |
|
1260 | 1259 | } |
1261 | 1260 | return $res_info_cache[$uid]; |
1262 | 1261 | } |
@@ -1277,7 +1276,7 @@ discard block |
||
1277 | 1276 | * @param int $user =null for which user to check, default current user |
1278 | 1277 | * @return boolean true permission granted, false for permission denied or null if event not found |
1279 | 1278 | */ |
1280 | - function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
|
1279 | + function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null) |
|
1281 | 1280 | { |
1282 | 1281 | if (!$user) $user = $this->user; |
1283 | 1282 | if ($user == $this->user) |
@@ -1286,13 +1285,13 @@ discard block |
||
1286 | 1285 | } |
1287 | 1286 | else |
1288 | 1287 | { |
1289 | - $grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user); |
|
1288 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
1290 | 1289 | } |
1291 | 1290 | |
1292 | 1291 | if ($other && !is_numeric($other)) |
1293 | 1292 | { |
1294 | 1293 | $resource = $this->resource_info($other); |
1295 | - return $needed & $resource['rights']; |
|
1294 | + return $needed&$resource['rights']; |
|
1296 | 1295 | } |
1297 | 1296 | if (is_int($event) && $event == 0) |
1298 | 1297 | { |
@@ -1302,15 +1301,15 @@ discard block |
||
1302 | 1301 | { |
1303 | 1302 | if (!is_array($event)) |
1304 | 1303 | { |
1305 | - $event = $this->read($event,$date_to_read,true,$date_format); // = no ACL check !!! |
|
1304 | + $event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!! |
|
1306 | 1305 | } |
1307 | 1306 | if (!is_array($event)) |
1308 | 1307 | { |
1309 | 1308 | if ($this->xmlrpc) |
1310 | 1309 | { |
1311 | - $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']); |
|
1310 | + $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']); |
|
1312 | 1311 | } |
1313 | - return null; // event not found |
|
1312 | + return null; // event not found |
|
1314 | 1313 | } |
1315 | 1314 | $owner = $event['owner']; |
1316 | 1315 | $private = !$event['public']; |
@@ -1318,7 +1317,7 @@ discard block |
||
1318 | 1317 | $grant = $grants[$owner]; |
1319 | 1318 | |
1320 | 1319 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
1321 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
1320 | + if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
1322 | 1321 | |
1323 | 1322 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
1324 | 1323 | { |
@@ -1327,15 +1326,15 @@ discard block |
||
1327 | 1326 | // |
1328 | 1327 | if ($event['participants'] && is_array($event['participants'])) |
1329 | 1328 | { |
1330 | - foreach(array_keys($event['participants']) as $uid) |
|
1329 | + foreach (array_keys($event['participants']) as $uid) |
|
1331 | 1330 | { |
1332 | - if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true))) |
|
1331 | + if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true))) |
|
1333 | 1332 | { |
1334 | 1333 | // if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant |
1335 | - $grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT; |
|
1334 | + $grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT; |
|
1336 | 1335 | break; |
1337 | 1336 | } |
1338 | - elseif ($grants[$uid] & Acl::READ) |
|
1337 | + elseif ($grants[$uid]&Acl::READ) |
|
1339 | 1338 | { |
1340 | 1339 | // if we have a READ grant from a participant, we dont give an implicit privat grant too |
1341 | 1340 | $grant |= Acl::READ; |
@@ -1354,12 +1353,12 @@ discard block |
||
1354 | 1353 | } |
1355 | 1354 | if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD) |
1356 | 1355 | { |
1357 | - $access = False; // a group can't be the owner of an event |
|
1356 | + $access = False; // a group can't be the owner of an event |
|
1358 | 1357 | } |
1359 | 1358 | else |
1360 | 1359 | { |
1361 | - $access = $user == $owner || $grant & $needed |
|
1362 | - && ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT); |
|
1360 | + $access = $user == $owner || $grant&$needed |
|
1361 | + && ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT); |
|
1363 | 1362 | } |
1364 | 1363 | // do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled |
1365 | 1364 | if ($access && $needed == Acl::DELETE && $event['deleted'] && |
@@ -1370,7 +1369,7 @@ discard block |
||
1370 | 1369 | } |
1371 | 1370 | if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms')) |
1372 | 1371 | { |
1373 | - $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access); |
|
1372 | + $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access); |
|
1374 | 1373 | } |
1375 | 1374 | //error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access)); |
1376 | 1375 | return $access; |
@@ -1385,9 +1384,9 @@ discard block |
||
1385 | 1384 | * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' |
1386 | 1385 | * @param boolean $user2server =False conversion between user- and server-time; default False == Off |
1387 | 1386 | */ |
1388 | - static function date2ts($date,$user2server=False) |
|
1387 | + static function date2ts($date, $user2server = False) |
|
1389 | 1388 | { |
1390 | - return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts'); |
|
1389 | + return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts'); |
|
1391 | 1390 | } |
1392 | 1391 | |
1393 | 1392 | /** |
@@ -1397,9 +1396,9 @@ discard block |
||
1397 | 1396 | * @param boolean $server2user conversation between user- and server-time default False == Off |
1398 | 1397 | * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string) |
1399 | 1398 | */ |
1400 | - static function date2array($date,$server2user=False) |
|
1399 | + static function date2array($date, $server2user = False) |
|
1401 | 1400 | { |
1402 | - return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array'); |
|
1401 | + return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array'); |
|
1403 | 1402 | } |
1404 | 1403 | |
1405 | 1404 | /** |
@@ -1410,9 +1409,9 @@ discard block |
||
1410 | 1409 | * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100) |
1411 | 1410 | * @return string date formatted according to $format |
1412 | 1411 | */ |
1413 | - static function date2string($date,$server2user=False,$format='Ymd') |
|
1412 | + static function date2string($date, $server2user = False, $format = 'Ymd') |
|
1414 | 1413 | { |
1415 | - return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format); |
|
1414 | + return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format); |
|
1416 | 1415 | } |
1417 | 1416 | |
1418 | 1417 | /** |
@@ -1422,9 +1421,9 @@ discard block |
||
1422 | 1421 | * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only |
1423 | 1422 | * @return string the formated date (incl. time) |
1424 | 1423 | */ |
1425 | - static function format_date($date,$format='') |
|
1424 | + static function format_date($date, $format = '') |
|
1426 | 1425 | { |
1427 | - return Api\DateTime::to($date,$format); |
|
1426 | + return Api\DateTime::to($date, $format); |
|
1428 | 1427 | } |
1429 | 1428 | |
1430 | 1429 | /** |
@@ -1446,7 +1445,7 @@ discard block |
||
1446 | 1445 | * @param mixed $param a variable number of parameters, to be inserted in $msg |
1447 | 1446 | * arrays get serialized with print_r() ! |
1448 | 1447 | */ |
1449 | - static function debug_message($msg,$backtrace=True) |
|
1448 | + static function debug_message($msg, $backtrace = True) |
|
1450 | 1449 | { |
1451 | 1450 | static $acl2string = array( |
1452 | 1451 | 0 => 'ACL-UNKNOWN', |
@@ -1457,22 +1456,22 @@ discard block |
||
1457 | 1456 | Acl::PRIVAT => 'ACL_PRIVATE', |
1458 | 1457 | self::ACL_FREEBUSY => 'ACL_FREEBUSY', |
1459 | 1458 | ); |
1460 | - for($i = 2; $i < func_num_args(); ++$i) |
|
1459 | + for ($i = 2; $i < func_num_args(); ++$i) |
|
1461 | 1460 | { |
1462 | 1461 | $param = func_get_arg($i); |
1463 | 1462 | |
1464 | 1463 | if (is_null($param)) |
1465 | 1464 | { |
1466 | - $param='NULL'; |
|
1465 | + $param = 'NULL'; |
|
1467 | 1466 | } |
1468 | 1467 | else |
1469 | 1468 | { |
1470 | - switch(gettype($param)) |
|
1469 | + switch (gettype($param)) |
|
1471 | 1470 | { |
1472 | 1471 | case 'string': |
1473 | - if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER) |
|
1472 | + if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER) |
|
1474 | 1473 | { |
1475 | - $param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER)); |
|
1474 | + $param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER)); |
|
1476 | 1475 | $param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)"; |
1477 | 1476 | } |
1478 | 1477 | else |
@@ -1495,11 +1494,11 @@ discard block |
||
1495 | 1494 | $param = $param ? 'True' : 'False'; |
1496 | 1495 | break; |
1497 | 1496 | case 'integer': |
1498 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
1497 | + if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)"; |
|
1499 | 1498 | break; |
1500 | 1499 | } |
1501 | 1500 | } |
1502 | - $msg = str_replace('%'.($i-1),$param,$msg); |
|
1501 | + $msg = str_replace('%'.($i - 1), $param, $msg); |
|
1503 | 1502 | } |
1504 | 1503 | error_log($msg); |
1505 | 1504 | if ($backtrace) error_log(function_backtrace(1)); |
@@ -1514,7 +1513,7 @@ discard block |
||
1514 | 1513 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
1515 | 1514 | * @return string with formated date |
1516 | 1515 | */ |
1517 | - function long_date($_first,$last=0,$display_time=false,$display_day=false) |
|
1516 | + function long_date($_first, $last = 0, $display_time = false, $display_day = false) |
|
1518 | 1517 | { |
1519 | 1518 | $first = $this->date2array($_first); |
1520 | 1519 | if ($last) |
@@ -1529,27 +1528,27 @@ discard block |
||
1529 | 1528 | |
1530 | 1529 | if ($display_day) |
1531 | 1530 | { |
1532 | - $range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
1531 | + $range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
1533 | 1532 | } |
1534 | 1533 | for ($i = 0; $i < 5; $i += 2) |
1535 | 1534 | { |
1536 | - switch($datefmt[$i]) |
|
1535 | + switch ($datefmt[$i]) |
|
1537 | 1536 | { |
1538 | 1537 | case 'd': |
1539 | - $range .= $first['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
1538 | + $range .= $first['day'].($datefmt[1] == '.' ? '.' : ''); |
|
1540 | 1539 | if ($first['month'] != $last['month'] || $first['year'] != $last['year']) |
1541 | 1540 | { |
1542 | 1541 | if (!$month_before_day) |
1543 | 1542 | { |
1544 | - $range .= ' '.lang(strftime('%B',$first['raw'])); |
|
1543 | + $range .= ' '.lang(strftime('%B', $first['raw'])); |
|
1545 | 1544 | } |
1546 | 1545 | if ($first['year'] != $last['year'] && $datefmt[0] != 'Y') |
1547 | 1546 | { |
1548 | - $range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year']; |
|
1547 | + $range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year']; |
|
1549 | 1548 | } |
1550 | 1549 | if ($display_time) |
1551 | 1550 | { |
1552 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
1551 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
1553 | 1552 | } |
1554 | 1553 | if (!$last) |
1555 | 1554 | { |
@@ -1559,43 +1558,43 @@ discard block |
||
1559 | 1558 | |
1560 | 1559 | if ($first['year'] != $last['year'] && $datefmt[0] == 'Y') |
1561 | 1560 | { |
1562 | - $range .= $last['year'] . ', '; |
|
1561 | + $range .= $last['year'].', '; |
|
1563 | 1562 | } |
1564 | 1563 | |
1565 | 1564 | if ($month_before_day) |
1566 | 1565 | { |
1567 | - $range .= lang(strftime('%B',$last['raw'])); |
|
1566 | + $range .= lang(strftime('%B', $last['raw'])); |
|
1568 | 1567 | } |
1569 | 1568 | } |
1570 | 1569 | else |
1571 | 1570 | { |
1572 | 1571 | if ($display_time) |
1573 | 1572 | { |
1574 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
1573 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
1575 | 1574 | } |
1576 | 1575 | $range .= ' - '; |
1577 | 1576 | } |
1578 | - $range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
1577 | + $range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : ''); |
|
1579 | 1578 | break; |
1580 | 1579 | case 'm': |
1581 | 1580 | case 'M': |
1582 | - $range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' '; |
|
1581 | + $range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' '; |
|
1583 | 1582 | break; |
1584 | 1583 | case 'Y': |
1585 | 1584 | if ($datefmt[0] != 'm') |
1586 | 1585 | { |
1587 | - $range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
1586 | + $range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
1588 | 1587 | } |
1589 | 1588 | break; |
1590 | 1589 | } |
1591 | 1590 | } |
1592 | 1591 | if ($display_time && $last) |
1593 | 1592 | { |
1594 | - $range .= ' '.adodb_date($timefmt,$last['raw']); |
|
1593 | + $range .= ' '.adodb_date($timefmt, $last['raw']); |
|
1595 | 1594 | } |
1596 | 1595 | if ($datefmt[4] == 'Y' && $datefmt[0] == 'm') |
1597 | 1596 | { |
1598 | - $range .= ', ' . $last['year']; |
|
1597 | + $range .= ', '.$last['year']; |
|
1599 | 1598 | } |
1600 | 1599 | return $range; |
1601 | 1600 | } |
@@ -1607,25 +1606,25 @@ discard block |
||
1607 | 1606 | * @param int $end_m end time in minutes since 0h |
1608 | 1607 | * @param boolean $both =false display the end-time too, duration is always displayed |
1609 | 1608 | */ |
1610 | - function timespan($start_m,$end_m,$both=false) |
|
1609 | + function timespan($start_m, $end_m, $both = false) |
|
1611 | 1610 | { |
1612 | 1611 | $duration = $end_m - $start_m; |
1613 | - if ($end_m == 24*60-1) ++$duration; |
|
1614 | - $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
1612 | + if ($end_m == 24 * 60 - 1) ++$duration; |
|
1613 | + $duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
1615 | 1614 | |
1616 | - $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
|
1615 | + $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false); |
|
1617 | 1616 | |
1618 | 1617 | if ($both) // end-time too |
1619 | 1618 | { |
1620 | - $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
|
1619 | + $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false); |
|
1621 | 1620 | // dont double am/pm if they are the same in both times |
1622 | - if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
|
1621 | + if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2)) |
|
1623 | 1622 | { |
1624 | - $timespan = str_replace($t,substr($t,0,-3),$timespan); |
|
1623 | + $timespan = str_replace($t, substr($t, 0, -3), $timespan); |
|
1625 | 1624 | } |
1626 | 1625 | $timespan .= ':'; |
1627 | 1626 | } |
1628 | - return $timespan . ' ' . $duration; |
|
1627 | + return $timespan.' '.$duration; |
|
1629 | 1628 | } |
1630 | 1629 | |
1631 | 1630 | /** |
@@ -1636,7 +1635,7 @@ discard block |
||
1636 | 1635 | * @param boolean $append_email =false append email (Name <email>) |
1637 | 1636 | * @return string with name |
1638 | 1637 | */ |
1639 | - function participant_name($id,$use_type=false, $append_email=false) |
|
1638 | + function participant_name($id, $use_type = false, $append_email = false) |
|
1640 | 1639 | { |
1641 | 1640 | static $id2lid = array(); |
1642 | 1641 | static $id2email = array(); |
@@ -1657,7 +1656,7 @@ discard block |
||
1657 | 1656 | else |
1658 | 1657 | { |
1659 | 1658 | $id2lid[$id] = Api\Accounts::username($id); |
1660 | - $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email'); |
|
1659 | + $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email'); |
|
1661 | 1660 | } |
1662 | 1661 | } |
1663 | 1662 | return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : ''); |
@@ -1671,37 +1670,37 @@ discard block |
||
1671 | 1670 | * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
1672 | 1671 | * @return array with id / names with status pairs |
1673 | 1672 | */ |
1674 | - function participants($event,$long_status=false,$show_group_invitation=false) |
|
1673 | + function participants($event, $long_status = false, $show_group_invitation = false) |
|
1675 | 1674 | { |
1676 | 1675 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
1677 | 1676 | $names = array(); |
1678 | - foreach((array)$event['participants'] as $id => $status) |
|
1677 | + foreach ((array)$event['participants'] as $id => $status) |
|
1679 | 1678 | { |
1680 | 1679 | if (!is_string($status)) continue; |
1681 | 1680 | $quantity = $role = null; |
1682 | - calendar_so::split_status($status,$quantity,$role); |
|
1681 | + calendar_so::split_status($status, $quantity, $role); |
|
1683 | 1682 | |
1684 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
1683 | + if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
1685 | 1684 | |
1686 | 1685 | $lang_status = lang($this->verbose_status[$status]); |
1687 | 1686 | if (!$long_status) |
1688 | 1687 | { |
1689 | - switch($status[0]) |
|
1688 | + switch ($status[0]) |
|
1690 | 1689 | { |
1691 | 1690 | case 'A': // accepted |
1692 | - $status = Api\Html::image('calendar','accepted',$lang_status); |
|
1691 | + $status = Api\Html::image('calendar', 'accepted', $lang_status); |
|
1693 | 1692 | break; |
1694 | 1693 | case 'R': // rejected |
1695 | - $status = Api\Html::image('calendar','rejected',$lang_status); |
|
1694 | + $status = Api\Html::image('calendar', 'rejected', $lang_status); |
|
1696 | 1695 | break; |
1697 | 1696 | case 'T': // tentative |
1698 | - $status = Api\Html::image('calendar','tentative',$lang_status); |
|
1697 | + $status = Api\Html::image('calendar', 'tentative', $lang_status); |
|
1699 | 1698 | break; |
1700 | 1699 | case 'U': // no response = unknown |
1701 | - $status = Api\Html::image('calendar','needs-action',$lang_status); |
|
1700 | + $status = Api\Html::image('calendar', 'needs-action', $lang_status); |
|
1702 | 1701 | break; |
1703 | 1702 | case 'D': // delegated |
1704 | - $status = Api\Html::image('calendar','forward',$lang_status); |
|
1703 | + $status = Api\Html::image('calendar', 'forward', $lang_status); |
|
1705 | 1704 | break; |
1706 | 1705 | case 'G': // group invitation |
1707 | 1706 | // Todo: Image, seems not to be used |
@@ -1723,13 +1722,13 @@ discard block |
||
1723 | 1722 | $role = lang($this->roles[$role]); |
1724 | 1723 | } |
1725 | 1724 | // allow to use cats as roles (beside regular iCal ones) |
1726 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
1725 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
1727 | 1726 | { |
1728 | 1727 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
1729 | 1728 | } |
1730 | 1729 | else |
1731 | 1730 | { |
1732 | - $role = lang(str_replace('X-','',$role)); |
|
1731 | + $role = lang(str_replace('X-', '', $role)); |
|
1733 | 1732 | } |
1734 | 1733 | $names[$id] .= ' '.$role; |
1735 | 1734 | } |
@@ -1746,13 +1745,13 @@ discard block |
||
1746 | 1745 | * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
1747 | 1746 | * @return array with id / names |
1748 | 1747 | */ |
1749 | - function categories($category,&$color) |
|
1748 | + function categories($category, &$color) |
|
1750 | 1749 | { |
1751 | 1750 | static $id2cat = array(); |
1752 | 1751 | $cats = array(); |
1753 | 1752 | $color = 0; |
1754 | 1753 | |
1755 | - foreach(explode(',',$category) as $cat_id) |
|
1754 | + foreach (explode(',', $category) as $cat_id) |
|
1756 | 1755 | { |
1757 | 1756 | if (!$cat_id) continue; |
1758 | 1757 | |
@@ -1767,7 +1766,7 @@ discard block |
||
1767 | 1766 | { |
1768 | 1767 | $color = $cat['data']['color']; |
1769 | 1768 | } |
1770 | - elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
1769 | + elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
1771 | 1770 | { |
1772 | 1771 | $color = $parts[1]; |
1773 | 1772 | } |
@@ -1779,12 +1778,12 @@ discard block |
||
1779 | 1778 | /** |
1780 | 1779 | * This is called only by list_cals(). It was moved here to remove fatal error in php5 beta4 |
1781 | 1780 | */ |
1782 | - private static function _list_cals_add($id,&$users,&$groups) |
|
1781 | + private static function _list_cals_add($id, &$users, &$groups) |
|
1783 | 1782 | { |
1784 | 1783 | $name = Api\Accounts::username($id); |
1785 | 1784 | if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id))) |
1786 | 1785 | { |
1787 | - return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
1786 | + return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
1788 | 1787 | } |
1789 | 1788 | if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g') |
1790 | 1789 | { |
@@ -1796,7 +1795,7 @@ discard block |
||
1796 | 1795 | } |
1797 | 1796 | $arr[$id] = array( |
1798 | 1797 | 'grantor' => $id, |
1799 | - 'value' => ($type == 'g' ? 'g_' : '') . $id, |
|
1798 | + 'value' => ($type == 'g' ? 'g_' : '').$id, |
|
1800 | 1799 | 'name' => $name, |
1801 | 1800 | 'sname' => $egw_name |
1802 | 1801 | ); |
@@ -1818,26 +1817,26 @@ discard block |
||
1818 | 1817 | * @param int $user account_id of user to generate list for |
1819 | 1818 | * @param array $grants =null calendar grants from user, or null to query them from acl class |
1820 | 1819 | */ |
1821 | - public static function list_calendars($user, array $grants=null) |
|
1820 | + public static function list_calendars($user, array $grants = null) |
|
1822 | 1821 | { |
1823 | 1822 | if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
1824 | 1823 | |
1825 | 1824 | $users = $groups = array(); |
1826 | - foreach(array_keys($grants) as $id) |
|
1825 | + foreach (array_keys($grants) as $id) |
|
1827 | 1826 | { |
1828 | - self::_list_cals_add($id,$users,$groups); |
|
1827 | + self::_list_cals_add($id, $users, $groups); |
|
1829 | 1828 | } |
1830 | 1829 | if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true))) |
1831 | 1830 | { |
1832 | - foreach($memberships as $group) |
|
1831 | + foreach ($memberships as $group) |
|
1833 | 1832 | { |
1834 | - self::_list_cals_add($group,$users,$groups); |
|
1833 | + self::_list_cals_add($group, $users, $groups); |
|
1835 | 1834 | |
1836 | - if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar'))) |
|
1835 | + if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar'))) |
|
1837 | 1836 | { |
1838 | - foreach($account_perms as $id) |
|
1837 | + foreach ($account_perms as $id) |
|
1839 | 1838 | { |
1840 | - self::_list_cals_add($id,$users,$groups); |
|
1839 | + self::_list_cals_add($id, $users, $groups); |
|
1841 | 1840 | } |
1842 | 1841 | } |
1843 | 1842 | } |
@@ -1845,7 +1844,7 @@ discard block |
||
1845 | 1844 | usort($users, array(__CLASS__, 'name_cmp')); |
1846 | 1845 | usort($groups, array(__CLASS__, 'name_cmp')); |
1847 | 1846 | |
1848 | - return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
1847 | + return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
1849 | 1848 | } |
1850 | 1849 | |
1851 | 1850 | /** |
@@ -1885,43 +1884,42 @@ discard block |
||
1885 | 1884 | * month: numerical month |
1886 | 1885 | * occurence: numerical year or 0 for every year |
1887 | 1886 | */ |
1888 | - function read_holidays($year=0) |
|
1887 | + function read_holidays($year = 0) |
|
1889 | 1888 | { |
1890 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
1889 | + if (!$year) $year = (int)date('Y', $this->now_su); |
|
1891 | 1890 | |
1892 | 1891 | $holidays = calendar_holidays::read( |
1893 | 1892 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
1894 | - $GLOBALS['egw_info']['server']['ical_holiday_url'] : |
|
1895 | - $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
1893 | + $GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
1896 | 1894 | |
1897 | 1895 | // search for birthdays |
1898 | 1896 | if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') |
1899 | 1897 | { |
1900 | 1898 | $contacts = new Api\Contacts(); |
1901 | - foreach($contacts->get_addressbooks() as $owner => $name) |
|
1899 | + foreach ($contacts->get_addressbooks() as $owner => $name) |
|
1902 | 1900 | { |
1903 | 1901 | $birthdays = $contacts->read_birthdays($owner, $year); |
1904 | 1902 | |
1905 | 1903 | // Add them in, being careful not to override any existing |
1906 | - foreach($birthdays as $date => $bdays) |
|
1904 | + foreach ($birthdays as $date => $bdays) |
|
1907 | 1905 | { |
1908 | - if(!array_key_exists($date, $holidays)) |
|
1906 | + if (!array_key_exists($date, $holidays)) |
|
1909 | 1907 | { |
1910 | 1908 | $holidays[$date] = array(); |
1911 | 1909 | } |
1912 | - foreach($bdays as $birthday) |
|
1910 | + foreach ($bdays as $birthday) |
|
1913 | 1911 | { |
1914 | 1912 | // Skip if name / date are already there - duplicate contacts |
1915 | - if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue; |
|
1913 | + if (in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue; |
|
1916 | 1914 | $holidays[$date][] = $birthday; |
1917 | 1915 | } |
1918 | 1916 | } |
1919 | 1917 | } |
1920 | 1918 | } |
1921 | 1919 | |
1922 | - if ((int) $this->debug >= 2 || $this->debug == 'read_holidays') |
|
1920 | + if ((int)$this->debug >= 2 || $this->debug == 'read_holidays') |
|
1923 | 1921 | { |
1924 | - $this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$holidays); |
|
1922 | + $this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $holidays); |
|
1925 | 1923 | } |
1926 | 1924 | return $holidays; |
1927 | 1925 | } |
@@ -1932,10 +1930,10 @@ discard block |
||
1932 | 1930 | * @param type $event |
1933 | 1931 | * @return array array of selected calendar fields |
1934 | 1932 | */ |
1935 | - public static function get_link_options ($event = array()) |
|
1933 | + public static function get_link_options($event = array()) |
|
1936 | 1934 | { |
1937 | - unset($event); // not used, but required by function signature |
|
1938 | - $options = array ( |
|
1935 | + unset($event); // not used, but required by function signature |
|
1936 | + $options = array( |
|
1939 | 1937 | 'end' => lang('End date'), |
1940 | 1938 | 'id' => lang('ID'), |
1941 | 1939 | 'owner' => lang('Event owner'), |
@@ -1962,7 +1960,7 @@ discard block |
||
1962 | 1960 | list($id, $recur) = explode('-', $event, 2); |
1963 | 1961 | $event = $this->read($id, $recur); |
1964 | 1962 | } |
1965 | - else if (!is_array($event) && (int) $event > 0) |
|
1963 | + else if (!is_array($event) && (int)$event > 0) |
|
1966 | 1964 | { |
1967 | 1965 | $event = $this->read($event); |
1968 | 1966 | } |
@@ -1970,7 +1968,7 @@ discard block |
||
1970 | 1968 | { |
1971 | 1969 | return $event; |
1972 | 1970 | } |
1973 | - $type = explode(',',$this->cal_prefs['link_title']); |
|
1971 | + $type = explode(',', $this->cal_prefs['link_title']); |
|
1974 | 1972 | if (is_array($type)) |
1975 | 1973 | { |
1976 | 1974 | foreach ($type as &$val) |
@@ -1996,10 +1994,10 @@ discard block |
||
1996 | 1994 | $extra_fields [] = $event[$val]; |
1997 | 1995 | } |
1998 | 1996 | } |
1999 | - $str_fields = implode(', ',$extra_fields); |
|
2000 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
1997 | + $str_fields = implode(', ', $extra_fields); |
|
1998 | + if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : ''); |
|
2001 | 1999 | } |
2002 | - return $this->format_date($event['start']) . ': ' . $event['title']; |
|
2000 | + return $this->format_date($event['start']).': '.$event['title']; |
|
2003 | 2001 | } |
2004 | 2002 | |
2005 | 2003 | /** |
@@ -2018,10 +2016,10 @@ discard block |
||
2018 | 2016 | 'offset' => $options['start'], |
2019 | 2017 | 'order' => 'cal_start DESC', |
2020 | 2018 | ); |
2021 | - if($options['num_rows']) { |
|
2019 | + if ($options['num_rows']) { |
|
2022 | 2020 | $query['num_rows'] = $options['num_rows']; |
2023 | 2021 | } |
2024 | - foreach((array) $this->search($query) as $event) |
|
2022 | + foreach ((array)$this->search($query) as $event) |
|
2025 | 2023 | { |
2026 | 2024 | $result[$event['id']] = $this->link_title($event); |
2027 | 2025 | } |
@@ -2038,11 +2036,11 @@ discard block |
||
2038 | 2036 | * @param int $user =null for which user to check, default current user |
2039 | 2037 | * @return boolean true if access is granted or false otherwise |
2040 | 2038 | */ |
2041 | - function file_access($id,$check,$rel_path,$user=null) |
|
2039 | + function file_access($id, $check, $rel_path, $user = null) |
|
2042 | 2040 | { |
2043 | - unset($rel_path); // not used, but required by function signature |
|
2041 | + unset($rel_path); // not used, but required by function signature |
|
2044 | 2042 | |
2045 | - return $this->check_perms($check,$id,0,'ts',null,$user); |
|
2043 | + return $this->check_perms($check, $id, 0, 'ts', null, $user); |
|
2046 | 2044 | } |
2047 | 2045 | |
2048 | 2046 | /** |
@@ -2058,36 +2056,36 @@ discard block |
||
2058 | 2056 | } |
2059 | 2057 | Api\Cache::setSession('calendar', 'default_prefs_set', 'set'); |
2060 | 2058 | |
2061 | - $default_prefs =& $GLOBALS['egw']->preferences->default['calendar']; |
|
2062 | - $forced_prefs =& $GLOBALS['egw']->preferences->forced['calendar']; |
|
2059 | + $default_prefs = & $GLOBALS['egw']->preferences->default['calendar']; |
|
2060 | + $forced_prefs = & $GLOBALS['egw']->preferences->forced['calendar']; |
|
2063 | 2061 | |
2064 | - $subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
2062 | + $subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
2065 | 2063 | $values = array( |
2066 | - 'notifyAdded' => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'), |
|
2067 | - 'notifyCanceled' => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'), |
|
2068 | - 'notifyModified' => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'), |
|
2069 | - 'notifyDisinvited'=> $subject . lang ('You have been uninvited from the meeting at %1','$$startdate$$'), |
|
2070 | - 'notifyResponse' => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'), |
|
2071 | - 'notifyAlarm' => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'), |
|
2064 | + 'notifyAdded' => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'), |
|
2065 | + 'notifyCanceled' => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'), |
|
2066 | + 'notifyModified' => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'), |
|
2067 | + 'notifyDisinvited'=> $subject.lang('You have been uninvited from the meeting at %1', '$$startdate$$'), |
|
2068 | + 'notifyResponse' => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'), |
|
2069 | + 'notifyAlarm' => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'), |
|
2072 | 2070 | 'interval' => 30, |
2073 | 2071 | ); |
2074 | - foreach($values as $var => $default) |
|
2072 | + foreach ($values as $var => $default) |
|
2075 | 2073 | { |
2076 | - $type = substr($var,0,6) == 'notify' ? 'forced' : 'default'; |
|
2074 | + $type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default'; |
|
2077 | 2075 | |
2078 | 2076 | // only set, if neither default nor forced pref exists |
2079 | 2077 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
2080 | 2078 | { |
2081 | - $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
|
2082 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
2079 | + $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too |
|
2080 | + if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced'); |
|
2083 | 2081 | $this->cal_prefs[$var] = $default; |
2084 | 2082 | $need_save = True; |
2085 | 2083 | } |
2086 | 2084 | } |
2087 | 2085 | if ($need_save) |
2088 | 2086 | { |
2089 | - $GLOBALS['egw']->preferences->save_repository(False,'default'); |
|
2090 | - $GLOBALS['egw']->preferences->save_repository(False,'forced'); |
|
2087 | + $GLOBALS['egw']->preferences->save_repository(False, 'default'); |
|
2088 | + $GLOBALS['egw']->preferences->save_repository(False, 'forced'); |
|
2091 | 2089 | } |
2092 | 2090 | } |
2093 | 2091 | |
@@ -2097,7 +2095,7 @@ discard block |
||
2097 | 2095 | * @param int|string $user account_id or account_lid |
2098 | 2096 | * @param string $pw =null password |
2099 | 2097 | */ |
2100 | - static function freebusy_url($user='',$pw=null) |
|
2098 | + static function freebusy_url($user = '', $pw = null) |
|
2101 | 2099 | { |
2102 | 2100 | if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
2103 | 2101 | |
@@ -2110,8 +2108,8 @@ discard block |
||
2110 | 2108 | elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2) |
2111 | 2109 | { |
2112 | 2110 | $credentials = $GLOBALS['egw_info']['user']['account_lid'] |
2113 | - . ':' . $GLOBALS['egw_info']['user']['passwd']; |
|
2114 | - $credentials = '&cred=' . base64_encode($credentials); |
|
2111 | + . ':'.$GLOBALS['egw_info']['user']['passwd']; |
|
2112 | + $credentials = '&cred='.base64_encode($credentials); |
|
2115 | 2113 | } |
2116 | 2114 | return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ? |
2117 | 2115 | ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : ''). |
@@ -2143,11 +2141,11 @@ discard block |
||
2143 | 2141 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
2144 | 2142 | * @return string|boolean string with etag or false |
2145 | 2143 | */ |
2146 | - function get_etag($entry, &$schedule_tag=null) |
|
2144 | + function get_etag($entry, &$schedule_tag = null) |
|
2147 | 2145 | { |
2148 | 2146 | if (!is_array($entry)) |
2149 | 2147 | { |
2150 | - list($id,$recur_date) = explode(':',$entry); |
|
2148 | + list($id, $recur_date) = explode(':', $entry); |
|
2151 | 2149 | $entry = $this->read($id, $recur_date, true, 'server'); |
2152 | 2150 | } |
2153 | 2151 | $etag = $schedule_tag = $entry['id'].':'.$entry['etag']; |
@@ -2165,15 +2163,15 @@ discard block |
||
2165 | 2163 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
2166 | 2164 | * @return integer |
2167 | 2165 | */ |
2168 | - public function get_ctag($user, $filter='owner', $master_only=false) |
|
2166 | + public function get_ctag($user, $filter = 'owner', $master_only = false) |
|
2169 | 2167 | { |
2170 | 2168 | if ($this->debug > 1) $startime = microtime(true); |
2171 | 2169 | |
2172 | 2170 | // resolve users to add memberships for users and members for groups |
2173 | 2171 | $users = $this->resolve_users($user); |
2174 | - $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
2172 | + $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
2175 | 2173 | |
2176 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
2174 | + if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs"); |
|
2177 | 2175 | return $ctag; |
2178 | 2176 | } |
2179 | 2177 | |
@@ -2193,7 +2191,7 @@ discard block |
||
2193 | 2191 | |
2194 | 2192 | $content = array( |
2195 | 2193 | 'info_cat' => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']), |
2196 | - 'info_priority' => $calendar['priority'] , |
|
2194 | + 'info_priority' => $calendar['priority'], |
|
2197 | 2195 | 'info_public' => $calendar['public'] != 'private', |
2198 | 2196 | 'info_subject' => $calendar['title'], |
2199 | 2197 | 'info_des' => $calendar['description'], |
@@ -2208,7 +2206,7 @@ discard block |
||
2208 | 2206 | $content['link_app'][] = $calendar['info_link']['app']; |
2209 | 2207 | $content['link_id'][] = $calendar['info_link']['id']; |
2210 | 2208 | // Copy claendar's links |
2211 | - foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link) |
|
2209 | + foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link) |
|
2212 | 2210 | { |
2213 | 2211 | if ($link['app'] != Link::VFS_APPNAME) |
2214 | 2212 | { |
@@ -2221,7 +2219,7 @@ discard block |
||
2221 | 2219 | } |
2222 | 2220 | } |
2223 | 2221 | // Copy same custom fields |
2224 | - foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
2222 | + foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
2225 | 2223 | { |
2226 | 2224 | if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
2227 | 2225 | } |
@@ -2239,20 +2237,20 @@ discard block |
||
2239 | 2237 | function timesheet_set($data) |
2240 | 2238 | { |
2241 | 2239 | $set = array(); |
2242 | - list($id,$recurrence) = explode(':',$data['id']); |
|
2243 | - if ((int)$id && ($event = $this->read($id,$recurrence))) |
|
2240 | + list($id, $recurrence) = explode(':', $data['id']); |
|
2241 | + if ((int)$id && ($event = $this->read($id, $recurrence))) |
|
2244 | 2242 | { |
2245 | 2243 | $set['ts_start'] = $event['start']; |
2246 | 2244 | $set['ts_title'] = $this->link_title($event); |
2247 | - $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
|
2245 | + $set['start_time'] = Api\DateTime::to($event['start'], 'H:i'); |
|
2248 | 2246 | $set['ts_description'] = $event['description']; |
2249 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
2247 | + if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
2250 | 2248 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
2251 | 2249 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
2252 | - $set['end_time'] = null; // unset end-time |
|
2250 | + $set['end_time'] = null; // unset end-time |
|
2253 | 2251 | $set['cat_id'] = (int)$event['category']; |
2254 | 2252 | |
2255 | - foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link) |
|
2253 | + foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link) |
|
2256 | 2254 | { |
2257 | 2255 | if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME) |
2258 | 2256 | { |
@@ -15,10 +15,13 @@ discard block |
||
15 | 15 | use EGroupware\Api\Link; |
16 | 16 | use EGroupware\Api\Acl; |
17 | 17 | |
18 | -if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
|
18 | +if (!defined('ACL_TYPE_IDENTIFER')) |
|
19 | +{ |
|
20 | + // used to mark ACL-values for the debug_message methode |
|
19 | 21 | { |
20 | 22 | define('ACL_TYPE_IDENTIFER','***ACL***'); |
21 | 23 | } |
24 | +} |
|
22 | 25 | |
23 | 26 | define('HOUR_s',60*60); |
24 | 27 | define('DAY_s',24*HOUR_s); |
@@ -219,7 +222,10 @@ discard block |
||
219 | 222 | */ |
220 | 223 | function __construct() |
221 | 224 | { |
222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
225 | + if ($this->debug > 0) |
|
226 | + { |
|
227 | + $this->debug_message('calendar_bo::bocal() started',True); |
|
228 | + } |
|
223 | 229 | |
224 | 230 | $this->so = new calendar_so(); |
225 | 231 | |
@@ -305,7 +311,10 @@ discard block |
||
305 | 311 | */ |
306 | 312 | static function email_info($ids) |
307 | 313 | { |
308 | - if (!$ids) return null; |
|
314 | + if (!$ids) |
|
315 | + { |
|
316 | + return null; |
|
317 | + } |
|
309 | 318 | |
310 | 319 | $data = array(); |
311 | 320 | foreach((array)$ids as $id) |
@@ -398,10 +407,13 @@ discard block |
||
398 | 407 | } |
399 | 408 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
400 | 409 | { |
401 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
410 | + if ($contact && !in_array($contact,$contact_list)) |
|
411 | + { |
|
412 | + // already added? |
|
402 | 413 | { |
403 | 414 | $contact_list[] = $contact; |
404 | 415 | } |
416 | + } |
|
405 | 417 | } |
406 | 418 | } |
407 | 419 | } |
@@ -461,21 +473,27 @@ discard block |
||
461 | 473 | { |
462 | 474 | foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
463 | 475 | { |
464 | - if ($contact && !in_array($contact,$users)) // already added? |
|
476 | + if ($contact && !in_array($contact,$users)) |
|
477 | + { |
|
478 | + // already added? |
|
465 | 479 | { |
466 | 480 | $users[] = $contact; |
467 | 481 | } |
482 | + } |
|
468 | 483 | } |
469 | 484 | continue; |
470 | 485 | } |
471 | 486 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
472 | 487 | { |
473 | - if ($user && !in_array($user,$users)) // already added? |
|
488 | + if ($user && !in_array($user,$users)) |
|
489 | + { |
|
490 | + // already added? |
|
474 | 491 | { |
475 | 492 | // General expansion check |
476 | 493 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
477 | 494 | { |
478 | 495 | $info = $this->resource_info($user); |
496 | + } |
|
479 | 497 | if($info && $info['resources']) |
480 | 498 | { |
481 | 499 | foreach($info['resources'] as $_user) |
@@ -496,12 +514,18 @@ discard block |
||
496 | 514 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
497 | 515 | } |
498 | 516 | // the further code is only for real users |
499 | - if (!is_numeric($user)) continue; |
|
517 | + if (!is_numeric($user)) |
|
518 | + { |
|
519 | + continue; |
|
520 | + } |
|
500 | 521 | |
501 | 522 | // for groups we have to include the members |
502 | 523 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
503 | 524 | { |
504 | - if ($no_enum_groups) continue; |
|
525 | + if ($no_enum_groups) |
|
526 | + { |
|
527 | + continue; |
|
528 | + } |
|
505 | 529 | |
506 | 530 | $members = $GLOBALS['egw']->accounts->members($user, true); |
507 | 531 | if (is_array($members)) |
@@ -583,11 +607,14 @@ discard block |
||
583 | 607 | } |
584 | 608 | |
585 | 609 | if (empty($params['users']) || |
586 | - is_array($params['users']) && count($params['users']) == 1 && empty($params['users'][0])) // null or '' casted to an array |
|
610 | + is_array($params['users']) && count($params['users']) == 1 && empty($params['users'][0])) |
|
611 | + { |
|
612 | + // null or '' casted to an array |
|
587 | 613 | { |
588 | 614 | // for a search use all account you have read grants from |
589 | 615 | $params['users'] = $params['query'] ? array_keys($this->grants) : $this->user; |
590 | 616 | } |
617 | + } |
|
591 | 618 | // resolve users to add memberships for users and members for groups |
592 | 619 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
593 | 620 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
@@ -602,7 +629,10 @@ discard block |
||
602 | 629 | $params['private_grants'] = array(); |
603 | 630 | foreach($this->grants as $user => $rights) |
604 | 631 | { |
605 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
632 | + if ($rights & Acl::PRIVAT) |
|
633 | + { |
|
634 | + $params['private_grants'][] = $user; |
|
635 | + } |
|
606 | 636 | } |
607 | 637 | } |
608 | 638 | |
@@ -617,7 +647,10 @@ discard block |
||
617 | 647 | { |
618 | 648 | return false; |
619 | 649 | } |
620 | - if (isset($params['start'])) $start = $this->date2ts($params['start']); |
|
650 | + if (isset($params['start'])) |
|
651 | + { |
|
652 | + $start = $this->date2ts($params['start']); |
|
653 | + } |
|
621 | 654 | |
622 | 655 | if (isset($params['end'])) |
623 | 656 | { |
@@ -681,10 +714,13 @@ discard block |
||
681 | 714 | $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
682 | 715 | } |
683 | 716 | // create empty entries for each day in the reported time |
684 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
717 | + for($ts = $start; $ts <= $end; $ts += DAY_s) |
|
718 | + { |
|
719 | + // good enough for array creation, but see while loop below. |
|
685 | 720 | { |
686 | 721 | $daysEvents[$this->date2string($ts)] = array(); |
687 | 722 | } |
723 | + } |
|
688 | 724 | foreach($events as $k => $event) |
689 | 725 | { |
690 | 726 | $e_start = max($this->date2ts($event['start']),$start); |
@@ -736,7 +772,10 @@ discard block |
||
736 | 772 | $integration_data = calendar_so::get_integration_data(); |
737 | 773 | } |
738 | 774 | |
739 | - if (!isset($integration_data[$app])) return null; |
|
775 | + if (!isset($integration_data[$app])) |
|
776 | + { |
|
777 | + return null; |
|
778 | + } |
|
740 | 779 | |
741 | 780 | return $part ? $integration_data[$app][$part] : $integration_data[$app]; |
742 | 781 | } |
@@ -783,8 +822,14 @@ discard block |
||
783 | 822 | */ |
784 | 823 | function clear_private_infos(&$event,$allowed_participants = array()) |
785 | 824 | { |
786 | - if ($event == false) return; |
|
787 | - if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
825 | + if ($event == false) |
|
826 | + { |
|
827 | + return; |
|
828 | + } |
|
829 | + if (!is_array($event['participants'])) |
|
830 | + { |
|
831 | + error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
832 | + } |
|
788 | 833 | |
789 | 834 | $event = array( |
790 | 835 | 'id' => $event['id'], |
@@ -829,19 +874,29 @@ discard block |
||
829 | 874 | } |
830 | 875 | $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
831 | 876 | |
832 | - if ($new_horizont <= $this->config['horizont']) // no move necessary |
|
877 | + if ($new_horizont <= $this->config['horizont']) |
|
878 | + { |
|
879 | + // no move necessary |
|
833 | 880 | { |
834 | 881 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
882 | + } |
|
835 | 883 | return; |
836 | 884 | } |
837 | 885 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
838 | 886 | { |
839 | 887 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
840 | 888 | } |
841 | - if (empty($maxdays)) $maxdays = 1000; // old default |
|
842 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
889 | + if (empty($maxdays)) |
|
890 | + { |
|
891 | + $maxdays = 1000; |
|
892 | + } |
|
893 | + // old default |
|
894 | + if ($new_horizont > time()+$maxdays*DAY_s) |
|
895 | + { |
|
896 | + // some user tries to "look" more then the maximum number of days in the future |
|
843 | 897 | { |
844 | 898 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
899 | + } |
|
845 | 900 | $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
846 | 901 | return; |
847 | 902 | } |
@@ -869,7 +924,10 @@ discard block |
||
869 | 924 | // update the horizont |
870 | 925 | Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
871 | 926 | |
872 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
927 | + if ($this->debug == 'check_move_horizont') |
|
928 | + { |
|
929 | + $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
930 | + } |
|
873 | 931 | } |
874 | 932 | |
875 | 933 | /** |
@@ -900,7 +958,10 @@ discard block |
||
900 | 958 | $event['end'] = $this->date2usertime($event_read['end']); |
901 | 959 | } |
902 | 960 | } |
903 | - if (!$start) $start = $event['start']; |
|
961 | + if (!$start) |
|
962 | + { |
|
963 | + $start = $event['start']; |
|
964 | + } |
|
904 | 965 | |
905 | 966 | $events = array(); |
906 | 967 | |
@@ -944,7 +1005,10 @@ discard block |
||
944 | 1005 | */ |
945 | 1006 | function db2data(&$events,$date_format='ts') |
946 | 1007 | { |
947 | - if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
1008 | + if (!is_array($events)) |
|
1009 | + { |
|
1010 | + echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
1011 | + } |
|
948 | 1012 | foreach ($events as &$event) |
949 | 1013 | { |
950 | 1014 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
@@ -1028,7 +1092,10 @@ discard block |
||
1028 | 1092 | */ |
1029 | 1093 | function date2usertime($ts,$date_format='ts') |
1030 | 1094 | { |
1031 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
1095 | + if (empty($ts) || $date_format == 'server') |
|
1096 | + { |
|
1097 | + return $ts; |
|
1098 | + } |
|
1032 | 1099 | |
1033 | 1100 | return Api\DateTime::server2user($ts,$date_format); |
1034 | 1101 | } |
@@ -1047,9 +1114,15 @@ discard block |
||
1047 | 1114 | */ |
1048 | 1115 | function read($ids,$date=null, $ignore_acl=False, $date_format='ts', $clear_private_infos_users=null, $read_recurrence=false) |
1049 | 1116 | { |
1050 | - if (!$ids) return false; |
|
1117 | + if (!$ids) |
|
1118 | + { |
|
1119 | + return false; |
|
1120 | + } |
|
1051 | 1121 | |
1052 | - if ($date) $date = $this->date2ts($date); |
|
1122 | + if ($date) |
|
1123 | + { |
|
1124 | + $date = $this->date2ts($date); |
|
1125 | + } |
|
1053 | 1126 | |
1054 | 1127 | $return = null; |
1055 | 1128 | |
@@ -1224,7 +1297,10 @@ discard block |
||
1224 | 1297 | { |
1225 | 1298 | static $res_info_cache = array(); |
1226 | 1299 | |
1227 | - if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
1300 | + if (!is_scalar($uid)) |
|
1301 | + { |
|
1302 | + throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
1303 | + } |
|
1228 | 1304 | |
1229 | 1305 | if (!isset($res_info_cache[$uid])) |
1230 | 1306 | { |
@@ -1279,7 +1355,10 @@ discard block |
||
1279 | 1355 | */ |
1280 | 1356 | function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
1281 | 1357 | { |
1282 | - if (!$user) $user = $this->user; |
|
1358 | + if (!$user) |
|
1359 | + { |
|
1360 | + $user = $this->user; |
|
1361 | + } |
|
1283 | 1362 | if ($user == $this->user) |
1284 | 1363 | { |
1285 | 1364 | $grants = $this->grants; |
@@ -1318,7 +1397,10 @@ discard block |
||
1318 | 1397 | $grant = $grants[$owner]; |
1319 | 1398 | |
1320 | 1399 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
1321 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
1400 | + if ($grant & ~self::ACL_INVITE) |
|
1401 | + { |
|
1402 | + $grant |= self::ACL_FREEBUSY; |
|
1403 | + } |
|
1322 | 1404 | |
1323 | 1405 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
1324 | 1406 | { |
@@ -1344,7 +1426,10 @@ discard block |
||
1344 | 1426 | elseif (!is_numeric($uid)) |
1345 | 1427 | { |
1346 | 1428 | // if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights |
1347 | - if ($grant == self::ACL_FREEBUSY) continue; |
|
1429 | + if ($grant == self::ACL_FREEBUSY) |
|
1430 | + { |
|
1431 | + continue; |
|
1432 | + } |
|
1348 | 1433 | // if we have a resource as participant |
1349 | 1434 | $resource = $this->resource_info($uid); |
1350 | 1435 | $grant |= $resource['rights']; |
@@ -1495,14 +1580,20 @@ discard block |
||
1495 | 1580 | $param = $param ? 'True' : 'False'; |
1496 | 1581 | break; |
1497 | 1582 | case 'integer': |
1498 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
1583 | + if ($param >= mktime(0,0,0,1,1,2000)) |
|
1584 | + { |
|
1585 | + $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
1586 | + } |
|
1499 | 1587 | break; |
1500 | 1588 | } |
1501 | 1589 | } |
1502 | 1590 | $msg = str_replace('%'.($i-1),$param,$msg); |
1503 | 1591 | } |
1504 | 1592 | error_log($msg); |
1505 | - if ($backtrace) error_log(function_backtrace(1)); |
|
1593 | + if ($backtrace) |
|
1594 | + { |
|
1595 | + error_log(function_backtrace(1)); |
|
1596 | + } |
|
1506 | 1597 | } |
1507 | 1598 | |
1508 | 1599 | /** |
@@ -1610,14 +1701,20 @@ discard block |
||
1610 | 1701 | function timespan($start_m,$end_m,$both=false) |
1611 | 1702 | { |
1612 | 1703 | $duration = $end_m - $start_m; |
1613 | - if ($end_m == 24*60-1) ++$duration; |
|
1704 | + if ($end_m == 24*60-1) |
|
1705 | + { |
|
1706 | + ++$duration; |
|
1707 | + } |
|
1614 | 1708 | $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
1615 | 1709 | |
1616 | 1710 | $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
1617 | 1711 | |
1618 | - if ($both) // end-time too |
|
1712 | + if ($both) |
|
1713 | + { |
|
1714 | + // end-time too |
|
1619 | 1715 | { |
1620 | 1716 | $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
1717 | + } |
|
1621 | 1718 | // dont double am/pm if they are the same in both times |
1622 | 1719 | if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
1623 | 1720 | { |
@@ -1641,7 +1738,10 @@ discard block |
||
1641 | 1738 | static $id2lid = array(); |
1642 | 1739 | static $id2email = array(); |
1643 | 1740 | |
1644 | - if ($use_type && $use_type != 'u') $id = $use_type.$id; |
|
1741 | + if ($use_type && $use_type != 'u') |
|
1742 | + { |
|
1743 | + $id = $use_type.$id; |
|
1744 | + } |
|
1645 | 1745 | |
1646 | 1746 | if (!isset($id2lid[$id])) |
1647 | 1747 | { |
@@ -1651,7 +1751,10 @@ discard block |
||
1651 | 1751 | if (($info = $this->resource_info($id))) |
1652 | 1752 | { |
1653 | 1753 | $id2lid[$id] = $info['name'] ? $info['name'] : $info['email']; |
1654 | - if ($info['name']) $id2email[$id] = $info['email']; |
|
1754 | + if ($info['name']) |
|
1755 | + { |
|
1756 | + $id2email[$id] = $info['email']; |
|
1757 | + } |
|
1655 | 1758 | } |
1656 | 1759 | } |
1657 | 1760 | else |
@@ -1677,11 +1780,18 @@ discard block |
||
1677 | 1780 | $names = array(); |
1678 | 1781 | foreach((array)$event['participants'] as $id => $status) |
1679 | 1782 | { |
1680 | - if (!is_string($status)) continue; |
|
1783 | + if (!is_string($status)) |
|
1784 | + { |
|
1785 | + continue; |
|
1786 | + } |
|
1681 | 1787 | $quantity = $role = null; |
1682 | 1788 | calendar_so::split_status($status,$quantity,$role); |
1683 | 1789 | |
1684 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
1790 | + if ($status == 'G' && !$show_group_invitation) |
|
1791 | + { |
|
1792 | + continue; |
|
1793 | + } |
|
1794 | + // dont show group-invitation |
|
1685 | 1795 | |
1686 | 1796 | $lang_status = lang($this->verbose_status[$status]); |
1687 | 1797 | if (!$long_status) |
@@ -1754,7 +1864,10 @@ discard block |
||
1754 | 1864 | |
1755 | 1865 | foreach(explode(',',$category) as $cat_id) |
1756 | 1866 | { |
1757 | - if (!$cat_id) continue; |
|
1867 | + if (!$cat_id) |
|
1868 | + { |
|
1869 | + continue; |
|
1870 | + } |
|
1758 | 1871 | |
1759 | 1872 | if (!isset($id2cat[$cat_id])) |
1760 | 1873 | { |
@@ -1820,7 +1933,10 @@ discard block |
||
1820 | 1933 | */ |
1821 | 1934 | public static function list_calendars($user, array $grants=null) |
1822 | 1935 | { |
1823 | - if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
1936 | + if (is_null($grants)) |
|
1937 | + { |
|
1938 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
1939 | + } |
|
1824 | 1940 | |
1825 | 1941 | $users = $groups = array(); |
1826 | 1942 | foreach(array_keys($grants) as $id) |
@@ -1868,7 +1984,10 @@ discard block |
||
1868 | 1984 | */ |
1869 | 1985 | function recure2string($event) |
1870 | 1986 | { |
1871 | - if (!is_array($event)) return false; |
|
1987 | + if (!is_array($event)) |
|
1988 | + { |
|
1989 | + return false; |
|
1990 | + } |
|
1872 | 1991 | return (string)calendar_rrule::event2rrule($event); |
1873 | 1992 | } |
1874 | 1993 | |
@@ -1887,7 +2006,10 @@ discard block |
||
1887 | 2006 | */ |
1888 | 2007 | function read_holidays($year=0) |
1889 | 2008 | { |
1890 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
2009 | + if (!$year) |
|
2010 | + { |
|
2011 | + $year = (int) date('Y',$this->now_su); |
|
2012 | + } |
|
1891 | 2013 | |
1892 | 2014 | $holidays = calendar_holidays::read( |
1893 | 2015 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
@@ -1912,7 +2034,10 @@ discard block |
||
1912 | 2034 | foreach($bdays as $birthday) |
1913 | 2035 | { |
1914 | 2036 | // Skip if name / date are already there - duplicate contacts |
1915 | - if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue; |
|
2037 | + if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) |
|
2038 | + { |
|
2039 | + continue; |
|
2040 | + } |
|
1916 | 2041 | $holidays[$date][] = $birthday; |
1917 | 2042 | } |
1918 | 2043 | } |
@@ -1997,7 +2122,10 @@ discard block |
||
1997 | 2122 | } |
1998 | 2123 | } |
1999 | 2124 | $str_fields = implode(', ',$extra_fields); |
2000 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
2125 | + if (is_array($extra_fields)) |
|
2126 | + { |
|
2127 | + return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
2128 | + } |
|
2001 | 2129 | } |
2002 | 2130 | return $this->format_date($event['start']) . ': ' . $event['title']; |
2003 | 2131 | } |
@@ -2018,7 +2146,8 @@ discard block |
||
2018 | 2146 | 'offset' => $options['start'], |
2019 | 2147 | 'order' => 'cal_start DESC', |
2020 | 2148 | ); |
2021 | - if($options['num_rows']) { |
|
2149 | + if($options['num_rows']) |
|
2150 | + { |
|
2022 | 2151 | $query['num_rows'] = $options['num_rows']; |
2023 | 2152 | } |
2024 | 2153 | foreach((array) $this->search($query) as $event) |
@@ -2079,7 +2208,10 @@ discard block |
||
2079 | 2208 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
2080 | 2209 | { |
2081 | 2210 | $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
2082 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
2211 | + if ($type == 'forced') |
|
2212 | + { |
|
2213 | + $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
2214 | + } |
|
2083 | 2215 | $this->cal_prefs[$var] = $default; |
2084 | 2216 | $need_save = True; |
2085 | 2217 | } |
@@ -2099,7 +2231,10 @@ discard block |
||
2099 | 2231 | */ |
2100 | 2232 | static function freebusy_url($user='',$pw=null) |
2101 | 2233 | { |
2102 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
2234 | + if (is_numeric($user)) |
|
2235 | + { |
|
2236 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
2237 | + } |
|
2103 | 2238 | |
2104 | 2239 | $credentials = ''; |
2105 | 2240 | |
@@ -2167,13 +2302,19 @@ discard block |
||
2167 | 2302 | */ |
2168 | 2303 | public function get_ctag($user, $filter='owner', $master_only=false) |
2169 | 2304 | { |
2170 | - if ($this->debug > 1) $startime = microtime(true); |
|
2305 | + if ($this->debug > 1) |
|
2306 | + { |
|
2307 | + $startime = microtime(true); |
|
2308 | + } |
|
2171 | 2309 | |
2172 | 2310 | // resolve users to add memberships for users and members for groups |
2173 | 2311 | $users = $this->resolve_users($user); |
2174 | 2312 | $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
2175 | 2313 | |
2176 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
2314 | + if ($this->debug > 1) |
|
2315 | + { |
|
2316 | + error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
2317 | + } |
|
2177 | 2318 | return $ctag; |
2178 | 2319 | } |
2179 | 2320 | |
@@ -2215,15 +2356,21 @@ discard block |
||
2215 | 2356 | $content['link_app'][] = $link['app']; |
2216 | 2357 | $content['link_id'][] = $link['id']; |
2217 | 2358 | } |
2218 | - if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above |
|
2359 | + if ($link['app'] == 'addressbook') |
|
2360 | + { |
|
2361 | + // prefering contact as primary contact over calendar entry set above |
|
2219 | 2362 | { |
2220 | 2363 | $content['info_contact'] = 'addressbook:'.$link['id']; |
2221 | 2364 | } |
2365 | + } |
|
2222 | 2366 | } |
2223 | 2367 | // Copy same custom fields |
2224 | 2368 | foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
2225 | 2369 | { |
2226 | - if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
|
2370 | + if ($this->customfields[$name]) |
|
2371 | + { |
|
2372 | + $content['#'.$name] = $calendar['#'.$name]; |
|
2373 | + } |
|
2227 | 2374 | } |
2228 | 2375 | //error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content)); |
2229 | 2376 | return $content; |
@@ -2246,7 +2393,11 @@ discard block |
||
2246 | 2393 | $set['ts_title'] = $this->link_title($event); |
2247 | 2394 | $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
2248 | 2395 | $set['ts_description'] = $event['description']; |
2249 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
2396 | + if ($this->isWholeDay($event)) |
|
2397 | + { |
|
2398 | + $event['end']++; |
|
2399 | + } |
|
2400 | + // whole day events are 1sec short |
|
2250 | 2401 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
2251 | 2402 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
2252 | 2403 | $set['end_time'] = null; // unset end-time |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Egroupware |
|
4 | - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
5 | - * @link http://www.egroupware.org |
|
6 | - * @author Nathan Gray |
|
7 | - * @version $Id$ |
|
8 | - */ |
|
3 | + * Egroupware |
|
4 | + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
5 | + * @link http://www.egroupware.org |
|
6 | + * @author Nathan Gray |
|
7 | + * @version $Id$ |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | use EGroupware\Api; |
11 | 11 | use EGroupware\Api\Etemplate; |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | /** |
25 | - * Set up what we know on the server side. |
|
26 | - * |
|
27 | - * Sending a first chunk of rows |
|
28 | - * |
|
29 | - * @param string $cname |
|
30 | - * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
31 | - */ |
|
25 | + * Set up what we know on the server side. |
|
26 | + * |
|
27 | + * Sending a first chunk of rows |
|
28 | + * |
|
29 | + * @param string $cname |
|
30 | + * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
31 | + */ |
|
32 | 32 | public function beforeSendToClient($cname, array $expand=null) |
33 | 33 | { |
34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
@@ -29,24 +29,24 @@ |
||
29 | 29 | * @param string $cname |
30 | 30 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
31 | 31 | */ |
32 | - public function beforeSendToClient($cname, array $expand=null) |
|
32 | + public function beforeSendToClient($cname, array $expand = null) |
|
33 | 33 | { |
34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
35 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
36 | - if(!is_array($value)) $value = array(); |
|
35 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
36 | + if (!is_array($value)) $value = array(); |
|
37 | 37 | |
38 | - foreach($value as &$events) |
|
38 | + foreach ($value as &$events) |
|
39 | 39 | { |
40 | - if(!is_array($events)) |
|
40 | + if (!is_array($events)) |
|
41 | 41 | { |
42 | 42 | continue; |
43 | 43 | } |
44 | - foreach($events as &$event) |
|
44 | + foreach ($events as &$event) |
|
45 | 45 | { |
46 | - if(!is_array($event)) continue; |
|
47 | - foreach(array('start','end') as $date) |
|
46 | + if (!is_array($event)) continue; |
|
47 | + foreach (array('start', 'end') as $date) |
|
48 | 48 | { |
49 | - $event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z'); |
|
49 | + $event[$date] = Api\DateTime::to($event[$date], 'Y-m-d\TH:i:s\Z'); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -33,7 +33,10 @@ discard block |
||
33 | 33 | { |
34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
35 | 35 | $value =& self::get_array(self::$request->content, $form_name, true); |
36 | - if(!is_array($value)) $value = array(); |
|
36 | + if(!is_array($value)) |
|
37 | + { |
|
38 | + $value = array(); |
|
39 | + } |
|
37 | 40 | |
38 | 41 | foreach($value as &$events) |
39 | 42 | { |
@@ -43,7 +46,10 @@ discard block |
||
43 | 46 | } |
44 | 47 | foreach($events as &$event) |
45 | 48 | { |
46 | - if(!is_array($event)) continue; |
|
49 | + if(!is_array($event)) |
|
50 | + { |
|
51 | + continue; |
|
52 | + } |
|
47 | 53 | foreach(array('start','end') as $date) |
48 | 54 | { |
49 | 55 | $event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z'); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Do some magic with the participants and recurrance. |
|
136 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
137 | - * filter by it later. |
|
138 | - */ |
|
135 | + * Do some magic with the participants and recurrance. |
|
136 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
137 | + * filter by it later. |
|
138 | + */ |
|
139 | 139 | if(is_array($data['participants'])) |
140 | 140 | { |
141 | 141 | $participants = $data['participants']; |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | - * Do some magic with the participants and recurrance. |
|
199 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
200 | - * filter by it later. |
|
201 | - */ |
|
198 | + * Do some magic with the participants and recurrance. |
|
199 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
200 | + * filter by it later. |
|
201 | + */ |
|
202 | 202 | protected function alter_participants($participants) |
203 | 203 | { |
204 | 204 | $data = array(); |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function __construct() |
116 | 116 | { |
117 | - parent::__construct('calendar'); // adds custom fields |
|
117 | + parent::__construct('calendar'); // adds custom fields |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Tracks the changes in one entry $data, by comparing it with the last version in $old |
122 | 122 | * Overrides parent to reformat participants into a format parent can handle |
123 | 123 | */ |
124 | - public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null) |
|
124 | + public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null) |
|
125 | 125 | { |
126 | 126 | // Don't try to track dates on recurring events. |
127 | 127 | // It won't change for the base event, and any change to the time creates an exception |
128 | - if($data['recur_type']) |
|
128 | + if ($data['recur_type']) |
|
129 | 129 | { |
130 | 130 | unset($data['start']); unset($data['end']); |
131 | 131 | unset($old['start']); unset($old['end']); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * If this is one of a recurring event, append the recur_date to the participant field so we can |
137 | 137 | * filter by it later. |
138 | 138 | */ |
139 | - if(is_array($data['participants'])) |
|
139 | + if (is_array($data['participants'])) |
|
140 | 140 | { |
141 | 141 | $participants = $data['participants']; |
142 | 142 | $data['participants'] = array(); |
@@ -144,33 +144,33 @@ discard block |
||
144 | 144 | } |
145 | 145 | // if clients eg. CalDAV do NOT set participants, they are left untouched |
146 | 146 | // therefore we should not track them, as all updates then show up as all participants removed |
147 | - elseif(!isset($data['participants'])) |
|
147 | + elseif (!isset($data['participants'])) |
|
148 | 148 | { |
149 | 149 | unset($old['participants']); |
150 | 150 | } |
151 | - if(is_array($old['participants'])) |
|
151 | + if (is_array($old['participants'])) |
|
152 | 152 | { |
153 | 153 | $participants = $old['participants']; |
154 | 154 | $old['participants'] = array(); |
155 | 155 | $old = array_merge($old, $this->alter_participants($participants)); |
156 | 156 | } |
157 | 157 | // Make sure dates are timestamps |
158 | - foreach(array('start','end') as $date) |
|
158 | + foreach (array('start', 'end') as $date) |
|
159 | 159 | { |
160 | - if(is_object($data[$date]) && is_a($data[$date], 'DateTime')) |
|
160 | + if (is_object($data[$date]) && is_a($data[$date], 'DateTime')) |
|
161 | 161 | { |
162 | 162 | $data[$date] = $data[$date]->format('ts'); |
163 | 163 | } |
164 | 164 | } |
165 | - parent::track($data,$old,$user,$deleted, $changed_fields); |
|
165 | + parent::track($data, $old, $user, $deleted, $changed_fields); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Overrides parent because calendar_boupdates handles the notifications |
170 | 170 | */ |
171 | - public function do_notifications($data,$old,$deleted=null) |
|
171 | + public function do_notifications($data, $old, $deleted = null) |
|
172 | 172 | { |
173 | - unset($data, $old, $deleted); // unused, but required by function signature |
|
173 | + unset($data, $old, $deleted); // unused, but required by function signature |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
@@ -185,21 +185,21 @@ discard block |
||
185 | 185 | * @param array $old = null |
186 | 186 | * @return array of keys with different values in $data and $old |
187 | 187 | */ |
188 | - public function changed_fields(array $data,array $old=null) |
|
188 | + public function changed_fields(array $data, array $old = null) |
|
189 | 189 | { |
190 | - if(is_array($data['participants'])) |
|
190 | + if (is_array($data['participants'])) |
|
191 | 191 | { |
192 | 192 | $participants = $data['participants']; |
193 | 193 | $data['participants'] = array(); |
194 | 194 | $data = array_merge($data, $this->alter_participants($participants)); |
195 | 195 | } |
196 | - if(is_array($old['participants'])) |
|
196 | + if (is_array($old['participants'])) |
|
197 | 197 | { |
198 | 198 | $participants = $old['participants']; |
199 | 199 | $old['participants'] = array(); |
200 | 200 | $old = array_merge($old, $this->alter_participants($participants)); |
201 | 201 | } |
202 | - return parent::changed_fields($data,$old); |
|
202 | + return parent::changed_fields($data, $old); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | protected function alter_participants($participants) |
211 | 211 | { |
212 | 212 | $data = array(); |
213 | - foreach($participants as $uid => $status) |
|
213 | + foreach ($participants as $uid => $status) |
|
214 | 214 | { |
215 | 215 | $quantity = $role = $user_type = $user_id = null; |
216 | 216 | calendar_so::split_status($status, $quantity, $role); |