@@ -123,7 +123,7 @@ |
||
| 123 | 123 | } |
| 124 | 124 | // Custom fields |
| 125 | 125 | if($content && strpos($content, '#') !== 0) |
| 126 | - { |
|
| 126 | + { |
|
| 127 | 127 | // Expand link-to custom fields |
| 128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
| 129 | 129 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | // Custom fields |
| 125 | 125 | if($content && strpos($content, '#') !== 0) |
| 126 | - { |
|
| 126 | + { |
|
| 127 | 127 | // Expand link-to custom fields |
| 128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
| 129 | 129 | |
@@ -151,12 +151,14 @@ discard block |
||
| 151 | 151 | // Try this first - a normal path /apps/appname/id/file |
| 152 | 152 | list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
| 153 | 153 | // Symlink? |
| 154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 154 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
| 155 | + { |
|
| 155 | 156 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
| 156 | 157 | $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
| 157 | 158 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
| 158 | 159 | |
| 159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
| 160 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
| 161 | + { |
|
| 160 | 162 | // Get rid of any virtual folders (eg: All$) and symlinks |
| 161 | 163 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
| 162 | 164 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
@@ -190,7 +192,10 @@ discard block |
||
| 190 | 192 | if(is_array($link)) |
| 191 | 193 | { |
| 192 | 194 | // Directories have their internal protocol in path here |
| 193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
| 195 | + if($link['path'] && strpos($link['path'], '://') !== false) |
|
| 196 | + { |
|
| 197 | + $link['path'] = $file['path']; |
|
| 198 | + } |
|
| 194 | 199 | $link = Api\Session::link('/index.php', $link); |
| 195 | 200 | } |
| 196 | 201 | else |
@@ -200,7 +205,10 @@ discard block |
||
| 200 | 205 | } |
| 201 | 206 | |
| 202 | 207 | // Prepend site, if missing |
| 203 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
| 208 | + if ($link[0] == '/') |
|
| 209 | + { |
|
| 210 | + $link = Api\Framework::getUrl($link); |
|
| 211 | + } |
|
| 204 | 212 | |
| 205 | 213 | $file['link'] = Api\Html::a_href(Api\Html::htmlspecialchars($file['name']), $link); |
| 206 | 214 | $file['webdav_url'] = Api\Session::link(Vfs::download_url($file['url'])); |
@@ -209,7 +217,10 @@ discard block |
||
| 209 | 217 | // Add markers |
| 210 | 218 | foreach($file as $key => &$value) |
| 211 | 219 | { |
| 212 | - if(!$value) $value = ''; |
|
| 220 | + if(!$value) |
|
| 221 | + { |
|
| 222 | + $value = ''; |
|
| 223 | + } |
|
| 213 | 224 | $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
| 214 | 225 | } |
| 215 | 226 | if($app_placeholders) |
@@ -251,9 +262,15 @@ discard block |
||
| 251 | 262 | ); |
| 252 | 263 | foreach($fields as $name => $label) |
| 253 | 264 | { |
| 254 | - if (!($n&1)) echo '<tr>'; |
|
| 265 | + if (!($n&1)) |
|
| 266 | + { |
|
| 267 | + echo '<tr>'; |
|
| 268 | + } |
|
| 255 | 269 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
| 256 | - if ($n&1) echo "</tr>\n"; |
|
| 270 | + if ($n&1) |
|
| 271 | + { |
|
| 272 | + echo "</tr>\n"; |
|
| 273 | + } |
|
| 257 | 274 | $n++; |
| 258 | 275 | } |
| 259 | 276 | |
@@ -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'; |
@@ -1428,13 +1428,18 @@ discard block |
||
| 1428 | 1428 | function calendar_upgrade1_0_1_008() |
| 1429 | 1429 | { |
| 1430 | 1430 | $config_data = Api\Config::read('calendar'); |
| 1431 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1431 | + if (isset($config_data['fields'])) |
|
| 1432 | + { |
|
| 1433 | + // old custom fields |
|
| 1432 | 1434 | { |
| 1433 | 1435 | $customfields = array(); |
| 1436 | + } |
|
| 1434 | 1437 | $order = 0; |
| 1435 | 1438 | foreach($config_data['fields'] as $name => $data) |
| 1436 | 1439 | { |
| 1437 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1440 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1441 | + { |
|
| 1442 | + // real not-disabled custom field |
|
| 1438 | 1443 | { |
| 1439 | 1444 | $customfields[substr($name,1)] = array( |
| 1440 | 1445 | 'type' => 'text', |
@@ -1443,6 +1448,7 @@ discard block |
||
| 1443 | 1448 | 'order' => ($order += 10), |
| 1444 | 1449 | ); |
| 1445 | 1450 | } |
| 1451 | + } |
|
| 1446 | 1452 | } |
| 1447 | 1453 | if (count($customfields)) |
| 1448 | 1454 | { |
@@ -2583,9 +2589,12 @@ discard block |
||
| 2583 | 2589 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2584 | 2590 | 'cal_user_type' => 'e', |
| 2585 | 2591 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2586 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2592 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2593 | + { |
|
| 2594 | + // order A, T, U, X |
|
| 2587 | 2595 | { |
| 2588 | 2596 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2597 | + } |
|
| 2589 | 2598 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2590 | 2599 | array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
| 2591 | 2600 | __LINE__, __FILE__, 'calendar'); |
@@ -2735,8 +2744,12 @@ discard block |
||
| 2735 | 2744 | function calendar_upgrade16_1_002() |
| 2736 | 2745 | { |
| 2737 | 2746 | // Explicitly add months as showing list of events, no times |
| 2738 | - $change = function($attr, $old_value, $owner) { |
|
| 2739 | - if($owner == Api\Preferences::FORCED_ID) return; |
|
| 2747 | + $change = function($attr, $old_value, $owner) |
|
| 2748 | + { |
|
| 2749 | + if($owner == Api\Preferences::FORCED_ID) |
|
| 2750 | + { |
|
| 2751 | + return; |
|
| 2752 | + } |
|
| 2740 | 2753 | if(is_array($old_value) && !in_array('month', $old_value)) |
| 2741 | 2754 | { |
| 2742 | 2755 | $old_value[] = 'month'; |
@@ -2758,8 +2771,13 @@ discard block |
||
| 2758 | 2771 | function calendar_upgrade17_1() |
| 2759 | 2772 | { |
| 2760 | 2773 | // Update birthdays as events preference from boolean |
| 2761 | - $change = function($attr, $old_value, $owner) { |
|
| 2762 | - if (!isset($old_value)) return null; // do not set anything, if nothing was set before |
|
| 2774 | + $change = function($attr, $old_value, $owner) |
|
| 2775 | + { |
|
| 2776 | + if (!isset($old_value)) |
|
| 2777 | + { |
|
| 2778 | + return null; |
|
| 2779 | + } |
|
| 2780 | + // do not set anything, if nothing was set before |
|
| 2763 | 2781 | return $old_value ? 'birthday' : 'none'; |
| 2764 | 2782 | }; |
| 2765 | 2783 | Api\Preferences::change_preference('calendar', 'birthdays_as_events', $change); |
@@ -32,8 +32,8 @@ |
||
| 32 | 32 | protected static $conditions = array('exists'); |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * For figuring out if an entry has changed |
|
| 36 | - */ |
|
| 35 | + * For figuring out if an entry has changed |
|
| 36 | + */ |
|
| 37 | 37 | protected $tracking; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -17,7 +17,8 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for calendar |
| 19 | 19 | */ |
| 20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
| 20 | +class calendar_import_csv extends importexport_basic_import_csv |
|
| 21 | +{ |
|
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * actions wich could be done to data entries |
@@ -83,8 +84,10 @@ discard block |
||
| 83 | 84 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
| 84 | 85 | |
| 85 | 86 | // Set owner, unless it's supposed to come from CSV file |
| 86 | - if($options['owner_from_csv']) { |
|
| 87 | - if(!is_numeric($record['owner'])) { |
|
| 87 | + if($options['owner_from_csv']) |
|
| 88 | + { |
|
| 89 | + if(!is_numeric($record['owner'])) |
|
| 90 | + { |
|
| 88 | 91 | $this->errors[$import_csv->get_current_position()] = lang( |
| 89 | 92 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
| 90 | 93 | $record->owner, |
@@ -106,7 +109,8 @@ discard block |
||
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | // Parse particpants |
| 109 | - if ($record->participants && !is_array($record->participants)) { |
|
| 112 | + if ($record->participants && !is_array($record->participants)) |
|
| 113 | + { |
|
| 110 | 114 | $warning = ''; |
| 111 | 115 | $record->participants = $this->parse_participants($record, $warning); |
| 112 | 116 | if($warning) |
@@ -138,27 +142,38 @@ discard block |
||
| 138 | 142 | } |
| 139 | 143 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
| 140 | 144 | |
| 141 | - if ( $options['conditions'] ) { |
|
| 142 | - foreach ( $options['conditions'] as $condition ) { |
|
| 145 | + if ( $options['conditions'] ) |
|
| 146 | + { |
|
| 147 | + foreach ( $options['conditions'] as $condition ) |
|
| 148 | + { |
|
| 143 | 149 | $records = array(); |
| 144 | - switch ( $condition['type'] ) { |
|
| 150 | + switch ( $condition['type'] ) |
|
| 151 | + { |
|
| 145 | 152 | // exists |
| 146 | 153 | case 'exists' : |
| 147 | 154 | // Check for that record |
| 148 | 155 | $result = $this->exists($record, $condition, $records); |
| 149 | 156 | |
| 150 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 157 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 158 | + { |
|
| 151 | 159 | // apply action to all records matching this exists condition |
| 152 | 160 | $action = $condition['true']; |
| 153 | - foreach ( (array)$records as $event ) { |
|
| 161 | + foreach ( (array)$records as $event ) |
|
| 162 | + { |
|
| 154 | 163 | $record->id = $event['id']; |
| 155 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 156 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
| 164 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
| 165 | + { |
|
| 166 | + if ( !is_array( $record->category ) ) |
|
| 167 | + { |
|
| 168 | + $record->category = explode( ',', $record->category ); |
|
| 169 | + } |
|
| 157 | 170 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
| 158 | 171 | } |
| 159 | 172 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 160 | 173 | } |
| 161 | - } else { |
|
| 174 | + } |
|
| 175 | + else |
|
| 176 | + { |
|
| 162 | 177 | $action = $condition['false']; |
| 163 | 178 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 164 | 179 | } |
@@ -169,9 +184,14 @@ discard block |
||
| 169 | 184 | die('condition / action not supported!!!'); |
| 170 | 185 | break; |
| 171 | 186 | } |
| 172 | - if ($action['last']) break; |
|
| 187 | + if ($action['last']) |
|
| 188 | + { |
|
| 189 | + break; |
|
| 190 | + } |
|
| 173 | 191 | } |
| 174 | - } else { |
|
| 192 | + } |
|
| 193 | + else |
|
| 194 | + { |
|
| 175 | 195 | // unconditional insert |
| 176 | 196 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 177 | 197 | } |
@@ -197,7 +217,8 @@ discard block |
||
| 197 | 217 | $missing = array(); |
| 198 | 218 | |
| 199 | 219 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
| 200 | - foreach($names as $key => $name) { |
|
| 220 | + foreach($names as $key => $name) |
|
| 221 | + { |
|
| 201 | 222 | //echo (__METHOD__ ." Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
| 202 | 223 | |
| 203 | 224 | // Search for direct account name, then user in accounts first |
@@ -205,9 +226,13 @@ discard block |
||
| 205 | 226 | $id = importexport_helper_functions::account_name2id($name); |
| 206 | 227 | |
| 207 | 228 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
| 208 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 229 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
| 230 | + { |
|
| 209 | 231 | $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
| 210 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 232 | + if($contacts) |
|
| 233 | + { |
|
| 234 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 235 | + } |
|
| 211 | 236 | } |
| 212 | 237 | if(!$id) |
| 213 | 238 | { |
@@ -215,7 +240,10 @@ discard block |
||
| 215 | 240 | foreach($this->bo->resources as $resource) |
| 216 | 241 | { |
| 217 | 242 | // Can't search for email |
| 218 | - if($resource['app'] == 'email') continue; |
|
| 243 | + if($resource['app'] == 'email') |
|
| 244 | + { |
|
| 245 | + continue; |
|
| 246 | + } |
|
| 219 | 247 | // Special resource search, since it does special stuff in link_query |
| 220 | 248 | if($resource['app'] == 'resources') |
| 221 | 249 | { |
@@ -224,7 +252,8 @@ discard block |
||
| 224 | 252 | $this->resource_so = new resources_so(); |
| 225 | 253 | } |
| 226 | 254 | $result = $this->resource_so->search($search,'res_id'); |
| 227 | - if(count($result) >= 1) { |
|
| 255 | + if(count($result) >= 1) |
|
| 256 | + { |
|
| 228 | 257 | $id = $resource['type'].$result[0]['res_id']; |
| 229 | 258 | break; |
| 230 | 259 | } |
@@ -243,7 +272,8 @@ discard block |
||
| 243 | 272 | } |
| 244 | 273 | } |
| 245 | 274 | } |
| 246 | - if($id) { |
|
| 275 | + if($id) |
|
| 276 | + { |
|
| 247 | 277 | $p_participants[$id] = calendar_so::combine_status( |
| 248 | 278 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
| 249 | 279 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -274,12 +304,14 @@ discard block |
||
| 274 | 304 | */ |
| 275 | 305 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
| 276 | 306 | { |
| 277 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 307 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
| 308 | + { |
|
| 278 | 309 | $event = $this->bo->read($record->__get($condition['string'])); |
| 279 | 310 | $records = array($event); |
| 280 | 311 | } |
| 281 | 312 | |
| 282 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 313 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 314 | + { |
|
| 283 | 315 | return true; |
| 284 | 316 | } |
| 285 | 317 | return false; |
@@ -295,7 +327,8 @@ discard block |
||
| 295 | 327 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
| 296 | 328 | { |
| 297 | 329 | $_data = $record->get_record_array(); |
| 298 | - switch ($_action) { |
|
| 330 | + switch ($_action) |
|
| 331 | + { |
|
| 299 | 332 | case 'none' : |
| 300 | 333 | return true; |
| 301 | 334 | case 'update' : |
@@ -303,7 +336,8 @@ discard block |
||
| 303 | 336 | $old = $this->bo->read($_data['id']); |
| 304 | 337 | |
| 305 | 338 | // Don't change a user account into a record |
| 306 | - if(!$this->definition->plugin_options['change_owner']) { |
|
| 339 | + if(!$this->definition->plugin_options['change_owner']) |
|
| 340 | + { |
|
| 307 | 341 | // Don't change owner of an existing record |
| 308 | 342 | unset($_data['owner']); |
| 309 | 343 | } |
@@ -313,24 +347,28 @@ discard block |
||
| 313 | 347 | { |
| 314 | 348 | $_data = array_merge($old, $_data); |
| 315 | 349 | $changed = $this->tracking->changed_fields($_data, $old); |
| 316 | - if(count($changed) == 0) { |
|
| 350 | + if(count($changed) == 0) |
|
| 351 | + { |
|
| 317 | 352 | return true; |
| 318 | 353 | } |
| 319 | 354 | } |
| 320 | 355 | // Fall through |
| 321 | 356 | case 'insert' : |
| 322 | - if($_action == 'insert') { |
|
| 357 | + if($_action == 'insert') |
|
| 358 | + { |
|
| 323 | 359 | // Backend doesn't like inserting with ID specified, can overwrite existing |
| 324 | 360 | unset($_data['id']); |
| 325 | 361 | } |
| 326 | 362 | // Make sure participants are set |
| 327 | - if(!$_data['participants']) { |
|
| 363 | + if(!$_data['participants']) |
|
| 364 | + { |
|
| 328 | 365 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
| 329 | 366 | $_data['participants'] = array( |
| 330 | 367 | $user => 'U' |
| 331 | 368 | ); |
| 332 | 369 | } |
| 333 | - if ( $this->dry_run ) { |
|
| 370 | + if ( $this->dry_run ) |
|
| 371 | + { |
|
| 334 | 372 | //print_r($_data); |
| 335 | 373 | // User is interested in conflict checks, do so for dry run |
| 336 | 374 | // Otherwise, conflicts are just ignored and imported anyway |
@@ -346,7 +384,9 @@ discard block |
||
| 346 | 384 | } |
| 347 | 385 | $this->results[$_action]++; |
| 348 | 386 | return true; |
| 349 | - } else { |
|
| 387 | + } |
|
| 388 | + else |
|
| 389 | + { |
|
| 350 | 390 | $messages = null; |
| 351 | 391 | $result = $this->bo->update( $_data, |
| 352 | 392 | !$this->definition->plugin_options['skip_conflicts'], |
@@ -398,7 +438,8 @@ discard block |
||
| 398 | 438 | * |
| 399 | 439 | * @return string name |
| 400 | 440 | */ |
| 401 | - public static function get_name() { |
|
| 441 | + public static function get_name() |
|
| 442 | + { |
|
| 402 | 443 | return lang('Calendar CSV import'); |
| 403 | 444 | } |
| 404 | 445 | |
@@ -407,7 +448,8 @@ discard block |
||
| 407 | 448 | * |
| 408 | 449 | * @return string descriprion |
| 409 | 450 | */ |
| 410 | - public static function get_description() { |
|
| 451 | + public static function get_description() |
|
| 452 | + { |
|
| 411 | 453 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators."); |
| 412 | 454 | } |
| 413 | 455 | |
@@ -416,7 +458,8 @@ discard block |
||
| 416 | 458 | * |
| 417 | 459 | * @return string suffix (comma seperated) |
| 418 | 460 | */ |
| 419 | - public static function get_filesuffix() { |
|
| 461 | + public static function get_filesuffix() |
|
| 462 | + { |
|
| 420 | 463 | return 'csv'; |
| 421 | 464 | } |
| 422 | 465 | |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | * @param int $cutoffdate =null |
| 178 | 178 | * @param array $not_uids =null uids NOT to return for meeting requests |
| 179 | 179 | * @return array |
| 180 | - */ |
|
| 180 | + */ |
|
| 181 | 181 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
| 182 | 182 | { |
| 183 | 183 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
@@ -20,8 +20,12 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
| 22 | 22 | { |
| 23 | - interface activesync_plugin_write {} |
|
| 24 | - interface activesync_plugin_meeting_requests {} |
|
| 23 | + interface activesync_plugin_write |
|
| 24 | + { |
|
| 25 | +} |
|
| 26 | + interface activesync_plugin_meeting_requests |
|
| 27 | + { |
|
| 28 | +} |
|
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | /** |
@@ -81,7 +85,10 @@ discard block |
||
| 81 | 85 | */ |
| 82 | 86 | public function GetFolderList() |
| 83 | 87 | { |
| 84 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 88 | + if (!isset($this->calendar)) |
|
| 89 | + { |
|
| 90 | + $this->calendar = new calendar_boupdate(); |
|
| 91 | + } |
|
| 85 | 92 | |
| 86 | 93 | $cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
| 87 | 94 | $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
@@ -180,13 +187,20 @@ discard block |
||
| 180 | 187 | */ |
| 181 | 188 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
| 182 | 189 | { |
| 183 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 190 | + if (!isset($this->calendar)) |
|
| 191 | + { |
|
| 192 | + $this->calendar = new calendar_boupdate(); |
|
| 193 | + } |
|
| 184 | 194 | |
| 185 | 195 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
| 186 | 196 | $type = $user = null; |
| 187 | 197 | $this->backend->splitID($id,$type,$user); |
| 188 | 198 | |
| 189 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
| 199 | + if (!$cutoffdate) |
|
| 200 | + { |
|
| 201 | + $cutoffdate = $this->bo->now - 100*24*3600; |
|
| 202 | + } |
|
| 203 | + // default three month back -30 breaks all sync recurrences |
|
| 190 | 204 | |
| 191 | 205 | $filter = array( |
| 192 | 206 | 'users' => $user, |
@@ -212,7 +226,10 @@ discard block |
||
| 212 | 226 | { |
| 213 | 227 | foreach ($events as $event) |
| 214 | 228 | { |
| 215 | - if ($not_uids && in_array($event['uid'], $not_uids)) continue; |
|
| 229 | + if ($not_uids && in_array($event['uid'], $not_uids)) |
|
| 230 | + { |
|
| 231 | + continue; |
|
| 232 | + } |
|
| 216 | 233 | $messagelist[] = $this->StatMessage($id, $event); |
| 217 | 234 | |
| 218 | 235 | // add virtual exceptions for recuring events too |
@@ -227,7 +244,10 @@ discard block |
||
| 227 | 244 | } |
| 228 | 245 | }*/ |
| 229 | 246 | } |
| 230 | - if (count($events) < $num_rows) break; |
|
| 247 | + if (count($events) < $num_rows) |
|
| 248 | + { |
|
| 249 | + break; |
|
| 250 | + } |
|
| 231 | 251 | } |
| 232 | 252 | //error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace()); |
| 233 | 253 | return $messagelist; |
@@ -289,7 +309,10 @@ discard block |
||
| 289 | 309 | { |
| 290 | 310 | unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
| 291 | 311 | |
| 292 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 312 | + if (!isset($this->calendar)) |
|
| 313 | + { |
|
| 314 | + $this->calendar = new calendar_boupdate(); |
|
| 315 | + } |
|
| 293 | 316 | |
| 294 | 317 | if (!($event = $this->calendar->read(abs($id), 0, false, 'server'))) |
| 295 | 318 | { |
@@ -367,7 +390,10 @@ discard block |
||
| 367 | 390 | 'created' => 'dtstamp', |
| 368 | 391 | ) as $key => $attr) |
| 369 | 392 | { |
| 370 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 393 | + if (!empty($event[$key])) |
|
| 394 | + { |
|
| 395 | + $message->$attr = $event[$key]; |
|
| 396 | + } |
|
| 371 | 397 | } |
| 372 | 398 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 373 | 399 | { |
@@ -379,7 +405,10 @@ discard block |
||
| 379 | 405 | 'location' => 'location', |
| 380 | 406 | ) as $key => $attr) |
| 381 | 407 | { |
| 382 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 408 | + if (!empty($event[$key])) |
|
| 409 | + { |
|
| 410 | + $message->$attr = $event[$key]; |
|
| 411 | + } |
|
| 383 | 412 | } |
| 384 | 413 | $message->organizer = $event['organizer']; |
| 385 | 414 | |
@@ -414,7 +443,10 @@ discard block |
||
| 414 | 443 | */ |
| 415 | 444 | function MeetingResponse($folderid, $requestid, $response) |
| 416 | 445 | { |
| 417 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 446 | + if (!isset($this->calendar)) |
|
| 447 | + { |
|
| 448 | + $this->calendar = new calendar_boupdate(); |
|
| 449 | + } |
|
| 418 | 450 | |
| 419 | 451 | static $as2status = array( // different from self::$status2as! |
| 420 | 452 | 1 => 'A', |
@@ -424,9 +456,12 @@ discard block |
||
| 424 | 456 | $status_in = isset($as2status[$response]) ? $as2status[$response] : 'U'; |
| 425 | 457 | $uid = $GLOBALS['egw_info']['user']['account_id']; |
| 426 | 458 | |
| 427 | - if (!is_numeric($requestid)) // iCal from fmail |
|
| 459 | + if (!is_numeric($requestid)) |
|
| 460 | + { |
|
| 461 | + // iCal from fmail |
|
| 428 | 462 | { |
| 429 | 463 | $ical = new calendar_ical(); |
| 464 | + } |
|
| 430 | 465 | if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1) |
| 431 | 466 | { |
| 432 | 467 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!"); |
@@ -536,7 +571,10 @@ discard block |
||
| 536 | 571 | { |
| 537 | 572 | unset($contentParameters); // unused, but required by function signature |
| 538 | 573 | |
| 539 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 574 | + if (!isset($this->calendar)) |
|
| 575 | + { |
|
| 576 | + $this->calendar = new calendar_boupdate(); |
|
| 577 | + } |
|
| 540 | 578 | |
| 541 | 579 | $old_event = array(); |
| 542 | 580 | $type = $account = null; |
@@ -551,10 +589,13 @@ discard block |
||
| 551 | 589 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing"); |
| 552 | 590 | return false; |
| 553 | 591 | } |
| 554 | - if ($recur_date) // virtual exception |
|
| 592 | + if ($recur_date) |
|
| 593 | + { |
|
| 594 | + // virtual exception |
|
| 555 | 595 | { |
| 556 | 596 | // @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed |
| 557 | 597 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 598 | + } |
|
| 558 | 599 | //error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 559 | 600 | } |
| 560 | 601 | if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
@@ -564,7 +605,11 @@ discard block |
||
| 564 | 605 | //error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
| 565 | 606 | return false; |
| 566 | 607 | } |
| 567 | - if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
| 608 | + if (!$id) |
|
| 609 | + { |
|
| 610 | + $old_event['owner'] = $account; |
|
| 611 | + } |
|
| 612 | + // we do NOT allow to change the owner of existing events |
|
| 568 | 613 | |
| 569 | 614 | $event = $this->message2event($message, $account, $old_event); |
| 570 | 615 | |
@@ -593,7 +638,10 @@ discard block |
||
| 593 | 638 | unset($ex_event['etag']); |
| 594 | 639 | foreach(array_keys($ex_event) as $name) |
| 595 | 640 | { |
| 596 | - if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
| 641 | + if (substr($name,0,6) == 'recur_') |
|
| 642 | + { |
|
| 643 | + unset($ex_event[$name]); |
|
| 644 | + } |
|
| 597 | 645 | } |
| 598 | 646 | $ex_event['recur_type'] = calendar_rrule::NONE; |
| 599 | 647 | |
@@ -646,7 +694,10 @@ discard block |
||
| 646 | 694 | 'end' => 'endtime', |
| 647 | 695 | ) as $key => $attr) |
| 648 | 696 | { |
| 649 | - if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 697 | + if (isset($message->$attr)) |
|
| 698 | + { |
|
| 699 | + $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 700 | + } |
|
| 650 | 701 | } |
| 651 | 702 | // copying strings |
| 652 | 703 | foreach(array( |
@@ -655,7 +706,10 @@ discard block |
||
| 655 | 706 | 'location' => 'location', |
| 656 | 707 | ) as $key => $attr) |
| 657 | 708 | { |
| 658 | - if (isset($message->$attr)) $event[$key] = $message->$attr; |
|
| 709 | + if (isset($message->$attr)) |
|
| 710 | + { |
|
| 711 | + $event[$key] = $message->$attr; |
|
| 712 | + } |
|
| 659 | 713 | } |
| 660 | 714 | |
| 661 | 715 | // only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse |
@@ -674,14 +728,22 @@ discard block |
||
| 674 | 728 | |
| 675 | 729 | if (($event['whole_day'] = $message->alldayevent)) |
| 676 | 730 | { |
| 677 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
| 731 | + if ($event['end'] == $event['start']) |
|
| 732 | + { |
|
| 733 | + $event['end'] += 24*3600; |
|
| 734 | + } |
|
| 735 | + // some clients send equal start&end for 1day |
|
| 678 | 736 | $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
| 679 | 737 | } |
| 680 | 738 | |
| 681 | 739 | $participants = array(); |
| 682 | 740 | foreach((array)$message->attendees as $attendee) |
| 683 | 741 | { |
| 684 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
| 742 | + if ($attendee->type == 3) |
|
| 743 | + { |
|
| 744 | + continue; |
|
| 745 | + } |
|
| 746 | + // we can not identify resources and re-add them anyway later |
|
| 685 | 747 | |
| 686 | 748 | $matches = null; |
| 687 | 749 | if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
@@ -696,7 +758,10 @@ discard block |
||
| 696 | 758 | //'n_fn' => $attendee->name, // not sure if we want matches without email |
| 697 | 759 | ); |
| 698 | 760 | // search addressbook for participant |
| 699 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
| 761 | + if (!isset($this->addressbook)) |
|
| 762 | + { |
|
| 763 | + $this->addressbook = new Api\Contacts(); |
|
| 764 | + } |
|
| 700 | 765 | if ((list($data) = $this->addressbook->search($search, |
| 701 | 766 | array('id','egw_addressbook.account_id as account_id','n_fn'), |
| 702 | 767 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
@@ -704,10 +769,13 @@ discard block |
||
| 704 | 769 | { |
| 705 | 770 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
| 706 | 771 | } |
| 707 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
| 772 | + elseif($attendee->name === $attendee->email || empty($attendee->name)) |
|
| 773 | + { |
|
| 774 | + // dont store empty or email as name |
|
| 708 | 775 | { |
| 709 | 776 | $uid = 'e'.$attendee->email; |
| 710 | 777 | } |
| 778 | + } |
|
| 711 | 779 | else // store just the email |
| 712 | 780 | { |
| 713 | 781 | $uid = 'e'.$attendee->name.' <'.$attendee->email.'>'; |
@@ -736,7 +804,11 @@ discard block |
||
| 736 | 804 | $role = 'REQ-PARTICIPANT'; |
| 737 | 805 | //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
| 738 | 806 | } |
| 739 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
| 807 | + if ($role == 'CHAIR') |
|
| 808 | + { |
|
| 809 | + $chair_set = true; |
|
| 810 | + } |
|
| 811 | + // by role from existing participant |
|
| 740 | 812 | |
| 741 | 813 | if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
| 742 | 814 | { |
@@ -750,10 +822,13 @@ discard block |
||
| 750 | 822 | elseif (isset($attendee->attendeetype) && |
| 751 | 823 | !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
| 752 | 824 | ($r = array_search($attendee->attendeetype,self::$role2as)) && |
| 753 | - (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 825 | + (int)self::$role2as[$role] != $attendee->attendeetype) |
|
| 826 | + { |
|
| 827 | + // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 754 | 828 | { |
| 755 | 829 | $role = $r; |
| 756 | 830 | } |
| 831 | + } |
|
| 757 | 832 | //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
| 758 | 833 | $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
| 759 | 834 | } |
@@ -768,12 +843,19 @@ discard block |
||
| 768 | 843 | // $account is also preserved, as AS does not add him as participant! |
| 769 | 844 | foreach((array)$event['participant_types'] as $type => $parts) |
| 770 | 845 | { |
| 771 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
| 846 | + if (in_array($type,array('c','e'))) |
|
| 847 | + { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 850 | + // they are correctly representable in AS |
|
| 772 | 851 | |
| 773 | 852 | foreach($parts as $id => $status) |
| 774 | 853 | { |
| 775 | 854 | // accounts are represented correctly, but the event owner which is no participant in AS |
| 776 | - if ($type == 'u' && $id != $account) continue; |
|
| 855 | + if ($type == 'u' && $id != $account) |
|
| 856 | + { |
|
| 857 | + continue; |
|
| 858 | + } |
|
| 777 | 859 | |
| 778 | 860 | $uid = calendar_so::combine_user($type, $id); |
| 779 | 861 | if (!isset($participants[$uid])) |
@@ -798,10 +880,13 @@ discard block |
||
| 798 | 880 | // check if event is recurring and import recur information (incl. timezone) |
| 799 | 881 | if ($message->recurrence) |
| 800 | 882 | { |
| 801 | - if ($message->timezone && !$event['id']) // dont care for timezone, if no new and recurring event |
|
| 883 | + if ($message->timezone && !$event['id']) |
|
| 884 | + { |
|
| 885 | + // dont care for timezone, if no new and recurring event |
|
| 802 | 886 | { |
| 803 | 887 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
| 804 | 888 | } |
| 889 | + } |
|
| 805 | 890 | $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
| 806 | 891 | array_search($message->recurrence->type, self::$recur_type2as); |
| 807 | 892 | $event['recur_interval'] = $message->recurrence->interval; |
@@ -838,10 +923,13 @@ discard block |
||
| 838 | 923 | { |
| 839 | 924 | // calculate enddate from occurences count, as we only support enddate |
| 840 | 925 | $count = $message->recurrence->occurrences; |
| 841 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
| 926 | + foreach(calendar_rrule::event2rrule($event, true) as $rtime) |
|
| 927 | + { |
|
| 928 | + // true = timestamps are user time here, because of save! |
|
| 842 | 929 | { |
| 843 | 930 | if (--$count <= 0) break; |
| 844 | 931 | } |
| 932 | + } |
|
| 845 | 933 | $event['recur_enddate'] = $rtime->format('ts'); |
| 846 | 934 | } |
| 847 | 935 | } |
@@ -856,7 +944,9 @@ discard block |
||
| 856 | 944 | break; |
| 857 | 945 | } |
| 858 | 946 | } |
| 859 | - if ($alarm !== true) // new alarm |
|
| 947 | + if ($alarm !== true) |
|
| 948 | + { |
|
| 949 | + // new alarm |
|
| 860 | 950 | { |
| 861 | 951 | // delete all earlier alarms of that user |
| 862 | 952 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
@@ -866,6 +956,7 @@ discard block |
||
| 866 | 956 | if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
| 867 | 957 | { |
| 868 | 958 | unset($event['alarm'][$key]); |
| 959 | + } |
|
| 869 | 960 | } |
| 870 | 961 | } |
| 871 | 962 | $event['alarm'][] = $alarm = array( |
@@ -946,7 +1037,10 @@ discard block |
||
| 946 | 1037 | { |
| 947 | 1038 | unset($contentParameters); // not used, but required by function signature |
| 948 | 1039 | |
| 949 | - if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
|
| 1040 | + if (!isset($this->caledar)) |
|
| 1041 | + { |
|
| 1042 | + $this->calendar = new calendar_boupdate(); |
|
| 1043 | + } |
|
| 950 | 1044 | |
| 951 | 1045 | $ret = $this->calendar->delete($id); |
| 952 | 1046 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -1008,7 +1102,10 @@ discard block |
||
| 1008 | 1102 | */ |
| 1009 | 1103 | public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment') |
| 1010 | 1104 | { |
| 1011 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1105 | + if (!isset($this->calendar)) |
|
| 1106 | + { |
|
| 1107 | + $this->calendar = new calendar_boupdate(); |
|
| 1108 | + } |
|
| 1012 | 1109 | //error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
| 1013 | 1110 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 1014 | 1111 | $mimesupport = $contentparameters->GetMimeSupport(); |
@@ -1046,7 +1143,10 @@ discard block |
||
| 1046 | 1143 | catch(Exception $e) { |
| 1047 | 1144 | unset($e); |
| 1048 | 1145 | // z-push (2.3 at least) requires a timezone for recurring events |
| 1049 | - if ($event['recur_type']) $message->timezone = self::UTC_BLOB; |
|
| 1146 | + if ($event['recur_type']) |
|
| 1147 | + { |
|
| 1148 | + $message->timezone = self::UTC_BLOB; |
|
| 1149 | + } |
|
| 1050 | 1150 | } |
| 1051 | 1151 | |
| 1052 | 1152 | // copying timestamps (they are already read in servertime, so non tz conversation) |
@@ -1057,7 +1157,10 @@ discard block |
||
| 1057 | 1157 | 'modified' => 'dtstamp', |
| 1058 | 1158 | ) as $key => $attr) |
| 1059 | 1159 | { |
| 1060 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1160 | + if (!empty($event[$key])) |
|
| 1161 | + { |
|
| 1162 | + $message->$attr = $event[$key]; |
|
| 1163 | + } |
|
| 1061 | 1164 | } |
| 1062 | 1165 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 1063 | 1166 | { |
@@ -1070,7 +1173,10 @@ discard block |
||
| 1070 | 1173 | 'location' => 'location', |
| 1071 | 1174 | ) as $key => $attr) |
| 1072 | 1175 | { |
| 1073 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1176 | + if (!empty($event[$key])) |
|
| 1177 | + { |
|
| 1178 | + $message->$attr = $event[$key]; |
|
| 1179 | + } |
|
| 1074 | 1180 | } |
| 1075 | 1181 | |
| 1076 | 1182 | // appoint description |
@@ -1103,7 +1209,10 @@ discard block |
||
| 1103 | 1209 | foreach($event['participants'] as $uid => $status) |
| 1104 | 1210 | { |
| 1105 | 1211 | // AS does NOT want calendar owner as participant |
| 1106 | - if ($uid == $account) continue; |
|
| 1212 | + if ($uid == $account) |
|
| 1213 | + { |
|
| 1214 | + continue; |
|
| 1215 | + } |
|
| 1107 | 1216 | $quantity = $role = null; |
| 1108 | 1217 | calendar_so::split_status($status, $quantity, $role); |
| 1109 | 1218 | |
@@ -1120,7 +1229,10 @@ discard block |
||
| 1120 | 1229 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
| 1121 | 1230 | ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
| 1122 | 1231 | |
| 1123 | - if (!$info) continue; |
|
| 1232 | + if (!$info) |
|
| 1233 | + { |
|
| 1234 | + continue; |
|
| 1235 | + } |
|
| 1124 | 1236 | |
| 1125 | 1237 | if (!$info['email'] && $info['responsible']) |
| 1126 | 1238 | { |
@@ -1136,10 +1248,17 @@ discard block |
||
| 1136 | 1248 | $message->organizeremail = $attendee->email; |
| 1137 | 1249 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
| 1138 | 1250 | } |
| 1139 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
| 1251 | + if ($uid[0] == 'r') |
|
| 1252 | + { |
|
| 1253 | + $attendee->type = 3; |
|
| 1254 | + } |
|
| 1255 | + // 3 = resource |
|
| 1140 | 1256 | } |
| 1141 | 1257 | // email must NOT be empty, but MAY be an arbitrary text |
| 1142 | - if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1258 | + if (empty($attendee->email)) |
|
| 1259 | + { |
|
| 1260 | + $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1261 | + } |
|
| 1143 | 1262 | |
| 1144 | 1263 | $message->attendees[] = $attendee; |
| 1145 | 1264 | } |
@@ -1174,9 +1293,12 @@ discard block |
||
| 1174 | 1293 | $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
| 1175 | 1294 | break; |
| 1176 | 1295 | } |
| 1177 | - if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1296 | + if ($rrule->enddate) |
|
| 1297 | + { |
|
| 1298 | + // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1178 | 1299 | { |
| 1179 | 1300 | $enddate = clone $rrule->time; |
| 1301 | + } |
|
| 1180 | 1302 | $enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'), |
| 1181 | 1303 | $rrule->enddate->format('d')); |
| 1182 | 1304 | $recurrence->until = $enddate->format('server'); |
@@ -1198,12 +1320,19 @@ discard block |
||
| 1198 | 1320 | { |
| 1199 | 1321 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
| 1200 | 1322 | } |
| 1201 | - if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1323 | + if (count($ex_events)>=1) |
|
| 1324 | + { |
|
| 1325 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1326 | + } |
|
| 1202 | 1327 | |
| 1203 | 1328 | $message->exceptions = array(); |
| 1204 | 1329 | foreach($ex_events as $ex_event) |
| 1205 | 1330 | { |
| 1206 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
| 1331 | + if ($ex_event['id'] == $event['id']) |
|
| 1332 | + { |
|
| 1333 | + continue; |
|
| 1334 | + } |
|
| 1335 | + // ignore series master |
|
| 1207 | 1336 | $exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException'); |
| 1208 | 1337 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
| 1209 | 1338 | foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
@@ -1223,7 +1352,10 @@ discard block |
||
| 1223 | 1352 | { |
| 1224 | 1353 | if (!empty($exception_time)) |
| 1225 | 1354 | { |
| 1226 | - if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1355 | + if (empty($event['uid'])) |
|
| 1356 | + { |
|
| 1357 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1358 | + } |
|
| 1227 | 1359 | $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
| 1228 | 1360 | $exception->deleted = 1; |
| 1229 | 1361 | $exception->exceptionstarttime = $exception_time; |
@@ -1279,12 +1411,18 @@ discard block |
||
| 1279 | 1411 | { |
| 1280 | 1412 | unset($folderid); // not used ($id is unique), but required by function signature |
| 1281 | 1413 | |
| 1282 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1414 | + if (!isset($this->calendar)) |
|
| 1415 | + { |
|
| 1416 | + $this->calendar = new calendar_boupdate(); |
|
| 1417 | + } |
|
| 1283 | 1418 | |
| 1284 | 1419 | $nul = null; |
| 1285 | - if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) // last true: $only_master=true |
|
| 1420 | + if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) |
|
| 1421 | + { |
|
| 1422 | + // last true: $only_master=true |
|
| 1286 | 1423 | { |
| 1287 | 1424 | $stat = false; |
| 1425 | + } |
|
| 1288 | 1426 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
| 1289 | 1427 | $backup = $this->calendar->debug; |
| 1290 | 1428 | //$this->calendar->debug = 2; |
@@ -1318,13 +1456,22 @@ discard block |
||
| 1318 | 1456 | $type = $owner = null; |
| 1319 | 1457 | $this->backend->splitID($folderid, $type, $owner); |
| 1320 | 1458 | |
| 1321 | - if ($type != 'calendar') return false; |
|
| 1459 | + if ($type != 'calendar') |
|
| 1460 | + { |
|
| 1461 | + return false; |
|
| 1462 | + } |
|
| 1322 | 1463 | |
| 1323 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1464 | + if (!isset($this->calendar)) |
|
| 1465 | + { |
|
| 1466 | + $this->calendar = new calendar_boupdate(); |
|
| 1467 | + } |
|
| 1324 | 1468 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
| 1325 | 1469 | $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
| 1326 | 1470 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
| 1327 | - if ($syncstate == 0) $syncstate = 1; |
|
| 1471 | + if ($syncstate == 0) |
|
| 1472 | + { |
|
| 1473 | + $syncstate = 1; |
|
| 1474 | + } |
|
| 1328 | 1475 | |
| 1329 | 1476 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'"); |
| 1330 | 1477 | } |
@@ -1400,10 +1547,16 @@ discard block |
||
| 1400 | 1547 | 'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0, |
| 1401 | 1548 | ); |
| 1402 | 1549 | |
| 1403 | - if ($tz === 'UTC') return $data; |
|
| 1550 | + if ($tz === 'UTC') |
|
| 1551 | + { |
|
| 1552 | + return $data; |
|
| 1553 | + } |
|
| 1404 | 1554 | |
| 1405 | 1555 | $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
| 1406 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
| 1556 | + if (strpos($component, 'VTIMEZONE') === false) |
|
| 1557 | + { |
|
| 1558 | + $component = calendar_timezones::tz2id($name,'component'); |
|
| 1559 | + } |
|
| 1407 | 1560 | // parse ical timezone defintion |
| 1408 | 1561 | $ical = self::ical2array($component); |
| 1409 | 1562 | $standard = $ical['VTIMEZONE']['STANDARD']; |
@@ -1446,11 +1599,17 @@ discard block |
||
| 1446 | 1599 | $data[$prefix.'week'] = 5; |
| 1447 | 1600 | } |
| 1448 | 1601 | // if both start and end use 1SU use week=5 and decrement month |
| 1449 | - if ($prefix == 'dststart') $start_byday = $matches[1]; |
|
| 1602 | + if ($prefix == 'dststart') |
|
| 1603 | + { |
|
| 1604 | + $start_byday = $matches[1]; |
|
| 1605 | + } |
|
| 1450 | 1606 | if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU') |
| 1451 | 1607 | { |
| 1452 | 1608 | $data[$prefix.'week'] = 5; |
| 1453 | - if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
|
| 1609 | + if ($prefix == 'dstend') |
|
| 1610 | + { |
|
| 1611 | + $data[$prefix.'month'] -= 1; |
|
| 1612 | + } |
|
| 1454 | 1613 | } |
| 1455 | 1614 | static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
| 1456 | 1615 | $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
@@ -1526,7 +1685,10 @@ discard block |
||
| 1526 | 1685 | static public function ical2array(&$ical,$section=null) |
| 1527 | 1686 | { |
| 1528 | 1687 | $arr = array(); |
| 1529 | - if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1688 | + if (!is_array($ical)) |
|
| 1689 | + { |
|
| 1690 | + $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1691 | + } |
|
| 1530 | 1692 | while (($line = array_shift($ical))) |
| 1531 | 1693 | { |
| 1532 | 1694 | list($name,$value) = explode(':',$line,2); |
@@ -1536,7 +1698,10 @@ discard block |
||
| 1536 | 1698 | } |
| 1537 | 1699 | elseif($name == 'END') |
| 1538 | 1700 | { |
| 1539 | - if ($section && $section==$value) return $arr; |
|
| 1701 | + if ($section && $section==$value) |
|
| 1702 | + { |
|
| 1703 | + return $arr; |
|
| 1704 | + } |
|
| 1540 | 1705 | break; |
| 1541 | 1706 | } |
| 1542 | 1707 | else |
@@ -1567,13 +1732,19 @@ discard block |
||
| 1567 | 1732 | |
| 1568 | 1733 | for($n = 0; !isset($cache[$key]); ++$n) |
| 1569 | 1734 | { |
| 1570 | - if (!$n) // check users timezone first |
|
| 1735 | + if (!$n) |
|
| 1736 | + { |
|
| 1737 | + // check users timezone first |
|
| 1571 | 1738 | { |
| 1572 | 1739 | $tz = Api\DateTime::$user_timezone->getName(); |
| 1573 | 1740 | } |
| 1574 | - elseif (!($tz = calendar_timezones::id2tz($n))) // no further timezones to check |
|
| 1741 | + } |
|
| 1742 | + elseif (!($tz = calendar_timezones::id2tz($n))) |
|
| 1743 | + { |
|
| 1744 | + // no further timezones to check |
|
| 1575 | 1745 | { |
| 1576 | 1746 | $cache[$key] = 'UTC'; |
| 1747 | + } |
|
| 1577 | 1748 | error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!'); |
| 1578 | 1749 | break; |
| 1579 | 1750 | } |
@@ -1637,7 +1808,11 @@ discard block |
||
| 1637 | 1808 | $account_id = $entry['grantor']; |
| 1638 | 1809 | $cals[$account_id] = $entry['name']; |
| 1639 | 1810 | } |
| 1640 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
| 1811 | + if ($hook_data['account_id'] > 0) |
|
| 1812 | + { |
|
| 1813 | + unset($cals[$hook_data['account_id']]); |
|
| 1814 | + } |
|
| 1815 | + // skip current user |
|
| 1641 | 1816 | } |
| 1642 | 1817 | $cals['G'] = lang('Primary group'); |
| 1643 | 1818 | $cals['A'] = lang('All'); |
@@ -1665,13 +1840,16 @@ discard block |
||
| 1665 | 1840 | * |
| 1666 | 1841 | * You need to comment implements activesync_plugin_write |
| 1667 | 1842 | */ |
| 1668 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
| 1843 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
| 1844 | +{ |
|
| 1845 | + // some tests |
|
| 1669 | 1846 | { |
| 1670 | 1847 | $GLOBALS['egw_info'] = array( |
| 1671 | 1848 | 'flags' => array( |
| 1672 | 1849 | 'currentapp' => 'login' |
| 1673 | 1850 | ) |
| 1674 | 1851 | ); |
| 1852 | +} |
|
| 1675 | 1853 | require_once('../../header.inc.php'); |
| 1676 | 1854 | ini_set('display_errors',1); |
| 1677 | 1855 | error_reporting(E_ALL & ~E_NOTICE); |
@@ -387,11 +387,11 @@ |
||
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | - * gets the icons displayed for a given event |
|
| 391 | - * |
|
| 392 | - * @param array $event |
|
| 393 | - * @return array of 'img' / 'title' pairs |
|
| 394 | - */ |
|
| 390 | + * gets the icons displayed for a given event |
|
| 391 | + * |
|
| 392 | + * @param array $event |
|
| 393 | + * @return array of 'img' / 'title' pairs |
|
| 394 | + */ |
|
| 395 | 395 | function event_icons($event) |
| 396 | 396 | { |
| 397 | 397 | $is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event); |
@@ -166,7 +166,10 @@ discard block |
||
| 166 | 166 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 167 | 167 | |
| 168 | 168 | // make sure the hook for export_limit is registered |
| 169 | - if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true); |
|
| 169 | + if (!Api\Hooks::exists('export_limit','calendar')) |
|
| 170 | + { |
|
| 171 | + Api\Hooks::read(true); |
|
| 172 | + } |
|
| 170 | 173 | } |
| 171 | 174 | |
| 172 | 175 | /** |
@@ -279,11 +282,15 @@ discard block |
||
| 279 | 282 | { |
| 280 | 283 | // only change the owners of the same resource-type as given in set_state[owner] |
| 281 | 284 | $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']); |
| 282 | - if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) |
|
| 285 | + if ((string)$set_owners[0] === '0') |
|
| 286 | + { |
|
| 287 | + // set exactly the specified owners (without the 0) |
|
| 283 | 288 | { |
| 284 | 289 | if ($set_states['owner'] === '0,r0') // small fix for resources |
| 285 | 290 | { |
| 286 | - $set_states['owner'] = $default; // --> set default, instead of none |
|
| 291 | + $set_states['owner'] = $default; |
|
| 292 | + } |
|
| 293 | + // --> set default, instead of none |
|
| 287 | 294 | } |
| 288 | 295 | else |
| 289 | 296 | { |
@@ -369,7 +376,10 @@ discard block |
||
| 369 | 376 | } |
| 370 | 377 | $this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index'; |
| 371 | 378 | |
| 372 | - if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 379 | + if ($this->debug > 0 || $this->debug == 'manage_states') |
|
| 380 | + { |
|
| 381 | + $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 382 | + } |
|
| 373 | 383 | // save the states in the session only when we are in calendar |
| 374 | 384 | if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar') |
| 375 | 385 | { |
@@ -505,8 +515,11 @@ discard block |
||
| 505 | 515 | |
| 506 | 516 | // resources menu hooks |
| 507 | 517 | foreach ($this->bo->resources as $resource) |
| 508 | - { |
|
| 509 | - if(!is_array($resource['cal_sidebox'])) continue; |
|
| 518 | + { |
|
| 519 | + if(!is_array($resource['cal_sidebox'])) |
|
| 520 | + { |
|
| 521 | + continue; |
|
| 522 | + } |
|
| 510 | 523 | $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']); |
| 511 | 524 | $file = ExecMethod($resource['cal_sidebox']['file'],array( |
| 512 | 525 | 'menuaction' => $this->view_menuaction, |
@@ -560,7 +573,10 @@ discard block |
||
| 560 | 573 | $sidebox = new Etemplate('calendar.sidebox'); |
| 561 | 574 | |
| 562 | 575 | $cont = $this->cal_prefs['saved_states']; |
| 563 | - if (!is_array($cont)) $cont = array(); |
|
| 576 | + if (!is_array($cont)) |
|
| 577 | + { |
|
| 578 | + $cont = array(); |
|
| 579 | + } |
|
| 564 | 580 | $cont['view'] = $this->view ? $this->view : 'week'; |
| 565 | 581 | $cont['date'] = $this->date ? $this->date : new Api\DateTime(); |
| 566 | 582 | $cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner']; |
@@ -593,8 +609,7 @@ discard block |
||
| 593 | 609 | if (class_exists('EGroupware\\collabora\\Bo') && |
| 594 | 610 | $GLOBALS['egw_info']['user']['apps']['collabora'] && |
| 595 | 611 | $discovery = \EGroupware\collabora\Bo::discover() |
| 596 | - ) |
|
| 597 | - { |
|
| 612 | + ) { |
|
| 598 | 613 | $cont['collabora_enabled'] = true; |
| 599 | 614 | } |
| 600 | 615 | } |
@@ -635,7 +650,10 @@ discard block |
||
| 635 | 650 | */ |
| 636 | 651 | public function update_client($event_id, Api\DateTime $recurrence_date = null) |
| 637 | 652 | { |
| 638 | - if(!$event_id) return false; |
|
| 653 | + if(!$event_id) |
|
| 654 | + { |
|
| 655 | + return false; |
|
| 656 | + } |
|
| 639 | 657 | if(is_string($event_id) && strpos($event_id,':') !== FALSE) |
| 640 | 658 | { |
| 641 | 659 | list($event_id, $date) = explode(':',$event_id); |
@@ -706,7 +724,10 @@ discard block |
||
| 706 | 724 | */ |
| 707 | 725 | public function to_client(&$event) |
| 708 | 726 | { |
| 709 | - if(!$event || !is_array($event)) return false; |
|
| 727 | + if(!$event || !is_array($event)) |
|
| 728 | + { |
|
| 729 | + return false; |
|
| 730 | + } |
|
| 710 | 731 | |
| 711 | 732 | if (!$this->bo->check_perms(Acl::EDIT,$event)) |
| 712 | 733 | { |
@@ -727,8 +748,16 @@ discard block |
||
| 727 | 748 | |
| 728 | 749 | $event['recure'] = $this->bo->recure2string($event); |
| 729 | 750 | |
| 730 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
| 731 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
| 751 | + if (empty($event['description'])) |
|
| 752 | + { |
|
| 753 | + $event['description'] = ' '; |
|
| 754 | + } |
|
| 755 | + // no description screws the titles horz. alignment |
|
| 756 | + if (empty($event['location'])) |
|
| 757 | + { |
|
| 758 | + $event['location'] = ' '; |
|
| 759 | + } |
|
| 760 | + // no location screws the owner horz. alignment |
|
| 732 | 761 | |
| 733 | 762 | // respect category permissions |
| 734 | 763 | if(!empty($event['category'])) |
@@ -817,8 +846,14 @@ discard block |
||
| 817 | 846 | if(!$timespan) |
| 818 | 847 | { |
| 819 | 848 | // Try to make time span into appropriate ranges to match |
| 820 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
| 821 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
| 849 | + if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) |
|
| 850 | + { |
|
| 851 | + $template = 'month'; |
|
| 852 | + } |
|
| 853 | + if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) |
|
| 854 | + { |
|
| 855 | + $template = 'week'; |
|
| 856 | + } |
|
| 822 | 857 | //error_log("Detected template $template"); |
| 823 | 858 | switch ($template) |
| 824 | 859 | { |
@@ -899,8 +934,7 @@ discard block |
||
| 899 | 934 | if (class_exists('EGroupware\\collabora\\Bo') && |
| 900 | 935 | $GLOBALS['egw_info']['user']['apps']['collabora'] && |
| 901 | 936 | $discovery = \EGroupware\collabora\Bo::discover() |
| 902 | - ) |
|
| 903 | - { |
|
| 937 | + ) { |
|
| 904 | 938 | $editable_mimes = $discovery; |
| 905 | 939 | } |
| 906 | 940 | } |
@@ -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'; |
@@ -120,11 +120,14 @@ discard block |
||
| 120 | 120 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 121 | 121 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 122 | 122 | { |
| 123 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 123 | + if ($owner) |
|
| 124 | + { |
|
| 125 | + // make an owner who is no user or we have no add-rights a participant |
|
| 124 | 126 | { |
| 125 | 127 | if(!is_array($owner)) |
| 126 | 128 | { |
| 127 | 129 | $owner = explode(',',$owner); |
| 130 | + } |
|
| 128 | 131 | } |
| 129 | 132 | // if we come from ressources we don't need any users selected in calendar |
| 130 | 133 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -156,9 +159,17 @@ discard block |
||
| 156 | 159 | $participant_types['u'] = $participant_types = $participants = array(); |
| 157 | 160 | foreach($extra_participants as $uid) |
| 158 | 161 | { |
| 159 | - if (isset($participants[$uid])) continue; // already included |
|
| 162 | + if (isset($participants[$uid])) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 166 | + // already included |
|
| 160 | 167 | |
| 161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 168 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 169 | + { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 172 | + // no right to invite --> ignored |
|
| 162 | 173 | |
| 163 | 174 | if (is_numeric($uid)) |
| 164 | 175 | { |
@@ -196,10 +207,13 @@ discard block |
||
| 196 | 207 | } |
| 197 | 208 | } |
| 198 | 209 | } |
| 199 | - if (!$participants) // if all participants got removed, include current user |
|
| 210 | + if (!$participants) |
|
| 211 | + { |
|
| 212 | + // if all participants got removed, include current user |
|
| 200 | 213 | { |
| 201 | 214 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 202 | 215 | } |
| 216 | + } |
|
| 203 | 217 | if(isset($_GET['cat_id'])) |
| 204 | 218 | { |
| 205 | 219 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -261,10 +275,13 @@ discard block |
||
| 261 | 275 | */ |
| 262 | 276 | function process_edit($content) |
| 263 | 277 | { |
| 264 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 278 | + if (!is_array($content)) |
|
| 279 | + { |
|
| 280 | + // redirect from etemplate, if POST empty |
|
| 265 | 281 | { |
| 266 | 282 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 267 | 283 | } |
| 284 | + } |
|
| 268 | 285 | // clear notification errors |
| 269 | 286 | notifications::errors(true); |
| 270 | 287 | $messages = null; |
@@ -277,7 +294,11 @@ discard block |
||
| 277 | 294 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 278 | 295 | |
| 279 | 296 | list($button) = @each($content['button']); |
| 280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 297 | + if (!$button && $content['action']) |
|
| 298 | + { |
|
| 299 | + $button = $content['action']; |
|
| 300 | + } |
|
| 301 | + // action selectbox |
|
| 281 | 302 | unset($content['button']); unset($content['action']); |
| 282 | 303 | |
| 283 | 304 | $view = $content['view']; |
@@ -290,7 +311,10 @@ discard block |
||
| 290 | 311 | { |
| 291 | 312 | list($date) = each($content['recur_exception']['delete_exception']); |
| 292 | 313 | // eT2 converts time to |
| 293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 314 | + if (!is_numeric($date)) |
|
| 315 | + { |
|
| 316 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 317 | + } |
|
| 294 | 318 | unset($content['recur_exception']['delete_exception']); |
| 295 | 319 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 296 | 320 | { |
@@ -299,7 +323,10 @@ discard block |
||
| 299 | 323 | foreach ($recur_exceptions as $id) |
| 300 | 324 | { |
| 301 | 325 | if (!($exception = $this->bo->read($id)) || |
| 302 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 326 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 327 | + { |
|
| 328 | + continue; |
|
| 329 | + } |
|
| 303 | 330 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 304 | 331 | $exception['reference'] = $exception['recurrence'] = 0; |
| 305 | 332 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -357,8 +384,7 @@ discard block |
||
| 357 | 384 | // Existing event, check for change from/to whole day |
| 358 | 385 | ($old = $this->bo->read($content['cal_id'])) && $old['whole_day'] !== $content['whole_day'] && |
| 359 | 386 | ($def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]) |
| 360 | - ) |
|
| 361 | - { |
|
| 387 | + ) { |
|
| 362 | 388 | // Reset default alarm |
| 363 | 389 | $old_default = array_shift($content['alarm']); |
| 364 | 390 | $this->bo->delete_alarm($old_default['id']); |
@@ -395,7 +421,10 @@ discard block |
||
| 395 | 421 | $event['end'] = $this->bo->date2ts($event['end']); |
| 396 | 422 | } |
| 397 | 423 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 398 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 424 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 425 | + { |
|
| 426 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 427 | + } |
|
| 399 | 428 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 400 | 429 | { |
| 401 | 430 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -522,7 +551,11 @@ discard block |
||
| 522 | 551 | break; |
| 523 | 552 | |
| 524 | 553 | default: // existing participant row |
| 525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 554 | + if (!is_array($data)) |
|
| 555 | + { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 558 | + // widgets in participant tab, above participant list |
|
| 526 | 559 | $quantity = $status = $role = null; |
| 527 | 560 | foreach(array('uid','status','quantity','role') as $name) |
| 528 | 561 | { |
@@ -655,7 +688,10 @@ discard block |
||
| 655 | 688 | { |
| 656 | 689 | foreach($participants as $id => &$p_response) |
| 657 | 690 | { |
| 658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 691 | + if($type == 'u' && $id == $event['owner']) |
|
| 692 | + { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 659 | 695 | calendar_so::split_status($p_response, $quantity, $role); |
| 660 | 696 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 661 | 697 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -737,17 +773,23 @@ discard block |
||
| 737 | 773 | { |
| 738 | 774 | foreach (array_keys($event['participants']) as $uid) |
| 739 | 775 | { |
| 740 | - if ($uid[0] == 'r') //ressource detection |
|
| 776 | + if ($uid[0] == 'r') |
|
| 777 | + { |
|
| 778 | + //ressource detection |
|
| 741 | 779 | { |
| 742 | 780 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 781 | + } |
|
| 743 | 782 | $button = ''; |
| 744 | 783 | break 2; //break foreach and case |
| 745 | 784 | } |
| 746 | 785 | } |
| 747 | 786 | } |
| 748 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 787 | + if ($content['edit_single']) |
|
| 788 | + { |
|
| 789 | + // we edited a single event from a series |
|
| 749 | 790 | { |
| 750 | 791 | $event['reference'] = $event['id']; |
| 792 | + } |
|
| 751 | 793 | $event['recurrence'] = $content['edit_single']; |
| 752 | 794 | unset($event['id']); |
| 753 | 795 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -849,7 +891,10 @@ discard block |
||
| 849 | 891 | case 'no': |
| 850 | 892 | break; |
| 851 | 893 | case 'startday': |
| 852 | - if ($sameday) break; |
|
| 894 | + if ($sameday) |
|
| 895 | + { |
|
| 896 | + break; |
|
| 897 | + } |
|
| 853 | 898 | default: |
| 854 | 899 | $status_reset_to_unknown = true; |
| 855 | 900 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -1017,7 +1062,10 @@ discard block |
||
| 1017 | 1062 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 1018 | 1063 | { |
| 1019 | 1064 | $msg = lang('Series deleted'); |
| 1020 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 1065 | + if ($exceptions_kept) |
|
| 1066 | + { |
|
| 1067 | + $msg .= lang(', exceptions preserved'); |
|
| 1068 | + } |
|
| 1021 | 1069 | } |
| 1022 | 1070 | else |
| 1023 | 1071 | { |
@@ -1053,11 +1101,14 @@ discard block |
||
| 1053 | 1101 | { |
| 1054 | 1102 | $msg = lang("Can't add alarms in the past !!!"); |
| 1055 | 1103 | } |
| 1056 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1104 | + elseif ($event['id']) |
|
| 1105 | + { |
|
| 1106 | + // save the alarm immediatly |
|
| 1057 | 1107 | { |
| 1058 | 1108 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 1059 | 1109 | { |
| 1060 | 1110 | $alarm['id'] = $alarm_id; |
| 1111 | + } |
|
| 1061 | 1112 | $event['alarm'][$alarm_id] = $alarm; |
| 1062 | 1113 | |
| 1063 | 1114 | $msg = lang('Alarm added'); |
@@ -1070,7 +1121,9 @@ discard block |
||
| 1070 | 1121 | } |
| 1071 | 1122 | else |
| 1072 | 1123 | { |
| 1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1124 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1125 | + { |
|
| 1126 | +} // get a temporary non-conflicting, numeric id |
|
| 1074 | 1127 | $event['alarm'][$alarm['id']] = $alarm; |
| 1075 | 1128 | } |
| 1076 | 1129 | } |
@@ -1093,10 +1146,13 @@ discard block |
||
| 1093 | 1146 | } |
| 1094 | 1147 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1095 | 1148 | { |
| 1096 | - if ($content['lock_token']) // remove an existing lock |
|
| 1149 | + if ($content['lock_token']) |
|
| 1150 | + { |
|
| 1151 | + // remove an existing lock |
|
| 1097 | 1152 | { |
| 1098 | 1153 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1099 | 1154 | } |
| 1155 | + } |
|
| 1100 | 1156 | if ($content['no_popup']) |
| 1101 | 1157 | { |
| 1102 | 1158 | Egw::redirect_link('/index.php',array( |
@@ -1154,13 +1210,19 @@ discard block |
||
| 1154 | 1210 | } |
| 1155 | 1211 | |
| 1156 | 1212 | // Copy links |
| 1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1213 | + if(!is_array($event['link_to'])) |
|
| 1214 | + { |
|
| 1215 | + $event['link_to'] = array(); |
|
| 1216 | + } |
|
| 1158 | 1217 | $event['link_to']['to_app'] = 'calendar'; |
| 1159 | 1218 | $event['link_to']['to_id'] = 0; |
| 1160 | 1219 | |
| 1161 | 1220 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
| 1162 | 1221 | { |
| 1163 | - if(!$link['id']) continue; |
|
| 1222 | + if(!$link['id']) |
|
| 1223 | + { |
|
| 1224 | + continue; |
|
| 1225 | + } |
|
| 1164 | 1226 | if ($link['app'] != Link::VFS_APPNAME) |
| 1165 | 1227 | { |
| 1166 | 1228 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1228,8 +1290,7 @@ discard block |
||
| 1228 | 1290 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1229 | 1291 | // Adjust for requested date in the past |
| 1230 | 1292 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1231 | - ) |
|
| 1232 | - { |
|
| 1293 | + ) { |
|
| 1233 | 1294 | |
| 1234 | 1295 | unset($orig_event); |
| 1235 | 1296 | // copy event by unsetting the id(s) |
@@ -1317,7 +1378,10 @@ discard block |
||
| 1317 | 1378 | foreach($event['participants'] as $uid => $status) |
| 1318 | 1379 | { |
| 1319 | 1380 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1320 | - if (empty($status)) continue; |
|
| 1381 | + if (empty($status)) |
|
| 1382 | + { |
|
| 1383 | + continue; |
|
| 1384 | + } |
|
| 1321 | 1385 | if(!is_array($status)) |
| 1322 | 1386 | { |
| 1323 | 1387 | $quantity = $role = null; |
@@ -1328,28 +1392,43 @@ discard block |
||
| 1328 | 1392 | ); |
| 1329 | 1393 | } |
| 1330 | 1394 | $toadd = ''; |
| 1331 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1395 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1396 | + { |
|
| 1397 | + continue; |
|
| 1398 | + } |
|
| 1332 | 1399 | |
| 1333 | 1400 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1334 | 1401 | { |
| 1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1402 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1403 | + { |
|
| 1404 | + continue; |
|
| 1405 | + } |
|
| 1336 | 1406 | |
| 1337 | 1407 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1338 | 1408 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1339 | 1409 | |
| 1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1410 | + if (!in_array($toadd,$to)) |
|
| 1411 | + { |
|
| 1412 | + $to[] = $toadd; |
|
| 1413 | + } |
|
| 1341 | 1414 | } |
| 1342 | 1415 | elseif ($uid < 0) |
| 1343 | 1416 | { |
| 1344 | 1417 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1345 | 1418 | { |
| 1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1419 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1420 | + { |
|
| 1421 | + continue; |
|
| 1422 | + } |
|
| 1347 | 1423 | |
| 1348 | 1424 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1349 | 1425 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1350 | 1426 | |
| 1351 | 1427 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1428 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1429 | + { |
|
| 1430 | + $to[] = $toadd; |
|
| 1431 | + } |
|
| 1353 | 1432 | } |
| 1354 | 1433 | } |
| 1355 | 1434 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1401,7 +1480,10 @@ discard block |
||
| 1401 | 1480 | 'preset[size]' => filesize($ics_file), |
| 1402 | 1481 | ); |
| 1403 | 1482 | $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
| 1404 | - 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.'); |
|
| 1483 | + if ($asrequest) |
|
| 1484 | + { |
|
| 1485 | + $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.'); |
|
| 1486 | + } |
|
| 1405 | 1487 | $response = Api\Json\Response::get(); |
| 1406 | 1488 | $response->call('app.calendar.custom_mail', $vars); |
| 1407 | 1489 | } |
@@ -1587,9 +1669,15 @@ discard block |
||
| 1587 | 1669 | } |
| 1588 | 1670 | } |
| 1589 | 1671 | // set new start and end if given by $_GET |
| 1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1672 | + if(isset($_GET['start'])) |
|
| 1673 | + { |
|
| 1674 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1675 | + if(isset($_GET['end'])) |
|
| 1676 | + { |
|
| 1677 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1678 | + if(isset($_GET['non_blocking'])) |
|
| 1679 | + { |
|
| 1680 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1593 | 1681 | // check if the event is the whole day |
| 1594 | 1682 | $start = $this->bo->date2array($event['start']); |
| 1595 | 1683 | $end = $this->bo->date2array($event['end']); |
@@ -1602,10 +1690,13 @@ discard block |
||
| 1602 | 1690 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1603 | 1691 | { |
| 1604 | 1692 | $link_id = $link_ids[$n]; |
| 1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1693 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1694 | + { |
|
| 1695 | + // guard against XSS |
|
| 1606 | 1696 | { |
| 1607 | 1697 | continue; |
| 1608 | 1698 | } |
| 1699 | + } |
|
| 1609 | 1700 | if(!$n) |
| 1610 | 1701 | { |
| 1611 | 1702 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1614,7 +1705,10 @@ discard block |
||
| 1614 | 1705 | { |
| 1615 | 1706 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1616 | 1707 | { |
| 1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1708 | + if (($l_id=$set['link_id'][$i])) |
|
| 1709 | + { |
|
| 1710 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1711 | + } |
|
| 1618 | 1712 | } |
| 1619 | 1713 | unset($set['link_app']); |
| 1620 | 1714 | unset($set['link_id']); |
@@ -1640,10 +1734,13 @@ discard block |
||
| 1640 | 1734 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1641 | 1735 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1642 | 1736 | |
| 1643 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1737 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1738 | + { |
|
| 1739 | + // already locked --> refresh the lock |
|
| 1644 | 1740 | { |
| 1645 | 1741 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1646 | 1742 | } |
| 1743 | + } |
|
| 1647 | 1744 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1648 | 1745 | { |
| 1649 | 1746 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1677,14 +1774,20 @@ discard block |
||
| 1677 | 1774 | )); |
| 1678 | 1775 | Framework::message($msg, $msg_type); |
| 1679 | 1776 | $content['duration'] = $content['end'] - $content['start']; |
| 1680 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1777 | + if (isset($this->durations[$content['duration']])) |
|
| 1778 | + { |
|
| 1779 | + $content['end'] = ''; |
|
| 1780 | + } |
|
| 1681 | 1781 | |
| 1682 | 1782 | $row = 3; |
| 1683 | 1783 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1684 | 1784 | // preserve some ui elements, if set eg. under error-conditions |
| 1685 | 1785 | foreach(array('quantity','resource','role') as $n) |
| 1686 | 1786 | { |
| 1687 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1787 | + if (isset($event['participants'][$n])) |
|
| 1788 | + { |
|
| 1789 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1790 | + } |
|
| 1688 | 1791 | } |
| 1689 | 1792 | foreach($event['participant_types'] as $type => $participants) |
| 1690 | 1793 | { |
@@ -1726,9 +1829,13 @@ discard block |
||
| 1726 | 1829 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1727 | 1830 | |
| 1728 | 1831 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1729 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1832 | + { |
|
| 1833 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1834 | + } |
|
| 1730 | 1835 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1731 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1836 | + { |
|
| 1837 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1838 | + } |
|
| 1732 | 1839 | // todo: make the participants available as links with email as title |
| 1733 | 1840 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1734 | 1841 | // enumerate group-invitations, so people can accept/reject them |
@@ -1759,7 +1866,11 @@ discard block |
||
| 1759 | 1866 | $content['participants']['cal_resources'] = ''; |
| 1760 | 1867 | foreach($this->bo->resources as $data) |
| 1761 | 1868 | { |
| 1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1869 | + if ($data['app'] == 'email') |
|
| 1870 | + { |
|
| 1871 | + continue; |
|
| 1872 | + } |
|
| 1873 | + // make no sense, as we cant search for email |
|
| 1763 | 1874 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1764 | 1875 | } |
| 1765 | 1876 | } |
@@ -1789,9 +1900,18 @@ discard block |
||
| 1789 | 1900 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1790 | 1901 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1791 | 1902 | $label = array(); |
| 1792 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1793 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1794 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1903 | + if ($days) |
|
| 1904 | + { |
|
| 1905 | + $label[] = $days.' '.lang('days'); |
|
| 1906 | + } |
|
| 1907 | + if ($hours) |
|
| 1908 | + { |
|
| 1909 | + $label[] = $hours.' '.lang('hours'); |
|
| 1910 | + } |
|
| 1911 | + if ($minutes) |
|
| 1912 | + { |
|
| 1913 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1914 | + } |
|
| 1795 | 1915 | if (!$label) |
| 1796 | 1916 | { |
| 1797 | 1917 | $alarm['offset'] = lang('at start of the event'); |
@@ -1861,25 +1981,34 @@ discard block |
||
| 1861 | 1981 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1862 | 1982 | 'history' => !$event['id'], |
| 1863 | 1983 | ); |
| 1864 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1984 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1985 | + { |
|
| 1986 | + // no mail without mail-app |
|
| 1865 | 1987 | { |
| 1866 | 1988 | unset($sel_options['action']['mail']); |
| 1989 | + } |
|
| 1867 | 1990 | unset($sel_options['action']['sendmeetingrequest']); |
| 1868 | 1991 | } |
| 1869 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1992 | + if (!$event['id']) |
|
| 1993 | + { |
|
| 1994 | + // no ical export for new (not saved) events |
|
| 1870 | 1995 | { |
| 1871 | 1996 | $readonlys['action'] = true; |
| 1872 | 1997 | } |
| 1998 | + } |
|
| 1873 | 1999 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
| 1874 | 2000 | { |
| 1875 | 2001 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1876 | 2002 | } |
| 1877 | 2003 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1878 | 2004 | |
| 1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 2005 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 2006 | + { |
|
| 2007 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1880 | 2008 | { |
| 1881 | 2009 | $sel_options['owner'][0] = lang('All participants'); |
| 1882 | 2010 | } |
| 2011 | + } |
|
| 1883 | 2012 | if (isset($event['participant_types']['u'][$this->user])) |
| 1884 | 2013 | { |
| 1885 | 2014 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1922,7 +2051,10 @@ discard block |
||
| 1922 | 2051 | |
| 1923 | 2052 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1924 | 2053 | |
| 1925 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 2054 | + if (!empty($preserved['lock_token'])) |
|
| 2055 | + { |
|
| 2056 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 2057 | + } |
|
| 1926 | 2058 | |
| 1927 | 2059 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1928 | 2060 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2078,7 +2210,10 @@ discard block |
||
| 2078 | 2210 | { |
| 2079 | 2211 | $quantity = $role = null; |
| 2080 | 2212 | calendar_so::split_status($status, $quantity, $role); |
| 2081 | - if (!is_numeric($uid) && $role == 'CHAIR') break; |
|
| 2213 | + if (!is_numeric($uid) && $role == 'CHAIR') |
|
| 2214 | + { |
|
| 2215 | + break; |
|
| 2216 | + } |
|
| 2082 | 2217 | } |
| 2083 | 2218 | if (!(!is_numeric($uid) && $role == 'CHAIR')) |
| 2084 | 2219 | { |
@@ -2294,13 +2429,16 @@ discard block |
||
| 2294 | 2429 | |
| 2295 | 2430 | foreach (array_keys($allConflicts) as $pId) |
| 2296 | 2431 | { |
| 2297 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2432 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2433 | + { |
|
| 2434 | + // resources Allow ignore conflicts |
|
| 2298 | 2435 | { |
| 2299 | 2436 | |
| 2300 | 2437 | switch ($resources_config['ignoreconflicts']) |
| 2301 | 2438 | { |
| 2302 | 2439 | case 'no': |
| 2303 | 2440 | $readonlys['button[ignore]'] = true; |
| 2441 | + } |
|
| 2304 | 2442 | break; |
| 2305 | 2443 | case 'allusers': |
| 2306 | 2444 | $readonlys['button[ignore]'] = false; |
@@ -2444,7 +2582,10 @@ discard block |
||
| 2444 | 2582 | } |
| 2445 | 2583 | else |
| 2446 | 2584 | { |
| 2447 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2585 | + if (!$content['duration']) |
|
| 2586 | + { |
|
| 2587 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2588 | + } |
|
| 2448 | 2589 | $weekds = 0; |
| 2449 | 2590 | foreach ($content['weekdays'] as &$wdays) |
| 2450 | 2591 | { |
@@ -2466,7 +2607,10 @@ discard block |
||
| 2466 | 2607 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2467 | 2608 | |
| 2468 | 2609 | $sel_options['duration'] = $this->durations; |
| 2469 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2610 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2611 | + { |
|
| 2612 | + $content['end'] = ''; |
|
| 2613 | + } |
|
| 2470 | 2614 | |
| 2471 | 2615 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2472 | 2616 | 'participants' => $content['participants'], |
@@ -2487,7 +2631,10 @@ discard block |
||
| 2487 | 2631 | */ |
| 2488 | 2632 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2489 | 2633 | { |
| 2490 | - 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); |
|
| 2634 | + if ($this->debug > 2) |
|
| 2635 | + { |
|
| 2636 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2637 | + } |
|
| 2491 | 2638 | |
| 2492 | 2639 | $busy = $this->bo->search(array( |
| 2493 | 2640 | 'start' => $start, |
@@ -2504,9 +2651,17 @@ discard block |
||
| 2504 | 2651 | $n = 0; |
| 2505 | 2652 | foreach($busy as $event) |
| 2506 | 2653 | { |
| 2507 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2654 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2655 | + { |
|
| 2656 | + continue; |
|
| 2657 | + } |
|
| 2658 | + // ignore our own event |
|
| 2508 | 2659 | |
| 2509 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2660 | + if ($event['non_blocking']) |
|
| 2661 | + { |
|
| 2662 | + continue; |
|
| 2663 | + } |
|
| 2664 | + // ignore non_blocking events |
|
| 2510 | 2665 | |
| 2511 | 2666 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2512 | 2667 | $non_rejected_found = false; |
@@ -2515,7 +2670,10 @@ discard block |
||
| 2515 | 2670 | $status = $event['participants'][$uid]; |
| 2516 | 2671 | $quantity = $role = null; |
| 2517 | 2672 | calendar_so::split_status($status, $quantity, $role); |
| 2518 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
| 2673 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 2674 | + { |
|
| 2675 | + continue; |
|
| 2676 | + } |
|
| 2519 | 2677 | |
| 2520 | 2678 | if (isset($event['participants'][$uid]) || |
| 2521 | 2679 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2525,7 +2683,10 @@ discard block |
||
| 2525 | 2683 | break; |
| 2526 | 2684 | } |
| 2527 | 2685 | } |
| 2528 | - if (!$non_rejected_found) continue; |
|
| 2686 | + if (!$non_rejected_found) |
|
| 2687 | + { |
|
| 2688 | + continue; |
|
| 2689 | + } |
|
| 2529 | 2690 | |
| 2530 | 2691 | if ($this->debug) |
| 2531 | 2692 | { |
@@ -2556,11 +2717,17 @@ discard block |
||
| 2556 | 2717 | 'start' => $ft_start, |
| 2557 | 2718 | 'end' => $ft_end, |
| 2558 | 2719 | ); |
| 2559 | - 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"; |
|
| 2720 | + if ($this->debug > 1) |
|
| 2721 | + { |
|
| 2722 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2723 | + } |
|
| 2560 | 2724 | } |
| 2561 | 2725 | $ft_start = $event['end']; |
| 2562 | 2726 | } |
| 2563 | - 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); |
|
| 2727 | + if ($this->debug > 0) |
|
| 2728 | + { |
|
| 2729 | + $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); |
|
| 2730 | + } |
|
| 2564 | 2731 | |
| 2565 | 2732 | return $freetime; |
| 2566 | 2733 | } |
@@ -2580,10 +2747,16 @@ discard block |
||
| 2580 | 2747 | */ |
| 2581 | 2748 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2582 | 2749 | { |
| 2583 | - 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); |
|
| 2750 | + if ($this->debug > 1) |
|
| 2751 | + { |
|
| 2752 | + $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); |
|
| 2753 | + } |
|
| 2584 | 2754 | |
| 2585 | 2755 | $freetime_daywise = array(); |
| 2586 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2756 | + if (!is_array($sel_options)) |
|
| 2757 | + { |
|
| 2758 | + $sel_options = array(); |
|
| 2759 | + } |
|
| 2587 | 2760 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2588 | 2761 | |
| 2589 | 2762 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2593,7 +2766,10 @@ discard block |
||
| 2593 | 2766 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2594 | 2767 | { |
| 2595 | 2768 | $end_time = 0; |
| 2596 | - 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); |
|
| 2769 | + if ($this->debug > 1) |
|
| 2770 | + { |
|
| 2771 | + $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); |
|
| 2772 | + } |
|
| 2597 | 2773 | } |
| 2598 | 2774 | $n = 0; |
| 2599 | 2775 | foreach($freetime as $ft) |
@@ -2614,13 +2790,19 @@ discard block |
||
| 2614 | 2790 | } |
| 2615 | 2791 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2616 | 2792 | |
| 2617 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2793 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2794 | + { |
|
| 2795 | + // start earlier then start_time |
|
| 2618 | 2796 | { |
| 2619 | 2797 | $start = $daybegin + $start_time*HOUR_s; |
| 2620 | 2798 | } |
| 2799 | + } |
|
| 2621 | 2800 | // if end_time given use it, else the original slot's end |
| 2622 | 2801 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2623 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2802 | + if ($end > $ft['end']) |
|
| 2803 | + { |
|
| 2804 | + $end = $ft['end']; |
|
| 2805 | + } |
|
| 2624 | 2806 | |
| 2625 | 2807 | // slot to small for duration |
| 2626 | 2808 | if ($end - $start < $duration) |
@@ -2662,7 +2844,10 @@ discard block |
||
| 2662 | 2844 | { |
| 2663 | 2845 | $msg = lang('Permission denied'); |
| 2664 | 2846 | |
| 2665 | - if ($return_error) return $msg; |
|
| 2847 | + if ($return_error) |
|
| 2848 | + { |
|
| 2849 | + return $msg; |
|
| 2850 | + } |
|
| 2666 | 2851 | } |
| 2667 | 2852 | else |
| 2668 | 2853 | { |
@@ -2724,27 +2909,42 @@ discard block |
||
| 2724 | 2909 | { |
| 2725 | 2910 | list($button) = each($_content['button']); |
| 2726 | 2911 | unset($_content['button']); |
| 2727 | - if ($button != 'cancel') // store changed Acl |
|
| 2912 | + if ($button != 'cancel') |
|
| 2913 | + { |
|
| 2914 | + // store changed Acl |
|
| 2728 | 2915 | { |
| 2729 | 2916 | foreach($_content as $data) |
| 2730 | 2917 | { |
| 2731 | 2918 | if (!($cat_id = $data['cat_id'])) continue; |
| 2919 | + } |
|
| 2732 | 2920 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2733 | 2921 | { |
| 2734 | 2922 | $rights = 0; |
| 2735 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2736 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2737 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2923 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2924 | + { |
|
| 2925 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2926 | + } |
|
| 2927 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2928 | + { |
|
| 2929 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2930 | + } |
|
| 2931 | + if ($account_id) |
|
| 2932 | + { |
|
| 2933 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2934 | + } |
|
| 2738 | 2935 | } |
| 2739 | 2936 | } |
| 2740 | 2937 | } |
| 2741 | - if ($button != 'apply') // end dialog |
|
| 2938 | + if ($button != 'apply') |
|
| 2939 | + { |
|
| 2940 | + // end dialog |
|
| 2742 | 2941 | { |
| 2743 | 2942 | Egw::redirect_link('/index.php', array( |
| 2744 | 2943 | 'menuaction' => 'admin.admin_ui.index', |
| 2745 | 2944 | 'ajax' => 'true' |
| 2746 | 2945 | ), 'admin'); |
| 2747 | 2946 | } |
| 2947 | + } |
|
| 2748 | 2948 | } |
| 2749 | 2949 | $content= $preserv = array(); |
| 2750 | 2950 | $n = 1; |
@@ -2758,8 +2958,14 @@ discard block |
||
| 2758 | 2958 | ); |
| 2759 | 2959 | foreach($data as $account_id => $rights) |
| 2760 | 2960 | { |
| 2761 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2762 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2961 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2962 | + { |
|
| 2963 | + $row['add'][] = $account_id; |
|
| 2964 | + } |
|
| 2965 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2966 | + { |
|
| 2967 | + $row['status'][] = $account_id; |
|
| 2968 | + } |
|
| 2763 | 2969 | } |
| 2764 | 2970 | $content[$n] = $row; |
| 2765 | 2971 | $preserv[$n] = array( |
@@ -2887,7 +3093,10 @@ discard block |
||
| 2887 | 3093 | break; |
| 2888 | 3094 | } |
| 2889 | 3095 | } |
| 2890 | - if($return) return; |
|
| 3096 | + if($return) |
|
| 3097 | + { |
|
| 3098 | + return; |
|
| 3099 | + } |
|
| 2891 | 3100 | } |
| 2892 | 3101 | $old_event=$event=$this->bo->read($eventId); |
| 2893 | 3102 | if (!$durationT) |
@@ -2981,7 +3190,10 @@ discard block |
||
| 2981 | 3190 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2982 | 3191 | |
| 2983 | 3192 | // Whole day non blocking with DAY_s would add a day |
| 2984 | - if($duration==DAY_s) $duration=0; |
|
| 3193 | + if($duration==DAY_s) |
|
| 3194 | + { |
|
| 3195 | + $duration=0; |
|
| 3196 | + } |
|
| 2985 | 3197 | } |
| 2986 | 3198 | |
| 2987 | 3199 | $status_reset_to_unknown = false; |
@@ -2999,7 +3211,10 @@ discard block |
||
| 2999 | 3211 | case 'no': |
| 3000 | 3212 | break; |
| 3001 | 3213 | case 'startday': |
| 3002 | - if ($sameday) break; |
|
| 3214 | + if ($sameday) |
|
| 3215 | + { |
|
| 3216 | + break; |
|
| 3217 | + } |
|
| 3003 | 3218 | default: |
| 3004 | 3219 | $status_reset_to_unknown = true; |
| 3005 | 3220 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -3043,7 +3258,10 @@ discard block |
||
| 3043 | 3258 | { |
| 3044 | 3259 | $response->call('egw.message', implode('<br />', $message)); |
| 3045 | 3260 | } |
| 3046 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3261 | + if($event['id'] != $eventId ) |
|
| 3262 | + { |
|
| 3263 | + $this->update_client($_eventId); |
|
| 3264 | + } |
|
| 3047 | 3265 | if ($status_reset_to_unknown) |
| 3048 | 3266 | { |
| 3049 | 3267 | foreach((array)$event['participants'] as $uid => $status) |
@@ -1490,13 +1490,13 @@ discard block |
||
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | - * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | - * |
|
| 1495 | - * @param string|int $id id of user or resource |
|
| 1496 | - * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | - * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | - * @return string with name |
|
| 1499 | - */ |
|
| 1493 | + * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | + * |
|
| 1495 | + * @param string|int $id id of user or resource |
|
| 1496 | + * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | + * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | + * @return string with name |
|
| 1499 | + */ |
|
| 1500 | 1500 | function participant_name($id,$use_type=false, $append_email=false) |
| 1501 | 1501 | { |
| 1502 | 1502 | static $id2lid = array(); |
@@ -1525,13 +1525,13 @@ discard block |
||
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
| 1528 | - * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | - * |
|
| 1530 | - * @param array $event event-data |
|
| 1531 | - * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | - * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | - * @return array with id / names with status pairs |
|
| 1534 | - */ |
|
| 1528 | + * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | + * |
|
| 1530 | + * @param array $event event-data |
|
| 1531 | + * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | + * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | + * @return array with id / names with status pairs |
|
| 1534 | + */ |
|
| 1535 | 1535 | function participants($event,$long_status=false,$show_group_invitation=false) |
| 1536 | 1536 | { |
| 1537 | 1537 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
@@ -1601,12 +1601,12 @@ discard block |
||
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | /** |
| 1604 | - * Converts category string of an event into array of (readable) category-names |
|
| 1605 | - * |
|
| 1606 | - * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | - * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | - * @return array with id / names |
|
| 1609 | - */ |
|
| 1604 | + * Converts category string of an event into array of (readable) category-names |
|
| 1605 | + * |
|
| 1606 | + * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | + * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | + * @return array with id / names |
|
| 1609 | + */ |
|
| 1610 | 1610 | function categories($category,&$color) |
| 1611 | 1611 | { |
| 1612 | 1612 | static $id2cat = array(); |
@@ -15,10 +15,13 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Link; |
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | -if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
|
| 18 | +if (!defined('ACL_TYPE_IDENTIFER')) |
|
| 19 | +{ |
|
| 20 | + // used to mark ACL-values for the debug_message methode |
|
| 19 | 21 | { |
| 20 | 22 | define('ACL_TYPE_IDENTIFER','***ACL***'); |
| 21 | 23 | } |
| 24 | +} |
|
| 22 | 25 | |
| 23 | 26 | define('HOUR_s',60*60); |
| 24 | 27 | define('DAY_s',24*HOUR_s); |
@@ -219,7 +222,10 @@ discard block |
||
| 219 | 222 | */ |
| 220 | 223 | function __construct() |
| 221 | 224 | { |
| 222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
| 225 | + if ($this->debug > 0) |
|
| 226 | + { |
|
| 227 | + $this->debug_message('calendar_bo::bocal() started',True); |
|
| 228 | + } |
|
| 223 | 229 | |
| 224 | 230 | $this->so = new calendar_so(); |
| 225 | 231 | |
@@ -305,7 +311,10 @@ discard block |
||
| 305 | 311 | */ |
| 306 | 312 | static function email_info($ids) |
| 307 | 313 | { |
| 308 | - if (!$ids) return null; |
|
| 314 | + if (!$ids) |
|
| 315 | + { |
|
| 316 | + return null; |
|
| 317 | + } |
|
| 309 | 318 | |
| 310 | 319 | $data = array(); |
| 311 | 320 | foreach((array)$ids as $id) |
@@ -398,10 +407,13 @@ discard block |
||
| 398 | 407 | } |
| 399 | 408 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
| 400 | 409 | { |
| 401 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
| 410 | + if ($contact && !in_array($contact,$contact_list)) |
|
| 411 | + { |
|
| 412 | + // already added? |
|
| 402 | 413 | { |
| 403 | 414 | $contact_list[] = $contact; |
| 404 | 415 | } |
| 416 | + } |
|
| 405 | 417 | } |
| 406 | 418 | } |
| 407 | 419 | } |
@@ -461,21 +473,27 @@ discard block |
||
| 461 | 473 | { |
| 462 | 474 | foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
| 463 | 475 | { |
| 464 | - if ($contact && !in_array($contact,$users)) // already added? |
|
| 476 | + if ($contact && !in_array($contact,$users)) |
|
| 477 | + { |
|
| 478 | + // already added? |
|
| 465 | 479 | { |
| 466 | 480 | $users[] = $contact; |
| 467 | 481 | } |
| 482 | + } |
|
| 468 | 483 | } |
| 469 | 484 | continue; |
| 470 | 485 | } |
| 471 | 486 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
| 472 | 487 | { |
| 473 | - if ($user && !in_array($user,$users)) // already added? |
|
| 488 | + if ($user && !in_array($user,$users)) |
|
| 489 | + { |
|
| 490 | + // already added? |
|
| 474 | 491 | { |
| 475 | 492 | // General expansion check |
| 476 | 493 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
| 477 | 494 | { |
| 478 | 495 | $info = $this->resource_info($user); |
| 496 | + } |
|
| 479 | 497 | if($info && $info['resources']) |
| 480 | 498 | { |
| 481 | 499 | foreach($info['resources'] as $_user) |
@@ -496,12 +514,18 @@ discard block |
||
| 496 | 514 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 497 | 515 | } |
| 498 | 516 | // the further code is only for real users |
| 499 | - if (!is_numeric($user)) continue; |
|
| 517 | + if (!is_numeric($user)) |
|
| 518 | + { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 500 | 521 | |
| 501 | 522 | // for groups we have to include the members |
| 502 | 523 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
| 503 | 524 | { |
| 504 | - if ($no_enum_groups) continue; |
|
| 525 | + if ($no_enum_groups) |
|
| 526 | + { |
|
| 527 | + continue; |
|
| 528 | + } |
|
| 505 | 529 | |
| 506 | 530 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 507 | 531 | if (is_array($members)) |
@@ -583,11 +607,14 @@ discard block |
||
| 583 | 607 | } |
| 584 | 608 | |
| 585 | 609 | if (empty($params['users']) || |
| 586 | - is_array($params['users']) && count($params['users']) == 1 && empty($params['users'][0])) // null or '' casted to an array |
|
| 610 | + is_array($params['users']) && count($params['users']) == 1 && empty($params['users'][0])) |
|
| 611 | + { |
|
| 612 | + // null or '' casted to an array |
|
| 587 | 613 | { |
| 588 | 614 | // for a search use all account you have read grants from |
| 589 | 615 | $params['users'] = $params['query'] ? array_keys($this->grants) : $this->user; |
| 590 | 616 | } |
| 617 | + } |
|
| 591 | 618 | // resolve users to add memberships for users and members for groups |
| 592 | 619 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
| 593 | 620 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
@@ -602,7 +629,10 @@ discard block |
||
| 602 | 629 | $params['private_grants'] = array(); |
| 603 | 630 | foreach($this->grants as $user => $rights) |
| 604 | 631 | { |
| 605 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 632 | + if ($rights & Acl::PRIVAT) |
|
| 633 | + { |
|
| 634 | + $params['private_grants'][] = $user; |
|
| 635 | + } |
|
| 606 | 636 | } |
| 607 | 637 | } |
| 608 | 638 | |
@@ -617,7 +647,10 @@ discard block |
||
| 617 | 647 | { |
| 618 | 648 | return false; |
| 619 | 649 | } |
| 620 | - if (isset($params['start'])) $start = $this->date2ts($params['start']); |
|
| 650 | + if (isset($params['start'])) |
|
| 651 | + { |
|
| 652 | + $start = $this->date2ts($params['start']); |
|
| 653 | + } |
|
| 621 | 654 | |
| 622 | 655 | if (isset($params['end'])) |
| 623 | 656 | { |
@@ -681,10 +714,13 @@ discard block |
||
| 681 | 714 | $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
| 682 | 715 | } |
| 683 | 716 | // create empty entries for each day in the reported time |
| 684 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 717 | + for($ts = $start; $ts <= $end; $ts += DAY_s) |
|
| 718 | + { |
|
| 719 | + // good enough for array creation, but see while loop below. |
|
| 685 | 720 | { |
| 686 | 721 | $daysEvents[$this->date2string($ts)] = array(); |
| 687 | 722 | } |
| 723 | + } |
|
| 688 | 724 | foreach($events as $k => $event) |
| 689 | 725 | { |
| 690 | 726 | $e_start = max($this->date2ts($event['start']),$start); |
@@ -736,7 +772,10 @@ discard block |
||
| 736 | 772 | $integration_data = calendar_so::get_integration_data(); |
| 737 | 773 | } |
| 738 | 774 | |
| 739 | - if (!isset($integration_data[$app])) return null; |
|
| 775 | + if (!isset($integration_data[$app])) |
|
| 776 | + { |
|
| 777 | + return null; |
|
| 778 | + } |
|
| 740 | 779 | |
| 741 | 780 | return $part ? $integration_data[$app][$part] : $integration_data[$app]; |
| 742 | 781 | } |
@@ -783,8 +822,14 @@ discard block |
||
| 783 | 822 | */ |
| 784 | 823 | function clear_private_infos(&$event,$allowed_participants = array()) |
| 785 | 824 | { |
| 786 | - if ($event == false) return; |
|
| 787 | - if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 825 | + if ($event == false) |
|
| 826 | + { |
|
| 827 | + return; |
|
| 828 | + } |
|
| 829 | + if (!is_array($event['participants'])) |
|
| 830 | + { |
|
| 831 | + error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 832 | + } |
|
| 788 | 833 | |
| 789 | 834 | $event = array( |
| 790 | 835 | 'id' => $event['id'], |
@@ -829,19 +874,29 @@ discard block |
||
| 829 | 874 | } |
| 830 | 875 | $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
| 831 | 876 | |
| 832 | - if ($new_horizont <= $this->config['horizont']) // no move necessary |
|
| 877 | + if ($new_horizont <= $this->config['horizont']) |
|
| 878 | + { |
|
| 879 | + // no move necessary |
|
| 833 | 880 | { |
| 834 | 881 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
| 882 | + } |
|
| 835 | 883 | return; |
| 836 | 884 | } |
| 837 | 885 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
| 838 | 886 | { |
| 839 | 887 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 840 | 888 | } |
| 841 | - if (empty($maxdays)) $maxdays = 1000; // old default |
|
| 842 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 889 | + if (empty($maxdays)) |
|
| 890 | + { |
|
| 891 | + $maxdays = 1000; |
|
| 892 | + } |
|
| 893 | + // old default |
|
| 894 | + if ($new_horizont > time()+$maxdays*DAY_s) |
|
| 895 | + { |
|
| 896 | + // some user tries to "look" more then the maximum number of days in the future |
|
| 843 | 897 | { |
| 844 | 898 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
| 899 | + } |
|
| 845 | 900 | $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
| 846 | 901 | return; |
| 847 | 902 | } |
@@ -869,7 +924,10 @@ discard block |
||
| 869 | 924 | // update the horizont |
| 870 | 925 | Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
| 871 | 926 | |
| 872 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 927 | + if ($this->debug == 'check_move_horizont') |
|
| 928 | + { |
|
| 929 | + $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 930 | + } |
|
| 873 | 931 | } |
| 874 | 932 | |
| 875 | 933 | /** |
@@ -900,7 +958,10 @@ discard block |
||
| 900 | 958 | $event['end'] = $this->date2usertime($event_read['end']); |
| 901 | 959 | } |
| 902 | 960 | } |
| 903 | - if (!$start) $start = $event['start']; |
|
| 961 | + if (!$start) |
|
| 962 | + { |
|
| 963 | + $start = $event['start']; |
|
| 964 | + } |
|
| 904 | 965 | |
| 905 | 966 | $events = array(); |
| 906 | 967 | |
@@ -944,7 +1005,10 @@ discard block |
||
| 944 | 1005 | */ |
| 945 | 1006 | function db2data(&$events,$date_format='ts') |
| 946 | 1007 | { |
| 947 | - if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1008 | + if (!is_array($events)) |
|
| 1009 | + { |
|
| 1010 | + echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1011 | + } |
|
| 948 | 1012 | foreach ($events as &$event) |
| 949 | 1013 | { |
| 950 | 1014 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
@@ -1028,7 +1092,10 @@ discard block |
||
| 1028 | 1092 | */ |
| 1029 | 1093 | function date2usertime($ts,$date_format='ts') |
| 1030 | 1094 | { |
| 1031 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
| 1095 | + if (empty($ts) || $date_format == 'server') |
|
| 1096 | + { |
|
| 1097 | + return $ts; |
|
| 1098 | + } |
|
| 1032 | 1099 | |
| 1033 | 1100 | return Api\DateTime::server2user($ts,$date_format); |
| 1034 | 1101 | } |
@@ -1047,9 +1114,15 @@ discard block |
||
| 1047 | 1114 | */ |
| 1048 | 1115 | function read($ids,$date=null, $ignore_acl=False, $date_format='ts', $clear_private_infos_users=null, $read_recurrence=false) |
| 1049 | 1116 | { |
| 1050 | - if (!$ids) return false; |
|
| 1117 | + if (!$ids) |
|
| 1118 | + { |
|
| 1119 | + return false; |
|
| 1120 | + } |
|
| 1051 | 1121 | |
| 1052 | - if ($date) $date = $this->date2ts($date); |
|
| 1122 | + if ($date) |
|
| 1123 | + { |
|
| 1124 | + $date = $this->date2ts($date); |
|
| 1125 | + } |
|
| 1053 | 1126 | |
| 1054 | 1127 | $return = null; |
| 1055 | 1128 | |
@@ -1224,7 +1297,10 @@ discard block |
||
| 1224 | 1297 | { |
| 1225 | 1298 | static $res_info_cache = array(); |
| 1226 | 1299 | |
| 1227 | - if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1300 | + if (!is_scalar($uid)) |
|
| 1301 | + { |
|
| 1302 | + throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1303 | + } |
|
| 1228 | 1304 | |
| 1229 | 1305 | if (!isset($res_info_cache[$uid])) |
| 1230 | 1306 | { |
@@ -1279,7 +1355,10 @@ discard block |
||
| 1279 | 1355 | */ |
| 1280 | 1356 | function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
| 1281 | 1357 | { |
| 1282 | - if (!$user) $user = $this->user; |
|
| 1358 | + if (!$user) |
|
| 1359 | + { |
|
| 1360 | + $user = $this->user; |
|
| 1361 | + } |
|
| 1283 | 1362 | if ($user == $this->user) |
| 1284 | 1363 | { |
| 1285 | 1364 | $grants = $this->grants; |
@@ -1318,7 +1397,10 @@ discard block |
||
| 1318 | 1397 | $grant = $grants[$owner]; |
| 1319 | 1398 | |
| 1320 | 1399 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1321 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1400 | + if ($grant & ~self::ACL_INVITE) |
|
| 1401 | + { |
|
| 1402 | + $grant |= self::ACL_FREEBUSY; |
|
| 1403 | + } |
|
| 1322 | 1404 | |
| 1323 | 1405 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1324 | 1406 | { |
@@ -1344,7 +1426,10 @@ discard block |
||
| 1344 | 1426 | elseif (!is_numeric($uid)) |
| 1345 | 1427 | { |
| 1346 | 1428 | // if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights |
| 1347 | - if ($grant == self::ACL_FREEBUSY) continue; |
|
| 1429 | + if ($grant == self::ACL_FREEBUSY) |
|
| 1430 | + { |
|
| 1431 | + continue; |
|
| 1432 | + } |
|
| 1348 | 1433 | // if we have a resource as participant |
| 1349 | 1434 | $resource = $this->resource_info($uid); |
| 1350 | 1435 | $grant |= $resource['rights']; |
@@ -1495,14 +1580,20 @@ discard block |
||
| 1495 | 1580 | $param = $param ? 'True' : 'False'; |
| 1496 | 1581 | break; |
| 1497 | 1582 | case 'integer': |
| 1498 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1583 | + if ($param >= mktime(0,0,0,1,1,2000)) |
|
| 1584 | + { |
|
| 1585 | + $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1586 | + } |
|
| 1499 | 1587 | break; |
| 1500 | 1588 | } |
| 1501 | 1589 | } |
| 1502 | 1590 | $msg = str_replace('%'.($i-1),$param,$msg); |
| 1503 | 1591 | } |
| 1504 | 1592 | error_log($msg); |
| 1505 | - if ($backtrace) error_log(function_backtrace(1)); |
|
| 1593 | + if ($backtrace) |
|
| 1594 | + { |
|
| 1595 | + error_log(function_backtrace(1)); |
|
| 1596 | + } |
|
| 1506 | 1597 | } |
| 1507 | 1598 | |
| 1508 | 1599 | /** |
@@ -1610,14 +1701,20 @@ discard block |
||
| 1610 | 1701 | function timespan($start_m,$end_m,$both=false) |
| 1611 | 1702 | { |
| 1612 | 1703 | $duration = $end_m - $start_m; |
| 1613 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1704 | + if ($end_m == 24*60-1) |
|
| 1705 | + { |
|
| 1706 | + ++$duration; |
|
| 1707 | + } |
|
| 1614 | 1708 | $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
| 1615 | 1709 | |
| 1616 | 1710 | $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
| 1617 | 1711 | |
| 1618 | - if ($both) // end-time too |
|
| 1712 | + if ($both) |
|
| 1713 | + { |
|
| 1714 | + // end-time too |
|
| 1619 | 1715 | { |
| 1620 | 1716 | $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
| 1717 | + } |
|
| 1621 | 1718 | // dont double am/pm if they are the same in both times |
| 1622 | 1719 | if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
| 1623 | 1720 | { |
@@ -1641,7 +1738,10 @@ discard block |
||
| 1641 | 1738 | static $id2lid = array(); |
| 1642 | 1739 | static $id2email = array(); |
| 1643 | 1740 | |
| 1644 | - if ($use_type && $use_type != 'u') $id = $use_type.$id; |
|
| 1741 | + if ($use_type && $use_type != 'u') |
|
| 1742 | + { |
|
| 1743 | + $id = $use_type.$id; |
|
| 1744 | + } |
|
| 1645 | 1745 | |
| 1646 | 1746 | if (!isset($id2lid[$id])) |
| 1647 | 1747 | { |
@@ -1651,7 +1751,10 @@ discard block |
||
| 1651 | 1751 | if (($info = $this->resource_info($id))) |
| 1652 | 1752 | { |
| 1653 | 1753 | $id2lid[$id] = $info['name'] ? $info['name'] : $info['email']; |
| 1654 | - if ($info['name']) $id2email[$id] = $info['email']; |
|
| 1754 | + if ($info['name']) |
|
| 1755 | + { |
|
| 1756 | + $id2email[$id] = $info['email']; |
|
| 1757 | + } |
|
| 1655 | 1758 | } |
| 1656 | 1759 | } |
| 1657 | 1760 | else |
@@ -1677,11 +1780,18 @@ discard block |
||
| 1677 | 1780 | $names = array(); |
| 1678 | 1781 | foreach((array)$event['participants'] as $id => $status) |
| 1679 | 1782 | { |
| 1680 | - if (!is_string($status)) continue; |
|
| 1783 | + if (!is_string($status)) |
|
| 1784 | + { |
|
| 1785 | + continue; |
|
| 1786 | + } |
|
| 1681 | 1787 | $quantity = $role = null; |
| 1682 | 1788 | calendar_so::split_status($status,$quantity,$role); |
| 1683 | 1789 | |
| 1684 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1790 | + if ($status == 'G' && !$show_group_invitation) |
|
| 1791 | + { |
|
| 1792 | + continue; |
|
| 1793 | + } |
|
| 1794 | + // dont show group-invitation |
|
| 1685 | 1795 | |
| 1686 | 1796 | $lang_status = lang($this->verbose_status[$status]); |
| 1687 | 1797 | if (!$long_status) |
@@ -1754,7 +1864,10 @@ discard block |
||
| 1754 | 1864 | |
| 1755 | 1865 | foreach(explode(',',$category) as $cat_id) |
| 1756 | 1866 | { |
| 1757 | - if (!$cat_id) continue; |
|
| 1867 | + if (!$cat_id) |
|
| 1868 | + { |
|
| 1869 | + continue; |
|
| 1870 | + } |
|
| 1758 | 1871 | |
| 1759 | 1872 | if (!isset($id2cat[$cat_id])) |
| 1760 | 1873 | { |
@@ -1820,7 +1933,10 @@ discard block |
||
| 1820 | 1933 | */ |
| 1821 | 1934 | public static function list_calendars($user, array $grants=null) |
| 1822 | 1935 | { |
| 1823 | - if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1936 | + if (is_null($grants)) |
|
| 1937 | + { |
|
| 1938 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1939 | + } |
|
| 1824 | 1940 | |
| 1825 | 1941 | $users = $groups = array(); |
| 1826 | 1942 | foreach(array_keys($grants) as $id) |
@@ -1868,7 +1984,10 @@ discard block |
||
| 1868 | 1984 | */ |
| 1869 | 1985 | function recure2string($event) |
| 1870 | 1986 | { |
| 1871 | - if (!is_array($event)) return false; |
|
| 1987 | + if (!is_array($event)) |
|
| 1988 | + { |
|
| 1989 | + return false; |
|
| 1990 | + } |
|
| 1872 | 1991 | return (string)calendar_rrule::event2rrule($event); |
| 1873 | 1992 | } |
| 1874 | 1993 | |
@@ -1887,7 +2006,10 @@ discard block |
||
| 1887 | 2006 | */ |
| 1888 | 2007 | function read_holidays($year=0) |
| 1889 | 2008 | { |
| 1890 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 2009 | + if (!$year) |
|
| 2010 | + { |
|
| 2011 | + $year = (int) date('Y',$this->now_su); |
|
| 2012 | + } |
|
| 1891 | 2013 | |
| 1892 | 2014 | $holidays = calendar_holidays::read( |
| 1893 | 2015 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
@@ -1912,7 +2034,10 @@ discard block |
||
| 1912 | 2034 | foreach($bdays as $birthday) |
| 1913 | 2035 | { |
| 1914 | 2036 | // Skip if name / date are already there - duplicate contacts |
| 1915 | - if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue; |
|
| 2037 | + if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) |
|
| 2038 | + { |
|
| 2039 | + continue; |
|
| 2040 | + } |
|
| 1916 | 2041 | $holidays[$date][] = $birthday; |
| 1917 | 2042 | } |
| 1918 | 2043 | } |
@@ -1997,7 +2122,10 @@ discard block |
||
| 1997 | 2122 | } |
| 1998 | 2123 | } |
| 1999 | 2124 | $str_fields = implode(', ',$extra_fields); |
| 2000 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2125 | + if (is_array($extra_fields)) |
|
| 2126 | + { |
|
| 2127 | + return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2128 | + } |
|
| 2001 | 2129 | } |
| 2002 | 2130 | return $this->format_date($event['start']) . ': ' . $event['title']; |
| 2003 | 2131 | } |
@@ -2018,7 +2146,8 @@ discard block |
||
| 2018 | 2146 | 'offset' => $options['start'], |
| 2019 | 2147 | 'order' => 'cal_start DESC', |
| 2020 | 2148 | ); |
| 2021 | - if($options['num_rows']) { |
|
| 2149 | + if($options['num_rows']) |
|
| 2150 | + { |
|
| 2022 | 2151 | $query['num_rows'] = $options['num_rows']; |
| 2023 | 2152 | } |
| 2024 | 2153 | foreach((array) $this->search($query) as $event) |
@@ -2079,7 +2208,10 @@ discard block |
||
| 2079 | 2208 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 2080 | 2209 | { |
| 2081 | 2210 | $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
| 2082 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2211 | + if ($type == 'forced') |
|
| 2212 | + { |
|
| 2213 | + $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2214 | + } |
|
| 2083 | 2215 | $this->cal_prefs[$var] = $default; |
| 2084 | 2216 | $need_save = True; |
| 2085 | 2217 | } |
@@ -2099,7 +2231,10 @@ discard block |
||
| 2099 | 2231 | */ |
| 2100 | 2232 | static function freebusy_url($user='',$pw=null) |
| 2101 | 2233 | { |
| 2102 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2234 | + if (is_numeric($user)) |
|
| 2235 | + { |
|
| 2236 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2237 | + } |
|
| 2103 | 2238 | |
| 2104 | 2239 | $credentials = ''; |
| 2105 | 2240 | |
@@ -2167,13 +2302,19 @@ discard block |
||
| 2167 | 2302 | */ |
| 2168 | 2303 | public function get_ctag($user, $filter='owner', $master_only=false) |
| 2169 | 2304 | { |
| 2170 | - if ($this->debug > 1) $startime = microtime(true); |
|
| 2305 | + if ($this->debug > 1) |
|
| 2306 | + { |
|
| 2307 | + $startime = microtime(true); |
|
| 2308 | + } |
|
| 2171 | 2309 | |
| 2172 | 2310 | // resolve users to add memberships for users and members for groups |
| 2173 | 2311 | $users = $this->resolve_users($user); |
| 2174 | 2312 | $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
| 2175 | 2313 | |
| 2176 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2314 | + if ($this->debug > 1) |
|
| 2315 | + { |
|
| 2316 | + error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2317 | + } |
|
| 2177 | 2318 | return $ctag; |
| 2178 | 2319 | } |
| 2179 | 2320 | |
@@ -2215,15 +2356,21 @@ discard block |
||
| 2215 | 2356 | $content['link_app'][] = $link['app']; |
| 2216 | 2357 | $content['link_id'][] = $link['id']; |
| 2217 | 2358 | } |
| 2218 | - if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above |
|
| 2359 | + if ($link['app'] == 'addressbook') |
|
| 2360 | + { |
|
| 2361 | + // prefering contact as primary contact over calendar entry set above |
|
| 2219 | 2362 | { |
| 2220 | 2363 | $content['info_contact'] = 'addressbook:'.$link['id']; |
| 2221 | 2364 | } |
| 2365 | + } |
|
| 2222 | 2366 | } |
| 2223 | 2367 | // Copy same custom fields |
| 2224 | 2368 | foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
| 2225 | 2369 | { |
| 2226 | - if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
|
| 2370 | + if ($this->customfields[$name]) |
|
| 2371 | + { |
|
| 2372 | + $content['#'.$name] = $calendar['#'.$name]; |
|
| 2373 | + } |
|
| 2227 | 2374 | } |
| 2228 | 2375 | //error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content)); |
| 2229 | 2376 | return $content; |
@@ -2246,7 +2393,11 @@ discard block |
||
| 2246 | 2393 | $set['ts_title'] = $this->link_title($event); |
| 2247 | 2394 | $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
| 2248 | 2395 | $set['ts_description'] = $event['description']; |
| 2249 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2396 | + if ($this->isWholeDay($event)) |
|
| 2397 | + { |
|
| 2398 | + $event['end']++; |
|
| 2399 | + } |
|
| 2400 | + // whole day events are 1sec short |
|
| 2250 | 2401 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2251 | 2402 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2252 | 2403 | $set['end_time'] = null; // unset end-time |
@@ -1504,22 +1504,22 @@ discard block |
||
| 1504 | 1504 | // check the old list against the new list |
| 1505 | 1505 | foreach ($old_event['participants'] as $userid => $status) |
| 1506 | 1506 | { |
| 1507 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1508 | - // Attendee will be deleted this way |
|
| 1509 | - $new_event['participants'][$userid] = 'G'; |
|
| 1510 | - } |
|
| 1511 | - elseif ($new_event['participants'][$userid] == $status) |
|
| 1512 | - { |
|
| 1513 | - // Same status -- nothing to do. |
|
| 1514 | - unset($new_event['participants'][$userid]); |
|
| 1515 | - } |
|
| 1507 | + if (!isset($new_event['participants'][$userid])){ |
|
| 1508 | + // Attendee will be deleted this way |
|
| 1509 | + $new_event['participants'][$userid] = 'G'; |
|
| 1510 | + } |
|
| 1511 | + elseif ($new_event['participants'][$userid] == $status) |
|
| 1512 | + { |
|
| 1513 | + // Same status -- nothing to do. |
|
| 1514 | + unset($new_event['participants'][$userid]); |
|
| 1515 | + } |
|
| 1516 | 1516 | } |
| 1517 | 1517 | // write the changes |
| 1518 | 1518 | foreach ($new_event['participants'] as $userid => $status) |
| 1519 | 1519 | { |
| 1520 | 1520 | $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
| 1521 | 1521 | } |
| 1522 | - } |
|
| 1522 | + } |
|
| 1523 | 1523 | |
| 1524 | 1524 | /** |
| 1525 | 1525 | * deletes an event |
@@ -2493,24 +2493,24 @@ discard block |
||
| 2493 | 2493 | /** |
| 2494 | 2494 | * classifies an incoming event from the eGW point-of-view |
| 2495 | 2495 | * |
| 2496 | - * exceptions: unlike other calendar apps eGW does not create an event exception |
|
| 2497 | - * if just the participant state changes - therefore we have to distinguish between |
|
| 2498 | - * real exceptions and status only exceptions |
|
| 2499 | - * |
|
| 2500 | - * @param array $event the event to check |
|
| 2501 | - * |
|
| 2502 | - * @return array |
|
| 2503 | - * type => |
|
| 2504 | - * SINGLE a single event |
|
| 2505 | - * SERIES-MASTER the series master |
|
| 2506 | - * SERIES-EXCEPTION event is a real exception |
|
| 2507 | - * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
| 2508 | - * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
| 2509 | - * stored_event => if event already exists in the database array with event data or false |
|
| 2510 | - * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
| 2511 | - * the corresponding series master event array |
|
| 2512 | - * NOTE: this param is false if event is of type SERIES-MASTER |
|
| 2513 | - */ |
|
| 2496 | + * exceptions: unlike other calendar apps eGW does not create an event exception |
|
| 2497 | + * if just the participant state changes - therefore we have to distinguish between |
|
| 2498 | + * real exceptions and status only exceptions |
|
| 2499 | + * |
|
| 2500 | + * @param array $event the event to check |
|
| 2501 | + * |
|
| 2502 | + * @return array |
|
| 2503 | + * type => |
|
| 2504 | + * SINGLE a single event |
|
| 2505 | + * SERIES-MASTER the series master |
|
| 2506 | + * SERIES-EXCEPTION event is a real exception |
|
| 2507 | + * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
| 2508 | + * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
| 2509 | + * stored_event => if event already exists in the database array with event data or false |
|
| 2510 | + * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
| 2511 | + * the corresponding series master event array |
|
| 2512 | + * NOTE: this param is false if event is of type SERIES-MASTER |
|
| 2513 | + */ |
|
| 2514 | 2514 | function get_event_info($event) |
| 2515 | 2515 | { |
| 2516 | 2516 | $type = 'SINGLE'; // default |
@@ -2681,16 +2681,16 @@ discard block |
||
| 2681 | 2681 | 'stored_event' => $stored_event, |
| 2682 | 2682 | 'master_event' => $master_event, |
| 2683 | 2683 | ); |
| 2684 | - } |
|
| 2685 | - |
|
| 2686 | - /** |
|
| 2687 | - * Translates all timestamps for a given event from server-time to user-time. |
|
| 2688 | - * The update() and save() methods expect timestamps in user-time. |
|
| 2689 | - * @param &$event the event we are working on |
|
| 2690 | - * |
|
| 2691 | - */ |
|
| 2692 | - function server2usertime (&$event) |
|
| 2693 | - { |
|
| 2684 | + } |
|
| 2685 | + |
|
| 2686 | + /** |
|
| 2687 | + * Translates all timestamps for a given event from server-time to user-time. |
|
| 2688 | + * The update() and save() methods expect timestamps in user-time. |
|
| 2689 | + * @param &$event the event we are working on |
|
| 2690 | + * |
|
| 2691 | + */ |
|
| 2692 | + function server2usertime (&$event) |
|
| 2693 | + { |
|
| 2694 | 2694 | // we run all dates through date2usertime, to adjust to user-time |
| 2695 | 2695 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2696 | 2696 | { |
@@ -2713,7 +2713,7 @@ discard block |
||
| 2713 | 2713 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2714 | 2714 | } |
| 2715 | 2715 | } |
| 2716 | - } |
|
| 2716 | + } |
|
| 2717 | 2717 | /** |
| 2718 | 2718 | * Delete events that are more than $age years old |
| 2719 | 2719 | * |
@@ -85,11 +85,17 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) |
|
| 89 | + { |
|
| 90 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | parent::__construct(); // calling the parent constructor |
| 91 | 94 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 95 | + if ($this->debug > 0) |
|
| 96 | + { |
|
| 97 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 98 | + } |
|
| 93 | 99 | } |
| 94 | 100 | |
| 95 | 101 | /** |
@@ -120,7 +126,10 @@ discard block |
||
| 120 | 126 | { |
| 121 | 127 | unset($updateTS); // ignored, as updating timestamps is required for sync! |
| 122 | 128 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 123 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
| 129 | + if (!is_array($messages)) |
|
| 130 | + { |
|
| 131 | + $messages = $messages ? (array)$messages : array(); |
|
| 132 | + } |
|
| 124 | 133 | |
| 125 | 134 | if ($this->debug > 1 || $this->debug == 'update') |
| 126 | 135 | { |
@@ -140,10 +149,13 @@ discard block |
||
| 140 | 149 | |
| 141 | 150 | $status_reset_to_unknown = false; |
| 142 | 151 | |
| 143 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
| 152 | + if (($new_event = !$event['id'])) |
|
| 153 | + { |
|
| 154 | + // some defaults for new entries |
|
| 144 | 155 | { |
| 145 | 156 | // if no owner given, set user to owner |
| 146 | 157 | if (!$event['owner']) $event['owner'] = $this->user; |
| 158 | + } |
|
| 147 | 159 | // set owner as participant if none is given |
| 148 | 160 | if (!is_array($event['participants']) || !count($event['participants'])) |
| 149 | 161 | { |
@@ -183,7 +195,10 @@ discard block |
||
| 183 | 195 | // check category based ACL |
| 184 | 196 | if ($event['category']) |
| 185 | 197 | { |
| 186 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 198 | + if (!is_array($event['category'])) |
|
| 199 | + { |
|
| 200 | + $event['category'] = explode(',',$event['category']); |
|
| 201 | + } |
|
| 187 | 202 | if (!$old_event || !isset($old_event['category'])) |
| 188 | 203 | { |
| 189 | 204 | $old_event['category'] = array(); |
@@ -235,13 +250,16 @@ discard block |
||
| 235 | 250 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) && |
| 236 | 251 | (($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding)) |
| 237 | 252 | { |
| 238 | - if ($checked_excluding) // warn user if not all recurrences have been checked |
|
| 253 | + if ($checked_excluding) |
|
| 254 | + { |
|
| 255 | + // warn user if not all recurrences have been checked |
|
| 239 | 256 | { |
| 240 | 257 | $conflicts['warning'] = array( |
| 241 | 258 | 'start' => $checked_excluding, |
| 242 | 259 | 'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)), |
| 243 | 260 | ); |
| 244 | 261 | } |
| 262 | + } |
|
| 245 | 263 | return $conflicts; |
| 246 | 264 | } |
| 247 | 265 | |
@@ -305,7 +323,10 @@ discard block |
||
| 305 | 323 | $types_with_quantity = array(); |
| 306 | 324 | foreach($this->resources as $type => $data) |
| 307 | 325 | { |
| 308 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 326 | + if ($data['max_quantity']) |
|
| 327 | + { |
|
| 328 | + $types_with_quantity[] = $type; |
|
| 329 | + } |
|
| 309 | 330 | } |
| 310 | 331 | // get all NOT rejected participants and evtl. their quantity |
| 311 | 332 | $quantity = $users = array(); |
@@ -313,12 +334,19 @@ discard block |
||
| 313 | 334 | { |
| 314 | 335 | $q = $role = null; |
| 315 | 336 | calendar_so::split_status($status, $q, $role); |
| 316 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 337 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 338 | + { |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 341 | + // ignore rejected or non-participants |
|
| 317 | 342 | |
| 318 | - if ($uid < 0) // group, check it's members too |
|
| 343 | + if ($uid < 0) |
|
| 344 | + { |
|
| 345 | + // group, check it's members too |
|
| 319 | 346 | { |
| 320 | 347 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
| 321 | 348 | } |
| 349 | + } |
|
| 322 | 350 | $users[] = $uid; |
| 323 | 351 | if (in_array($uid[0],$types_with_quantity)) |
| 324 | 352 | { |
@@ -349,18 +377,24 @@ discard block |
||
| 349 | 377 | $startts = $date->format('ts'); |
| 350 | 378 | |
| 351 | 379 | // skip past events or recurrences |
| 352 | - if ($startts+$duration < $this->now_su) continue; |
|
| 380 | + if ($startts+$duration < $this->now_su) |
|
| 381 | + { |
|
| 382 | + continue; |
|
| 383 | + } |
|
| 353 | 384 | |
| 354 | 385 | // abort check if configured limits are exceeded |
| 355 | 386 | if ($event['recur_type'] && |
| 356 | 387 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 357 | 388 | microtime(true) > $start+$max_check_time || // max check time exceeded |
| 358 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
| 389 | + $startts > $this->config['horizont'])) |
|
| 390 | + { |
|
| 391 | + // we are behind horizon for which recurrences are rendered |
|
| 359 | 392 | { |
| 360 | 393 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 361 | 394 | { |
| 362 | 395 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 363 | 396 | $checked, microtime(true)-$start, $date); |
| 397 | + } |
|
| 364 | 398 | } |
| 365 | 399 | $checked_excluding = $date; |
| 366 | 400 | break; |
@@ -384,10 +418,13 @@ discard block |
||
| 384 | 418 | { |
| 385 | 419 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 386 | 420 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 387 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 421 | + $overlap['non_blocking']) |
|
| 422 | + { |
|
| 423 | + // that's a non_blocking event |
|
| 388 | 424 | { |
| 389 | 425 | continue; |
| 390 | 426 | } |
| 427 | + } |
|
| 391 | 428 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 392 | 429 | { |
| 393 | 430 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -875,14 +912,20 @@ discard block |
||
| 875 | 912 | $startdate = new Api\DateTime($event['start']); |
| 876 | 913 | $enddate = new Api\DateTime($event['end']); |
| 877 | 914 | $modified = new Api\DateTime($event['modified']); |
| 878 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
| 915 | + if ($old_event) |
|
| 916 | + { |
|
| 917 | + $olddate = new Api\DateTime($old_event['start']); |
|
| 918 | + } |
|
| 879 | 919 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 880 | 920 | $owner_prefs = $ics = null; |
| 881 | 921 | foreach($to_notify as $userid => $statusid) |
| 882 | 922 | { |
| 883 | 923 | $res_info = $quantity = $role = null; |
| 884 | 924 | calendar_so::split_status($statusid, $quantity, $role); |
| 885 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 925 | + if ($this->debug > 0) |
|
| 926 | + { |
|
| 927 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 928 | + } |
|
| 886 | 929 | |
| 887 | 930 | if (!is_numeric($userid)) |
| 888 | 931 | { |
@@ -901,7 +944,11 @@ discard block |
||
| 901 | 944 | |
| 902 | 945 | if (!isset($userid)) |
| 903 | 946 | { |
| 904 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 947 | + if (empty($res_info['email'])) |
|
| 948 | + { |
|
| 949 | + continue; |
|
| 950 | + } |
|
| 951 | + // no way to notify |
|
| 905 | 952 | // check if event-owner wants non-EGroupware users notified |
| 906 | 953 | if (is_null($owner_prefs)) |
| 907 | 954 | { |
@@ -975,7 +1022,10 @@ discard block |
||
| 975 | 1022 | $details['to-lastname'] = isset($tln)? $tln: ''; |
| 976 | 1023 | |
| 977 | 1024 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 978 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1025 | + if (!isset($part_prefs['common']['tz'])) |
|
| 1026 | + { |
|
| 1027 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1028 | + } |
|
| 979 | 1029 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 980 | 1030 | $timeformat = $part_prefs['common']['timeformat']; |
| 981 | 1031 | switch($timeformat) |
@@ -1010,9 +1060,12 @@ discard block |
||
| 1010 | 1060 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 1011 | 1061 | { |
| 1012 | 1062 | case 'ical': |
| 1013 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1063 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 1064 | + { |
|
| 1065 | + // need different ical for organizer notification |
|
| 1014 | 1066 | { |
| 1015 | 1067 | $calendar_ical = new calendar_ical(); |
| 1068 | + } |
|
| 1016 | 1069 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 1017 | 1070 | // we need to pass $event[id] so iCal class reads event again, |
| 1018 | 1071 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1028,7 +1081,10 @@ discard block |
||
| 1028 | 1081 | 'encoding' => '8bit', |
| 1029 | 1082 | 'type' => 'text/calendar; method='.$method, |
| 1030 | 1083 | ); |
| 1031 | - if ($m_type != $msg_type) unset($ics); |
|
| 1084 | + if ($m_type != $msg_type) |
|
| 1085 | + { |
|
| 1086 | + unset($ics); |
|
| 1087 | + } |
|
| 1032 | 1088 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 1033 | 1089 | // fall through |
| 1034 | 1090 | case 'extended': |
@@ -1088,11 +1144,16 @@ discard block |
||
| 1088 | 1144 | 'app' => 'calendar' |
| 1089 | 1145 | )); |
| 1090 | 1146 | } |
| 1091 | - if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1147 | + if ($m_type === MSG_ALARM) |
|
| 1148 | + { |
|
| 1149 | + $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1150 | + } |
|
| 1092 | 1151 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
| 1093 | 1152 | $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
| 1094 | 1153 | |
| 1095 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1154 | + if(is_array($attachment)) |
|
| 1155 | + { |
|
| 1156 | +$notification->set_attachments(array($attachment)); } |
|
| 1096 | 1157 | $notification->send(); |
| 1097 | 1158 | foreach(notifications::errors(true) as $error) |
| 1098 | 1159 | { |
@@ -1128,7 +1189,10 @@ discard block |
||
| 1128 | 1189 | Api\Translation::init(); |
| 1129 | 1190 | } |
| 1130 | 1191 | // restore timezone, in case we had to reset it to server-timezone |
| 1131 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1192 | + if ($restore_tz) |
|
| 1193 | + { |
|
| 1194 | + date_default_timezone_set($restore_tz); |
|
| 1195 | + } |
|
| 1132 | 1196 | |
| 1133 | 1197 | return true; |
| 1134 | 1198 | } |
@@ -1163,10 +1227,13 @@ discard block |
||
| 1163 | 1227 | { |
| 1164 | 1228 | $to_notify = $event['participants']; |
| 1165 | 1229 | } |
| 1166 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1230 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
| 1231 | + { |
|
| 1232 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1167 | 1233 | { |
| 1168 | 1234 | $to_notify[$alarm['owner']] = 'A'; |
| 1169 | 1235 | } |
| 1236 | + } |
|
| 1170 | 1237 | else |
| 1171 | 1238 | { |
| 1172 | 1239 | return False; // no rights |
@@ -1215,14 +1282,20 @@ discard block |
||
| 1215 | 1282 | if ($event['id']) |
| 1216 | 1283 | { |
| 1217 | 1284 | // invalidate the read-cache if it contains the event we store now |
| 1218 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1285 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1286 | + { |
|
| 1287 | + self::$cached_event = array(); |
|
| 1288 | + } |
|
| 1219 | 1289 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
| 1220 | 1290 | } |
| 1221 | 1291 | else |
| 1222 | 1292 | { |
| 1223 | 1293 | $old_event = null; |
| 1224 | 1294 | } |
| 1225 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1295 | + if (!isset($event['whole_day'])) |
|
| 1296 | + { |
|
| 1297 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1298 | + } |
|
| 1226 | 1299 | |
| 1227 | 1300 | // set recur-enddate/range-end to real end-date of last recurrence |
| 1228 | 1301 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
@@ -1299,7 +1372,10 @@ discard block |
||
| 1299 | 1372 | foreach($timestamps as $ts) |
| 1300 | 1373 | { |
| 1301 | 1374 | // we convert here from user-time to timestamps in server-time! |
| 1302 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1375 | + if (isset($event[$ts])) |
|
| 1376 | + { |
|
| 1377 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1378 | + } |
|
| 1303 | 1379 | } |
| 1304 | 1380 | // convert tzid name to integer tz_id, of set user default |
| 1305 | 1381 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1335,7 +1411,10 @@ discard block |
||
| 1335 | 1411 | if ($alarm['owner'] && isset($expanded['participants'])) |
| 1336 | 1412 | { |
| 1337 | 1413 | // Don't auto-delete alarm if for all users |
| 1338 | - if($alarm['all']) continue; |
|
| 1414 | + if($alarm['all']) |
|
| 1415 | + { |
|
| 1416 | + continue; |
|
| 1417 | + } |
|
| 1339 | 1418 | |
| 1340 | 1419 | $status = $expanded['participants'][$alarm['owner']]; |
| 1341 | 1420 | if (!isset($status) || calendar_so::split_status($status) === 'R') |
@@ -1356,7 +1435,10 @@ discard block |
||
| 1356 | 1435 | if (!isset($event['alarm'][$id])) |
| 1357 | 1436 | { |
| 1358 | 1437 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1359 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1438 | + if ($alarm['time'] < time()) |
|
| 1439 | + { |
|
| 1440 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1441 | + } |
|
| 1360 | 1442 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1361 | 1443 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1362 | 1444 | $old_event['participants'][$alarm['owner']]; |
@@ -1412,7 +1494,10 @@ discard block |
||
| 1412 | 1494 | |
| 1413 | 1495 | // Update history |
| 1414 | 1496 | $tracking = new calendar_tracking($this); |
| 1415 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1497 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1498 | + { |
|
| 1499 | + $event['id']=$cal_id; |
|
| 1500 | + } |
|
| 1416 | 1501 | $tracking->track($save_event, $old_event); |
| 1417 | 1502 | |
| 1418 | 1503 | return $cal_id; |
@@ -1429,9 +1514,12 @@ discard block |
||
| 1429 | 1514 | */ |
| 1430 | 1515 | function check_status_perms($uid,$event) |
| 1431 | 1516 | { |
| 1432 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1517 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1518 | + { |
|
| 1519 | + // for contact we use the owner of the event |
|
| 1433 | 1520 | { |
| 1434 | 1521 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1522 | + } |
|
| 1435 | 1523 | |
| 1436 | 1524 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
| 1437 | 1525 | } |
@@ -1442,13 +1530,19 @@ discard block |
||
| 1442 | 1530 | return $access; |
| 1443 | 1531 | } |
| 1444 | 1532 | // no access or denied access because of category acl --> regular check |
| 1445 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1533 | + if (!is_numeric($uid)) |
|
| 1534 | + { |
|
| 1535 | + // this is eg. for resources (r123) |
|
| 1446 | 1536 | { |
| 1447 | 1537 | $resource = $this->resource_info($uid); |
| 1538 | + } |
|
| 1448 | 1539 | |
| 1449 | 1540 | return Acl::EDIT & $resource['rights']; |
| 1450 | 1541 | } |
| 1451 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1542 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1543 | + { |
|
| 1544 | + return false; |
|
| 1545 | + } |
|
| 1452 | 1546 | |
| 1453 | 1547 | // regular user and groups (need to check memberships too) |
| 1454 | 1548 | if (!isset($event['participants'][$uid])) |
@@ -1472,7 +1566,10 @@ discard block |
||
| 1472 | 1566 | */ |
| 1473 | 1567 | function check_cat_acl($right,$event) |
| 1474 | 1568 | { |
| 1475 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1569 | + if (!is_array($event)) |
|
| 1570 | + { |
|
| 1571 | + $event = $this->read($event); |
|
| 1572 | + } |
|
| 1476 | 1573 | |
| 1477 | 1574 | $ret = null; |
| 1478 | 1575 | if ($event['category']) |
@@ -1529,7 +1626,10 @@ discard block |
||
| 1529 | 1626 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1530 | 1627 | { |
| 1531 | 1628 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1532 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1629 | + if (!isset(self::$cat_rights_cache)) |
|
| 1630 | + { |
|
| 1631 | + self::get_cat_rights($cat_id); |
|
| 1632 | + } |
|
| 1533 | 1633 | |
| 1534 | 1634 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1535 | 1635 | { |
@@ -1541,7 +1641,10 @@ discard block |
||
| 1541 | 1641 | else |
| 1542 | 1642 | { |
| 1543 | 1643 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1544 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1644 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1645 | + { |
|
| 1646 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1647 | + } |
|
| 1545 | 1648 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1546 | 1649 | } |
| 1547 | 1650 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1574,7 +1677,10 @@ discard block |
||
| 1574 | 1677 | foreach($cat_rights as $uid => $value) |
| 1575 | 1678 | { |
| 1576 | 1679 | $all |= $value; |
| 1577 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1680 | + if (in_array($uid,$memberships)) |
|
| 1681 | + { |
|
| 1682 | + $own |= $value; |
|
| 1683 | + } |
|
| 1578 | 1684 | } |
| 1579 | 1685 | } |
| 1580 | 1686 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1621,13 +1727,16 @@ discard block |
||
| 1621 | 1727 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1622 | 1728 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1623 | 1729 | { |
| 1624 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1730 | + if ($status == 'R') |
|
| 1731 | + { |
|
| 1732 | + // remove alarms belonging to rejected participants |
|
| 1625 | 1733 | { |
| 1626 | 1734 | foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1627 | 1735 | { |
| 1628 | 1736 | if ((string)$alarm['owner'] === (string)$uid) |
| 1629 | 1737 | { |
| 1630 | 1738 | $this->so->delete_alarm($id); |
| 1739 | + } |
|
| 1631 | 1740 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1632 | 1741 | } |
| 1633 | 1742 | } |
@@ -1644,8 +1753,15 @@ discard block |
||
| 1644 | 1753 | |
| 1645 | 1754 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1646 | 1755 | { |
| 1647 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1648 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1756 | + if (!is_array($event)) |
|
| 1757 | + { |
|
| 1758 | + $event = $this->read($cal_id); |
|
| 1759 | + } |
|
| 1760 | + if (isset($recur_date)) |
|
| 1761 | + { |
|
| 1762 | + $event = $this->read($event['id'],$recur_date); |
|
| 1763 | + } |
|
| 1764 | + //re-read the actually edited recurring event |
|
| 1649 | 1765 | $this->send_update($status2msg[$status],$event['participants'],$event); |
| 1650 | 1766 | } |
| 1651 | 1767 | |
@@ -1668,12 +1784,16 @@ discard block |
||
| 1668 | 1784 | */ |
| 1669 | 1785 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1670 | 1786 | { |
| 1671 | - if (!isset($new_event['participants'])) return; |
|
| 1787 | + if (!isset($new_event['participants'])) |
|
| 1788 | + { |
|
| 1789 | + return; |
|
| 1790 | + } |
|
| 1672 | 1791 | |
| 1673 | 1792 | // check the old list against the new list |
| 1674 | 1793 | foreach ($old_event['participants'] as $userid => $status) |
| 1675 | - { |
|
| 1676 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1794 | + { |
|
| 1795 | + if (!isset($new_event['participants'][$userid])) |
|
| 1796 | + { |
|
| 1677 | 1797 | // Attendee will be deleted this way |
| 1678 | 1798 | $new_event['participants'][$userid] = 'G'; |
| 1679 | 1799 | } |
@@ -1756,7 +1876,10 @@ discard block |
||
| 1756 | 1876 | } |
| 1757 | 1877 | else |
| 1758 | 1878 | { |
| 1759 | - if (!($exception = $this->read($id))) continue; |
|
| 1879 | + if (!($exception = $this->read($id))) |
|
| 1880 | + { |
|
| 1881 | + continue; |
|
| 1882 | + } |
|
| 1760 | 1883 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1761 | 1884 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1762 | 1885 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1827,7 +1950,10 @@ discard block |
||
| 1827 | 1950 | $event_arr = $this->event2array($event); |
| 1828 | 1951 | foreach($event_arr as $key => $val) |
| 1829 | 1952 | { |
| 1830 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1953 | + if ($key == 'recur_type') |
|
| 1954 | + { |
|
| 1955 | + $key = 'repetition'; |
|
| 1956 | + } |
|
| 1831 | 1957 | $details[$key] = $val['data']; |
| 1832 | 1958 | } |
| 1833 | 1959 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1836,7 +1962,10 @@ discard block |
||
| 1836 | 1962 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
| 1837 | 1963 | $link = $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit&cal_id='.$event['id'].'&date='.$eventStart_arr['full'].'&no_popup=1&ajax=true'; |
| 1838 | 1964 | // if url is only a path, try guessing the rest ;-) |
| 1839 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
| 1965 | + if ($link[0] == '/') |
|
| 1966 | + { |
|
| 1967 | + $link = Api\Framework::getUrl($link); |
|
| 1968 | + } |
|
| 1840 | 1969 | $event_arr['link']['data'] = $details['link'] = $link; |
| 1841 | 1970 | |
| 1842 | 1971 | /* this is needed for notification-app |
@@ -2009,7 +2138,10 @@ discard block |
||
| 2009 | 2138 | */ |
| 2010 | 2139 | function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
| 2011 | 2140 | { |
| 2012 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 2141 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 2142 | + { |
|
| 2143 | + return; |
|
| 2144 | + } |
|
| 2013 | 2145 | |
| 2014 | 2146 | $time = new Api\DateTime($event['start']); |
| 2015 | 2147 | if(!is_array($event['alarm'])) |
@@ -2092,7 +2224,10 @@ discard block |
||
| 2092 | 2224 | if (is_array($old_event) || $old_event > 0) |
| 2093 | 2225 | { |
| 2094 | 2226 | // preserve categories without users read access |
| 2095 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2227 | + if (!is_array($old_event)) |
|
| 2228 | + { |
|
| 2229 | + $old_event = $this->read($old_event); |
|
| 2230 | + } |
|
| 2096 | 2231 | $old_categories = explode(',',$old_event['category']); |
| 2097 | 2232 | $old_cats_preserve = array(); |
| 2098 | 2233 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2183,7 +2318,10 @@ discard block |
||
| 2183 | 2318 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 2184 | 2319 | } |
| 2185 | 2320 | |
| 2186 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2321 | + if (!isset($event['recurrence'])) |
|
| 2322 | + { |
|
| 2323 | + $event['recurrence'] = 0; |
|
| 2324 | + } |
|
| 2187 | 2325 | |
| 2188 | 2326 | if ($filter == 'master') |
| 2189 | 2327 | { |
@@ -2237,19 +2375,26 @@ discard block |
||
| 2237 | 2375 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2238 | 2376 | } |
| 2239 | 2377 | } |
| 2240 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2378 | + } |
|
| 2379 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2241 | 2380 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2242 | 2381 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2243 | 2382 | { |
| 2244 | 2383 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2245 | 2384 | } |
| 2246 | 2385 | } |
| 2247 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2386 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2387 | + { |
|
| 2388 | + return $matchingEvents; |
|
| 2389 | + } |
|
| 2248 | 2390 | } |
| 2249 | 2391 | unset($event['id']); |
| 2250 | 2392 | |
| 2251 | 2393 | // No chance to find a master without [U]ID |
| 2252 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2394 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2395 | + { |
|
| 2396 | + return $matchingEvents; |
|
| 2397 | + } |
|
| 2253 | 2398 | |
| 2254 | 2399 | // only query calendars of users, we have READ-grants from |
| 2255 | 2400 | $users = array(); |
@@ -2258,17 +2403,23 @@ discard block |
||
| 2258 | 2403 | $user = trim($user); |
| 2259 | 2404 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
| 2260 | 2405 | { |
| 2261 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2406 | + if ($user && !in_array($user,$users)) |
|
| 2407 | + { |
|
| 2408 | + // already added? |
|
| 2262 | 2409 | { |
| 2263 | 2410 | $users[] = $user; |
| 2264 | 2411 | } |
| 2412 | + } |
|
| 2265 | 2413 | } |
| 2266 | 2414 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2267 | 2415 | { |
| 2268 | 2416 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2269 | 2417 | } |
| 2270 | 2418 | // the further code is only for real users |
| 2271 | - if (!is_numeric($user)) continue; |
|
| 2419 | + if (!is_numeric($user)) |
|
| 2420 | + { |
|
| 2421 | + continue; |
|
| 2422 | + } |
|
| 2272 | 2423 | |
| 2273 | 2424 | // for groups we have to include the members |
| 2274 | 2425 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2348,7 +2499,10 @@ discard block |
||
| 2348 | 2499 | } |
| 2349 | 2500 | foreach ($matchFields as $key) |
| 2350 | 2501 | { |
| 2351 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2502 | + if (isset($event[$key])) |
|
| 2503 | + { |
|
| 2504 | + $query['cal_'.$key] = $event[$key]; |
|
| 2505 | + } |
|
| 2352 | 2506 | } |
| 2353 | 2507 | } |
| 2354 | 2508 | |
@@ -2388,7 +2542,10 @@ discard block |
||
| 2388 | 2542 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2389 | 2543 | } |
| 2390 | 2544 | |
| 2391 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2545 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2546 | + { |
|
| 2547 | + continue; |
|
| 2548 | + } |
|
| 2392 | 2549 | |
| 2393 | 2550 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2394 | 2551 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2555,13 +2712,16 @@ discard block |
||
| 2555 | 2712 | foreach ($event['participants'] as $attendee => $status) |
| 2556 | 2713 | { |
| 2557 | 2714 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2558 | - $attendee != $egwEvent['owner']) // || |
|
| 2715 | + $attendee != $egwEvent['owner']) |
|
| 2716 | + { |
|
| 2717 | + // || |
|
| 2559 | 2718 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2560 | 2719 | { |
| 2561 | 2720 | if ($this->log) |
| 2562 | 2721 | { |
| 2563 | 2722 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2564 | 2723 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2724 | + } |
|
| 2565 | 2725 | } |
| 2566 | 2726 | continue 2; |
| 2567 | 2727 | } |
@@ -2883,7 +3043,10 @@ discard block |
||
| 2883 | 3043 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2884 | 3044 | { |
| 2885 | 3045 | // we convert here from server-time to timestamps in user-time! |
| 2886 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3046 | + if (isset($event[$ts])) |
|
| 3047 | + { |
|
| 3048 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3049 | + } |
|
| 2887 | 3050 | } |
| 2888 | 3051 | // same with the recur exceptions |
| 2889 | 3052 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2911,9 +3074,12 @@ discard block |
||
| 2911 | 3074 | */ |
| 2912 | 3075 | function purge($age) |
| 2913 | 3076 | { |
| 2914 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 3077 | + if (is_numeric($age) && $age > 0) |
|
| 3078 | + { |
|
| 3079 | + // just make sure bogus values dont delete everything |
|
| 2915 | 3080 | { |
| 2916 | 3081 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2917 | 3082 | } |
| 3083 | + } |
|
| 2918 | 3084 | } |
| 2919 | 3085 | } |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Egroupware |
|
| 4 | - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
| 5 | - * @link http://www.egroupware.org |
|
| 6 | - * @author Nathan Gray |
|
| 7 | - * @version $Id$ |
|
| 8 | - */ |
|
| 3 | + * Egroupware |
|
| 4 | + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
| 5 | + * @link http://www.egroupware.org |
|
| 6 | + * @author Nathan Gray |
|
| 7 | + * @version $Id$ |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | use EGroupware\Api; |
| 11 | 11 | use EGroupware\Api\Etemplate; |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * Set up what we know on the server side. |
|
| 26 | - * |
|
| 27 | - * Sending a first chunk of rows |
|
| 28 | - * |
|
| 29 | - * @param string $cname |
|
| 30 | - * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 31 | - */ |
|
| 25 | + * Set up what we know on the server side. |
|
| 26 | + * |
|
| 27 | + * Sending a first chunk of rows |
|
| 28 | + * |
|
| 29 | + * @param string $cname |
|
| 30 | + * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 31 | + */ |
|
| 32 | 32 | public function beforeSendToClient($cname, array $expand=null) |
| 33 | 33 | { |
| 34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
@@ -33,7 +33,10 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
| 35 | 35 | $value =& self::get_array(self::$request->content, $form_name, true); |
| 36 | - if(!is_array($value)) $value = array(); |
|
| 36 | + if(!is_array($value)) |
|
| 37 | + { |
|
| 38 | + $value = array(); |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | foreach($value as &$events) |
| 39 | 42 | { |
@@ -43,7 +46,10 @@ discard block |
||
| 43 | 46 | } |
| 44 | 47 | foreach($events as &$event) |
| 45 | 48 | { |
| 46 | - if(!is_array($event)) continue; |
|
| 49 | + if(!is_array($event)) |
|
| 50 | + { |
|
| 51 | + continue; |
|
| 52 | + } |
|
| 47 | 53 | foreach(array('start','end') as $date) |
| 48 | 54 | { |
| 49 | 55 | $event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z'); |