@@ -113,8 +113,6 @@ discard block |
||
| 113 | 113 | * @param array $ids array with contact id(s) |
| 114 | 114 | * @param string &$err error-message on error |
| 115 | 115 | * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf |
| 116 | - * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders |
|
| 117 | - * @param string $charset=null charset to override default set by mimetype or export charset |
|
| 118 | 116 | * @return string|boolean merged document or false on error |
| 119 | 117 | */ |
| 120 | 118 | function merge_string($content,$ids,$err,$mimetype,$fix) |
@@ -234,7 +232,6 @@ discard block |
||
| 234 | 232 | * Return replacements for the calendar |
| 235 | 233 | * |
| 236 | 234 | * @param int|array $id event-id or array with id/recur_date, or array with event info |
| 237 | - * @param boolean $last_event_too=false also include information about the last event |
|
| 238 | 235 | * @return array |
| 239 | 236 | */ |
| 240 | 237 | public function calendar_replacements($id,$prefix = '', &$content = '') |
@@ -326,20 +326,20 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | - * Table plugin for event |
|
| 330 | - * Lists events for a certain day of the week. Only works for one week at a time, so for multiple weeks, |
|
| 331 | - * use multiple date ranges. |
|
| 332 | - * |
|
| 333 | - * Use: |
|
| 334 | - * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$ |
|
| 335 | - * The day of the week may be language specific (date('l')). |
|
| 336 | - * |
|
| 337 | - * @param string $plugin (Monday-Sunday) |
|
| 338 | - * @param int/array date or date range |
|
| 339 | - * @param int $n Row number |
|
| 340 | - * @param string $repeat Text being repeated for each entry |
|
| 341 | - * @return array |
|
| 342 | - */ |
|
| 329 | + * Table plugin for event |
|
| 330 | + * Lists events for a certain day of the week. Only works for one week at a time, so for multiple weeks, |
|
| 331 | + * use multiple date ranges. |
|
| 332 | + * |
|
| 333 | + * Use: |
|
| 334 | + * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$ |
|
| 335 | + * The day of the week may be language specific (date('l')). |
|
| 336 | + * |
|
| 337 | + * @param string $plugin (Monday-Sunday) |
|
| 338 | + * @param int/array date or date range |
|
| 339 | + * @param int $n Row number |
|
| 340 | + * @param string $repeat Text being repeated for each entry |
|
| 341 | + * @return array |
|
| 342 | + */ |
|
| 343 | 343 | public function day_plugin($plugin,$date,$n,$repeat) |
| 344 | 344 | { |
| 345 | 345 | static $days = null; |
@@ -414,16 +414,16 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | - * Table plugin for a certain date |
|
| 418 | - * |
|
| 419 | - * Can be either a particular date (2011-02-15) or a day of the month (15) |
|
| 420 | - * |
|
| 421 | - * @param string $plugin |
|
| 422 | - * @param int $id ID for this record |
|
| 423 | - * @param int $n Repeated row number |
|
| 424 | - * @param string $repeat Text being repeated for each entry |
|
| 425 | - * @return array |
|
| 426 | - */ |
|
| 417 | + * Table plugin for a certain date |
|
| 418 | + * |
|
| 419 | + * Can be either a particular date (2011-02-15) or a day of the month (15) |
|
| 420 | + * |
|
| 421 | + * @param string $plugin |
|
| 422 | + * @param int $id ID for this record |
|
| 423 | + * @param int $n Repeated row number |
|
| 424 | + * @param string $repeat Text being repeated for each entry |
|
| 425 | + * @return array |
|
| 426 | + */ |
|
| 427 | 427 | public function day($plugin,$id,$n,$repeat) |
| 428 | 428 | { |
| 429 | 429 | static $days = null; |
@@ -515,15 +515,15 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | - * Table plugin for participants |
|
| 519 | - * |
|
| 520 | - * Copied from eventmgr resources |
|
| 521 | - * |
|
| 522 | - * @param string $plugin |
|
| 523 | - * @param int $id |
|
| 524 | - * @param int $n |
|
| 525 | - * @return array |
|
| 526 | - */ |
|
| 518 | + * Table plugin for participants |
|
| 519 | + * |
|
| 520 | + * Copied from eventmgr resources |
|
| 521 | + * |
|
| 522 | + * @param string $plugin |
|
| 523 | + * @param int $id |
|
| 524 | + * @param int $n |
|
| 525 | + * @return array |
|
| 526 | + */ |
|
| 527 | 527 | public function participant($plugin,$id,$n) |
| 528 | 528 | { |
| 529 | 529 | unset($plugin); // not used, but required by function signature |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | { |
| 583 | 583 | foreach($resource as $name => $value) |
| 584 | 584 | { |
| 585 | - $replacements['$$'.$name.'$$'] = $value; |
|
| 585 | + $replacements['$$'.$name.'$$'] = $value; |
|
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | break; |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Register table plugins |
| 86 | 86 | $this->table_plugins['participant'] = 'participant'; |
| 87 | - for($i = 0; $i < 7; $i++) |
|
| 87 | + for ($i = 0; $i < 7; $i++) |
|
| 88 | 88 | { |
| 89 | 89 | $this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin'; |
| 90 | 90 | } |
| 91 | - for($i = 1; $i <= 31; $i++) { |
|
| 91 | + for ($i = 1; $i <= 31; $i++) { |
|
| 92 | 92 | $this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31) |
| 93 | 93 | } |
| 94 | - foreach(self::$relative as $day) { |
|
| 94 | + foreach (self::$relative as $day) { |
|
| 95 | 95 | $this->table_plugins[$day] = 'day'; // Current day |
| 96 | 96 | } |
| 97 | 97 | $this->query = is_array($this->bo->cal_prefs['saved_states']) ? |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @param string $charset=null charset to override default set by mimetype or export charset |
| 118 | 118 | * @return string|boolean merged document or false on error |
| 119 | 119 | */ |
| 120 | - function merge_string($content,$ids,$err,$mimetype,$fix) |
|
| 120 | + function merge_string($content, $ids, $err, $mimetype, $fix) |
|
| 121 | 121 | { |
| 122 | 122 | //error_log(__METHOD__ . ' IDs: ' . array2string($ids)); |
| 123 | 123 | // Handle merging a list of events into a document with range instead of pagerepeat |
| 124 | - if((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids)) |
|
| 124 | + if ((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids)) |
|
| 125 | 125 | { |
| 126 | 126 | //error_log(__METHOD__ . ' Got list of events(?), no pagerepeat tag'); |
| 127 | 127 | // Merging more than one something will fail without pagerepeat |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | $events = $ids; |
| 132 | 132 | $ids = array('start' => PHP_INT_MAX, 'end' => 0); |
| 133 | 133 | $this->ids = array(); |
| 134 | - foreach($events as $event) { |
|
| 135 | - if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 136 | - if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts'); |
|
| 134 | + foreach ($events as $event) { |
|
| 135 | + if ($event['start'] && Api\DateTime::to($event['start'], 'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
| 136 | + if ($event['end'] && Api\DateTime::to($event['end'], 'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'], 'ts'); |
|
| 137 | 137 | // Keep ids for future use |
| 138 | 138 | $this->ids[] = $event['id']; |
| 139 | 139 | } |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | 'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null |
| 155 | 155 | )); |
| 156 | 156 | $ids = array(); |
| 157 | - foreach($events as $event) { |
|
| 157 | + foreach ($events as $event) { |
|
| 158 | 158 | $ids[] = $event; |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return parent::merge_string($content, $ids, $err, $mimetype,$fix); |
|
| 162 | + return parent::merge_string($content, $ids, $err, $mimetype, $fix); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | * @param string &$content=null content to create some replacements only if they are used |
| 170 | 170 | * @return array|boolean |
| 171 | 171 | */ |
| 172 | - protected function get_replacements($id,&$content=null) |
|
| 172 | + protected function get_replacements($id, &$content = null) |
|
| 173 | 173 | { |
| 174 | 174 | $prefix = ''; |
| 175 | 175 | // List events ? |
| 176 | - if(is_array($id) && !$id['id'] && !$id[0]['id']) |
|
| 176 | + if (is_array($id) && !$id['id'] && !$id[0]['id']) |
|
| 177 | 177 | { |
| 178 | 178 | $events = $this->bo->search($this->query + $id + array( |
| 179 | 179 | 'offset' => 0, |
| 180 | 180 | 'order' => 'cal_start', |
| 181 | 181 | 'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null |
| 182 | 182 | )); |
| 183 | - if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
| 183 | + if (strpos($content, '$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
| 184 | 184 | { |
| 185 | - array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
| 185 | + array_unshift($events, false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
| 186 | 186 | $prefix = 'calendar/%d'; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | $events = $id; |
| 193 | 193 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
| 194 | 194 | $this->ids = array(); |
| 195 | - foreach($events as $event) { |
|
| 196 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 197 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 195 | + foreach ($events as $event) { |
|
| 196 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 197 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 198 | 198 | // Keep ids for future use |
| 199 | - $this->ids[] = $event['id']; |
|
| 199 | + $this->ids[] = $event['id']; |
|
| 200 | 200 | } |
| 201 | 201 | $id = array($id); |
| 202 | 202 | } |
@@ -208,20 +208,20 @@ discard block |
||
| 208 | 208 | // as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions |
| 209 | 209 | if (Api\Storage\Merge::hasExportLimit($this->export_limit) && !Api\Storage\Merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit) |
| 210 | 210 | { |
| 211 | - $err = lang('No rights to export more than %1 entries!',(int)$this->export_limit); |
|
| 211 | + $err = lang('No rights to export more than %1 entries!', (int)$this->export_limit); |
|
| 212 | 212 | throw new Api\Exception\WrongUserinput($err); |
| 213 | 213 | } |
| 214 | 214 | $replacements = array(); |
| 215 | 215 | $n = 0; |
| 216 | - foreach($events as $event) |
|
| 216 | + foreach ($events as $event) |
|
| 217 | 217 | { |
| 218 | - $values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content); |
|
| 219 | - if(is_array($id) && $id['start']) |
|
| 218 | + $values = $this->calendar_replacements($event, sprintf($prefix, ++$n), $content); |
|
| 219 | + if (is_array($id) && $id['start']) |
|
| 220 | 220 | { |
| 221 | - foreach(self::$range_tags as $key => $format) |
|
| 221 | + foreach (self::$range_tags as $key => $format) |
|
| 222 | 222 | { |
| 223 | 223 | $value = date($format, $key == 'end' ? $id['end'] : $id['start']); |
| 224 | - if($key == 'month') $value = lang($value); |
|
| 224 | + if ($key == 'month') $value = lang($value); |
|
| 225 | 225 | $values["$\$range/$key$$"] = $value; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | * @param boolean $last_event_too=false also include information about the last event |
| 238 | 238 | * @return array |
| 239 | 239 | */ |
| 240 | - public function calendar_replacements($id,$prefix = '', &$content = '') |
|
| 240 | + public function calendar_replacements($id, $prefix = '', &$content = '') |
|
| 241 | 241 | { |
| 242 | 242 | $replacements = array(); |
| 243 | - if(!is_array($id) || !$id['start']) { |
|
| 243 | + if (!is_array($id) || !$id['start']) { |
|
| 244 | 244 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 245 | 245 | } else { |
| 246 | 246 | $event = $id; |
@@ -253,68 +253,68 @@ discard block |
||
| 253 | 253 | importexport_export_csv::convert($record, $types, 'calendar'); |
| 254 | 254 | |
| 255 | 255 | $array = $record->get_record_array(); |
| 256 | - foreach($array as $key => $value) |
|
| 256 | + foreach ($array as $key => $value) |
|
| 257 | 257 | { |
| 258 | - $replacements['$$'.($prefix?$prefix.'/':'').$key.'$$'] = $value; |
|
| 258 | + $replacements['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id']; |
|
| 262 | - foreach($this->bo->event2array($event) as $name => $data) |
|
| 261 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_id'.'$$'] = $event['id']; |
|
| 262 | + foreach ($this->bo->event2array($event) as $name => $data) |
|
| 263 | 263 | { |
| 264 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
| 265 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
| 264 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
| 265 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
| 266 | 266 | } |
| 267 | 267 | // Add seperate lists of participants by type |
| 268 | - if(strpos($content, 'calendar_participants/')!== false) |
|
| 268 | + if (strpos($content, 'calendar_participants/') !== false) |
|
| 269 | 269 | { |
| 270 | 270 | $types = array(); |
| 271 | - foreach($this->bo->resources as $resource) |
|
| 271 | + foreach ($this->bo->resources as $resource) |
|
| 272 | 272 | { |
| 273 | 273 | $types[$resource['app']] = array(); |
| 274 | 274 | } |
| 275 | - foreach($event['participants'] as $uid => $status) |
|
| 275 | + foreach ($event['participants'] as $uid => $status) |
|
| 276 | 276 | { |
| 277 | 277 | $type = $this->bo->resources[$uid[0]]['app']; |
| 278 | - if($type == 'api-accounts') |
|
| 278 | + if ($type == 'api-accounts') |
|
| 279 | 279 | { |
| 280 | 280 | $type = ($GLOBALS['egw']->accounts->get_type($uid) == 'g' ? 'group' : 'account'); |
| 281 | 281 | } |
| 282 | 282 | $types[$type][] = $this->bo->participant_name($uid); |
| 283 | 283 | } |
| 284 | - foreach($types as $t_id => $type) |
|
| 284 | + foreach ($types as $t_id => $type) |
|
| 285 | 285 | { |
| 286 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type); |
|
| 286 | + $replacements['$$'.($prefix ? $prefix.'/' : '')."calendar_participants/{$t_id}$$"] = implode(', ', $type); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | - if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$']) |
|
| 289 | + if (!$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$']) |
|
| 290 | 290 | { |
| 291 | 291 | // Need to set it to '' if not set or previous record may be used |
| 292 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'] = ''; |
|
| 292 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'] = ''; |
|
| 293 | 293 | } |
| 294 | - foreach(array('start','end') as $what) |
|
| 294 | + foreach (array('start', 'end') as $what) |
|
| 295 | 295 | { |
| 296 | - foreach(array( |
|
| 296 | + foreach (array( |
|
| 297 | 297 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
| 298 | 298 | 'day' => 'l', |
| 299 | - 'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
| 299 | + 'time' => (date('Ymd', $event['start']) != date('Ymd', $event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '').($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
| 300 | 300 | ) as $name => $format) |
| 301 | 301 | { |
| 302 | - $value = Api\DateTime::to($event[$what],$format); |
|
| 302 | + $value = Api\DateTime::to($event[$what], $format); |
|
| 303 | 303 | if ($format == 'l') $value = lang($value); |
| 304 | - $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; |
|
| 304 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$what.$name.'$$'] = $value; |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | - $duration = ($event['end'] - $event['start'])/60; |
|
| 308 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
| 307 | + $duration = ($event['end'] - $event['start']) / 60; |
|
| 308 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
| 309 | 309 | |
| 310 | 310 | // Add in contact stuff for owner |
| 311 | - if (strpos($content,'$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'],'person_id'))) |
|
| 311 | + if (strpos($content, '$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'], 'person_id'))) |
|
| 312 | 312 | { |
| 313 | - $replacements += $this->contact_replacements($user,($prefix ? $prefix.'/':'').'calendar_owner'); |
|
| 314 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'],'account_primary_group')); |
|
| 313 | + $replacements += $this->contact_replacements($user, ($prefix ? $prefix.'/' : '').'calendar_owner'); |
|
| 314 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_primary_group')); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if($content && strpos($content, '$$#') !== FALSE) |
|
| 317 | + if ($content && strpos($content, '$$#') !== FALSE) |
|
| 318 | 318 | { |
| 319 | 319 | $this->cf_link_to_expand($event, $content, $replacements); |
| 320 | 320 | } |
@@ -340,77 +340,77 @@ discard block |
||
| 340 | 340 | * @param string $repeat Text being repeated for each entry |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
| 343 | - public function day_plugin($plugin,$date,$n,$repeat) |
|
| 343 | + public function day_plugin($plugin, $date, $n, $repeat) |
|
| 344 | 344 | { |
| 345 | 345 | static $days = null; |
| 346 | - if(is_array($date) && !$date['start']) { |
|
| 346 | + if (is_array($date) && !$date['start']) { |
|
| 347 | 347 | // List of IDs |
| 348 | - if($date[0]['start']) { |
|
| 348 | + if ($date[0]['start']) { |
|
| 349 | 349 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
| 350 | - foreach($date as $event) { |
|
| 351 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 352 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 350 | + foreach ($date as $event) { |
|
| 351 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 352 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 353 | 353 | } |
| 354 | 354 | $date = $id; |
| 355 | 355 | } else { |
| 356 | 356 | $event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null); |
| 357 | - if(date('l',$event['start']) != $plugin) return array(); |
|
| 357 | + if (date('l', $event['start']) != $plugin) return array(); |
|
| 358 | 358 | $date = $event['start']; |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $_date = $date['start'] ? $date['start'] : $date; |
| 363 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 363 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
| 364 | 364 | |
| 365 | 365 | $events = $this->bo->search($this->query + array( |
| 366 | - 'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
| 367 | - 'end' => $date['end'] ? $date['end'] : mktime(23,59,59,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
| 366 | + 'start' => $date['end'] ? $date['start'] : mktime(0, 0, 0, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
| 367 | + 'end' => $date['end'] ? $date['end'] : mktime(23, 59, 59, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
| 368 | 368 | 'offset' => 0, |
| 369 | 369 | 'num_rows' => 20, |
| 370 | 370 | 'order' => 'cal_start', |
| 371 | 371 | 'daywise' => true, |
| 372 | - 'cfs' => array(), // read all custom-fields |
|
| 372 | + 'cfs' => array(), // read all custom-fields |
|
| 373 | 373 | )); |
| 374 | 374 | |
| 375 | 375 | if (true) $days = array(); |
| 376 | 376 | $replacements = array(); |
| 377 | 377 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 378 | - foreach($events as $day => $list) |
|
| 378 | + foreach ($events as $day => $list) |
|
| 379 | 379 | { |
| 380 | - foreach($list as $event) |
|
| 380 | + foreach ($list as $event) |
|
| 381 | 381 | { |
| 382 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 382 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 383 | 383 | $start = Api\DateTime::to($event['start'], 'array'); |
| 384 | 384 | $end = Api\DateTime::to($event['end'], 'array'); |
| 385 | 385 | $replacements = $this->calendar_replacements($event); |
| 386 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 387 | - $dow = date('l',$event['start']); |
|
| 386 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 387 | + $dow = date('l', $event['start']); |
|
| 388 | 388 | } else { |
| 389 | 389 | $dow = date('l', strtotime($day)); |
| 390 | 390 | // Fancy date+time formatting for multi-day events |
| 391 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
| 392 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
| 391 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
| 392 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - $days[date('Ymd',$_date)][$dow][] = $replacements; |
|
| 395 | + $days[date('Ymd', $_date)][$dow][] = $replacements; |
|
| 396 | 396 | } |
| 397 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 397 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 398 | 398 | $date_marker = array( |
| 399 | 399 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
| 400 | 400 | '$$day/name$$' => lang(date('l', strtotime($day))) |
| 401 | 401 | ); |
| 402 | - if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) { |
|
| 402 | + if (!is_array($days[date('Ymd', $_date)][date('l', strtotime($day))])) { |
|
| 403 | 403 | $blank = $this->calendar_replacements(array()); |
| 404 | - foreach($blank as &$value) |
|
| 404 | + foreach ($blank as &$value) |
|
| 405 | 405 | { |
| 406 | 406 | $value = ''; |
| 407 | 407 | } |
| 408 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][] = $blank; |
|
| 408 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][] = $blank; |
|
| 409 | 409 | } |
| 410 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][0] += $date_marker; |
|
| 410 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][0] += $date_marker; |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
| 413 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -424,27 +424,27 @@ discard block |
||
| 424 | 424 | * @param string $repeat Text being repeated for each entry |
| 425 | 425 | * @return array |
| 426 | 426 | */ |
| 427 | - public function day($plugin,$id,$n,$repeat) |
|
| 427 | + public function day($plugin, $id, $n, $repeat) |
|
| 428 | 428 | { |
| 429 | 429 | static $days = null; |
| 430 | 430 | |
| 431 | 431 | // Figure out which day |
| 432 | - list($type, $which) = explode('_',$plugin); |
|
| 433 | - if($type == 'day' && $which) |
|
| 432 | + list($type, $which) = explode('_', $plugin); |
|
| 433 | + if ($type == 'day' && $which) |
|
| 434 | 434 | { |
| 435 | - if($id[0]['start']) |
|
| 435 | + if ($id[0]['start']) |
|
| 436 | 436 | { |
| 437 | 437 | $dates = array('start' => PHP_INT_MAX, 'end' => 0); |
| 438 | - foreach($id as $event) { |
|
| 439 | - if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
| 440 | - if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
| 438 | + foreach ($id as $event) { |
|
| 439 | + if ($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
| 440 | + if ($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
| 441 | 441 | } |
| 442 | 442 | $id = $dates; |
| 443 | 443 | } |
| 444 | 444 | $arr = $this->bo->date2array($id['start']); |
| 445 | 445 | $arr['day'] = $which; |
| 446 | 446 | $date = $this->bo->date2ts($arr); |
| 447 | - if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
| 447 | + if (is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
| 448 | 448 | } |
| 449 | 449 | elseif ($plugin == 'selected') |
| 450 | 450 | { |
@@ -454,64 +454,64 @@ discard block |
||
| 454 | 454 | { |
| 455 | 455 | $date = strtotime($plugin); |
| 456 | 456 | } |
| 457 | - if($type == 'day' && is_array($id) && !$id['start']) { |
|
| 457 | + if ($type == 'day' && is_array($id) && !$id['start']) { |
|
| 458 | 458 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 459 | - if($which && date('d',$event['start']) != $which) return array(); |
|
| 460 | - if(date('Ymd',$date) != date('Ymd', $event['start'])) return array(); |
|
| 459 | + if ($which && date('d', $event['start']) != $which) return array(); |
|
| 460 | + if (date('Ymd', $date) != date('Ymd', $event['start'])) return array(); |
|
| 461 | 461 | return $n == 0 ? $this->calendar_replacements($event) : array(); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Use start for cache, in case of multiple months |
| 465 | 465 | $_date = $id['start'] ? $id['start'] : $date; |
| 466 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 466 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
| 467 | 467 | |
| 468 | 468 | $events = $this->bo->search($this->query + array( |
| 469 | 469 | 'start' => $date, |
| 470 | - 'end' => mktime(23,59,59,date('m',$date),date('d',$date),date('Y',$date)), |
|
| 470 | + 'end' => mktime(23, 59, 59, date('m', $date), date('d', $date), date('Y', $date)), |
|
| 471 | 471 | 'offset' => 0, |
| 472 | 472 | 'num_rows' => 20, |
| 473 | 473 | 'order' => 'cal_start', |
| 474 | 474 | 'daywise' => true, |
| 475 | - 'cfs' => array(), // read all custom-fields |
|
| 475 | + 'cfs' => array(), // read all custom-fields |
|
| 476 | 476 | )); |
| 477 | 477 | |
| 478 | 478 | $replacements = array(); |
| 479 | 479 | if (true) $days = array(); |
| 480 | 480 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 481 | - foreach($events as $day => $list) |
|
| 481 | + foreach ($events as $day => $list) |
|
| 482 | 482 | { |
| 483 | - foreach($list as $event) |
|
| 483 | + foreach ($list as $event) |
|
| 484 | 484 | { |
| 485 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 485 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 486 | 486 | $start = Api\DateTime::to($event['start'], 'array'); |
| 487 | 487 | $end = Api\DateTime::to($event['end'], 'array'); |
| 488 | 488 | $replacements = $this->calendar_replacements($event); |
| 489 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 489 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 490 | 490 | //$dow = date('l',$event['start']); |
| 491 | 491 | } else { |
| 492 | 492 | // Fancy date+time formatting for multi-day events |
| 493 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
| 494 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
| 493 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
| 494 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
| 495 | 495 | } |
| 496 | - $days[date('Ymd',$_date)][$plugin][] = $replacements; |
|
| 496 | + $days[date('Ymd', $_date)][$plugin][] = $replacements; |
|
| 497 | 497 | } |
| 498 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 498 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 499 | 499 | $date_marker = array( |
| 500 | 500 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
| 501 | 501 | '$$day/name$$' => lang(date('l', strtotime($day))) |
| 502 | 502 | ); |
| 503 | - if(!is_array($days[date('Ymd',$_date)][$plugin])) { |
|
| 503 | + if (!is_array($days[date('Ymd', $_date)][$plugin])) { |
|
| 504 | 504 | $blank = $this->calendar_replacements(array()); |
| 505 | - foreach($blank as &$value) |
|
| 505 | + foreach ($blank as &$value) |
|
| 506 | 506 | { |
| 507 | 507 | $value = ''; |
| 508 | 508 | } |
| 509 | - $days[date('Ymd',$_date)][$plugin][] = $blank; |
|
| 509 | + $days[date('Ymd', $_date)][$plugin][] = $blank; |
|
| 510 | 510 | } |
| 511 | - $days[date('Ymd',$_date)][$plugin][0] += $date_marker; |
|
| 511 | + $days[date('Ymd', $_date)][$plugin][0] += $date_marker; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
| 514 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -524,30 +524,30 @@ discard block |
||
| 524 | 524 | * @param int $n |
| 525 | 525 | * @return array |
| 526 | 526 | */ |
| 527 | - public function participant($plugin,$id,$n) |
|
| 527 | + public function participant($plugin, $id, $n) |
|
| 528 | 528 | { |
| 529 | - unset($plugin); // not used, but required by function signature |
|
| 529 | + unset($plugin); // not used, but required by function signature |
|
| 530 | 530 | |
| 531 | - if(!is_array($id) || !$id['start']) { |
|
| 531 | + if (!is_array($id) || !$id['start']) { |
|
| 532 | 532 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 533 | 533 | } else { |
| 534 | 534 | $event = $id; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - if(!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
| 537 | + if (!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
| 538 | 538 | |
| 539 | 539 | $participant = null; |
| 540 | 540 | $status = null; |
| 541 | 541 | $i = -1; |
| 542 | - foreach($event['participants'] as $participant => $status) { |
|
| 543 | - if(++$i == $n) break; |
|
| 542 | + foreach ($event['participants'] as $participant => $status) { |
|
| 543 | + if (++$i == $n) break; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - if(!$participant) return array(); |
|
| 546 | + if (!$participant) return array(); |
|
| 547 | 547 | |
| 548 | 548 | // Add some common information |
| 549 | 549 | $quantity = $role = null; |
| 550 | - calendar_so::split_status($status,$quantity,$role); |
|
| 550 | + calendar_so::split_status($status, $quantity, $role); |
|
| 551 | 551 | if ($role != 'REQ-PARTICIPANT') |
| 552 | 552 | { |
| 553 | 553 | if (isset($this->bo->roles[$role])) |
@@ -555,13 +555,13 @@ discard block |
||
| 555 | 555 | $role = lang($this->bo->roles[$role]); |
| 556 | 556 | } |
| 557 | 557 | // allow to use cats as roles (beside regular iCal ones) |
| 558 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
| 558 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
| 559 | 559 | { |
| 560 | 560 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
| 561 | 561 | } |
| 562 | 562 | else |
| 563 | 563 | { |
| 564 | - $role = lang(str_replace('X-','',$role)); |
|
| 564 | + $role = lang(str_replace('X-', '', $role)); |
|
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | $info = array( |
@@ -574,26 +574,26 @@ discard block |
||
| 574 | 574 | switch ($participant[0]) |
| 575 | 575 | { |
| 576 | 576 | case 'c': |
| 577 | - $replacements = $this->contact_replacements(substr($participant,1),''); |
|
| 577 | + $replacements = $this->contact_replacements(substr($participant, 1), ''); |
|
| 578 | 578 | break; |
| 579 | 579 | case 'r': |
| 580 | 580 | if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo'); |
| 581 | - if (($resource = self::$resources->read(substr($participant,1)))) |
|
| 581 | + if (($resource = self::$resources->read(substr($participant, 1)))) |
|
| 582 | 582 | { |
| 583 | - foreach($resource as $name => $value) |
|
| 583 | + foreach ($resource as $name => $value) |
|
| 584 | 584 | { |
| 585 | 585 | $replacements['$$'.$name.'$$'] = $value; |
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | break; |
| 589 | 589 | default: |
| 590 | - if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant,'person_id'))) |
|
| 590 | + if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant, 'person_id'))) |
|
| 591 | 591 | { |
| 592 | - $replacements = $this->contact_replacements($contact,''); |
|
| 592 | + $replacements = $this->contact_replacements($contact, ''); |
|
| 593 | 593 | } |
| 594 | 594 | break; |
| 595 | 595 | } |
| 596 | - foreach($info as $name => $value) |
|
| 596 | + foreach ($info as $name => $value) |
|
| 597 | 597 | { |
| 598 | 598 | $replacements['$$'.$name.'$$'] = $value; |
| 599 | 599 | } |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>"; |
| 616 | 616 | |
| 617 | 617 | $n = 0; |
| 618 | - foreach(array( |
|
| 618 | + foreach (array( |
|
| 619 | 619 | 'calendar_id' => lang('Calendar ID'), |
| 620 | 620 | 'calendar_title' => lang('Title'), |
| 621 | 621 | 'calendar_description' => lang('Description'), |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | 'calendar_owner' => lang('Owner'), |
| 639 | 639 | ) as $name => $label) |
| 640 | 640 | { |
| 641 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
| 641 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
| 642 | 642 | { |
| 643 | 643 | echo "</tr>\n"; |
| 644 | 644 | $n++; |
@@ -651,13 +651,13 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | echo '<tr><td colspan="4"><h3>'.lang('Range fields').":</h3></td></tr>"; |
| 653 | 653 | echo '<tr><td colspan="4">'.lang('If you select a range (month, week, etc) instead of a list of entries, these extra fields are available').'</td></tr>'; |
| 654 | - foreach(array_keys(self::$range_tags) as $name) |
|
| 654 | + foreach (array_keys(self::$range_tags) as $name) |
|
| 655 | 655 | { |
| 656 | 656 | echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n"; |
| 657 | 657 | } |
| 658 | 658 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
| 659 | 659 | $custom = Api\Storage\Customfields::get('calendar'); |
| 660 | - foreach($custom as $name => $field) |
|
| 660 | + foreach ($custom as $name => $field) |
|
| 661 | 661 | { |
| 662 | 662 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
| 663 | 663 | } |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | echo '<tr><td colspan="4"><h3>'.lang('Participants').":</h3></td></tr>"; |
| 667 | 667 | echo '<tr><td>{{calendar_participants/account}}</td><td colspan="3">'.lang('Accounts')."</td></tr>\n"; |
| 668 | 668 | echo '<tr><td>{{calendar_participants/group}}</td><td colspan="3">'.lang('Groups')."</td></tr>\n"; |
| 669 | - foreach($this->bo->resources as $resource) |
|
| 669 | + foreach ($this->bo->resources as $resource) |
|
| 670 | 670 | { |
| 671 | - if($resource['type']) |
|
| 671 | + if ($resource['type']) |
|
| 672 | 672 | { |
| 673 | 673 | echo '<tr><td>{{calendar_participants/'.$resource['app'].'}}</td><td colspan="3">'.lang($resource['app'])."</td></tr>\n"; |
| 674 | 674 | } |
@@ -685,19 +685,19 @@ discard block |
||
| 685 | 685 | echo '<tr style="vertical-align:top"><td colspan="2"><table >'; |
| 686 | 686 | echo '<tr><td><h3>'.lang('Day of week tables').":</h3></td></tr>"; |
| 687 | 687 | $days = array(); |
| 688 | - for($i = 0; $i < 7; $i++) |
|
| 688 | + for ($i = 0; $i < 7; $i++) |
|
| 689 | 689 | { |
| 690 | - $days[date('N',strtotime("+$i days"))] = date('l',strtotime("+$i days")); |
|
| 690 | + $days[date('N', strtotime("+$i days"))] = date('l', strtotime("+$i days")); |
|
| 691 | 691 | } |
| 692 | 692 | ksort($days); |
| 693 | - foreach($days as $day) |
|
| 693 | + foreach ($days as $day) |
|
| 694 | 694 | { |
| 695 | - echo '<tr><td>{{table/'.$day. '}} ... {{endtable}}</td></tr>'; |
|
| 695 | + echo '<tr><td>{{table/'.$day.'}} ... {{endtable}}</td></tr>'; |
|
| 696 | 696 | } |
| 697 | 697 | echo '</table></td><td colspan="2"><table >'; |
| 698 | 698 | echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>"; |
| 699 | - foreach(self::$relative as $value) { |
|
| 700 | - echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>'; |
|
| 699 | + foreach (self::$relative as $value) { |
|
| 700 | + echo '<tr><td>{{table/'.$value.'}} ... {{endtable}}</td></tr>'; |
|
| 701 | 701 | } |
| 702 | 702 | echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>'; |
| 703 | 703 | echo '</table></td></tr>'; |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>'; |
| 706 | 706 | |
| 707 | 707 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
| 708 | - foreach(array( |
|
| 708 | + foreach (array( |
|
| 709 | 709 | 'link' => lang('HTML link to the current record'), |
| 710 | 710 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
| 711 | 711 | 'attachments' => lang('List of files linked to the current record'), |
@@ -88,10 +88,12 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin'; |
| 90 | 90 | } |
| 91 | - for($i = 1; $i <= 31; $i++) { |
|
| 91 | + for($i = 1; $i <= 31; $i++) |
|
| 92 | + { |
|
| 92 | 93 | $this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31) |
| 93 | 94 | } |
| 94 | - foreach(self::$relative as $day) { |
|
| 95 | + foreach(self::$relative as $day) |
|
| 96 | + { |
|
| 95 | 97 | $this->table_plugins[$day] = 'day'; // Current day |
| 96 | 98 | } |
| 97 | 99 | $this->query = is_array($this->bo->cal_prefs['saved_states']) ? |
@@ -131,9 +133,16 @@ discard block |
||
| 131 | 133 | $events = $ids; |
| 132 | 134 | $ids = array('start' => PHP_INT_MAX, 'end' => 0); |
| 133 | 135 | $this->ids = array(); |
| 134 | - foreach($events as $event) { |
|
| 135 | - if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 136 | - if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts'); |
|
| 136 | + foreach($events as $event) |
|
| 137 | + { |
|
| 138 | + if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) |
|
| 139 | + { |
|
| 140 | + $ids['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 141 | + } |
|
| 142 | + if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) |
|
| 143 | + { |
|
| 144 | + $ids['end'] = Api\DateTime::to($event['end'],'ts'); |
|
| 145 | + } |
|
| 137 | 146 | // Keep ids for future use |
| 138 | 147 | $this->ids[] = $event['id']; |
| 139 | 148 | } |
@@ -154,7 +163,8 @@ discard block |
||
| 154 | 163 | 'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null |
| 155 | 164 | )); |
| 156 | 165 | $ids = array(); |
| 157 | - foreach($events as $event) { |
|
| 166 | + foreach($events as $event) |
|
| 167 | + { |
|
| 158 | 168 | $ids[] = $event; |
| 159 | 169 | } |
| 160 | 170 | } |
@@ -192,9 +202,16 @@ discard block |
||
| 192 | 202 | $events = $id; |
| 193 | 203 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
| 194 | 204 | $this->ids = array(); |
| 195 | - foreach($events as $event) { |
|
| 196 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 197 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 205 | + foreach($events as $event) |
|
| 206 | + { |
|
| 207 | + if($event['start'] && $event['start'] < $id['start']) |
|
| 208 | + { |
|
| 209 | + $id['start'] = $event['start']; |
|
| 210 | + } |
|
| 211 | + if($event['end'] && $event['end'] > $id['end']) |
|
| 212 | + { |
|
| 213 | + $id['end'] = $event['end']; |
|
| 214 | + } |
|
| 198 | 215 | // Keep ids for future use |
| 199 | 216 | $this->ids[] = $event['id']; |
| 200 | 217 | } |
@@ -221,7 +238,10 @@ discard block |
||
| 221 | 238 | foreach(self::$range_tags as $key => $format) |
| 222 | 239 | { |
| 223 | 240 | $value = date($format, $key == 'end' ? $id['end'] : $id['start']); |
| 224 | - if($key == 'month') $value = lang($value); |
|
| 241 | + if($key == 'month') |
|
| 242 | + { |
|
| 243 | + $value = lang($value); |
|
| 244 | + } |
|
| 225 | 245 | $values["$\$range/$key$$"] = $value; |
| 226 | 246 | } |
| 227 | 247 | } |
@@ -240,9 +260,12 @@ discard block |
||
| 240 | 260 | public function calendar_replacements($id,$prefix = '', &$content = '') |
| 241 | 261 | { |
| 242 | 262 | $replacements = array(); |
| 243 | - if(!is_array($id) || !$id['start']) { |
|
| 263 | + if(!is_array($id) || !$id['start']) |
|
| 264 | + { |
|
| 244 | 265 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 245 | - } else { |
|
| 266 | + } |
|
| 267 | + else |
|
| 268 | + { |
|
| 246 | 269 | $event = $id; |
| 247 | 270 | } |
| 248 | 271 | |
@@ -261,7 +284,10 @@ discard block |
||
| 261 | 284 | $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id']; |
| 262 | 285 | foreach($this->bo->event2array($event) as $name => $data) |
| 263 | 286 | { |
| 264 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
| 287 | + if (substr($name,-4) == 'date') |
|
| 288 | + { |
|
| 289 | + $name = substr($name,0,-4); |
|
| 290 | + } |
|
| 265 | 291 | $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
| 266 | 292 | } |
| 267 | 293 | // Add seperate lists of participants by type |
@@ -300,7 +326,10 @@ discard block |
||
| 300 | 326 | ) as $name => $format) |
| 301 | 327 | { |
| 302 | 328 | $value = Api\DateTime::to($event[$what],$format); |
| 303 | - if ($format == 'l') $value = lang($value); |
|
| 329 | + if ($format == 'l') |
|
| 330 | + { |
|
| 331 | + $value = lang($value); |
|
| 332 | + } |
|
| 304 | 333 | $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; |
| 305 | 334 | } |
| 306 | 335 | } |
@@ -343,24 +372,41 @@ discard block |
||
| 343 | 372 | public function day_plugin($plugin,$date,$n,$repeat) |
| 344 | 373 | { |
| 345 | 374 | static $days = null; |
| 346 | - if(is_array($date) && !$date['start']) { |
|
| 375 | + if(is_array($date) && !$date['start']) |
|
| 376 | + { |
|
| 347 | 377 | // List of IDs |
| 348 | - if($date[0]['start']) { |
|
| 378 | + if($date[0]['start']) |
|
| 379 | + { |
|
| 349 | 380 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
| 350 | - foreach($date as $event) { |
|
| 351 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
| 352 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
| 381 | + foreach($date as $event) |
|
| 382 | + { |
|
| 383 | + if($event['start'] && $event['start'] < $id['start']) |
|
| 384 | + { |
|
| 385 | + $id['start'] = $event['start']; |
|
| 386 | + } |
|
| 387 | + if($event['end'] && $event['end'] > $id['end']) |
|
| 388 | + { |
|
| 389 | + $id['end'] = $event['end']; |
|
| 390 | + } |
|
| 353 | 391 | } |
| 354 | 392 | $date = $id; |
| 355 | - } else { |
|
| 393 | + } |
|
| 394 | + else |
|
| 395 | + { |
|
| 356 | 396 | $event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null); |
| 357 | - if(date('l',$event['start']) != $plugin) return array(); |
|
| 397 | + if(date('l',$event['start']) != $plugin) |
|
| 398 | + { |
|
| 399 | + return array(); |
|
| 400 | + } |
|
| 358 | 401 | $date = $event['start']; |
| 359 | 402 | } |
| 360 | 403 | } |
| 361 | 404 | |
| 362 | 405 | $_date = $date['start'] ? $date['start'] : $date; |
| 363 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 406 | + if($days[date('Ymd',$_date)][$plugin]) |
|
| 407 | + { |
|
| 408 | + return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 409 | + } |
|
| 364 | 410 | |
| 365 | 411 | $events = $this->bo->search($this->query + array( |
| 366 | 412 | 'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)), |
@@ -372,20 +418,29 @@ discard block |
||
| 372 | 418 | 'cfs' => array(), // read all custom-fields |
| 373 | 419 | )); |
| 374 | 420 | |
| 375 | - if (true) $days = array(); |
|
| 421 | + if (true) |
|
| 422 | + { |
|
| 423 | + $days = array(); |
|
| 424 | + } |
|
| 376 | 425 | $replacements = array(); |
| 377 | 426 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 378 | 427 | foreach($events as $day => $list) |
| 379 | 428 | { |
| 380 | 429 | foreach($list as $event) |
| 381 | 430 | { |
| 382 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 431 | + if($this->ids && !in_array($event['id'], $this->ids)) |
|
| 432 | + { |
|
| 433 | + continue; |
|
| 434 | + } |
|
| 383 | 435 | $start = Api\DateTime::to($event['start'], 'array'); |
| 384 | 436 | $end = Api\DateTime::to($event['end'], 'array'); |
| 385 | 437 | $replacements = $this->calendar_replacements($event); |
| 386 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 438 | + if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) |
|
| 439 | + { |
|
| 387 | 440 | $dow = date('l',$event['start']); |
| 388 | - } else { |
|
| 441 | + } |
|
| 442 | + else |
|
| 443 | + { |
|
| 389 | 444 | $dow = date('l', strtotime($day)); |
| 390 | 445 | // Fancy date+time formatting for multi-day events |
| 391 | 446 | $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
@@ -394,12 +449,14 @@ discard block |
||
| 394 | 449 | |
| 395 | 450 | $days[date('Ymd',$_date)][$dow][] = $replacements; |
| 396 | 451 | } |
| 397 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 452 | + if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) |
|
| 453 | + { |
|
| 398 | 454 | $date_marker = array( |
| 399 | 455 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
| 400 | 456 | '$$day/name$$' => lang(date('l', strtotime($day))) |
| 401 | 457 | ); |
| 402 | - if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) { |
|
| 458 | + if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) |
|
| 459 | + { |
|
| 403 | 460 | $blank = $this->calendar_replacements(array()); |
| 404 | 461 | foreach($blank as &$value) |
| 405 | 462 | { |
@@ -435,16 +492,26 @@ discard block |
||
| 435 | 492 | if($id[0]['start']) |
| 436 | 493 | { |
| 437 | 494 | $dates = array('start' => PHP_INT_MAX, 'end' => 0); |
| 438 | - foreach($id as $event) { |
|
| 439 | - if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
| 440 | - if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
| 495 | + foreach($id as $event) |
|
| 496 | + { |
|
| 497 | + if($event['start'] && $event['start'] < $dates['start']) |
|
| 498 | + { |
|
| 499 | + $dates['start'] = $event['start']; |
|
| 500 | + } |
|
| 501 | + if($event['end'] && $event['end'] > $dates['end']) |
|
| 502 | + { |
|
| 503 | + $dates['end'] = $event['end']; |
|
| 504 | + } |
|
| 441 | 505 | } |
| 442 | 506 | $id = $dates; |
| 443 | 507 | } |
| 444 | 508 | $arr = $this->bo->date2array($id['start']); |
| 445 | 509 | $arr['day'] = $which; |
| 446 | 510 | $date = $this->bo->date2ts($arr); |
| 447 | - if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
| 511 | + if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) |
|
| 512 | + { |
|
| 513 | + return array(); |
|
| 514 | + } |
|
| 448 | 515 | } |
| 449 | 516 | elseif ($plugin == 'selected') |
| 450 | 517 | { |
@@ -454,16 +521,26 @@ discard block |
||
| 454 | 521 | { |
| 455 | 522 | $date = strtotime($plugin); |
| 456 | 523 | } |
| 457 | - if($type == 'day' && is_array($id) && !$id['start']) { |
|
| 524 | + if($type == 'day' && is_array($id) && !$id['start']) |
|
| 525 | + { |
|
| 458 | 526 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 459 | - if($which && date('d',$event['start']) != $which) return array(); |
|
| 460 | - if(date('Ymd',$date) != date('Ymd', $event['start'])) return array(); |
|
| 527 | + if($which && date('d',$event['start']) != $which) |
|
| 528 | + { |
|
| 529 | + return array(); |
|
| 530 | + } |
|
| 531 | + if(date('Ymd',$date) != date('Ymd', $event['start'])) |
|
| 532 | + { |
|
| 533 | + return array(); |
|
| 534 | + } |
|
| 461 | 535 | return $n == 0 ? $this->calendar_replacements($event) : array(); |
| 462 | 536 | } |
| 463 | 537 | |
| 464 | 538 | // Use start for cache, in case of multiple months |
| 465 | 539 | $_date = $id['start'] ? $id['start'] : $date; |
| 466 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 540 | + if($days[date('Ymd',$_date)][$plugin]) |
|
| 541 | + { |
|
| 542 | + return $days[date('Ymd',$_date)][$plugin][$n]; |
|
| 543 | + } |
|
| 467 | 544 | |
| 468 | 545 | $events = $this->bo->search($this->query + array( |
| 469 | 546 | 'start' => $date, |
@@ -476,31 +553,42 @@ discard block |
||
| 476 | 553 | )); |
| 477 | 554 | |
| 478 | 555 | $replacements = array(); |
| 479 | - if (true) $days = array(); |
|
| 556 | + if (true) |
|
| 557 | + { |
|
| 558 | + $days = array(); |
|
| 559 | + } |
|
| 480 | 560 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 481 | 561 | foreach($events as $day => $list) |
| 482 | 562 | { |
| 483 | 563 | foreach($list as $event) |
| 484 | 564 | { |
| 485 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
| 565 | + if($this->ids && !in_array($event['id'], $this->ids)) |
|
| 566 | + { |
|
| 567 | + continue; |
|
| 568 | + } |
|
| 486 | 569 | $start = Api\DateTime::to($event['start'], 'array'); |
| 487 | 570 | $end = Api\DateTime::to($event['end'], 'array'); |
| 488 | 571 | $replacements = $this->calendar_replacements($event); |
| 489 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
| 572 | + if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) |
|
| 573 | + { |
|
| 490 | 574 | //$dow = date('l',$event['start']); |
| 491 | - } else { |
|
| 575 | + } |
|
| 576 | + else |
|
| 577 | + { |
|
| 492 | 578 | // Fancy date+time formatting for multi-day events |
| 493 | 579 | $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
| 494 | 580 | $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
| 495 | 581 | } |
| 496 | 582 | $days[date('Ymd',$_date)][$plugin][] = $replacements; |
| 497 | 583 | } |
| 498 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
| 584 | + if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) |
|
| 585 | + { |
|
| 499 | 586 | $date_marker = array( |
| 500 | 587 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
| 501 | 588 | '$$day/name$$' => lang(date('l', strtotime($day))) |
| 502 | 589 | ); |
| 503 | - if(!is_array($days[date('Ymd',$_date)][$plugin])) { |
|
| 590 | + if(!is_array($days[date('Ymd',$_date)][$plugin])) |
|
| 591 | + { |
|
| 504 | 592 | $blank = $this->calendar_replacements(array()); |
| 505 | 593 | foreach($blank as &$value) |
| 506 | 594 | { |
@@ -528,22 +616,35 @@ discard block |
||
| 528 | 616 | { |
| 529 | 617 | unset($plugin); // not used, but required by function signature |
| 530 | 618 | |
| 531 | - if(!is_array($id) || !$id['start']) { |
|
| 619 | + if(!is_array($id) || !$id['start']) |
|
| 620 | + { |
|
| 532 | 621 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
| 533 | - } else { |
|
| 622 | + } |
|
| 623 | + else |
|
| 624 | + { |
|
| 534 | 625 | $event = $id; |
| 535 | 626 | } |
| 536 | 627 | |
| 537 | - if(!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
| 628 | + if(!is_array($event['participants']) || $n >= count($event['participants'])) |
|
| 629 | + { |
|
| 630 | + return array(); |
|
| 631 | + } |
|
| 538 | 632 | |
| 539 | 633 | $participant = null; |
| 540 | 634 | $status = null; |
| 541 | 635 | $i = -1; |
| 542 | - foreach($event['participants'] as $participant => $status) { |
|
| 543 | - if(++$i == $n) break; |
|
| 636 | + foreach($event['participants'] as $participant => $status) |
|
| 637 | + { |
|
| 638 | + if(++$i == $n) |
|
| 639 | + { |
|
| 640 | + break; |
|
| 641 | + } |
|
| 544 | 642 | } |
| 545 | 643 | |
| 546 | - if(!$participant) return array(); |
|
| 644 | + if(!$participant) |
|
| 645 | + { |
|
| 646 | + return array(); |
|
| 647 | + } |
|
| 547 | 648 | |
| 548 | 649 | // Add some common information |
| 549 | 650 | $quantity = $role = null; |
@@ -577,7 +678,10 @@ discard block |
||
| 577 | 678 | $replacements = $this->contact_replacements(substr($participant,1),''); |
| 578 | 679 | break; |
| 579 | 680 | case 'r': |
| 580 | - if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo'); |
|
| 681 | + if (is_null(self::$resources)) |
|
| 682 | + { |
|
| 683 | + self::$resources = CreateObject('resources.resources_bo'); |
|
| 684 | + } |
|
| 581 | 685 | if (($resource = self::$resources->read(substr($participant,1)))) |
| 582 | 686 | { |
| 583 | 687 | foreach($resource as $name => $value) |
@@ -638,14 +742,23 @@ discard block |
||
| 638 | 742 | 'calendar_owner' => lang('Owner'), |
| 639 | 743 | ) as $name => $label) |
| 640 | 744 | { |
| 641 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
| 745 | + if (in_array($name,array('start','end')) && $n&1) |
|
| 746 | + { |
|
| 747 | + // main values, which should be in the first column |
|
| 642 | 748 | { |
| 643 | 749 | echo "</tr>\n"; |
| 750 | + } |
|
| 644 | 751 | $n++; |
| 645 | 752 | } |
| 646 | - if (!($n&1)) echo '<tr>'; |
|
| 753 | + if (!($n&1)) |
|
| 754 | + { |
|
| 755 | + echo '<tr>'; |
|
| 756 | + } |
|
| 647 | 757 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
| 648 | - if ($n&1) echo "</tr>\n"; |
|
| 758 | + if ($n&1) |
|
| 759 | + { |
|
| 760 | + echo "</tr>\n"; |
|
| 761 | + } |
|
| 649 | 762 | $n++; |
| 650 | 763 | } |
| 651 | 764 | |
@@ -696,7 +809,8 @@ discard block |
||
| 696 | 809 | } |
| 697 | 810 | echo '</table></td><td colspan="2"><table >'; |
| 698 | 811 | echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>"; |
| 699 | - foreach(self::$relative as $value) { |
|
| 812 | + foreach(self::$relative as $value) |
|
| 813 | + { |
|
| 700 | 814 | echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>'; |
| 701 | 815 | } |
| 702 | 816 | echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>'; |
@@ -211,23 +211,11 @@ discard block |
||
| 211 | 211 | * @param int $start startdate of the search/list (servertime) |
| 212 | 212 | * @param int $end enddate of the search/list (servertime) |
| 213 | 213 | * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users |
| 214 | - * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 214 | + * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 215 | 215 | * @param string $filter ='default' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted) |
| 216 | 216 | * @param int|boolean $offset =False offset for a limited query or False (default) |
| 217 | 217 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 218 | 218 | * @param array $params =array() |
| 219 | - * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search) |
|
| 220 | - * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! |
|
| 221 | - * array: everything is directly used as $where |
|
| 222 | - * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma |
|
| 223 | - * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted) |
|
| 224 | - * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date", |
|
| 225 | - * if specified and not false an iterator for the rows is returned |
|
| 226 | - * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause |
|
| 227 | - * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names |
|
| 228 | - * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved! |
|
| 229 | - * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS) |
|
| 230 | - * @param boolean $params['enum_recuring'] =true enumerate recuring events |
|
| 231 | 219 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 232 | 220 | * @return array of events |
| 233 | 221 | */ |
@@ -594,7 +582,7 @@ discard block |
||
| 594 | 582 | /** |
| 595 | 583 | * generate SQL to filter after a given category (incl. subcategories) |
| 596 | 584 | * |
| 597 | - * @param array|int $cat_id cat-id or array of cat-ids, or !$cat_id for none |
|
| 585 | + * @param integer $cat_id cat-id or array of cat-ids, or !$cat_id for none |
|
| 598 | 586 | * @return string SQL to include in the query |
| 599 | 587 | */ |
| 600 | 588 | function cat_filter($cat_id) |
@@ -682,24 +670,11 @@ discard block |
||
| 682 | 670 | * @param int $start startdate of the search/list (servertime) |
| 683 | 671 | * @param int $end enddate of the search/list (servertime) |
| 684 | 672 | * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users |
| 685 | - * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 673 | + * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 686 | 674 | * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted) |
| 687 | 675 | * @param int|boolean $offset =False offset for a limited query or False (default) |
| 688 | 676 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 689 | 677 | * @param array $params =array() |
| 690 | - * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search) |
|
| 691 | - * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! |
|
| 692 | - * array: everything is directly used as $where |
|
| 693 | - * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma |
|
| 694 | - * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array |
|
| 695 | - * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date", |
|
| 696 | - * if specified and not false an iterator for the rows is returned |
|
| 697 | - * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause |
|
| 698 | - * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names |
|
| 699 | - * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved! |
|
| 700 | - * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS) |
|
| 701 | - * @param boolean $params['enum_recuring'] =true enumerate recuring events |
|
| 702 | - * @param boolean $params['use_so_events'] =false, true return result of new $this->events() |
|
| 703 | 678 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 704 | 679 | * @return Iterator|array of events |
| 705 | 680 | */ |
@@ -1140,11 +1115,11 @@ discard block |
||
| 1140 | 1115 | * Ask other apps if they want to participate in calendar search / display |
| 1141 | 1116 | * |
| 1142 | 1117 | * @param &$selects parts of union query |
| 1143 | - * @param $start see search() |
|
| 1144 | - * @param $end |
|
| 1118 | + * @param integer $start see search() |
|
| 1119 | + * @param integer $end |
|
| 1145 | 1120 | * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo) |
| 1146 | - * @param $cat_id |
|
| 1147 | - * @param $filter |
|
| 1121 | + * @param integer $cat_id |
|
| 1122 | + * @param string $filter |
|
| 1148 | 1123 | * @param $query |
| 1149 | 1124 | * @param $users_raw as passed to calendar_bo::search (no members and memberships added) |
| 1150 | 1125 | */ |
@@ -1312,6 +1287,7 @@ discard block |
||
| 1312 | 1287 | * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all |
| 1313 | 1288 | * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all |
| 1314 | 1289 | * @param int &$etag etag=null etag to check or null, on return new etag |
| 1290 | + * @param boolean $set_recurrences |
|
| 1315 | 1291 | * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise |
| 1316 | 1292 | */ |
| 1317 | 1293 | function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null) |
@@ -1722,7 +1698,7 @@ discard block |
||
| 1722 | 1698 | * @param int $cal_id |
| 1723 | 1699 | * @param int $start new starttime |
| 1724 | 1700 | * @param int $end new endtime |
| 1725 | - * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all |
|
| 1701 | + * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all |
|
| 1726 | 1702 | * @param int $old_start =0 old starttime or (default) 0, to query it from the db |
| 1727 | 1703 | * @param int $old_end =0 old starttime or (default) 0 |
| 1728 | 1704 | * @todo Recalculate recurrences, if timezone changes |
@@ -1899,12 +1875,12 @@ discard block |
||
| 1899 | 1875 | * |
| 1900 | 1876 | * @param int $cal_id |
| 1901 | 1877 | * @param array $participants uid => status pairs |
| 1902 | - * @param int|boolean $change_since =0, false=new event, |
|
| 1878 | + * @param integer $change_since =0, false=new event, |
|
| 1903 | 1879 | * 0=all, > 0 time from which on the repetitions should be changed |
| 1904 | 1880 | * @param boolean $add_only =false |
| 1905 | 1881 | * false = add AND delete participants if needed (full list of participants required in $participants) |
| 1906 | 1882 | * true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants) |
| 1907 | - * @return int|boolean number of updated recurrences or false on error |
|
| 1883 | + * @return boolean number of updated recurrences or false on error |
|
| 1908 | 1884 | */ |
| 1909 | 1885 | function participants($cal_id,$participants,$change_since=0,$add_only=false) |
| 1910 | 1886 | { |
@@ -2045,7 +2021,7 @@ discard block |
||
| 2045 | 2021 | * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0) |
| 2046 | 2022 | * |
| 2047 | 2023 | * @param int $cal_id |
| 2048 | - * @param char $user_type 'u' regular user, 'r' resource, 'c' contact |
|
| 2024 | + * @param string $user_type 'u' regular user, 'r' resource, 'c' contact |
|
| 2049 | 2025 | * @param int|string $user_id |
| 2050 | 2026 | * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A' |
| 2051 | 2027 | * @param int $recur_date =0 date to change, or 0 = all since now |
@@ -2962,7 +2938,7 @@ discard block |
||
| 2962 | 2938 | * Updates the modification timestamp to force an etag, ctag and sync-token change |
| 2963 | 2939 | * |
| 2964 | 2940 | * @param int $id event id |
| 2965 | - * @param int|boolean $update_master =false id of series master or true, to update series master too |
|
| 2941 | + * @param boolean $update_master =false id of series master or true, to update series master too |
|
| 2966 | 2942 | * @param int $time =null new timestamp, default current (server-)time |
| 2967 | 2943 | * @param int $modifier =null uid of the modifier, default current user |
| 2968 | 2944 | */ |
@@ -1528,7 +1528,7 @@ |
||
| 1528 | 1528 | if (!$set_recurrences) |
| 1529 | 1529 | { |
| 1530 | 1530 | $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
| 1531 | - $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1531 | + $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1532 | 1532 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
| 1533 | 1533 | } |
| 1534 | 1534 | |
@@ -154,16 +154,32 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
| 156 | 156 | { |
| 157 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
|
| 157 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) |
|
| 158 | 158 | { |
| 159 | - return $this->cal_table; // no need / use for a view |
|
| 159 | + // using view without start-date is slower! |
|
| 160 | + { |
|
| 161 | + return $this->cal_table; |
|
| 162 | + } |
|
| 163 | + // no need / use for a view |
|
| 160 | 164 | } |
| 161 | 165 | |
| 162 | 166 | $where = array(); |
| 163 | - if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 164 | - if ($end) $where[] = "range_start<".(int)$end; |
|
| 165 | - if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 166 | - if ($_where) $where = array_merge($where, $_where); |
|
| 167 | + if (isset($deleted)) |
|
| 168 | + { |
|
| 169 | + $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 170 | + } |
|
| 171 | + if ($end) |
|
| 172 | + { |
|
| 173 | + $where[] = "range_start<".(int)$end; |
|
| 174 | + } |
|
| 175 | + if ($start) |
|
| 176 | + { |
|
| 177 | + $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 178 | + } |
|
| 179 | + if ($_where) |
|
| 180 | + { |
|
| 181 | + $where = array_merge($where, $_where); |
|
| 182 | + } |
|
| 167 | 183 | |
| 168 | 184 | $sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table"; |
| 169 | 185 | |
@@ -184,16 +200,32 @@ discard block |
||
| 184 | 200 | */ |
| 185 | 201 | protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
| 186 | 202 | { |
| 187 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
|
| 203 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) |
|
| 204 | + { |
|
| 205 | + // using view without start- AND end-date is slower! |
|
| 188 | 206 | { |
| 189 | - return $this->dates_table; // no need / use for a view |
|
| 207 | + return $this->dates_table; |
|
| 208 | + } |
|
| 209 | + // no need / use for a view |
|
| 190 | 210 | } |
| 191 | 211 | |
| 192 | 212 | $where = array(); |
| 193 | - if (isset($deleted)) $where['recur_exception'] = $deleted; |
|
| 194 | - if ($end) $where[] = "cal_start<".(int)$end; |
|
| 195 | - if ($start) $where[] = "cal_end>".(int)$start; |
|
| 196 | - if ($_where) $where = array_merge($where, $_where); |
|
| 213 | + if (isset($deleted)) |
|
| 214 | + { |
|
| 215 | + $where['recur_exception'] = $deleted; |
|
| 216 | + } |
|
| 217 | + if ($end) |
|
| 218 | + { |
|
| 219 | + $where[] = "cal_start<".(int)$end; |
|
| 220 | + } |
|
| 221 | + if ($start) |
|
| 222 | + { |
|
| 223 | + $where[] = "cal_end>".(int)$start; |
|
| 224 | + } |
|
| 225 | + if ($_where) |
|
| 226 | + { |
|
| 227 | + $where = array_merge($where, $_where); |
|
| 228 | + } |
|
| 197 | 229 | |
| 198 | 230 | // Api\Db::union uses Api\Db::select which check if join contains "WHERE" |
| 199 | 231 | // to support old join syntax like ", other_table WHERE ...", |
@@ -243,7 +275,10 @@ discard block |
||
| 243 | 275 | throw new Api\Exception\AssertionFailed("Unsupported value for parameters!"); |
| 244 | 276 | } |
| 245 | 277 | $where = is_array($params['query']) ? $params['query'] : array(); |
| 246 | - if ($cat_id) $where[] = $this->cat_filter($cat_id); |
|
| 278 | + if ($cat_id) |
|
| 279 | + { |
|
| 280 | + $where[] = $this->cat_filter($cat_id); |
|
| 281 | + } |
|
| 247 | 282 | $egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted'); |
| 248 | 283 | |
| 249 | 284 | $status_filter = $this->status_filter($filter, $params['enum_recuring']); |
@@ -264,7 +299,10 @@ discard block |
||
| 264 | 299 | if ($users) |
| 265 | 300 | { |
| 266 | 301 | // fix $users to also prefix system users and groups (with 'u') |
| 267 | - if (!is_array($users)) $users = $users ? (array)$users : array(); |
|
| 302 | + if (!is_array($users)) |
|
| 303 | + { |
|
| 304 | + $users = $users ? (array)$users : array(); |
|
| 305 | + } |
|
| 268 | 306 | foreach($users as &$uid) |
| 269 | 307 | { |
| 270 | 308 | $user_type = $user_id = null; |
@@ -284,15 +322,22 @@ discard block |
||
| 284 | 322 | $sql .= " AND\n ".$params['sql_filter']; |
| 285 | 323 | } |
| 286 | 324 | |
| 287 | - if ($params['order']) // only order if requested |
|
| 325 | + if ($params['order']) |
|
| 288 | 326 | { |
| 289 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 327 | + // only order if requested |
|
| 328 | + { |
|
| 329 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; |
|
| 330 | + } |
|
| 331 | + // gard against SQL injection |
|
| 290 | 332 | $sql .= "\nORDER BY ".$params['order']; |
| 291 | 333 | } |
| 292 | 334 | |
| 293 | - if ($offset === false) // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 335 | + if ($offset === false) |
|
| 336 | + { |
|
| 337 | + // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 294 | 338 | { |
| 295 | 339 | $offset = 0; |
| 340 | + } |
|
| 296 | 341 | $num_rows = -1; |
| 297 | 342 | } |
| 298 | 343 | $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
@@ -318,26 +363,35 @@ discard block |
||
| 318 | 363 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
| 319 | 364 | |
| 320 | 365 | $where = array(); |
| 321 | - if (is_scalar($ids) && !is_numeric($ids)) // a single uid |
|
| 366 | + if (is_scalar($ids) && !is_numeric($ids)) |
|
| 367 | + { |
|
| 368 | + // a single uid |
|
| 322 | 369 | { |
| 323 | 370 | // We want only the parents to match |
| 324 | 371 | $where['cal_uid'] = $ids; |
| 372 | + } |
|
| 325 | 373 | $where['cal_reference'] = 0; |
| 326 | 374 | } |
| 327 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
| 375 | + elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) |
|
| 376 | + { |
|
| 377 | + // one or more cal_id's |
|
| 328 | 378 | { |
| 329 | 379 | $where['cal_id'] = $ids; |
| 330 | 380 | } |
| 381 | + } |
|
| 331 | 382 | else // array with column => value pairs |
| 332 | 383 | { |
| 333 | 384 | $where = $ids; |
| 334 | 385 | unset($ids); // otherwise users get not read! |
| 335 | 386 | } |
| 336 | - if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
|
| 387 | + if (isset($where['cal_id'])) |
|
| 388 | + { |
|
| 389 | + // prevent non-unique column-name cal_id |
|
| 337 | 390 | { |
| 338 | 391 | $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
| 339 | 392 | 'cal_id' => $where['cal_id'], |
| 340 | 393 | )); |
| 394 | + } |
|
| 341 | 395 | unset($where['cal_id']); |
| 342 | 396 | } |
| 343 | 397 | if ((int) $recur_date) |
@@ -387,10 +441,16 @@ discard block |
||
| 387 | 441 | $row['recur_exception'] = $row['alarm'] = array(); |
| 388 | 442 | $events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_'); |
| 389 | 443 | } |
| 390 | - if (!$events) return $events; |
|
| 444 | + if (!$events) |
|
| 445 | + { |
|
| 446 | + return $events; |
|
| 447 | + } |
|
| 391 | 448 | |
| 392 | 449 | $ids = array_keys($events); |
| 393 | - if (count($ids) == 1) $ids = $ids[0]; |
|
| 450 | + if (count($ids) == 1) |
|
| 451 | + { |
|
| 452 | + $ids = $ids[0]; |
|
| 453 | + } |
|
| 394 | 454 | |
| 395 | 455 | foreach ($events as &$event) |
| 396 | 456 | { |
@@ -464,10 +524,13 @@ discard block |
||
| 464 | 524 | 'cal_id' => $ids, |
| 465 | 525 | 'cal_recur_date' => $recur_date, |
| 466 | 526 | "cal_status NOT IN ('X','E')", |
| 467 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
| 527 | + ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) |
|
| 528 | + { |
|
| 529 | + // DESC puts users before resources and contacts |
|
| 468 | 530 | { |
| 469 | 531 | // combine all participant data in uid and status values |
| 470 | 532 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 533 | + } |
|
| 471 | 534 | $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
| 472 | 535 | |
| 473 | 536 | $events[$row['cal_id']]['participants'][$uid] = $status; |
@@ -524,7 +587,10 @@ discard block |
||
| 524 | 587 | $last_request = time(); |
| 525 | 588 | } |
| 526 | 589 | $signature = serialize(func_get_args()); |
| 527 | - if (isset($ctags[$signature])) return $ctags[$signature]; |
|
| 590 | + if (isset($ctags[$signature])) |
|
| 591 | + { |
|
| 592 | + return $ctags[$signature]; |
|
| 593 | + } |
|
| 528 | 594 | |
| 529 | 595 | $types = array(); |
| 530 | 596 | foreach((array)$users as $uid) |
@@ -557,7 +623,10 @@ discard block |
||
| 557 | 623 | // owner can only by users, no groups or resources |
| 558 | 624 | foreach($users as $key => $user) |
| 559 | 625 | { |
| 560 | - if (!($user > 0)) unset($users[$key]); |
|
| 626 | + if (!($user > 0)) |
|
| 627 | + { |
|
| 628 | + unset($users[$key]); |
|
| 629 | + } |
|
| 561 | 630 | } |
| 562 | 631 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
| 563 | 632 | $this->db->expression($this->cal_table, array( |
@@ -579,7 +648,10 @@ discard block |
||
| 579 | 648 | */ |
| 580 | 649 | function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
| 581 | 650 | { |
| 582 | - if (!is_array($cols)) $cols = explode(',', $cols); |
|
| 651 | + if (!is_array($cols)) |
|
| 652 | + { |
|
| 653 | + $cols = explode(',', $cols); |
|
| 654 | + } |
|
| 583 | 655 | |
| 584 | 656 | // special handling of cal_user_modified "pseudo" column |
| 585 | 657 | if (($key = array_search('cal_user_modified', $cols)) !== false) |
@@ -604,7 +676,10 @@ discard block |
||
| 604 | 676 | { |
| 605 | 677 | $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); |
| 606 | 678 | array_walk($cats,create_function('&$val,$key','$val = (int) $val;')); |
| 607 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
| 679 | + if (is_array($cat_id) && count($cat_id)==1) |
|
| 680 | + { |
|
| 681 | + $cat_id = $cat_id[0]; |
|
| 682 | + } |
|
| 608 | 683 | $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
| 609 | 684 | foreach($cats as $cat) |
| 610 | 685 | { |
@@ -663,10 +738,13 @@ discard block |
||
| 663 | 738 | $where[] = "$this->user_table.cal_status NOT IN ('X','E')"; |
| 664 | 739 | break; |
| 665 | 740 | default: |
| 666 | - if ($enum_recuring) // regular UI |
|
| 741 | + if ($enum_recuring) |
|
| 742 | + { |
|
| 743 | + // regular UI |
|
| 667 | 744 | { |
| 668 | 745 | $where[] = "$this->user_table.cal_status NOT IN ('R','X','E')"; |
| 669 | 746 | } |
| 747 | + } |
|
| 670 | 748 | else // CalDAV / eSync / iCal need to include 'E' = exceptions |
| 671 | 749 | { |
| 672 | 750 | $where[] = "$this->user_table.cal_status NOT IN ('R','X')"; |
@@ -798,7 +876,10 @@ discard block |
||
| 798 | 876 | $user_ids = array(); |
| 799 | 877 | foreach($ids as $user_id) |
| 800 | 878 | { |
| 801 | - if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
|
| 879 | + if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') |
|
| 880 | + { |
|
| 881 | + $user_ids[] = $user_id; |
|
| 882 | + } |
|
| 802 | 883 | } |
| 803 | 884 | $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
| 804 | 885 | } |
@@ -818,7 +899,10 @@ discard block |
||
| 818 | 899 | } |
| 819 | 900 | } |
| 820 | 901 | // this is only used, when we cannot use UNIONS |
| 821 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 902 | + if (!$useUnionQuery) |
|
| 903 | + { |
|
| 904 | + $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 905 | + } |
|
| 822 | 906 | |
| 823 | 907 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
| 824 | 908 | } |
@@ -837,7 +921,11 @@ discard block |
||
| 837 | 921 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
| 838 | 922 | } |
| 839 | 923 | } |
| 840 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 924 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) |
|
| 925 | + { |
|
| 926 | + $params['order'] = 'cal_start'; |
|
| 927 | + } |
|
| 928 | + // gard against SQL injection |
|
| 841 | 929 | |
| 842 | 930 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
| 843 | 931 | if (!$params['enum_recuring']) |
@@ -847,9 +935,15 @@ discard block |
||
| 847 | 935 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
| 848 | 936 | $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
| 849 | 937 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
| 850 | - if ($end) $where[] = (int)$end.' > range_start'; |
|
| 938 | + if ($end) |
|
| 939 | + { |
|
| 940 | + $where[] = (int)$end.' > range_start'; |
|
| 941 | + } |
|
| 851 | 942 | } |
| 852 | - elseif ($end) $where[] = (int)$end.' > cal_start'; |
|
| 943 | + elseif ($end) |
|
| 944 | + { |
|
| 945 | + $where[] = (int)$end.' > cal_start'; |
|
| 946 | + } |
|
| 853 | 947 | |
| 854 | 948 | if ($remove_rejected_by_user && $filter != 'everything') |
| 855 | 949 | { |
@@ -863,7 +957,10 @@ discard block |
||
| 863 | 957 | 'rejected_by_user.cal_status IS NULL', |
| 864 | 958 | "rejected_by_user.cal_status NOT IN ('R','X')", |
| 865 | 959 | ); |
| 866 | - if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 960 | + if ($filter == 'owner') |
|
| 961 | + { |
|
| 962 | + $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 963 | + } |
|
| 867 | 964 | $where[] = '('.implode(' OR ',$or_required).')'; |
| 868 | 965 | } |
| 869 | 966 | // using a time-range and deleted attribute limited view instead of full table |
@@ -885,7 +982,10 @@ discard block |
||
| 885 | 982 | if ($useUnionQuery) |
| 886 | 983 | { |
| 887 | 984 | // allow apps to supply participants and/or icons |
| 888 | - if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 985 | + if (!isset($params['cols'])) |
|
| 986 | + { |
|
| 987 | + $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 988 | + } |
|
| 889 | 989 | |
| 890 | 990 | // changed the original OR in the query into a union, to speed up the query execution under MySQL 5 |
| 891 | 991 | // with time-range views benefit is now at best slim for huge tables or none at all! |
@@ -940,9 +1040,12 @@ discard block |
||
| 940 | 1040 | $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
| 941 | 1041 | } |
| 942 | 1042 | } |
| 943 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1043 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1044 | + { |
|
| 1045 | + // get the total too |
|
| 944 | 1046 | { |
| 945 | 1047 | $save_selects = $selects; |
| 1048 | + } |
|
| 946 | 1049 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 947 | 1050 | foreach(array_keys($selects) as $key) |
| 948 | 1051 | { |
@@ -953,14 +1056,20 @@ discard block |
||
| 953 | 1056 | array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
| 954 | 1057 | } |
| 955 | 1058 | } |
| 956 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1059 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1060 | + { |
|
| 1061 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1062 | + } |
|
| 957 | 1063 | |
| 958 | 1064 | $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
| 959 | 1065 | |
| 960 | 1066 | // restore original cols / selects |
| 961 | 1067 | $selects = $save_selects; unset($save_selects); |
| 962 | 1068 | } |
| 963 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1069 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1070 | + { |
|
| 1071 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1072 | + } |
|
| 964 | 1073 | |
| 965 | 1074 | $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
| 966 | 1075 | } |
@@ -978,9 +1087,12 @@ discard block |
||
| 978 | 1087 | 'table_def' => $cal_table_def, |
| 979 | 1088 | )); |
| 980 | 1089 | |
| 981 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1090 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1091 | + { |
|
| 1092 | + // get the total too |
|
| 982 | 1093 | { |
| 983 | 1094 | $save_selects = $selects; |
| 1095 | + } |
|
| 984 | 1096 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 985 | 1097 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
| 986 | 1098 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
@@ -1008,7 +1120,10 @@ discard block |
||
| 1008 | 1120 | foreach($rs as $row) |
| 1009 | 1121 | { |
| 1010 | 1122 | $id = $row['cal_id']; |
| 1011 | - if (is_numeric($id)) $ids[] = $id; |
|
| 1123 | + if (is_numeric($id)) |
|
| 1124 | + { |
|
| 1125 | + $ids[] = $id; |
|
| 1126 | + } |
|
| 1012 | 1127 | |
| 1013 | 1128 | if ($row['cal_recur_date']) |
| 1014 | 1129 | { |
@@ -1028,7 +1143,10 @@ discard block |
||
| 1028 | 1143 | $row['recur_exception'] = $row['alarm'] = array(); |
| 1029 | 1144 | |
| 1030 | 1145 | // compile a list of recurrences per cal_id |
| 1031 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1146 | + if (!in_array($id,(array)$recur_ids[$row['cal_id']])) |
|
| 1147 | + { |
|
| 1148 | + $recur_ids[$row['cal_id']][] = $id; |
|
| 1149 | + } |
|
| 1032 | 1150 | |
| 1033 | 1151 | $events[$id] = Api\Db::strip_array_keys($row,'cal_'); |
| 1034 | 1152 | } |
@@ -1047,10 +1165,16 @@ discard block |
||
| 1047 | 1165 | //'cal_id' => array_unique($ids), |
| 1048 | 1166 | 'cal_recur_date' => $recur_dates, |
| 1049 | 1167 | ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='', |
| 1050 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1168 | + $this->db->get_table_definitions('calendar',$this->user_table)) as $row) |
|
| 1169 | + { |
|
| 1170 | + // DESC puts users before resources and contacts |
|
| 1051 | 1171 | { |
| 1052 | 1172 | $id = $row['cal_id']; |
| 1053 | - if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
|
| 1173 | + } |
|
| 1174 | + if ($row['cal_recur_date']) |
|
| 1175 | + { |
|
| 1176 | + $id .= '-'.$row['cal_recur_date']; |
|
| 1177 | + } |
|
| 1054 | 1178 | |
| 1055 | 1179 | // combine all participant data in uid and status values |
| 1056 | 1180 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
@@ -1069,7 +1193,10 @@ discard block |
||
| 1069 | 1193 | } |
| 1070 | 1194 | |
| 1071 | 1195 | // set data, if recurrence is requested |
| 1072 | - if (isset($events[$id])) $events[$id]['participants'][$uid] = $status; |
|
| 1196 | + if (isset($events[$id])) |
|
| 1197 | + { |
|
| 1198 | + $events[$id]['participants'][$uid] = $status; |
|
| 1199 | + } |
|
| 1073 | 1200 | } |
| 1074 | 1201 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
| 1075 | 1202 | if (!$params['enum_recuring'] || !$params['daywise']) |
@@ -1085,7 +1212,10 @@ discard block |
||
| 1085 | 1212 | { |
| 1086 | 1213 | foreach($events as $id => $event) |
| 1087 | 1214 | { |
| 1088 | - if ($event['id'] == $row['cal_id']) break; |
|
| 1215 | + if ($event['id'] == $row['cal_id']) |
|
| 1216 | + { |
|
| 1217 | + break; |
|
| 1218 | + } |
|
| 1089 | 1219 | } |
| 1090 | 1220 | } |
| 1091 | 1221 | $events[$id]['recur_exception'][] = $row['cal_start']; |
@@ -1095,7 +1225,10 @@ discard block |
||
| 1095 | 1225 | if (!is_null($params['cfs'])) |
| 1096 | 1226 | { |
| 1097 | 1227 | $where = array('cal_id' => $ids); |
| 1098 | - if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
|
| 1228 | + if ($params['cfs']) |
|
| 1229 | + { |
|
| 1230 | + $where['cal_extra_name'] = $params['cfs']; |
|
| 1231 | + } |
|
| 1099 | 1232 | foreach($this->db->select($this->extra_table,'*',$where, |
| 1100 | 1233 | __LINE__,__FILE__,false,'','calendar') as $row) |
| 1101 | 1234 | { |
@@ -1115,14 +1248,20 @@ discard block |
||
| 1115 | 1248 | { |
| 1116 | 1249 | $event_start = $alarm['time'] + $alarm['offset']; |
| 1117 | 1250 | |
| 1118 | - if (isset($events[$cal_id])) // none recuring event |
|
| 1251 | + if (isset($events[$cal_id])) |
|
| 1252 | + { |
|
| 1253 | + // none recuring event |
|
| 1119 | 1254 | { |
| 1120 | 1255 | $events[$cal_id]['alarm'][$id] = $alarm; |
| 1121 | 1256 | } |
| 1122 | - elseif (isset($events[$cal_id.'-'.$event_start])) // recuring event |
|
| 1257 | + } |
|
| 1258 | + elseif (isset($events[$cal_id.'-'.$event_start])) |
|
| 1259 | + { |
|
| 1260 | + // recuring event |
|
| 1123 | 1261 | { |
| 1124 | 1262 | $events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm; |
| 1125 | 1263 | } |
| 1264 | + } |
|
| 1126 | 1265 | } |
| 1127 | 1266 | } |
| 1128 | 1267 | } |
@@ -1222,10 +1361,13 @@ discard block |
||
| 1222 | 1361 | } |
| 1223 | 1362 | foreach((array)$cols as $col) |
| 1224 | 1363 | { |
| 1225 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
| 1364 | + if (substr($col,0,7) == 'egw_cal') |
|
| 1365 | + { |
|
| 1366 | + // remove table name |
|
| 1226 | 1367 | { |
| 1227 | 1368 | $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
| 1228 | 1369 | } |
| 1370 | + } |
|
| 1229 | 1371 | if (isset($app_cols[$col])) |
| 1230 | 1372 | { |
| 1231 | 1373 | $return_cols[] = $app_cols[$col]; |
@@ -1319,7 +1461,11 @@ discard block |
||
| 1319 | 1461 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 1320 | 1462 | { |
| 1321 | 1463 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
| 1322 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1464 | + if (empty($minimum_uid_length) || $minimum_uid_length<=1) |
|
| 1465 | + { |
|
| 1466 | + $minimum_uid_length = 8; |
|
| 1467 | + } |
|
| 1468 | + // we just do not accept no uid, or uid way to short! |
|
| 1323 | 1469 | } |
| 1324 | 1470 | else |
| 1325 | 1471 | { |
@@ -1367,7 +1513,10 @@ discard block |
||
| 1367 | 1513 | } |
| 1368 | 1514 | } |
| 1369 | 1515 | // set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values! |
| 1370 | - if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
|
| 1516 | + if (isset($event['cal_start'])) |
|
| 1517 | + { |
|
| 1518 | + $event['range_start'] = $event['cal_start']; |
|
| 1519 | + } |
|
| 1371 | 1520 | if (isset($event['cal_end'])) |
| 1372 | 1521 | { |
| 1373 | 1522 | $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
@@ -1388,7 +1537,10 @@ discard block |
||
| 1388 | 1537 | $event['cal_category'] = implode(',',$categories); |
| 1389 | 1538 | |
| 1390 | 1539 | // make sure recurring events never reference to an other recurrent event |
| 1391 | - if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
|
| 1540 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1541 | + { |
|
| 1542 | + $event['cal_reference'] = 0; |
|
| 1543 | + } |
|
| 1392 | 1544 | |
| 1393 | 1545 | if ($cal_id) |
| 1394 | 1546 | { |
@@ -1405,7 +1557,10 @@ discard block |
||
| 1405 | 1557 | { |
| 1406 | 1558 | $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
| 1407 | 1559 | } |
| 1408 | - if (!is_null($etag)) $where['cal_etag'] = $etag; |
|
| 1560 | + if (!is_null($etag)) |
|
| 1561 | + { |
|
| 1562 | + $where['cal_etag'] = $etag; |
|
| 1563 | + } |
|
| 1409 | 1564 | |
| 1410 | 1565 | unset($event['cal_etag']); |
| 1411 | 1566 | $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
@@ -1416,14 +1571,24 @@ discard block |
||
| 1416 | 1571 | { |
| 1417 | 1572 | return 0; // wrong etag, someone else updated the entry |
| 1418 | 1573 | } |
| 1419 | - if (!is_null($etag)) ++$etag; |
|
| 1574 | + if (!is_null($etag)) |
|
| 1575 | + { |
|
| 1576 | + ++$etag; |
|
| 1577 | + } |
|
| 1420 | 1578 | } |
| 1421 | 1579 | else |
| 1422 | 1580 | { |
| 1423 | 1581 | // new event |
| 1424 | - if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1582 | + if (!$event['cal_owner']) |
|
| 1583 | + { |
|
| 1584 | + $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1585 | + } |
|
| 1425 | 1586 | |
| 1426 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1587 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) |
|
| 1588 | + { |
|
| 1589 | + $event['cal_uid'] = ''; |
|
| 1590 | + } |
|
| 1591 | + // uid is NOT NULL! |
|
| 1427 | 1592 | |
| 1428 | 1593 | $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
| 1429 | 1594 | if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id'))) |
@@ -1575,8 +1740,7 @@ discard block |
||
| 1575 | 1740 | // recurrences need to be truncated |
| 1576 | 1741 | if((int)$event['recur_enddate'] > 0 && |
| 1577 | 1742 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
| 1578 | - ) |
|
| 1579 | - { |
|
| 1743 | + ) { |
|
| 1580 | 1744 | $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1581 | 1745 | $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1582 | 1746 | } |
@@ -1584,8 +1748,7 @@ discard block |
||
| 1584 | 1748 | // recurrences need to be expanded |
| 1585 | 1749 | if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
| 1586 | 1750 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
| 1587 | - ) |
|
| 1588 | - { |
|
| 1751 | + ) { |
|
| 1589 | 1752 | $set_recurrences = true; |
| 1590 | 1753 | $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
| 1591 | 1754 | } |
@@ -1732,12 +1895,18 @@ discard block |
||
| 1732 | 1895 | { |
| 1733 | 1896 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
| 1734 | 1897 | |
| 1735 | - if (!(int) $cal_id) return false; |
|
| 1898 | + if (!(int) $cal_id) |
|
| 1899 | + { |
|
| 1900 | + return false; |
|
| 1901 | + } |
|
| 1736 | 1902 | |
| 1737 | 1903 | if (!$old_start) |
| 1738 | 1904 | { |
| 1739 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1905 | + if ($change_since !== false) |
|
| 1906 | + { |
|
| 1907 | + $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1740 | 1908 | array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
| 1909 | + } |
|
| 1741 | 1910 | // if no recurrence found, create one with the new dates |
| 1742 | 1911 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
| 1743 | 1912 | { |
@@ -1839,7 +2008,10 @@ discard block |
||
| 1839 | 2008 | $user_type = $uid[0]; |
| 1840 | 2009 | $email = substr($uid, 1); |
| 1841 | 2010 | $matches = null; |
| 1842 | - if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1]; |
|
| 2011 | + if (preg_match('/<([^<>]+)>$/', $email, $matches)) |
|
| 2012 | + { |
|
| 2013 | + $email = $matches[1]; |
|
| 2014 | + } |
|
| 1843 | 2015 | $user_id = md5(trim(strtolower($email))); |
| 1844 | 2016 | } |
| 1845 | 2017 | else |
@@ -1859,8 +2031,14 @@ discard block |
||
| 1859 | 2031 | */ |
| 1860 | 2032 | static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
| 1861 | 2033 | { |
| 1862 | - if ((int)$quantity > 1) $status .= (int)$quantity; |
|
| 1863 | - if ($role != 'REQ-PARTICIPANT') $status .= $role; |
|
| 2034 | + if ((int)$quantity > 1) |
|
| 2035 | + { |
|
| 2036 | + $status .= (int)$quantity; |
|
| 2037 | + } |
|
| 2038 | + if ($role != 'REQ-PARTICIPANT') |
|
| 2039 | + { |
|
| 2040 | + $status .= $role; |
|
| 2041 | + } |
|
| 1864 | 2042 | |
| 1865 | 2043 | return $status; |
| 1866 | 2044 | } |
@@ -1881,8 +2059,14 @@ discard block |
||
| 1881 | 2059 | $matches = null; |
| 1882 | 2060 | if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
| 1883 | 2061 | { |
| 1884 | - if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
|
| 1885 | - if ($matches[2]) $role = $matches[2]; |
|
| 2062 | + if ((int)$matches[1] > 0) |
|
| 2063 | + { |
|
| 2064 | + $quantity = (int)$matches[1]; |
|
| 2065 | + } |
|
| 2066 | + if ($matches[2]) |
|
| 2067 | + { |
|
| 2068 | + $role = $matches[2]; |
|
| 2069 | + } |
|
| 1886 | 2070 | $status = $status[0]; |
| 1887 | 2071 | } |
| 1888 | 2072 | elseif ($status === true) |
@@ -1993,9 +2177,13 @@ discard block |
||
| 1993 | 2177 | } |
| 1994 | 2178 | } |
| 1995 | 2179 | |
| 1996 | - if (count($participants)) // participants which need to be added |
|
| 2180 | + if (count($participants)) |
|
| 2181 | + { |
|
| 2182 | + // participants which need to be added |
|
| 1997 | 2183 | { |
| 1998 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2184 | + if (!count($recurrences)) $recurrences[] = 0; |
|
| 2185 | + } |
|
| 2186 | + // insert the default recurrence |
|
| 1999 | 2187 | |
| 2000 | 2188 | $delete_deleted = array(); |
| 2001 | 2189 | |
@@ -2067,7 +2255,10 @@ discard block |
||
| 2067 | 2255 | return false; |
| 2068 | 2256 | } |
| 2069 | 2257 | |
| 2070 | - if (is_numeric($status)) $status = $status_code_short[$status]; |
|
| 2258 | + if (is_numeric($status)) |
|
| 2259 | + { |
|
| 2260 | + $status = $status_code_short[$status]; |
|
| 2261 | + } |
|
| 2071 | 2262 | |
| 2072 | 2263 | $uid = self::combine_user($user_type, $user_id); |
| 2073 | 2264 | $user_id_md5 = null; |
@@ -2087,16 +2278,25 @@ discard block |
||
| 2087 | 2278 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')'; |
| 2088 | 2279 | } |
| 2089 | 2280 | |
| 2090 | - if ($status == 'G') // remove group invitations, as we dont store them in the db |
|
| 2281 | + if ($status == 'G') |
|
| 2282 | + { |
|
| 2283 | + // remove group invitations, as we dont store them in the db |
|
| 2091 | 2284 | { |
| 2092 | 2285 | $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
| 2286 | + } |
|
| 2093 | 2287 | $ret = $this->db->affected_rows(); |
| 2094 | 2288 | } |
| 2095 | 2289 | else |
| 2096 | 2290 | { |
| 2097 | 2291 | $set = array('cal_status' => $status); |
| 2098 | - if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2099 | - if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
|
| 2292 | + if ($user_type == 'e' || $attendee) |
|
| 2293 | + { |
|
| 2294 | + $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2295 | + } |
|
| 2296 | + if (!is_null($role) && $role != 'REQ-PARTICIPANT') |
|
| 2297 | + { |
|
| 2298 | + $set['cal_role'] = $role; |
|
| 2299 | + } |
|
| 2100 | 2300 | $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
| 2101 | 2301 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2102 | 2302 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
@@ -2129,7 +2329,10 @@ discard block |
||
| 2129 | 2329 | { |
| 2130 | 2330 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
| 2131 | 2331 | $update = array('cal_end' => $end); |
| 2132 | - if (isset($exception)) $update['recur_exception'] = $exception; |
|
| 2332 | + if (isset($exception)) |
|
| 2333 | + { |
|
| 2334 | + $update['recur_exception'] = $exception; |
|
| 2335 | + } |
|
| 2133 | 2336 | |
| 2134 | 2337 | $this->db->insert($this->dates_table, $update, array( |
| 2135 | 2338 | 'cal_id' => $cal_id, |
@@ -2144,7 +2347,11 @@ discard block |
||
| 2144 | 2347 | { |
| 2145 | 2348 | foreach($participants as $uid => $status) |
| 2146 | 2349 | { |
| 2147 | - if ($status == 'G') continue; // dont save group-invitations |
|
| 2350 | + if ($status == 'G') |
|
| 2351 | + { |
|
| 2352 | + continue; |
|
| 2353 | + } |
|
| 2354 | + // dont save group-invitations |
|
| 2148 | 2355 | |
| 2149 | 2356 | $type = ''; |
| 2150 | 2357 | $id = null; |
@@ -2373,7 +2580,10 @@ discard block |
||
| 2373 | 2580 | } |
| 2374 | 2581 | $alarm['cal_id'] = $cal_id; // we need the back-reference |
| 2375 | 2582 | // add an alarm uid, if none is given |
| 2376 | - if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2583 | + if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) |
|
| 2584 | + { |
|
| 2585 | + $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2586 | + } |
|
| 2377 | 2587 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
| 2378 | 2588 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
| 2379 | 2589 | if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner'])) |
@@ -2382,10 +2592,16 @@ discard block |
||
| 2382 | 2592 | } |
| 2383 | 2593 | |
| 2384 | 2594 | // update the modification information of the related event |
| 2385 | - if ($update_modified) $this->updateModified($cal_id, true); |
|
| 2595 | + if ($update_modified) |
|
| 2596 | + { |
|
| 2597 | + $this->updateModified($cal_id, true); |
|
| 2598 | + } |
|
| 2386 | 2599 | |
| 2387 | 2600 | // update cache, if used |
| 2388 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2601 | + if (isset(self::$alarm_cache)) |
|
| 2602 | + { |
|
| 2603 | + $this->read_alarms($cal_id, true); |
|
| 2604 | + } |
|
| 2389 | 2605 | |
| 2390 | 2606 | return $id; |
| 2391 | 2607 | } |
@@ -2408,7 +2624,10 @@ discard block |
||
| 2408 | 2624 | $this->async->cancel_timer($id); |
| 2409 | 2625 | } |
| 2410 | 2626 | // update cache, if used |
| 2411 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false); |
|
| 2627 | + if (isset(self::$alarm_cache)) |
|
| 2628 | + { |
|
| 2629 | + $this->read_alarms($cal_id, false); |
|
| 2630 | + } |
|
| 2412 | 2631 | } |
| 2413 | 2632 | return count($alarms); |
| 2414 | 2633 | } |
@@ -2431,7 +2650,10 @@ discard block |
||
| 2431 | 2650 | $ret = $this->async->cancel_timer($id); |
| 2432 | 2651 | |
| 2433 | 2652 | // update cache, if used |
| 2434 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2653 | + if (isset(self::$alarm_cache)) |
|
| 2654 | + { |
|
| 2655 | + $this->read_alarms($cal_id, true); |
|
| 2656 | + } |
|
| 2435 | 2657 | |
| 2436 | 2658 | return $ret; |
| 2437 | 2659 | } |
@@ -2455,11 +2677,14 @@ discard block |
||
| 2455 | 2677 | $user_id = null; |
| 2456 | 2678 | self::split_user($old_user,$user_type,$user_id); |
| 2457 | 2679 | |
| 2458 | - if ($user_type == 'u') // only accounts can be owners of events |
|
| 2680 | + if ($user_type == 'u') |
|
| 2681 | + { |
|
| 2682 | + // only accounts can be owners of events |
|
| 2459 | 2683 | { |
| 2460 | 2684 | foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
| 2461 | 2685 | { |
| 2462 | 2686 | $this->delete($row['cal_id']); |
| 2687 | + } |
|
| 2463 | 2688 | } |
| 2464 | 2689 | } |
| 2465 | 2690 | $this->db->delete($this->user_table,array( |
@@ -2487,11 +2712,14 @@ discard block |
||
| 2487 | 2712 | { |
| 2488 | 2713 | $ids[] = $row['cal_id']; |
| 2489 | 2714 | } |
| 2490 | - if ($ids) $this->db->delete($this->user_table,array( |
|
| 2715 | + if ($ids) |
|
| 2716 | + { |
|
| 2717 | + $this->db->delete($this->user_table,array( |
|
| 2491 | 2718 | 'cal_user_type' => 'u', |
| 2492 | 2719 | 'cal_user_id' => $old_user, |
| 2493 | 2720 | 'cal_id' => $ids, |
| 2494 | 2721 | ),__LINE__,__FILE__,'calendar'); |
| 2722 | + } |
|
| 2495 | 2723 | // now change participant in the rest to contain new user instead of old user |
| 2496 | 2724 | $this->db->update($this->user_table,array( |
| 2497 | 2725 | 'cal_user_id' => $new_user, |
@@ -2516,8 +2744,14 @@ discard block |
||
| 2516 | 2744 | { |
| 2517 | 2745 | $participant_status = array(); |
| 2518 | 2746 | $where = array('cal_id' => $cal_id); |
| 2519 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2520 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2747 | + if ($start != 0 && $end == 0) |
|
| 2748 | + { |
|
| 2749 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2750 | + } |
|
| 2751 | + if ($start == 0 && $end != 0) |
|
| 2752 | + { |
|
| 2753 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2754 | + } |
|
| 2521 | 2755 | if ($start != 0 && $end != 0) |
| 2522 | 2756 | { |
| 2523 | 2757 | $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2528,7 +2762,10 @@ discard block |
||
| 2528 | 2762 | // inititalize the array |
| 2529 | 2763 | $participant_status[$row['cal_recur_date']] = null; |
| 2530 | 2764 | } |
| 2531 | - if (is_null($uid)) return $participant_status; |
|
| 2765 | + if (is_null($uid)) |
|
| 2766 | + { |
|
| 2767 | + return $participant_status; |
|
| 2768 | + } |
|
| 2532 | 2769 | $user_type = $user_id = null; |
| 2533 | 2770 | self::split_user($uid, $user_type, $user_id, true); |
| 2534 | 2771 | |
@@ -2537,8 +2774,14 @@ discard block |
||
| 2537 | 2774 | 'cal_user_type' => $user_type ? $user_type : 'u', |
| 2538 | 2775 | 'cal_user_id' => $user_id, |
| 2539 | 2776 | ); |
| 2540 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2541 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2777 | + if ($start != 0 && $end == 0) |
|
| 2778 | + { |
|
| 2779 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2780 | + } |
|
| 2781 | + if ($start == 0 && $end != 0) |
|
| 2782 | + { |
|
| 2783 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2784 | + } |
|
| 2542 | 2785 | if ($start != 0 && $end != 0) |
| 2543 | 2786 | { |
| 2544 | 2787 | $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2628,17 +2871,26 @@ discard block |
||
| 2628 | 2871 | */ |
| 2629 | 2872 | function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
| 2630 | 2873 | { |
| 2631 | - if (!is_array($event)) return false; |
|
| 2874 | + if (!is_array($event)) |
|
| 2875 | + { |
|
| 2876 | + return false; |
|
| 2877 | + } |
|
| 2632 | 2878 | $cal_id = (int) $event['id']; |
| 2633 | 2879 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2634 | 2880 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
| 2635 | - if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
|
| 2881 | + if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) |
|
| 2882 | + { |
|
| 2883 | + return false; |
|
| 2884 | + } |
|
| 2636 | 2885 | |
| 2637 | 2886 | $days = array(); |
| 2638 | 2887 | |
| 2639 | 2888 | $expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']); |
| 2640 | 2889 | |
| 2641 | - if ($filter == 'tz_only' && !$expand_all) return $days; |
|
| 2890 | + if ($filter == 'tz_only' && !$expand_all) |
|
| 2891 | + { |
|
| 2892 | + return $days; |
|
| 2893 | + } |
|
| 2642 | 2894 | |
| 2643 | 2895 | $remote = in_array($filter, array('tz_rrule', 'rrule')); |
| 2644 | 2896 | |
@@ -2681,7 +2933,10 @@ discard block |
||
| 2681 | 2933 | $remote_rrule->next_no_exception(); |
| 2682 | 2934 | } |
| 2683 | 2935 | $egw_rrule->next_no_exception(); |
| 2684 | - if (!$egw_rrule->valid()) return $days; |
|
| 2936 | + if (!$egw_rrule->valid()) |
|
| 2937 | + { |
|
| 2938 | + return $days; |
|
| 2939 | + } |
|
| 2685 | 2940 | } |
| 2686 | 2941 | $day = $egw_rrule->current(); |
| 2687 | 2942 | $locts = (int)Api\DateTime::to($day,'server'); |
@@ -2835,7 +3090,11 @@ discard block |
||
| 2835 | 3090 | } |
| 2836 | 3091 | } |
| 2837 | 3092 | |
| 2838 | - if (empty($participants)) return false; // occurrence does not exist at all yet |
|
| 3093 | + if (empty($participants)) |
|
| 3094 | + { |
|
| 3095 | + return false; |
|
| 3096 | + } |
|
| 3097 | + // occurrence does not exist at all yet |
|
| 2839 | 3098 | |
| 2840 | 3099 | foreach ($recurrence_zero as $uid => $status) |
| 2841 | 3100 | { |
@@ -2892,7 +3151,9 @@ discard block |
||
| 2892 | 3151 | } |
| 2893 | 3152 | if (!isset($participants[$uid]) |
| 2894 | 3153 | || $participants[$uid] != $status) |
| 2895 | - return true; |
|
| 3154 | + { |
|
| 3155 | + return true; |
|
| 3156 | + } |
|
| 2896 | 3157 | unset($participants[$uid]); |
| 2897 | 3158 | } |
| 2898 | 3159 | return (!empty($participants)); |
@@ -2906,7 +3167,10 @@ discard block |
||
| 2906 | 3167 | */ |
| 2907 | 3168 | function isWholeDay($event) |
| 2908 | 3169 | { |
| 2909 | - if (!isset($event['start']) || !isset($event['end'])) return false; |
|
| 3170 | + if (!isset($event['start']) || !isset($event['end'])) |
|
| 3171 | + { |
|
| 3172 | + return false; |
|
| 3173 | + } |
|
| 2910 | 3174 | |
| 2911 | 3175 | if (empty($event['tzid'])) |
| 2912 | 3176 | { |
@@ -2968,8 +3232,14 @@ discard block |
||
| 2968 | 3232 | */ |
| 2969 | 3233 | function updateModified($id, $update_master=false, $time=null, $modifier=null) |
| 2970 | 3234 | { |
| 2971 | - if (is_null($time) || !$time) $time = time(); |
|
| 2972 | - if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3235 | + if (is_null($time) || !$time) |
|
| 3236 | + { |
|
| 3237 | + $time = time(); |
|
| 3238 | + } |
|
| 3239 | + if (is_null($modifier)) |
|
| 3240 | + { |
|
| 3241 | + $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3242 | + } |
|
| 2973 | 3243 | |
| 2974 | 3244 | $this->db->update($this->cal_table, |
| 2975 | 3245 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | " CASE WHEN recur_type IS NULL THEN egw_cal.range_start ELSE cal_start END AS cal_start,\n". |
| 253 | 253 | " CASE WHEN recur_type IS NULL THEN egw_cal.range_end ELSE cal_end END AS cal_end\n". |
| 254 | 254 | // using time-limited range view, instead of complete table, give a big performance plus |
| 255 | - "FROM $egw_cal\n". |
|
| 255 | + "from $egw_cal\n". |
|
| 256 | 256 | "JOIN egw_cal_user ON egw_cal_user.cal_id=egw_cal.cal_id\n". |
| 257 | 257 | // need to left join dates, as egw_cal_user.recur_date is null for non-recuring event |
| 258 | 258 | "LEFT JOIN egw_cal_dates ON egw_cal_user.cal_id=egw_cal_dates.cal_id AND egw_cal_dates.cal_start=egw_cal_user.cal_recur_date\n". |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | $where[] = 'cal_start >= '.(int)$recur_date; |
| 346 | 346 | $group_by = 'GROUP BY '.$cols; |
| 347 | 347 | $cols .= ',MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end'; |
| 348 | - $join = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join"; |
|
| 348 | + $join = "join $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join"; |
|
| 349 | 349 | } |
| 350 | 350 | else |
| 351 | 351 | { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | $cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted'); |
| 871 | 871 | $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
| 872 | 872 | |
| 873 | - $join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ". |
|
| 873 | + $join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ". |
|
| 874 | 874 | "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ". |
| 875 | 875 | $rejected_by_user_join; |
| 876 | 876 | // dates table join only needed to enum recuring events, we use a time-range limited view here too |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 947 | 947 | foreach(array_keys($selects) as $key) |
| 948 | 948 | { |
| 949 | - $selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 949 | + $selects[$key]['cols'] = "distinct $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 950 | 950 | if (!$params['enum_recuring']) |
| 951 | 951 | { |
| 952 | 952 | $selects[$key]['cols'] = str_replace(array('cal_start','cal_end'), |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | { |
| 1398 | 1398 | $old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate", |
| 1399 | 1399 | "$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__, |
| 1400 | - false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch(); |
|
| 1400 | + false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch(); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | $where = array('cal_id' => $cal_id); |
| 1403 | 1403 | // read only timezone id, to check if it is changed |
@@ -1762,13 +1762,13 @@ discard block |
||
| 1762 | 1762 | if ($move_start) |
| 1763 | 1763 | { |
| 1764 | 1764 | // move the recur-date of the participants |
| 1765 | - $this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
|
| 1765 | + $this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
|
| 1766 | 1766 | ((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__); |
| 1767 | 1767 | } |
| 1768 | 1768 | if ($move_start || $move_end) |
| 1769 | 1769 | { |
| 1770 | 1770 | // move the event and it's recurrences |
| 1771 | - $this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
|
| 1771 | + $this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
|
| 1772 | 1772 | ((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__); |
| 1773 | 1773 | } |
| 1774 | 1774 | return $this->db->affected_rows(); |
@@ -2468,7 +2468,7 @@ discard block |
||
| 2468 | 2468 | ),__LINE__,__FILE__,'calendar'); |
| 2469 | 2469 | |
| 2470 | 2470 | // delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner) |
| 2471 | - foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2471 | + foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2472 | 2472 | False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
| 2473 | 2473 | { |
| 2474 | 2474 | $this->delete($row['cal_id']); |
@@ -19,40 +19,40 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * some necessary defines used by the calendar |
| 21 | 21 | */ |
| 22 | -if(!extension_loaded('mcal')) |
|
| 22 | +if (!extension_loaded('mcal')) |
|
| 23 | 23 | { |
| 24 | - define('MCAL_RECUR_NONE',0); |
|
| 25 | - define('MCAL_RECUR_DAILY',1); |
|
| 26 | - define('MCAL_RECUR_WEEKLY',2); |
|
| 27 | - define('MCAL_RECUR_MONTHLY_MDAY',3); |
|
| 28 | - define('MCAL_RECUR_MONTHLY_WDAY',4); |
|
| 29 | - define('MCAL_RECUR_YEARLY',5); |
|
| 30 | - define('MCAL_RECUR_SECONDLY',6); |
|
| 31 | - define('MCAL_RECUR_MINUTELY',7); |
|
| 32 | - define('MCAL_RECUR_HOURLY',8); |
|
| 33 | - |
|
| 34 | - define('MCAL_M_SUNDAY',1); |
|
| 35 | - define('MCAL_M_MONDAY',2); |
|
| 36 | - define('MCAL_M_TUESDAY',4); |
|
| 37 | - define('MCAL_M_WEDNESDAY',8); |
|
| 38 | - define('MCAL_M_THURSDAY',16); |
|
| 39 | - define('MCAL_M_FRIDAY',32); |
|
| 40 | - define('MCAL_M_SATURDAY',64); |
|
| 41 | - |
|
| 42 | - define('MCAL_M_WEEKDAYS',62); |
|
| 43 | - define('MCAL_M_WEEKEND',65); |
|
| 44 | - define('MCAL_M_ALLDAYS',127); |
|
| 24 | + define('MCAL_RECUR_NONE', 0); |
|
| 25 | + define('MCAL_RECUR_DAILY', 1); |
|
| 26 | + define('MCAL_RECUR_WEEKLY', 2); |
|
| 27 | + define('MCAL_RECUR_MONTHLY_MDAY', 3); |
|
| 28 | + define('MCAL_RECUR_MONTHLY_WDAY', 4); |
|
| 29 | + define('MCAL_RECUR_YEARLY', 5); |
|
| 30 | + define('MCAL_RECUR_SECONDLY', 6); |
|
| 31 | + define('MCAL_RECUR_MINUTELY', 7); |
|
| 32 | + define('MCAL_RECUR_HOURLY', 8); |
|
| 33 | + |
|
| 34 | + define('MCAL_M_SUNDAY', 1); |
|
| 35 | + define('MCAL_M_MONDAY', 2); |
|
| 36 | + define('MCAL_M_TUESDAY', 4); |
|
| 37 | + define('MCAL_M_WEDNESDAY', 8); |
|
| 38 | + define('MCAL_M_THURSDAY', 16); |
|
| 39 | + define('MCAL_M_FRIDAY', 32); |
|
| 40 | + define('MCAL_M_SATURDAY', 64); |
|
| 41 | + |
|
| 42 | + define('MCAL_M_WEEKDAYS', 62); |
|
| 43 | + define('MCAL_M_WEEKEND', 65); |
|
| 44 | + define('MCAL_M_ALLDAYS', 127); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -define('REJECTED',0); |
|
| 48 | -define('NO_RESPONSE',1); |
|
| 49 | -define('TENTATIVE',2); |
|
| 50 | -define('ACCEPTED',3); |
|
| 51 | -define('DELEGATED',4); |
|
| 47 | +define('REJECTED', 0); |
|
| 48 | +define('NO_RESPONSE', 1); |
|
| 49 | +define('TENTATIVE', 2); |
|
| 50 | +define('ACCEPTED', 3); |
|
| 51 | +define('DELEGATED', 4); |
|
| 52 | 52 | |
| 53 | -define('HOUR_s',60*60); |
|
| 54 | -define('DAY_s',24*HOUR_s); |
|
| 55 | -define('WEEK_s',7*DAY_s); |
|
| 53 | +define('HOUR_s', 60 * 60); |
|
| 54 | +define('DAY_s', 24 * HOUR_s); |
|
| 55 | +define('WEEK_s', 7 * DAY_s); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Class to store all calendar data (storage object) |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * name of the main calendar table and prefix for all other calendar tables |
| 101 | 101 | */ |
| 102 | 102 | var $cal_table = 'egw_cal'; |
| 103 | - var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables; |
|
| 103 | + var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * reference to global db-object |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $this->db = $GLOBALS['egw']->db; |
| 137 | 137 | |
| 138 | 138 | $this->all_tables = array($this->cal_table); |
| 139 | - foreach(array('extra','repeats','user','dates') as $name) |
|
| 139 | + foreach (array('extra', 'repeats', 'user', 'dates') as $name) |
|
| 140 | 140 | { |
| 141 | 141 | $vname = $name.'_table'; |
| 142 | 142 | $this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name; |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | * @param boolean $deleted =false |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
|
| 155 | + protected function cal_range_view($start, $end, array $_where = null, $deleted = false) |
|
| 156 | 156 | { |
| 157 | 157 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
| 158 | 158 | { |
| 159 | - return $this->cal_table; // no need / use for a view |
|
| 159 | + return $this->cal_table; // no need / use for a view |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $where = array(); |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | * @param boolean $deleted =false |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | - protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
|
| 185 | + protected function dates_range_view($start, $end, array $_where = null, $deleted = false) |
|
| 186 | 186 | { |
| 187 | 187 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
| 188 | 188 | { |
| 189 | - return $this->dates_table; // no need / use for a view |
|
| 189 | + return $this->dates_table; // no need / use for a view |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $where = array(); |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 232 | 232 | * @return array of events |
| 233 | 233 | */ |
| 234 | - function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
| 234 | + function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
| 235 | 235 | { |
| 236 | - error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
| 236 | + error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
| 237 | 237 | $start_time = microtime(true); |
| 238 | 238 | // not everything is supported by now |
| 239 | 239 | if (!$start || !$end || is_string($params['query']) || |
| 240 | 240 | //in_array($filter,array('owner','deleted')) || |
| 241 | - $params['enum_recuring']===false) |
|
| 241 | + $params['enum_recuring'] === false) |
|
| 242 | 242 | { |
| 243 | 243 | throw new Api\Exception\AssertionFailed("Unsupported value for parameters!"); |
| 244 | 244 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | { |
| 266 | 266 | // fix $users to also prefix system users and groups (with 'u') |
| 267 | 267 | if (!is_array($users)) $users = $users ? (array)$users : array(); |
| 268 | - foreach($users as &$uid) |
|
| 268 | + foreach ($users as &$uid) |
|
| 269 | 269 | { |
| 270 | 270 | $user_type = $user_id = null; |
| 271 | 271 | self::split_user($uid, $user_type, $user_id, true); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | if ($params['order']) // only order if requested |
| 288 | 288 | { |
| 289 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 289 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 290 | 290 | $sql .= "\nORDER BY ".$params['order']; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | $offset = 0; |
| 296 | 296 | $num_rows = -1; |
| 297 | 297 | } |
| 298 | - $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
| 299 | - error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3)); |
|
| 298 | + $events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
| 299 | + error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3)); |
|
| 300 | 300 | return $events; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one |
| 310 | 310 | * @return array|boolean array with cal_id => event array pairs or false if entry not found |
| 311 | 311 | */ |
| 312 | - function read($ids,$recur_date=0) |
|
| 312 | + function read($ids, $recur_date = 0) |
|
| 313 | 313 | { |
| 314 | 314 | //error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace()); |
| 315 | 315 | $cols = self::get_columns('calendar', $this->cal_table); |
| 316 | 316 | $cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
| 317 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols); |
|
| 317 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols); |
|
| 318 | 318 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
| 319 | 319 | |
| 320 | 320 | $where = array(); |
@@ -324,23 +324,23 @@ discard block |
||
| 324 | 324 | $where['cal_uid'] = $ids; |
| 325 | 325 | $where['cal_reference'] = 0; |
| 326 | 326 | } |
| 327 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
| 327 | + elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids)) // one or more cal_id's |
|
| 328 | 328 | { |
| 329 | 329 | $where['cal_id'] = $ids; |
| 330 | 330 | } |
| 331 | 331 | else // array with column => value pairs |
| 332 | 332 | { |
| 333 | 333 | $where = $ids; |
| 334 | - unset($ids); // otherwise users get not read! |
|
| 334 | + unset($ids); // otherwise users get not read! |
|
| 335 | 335 | } |
| 336 | 336 | if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
| 337 | 337 | { |
| 338 | - $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
|
| 338 | + $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array( |
|
| 339 | 339 | 'cal_id' => $where['cal_id'], |
| 340 | 340 | )); |
| 341 | 341 | unset($where['cal_id']); |
| 342 | 342 | } |
| 343 | - if ((int) $recur_date) |
|
| 343 | + if ((int)$recur_date) |
|
| 344 | 344 | { |
| 345 | 345 | $where[] = 'cal_start >= '.(int)$recur_date; |
| 346 | 346 | $group_by = 'GROUP BY '.$cols; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | $cols .= ',range_end AS recur_enddate'; |
| 355 | 355 | |
| 356 | - $events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
| 356 | + $events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
| 357 | 357 | |
| 358 | 358 | return $events ? $events : false; |
| 359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param int $recur_date =0 |
| 366 | 366 | * @return array |
| 367 | 367 | */ |
| 368 | - protected function &get_events($rs, $recur_date=0) |
|
| 368 | + protected function &get_events($rs, $recur_date = 0) |
|
| 369 | 369 | { |
| 370 | 370 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 371 | 371 | { |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $events = array(); |
| 380 | - foreach($rs as $row) |
|
| 380 | + foreach ($rs as $row) |
|
| 381 | 381 | { |
| 382 | 382 | if (!$row['recur_type']) |
| 383 | 383 | { |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | unset($row['recur_enddate']); |
| 386 | 386 | } |
| 387 | 387 | $row['recur_exception'] = $row['alarm'] = array(); |
| 388 | - $events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_'); |
|
| 388 | + $events[$row['cal_id']] = Api\Db::strip_array_keys($row, 'cal_'); |
|
| 389 | 389 | } |
| 390 | 390 | if (!$events) return $events; |
| 391 | 391 | |
@@ -397,26 +397,26 @@ discard block |
||
| 397 | 397 | if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length) |
| 398 | 398 | { |
| 399 | 399 | // event (without uid), not strong enough uid => create new uid |
| 400 | - $event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']); |
|
| 400 | + $event['uid'] = Api\CalDAV::generate_uid('calendar', $event['id']); |
|
| 401 | 401 | $this->db->update($this->cal_table, array('cal_uid' => $event['uid']), |
| 402 | - array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar'); |
|
| 402 | + array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar'); |
|
| 403 | 403 | } |
| 404 | 404 | if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE) |
| 405 | 405 | { |
| 406 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 406 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 407 | 407 | 'cal_id' => $ids, |
| 408 | 408 | 'recur_exception' => true, |
| 409 | 409 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
| 410 | 410 | { |
| 411 | 411 | $events[$row['cal_id']]['recur_exception'][] = $row['cal_start']; |
| 412 | 412 | } |
| 413 | - break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
| 413 | + break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
| 414 | 414 | } |
| 415 | 415 | // make sure we fetch only real exceptions (deleted occurrences of a series should not show up) |
| 416 | - if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
| 416 | + if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
| 417 | 417 | { |
| 418 | 418 | //_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']); |
| 419 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 419 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 420 | 420 | 'cal_id' => $event['id'], |
| 421 | 421 | 'cal_start' => $event['start'], |
| 422 | 422 | 'recur_exception' => true, |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | 'cal_deleted' => NULL |
| 433 | 433 | ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn()) |
| 434 | 434 | { |
| 435 | - $e = $this->read($event['id'],$event['start']+1); |
|
| 435 | + $e = $this->read($event['id'], $event['start'] + 1); |
|
| 436 | 436 | $event = $e[$event['id']]; |
| 437 | 437 | break; |
| 438 | 438 | } |
@@ -454,21 +454,21 @@ discard block |
||
| 454 | 454 | if ($recur_date) |
| 455 | 455 | { |
| 456 | 456 | // also remember recur_date, maybe we need it later, duno now |
| 457 | - $recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']); |
|
| 457 | + $recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0 |
| 462 | 462 | // sorting by cal_recur_date ASC makes sure recurence status always overwrites series status |
| 463 | - foreach($this->db->select($this->user_table,'*',array( |
|
| 463 | + foreach ($this->db->select($this->user_table, '*', array( |
|
| 464 | 464 | 'cal_id' => $ids, |
| 465 | 465 | 'cal_recur_date' => $recur_date, |
| 466 | 466 | "cal_status NOT IN ('X','E')", |
| 467 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
| 467 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row) // DESC puts users before resources and contacts |
|
| 468 | 468 | { |
| 469 | 469 | // combine all participant data in uid and status values |
| 470 | 470 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 471 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 471 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 472 | 472 | |
| 473 | 473 | $events[$row['cal_id']]['participants'][$uid] = $status; |
| 474 | 474 | $events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status; |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | // custom fields |
| 480 | - foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 480 | + foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 481 | 481 | { |
| 482 | 482 | $events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value']; |
| 483 | 483 | } |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | // alarms |
| 486 | 486 | if (is_array($ids)) |
| 487 | 487 | { |
| 488 | - foreach($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
| 488 | + foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
| 489 | 489 | { |
| 490 | 490 | $events[$cal_id]['alarm'] = $alarms; |
| 491 | 491 | } |
@@ -514,11 +514,11 @@ discard block |
||
| 514 | 514 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
| 515 | 515 | * @return int maximum modification timestamp |
| 516 | 516 | */ |
| 517 | - function get_ctag($users, $owner_too=false,$master_only=false) |
|
| 517 | + function get_ctag($users, $owner_too = false, $master_only = false) |
|
| 518 | 518 | { |
| 519 | - static $ctags = array(); // some per-request caching |
|
| 519 | + static $ctags = array(); // some per-request caching |
|
| 520 | 520 | static $last_request = null; |
| 521 | - if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME) |
|
| 521 | + if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME) |
|
| 522 | 522 | { |
| 523 | 523 | $ctags = array(); |
| 524 | 524 | $last_request = time(); |
@@ -527,13 +527,13 @@ discard block |
||
| 527 | 527 | if (isset($ctags[$signature])) return $ctags[$signature]; |
| 528 | 528 | |
| 529 | 529 | $types = array(); |
| 530 | - foreach((array)$users as $uid) |
|
| 530 | + foreach ((array)$users as $uid) |
|
| 531 | 531 | { |
| 532 | 532 | $type = $id = null; |
| 533 | 533 | self::split_user($uid, $type, $id, true); |
| 534 | 534 | $types[$type][] = $id; |
| 535 | 535 | } |
| 536 | - foreach($types as $type => $ids) |
|
| 536 | + foreach ($types as $type => $ids) |
|
| 537 | 537 | { |
| 538 | 538 | $where = array( |
| 539 | 539 | 'cal_user_type' => $type, |
@@ -555,17 +555,17 @@ discard block |
||
| 555 | 555 | if ($owner_too) |
| 556 | 556 | { |
| 557 | 557 | // owner can only by users, no groups or resources |
| 558 | - foreach($users as $key => $user) |
|
| 558 | + foreach ($users as $key => $user) |
|
| 559 | 559 | { |
| 560 | 560 | if (!($user > 0)) unset($users[$key]); |
| 561 | 561 | } |
| 562 | 562 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
| 563 | 563 | $this->db->expression($this->cal_table, array( |
| 564 | 564 | 'cal_owner' => $users, |
| 565 | - ),')'); |
|
| 565 | + ), ')'); |
|
| 566 | 566 | } |
| 567 | - return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)', |
|
| 568 | - $where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
| 567 | + return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)', |
|
| 568 | + $where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query |
| 578 | 578 | * @return Iterator as Api\Db::select |
| 579 | 579 | */ |
| 580 | - function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
| 580 | + function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
| 581 | 581 | { |
| 582 | 582 | if (!is_array($cols)) $cols = explode(',', $cols); |
| 583 | 583 | |
@@ -605,14 +605,14 @@ discard block |
||
| 605 | 605 | $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); |
| 606 | 606 | array_walk($cats, function(&$val, $key) |
| 607 | 607 | { |
| 608 | - unset($key); // not used, but required by function signature |
|
| 609 | - $val = (int) $val; |
|
| 608 | + unset($key); // not used, but required by function signature |
|
| 609 | + $val = (int)$val; |
|
| 610 | 610 | }); |
| 611 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
| 612 | - $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
| 613 | - foreach($cats as $cat) |
|
| 611 | + if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0]; |
|
| 612 | + $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
| 613 | + foreach ($cats as $cat) |
|
| 614 | 614 | { |
| 615 | - $sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
| 615 | + $sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
| 616 | 616 | } |
| 617 | 617 | $sql .= ') '; |
| 618 | 618 | } |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | * @param array $where =array() array to add filters too |
| 628 | 628 | * @return array |
| 629 | 629 | */ |
| 630 | - protected function status_filter($filter, $enum_recuring=true, array $where=array()) |
|
| 630 | + protected function status_filter($filter, $enum_recuring = true, array $where = array()) |
|
| 631 | 631 | { |
| 632 | - if($filter != 'deleted' && $filter != 'everything') |
|
| 632 | + if ($filter != 'deleted' && $filter != 'everything') |
|
| 633 | 633 | { |
| 634 | 634 | $where[] = 'cal_deleted IS NULL'; |
| 635 | 635 | } |
| 636 | - switch($filter) |
|
| 636 | + switch ($filter) |
|
| 637 | 637 | { |
| 638 | 638 | case 'everything': // no filter at all |
| 639 | 639 | break; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 708 | 708 | * @return Iterator|array of events |
| 709 | 709 | */ |
| 710 | - function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
| 710 | + function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
| 711 | 711 | { |
| 712 | 712 | //error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
| 713 | 713 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | { |
| 731 | 731 | $all_cols = self::get_columns('calendar', $this->cal_table); |
| 732 | 732 | $all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
| 733 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 733 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 734 | 734 | } |
| 735 | 735 | $where = array(); |
| 736 | 736 | if (is_array($params['query'])) |
@@ -739,19 +739,19 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | elseif ($params['query']) |
| 741 | 741 | { |
| 742 | - foreach(array('cal_title','cal_description','cal_location') as $col) |
|
| 742 | + foreach (array('cal_title', 'cal_description', 'cal_location') as $col) |
|
| 743 | 743 | { |
| 744 | 744 | $to_or[] = $col.' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%'); |
| 745 | 745 | } |
| 746 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 746 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 747 | 747 | |
| 748 | 748 | // Searching - restrict private to own or private grant |
| 749 | 749 | if (!isset($params['private_grants'])) |
| 750 | 750 | { |
| 751 | 751 | $params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar'); |
| 752 | - $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
| 752 | + $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
| 753 | 753 | } |
| 754 | - $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')'; |
|
| 754 | + $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')'; |
|
| 755 | 755 | $where[] = $private_filter; |
| 756 | 756 | } |
| 757 | 757 | if (!empty($params['sql_filter'])) |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | { |
| 761 | 761 | $where[] = $params['sql_filter']; |
| 762 | 762 | } |
| 763 | - elseif(is_array($params['sql_filter'])) |
|
| 763 | + elseif (is_array($params['sql_filter'])) |
|
| 764 | 764 | { |
| 765 | 765 | $where = array_merge($where, $params['sql_filter']); |
| 766 | 766 | } |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | if ($users) |
| 769 | 769 | { |
| 770 | 770 | $users_by_type = array(); |
| 771 | - foreach((array)$users as $user) |
|
| 771 | + foreach ((array)$users as $user) |
|
| 772 | 772 | { |
| 773 | 773 | if (is_numeric($user)) |
| 774 | 774 | { |
| 775 | - $users_by_type['u'][] = (int) $user; |
|
| 775 | + $users_by_type['u'][] = (int)$user; |
|
| 776 | 776 | } |
| 777 | 777 | else |
| 778 | 778 | { |
@@ -784,45 +784,45 @@ discard block |
||
| 784 | 784 | $to_or = $user_or = array(); |
| 785 | 785 | $owner_or = null; |
| 786 | 786 | $useUnionQuery = $this->db->capabilities['distinct_on_text'] && $this->db->capabilities['union']; |
| 787 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
| 788 | - foreach($users_by_type as $type => $ids) |
|
| 787 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
| 788 | + foreach ($users_by_type as $type => $ids) |
|
| 789 | 789 | { |
| 790 | 790 | // when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union |
| 791 | 791 | if ($useUnionQuery) |
| 792 | 792 | { |
| 793 | - $user_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
| 793 | + $user_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
| 794 | 794 | 'cal_user_type' => $type, |
| 795 | - ),' AND '.$this->user_table.'.',array( |
|
| 795 | + ), ' AND '.$this->user_table.'.', array( |
|
| 796 | 796 | 'cal_user_id' => $ids, |
| 797 | 797 | )); |
| 798 | 798 | if ($type == 'u' && $filter == 'owner') |
| 799 | 799 | { |
| 800 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
| 800 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
| 801 | 801 | // only users can be owners, no need to add groups |
| 802 | 802 | $user_ids = array(); |
| 803 | - foreach($ids as $user_id) |
|
| 803 | + foreach ($ids as $user_id) |
|
| 804 | 804 | { |
| 805 | 805 | if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
| 806 | 806 | } |
| 807 | - $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
|
| 807 | + $owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids)); |
|
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | else |
| 811 | 811 | { |
| 812 | - $to_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
| 812 | + $to_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
| 813 | 813 | 'cal_user_type' => $type, |
| 814 | - ),' AND '.$this->user_table.'.',array( |
|
| 814 | + ), ' AND '.$this->user_table.'.', array( |
|
| 815 | 815 | 'cal_user_id' => $ids, |
| 816 | 816 | )); |
| 817 | 817 | if ($type == 'u' && $filter == 'owner') |
| 818 | 818 | { |
| 819 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
| 820 | - $to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids)); |
|
| 819 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
| 820 | + $to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids)); |
|
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | // this is only used, when we cannot use UNIONS |
| 825 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 825 | + if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 826 | 826 | |
| 827 | 827 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
| 828 | 828 | } |
@@ -841,15 +841,15 @@ discard block |
||
| 841 | 841 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 844 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 845 | 845 | |
| 846 | 846 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
| 847 | 847 | if (!$params['enum_recuring']) |
| 848 | 848 | { |
| 849 | 849 | $where[] = "$this->user_table.cal_recur_date=0"; |
| 850 | - $cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols); |
|
| 850 | + $cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols); |
|
| 851 | 851 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
| 852 | - $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
| 852 | + $where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
| 853 | 853 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
| 854 | 854 | if ($end) $where[] = (int)$end.' > range_start'; |
| 855 | 855 | } |
@@ -861,14 +861,13 @@ discard block |
||
| 861 | 861 | " ON $this->cal_table.cal_id=rejected_by_user.cal_id". |
| 862 | 862 | " AND rejected_by_user.cal_user_type='u'". |
| 863 | 863 | " AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user). |
| 864 | - " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : |
|
| 865 | - '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
| 864 | + " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
| 866 | 865 | $or_required = array( |
| 867 | 866 | 'rejected_by_user.cal_status IS NULL', |
| 868 | 867 | "rejected_by_user.cal_status NOT IN ('R','X')", |
| 869 | 868 | ); |
| 870 | 869 | if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
| 871 | - $where[] = '('.implode(' OR ',$or_required).')'; |
|
| 870 | + $where[] = '('.implode(' OR ', $or_required).')'; |
|
| 872 | 871 | } |
| 873 | 872 | // using a time-range and deleted attribute limited view instead of full table |
| 874 | 873 | $cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted'); |
@@ -880,7 +879,7 @@ discard block |
||
| 880 | 879 | // dates table join only needed to enum recuring events, we use a time-range limited view here too |
| 881 | 880 | if ($params['enum_recuring']) |
| 882 | 881 | { |
| 883 | - $join = "JOIN ".$this->dates_table. // using dates_table direct seems quicker then an other view |
|
| 882 | + $join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view |
|
| 884 | 883 | //$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted'). |
| 885 | 884 | " ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join; |
| 886 | 885 | } |
@@ -907,29 +906,29 @@ discard block |
||
| 907 | 906 | // as replace the OR by construction of a suitable UNION for performance reasons |
| 908 | 907 | if ($owner_or || $user_or) |
| 909 | 908 | { |
| 910 | - foreach($user_or as $user_sql) |
|
| 909 | + foreach ($user_or as $user_sql) |
|
| 911 | 910 | { |
| 912 | 911 | $selects[] = $select; |
| 913 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
| 912 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
| 914 | 913 | if ($params['enum_recuring']) |
| 915 | 914 | { |
| 916 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 915 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 917 | 916 | $selects[] = $select; |
| 918 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
| 919 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 917 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
| 918 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 920 | 919 | } |
| 921 | 920 | } |
| 922 | 921 | // if the query is to be filtered by owner we need to add more selects for the union |
| 923 | 922 | if ($owner_or) |
| 924 | 923 | { |
| 925 | 924 | $selects[] = $select; |
| 926 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
| 925 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
| 927 | 926 | if ($params['enum_recuring']) |
| 928 | 927 | { |
| 929 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 928 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 930 | 929 | $selects[] = $select; |
| 931 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
| 932 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 930 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
| 931 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 933 | 932 | } |
| 934 | 933 | } |
| 935 | 934 | } |
@@ -939,34 +938,34 @@ discard block |
||
| 939 | 938 | $selects[] = $select; |
| 940 | 939 | if ($params['enum_recuring']) |
| 941 | 940 | { |
| 942 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 941 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 943 | 942 | $selects[] = $select; |
| 944 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 943 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 945 | 944 | } |
| 946 | 945 | } |
| 947 | 946 | if (is_numeric($offset) && !$params['no_total']) // get the total too |
| 948 | 947 | { |
| 949 | 948 | $save_selects = $selects; |
| 950 | 949 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 951 | - foreach(array_keys($selects) as $key) |
|
| 950 | + foreach (array_keys($selects) as $key) |
|
| 952 | 951 | { |
| 953 | 952 | $selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date"; |
| 954 | 953 | if (!$params['enum_recuring']) |
| 955 | 954 | { |
| 956 | - $selects[$key]['cols'] = str_replace(array('cal_start','cal_end'), |
|
| 957 | - array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
|
| 955 | + $selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'), |
|
| 956 | + array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']); |
|
| 958 | 957 | } |
| 959 | 958 | } |
| 960 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 959 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 961 | 960 | |
| 962 | - $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
|
| 961 | + $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
|
| 963 | 962 | |
| 964 | 963 | // restore original cols / selects |
| 965 | 964 | $selects = $save_selects; unset($save_selects); |
| 966 | 965 | } |
| 967 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 966 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 968 | 967 | |
| 969 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
| 968 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
| 970 | 969 | } |
| 971 | 970 | else // MsSQL oder MySQL 3.23 |
| 972 | 971 | { |
@@ -989,27 +988,27 @@ discard block |
||
| 989 | 988 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
| 990 | 989 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
| 991 | 990 | { |
| 992 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 991 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 993 | 992 | } |
| 994 | 993 | $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
| 995 | 994 | $selects = $save_selects; |
| 996 | 995 | } |
| 997 | 996 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
| 998 | 997 | { |
| 999 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 998 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 1000 | 999 | } |
| 1001 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
| 1000 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
| 1002 | 1001 | } |
| 1003 | 1002 | //error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql); |
| 1004 | 1003 | |
| 1005 | 1004 | if (isset($params['cols'])) |
| 1006 | 1005 | { |
| 1007 | - return $rs; // if colums are specified we return the recordset / iterator |
|
| 1006 | + return $rs; // if colums are specified we return the recordset / iterator |
|
| 1008 | 1007 | } |
| 1009 | 1008 | // Todo: return $this->get_events($rs); |
| 1010 | 1009 | |
| 1011 | 1010 | $events = $ids = $recur_dates = $recur_ids = array(); |
| 1012 | - foreach($rs as $row) |
|
| 1011 | + foreach ($rs as $row) |
|
| 1013 | 1012 | { |
| 1014 | 1013 | $id = $row['cal_id']; |
| 1015 | 1014 | if (is_numeric($id)) $ids[] = $id; |
@@ -1021,9 +1020,9 @@ discard block |
||
| 1021 | 1020 | } |
| 1022 | 1021 | if ($row['participants']) |
| 1023 | 1022 | { |
| 1024 | - $row['participants'] = explode(',',$row['participants']); |
|
| 1023 | + $row['participants'] = explode(',', $row['participants']); |
|
| 1025 | 1024 | $row['participants'] = array_combine($row['participants'], |
| 1026 | - array_fill(0,count($row['participants']),'')); |
|
| 1025 | + array_fill(0, count($row['participants']), '')); |
|
| 1027 | 1026 | } |
| 1028 | 1027 | else |
| 1029 | 1028 | { |
@@ -1032,9 +1031,9 @@ discard block |
||
| 1032 | 1031 | $row['recur_exception'] = $row['alarm'] = array(); |
| 1033 | 1032 | |
| 1034 | 1033 | // compile a list of recurrences per cal_id |
| 1035 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1034 | + if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1036 | 1035 | |
| 1037 | - $events[$id] = Api\Db::strip_array_keys($row,'cal_'); |
|
| 1036 | + $events[$id] = Api\Db::strip_array_keys($row, 'cal_'); |
|
| 1038 | 1037 | } |
| 1039 | 1038 | //_debug_array($events); |
| 1040 | 1039 | if (count($ids)) |
@@ -1044,26 +1043,26 @@ discard block |
||
| 1044 | 1043 | // now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date) |
| 1045 | 1044 | // This will always read the first entry of each recuring event too, we eliminate it later |
| 1046 | 1045 | $recur_dates[] = 0; |
| 1047 | - $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")". |
|
| 1046 | + $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")". |
|
| 1048 | 1047 | ($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid "; |
| 1049 | 1048 | //$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates "; |
| 1050 | - foreach($this->db->select($utcal_id_view,'*',array( |
|
| 1049 | + foreach ($this->db->select($utcal_id_view, '*', array( |
|
| 1051 | 1050 | //'cal_id' => array_unique($ids), |
| 1052 | 1051 | 'cal_recur_date' => $recur_dates, |
| 1053 | - ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='', |
|
| 1054 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1052 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', $num_rows, $join = '', |
|
| 1053 | + $this->db->get_table_definitions('calendar', $this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1055 | 1054 | { |
| 1056 | 1055 | $id = $row['cal_id']; |
| 1057 | 1056 | if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
| 1058 | 1057 | |
| 1059 | 1058 | // combine all participant data in uid and status values |
| 1060 | 1059 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1061 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 1060 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 1062 | 1061 | |
| 1063 | 1062 | // set accept/reject/tentative of series for all recurrences |
| 1064 | 1063 | if (!$row['cal_recur_date']) |
| 1065 | 1064 | { |
| 1066 | - foreach((array)$recur_ids[$row['cal_id']] as $i) |
|
| 1065 | + foreach ((array)$recur_ids[$row['cal_id']] as $i) |
|
| 1067 | 1066 | { |
| 1068 | 1067 | if (isset($events[$i]) && !isset($events[$i]['participants'][$uid])) |
| 1069 | 1068 | { |
@@ -1078,16 +1077,16 @@ discard block |
||
| 1078 | 1077 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
| 1079 | 1078 | if (!$params['enum_recuring'] || !$params['daywise']) |
| 1080 | 1079 | { |
| 1081 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 1080 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 1082 | 1081 | 'cal_id' => $ids, |
| 1083 | 1082 | 'recur_exception' => true, |
| 1084 | 1083 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
| 1085 | 1084 | { |
| 1086 | 1085 | // for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start |
| 1087 | 1086 | // find master, which is first recurrence |
| 1088 | - if (!isset($events[$id=$row['cal_id']])) |
|
| 1087 | + if (!isset($events[$id = $row['cal_id']])) |
|
| 1089 | 1088 | { |
| 1090 | - foreach($events as $id => $event) |
|
| 1089 | + foreach ($events as $id => $event) |
|
| 1091 | 1090 | { |
| 1092 | 1091 | if ($event['id'] == $row['cal_id']) break; |
| 1093 | 1092 | } |
@@ -1100,10 +1099,10 @@ discard block |
||
| 1100 | 1099 | { |
| 1101 | 1100 | $where = array('cal_id' => $ids); |
| 1102 | 1101 | if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
| 1103 | - foreach($this->db->select($this->extra_table,'*',$where, |
|
| 1104 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1102 | + foreach ($this->db->select($this->extra_table, '*', $where, |
|
| 1103 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1105 | 1104 | { |
| 1106 | - foreach((array)$recur_ids[$row['cal_id']] as $id) |
|
| 1105 | + foreach ((array)$recur_ids[$row['cal_id']] as $id) |
|
| 1107 | 1106 | { |
| 1108 | 1107 | if (isset($events[$id])) |
| 1109 | 1108 | { |
@@ -1113,9 +1112,9 @@ discard block |
||
| 1113 | 1112 | } |
| 1114 | 1113 | } |
| 1115 | 1114 | // alarms |
| 1116 | - foreach($this->read_alarms($ids) as $cal_id => $alarms) |
|
| 1115 | + foreach ($this->read_alarms($ids) as $cal_id => $alarms) |
|
| 1117 | 1116 | { |
| 1118 | - foreach($alarms as $id => $alarm) |
|
| 1117 | + foreach ($alarms as $id => $alarm) |
|
| 1119 | 1118 | { |
| 1120 | 1119 | $event_start = $alarm['time'] + $alarm['offset']; |
| 1121 | 1120 | |
@@ -1152,16 +1151,16 @@ discard block |
||
| 1152 | 1151 | * @param $query |
| 1153 | 1152 | * @param $users_raw as passed to calendar_bo::search (no members and memberships added) |
| 1154 | 1153 | */ |
| 1155 | - private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw) |
|
| 1154 | + private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw) |
|
| 1156 | 1155 | { |
| 1157 | - if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) || |
|
| 1158 | - !in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home'))) |
|
| 1156 | + if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) || |
|
| 1157 | + !in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home'))) |
|
| 1159 | 1158 | { |
| 1160 | - return; // disable integration for GroupDAV, SyncML, ... |
|
| 1159 | + return; // disable integration for GroupDAV, SyncML, ... |
|
| 1161 | 1160 | } |
| 1162 | 1161 | self::$integration_data = Api\Hooks::process(array( |
| 1163 | 1162 | 'location' => 'calendar_search_union', |
| 1164 | - 'cols' => $selects[0]['cols'], // cols to return |
|
| 1163 | + 'cols' => $selects[0]['cols'], // cols to return |
|
| 1165 | 1164 | 'start' => $start, |
| 1166 | 1165 | 'end' => $end, |
| 1167 | 1166 | 'users' => $users, |
@@ -1170,12 +1169,12 @@ discard block |
||
| 1170 | 1169 | 'filter'=> $filter, |
| 1171 | 1170 | 'query' => $query, |
| 1172 | 1171 | )); |
| 1173 | - foreach(self::$integration_data as $data) |
|
| 1172 | + foreach (self::$integration_data as $data) |
|
| 1174 | 1173 | { |
| 1175 | 1174 | if (is_array($data['selects'])) |
| 1176 | 1175 | { |
| 1177 | 1176 | //echo $app; _debug_array($data); |
| 1178 | - $selects = array_merge($selects,$data['selects']); |
|
| 1177 | + $selects = array_merge($selects, $data['selects']); |
|
| 1179 | 1178 | } |
| 1180 | 1179 | } |
| 1181 | 1180 | } |
@@ -1200,35 +1199,35 @@ discard block |
||
| 1200 | 1199 | * @param string $required_app ='calendar' |
| 1201 | 1200 | * @return string cols for union query to match ones supplied in $required |
| 1202 | 1201 | */ |
| 1203 | - public static function union_cols(array $app_cols,$required,$required_app='calendar') |
|
| 1202 | + public static function union_cols(array $app_cols, $required, $required_app = 'calendar') |
|
| 1204 | 1203 | { |
| 1205 | 1204 | // remove evtl. used DISTINCT, we currently dont need it |
| 1206 | - if (($distinct = substr($required,0,9) == 'DISTINCT ')) |
|
| 1205 | + if (($distinct = substr($required, 0, 9) == 'DISTINCT ')) |
|
| 1207 | 1206 | { |
| 1208 | - $required = substr($required,9); |
|
| 1207 | + $required = substr($required, 9); |
|
| 1209 | 1208 | } |
| 1210 | 1209 | $return_cols = array(); |
| 1211 | - foreach(is_array($required) ? $required : explode(',',$required) as $cols) |
|
| 1210 | + foreach (is_array($required) ? $required : explode(',', $required) as $cols) |
|
| 1212 | 1211 | { |
| 1213 | 1212 | $matches = null; |
| 1214 | - if (substr($cols,-2) == '.*') |
|
| 1213 | + if (substr($cols, -2) == '.*') |
|
| 1215 | 1214 | { |
| 1216 | - $cols = self::get_columns($required_app,substr($cols,0,-2)); |
|
| 1215 | + $cols = self::get_columns($required_app, substr($cols, 0, -2)); |
|
| 1217 | 1216 | } |
| 1218 | 1217 | // remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)" |
| 1219 | 1218 | elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches)) |
| 1220 | 1219 | { |
| 1221 | 1220 | $cols = $matches[1]; |
| 1222 | 1221 | } |
| 1223 | - elseif (strpos($cols,' AS ') !== false) |
|
| 1222 | + elseif (strpos($cols, ' AS ') !== false) |
|
| 1224 | 1223 | { |
| 1225 | - list(,$cols) = explode(' AS ',$cols); |
|
| 1224 | + list(,$cols) = explode(' AS ', $cols); |
|
| 1226 | 1225 | } |
| 1227 | - foreach((array)$cols as $col) |
|
| 1226 | + foreach ((array)$cols as $col) |
|
| 1228 | 1227 | { |
| 1229 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
| 1228 | + if (substr($col, 0, 7) == 'egw_cal') // remove table name |
|
| 1230 | 1229 | { |
| 1231 | - $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
|
| 1230 | + $col = preg_replace('/^egw_cal[a-z_]*\./', '', $col); |
|
| 1232 | 1231 | } |
| 1233 | 1232 | if (isset($app_cols[$col])) |
| 1234 | 1233 | { |
@@ -1241,7 +1240,7 @@ discard block |
||
| 1241 | 1240 | } |
| 1242 | 1241 | } |
| 1243 | 1242 | //error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols))); |
| 1244 | - return implode(',',$return_cols); |
|
| 1243 | + return implode(',', $return_cols); |
|
| 1245 | 1244 | } |
| 1246 | 1245 | |
| 1247 | 1246 | /** |
@@ -1251,21 +1250,21 @@ discard block |
||
| 1251 | 1250 | * @param string $table |
| 1252 | 1251 | * @return array of column names |
| 1253 | 1252 | */ |
| 1254 | - static private function get_columns($app,$table) |
|
| 1253 | + static private function get_columns($app, $table) |
|
| 1255 | 1254 | { |
| 1256 | 1255 | if ($table != 'egw_cal') |
| 1257 | 1256 | { |
| 1258 | - $table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table); |
|
| 1257 | + $table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table); |
|
| 1259 | 1258 | $cols = array_keys($table_def['fd']); |
| 1260 | 1259 | } |
| 1261 | 1260 | else |
| 1262 | 1261 | { |
| 1263 | 1262 | // special handling for egw_cal, as old databases have a different column order!!! |
| 1264 | - $cols =& Api\Cache::getSession(__CLASS__,$table); |
|
| 1263 | + $cols = & Api\Cache::getSession(__CLASS__, $table); |
|
| 1265 | 1264 | |
| 1266 | 1265 | if (is_null($cols)) |
| 1267 | 1266 | { |
| 1268 | - $meta = $GLOBALS['egw']->db->metadata($table,true); |
|
| 1267 | + $meta = $GLOBALS['egw']->db->metadata($table, true); |
|
| 1269 | 1268 | $cols = array_keys($meta['meta']); |
| 1270 | 1269 | } |
| 1271 | 1270 | } |
@@ -1318,12 +1317,12 @@ discard block |
||
| 1318 | 1317 | * @param int &$etag etag=null etag to check or null, on return new etag |
| 1319 | 1318 | * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise |
| 1320 | 1319 | */ |
| 1321 | - function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null) |
|
| 1320 | + function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null) |
|
| 1322 | 1321 | { |
| 1323 | 1322 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 1324 | 1323 | { |
| 1325 | 1324 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
| 1326 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1325 | + if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1327 | 1326 | } |
| 1328 | 1327 | else |
| 1329 | 1328 | { |
@@ -1334,7 +1333,7 @@ discard block |
||
| 1334 | 1333 | |
| 1335 | 1334 | //error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace()); |
| 1336 | 1335 | |
| 1337 | - $cal_id = (int) $event['id']; |
|
| 1336 | + $cal_id = (int)$event['id']; |
|
| 1338 | 1337 | unset($event['id']); |
| 1339 | 1338 | $set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE; |
| 1340 | 1339 | |
@@ -1362,9 +1361,9 @@ discard block |
||
| 1362 | 1361 | } |
| 1363 | 1362 | |
| 1364 | 1363 | // add colum prefix 'cal_' if there's not already a 'recur_' prefix |
| 1365 | - foreach($event as $col => $val) |
|
| 1364 | + foreach ($event as $col => $val) |
|
| 1366 | 1365 | { |
| 1367 | - if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
| 1366 | + if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
| 1368 | 1367 | { |
| 1369 | 1368 | $event['cal_'.$col] = $val; |
| 1370 | 1369 | unset($event[$col]); |
@@ -1374,13 +1373,12 @@ discard block |
||
| 1374 | 1373 | if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
| 1375 | 1374 | if (isset($event['cal_end'])) |
| 1376 | 1375 | { |
| 1377 | - $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
|
| 1378 | - ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
| 1376 | + $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
| 1379 | 1377 | } |
| 1380 | 1378 | // ensure that we find mathing entries later on |
| 1381 | 1379 | if (!is_array($event['cal_category'])) |
| 1382 | 1380 | { |
| 1383 | - $categories = array_unique(explode(',',$event['cal_category'])); |
|
| 1381 | + $categories = array_unique(explode(',', $event['cal_category'])); |
|
| 1384 | 1382 | sort($categories); |
| 1385 | 1383 | } |
| 1386 | 1384 | else |
@@ -1389,7 +1387,7 @@ discard block |
||
| 1389 | 1387 | } |
| 1390 | 1388 | sort($categories, SORT_NUMERIC); |
| 1391 | 1389 | |
| 1392 | - $event['cal_category'] = implode(',',$categories); |
|
| 1390 | + $event['cal_category'] = implode(',', $categories); |
|
| 1393 | 1391 | |
| 1394 | 1392 | // make sure recurring events never reference to an other recurrent event |
| 1395 | 1393 | if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
@@ -1407,18 +1405,18 @@ discard block |
||
| 1407 | 1405 | // read only timezone id, to check if it is changed |
| 1408 | 1406 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1409 | 1407 | { |
| 1410 | - $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
|
| 1408 | + $old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn(); |
|
| 1411 | 1409 | } |
| 1412 | 1410 | if (!is_null($etag)) $where['cal_etag'] = $etag; |
| 1413 | 1411 | |
| 1414 | 1412 | unset($event['cal_etag']); |
| 1415 | - $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
| 1413 | + $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
| 1416 | 1414 | |
| 1417 | - $this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar'); |
|
| 1415 | + $this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar'); |
|
| 1418 | 1416 | |
| 1419 | 1417 | if (!is_null($etag) && $this->db->affected_rows() < 1) |
| 1420 | 1418 | { |
| 1421 | - return 0; // wrong etag, someone else updated the entry |
|
| 1419 | + return 0; // wrong etag, someone else updated the entry |
|
| 1422 | 1420 | } |
| 1423 | 1421 | if (!is_null($etag)) ++$etag; |
| 1424 | 1422 | } |
@@ -1427,10 +1425,10 @@ discard block |
||
| 1427 | 1425 | // new event |
| 1428 | 1426 | if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 1429 | 1427 | |
| 1430 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1428 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1431 | 1429 | |
| 1432 | - $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
|
| 1433 | - if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id'))) |
|
| 1430 | + $this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar'); |
|
| 1431 | + if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id'))) |
|
| 1434 | 1432 | { |
| 1435 | 1433 | return false; |
| 1436 | 1434 | } |
@@ -1440,7 +1438,7 @@ discard block |
||
| 1440 | 1438 | // event without uid or not strong enough uid |
| 1441 | 1439 | if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length) |
| 1442 | 1440 | { |
| 1443 | - $update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id); |
|
| 1441 | + $update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar', $cal_id); |
|
| 1444 | 1442 | } |
| 1445 | 1443 | // set caldav_name, if not given by caller |
| 1446 | 1444 | if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>=')) |
@@ -1449,37 +1447,37 @@ discard block |
||
| 1449 | 1447 | } |
| 1450 | 1448 | if ($update) |
| 1451 | 1449 | { |
| 1452 | - $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
| 1450 | + $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 1453 | 1451 | } |
| 1454 | 1452 | |
| 1455 | 1453 | if ($event['recur_type'] == MCAL_RECUR_NONE) |
| 1456 | 1454 | { |
| 1457 | - $this->db->delete($this->dates_table,array( |
|
| 1455 | + $this->db->delete($this->dates_table, array( |
|
| 1458 | 1456 | 'cal_id' => $cal_id), |
| 1459 | - __LINE__,__FILE__,'calendar'); |
|
| 1457 | + __LINE__, __FILE__, 'calendar'); |
|
| 1460 | 1458 | |
| 1461 | 1459 | // delete all user-records, with recur-date != 0 |
| 1462 | - $this->db->delete($this->user_table,array( |
|
| 1460 | + $this->db->delete($this->user_table, array( |
|
| 1463 | 1461 | 'cal_id' => $cal_id, 'cal_recur_date != 0'), |
| 1464 | - __LINE__,__FILE__,'calendar'); |
|
| 1462 | + __LINE__, __FILE__, 'calendar'); |
|
| 1465 | 1463 | |
| 1466 | - $this->db->delete($this->repeats_table,array( |
|
| 1464 | + $this->db->delete($this->repeats_table, array( |
|
| 1467 | 1465 | 'cal_id' => $cal_id), |
| 1468 | - __LINE__,__FILE__,'calendar'); |
|
| 1466 | + __LINE__, __FILE__, 'calendar'); |
|
| 1469 | 1467 | |
| 1470 | 1468 | // add exception marker to master, so participants added to exceptions *only* get found |
| 1471 | 1469 | if ($event['cal_reference']) |
| 1472 | 1470 | { |
| 1473 | 1471 | $master_participants = array(); |
| 1474 | - foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
| 1472 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
| 1475 | 1473 | 'cal_id' => $event['cal_reference'], |
| 1476 | 1474 | 'cal_recur_date' => 0, |
| 1477 | - "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
| 1475 | + "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
| 1478 | 1476 | ), __LINE__, __FILE__, 'calendar') as $row) |
| 1479 | 1477 | { |
| 1480 | 1478 | $master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1481 | 1479 | } |
| 1482 | - foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
| 1480 | + foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
| 1483 | 1481 | { |
| 1484 | 1482 | $user_type = $user_id = null; |
| 1485 | 1483 | self::split_user($uid, $user_type, $user_id, true); |
@@ -1498,10 +1496,10 @@ discard block |
||
| 1498 | 1496 | else // write information about recuring event, if recur_type is present in the array |
| 1499 | 1497 | { |
| 1500 | 1498 | // fetch information about the currently saved (old) event |
| 1501 | - $old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 1502 | - $old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min; |
|
| 1499 | + $old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 1500 | + $old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min; |
|
| 1503 | 1501 | $old_exceptions = array(); |
| 1504 | - foreach($this->db->select($this->dates_table, 'cal_start', array( |
|
| 1502 | + foreach ($this->db->select($this->dates_table, 'cal_start', array( |
|
| 1505 | 1503 | 'cal_id' => $cal_id, |
| 1506 | 1504 | 'recur_exception' => true |
| 1507 | 1505 | ), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row) |
@@ -1520,8 +1518,8 @@ discard block |
||
| 1520 | 1518 | 'cal_recur_date' => 0, |
| 1521 | 1519 | ); |
| 1522 | 1520 | $old_participants = array(); |
| 1523 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
| 1524 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1521 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
| 1522 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1525 | 1523 | { |
| 1526 | 1524 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1527 | 1525 | $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
@@ -1531,7 +1529,7 @@ discard block |
||
| 1531 | 1529 | // re-check: did so much recurrence data change that we have to rebuild it from scratch? |
| 1532 | 1530 | if (!$set_recurrences) |
| 1533 | 1531 | { |
| 1534 | - $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
|
| 1532 | + $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) || |
|
| 1535 | 1533 | $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
| 1536 | 1534 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
| 1537 | 1535 | } |
@@ -1540,22 +1538,22 @@ discard block |
||
| 1540 | 1538 | { |
| 1541 | 1539 | // too much recurrence data has changed, we have to do a rebuild from scratch |
| 1542 | 1540 | // delete all, but the lowest dates record |
| 1543 | - $this->db->delete($this->dates_table,array( |
|
| 1541 | + $this->db->delete($this->dates_table, array( |
|
| 1544 | 1542 | 'cal_id' => $cal_id, |
| 1545 | 1543 | 'cal_start > '.(int)$old_min, |
| 1546 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1544 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1547 | 1545 | |
| 1548 | 1546 | // delete all user-records, with recur-date != 0 |
| 1549 | - $this->db->delete($this->user_table,array( |
|
| 1547 | + $this->db->delete($this->user_table, array( |
|
| 1550 | 1548 | 'cal_id' => $cal_id, |
| 1551 | 1549 | 'cal_recur_date != 0', |
| 1552 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1550 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1553 | 1551 | } |
| 1554 | 1552 | else |
| 1555 | 1553 | { |
| 1556 | 1554 | // we adjust some possibly changed recurrences manually |
| 1557 | 1555 | // deleted exceptions: re-insert recurrences into the user and dates table |
| 1558 | - if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception']))) |
|
| 1556 | + if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception']))) |
|
| 1559 | 1557 | { |
| 1560 | 1558 | if (isset($event['cal_participants'])) |
| 1561 | 1559 | { |
@@ -1566,7 +1564,7 @@ discard block |
||
| 1566 | 1564 | // use old default |
| 1567 | 1565 | $participants = $old_participants; |
| 1568 | 1566 | } |
| 1569 | - foreach($deleted_exceptions as $id => $deleted_exception) |
|
| 1567 | + foreach ($deleted_exceptions as $id => $deleted_exception) |
|
| 1570 | 1568 | { |
| 1571 | 1569 | // rebuild participants for the re-inserted recurrence |
| 1572 | 1570 | $this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants); |
@@ -1574,24 +1572,24 @@ discard block |
||
| 1574 | 1572 | } |
| 1575 | 1573 | |
| 1576 | 1574 | // check if recurrence enddate was adjusted |
| 1577 | - if(isset($event['recur_enddate'])) |
|
| 1575 | + if (isset($event['recur_enddate'])) |
|
| 1578 | 1576 | { |
| 1579 | 1577 | // recurrences need to be truncated |
| 1580 | - if((int)$event['recur_enddate'] > 0 && |
|
| 1578 | + if ((int)$event['recur_enddate'] > 0 && |
|
| 1581 | 1579 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
| 1582 | 1580 | ) |
| 1583 | 1581 | { |
| 1584 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
| 1585 | - $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
| 1582 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
| 1583 | + $this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
| 1586 | 1584 | } |
| 1587 | 1585 | |
| 1588 | 1586 | // recurrences need to be expanded |
| 1589 | - if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
| 1587 | + if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
| 1590 | 1588 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
| 1591 | 1589 | ) |
| 1592 | 1590 | { |
| 1593 | 1591 | $set_recurrences = true; |
| 1594 | - $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
|
| 1592 | + $set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s); |
|
| 1595 | 1593 | } |
| 1596 | 1594 | //error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start"); |
| 1597 | 1595 | } |
@@ -1600,9 +1598,9 @@ discard block |
||
| 1600 | 1598 | if (count($event['recur_exception'])) |
| 1601 | 1599 | { |
| 1602 | 1600 | // added and existing exceptions: delete the execeptions from the user table, it could be the first time |
| 1603 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar'); |
|
| 1601 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar'); |
|
| 1604 | 1602 | // update recur_exception flag based on current exceptions |
| 1605 | - $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array( |
|
| 1603 | + $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array( |
|
| 1606 | 1604 | 'cal_start' => $event['recur_exception'], |
| 1607 | 1605 | )), array( |
| 1608 | 1606 | 'cal_id' => $cal_id, |
@@ -1611,25 +1609,25 @@ discard block |
||
| 1611 | 1609 | } |
| 1612 | 1610 | |
| 1613 | 1611 | // write the repeats table |
| 1614 | - unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
| 1615 | - $this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
| 1612 | + unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
| 1613 | + $this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 1616 | 1614 | } |
| 1617 | 1615 | // update start- and endtime if present in the event-array, evtl. we need to move all recurrences |
| 1618 | 1616 | if (isset($event['cal_start']) && isset($event['cal_end'])) |
| 1619 | 1617 | { |
| 1620 | - $this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
| 1618 | + $this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
| 1621 | 1619 | } |
| 1622 | 1620 | // update participants if present in the event-array |
| 1623 | 1621 | if (isset($event['cal_participants'])) |
| 1624 | 1622 | { |
| 1625 | - $this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since); |
|
| 1623 | + $this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since); |
|
| 1626 | 1624 | } |
| 1627 | 1625 | // Custom fields |
| 1628 | - foreach($event as $name => $value) |
|
| 1626 | + foreach ($event as $name => $value) |
|
| 1629 | 1627 | { |
| 1630 | 1628 | if ($name[0] == '#') |
| 1631 | 1629 | { |
| 1632 | - if (is_array($value) && array_key_exists('id',$value)) |
|
| 1630 | + if (is_array($value) && array_key_exists('id', $value)) |
|
| 1633 | 1631 | { |
| 1634 | 1632 | //error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace()); |
| 1635 | 1633 | $value = $value['id']; |
@@ -1637,19 +1635,19 @@ discard block |
||
| 1637 | 1635 | } |
| 1638 | 1636 | if ($value) |
| 1639 | 1637 | { |
| 1640 | - $this->db->insert($this->extra_table,array( |
|
| 1641 | - 'cal_extra_value' => is_array($value) ? implode(',',$value) : $value, |
|
| 1642 | - ),array( |
|
| 1638 | + $this->db->insert($this->extra_table, array( |
|
| 1639 | + 'cal_extra_value' => is_array($value) ? implode(',', $value) : $value, |
|
| 1640 | + ), array( |
|
| 1643 | 1641 | 'cal_id' => $cal_id, |
| 1644 | - 'cal_extra_name' => substr($name,1), |
|
| 1645 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1642 | + 'cal_extra_name' => substr($name, 1), |
|
| 1643 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1646 | 1644 | } |
| 1647 | 1645 | else |
| 1648 | 1646 | { |
| 1649 | - $this->db->delete($this->extra_table,array( |
|
| 1647 | + $this->db->delete($this->extra_table, array( |
|
| 1650 | 1648 | 'cal_id' => $cal_id, |
| 1651 | - 'cal_extra_name' => substr($name,1), |
|
| 1652 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1649 | + 'cal_extra_name' => substr($name, 1), |
|
| 1650 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1653 | 1651 | } |
| 1654 | 1652 | } |
| 1655 | 1653 | } |
@@ -1660,9 +1658,9 @@ discard block |
||
| 1660 | 1658 | { |
| 1661 | 1659 | if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0) |
| 1662 | 1660 | { |
| 1663 | - unset($alarm['id']); // unset the temporary id to add the alarm |
|
| 1661 | + unset($alarm['id']); // unset the temporary id to add the alarm |
|
| 1664 | 1662 | } |
| 1665 | - if(!isset($alarm['offset'])) |
|
| 1663 | + if (!isset($alarm['offset'])) |
|
| 1666 | 1664 | { |
| 1667 | 1665 | $alarm['offset'] = $event['cal_start'] - $alarm['time']; |
| 1668 | 1666 | } |
@@ -1673,14 +1671,14 @@ discard block |
||
| 1673 | 1671 | |
| 1674 | 1672 | if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm)) |
| 1675 | 1673 | { |
| 1676 | - continue; // pgoerzen: don't add alarm in the past |
|
| 1674 | + continue; // pgoerzen: don't add alarm in the past |
|
| 1677 | 1675 | } |
| 1678 | - $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
| 1676 | + $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
| 1679 | 1677 | } |
| 1680 | 1678 | } |
| 1681 | 1679 | if (is_null($etag)) |
| 1682 | 1680 | { |
| 1683 | - $etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 1681 | + $etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 1684 | 1682 | } |
| 1685 | 1683 | |
| 1686 | 1684 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
@@ -1700,7 +1698,7 @@ discard block |
||
| 1700 | 1698 | * are dealing with, default is now. |
| 1701 | 1699 | * @return boolean true if alarm could be shifted, false if not |
| 1702 | 1700 | */ |
| 1703 | - public static function shift_alarm(array $_event, array &$alarm, $timestamp=null) |
|
| 1701 | + public static function shift_alarm(array $_event, array &$alarm, $timestamp = null) |
|
| 1704 | 1702 | { |
| 1705 | 1703 | if ($_event['recur_type'] == MCAL_RECUR_NONE) |
| 1706 | 1704 | { |
@@ -1711,7 +1709,7 @@ discard block |
||
| 1711 | 1709 | $rrule = calendar_rrule::event2rrule($event, false); |
| 1712 | 1710 | foreach ($rrule as $time) |
| 1713 | 1711 | { |
| 1714 | - if ($start < ($ts = Api\DateTime::to($time,'server'))) |
|
| 1712 | + if ($start < ($ts = Api\DateTime::to($time, 'server'))) |
|
| 1715 | 1713 | { |
| 1716 | 1714 | $alarm['time'] = $ts - $alarm['offset']; |
| 1717 | 1715 | return true; |
@@ -1732,34 +1730,34 @@ discard block |
||
| 1732 | 1730 | * @todo Recalculate recurrences, if timezone changes |
| 1733 | 1731 | * @return int|boolean number of moved recurrences or false on error |
| 1734 | 1732 | */ |
| 1735 | - function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0) |
|
| 1733 | + function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0) |
|
| 1736 | 1734 | { |
| 1737 | 1735 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
| 1738 | 1736 | |
| 1739 | - if (!(int) $cal_id) return false; |
|
| 1737 | + if (!(int)$cal_id) return false; |
|
| 1740 | 1738 | |
| 1741 | 1739 | if (!$old_start) |
| 1742 | 1740 | { |
| 1743 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1744 | - array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
|
| 1741 | + if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1742 | + array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch(); |
|
| 1745 | 1743 | // if no recurrence found, create one with the new dates |
| 1746 | 1744 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
| 1747 | 1745 | { |
| 1748 | - $this->db->insert($this->dates_table,array( |
|
| 1746 | + $this->db->insert($this->dates_table, array( |
|
| 1749 | 1747 | 'cal_id' => $cal_id, |
| 1750 | 1748 | 'cal_start' => $start, |
| 1751 | 1749 | 'cal_end' => $end, |
| 1752 | - ),false,__LINE__,__FILE__,'calendar'); |
|
| 1750 | + ), false, __LINE__, __FILE__, 'calendar'); |
|
| 1753 | 1751 | |
| 1754 | 1752 | return 1; |
| 1755 | 1753 | } |
| 1756 | - $move_start = (int) ($start-$row['cal_start']); |
|
| 1757 | - $move_end = (int) ($end-$row['cal_end']); |
|
| 1754 | + $move_start = (int)($start - $row['cal_start']); |
|
| 1755 | + $move_end = (int)($end - $row['cal_end']); |
|
| 1758 | 1756 | } |
| 1759 | 1757 | else |
| 1760 | 1758 | { |
| 1761 | - $move_start = (int) ($start-$old_start); |
|
| 1762 | - $move_end = (int) ($end-$old_end); |
|
| 1759 | + $move_start = (int)($start - $old_start); |
|
| 1760 | + $move_end = (int)($end - $old_end); |
|
| 1763 | 1761 | } |
| 1764 | 1762 | $where = 'cal_id='.(int)$cal_id; |
| 1765 | 1763 | |
@@ -1767,13 +1765,13 @@ discard block |
||
| 1767 | 1765 | { |
| 1768 | 1766 | // move the recur-date of the participants |
| 1769 | 1767 | $this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
| 1770 | - ((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__); |
|
| 1768 | + ((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__); |
|
| 1771 | 1769 | } |
| 1772 | 1770 | if ($move_start || $move_end) |
| 1773 | 1771 | { |
| 1774 | 1772 | // move the event and it's recurrences |
| 1775 | 1773 | $this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
| 1776 | - ((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__); |
|
| 1774 | + ((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__); |
|
| 1777 | 1775 | } |
| 1778 | 1776 | return $this->db->affected_rows(); |
| 1779 | 1777 | } |
@@ -1792,8 +1790,7 @@ discard block |
||
| 1792 | 1790 | } |
| 1793 | 1791 | if (is_array($attendee)) |
| 1794 | 1792 | { |
| 1795 | - $email = !empty($attendee['email']) ? $user_attendee['email'] : |
|
| 1796 | - (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
| 1793 | + $email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
| 1797 | 1794 | $attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email; |
| 1798 | 1795 | } |
| 1799 | 1796 | return $attendee; |
@@ -1806,11 +1803,11 @@ discard block |
||
| 1806 | 1803 | * @param string|array $attendee attendee information: email, json or array with attr cn and url |
| 1807 | 1804 | * @return string|int combined id |
| 1808 | 1805 | */ |
| 1809 | - static function combine_user($user_type, $user_id, $attendee=null) |
|
| 1806 | + static function combine_user($user_type, $user_id, $attendee = null) |
|
| 1810 | 1807 | { |
| 1811 | 1808 | if (!$user_type || $user_type == 'u') |
| 1812 | 1809 | { |
| 1813 | - return (int) $user_id; |
|
| 1810 | + return (int)$user_id; |
|
| 1814 | 1811 | } |
| 1815 | 1812 | if ($user_type == 'e' && $attendee) |
| 1816 | 1813 | { |
@@ -1830,12 +1827,12 @@ discard block |
||
| 1830 | 1827 | * @param string|int &$user_id id |
| 1831 | 1828 | * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e" |
| 1832 | 1829 | */ |
| 1833 | - static function split_user($uid, &$user_type, &$user_id, $md5_email=false) |
|
| 1830 | + static function split_user($uid, &$user_type, &$user_id, $md5_email = false) |
|
| 1834 | 1831 | { |
| 1835 | 1832 | if (is_numeric($uid)) |
| 1836 | 1833 | { |
| 1837 | 1834 | $user_type = 'u'; |
| 1838 | - $user_id = (int) $uid; |
|
| 1835 | + $user_id = (int)$uid; |
|
| 1839 | 1836 | } |
| 1840 | 1837 | // create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>") |
| 1841 | 1838 | elseif ($md5_email && $uid[0] == 'e') |
@@ -1849,7 +1846,7 @@ discard block |
||
| 1849 | 1846 | else |
| 1850 | 1847 | { |
| 1851 | 1848 | $user_type = $uid[0]; |
| 1852 | - $user_id = substr($uid,1); |
|
| 1849 | + $user_id = substr($uid, 1); |
|
| 1853 | 1850 | } |
| 1854 | 1851 | } |
| 1855 | 1852 | |
@@ -1861,7 +1858,7 @@ discard block |
||
| 1861 | 1858 | * @param string $role ='REQ-PARTICIPANT' |
| 1862 | 1859 | * @return string |
| 1863 | 1860 | */ |
| 1864 | - static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
|
| 1861 | + static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT') |
|
| 1865 | 1862 | { |
| 1866 | 1863 | if ((int)$quantity > 1) $status .= (int)$quantity; |
| 1867 | 1864 | if ($role != 'REQ-PARTICIPANT') $status .= $role; |
@@ -1877,13 +1874,13 @@ discard block |
||
| 1877 | 1874 | * @param string &$role=null only O: role |
| 1878 | 1875 | * @return string status U, T, A or R, same as $status parameter on return |
| 1879 | 1876 | */ |
| 1880 | - static function split_status(&$status,&$quantity=null,&$role=null) |
|
| 1877 | + static function split_status(&$status, &$quantity = null, &$role = null) |
|
| 1881 | 1878 | { |
| 1882 | 1879 | $quantity = 1; |
| 1883 | 1880 | $role = 'REQ-PARTICIPANT'; |
| 1884 | 1881 | //error_log(__METHOD__.__LINE__.array2string($status)); |
| 1885 | 1882 | $matches = null; |
| 1886 | - if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
|
| 1883 | + if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches)) |
|
| 1887 | 1884 | { |
| 1888 | 1885 | if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
| 1889 | 1886 | if ($matches[2]) $role = $matches[2]; |
@@ -1910,14 +1907,14 @@ discard block |
||
| 1910 | 1907 | * true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants) |
| 1911 | 1908 | * @return int|boolean number of updated recurrences or false on error |
| 1912 | 1909 | */ |
| 1913 | - function participants($cal_id,$participants,$change_since=0,$add_only=false) |
|
| 1910 | + function participants($cal_id, $participants, $change_since = 0, $add_only = false) |
|
| 1914 | 1911 | { |
| 1915 | 1912 | //error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only"); |
| 1916 | 1913 | |
| 1917 | 1914 | $recurrences = array(); |
| 1918 | 1915 | |
| 1919 | 1916 | // remove group-invitations, they are NOT stored in the db |
| 1920 | - foreach($participants as $uid => $status) |
|
| 1917 | + foreach ($participants as $uid => $status) |
|
| 1921 | 1918 | { |
| 1922 | 1919 | if ($status[0] == 'G') |
| 1923 | 1920 | { |
@@ -1926,7 +1923,7 @@ discard block |
||
| 1926 | 1923 | } |
| 1927 | 1924 | $where = array('cal_id' => $cal_id); |
| 1928 | 1925 | |
| 1929 | - if ((int) $change_since) |
|
| 1926 | + if ((int)$change_since) |
|
| 1930 | 1927 | { |
| 1931 | 1928 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')'; |
| 1932 | 1929 | } |
@@ -1934,31 +1931,31 @@ discard block |
||
| 1934 | 1931 | if ($change_since !== false) |
| 1935 | 1932 | { |
| 1936 | 1933 | // find all existing recurrences |
| 1937 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1934 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1938 | 1935 | { |
| 1939 | 1936 | $recurrences[] = $row['cal_recur_date']; |
| 1940 | 1937 | } |
| 1941 | 1938 | |
| 1942 | 1939 | // update existing entries |
| 1943 | - $existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar'); |
|
| 1940 | + $existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar'); |
|
| 1944 | 1941 | |
| 1945 | 1942 | // create a full list of participants which already exist in the db |
| 1946 | 1943 | // with status, quantity and role of the earliest recurence |
| 1947 | 1944 | $old_participants = array(); |
| 1948 | - foreach($existing_entries as $row) |
|
| 1945 | + foreach ($existing_entries as $row) |
|
| 1949 | 1946 | { |
| 1950 | 1947 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1951 | 1948 | if ($row['cal_recur_date'] || !isset($old_participants[$uid])) |
| 1952 | 1949 | { |
| 1953 | - $old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 1950 | + $old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 1954 | 1951 | } |
| 1955 | 1952 | } |
| 1956 | 1953 | |
| 1957 | 1954 | // tag participants which should be deleted |
| 1958 | - if($add_only === false) |
|
| 1955 | + if ($add_only === false) |
|
| 1959 | 1956 | { |
| 1960 | 1957 | $deleted = array(); |
| 1961 | - foreach($existing_entries as $row) |
|
| 1958 | + foreach ($existing_entries as $row) |
|
| 1962 | 1959 | { |
| 1963 | 1960 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1964 | 1961 | // delete not longer set participants |
@@ -1971,7 +1968,7 @@ discard block |
||
| 1971 | 1968 | |
| 1972 | 1969 | // only keep added OR status (incl. quantity!) changed participants for further steps |
| 1973 | 1970 | // we do not touch unchanged (!) existing ones |
| 1974 | - foreach($participants as $uid => $status) |
|
| 1971 | + foreach ($participants as $uid => $status) |
|
| 1975 | 1972 | { |
| 1976 | 1973 | if ($old_participants[$uid] === $status) |
| 1977 | 1974 | { |
@@ -1983,46 +1980,46 @@ discard block |
||
| 1983 | 1980 | if ($add_only === false && count($deleted)) |
| 1984 | 1981 | { |
| 1985 | 1982 | $to_or = array(); |
| 1986 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
| 1987 | - foreach($deleted as $type => $ids) |
|
| 1983 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
| 1984 | + foreach ($deleted as $type => $ids) |
|
| 1988 | 1985 | { |
| 1989 | - $to_or[] = $this->db->expression($table_def,array( |
|
| 1986 | + $to_or[] = $this->db->expression($table_def, array( |
|
| 1990 | 1987 | 'cal_user_type' => $type, |
| 1991 | 1988 | 'cal_user_id' => $ids, |
| 1992 | 1989 | )); |
| 1993 | 1990 | } |
| 1994 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 1995 | - $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
| 1996 | - $this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar'); |
|
| 1991 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 1992 | + $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
| 1993 | + $this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar'); |
|
| 1997 | 1994 | } |
| 1998 | 1995 | } |
| 1999 | 1996 | |
| 2000 | 1997 | if (count($participants)) // participants which need to be added |
| 2001 | 1998 | { |
| 2002 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 1999 | + if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2003 | 2000 | |
| 2004 | 2001 | $delete_deleted = array(); |
| 2005 | 2002 | |
| 2006 | 2003 | // update participants |
| 2007 | - foreach($participants as $uid => $status) |
|
| 2004 | + foreach ($participants as $uid => $status) |
|
| 2008 | 2005 | { |
| 2009 | 2006 | $type = $id = $quantity = $role = null; |
| 2010 | 2007 | self::split_user($uid, $type, $id, true); |
| 2011 | - self::split_status($status,$quantity,$role); |
|
| 2008 | + self::split_status($status, $quantity, $role); |
|
| 2012 | 2009 | $set = array( |
| 2013 | 2010 | 'cal_status' => $status, |
| 2014 | 2011 | 'cal_quantity' => $quantity, |
| 2015 | 2012 | 'cal_role' => $role, |
| 2016 | 2013 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
| 2017 | 2014 | ); |
| 2018 | - foreach($recurrences as $recur_date) |
|
| 2015 | + foreach ($recurrences as $recur_date) |
|
| 2019 | 2016 | { |
| 2020 | - $this->db->insert($this->user_table,$set,array( |
|
| 2017 | + $this->db->insert($this->user_table, $set, array( |
|
| 2021 | 2018 | 'cal_id' => $cal_id, |
| 2022 | 2019 | 'cal_recur_date' => $recur_date, |
| 2023 | 2020 | 'cal_user_type' => $type, |
| 2024 | 2021 | 'cal_user_id' => $id, |
| 2025 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2022 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2026 | 2023 | } |
| 2027 | 2024 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2028 | 2025 | if ($uid < 0) |
@@ -2032,13 +2029,13 @@ discard block |
||
| 2032 | 2029 | } |
| 2033 | 2030 | if ($delete_deleted) |
| 2034 | 2031 | { |
| 2035 | - $this->db->delete($this->user_table, $where=array( |
|
| 2032 | + $this->db->delete($this->user_table, $where = array( |
|
| 2036 | 2033 | 'cal_id' => $cal_id, |
| 2037 | 2034 | 'cal_recur_date' => $recurrences, |
| 2038 | 2035 | 'cal_user_type' => 'u', |
| 2039 | 2036 | 'cal_user_id' => array_unique($delete_deleted), |
| 2040 | 2037 | 'cal_status' => 'X', |
| 2041 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2038 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2042 | 2039 | //error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows'); |
| 2043 | 2040 | } |
| 2044 | 2041 | } |
@@ -2057,7 +2054,7 @@ discard block |
||
| 2057 | 2054 | * @param string $attendee =null extra attendee information to set for all types (incl. accounts!) |
| 2058 | 2055 | * @return int number of changed recurrences |
| 2059 | 2056 | */ |
| 2060 | - function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null) |
|
| 2057 | + function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null) |
|
| 2061 | 2058 | { |
| 2062 | 2059 | static $status_code_short = array( |
| 2063 | 2060 | REJECTED => 'R', |
@@ -2082,7 +2079,7 @@ discard block |
||
| 2082 | 2079 | 'cal_user_type' => $user_type, |
| 2083 | 2080 | 'cal_user_id' => $user_id_md5, |
| 2084 | 2081 | ); |
| 2085 | - if ((int) $recur_date) |
|
| 2082 | + if ((int)$recur_date) |
|
| 2086 | 2083 | { |
| 2087 | 2084 | $where['cal_recur_date'] = $recur_date; |
| 2088 | 2085 | } |
@@ -2093,7 +2090,7 @@ discard block |
||
| 2093 | 2090 | |
| 2094 | 2091 | if ($status == 'G') // remove group invitations, as we dont store them in the db |
| 2095 | 2092 | { |
| 2096 | - $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
|
| 2093 | + $this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar'); |
|
| 2097 | 2094 | $ret = $this->db->affected_rows(); |
| 2098 | 2095 | } |
| 2099 | 2096 | else |
@@ -2101,7 +2098,7 @@ discard block |
||
| 2101 | 2098 | $set = array('cal_status' => $status); |
| 2102 | 2099 | if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
| 2103 | 2100 | if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
| 2104 | - $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
|
| 2101 | + $this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar'); |
|
| 2105 | 2102 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2106 | 2103 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
| 2107 | 2104 | { |
@@ -2114,7 +2111,7 @@ discard block |
||
| 2114 | 2111 | // update modified and modifier in main table |
| 2115 | 2112 | if ($ret) |
| 2116 | 2113 | { |
| 2117 | - $this->updateModified($cal_id, true); // true = update series master too |
|
| 2114 | + $this->updateModified($cal_id, true); // true = update series master too |
|
| 2118 | 2115 | } |
| 2119 | 2116 | //error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret"); |
| 2120 | 2117 | return $ret; |
@@ -2129,7 +2126,7 @@ discard block |
||
| 2129 | 2126 | * @param array $participants uid => status pairs |
| 2130 | 2127 | * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception) |
| 2131 | 2128 | */ |
| 2132 | - function recurrence($cal_id,$start,$end,$participants,$exception=null) |
|
| 2129 | + function recurrence($cal_id, $start, $end, $participants, $exception = null) |
|
| 2133 | 2130 | { |
| 2134 | 2131 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
| 2135 | 2132 | $update = array('cal_end' => $end); |
@@ -2138,7 +2135,7 @@ discard block |
||
| 2138 | 2135 | $this->db->insert($this->dates_table, $update, array( |
| 2139 | 2136 | 'cal_id' => $cal_id, |
| 2140 | 2137 | 'cal_start' => $start, |
| 2141 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2138 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2142 | 2139 | |
| 2143 | 2140 | if (!is_array($participants)) |
| 2144 | 2141 | { |
@@ -2146,26 +2143,26 @@ discard block |
||
| 2146 | 2143 | } |
| 2147 | 2144 | if ($exception !== true) |
| 2148 | 2145 | { |
| 2149 | - foreach($participants as $uid => $status) |
|
| 2146 | + foreach ($participants as $uid => $status) |
|
| 2150 | 2147 | { |
| 2151 | - if ($status == 'G') continue; // dont save group-invitations |
|
| 2148 | + if ($status == 'G') continue; // dont save group-invitations |
|
| 2152 | 2149 | |
| 2153 | 2150 | $type = ''; |
| 2154 | 2151 | $id = null; |
| 2155 | 2152 | self::split_user($uid, $type, $id, true); |
| 2156 | 2153 | $quantity = $role = null; |
| 2157 | - self::split_status($status,$quantity,$role); |
|
| 2158 | - $this->db->insert($this->user_table,array( |
|
| 2154 | + self::split_status($status, $quantity, $role); |
|
| 2155 | + $this->db->insert($this->user_table, array( |
|
| 2159 | 2156 | 'cal_status' => $status, |
| 2160 | 2157 | 'cal_quantity' => $quantity, |
| 2161 | 2158 | 'cal_role' => $role, |
| 2162 | 2159 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
| 2163 | - ),array( |
|
| 2160 | + ), array( |
|
| 2164 | 2161 | 'cal_id' => $cal_id, |
| 2165 | 2162 | 'cal_recur_date' => $start, |
| 2166 | 2163 | 'cal_user_type' => $type, |
| 2167 | 2164 | 'cal_user_id' => $id, |
| 2168 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2165 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2169 | 2166 | } |
| 2170 | 2167 | } |
| 2171 | 2168 | } |
@@ -2179,7 +2176,7 @@ discard block |
||
| 2179 | 2176 | function unfinished_recuring($time) |
| 2180 | 2177 | { |
| 2181 | 2178 | $ids = array(); |
| 2182 | - foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
| 2179 | + foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
| 2183 | 2180 | '(range_end IS NULL OR range_end > '.(int)$time.')', |
| 2184 | 2181 | __LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0, |
| 2185 | 2182 | " JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id". |
@@ -2205,9 +2202,9 @@ discard block |
||
| 2205 | 2202 | // update timestamp of series master, updates own timestamp too, which does not hurt ;-) |
| 2206 | 2203 | $this->updateModified($cal_id, true); |
| 2207 | 2204 | |
| 2208 | - foreach($this->all_tables as $table) |
|
| 2205 | + foreach ($this->all_tables as $table) |
|
| 2209 | 2206 | { |
| 2210 | - $this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar'); |
|
| 2207 | + $this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 2211 | 2208 | } |
| 2212 | 2209 | } |
| 2213 | 2210 | |
@@ -2223,19 +2220,19 @@ discard block |
||
| 2223 | 2220 | function purge($date) |
| 2224 | 2221 | { |
| 2225 | 2222 | // with new range_end we simple delete all with range_end < $date (range_end NULL is never returned) |
| 2226 | - foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2223 | + foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2227 | 2224 | { |
| 2228 | 2225 | //echo __METHOD__." About to delete".$row['cal_id']."\r\n"; |
| 2229 | - foreach($this->all_tables as $table) |
|
| 2226 | + foreach ($this->all_tables as $table) |
|
| 2230 | 2227 | { |
| 2231 | 2228 | $this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar'); |
| 2232 | 2229 | } |
| 2233 | 2230 | // handle sync |
| 2234 | - $this->db->update('egw_api_content_history',array( |
|
| 2231 | + $this->db->update('egw_api_content_history', array( |
|
| 2235 | 2232 | 'sync_deleted' => time(), |
| 2236 | - ),array( |
|
| 2233 | + ), array( |
|
| 2237 | 2234 | 'sync_appname' => 'calendar', |
| 2238 | - 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
| 2235 | + 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
| 2239 | 2236 | ), __LINE__, __FILE__); |
| 2240 | 2237 | // handle links |
| 2241 | 2238 | Link::unlink('', 'calendar', $row['cal_id']); |
@@ -2258,23 +2255,23 @@ discard block |
||
| 2258 | 2255 | * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id |
| 2259 | 2256 | * @return array of (cal_id => array of) alarms with alarm-id as key |
| 2260 | 2257 | */ |
| 2261 | - function read_alarms($cal_id, $update_cache=null) |
|
| 2258 | + function read_alarms($cal_id, $update_cache = null) |
|
| 2262 | 2259 | { |
| 2263 | 2260 | if (!isset(self::$alarm_cache) && is_array($cal_id)) |
| 2264 | 2261 | { |
| 2265 | 2262 | self::$alarm_cache = array(); |
| 2266 | 2263 | if (($jobs = $this->async->read('cal:%'))) |
| 2267 | 2264 | { |
| 2268 | - foreach($jobs as $id => $job) |
|
| 2265 | + foreach ($jobs as $id => $job) |
|
| 2269 | 2266 | { |
| 2270 | - $alarm = $job['data']; // text, enabled |
|
| 2267 | + $alarm = $job['data']; // text, enabled |
|
| 2271 | 2268 | $alarm['id'] = $id; |
| 2272 | 2269 | $alarm['time'] = $job['next']; |
| 2273 | 2270 | |
| 2274 | 2271 | self::$alarm_cache[$alarm['cal_id']][$id] = $alarm; |
| 2275 | 2272 | } |
| 2276 | 2273 | } |
| 2277 | - unset($update_cache); // just done |
|
| 2274 | + unset($update_cache); // just done |
|
| 2278 | 2275 | } |
| 2279 | 2276 | $alarms = array(); |
| 2280 | 2277 | |
@@ -2282,13 +2279,13 @@ discard block |
||
| 2282 | 2279 | { |
| 2283 | 2280 | if (isset($update_cache)) |
| 2284 | 2281 | { |
| 2285 | - foreach((array)$cal_id as $id) |
|
| 2282 | + foreach ((array)$cal_id as $id) |
|
| 2286 | 2283 | { |
| 2287 | 2284 | if ($update_cache === false) |
| 2288 | 2285 | { |
| 2289 | 2286 | unset(self::$alarm_cache[$cal_id]); |
| 2290 | 2287 | } |
| 2291 | - elseif($update_cache === true) |
|
| 2288 | + elseif ($update_cache === true) |
|
| 2292 | 2289 | { |
| 2293 | 2290 | self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id); |
| 2294 | 2291 | } |
@@ -2300,7 +2297,7 @@ discard block |
||
| 2300 | 2297 | } |
| 2301 | 2298 | else |
| 2302 | 2299 | { |
| 2303 | - foreach($cal_id as $id) |
|
| 2300 | + foreach ($cal_id as $id) |
|
| 2304 | 2301 | { |
| 2305 | 2302 | $alarms[$id] = (array)self::$alarm_cache[$id]; |
| 2306 | 2303 | } |
@@ -2315,9 +2312,9 @@ discard block |
||
| 2315 | 2312 | { |
| 2316 | 2313 | if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%'))) |
| 2317 | 2314 | { |
| 2318 | - foreach($jobs as $id => $job) |
|
| 2315 | + foreach ($jobs as $id => $job) |
|
| 2319 | 2316 | { |
| 2320 | - $alarm = $job['data']; // text, enabled |
|
| 2317 | + $alarm = $job['data']; // text, enabled |
|
| 2321 | 2318 | $alarm['id'] = $id; |
| 2322 | 2319 | $alarm['time'] = $job['next']; |
| 2323 | 2320 | |
@@ -2340,8 +2337,8 @@ discard block |
||
| 2340 | 2337 | { |
| 2341 | 2338 | return False; |
| 2342 | 2339 | } |
| 2343 | - list($alarm_id,$job) = each($jobs); |
|
| 2344 | - $alarm = $job['data']; // text, enabled |
|
| 2340 | + list($alarm_id, $job) = each($jobs); |
|
| 2341 | + $alarm = $job['data']; // text, enabled |
|
| 2345 | 2342 | $alarm['id'] = $alarm_id; |
| 2346 | 2343 | $alarm['time'] = $job['next']; |
| 2347 | 2344 | |
@@ -2357,12 +2354,12 @@ discard block |
||
| 2357 | 2354 | * @param boolean $update_modified =true call update modified, default true |
| 2358 | 2355 | * @return string id of the alarm |
| 2359 | 2356 | */ |
| 2360 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 2357 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 2361 | 2358 | { |
| 2362 | 2359 | //error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace()); |
| 2363 | 2360 | if (!($id = $alarm['id'])) |
| 2364 | 2361 | { |
| 2365 | - $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
| 2362 | + $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
| 2366 | 2363 | $n = count($alarms); |
| 2367 | 2364 | do |
| 2368 | 2365 | { |
@@ -2375,12 +2372,12 @@ discard block |
||
| 2375 | 2372 | { |
| 2376 | 2373 | $this->async->cancel_timer($id); |
| 2377 | 2374 | } |
| 2378 | - $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
| 2375 | + $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
| 2379 | 2376 | // add an alarm uid, if none is given |
| 2380 | 2377 | if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
| 2381 | 2378 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
| 2382 | 2379 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
| 2383 | - if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner'])) |
|
| 2380 | + if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner'])) |
|
| 2384 | 2381 | { |
| 2385 | 2382 | return False; |
| 2386 | 2383 | } |
@@ -2407,7 +2404,7 @@ discard block |
||
| 2407 | 2404 | //error_log(__METHOD__."($cal_id) ".function_backtrace()); |
| 2408 | 2405 | if (($alarms = $this->read_alarms($cal_id))) |
| 2409 | 2406 | { |
| 2410 | - foreach(array_keys($alarms) as $id) |
|
| 2407 | + foreach (array_keys($alarms) as $id) |
|
| 2411 | 2408 | { |
| 2412 | 2409 | $this->async->cancel_timer($id); |
| 2413 | 2410 | } |
@@ -2427,7 +2424,7 @@ discard block |
||
| 2427 | 2424 | { |
| 2428 | 2425 | //error_log(__METHOD__."('$id') ".function_backtrace()); |
| 2429 | 2426 | // update the modification information of the related event |
| 2430 | - list(,$cal_id) = explode(':',$id); |
|
| 2427 | + list(,$cal_id) = explode(':', $id); |
|
| 2431 | 2428 | if ($cal_id) |
| 2432 | 2429 | { |
| 2433 | 2430 | $this->updateModified($cal_id, true); |
@@ -2446,7 +2443,7 @@ discard block |
||
| 2446 | 2443 | * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it |
| 2447 | 2444 | * @param int $new_user =null |
| 2448 | 2445 | */ |
| 2449 | - function deleteaccount($old_user, $new_user=null) |
|
| 2446 | + function deleteaccount($old_user, $new_user = null) |
|
| 2450 | 2447 | { |
| 2451 | 2448 | if (is_array($old_user)) |
| 2452 | 2449 | { |
@@ -2457,52 +2454,52 @@ discard block |
||
| 2457 | 2454 | { |
| 2458 | 2455 | $user_type = ''; |
| 2459 | 2456 | $user_id = null; |
| 2460 | - self::split_user($old_user,$user_type,$user_id); |
|
| 2457 | + self::split_user($old_user, $user_type, $user_id); |
|
| 2461 | 2458 | |
| 2462 | 2459 | if ($user_type == 'u') // only accounts can be owners of events |
| 2463 | 2460 | { |
| 2464 | - foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2461 | + foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2465 | 2462 | { |
| 2466 | 2463 | $this->delete($row['cal_id']); |
| 2467 | 2464 | } |
| 2468 | 2465 | } |
| 2469 | - $this->db->delete($this->user_table,array( |
|
| 2466 | + $this->db->delete($this->user_table, array( |
|
| 2470 | 2467 | 'cal_user_type' => $user_type, |
| 2471 | 2468 | 'cal_user_id' => $user_id, |
| 2472 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2469 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2473 | 2470 | |
| 2474 | 2471 | // delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner) |
| 2475 | - foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2476 | - False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
| 2472 | + foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__, |
|
| 2473 | + False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
| 2477 | 2474 | { |
| 2478 | 2475 | $this->delete($row['cal_id']); |
| 2479 | 2476 | } |
| 2480 | 2477 | } |
| 2481 | 2478 | else |
| 2482 | 2479 | { |
| 2483 | - $this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar'); |
|
| 2480 | + $this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar'); |
|
| 2484 | 2481 | // delete participation of old user, if new user is already a participant |
| 2485 | 2482 | $ids = array(); |
| 2486 | - foreach($this->db->select($this->user_table,'cal_id',array( // MySQL does NOT allow to run this as delete! |
|
| 2483 | + foreach ($this->db->select($this->user_table, 'cal_id', array( // MySQL does NOT allow to run this as delete! |
|
| 2487 | 2484 | 'cal_user_type' => 'u', |
| 2488 | 2485 | 'cal_user_id' => $old_user, |
| 2489 | 2486 | "cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')", |
| 2490 | - ),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2487 | + ), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2491 | 2488 | { |
| 2492 | 2489 | $ids[] = $row['cal_id']; |
| 2493 | 2490 | } |
| 2494 | - if ($ids) $this->db->delete($this->user_table,array( |
|
| 2491 | + if ($ids) $this->db->delete($this->user_table, array( |
|
| 2495 | 2492 | 'cal_user_type' => 'u', |
| 2496 | 2493 | 'cal_user_id' => $old_user, |
| 2497 | 2494 | 'cal_id' => $ids, |
| 2498 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2495 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2499 | 2496 | // now change participant in the rest to contain new user instead of old user |
| 2500 | - $this->db->update($this->user_table,array( |
|
| 2497 | + $this->db->update($this->user_table, array( |
|
| 2501 | 2498 | 'cal_user_id' => $new_user, |
| 2502 | - ),array( |
|
| 2499 | + ), array( |
|
| 2503 | 2500 | 'cal_user_type' => 'u', |
| 2504 | 2501 | 'cal_user_id' => $old_user, |
| 2505 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2502 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2506 | 2503 | } |
| 2507 | 2504 | } |
| 2508 | 2505 | |
@@ -2516,18 +2513,18 @@ discard block |
||
| 2516 | 2513 | * |
| 2517 | 2514 | * @return array recur_date => status pairs (index 0 => main status) |
| 2518 | 2515 | */ |
| 2519 | - function get_recurrences($cal_id, $uid=null, $start=0, $end=0) |
|
| 2516 | + function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0) |
|
| 2520 | 2517 | { |
| 2521 | 2518 | $participant_status = array(); |
| 2522 | 2519 | $where = array('cal_id' => $cal_id); |
| 2523 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2524 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2520 | + if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
| 2521 | + if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
| 2525 | 2522 | if ($start != 0 && $end != 0) |
| 2526 | 2523 | { |
| 2527 | - $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
| 2528 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
| 2524 | + $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
| 2525 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
| 2529 | 2526 | } |
| 2530 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2527 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2531 | 2528 | { |
| 2532 | 2529 | // inititalize the array |
| 2533 | 2530 | $participant_status[$row['cal_recur_date']] = null; |
@@ -2541,17 +2538,17 @@ discard block |
||
| 2541 | 2538 | 'cal_user_type' => $user_type ? $user_type : 'u', |
| 2542 | 2539 | 'cal_user_id' => $user_id, |
| 2543 | 2540 | ); |
| 2544 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2545 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2541 | + if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
| 2542 | + if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
| 2546 | 2543 | if ($start != 0 && $end != 0) |
| 2547 | 2544 | { |
| 2548 | - $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
| 2549 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
| 2545 | + $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
| 2546 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
| 2550 | 2547 | } |
| 2551 | - foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2, |
|
| 2552 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2548 | + foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2, |
|
| 2549 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2553 | 2550 | { |
| 2554 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 2551 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 2555 | 2552 | $participant_status[$row['cal_recur_date']] = $status; |
| 2556 | 2553 | } |
| 2557 | 2554 | return $participant_status; |
@@ -2600,8 +2597,8 @@ discard block |
||
| 2600 | 2597 | 'cal_uid' => $uid, |
| 2601 | 2598 | ); |
| 2602 | 2599 | $related = array(); |
| 2603 | - foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where, |
|
| 2604 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2600 | + foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where, |
|
| 2601 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2605 | 2602 | { |
| 2606 | 2603 | if ($row['cal_reference'] != 0) |
| 2607 | 2604 | { |
@@ -2630,10 +2627,10 @@ discard block |
||
| 2630 | 2627 | * |
| 2631 | 2628 | * @return array Array of exception days (false for non-recurring events). |
| 2632 | 2629 | */ |
| 2633 | - function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
|
| 2630 | + function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all') |
|
| 2634 | 2631 | { |
| 2635 | 2632 | if (!is_array($event)) return false; |
| 2636 | - $cal_id = (int) $event['id']; |
|
| 2633 | + $cal_id = (int)$event['id']; |
|
| 2637 | 2634 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2638 | 2635 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
| 2639 | 2636 | if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
@@ -2657,27 +2654,27 @@ discard block |
||
| 2657 | 2654 | while ($egw_rrule->valid()) |
| 2658 | 2655 | { |
| 2659 | 2656 | while ($egw_rrule->exceptions && |
| 2660 | - in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions)) |
|
| 2657 | + in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions)) |
|
| 2661 | 2658 | { |
| 2662 | - if (in_array($filter, array('map','tz_map','rrule','tz_rrule'))) |
|
| 2659 | + if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule'))) |
|
| 2663 | 2660 | { |
| 2664 | 2661 | // real exception |
| 2665 | - $locts = (int)Api\DateTime::to($egw_rrule->current(),'server'); |
|
| 2662 | + $locts = (int)Api\DateTime::to($egw_rrule->current(), 'server'); |
|
| 2666 | 2663 | if ($expand_all) |
| 2667 | 2664 | { |
| 2668 | - $remts = (int)Api\DateTime::to($remote_rrule->current(),'server'); |
|
| 2665 | + $remts = (int)Api\DateTime::to($remote_rrule->current(), 'server'); |
|
| 2669 | 2666 | if ($remote) |
| 2670 | 2667 | { |
| 2671 | - $days[$locts]= $remts; |
|
| 2668 | + $days[$locts] = $remts; |
|
| 2672 | 2669 | } |
| 2673 | 2670 | else |
| 2674 | 2671 | { |
| 2675 | - $days[$remts]= $locts; |
|
| 2672 | + $days[$remts] = $locts; |
|
| 2676 | 2673 | } |
| 2677 | 2674 | } |
| 2678 | 2675 | else |
| 2679 | 2676 | { |
| 2680 | - $days[$locts]= $locts; |
|
| 2677 | + $days[$locts] = $locts; |
|
| 2681 | 2678 | } |
| 2682 | 2679 | } |
| 2683 | 2680 | if ($expand_all) |
@@ -2688,14 +2685,14 @@ discard block |
||
| 2688 | 2685 | if (!$egw_rrule->valid()) return $days; |
| 2689 | 2686 | } |
| 2690 | 2687 | $day = $egw_rrule->current(); |
| 2691 | - $locts = (int)Api\DateTime::to($day,'server'); |
|
| 2688 | + $locts = (int)Api\DateTime::to($day, 'server'); |
|
| 2692 | 2689 | $tz_exception = ($filter == 'tz_rrule'); |
| 2693 | 2690 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2694 | 2691 | // '()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)"); |
| 2695 | 2692 | if ($expand_all) |
| 2696 | 2693 | { |
| 2697 | 2694 | $remote_day = $remote_rrule->current(); |
| 2698 | - $remts = (int)Api\DateTime::to($remote_day,'server'); |
|
| 2695 | + $remts = (int)Api\DateTime::to($remote_day, 'server'); |
|
| 2699 | 2696 | // error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2700 | 2697 | // '()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)"); |
| 2701 | 2698 | } |
@@ -2714,11 +2711,11 @@ discard block |
||
| 2714 | 2711 | // '() tz exception: ' . $day->format('Ymd\THis')); |
| 2715 | 2712 | if ($remote) |
| 2716 | 2713 | { |
| 2717 | - $days[$locts]= $remts; |
|
| 2714 | + $days[$locts] = $remts; |
|
| 2718 | 2715 | } |
| 2719 | 2716 | else |
| 2720 | 2717 | { |
| 2721 | - $days[$remts]= $locts; |
|
| 2718 | + $days[$remts] = $locts; |
|
| 2722 | 2719 | } |
| 2723 | 2720 | } |
| 2724 | 2721 | } |
@@ -2740,18 +2737,18 @@ discard block |
||
| 2740 | 2737 | { |
| 2741 | 2738 | if ($remote) |
| 2742 | 2739 | { |
| 2743 | - $days[$locts]= $remts; |
|
| 2740 | + $days[$locts] = $remts; |
|
| 2744 | 2741 | } |
| 2745 | 2742 | else |
| 2746 | 2743 | { |
| 2747 | - $days[$remts]= $locts; |
|
| 2744 | + $days[$remts] = $locts; |
|
| 2748 | 2745 | } |
| 2749 | 2746 | } |
| 2750 | 2747 | } |
| 2751 | 2748 | } |
| 2752 | 2749 | elseif ($filter != 'map') |
| 2753 | 2750 | { |
| 2754 | - $days[$locts]= $locts; |
|
| 2751 | + $days[$locts] = $locts; |
|
| 2755 | 2752 | } |
| 2756 | 2753 | } |
| 2757 | 2754 | elseif (($filter == 'map' || filter == 'tz_map') && |
@@ -2761,11 +2758,11 @@ discard block |
||
| 2761 | 2758 | if ($expand_all) |
| 2762 | 2759 | { |
| 2763 | 2760 | |
| 2764 | - $days[$remts]= $locts; |
|
| 2761 | + $days[$remts] = $locts; |
|
| 2765 | 2762 | } |
| 2766 | 2763 | else |
| 2767 | 2764 | { |
| 2768 | - $days[$locts]= $locts; |
|
| 2765 | + $days[$locts] = $locts; |
|
| 2769 | 2766 | } |
| 2770 | 2767 | } |
| 2771 | 2768 | } |
@@ -2789,9 +2786,9 @@ discard block |
||
| 2789 | 2786 | */ |
| 2790 | 2787 | function status_pseudo_exception($cal_id, $recur_date, $filter) |
| 2791 | 2788 | { |
| 2792 | - static $recurrence_zero=null; |
|
| 2793 | - static $cached_id=null; |
|
| 2794 | - static $user=null; |
|
| 2789 | + static $recurrence_zero = null; |
|
| 2790 | + static $cached_id = null; |
|
| 2791 | + static $user = null; |
|
| 2795 | 2792 | |
| 2796 | 2793 | if (!isset($cached_id) || $cached_id != $cal_id) |
| 2797 | 2794 | { |
@@ -2802,8 +2799,8 @@ discard block |
||
| 2802 | 2799 | 'cal_id' => $cal_id, |
| 2803 | 2800 | 'cal_recur_date' => 0, |
| 2804 | 2801 | ); |
| 2805 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
| 2806 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2802 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
| 2803 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2807 | 2804 | { |
| 2808 | 2805 | switch ($row['cal_user_type']) |
| 2809 | 2806 | { |
@@ -2826,8 +2823,8 @@ discard block |
||
| 2826 | 2823 | 'cal_id' => $cal_id, |
| 2827 | 2824 | 'cal_recur_date' => $recur_date, |
| 2828 | 2825 | ); |
| 2829 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
| 2830 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2826 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
| 2827 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2831 | 2828 | { |
| 2832 | 2829 | switch ($row['cal_user_type']) |
| 2833 | 2830 | { |
@@ -2924,14 +2921,14 @@ discard block |
||
| 2924 | 2921 | } |
| 2925 | 2922 | $timezone = self::$tz_cache[$event['tzid']]; |
| 2926 | 2923 | } |
| 2927 | - $start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone); |
|
| 2924 | + $start_time = new Api\DateTime($event['start'], Api\DateTime::$server_timezone); |
|
| 2928 | 2925 | $start_time->setTimezone($timezone); |
| 2929 | - $end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone); |
|
| 2926 | + $end_time = new Api\DateTime($event['end'], Api\DateTime::$server_timezone); |
|
| 2930 | 2927 | $end_time->setTimezone($timezone); |
| 2931 | 2928 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2932 | 2929 | // '(): ' . $start . '-' . $end); |
| 2933 | - $start = Api\DateTime::to($start_time,'array'); |
|
| 2934 | - $end = Api\DateTime::to($end_time,'array'); |
|
| 2930 | + $start = Api\DateTime::to($start_time, 'array'); |
|
| 2931 | + $end = Api\DateTime::to($end_time, 'array'); |
|
| 2935 | 2932 | |
| 2936 | 2933 | |
| 2937 | 2934 | return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59; |
@@ -2945,7 +2942,7 @@ discard block |
||
| 2945 | 2942 | * |
| 2946 | 2943 | * @return DateTime |
| 2947 | 2944 | */ |
| 2948 | - function &startOfDay(Api\DateTime $time, $tz_id=null) |
|
| 2945 | + function &startOfDay(Api\DateTime $time, $tz_id = null) |
|
| 2949 | 2946 | { |
| 2950 | 2947 | if (empty($tz_id)) |
| 2951 | 2948 | { |
@@ -2970,14 +2967,14 @@ discard block |
||
| 2970 | 2967 | * @param int $time =null new timestamp, default current (server-)time |
| 2971 | 2968 | * @param int $modifier =null uid of the modifier, default current user |
| 2972 | 2969 | */ |
| 2973 | - function updateModified($id, $update_master=false, $time=null, $modifier=null) |
|
| 2970 | + function updateModified($id, $update_master = false, $time = null, $modifier = null) |
|
| 2974 | 2971 | { |
| 2975 | 2972 | if (is_null($time) || !$time) $time = time(); |
| 2976 | 2973 | if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
| 2977 | 2974 | |
| 2978 | 2975 | $this->db->update($this->cal_table, |
| 2979 | 2976 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |
| 2980 | - array('cal_id' => $id), __LINE__,__FILE__, 'calendar'); |
|
| 2977 | + array('cal_id' => $id), __LINE__, __FILE__, 'calendar'); |
|
| 2981 | 2978 | |
| 2982 | 2979 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
| 2983 | 2980 | if ($update_master) |
@@ -204,6 +204,7 @@ |
||
| 204 | 204 | * |
| 205 | 205 | * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date |
| 206 | 206 | * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT |
| 207 | + * @param boolean $updated |
|
| 207 | 208 | * @return string message about update |
| 208 | 209 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
| 209 | 210 | * @throws Api\Exception\WrongUserinput if no PDO sqlite support |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public static function DateTimeZone($tzid) |
| 73 | 73 | { |
| 74 | - if (($id = self::tz2id($tzid,'alias'))) |
|
| 74 | + if (($id = self::tz2id($tzid, 'alias'))) |
|
| 75 | 75 | { |
| 76 | 76 | $tzid = self::id2tz($id); |
| 77 | 77 | } |
@@ -89,34 +89,34 @@ discard block |
||
| 89 | 89 | * @param string $what ='id' what to return, default id, null for whole array |
| 90 | 90 | * @return int tz_id or null if not found |
| 91 | 91 | */ |
| 92 | - public static function tz2id($tzid,$what='id') |
|
| 92 | + public static function tz2id($tzid, $what = 'id') |
|
| 93 | 93 | { |
| 94 | - $id =& self::$tz2id[$tzid]; |
|
| 94 | + $id = & self::$tz2id[$tzid]; |
|
| 95 | 95 | |
| 96 | 96 | if (!isset($id)) |
| 97 | 97 | { |
| 98 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 98 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 99 | 99 | 'tz_tzid' => $tzid, |
| 100 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 100 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 101 | 101 | { |
| 102 | 102 | $id = $data['tz_id']; |
| 103 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
| 103 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | // check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires' |
| 107 | 107 | if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2) |
| 108 | 108 | { |
| 109 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 109 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 110 | 110 | 'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]), |
| 111 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 111 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 112 | 112 | { |
| 113 | 113 | $id = $data['tz_id']; |
| 114 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
| 114 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | if (isset($id) && $what != 'id') |
| 118 | 118 | { |
| 119 | - return self::id2tz($id,$what); |
|
| 119 | + return self::id2tz($id, $what); |
|
| 120 | 120 | } |
| 121 | 121 | return $id; |
| 122 | 122 | } |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude' |
| 135 | 135 | * @return mixed false: if not found |
| 136 | 136 | */ |
| 137 | - public static function id2tz($id,$what='tzid') |
|
| 137 | + public static function id2tz($id, $what = 'tzid') |
|
| 138 | 138 | { |
| 139 | - $data =& self::$tz_cache[$id]; |
|
| 139 | + $data = & self::$tz_cache[$id]; |
|
| 140 | 140 | |
| 141 | 141 | if (!isset($data)) |
| 142 | 142 | { |
| 143 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 143 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 144 | 144 | 'tz_id' => $id, |
| 145 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 145 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 146 | 146 | { |
| 147 | - $data = Api\Db::strip_array_keys($data,'tz_'); |
|
| 147 | + $data = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 148 | 148 | self::$tz2id[$data['tzid']] = $id; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | // if not tzid queried, resolve aliases automatically |
| 152 | 152 | if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') |
| 153 | 153 | { |
| 154 | - $data = self::id2tz($data['alias'],null); |
|
| 154 | + $data = self::id2tz($data['alias'], null); |
|
| 155 | 155 | } |
| 156 | 156 | return !$data ? $data : ($what ? $data[$what] : $data); |
| 157 | 157 | } |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public static function init_static() |
| 172 | 172 | { |
| 173 | - self::$tz_cache =& Api\Cache::getSession(__CLASS__,'tz_cache'); |
|
| 174 | - self::$tz2id =& Api\Cache::getSession(__CLASS__,'tz2id'); |
|
| 173 | + self::$tz_cache = & Api\Cache::getSession(__CLASS__, 'tz_cache'); |
|
| 174 | + self::$tz2id = & Api\Cache::getSession(__CLASS__, 'tz2id'); |
|
| 175 | 175 | |
| 176 | 176 | // init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar |
| 177 | 177 | if (!is_array(self::$tz2id)) |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $updated = false; |
| 190 | 190 | $msg = self::import_zones($updated); |
| 191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
| 191 | + if ($updated) error_log($msg); // log that timezones have been updated |
|
| 192 | 192 | |
| 193 | 193 | $alias_msg = self::import_tz_aliases($updated); |
| 194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 194 | + if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 195 | 195 | |
| 196 | 196 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
| 197 | 197 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @throws Api\Exception\WrongUserinput for broken sqlite extension |
| 211 | 211 | * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json |
| 212 | 212 | */ |
| 213 | - public static function import_zones(&$updated=null, $file='calendar/setup/zones.json') |
|
| 213 | + public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json') |
|
| 214 | 214 | { |
| 215 | 215 | $path = EGW_SERVER_ROOT.'/'.$file; |
| 216 | 216 | |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | { |
| 233 | 233 | $updated = false; |
| 234 | 234 | fclose($fp); |
| 235 | - return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right |
|
| 235 | + return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right |
|
| 236 | 236 | } |
| 237 | - $json .= fread($fp, 1024*1024); |
|
| 237 | + $json .= fread($fp, 1024 * 1024); |
|
| 238 | 238 | fclose($fp); |
| 239 | 239 | if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones'])) |
| 240 | 240 | { |
@@ -242,38 +242,38 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | // import zones first and then aliases |
| 244 | 244 | $tz2id = array(); |
| 245 | - foreach(array('zones', 'aliases') as $type) |
|
| 245 | + foreach (array('zones', 'aliases') as $type) |
|
| 246 | 246 | { |
| 247 | - foreach($zones[$type] as $tzid => $data) |
|
| 247 | + foreach ($zones[$type] as $tzid => $data) |
|
| 248 | 248 | { |
| 249 | 249 | if ($type == 'aliases') |
| 250 | 250 | { |
| 251 | 251 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
| 252 | - if (!$data['alias']) continue; // there's no such tzid |
|
| 252 | + if (!$data['alias']) continue; // there's no such tzid |
|
| 253 | 253 | } |
| 254 | 254 | // check if already in database |
| 255 | - $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
|
| 255 | + $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array( |
|
| 256 | 256 | 'tz_tzid' => $tzid, |
| 257 | - ),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 257 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 258 | 258 | |
| 259 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
| 259 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
| 260 | 260 | 'tz_alias' => $data['alias'], |
| 261 | 261 | 'tz_latitude' => $data['latitude'], |
| 262 | 262 | 'tz_longitude' => $data['longitude'], |
| 263 | 263 | 'tz_component' => $data['ics'], |
| 264 | - ),array( |
|
| 264 | + ), array( |
|
| 265 | 265 | 'tz_tzid' => $tzid, |
| 266 | - ),__LINE__,__FILE__,'calendar'); |
|
| 266 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 267 | 267 | |
| 268 | 268 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
| 269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 269 | + if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id'); |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
| 273 | 273 | |
| 274 | 274 | //_debug_array($tz2id); |
| 275 | 275 | $updated = true; |
| 276 | - return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id)); |
|
| 276 | + return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id)); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @return string message about update |
| 285 | 285 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
| 286 | 286 | */ |
| 287 | - public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php') |
|
| 287 | + public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php') |
|
| 288 | 288 | { |
| 289 | 289 | $path = EGW_SERVER_ROOT.'/'.$file; |
| 290 | 290 | |
@@ -297,27 +297,27 @@ discard block |
||
| 297 | 297 | if ($tz_aliases_mtime === $config['tz_aliases_mtime']) |
| 298 | 298 | { |
| 299 | 299 | $updated = false; |
| 300 | - return lang('Nothing to update, version is already %1.',$tz_aliases_mtime); |
|
| 300 | + return lang('Nothing to update, version is already %1.', $tz_aliases_mtime); |
|
| 301 | 301 | } |
| 302 | 302 | $tz_aliases = array(); |
| 303 | - include($path); // sets $tz_aliases |
|
| 303 | + include($path); // sets $tz_aliases |
|
| 304 | 304 | |
| 305 | 305 | $updates = 0; |
| 306 | - foreach($tz_aliases as $alias => $tzid) |
|
| 306 | + foreach ($tz_aliases as $alias => $tzid) |
|
| 307 | 307 | { |
| 308 | - if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
| 308 | + if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
| 309 | 309 | ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
| 310 | 310 | { |
| 311 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
| 311 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
| 312 | 312 | 'tz_alias' => $tz_id, |
| 313 | - ),array( |
|
| 313 | + ), array( |
|
| 314 | 314 | 'tz_tzid' => $alias, |
| 315 | - ),__LINE__,__FILE__,'calendar'); |
|
| 315 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 316 | 316 | ++$updates; |
| 317 | 317 | } |
| 318 | 318 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
| 319 | 319 | } |
| 320 | - Api\Config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi'); |
|
| 320 | + Api\Config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi'); |
|
| 321 | 321 | |
| 322 | 322 | //_debug_array($tz2id); |
| 323 | 323 | $updated = true; |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | // $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly |
| 360 | 360 | // --> we have to parse it and let Horde_Icalendar add it again |
| 361 | - $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false); |
|
| 362 | - $horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE'); |
|
| 361 | + $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false); |
|
| 362 | + $horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE'); |
|
| 363 | 363 | // DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing |
| 364 | 364 | $standard = $horde_vtimezone->findComponent('STANDARD'); |
| 365 | 365 | if (is_a($standard, 'Horde_Icalendar')) |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component |
| 391 | 391 | * @return string |
| 392 | 392 | */ |
| 393 | - public static function user_timezone($user=null, $type='vcalendar') |
|
| 393 | + public static function user_timezone($user = null, $type = 'vcalendar') |
|
| 394 | 394 | { |
| 395 | 395 | if (!$user || $user == $GLOBALS['egw_info']['user']['account_id']) |
| 396 | 396 | { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | case 'vcalendar': |
| 410 | 410 | // checking type of $val, now we included the object definition (no need to always include it!) |
| 411 | 411 | $vcal = new Horde_Icalendar; |
| 412 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 412 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 413 | 413 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 414 | 414 | self::add_vtimezone($vcal, $tzid); |
| 415 | 415 | $tzid = $vcal->exportvCalendar('utf-8'); |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | case 'tzid': |
| 418 | 418 | break; |
| 419 | 419 | default: |
| 420 | - $tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type); |
|
| 420 | + $tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type); |
|
| 421 | 421 | break; |
| 422 | 422 | } |
| 423 | 423 | return $tzid; |
@@ -188,10 +188,18 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $updated = false; |
| 190 | 190 | $msg = self::import_zones($updated); |
| 191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
| 191 | + if ($updated) |
|
| 192 | + { |
|
| 193 | + error_log($msg); |
|
| 194 | + } |
|
| 195 | + // log that timezones have been updated |
|
| 192 | 196 | |
| 193 | 197 | $alias_msg = self::import_tz_aliases($updated); |
| 194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 198 | + if ($updated) |
|
| 199 | + { |
|
| 200 | + error_log($alias_msg); |
|
| 201 | + } |
|
| 202 | + // log that timezone aliases have been updated |
|
| 195 | 203 | |
| 196 | 204 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
| 197 | 205 | |
@@ -249,7 +257,11 @@ discard block |
||
| 249 | 257 | if ($type == 'aliases') |
| 250 | 258 | { |
| 251 | 259 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
| 252 | - if (!$data['alias']) continue; // there's no such tzid |
|
| 260 | + if (!$data['alias']) |
|
| 261 | + { |
|
| 262 | + continue; |
|
| 263 | + } |
|
| 264 | + // there's no such tzid |
|
| 253 | 265 | } |
| 254 | 266 | // check if already in database |
| 255 | 267 | $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
@@ -266,7 +278,10 @@ discard block |
||
| 266 | 278 | ),__LINE__,__FILE__,'calendar'); |
| 267 | 279 | |
| 268 | 280 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
| 269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 281 | + if (!$tz2id[$tzid]) |
|
| 282 | + { |
|
| 283 | + $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | } |
| 272 | 287 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
@@ -306,13 +321,16 @@ discard block |
||
| 306 | 321 | foreach($tz_aliases as $alias => $tzid) |
| 307 | 322 | { |
| 308 | 323 | if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
| 309 | - ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
|
| 324 | + ($tz_id = self::tz2id($tzid))) |
|
| 325 | + { |
|
| 326 | + // given tzid for alias exists in DB |
|
| 310 | 327 | { |
| 311 | 328 | $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
| 312 | 329 | 'tz_alias' => $tz_id, |
| 313 | 330 | ),array( |
| 314 | 331 | 'tz_tzid' => $alias, |
| 315 | 332 | ),__LINE__,__FILE__,'calendar'); |
| 333 | + } |
|
| 316 | 334 | ++$updates; |
| 317 | 335 | } |
| 318 | 336 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
@@ -402,7 +420,10 @@ discard block |
||
| 402 | 420 | $prefs = $prefs_obj->read(); |
| 403 | 421 | $tzid = $prefs['common']['tz']; |
| 404 | 422 | } |
| 405 | - if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName(); |
|
| 423 | + if (!$tzid) |
|
| 424 | + { |
|
| 425 | + $tzid = Api\DateTime::$server_timezone->getName(); |
|
| 426 | + } |
|
| 406 | 427 | |
| 407 | 428 | switch ($type) |
| 408 | 429 | { |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | * date instead of today |
| 1078 | 1078 | * @param boolean $no_notifications Toggle notifications to participants |
| 1079 | 1079 | * |
| 1080 | - * @return false or error message |
|
| 1080 | + * @return string|false or error message |
|
| 1081 | 1081 | */ |
| 1082 | 1082 | function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true) |
| 1083 | 1083 | { |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | * Freetime search |
| 2174 | 2174 | * |
| 2175 | 2175 | * As the function is called in a popup via javascript, parametes get initialy transfered via the url |
| 2176 | - * @param array $content=null array with parameters or false (default) to use the get-params |
|
| 2176 | + * @param array $content array with parameters or false (default) to use the get-params |
|
| 2177 | 2177 | * @param string start[str] start-date |
| 2178 | 2178 | * @param string start[hour] start-hour |
| 2179 | 2179 | * @param string start[min] start-minutes |
@@ -2417,7 +2417,7 @@ discard block |
||
| 2417 | 2417 | /** |
| 2418 | 2418 | * Export events as vCalendar version 2.0 files (iCal) |
| 2419 | 2419 | * |
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2420 | + * @param integer $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | 2421 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2422 | 2422 | * @return string error-msg if $return_error |
| 2423 | 2423 | */ |
@@ -2415,14 +2415,14 @@ discard block |
||
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | /** |
| 2418 | - * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | - * |
|
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | - * @return string error-msg if $return_error |
|
| 2423 | - */ |
|
| 2424 | - function export($content=0,$return_error=false) |
|
| 2425 | - { |
|
| 2418 | + * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | + * |
|
| 2420 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | + * @return string error-msg if $return_error |
|
| 2423 | + */ |
|
| 2424 | + function export($content=0,$return_error=false) |
|
| 2425 | + { |
|
| 2426 | 2426 | $boical = new calendar_ical(); |
| 2427 | 2427 | #error_log(__METHOD__.print_r($content,true)); |
| 2428 | 2428 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
| 2477 | 2477 | $etpl = new etemplate_new('calendar.export'); |
| 2478 | 2478 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
| 2479 | - } |
|
| 2479 | + } |
|
| 2480 | 2480 | |
| 2481 | 2481 | /** |
| 2482 | 2482 | * Edit category ACL (admin only) |
@@ -2548,8 +2548,8 @@ discard block |
||
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
| 2551 | - * Set up the required fields to get the history tab |
|
| 2552 | - */ |
|
| 2551 | + * Set up the required fields to get the history tab |
|
| 2552 | + */ |
|
| 2553 | 2553 | public function setup_history(&$content, &$sel_options) |
| 2554 | 2554 | { |
| 2555 | 2555 | $status = 'history_status'; |
@@ -557,214 +557,214 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | switch((string)$button) |
| 559 | 559 | { |
| 560 | - case 'exception': // create an exception in a recuring event |
|
| 561 | - $msg = $this->_create_exception($event,$preserv); |
|
| 562 | - break; |
|
| 560 | + case 'exception': // create an exception in a recuring event |
|
| 561 | + $msg = $this->_create_exception($event,$preserv); |
|
| 562 | + break; |
|
| 563 | 563 | |
| 564 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 565 | - unset($event['id']); |
|
| 566 | - unset($event['uid']); |
|
| 567 | - unset($event['reference']); |
|
| 568 | - unset($preserv['reference']); |
|
| 569 | - unset($event['recurrence']); |
|
| 570 | - unset($preserv['recurrence']); |
|
| 571 | - unset($event['recur_exception']); |
|
| 572 | - unset($event['edit_single']); // in case it has been set |
|
| 573 | - unset($event['modified']); |
|
| 574 | - unset($event['modifier']); |
|
| 575 | - unset($event['caldav_name']); |
|
| 576 | - $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner; |
|
| 564 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 565 | + unset($event['id']); |
|
| 566 | + unset($event['uid']); |
|
| 567 | + unset($event['reference']); |
|
| 568 | + unset($preserv['reference']); |
|
| 569 | + unset($event['recurrence']); |
|
| 570 | + unset($preserv['recurrence']); |
|
| 571 | + unset($event['recur_exception']); |
|
| 572 | + unset($event['edit_single']); // in case it has been set |
|
| 573 | + unset($event['modified']); |
|
| 574 | + unset($event['modifier']); |
|
| 575 | + unset($event['caldav_name']); |
|
| 576 | + $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner; |
|
| 577 | + |
|
| 578 | + // Clear participant stati |
|
| 579 | + foreach($event['participant_types'] as $type => &$participants) |
|
| 580 | + { |
|
| 581 | + foreach($participants as $id => &$p_response) |
|
| 582 | + { |
|
| 583 | + if($type == 'u' && $id == $event['owner']) continue; |
|
| 584 | + calendar_so::split_status($p_response, $quantity, $role); |
|
| 585 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 586 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 587 | + $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 588 | + } |
|
| 589 | + } |
|
| 577 | 590 | |
| 578 | - // Clear participant stati |
|
| 579 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 580 | - { |
|
| 581 | - foreach($participants as $id => &$p_response) |
|
| 591 | + // Copy alarms |
|
| 592 | + if (is_array($event['alarm'])) |
|
| 582 | 593 | { |
| 583 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 584 | - calendar_so::split_status($p_response, $quantity, $role); |
|
| 585 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 586 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 587 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 594 | + foreach($event['alarm'] as $n => &$alarm) |
|
| 595 | + { |
|
| 596 | + unset($alarm['id']); |
|
| 597 | + unset($alarm['cal_id']); |
|
| 598 | + } |
|
| 588 | 599 | } |
| 589 | - } |
|
| 590 | 600 | |
| 591 | - // Copy alarms |
|
| 592 | - if (is_array($event['alarm'])) |
|
| 593 | - { |
|
| 594 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 601 | + // Get links to be copied |
|
| 602 | + // With no ID, $content['link_to']['to_id'] is used |
|
| 603 | + $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 604 | + foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 595 | 605 | { |
| 596 | - unset($alarm['id']); |
|
| 597 | - unset($alarm['cal_id']); |
|
| 606 | + if ($link['app'] != Link::VFS_APPNAME) |
|
| 607 | + { |
|
| 608 | + Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 609 | + } |
|
| 610 | + elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 611 | + { |
|
| 612 | + Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 613 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 614 | + 'name' => $link['id'], |
|
| 615 | + ), $link['remark']); |
|
| 616 | + } |
|
| 598 | 617 | } |
| 599 | - } |
|
| 618 | + unset($link); |
|
| 619 | + $preserv['view'] = $preserv['edit_single'] = false; |
|
| 620 | + $msg = lang('Event copied - the copy can now be edited'); |
|
| 621 | + $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 622 | + break; |
|
| 600 | 623 | |
| 601 | - // Get links to be copied |
|
| 602 | - // With no ID, $content['link_to']['to_id'] is used |
|
| 603 | - $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 604 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 605 | - { |
|
| 606 | - if ($link['app'] != Link::VFS_APPNAME) |
|
| 624 | + case 'mail': |
|
| 625 | + case 'sendrequest': |
|
| 626 | + case 'save': |
|
| 627 | + case 'print': |
|
| 628 | + case 'apply': |
|
| 629 | + case 'infolog': |
|
| 630 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 607 | 631 | { |
| 608 | - Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 632 | + $msg = lang('Permission denied'); |
|
| 633 | + $button = ''; |
|
| 634 | + break; |
|
| 609 | 635 | } |
| 610 | - elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 636 | + if ($event['start'] > $event['end']) |
|
| 611 | 637 | { |
| 612 | - Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 613 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 614 | - 'name' => $link['id'], |
|
| 615 | - ), $link['remark']); |
|
| 638 | + $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 639 | + $button = ''; |
|
| 640 | + break; |
|
| 616 | 641 | } |
| 617 | - } |
|
| 618 | - unset($link); |
|
| 619 | - $preserv['view'] = $preserv['edit_single'] = false; |
|
| 620 | - $msg = lang('Event copied - the copy can now be edited'); |
|
| 621 | - $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 622 | - break; |
|
| 623 | - |
|
| 624 | - case 'mail': |
|
| 625 | - case 'sendrequest': |
|
| 626 | - case 'save': |
|
| 627 | - case 'print': |
|
| 628 | - case 'apply': |
|
| 629 | - case 'infolog': |
|
| 630 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 631 | - { |
|
| 632 | - $msg = lang('Permission denied'); |
|
| 633 | - $button = ''; |
|
| 634 | - break; |
|
| 635 | - } |
|
| 636 | - if ($event['start'] > $event['end']) |
|
| 637 | - { |
|
| 638 | - $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 639 | - $button = ''; |
|
| 640 | - break; |
|
| 641 | - } |
|
| 642 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 643 | - { |
|
| 644 | - $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 645 | - $button = ''; |
|
| 646 | - break; |
|
| 647 | - } |
|
| 648 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 649 | - { |
|
| 650 | - $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 651 | - $button = ''; |
|
| 652 | - break; |
|
| 653 | - } |
|
| 654 | - if (!$event['participants']) |
|
| 655 | - { |
|
| 656 | - $msg = lang('Error: no participants selected !!!'); |
|
| 657 | - $button = ''; |
|
| 658 | - break; |
|
| 659 | - } |
|
| 660 | - // if private event with ressource reservation is forbidden |
|
| 661 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 662 | - { |
|
| 663 | - foreach (array_keys($event['participants']) as $uid) |
|
| 642 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 664 | 643 | { |
| 665 | - if ($uid[0] == 'r') //ressource detection |
|
| 644 | + $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 645 | + $button = ''; |
|
| 646 | + break; |
|
| 647 | + } |
|
| 648 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 649 | + { |
|
| 650 | + $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 651 | + $button = ''; |
|
| 652 | + break; |
|
| 653 | + } |
|
| 654 | + if (!$event['participants']) |
|
| 655 | + { |
|
| 656 | + $msg = lang('Error: no participants selected !!!'); |
|
| 657 | + $button = ''; |
|
| 658 | + break; |
|
| 659 | + } |
|
| 660 | + // if private event with ressource reservation is forbidden |
|
| 661 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 662 | + { |
|
| 663 | + foreach (array_keys($event['participants']) as $uid) |
|
| 666 | 664 | { |
| 667 | - $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 668 | - $button = ''; |
|
| 669 | - break 2; //break foreach and case |
|
| 665 | + if ($uid[0] == 'r') //ressource detection |
|
| 666 | + { |
|
| 667 | + $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 668 | + $button = ''; |
|
| 669 | + break 2; //break foreach and case |
|
| 670 | + } |
|
| 670 | 671 | } |
| 671 | 672 | } |
| 672 | - } |
|
| 673 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 674 | - { |
|
| 675 | - $event['reference'] = $event['id']; |
|
| 676 | - $event['recurrence'] = $content['edit_single']; |
|
| 677 | - unset($event['id']); |
|
| 678 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 679 | - if (!is_array($conflicts) && $conflicts) |
|
| 673 | + if ($content['edit_single']) // we edited a single event from a series |
|
| 680 | 674 | { |
| 681 | - // now we need to add the original start as recur-execption to the series |
|
| 682 | - $recur_event = $this->bo->read($event['reference']); |
|
| 683 | - $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 684 | - // check if we need to move the alarms, because they are next on that exception |
|
| 685 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 675 | + $event['reference'] = $event['id']; |
|
| 676 | + $event['recurrence'] = $content['edit_single']; |
|
| 677 | + unset($event['id']); |
|
| 678 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 679 | + if (!is_array($conflicts) && $conflicts) |
|
| 686 | 680 | { |
| 687 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 681 | + // now we need to add the original start as recur-execption to the series |
|
| 682 | + $recur_event = $this->bo->read($event['reference']); |
|
| 683 | + $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 684 | + // check if we need to move the alarms, because they are next on that exception |
|
| 685 | + foreach($recur_event['alarm'] as $id => $alarm) |
|
| 688 | 686 | { |
| 689 | - $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 690 | - foreach ($rrule as $time) |
|
| 687 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 691 | 688 | { |
| 692 | - if ($content['edit_single'] < $time->format('ts')) |
|
| 689 | + $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 690 | + foreach ($rrule as $time) |
|
| 693 | 691 | { |
| 694 | - $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 695 | - $this->bo->save_alarm($event['reference'], $alarm); |
|
| 696 | - break; |
|
| 692 | + if ($content['edit_single'] < $time->format('ts')) |
|
| 693 | + { |
|
| 694 | + $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 695 | + $this->bo->save_alarm($event['reference'], $alarm); |
|
| 696 | + break; |
|
| 697 | + } |
|
| 697 | 698 | } |
| 698 | 699 | } |
| 699 | 700 | } |
| 700 | - } |
|
| 701 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 702 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 703 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 701 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 702 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 703 | + $this->bo->update($recur_event,true); // no conflict check here |
|
| 704 | 704 | |
| 705 | - if(Api\Json\Response::isJSONResponse()) |
|
| 705 | + if(Api\Json\Response::isJSONResponse()) |
|
| 706 | + { |
|
| 707 | + // Sending null will trigger a removal of the original |
|
| 708 | + // for that date |
|
| 709 | + Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 710 | + } |
|
| 711 | + |
|
| 712 | + unset($recur_event); |
|
| 713 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 714 | + unset($preserv['edit_single']); |
|
| 715 | + } |
|
| 716 | + else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 706 | 717 | { |
| 707 | - // Sending null will trigger a removal of the original |
|
| 708 | - // for that date |
|
| 709 | - Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 718 | + $event['id'] = $event['reference']; |
|
| 719 | + $event['reference'] = $event['recurrence'] = 0; |
|
| 720 | + $event['uid'] = $content['uid']; |
|
| 710 | 721 | } |
| 711 | - |
|
| 712 | - unset($recur_event); |
|
| 713 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 714 | - unset($preserv['edit_single']); |
|
| 715 | - } |
|
| 716 | - else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 717 | - { |
|
| 718 | - $event['id'] = $event['reference']; |
|
| 719 | - $event['reference'] = $event['recurrence'] = 0; |
|
| 720 | - $event['uid'] = $content['uid']; |
|
| 722 | + $update_type = 'edit'; |
|
| 721 | 723 | } |
| 722 | - $update_type = 'edit'; |
|
| 723 | - } |
|
| 724 | - else // we edited a non-reccuring event or the whole series |
|
| 725 | - { |
|
| 726 | - if (($old_event = $this->bo->read($event['id']))) |
|
| 724 | + else // we edited a non-reccuring event or the whole series |
|
| 727 | 725 | { |
| 728 | - if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 726 | + if (($old_event = $this->bo->read($event['id']))) |
|
| 729 | 727 | { |
| 730 | - $update_type = 'edit'; |
|
| 731 | - |
|
| 732 | - // we edit a existing series event |
|
| 733 | - if ($event['start'] != $old_event['start'] || |
|
| 734 | - $event['whole_day'] != $old_event['whole_day'] || |
|
| 735 | - $event['end'] != $old_event['end']) |
|
| 728 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 736 | 729 | { |
| 737 | - // calculate offset against old series start or clicked recurrance, |
|
| 738 | - // depending on which is smaller |
|
| 739 | - $offset = $event['start'] - $old_event['start']; |
|
| 740 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 741 | - { |
|
| 742 | - $offset = $off2; |
|
| 743 | - } |
|
| 744 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 745 | - if($msg) |
|
| 730 | + $update_type = 'edit'; |
|
| 731 | + |
|
| 732 | + // we edit a existing series event |
|
| 733 | + if ($event['start'] != $old_event['start'] || |
|
| 734 | + $event['whole_day'] != $old_event['whole_day'] || |
|
| 735 | + $event['end'] != $old_event['end']) |
|
| 746 | 736 | { |
| 747 | - $noerror = false; |
|
| 737 | + // calculate offset against old series start or clicked recurrance, |
|
| 738 | + // depending on which is smaller |
|
| 739 | + $offset = $event['start'] - $old_event['start']; |
|
| 740 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 741 | + { |
|
| 742 | + $offset = $off2; |
|
| 743 | + } |
|
| 744 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 745 | + if($msg) |
|
| 746 | + { |
|
| 747 | + $noerror = false; |
|
| 748 | + } |
|
| 748 | 749 | } |
| 749 | 750 | } |
| 750 | - } |
|
| 751 | - else |
|
| 752 | - { |
|
| 753 | - if ($old_event['start'] != $event['start'] || |
|
| 754 | - $old_event['end'] != $event['end'] || |
|
| 755 | - $event['whole_day'] != $old_event['whole_day']) |
|
| 751 | + else |
|
| 756 | 752 | { |
| 757 | - $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 758 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 753 | + if ($old_event['start'] != $event['start'] || |
|
| 754 | + $old_event['end'] != $event['end'] || |
|
| 755 | + $event['whole_day'] != $old_event['whole_day']) |
|
| 759 | 756 | { |
| 760 | - $q = $r = null; |
|
| 761 | - calendar_so::split_status($status,$q,$r); |
|
| 762 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 757 | + $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 758 | + foreach((array)$event['participants'] as $uid => $status) |
|
| 763 | 759 | { |
| 764 | - $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
| 765 | - $part_prefs = $preferences->read_repository(); |
|
| 766 | - switch ($part_prefs['calendar']['reset_stati']) |
|
| 760 | + $q = $r = null; |
|
| 761 | + calendar_so::split_status($status,$q,$r); |
|
| 762 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 767 | 763 | { |
| 764 | + $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
| 765 | + $part_prefs = $preferences->read_repository(); |
|
| 766 | + switch ($part_prefs['calendar']['reset_stati']) |
|
| 767 | + { |
|
| 768 | 768 | case 'no': |
| 769 | 769 | break; |
| 770 | 770 | case 'startday': |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | $status_reset_to_unknown = true; |
| 774 | 774 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
| 775 | 775 | // todo: report reset status to user |
| 776 | - } |
|
| 776 | + } |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | // check if we need to move the alarms, because they are relative |
@@ -910,83 +910,83 @@ discard block |
||
| 910 | 910 | } |
| 911 | 911 | break; |
| 912 | 912 | |
| 913 | - case 'cancel': |
|
| 914 | - if($content['cancel_needs_refresh']) |
|
| 915 | - { |
|
| 916 | - Framework::refresh_opener($msg, 'calendar'); |
|
| 917 | - } |
|
| 918 | - break; |
|
| 919 | - |
|
| 920 | - case 'delete': // delete of event (regular or series) |
|
| 921 | - $exceptions_kept = null; |
|
| 922 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 923 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 924 | - { |
|
| 925 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 913 | + case 'cancel': |
|
| 914 | + if($content['cancel_needs_refresh']) |
|
| 926 | 915 | { |
| 927 | - $msg = lang('Series deleted'); |
|
| 928 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 916 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 929 | 917 | } |
| 930 | - else |
|
| 918 | + break; |
|
| 919 | + |
|
| 920 | + case 'delete': // delete of event (regular or series) |
|
| 921 | + $exceptions_kept = null; |
|
| 922 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 923 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 931 | 924 | { |
| 932 | - $msg = lang('Event deleted'); |
|
| 933 | - } |
|
| 925 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 926 | + { |
|
| 927 | + $msg = lang('Series deleted'); |
|
| 928 | + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 929 | + } |
|
| 930 | + else |
|
| 931 | + { |
|
| 932 | + $msg = lang('Event deleted'); |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - } |
|
| 936 | - break; |
|
| 935 | + } |
|
| 936 | + break; |
|
| 937 | 937 | |
| 938 | - case 'freetime': |
|
| 939 | - // the "click" has to be in onload, to make sure the button is already created |
|
| 940 | - $event['button_was'] = $button; |
|
| 941 | - break; |
|
| 938 | + case 'freetime': |
|
| 939 | + // the "click" has to be in onload, to make sure the button is already created |
|
| 940 | + $event['button_was'] = $button; |
|
| 941 | + break; |
|
| 942 | 942 | |
| 943 | - case 'add_alarm': |
|
| 944 | - $time = $content['start']; |
|
| 945 | - $offset = $time - $content['new_alarm']['date']; |
|
| 946 | - if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 947 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 948 | - $time < $next_occurrence['start']) |
|
| 949 | - { |
|
| 950 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 951 | - } |
|
| 952 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 953 | - { |
|
| 954 | - $alarm = array( |
|
| 955 | - 'offset' => $offset, |
|
| 956 | - 'time' => $content['new_alarm']['date'], |
|
| 957 | - 'all' => !$content['new_alarm']['owner'], |
|
| 958 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 959 | - ); |
|
| 960 | - if ($alarm['time'] < $this->bo->now_su) |
|
| 943 | + case 'add_alarm': |
|
| 944 | + $time = $content['start']; |
|
| 945 | + $offset = $time - $content['new_alarm']['date']; |
|
| 946 | + if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 947 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 948 | + $time < $next_occurrence['start']) |
|
| 961 | 949 | { |
| 962 | - $msg = lang("Can't add alarms in the past !!!"); |
|
| 950 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 963 | 951 | } |
| 964 | - elseif ($event['id']) // save the alarm immediatly |
|
| 952 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 965 | 953 | { |
| 966 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 954 | + $alarm = array( |
|
| 955 | + 'offset' => $offset, |
|
| 956 | + 'time' => $content['new_alarm']['date'], |
|
| 957 | + 'all' => !$content['new_alarm']['owner'], |
|
| 958 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 959 | + ); |
|
| 960 | + if ($alarm['time'] < $this->bo->now_su) |
|
| 961 | + { |
|
| 962 | + $msg = lang("Can't add alarms in the past !!!"); |
|
| 963 | + } |
|
| 964 | + elseif ($event['id']) // save the alarm immediatly |
|
| 967 | 965 | { |
| 968 | - $alarm['id'] = $alarm_id; |
|
| 969 | - $event['alarm'][$alarm_id] = $alarm; |
|
| 966 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 967 | + { |
|
| 968 | + $alarm['id'] = $alarm_id; |
|
| 969 | + $event['alarm'][$alarm_id] = $alarm; |
|
| 970 | 970 | |
| 971 | - $msg = lang('Alarm added'); |
|
| 972 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 971 | + $msg = lang('Alarm added'); |
|
| 972 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 973 | + } |
|
| 974 | + else |
|
| 975 | + { |
|
| 976 | + $msg = lang('Error adding the alarm'); |
|
| 977 | + } |
|
| 973 | 978 | } |
| 974 | 979 | else |
| 975 | 980 | { |
| 976 | - $msg = lang('Error adding the alarm'); |
|
| 981 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 982 | + $event['alarm'][$alarm['id']] = $alarm; |
|
| 977 | 983 | } |
| 978 | 984 | } |
| 979 | 985 | else |
| 980 | 986 | { |
| 981 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 982 | - $event['alarm'][$alarm['id']] = $alarm; |
|
| 987 | + $msg = lang('Permission denied'); |
|
| 983 | 988 | } |
| 984 | - } |
|
| 985 | - else |
|
| 986 | - { |
|
| 987 | - $msg = lang('Permission denied'); |
|
| 988 | - } |
|
| 989 | - break; |
|
| 989 | + break; |
|
| 990 | 990 | } |
| 991 | 991 | // add notification-errors, if we have some |
| 992 | 992 | if (($notification_errors = notifications::errors(true))) |
@@ -110,11 +110,14 @@ discard block |
||
| 110 | 110 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 111 | 111 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 112 | 112 | { |
| 113 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 113 | + if ($owner) |
|
| 114 | + { |
|
| 115 | + // make an owner who is no user or we have no add-rights a participant |
|
| 114 | 116 | { |
| 115 | 117 | if(!is_array($owner)) |
| 116 | 118 | { |
| 117 | 119 | $owner = explode(',',$owner); |
| 120 | + } |
|
| 118 | 121 | } |
| 119 | 122 | // if we come from ressources we don't need any users selected in calendar |
| 120 | 123 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -150,9 +153,17 @@ discard block |
||
| 150 | 153 | $participant_types['u'] = $participant_types = $participants = array(); |
| 151 | 154 | foreach($extra_participants as $uid) |
| 152 | 155 | { |
| 153 | - if (isset($participants[$uid])) continue; // already included |
|
| 156 | + if (isset($participants[$uid])) |
|
| 157 | + { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 160 | + // already included |
|
| 154 | 161 | |
| 155 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 162 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 166 | + // no right to invite --> ignored |
|
| 156 | 167 | |
| 157 | 168 | if (is_numeric($uid)) |
| 158 | 169 | { |
@@ -180,10 +191,13 @@ discard block |
||
| 180 | 191 | } |
| 181 | 192 | } |
| 182 | 193 | } |
| 183 | - if (!$participants) // if all participants got removed, include current user |
|
| 194 | + if (!$participants) |
|
| 195 | + { |
|
| 196 | + // if all participants got removed, include current user |
|
| 184 | 197 | { |
| 185 | 198 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 186 | 199 | } |
| 200 | + } |
|
| 187 | 201 | if(isset($_GET['cat_id'])) |
| 188 | 202 | { |
| 189 | 203 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -231,10 +245,13 @@ discard block |
||
| 231 | 245 | */ |
| 232 | 246 | function process_edit($content) |
| 233 | 247 | { |
| 234 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 248 | + if (!is_array($content)) |
|
| 249 | + { |
|
| 250 | + // redirect from etemplate, if POST empty |
|
| 235 | 251 | { |
| 236 | 252 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 237 | 253 | } |
| 254 | + } |
|
| 238 | 255 | // clear notification errors |
| 239 | 256 | notifications::errors(true); |
| 240 | 257 | $messages = null; |
@@ -247,7 +264,11 @@ discard block |
||
| 247 | 264 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 248 | 265 | |
| 249 | 266 | list($button) = @each($content['button']); |
| 250 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 267 | + if (!$button && $content['action']) |
|
| 268 | + { |
|
| 269 | + $button = $content['action']; |
|
| 270 | + } |
|
| 271 | + // action selectbox |
|
| 251 | 272 | unset($content['button']); unset($content['action']); |
| 252 | 273 | |
| 253 | 274 | $view = $content['view']; |
@@ -260,7 +281,10 @@ discard block |
||
| 260 | 281 | { |
| 261 | 282 | list($date) = each($content['recur_exception']['delete_exception']); |
| 262 | 283 | // eT2 converts time to |
| 263 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 284 | + if (!is_numeric($date)) |
|
| 285 | + { |
|
| 286 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 287 | + } |
|
| 264 | 288 | unset($content['recur_exception']['delete_exception']); |
| 265 | 289 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 266 | 290 | { |
@@ -269,7 +293,10 @@ discard block |
||
| 269 | 293 | foreach ($recur_exceptions as $id) |
| 270 | 294 | { |
| 271 | 295 | if (!($exception = $this->bo->read($id)) || |
| 272 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 296 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 297 | + { |
|
| 298 | + continue; |
|
| 299 | + } |
|
| 273 | 300 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 274 | 301 | $exception['reference'] = $exception['recurrence'] = 0; |
| 275 | 302 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -344,7 +371,10 @@ discard block |
||
| 344 | 371 | $event['end'] = $this->bo->date2ts($event['end']); |
| 345 | 372 | } |
| 346 | 373 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 347 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 374 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 375 | + { |
|
| 376 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 377 | + } |
|
| 348 | 378 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 349 | 379 | { |
| 350 | 380 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -371,7 +401,8 @@ discard block |
||
| 371 | 401 | break; |
| 372 | 402 | case 'participant': |
| 373 | 403 | foreach($data as $participant) |
| 374 | - { // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
|
| 404 | + { |
|
| 405 | +// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
|
| 375 | 406 | $email = array(); |
| 376 | 407 | if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
| 377 | 408 | { |
@@ -451,7 +482,11 @@ discard block |
||
| 451 | 482 | break; |
| 452 | 483 | |
| 453 | 484 | default: // existing participant row |
| 454 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 485 | + if (!is_array($data)) |
|
| 486 | + { |
|
| 487 | + continue; |
|
| 488 | + } |
|
| 489 | + // widgets in participant tab, above participant list |
|
| 455 | 490 | foreach(array('uid','status','quantity','role') as $name) |
| 456 | 491 | { |
| 457 | 492 | $$name = $data[$name]; |
@@ -580,7 +615,10 @@ discard block |
||
| 580 | 615 | { |
| 581 | 616 | foreach($participants as $id => &$p_response) |
| 582 | 617 | { |
| 583 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 618 | + if($type == 'u' && $id == $event['owner']) |
|
| 619 | + { |
|
| 620 | + continue; |
|
| 621 | + } |
|
| 584 | 622 | calendar_so::split_status($p_response, $quantity, $role); |
| 585 | 623 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 586 | 624 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -662,17 +700,23 @@ discard block |
||
| 662 | 700 | { |
| 663 | 701 | foreach (array_keys($event['participants']) as $uid) |
| 664 | 702 | { |
| 665 | - if ($uid[0] == 'r') //ressource detection |
|
| 703 | + if ($uid[0] == 'r') |
|
| 704 | + { |
|
| 705 | + //ressource detection |
|
| 666 | 706 | { |
| 667 | 707 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 708 | + } |
|
| 668 | 709 | $button = ''; |
| 669 | 710 | break 2; //break foreach and case |
| 670 | 711 | } |
| 671 | 712 | } |
| 672 | 713 | } |
| 673 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 714 | + if ($content['edit_single']) |
|
| 715 | + { |
|
| 716 | + // we edited a single event from a series |
|
| 674 | 717 | { |
| 675 | 718 | $event['reference'] = $event['id']; |
| 719 | + } |
|
| 676 | 720 | $event['recurrence'] = $content['edit_single']; |
| 677 | 721 | unset($event['id']); |
| 678 | 722 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -768,7 +812,10 @@ discard block |
||
| 768 | 812 | case 'no': |
| 769 | 813 | break; |
| 770 | 814 | case 'startday': |
| 771 | - if ($sameday) break; |
|
| 815 | + if ($sameday) |
|
| 816 | + { |
|
| 817 | + break; |
|
| 818 | + } |
|
| 772 | 819 | default: |
| 773 | 820 | $status_reset_to_unknown = true; |
| 774 | 821 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -925,7 +972,10 @@ discard block |
||
| 925 | 972 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 926 | 973 | { |
| 927 | 974 | $msg = lang('Series deleted'); |
| 928 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 975 | + if ($exceptions_kept) |
|
| 976 | + { |
|
| 977 | + $msg .= lang(', exceptions preserved'); |
|
| 978 | + } |
|
| 929 | 979 | } |
| 930 | 980 | else |
| 931 | 981 | { |
@@ -961,11 +1011,14 @@ discard block |
||
| 961 | 1011 | { |
| 962 | 1012 | $msg = lang("Can't add alarms in the past !!!"); |
| 963 | 1013 | } |
| 964 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1014 | + elseif ($event['id']) |
|
| 1015 | + { |
|
| 1016 | + // save the alarm immediatly |
|
| 965 | 1017 | { |
| 966 | 1018 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 967 | 1019 | { |
| 968 | 1020 | $alarm['id'] = $alarm_id; |
| 1021 | + } |
|
| 969 | 1022 | $event['alarm'][$alarm_id] = $alarm; |
| 970 | 1023 | |
| 971 | 1024 | $msg = lang('Alarm added'); |
@@ -978,7 +1031,9 @@ discard block |
||
| 978 | 1031 | } |
| 979 | 1032 | else |
| 980 | 1033 | { |
| 981 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1035 | + { |
|
| 1036 | +} // get a temporary non-conflicting, numeric id |
|
| 982 | 1037 | $event['alarm'][$alarm['id']] = $alarm; |
| 983 | 1038 | } |
| 984 | 1039 | } |
@@ -1001,10 +1056,13 @@ discard block |
||
| 1001 | 1056 | } |
| 1002 | 1057 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1003 | 1058 | { |
| 1004 | - if ($content['lock_token']) // remove an existing lock |
|
| 1059 | + if ($content['lock_token']) |
|
| 1060 | + { |
|
| 1061 | + // remove an existing lock |
|
| 1005 | 1062 | { |
| 1006 | 1063 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1007 | 1064 | } |
| 1065 | + } |
|
| 1008 | 1066 | if ($content['no_popup']) |
| 1009 | 1067 | { |
| 1010 | 1068 | Egw::redirect_link('/index.php',array( |
@@ -1108,8 +1166,7 @@ discard block |
||
| 1108 | 1166 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1109 | 1167 | // Adjust for requested date in the past |
| 1110 | 1168 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1111 | - ) |
|
| 1112 | - { |
|
| 1169 | + ) { |
|
| 1113 | 1170 | |
| 1114 | 1171 | unset($orig_event); |
| 1115 | 1172 | // copy event by unsetting the id(s) |
@@ -1197,32 +1254,50 @@ discard block |
||
| 1197 | 1254 | foreach($event['participants'] as $uid => $status) |
| 1198 | 1255 | { |
| 1199 | 1256 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1200 | - if (empty($status)) continue; |
|
| 1257 | + if (empty($status)) |
|
| 1258 | + { |
|
| 1259 | + continue; |
|
| 1260 | + } |
|
| 1201 | 1261 | $toadd = ''; |
| 1202 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1262 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1263 | + { |
|
| 1264 | + continue; |
|
| 1265 | + } |
|
| 1203 | 1266 | |
| 1204 | 1267 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1205 | 1268 | { |
| 1206 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1269 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1270 | + { |
|
| 1271 | + continue; |
|
| 1272 | + } |
|
| 1207 | 1273 | |
| 1208 | 1274 | $lid = $firstname = $lastname = null; |
| 1209 | 1275 | $GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname); |
| 1210 | 1276 | |
| 1211 | 1277 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1212 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1278 | + if (!in_array($toadd,$to)) |
|
| 1279 | + { |
|
| 1280 | + $to[] = $toadd; |
|
| 1281 | + } |
|
| 1213 | 1282 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1214 | 1283 | } |
| 1215 | 1284 | elseif ($uid < 0) |
| 1216 | 1285 | { |
| 1217 | 1286 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1218 | 1287 | { |
| 1219 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1288 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1289 | + { |
|
| 1290 | + continue; |
|
| 1291 | + } |
|
| 1220 | 1292 | |
| 1221 | 1293 | $GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname); |
| 1222 | 1294 | |
| 1223 | 1295 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1224 | 1296 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1225 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1297 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1298 | + { |
|
| 1299 | + $to[] = $toadd; |
|
| 1300 | + } |
|
| 1226 | 1301 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1227 | 1302 | } |
| 1228 | 1303 | } |
@@ -1275,7 +1350,10 @@ discard block |
||
| 1275 | 1350 | 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
| 1276 | 1351 | 'preset[size]' => filesize($ics_file), |
| 1277 | 1352 | ); |
| 1278 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1353 | + if ($asrequest) |
|
| 1354 | + { |
|
| 1355 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1356 | + } |
|
| 1279 | 1357 | $response = Api\Json\Response::get(); |
| 1280 | 1358 | $response->call('app.calendar.custom_mail', $vars); |
| 1281 | 1359 | } |
@@ -1461,9 +1539,15 @@ discard block |
||
| 1461 | 1539 | } |
| 1462 | 1540 | } |
| 1463 | 1541 | // set new start and end if given by $_GET |
| 1464 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1465 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1466 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1542 | + if(isset($_GET['start'])) |
|
| 1543 | + { |
|
| 1544 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1545 | + if(isset($_GET['end'])) |
|
| 1546 | + { |
|
| 1547 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1548 | + if(isset($_GET['non_blocking'])) |
|
| 1549 | + { |
|
| 1550 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1467 | 1551 | // check if the event is the whole day |
| 1468 | 1552 | $start = $this->bo->date2array($event['start']); |
| 1469 | 1553 | $end = $this->bo->date2array($event['end']); |
@@ -1476,10 +1560,13 @@ discard block |
||
| 1476 | 1560 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1477 | 1561 | { |
| 1478 | 1562 | $link_id = $link_ids[$n]; |
| 1479 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1563 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1564 | + { |
|
| 1565 | + // guard against XSS |
|
| 1480 | 1566 | { |
| 1481 | 1567 | continue; |
| 1482 | 1568 | } |
| 1569 | + } |
|
| 1483 | 1570 | if(!$n) |
| 1484 | 1571 | { |
| 1485 | 1572 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1488,7 +1575,10 @@ discard block |
||
| 1488 | 1575 | { |
| 1489 | 1576 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1490 | 1577 | { |
| 1491 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1578 | + if (($l_id=$set['link_id'][$i])) |
|
| 1579 | + { |
|
| 1580 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1581 | + } |
|
| 1492 | 1582 | } |
| 1493 | 1583 | unset($set['link_app']); |
| 1494 | 1584 | unset($set['link_id']); |
@@ -1514,10 +1604,13 @@ discard block |
||
| 1514 | 1604 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1515 | 1605 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1516 | 1606 | |
| 1517 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1607 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1608 | + { |
|
| 1609 | + // already locked --> refresh the lock |
|
| 1518 | 1610 | { |
| 1519 | 1611 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1520 | 1612 | } |
| 1613 | + } |
|
| 1521 | 1614 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1522 | 1615 | { |
| 1523 | 1616 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1550,14 +1643,20 @@ discard block |
||
| 1550 | 1643 | )); |
| 1551 | 1644 | Framework::message($msg, $msg_type); |
| 1552 | 1645 | $content['duration'] = $content['end'] - $content['start']; |
| 1553 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1646 | + if (isset($this->durations[$content['duration']])) |
|
| 1647 | + { |
|
| 1648 | + $content['end'] = ''; |
|
| 1649 | + } |
|
| 1554 | 1650 | |
| 1555 | 1651 | $row = 3; |
| 1556 | 1652 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1557 | 1653 | // preserve some ui elements, if set eg. under error-conditions |
| 1558 | 1654 | foreach(array('quantity','resource','role') as $n) |
| 1559 | 1655 | { |
| 1560 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1656 | + if (isset($event['participants'][$n])) |
|
| 1657 | + { |
|
| 1658 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1659 | + } |
|
| 1561 | 1660 | } |
| 1562 | 1661 | foreach($event['participant_types'] as $type => $participants) |
| 1563 | 1662 | { |
@@ -1599,9 +1698,13 @@ discard block |
||
| 1599 | 1698 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1600 | 1699 | |
| 1601 | 1700 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1602 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1701 | + { |
|
| 1702 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1703 | + } |
|
| 1603 | 1704 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1604 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1705 | + { |
|
| 1706 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1707 | + } |
|
| 1605 | 1708 | // todo: make the participants available as links with email as title |
| 1606 | 1709 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1607 | 1710 | // enumerate group-invitations, so people can accept/reject them |
@@ -1632,7 +1735,11 @@ discard block |
||
| 1632 | 1735 | $content['participants']['cal_resources'] = ''; |
| 1633 | 1736 | foreach($this->bo->resources as $data) |
| 1634 | 1737 | { |
| 1635 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1738 | + if ($data['app'] == 'email') |
|
| 1739 | + { |
|
| 1740 | + continue; |
|
| 1741 | + } |
|
| 1742 | + // make no sense, as we cant search for email |
|
| 1636 | 1743 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1637 | 1744 | } |
| 1638 | 1745 | } |
@@ -1660,9 +1767,18 @@ discard block |
||
| 1660 | 1767 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1661 | 1768 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1662 | 1769 | $label = array(); |
| 1663 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1664 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1665 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1770 | + if ($days) |
|
| 1771 | + { |
|
| 1772 | + $label[] = $days.' '.lang('days'); |
|
| 1773 | + } |
|
| 1774 | + if ($hours) |
|
| 1775 | + { |
|
| 1776 | + $label[] = $hours.' '.lang('hours'); |
|
| 1777 | + } |
|
| 1778 | + if ($minutes) |
|
| 1779 | + { |
|
| 1780 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1781 | + } |
|
| 1666 | 1782 | $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
| 1667 | 1783 | $content['alarm'][] = $alarm; |
| 1668 | 1784 | |
@@ -1725,25 +1841,34 @@ discard block |
||
| 1725 | 1841 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1726 | 1842 | 'history' => !$event['id'], |
| 1727 | 1843 | ); |
| 1728 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1844 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1845 | + { |
|
| 1846 | + // no mail without mail-app |
|
| 1729 | 1847 | { |
| 1730 | 1848 | unset($sel_options['action']['mail']); |
| 1849 | + } |
|
| 1731 | 1850 | unset($sel_options['action']['sendmeetingrequest']); |
| 1732 | 1851 | } |
| 1733 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1852 | + if (!$event['id']) |
|
| 1853 | + { |
|
| 1854 | + // no ical export for new (not saved) events |
|
| 1734 | 1855 | { |
| 1735 | 1856 | $readonlys['action'] = true; |
| 1736 | 1857 | } |
| 1858 | + } |
|
| 1737 | 1859 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
| 1738 | 1860 | { |
| 1739 | 1861 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1740 | 1862 | } |
| 1741 | 1863 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1742 | 1864 | |
| 1743 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1865 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1866 | + { |
|
| 1867 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1744 | 1868 | { |
| 1745 | 1869 | $sel_options['owner'][0] = lang('All participants'); |
| 1746 | 1870 | } |
| 1871 | + } |
|
| 1747 | 1872 | if (isset($event['participant_types']['u'][$this->user])) |
| 1748 | 1873 | { |
| 1749 | 1874 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1785,7 +1910,10 @@ discard block |
||
| 1785 | 1910 | |
| 1786 | 1911 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1787 | 1912 | |
| 1788 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 1913 | + if (!empty($preserved['lock_token'])) |
|
| 1914 | + { |
|
| 1915 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 1916 | + } |
|
| 1789 | 1917 | |
| 1790 | 1918 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1791 | 1919 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -1987,7 +2115,10 @@ discard block |
||
| 1987 | 2115 | // set status and send notification / meeting response |
| 1988 | 2116 | if ($this->bo->set_status($event['id'], $user, $status)) |
| 1989 | 2117 | { |
| 1990 | - if (!$msg) $msg = lang('Status changed'); |
|
| 2118 | + if (!$msg) |
|
| 2119 | + { |
|
| 2120 | + $msg = lang('Status changed'); |
|
| 2121 | + } |
|
| 1991 | 2122 | } |
| 1992 | 2123 | break; |
| 1993 | 2124 | |
@@ -2066,13 +2197,16 @@ discard block |
||
| 2066 | 2197 | |
| 2067 | 2198 | foreach (array_keys($allConflicts) as $pId) |
| 2068 | 2199 | { |
| 2069 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2200 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2201 | + { |
|
| 2202 | + // resources Allow ignore conflicts |
|
| 2070 | 2203 | { |
| 2071 | 2204 | |
| 2072 | 2205 | switch ($resources_config['ignoreconflicts']) |
| 2073 | 2206 | { |
| 2074 | 2207 | case 'no': |
| 2075 | 2208 | $readonlys['button[ignore]'] = true; |
| 2209 | + } |
|
| 2076 | 2210 | break; |
| 2077 | 2211 | case 'allusers': |
| 2078 | 2212 | $readonlys['button[ignore]'] = false; |
@@ -2216,7 +2350,10 @@ discard block |
||
| 2216 | 2350 | } |
| 2217 | 2351 | else |
| 2218 | 2352 | { |
| 2219 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2353 | + if (!$content['duration']) |
|
| 2354 | + { |
|
| 2355 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2356 | + } |
|
| 2220 | 2357 | $weekds = 0; |
| 2221 | 2358 | foreach ($content['weekdays'] as &$wdays) |
| 2222 | 2359 | { |
@@ -2238,7 +2375,10 @@ discard block |
||
| 2238 | 2375 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2239 | 2376 | |
| 2240 | 2377 | $sel_options['duration'] = $this->durations; |
| 2241 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2378 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2379 | + { |
|
| 2380 | + $content['end'] = ''; |
|
| 2381 | + } |
|
| 2242 | 2382 | |
| 2243 | 2383 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2244 | 2384 | 'participants' => $content['participants'], |
@@ -2259,7 +2399,10 @@ discard block |
||
| 2259 | 2399 | */ |
| 2260 | 2400 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2261 | 2401 | { |
| 2262 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2402 | + if ($this->debug > 2) |
|
| 2403 | + { |
|
| 2404 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2405 | + } |
|
| 2263 | 2406 | |
| 2264 | 2407 | $busy = $this->bo->search(array( |
| 2265 | 2408 | 'start' => $start, |
@@ -2276,15 +2419,26 @@ discard block |
||
| 2276 | 2419 | $n = 0; |
| 2277 | 2420 | foreach($busy as $event) |
| 2278 | 2421 | { |
| 2279 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2422 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2423 | + { |
|
| 2424 | + continue; |
|
| 2425 | + } |
|
| 2426 | + // ignore our own event |
|
| 2280 | 2427 | |
| 2281 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2428 | + if ($event['non_blocking']) |
|
| 2429 | + { |
|
| 2430 | + continue; |
|
| 2431 | + } |
|
| 2432 | + // ignore non_blocking events |
|
| 2282 | 2433 | |
| 2283 | 2434 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2284 | 2435 | $non_rejected_found = false; |
| 2285 | 2436 | foreach($participants as $uid) |
| 2286 | 2437 | { |
| 2287 | - if ($event['participants'][$uid] == 'R') continue; |
|
| 2438 | + if ($event['participants'][$uid] == 'R') |
|
| 2439 | + { |
|
| 2440 | + continue; |
|
| 2441 | + } |
|
| 2288 | 2442 | |
| 2289 | 2443 | if (isset($event['participants'][$uid]) || |
| 2290 | 2444 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2294,7 +2448,10 @@ discard block |
||
| 2294 | 2448 | break; |
| 2295 | 2449 | } |
| 2296 | 2450 | } |
| 2297 | - if (!$non_rejected_found) continue; |
|
| 2451 | + if (!$non_rejected_found) |
|
| 2452 | + { |
|
| 2453 | + continue; |
|
| 2454 | + } |
|
| 2298 | 2455 | |
| 2299 | 2456 | if ($this->debug) |
| 2300 | 2457 | { |
@@ -2325,11 +2482,17 @@ discard block |
||
| 2325 | 2482 | 'start' => $ft_start, |
| 2326 | 2483 | 'end' => $ft_end, |
| 2327 | 2484 | ); |
| 2328 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2485 | + if ($this->debug > 1) |
|
| 2486 | + { |
|
| 2487 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2488 | + } |
|
| 2329 | 2489 | } |
| 2330 | 2490 | $ft_start = $event['end']; |
| 2331 | 2491 | } |
| 2332 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2492 | + if ($this->debug > 0) |
|
| 2493 | + { |
|
| 2494 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2495 | + } |
|
| 2333 | 2496 | |
| 2334 | 2497 | return $freetime; |
| 2335 | 2498 | } |
@@ -2349,10 +2512,16 @@ discard block |
||
| 2349 | 2512 | */ |
| 2350 | 2513 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2351 | 2514 | { |
| 2352 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2515 | + if ($this->debug > 1) |
|
| 2516 | + { |
|
| 2517 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2518 | + } |
|
| 2353 | 2519 | |
| 2354 | 2520 | $freetime_daywise = array(); |
| 2355 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2521 | + if (!is_array($sel_options)) |
|
| 2522 | + { |
|
| 2523 | + $sel_options = array(); |
|
| 2524 | + } |
|
| 2356 | 2525 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2357 | 2526 | |
| 2358 | 2527 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2362,7 +2531,10 @@ discard block |
||
| 2362 | 2531 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2363 | 2532 | { |
| 2364 | 2533 | $end_time = 0; |
| 2365 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2534 | + if ($this->debug > 1) |
|
| 2535 | + { |
|
| 2536 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2537 | + } |
|
| 2366 | 2538 | } |
| 2367 | 2539 | $n = 0; |
| 2368 | 2540 | foreach($freetime as $ft) |
@@ -2383,13 +2555,19 @@ discard block |
||
| 2383 | 2555 | } |
| 2384 | 2556 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2385 | 2557 | |
| 2386 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2558 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2559 | + { |
|
| 2560 | + // start earlier then start_time |
|
| 2387 | 2561 | { |
| 2388 | 2562 | $start = $daybegin + $start_time*HOUR_s; |
| 2389 | 2563 | } |
| 2564 | + } |
|
| 2390 | 2565 | // if end_time given use it, else the original slot's end |
| 2391 | 2566 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2392 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2567 | + if ($end > $ft['end']) |
|
| 2568 | + { |
|
| 2569 | + $end = $ft['end']; |
|
| 2570 | + } |
|
| 2393 | 2571 | |
| 2394 | 2572 | // slot to small for duration |
| 2395 | 2573 | if ($end - $start < $duration) |
@@ -2431,7 +2609,10 @@ discard block |
||
| 2431 | 2609 | { |
| 2432 | 2610 | $msg = lang('Permission denied'); |
| 2433 | 2611 | |
| 2434 | - if ($return_error) return $msg; |
|
| 2612 | + if ($return_error) |
|
| 2613 | + { |
|
| 2614 | + return $msg; |
|
| 2615 | + } |
|
| 2435 | 2616 | } |
| 2436 | 2617 | else |
| 2437 | 2618 | { |
@@ -2493,27 +2674,42 @@ discard block |
||
| 2493 | 2674 | { |
| 2494 | 2675 | list($button) = each($_content['button']); |
| 2495 | 2676 | unset($_content['button']); |
| 2496 | - if ($button != 'cancel') // store changed Acl |
|
| 2677 | + if ($button != 'cancel') |
|
| 2678 | + { |
|
| 2679 | + // store changed Acl |
|
| 2497 | 2680 | { |
| 2498 | 2681 | foreach($_content as $data) |
| 2499 | 2682 | { |
| 2500 | 2683 | if (!($cat_id = $data['cat_id'])) continue; |
| 2684 | + } |
|
| 2501 | 2685 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2502 | 2686 | { |
| 2503 | 2687 | $rights = 0; |
| 2504 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2505 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2506 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2688 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2689 | + { |
|
| 2690 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2691 | + } |
|
| 2692 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2693 | + { |
|
| 2694 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2695 | + } |
|
| 2696 | + if ($account_id) |
|
| 2697 | + { |
|
| 2698 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2699 | + } |
|
| 2507 | 2700 | } |
| 2508 | 2701 | } |
| 2509 | 2702 | } |
| 2510 | - if ($button != 'apply') // end dialog |
|
| 2703 | + if ($button != 'apply') |
|
| 2704 | + { |
|
| 2705 | + // end dialog |
|
| 2511 | 2706 | { |
| 2512 | 2707 | Egw::redirect_link('/index.php', array( |
| 2513 | 2708 | 'menuaction' => 'admin.admin_ui.index', |
| 2514 | 2709 | 'ajax' => 'true' |
| 2515 | 2710 | ), 'admin'); |
| 2516 | 2711 | } |
| 2712 | + } |
|
| 2517 | 2713 | } |
| 2518 | 2714 | $content= $preserv = array(); |
| 2519 | 2715 | $n = 1; |
@@ -2527,8 +2723,14 @@ discard block |
||
| 2527 | 2723 | ); |
| 2528 | 2724 | foreach($data as $account_id => $rights) |
| 2529 | 2725 | { |
| 2530 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2531 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2726 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2727 | + { |
|
| 2728 | + $row['add'][] = $account_id; |
|
| 2729 | + } |
|
| 2730 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2731 | + { |
|
| 2732 | + $row['status'][] = $account_id; |
|
| 2733 | + } |
|
| 2532 | 2734 | } |
| 2533 | 2735 | $content[$n] = $row; |
| 2534 | 2736 | $preserv[$n] = array( |
@@ -2656,7 +2858,10 @@ discard block |
||
| 2656 | 2858 | break; |
| 2657 | 2859 | } |
| 2658 | 2860 | } |
| 2659 | - if($return) return; |
|
| 2861 | + if($return) |
|
| 2862 | + { |
|
| 2863 | + return; |
|
| 2864 | + } |
|
| 2660 | 2865 | } |
| 2661 | 2866 | $old_event=$event=$this->bo->read($eventId); |
| 2662 | 2867 | if (!$durationT) |
@@ -2741,7 +2946,10 @@ discard block |
||
| 2741 | 2946 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2742 | 2947 | |
| 2743 | 2948 | // Whole day non blocking with DAY_s would add a day |
| 2744 | - if($duration==DAY_s) $duration=0; |
|
| 2949 | + if($duration==DAY_s) |
|
| 2950 | + { |
|
| 2951 | + $duration=0; |
|
| 2952 | + } |
|
| 2745 | 2953 | } |
| 2746 | 2954 | // Drag a normal event to whole day non-blocking |
| 2747 | 2955 | else if ($durationT == 'whole_day') |
@@ -2765,7 +2973,10 @@ discard block |
||
| 2765 | 2973 | case 'no': |
| 2766 | 2974 | break; |
| 2767 | 2975 | case 'startday': |
| 2768 | - if ($sameday) break; |
|
| 2976 | + if ($sameday) |
|
| 2977 | + { |
|
| 2978 | + break; |
|
| 2979 | + } |
|
| 2769 | 2980 | default: |
| 2770 | 2981 | $status_reset_to_unknown = true; |
| 2771 | 2982 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -2803,7 +3014,10 @@ discard block |
||
| 2803 | 3014 | { |
| 2804 | 3015 | $response->call('egw.message', implode('<br />', $message)); |
| 2805 | 3016 | } |
| 2806 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3017 | + if($event['id'] != $eventId ) |
|
| 3018 | + { |
|
| 3019 | + $this->update_client($_eventId); |
|
| 3020 | + } |
|
| 2807 | 3021 | if ($status_reset_to_unknown) |
| 2808 | 3022 | { |
| 2809 | 3023 | foreach((array)$event['participants'] as $uid => $status) |
@@ -2890,11 +2890,11 @@ |
||
| 2890 | 2890 | { |
| 2891 | 2891 | $msg = lang('Event deleted'); |
| 2892 | 2892 | } |
| 2893 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 2893 | + $response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete')); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | else |
| 2896 | 2896 | { |
| 2897 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 2897 | + $response->apply('egw.message', array(lang('Error')),'error'); |
|
| 2898 | 2898 | } |
| 2899 | 2899 | } |
| 2900 | 2900 | |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @var locktime in seconds |
| 57 | 57 | */ |
| 58 | - var $locktime_default=1; |
|
| 58 | + var $locktime_default = 1; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Constructor |
| 62 | 62 | */ |
| 63 | 63 | function __construct() |
| 64 | 64 | { |
| 65 | - parent::__construct(true); // call the parent's constructor |
|
| 65 | + parent::__construct(true); // call the parent's constructor |
|
| 66 | 66 | |
| 67 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 67 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 68 | 68 | { |
| 69 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
| 69 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function &default_add_event() |
| 79 | 79 | { |
| 80 | - $extra_participants = $_GET['participants'] ? explode(',',$_GET['participants']) : array(); |
|
| 80 | + $extra_participants = $_GET['participants'] ? explode(',', $_GET['participants']) : array(); |
|
| 81 | 81 | |
| 82 | 82 | // if participant is a contact, add its link title as title |
| 83 | - foreach($extra_participants as $uid) |
|
| 83 | + foreach ($extra_participants as $uid) |
|
| 84 | 84 | { |
| 85 | 85 | if ($uid[0] == 'c') |
| 86 | 86 | { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if (isset($_GET['owner'])) |
| 93 | 93 | { |
| 94 | 94 | $owner = $_GET['owner']; |
| 95 | - if(is_array($owner)) |
|
| 95 | + if (is_array($owner)) |
|
| 96 | 96 | { |
| 97 | 97 | $extra_participants += $owner; |
| 98 | 98 | $owner = count($owner) > 1 ? $this->user : $owner[0]; |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 111 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
| 111 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
| 112 | 112 | { |
| 113 | 113 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
| 114 | 114 | { |
| 115 | - if(!is_array($owner)) |
|
| 115 | + if (!is_array($owner)) |
|
| 116 | 116 | { |
| 117 | - $owner = explode(',',$owner); |
|
| 117 | + $owner = explode(',', $owner); |
|
| 118 | 118 | } |
| 119 | 119 | // if we come from ressources we don't need any users selected in calendar |
| 120 | 120 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
| 121 | 121 | { |
| 122 | - foreach($owner as $uid) |
|
| 122 | + foreach ($owner as $uid) |
|
| 123 | 123 | { |
| 124 | 124 | $extra_participants[] = $uid; |
| 125 | 125 | } |
@@ -129,71 +129,71 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
| 131 | 131 | |
| 132 | - if(isset($_GET['start'])) |
|
| 132 | + if (isset($_GET['start'])) |
|
| 133 | 133 | { |
| 134 | 134 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
| 135 | 135 | } |
| 136 | 136 | else |
| 137 | 137 | { |
| 138 | 138 | $start = $this->bo->date2ts(array( |
| 139 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
| 140 | - 'hour' => (int) (isset($_GET['hour']) && (int) $_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 141 | - 'minute' => (int) $_GET['minute'], |
|
| 139 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
| 140 | + 'hour' => (int)(isset($_GET['hour']) && (int)$_GET['hour'] ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 141 | + 'minute' => (int)$_GET['minute'], |
|
| 142 | 142 | )); |
| 143 | 143 | } |
| 144 | 144 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
| 145 | 145 | |
| 146 | 146 | $participant_types['u'] = $participant_types = $participants = array(); |
| 147 | - foreach($extra_participants as $uid) |
|
| 147 | + foreach ($extra_participants as $uid) |
|
| 148 | 148 | { |
| 149 | - if (isset($participants[$uid])) continue; // already included |
|
| 149 | + if (isset($participants[$uid])) continue; // already included |
|
| 150 | 150 | |
| 151 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 151 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 152 | 152 | |
| 153 | 153 | if (is_numeric($uid)) |
| 154 | 154 | { |
| 155 | 155 | $participants[$uid] = $participant_types['u'][$uid] = |
| 156 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 157 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 156 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 157 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 158 | 158 | } |
| 159 | 159 | elseif (is_array($this->bo->resources[$uid[0]])) |
| 160 | 160 | { |
| 161 | 161 | // Expand mailing lists |
| 162 | - if($uid[0] == 'l') |
|
| 162 | + if ($uid[0] == 'l') |
|
| 163 | 163 | { |
| 164 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
| 164 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
| 165 | 165 | { |
| 166 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
| 167 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
| 166 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
| 167 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
| 168 | 168 | } |
| 169 | 169 | continue; |
| 170 | 170 | } |
| 171 | 171 | // if contact is a user, use the user instead (as the GUI) |
| 172 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
| 172 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
| 173 | 173 | { |
| 174 | 174 | $uid = $account_id; |
| 175 | 175 | $participants[$uid] = $participant_types['u'][$uid] = |
| 176 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 177 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 176 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 177 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 178 | 178 | continue; |
| 179 | 179 | } |
| 180 | 180 | $res_data = $this->bo->resources[$uid[0]]; |
| 181 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
| 182 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
| 181 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
| 182 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
| 183 | 183 | { |
| 184 | 184 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
| 185 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
| 185 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | if (!$participants) // if all participants got removed, include current user |
| 190 | 190 | { |
| 191 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
| 191 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
| 192 | 192 | } |
| 193 | - if(isset($_GET['cat_id'])) |
|
| 193 | + if (isset($_GET['cat_id'])) |
|
| 194 | 194 | { |
| 195 | - $cat_id = explode(',',$_GET['cat_id']); |
|
| 196 | - foreach($cat_id as &$cat) |
|
| 195 | + $cat_id = explode(',', $_GET['cat_id']); |
|
| 196 | + foreach ($cat_id as &$cat) |
|
| 197 | 197 | { |
| 198 | 198 | $cat = (int)$cat; |
| 199 | 199 | } |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | if ((string)$this->cal_prefs['default-alarm'] !== '') |
| 205 | 205 | { |
| 206 | 206 | $offset = 60 * $this->cal_prefs['default-alarm']; |
| 207 | - $alarms[1] = array( |
|
| 207 | + $alarms[1] = array( |
|
| 208 | 208 | 'default' => 1, |
| 209 | - 'offset' => $offset , |
|
| 209 | + 'offset' => $offset, |
|
| 210 | 210 | 'time' => $start - $offset, |
| 211 | 211 | 'all' => false, |
| 212 | 212 | 'owner' => $owner, |
| 213 | 213 | 'id' => 1, |
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
| 216 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
| 217 | 217 | $end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration; |
| 218 | 218 | return array( |
| 219 | 219 | 'participant_types' => $participant_types, |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | 'start' => $start, |
| 223 | 223 | 'end' => $end, |
| 224 | 224 | 'tzid' => $this->bo->common_prefs['tz'], |
| 225 | - 'priority' => 2, // normal |
|
| 225 | + 'priority' => 2, // normal |
|
| 226 | 226 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
| 227 | 227 | 'alarm' => $alarms, |
| 228 | 228 | 'recur_exception' => array(), |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | if (!is_array($content)) // redirect from etemplate, if POST empty |
| 243 | 243 | { |
| 244 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
| 244 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
| 245 | 245 | } |
| 246 | 246 | // clear notification errors |
| 247 | 247 | notifications::errors(true); |
@@ -255,22 +255,22 @@ discard block |
||
| 255 | 255 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 256 | 256 | |
| 257 | 257 | list($button) = @each($content['button']); |
| 258 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 258 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 259 | 259 | unset($content['button']); unset($content['action']); |
| 260 | 260 | |
| 261 | 261 | $view = $content['view']; |
| 262 | 262 | if ($button == 'ical') |
| 263 | 263 | { |
| 264 | - $msg = $this->export($content['id'],true); |
|
| 264 | + $msg = $this->export($content['id'], true); |
|
| 265 | 265 | } |
| 266 | 266 | // delete a recur-exception |
| 267 | 267 | if ($content['recur_exception']['delete_exception']) |
| 268 | 268 | { |
| 269 | 269 | list($date) = each($content['recur_exception']['delete_exception']); |
| 270 | 270 | // eT2 converts time to |
| 271 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 271 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
| 272 | 272 | unset($content['recur_exception']['delete_exception']); |
| 273 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
| 273 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
| 274 | 274 | { |
| 275 | 275 | // propagate the exception to a single event |
| 276 | 276 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
| 281 | 281 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 282 | 282 | $exception['reference'] = $exception['recurrence'] = 0; |
| 283 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
| 283 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
| 284 | 284 | break; |
| 285 | 285 | } |
| 286 | 286 | unset($content['recur_exception'][$key]); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
| 322 | 322 | if ((string)$def_alarm === '') |
| 323 | 323 | { |
| 324 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 324 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 325 | 325 | } |
| 326 | 326 | else |
| 327 | 327 | { |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | unset($event['alarm']['delete_alarm']); |
| 336 | 336 | unset($event['duration']); |
| 337 | 337 | |
| 338 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
| 338 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
| 339 | 339 | { |
| 340 | 340 | // no conversation necessary, event is already in the right format |
| 341 | 341 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
| 356 | 356 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 357 | 357 | { |
| 358 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
| 358 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
| 359 | 359 | } |
| 360 | 360 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
| 361 | 361 | { |
@@ -367,9 +367,9 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $event['participants'] = $event['participant_types'] = array(); |
| 369 | 369 | |
| 370 | - foreach($content['participants'] as $key => $data) |
|
| 370 | + foreach ($content['participants'] as $key => $data) |
|
| 371 | 371 | { |
| 372 | - switch($key) |
|
| 372 | + switch ($key) |
|
| 373 | 373 | { |
| 374 | 374 | case 'delete': // handled in default |
| 375 | 375 | case 'quantity': // handled in new_resource |
@@ -378,20 +378,20 @@ discard block |
||
| 378 | 378 | case 'status_date': |
| 379 | 379 | break; |
| 380 | 380 | case 'participant': |
| 381 | - foreach($data as $participant) |
|
| 381 | + foreach ($data as $participant) |
|
| 382 | 382 | { // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
| 383 | 383 | $email = array(); |
| 384 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
| 384 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
| 385 | 385 | { |
| 386 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
| 387 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 386 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
| 387 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 388 | 388 | { |
| 389 | 389 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
| 390 | 390 | } |
| 391 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
| 391 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
| 392 | 392 | 'email' => $email[2], |
| 393 | 393 | 'email_home' => $email[2], |
| 394 | - ),true,'','','',false,'OR'))) |
|
| 394 | + ), true, '', '', '', false, 'OR'))) |
|
| 395 | 395 | { |
| 396 | 396 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
| 397 | 397 | } |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | else |
| 404 | 404 | { |
| 405 | - if(is_numeric($participant)) |
|
| 405 | + if (is_numeric($participant)) |
|
| 406 | 406 | { |
| 407 | 407 | $uid = 'u'.$participant; |
| 408 | 408 | $id = $participant; |
@@ -411,12 +411,12 @@ discard block |
||
| 411 | 411 | else |
| 412 | 412 | { |
| 413 | 413 | $uid = $participant; |
| 414 | - $id = substr($participant,1); |
|
| 414 | + $id = substr($participant, 1); |
|
| 415 | 415 | $resource = $this->bo->resources[$participant[0]]; |
| 416 | 416 | } |
| 417 | - if(!$this->bo->check_acl_invite($uid)) |
|
| 417 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 418 | 418 | { |
| 419 | - if(!$msg_permission_denied_added) |
|
| 419 | + if (!$msg_permission_denied_added) |
|
| 420 | 420 | { |
| 421 | 421 | $msg .= lang('Permission denied!'); |
| 422 | 422 | $msg_permission_denied_added = true; |
@@ -426,16 +426,15 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | $type = $resource['type']; |
| 428 | 428 | $status = isset($this->bo->resources[$type]['new_status']) ? |
| 429 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
| 430 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 429 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 431 | 430 | |
| 432 | 431 | // Expand mailing lists |
| 433 | - if($type == 'l') |
|
| 432 | + if ($type == 'l') |
|
| 434 | 433 | { |
| 435 | - foreach($this->bo->enum_mailing_list($participant) as $contact) |
|
| 434 | + foreach ($this->bo->enum_mailing_list($participant) as $contact) |
|
| 436 | 435 | { |
| 437 | - $event['participants'][$contact] = $event['participant_types']['c'][substr($contact,1)] = |
|
| 438 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 436 | + $event['participants'][$contact] = $event['participant_types']['c'][substr($contact, 1)] = |
|
| 437 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 439 | 438 | } |
| 440 | 439 | continue; |
| 441 | 440 | } |
@@ -445,8 +444,8 @@ discard block |
||
| 445 | 444 | // todo check real availability = maximum - already booked quantity |
| 446 | 445 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
| 447 | 446 | { |
| 448 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
| 449 | - foreach(array('quantity','resource','role') as $n) |
|
| 447 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
| 448 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 450 | 449 | { |
| 451 | 450 | $event['participants'][$n] = $content['participants'][$n]; |
| 452 | 451 | } |
@@ -455,7 +454,7 @@ discard block |
||
| 455 | 454 | else |
| 456 | 455 | { |
| 457 | 456 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 458 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 457 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 459 | 458 | } |
| 460 | 459 | } |
| 461 | 460 | } |
@@ -469,14 +468,14 @@ discard block |
||
| 469 | 468 | break; |
| 470 | 469 | |
| 471 | 470 | default: // existing participant row |
| 472 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 473 | - foreach(array('uid','status','quantity','role') as $name) |
|
| 471 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 472 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
| 474 | 473 | { |
| 475 | 474 | $$name = $data[$name]; |
| 476 | 475 | } |
| 477 | 476 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
| 478 | 477 | { |
| 479 | - $uid = false; // entry has been deleted |
|
| 478 | + $uid = false; // entry has been deleted |
|
| 480 | 479 | } |
| 481 | 480 | elseif ($uid) |
| 482 | 481 | { |
@@ -487,7 +486,7 @@ discard block |
||
| 487 | 486 | } |
| 488 | 487 | else |
| 489 | 488 | { |
| 490 | - $id = substr($uid,1); |
|
| 489 | + $id = substr($uid, 1); |
|
| 491 | 490 | $type = $uid[0]; |
| 492 | 491 | } |
| 493 | 492 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
@@ -495,19 +494,19 @@ discard block |
||
| 495 | 494 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 496 | 495 | $quantity = $role = null; |
| 497 | 496 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 498 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 497 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 499 | 498 | { |
| 500 | 499 | // Update main window |
| 501 | 500 | $client_updated = $this->update_client($event['id'], $content['edit_single']); |
| 502 | 501 | |
| 503 | 502 | // refreshing the calendar-view with the changed participant-status |
| 504 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 503 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 505 | 504 | { |
| 506 | 505 | $msg = lang('Status for all future scheduled days changed'); |
| 507 | 506 | } |
| 508 | 507 | else |
| 509 | 508 | { |
| 510 | - if(isset($content['edit_single'])) |
|
| 509 | + if (isset($content['edit_single'])) |
|
| 511 | 510 | { |
| 512 | 511 | $msg = lang('Status for this particular day changed'); |
| 513 | 512 | // prevent accidentally creating a real exception afterwards |
@@ -528,7 +527,7 @@ discard block |
||
| 528 | 527 | if ($status == 'R' && $event['alarm']) |
| 529 | 528 | { |
| 530 | 529 | // remove from bo->set_status deleted alarms of rejected users from UI too |
| 531 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
| 530 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
| 532 | 531 | { |
| 533 | 532 | if ((string)$alarm['owner'] === (string)$uid) |
| 534 | 533 | { |
@@ -541,7 +540,7 @@ discard block |
||
| 541 | 540 | if ($uid && $status != 'G') |
| 542 | 541 | { |
| 543 | 542 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 544 | - calendar_so::combine_status($status,$quantity,$role); |
|
| 543 | + calendar_so::combine_status($status, $quantity, $role); |
|
| 545 | 544 | } |
| 546 | 545 | } |
| 547 | 546 | break; |
@@ -560,26 +559,26 @@ discard block |
||
| 560 | 559 | 'tabs' => $content['tabs'], |
| 561 | 560 | 'template' => $content['template'], |
| 562 | 561 | ); |
| 563 | - $noerror=true; |
|
| 562 | + $noerror = true; |
|
| 564 | 563 | |
| 565 | 564 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
| 566 | 565 | |
| 567 | 566 | $ignore_conflicts = $status_reset_to_unknown = false; |
| 568 | 567 | |
| 569 | - switch((string)$button) |
|
| 568 | + switch ((string)$button) |
|
| 570 | 569 | { |
| 571 | 570 | case 'ignore': |
| 572 | 571 | $ignore_conflicts = true; |
| 573 | - $button = $event['button_was']; // save or apply |
|
| 572 | + $button = $event['button_was']; // save or apply |
|
| 574 | 573 | unset($event['button_was']); |
| 575 | 574 | break; |
| 576 | 575 | |
| 577 | 576 | } |
| 578 | 577 | |
| 579 | - switch((string)$button) |
|
| 578 | + switch ((string)$button) |
|
| 580 | 579 | { |
| 581 | 580 | case 'exception': // create an exception in a recuring event |
| 582 | - $msg = $this->_create_exception($event,$preserv); |
|
| 581 | + $msg = $this->_create_exception($event, $preserv); |
|
| 583 | 582 | break; |
| 584 | 583 | |
| 585 | 584 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -590,29 +589,29 @@ discard block |
||
| 590 | 589 | unset($event['recurrence']); |
| 591 | 590 | unset($preserv['recurrence']); |
| 592 | 591 | unset($event['recur_exception']); |
| 593 | - unset($event['edit_single']); // in case it has been set |
|
| 592 | + unset($event['edit_single']); // in case it has been set |
|
| 594 | 593 | unset($event['modified']); |
| 595 | 594 | unset($event['modifier']); |
| 596 | 595 | unset($event['caldav_name']); |
| 597 | - $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner; |
|
| 596 | + $event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD, 0, $this->owner) ? $this->user : $this->owner; |
|
| 598 | 597 | |
| 599 | 598 | // Clear participant stati |
| 600 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 599 | + foreach ($event['participant_types'] as $type => &$participants) |
|
| 601 | 600 | { |
| 602 | - foreach($participants as $id => &$p_response) |
|
| 601 | + foreach ($participants as $id => &$p_response) |
|
| 603 | 602 | { |
| 604 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 603 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
| 605 | 604 | calendar_so::split_status($p_response, $quantity, $role); |
| 606 | 605 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 607 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 608 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 606 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
| 607 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
| 609 | 608 | } |
| 610 | 609 | } |
| 611 | 610 | |
| 612 | 611 | // Copy alarms |
| 613 | 612 | if (is_array($event['alarm'])) |
| 614 | 613 | { |
| 615 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 614 | + foreach ($event['alarm'] as $n => &$alarm) |
|
| 616 | 615 | { |
| 617 | 616 | unset($alarm['id']); |
| 618 | 617 | unset($alarm['cal_id']); |
@@ -622,7 +621,7 @@ discard block |
||
| 622 | 621 | // Get links to be copied |
| 623 | 622 | // With no ID, $content['link_to']['to_id'] is used |
| 624 | 623 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
| 625 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 624 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
| 626 | 625 | { |
| 627 | 626 | if ($link['app'] != Link::VFS_APPNAME) |
| 628 | 627 | { |
@@ -648,7 +647,7 @@ discard block |
||
| 648 | 647 | case 'print': |
| 649 | 648 | case 'apply': |
| 650 | 649 | case 'infolog': |
| 651 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 650 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 652 | 651 | { |
| 653 | 652 | $msg = lang('Permission denied'); |
| 654 | 653 | $button = ''; |
@@ -666,7 +665,7 @@ discard block |
||
| 666 | 665 | $button = ''; |
| 667 | 666 | break; |
| 668 | 667 | } |
| 669 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 668 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 670 | 669 | { |
| 671 | 670 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
| 672 | 671 | $button = ''; |
@@ -696,14 +695,14 @@ discard block |
||
| 696 | 695 | $event['reference'] = $event['id']; |
| 697 | 696 | $event['recurrence'] = $content['edit_single']; |
| 698 | 697 | unset($event['id']); |
| 699 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 698 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 700 | 699 | if (!is_array($conflicts) && $conflicts) |
| 701 | 700 | { |
| 702 | 701 | // now we need to add the original start as recur-execption to the series |
| 703 | 702 | $recur_event = $this->bo->read($event['reference']); |
| 704 | 703 | $recur_event['recur_exception'][] = $content['edit_single']; |
| 705 | 704 | // check if we need to move the alarms, because they are next on that exception |
| 706 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 705 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
| 707 | 706 | { |
| 708 | 707 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
| 709 | 708 | { |
@@ -719,11 +718,11 @@ discard block |
||
| 719 | 718 | } |
| 720 | 719 | } |
| 721 | 720 | } |
| 722 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 723 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 724 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 721 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 722 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 723 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 725 | 724 | |
| 726 | - if(Api\Json\Response::isJSONResponse()) |
|
| 725 | + if (Api\Json\Response::isJSONResponse()) |
|
| 727 | 726 | { |
| 728 | 727 | // Sending null will trigger a removal of the original |
| 729 | 728 | // for that date |
@@ -731,7 +730,7 @@ discard block |
||
| 731 | 730 | } |
| 732 | 731 | |
| 733 | 732 | unset($recur_event); |
| 734 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 733 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 735 | 734 | unset($preserv['edit_single']); |
| 736 | 735 | } |
| 737 | 736 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -762,8 +761,8 @@ discard block |
||
| 762 | 761 | { |
| 763 | 762 | $offset = $off2; |
| 764 | 763 | } |
| 765 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 766 | - if($msg) |
|
| 764 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
| 765 | + if ($msg) |
|
| 767 | 766 | { |
| 768 | 767 | $noerror = false; |
| 769 | 768 | } |
@@ -776,13 +775,13 @@ discard block |
||
| 776 | 775 | $event['whole_day'] != $old_event['whole_day']) |
| 777 | 776 | { |
| 778 | 777 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 779 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 778 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 780 | 779 | { |
| 781 | 780 | $q = $r = null; |
| 782 | - calendar_so::split_status($status,$q,$r); |
|
| 781 | + calendar_so::split_status($status, $q, $r); |
|
| 783 | 782 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 784 | 783 | { |
| 785 | - $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
| 784 | + $preferences = CreateObject('phpgwapi.preferences', $uid); |
|
| 786 | 785 | $part_prefs = $preferences->read_repository(); |
| 787 | 786 | switch ($part_prefs['calendar']['reset_stati']) |
| 788 | 787 | { |
@@ -792,7 +791,7 @@ discard block |
||
| 792 | 791 | if ($sameday) break; |
| 793 | 792 | default: |
| 794 | 793 | $status_reset_to_unknown = true; |
| 795 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 794 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 796 | 795 | // todo: report reset status to user |
| 797 | 796 | } |
| 798 | 797 | } |
@@ -804,43 +803,43 @@ discard block |
||
| 804 | 803 | } |
| 805 | 804 | // Adding participants needs to be done as an edit, in case we |
| 806 | 805 | // have participants visible in seperate calendars |
| 807 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 806 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 808 | 807 | { |
| 809 | 808 | $update_type = 'edit'; |
| 810 | 809 | } |
| 811 | 810 | // Changing category may affect event filtering |
| 812 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 811 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 813 | 812 | { |
| 814 | 813 | $update_type = 'edit'; |
| 815 | 814 | } |
| 816 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 815 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 817 | 816 | unset($event['ignore']); |
| 818 | 817 | } |
| 819 | 818 | if (is_array($conflicts)) |
| 820 | 819 | { |
| 821 | - $event['button_was'] = $button; // remember for ignore |
|
| 822 | - return $this->conflicts($event,$conflicts,$preserv); |
|
| 820 | + $event['button_was'] = $button; // remember for ignore |
|
| 821 | + return $this->conflicts($event, $conflicts, $preserv); |
|
| 823 | 822 | } |
| 824 | 823 | |
| 825 | 824 | // Event spans multiple days, need an edit to make sure they all get updated |
| 826 | 825 | // We could check old date, as removing from days could still be an update |
| 827 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 826 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 828 | 827 | { |
| 829 | 828 | $update_type = 'edit'; |
| 830 | 829 | } |
| 831 | 830 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
| 832 | 831 | if ($messages) |
| 833 | 832 | { |
| 834 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
| 833 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
| 835 | 834 | } |
| 836 | 835 | if ($conflicts === 0) |
| 837 | 836 | { |
| 838 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 839 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 840 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 837 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 838 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 839 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 841 | 840 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 842 | 841 | 'cal_id' => $content['id'], |
| 843 | - ))).'">','</a>'); |
|
| 842 | + ))).'">', '</a>'); |
|
| 844 | 843 | $noerror = false; |
| 845 | 844 | } |
| 846 | 845 | elseif ($conflicts > 0) |
@@ -862,19 +861,19 @@ discard block |
||
| 862 | 861 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
| 863 | 862 | if ($alarm['time'] < $this->bo->now_su) |
| 864 | 863 | { |
| 865 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
| 864 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
| 866 | 865 | { |
| 867 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 866 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 868 | 867 | } |
| 869 | 868 | else |
| 870 | 869 | { |
| 871 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 870 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 872 | 871 | } |
| 873 | 872 | } |
| 874 | 873 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
| 875 | 874 | elseif ($event_time < $event['start']) |
| 876 | 875 | { |
| 877 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 876 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 878 | 877 | } |
| 879 | 878 | if ($alarm) |
| 880 | 879 | { |
@@ -883,9 +882,9 @@ discard block |
||
| 883 | 882 | } |
| 884 | 883 | } |
| 885 | 884 | // attach all future exceptions to the new series |
| 886 | - $events =& $this->bo->search(array( |
|
| 885 | + $events = & $this->bo->search(array( |
|
| 887 | 886 | 'query' => array('cal_uid' => $old_event['uid']), |
| 888 | - 'filter' => 'owner', // return all possible entries |
|
| 887 | + 'filter' => 'owner', // return all possible entries |
|
| 889 | 888 | 'daywise' => false, |
| 890 | 889 | 'date_format' => 'ts', |
| 891 | 890 | )); |
@@ -896,7 +895,7 @@ discard block |
||
| 896 | 895 | $exception['recurrence'] += $offset; |
| 897 | 896 | $exception['reference'] = $event['id']; |
| 898 | 897 | $exception['uid'] = $event['uid']; |
| 899 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
| 898 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
| 900 | 899 | } |
| 901 | 900 | } |
| 902 | 901 | } |
@@ -904,12 +903,12 @@ discard block |
||
| 904 | 903 | $message = lang('Event saved'); |
| 905 | 904 | if ($status_reset_to_unknown) |
| 906 | 905 | { |
| 907 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 906 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 908 | 907 | { |
| 909 | 908 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 910 | 909 | { |
| 911 | - calendar_so::split_status($status,$q,$r); |
|
| 912 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 910 | + calendar_so::split_status($status, $q, $r); |
|
| 911 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 913 | 912 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 914 | 913 | } |
| 915 | 914 | } |
@@ -917,17 +916,17 @@ discard block |
||
| 917 | 916 | } |
| 918 | 917 | |
| 919 | 918 | $response = Api\Json\Response::get(); |
| 920 | - if($response && $update_type != 'delete') |
|
| 919 | + if ($response && $update_type != 'delete') |
|
| 921 | 920 | { |
| 922 | 921 | $client_updated = $this->update_client($event['id']); |
| 923 | 922 | } |
| 924 | 923 | |
| 925 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
| 924 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
| 926 | 925 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
| 927 | 926 | // writing links for new entry, existing ones are handled by the widget itself |
| 928 | 927 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
| 929 | 928 | { |
| 930 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
| 929 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
| 931 | 930 | } |
| 932 | 931 | } |
| 933 | 932 | else |
@@ -937,7 +936,7 @@ discard block |
||
| 937 | 936 | break; |
| 938 | 937 | |
| 939 | 938 | case 'cancel': |
| 940 | - if($content['cancel_needs_refresh']) |
|
| 939 | + if ($content['cancel_needs_refresh']) |
|
| 941 | 940 | { |
| 942 | 941 | Framework::refresh_opener($msg, 'calendar'); |
| 943 | 942 | } |
@@ -975,7 +974,7 @@ discard block |
||
| 975 | 974 | { |
| 976 | 975 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
| 977 | 976 | } |
| 978 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 977 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
| 979 | 978 | { |
| 980 | 979 | $alarm = array( |
| 981 | 980 | 'offset' => $offset, |
@@ -989,13 +988,13 @@ discard block |
||
| 989 | 988 | } |
| 990 | 989 | elseif ($event['id']) // save the alarm immediatly |
| 991 | 990 | { |
| 992 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 991 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
| 993 | 992 | { |
| 994 | 993 | $alarm['id'] = $alarm_id; |
| 995 | 994 | $event['alarm'][$alarm_id] = $alarm; |
| 996 | 995 | |
| 997 | 996 | $msg = lang('Alarm added'); |
| 998 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 997 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
| 999 | 998 | } |
| 1000 | 999 | else |
| 1001 | 1000 | { |
@@ -1004,7 +1003,7 @@ discard block |
||
| 1004 | 1003 | } |
| 1005 | 1004 | else |
| 1006 | 1005 | { |
| 1007 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1006 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1008 | 1007 | $event['alarm'][$alarm['id']] = $alarm; |
| 1009 | 1008 | } |
| 1010 | 1009 | } |
@@ -1021,31 +1020,31 @@ discard block |
||
| 1021 | 1020 | } |
| 1022 | 1021 | // New event, send data before updating so it's there |
| 1023 | 1022 | $response = Api\Json\Response::get(); |
| 1024 | - if($response && !$content['id'] && $event['id']) |
|
| 1023 | + if ($response && !$content['id'] && $event['id']) |
|
| 1025 | 1024 | { |
| 1026 | 1025 | $client_updated = $this->update_client($event['id']); |
| 1027 | 1026 | } |
| 1028 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
| 1027 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
| 1029 | 1028 | { |
| 1030 | 1029 | if ($content['lock_token']) // remove an existing lock |
| 1031 | 1030 | { |
| 1032 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
| 1031 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
| 1033 | 1032 | } |
| 1034 | 1033 | if ($content['no_popup']) |
| 1035 | 1034 | { |
| 1036 | - Egw::redirect_link('/index.php',array( |
|
| 1035 | + Egw::redirect_link('/index.php', array( |
|
| 1037 | 1036 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 1038 | 1037 | 'msg' => $msg, |
| 1039 | 1038 | )); |
| 1040 | 1039 | } |
| 1041 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1040 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1042 | 1041 | { |
| 1043 | - Framework::refresh_opener($msg,'calendar'); |
|
| 1042 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 1044 | 1043 | } |
| 1045 | 1044 | else |
| 1046 | 1045 | { |
| 1047 | 1046 | Framework::refresh_opener($msg, 'calendar', |
| 1048 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
| 1047 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
| 1049 | 1048 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
| 1050 | 1049 | ); |
| 1051 | 1050 | } |
@@ -1053,7 +1052,7 @@ discard block |
||
| 1053 | 1052 | exit(); |
| 1054 | 1053 | } |
| 1055 | 1054 | unset($event['no_notifications']); |
| 1056 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1055 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1057 | 1056 | } |
| 1058 | 1057 | |
| 1059 | 1058 | /** |
@@ -1065,7 +1064,7 @@ discard block |
||
| 1065 | 1064 | * @param array &$preserv |
| 1066 | 1065 | * @return string message that exception was created |
| 1067 | 1066 | */ |
| 1068 | - function _create_exception(&$event,&$preserv) |
|
| 1067 | + function _create_exception(&$event, &$preserv) |
|
| 1069 | 1068 | { |
| 1070 | 1069 | // In some cases where the user makes the first day an exception, actual_date may be missing |
| 1071 | 1070 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1075,17 +1074,17 @@ discard block |
||
| 1075 | 1074 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
| 1076 | 1075 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
| 1077 | 1076 | $event['recur_type'] = MCAL_RECUR_NONE; |
| 1078 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
| 1077 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
| 1079 | 1078 | { |
| 1080 | 1079 | unset($event[$name]); |
| 1081 | 1080 | } |
| 1082 | 1081 | // add all alarms as new alarms to execption |
| 1083 | 1082 | $event['alarm'] = array_values((array)$event['alarm']); |
| 1084 | - foreach($event['alarm'] as &$alarm) |
|
| 1083 | + foreach ($event['alarm'] as &$alarm) |
|
| 1085 | 1084 | { |
| 1086 | 1085 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
| 1087 | 1086 | } |
| 1088 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1087 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1089 | 1088 | { |
| 1090 | 1089 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
| 1091 | 1090 | } |
@@ -1112,14 +1111,14 @@ discard block |
||
| 1112 | 1111 | { |
| 1113 | 1112 | $msg = false; |
| 1114 | 1113 | |
| 1115 | - if(!$as_of_date ) |
|
| 1114 | + if (!$as_of_date) |
|
| 1116 | 1115 | { |
| 1117 | 1116 | $as_of_date = time(); |
| 1118 | 1117 | } |
| 1119 | 1118 | |
| 1120 | 1119 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
| 1121 | 1120 | |
| 1122 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1121 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1123 | 1122 | { |
| 1124 | 1123 | $msg = lang("Error: You can't shift a series from the past!"); |
| 1125 | 1124 | return $msg; |
@@ -1132,11 +1131,11 @@ discard block |
||
| 1132 | 1131 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
| 1133 | 1132 | |
| 1134 | 1133 | // base start-date of new series on actual / clicked date |
| 1135 | - $event['start'] = $as_of_date ; |
|
| 1134 | + $event['start'] = $as_of_date; |
|
| 1136 | 1135 | |
| 1137 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
| 1136 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
| 1138 | 1137 | // Adjust for requested date in the past |
| 1139 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
| 1138 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
| 1140 | 1139 | ) |
| 1141 | 1140 | { |
| 1142 | 1141 | |
@@ -1156,17 +1155,17 @@ discard block |
||
| 1156 | 1155 | $rriter->next_no_exception(); |
| 1157 | 1156 | $occurrence = $rriter->current(); |
| 1158 | 1157 | } |
| 1159 | - while ($rriter->valid() && ( |
|
| 1158 | + while ($rriter->valid() && ( |
|
| 1160 | 1159 | Api\DateTime::to($occurrence, 'ts') <= time() || |
| 1161 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
| 1160 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
| 1162 | 1161 | ) && ($last = $occurrence)); |
| 1163 | 1162 | |
| 1164 | 1163 | |
| 1165 | 1164 | // Make sure as_of_date is still valid, may have to move forward |
| 1166 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
| 1165 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
| 1167 | 1166 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
| 1168 | 1167 | { |
| 1169 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
| 1168 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
| 1170 | 1169 | } |
| 1171 | 1170 | |
| 1172 | 1171 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1174,7 +1173,7 @@ discard block |
||
| 1174 | 1173 | { |
| 1175 | 1174 | $event['end'] = $event['start'] + $duration; |
| 1176 | 1175 | } |
| 1177 | - elseif($event['end'] < $event['start']) |
|
| 1176 | + elseif ($event['end'] < $event['start']) |
|
| 1178 | 1177 | { |
| 1179 | 1178 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
| 1180 | 1179 | } |
@@ -1183,7 +1182,7 @@ discard block |
||
| 1183 | 1182 | $event['participants'] = $old_event['participants']; |
| 1184 | 1183 | foreach ($old_event['recur_exception'] as $key => $exdate) |
| 1185 | 1184 | { |
| 1186 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
| 1185 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
| 1187 | 1186 | { |
| 1188 | 1187 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
| 1189 | 1188 | unset($old_event['recur_exception'][$key]); |
@@ -1197,18 +1196,18 @@ discard block |
||
| 1197 | 1196 | } |
| 1198 | 1197 | $last->setTime(0, 0, 0); |
| 1199 | 1198 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
| 1200 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
| 1199 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
| 1201 | 1200 | { |
| 1202 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1203 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 1204 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 1201 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1202 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 1203 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 1205 | 1204 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 1206 | 1205 | 'cal_id' => $event['id'], |
| 1207 | - ))).'">','</a>'); |
|
| 1206 | + ))).'">', '</a>'); |
|
| 1208 | 1207 | $event = $orig_event; |
| 1209 | 1208 | } |
| 1210 | 1209 | } |
| 1211 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 1210 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
| 1212 | 1211 | return $msg; |
| 1213 | 1212 | } |
| 1214 | 1213 | |
@@ -1219,11 +1218,11 @@ discard block |
||
| 1219 | 1218 | * @param boolean $added |
| 1220 | 1219 | * @return string javascript window.open command |
| 1221 | 1220 | */ |
| 1222 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
| 1221 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
| 1223 | 1222 | { |
| 1224 | 1223 | $to = array(); |
| 1225 | 1224 | |
| 1226 | - foreach($event['participants'] as $uid => $status) |
|
| 1225 | + foreach ($event['participants'] as $uid => $status) |
|
| 1227 | 1226 | { |
| 1228 | 1227 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1229 | 1228 | if (empty($status)) continue; |
@@ -1232,35 +1231,35 @@ discard block |
||
| 1232 | 1231 | |
| 1233 | 1232 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1234 | 1233 | { |
| 1235 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1234 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
| 1236 | 1235 | |
| 1237 | 1236 | $lid = $firstname = $lastname = null; |
| 1238 | - $GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname); |
|
| 1237 | + $GLOBALS['egw']->accounts->get_account_name($status['uid'], $lid, $firstname, $lastname); |
|
| 1239 | 1238 | |
| 1240 | 1239 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1241 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1240 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
| 1242 | 1241 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1243 | 1242 | } |
| 1244 | 1243 | elseif ($uid < 0) |
| 1245 | 1244 | { |
| 1246 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
| 1245 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
| 1247 | 1246 | { |
| 1248 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1247 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
| 1249 | 1248 | |
| 1250 | - $GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname); |
|
| 1249 | + $GLOBALS['egw']->accounts->get_account_name($uid, $lid, $firstname, $lastname); |
|
| 1251 | 1250 | |
| 1252 | 1251 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1253 | 1252 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1254 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1253 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1255 | 1254 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1256 | 1255 | } |
| 1257 | 1256 | } |
| 1258 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1257 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1259 | 1258 | { |
| 1260 | 1259 | $to[] = $info['email']; |
| 1261 | 1260 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1262 | 1261 | } |
| 1263 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1262 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1264 | 1263 | { |
| 1265 | 1264 | $to[] = $info['email']; |
| 1266 | 1265 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1269,7 +1268,7 @@ discard block |
||
| 1269 | 1268 | // prefer event description over standard notification text |
| 1270 | 1269 | if (empty($event['description'])) |
| 1271 | 1270 | { |
| 1272 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1271 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1273 | 1272 | } |
| 1274 | 1273 | else |
| 1275 | 1274 | { |
@@ -1284,12 +1283,12 @@ discard block |
||
| 1284 | 1283 | $boical = new calendar_ical(); |
| 1285 | 1284 | // we need to pass $event[id] so iCal class reads event again, |
| 1286 | 1285 | // as event is in user TZ, but iCal class expects server TZ! |
| 1287 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
| 1286 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
| 1288 | 1287 | |
| 1289 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
| 1290 | - if(($f = fopen($ics_file,'w'))) |
|
| 1288 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
| 1289 | + if (($f = fopen($ics_file, 'w'))) |
|
| 1291 | 1290 | { |
| 1292 | - fwrite($f,$ics); |
|
| 1291 | + fwrite($f, $ics); |
|
| 1293 | 1292 | fclose($f); |
| 1294 | 1293 | } |
| 1295 | 1294 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1301,7 +1300,7 @@ discard block |
||
| 1301 | 1300 | 'preset[body]' => $body, |
| 1302 | 1301 | 'preset[name]' => 'event.ics', |
| 1303 | 1302 | 'preset[file]' => $ics_file, |
| 1304 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
| 1303 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
| 1305 | 1304 | 'preset[size]' => filesize($ics_file), |
| 1306 | 1305 | ); |
| 1307 | 1306 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
@@ -1357,7 +1356,7 @@ discard block |
||
| 1357 | 1356 | * @param mixed $link_to_id ='' from or for the link-widget |
| 1358 | 1357 | * @param string $msg_type =null default automatic detect, if it contains "error" |
| 1359 | 1358 | */ |
| 1360 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
| 1359 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
| 1361 | 1360 | { |
| 1362 | 1361 | $sel_options = array( |
| 1363 | 1362 | 'recur_type' => &$this->bo->recur_types, |
@@ -1381,8 +1380,8 @@ discard block |
||
| 1381 | 1380 | 'no_popup' => isset($_GET['no_popup']), |
| 1382 | 1381 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
| 1383 | 1382 | ); |
| 1384 | - $cal_id = (int) $_GET['cal_id']; |
|
| 1385 | - if($_GET['action']) |
|
| 1383 | + $cal_id = (int)$_GET['cal_id']; |
|
| 1384 | + if ($_GET['action']) |
|
| 1386 | 1385 | { |
| 1387 | 1386 | $event = $this->bo->read($cal_id); |
| 1388 | 1387 | $event['action'] = $_GET['action']; |
@@ -1400,14 +1399,14 @@ discard block |
||
| 1400 | 1399 | { |
| 1401 | 1400 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
| 1402 | 1401 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
| 1403 | - $event =& $this->default_add_event(); |
|
| 1402 | + $event = & $this->default_add_event(); |
|
| 1404 | 1403 | } |
| 1405 | 1404 | if (!empty($_GET['ical_data']) && |
| 1406 | 1405 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
| 1407 | 1406 | { |
| 1408 | 1407 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
| 1409 | 1408 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
| 1410 | - $event =& $this->default_add_event(); |
|
| 1409 | + $event = & $this->default_add_event(); |
|
| 1411 | 1410 | } |
| 1412 | 1411 | if (!empty($_GET['ical'])) |
| 1413 | 1412 | { |
@@ -1416,14 +1415,14 @@ discard block |
||
| 1416 | 1415 | { |
| 1417 | 1416 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
| 1418 | 1417 | $msg = lang('Error: importing the iCal'); |
| 1419 | - $event =& $this->default_add_event(); |
|
| 1418 | + $event = & $this->default_add_event(); |
|
| 1420 | 1419 | } |
| 1421 | 1420 | else |
| 1422 | 1421 | { |
| 1423 | 1422 | if (count($events) > 1) |
| 1424 | 1423 | { |
| 1425 | 1424 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
| 1426 | - $msg_type = 'notice'; // no not hide automatic |
|
| 1425 | + $msg_type = 'notice'; // no not hide automatic |
|
| 1427 | 1426 | } |
| 1428 | 1427 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
| 1429 | 1428 | $this->bo->db2data($events, 'ts'); |
@@ -1436,7 +1435,7 @@ discard block |
||
| 1436 | 1435 | else |
| 1437 | 1436 | { |
| 1438 | 1437 | $event['participant_types'] = array(); |
| 1439 | - foreach($event['participants'] as $uid => $status) |
|
| 1438 | + foreach ($event['participants'] as $uid => $status) |
|
| 1440 | 1439 | { |
| 1441 | 1440 | $user_type = $user_id = null; |
| 1442 | 1441 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1457,15 +1456,15 @@ discard block |
||
| 1457 | 1456 | } |
| 1458 | 1457 | else |
| 1459 | 1458 | { |
| 1460 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
| 1459 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
| 1461 | 1460 | exit(); |
| 1462 | 1461 | } |
| 1463 | 1462 | } |
| 1464 | - $event =& $this->default_add_event(); |
|
| 1463 | + $event = & $this->default_add_event(); |
|
| 1465 | 1464 | } |
| 1466 | 1465 | else |
| 1467 | 1466 | { |
| 1468 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1467 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1469 | 1468 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1470 | 1469 | { |
| 1471 | 1470 | if (empty($event['whole_day'])) |
@@ -1478,10 +1477,10 @@ discard block |
||
| 1478 | 1477 | $date->setUser(); |
| 1479 | 1478 | } |
| 1480 | 1479 | $event = $this->bo->read($cal_id, $date, true); |
| 1481 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1480 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1482 | 1481 | if ($_GET['exception']) |
| 1483 | 1482 | { |
| 1484 | - $msg = $this->_create_exception($event,$preserv); |
|
| 1483 | + $msg = $this->_create_exception($event, $preserv); |
|
| 1485 | 1484 | } |
| 1486 | 1485 | else |
| 1487 | 1486 | { |
@@ -1490,9 +1489,9 @@ discard block |
||
| 1490 | 1489 | } |
| 1491 | 1490 | } |
| 1492 | 1491 | // set new start and end if given by $_GET |
| 1493 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1494 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1495 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1492 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
| 1493 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
| 1494 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1496 | 1495 | // check if the event is the whole day |
| 1497 | 1496 | $start = $this->bo->date2array($event['start']); |
| 1498 | 1497 | $end = $this->bo->date2array($event['end']); |
@@ -1502,30 +1501,30 @@ discard block |
||
| 1502 | 1501 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
| 1503 | 1502 | { |
| 1504 | 1503 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
| 1505 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1504 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1506 | 1505 | { |
| 1507 | 1506 | $link_id = $link_ids[$n]; |
| 1508 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1507 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
| 1509 | 1508 | { |
| 1510 | 1509 | continue; |
| 1511 | 1510 | } |
| 1512 | - if(!$n) |
|
| 1511 | + if (!$n) |
|
| 1513 | 1512 | { |
| 1514 | - $event['title'] = Link::title($link_app,$link_id); |
|
| 1513 | + $event['title'] = Link::title($link_app, $link_id); |
|
| 1515 | 1514 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
| 1516 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
| 1515 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
| 1517 | 1516 | { |
| 1518 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
| 1517 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
| 1519 | 1518 | { |
| 1520 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1519 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
| 1521 | 1520 | } |
| 1522 | 1521 | unset($set['link_app']); |
| 1523 | 1522 | unset($set['link_id']); |
| 1524 | 1523 | |
| 1525 | - $event = array_merge($event,$set); |
|
| 1524 | + $event = array_merge($event, $set); |
|
| 1526 | 1525 | } |
| 1527 | 1526 | } |
| 1528 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
| 1527 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
| 1529 | 1528 | } |
| 1530 | 1529 | } |
| 1531 | 1530 | } |
@@ -1535,44 +1534,44 @@ discard block |
||
| 1535 | 1534 | { |
| 1536 | 1535 | $etpl->read($preserv['template'] = 'calendar.edit'); |
| 1537 | 1536 | } |
| 1538 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
| 1537 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
| 1539 | 1538 | //echo "view=$view, event="; _debug_array($event); |
| 1540 | 1539 | // shared locking of entries to edit |
| 1541 | 1540 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
| 1542 | 1541 | { |
| 1543 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
| 1542 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
| 1544 | 1543 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1545 | 1544 | |
| 1546 | 1545 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
| 1547 | 1546 | { |
| 1548 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
| 1547 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
| 1549 | 1548 | } |
| 1550 | 1549 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1551 | 1550 | { |
| 1552 | 1551 | $msg .= ' '.lang('This entry is currently opened by %1!', |
| 1553 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
| 1552 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
| 1554 | 1553 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
| 1555 | 1554 | } |
| 1556 | - elseif($lock) |
|
| 1555 | + elseif ($lock) |
|
| 1557 | 1556 | { |
| 1558 | 1557 | $preserv['lock_token'] = $lock['token']; |
| 1559 | 1558 | } |
| 1560 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
| 1559 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
| 1561 | 1560 | { |
| 1562 | 1561 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
| 1563 | 1562 | } |
| 1564 | 1563 | else |
| 1565 | 1564 | { |
| 1566 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1565 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1567 | 1566 | $view = true; |
| 1568 | 1567 | } |
| 1569 | 1568 | } |
| 1570 | - $content = array_merge($event,array( |
|
| 1569 | + $content = array_merge($event, array( |
|
| 1571 | 1570 | 'link_to' => array( |
| 1572 | 1571 | 'to_id' => $link_to_id, |
| 1573 | 1572 | 'to_app' => 'calendar', |
| 1574 | 1573 | ), |
| 1575 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1574 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1576 | 1575 | 'tabs' => $preserv['tabs'], |
| 1577 | 1576 | 'view' => $view, |
| 1578 | 1577 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1584,11 +1583,11 @@ discard block |
||
| 1584 | 1583 | $row = 3; |
| 1585 | 1584 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1586 | 1585 | // preserve some ui elements, if set eg. under error-conditions |
| 1587 | - foreach(array('quantity','resource','role') as $n) |
|
| 1586 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 1588 | 1587 | { |
| 1589 | 1588 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
| 1590 | 1589 | } |
| 1591 | - foreach($event['participant_types'] as $type => $participants) |
|
| 1590 | + foreach ($event['participant_types'] as $type => $participants) |
|
| 1592 | 1591 | { |
| 1593 | 1592 | $name = 'accounts'; |
| 1594 | 1593 | if (isset($this->bo->resources[$type])) |
@@ -1597,17 +1596,17 @@ discard block |
||
| 1597 | 1596 | } |
| 1598 | 1597 | // sort participants (in there group/app) by title |
| 1599 | 1598 | uksort($participants, array($this, 'uid_title_cmp')); |
| 1600 | - foreach($participants as $id => $status) |
|
| 1599 | + foreach ($participants as $id => $status) |
|
| 1601 | 1600 | { |
| 1602 | 1601 | $uid = $type == 'u' ? $id : $type.$id; |
| 1603 | 1602 | $quantity = $role = null; |
| 1604 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1603 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1605 | 1604 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1606 | 1605 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
| 1607 | 1606 | 'uid' => $uid, |
| 1608 | 1607 | 'status' => $status, |
| 1609 | 1608 | 'old_status' => $status, |
| 1610 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1609 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1611 | 1610 | 'role' => $role, |
| 1612 | 1611 | ); |
| 1613 | 1612 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1616,33 +1615,33 @@ discard block |
||
| 1616 | 1615 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
| 1617 | 1616 | } |
| 1618 | 1617 | // allow third party apps to use categories for roles |
| 1619 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
| 1618 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
| 1620 | 1619 | { |
| 1621 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
| 1620 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
| 1622 | 1621 | } |
| 1623 | 1622 | else |
| 1624 | 1623 | { |
| 1625 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
| 1624 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
| 1626 | 1625 | } |
| 1627 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
| 1626 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
| 1628 | 1627 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1629 | 1628 | |
| 1630 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
| 1629 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
| 1631 | 1630 | $readonlys['participants'][$row]['status'] = $no_status; |
| 1632 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1631 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1633 | 1632 | $readonlys['participants']['delete'][$uid] = true; |
| 1634 | 1633 | // todo: make the participants available as links with email as title |
| 1635 | 1634 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1636 | 1635 | // enumerate group-invitations, so people can accept/reject them |
| 1637 | 1636 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
| 1638 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
| 1637 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
| 1639 | 1638 | { |
| 1640 | 1639 | $sel_options['status']['G'] = lang('Select one'); |
| 1641 | 1640 | // sort members by title |
| 1642 | 1641 | usort($members, array($this, 'uid_title_cmp')); |
| 1643 | - foreach($members as $member) |
|
| 1642 | + foreach ($members as $member) |
|
| 1644 | 1643 | { |
| 1645 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
| 1644 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
| 1646 | 1645 | { |
| 1647 | 1646 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1648 | 1647 | 'app' => 'Group invitation', |
@@ -1651,7 +1650,7 @@ discard block |
||
| 1651 | 1650 | ); |
| 1652 | 1651 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
| 1653 | 1652 | // read access is enough to invite participants, but you need edit rights to change status |
| 1654 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
| 1653 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
| 1655 | 1654 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
| 1656 | 1655 | } |
| 1657 | 1656 | } |
@@ -1659,43 +1658,43 @@ discard block |
||
| 1659 | 1658 | } |
| 1660 | 1659 | // resouces / apps we shedule, atm. resources and addressbook |
| 1661 | 1660 | $content['participants']['cal_resources'] = ''; |
| 1662 | - foreach($this->bo->resources as $data) |
|
| 1661 | + foreach ($this->bo->resources as $data) |
|
| 1663 | 1662 | { |
| 1664 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1663 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1665 | 1664 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1666 | 1665 | } |
| 1667 | 1666 | } |
| 1668 | 1667 | $content['participants']['status_date'] = $preserv['actual_date']; |
| 1669 | - $preserved = array_merge($preserv,$content); |
|
| 1668 | + $preserved = array_merge($preserv, $content); |
|
| 1670 | 1669 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
| 1671 | 1670 | if ($event['alarm']) |
| 1672 | 1671 | { |
| 1673 | 1672 | // makes keys of the alarm-array starting with 1 |
| 1674 | 1673 | $content['alarm'] = array(false); |
| 1675 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
| 1674 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
| 1676 | 1675 | { |
| 1677 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
| 1676 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
| 1678 | 1677 | { |
| 1679 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1678 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1680 | 1679 | } |
| 1681 | - $alarm['all'] = (int) $alarm['all']; |
|
| 1680 | + $alarm['all'] = (int)$alarm['all']; |
|
| 1682 | 1681 | $after = false; |
| 1683 | - if($alarm['offset'] < 0) |
|
| 1682 | + if ($alarm['offset'] < 0) |
|
| 1684 | 1683 | { |
| 1685 | 1684 | $after = true; |
| 1686 | 1685 | $alarm['offset'] = -1 * $alarm['offset']; |
| 1687 | 1686 | } |
| 1688 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
| 1689 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1690 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
| 1687 | + $days = (int)($alarm['offset'] / DAY_s); |
|
| 1688 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1689 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
| 1691 | 1690 | $label = array(); |
| 1692 | 1691 | if ($days) $label[] = $days.' '.lang('days'); |
| 1693 | 1692 | if ($hours) $label[] = $hours.' '.lang('hours'); |
| 1694 | 1693 | if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
| 1695 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
| 1694 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
| 1696 | 1695 | $content['alarm'][] = $alarm; |
| 1697 | 1696 | |
| 1698 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
| 1697 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
| 1699 | 1698 | } |
| 1700 | 1699 | if (count($content['alarm']) == 1) |
| 1701 | 1700 | { |
@@ -1710,20 +1709,20 @@ discard block |
||
| 1710 | 1709 | |
| 1711 | 1710 | if ($view) |
| 1712 | 1711 | { |
| 1713 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1712 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1714 | 1713 | $readonlys['button[cancel]'] = $readonlys['action'] = |
| 1715 | 1714 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
| 1716 | 1715 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
| 1717 | 1716 | |
| 1718 | 1717 | $content['participants']['no_add'] = true; |
| 1719 | 1718 | |
| 1720 | - if(!$event['whole_day']) |
|
| 1719 | + if (!$event['whole_day']) |
|
| 1721 | 1720 | { |
| 1722 | 1721 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
| 1723 | 1722 | } |
| 1724 | 1723 | |
| 1725 | 1724 | // respect category permissions |
| 1726 | - if(!empty($event['category'])) |
|
| 1725 | + if (!empty($event['category'])) |
|
| 1727 | 1726 | { |
| 1728 | 1727 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
| 1729 | 1728 | } |
@@ -1734,7 +1733,7 @@ discard block |
||
| 1734 | 1733 | |
| 1735 | 1734 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1736 | 1735 | { |
| 1737 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1736 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1738 | 1737 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
| 1739 | 1738 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
| 1740 | 1739 | } |
@@ -1744,9 +1743,9 @@ discard block |
||
| 1744 | 1743 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
| 1745 | 1744 | } |
| 1746 | 1745 | } |
| 1747 | - if($content['category'] && !is_array($content['category'])) |
|
| 1746 | + if ($content['category'] && !is_array($content['category'])) |
|
| 1748 | 1747 | { |
| 1749 | - $content['category'] = explode(',',$event['category']); |
|
| 1748 | + $content['category'] = explode(',', $event['category']); |
|
| 1750 | 1749 | } |
| 1751 | 1750 | // disabling the custom fields tab, if there are none |
| 1752 | 1751 | $readonlys['tabs'] = array( |
@@ -1763,13 +1762,13 @@ discard block |
||
| 1763 | 1762 | { |
| 1764 | 1763 | $readonlys['action'] = true; |
| 1765 | 1764 | } |
| 1766 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
| 1765 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
| 1767 | 1766 | { |
| 1768 | 1767 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1769 | 1768 | } |
| 1770 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
| 1769 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
| 1771 | 1770 | |
| 1772 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1771 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1773 | 1772 | { |
| 1774 | 1773 | $sel_options['owner'][0] = lang('All participants'); |
| 1775 | 1774 | } |
@@ -1777,25 +1776,25 @@ discard block |
||
| 1777 | 1776 | { |
| 1778 | 1777 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
| 1779 | 1778 | } |
| 1780 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
| 1779 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
| 1781 | 1780 | { |
| 1782 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
| 1781 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
| 1783 | 1782 | { |
| 1784 | 1783 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
| 1785 | 1784 | } |
| 1786 | 1785 | } |
| 1787 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1786 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1788 | 1787 | if (!$event['id']) |
| 1789 | 1788 | { |
| 1790 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
| 1789 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
| 1791 | 1790 | } |
| 1792 | 1791 | if ($preserved['no_popup']) |
| 1793 | 1792 | { |
| 1794 | - $etpl->set_cell_attribute('button[cancel]','onclick',''); |
|
| 1793 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', ''); |
|
| 1795 | 1794 | } |
| 1796 | 1795 | |
| 1797 | 1796 | // Allow admins to restore deleted events |
| 1798 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
| 1797 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
| 1799 | 1798 | { |
| 1800 | 1799 | $content['deleted'] = $preserved['deleted'] = null; |
| 1801 | 1800 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1807,7 +1806,7 @@ discard block |
||
| 1807 | 1806 | // Setup history tab |
| 1808 | 1807 | $this->setup_history($content, $sel_options); |
| 1809 | 1808 | |
| 1810 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
| 1809 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
| 1811 | 1810 | . (!$event['id'] ? lang('Add') |
| 1812 | 1811 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
| 1813 | 1812 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1817,15 +1816,15 @@ discard block |
||
| 1817 | 1816 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
| 1818 | 1817 | |
| 1819 | 1818 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1820 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1819 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1821 | 1820 | { |
| 1822 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1821 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1823 | 1822 | $content['button']['save'] = true; |
| 1824 | - $this->process_edit(array_merge($content,$preserved)); |
|
| 1823 | + $this->process_edit(array_merge($content, $preserved)); |
|
| 1825 | 1824 | } |
| 1826 | 1825 | else |
| 1827 | 1826 | { |
| 1828 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
| 1827 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
| 1829 | 1828 | } |
| 1830 | 1829 | } |
| 1831 | 1830 | |
@@ -1835,14 +1834,14 @@ discard block |
||
| 1835 | 1834 | * @param int $id |
| 1836 | 1835 | * @param string $token |
| 1837 | 1836 | */ |
| 1838 | - function ajax_unlock($id,$token) |
|
| 1837 | + function ajax_unlock($id, $token) |
|
| 1839 | 1838 | { |
| 1840 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
| 1839 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
| 1841 | 1840 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1842 | 1841 | |
| 1843 | 1842 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
| 1844 | 1843 | { |
| 1845 | - Vfs::unlock($lock_path,$token,false); |
|
| 1844 | + Vfs::unlock($lock_path, $token, false); |
|
| 1846 | 1845 | } |
| 1847 | 1846 | } |
| 1848 | 1847 | |
@@ -1854,17 +1853,17 @@ discard block |
||
| 1854 | 1853 | * are called by new mail-app; and we intend to use the stuff passed on by session |
| 1855 | 1854 | * @param string $msg = null |
| 1856 | 1855 | */ |
| 1857 | - function meeting(array $event=null, $msg=null) |
|
| 1856 | + function meeting(array $event = null, $msg = null) |
|
| 1858 | 1857 | { |
| 1859 | 1858 | $user = $GLOBALS['egw_info']['user']['account_id']; |
| 1860 | 1859 | $readonlys['button[apply]'] = true; |
| 1861 | - $_usesession=!is_array($event); |
|
| 1860 | + $_usesession = !is_array($event); |
|
| 1862 | 1861 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
| 1863 | 1862 | //are called by new mail-app; and we intend to use the stuff passed on by session |
| 1864 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
| 1863 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
| 1865 | 1864 | { |
| 1866 | - $event=null; // set to null |
|
| 1867 | - $_usesession=true; // trigger session read |
|
| 1865 | + $event = null; // set to null |
|
| 1866 | + $_usesession = true; // trigger session read |
|
| 1868 | 1867 | } |
| 1869 | 1868 | if (!is_array($event)) |
| 1870 | 1869 | { |
@@ -1893,7 +1892,7 @@ discard block |
||
| 1893 | 1892 | |
| 1894 | 1893 | if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted']) |
| 1895 | 1894 | { |
| 1896 | - switch(strtolower($ical_method)) |
|
| 1895 | + switch (strtolower($ical_method)) |
|
| 1897 | 1896 | { |
| 1898 | 1897 | case 'reply': |
| 1899 | 1898 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -1947,19 +1946,19 @@ discard block |
||
| 1947 | 1946 | } |
| 1948 | 1947 | else // event not in calendar |
| 1949 | 1948 | { |
| 1950 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 1949 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 1951 | 1950 | } |
| 1952 | 1951 | $event['participant_types'] = array(); |
| 1953 | - foreach($event['participants'] as $uid => $status) |
|
| 1952 | + foreach ($event['participants'] as $uid => $status) |
|
| 1954 | 1953 | { |
| 1955 | 1954 | $user_type = $user_id = null; |
| 1956 | 1955 | calendar_so::split_user($uid, $user_type, $user_id); |
| 1957 | 1956 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
| 1958 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 1957 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 1959 | 1958 | } |
| 1960 | 1959 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
| 1961 | 1960 | $event['recure'] = $this->bo->recure2string($event); |
| 1962 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
| 1961 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 1963 | 1962 | |
| 1964 | 1963 | // ignore events in the past (for recurring events check enddate!) |
| 1965 | 1964 | if ($this->bo->date2ts($event['start']) < $this->bo->now_su && |
@@ -1979,23 +1978,23 @@ discard block |
||
| 1979 | 1978 | // clear notification errors |
| 1980 | 1979 | notifications::errors(true); |
| 1981 | 1980 | |
| 1982 | - switch($button) |
|
| 1981 | + switch ($button) |
|
| 1983 | 1982 | { |
| 1984 | 1983 | case 'reject': |
| 1985 | 1984 | if (!$event['id']) |
| 1986 | 1985 | { |
| 1987 | 1986 | // send reply to organizer |
| 1988 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
| 1989 | - break; // no need to store rejected event |
|
| 1987 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
| 1988 | + break; // no need to store rejected event |
|
| 1990 | 1989 | } |
| 1991 | 1990 | // fall-through |
| 1992 | 1991 | case 'accept': |
| 1993 | 1992 | case 'tentativ': |
| 1994 | - $status = strtoupper($button[0]); // A, R or T |
|
| 1993 | + $status = strtoupper($button[0]); // A, R or T |
|
| 1995 | 1994 | if (!$event['id']) |
| 1996 | 1995 | { |
| 1997 | 1996 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
| 1998 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 1997 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 1999 | 1998 | { |
| 2000 | 1999 | // --> make organize a participant with role chair and current user the owner |
| 2001 | 2000 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2003,7 +2002,7 @@ discard block |
||
| 2003 | 2002 | $event['owner'] = $this->user; |
| 2004 | 2003 | } |
| 2005 | 2004 | // store event without notifications! |
| 2006 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
| 2005 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
| 2007 | 2006 | { |
| 2008 | 2007 | $msg[] = lang('Event saved'); |
| 2009 | 2008 | } |
@@ -2041,7 +2040,7 @@ discard block |
||
| 2041 | 2040 | Framework::message(implode("\n", (array)$msg)); |
| 2042 | 2041 | $readonlys['button[edit]'] = !$event['id']; |
| 2043 | 2042 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
| 2044 | - switch(strtolower($ical_method)) |
|
| 2043 | + switch (strtolower($ical_method)) |
|
| 2045 | 2044 | { |
| 2046 | 2045 | case 'reply': |
| 2047 | 2046 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2065,37 +2064,37 @@ discard block |
||
| 2065 | 2064 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
| 2066 | 2065 | * @param array $preserv data to preserv |
| 2067 | 2066 | */ |
| 2068 | - function conflicts($event,$conflicts,$preserv) |
|
| 2067 | + function conflicts($event, $conflicts, $preserv) |
|
| 2069 | 2068 | { |
| 2070 | 2069 | $etpl = new Etemplate('calendar.conflicts'); |
| 2071 | 2070 | $allConflicts = array(); |
| 2072 | 2071 | |
| 2073 | - foreach($conflicts as $k => $conflict) |
|
| 2072 | + foreach ($conflicts as $k => $conflict) |
|
| 2074 | 2073 | { |
| 2075 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
| 2074 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
| 2076 | 2075 | |
| 2077 | 2076 | $conflicts[$k] += array( |
| 2078 | 2077 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
| 2079 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
| 2080 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
| 2081 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
| 2082 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
| 2083 | - ),true,true)), // show group invitations too |
|
| 2078 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
| 2079 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
| 2080 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
| 2081 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
| 2082 | + ), true, true)), // show group invitations too |
|
| 2084 | 2083 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
| 2085 | 2084 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
| 2086 | 2085 | ); |
| 2087 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 2086 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 2088 | 2087 | } |
| 2089 | 2088 | $content = $event + array( |
| 2090 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2089 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2091 | 2090 | ); |
| 2092 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
| 2091 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
| 2093 | 2092 | $resources_config = Api\Config::read('resources'); |
| 2094 | 2093 | $readonlys = array(); |
| 2095 | 2094 | |
| 2096 | 2095 | foreach (array_keys($allConflicts) as $pId) |
| 2097 | 2096 | { |
| 2098 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2097 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
| 2099 | 2098 | { |
| 2100 | 2099 | |
| 2101 | 2100 | switch ($resources_config['ignoreconflicts']) |
@@ -2115,7 +2114,7 @@ discard block |
||
| 2115 | 2114 | } |
| 2116 | 2115 | } |
| 2117 | 2116 | } |
| 2118 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
| 2117 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
| 2119 | 2118 | } |
| 2120 | 2119 | |
| 2121 | 2120 | /** |
@@ -2133,7 +2132,7 @@ discard block |
||
| 2133 | 2132 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
| 2134 | 2133 | |
| 2135 | 2134 | // convert start/end date-time values to timestamps |
| 2136 | - foreach(array('start', 'end') as $name) |
|
| 2135 | + foreach (array('start', 'end') as $name) |
|
| 2137 | 2136 | { |
| 2138 | 2137 | if (!empty($edit_content[$name])) |
| 2139 | 2138 | { |
@@ -2163,7 +2162,7 @@ discard block |
||
| 2163 | 2162 | 'recur_type' => $edit_content['recur_type'], |
| 2164 | 2163 | 'participants' => array(), |
| 2165 | 2164 | ); |
| 2166 | - foreach($edit_content['participants'] as $key => $data) |
|
| 2165 | + foreach ($edit_content['participants'] as $key => $data) |
|
| 2167 | 2166 | { |
| 2168 | 2167 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
| 2169 | 2168 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2178,21 +2177,21 @@ discard block |
||
| 2178 | 2177 | // default search parameters |
| 2179 | 2178 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
| 2180 | 2179 | $content['end_time'] = $this->cal_prefs['workdayends']; |
| 2181 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
| 2180 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
| 2182 | 2181 | { |
| 2183 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2182 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2184 | 2183 | } |
| 2185 | 2184 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
| 2186 | 2185 | |
| 2187 | 2186 | $content['search_window'] = 7 * DAY_s; |
| 2188 | 2187 | |
| 2189 | 2188 | // store content in session |
| 2190 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
| 2189 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
| 2191 | 2190 | |
| 2192 | 2191 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
| 2193 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
| 2192 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
| 2194 | 2193 | |
| 2195 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
| 2194 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
| 2196 | 2195 | |
| 2197 | 2196 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
| 2198 | 2197 | |
@@ -2215,26 +2214,26 @@ discard block |
||
| 2215 | 2214 | { |
| 2216 | 2215 | $etpl = new Etemplate('calendar.freetimesearch'); |
| 2217 | 2216 | $sel_options['search_window'] = array( |
| 2218 | - 7*DAY_s => lang('one week'), |
|
| 2219 | - 14*DAY_s => lang('two weeks'), |
|
| 2220 | - 31*DAY_s => lang('one month'), |
|
| 2221 | - 92*DAY_s => lang('three month'), |
|
| 2222 | - 365*DAY_s => lang('one year'), |
|
| 2217 | + 7 * DAY_s => lang('one week'), |
|
| 2218 | + 14 * DAY_s => lang('two weeks'), |
|
| 2219 | + 31 * DAY_s => lang('one month'), |
|
| 2220 | + 92 * DAY_s => lang('three month'), |
|
| 2221 | + 365 * DAY_s => lang('one year'), |
|
| 2223 | 2222 | ); |
| 2224 | 2223 | if (!is_array($content)) |
| 2225 | 2224 | { |
| 2226 | 2225 | // get content from session (and delete it immediatly) |
| 2227 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2228 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2226 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2227 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2229 | 2228 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
| 2230 | 2229 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
| 2231 | 2230 | $sTime = $content['start_time']; |
| 2232 | 2231 | $eTime = $content['end_time']; |
| 2233 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
| 2234 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
| 2232 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
| 2233 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
| 2235 | 2234 | |
| 2236 | 2235 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
| 2237 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
| 2236 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
| 2238 | 2237 | { |
| 2239 | 2238 | if ($window > $content['duration']) |
| 2240 | 2239 | { |
@@ -2261,19 +2260,19 @@ discard block |
||
| 2261 | 2260 | { |
| 2262 | 2261 | $content['msg'] .= lang('Only the initial date of that recuring event is checked!'); |
| 2263 | 2262 | } |
| 2264 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
| 2265 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
| 2263 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
| 2264 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
| 2266 | 2265 | |
| 2267 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
| 2266 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
| 2268 | 2267 | |
| 2269 | 2268 | $sel_options['duration'] = $this->durations; |
| 2270 | 2269 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
| 2271 | 2270 | |
| 2272 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
| 2271 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
| 2273 | 2272 | 'participants' => $content['participants'], |
| 2274 | 2273 | 'cal_id' => $content['cal_id'], |
| 2275 | 2274 | 'recur_type' => $content['recur_type'], |
| 2276 | - ),2); |
|
| 2275 | + ), 2); |
|
| 2277 | 2276 | } |
| 2278 | 2277 | |
| 2279 | 2278 | /** |
@@ -2286,15 +2285,15 @@ discard block |
||
| 2286 | 2285 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
| 2287 | 2286 | * @return array of free time-slots: array with start and end values |
| 2288 | 2287 | */ |
| 2289 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
| 2288 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
| 2290 | 2289 | { |
| 2291 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2290 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
| 2292 | 2291 | |
| 2293 | 2292 | $busy = $this->bo->search(array( |
| 2294 | 2293 | 'start' => $start, |
| 2295 | 2294 | 'end' => $end, |
| 2296 | 2295 | 'users' => $participants, |
| 2297 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2296 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2298 | 2297 | )); |
| 2299 | 2298 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
| 2300 | 2299 | 'start' => $end, |
@@ -2303,15 +2302,15 @@ discard block |
||
| 2303 | 2302 | $ft_start = $start; |
| 2304 | 2303 | $freetime = array(); |
| 2305 | 2304 | $n = 0; |
| 2306 | - foreach($busy as $event) |
|
| 2305 | + foreach ($busy as $event) |
|
| 2307 | 2306 | { |
| 2308 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2307 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2309 | 2308 | |
| 2310 | 2309 | if ($event['non_blocking']) continue; // ignore non_blocking events |
| 2311 | 2310 | |
| 2312 | 2311 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2313 | 2312 | $non_rejected_found = false; |
| 2314 | - foreach($participants as $uid) |
|
| 2313 | + foreach ($participants as $uid) |
|
| 2315 | 2314 | { |
| 2316 | 2315 | if ($event['participants'][$uid] == 'R') continue; |
| 2317 | 2316 | |
@@ -2327,10 +2326,10 @@ discard block |
||
| 2327 | 2326 | |
| 2328 | 2327 | if ($this->debug) |
| 2329 | 2328 | { |
| 2330 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
| 2329 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
| 2331 | 2330 | echo "event[title]=$event[title]<br>\n"; |
| 2332 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
| 2333 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
| 2331 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
| 2332 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
| 2334 | 2333 | } |
| 2335 | 2334 | // $events ends before our actual position ==> ignore it |
| 2336 | 2335 | if ($event['end'] < $ft_start) |
@@ -2354,11 +2353,11 @@ discard block |
||
| 2354 | 2353 | 'start' => $ft_start, |
| 2355 | 2354 | 'end' => $ft_end, |
| 2356 | 2355 | ); |
| 2357 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2356 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
| 2358 | 2357 | } |
| 2359 | 2358 | $ft_start = $event['end']; |
| 2360 | 2359 | } |
| 2361 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2360 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
| 2362 | 2361 | |
| 2363 | 2362 | return $freetime; |
| 2364 | 2363 | } |
@@ -2378,46 +2377,46 @@ discard block |
||
| 2378 | 2377 | */ |
| 2379 | 2378 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2380 | 2379 | { |
| 2381 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2380 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
| 2382 | 2381 | |
| 2383 | 2382 | $freetime_daywise = array(); |
| 2384 | 2383 | if (!is_array($sel_options)) $sel_options = array(); |
| 2385 | 2384 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2386 | 2385 | |
| 2387 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
| 2388 | - $end_time = (int) $_end_time; |
|
| 2386 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
| 2387 | + $end_time = (int)$_end_time; |
|
| 2389 | 2388 | |
| 2390 | 2389 | // ignore the end_time, if duration would never fit |
| 2391 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
| 2390 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
| 2392 | 2391 | { |
| 2393 | 2392 | $end_time = 0; |
| 2394 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2393 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
| 2395 | 2394 | } |
| 2396 | 2395 | $n = 0; |
| 2397 | - foreach($freetime as $ft) |
|
| 2396 | + foreach ($freetime as $ft) |
|
| 2398 | 2397 | { |
| 2399 | 2398 | $adaybegin = $this->bo->date2array($ft['start']); |
| 2400 | 2399 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
| 2401 | 2400 | unset($adaybegin['raw']); |
| 2402 | 2401 | $daybegin = $this->bo->date2ts($adaybegin); |
| 2403 | 2402 | |
| 2404 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
| 2403 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
| 2405 | 2404 | { |
| 2406 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
| 2407 | - $mcal_dow = pow(2,$dow); |
|
| 2408 | - if (!($weekdays & $mcal_dow)) |
|
| 2405 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
| 2406 | + $mcal_dow = pow(2, $dow); |
|
| 2407 | + if (!($weekdays&$mcal_dow)) |
|
| 2409 | 2408 | { |
| 2410 | 2409 | //echo "wrong day of week $dow<br>\n"; |
| 2411 | - continue; // wrong day of week |
|
| 2410 | + continue; // wrong day of week |
|
| 2412 | 2411 | } |
| 2413 | 2412 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2414 | 2413 | |
| 2415 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2414 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
| 2416 | 2415 | { |
| 2417 | - $start = $daybegin + $start_time*HOUR_s; |
|
| 2416 | + $start = $daybegin + $start_time * HOUR_s; |
|
| 2418 | 2417 | } |
| 2419 | 2418 | // if end_time given use it, else the original slot's end |
| 2420 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
| 2419 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
| 2421 | 2420 | if ($end > $ft['end']) $end = $ft['end']; |
| 2422 | 2421 | |
| 2423 | 2422 | // slot to small for duration |
@@ -2431,11 +2430,11 @@ discard block |
||
| 2431 | 2430 | 'end' => $end, |
| 2432 | 2431 | ); |
| 2433 | 2432 | $times = array(); |
| 2434 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
| 2433 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
| 2435 | 2434 | { |
| 2436 | 2435 | $e = $s + $duration; |
| 2437 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
| 2438 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
| 2436 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
| 2437 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
| 2439 | 2438 | } |
| 2440 | 2439 | $sel_options[$n.'start'] = $times; |
| 2441 | 2440 | } |
@@ -2450,13 +2449,13 @@ discard block |
||
| 2450 | 2449 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2451 | 2450 | * @return string error-msg if $return_error |
| 2452 | 2451 | */ |
| 2453 | - function export($content=0,$return_error=false) |
|
| 2452 | + function export($content = 0, $return_error = false) |
|
| 2454 | 2453 | { |
| 2455 | 2454 | $boical = new calendar_ical(); |
| 2456 | 2455 | #error_log(__METHOD__.print_r($content,true)); |
| 2457 | 2456 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
| 2458 | 2457 | { |
| 2459 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
| 2458 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
| 2460 | 2459 | { |
| 2461 | 2460 | $msg = lang('Permission denied'); |
| 2462 | 2461 | |
@@ -2464,20 +2463,20 @@ discard block |
||
| 2464 | 2463 | } |
| 2465 | 2464 | else |
| 2466 | 2465 | { |
| 2467 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
| 2466 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
| 2468 | 2467 | echo $ical; |
| 2469 | 2468 | common::egw_exit(); |
| 2470 | 2469 | } |
| 2471 | 2470 | } |
| 2472 | 2471 | if (is_array($content)) |
| 2473 | 2472 | { |
| 2474 | - $events =& $this->bo->search(array( |
|
| 2473 | + $events = & $this->bo->search(array( |
|
| 2475 | 2474 | 'start' => $content['start'], |
| 2476 | 2475 | 'end' => $content['end'], |
| 2477 | 2476 | 'enum_recuring' => false, |
| 2478 | 2477 | 'daywise' => false, |
| 2479 | 2478 | 'owner' => $this->owner, |
| 2480 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2479 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2481 | 2480 | )); |
| 2482 | 2481 | if (!$events) |
| 2483 | 2482 | { |
@@ -2485,8 +2484,8 @@ discard block |
||
| 2485 | 2484 | } |
| 2486 | 2485 | else |
| 2487 | 2486 | { |
| 2488 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
| 2489 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
| 2487 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
| 2488 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
| 2490 | 2489 | echo $ical; |
| 2491 | 2490 | common::egw_exit(); |
| 2492 | 2491 | } |
@@ -2502,9 +2501,9 @@ discard block |
||
| 2502 | 2501 | } |
| 2503 | 2502 | $content['msg'] = $msg; |
| 2504 | 2503 | |
| 2505 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
| 2504 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
| 2506 | 2505 | $etpl = new etemplate_new('calendar.export'); |
| 2507 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
| 2506 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
| 2508 | 2507 | } |
| 2509 | 2508 | |
| 2510 | 2509 | /** |
@@ -2512,7 +2511,7 @@ discard block |
||
| 2512 | 2511 | * |
| 2513 | 2512 | * @param array $_content |
| 2514 | 2513 | */ |
| 2515 | - function cat_acl(array $_content=null) |
|
| 2514 | + function cat_acl(array $_content = null) |
|
| 2516 | 2515 | { |
| 2517 | 2516 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
| 2518 | 2517 | { |
@@ -2524,15 +2523,15 @@ discard block |
||
| 2524 | 2523 | unset($_content['button']); |
| 2525 | 2524 | if ($button != 'cancel') // store changed Acl |
| 2526 | 2525 | { |
| 2527 | - foreach($_content as $data) |
|
| 2526 | + foreach ($_content as $data) |
|
| 2528 | 2527 | { |
| 2529 | 2528 | if (!($cat_id = $data['cat_id'])) continue; |
| 2530 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
| 2529 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
| 2531 | 2530 | { |
| 2532 | 2531 | $rights = 0; |
| 2533 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2534 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2535 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2532 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2533 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2534 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
| 2536 | 2535 | } |
| 2537 | 2536 | } |
| 2538 | 2537 | } |
@@ -2544,20 +2543,20 @@ discard block |
||
| 2544 | 2543 | ), 'admin'); |
| 2545 | 2544 | } |
| 2546 | 2545 | } |
| 2547 | - $content= $preserv = array(); |
|
| 2546 | + $content = $preserv = array(); |
|
| 2548 | 2547 | $n = 1; |
| 2549 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2548 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2550 | 2549 | { |
| 2551 | - $cat_id = substr($Lcat_id,1); |
|
| 2550 | + $cat_id = substr($Lcat_id, 1); |
|
| 2552 | 2551 | $row = array( |
| 2553 | 2552 | 'cat_id' => $cat_id, |
| 2554 | 2553 | 'add' => array(), |
| 2555 | 2554 | 'status' => array(), |
| 2556 | 2555 | ); |
| 2557 | - foreach($data as $account_id => $rights) |
|
| 2556 | + foreach ($data as $account_id => $rights) |
|
| 2558 | 2557 | { |
| 2559 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2560 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2558 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2559 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2561 | 2560 | } |
| 2562 | 2561 | $content[$n] = $row; |
| 2563 | 2562 | $preserv[$n] = array( |
@@ -2573,7 +2572,7 @@ discard block |
||
| 2573 | 2572 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
| 2574 | 2573 | $tmp = new Etemplate('calendar.cat_acl'); |
| 2575 | 2574 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
| 2576 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
| 2575 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
| 2577 | 2576 | } |
| 2578 | 2577 | |
| 2579 | 2578 | /** |
@@ -2623,18 +2622,18 @@ discard block |
||
| 2623 | 2622 | |
| 2624 | 2623 | |
| 2625 | 2624 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
| 2626 | - if($content['recur_type'] || $content['recurrence']) |
|
| 2625 | + if ($content['recur_type'] || $content['recurrence']) |
|
| 2627 | 2626 | { |
| 2628 | 2627 | $content['history']['filter'] = array( |
| 2629 | 2628 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
| 2630 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
| 2631 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
| 2629 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
| 2630 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
| 2632 | 2631 | ); |
| 2633 | 2632 | } |
| 2634 | 2633 | |
| 2635 | 2634 | // Translate labels |
| 2636 | 2635 | $tracking = new calendar_tracking(); |
| 2637 | - foreach($tracking->field2label as $field => $label) |
|
| 2636 | + foreach ($tracking->field2label as $field => $label) |
|
| 2638 | 2637 | { |
| 2639 | 2638 | $sel_options[$status][$field] = lang($label); |
| 2640 | 2639 | } |
@@ -2653,44 +2652,44 @@ discard block |
||
| 2653 | 2652 | * which particular instance was dragged |
| 2654 | 2653 | * @return string XML response if no error occurs |
| 2655 | 2654 | */ |
| 2656 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
| 2655 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
| 2657 | 2656 | { |
| 2658 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 2657 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 2659 | 2658 | $ignore_conflicts = false; |
| 2660 | 2659 | |
| 2661 | 2660 | // we do not allow dragging into another users calendar ATM |
| 2662 | - if($targetOwner < 0) |
|
| 2661 | + if ($targetOwner < 0) |
|
| 2663 | 2662 | { |
| 2664 | 2663 | $targetOwner = array($targetOwner); |
| 2665 | 2664 | } |
| 2666 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2665 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2667 | 2666 | { |
| 2668 | 2667 | $targetOwner = $calendarOwner; |
| 2669 | 2668 | } |
| 2670 | 2669 | // But you may be viewing multiple users, or a group calendar and |
| 2671 | 2670 | // dragging your event - dragging across calendars does not change owner |
| 2672 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2671 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2673 | 2672 | { |
| 2674 | 2673 | $return = true; |
| 2675 | - foreach($targetOwner as $owner) |
|
| 2674 | + foreach ($targetOwner as $owner) |
|
| 2676 | 2675 | { |
| 2677 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
| 2676 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
| 2678 | 2677 | { |
| 2679 | 2678 | $return = false; |
| 2680 | 2679 | break; |
| 2681 | 2680 | } |
| 2682 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
| 2681 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
| 2683 | 2682 | { |
| 2684 | 2683 | $return = false; |
| 2685 | 2684 | break; |
| 2686 | 2685 | } |
| 2687 | 2686 | } |
| 2688 | - if($return) return; |
|
| 2687 | + if ($return) return; |
|
| 2689 | 2688 | } |
| 2690 | - $old_event=$event=$this->bo->read($eventId); |
|
| 2689 | + $old_event = $event = $this->bo->read($eventId); |
|
| 2691 | 2690 | if (!$durationT) |
| 2692 | 2691 | { |
| 2693 | - $duration=$event['end']-$event['start']; |
|
| 2692 | + $duration = $event['end'] - $event['start']; |
|
| 2694 | 2693 | } |
| 2695 | 2694 | // Drag a normal event to whole day non-blocking |
| 2696 | 2695 | else if ($durationT == 'whole_day') |
@@ -2698,7 +2697,7 @@ discard block |
||
| 2698 | 2697 | $event['whole_day'] = true; |
| 2699 | 2698 | $event['non_blocking'] = true; |
| 2700 | 2699 | // Make duration whole days, less 1 second |
| 2701 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
| 2700 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
| 2702 | 2701 | } |
| 2703 | 2702 | else |
| 2704 | 2703 | { |
@@ -2711,18 +2710,18 @@ discard block |
||
| 2711 | 2710 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2712 | 2711 | if (!empty($event['whole_day'])) |
| 2713 | 2712 | { |
| 2714 | - $d =& $this->bo->so->startOfDay($d); |
|
| 2713 | + $d = & $this->bo->so->startOfDay($d); |
|
| 2715 | 2714 | $d->setUser(); |
| 2716 | 2715 | } |
| 2717 | 2716 | $event = $this->bo->read($eventId, $d, true); |
| 2718 | 2717 | |
| 2719 | 2718 | // For DnD, create an exception if they gave the date |
| 2720 | 2719 | $preserv = null; |
| 2721 | - $this->_create_exception($event,$preserv); |
|
| 2720 | + $this->_create_exception($event, $preserv); |
|
| 2722 | 2721 | unset($event['id']); |
| 2723 | 2722 | |
| 2724 | 2723 | $messages = null; |
| 2725 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
| 2724 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
| 2726 | 2725 | if (!is_array($conflicts) && $conflicts) |
| 2727 | 2726 | { |
| 2728 | 2727 | // now we need to add the original start as recur-execption to the series |
@@ -2730,28 +2729,28 @@ discard block |
||
| 2730 | 2729 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 2731 | 2730 | // check if we need to move the alarms, because they are next on that exception |
| 2732 | 2731 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 2733 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2734 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2735 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 2732 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2733 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2734 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 2736 | 2735 | |
| 2737 | 2736 | // Sending null will trigger a removal of the original for that date |
| 2738 | 2737 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 2739 | 2738 | |
| 2740 | 2739 | unset($recur_event); |
| 2741 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2740 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2742 | 2741 | unset($preserv['edit_single']); |
| 2743 | 2742 | } |
| 2744 | 2743 | } |
| 2745 | 2744 | |
| 2746 | 2745 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
| 2747 | 2746 | $event['start'] = $d->format('ts'); |
| 2748 | - $event['end'] = $event['start']+$duration; |
|
| 2747 | + $event['end'] = $event['start'] + $duration; |
|
| 2749 | 2748 | |
| 2750 | 2749 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
| 2751 | 2750 | { |
| 2752 | 2751 | // calculate offset against clicked recurrance, |
| 2753 | 2752 | // depending on which is smaller |
| 2754 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
| 2753 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
| 2755 | 2754 | $event['start'] = $old_event['start'] + $offset; |
| 2756 | 2755 | $event['duration'] = $duration; |
| 2757 | 2756 | |
@@ -2762,34 +2761,34 @@ discard block |
||
| 2762 | 2761 | // Can't handle conflict. Just ignore it. |
| 2763 | 2762 | $ignore_conflicts = true; |
| 2764 | 2763 | } |
| 2765 | - if(!$event['recur_type']) |
|
| 2764 | + if (!$event['recur_type']) |
|
| 2766 | 2765 | { |
| 2767 | 2766 | $this->bo->check_move_alarms($event, $old_event); |
| 2768 | 2767 | } |
| 2769 | 2768 | |
| 2770 | 2769 | // Drag a whole day to a time |
| 2771 | - if($durationT && $durationT != 'whole_day') |
|
| 2770 | + if ($durationT && $durationT != 'whole_day') |
|
| 2772 | 2771 | { |
| 2773 | 2772 | $event['whole_day'] = ($duration == DAY_s); |
| 2774 | 2773 | $event['non_blocking'] = false; |
| 2775 | 2774 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
| 2776 | 2775 | // so save the change now, and then let the conflict check happen. |
| 2777 | 2776 | $message = null; |
| 2778 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
| 2777 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
| 2779 | 2778 | |
| 2780 | 2779 | // Whole day non blocking with DAY_s would add a day |
| 2781 | - if($duration==DAY_s) $duration=0; |
|
| 2780 | + if ($duration == DAY_s) $duration = 0; |
|
| 2782 | 2781 | } |
| 2783 | 2782 | |
| 2784 | 2783 | $status_reset_to_unknown = false; |
| 2785 | 2784 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 2786 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 2785 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 2787 | 2786 | { |
| 2788 | 2787 | $q = $r = null; |
| 2789 | - calendar_so::split_status($status,$q,$r); |
|
| 2788 | + calendar_so::split_status($status, $q, $r); |
|
| 2790 | 2789 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 2791 | 2790 | { |
| 2792 | - $preferences = CreateObject('phpgwapi.preferences',$uid); |
|
| 2791 | + $preferences = CreateObject('phpgwapi.preferences', $uid); |
|
| 2793 | 2792 | $part_prefs = $preferences->read_repository(); |
| 2794 | 2793 | switch ($part_prefs['calendar']['reset_stati']) |
| 2795 | 2794 | { |
@@ -2799,23 +2798,23 @@ discard block |
||
| 2799 | 2798 | if ($sameday) break; |
| 2800 | 2799 | default: |
| 2801 | 2800 | $status_reset_to_unknown = true; |
| 2802 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 2801 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 2803 | 2802 | // todo: report reset status to user |
| 2804 | 2803 | } |
| 2805 | 2804 | } |
| 2806 | 2805 | } |
| 2807 | 2806 | |
| 2808 | 2807 | $message = false; |
| 2809 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
| 2808 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
| 2810 | 2809 | |
| 2811 | - $this->update_client($event['id'],$d); |
|
| 2810 | + $this->update_client($event['id'], $d); |
|
| 2812 | 2811 | $response = Api\Json\Response::get(); |
| 2813 | - if(!is_array($conflicts) && $conflicts) |
|
| 2812 | + if (!is_array($conflicts) && $conflicts) |
|
| 2814 | 2813 | { |
| 2815 | - if(is_int($conflicts)) |
|
| 2814 | + if (is_int($conflicts)) |
|
| 2816 | 2815 | { |
| 2817 | 2816 | $event['id'] = $conflicts; |
| 2818 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 2817 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 2819 | 2818 | } |
| 2820 | 2819 | } |
| 2821 | 2820 | else if ($conflicts) |
@@ -2828,21 +2827,21 @@ discard block |
||
| 2828 | 2827 | .'&end='.$event['end'] |
| 2829 | 2828 | .'&non_interactive=true' |
| 2830 | 2829 | .'&cancel_needs_refresh=true', |
| 2831 | - '',750,410); |
|
| 2830 | + '', 750, 410); |
|
| 2832 | 2831 | } |
| 2833 | 2832 | else if ($message) |
| 2834 | 2833 | { |
| 2835 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 2834 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 2836 | 2835 | } |
| 2837 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 2836 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
| 2838 | 2837 | if ($status_reset_to_unknown) |
| 2839 | 2838 | { |
| 2840 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 2839 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 2841 | 2840 | { |
| 2842 | 2841 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 2843 | 2842 | { |
| 2844 | - calendar_so::split_status($status,$q,$r); |
|
| 2845 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 2843 | + calendar_so::split_status($status, $q, $r); |
|
| 2844 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 2846 | 2845 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 2847 | 2846 | } |
| 2848 | 2847 | } |
@@ -2859,7 +2858,7 @@ discard block |
||
| 2859 | 2858 | { |
| 2860 | 2859 | list($eventId, $date) = explode(':', $_eventId); |
| 2861 | 2860 | $event = $this->bo->read($eventId); |
| 2862 | - if($date) |
|
| 2861 | + if ($date) |
|
| 2863 | 2862 | { |
| 2864 | 2863 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2865 | 2864 | } |
@@ -2869,29 +2868,29 @@ discard block |
||
| 2869 | 2868 | { |
| 2870 | 2869 | if (!empty($event['whole_day'])) |
| 2871 | 2870 | { |
| 2872 | - $d =& $this->bo->so->startOfDay($date); |
|
| 2871 | + $d = & $this->bo->so->startOfDay($date); |
|
| 2873 | 2872 | $d->setUser(); |
| 2874 | 2873 | } |
| 2875 | 2874 | $event = $this->bo->read($eventId, $d, true); |
| 2876 | 2875 | $date = $d->format('ts'); |
| 2877 | 2876 | } |
| 2878 | - if($event['participants'][$uid]) |
|
| 2877 | + if ($event['participants'][$uid]) |
|
| 2879 | 2878 | { |
| 2880 | 2879 | $q = $r = null; |
| 2881 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 2882 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 2883 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 2880 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 2881 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 2882 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 2884 | 2883 | } |
| 2885 | 2884 | else |
| 2886 | 2885 | { |
| 2887 | 2886 | // Group membership |
| 2888 | - foreach($event['participants'] as $id => $status) |
|
| 2887 | + foreach ($event['participants'] as $id => $status) |
|
| 2889 | 2888 | { |
| 2890 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
| 2889 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
| 2891 | 2890 | { |
| 2892 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 2893 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 2894 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 2891 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 2892 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 2893 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 2895 | 2894 | break; |
| 2896 | 2895 | } |
| 2897 | 2896 | } |
@@ -2899,7 +2898,7 @@ discard block |
||
| 2899 | 2898 | |
| 2900 | 2899 | // Directly update stored data. If event is still visible, it will |
| 2901 | 2900 | // be notified & update itself. |
| 2902 | - $this->update_client($eventId,$d); |
|
| 2901 | + $this->update_client($eventId, $d); |
|
| 2903 | 2902 | } |
| 2904 | 2903 | |
| 2905 | 2904 | /** |
@@ -2907,8 +2906,8 @@ discard block |
||
| 2907 | 2906 | */ |
| 2908 | 2907 | public function ajax_delete($eventId) |
| 2909 | 2908 | { |
| 2910 | - list($id, $date) = explode(':',$eventId); |
|
| 2911 | - $event=$this->bo->read($id); |
|
| 2909 | + list($id, $date) = explode(':', $eventId); |
|
| 2910 | + $event = $this->bo->read($id); |
|
| 2912 | 2911 | $response = Api\Json\Response::get(); |
| 2913 | 2912 | |
| 2914 | 2913 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -2921,11 +2920,11 @@ discard block |
||
| 2921 | 2920 | { |
| 2922 | 2921 | $msg = lang('Event deleted'); |
| 2923 | 2922 | } |
| 2924 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 2923 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
| 2925 | 2924 | } |
| 2926 | 2925 | else |
| 2927 | 2926 | { |
| 2928 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 2927 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
| 2929 | 2928 | } |
| 2930 | 2929 | } |
| 2931 | 2930 | |
@@ -2938,11 +2937,11 @@ discard block |
||
| 2938 | 2937 | */ |
| 2939 | 2938 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
| 2940 | 2939 | { |
| 2941 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 2940 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 2942 | 2941 | |
| 2943 | - $old_event=$event=$this->bo->read($eventId); |
|
| 2942 | + $old_event = $event = $this->bo->read($eventId); |
|
| 2944 | 2943 | $event = $this->bo->read($eventId); |
| 2945 | - if($date) |
|
| 2944 | + if ($date) |
|
| 2946 | 2945 | { |
| 2947 | 2946 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2948 | 2947 | } |
@@ -2952,17 +2951,17 @@ discard block |
||
| 2952 | 2951 | { |
| 2953 | 2952 | if (!empty($event['whole_day'])) |
| 2954 | 2953 | { |
| 2955 | - $d =& $this->bo->so->startOfDay($date); |
|
| 2954 | + $d = & $this->bo->so->startOfDay($date); |
|
| 2956 | 2955 | $d->setUser(); |
| 2957 | 2956 | } |
| 2958 | 2957 | $event = $this->bo->read($eventId, $d, true); |
| 2959 | 2958 | // For DnD, create an exception if they gave the date |
| 2960 | 2959 | $preserv = null; |
| 2961 | - $this->_create_exception($event,$preserv); |
|
| 2960 | + $this->_create_exception($event, $preserv); |
|
| 2962 | 2961 | unset($event['id']); |
| 2963 | 2962 | |
| 2964 | 2963 | $messages = null; |
| 2965 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
| 2964 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
| 2966 | 2965 | if (!is_array($conflicts) && $conflicts) |
| 2967 | 2966 | { |
| 2968 | 2967 | // now we need to add the original start as recur-execption to the series |
@@ -2970,27 +2969,27 @@ discard block |
||
| 2970 | 2969 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 2971 | 2970 | // check if we need to move the alarms, because they are next on that exception |
| 2972 | 2971 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 2973 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2974 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2975 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 2972 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2973 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2974 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 2976 | 2975 | |
| 2977 | 2976 | // Sending null will trigger a removal of the original for that date |
| 2978 | 2977 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 2979 | 2978 | |
| 2980 | 2979 | unset($recur_event); |
| 2981 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2980 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2982 | 2981 | unset($preserv['edit_single']); |
| 2983 | 2982 | } |
| 2984 | 2983 | } |
| 2985 | - foreach($remove as $participant) |
|
| 2984 | + foreach ($remove as $participant) |
|
| 2986 | 2985 | { |
| 2987 | 2986 | unset($event['participants'][$participant]); |
| 2988 | 2987 | } |
| 2989 | - foreach($invite as $participant) |
|
| 2988 | + foreach ($invite as $participant) |
|
| 2990 | 2989 | { |
| 2991 | 2990 | $event['participants'][$participant] = 'U'; |
| 2992 | 2991 | } |
| 2993 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
| 2992 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
| 2994 | 2993 | |
| 2995 | 2994 | $response = Api\Json\Response::get(); |
| 2996 | 2995 | |
@@ -2998,8 +2997,8 @@ discard block |
||
| 2998 | 2997 | { |
| 2999 | 2998 | // Save it anyway, was done with explicit user interaction, |
| 3000 | 2999 | // and if we don't we lose the invite |
| 3001 | - $this->bo->update($event,true); // no conflict check here |
|
| 3002 | - $this->update_client($event['id'],$d); |
|
| 3000 | + $this->bo->update($event, true); // no conflict check here |
|
| 3001 | + $this->update_client($event['id'], $d); |
|
| 3003 | 3002 | $response->call( |
| 3004 | 3003 | 'egw_openWindowCentered2', |
| 3005 | 3004 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3008,22 +3007,22 @@ discard block |
||
| 3008 | 3007 | .'&end='.$event['end'] |
| 3009 | 3008 | .'&non_interactive=true' |
| 3010 | 3009 | .'&cancel_needs_refresh=true', |
| 3011 | - '',750,410); |
|
| 3010 | + '', 750, 410); |
|
| 3012 | 3011 | } |
| 3013 | 3012 | else if ($message) |
| 3014 | 3013 | { |
| 3015 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 3014 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 3016 | 3015 | } |
| 3017 | - if($conflicts) |
|
| 3016 | + if ($conflicts) |
|
| 3018 | 3017 | { |
| 3019 | - $this->update_client($event['id'],$d); |
|
| 3020 | - if(is_int($conflicts)) |
|
| 3018 | + $this->update_client($event['id'], $d); |
|
| 3019 | + if (is_int($conflicts)) |
|
| 3021 | 3020 | { |
| 3022 | 3021 | $event['id'] = $conflicts; |
| 3023 | 3022 | } |
| 3024 | - if($event['id']) |
|
| 3023 | + if ($event['id']) |
|
| 3025 | 3024 | { |
| 3026 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 3025 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 3027 | 3026 | } |
| 3028 | 3027 | } |
| 3029 | 3028 | } |
@@ -3034,13 +3033,13 @@ discard block |
||
| 3034 | 3033 | * @param array $mailContent = null mail content |
| 3035 | 3034 | * @return array |
| 3036 | 3035 | */ |
| 3037 | - function mail_import(array $mailContent=null) |
|
| 3036 | + function mail_import(array $mailContent = null) |
|
| 3038 | 3037 | { |
| 3039 | 3038 | // It would get called from compose as a popup with egw_data |
| 3040 | 3039 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
| 3041 | 3040 | { |
| 3042 | 3041 | // get raw mail data |
| 3043 | - Link::get_data ($_GET['egw_data']); |
|
| 3042 | + Link::get_data($_GET['egw_data']); |
|
| 3044 | 3043 | return false; |
| 3045 | 3044 | } |
| 3046 | 3045 | |
@@ -3050,7 +3049,7 @@ discard block |
||
| 3050 | 3049 | $AB = new Api\Contacts(); |
| 3051 | 3050 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
| 3052 | 3051 | |
| 3053 | - $participants[0] = array ( |
|
| 3052 | + $participants[0] = array( |
|
| 3054 | 3053 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
| 3055 | 3054 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
| 3056 | 3055 | 'status' => 'A', |
@@ -3058,23 +3057,23 @@ discard block |
||
| 3058 | 3057 | 'app' => 'User', |
| 3059 | 3058 | 'role' => 'REQ-PARTICIPANT' |
| 3060 | 3059 | ); |
| 3061 | - foreach($mailContent['addresses'] as $address) |
|
| 3060 | + foreach ($mailContent['addresses'] as $address) |
|
| 3062 | 3061 | { |
| 3063 | 3062 | // Get available contacts from the email |
| 3064 | 3063 | $contacts = $AB->search(array( |
| 3065 | 3064 | 'email' => $address['email'], |
| 3066 | 3065 | 'email_home' => $address['email'] |
| 3067 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
| 3066 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
| 3068 | 3067 | if (is_array($contacts)) |
| 3069 | 3068 | { |
| 3070 | - foreach($contacts as $account) |
|
| 3069 | + foreach ($contacts as $account) |
|
| 3071 | 3070 | { |
| 3072 | 3071 | $accounts[] = $account['account_id']; |
| 3073 | 3072 | } |
| 3074 | 3073 | } |
| 3075 | 3074 | else |
| 3076 | 3075 | { |
| 3077 | - $participants []= array ( |
|
| 3076 | + $participants [] = array( |
|
| 3078 | 3077 | 'app' => 'email', |
| 3079 | 3078 | 'uid' => 'e'.$address['email'], |
| 3080 | 3079 | 'status' => 'U', |
@@ -3082,7 +3081,7 @@ discard block |
||
| 3082 | 3081 | ); |
| 3083 | 3082 | } |
| 3084 | 3083 | } |
| 3085 | - $participants = array_merge($participants , array( |
|
| 3084 | + $participants = array_merge($participants, array( |
|
| 3086 | 3085 | "participant" => $accounts, |
| 3087 | 3086 | "role" => "REQ-PARTICIPANT", |
| 3088 | 3087 | "add" => "pressed" |
@@ -3106,14 +3105,14 @@ discard block |
||
| 3106 | 3105 | { |
| 3107 | 3106 | foreach ($mailContent['attachments'] as $attachment) |
| 3108 | 3107 | { |
| 3109 | - if($attachment['egw_data']) |
|
| 3108 | + if ($attachment['egw_data']) |
|
| 3110 | 3109 | { |
| 3111 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
| 3110 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
| 3112 | 3111 | } |
| 3113 | - else if(is_readable($attachment['tmp_name']) || |
|
| 3112 | + else if (is_readable($attachment['tmp_name']) || |
|
| 3114 | 3113 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
| 3115 | 3114 | { |
| 3116 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
| 3115 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
| 3117 | 3116 | } |
| 3118 | 3117 | } |
| 3119 | 3118 | } |
@@ -539,8 +539,9 @@ |
||
| 539 | 539 | * @param int &$success number of succeded actions |
| 540 | 540 | * @param int &$failed number of failed actions (not enought permissions) |
| 541 | 541 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 events 'deleted' |
| 542 | - * @param string/array $session_name 'calendar_list' |
|
| 543 | - * @return boolean true if all actions succeded, false otherwise |
|
| 542 | + * @param string $session_name 'calendar_list' |
|
| 543 | + * @param null|string $msg |
|
| 544 | + * @return null|boolean true if all actions succeded, false otherwise |
|
| 544 | 545 | */ |
| 545 | 546 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
| 546 | 547 | { |
@@ -77,8 +77,14 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function listview($_content=null,$msg='',$home=false) |
| 79 | 79 | { |
| 80 | - if ($_GET['msg']) $msg .= $_GET['msg']; |
|
| 81 | - if ($this->group_warning) $msg .= $this->group_warning; |
|
| 80 | + if ($_GET['msg']) |
|
| 81 | + { |
|
| 82 | + $msg .= $_GET['msg']; |
|
| 83 | + } |
|
| 84 | + if ($this->group_warning) |
|
| 85 | + { |
|
| 86 | + $msg .= $this->group_warning; |
|
| 87 | + } |
|
| 82 | 88 | |
| 83 | 89 | $etpl = new Etemplate('calendar.list'); |
| 84 | 90 | |
@@ -106,7 +112,8 @@ discard block |
||
| 106 | 112 | { |
| 107 | 113 | // Allow merge using the date range filter |
| 108 | 114 | if(strpos($_content['nm']['action'],'document') !== false && |
| 109 | - !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
|
| 115 | + !count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
|
| 116 | + { |
|
| 110 | 117 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 111 | 118 | } |
| 112 | 119 | if (!count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
@@ -165,15 +172,21 @@ discard block |
||
| 165 | 172 | { |
| 166 | 173 | $params = null; |
| 167 | 174 | parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
| 168 | - if (isset($params['keywords'])) // new search => set filters so every match is shown |
|
| 175 | + if (isset($params['keywords'])) |
|
| 176 | + { |
|
| 177 | + // new search => set filters so every match is shown |
|
| 169 | 178 | { |
| 170 | 179 | $this->adjust_for_search($params['keywords'], $content['nm']); |
| 171 | 180 | } |
| 181 | + } |
|
| 172 | 182 | } |
| 173 | - if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
|
| 183 | + if (isset($_REQUEST['keywords'])) |
|
| 184 | + { |
|
| 185 | + // new search => set filters so every match is shown |
|
| 174 | 186 | { |
| 175 | 187 | $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
| 176 | 188 | } |
| 189 | + } |
|
| 177 | 190 | $sel_options['filter'] = &$this->date_filters; |
| 178 | 191 | |
| 179 | 192 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
@@ -264,9 +277,12 @@ discard block |
||
| 264 | 277 | $old_params = Api\Cache::getSession('calendar', 'calendar_list'); |
| 265 | 278 | if (is_array($old_params)) |
| 266 | 279 | { |
| 267 | - if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly |
|
| 280 | + if ($old_params['filter'] && $old_params['filter'] != $params['filter']) |
|
| 281 | + { |
|
| 282 | + // filter changed => order accordingly |
|
| 268 | 283 | { |
| 269 | 284 | $params['order'] = 'cal_start'; |
| 285 | + } |
|
| 270 | 286 | $params['sort'] = $params['filter'] == 'before' ? 'DESC' : 'ASC'; |
| 271 | 287 | } |
| 272 | 288 | if ($old_params['search'] != $params['search']) |
@@ -274,7 +290,10 @@ discard block |
||
| 274 | 290 | $this->adjust_for_search($params['search'],$params); |
| 275 | 291 | } |
| 276 | 292 | } |
| 277 | - if (!$params['csv_export']) Api\Cache::setSession('calendar', 'calendar_list', $params); |
|
| 293 | + if (!$params['csv_export']) |
|
| 294 | + { |
|
| 295 | + Api\Cache::setSession('calendar', 'calendar_list', $params); |
|
| 296 | + } |
|
| 278 | 297 | |
| 279 | 298 | // do we need to query custom fields and which |
| 280 | 299 | // Check stored preference if selectcols isn't available (ie: first call) |
@@ -288,7 +307,10 @@ discard block |
||
| 288 | 307 | $cfs = array(); |
| 289 | 308 | foreach($select_cols as $col) |
| 290 | 309 | { |
| 291 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 310 | + if ($col[0] == '#') |
|
| 311 | + { |
|
| 312 | + $cfs[] = substr($col,1); |
|
| 313 | + } |
|
| 292 | 314 | } |
| 293 | 315 | } |
| 294 | 316 | $search_params = array( |
@@ -521,7 +543,10 @@ discard block |
||
| 521 | 543 | { |
| 522 | 544 | $rows['format'] = '64'; |
| 523 | 545 | } |
| 524 | - if ($this->cat_id) $rows['no_cat_id'] = true; |
|
| 546 | + if ($this->cat_id) |
|
| 547 | + { |
|
| 548 | + $rows['no_cat_id'] = true; |
|
| 549 | + } |
|
| 525 | 550 | if (!$GLOBALS['egw_info']['user']['apps']['projectmanager']) |
| 526 | 551 | { |
| 527 | 552 | $params['options-selectcols']['pm_id'] = false; |
@@ -587,7 +612,10 @@ discard block |
||
| 587 | 612 | $this->get_rows($query,$events,$readonlys); |
| 588 | 613 | foreach($events as $key => $event) |
| 589 | 614 | { |
| 590 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 615 | + if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) |
|
| 616 | + { |
|
| 617 | + unset($events[$key]); |
|
| 618 | + } |
|
| 591 | 619 | } |
| 592 | 620 | $checked = array_values($events); // Clear keys |
| 593 | 621 | } |
@@ -601,7 +629,10 @@ discard block |
||
| 601 | 629 | $ids = array(); |
| 602 | 630 | foreach($checked as $id) |
| 603 | 631 | { |
| 604 | - if (is_array($id)) $id = $id['id']; |
|
| 632 | + if (is_array($id)) |
|
| 633 | + { |
|
| 634 | + $id = $id['id']; |
|
| 635 | + } |
|
| 605 | 636 | // get rid of recurrences, doublicate series and calendar-integration events |
| 606 | 637 | if (($id = (int)$id)) |
| 607 | 638 | { |
@@ -615,7 +646,10 @@ discard block |
||
| 615 | 646 | exit(); |
| 616 | 647 | |
| 617 | 648 | case 'document': |
| 618 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 649 | + if (!$settings) |
|
| 650 | + { |
|
| 651 | + $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 652 | + } |
|
| 619 | 653 | $document_merge = new calendar_merge(); |
| 620 | 654 | $msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']); |
| 621 | 655 | $failed = count($checked); |
@@ -802,7 +836,8 @@ discard block |
||
| 802 | 836 | $success++; |
| 803 | 837 | |
| 804 | 838 | // Can't link to just one of a recurring series of events |
| 805 | - if(!$recur_date || $app) { |
|
| 839 | + if(!$recur_date || $app) |
|
| 840 | + { |
|
| 806 | 841 | // Create link |
| 807 | 842 | $link_id = $app ? $app_id : $id; |
| 808 | 843 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @var mixed |
| 41 | 41 | */ |
| 42 | - var $debug=false; |
|
| 42 | + var $debug = false; |
|
| 43 | 43 | /** |
| 44 | 44 | * Filternames |
| 45 | 45 | * |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 62 | 62 | */ |
| 63 | - function __construct($set_states=null) |
|
| 63 | + function __construct($set_states = null) |
|
| 64 | 64 | { |
| 65 | - parent::__construct(true,$set_states); // call the parent's constructor |
|
| 65 | + parent::__construct(true, $set_states); // call the parent's constructor |
|
| 66 | 66 | |
| 67 | - foreach($this->date_filters as $name => $label) |
|
| 67 | + foreach ($this->date_filters as $name => $label) |
|
| 68 | 68 | { |
| 69 | 69 | $this->date_filters[$name] = lang($label); |
| 70 | 70 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * Show the listview |
| 77 | 77 | */ |
| 78 | - function listview($_content=null,$msg='',$home=false) |
|
| 78 | + function listview($_content = null, $msg = '', $home = false) |
|
| 79 | 79 | { |
| 80 | 80 | if ($_GET['msg']) $msg .= $_GET['msg']; |
| 81 | 81 | if ($this->group_warning) $msg .= $this->group_warning; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $etpl = new Etemplate('calendar.list'); |
| 84 | 84 | |
| 85 | 85 | // Handle merge from sidebox |
| 86 | - if($_GET['merge']) |
|
| 86 | + if ($_GET['merge']) |
|
| 87 | 87 | { |
| 88 | 88 | $_content['nm']['action'] = 'document_'.$_GET['merge']; |
| 89 | 89 | $_content['nm']['select_all'] = true; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if (is_array($_content)) |
| 93 | 93 | { |
| 94 | 94 | // handle a single button like actions |
| 95 | - foreach(array('delete','timesheet','document') as $button) |
|
| 95 | + foreach (array('delete', 'timesheet', 'document') as $button) |
|
| 96 | 96 | { |
| 97 | 97 | if ($_content['nm']['rows'][$button]) |
| 98 | 98 | { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | if ($_content['nm']['action']) |
| 106 | 106 | { |
| 107 | 107 | // Allow merge using the date range filter |
| 108 | - if(strpos($_content['nm']['action'],'document') !== false && |
|
| 108 | + if (strpos($_content['nm']['action'], 'document') !== false && |
|
| 109 | 109 | !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
| 110 | 110 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 111 | 111 | } |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | 118 | $success = $failed = $action_msg = null; |
| 119 | - if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], |
|
| 120 | - $success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 119 | + if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'], |
|
| 120 | + $success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 121 | 121 | { |
| 122 | - $msg .= lang('%1 event(s) %2',$success,$action_msg); |
|
| 122 | + $msg .= lang('%1 event(s) %2', $success, $action_msg); |
|
| 123 | 123 | } |
| 124 | - elseif(is_null($msg)) |
|
| 124 | + elseif (is_null($msg)) |
|
| 125 | 125 | { |
| 126 | - $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 126 | + $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $content['nm'] = array( |
| 137 | 137 | 'get_rows' => 'calendar.calendar_uilist.get_rows', |
| 138 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 138 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 141 | 141 | 'filter' => 'after', |
| 142 | - 'order' => 'cal_start',// IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | - 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' |
|
| 142 | + 'order' => 'cal_start', // IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 144 | 144 | 'default_cols' => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id', |
| 145 | 145 | 'filter_onchange' => "app.calendar.filter_change", |
| 146 | - 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 146 | + 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 147 | 147 | 'row_modified' => 'modified', |
| 148 | 148 | 'favorites' => true, |
| 149 | 149 | 'placeholder_actions' => array('add') |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | $content['nm']['actions'] = $this->get_actions(); |
| 153 | 153 | |
| 154 | - if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters))) |
|
| 154 | + if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters))) |
|
| 155 | 155 | { |
| 156 | 156 | $content['nm']['filter'] = $_GET['filter']; |
| 157 | 157 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | !empty($json_data['request']['parameters'][0])) |
| 165 | 165 | { |
| 166 | 166 | $params = null; |
| 167 | - parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 167 | + parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 168 | 168 | if (isset($params['keywords'])) // new search => set filters so every match is shown |
| 169 | 169 | { |
| 170 | 170 | $this->adjust_for_search($params['keywords'], $content['nm']); |
@@ -172,22 +172,22 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
| 174 | 174 | { |
| 175 | - $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
|
| 175 | + $this->adjust_for_search($_REQUEST['keywords'], $content['nm']); |
|
| 176 | 176 | } |
| 177 | 177 | $sel_options['filter'] = &$this->date_filters; |
| 178 | 178 | |
| 179 | 179 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
| 180 | 180 | $sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar'); |
| 181 | 181 | // Prevent double encoding - widget does this on its own, but we're just grabbing the options |
| 182 | - foreach($sel_options['category'] as &$label) |
|
| 182 | + foreach ($sel_options['category'] as &$label) |
|
| 183 | 183 | { |
| 184 | - if(!is_array($label)) |
|
| 184 | + if (!is_array($label)) |
|
| 185 | 185 | { |
| 186 | - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); |
|
| 186 | + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); |
|
| 187 | 187 | } |
| 188 | - elseif($label['label']) |
|
| 188 | + elseif ($label['label']) |
|
| 189 | 189 | { |
| 190 | - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); |
|
| 190 | + $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8'); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -195,15 +195,15 @@ discard block |
||
| 195 | 195 | if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '') |
| 196 | 196 | { |
| 197 | 197 | $content['css'] .= '<style type="text/css">@media screen { .listDescription { max-height: '. |
| 198 | - (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35). // dono why em is not real lines |
|
| 198 | + (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines |
|
| 199 | 199 | 'em; overflow: auto; }}</style>'; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if($msg) |
|
| 202 | + if ($msg) |
|
| 203 | 203 | { |
| 204 | 204 | Framework::message($msg); |
| 205 | 205 | } |
| 206 | - $html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0); |
|
| 206 | + $html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0); |
|
| 207 | 207 | |
| 208 | 208 | // Not sure why this has to be echoed instead of appended, but that's what works. |
| 209 | 209 | //echo calendar_uiviews::edit_series(); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | /** |
| 215 | 215 | * set filter for search, so that everything is shown |
| 216 | 216 | */ |
| 217 | - function adjust_for_search($keywords,&$params) |
|
| 217 | + function adjust_for_search($keywords, &$params) |
|
| 218 | 218 | { |
| 219 | 219 | $params['search'] = $keywords; |
| 220 | 220 | $params['start'] = 0; |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | * @param array &$rows returned rows/events |
| 241 | 241 | * @param array &$readonlys eg. to disable buttons based on Acl |
| 242 | 242 | */ |
| 243 | - function get_rows(&$params,&$rows,&$readonlys) |
|
| 243 | + function get_rows(&$params, &$rows, &$readonlys) |
|
| 244 | 244 | { |
| 245 | - unset($readonlys); // not used; |
|
| 245 | + unset($readonlys); // not used; |
|
| 246 | 246 | //echo "uilist::get_rows() params="; _debug_array($params); |
| 247 | 247 | $this->filter = $params['filter']; |
| 248 | 248 | if ($params['filter'] == 'custom') |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | if ($old_params['search'] != $params['search']) |
| 274 | 274 | { |
| 275 | - $this->adjust_for_search($params['search'],$params); |
|
| 275 | + $this->adjust_for_search($params['search'], $params); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | if (!$params['csv_export']) Api\Cache::setSession('calendar', 'calendar_list', $params); |
@@ -280,23 +280,23 @@ discard block |
||
| 280 | 280 | // do we need to query custom fields and which |
| 281 | 281 | // Check stored preference if selectcols isn't available (ie: first call) |
| 282 | 282 | $select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows']; |
| 283 | - if(!is_array($params['selectcols'])) |
|
| 283 | + if (!is_array($params['selectcols'])) |
|
| 284 | 284 | { |
| 285 | - $select_cols = explode(',',$select_cols); |
|
| 285 | + $select_cols = explode(',', $select_cols); |
|
| 286 | 286 | } |
| 287 | - if (in_array('cfs',$select_cols)) |
|
| 287 | + if (in_array('cfs', $select_cols)) |
|
| 288 | 288 | { |
| 289 | 289 | $cfs = array(); |
| 290 | - foreach($select_cols as $col) |
|
| 290 | + foreach ($select_cols as $col) |
|
| 291 | 291 | { |
| 292 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 292 | + if ($col[0] == '#') $cfs[] = substr($col, 1); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | $search_params = array( |
| 296 | 296 | 'cat_id' => $params['cat_id'] ? $params['cat_id'] : 0, |
| 297 | 297 | 'filter' => $this->filter, |
| 298 | 298 | 'query' => $params['search'], |
| 299 | - 'offset' => (int) $params['start'], |
|
| 299 | + 'offset' => (int)$params['start'], |
|
| 300 | 300 | 'num_rows'=> $params['num_rows'], |
| 301 | 301 | 'order' => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC', |
| 302 | 302 | 'cfs' => $params['csv_export'] ? array() : $cfs, |
@@ -304,24 +304,24 @@ discard block |
||
| 304 | 304 | // Non-blocking events above blocking |
| 305 | 305 | $search_params['order'] .= ', cal_non_blocking DESC'; |
| 306 | 306 | |
| 307 | - switch($this->filter) |
|
| 307 | + switch ($this->filter) |
|
| 308 | 308 | { |
| 309 | 309 | case 'all': |
| 310 | 310 | break; |
| 311 | 311 | case 'before': |
| 312 | - $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date; |
|
| 313 | - $label = lang('Before %1',$this->bo->long_date($search_params['end'])); |
|
| 312 | + $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date; |
|
| 313 | + $label = lang('Before %1', $this->bo->long_date($search_params['end'])); |
|
| 314 | 314 | break; |
| 315 | 315 | case 'custom': |
| 316 | - $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts'); |
|
| 317 | - $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1; |
|
| 318 | - $label = $this->bo->long_date($this->first,$this->last); |
|
| 316 | + $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts'); |
|
| 317 | + $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1; |
|
| 318 | + $label = $this->bo->long_date($this->first, $this->last); |
|
| 319 | 319 | break; |
| 320 | 320 | case 'today': |
| 321 | 321 | $today = new Api\DateTime(); |
| 322 | 322 | $today->setTime(0, 0, 0); |
| 323 | 323 | $this->first = $search_params['start'] = $today->format('ts'); |
| 324 | - $today->setTime(23,59,59); |
|
| 324 | + $today->setTime(23, 59, 59); |
|
| 325 | 325 | $this->last = $search_params['end'] = $today->format('ts'); |
| 326 | 326 | break; |
| 327 | 327 | case 'week': |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 334 | 334 | unset($this->last['raw']); |
| 335 | 335 | $this->last = $this->bo->date2ts($this->last); |
| 336 | - $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last); |
|
| 336 | + $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last); |
|
| 337 | 337 | $search_params['start'] = $this->first; |
| 338 | 338 | $search_params['end'] = $this->last; |
| 339 | 339 | $params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | unset($this->first['raw']); |
| 347 | 347 | $this->last = $this->first; |
| 348 | 348 | $this->last['month'] += 1; |
| 349 | - $this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 349 | + $this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 350 | 350 | $this->first = $this->bo->date2ts($this->first); |
| 351 | 351 | $this->last = $this->bo->date2ts($this->last); |
| 352 | 352 | $this->last--; |
@@ -359,29 +359,29 @@ discard block |
||
| 359 | 359 | // fall through to after given date |
| 360 | 360 | case 'after': |
| 361 | 361 | default: |
| 362 | - $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date; |
|
| 363 | - $label = lang('After %1',$this->bo->long_date($this->date)); |
|
| 362 | + $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date; |
|
| 363 | + $label = lang('After %1', $this->bo->long_date($this->date)); |
|
| 364 | 364 | $search_params['start'] = $this->date; |
| 365 | 365 | break; |
| 366 | 366 | } |
| 367 | - if($params['status_filter']) |
|
| 367 | + if ($params['status_filter']) |
|
| 368 | 368 | { |
| 369 | 369 | $search_params['filter'] = $params['status_filter']; |
| 370 | 370 | } |
| 371 | 371 | if ($params['col_filter']['participant']) |
| 372 | 372 | { |
| 373 | - $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']); |
|
| 373 | + $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']); |
|
| 374 | 374 | } |
| 375 | 375 | elseif (!$params['col_filter'] || !$params['col_filter']['participant']) |
| 376 | 376 | { |
| 377 | - $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner); |
|
| 377 | + $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner); |
|
| 378 | 378 | } |
| 379 | 379 | if ($params['col_filter']) |
| 380 | 380 | { |
| 381 | 381 | $col_filter = array(); |
| 382 | - foreach($params['col_filter'] as $name => $val) |
|
| 382 | + foreach ($params['col_filter'] as $name => $val) |
|
| 383 | 383 | { |
| 384 | - if (!in_array($name, array('participant','row_id')) && (string)$val !== '') |
|
| 384 | + if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '') |
|
| 385 | 385 | { |
| 386 | 386 | $col_filter[$name] = $val; |
| 387 | 387 | } |
@@ -391,18 +391,18 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // App header is mostly taken care of on the client side, but here we update |
| 393 | 393 | // it to match changing list filters |
| 394 | - if($params['view'] && $params['view'] == 'listview') |
|
| 394 | + if ($params['view'] && $params['view'] == 'listview') |
|
| 395 | 395 | { |
| 396 | 396 | Api\Json\Response::get()->call('app.calendar.set_app_header', |
| 397 | - (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') . |
|
| 397 | + (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : ''). |
|
| 398 | 398 | $label); |
| 399 | 399 | } |
| 400 | - foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 400 | + foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 401 | 401 | { |
| 402 | 402 | |
| 403 | 403 | if ($params['csv_export']) |
| 404 | 404 | { |
| 405 | - $event['participants'] = implode(",\n",$this->bo->participants($event,true)); |
|
| 405 | + $event['participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 406 | 406 | } |
| 407 | 407 | else |
| 408 | 408 | { |
@@ -410,23 +410,23 @@ discard block |
||
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $matches = null; |
| 413 | - if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches)) |
|
| 413 | + if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches)) |
|
| 414 | 414 | { |
| 415 | 415 | $app = $matches[1]; |
| 416 | 416 | $app_id = $matches[2]; |
| 417 | 417 | $icons = array(); |
| 418 | - if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event))) |
|
| 418 | + if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event))) |
|
| 419 | 419 | { |
| 420 | - $icons[] = Api\Html::image('calendar','private'); |
|
| 420 | + $icons[] = Api\Html::image('calendar', 'private'); |
|
| 421 | 421 | } |
| 422 | 422 | else |
| 423 | 423 | { |
| 424 | - $icons = calendar_uiviews::integration_get_icons($app,$app_id,$event); |
|
| 424 | + $icons = calendar_uiviews::integration_get_icons($app, $app_id, $event); |
|
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | else |
| 428 | 428 | { |
| 429 | - $is_private = !$this->bo->check_perms(Acl::READ,$event); |
|
| 429 | + $is_private = !$this->bo->check_perms(Acl::READ, $event); |
|
| 430 | 430 | } |
| 431 | 431 | if ($is_private) |
| 432 | 432 | { |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | $event['app_id'] = $event['id']; |
| 438 | 438 | |
| 439 | 439 | // Edit link |
| 440 | - if($app && $app_id) |
|
| 440 | + if ($app && $app_id) |
|
| 441 | 441 | { |
| 442 | - $popup = calendar_uiviews::integration_get_popup($app,$app_id); |
|
| 442 | + $popup = calendar_uiviews::integration_get_popup($app, $app_id); |
|
| 443 | 443 | |
| 444 | 444 | // Need to strip off 'onclick' |
| 445 | 445 | $event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup); |
@@ -450,18 +450,18 @@ discard block |
||
| 450 | 450 | // populate js_integration_data, if not already set |
| 451 | 451 | if (!isset($js_integration_data[$app])) |
| 452 | 452 | { |
| 453 | - $js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 453 | + $js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | elseif ($event['recur_type'] != MCAL_RECUR_NONE) |
| 457 | 457 | { |
| 458 | - $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts'); |
|
| 458 | + $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts'); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Format start and end with timezone |
| 462 | - foreach(array('start','end') as $time) |
|
| 462 | + foreach (array('start', 'end') as $time) |
|
| 463 | 463 | { |
| 464 | - $event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z'); |
|
| 464 | + $event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z'); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $rows[] = $event; |
@@ -471,35 +471,35 @@ discard block |
||
| 471 | 471 | // set js_calendar_integration object, to use it in app.js cal_open() function |
| 472 | 472 | $params['js_integration_data'] = json_encode($js_integration_data); |
| 473 | 473 | |
| 474 | - $wv=0; |
|
| 475 | - $dv=0; |
|
| 474 | + $wv = 0; |
|
| 475 | + $dv = 0; |
|
| 476 | 476 | |
| 477 | 477 | // Add in some select options |
| 478 | - $users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']); |
|
| 478 | + $users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']); |
|
| 479 | 479 | |
| 480 | 480 | $this->bo->warnings['groupmembers'] = ''; |
| 481 | - if(($message = $this->check_owners_access($users))) |
|
| 481 | + if (($message = $this->check_owners_access($users))) |
|
| 482 | 482 | { |
| 483 | 483 | Api\Json\Response::get()->error($message); |
| 484 | 484 | } |
| 485 | - else if($this->bo->warnings['groupmembers']) |
|
| 485 | + else if ($this->bo->warnings['groupmembers']) |
|
| 486 | 486 | { |
| 487 | 487 | Api\Json\Response::get()->error($this->bo->warnings['groupmembers']); |
| 488 | 488 | } |
| 489 | 489 | $rows['sel_options']['filter'] = $this->date_filters; |
| 490 | - if($label) |
|
| 490 | + if ($label) |
|
| 491 | 491 | { |
| 492 | 492 | $rows['sel_options']['filter'][$params['filter']] = $label; |
| 493 | 493 | } |
| 494 | - foreach($users as $owner) |
|
| 494 | + foreach ($users as $owner) |
|
| 495 | 495 | { |
| 496 | - if(!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 496 | + if (!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 497 | 497 | { |
| 498 | 498 | $app = $this->bo->resources[$owner[0]]['app']; |
| 499 | - $_owner = substr($owner,1); |
|
| 499 | + $_owner = substr($owner, 1); |
|
| 500 | 500 | // Try link first |
| 501 | - $title = Link::title($app, $_owner ); |
|
| 502 | - if($title) |
|
| 501 | + $title = Link::title($app, $_owner); |
|
| 502 | + if ($title) |
|
| 503 | 503 | { |
| 504 | 504 | $rows['sel_options']['owner'][$owner] = $title; |
| 505 | 505 | } |
@@ -507,15 +507,15 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | $params['options-selectcols']['week'] = lang('Week'); |
| 509 | 509 | $params['options-selectcols']['weekday'] = lang('Weekday'); |
| 510 | - if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,') |
|
| 510 | + if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,') |
|
| 511 | 511 | { |
| 512 | - $rows['format'] = '32'; // prefix date with week-number |
|
| 513 | - $wv=1; |
|
| 512 | + $rows['format'] = '32'; // prefix date with week-number |
|
| 513 | + $wv = 1; |
|
| 514 | 514 | } |
| 515 | - if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE)) |
|
| 515 | + if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE)) |
|
| 516 | 516 | { |
| 517 | 517 | $rows['format'] = '16'; |
| 518 | - $dv=1; |
|
| 518 | + $dv = 1; |
|
| 519 | 519 | } |
| 520 | 520 | if ($wv && $dv) |
| 521 | 521 | { |
@@ -542,36 +542,36 @@ discard block |
||
| 542 | 542 | * @param string/array $session_name 'calendar_list' |
| 543 | 543 | * @return boolean true if all actions succeded, false otherwise |
| 544 | 544 | */ |
| 545 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
|
| 545 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false) |
|
| 546 | 546 | { |
| 547 | 547 | //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)"); |
| 548 | 548 | $success = $failed = 0; |
| 549 | 549 | $msg = null; |
| 550 | 550 | |
| 551 | 551 | // Split out combined values |
| 552 | - if(strpos($action, 'status') !== false) |
|
| 552 | + if (strpos($action, 'status') !== false) |
|
| 553 | 553 | { |
| 554 | 554 | list($action, $status) = explode('-', $action); |
| 555 | 555 | } |
| 556 | 556 | elseif (strpos($action, '_') !== false) |
| 557 | 557 | { |
| 558 | - list($action, $settings) = explode('_', $action,2); |
|
| 558 | + list($action, $settings) = explode('_', $action, 2); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | if ($use_all) |
| 562 | 562 | { |
| 563 | 563 | // get the whole selection |
| 564 | 564 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 565 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 566 | - $query['num_rows'] = -1; // all |
|
| 565 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 566 | + $query['num_rows'] = -1; // all |
|
| 567 | 567 | $readonlys = null; |
| 568 | - $this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document'))); // true = only return the id's |
|
| 568 | + $this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's |
|
| 569 | 569 | // Get rid of any extras (rows that aren't events) |
| 570 | - if(in_array($action,array('ical','document'))) |
|
| 570 | + if (in_array($action, array('ical', 'document'))) |
|
| 571 | 571 | { |
| 572 | - foreach($checked as $key => $event) |
|
| 572 | + foreach ($checked as $key => $event) |
|
| 573 | 573 | { |
| 574 | - if(!is_numeric($key)) |
|
| 574 | + if (!is_numeric($key)) |
|
| 575 | 575 | { |
| 576 | 576 | unset($checked[$key]); |
| 577 | 577 | } |
@@ -579,27 +579,27 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | // for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id |
| 582 | - elseif($action == 'document') |
|
| 582 | + elseif ($action == 'document') |
|
| 583 | 583 | { |
| 584 | 584 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 585 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 585 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 586 | 586 | $events = null; |
| 587 | - $this->get_rows($query,$events,$readonlys); |
|
| 588 | - foreach($events as $key => $event) |
|
| 587 | + $this->get_rows($query, $events, $readonlys); |
|
| 588 | + foreach ($events as $key => $event) |
|
| 589 | 589 | { |
| 590 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 590 | + if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 591 | 591 | } |
| 592 | 592 | $checked = array_values($events); // Clear keys |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // Actions where one action is done to the group |
| 596 | - switch($action) |
|
| 596 | + switch ($action) |
|
| 597 | 597 | { |
| 598 | 598 | case 'ical': |
| 599 | 599 | // compile list of unique cal_id's, as iCal should contain whole series, not recurrences |
| 600 | 600 | // calendar_ical->exportVCal needs to read events again, to get them in server-time |
| 601 | 601 | $ids = array(); |
| 602 | - foreach($checked as $id) |
|
| 602 | + foreach ($checked as $id) |
|
| 603 | 603 | { |
| 604 | 604 | if (is_array($id)) $id = $id['id']; |
| 605 | 605 | // get rid of recurrences, doublicate series and calendar-integration events |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | $boical = new calendar_ical(); |
| 612 | - $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 612 | + $ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 613 | 613 | Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical)); |
| 614 | 614 | echo $ical; |
| 615 | 615 | exit(); |
@@ -624,19 +624,19 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Actions where the action is applied to each entry |
| 627 | - if(strpos($action, 'timesheet') !== false) |
|
| 627 | + if (strpos($action, 'timesheet') !== false) |
|
| 628 | 628 | { |
| 629 | 629 | $timesheet_bo = new timesheet_bo(); |
| 630 | 630 | } |
| 631 | - foreach($checked as &$id) |
|
| 631 | + foreach ($checked as &$id) |
|
| 632 | 632 | { |
| 633 | 633 | $recur_date = $app = $app_id = null; |
| 634 | - if(is_array($id) && $id['id']) |
|
| 634 | + if (is_array($id) && $id['id']) |
|
| 635 | 635 | { |
| 636 | 636 | $id = $id['id']; |
| 637 | 637 | } |
| 638 | 638 | $matches = null; |
| 639 | - if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches)) |
|
| 639 | + if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches)) |
|
| 640 | 640 | { |
| 641 | 641 | $app = $matches[1]; |
| 642 | 642 | $app_id = $matches[2]; |
@@ -644,36 +644,36 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | else |
| 646 | 646 | { |
| 647 | - list($id,$recur_date) = explode(':',$id); |
|
| 647 | + list($id, $recur_date) = explode(':', $id); |
|
| 648 | 648 | } |
| 649 | - switch($action) |
|
| 649 | + switch ($action) |
|
| 650 | 650 | { |
| 651 | 651 | case 'delete': |
| 652 | 652 | $action_msg = lang('deleted'); |
| 653 | - if($settings == 'series') |
|
| 653 | + if ($settings == 'series') |
|
| 654 | 654 | { |
| 655 | 655 | // Delete the whole thing |
| 656 | 656 | $recur_date = 0; |
| 657 | 657 | } |
| 658 | - if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) |
|
| 658 | + if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification)) |
|
| 659 | 659 | { |
| 660 | 660 | $success++; |
| 661 | - if(!$recur_date && $settings == 'series') |
|
| 661 | + if (!$recur_date && $settings == 'series') |
|
| 662 | 662 | { |
| 663 | 663 | // If there are multiple events in a series selected, the next one could purge |
| 664 | - foreach($checked as $key => $c_id) |
|
| 664 | + foreach ($checked as $key => $c_id) |
|
| 665 | 665 | { |
| 666 | - list($c_id,$recur_date) = explode(':',$c_id); |
|
| 667 | - if($c_id == $id) |
|
| 666 | + list($c_id, $recur_date) = explode(':', $c_id); |
|
| 667 | + if ($c_id == $id) |
|
| 668 | 668 | { |
| 669 | 669 | unset($checked[$key]); |
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if(Api\Json\Response::isJSONResponse()) |
|
| 674 | + if (Api\Json\Response::isJSONResponse()) |
|
| 675 | 675 | { |
| 676 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete'); |
|
| 676 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete'); |
|
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | else |
@@ -683,23 +683,23 @@ discard block |
||
| 683 | 683 | break; |
| 684 | 684 | case 'undelete': |
| 685 | 685 | $action_msg = lang('recovered'); |
| 686 | - if($settings == 'series') |
|
| 686 | + if ($settings == 'series') |
|
| 687 | 687 | { |
| 688 | 688 | // unDelete the whole thing |
| 689 | 689 | $recur_date = 0; |
| 690 | 690 | } |
| 691 | - if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) && |
|
| 691 | + if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) && |
|
| 692 | 692 | is_array($event) && $event['deleted']) |
| 693 | 693 | { |
| 694 | 694 | $event['deleted'] = null; |
| 695 | - if($this->bo->save($event)) |
|
| 695 | + if ($this->bo->save($event)) |
|
| 696 | 696 | { |
| 697 | 697 | $success++; |
| 698 | 698 | |
| 699 | - if(Api\Json\Response::isJSONResponse()) |
|
| 699 | + if (Api\Json\Response::isJSONResponse()) |
|
| 700 | 700 | { |
| 701 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 702 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit'); |
|
| 701 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 702 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit'); |
|
| 703 | 703 | } |
| 704 | 704 | break; |
| 705 | 705 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | break; |
| 709 | 709 | case 'status': |
| 710 | 710 | $action_msg = lang('Status changed'); |
| 711 | - if($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 711 | + if ($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 712 | 712 | { |
| 713 | 713 | $old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']]; |
| 714 | 714 | $quantity = $role = null; |
@@ -717,12 +717,12 @@ discard block |
||
| 717 | 717 | { |
| 718 | 718 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 719 | 719 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 720 | - if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date, |
|
| 721 | - false,true,$skip_notification)) |
|
| 720 | + if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date, |
|
| 721 | + false, true, $skip_notification)) |
|
| 722 | 722 | { |
| 723 | - if(Api\Json\Response::isJSONResponse()) |
|
| 723 | + if (Api\Json\Response::isJSONResponse()) |
|
| 724 | 724 | { |
| 725 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 725 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 726 | 726 | } |
| 727 | 727 | $success++; |
| 728 | 728 | //$msg = lang('Status changed'); |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | break; |
| 741 | 741 | case 'timesheet-add': |
| 742 | - if($id && !$app) |
|
| 742 | + if ($id && !$app) |
|
| 743 | 743 | { |
| 744 | 744 | $event = $this->bo->read($id, $recur_date); |
| 745 | 745 | } |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | $result = $this->bo->search($query); |
| 752 | 752 | $event = $result[$app.$app_id]; |
| 753 | 753 | } |
| 754 | - if(!$event) |
|
| 754 | + if (!$event) |
|
| 755 | 755 | { |
| 756 | 756 | $failed++; |
| 757 | 757 | continue; |
@@ -768,16 +768,16 @@ discard block |
||
| 768 | 768 | ); |
| 769 | 769 | |
| 770 | 770 | // Add global categories |
| 771 | - $categories = explode(',',$event['category']); |
|
| 771 | + $categories = explode(',', $event['category']); |
|
| 772 | 772 | $global_categories = array(); |
| 773 | - foreach($categories as $cat_id) |
|
| 773 | + foreach ($categories as $cat_id) |
|
| 774 | 774 | { |
| 775 | - if($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 775 | + if ($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 776 | 776 | { |
| 777 | 777 | $global_categories[] = $cat_id; |
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | - if(count($global_categories)) |
|
| 780 | + if (count($global_categories)) |
|
| 781 | 781 | { |
| 782 | 782 | $timesheet['cat_id'] = implode(',', $global_categories); |
| 783 | 783 | } |
@@ -797,12 +797,12 @@ discard block |
||
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - if(!$err) |
|
| 800 | + if (!$err) |
|
| 801 | 801 | { |
| 802 | 802 | $success++; |
| 803 | 803 | |
| 804 | 804 | // Can't link to just one of a recurring series of events |
| 805 | - if(!$recur_date || $app) { |
|
| 805 | + if (!$recur_date || $app) { |
|
| 806 | 806 | // Create link |
| 807 | 807 | $link_id = $app ? $app_id : $id; |
| 808 | 808 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | protected function get_merge_range($nm) |
| 831 | 831 | { |
| 832 | 832 | $checked = array(); |
| 833 | - if($nm['filter'] == 'fixed') |
|
| 833 | + if ($nm['filter'] == 'fixed') |
|
| 834 | 834 | { |
| 835 | 835 | $checked['start'] = $nm['startdate']; |
| 836 | 836 | $last = $this->bo->date2array($nm['enddate']); |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | else |
| 841 | 841 | { |
| 842 | - switch($nm['filter']) |
|
| 842 | + switch ($nm['filter']) |
|
| 843 | 843 | { |
| 844 | 844 | case 'after': |
| 845 | 845 | $checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today'); |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | $checked['end'] = $nm['enddate']; |
| 853 | 853 | break; |
| 854 | 854 | default: |
| 855 | - $date = date_create_from_format('Ymd',$this->date); |
|
| 856 | - $checked['start']= $date->format('U'); |
|
| 855 | + $date = date_create_from_format('Ymd', $this->date); |
|
| 856 | + $checked['start'] = $date->format('U'); |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | return $checked; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | 'allowOnMultiple' => false, |
| 879 | 879 | 'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id', |
| 880 | 880 | 'popup' => Link::get_registry('calendar', 'view_popup'), |
| 881 | - 'group' => $group=1, |
|
| 881 | + 'group' => $group = 1, |
|
| 882 | 882 | 'onExecute' => 'javaScript:app.calendar.cal_open', |
| 883 | 883 | 'disableClass' => 'rowNoView', |
| 884 | 884 | ), |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | 'group' => $group, |
| 904 | 904 | ), |
| 905 | 905 | ); |
| 906 | - $status = array_map('lang',$this->bo->verbose_status); |
|
| 906 | + $status = array_map('lang', $this->bo->verbose_status); |
|
| 907 | 907 | unset($status['G']); |
| 908 | 908 | $actions['status'] = array( |
| 909 | 909 | 'caption' => 'Change your status', |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | 'children' => $status, |
| 913 | 913 | 'group' => ++$group, |
| 914 | 914 | ); |
| 915 | - ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 915 | + ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 916 | 916 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 917 | 917 | { |
| 918 | 918 | $actions['filemanager'] = array( |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | 'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id', |
| 945 | 945 | 'group' => $group, |
| 946 | 946 | 'allowOnMultiple' => false, |
| 947 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 947 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 948 | 948 | 'onExecute' => 'javaScript:app.calendar.cal_fix_app_id', |
| 949 | 949 | 'popup' => Link::get_registry('timesheet', 'add_popup'), |
| 950 | 950 | ); |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | 'caption' => 'Timesheet', |
| 954 | 954 | 'group' => $group, |
| 955 | 955 | 'allowOnMultiple' => 'only', |
| 956 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 956 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 957 | 957 | ); |
| 958 | 958 | } |
| 959 | 959 | $actions['ical'] = array( |
@@ -962,11 +962,11 @@ discard block |
||
| 962 | 962 | 'group' => ++$group, |
| 963 | 963 | 'hint' => 'Download this event as iCal', |
| 964 | 964 | 'disableClass' => 'rowNoView', |
| 965 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 965 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 966 | 966 | ); |
| 967 | 967 | $actions['documents'] = calendar_merge::document_action( |
| 968 | 968 | $this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_', |
| 969 | - $this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar') |
|
| 969 | + $this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar') |
|
| 970 | 970 | ); |
| 971 | 971 | ++$group; |
| 972 | 972 | $actions['delete'] = array( |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | 'disableClass' => 'rowNoDelete', |
| 977 | 977 | ); |
| 978 | 978 | // Add in deleted for admins |
| 979 | - if($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 979 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 980 | 980 | { |
| 981 | 981 | $actions['undelete'] = array( |
| 982 | 982 | 'caption' => 'Un-delete', |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | /** |
| 413 | 413 | * Displays the planner view |
| 414 | 414 | * |
| 415 | - * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 415 | + * @param null|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 416 | 416 | */ |
| 417 | 417 | function &planner($content = array(), $home=false) |
| 418 | 418 | { |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * Used for home app |
| 498 | 498 | * |
| 499 | 499 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 500 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 500 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 501 | 501 | */ |
| 502 | 502 | function &month($weeks=0,$home=false) |
| 503 | 503 | { |
@@ -580,6 +580,8 @@ discard block |
||
| 580 | 580 | * @param int &$first timestamp 0h of first day of week containing the first of the current month |
| 581 | 581 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 582 | 582 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 583 | + * @param integer $first |
|
| 584 | + * @param integer $last |
|
| 583 | 585 | */ |
| 584 | 586 | function _week_align_month(&$first,&$last,$day=1) |
| 585 | 587 | { |
@@ -604,7 +606,7 @@ discard block |
||
| 604 | 606 | * Displays the weekview, with 5 or 7 days |
| 605 | 607 | * |
| 606 | 608 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 607 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 609 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 608 | 610 | */ |
| 609 | 611 | function week($days=0,$home=false) |
| 610 | 612 | { |
@@ -740,7 +742,7 @@ discard block |
||
| 740 | 742 | /** |
| 741 | 743 | * Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider |
| 742 | 744 | * |
| 743 | - * @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 745 | + * @param string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 744 | 746 | * On return $todo_label contains the label for the todo-box |
| 745 | 747 | * @return string/boolean Api\Html with a table of open todo's or false if no hook availible |
| 746 | 748 | */ |
@@ -824,7 +826,7 @@ discard block |
||
| 824 | 826 | * - 'edit_popup' => '400x300' (optional) |
| 825 | 827 | * |
| 826 | 828 | * @param string $app |
| 827 | - * @param int|string $id |
|
| 829 | + * @param string $id |
|
| 828 | 830 | * @return string |
| 829 | 831 | */ |
| 830 | 832 | public static function integration_get_popup($app,$id) |
@@ -864,7 +866,7 @@ discard block |
||
| 864 | 866 | * Icons specified in $events['icons'] are always displayed! |
| 865 | 867 | * |
| 866 | 868 | * @param string $app |
| 867 | - * @param int|string $id |
|
| 869 | + * @param string $id |
|
| 868 | 870 | * @param array $event |
| 869 | 871 | * @return array |
| 870 | 872 | */ |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @var mixed |
| 43 | 43 | */ |
| 44 | - var $debug=false; |
|
| 44 | + var $debug = false; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * extra rows above and below the workday |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @var boolean |
| 94 | 94 | */ |
| 95 | - var $use_time_grid=true; |
|
| 95 | + var $use_time_grid = true; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Pref value of use_time_grid preference |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @var boolean |
| 107 | 107 | */ |
| 108 | - var $scroll_to_wdstart=false; |
|
| 108 | + var $scroll_to_wdstart = false; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * counter for the current whole day event of a single day |
| 112 | 112 | * |
| 113 | 113 | * @var int |
| 114 | 114 | */ |
| 115 | - var $wholeDayPosCounter=1; |
|
| 115 | + var $wholeDayPosCounter = 1; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Switch to disable private data and possibility to view and edit events |
@@ -135,25 +135,25 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 137 | 137 | */ |
| 138 | - function __construct($set_states=null) |
|
| 138 | + function __construct($set_states = null) |
|
| 139 | 139 | { |
| 140 | - parent::__construct(false,$set_states); // call the parent's constructor |
|
| 140 | + parent::__construct(false, $set_states); // call the parent's constructor |
|
| 141 | 141 | $this->extraRowsOriginal = $this->extraRows; //save original extraRows value |
| 142 | 142 | |
| 143 | 143 | $GLOBALS['egw_info']['flags']['nonavbar'] = False; |
| 144 | 144 | |
| 145 | 145 | // Check for GET message (from merge) |
| 146 | - if($_GET['msg']) |
|
| 146 | + if ($_GET['msg']) |
|
| 147 | 147 | { |
| 148 | 148 | Framework::message($_GET['msg']); |
| 149 | 149 | unset($_GET['msg']); |
| 150 | 150 | } |
| 151 | 151 | // standard params for calling bocal::search for all views |
| 152 | - $this->owner = str_replace('%2C',',',$this->owner); |
|
| 152 | + $this->owner = str_replace('%2C', ',', $this->owner); |
|
| 153 | 153 | $this->search_params = array( |
| 154 | 154 | 'start' => $this->date, |
| 155 | - 'cat_id' => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0, |
|
| 156 | - 'users' => explode(',',$this->owner), |
|
| 155 | + 'cat_id' => $this->cat_id ? (is_array($this->cat_id) ? $this->cat_id : explode(',', $this->cat_id)) : 0, |
|
| 156 | + 'users' => explode(',', $this->owner), |
|
| 157 | 157 | 'filter' => $this->filter, |
| 158 | 158 | 'daywise' => True, |
| 159 | 159 | 'use_so_events' => $this->test === 'true', |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function week_number($time) |
| 181 | 181 | { |
| 182 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 182 | + if (!is_a($time, 'DateTime')) $time = new Api\DateTime($time); |
|
| 183 | 183 | |
| 184 | 184 | // if week does not start Monday and $time is Sunday --> add one day |
| 185 | 185 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | /** |
| 198 | 198 | * Load all views used by calendar, client side switches between them as needed |
| 199 | 199 | */ |
| 200 | - function index($content=array()) |
|
| 200 | + function index($content = array()) |
|
| 201 | 201 | { |
| 202 | - if($content['merge']) |
|
| 202 | + if ($content['merge']) |
|
| 203 | 203 | { |
| 204 | 204 | // View from sidebox is JSON encoded |
| 205 | - $this->manage_states(array_merge($content,json_decode($content['view'],true))); |
|
| 206 | - if($content['first']) |
|
| 205 | + $this->manage_states(array_merge($content, json_decode($content['view'], true))); |
|
| 206 | + if ($content['first']) |
|
| 207 | 207 | { |
| 208 | - $this->first = Api\DateTime::to($content['first'],'ts'); |
|
| 208 | + $this->first = Api\DateTime::to($content['first'], 'ts'); |
|
| 209 | 209 | } |
| 210 | - if($content['last']) |
|
| 210 | + if ($content['last']) |
|
| 211 | 211 | { |
| 212 | - $this->last = Api\DateTime::to($content['last'],'ts'); |
|
| 212 | + $this->last = Api\DateTime::to($content['last'], 'ts'); |
|
| 213 | 213 | } |
| 214 | 214 | $_GET['merge'] = $content['merge']; |
| 215 | 215 | $this->merge(); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view)); |
| 226 | 226 | |
| 227 | 227 | // Sidebox & iframe for old views |
| 228 | - if(in_array($this->view,array('year')) && $_GET['view']) |
|
| 228 | + if (in_array($this->view, array('year')) && $_GET['view']) |
|
| 229 | 229 | { |
| 230 | 230 | $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
| 231 | 231 | $this->manage_states($_GET); |
@@ -237,24 +237,24 @@ discard block |
||
| 237 | 237 | $tmpl = new Etemplate('calendar.toolbar'); |
| 238 | 238 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 239 | 239 | // Adjust toolbar for mobile |
| 240 | - if(Api\Header\UserAgent::mobile()){ |
|
| 241 | - $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
|
| 242 | - $tmpl->setElementAttribute('toolbar','view_range', '3'); |
|
| 240 | + if (Api\Header\UserAgent::mobile()) { |
|
| 241 | + $tmpl->setElementAttribute('toolbar', 'class', 'et2_head_toolbar'); |
|
| 242 | + $tmpl->setElementAttribute('toolbar', 'view_range', '3'); |
|
| 243 | 243 | } |
| 244 | - $tmpl->exec('calendar_uiviews::index',array()); |
|
| 244 | + $tmpl->exec('calendar_uiviews::index', array()); |
|
| 245 | 245 | |
| 246 | 246 | // Load the different views once, we'll switch between them on the client side |
| 247 | 247 | $todo = new Etemplate('calendar.todo'); |
| 248 | 248 | $label = ''; |
| 249 | - $todo->exec('calendar_uiviews::index',array('todos'=>$this->get_todos($label), 'label' => $label)); |
|
| 249 | + $todo->exec('calendar_uiviews::index', array('todos'=>$this->get_todos($label), 'label' => $label)); |
|
| 250 | 250 | |
| 251 | 251 | // Actually, this takes care of most of it... |
| 252 | 252 | $this->week(); |
| 253 | 253 | |
| 254 | 254 | $planner = new Etemplate('calendar.planner'); |
| 255 | 255 | // Get the actions |
| 256 | - $planner->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 257 | - $planner->exec('calendar_uiviews::index',array()); |
|
| 256 | + $planner->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 257 | + $planner->exec('calendar_uiviews::index', array()); |
|
| 258 | 258 | |
| 259 | 259 | // List view in a separate file |
| 260 | 260 | $list_ui = new calendar_uilist(); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | { |
| 397 | 397 | foreach (array_keys($actions) as $key) |
| 398 | 398 | { |
| 399 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 399 | + if (!in_array($key, array('day_view', 'week_view', 'next', 'today', 'previous'))) { |
|
| 400 | 400 | $actions[$key]['toolbarDefault'] = false; |
| 401 | 401 | } |
| 402 | 402 | else { |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * |
| 415 | 415 | * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
| 416 | 416 | */ |
| 417 | - function &planner($content = array(), $home=false) |
|
| 417 | + function &planner($content = array(), $home = false) |
|
| 418 | 418 | { |
| 419 | 419 | if ($this->sortby == 'month') // yearly planner with month rows |
| 420 | 420 | { |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | unset($this->first['raw']); |
| 424 | 424 | $this->last = $this->first; |
| 425 | 425 | $this->last['year']++; |
| 426 | - $this->last = $this->bo->date2ts($this->last)-1; |
|
| 426 | + $this->last = $this->bo->date2ts($this->last) - 1; |
|
| 427 | 427 | } |
| 428 | 428 | elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
| 429 | 429 | { |
| 430 | 430 | if ($this->day < 15) // show one complete month |
| 431 | 431 | { |
| 432 | - $this->_week_align_month($this->first,$this->last); |
|
| 432 | + $this->_week_align_month($this->first, $this->last); |
|
| 433 | 433 | } |
| 434 | 434 | else // show 2 half month |
| 435 | 435 | { |
| 436 | - $this->_week_align_month($this->first,$this->last,15); |
|
| 436 | + $this->_week_align_month($this->first, $this->last, 15); |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | $start->setWeekstart(); |
| 443 | 443 | $this->first = $start->format('ts'); |
| 444 | 444 | $this->last = $this->bo->date2array($this->first); |
| 445 | - $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1; |
|
| 445 | + $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks']) - 1; |
|
| 446 | 446 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 447 | 447 | unset($this->last['raw']); |
| 448 | 448 | $this->last = $this->bo->date2ts($this->last); |
@@ -458,9 +458,9 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | $merge = $this->merge(); |
| 461 | - if($merge) |
|
| 461 | + if ($merge) |
|
| 462 | 462 | { |
| 463 | - Egw::redirect_link('/index.php',array( |
|
| 463 | + Egw::redirect_link('/index.php', array( |
|
| 464 | 464 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 465 | 465 | 'msg' => $merge, |
| 466 | 466 | )); |
@@ -472,21 +472,21 @@ discard block |
||
| 472 | 472 | $search_params['end'] = $this->last; |
| 473 | 473 | $search_params['enum_groups'] = $this->sortby == 'user'; |
| 474 | 474 | $content['planner'] = $this->bo->search($search_params); |
| 475 | - foreach($content['planner'] as &$event) |
|
| 475 | + foreach ($content['planner'] as &$event) |
|
| 476 | 476 | { |
| 477 | 477 | $this->to_client($event); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 480 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3', False, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last)); |
|
| 481 | 481 | |
| 482 | 482 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 483 | 483 | |
| 484 | - $tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 485 | - $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 486 | - $tmpl->setElementAttribute('planner','owner', $search_params['users']); |
|
| 487 | - $tmpl->setElementAttribute('planner','group_by', $this->sortby); |
|
| 484 | + $tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 485 | + $tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 486 | + $tmpl->setElementAttribute('planner', 'owner', $search_params['users']); |
|
| 487 | + $tmpl->setElementAttribute('planner', 'group_by', $this->sortby); |
|
| 488 | 488 | // Get the actions |
| 489 | - $tmpl->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 489 | + $tmpl->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 490 | 490 | |
| 491 | 491 | $tmpl->exec(__METHOD__, $content); |
| 492 | 492 | } |
@@ -499,30 +499,30 @@ discard block |
||
| 499 | 499 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 500 | 500 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 501 | 501 | */ |
| 502 | - function &month($weeks=0,$home=false) |
|
| 502 | + function &month($weeks = 0, $home = false) |
|
| 503 | 503 | { |
| 504 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 504 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2', True, $weeks, $this->date); |
|
| 505 | 505 | |
| 506 | 506 | if (!$home) |
| 507 | 507 | { |
| 508 | - trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED); |
|
| 508 | + trigger_error(__METHOD__.' only used by home app', E_USER_DEPRECATED); |
|
| 509 | 509 | return; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 512 | + $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 513 | 513 | $granularity = 0; |
| 514 | - if($weeks) |
|
| 514 | + if ($weeks) |
|
| 515 | 515 | { |
| 516 | 516 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 517 | 517 | |
| 518 | 518 | $list = $this->cal_prefs['use_time_grid']; |
| 519 | - if(!is_array($list)) |
|
| 519 | + if (!is_array($list)) |
|
| 520 | 520 | { |
| 521 | - $list = explode(',',$list); |
|
| 521 | + $list = explode(',', $list); |
|
| 522 | 522 | } |
| 523 | - if(is_array($list)) |
|
| 523 | + if (is_array($list)) |
|
| 524 | 524 | { |
| 525 | - $granularity = in_array('weekN',$list) ? 0 : $granularity; |
|
| 525 | + $granularity = in_array('weekN', $list) ? 0 : $granularity; |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | $content = array('view' => array()); |
@@ -532,23 +532,23 @@ discard block |
||
| 532 | 532 | $start = new Api\DateTime($this->date); |
| 533 | 533 | $start->setWeekstart(); |
| 534 | 534 | $this->first = $start->format('ts'); |
| 535 | - $this->last = strtotime("+$weeks weeks",$this->first) - 1; |
|
| 535 | + $this->last = strtotime("+$weeks weeks", $this->first) - 1; |
|
| 536 | 536 | $weekNavH = "$weeks weeks"; |
| 537 | 537 | $navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '. |
| 538 | - $this->bo->long_date($this->first,$this->last); |
|
| 538 | + $this->bo->long_date($this->first, $this->last); |
|
| 539 | 539 | } |
| 540 | 540 | else |
| 541 | 541 | { |
| 542 | - $this->_week_align_month($this->first,$this->last); |
|
| 542 | + $this->_week_align_month($this->first, $this->last); |
|
| 543 | 543 | $weekNavH = "1 month"; |
| 544 | - $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
|
| 544 | + $navHeader = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year; |
|
| 545 | 545 | } |
| 546 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 546 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4', False, $weeks, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last)); |
|
| 547 | 547 | |
| 548 | 548 | // Loop through, using Api\DateTime to handle DST |
| 549 | 549 | $week = 0; |
| 550 | 550 | $week_start = new EGroupware\Api\DateTime($this->first); |
| 551 | - $week_start->setTime(0,0,0); |
|
| 551 | + $week_start->setTime(0, 0, 0); |
|
| 552 | 552 | $week_end = new Api\DateTime($week_start); |
| 553 | 553 | $week_end->add(new DateInterval('P6DT23H59M59S')); |
| 554 | 554 | $last = new EGroupware\Api\DateTime($this->last); |
@@ -562,14 +562,14 @@ discard block |
||
| 562 | 562 | array( |
| 563 | 563 | 'id' => $week_start->format('Ymd') |
| 564 | 564 | ); |
| 565 | - $home->setElementAttribute("view[$week]",'onchange',false); |
|
| 566 | - $home->setElementAttribute("view[$week]",'granularity',$granularity); |
|
| 567 | - $home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']); |
|
| 565 | + $home->setElementAttribute("view[$week]", 'onchange', false); |
|
| 566 | + $home->setElementAttribute("view[$week]", 'granularity', $granularity); |
|
| 567 | + $home->setElementAttribute("view[$week]", 'show_weekend', $this->search_params['weekend']); |
|
| 568 | 568 | $week++; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | // Get the actions |
| 572 | - $home->setElementAttribute('view','actions',$this->get_actions()); |
|
| 572 | + $home->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 573 | 573 | |
| 574 | 574 | $home->exec(__METHOD__, $content); |
| 575 | 575 | } |
@@ -581,13 +581,13 @@ discard block |
||
| 581 | 581 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 582 | 582 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 583 | 583 | */ |
| 584 | - function _week_align_month(&$first,&$last,$day=1) |
|
| 584 | + function _week_align_month(&$first, &$last, $day = 1) |
|
| 585 | 585 | { |
| 586 | 586 | $start = new Api\DateTime($this->date); |
| 587 | - $start->setDate($this->year,$this->month,$this->day=$day); |
|
| 587 | + $start->setDate($this->year, $this->month, $this->day = $day); |
|
| 588 | 588 | $start->setWeekstart(); |
| 589 | 589 | $first = $start->format('ts'); |
| 590 | - $start->setDate($this->year,$this->month+1,$day); |
|
| 590 | + $start->setDate($this->year, $this->month + 1, $day); |
|
| 591 | 591 | if ($day == 1) $start->add('-1day'); |
| 592 | 592 | $start->setWeekstart(); |
| 593 | 593 | // now we need to calculate the end of the last day of that week |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | $arr['day'] += 6; |
| 597 | 597 | $arr['hour'] = 23; |
| 598 | 598 | $arr['min'] = $arr['sec'] = 59; |
| 599 | - unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 599 | + unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 600 | 600 | $last = $this->bo->date2ts($arr); |
| 601 | 601 | } |
| 602 | 602 | |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 607 | 607 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 608 | 608 | */ |
| 609 | - function week($days=0,$home=false) |
|
| 609 | + function week($days = 0, $home = false) |
|
| 610 | 610 | { |
| 611 | 611 | if (!$days) |
| 612 | 612 | { |
@@ -614,17 +614,17 @@ discard block |
||
| 614 | 614 | if ($days != 5) $days = 7; |
| 615 | 615 | if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
| 616 | 616 | { |
| 617 | - $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
|
| 617 | + $GLOBALS['egw']->preferences->add('calendar', 'days_in_weekview', $days); |
|
| 618 | 618 | $GLOBALS['egw']->preferences->save_repository(); |
| 619 | 619 | $this->cal_prefs['days_in_weekview'] = $days; |
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 622 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2', True, $days, $this->date); |
|
| 623 | 623 | |
| 624 | 624 | if ($days <= 4) // next 4 days view |
| 625 | 625 | { |
| 626 | 626 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 627 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 627 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 628 | 628 | $view = $days == 1 ? 'day' : 'day4'; |
| 629 | 629 | } |
| 630 | 630 | else |
@@ -634,30 +634,30 @@ discard block |
||
| 634 | 634 | $wd_start = $this->first = $start->format('ts'); |
| 635 | 635 | if ($days <= 5) // no weekend-days |
| 636 | 636 | { |
| 637 | - switch($this->cal_prefs['weekdaystarts']) |
|
| 637 | + switch ($this->cal_prefs['weekdaystarts']) |
|
| 638 | 638 | { |
| 639 | 639 | case 'Saturday': |
| 640 | - $this->first = strtotime("+2 days",$this->first); |
|
| 640 | + $this->first = strtotime("+2 days", $this->first); |
|
| 641 | 641 | break; |
| 642 | 642 | case 'Sunday': |
| 643 | - $this->first = strtotime("+1 day",$this->first); |
|
| 643 | + $this->first = strtotime("+1 day", $this->first); |
|
| 644 | 644 | break; |
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 647 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 648 | 648 | $view = 'week'; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 652 | 652 | |
| 653 | 653 | $list = $this->cal_prefs['use_time_grid']; |
| 654 | - if(!is_array($list)) |
|
| 654 | + if (!is_array($list)) |
|
| 655 | 655 | { |
| 656 | - $list = explode(',',$list); |
|
| 656 | + $list = explode(',', $list); |
|
| 657 | 657 | } |
| 658 | - if(is_array($list)) |
|
| 658 | + if (is_array($list)) |
|
| 659 | 659 | { |
| 660 | - $granularity = in_array($view,$list) ? 0 : $granularity; |
|
| 660 | + $granularity = in_array($view, $list) ? 0 : $granularity; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | $search_params = array( |
@@ -670,15 +670,15 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | $content = array('view' => array()); |
| 672 | 672 | |
| 673 | - if(!$home) |
|
| 673 | + if (!$home) |
|
| 674 | 674 | { |
| 675 | 675 | // Fill with the minimum needed 'weeks' |
| 676 | 676 | $min = max( |
| 677 | 677 | 6, // Some months need 6 weeks for full display |
| 678 | - $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 678 | + $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 679 | 679 | $this->cal_prefs['week_consolidate'] // We collapse after this many users |
| 680 | 680 | ); |
| 681 | - for($i = 0; $i < $min; $i++) |
|
| 681 | + for ($i = 0; $i < $min; $i++) |
|
| 682 | 682 | { |
| 683 | 683 | $content['view'][] = array(); |
| 684 | 684 | } |
@@ -686,8 +686,8 @@ discard block |
||
| 686 | 686 | else |
| 687 | 687 | { |
| 688 | 688 | // Always do 7 days for a week so scrolling works properly |
| 689 | - $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
|
| 690 | - if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
|
| 689 | + $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days", $this->first) - 1); |
|
| 690 | + if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] || // for more then X users, show all in one row |
|
| 691 | 691 | $days == 1 // Showing just 1 day |
| 692 | 692 | ) |
| 693 | 693 | { |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | else |
| 698 | 698 | { |
| 699 | - foreach(array_keys($this->_get_planner_users(false)) as $uid) |
|
| 699 | + foreach (array_keys($this->_get_planner_users(false)) as $uid) |
|
| 700 | 700 | { |
| 701 | 701 | $search_params['users'] = $uid; |
| 702 | 702 | $content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params)) |
@@ -704,15 +704,15 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | - $tmpl = $home ? $home :new Etemplate('calendar.view'); |
|
| 708 | - foreach(array_keys($content['view']) as $index) |
|
| 707 | + $tmpl = $home ? $home : new Etemplate('calendar.view'); |
|
| 708 | + foreach (array_keys($content['view']) as $index) |
|
| 709 | 709 | { |
| 710 | - $tmpl->setElementAttribute("view[$index]",'granularity',$granularity); |
|
| 711 | - $tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']); |
|
| 710 | + $tmpl->setElementAttribute("view[$index]", 'granularity', $granularity); |
|
| 711 | + $tmpl->setElementAttribute("view[$index]", 'show_weekend', $this->search_params['weekend']); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | // Get the actions |
| 715 | - $tmpl->setElementAttribute('view','actions',$this->get_actions()); |
|
| 715 | + $tmpl->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 716 | 716 | |
| 717 | 717 | $tmpl->exec(__METHOD__, $content); |
| 718 | 718 | } |
@@ -754,57 +754,56 @@ discard block |
||
| 754 | 754 | 'owner' => $this->owner // num. id of the user, not necessary current user |
| 755 | 755 | )); |
| 756 | 756 | |
| 757 | - if(is_array($todo_label)) |
|
| 757 | + if (is_array($todo_label)) |
|
| 758 | 758 | { |
| 759 | - list($label,$showall)=$todo_label; |
|
| 759 | + list($label, $showall) = $todo_label; |
|
| 760 | 760 | } |
| 761 | 761 | else |
| 762 | 762 | { |
| 763 | - $label=$todo_label; |
|
| 764 | - $showall=true; |
|
| 763 | + $label = $todo_label; |
|
| 764 | + $showall = true; |
|
| 765 | 765 | } |
| 766 | 766 | $maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
| 767 | - if($maxshow <= 0) |
|
| 767 | + if ($maxshow <= 0) |
|
| 768 | 768 | { |
| 769 | - $maxshow=10; |
|
| 769 | + $maxshow = 10; |
|
| 770 | 770 | } |
| 771 | 771 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
| 772 | 772 | |
| 773 | 773 | $content = $todo_label = ''; |
| 774 | 774 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
| 775 | 775 | { |
| 776 | - foreach($todos_from_hook as $todos) |
|
| 776 | + foreach ($todos_from_hook as $todos) |
|
| 777 | 777 | { |
| 778 | 778 | $i = 0; |
| 779 | 779 | if (is_array($todos)) |
| 780 | 780 | { |
| 781 | 781 | $todo_label = !empty($label) ? $label : lang("open ToDo's:"); |
| 782 | 782 | |
| 783 | - foreach($todos as &$todo) |
|
| 783 | + foreach ($todos as &$todo) |
|
| 784 | 784 | { |
| 785 | - if(!$showall && ($i++ > $maxshow)) |
|
| 785 | + if (!$showall && ($i++ > $maxshow)) |
|
| 786 | 786 | { |
| 787 | 787 | break; |
| 788 | 788 | } |
| 789 | 789 | $icons = ''; |
| 790 | - foreach($todo['icons'] as $name => $alt) |
|
| 790 | + foreach ($todo['icons'] as $name => $alt) |
|
| 791 | 791 | { |
| 792 | - $icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"'); |
|
| 792 | + $icons .= ($icons ? ' ' : '').Api\Html::image('infolog', $name, lang($alt), 'border="0" width="15" height="15"'); |
|
| 793 | 793 | } |
| 794 | 794 | $todo['icons'] = $icons; |
| 795 | 795 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 796 | - if($todo['edit']) { |
|
| 796 | + if ($todo['edit']) { |
|
| 797 | 797 | $todo['edit_size'] = $todo['edit']['size']; |
| 798 | 798 | unset($todo['edit']['size']); |
| 799 | - $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 800 | - $edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 801 | - $todo['edit'] = Framework::link('/index.php',$todo['edit'],true); |
|
| 799 | + $edit_icon_href = Api\Html::a_href($icons, $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 800 | + $edit_href = Api\Html::a_href($todo['title'], $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 801 | + $todo['edit'] = Framework::link('/index.php', $todo['edit'], true); |
|
| 802 | 802 | } |
| 803 | - $icon_href = Api\Html::a_href($icons,$todo['view']); |
|
| 803 | + $icon_href = Api\Html::a_href($icons, $todo['view']); |
|
| 804 | 804 | $content .= " <tr class=\"$class\">\n <td valign=\"top\" width=\"15%\" nowrap>". |
| 805 | - ($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)). |
|
| 806 | - "</td>\n <td>".($this->printer_friendly?$todo['title']: |
|
| 807 | - $edit_href)."</td>\n </tr>\n"; |
|
| 805 | + ($this->bo->printer_friendly ? $icons : ($edit_icon_href ? $edit_icon_href : $icon_href)). |
|
| 806 | + "</td>\n <td>".($this->printer_friendly ? $todo['title'] : $edit_href)."</td>\n </tr>\n"; |
|
| 808 | 807 | /** |
| 809 | 808 | * ToDo: add delete and closing action |
| 810 | 809 | */ |
@@ -827,9 +826,9 @@ discard block |
||
| 827 | 826 | * @param int|string $id |
| 828 | 827 | * @return string |
| 829 | 828 | */ |
| 830 | - public static function integration_get_popup($app,$id) |
|
| 829 | + public static function integration_get_popup($app, $id) |
|
| 831 | 830 | { |
| 832 | - $app_data = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 831 | + $app_data = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 833 | 832 | |
| 834 | 833 | if (is_array($app_data) && isset($app_data['edit'])) |
| 835 | 834 | { |
@@ -839,7 +838,7 @@ discard block |
||
| 839 | 838 | } |
| 840 | 839 | else |
| 841 | 840 | { |
| 842 | - $edit = Link::edit($app,$id,$popup_size); |
|
| 841 | + $edit = Link::edit($app, $id, $popup_size); |
|
| 843 | 842 | } |
| 844 | 843 | if ($edit) |
| 845 | 844 | { |
@@ -868,28 +867,28 @@ discard block |
||
| 868 | 867 | * @param array $event |
| 869 | 868 | * @return array |
| 870 | 869 | */ |
| 871 | - static function integration_get_icons($app,$id,$event) |
|
| 870 | + static function integration_get_icons($app, $id, $event) |
|
| 872 | 871 | { |
| 873 | 872 | $icons = array(); |
| 874 | 873 | if ($event['icons']) |
| 875 | 874 | { |
| 876 | - foreach(explode(',',$event['icons']) as $icon) |
|
| 875 | + foreach (explode(',', $event['icons']) as $icon) |
|
| 877 | 876 | { |
| 878 | - list($icon_app,$icon) = explode(':',$icon); |
|
| 879 | - if (Api\Image::find($icon_app,$icon)) |
|
| 877 | + list($icon_app, $icon) = explode(':', $icon); |
|
| 878 | + if (Api\Image::find($icon_app, $icon)) |
|
| 880 | 879 | { |
| 881 | - $icons[] = Api\Html::image($icon_app,$icon); |
|
| 880 | + $icons[] = Api\Html::image($icon_app, $icon); |
|
| 882 | 881 | } |
| 883 | 882 | } |
| 884 | 883 | } |
| 885 | - $app_data = calendar_bo::integration_get_data($app,'icons'); |
|
| 884 | + $app_data = calendar_bo::integration_get_data($app, 'icons'); |
|
| 886 | 885 | if (is_null($app_data)) |
| 887 | 886 | { |
| 888 | - $icons[] = Api\Html::image($app,'navbar'); // use navbar icon |
|
| 887 | + $icons[] = Api\Html::image($app, 'navbar'); // use navbar icon |
|
| 889 | 888 | } |
| 890 | 889 | elseif ($app_data) |
| 891 | 890 | { |
| 892 | - $icons += (array)ExecMethod2($app_data,$id,$event); |
|
| 891 | + $icons += (array)ExecMethod2($app_data, $id, $event); |
|
| 893 | 892 | } |
| 894 | 893 | return $icons; |
| 895 | 894 | } |
@@ -912,20 +911,20 @@ discard block |
||
| 912 | 911 | unset($actions['select_all']); |
| 913 | 912 | |
| 914 | 913 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 915 | - foreach($actions as $id => &$action) |
|
| 914 | + foreach ($actions as $id => &$action) |
|
| 916 | 915 | { |
| 917 | - if($id=='add') continue; |
|
| 918 | - if(!$action['enabled']) |
|
| 916 | + if ($id == 'add') continue; |
|
| 917 | + if (!$action['enabled']) |
|
| 919 | 918 | { |
| 920 | 919 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
| 921 | 920 | } |
| 922 | 921 | } |
| 923 | 922 | $actions['add']['open'] = '{"app":"calendar","type":"add"}'; |
| 924 | - $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 923 | + $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 925 | 924 | $actions['copy']['open'] = '{"app": "calendar", "type": "add", "extra": "cal_id=$id&action=copy"}'; |
| 926 | 925 | $actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 927 | 926 | |
| 928 | - foreach($actions['status']['children'] as $id => &$status) |
|
| 927 | + foreach ($actions['status']['children'] as $id => &$status) |
|
| 929 | 928 | { |
| 930 | 929 | $status = array( |
| 931 | 930 | 'id' => $id, |
@@ -936,7 +935,7 @@ discard block |
||
| 936 | 935 | |
| 937 | 936 | if ($actions['filemanager']) |
| 938 | 937 | { |
| 939 | - $actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url']; |
|
| 938 | + $actions['filemanager']['url'] = '/index.php?'.$actions['filemanager']['url']; |
|
| 940 | 939 | $actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 941 | 940 | } |
| 942 | 941 | if ($actions['infolog_app']) |
@@ -981,26 +980,26 @@ discard block |
||
| 981 | 980 | { |
| 982 | 981 | $start = $this->bo->date2array($event['start']); |
| 983 | 982 | $end = $this->bo->date2array($event['end']); |
| 984 | - if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 983 | + if (!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 985 | 984 | { |
| 986 | - if($event['non_blocking']) |
|
| 985 | + if ($event['non_blocking']) |
|
| 987 | 986 | { |
| 988 | - $dayEvents[$day][$num]['whole_day_on_top']=true; |
|
| 989 | - $this->whole_day_positions[$num]=($this->rowHeight*($num+2)); |
|
| 987 | + $dayEvents[$day][$num]['whole_day_on_top'] = true; |
|
| 988 | + $this->whole_day_positions[$num] = ($this->rowHeight * ($num + 2)); |
|
| 990 | 989 | $extraRowsToAdd++; |
| 991 | 990 | } |
| 992 | 991 | else |
| 993 | 992 | { |
| 994 | - $dayEvents[$day][$num]['whole_day']=true; |
|
| 993 | + $dayEvents[$day][$num]['whole_day'] = true; |
|
| 995 | 994 | } |
| 996 | 995 | } |
| 997 | 996 | $this->to_client($dayEvents[$day][$num]); |
| 998 | 997 | } |
| 999 | 998 | // check after every day if we have to increase $this->extraRows |
| 1000 | - if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows) |
|
| 999 | + if (($this->extraRowsOriginal + $extraRowsToAdd) > $this->extraRows) |
|
| 1001 | 1000 | { |
| 1002 | 1001 | $this->remBotExtraRows = $extraRowsToAdd; |
| 1003 | - $this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd); |
|
| 1002 | + $this->extraRows = ($this->extraRowsOriginal + $extraRowsToAdd); |
|
| 1004 | 1003 | } |
| 1005 | 1004 | } |
| 1006 | 1005 | } |
@@ -179,7 +179,10 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function week_number($time) |
| 181 | 181 | { |
| 182 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 182 | + if (!is_a($time,'DateTime')) |
|
| 183 | + { |
|
| 184 | + $time = new Api\DateTime($time); |
|
| 185 | + } |
|
| 183 | 186 | |
| 184 | 187 | // if week does not start Monday and $time is Sunday --> add one day |
| 185 | 188 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -237,7 +240,8 @@ discard block |
||
| 237 | 240 | $tmpl = new Etemplate('calendar.toolbar'); |
| 238 | 241 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 239 | 242 | // Adjust toolbar for mobile |
| 240 | - if(Api\Header\UserAgent::mobile()){ |
|
| 243 | + if(Api\Header\UserAgent::mobile()) |
|
| 244 | + { |
|
| 241 | 245 | $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
| 242 | 246 | $tmpl->setElementAttribute('toolbar','view_range', '3'); |
| 243 | 247 | } |
@@ -396,10 +400,12 @@ discard block |
||
| 396 | 400 | { |
| 397 | 401 | foreach (array_keys($actions) as $key) |
| 398 | 402 | { |
| 399 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 403 | + if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) |
|
| 404 | + { |
|
| 400 | 405 | $actions[$key]['toolbarDefault'] = false; |
| 401 | 406 | } |
| 402 | - else { |
|
| 407 | + else |
|
| 408 | + { |
|
| 403 | 409 | $actions[$key]['toolbarDefault'] = true; |
| 404 | 410 | } |
| 405 | 411 | } |
@@ -416,29 +422,38 @@ discard block |
||
| 416 | 422 | */ |
| 417 | 423 | function &planner($content = array(), $home=false) |
| 418 | 424 | { |
| 419 | - if ($this->sortby == 'month') // yearly planner with month rows |
|
| 425 | + if ($this->sortby == 'month') |
|
| 426 | + { |
|
| 427 | + // yearly planner with month rows |
|
| 420 | 428 | { |
| 421 | 429 | $this->first = $this->bo->date2array($this->date); |
| 430 | + } |
|
| 422 | 431 | $this->first['day'] = 1; |
| 423 | 432 | unset($this->first['raw']); |
| 424 | 433 | $this->last = $this->first; |
| 425 | 434 | $this->last['year']++; |
| 426 | 435 | $this->last = $this->bo->date2ts($this->last)-1; |
| 427 | 436 | } |
| 428 | - elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
|
| 437 | + elseif (!$this->planner_view || $this->planner_view == 'month') |
|
| 438 | + { |
|
| 439 | + // planner monthview |
|
| 429 | 440 | { |
| 430 | 441 | if ($this->day < 15) // show one complete month |
| 431 | 442 | { |
| 432 | 443 | $this->_week_align_month($this->first,$this->last); |
| 444 | + } |
|
| 433 | 445 | } |
| 434 | 446 | else // show 2 half month |
| 435 | 447 | { |
| 436 | 448 | $this->_week_align_month($this->first,$this->last,15); |
| 437 | 449 | } |
| 438 | 450 | } |
| 439 | - elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
|
| 451 | + elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') |
|
| 452 | + { |
|
| 453 | + // weeekview |
|
| 440 | 454 | { |
| 441 | 455 | $start = new Api\DateTime($this->date); |
| 456 | + } |
|
| 442 | 457 | $start->setWeekstart(); |
| 443 | 458 | $this->first = $start->format('ts'); |
| 444 | 459 | $this->last = $this->bo->date2array($this->first); |
@@ -477,7 +492,10 @@ discard block |
||
| 477 | 492 | $this->to_client($event); |
| 478 | 493 | } |
| 479 | 494 | |
| 480 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 495 | + if ($this->debug > 0) |
|
| 496 | + { |
|
| 497 | + $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 498 | + } |
|
| 481 | 499 | |
| 482 | 500 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 483 | 501 | |
@@ -501,7 +519,10 @@ discard block |
||
| 501 | 519 | */ |
| 502 | 520 | function &month($weeks=0,$home=false) |
| 503 | 521 | { |
| 504 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 522 | + if ($this->debug > 0) |
|
| 523 | + { |
|
| 524 | + $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 525 | + } |
|
| 505 | 526 | |
| 506 | 527 | if (!$home) |
| 507 | 528 | { |
@@ -543,7 +564,10 @@ discard block |
||
| 543 | 564 | $weekNavH = "1 month"; |
| 544 | 565 | $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
| 545 | 566 | } |
| 546 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 567 | + if ($this->debug > 0) |
|
| 568 | + { |
|
| 569 | + $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 570 | + } |
|
| 547 | 571 | |
| 548 | 572 | // Loop through, using Api\DateTime to handle DST |
| 549 | 573 | $week = 0; |
@@ -588,7 +612,10 @@ discard block |
||
| 588 | 612 | $start->setWeekstart(); |
| 589 | 613 | $first = $start->format('ts'); |
| 590 | 614 | $start->setDate($this->year,$this->month+1,$day); |
| 591 | - if ($day == 1) $start->add('-1day'); |
|
| 615 | + if ($day == 1) |
|
| 616 | + { |
|
| 617 | + $start->add('-1day'); |
|
| 618 | + } |
|
| 592 | 619 | $start->setWeekstart(); |
| 593 | 620 | // now we need to calculate the end of the last day of that week |
| 594 | 621 | // as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!! |
@@ -611,19 +638,31 @@ discard block |
||
| 611 | 638 | if (!$days) |
| 612 | 639 | { |
| 613 | 640 | $days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview']; |
| 614 | - if ($days != 5) $days = 7; |
|
| 615 | - if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
|
| 641 | + if ($days != 5) |
|
| 642 | + { |
|
| 643 | + $days = 7; |
|
| 644 | + } |
|
| 645 | + if ($days != $this->cal_prefs['days_in_weekview']) |
|
| 646 | + { |
|
| 647 | + // save the preference |
|
| 616 | 648 | { |
| 617 | 649 | $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
| 650 | + } |
|
| 618 | 651 | $GLOBALS['egw']->preferences->save_repository(); |
| 619 | 652 | $this->cal_prefs['days_in_weekview'] = $days; |
| 620 | 653 | } |
| 621 | 654 | } |
| 622 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 655 | + if ($this->debug > 0) |
|
| 656 | + { |
|
| 657 | + $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 658 | + } |
|
| 623 | 659 | |
| 624 | - if ($days <= 4) // next 4 days view |
|
| 660 | + if ($days <= 4) |
|
| 661 | + { |
|
| 662 | + // next 4 days view |
|
| 625 | 663 | { |
| 626 | 664 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 665 | + } |
|
| 627 | 666 | $this->last = strtotime("+$days days",$this->first) - 1; |
| 628 | 667 | $view = $days == 1 ? 'day' : 'day4'; |
| 629 | 668 | } |
@@ -632,12 +671,15 @@ discard block |
||
| 632 | 671 | $start = new Api\DateTime($this->date); |
| 633 | 672 | $start->setWeekstart(); |
| 634 | 673 | $wd_start = $this->first = $start->format('ts'); |
| 635 | - if ($days <= 5) // no weekend-days |
|
| 674 | + if ($days <= 5) |
|
| 675 | + { |
|
| 676 | + // no weekend-days |
|
| 636 | 677 | { |
| 637 | 678 | switch($this->cal_prefs['weekdaystarts']) |
| 638 | 679 | { |
| 639 | 680 | case 'Saturday': |
| 640 | 681 | $this->first = strtotime("+2 days",$this->first); |
| 682 | + } |
|
| 641 | 683 | break; |
| 642 | 684 | case 'Sunday': |
| 643 | 685 | $this->first = strtotime("+1 day",$this->first); |
@@ -666,7 +708,10 @@ discard block |
||
| 666 | 708 | ) + $this->search_params; |
| 667 | 709 | |
| 668 | 710 | $users = $this->search_params['users']; |
| 669 | - if (!is_array($users)) $users = array($users); |
|
| 711 | + if (!is_array($users)) |
|
| 712 | + { |
|
| 713 | + $users = array($users); |
|
| 714 | + } |
|
| 670 | 715 | |
| 671 | 716 | $content = array('view' => array()); |
| 672 | 717 | |
@@ -689,8 +734,7 @@ discard block |
||
| 689 | 734 | $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
| 690 | 735 | if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
| 691 | 736 | $days == 1 // Showing just 1 day |
| 692 | - ) |
|
| 693 | - { |
|
| 737 | + ) { |
|
| 694 | 738 | $content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) + |
| 695 | 739 | array('owner' => $users); |
| 696 | 740 | } |
@@ -793,7 +837,8 @@ discard block |
||
| 793 | 837 | } |
| 794 | 838 | $todo['icons'] = $icons; |
| 795 | 839 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 796 | - if($todo['edit']) { |
|
| 840 | + if($todo['edit']) |
|
| 841 | + { |
|
| 797 | 842 | $todo['edit_size'] = $todo['edit']['size']; |
| 798 | 843 | unset($todo['edit']['size']); |
| 799 | 844 | $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
@@ -914,7 +959,10 @@ discard block |
||
| 914 | 959 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 915 | 960 | foreach($actions as $id => &$action) |
| 916 | 961 | { |
| 917 | - if($id=='add') continue; |
|
| 962 | + if($id=='add') |
|
| 963 | + { |
|
| 964 | + continue; |
|
| 965 | + } |
|
| 918 | 966 | if(!$action['enabled']) |
| 919 | 967 | { |
| 920 | 968 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param int $truncsize |
| 273 | 273 | * @param int $bodypreference |
| 274 | 274 | * @param $optionbodypreference |
| 275 | - * @param bool $mimesupport |
|
| 275 | + * @param integer $mimesupport |
|
| 276 | 276 | * @return SyncMail |
| 277 | 277 | */ |
| 278 | 278 | function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0) |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | * @param string $displayname => new folder name (to be created, or to be renamed to) |
| 876 | 876 | * @param string $type folder type, ignored in IMAP |
| 877 | 877 | * |
| 878 | - * @return array|boolean stat array or false on error |
|
| 878 | + * @return boolean stat array or false on error |
|
| 879 | 879 | */ |
| 880 | 880 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 881 | 881 | { |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * @param string $id of the folder to delete |
| 891 | 891 | * |
| 892 | 892 | * @return |
| 893 | - * @TODO check what is to be returned |
|
| 893 | + boolean @TODO check what is to be returned |
|
| 894 | 894 | */ |
| 895 | 895 | public function DeleteFolder($parentid, $id) |
| 896 | 896 | { |
@@ -1578,6 +1578,7 @@ discard block |
||
| 1578 | 1578 | * Unpack timezone info from Sync |
| 1579 | 1579 | * |
| 1580 | 1580 | * copied from backend/ics.php |
| 1581 | + * @param string $data |
|
| 1581 | 1582 | */ |
| 1582 | 1583 | static public function _getTZFromSyncBlob($data) |
| 1583 | 1584 | { |
@@ -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(); |
@@ -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_exceptions'] = 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,8 +1672,8 @@ discard block |
||
| 1673 | 1672 | ) |
| 1674 | 1673 | ); |
| 1675 | 1674 | require_once('../../header.inc.php'); |
| 1676 | - ini_set('display_errors',1); |
|
| 1677 | - error_reporting(E_ALL & ~E_NOTICE); |
|
| 1675 | + ini_set('display_errors', 1); |
|
| 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"; |
| 1680 | 1679 | echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\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"; |
@@ -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); |
@@ -11,6 +11,10 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | use EGroupware\Api; |
| 13 | 13 | |
| 14 | +/** |
|
| 15 | + * @param string $table |
|
| 16 | + * @param string $field |
|
| 17 | + */ |
|
| 14 | 18 | function calendar_v0_9_2to0_9_3update_owner($table, $field) |
| 15 | 19 | { |
| 16 | 20 | $GLOBALS['egw_setup']->oProc->query("select distinct($field) from $table"); |
@@ -2306,7 +2310,7 @@ discard block |
||
| 2306 | 2310 | * |
| 2307 | 2311 | * Also fix recurring events containing a reference to an other master, created when an exception is made a recurring event. |
| 2308 | 2312 | * |
| 2309 | - * @return type |
|
| 2313 | + * @return string |
|
| 2310 | 2314 | */ |
| 2311 | 2315 | function calendar_upgrade14_1() |
| 2312 | 2316 | { |
@@ -1909,7 +1909,7 @@ |
||
| 1909 | 1909 | WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1912 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1913 | 1913 | WHERE recur_interval=0',__LINE__,__FILE__); |
| 1914 | 1914 | |
| 1915 | 1915 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $owner[count($owner)] = $GLOBALS['egw_setup']->oProc->f($field); |
| 22 | 22 | } |
| 23 | - if($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'],'0.9.10pre4')) |
|
| 23 | + if ($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.10pre4')) |
|
| 24 | 24 | { |
| 25 | 25 | $acctstbl = 'accounts'; |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $acctstbl = 'phpgw_accounts'; |
| 30 | 30 | } |
| 31 | - for($i=0;$i<count($owner);$i++) |
|
| 31 | + for ($i = 0; $i < count($owner); $i++) |
|
| 32 | 32 | { |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 34 | 34 | $GLOBALS['egw_setup']->oProc->next_record(); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function calendar_upgrade0_9_3pre1() |
| 43 | 43 | { |
| 44 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by'); |
|
| 45 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login'); |
|
| 44 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry', 'cal_create_by'); |
|
| 45 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry_user', 'cal_login'); |
|
| 46 | 46 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3pre2'; |
| 47 | 47 | return $GLOBALS['setup_info']['calendar']['currentver']; |
| 48 | 48 | } |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | ) |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__); |
|
| 212 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry', __LINE__, __FILE__); |
|
| 213 | 213 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 214 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 214 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 215 | 215 | { |
| 216 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 217 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 216 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 217 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 218 | 218 | { |
| 219 | 219 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 220 | 220 | $cal_owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | $cal_access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 225 | 225 | $cal_name = $GLOBALS['egw_setup']->oProc->f('cal_name'); |
| 226 | 226 | $cal_description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 227 | - $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),0,4))); |
|
| 228 | - $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),0,4))); |
|
| 229 | - $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 227 | + $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 0, 4))); |
|
| 228 | + $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 0, 4))); |
|
| 229 | + $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 230 | 230 | $db2->next_record(); |
| 231 | 231 | $cal_group = $db2->f('groups'); |
| 232 | 232 | $db2->query('INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) ' |
| 233 | - .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__); |
|
| 233 | + .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')", __LINE__, __FILE__); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | ) |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__); |
|
| 254 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user', __LINE__, __FILE__); |
|
| 255 | 255 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 256 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 256 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 257 | 257 | { |
| 258 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__); |
|
| 259 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 258 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id', __LINE__, __FILE__); |
|
| 259 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 260 | 260 | { |
| 261 | 261 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 262 | 262 | $cal_login = $GLOBALS['egw_setup']->oProc->f('cal_login'); |
| 263 | 263 | $cal_status = $GLOBALS['egw_setup']->oProc->f('cal_status'); |
| 264 | - $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')",__LINE__,__FILE__); |
|
| 264 | + $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')", __LINE__, __FILE__); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -284,18 +284,18 @@ discard block |
||
| 284 | 284 | ) |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__); |
|
| 287 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats', __LINE__, __FILE__); |
|
| 288 | 288 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 289 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 289 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 290 | 290 | { |
| 291 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__); |
|
| 292 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 291 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id', __LINE__, __FILE__); |
|
| 292 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 293 | 293 | { |
| 294 | 294 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 295 | 295 | $cal_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 296 | - if(isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 296 | + if (isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 297 | 297 | { |
| 298 | - $enddate = mktime(0,0,0,intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),0,4))); |
|
| 298 | + $enddate = mktime(0, 0, 0, intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 0, 4))); |
|
| 299 | 299 | $useend = 1; |
| 300 | 300 | } |
| 301 | 301 | else |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | $cal_frequency = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 307 | 307 | $cal_days = $GLOBALS['egw_setup']->oProc->f('cal_days'); |
| 308 | - $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__); |
|
| 308 | + $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')", __LINE__, __FILE__); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 313 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 313 | + $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'", __LINE__, __FILE__); |
|
| 314 | 314 | |
| 315 | 315 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 316 | 316 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -322,19 +322,19 @@ discard block |
||
| 322 | 322 | $db2 = $GLOBALS['egw_setup']->db; |
| 323 | 323 | |
| 324 | 324 | $GLOBALS['egw_setup']->oProc->RenameColumn('calendar_entry', 'cal_duration', 'cal_edatetime'); |
| 325 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 326 | - if($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 325 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 326 | + if ($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 327 | 327 | { |
| 328 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 328 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 329 | 329 | { |
| 330 | - $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'),__LINE__,__FILE__); |
|
| 330 | + $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'), __LINE__, __FILE__); |
|
| 331 | 331 | $db2->next_record(); |
| 332 | 332 | $tz = $db2->f('preference_value'); |
| 333 | 333 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 334 | 334 | $datetime = $GLOBALS['egw_setup']->oProc->f('cal_datetime') - ((60 * 60) * $tz); |
| 335 | 335 | $mdatetime = $GLOBALS['egw_setup']->oProc->f('cal_mdatetime') - ((60 * 60) * $tz); |
| 336 | 336 | $edatetime = $datetime + (60 * $GLOBALS['egw_setup']->oProc->f('cal_edatetime')); |
| 337 | - $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 337 | + $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -582,22 +582,22 @@ discard block |
||
| 582 | 582 | { |
| 583 | 583 | $db2 = $GLOBALS['egw_setup']->db; |
| 584 | 584 | |
| 585 | - if(extension_loaded('mcal') == False) |
|
| 585 | + if (extension_loaded('mcal') == False) |
|
| 586 | 586 | { |
| 587 | - define(RECUR_NONE,0); |
|
| 588 | - define(RECUR_DAILY,1); |
|
| 589 | - define(RECUR_WEEKLY,2); |
|
| 590 | - define(RECUR_MONTHLY_MDAY,3); |
|
| 591 | - define(RECUR_MONTHLY_WDAY,4); |
|
| 592 | - define(RECUR_YEARLY,5); |
|
| 593 | - |
|
| 594 | - define(M_SUNDAY,1); |
|
| 595 | - define(M_MONDAY,2); |
|
| 596 | - define(M_TUESDAY,4); |
|
| 597 | - define(M_WEDNESDAY,8); |
|
| 598 | - define(M_THURSDAY,16); |
|
| 599 | - define(M_FRIDAY,32); |
|
| 600 | - define(M_SATURDAY,64); |
|
| 587 | + define(RECUR_NONE, 0); |
|
| 588 | + define(RECUR_DAILY, 1); |
|
| 589 | + define(RECUR_WEEKLY, 2); |
|
| 590 | + define(RECUR_MONTHLY_MDAY, 3); |
|
| 591 | + define(RECUR_MONTHLY_WDAY, 4); |
|
| 592 | + define(RECUR_YEARLY, 5); |
|
| 593 | + |
|
| 594 | + define(M_SUNDAY, 1); |
|
| 595 | + define(M_MONDAY, 2); |
|
| 596 | + define(M_TUESDAY, 4); |
|
| 597 | + define(M_WEDNESDAY, 8); |
|
| 598 | + define(M_THURSDAY, 16); |
|
| 599 | + define(M_FRIDAY, 32); |
|
| 600 | + define(M_SATURDAY, 64); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | // calendar_entry => phpgw_cal |
@@ -624,13 +624,13 @@ discard block |
||
| 624 | 624 | ) |
| 625 | 625 | ); |
| 626 | 626 | |
| 627 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry',__LINE__,__FILE__); |
|
| 628 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 627 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry', __LINE__, __FILE__); |
|
| 628 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 629 | 629 | { |
| 630 | 630 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 631 | 631 | $owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
| 632 | 632 | $access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 633 | - switch($access) |
|
| 633 | + switch ($access) |
|
| 634 | 634 | { |
| 635 | 635 | case 'private': |
| 636 | 636 | $is_public = 0; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | $description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 653 | 653 | |
| 654 | 654 | $db2->query("INSERT INTO phpgw_cal(cal_id,owner,groups,datetime,mdatetime,edatetime,priority,cal_type,is_public,title,description) " |
| 655 | - . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')",__LINE__,__FILE__); |
|
| 655 | + . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')", __LINE__, __FILE__); |
|
| 656 | 656 | } |
| 657 | 657 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry'); |
| 658 | 658 | |
@@ -660,12 +660,12 @@ discard block |
||
| 660 | 660 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 661 | 661 | Array( |
| 662 | 662 | 'fd' => array( |
| 663 | - 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 664 | - 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 665 | - 'recur_use_end' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 666 | - 'recur_enddate' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 667 | - 'recur_interval' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1'), |
|
| 668 | - 'recur_data' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1') |
|
| 663 | + 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 664 | + 'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 665 | + 'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 666 | + 'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 667 | + 'recur_interval' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1'), |
|
| 668 | + 'recur_data' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1') |
|
| 669 | 669 | ), |
| 670 | 670 | 'pk' => array(), |
| 671 | 671 | 'fk' => array(), |
@@ -673,12 +673,12 @@ discard block |
||
| 673 | 673 | 'uc' => array() |
| 674 | 674 | ) |
| 675 | 675 | ); |
| 676 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__); |
|
| 677 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 676 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats', __LINE__, __FILE__); |
|
| 677 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 678 | 678 | { |
| 679 | 679 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 680 | 680 | $recur_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 681 | - switch($recur_type) |
|
| 681 | + switch ($recur_type) |
|
| 682 | 682 | { |
| 683 | 683 | case 'daily': |
| 684 | 684 | $recur_type_num = RECUR_DAILY; |
@@ -701,20 +701,20 @@ discard block |
||
| 701 | 701 | $recur_interval = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 702 | 702 | $days = strtoupper($GLOBALS['egw_setup']->oProc->f('cal_days')); |
| 703 | 703 | $recur_data = 0; |
| 704 | - $recur_data += (substr($days,0,1)=='Y'?M_SUNDAY:0); |
|
| 705 | - $recur_data += (substr($days,1,1)=='Y'?M_MONDAY:0); |
|
| 706 | - $recur_data += (substr($days,2,1)=='Y'?M_TUESDAY:0); |
|
| 707 | - $recur_data += (substr($days,3,1)=='Y'?M_WEDNESDAY:0); |
|
| 708 | - $recur_data += (substr($days,4,1)=='Y'?M_THURSDAY:0); |
|
| 709 | - $recur_data += (substr($days,5,1)=='Y'?M_FRIDAY:0); |
|
| 710 | - $recur_data += (substr($days,6,1)=='Y'?M_SATURDAY:0); |
|
| 704 | + $recur_data += (substr($days, 0, 1) == 'Y' ? M_SUNDAY : 0); |
|
| 705 | + $recur_data += (substr($days, 1, 1) == 'Y' ? M_MONDAY : 0); |
|
| 706 | + $recur_data += (substr($days, 2, 1) == 'Y' ? M_TUESDAY : 0); |
|
| 707 | + $recur_data += (substr($days, 3, 1) == 'Y' ? M_WEDNESDAY : 0); |
|
| 708 | + $recur_data += (substr($days, 4, 1) == 'Y' ? M_THURSDAY : 0); |
|
| 709 | + $recur_data += (substr($days, 5, 1) == 'Y' ? M_FRIDAY : 0); |
|
| 710 | + $recur_data += (substr($days, 6, 1) == 'Y' ? M_SATURDAY : 0); |
|
| 711 | 711 | $db2->query("INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_use_end,recur_enddate,recur_interval,recur_data) " |
| 712 | - . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)",__LINE__,__FILE__); |
|
| 712 | + . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)", __LINE__, __FILE__); |
|
| 713 | 713 | } |
| 714 | 714 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry_repeats'); |
| 715 | 715 | |
| 716 | 716 | // calendar_entry_user => phpgw_cal_user |
| 717 | - $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user','phpgw_cal_user'); |
|
| 717 | + $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user', 'phpgw_cal_user'); |
|
| 718 | 718 | |
| 719 | 719 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.002'; |
| 720 | 720 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -733,11 +733,11 @@ discard block |
||
| 733 | 733 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 734 | 734 | Array( |
| 735 | 735 | 'fd' => array( |
| 736 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 737 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 738 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 736 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 737 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 738 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 739 | 739 | ), |
| 740 | - 'pk' => array('locale','name'), |
|
| 740 | + 'pk' => array('locale', 'name'), |
|
| 741 | 741 | 'fk' => array(), |
| 742 | 742 | 'ix' => array(), |
| 743 | 743 | 'uc' => array() |
@@ -769,10 +769,10 @@ discard block |
||
| 769 | 769 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 770 | 770 | Array( |
| 771 | 771 | 'fd' => array( |
| 772 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 773 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 774 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 775 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 772 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 773 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 774 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 775 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 776 | 776 | ), |
| 777 | 777 | 'pk' => array('hol_id'), |
| 778 | 778 | 'fk' => array(), |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | function calendar_upgrade0_9_11_007() |
| 790 | 790 | { |
| 791 | 791 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 792 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','mday',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 793 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','month_num',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 794 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','occurence',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 795 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','dow',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 792 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'mday', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 793 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'month_num', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 794 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'occurence', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 795 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'dow', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 796 | 796 | |
| 797 | 797 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.008'; |
| 798 | 798 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | function calendar_upgrade0_9_11_009() |
| 810 | 810 | { |
| 811 | 811 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 812 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','observance_rule',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 812 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'observance_rule', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 813 | 813 | |
| 814 | 814 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.010'; |
| 815 | 815 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | function calendar_upgrade0_9_13_002() |
| 846 | 846 | { |
| 847 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 847 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'reference', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 848 | 848 | |
| 849 | 849 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.003'; |
| 850 | 850 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 857 | 857 | Array( |
| 858 | 858 | 'fd' => array( |
| 859 | - 'alarm_id' => array('type' => 'auto','nullable' => False), |
|
| 859 | + 'alarm_id' => array('type' => 'auto', 'nullable' => False), |
|
| 860 | 860 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 861 | 861 | 'cal_owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 862 | 862 | 'cal_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -869,8 +869,8 @@ discard block |
||
| 869 | 869 | ) |
| 870 | 870 | ); |
| 871 | 871 | |
| 872 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','uid',array('type' => 'varchar', 'precision' => 255,'nullable' => False)); |
|
| 873 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','location',array('type' => 'varchar', 'precision' => 255,'nullable' => True)); |
|
| 872 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'uid', array('type' => 'varchar', 'precision' => 255, 'nullable' => False)); |
|
| 873 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'location', array('type' => 'varchar', 'precision' => 255, 'nullable' => True)); |
|
| 874 | 874 | |
| 875 | 875 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.004'; |
| 876 | 876 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | function calendar_upgrade0_9_13_004() |
| 881 | 881 | { |
| 882 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm','alarm_enabled',array('type' => 'int', 'precision' => 4,'nullable' => False, 'default' => '1')); |
|
| 882 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm', 'alarm_enabled', array('type' => 'int', 'precision' => 4, 'nullable' => False, 'default' => '1')); |
|
| 883 | 883 | |
| 884 | 884 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.005'; |
| 885 | 885 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -889,18 +889,18 @@ discard block |
||
| 889 | 889 | function calendar_upgrade0_9_13_005() |
| 890 | 890 | { |
| 891 | 891 | $calendar_data = Array(); |
| 892 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
|
| 893 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 892 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal', __LINE__, __FILE__); |
|
| 893 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 894 | 894 | { |
| 895 | 895 | $calendar_data[$GLOBALS['egw_setup']->oProc->f('cal_id')] = $GLOBALS['egw_setup']->oProc->f('category'); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','category',array('type' => 'varchar', 'precision' => 30,'nullable' => True)); |
|
| 898 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'category', array('type' => 'varchar', 'precision' => 30, 'nullable' => True)); |
|
| 899 | 899 | |
| 900 | 900 | @reset($calendar_data); |
| 901 | - while($calendar_data && list($cal_id,$category) = each($calendar_data)) |
|
| 901 | + while ($calendar_data && list($cal_id, $category) = each($calendar_data)) |
|
| 902 | 902 | { |
| 903 | - $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); |
|
| 903 | + $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id, __LINE__, __FILE__); |
|
| 904 | 904 | } |
| 905 | 905 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.006'; |
| 906 | 906 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | function calendar_upgrade0_9_13_006() |
| 911 | 911 | { |
| 912 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_exception',array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 912 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats', 'recur_exception', array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 913 | 913 | |
| 914 | 914 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007'; |
| 915 | 915 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -919,20 +919,20 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | function calendar_upgrade0_9_13_007() |
| 921 | 921 | { |
| 922 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user','cal_type',array( |
|
| 922 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user', 'cal_type', array( |
|
| 923 | 923 | 'type' => 'varchar', |
| 924 | 924 | 'precision' => '1', |
| 925 | 925 | 'nullable' => False, |
| 926 | 926 | 'default' => 'u' |
| 927 | 927 | )); |
| 928 | 928 | |
| 929 | - $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra',array( |
|
| 929 | + $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra', array( |
|
| 930 | 930 | 'fd' => array( |
| 931 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 932 | - 'cal_extra_name' => array('type' => 'varchar','precision' => '40','nullable' => False), |
|
| 933 | - 'cal_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '') |
|
| 931 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 932 | + 'cal_extra_name' => array('type' => 'varchar', 'precision' => '40', 'nullable' => False), |
|
| 933 | + 'cal_extra_value' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '') |
|
| 934 | 934 | ), |
| 935 | - 'pk' => array('cal_id','cal_extra_name'), |
|
| 935 | + 'pk' => array('cal_id', 'cal_extra_name'), |
|
| 936 | 936 | 'fk' => array(), |
| 937 | 937 | 'ix' => array(), |
| 938 | 938 | 'uc' => array() |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | function calendar_upgrade0_9_16_001() |
| 950 | 950 | { |
| 951 | 951 | // this is to set the default as schema_proc was not setting an empty default |
| 952 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user','cal_type',array( |
|
| 952 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user', 'cal_type', array( |
|
| 953 | 953 | 'type' => 'varchar', |
| 954 | 954 | 'precision' => '1', |
| 955 | 955 | 'nullable' => False, |
@@ -966,15 +966,15 @@ discard block |
||
| 966 | 966 | |
| 967 | 967 | function calendar_upgrade0_9_16_002() |
| 968 | 968 | { |
| 969 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 969 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 970 | 970 | 'fd' => array( |
| 971 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 972 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 973 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 974 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 975 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 976 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 977 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 971 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 972 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 973 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 974 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 975 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 976 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 977 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 978 | 978 | ), |
| 979 | 979 | 'pk' => array(), |
| 980 | 980 | 'fk' => array(), |
@@ -990,14 +990,14 @@ discard block |
||
| 990 | 990 | |
| 991 | 991 | function calendar_upgrade0_9_16_003() |
| 992 | 992 | { |
| 993 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user',array( |
|
| 993 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user', array( |
|
| 994 | 994 | 'fd' => array( |
| 995 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 996 | - 'cal_login' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 997 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A'), |
|
| 998 | - 'cal_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u') |
|
| 995 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 996 | + 'cal_login' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 997 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A'), |
|
| 998 | + 'cal_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u') |
|
| 999 | 999 | ), |
| 1000 | - 'pk' => array('cal_id','cal_login','cal_type'), |
|
| 1000 | + 'pk' => array('cal_id', 'cal_login', 'cal_type'), |
|
| 1001 | 1001 | 'fk' => array(), |
| 1002 | 1002 | 'ix' => array(), |
| 1003 | 1003 | 'uc' => array() |
@@ -1011,16 +1011,16 @@ discard block |
||
| 1011 | 1011 | |
| 1012 | 1012 | function calendar_upgrade0_9_16_004() |
| 1013 | 1013 | { |
| 1014 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays',array( |
|
| 1014 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays', array( |
|
| 1015 | 1015 | 'fd' => array( |
| 1016 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 1017 | - 'locale' => array('type' => 'char','precision' => '2','nullable' => False), |
|
| 1018 | - 'name' => array('type' => 'varchar','precision' => '50','nullable' => False), |
|
| 1019 | - 'mday' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1020 | - 'month_num' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1021 | - 'occurence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1022 | - 'dow' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1023 | - 'observance_rule' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1016 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1017 | + 'locale' => array('type' => 'char', 'precision' => '2', 'nullable' => False), |
|
| 1018 | + 'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False), |
|
| 1019 | + 'mday' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1020 | + 'month_num' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1021 | + 'occurence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1022 | + 'dow' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1023 | + 'observance_rule' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1024 | 1024 | ), |
| 1025 | 1025 | 'pk' => array('hol_id'), |
| 1026 | 1026 | 'fk' => array(), |
@@ -1038,13 +1038,13 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | // creates uid's for all entries which do not have unique ones, they are '[email protected]' |
| 1040 | 1040 | // very old entries even have an empty uid, see 0.9.16.006 update |
| 1041 | - $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'",__LINE__,__FILE__); |
|
| 1041 | + $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'", __LINE__, __FILE__); |
|
| 1042 | 1042 | while ($GLOBALS['egw_setup']->oProc->next_record()) |
| 1043 | 1043 | { |
| 1044 | 1044 | $config[$GLOBALS['egw_setup']->oProc->f(0)] = $GLOBALS['egw_setup']->oProc->f(1); |
| 1045 | 1045 | } |
| 1046 | 1046 | $GLOBALS['egw_setup']->oProc->query('UPDATE phpgw_cal SET uid='. |
| 1047 | - $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'),'cal_id', |
|
| 1047 | + $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'), 'cal_id', |
|
| 1048 | 1048 | $GLOBALS['egw_setup']->db->quote('-'.$config['install_id'].'@'. |
| 1049 | 1049 | ($config['mail_suffix'] ? $config['mail_suffix'] : 'local'))). |
| 1050 | 1050 | " WHERE uid LIKE '-@%' OR uid=''"); |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | function calendar_upgrade0_9_16_007() |
| 1068 | 1068 | { |
| 1069 | 1069 | // update the sequenzes for refreshed tables (postgres only) |
| 1070 | - $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays','hol_id'); |
|
| 1070 | + $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays', 'hol_id'); |
|
| 1071 | 1071 | |
| 1072 | 1072 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0'; |
| 1073 | 1073 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1077,19 +1077,19 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | function calendar_upgrade1_0_0() |
| 1079 | 1079 | { |
| 1080 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','uid','cal_uid'); |
|
| 1081 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','owner','cal_owner'); |
|
| 1082 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','category','cal_category'); |
|
| 1083 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','groups','cal_groups'); |
|
| 1084 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','datetime','cal_starttime'); |
|
| 1085 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','mdatetime','cal_modified'); |
|
| 1086 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','edatetime','cal_endtime'); |
|
| 1087 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','priority','cal_priority'); |
|
| 1088 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','is_public','cal_public'); |
|
| 1089 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','title','cal_title'); |
|
| 1090 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','description','cal_description'); |
|
| 1091 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','location','cal_location'); |
|
| 1092 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','reference','cal_reference'); |
|
| 1080 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'uid', 'cal_uid'); |
|
| 1081 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'owner', 'cal_owner'); |
|
| 1082 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'category', 'cal_category'); |
|
| 1083 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'groups', 'cal_groups'); |
|
| 1084 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'datetime', 'cal_starttime'); |
|
| 1085 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'mdatetime', 'cal_modified'); |
|
| 1086 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'edatetime', 'cal_endtime'); |
|
| 1087 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'priority', 'cal_priority'); |
|
| 1088 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'is_public', 'cal_public'); |
|
| 1089 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'title', 'cal_title'); |
|
| 1090 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'description', 'cal_description'); |
|
| 1091 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'location', 'cal_location'); |
|
| 1092 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'reference', 'cal_reference'); |
|
| 1093 | 1093 | |
| 1094 | 1094 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.001'; |
| 1095 | 1095 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1099,13 +1099,13 @@ discard block |
||
| 1099 | 1099 | |
| 1100 | 1100 | function calendar_upgrade1_0_0_001() |
| 1101 | 1101 | { |
| 1102 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','locale','hol_locale'); |
|
| 1103 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','name','hol_name'); |
|
| 1104 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','mday','hol_mday'); |
|
| 1105 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','month_num','hol_month_num'); |
|
| 1106 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','occurence','hol_occurence'); |
|
| 1107 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','dow','hol_dow'); |
|
| 1108 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','observance_rule','hol_observance_rule'); |
|
| 1102 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'locale', 'hol_locale'); |
|
| 1103 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'name', 'hol_name'); |
|
| 1104 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'mday', 'hol_mday'); |
|
| 1105 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'month_num', 'hol_month_num'); |
|
| 1106 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'occurence', 'hol_occurence'); |
|
| 1107 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'dow', 'hol_dow'); |
|
| 1108 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'observance_rule', 'hol_observance_rule'); |
|
| 1109 | 1109 | |
| 1110 | 1110 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.002'; |
| 1111 | 1111 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | |
| 1116 | 1116 | function calendar_upgrade1_0_0_002() |
| 1117 | 1117 | { |
| 1118 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_login','cal_user_id'); |
|
| 1119 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_type','cal_user_type'); |
|
| 1118 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_login', 'cal_user_id'); |
|
| 1119 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_type', 'cal_user_type'); |
|
| 1120 | 1120 | |
| 1121 | 1121 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.003'; |
| 1122 | 1122 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | |
| 1127 | 1127 | function calendar_upgrade1_0_0_003() |
| 1128 | 1128 | { |
| 1129 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','cal_title',array( |
|
| 1129 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'cal_title', array( |
|
| 1130 | 1130 | 'type' => 'varchar', |
| 1131 | 1131 | 'precision' => '255', |
| 1132 | 1132 | 'nullable' => False, |
@@ -1141,15 +1141,15 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | function calendar_upgrade1_0_0_004() |
| 1143 | 1143 | { |
| 1144 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 1144 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 1145 | 1145 | 'fd' => array( |
| 1146 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1147 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1148 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1149 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1150 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1151 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1152 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1146 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1147 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1148 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1149 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1150 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1151 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1152 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1153 | 1153 | ), |
| 1154 | 1154 | 'pk' => array('cal_id'), |
| 1155 | 1155 | 'fk' => array(), |
@@ -1166,19 +1166,19 @@ discard block |
||
| 1166 | 1166 | function calendar_upgrade1_0_0_005() |
| 1167 | 1167 | { |
| 1168 | 1168 | // change prefix of all calendar tables to egw_ |
| 1169 | - foreach(array('cal_user','cal_repeats','cal_extra','cal_holidays','cal') as $name) |
|
| 1169 | + foreach (array('cal_user', 'cal_repeats', 'cal_extra', 'cal_holidays', 'cal') as $name) |
|
| 1170 | 1170 | { |
| 1171 | - $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name,'egw_'.$name); |
|
| 1171 | + $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name, 'egw_'.$name); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | // create new dates table, with content from the egw_cal table |
| 1175 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates',array( |
|
| 1175 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates', array( |
|
| 1176 | 1176 | 'fd' => array( |
| 1177 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1178 | - 'cal_start' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1179 | - 'cal_end' => array('type' => 'int','precision' => '8','nullable' => False) |
|
| 1177 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1178 | + 'cal_start' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1179 | + 'cal_end' => array('type' => 'int', 'precision' => '8', 'nullable' => False) |
|
| 1180 | 1180 | ), |
| 1181 | - 'pk' => array('cal_id','cal_start'), |
|
| 1181 | + 'pk' => array('cal_id', 'cal_start'), |
|
| 1182 | 1182 | 'fk' => array(), |
| 1183 | 1183 | 'ix' => array(), |
| 1184 | 1184 | 'uc' => array() |
@@ -1186,49 +1186,49 @@ discard block |
||
| 1186 | 1186 | $GLOBALS['egw_setup']->oProc->query("INSERT INTO egw_cal_dates SELECT cal_id,cal_starttime,cal_endtime FROM egw_cal"); |
| 1187 | 1187 | |
| 1188 | 1188 | // drop the fields transfered to the dates table |
| 1189 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1189 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1190 | 1190 | 'fd' => array( |
| 1191 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1192 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1193 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1194 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1195 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1196 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1197 | - 'cal_endtime' => array('type' => 'int','precision' => '8'), |
|
| 1198 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1199 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1200 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1201 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1191 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1192 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1193 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1194 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1195 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1196 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1197 | + 'cal_endtime' => array('type' => 'int', 'precision' => '8'), |
|
| 1198 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1199 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1200 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1201 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1202 | 1202 | 'cal_description' => array('type' => 'text'), |
| 1203 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1204 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1203 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1204 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1205 | 1205 | ), |
| 1206 | 1206 | 'pk' => array('cal_id'), |
| 1207 | 1207 | 'fk' => array(), |
| 1208 | 1208 | 'ix' => array(), |
| 1209 | 1209 | 'uc' => array() |
| 1210 | - ),'cal_starttime'); |
|
| 1211 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1210 | + ), 'cal_starttime'); |
|
| 1211 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1212 | 1212 | 'fd' => array( |
| 1213 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1214 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1215 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1216 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1217 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1218 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1219 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1220 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1221 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1222 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1213 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1214 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1215 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1216 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1217 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1218 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1219 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1220 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1221 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1222 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1223 | 1223 | 'cal_description' => array('type' => 'text'), |
| 1224 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1225 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1224 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1225 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1226 | 1226 | ), |
| 1227 | 1227 | 'pk' => array('cal_id'), |
| 1228 | 1228 | 'fk' => array(), |
| 1229 | 1229 | 'ix' => array(), |
| 1230 | 1230 | 'uc' => array() |
| 1231 | - ),'cal_endtime'); |
|
| 1231 | + ), 'cal_endtime'); |
|
| 1232 | 1232 | |
| 1233 | 1233 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.001'; |
| 1234 | 1234 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1244,15 +1244,15 @@ discard block |
||
| 1244 | 1244 | 'precision' => '8', |
| 1245 | 1245 | 'default' => '0' |
| 1246 | 1246 | ));*/ |
| 1247 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 1247 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 1248 | 1248 | 'fd' => array( |
| 1249 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1250 | - 'cal_recur_date' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1251 | - 'cal_user_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u'), |
|
| 1252 | - 'cal_user_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1253 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A') |
|
| 1249 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1250 | + 'cal_recur_date' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1251 | + 'cal_user_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u'), |
|
| 1252 | + 'cal_user_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1253 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A') |
|
| 1254 | 1254 | ), |
| 1255 | - 'pk' => array('cal_id','cal_recur_date','cal_user_type','cal_user_id'), |
|
| 1255 | + 'pk' => array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'), |
|
| 1256 | 1256 | 'fk' => array(), |
| 1257 | 1257 | 'ix' => array(), |
| 1258 | 1258 | 'uc' => array() |
@@ -1266,50 +1266,50 @@ discard block |
||
| 1266 | 1266 | |
| 1267 | 1267 | function calendar_upgrade1_0_1_002() |
| 1268 | 1268 | { |
| 1269 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1269 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1270 | 1270 | 'fd' => array( |
| 1271 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1272 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1273 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1274 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1275 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1276 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1277 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1278 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1279 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1271 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1272 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1273 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1274 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1275 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1276 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1277 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1278 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1279 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1280 | 1280 | 'cal_description' => array('type' => 'text'), |
| 1281 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1282 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1281 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1282 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1283 | 1283 | ), |
| 1284 | 1284 | 'pk' => array('cal_id'), |
| 1285 | 1285 | 'fk' => array(), |
| 1286 | 1286 | 'ix' => array(), |
| 1287 | 1287 | 'uc' => array() |
| 1288 | - ),'cal_type'); |
|
| 1289 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_owner',array( |
|
| 1288 | + ), 'cal_type'); |
|
| 1289 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_owner', array( |
|
| 1290 | 1290 | 'type' => 'int', |
| 1291 | 1291 | 'precision' => '4', |
| 1292 | 1292 | 'nullable' => False |
| 1293 | 1293 | )); |
| 1294 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_priority',array( |
|
| 1294 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_priority', array( |
|
| 1295 | 1295 | 'type' => 'int', |
| 1296 | 1296 | 'precision' => '2', |
| 1297 | 1297 | 'nullable' => False, |
| 1298 | 1298 | 'default' => '2' |
| 1299 | 1299 | )); |
| 1300 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_public',array( |
|
| 1300 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_public', array( |
|
| 1301 | 1301 | 'type' => 'int', |
| 1302 | 1302 | 'precision' => '2', |
| 1303 | 1303 | 'nullable' => False, |
| 1304 | 1304 | 'default' => '1' |
| 1305 | 1305 | )); |
| 1306 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_reference',array( |
|
| 1306 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_reference', array( |
|
| 1307 | 1307 | 'type' => 'int', |
| 1308 | 1308 | 'precision' => '4', |
| 1309 | 1309 | 'nullable' => False, |
| 1310 | 1310 | 'default' => '0' |
| 1311 | 1311 | )); |
| 1312 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_modifier',array( |
|
| 1312 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_modifier', array( |
|
| 1313 | 1313 | 'type' => 'int', |
| 1314 | 1314 | 'precision' => '4' |
| 1315 | 1315 | )); |
@@ -1322,36 +1322,36 @@ discard block |
||
| 1322 | 1322 | |
| 1323 | 1323 | function calendar_upgrade1_0_1_003() |
| 1324 | 1324 | { |
| 1325 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 1325 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 1326 | 1326 | 'fd' => array( |
| 1327 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1328 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1329 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1330 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1331 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1332 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1327 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1328 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1329 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1330 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1331 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1332 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1333 | 1333 | ), |
| 1334 | 1334 | 'pk' => array('cal_id'), |
| 1335 | 1335 | 'fk' => array(), |
| 1336 | 1336 | 'ix' => array(), |
| 1337 | 1337 | 'uc' => array() |
| 1338 | - ),'recur_use_end'); |
|
| 1339 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','cal_id',array( |
|
| 1338 | + ), 'recur_use_end'); |
|
| 1339 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'cal_id', array( |
|
| 1340 | 1340 | 'type' => 'int', |
| 1341 | 1341 | 'precision' => '4', |
| 1342 | 1342 | 'nullable' => False |
| 1343 | 1343 | )); |
| 1344 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_type',array( |
|
| 1344 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_type', array( |
|
| 1345 | 1345 | 'type' => 'int', |
| 1346 | 1346 | 'precision' => '2', |
| 1347 | 1347 | 'nullable' => False |
| 1348 | 1348 | )); |
| 1349 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_interval',array( |
|
| 1349 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_interval', array( |
|
| 1350 | 1350 | 'type' => 'int', |
| 1351 | 1351 | 'precision' => '2', |
| 1352 | 1352 | 'default' => '1' |
| 1353 | 1353 | )); |
| 1354 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_data',array( |
|
| 1354 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_data', array( |
|
| 1355 | 1355 | 'type' => 'int', |
| 1356 | 1356 | 'precision' => '2', |
| 1357 | 1357 | 'default' => '1' |
@@ -1365,13 +1365,13 @@ discard block |
||
| 1365 | 1365 | |
| 1366 | 1366 | function calendar_upgrade1_0_1_004() |
| 1367 | 1367 | { |
| 1368 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1368 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1369 | 1369 | 'type' => 'int', |
| 1370 | 1370 | 'precision' => '4', |
| 1371 | 1371 | 'nullable' => False, |
| 1372 | 1372 | 'default' => '0' |
| 1373 | 1373 | )); |
| 1374 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1374 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1375 | 1375 | 'type' => 'int', |
| 1376 | 1376 | 'precision' => '4', |
| 1377 | 1377 | 'nullable' => False, |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | |
| 1387 | 1387 | function calendar_upgrade1_0_1_005() |
| 1388 | 1388 | { |
| 1389 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_quantity',array( |
|
| 1389 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1390 | 1390 | 'type' => 'int', |
| 1391 | 1391 | 'precision' => '4', |
| 1392 | 1392 | 'default' => '1' |
@@ -1400,7 +1400,7 @@ discard block |
||
| 1400 | 1400 | |
| 1401 | 1401 | function calendar_upgrade1_0_1_006() |
| 1402 | 1402 | { |
| 1403 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_non_blocking',array( |
|
| 1403 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_non_blocking', array( |
|
| 1404 | 1404 | 'type' => 'int', |
| 1405 | 1405 | 'precision' => '2', |
| 1406 | 1406 | 'default' => '0' |
@@ -1414,9 +1414,9 @@ discard block |
||
| 1414 | 1414 | |
| 1415 | 1415 | function calendar_upgrade1_0_1_007() |
| 1416 | 1416 | { |
| 1417 | - $GLOBALS['egw_setup']->db->update('egw_cal_repeats',array('recur_exception' => null),array('recur_exception' => ''),__LINE__,__FILE__,'calendar'); |
|
| 1417 | + $GLOBALS['egw_setup']->db->update('egw_cal_repeats', array('recur_exception' => null), array('recur_exception' => ''), __LINE__, __FILE__, 'calendar'); |
|
| 1418 | 1418 | |
| 1419 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_exception',array( |
|
| 1419 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_exception', array( |
|
| 1420 | 1420 | 'type' => 'text' |
| 1421 | 1421 | )); |
| 1422 | 1422 | |
@@ -1433,11 +1433,11 @@ discard block |
||
| 1433 | 1433 | { |
| 1434 | 1434 | $customfields = array(); |
| 1435 | 1435 | $order = 0; |
| 1436 | - foreach($config_data['fields'] as $name => $data) |
|
| 1436 | + foreach ($config_data['fields'] as $name => $data) |
|
| 1437 | 1437 | { |
| 1438 | 1438 | if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
| 1439 | 1439 | { |
| 1440 | - $customfields[substr($name,1)] = array( |
|
| 1440 | + $customfields[substr($name, 1)] = array( |
|
| 1441 | 1441 | 'type' => 'text', |
| 1442 | 1442 | 'len' => $data['length'].($data['shown'] ? ','.$data['shown'] : ''), |
| 1443 | 1443 | 'label' => $data['name'], |
@@ -1460,38 +1460,38 @@ discard block |
||
| 1460 | 1460 | function calendar_upgrade1_0_1_009() |
| 1461 | 1461 | { |
| 1462 | 1462 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 1463 | - $GLOBALS['egw_setup']->db->select('egw_cal','DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date',"cal_groups != ''",__LINE__,__FILE__, |
|
| 1464 | - False,'','calendar',0,',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1465 | - while(($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1463 | + $GLOBALS['egw_setup']->db->select('egw_cal', 'DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date', "cal_groups != ''", __LINE__, __FILE__, |
|
| 1464 | + False, '', 'calendar', 0, ',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1465 | + while (($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1466 | 1466 | { |
| 1467 | 1467 | $row['cal_user_type'] = 'u'; |
| 1468 | - foreach(explode(',',$row['cal_groups']) as $group) |
|
| 1468 | + foreach (explode(',', $row['cal_groups']) as $group) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | $row['cal_user_id'] = $group; |
| 1471 | - $db2->insert('egw_cal_user',array('cal_status' => 'U'),$row,__LINE__,__FILE__,'calendar'); |
|
| 1471 | + $db2->insert('egw_cal_user', array('cal_status' => 'U'), $row, __LINE__, __FILE__, 'calendar'); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | } |
| 1474 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1474 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1475 | 1475 | 'fd' => array( |
| 1476 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1477 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1478 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1479 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1480 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1481 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1482 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1483 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1476 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1477 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1478 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1479 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1480 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1481 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1482 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1483 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1484 | 1484 | 'cal_description' => array('type' => 'text'), |
| 1485 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1486 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1487 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1488 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0') |
|
| 1485 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1486 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1487 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1488 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0') |
|
| 1489 | 1489 | ), |
| 1490 | 1490 | 'pk' => array('cal_id'), |
| 1491 | 1491 | 'fk' => array(), |
| 1492 | 1492 | 'ix' => array(), |
| 1493 | 1493 | 'uc' => array() |
| 1494 | - ),'cal_groups'); |
|
| 1494 | + ), 'cal_groups'); |
|
| 1495 | 1495 | |
| 1496 | 1496 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2'; |
| 1497 | 1497 | } |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | function calendar_upgrade1_2() |
| 1502 | 1502 | { |
| 1503 | 1503 | // get old alarms (saved before 1.2) working again |
| 1504 | - $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'",__LINE__,__FILE__); |
|
| 1504 | + $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'", __LINE__, __FILE__); |
|
| 1505 | 1505 | |
| 1506 | 1506 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2.001'; |
| 1507 | 1507 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | |
| 1510 | 1510 | function calendar_upgrade1_2_001() |
| 1511 | 1511 | { |
| 1512 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_special',array( |
|
| 1512 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_special', array( |
|
| 1513 | 1513 | 'type' => 'int', |
| 1514 | 1514 | 'precision' => '2', |
| 1515 | 1515 | 'default' => '0' |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | |
| 1528 | 1528 | function calendar_upgrade1_4() |
| 1529 | 1529 | { |
| 1530 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_etag',array( |
|
| 1530 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_etag', array( |
|
| 1531 | 1531 | 'type' => 'int', |
| 1532 | 1532 | 'precision' => '4', |
| 1533 | 1533 | 'default' => '0' |
@@ -1539,59 +1539,59 @@ discard block |
||
| 1539 | 1539 | |
| 1540 | 1540 | function calendar_upgrade1_5() |
| 1541 | 1541 | { |
| 1542 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1542 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1543 | 1543 | 'fd' => array( |
| 1544 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1545 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1546 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1547 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1548 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1549 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1550 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1551 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1544 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1545 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1546 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1547 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1548 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1549 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1550 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1551 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1552 | 1552 | 'cal_description' => array('type' => 'text'), |
| 1553 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1554 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1555 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1556 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1557 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1558 | - 'cal_etag' => array('type' => 'int','precision' => '4'), |
|
| 1559 | - 'cal_edit_time' => array('type' => 'int','precision' => '8') |
|
| 1553 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1554 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1555 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1556 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1557 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1558 | + 'cal_etag' => array('type' => 'int', 'precision' => '4'), |
|
| 1559 | + 'cal_edit_time' => array('type' => 'int', 'precision' => '8') |
|
| 1560 | 1560 | ), |
| 1561 | 1561 | 'pk' => array('cal_id'), |
| 1562 | 1562 | 'fk' => array(), |
| 1563 | 1563 | 'ix' => array(), |
| 1564 | 1564 | 'uc' => array() |
| 1565 | - ),'cal_edit_user'); |
|
| 1566 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1565 | + ), 'cal_edit_user'); |
|
| 1566 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1567 | 1567 | 'fd' => array( |
| 1568 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1569 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1570 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1571 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1572 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1573 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1574 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1575 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1568 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1569 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1570 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1571 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1572 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1573 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1574 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1575 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1576 | 1576 | 'cal_description' => array('type' => 'text'), |
| 1577 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1578 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1579 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1580 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1581 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1582 | - 'cal_etag' => array('type' => 'int','precision' => '4') |
|
| 1577 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1578 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1579 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1580 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1581 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1582 | + 'cal_etag' => array('type' => 'int', 'precision' => '4') |
|
| 1583 | 1583 | ), |
| 1584 | 1584 | 'pk' => array('cal_id'), |
| 1585 | 1585 | 'fk' => array(), |
| 1586 | 1586 | 'ix' => array(), |
| 1587 | 1587 | 'uc' => array() |
| 1588 | - ),'cal_edit_time'); |
|
| 1589 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_etag',array( |
|
| 1588 | + ), 'cal_edit_time'); |
|
| 1589 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_etag', array( |
|
| 1590 | 1590 | 'type' => 'int', |
| 1591 | 1591 | 'precision' => '4', |
| 1592 | 1592 | 'default' => '0' |
| 1593 | 1593 | )); |
| 1594 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL',__LINE__,__FILE__); |
|
| 1594 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL', __LINE__, __FILE__); |
|
| 1595 | 1595 | |
| 1596 | 1596 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.5.001'; |
| 1597 | 1597 | } |
@@ -1599,12 +1599,12 @@ discard block |
||
| 1599 | 1599 | |
| 1600 | 1600 | function calendar_upgrade1_5_001() |
| 1601 | 1601 | { |
| 1602 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1602 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1603 | 1603 | 'type' => 'int', |
| 1604 | 1604 | 'precision' => '4', |
| 1605 | 1605 | 'nullable' => False |
| 1606 | 1606 | )); |
| 1607 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1607 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1608 | 1608 | 'type' => 'varchar', |
| 1609 | 1609 | 'precision' => '128', |
| 1610 | 1610 | 'nullable' => False |
@@ -1618,12 +1618,12 @@ discard block |
||
| 1618 | 1618 | { |
| 1619 | 1619 | // update the alarm methods |
| 1620 | 1620 | $async = new Api\Asyncservice(); |
| 1621 | - foreach((array)$async->read('cal:%') as $job) |
|
| 1621 | + foreach ((array)$async->read('cal:%') as $job) |
|
| 1622 | 1622 | { |
| 1623 | 1623 | if ($job['method'] == 'calendar.bocalupdate.send_alarm') |
| 1624 | 1624 | { |
| 1625 | 1625 | $job['method'] = 'calendar.calendar_boupdate.send_alarm'; |
| 1626 | - $async->write($job,true); |
|
| 1626 | + $async->write($job, true); |
|
| 1627 | 1627 | } |
| 1628 | 1628 | } |
| 1629 | 1629 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.6'; |
@@ -1640,48 +1640,48 @@ discard block |
||
| 1640 | 1640 | { |
| 1641 | 1641 | // Set UID of series exception to UID of series master |
| 1642 | 1642 | // update cal_etag, cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1643 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1643 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1644 | 1644 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1645 | 1645 | FROM egw_cal cal_ex |
| 1646 | 1646 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1647 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1647 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1648 | 1648 | { |
| 1649 | 1649 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1650 | 1650 | { |
| 1651 | 1651 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1652 | 1652 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1653 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1653 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | // Search series exception for nearest exception in series master and add that RECURRENCE-ID |
| 1658 | 1658 | // as cal_reference (for 1.6.003 and move it to new field cal_recurrence in 1.7.001) |
| 1659 | 1659 | $diff = null; |
| 1660 | - foreach($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1660 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1661 | 1661 | JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id |
| 1662 | 1662 | JOIN egw_cal_repeats ON cal_reference=egw_cal_repeats.cal_id |
| 1663 | - WHERE cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1663 | + WHERE cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1664 | 1664 | { |
| 1665 | 1665 | $recurrence = null; |
| 1666 | - foreach(explode(',',$row['recur_exception']) as $ts) |
|
| 1666 | + foreach (explode(',', $row['recur_exception']) as $ts) |
|
| 1667 | 1667 | { |
| 1668 | - if (is_null($recurrence) || abs($ts-$row['cal_start']) < $diff) |
|
| 1668 | + if (is_null($recurrence) || abs($ts - $row['cal_start']) < $diff) |
|
| 1669 | 1669 | { |
| 1670 | 1670 | $recurrence = $ts; |
| 1671 | - $diff = abs($ts-$row['cal_start']); |
|
| 1671 | + $diff = abs($ts - $row['cal_start']); |
|
| 1672 | 1672 | } |
| 1673 | 1673 | } |
| 1674 | 1674 | if ($recurrence) |
| 1675 | 1675 | { |
| 1676 | 1676 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$recurrence. |
| 1677 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1677 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | else |
| 1680 | 1680 | { |
| 1681 | 1681 | // if we cannot determine the RECURRENCE-ID use cal_start |
| 1682 | 1682 | // because RECURRENCE-ID must be present |
| 1683 | 1683 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$row['cal_start']. |
| 1684 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1684 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1685 | 1685 | } |
| 1686 | 1686 | } |
| 1687 | 1687 | |
@@ -1696,33 +1696,33 @@ discard block |
||
| 1696 | 1696 | */ |
| 1697 | 1697 | function calendar_upgrade1_6_003() |
| 1698 | 1698 | { |
| 1699 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_creator',array( |
|
| 1699 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_creator', array( |
|
| 1700 | 1700 | 'type' => 'int', |
| 1701 | 1701 | 'precision' => '4', |
| 1702 | 1702 | 'comment' => 'creating user' |
| 1703 | 1703 | )); |
| 1704 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner',__LINE__,__FILE__); |
|
| 1705 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_creator',array( |
|
| 1704 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner', __LINE__, __FILE__); |
|
| 1705 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_creator', array( |
|
| 1706 | 1706 | 'type' => 'int', |
| 1707 | 1707 | 'precision' => '4', |
| 1708 | 1708 | 'nullable' => False, |
| 1709 | 1709 | 'comment' => 'creating user' |
| 1710 | 1710 | )); |
| 1711 | 1711 | |
| 1712 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_created',array( |
|
| 1712 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_created', array( |
|
| 1713 | 1713 | 'type' => 'int', |
| 1714 | 1714 | 'precision' => '8', |
| 1715 | 1715 | 'comment' => 'creation time of event' |
| 1716 | 1716 | )); |
| 1717 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified',__LINE__,__FILE__); |
|
| 1718 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_created',array( |
|
| 1717 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified', __LINE__, __FILE__); |
|
| 1718 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_created', array( |
|
| 1719 | 1719 | 'type' => 'int', |
| 1720 | 1720 | 'precision' => '8', |
| 1721 | 1721 | 'nullable' => False, |
| 1722 | 1722 | 'comment' => 'creation time of event' |
| 1723 | 1723 | )); |
| 1724 | 1724 | |
| 1725 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_recurrence',array( |
|
| 1725 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_recurrence', array( |
|
| 1726 | 1726 | 'type' => 'int', |
| 1727 | 1727 | 'precision' => '8', |
| 1728 | 1728 | 'nullable' => False, |
@@ -1733,14 +1733,14 @@ discard block |
||
| 1733 | 1733 | // move RECURRENCE-ID from temporarily (1.6.003) |
| 1734 | 1734 | // used field cal_reference to new field cal_recurrence |
| 1735 | 1735 | // and restore cal_reference field of series exceptions with id of the series master |
| 1736 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1736 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1737 | 1737 | SELECT cal_ex.cal_id AS cal_id_ex,cal_master.cal_id AS cal_id_master, |
| 1738 | 1738 | cal_ex.cal_reference AS cal_reference_ex,cal_ex.cal_uid AS cal_uid_ex, |
| 1739 | 1739 | cal_master.cal_uid AS cal_uid_master |
| 1740 | 1740 | FROM egw_cal cal_ex |
| 1741 | 1741 | JOIN egw_cal cal_master |
| 1742 | 1742 | ON cal_ex.cal_uid=cal_master.cal_uid AND cal_master.cal_reference = 0 AND cal_ex.cal_owner = cal_master.cal_owner |
| 1743 | - WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__,__FILE__) as $row) |
|
| 1743 | + WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__, __FILE__) as $row) |
|
| 1744 | 1744 | { |
| 1745 | 1745 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_recurrence='.(int)$row['cal_reference_ex']. |
| 1746 | 1746 | ', cal_reference='.(int)$row['cal_id_master']. |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | */ |
| 1758 | 1758 | function calendar_upgrade1_7_001() |
| 1759 | 1759 | { |
| 1760 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_role',array( |
|
| 1760 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_role', array( |
|
| 1761 | 1761 | 'type' => 'varchar', |
| 1762 | 1762 | 'precision' => '64', |
| 1763 | 1763 | 'default' => 'REQ-PARTICIPANT' |
@@ -1773,14 +1773,14 @@ discard block |
||
| 1773 | 1773 | */ |
| 1774 | 1774 | function calendar_upgrade1_7_002() |
| 1775 | 1775 | { |
| 1776 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones',array( |
|
| 1776 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones', array( |
|
| 1777 | 1777 | 'fd' => array( |
| 1778 | - 'tz_id' => array('type' => 'auto','nullable' => False), |
|
| 1779 | - 'tz_tzid' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
| 1780 | - 'tz_alias' => array('type' => 'int','precision' => '4','comment' => 'tz_id for data'), |
|
| 1781 | - 'tz_latitude' => array('type' => 'int','precision' => '4'), |
|
| 1782 | - 'tz_longitude' => array('type' => 'int','precision' => '4'), |
|
| 1783 | - 'tz_component' => array('type' => 'text','comment' => 'iCal VTIMEZONE component') |
|
| 1778 | + 'tz_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1779 | + 'tz_tzid' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
| 1780 | + 'tz_alias' => array('type' => 'int', 'precision' => '4', 'comment' => 'tz_id for data'), |
|
| 1781 | + 'tz_latitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1782 | + 'tz_longitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1783 | + 'tz_component' => array('type' => 'text', 'comment' => 'iCal VTIMEZONE component') |
|
| 1784 | 1784 | ), |
| 1785 | 1785 | 'pk' => array('tz_id'), |
| 1786 | 1786 | 'fk' => array(), |
@@ -1800,38 +1800,38 @@ discard block |
||
| 1800 | 1800 | */ |
| 1801 | 1801 | function calendar_upgrade1_7_003() |
| 1802 | 1802 | { |
| 1803 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_type',array( |
|
| 1803 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_type', array( |
|
| 1804 | 1804 | 'type' => 'varchar', |
| 1805 | 1805 | 'precision' => '1', |
| 1806 | 1806 | 'nullable' => False, |
| 1807 | 1807 | 'default' => 'u', |
| 1808 | 1808 | 'comment' => 'u=user, g=group, c=contact, r=resource, e=email' |
| 1809 | 1809 | )); |
| 1810 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1810 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1811 | 1811 | 'type' => 'varchar', |
| 1812 | 1812 | 'precision' => '128', |
| 1813 | 1813 | 'nullable' => False, |
| 1814 | 1814 | 'comment' => 'id or email-address for type=e' |
| 1815 | 1815 | )); |
| 1816 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_status',array( |
|
| 1816 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_status', array( |
|
| 1817 | 1817 | 'type' => 'char', |
| 1818 | 1818 | 'precision' => '1', |
| 1819 | 1819 | 'default' => 'A', |
| 1820 | 1820 | 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative' |
| 1821 | 1821 | )); |
| 1822 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_quantity',array( |
|
| 1822 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1823 | 1823 | 'type' => 'int', |
| 1824 | 1824 | 'precision' => '4', |
| 1825 | 1825 | 'default' => '1', |
| 1826 | 1826 | 'comment' => 'only for certain types (eg. resources)' |
| 1827 | 1827 | )); |
| 1828 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_role',array( |
|
| 1828 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_role', array( |
|
| 1829 | 1829 | 'type' => 'varchar', |
| 1830 | 1830 | 'precision' => '64', |
| 1831 | 1831 | 'default' => 'REQ-PARTICIPANT', |
| 1832 | 1832 | 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id' |
| 1833 | 1833 | )); |
| 1834 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_modified',array( |
|
| 1834 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_modified', array( |
|
| 1835 | 1835 | 'type' => 'timestamp', |
| 1836 | 1836 | 'default' => 'current_timestamp', |
| 1837 | 1837 | 'comment' => 'automatic timestamp of last update' |
@@ -1847,19 +1847,19 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | function calendar_upgrade1_7_004() |
| 1849 | 1849 | { |
| 1850 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_start',array( |
|
| 1850 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_start', array( |
|
| 1851 | 1851 | 'type' => 'int', |
| 1852 | 1852 | 'precision' => '8', |
| 1853 | 1853 | 'nullable' => False, |
| 1854 | 1854 | 'comment' => 'starttime in server time' |
| 1855 | 1855 | )); |
| 1856 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_end',array( |
|
| 1856 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_end', array( |
|
| 1857 | 1857 | 'type' => 'int', |
| 1858 | 1858 | 'precision' => '8', |
| 1859 | 1859 | 'nullable' => False, |
| 1860 | 1860 | 'comment' => 'endtime in server time' |
| 1861 | 1861 | )); |
| 1862 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','tz_id',array( |
|
| 1862 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'tz_id', array( |
|
| 1863 | 1863 | 'type' => 'int', |
| 1864 | 1864 | 'precision' => '4', |
| 1865 | 1865 | 'comment' => 'key into egw_cal_timezones' |
@@ -1868,7 +1868,7 @@ discard block |
||
| 1868 | 1868 | // set id of server timezone for existing events, as that's the timezone their recurrences are using |
| 1869 | 1869 | if (($tzid = date_default_timezone_get()) && ($tz_id = calendar_timezones::tz2id($tzid))) |
| 1870 | 1870 | { |
| 1871 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id,__LINE__,__FILE__); |
|
| 1871 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id, __LINE__, __FILE__); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.005'; |
| 1874 | 1874 | } |
@@ -1895,22 +1895,22 @@ discard block |
||
| 1895 | 1895 | */ |
| 1896 | 1896 | function calendar_upgrade1_7_006() |
| 1897 | 1897 | { |
| 1898 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1899 | - WHERE (cal_end-cal_start)%86400=86340',__LINE__,__FILE__) as $row) |
|
| 1898 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1899 | + WHERE (cal_end-cal_start)%86400=86340',__LINE__, __FILE__) as $row) |
|
| 1900 | 1900 | { |
| 1901 | 1901 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end+59 |
| 1902 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1902 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1906 | - WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__,__FILE__) as $row) |
|
| 1905 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1906 | + WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__, __FILE__) as $row) |
|
| 1907 | 1907 | { |
| 1908 | 1908 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end-1 |
| 1909 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1909 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
| 1913 | - WHERE recur_interval=0',__LINE__,__FILE__); |
|
| 1913 | + WHERE recur_interval=0',__LINE__, __FILE__); |
|
| 1914 | 1914 | |
| 1915 | 1915 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
| 1916 | 1916 | } |
@@ -1926,17 +1926,17 @@ discard block |
||
| 1926 | 1926 | { |
| 1927 | 1927 | // Set UID of series exception to UID of series master |
| 1928 | 1928 | // update cal_etag,cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1929 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1929 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1930 | 1930 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1931 | 1931 | FROM egw_cal cal_ex |
| 1932 | 1932 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1933 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1933 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1934 | 1934 | { |
| 1935 | 1935 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1936 | 1936 | { |
| 1937 | 1937 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1938 | 1938 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1939 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1939 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.008'; |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | */ |
| 1950 | 1950 | function calendar_upgrade1_7_008() |
| 1951 | 1951 | { |
| 1952 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user',array('cal_user_type','cal_user_id')); |
|
| 1952 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', array('cal_user_type', 'cal_user_id')); |
|
| 1953 | 1953 | |
| 1954 | 1954 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.009'; |
| 1955 | 1955 | } |
@@ -1961,22 +1961,22 @@ discard block |
||
| 1961 | 1961 | */ |
| 1962 | 1962 | function calendar_upgrade1_7_009() |
| 1963 | 1963 | { |
| 1964 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_uid'); |
|
| 1965 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_owner'); |
|
| 1964 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_uid'); |
|
| 1965 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_owner'); |
|
| 1966 | 1966 | |
| 1967 | 1967 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010'; |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | 1970 | function calendar_upgrade1_7_010() |
| 1971 | 1971 | { |
| 1972 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_deleted',array( |
|
| 1972 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_deleted', array( |
|
| 1973 | 1973 | 'type' => 'bool', |
| 1974 | 1974 | 'nullable' => False, |
| 1975 | 1975 | 'default' => '0', |
| 1976 | 1976 | 'comment' => '1 if the event has been deleted, but you want to keep it around' |
| 1977 | 1977 | )); |
| 1978 | 1978 | |
| 1979 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1979 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | 1982 | function calendar_upgrade1_7_011() |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | function calendar_upgrade1_9_001() |
| 2002 | 2002 | { |
| 2003 | 2003 | // delete in the past wrongly created entries for a single recurrence, which mess up the update, beside being wrong anyway |
| 2004 | - $GLOBALS['egw_setup']->db->delete('egw_api_content_history',array( |
|
| 2004 | + $GLOBALS['egw_setup']->db->delete('egw_api_content_history', array( |
|
| 2005 | 2005 | 'sync_appname' => 'calendar', |
| 2006 | 2006 | "sync_contentid LIKE '%:%'", |
| 2007 | 2007 | ), __LINE__, __FILE__); |
@@ -2012,36 +2012,36 @@ discard block |
||
| 2012 | 2012 | 'precision' => '8', |
| 2013 | 2013 | 'comment' => 'ts when event was deleted' |
| 2014 | 2014 | ));*/ |
| 2015 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal',array( |
|
| 2015 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal', array( |
|
| 2016 | 2016 | 'fd' => array( |
| 2017 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 2018 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'unique id of event(-series)'), |
|
| 2019 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'event owner / calendar'), |
|
| 2020 | - 'cal_category' => array('type' => 'varchar','precision' => '30','comment' => 'category id'), |
|
| 2021 | - 'cal_modified' => array('type' => 'int','precision' => '8','comment' => 'ts of last modification'), |
|
| 2022 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 2023 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1','comment' => '1=public, 0=private event'), |
|
| 2024 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 2017 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 2018 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'unique id of event(-series)'), |
|
| 2019 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'event owner / calendar'), |
|
| 2020 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30', 'comment' => 'category id'), |
|
| 2021 | + 'cal_modified' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts of last modification'), |
|
| 2022 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 2023 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1', 'comment' => '1=public, 0=private event'), |
|
| 2024 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 2025 | 2025 | 'cal_description' => array('type' => 'text'), |
| 2026 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 2027 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0','comment' => 'cal_id of series for exception'), |
|
| 2028 | - 'cal_modifier' => array('type' => 'int','precision' => '4','comment' => 'user who last modified event'), |
|
| 2029 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0','comment' => '1 for non-blocking events'), |
|
| 2030 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 2031 | - 'cal_etag' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'etag for optimistic locking'), |
|
| 2032 | - 'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'), |
|
| 2033 | - 'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'), |
|
| 2034 | - 'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'), |
|
| 2035 | - 'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'), |
|
| 2036 | - 'cal_deleted' => array('type' => 'int','precision' => '8','comment' => 'ts when event was deleted') |
|
| 2026 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 2027 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0', 'comment' => 'cal_id of series for exception'), |
|
| 2028 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4', 'comment' => 'user who last modified event'), |
|
| 2029 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'comment' => '1 for non-blocking events'), |
|
| 2030 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 2031 | + 'cal_etag' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'etag for optimistic locking'), |
|
| 2032 | + 'cal_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'creating user'), |
|
| 2033 | + 'cal_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'comment' => 'creation time of event'), |
|
| 2034 | + 'cal_recurrence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'cal_start of original recurrence for exception'), |
|
| 2035 | + 'tz_id' => array('type' => 'int', 'precision' => '4', 'comment' => 'key into egw_cal_timezones'), |
|
| 2036 | + 'cal_deleted' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts when event was deleted') |
|
| 2037 | 2037 | ), |
| 2038 | 2038 | 'pk' => array('cal_id'), |
| 2039 | 2039 | 'fk' => array(), |
| 2040 | - 'ix' => array('cal_uid','cal_owner','cal_deleted'), |
|
| 2040 | + 'ix' => array('cal_uid', 'cal_owner', 'cal_deleted'), |
|
| 2041 | 2041 | 'uc' => array() |
| 2042 | - ),array( |
|
| 2042 | + ), array( |
|
| 2043 | 2043 | // for deleted rows use cal_modified as deleted date, NULL for not deleted ones |
| 2044 | - 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN cal_modified ELSE NULL END', |
|
| 2044 | + 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true, 'bool').' THEN cal_modified ELSE NULL END', |
|
| 2045 | 2045 | )); |
| 2046 | 2046 | |
| 2047 | 2047 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.002'; |
@@ -2053,16 +2053,16 @@ discard block |
||
| 2053 | 2053 | */ |
| 2054 | 2054 | function calendar_upgrade1_9_002() |
| 2055 | 2055 | { |
| 2056 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','caldav_name',array( |
|
| 2056 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'caldav_name', array( |
|
| 2057 | 2057 | 'type' => 'varchar', |
| 2058 | 2058 | 'precision' => '64', |
| 2059 | 2059 | 'comment' => 'name part of CalDAV URL, if specified by client' |
| 2060 | 2060 | )); |
| 2061 | - $GLOBALS['egw_setup']->db->query($sql='UPDATE egw_cal SET caldav_name='. |
|
| 2061 | + $GLOBALS['egw_setup']->db->query($sql = 'UPDATE egw_cal SET caldav_name='. |
|
| 2062 | 2062 | $GLOBALS['egw_setup']->db->concat( |
| 2063 | - $GLOBALS['egw_setup']->db->to_varchar('cal_id'),"'.ics'"),__LINE__,__FILE__); |
|
| 2063 | + $GLOBALS['egw_setup']->db->to_varchar('cal_id'), "'.ics'"), __LINE__, __FILE__); |
|
| 2064 | 2064 | |
| 2065 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','caldav_name'); |
|
| 2065 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'caldav_name'); |
|
| 2066 | 2066 | |
| 2067 | 2067 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.003'; |
| 2068 | 2068 | } |
@@ -2073,8 +2073,8 @@ discard block |
||
| 2073 | 2073 | */ |
| 2074 | 2074 | function calendar_upgrade1_9_003() |
| 2075 | 2075 | { |
| 2076 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_modified'); |
|
| 2077 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user','cal_user_modified'); |
|
| 2076 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_modified'); |
|
| 2077 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', 'cal_user_modified'); |
|
| 2078 | 2078 | |
| 2079 | 2079 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.004'; |
| 2080 | 2080 | } |
@@ -2086,7 +2086,7 @@ discard block |
||
| 2086 | 2086 | */ |
| 2087 | 2087 | function calendar_upgrade1_9_004() |
| 2088 | 2088 | { |
| 2089 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates','recur_exception',array( |
|
| 2089 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates', 'recur_exception', array( |
|
| 2090 | 2090 | 'type' => 'bool', |
| 2091 | 2091 | 'default' => '', |
| 2092 | 2092 | 'null' => false, |
@@ -2094,16 +2094,16 @@ discard block |
||
| 2094 | 2094 | )); |
| 2095 | 2095 | |
| 2096 | 2096 | // migrate existing exceptions to egw_cal_dates |
| 2097 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2097 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2098 | 2098 | 'egw_cal_repeats.cal_id AS cal_id,egw_cal_repeats.recur_exception AS recur_exception,MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
| 2099 | 2099 | 'egw_cal_repeats.recur_exception IS NOT NULL', __LINE__, __FILE__, false, |
| 2100 | 2100 | 'GROUP BY egw_cal_repeats.cal_id,egw_cal_repeats.recur_exception', 'calendar', '', |
| 2101 | 2101 | 'JOIN egw_cal_dates ON egw_cal_repeats.cal_id=egw_cal_dates.cal_id') as $row) |
| 2102 | 2102 | { |
| 2103 | - foreach($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2103 | + foreach ($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2104 | 2104 | { |
| 2105 | 2105 | $GLOBALS['egw_setup']->db->insert('egw_cal_dates', array( |
| 2106 | - 'cal_end' => $recur_exception+$row['cal_end']-$row['cal_start'], |
|
| 2106 | + 'cal_end' => $recur_exception + $row['cal_end'] - $row['cal_start'], |
|
| 2107 | 2107 | 'recur_exception' => true, |
| 2108 | 2108 | ), array( |
| 2109 | 2109 | 'cal_id' => $row['cal_id'], |
@@ -2115,11 +2115,11 @@ discard block |
||
| 2115 | 2115 | |
| 2116 | 2116 | $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
| 2117 | 2117 | 'fd' => array( |
| 2118 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2119 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2120 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 2121 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2122 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2118 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2119 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2120 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 2121 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2122 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2123 | 2123 | ), |
| 2124 | 2124 | 'pk' => array('cal_id'), |
| 2125 | 2125 | 'fk' => array(), |
@@ -2140,19 +2140,19 @@ discard block |
||
| 2140 | 2140 | // returns NULL, if there are no rows! |
| 2141 | 2141 | if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384) |
| 2142 | 2142 | { |
| 2143 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_description',array( |
|
| 2143 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_description', array( |
|
| 2144 | 2144 | 'type' => 'varchar', |
| 2145 | 2145 | 'precision' => '16384' |
| 2146 | 2146 | )); |
| 2147 | 2147 | } |
| 2148 | 2148 | // allow more categories |
| 2149 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2149 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2150 | 2150 | 'type' => 'varchar', |
| 2151 | 2151 | 'precision' => '64', |
| 2152 | 2152 | 'comment' => 'category id(s)' |
| 2153 | 2153 | )); |
| 2154 | 2154 | // remove silly default of 1 |
| 2155 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_title',array( |
|
| 2155 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_title', array( |
|
| 2156 | 2156 | 'type' => 'varchar', |
| 2157 | 2157 | 'precision' => '255', |
| 2158 | 2158 | 'nullable' => False |
@@ -2167,14 +2167,14 @@ discard block |
||
| 2167 | 2167 | { |
| 2168 | 2168 | // PostgreSQL needs temporary a nullable column, to not stall on broken events without dates! |
| 2169 | 2169 | // We add that constrain in 1.9.007, after deleting all rows with range_start=0 OR range_start IS NULL |
| 2170 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_start',array( |
|
| 2170 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_start', array( |
|
| 2171 | 2171 | 'type' => 'int', |
| 2172 | 2172 | 'precision' => '8', |
| 2173 | 2173 | 'comment' => 'startdate (of range)' |
| 2174 | 2174 | )); |
| 2175 | 2175 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_start = (SELECT MIN(cal_start) FROM egw_cal_dates WHERE egw_cal_dates.cal_id=egw_cal.cal_id)', __LINE__, __FILE__); |
| 2176 | 2176 | |
| 2177 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_end',array( |
|
| 2177 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_end', array( |
|
| 2178 | 2178 | 'type' => 'int', |
| 2179 | 2179 | 'precision' => '8', |
| 2180 | 2180 | 'comment' => 'enddate (of range, UNTIL of RRULE)' |
@@ -2190,18 +2190,18 @@ discard block |
||
| 2190 | 2190 | { |
| 2191 | 2191 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_end=recur_enddate FROM egw_cal_repeats WHERE egw_cal.cal_id=egw_cal_repeats.cal_id', __LINE__, __FILE__); |
| 2192 | 2192 | } |
| 2193 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 2193 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 2194 | 2194 | 'fd' => array( |
| 2195 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2196 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2197 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2198 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1') |
|
| 2195 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2196 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2197 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2198 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1') |
|
| 2199 | 2199 | ), |
| 2200 | 2200 | 'pk' => array('cal_id'), |
| 2201 | 2201 | 'fk' => array(), |
| 2202 | 2202 | 'ix' => array(), |
| 2203 | 2203 | 'uc' => array() |
| 2204 | - ),'recur_enddate'); |
|
| 2204 | + ), 'recur_enddate'); |
|
| 2205 | 2205 | |
| 2206 | 2206 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.007'; |
| 2207 | 2207 | } |
@@ -2213,14 +2213,14 @@ discard block |
||
| 2213 | 2213 | */ |
| 2214 | 2214 | function calendar_upgrade1_9_007() |
| 2215 | 2215 | { |
| 2216 | - foreach(array('egw_cal_repeats','egw_cal_dates','egw_cal_user','egw_cal_extra') as $table) |
|
| 2216 | + foreach (array('egw_cal_repeats', 'egw_cal_dates', 'egw_cal_user', 'egw_cal_extra') as $table) |
|
| 2217 | 2217 | { |
| 2218 | 2218 | $GLOBALS['egw_setup']->db->query("DELETE FROM $table WHERE cal_id IN (SELECT cal_id FROM egw_cal WHERE range_start=0 OR range_start IS NULL)", __LINE__, __FILE__); |
| 2219 | 2219 | } |
| 2220 | 2220 | $GLOBALS['egw_setup']->db->query("DELETE FROM egw_cal WHERE range_start=0 OR range_start IS NULL", __LINE__, __FILE__); |
| 2221 | 2221 | |
| 2222 | 2222 | // now we can remove temporary default of 0 from range_start and set it NOT NULL |
| 2223 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','range_start',array( |
|
| 2223 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'range_start', array( |
|
| 2224 | 2224 | 'type' => 'int', |
| 2225 | 2225 | 'precision' => '8', |
| 2226 | 2226 | 'nullable' => False, |
@@ -2285,7 +2285,7 @@ discard block |
||
| 2285 | 2285 | |
| 2286 | 2286 | function calendar_upgrade1_9_010() |
| 2287 | 2287 | { |
| 2288 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2288 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2289 | 2289 | 'type' => 'varchar', |
| 2290 | 2290 | 'precision' => '200', |
| 2291 | 2291 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2315,7 +2315,7 @@ discard block |
||
| 2315 | 2315 | SET cal_reference=0,cal_recurrence=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time()." |
| 2316 | 2316 | WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__); |
| 2317 | 2317 | |
| 2318 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2318 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2319 | 2319 | "SELECT DISTINCT master.cal_id,egw_cal_user.cal_user_type,egw_cal_user.cal_user_id,'E' AS cal_status |
| 2320 | 2320 | FROM egw_cal_user |
| 2321 | 2321 | JOIN egw_cal ON egw_cal_user.cal_id=egw_cal.cal_id |
@@ -2342,7 +2342,7 @@ discard block |
||
| 2342 | 2342 | */ |
| 2343 | 2343 | function calendar_upgrade14_1_001() |
| 2344 | 2344 | { |
| 2345 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2345 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2346 | 2346 | "SELECT egw_cal.cal_id AS cal_id,cal_start,cal_end,range_start,range_end,egw_cal_repeats.*,tz_tzid AS tzid |
| 2347 | 2347 | FROM egw_cal |
| 2348 | 2348 | JOIN egw_cal_repeats ON egw_cal_repeats.cal_id=egw_cal.cal_id |
@@ -2364,7 +2364,7 @@ discard block |
||
| 2364 | 2364 | $enddate->modify(($event['end'] - $event['start']).' second'); |
| 2365 | 2365 | if (($range_end = $enddate->format('server')) != $event['range_end']) |
| 2366 | 2366 | { |
| 2367 | - $GLOBALS['egw_setup']->db->update('egw_cal',array( |
|
| 2367 | + $GLOBALS['egw_setup']->db->update('egw_cal', array( |
|
| 2368 | 2368 | 'range_end' => $range_end, |
| 2369 | 2369 | 'cal_etag=cal_etag+1', |
| 2370 | 2370 | 'cal_modified' => time(), |
@@ -2374,7 +2374,7 @@ discard block |
||
| 2374 | 2374 | //error_log(__FUNCTION__."() #$event[id], start=".date('Y-m-d H:i:s', $event['start']).', end='.date('Y-m-d H:i:s', $event['end']).', range_end='.date('Y-m-d H:i:s', $event['recur_enddate']).' --> '.date('Y-m-d H:i:s', $range_end)); |
| 2375 | 2375 | } |
| 2376 | 2376 | } |
| 2377 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2377 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2378 | 2378 | } |
| 2379 | 2379 | |
| 2380 | 2380 | /** |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | // if maximum is bigger then 3 |
| 2399 | 2399 | if ($values[1] > 3) |
| 2400 | 2400 | { |
| 2401 | - switch($GLOBALS['egw_setup']->db->Type) |
|
| 2401 | + switch ($GLOBALS['egw_setup']->db->Type) |
|
| 2402 | 2402 | { |
| 2403 | 2403 | case 'mysql': |
| 2404 | 2404 | $sql = "UPDATE egw_cal |
@@ -2448,7 +2448,7 @@ discard block |
||
| 2448 | 2448 | |
| 2449 | 2449 | function calendar_upgrade14_2_003() |
| 2450 | 2450 | { |
| 2451 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_uid',array( |
|
| 2451 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_uid', array( |
|
| 2452 | 2452 | 'type' => 'ascii', |
| 2453 | 2453 | 'precision' => '128', |
| 2454 | 2454 | 'nullable' => False, |
@@ -2460,13 +2460,13 @@ discard block |
||
| 2460 | 2460 | { |
| 2461 | 2461 | $GLOBALS['egw_setup']->db->query("UPDATE egw_cal SET cal_category='' WHERE cal_category NOT REGEXP '^[0-9,]*$'", __LINE__, __FILE__); |
| 2462 | 2462 | } |
| 2463 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2463 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2464 | 2464 | 'type' => 'ascii', |
| 2465 | 2465 | 'meta' => 'category', |
| 2466 | 2466 | 'precision' => '64', |
| 2467 | 2467 | 'comment' => 'category id(s)' |
| 2468 | 2468 | )); |
| 2469 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2469 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2470 | 2470 | 'type' => 'ascii', |
| 2471 | 2471 | 'precision' => '128', |
| 2472 | 2472 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2523,22 +2523,22 @@ discard block |
||
| 2523 | 2523 | 'type' => 'auto', |
| 2524 | 2524 | 'nullable' => False |
| 2525 | 2525 | ));*/ |
| 2526 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 2526 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 2527 | 2527 | 'fd' => array( |
| 2528 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2529 | - 'cal_recur_date' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0'), |
|
| 2530 | - 'cal_user_type' => array('type' => 'ascii','precision' => '1','nullable' => False,'default' => 'u','comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2531 | - 'cal_user_id' => array('type' => 'varchar','meta' => array("cal_user_type='u'" => 'account'),'precision' => '128','nullable' => False,'comment' => 'id or email-address for type=e'), |
|
| 2532 | - 'cal_status' => array('type' => 'ascii','precision' => '1','default' => 'A','comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2533 | - 'cal_quantity' => array('type' => 'int','precision' => '4','default' => '1','comment' => 'only for certain types (eg. resources)'), |
|
| 2534 | - 'cal_role' => array('type' => 'ascii','precision' => '64','default' => 'REQ-PARTICIPANT','comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2535 | - 'cal_user_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'automatic timestamp of last update'), |
|
| 2536 | - 'cal_user_auto' => array('type' => 'auto','nullable' => False) |
|
| 2528 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2529 | + 'cal_recur_date' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 2530 | + 'cal_user_type' => array('type' => 'ascii', 'precision' => '1', 'nullable' => False, 'default' => 'u', 'comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2531 | + 'cal_user_id' => array('type' => 'varchar', 'meta' => array("cal_user_type='u'" => 'account'), 'precision' => '128', 'nullable' => False, 'comment' => 'id or email-address for type=e'), |
|
| 2532 | + 'cal_status' => array('type' => 'ascii', 'precision' => '1', 'default' => 'A', 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2533 | + 'cal_quantity' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'comment' => 'only for certain types (eg. resources)'), |
|
| 2534 | + 'cal_role' => array('type' => 'ascii', 'precision' => '64', 'default' => 'REQ-PARTICIPANT', 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2535 | + 'cal_user_modified' => array('type' => 'timestamp', 'default' => 'current_timestamp', 'comment' => 'automatic timestamp of last update'), |
|
| 2536 | + 'cal_user_auto' => array('type' => 'auto', 'nullable' => False) |
|
| 2537 | 2537 | ), |
| 2538 | 2538 | 'pk' => array('cal_user_auto'), |
| 2539 | 2539 | 'fk' => array(), |
| 2540 | - 'ix' => array('cal_user_modified',array('cal_user_type','cal_user_id')), |
|
| 2541 | - 'uc' => array(array('cal_id','cal_recur_date','cal_user_type','cal_user_id')) |
|
| 2540 | + 'ix' => array('cal_user_modified', array('cal_user_type', 'cal_user_id')), |
|
| 2541 | + 'uc' => array(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id')) |
|
| 2542 | 2542 | )); |
| 2543 | 2543 | |
| 2544 | 2544 | return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.005'; |
@@ -2547,12 +2547,12 @@ discard block |
||
| 2547 | 2547 | |
| 2548 | 2548 | function calendar_upgrade14_2_005() |
| 2549 | 2549 | { |
| 2550 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_tzid',array( |
|
| 2550 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_tzid', array( |
|
| 2551 | 2551 | 'type' => 'ascii', |
| 2552 | 2552 | 'precision' => '128', |
| 2553 | 2553 | 'nullable' => False |
| 2554 | 2554 | )); |
| 2555 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_component',array( |
|
| 2555 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_component', array( |
|
| 2556 | 2556 | 'type' => 'ascii', |
| 2557 | 2557 | 'precision' => '8192', |
| 2558 | 2558 | 'comment' => 'iCal VTIMEZONE component' |
@@ -2568,7 +2568,7 @@ discard block |
||
| 2568 | 2568 | */ |
| 2569 | 2569 | function calendar_upgrade14_3() |
| 2570 | 2570 | { |
| 2571 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_attendee',array( |
|
| 2571 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_attendee', array( |
|
| 2572 | 2572 | 'type' => 'varchar', |
| 2573 | 2573 | 'precision' => '255', |
| 2574 | 2574 | 'comment' => 'email or json object with attr. cn, url, ...' |
@@ -2579,12 +2579,12 @@ discard block |
||
| 2579 | 2579 | |
| 2580 | 2580 | // delete all but one row, which would give a doublicate key, after above normalising of email addresses |
| 2581 | 2581 | // by ordering by status we prever accepted over tentative over unknow over deleted |
| 2582 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2582 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2583 | 2583 | 'cal_user_type' => 'e', |
| 2584 | 2584 | ), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1", 'calendar') as $row) |
| 2585 | 2585 | { |
| 2586 | 2586 | $n = 0; |
| 2587 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2587 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2588 | 2588 | 'cal_id' => $row['cal_id'], |
| 2589 | 2589 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2590 | 2590 | 'cal_user_type' => 'e', |
@@ -2592,7 +2592,7 @@ discard block |
||
| 2592 | 2592 | ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
| 2593 | 2593 | { |
| 2594 | 2594 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2595 | - $GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status')))); |
|
| 2595 | + $GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id', 'cal_status')))); |
|
| 2596 | 2596 | } |
| 2597 | 2597 | } |
| 2598 | 2598 | |
@@ -2601,7 +2601,7 @@ discard block |
||
| 2601 | 2601 | "UPDATE egw_cal_user SET cal_user_attendee=cal_user_id,cal_user_id=MD5($email) WHERE cal_user_type='e'", |
| 2602 | 2602 | __LINE__, __FILE__); |
| 2603 | 2603 | |
| 2604 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 2604 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 2605 | 2605 | 'type' => 'ascii', |
| 2606 | 2606 | 'meta' => array( |
| 2607 | 2607 | "cal_user_type='u'" => 'account' |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | { |
| 2624 | 2624 | $GLOBALS['calendar_upgrade14_3_001-run'] = true; |
| 2625 | 2625 | |
| 2626 | - foreach($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2626 | + foreach ($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2627 | 2627 | FROM egw_cal_user |
| 2628 | 2628 | JOIN egw_cal_user euser ON euser.cal_id=egw_cal_user.cal_id AND euser.cal_user_type='e' AND euser.cal_user_id=egw_cal_user.cal_user_id AND euser.cal_user_attendee IS NULL |
| 2629 | 2629 | WHERE egw_cal_user.cal_user_type='e' AND egw_cal_user.cal_user_attendee IS NOT NULL |
@@ -2674,8 +2674,8 @@ discard block |
||
| 2674 | 2674 | { |
| 2675 | 2675 | Api\Preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner) |
| 2676 | 2676 | { |
| 2677 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2678 | - if($old_value['state'] && is_array($old_value['state'])) |
|
| 2677 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2678 | + if ($old_value['state'] && is_array($old_value['state'])) |
|
| 2679 | 2679 | { |
| 2680 | 2680 | unset($old_value['state']['date']); |
| 2681 | 2681 | unset($old_value['state']['startdate']); |
@@ -2695,15 +2695,15 @@ discard block |
||
| 2695 | 2695 | { |
| 2696 | 2696 | Api\Preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner) |
| 2697 | 2697 | { |
| 2698 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2699 | - switch($old_value) |
|
| 2698 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2699 | + switch ($old_value) |
|
| 2700 | 2700 | { |
| 2701 | 2701 | case 'all': |
| 2702 | 2702 | return 0; |
| 2703 | 2703 | case 'day_week': |
| 2704 | - return ['day','day4','week']; |
|
| 2704 | + return ['day', 'day4', 'week']; |
|
| 2705 | 2705 | case 'day4': |
| 2706 | - return ['day','day4']; |
|
| 2706 | + return ['day', 'day4']; |
|
| 2707 | 2707 | } |
| 2708 | 2708 | return null; |
| 2709 | 2709 | }); |
@@ -2728,7 +2728,7 @@ discard block |
||
| 2728 | 2728 | function calendar_upgrade16_1_001() |
| 2729 | 2729 | { |
| 2730 | 2730 | $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_extra', 'cal_extra_value', |
| 2731 | - array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')); |
|
| 2731 | + array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => '')); |
|
| 2732 | 2732 | |
| 2733 | 2733 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'forced'); |
| 2734 | 2734 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'default'); |
@@ -1429,13 +1429,18 @@ discard block |
||
| 1429 | 1429 | function calendar_upgrade1_0_1_008() |
| 1430 | 1430 | { |
| 1431 | 1431 | $config_data = Api\Config::read('calendar'); |
| 1432 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1432 | + if (isset($config_data['fields'])) |
|
| 1433 | + { |
|
| 1434 | + // old custom fields |
|
| 1433 | 1435 | { |
| 1434 | 1436 | $customfields = array(); |
| 1437 | + } |
|
| 1435 | 1438 | $order = 0; |
| 1436 | 1439 | foreach($config_data['fields'] as $name => $data) |
| 1437 | 1440 | { |
| 1438 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1441 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1442 | + { |
|
| 1443 | + // real not-disabled custom field |
|
| 1439 | 1444 | { |
| 1440 | 1445 | $customfields[substr($name,1)] = array( |
| 1441 | 1446 | 'type' => 'text', |
@@ -1444,6 +1449,7 @@ discard block |
||
| 1444 | 1449 | 'order' => ($order += 10), |
| 1445 | 1450 | ); |
| 1446 | 1451 | } |
| 1452 | + } |
|
| 1447 | 1453 | } |
| 1448 | 1454 | if (count($customfields)) |
| 1449 | 1455 | { |
@@ -2589,9 +2595,12 @@ discard block |
||
| 2589 | 2595 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2590 | 2596 | 'cal_user_type' => 'e', |
| 2591 | 2597 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2592 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2598 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2599 | + { |
|
| 2600 | + // order A, T, U, X |
|
| 2593 | 2601 | { |
| 2594 | 2602 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2603 | + } |
|
| 2595 | 2604 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status')))); |
| 2596 | 2605 | } |
| 2597 | 2606 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 34 | 34 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 35 | - $GLOBALS['egw_setup']->oProc->query("UPDATE $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 35 | + $GLOBALS['egw_setup']->oProc->query("update $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | $GLOBALS['egw_setup']->oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0)); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 189 | 189 | |
| 190 | 190 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry', |
| 191 | - Array( |
|
| 191 | + array( |
|
| 192 | 192 | 'fd' => array( |
| 193 | 193 | 'cal_id' => array('type' => 'auto', 'nullable' => false), |
| 194 | 194 | 'cal_owner' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry'); |
| 239 | 239 | |
| 240 | 240 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_user', |
| 241 | - Array( |
|
| 241 | + array( |
|
| 242 | 242 | 'fd' => array( |
| 243 | 243 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
| 244 | 244 | 'cal_login' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_user'); |
| 269 | 269 | |
| 270 | 270 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_repeats', |
| 271 | - Array( |
|
| 271 | + array( |
|
| 272 | 272 | 'fd' => array( |
| 273 | 273 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'default' => '0', 'nullable' => false), |
| 274 | 274 | 'cal_type' => array('type' => 'varchar', 'precision' => 20, 'default' => 'daily', 'nullable' => false), |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 313 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 313 | + $GLOBALS['egw_setup']->oProc->query("update {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 314 | 314 | |
| 315 | 315 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 316 | 316 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | // calendar_entry => phpgw_cal |
| 604 | 604 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal', |
| 605 | - Array( |
|
| 605 | + array( |
|
| 606 | 606 | 'fd' => array( |
| 607 | 607 | 'cal_id' => array('type' => 'auto', 'nullable' => False), |
| 608 | 608 | 'owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | // calendar_entry_repeats => phpgw_cal_repeats |
| 660 | 660 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 661 | - Array( |
|
| 661 | + array( |
|
| 662 | 662 | 'fd' => array( |
| 663 | 663 | 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
| 664 | 664 | 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | function calendar_upgrade0_9_11_003() |
| 732 | 732 | { |
| 733 | 733 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 734 | - Array( |
|
| 734 | + array( |
|
| 735 | 735 | 'fd' => array( |
| 736 | 736 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
| 737 | 737 | 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | $GLOBALS['egw_setup']->oProc->DropTable('phpgw_cal_holidays'); |
| 769 | 769 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 770 | - Array( |
|
| 770 | + array( |
|
| 771 | 771 | 'fd' => array( |
| 772 | 772 | 'hol_id' => array('type' => 'auto','nullable' => False), |
| 773 | 773 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | function calendar_upgrade0_9_13_003() |
| 855 | 855 | { |
| 856 | 856 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 857 | - Array( |
|
| 857 | + array( |
|
| 858 | 858 | 'fd' => array( |
| 859 | 859 | 'alarm_id' => array('type' => 'auto','nullable' => False), |
| 860 | 860 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | function calendar_upgrade0_9_13_005() |
| 890 | 890 | { |
| 891 | - $calendar_data = Array(); |
|
| 891 | + $calendar_data = array(); |
|
| 892 | 892 | $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
| 893 | 893 | while($GLOBALS['egw_setup']->oProc->next_record()) |
| 894 | 894 | { |
@@ -187,7 +187,7 @@ |
||
| 187 | 187 | * |
| 188 | 188 | * @param string $file filename |
| 189 | 189 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 190 | - * @return boolean false on error |
|
| 190 | + * @return boolean|null false on error |
|
| 191 | 191 | */ |
| 192 | 192 | function fix_api($file, $dry_run=false) |
| 193 | 193 | { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // raw replacements |
| 19 | 19 | $add_use_api = array( |
| 20 | - "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
| 20 | + "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
| 21 | 21 | "#<\?php\n+\s*/\*+?(.*)\*/#msU" => "<?php\n/**$1*/\n\nuse EGroupware\\Api;", |
| 22 | 22 | ); |
| 23 | 23 | $replace = array( |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // enclose class-names and static methods with some syntax check |
| 47 | 47 | $class_start = '#(?<!function)([\[\s,;().!=])'; |
| 48 | 48 | $class_end = '(::|\\(|\\)|;|\?|:|\\s|,|$)#'; |
| 49 | -foreach(array( |
|
| 49 | +foreach (array( |
|
| 50 | 50 | 'accounts' => 'Api\\Accounts', |
| 51 | 51 | 'acl' => 'Api\\Acl', |
| 52 | 52 | 'EGW_ACL_READ' => 'Api\\Acl::READ', |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 190 | 190 | * @return boolean false on error |
| 191 | 191 | */ |
| 192 | -function fix_api($file, $dry_run=false) |
|
| 192 | +function fix_api($file, $dry_run = false) |
|
| 193 | 193 | { |
| 194 | 194 | global $prog, $replace, $add_use_api; |
| 195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 195 | + if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 196 | 196 | |
| 197 | 197 | if (($content = $content_in = file_get_contents($file)) === false) return false; |
| 198 | 198 | |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
| 205 | 205 | |
| 206 | - if ($content2 == $content_in) return true; // nothing changed |
|
| 206 | + if ($content2 == $content_in) return true; // nothing changed |
|
| 207 | 207 | |
| 208 | 208 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
| 209 | 209 | |
| 210 | 210 | // shorten some classes, if used, with further use declarations |
| 211 | - foreach(array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
| 211 | + foreach (array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
| 212 | 212 | { |
| 213 | 213 | if (strpos($content, $namespace) !== false && strpos($content, 'use EGroupware\\'.$namespace) === false) |
| 214 | 214 | { |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 248 | 248 | * @return boolean false on error |
| 249 | 249 | */ |
| 250 | -function fix_api_recursive($dir, $dry_run=false) |
|
| 250 | +function fix_api_recursive($dir, $dry_run = false) |
|
| 251 | 251 | { |
| 252 | 252 | if (!is_dir($dir)) return false; |
| 253 | 253 | |
| 254 | - foreach(scandir($dir) as $file) |
|
| 254 | + foreach (scandir($dir) as $file) |
|
| 255 | 255 | { |
| 256 | 256 | if ($file == '.' || $file == '..') continue; |
| 257 | 257 | |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | fix_api_recursive($dir.'/'.$file, $dry_run); |
| 261 | 261 | } |
| 262 | - elseif(substr($file,-4) == '.php') |
|
| 262 | + elseif (substr($file, -4) == '.php') |
|
| 263 | 263 | { |
| 264 | - echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': '; |
|
| 264 | + echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': '; |
|
| 265 | 265 | fix_api($dir.'/'.$file, $dry_run); |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | - echo "\r".str_repeat(' ',100)."\r"; |
|
| 268 | + echo "\r".str_repeat(' ', 100)."\r"; |
|
| 269 | 269 | return true; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param string $error =null |
| 276 | 276 | */ |
| 277 | -function usage($error=null) |
|
| 277 | +function usage($error = null) |
|
| 278 | 278 | { |
| 279 | 279 | global $prog; |
| 280 | 280 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | if (!$args) usage(); |
| 289 | 289 | |
| 290 | 290 | $dry_run = false; |
| 291 | -while(($arg = array_shift($args)) && $arg[0] == '-') |
|
| 291 | +while (($arg = array_shift($args)) && $arg[0] == '-') |
|
| 292 | 292 | { |
| 293 | - switch($arg) |
|
| 293 | + switch ($arg) |
|
| 294 | 294 | { |
| 295 | 295 | case '-h': |
| 296 | 296 | case '--help': |
@@ -323,4 +323,4 @@ discard block |
||
| 323 | 323 | fix_api_recursive($arg, $dry_run); |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | -while(($arg = array_shift($args))); |
|
| 326 | +while (($arg = array_shift($args))); |
|
@@ -10,10 +10,13 @@ discard block |
||
| 10 | 10 | * @version $Id$ |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
| 13 | +if (php_sapi_name() !== 'cli') |
|
| 14 | +{ |
|
| 15 | + // security precaution: forbit calling as web-page |
|
| 14 | 16 | { |
| 15 | 17 | die('<h1>fix_api.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 16 | 18 | } |
| 19 | +} |
|
| 17 | 20 | |
| 18 | 21 | // raw replacements |
| 19 | 22 | $add_use_api = array( |
@@ -192,9 +195,16 @@ discard block |
||
| 192 | 195 | function fix_api($file, $dry_run=false) |
| 193 | 196 | { |
| 194 | 197 | global $prog, $replace, $add_use_api; |
| 195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 198 | + if (basename($file) == $prog) |
|
| 199 | + { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 202 | + // dont fix ourself ;-) |
|
| 196 | 203 | |
| 197 | - if (($content = $content_in = file_get_contents($file)) === false) return false; |
|
| 204 | + if (($content = $content_in = file_get_contents($file)) === false) |
|
| 205 | + { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | if (!preg_match("|<\?php\n+\s*/\*\*?.*\*/|msU", $content)) |
| 200 | 210 | { |
@@ -203,7 +213,11 @@ discard block |
||
| 203 | 213 | } |
| 204 | 214 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
| 205 | 215 | |
| 206 | - if ($content2 == $content_in) return true; // nothing changed |
|
| 216 | + if ($content2 == $content_in) |
|
| 217 | + { |
|
| 218 | + return true; |
|
| 219 | + } |
|
| 220 | + // nothing changed |
|
| 207 | 221 | |
| 208 | 222 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
| 209 | 223 | |
@@ -249,11 +263,17 @@ discard block |
||
| 249 | 263 | */ |
| 250 | 264 | function fix_api_recursive($dir, $dry_run=false) |
| 251 | 265 | { |
| 252 | - if (!is_dir($dir)) return false; |
|
| 266 | + if (!is_dir($dir)) |
|
| 267 | + { |
|
| 268 | + return false; |
|
| 269 | + } |
|
| 253 | 270 | |
| 254 | 271 | foreach(scandir($dir) as $file) |
| 255 | 272 | { |
| 256 | - if ($file == '.' || $file == '..') continue; |
|
| 273 | + if ($file == '.' || $file == '..') |
|
| 274 | + { |
|
| 275 | + continue; |
|
| 276 | + } |
|
| 257 | 277 | |
| 258 | 278 | if (is_dir($dir.'/'.$file)) |
| 259 | 279 | { |
@@ -278,14 +298,20 @@ discard block |
||
| 278 | 298 | { |
| 279 | 299 | global $prog; |
| 280 | 300 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
| 281 | - if ($error) echo $error."\n\n"; |
|
| 301 | + if ($error) |
|
| 302 | + { |
|
| 303 | + echo $error."\n\n"; |
|
| 304 | + } |
|
| 282 | 305 | exit($error ? 1 : 0); |
| 283 | 306 | } |
| 284 | 307 | |
| 285 | 308 | $args = $_SERVER['argv']; |
| 286 | 309 | $prog = basename(array_shift($args)); |
| 287 | 310 | |
| 288 | -if (!$args) usage(); |
|
| 311 | +if (!$args) |
|
| 312 | +{ |
|
| 313 | + usage(); |
|
| 314 | +} |
|
| 289 | 315 | |
| 290 | 316 | $dry_run = false; |
| 291 | 317 | while(($arg = array_shift($args)) && $arg[0] == '-') |
@@ -303,16 +329,22 @@ discard block |
||
| 303 | 329 | break; |
| 304 | 330 | |
| 305 | 331 | default: |
| 306 | - if ($args) // not last argument |
|
| 332 | + if ($args) |
|
| 333 | + { |
|
| 334 | + // not last argument |
|
| 307 | 335 | { |
| 308 | 336 | usage("Unknown argument '$arg'!"); |
| 309 | 337 | } |
| 338 | + } |
|
| 310 | 339 | break 2; |
| 311 | 340 | } |
| 312 | 341 | } |
| 313 | 342 | |
| 314 | 343 | do { |
| 315 | - if (!file_exists($arg)) usage("Error: $arg not found!"); |
|
| 344 | + if (!file_exists($arg)) |
|
| 345 | + { |
|
| 346 | + usage("Error: $arg not found!"); |
|
| 347 | + } |
|
| 316 | 348 | |
| 317 | 349 | if (!is_dir($arg)) |
| 318 | 350 | { |