@@ -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'; |
@@ -2759,8 +2772,13 @@ discard block |
||
| 2759 | 2772 | function calendar_upgrade17_1() |
| 2760 | 2773 | { |
| 2761 | 2774 | // Update birthdays as events preference from boolean |
| 2762 | - $change = function($attr, $old_value, $owner) { |
|
| 2763 | - if (!isset($old_value)) return null; // do not set anything, if nothing was set before |
|
| 2775 | + $change = function($attr, $old_value, $owner) |
|
| 2776 | + { |
|
| 2777 | + if (!isset($old_value)) |
|
| 2778 | + { |
|
| 2779 | + return null; |
|
| 2780 | + } |
|
| 2781 | + // do not set anything, if nothing was set before |
|
| 2764 | 2782 | unset($attr, $owner); |
| 2765 | 2783 | return $old_value ? 'birthday' : 'none'; |
| 2766 | 2784 | }; |
@@ -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($result && count($result) >= 1) { |
|
| 255 | + if($result && 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 | |
@@ -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 | static $sent_groups = array(); |
| 712 | 733 | |
@@ -729,8 +750,16 @@ discard block |
||
| 729 | 750 | |
| 730 | 751 | $event['recure'] = $this->bo->recure2string($event); |
| 731 | 752 | |
| 732 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
| 733 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
| 753 | + if (empty($event['description'])) |
|
| 754 | + { |
|
| 755 | + $event['description'] = ' '; |
|
| 756 | + } |
|
| 757 | + // no description screws the titles horz. alignment |
|
| 758 | + if (empty($event['location'])) |
|
| 759 | + { |
|
| 760 | + $event['location'] = ' '; |
|
| 761 | + } |
|
| 762 | + // no location screws the owner horz. alignment |
|
| 734 | 763 | |
| 735 | 764 | // respect category permissions |
| 736 | 765 | if(!empty($event['category'])) |
@@ -828,8 +857,14 @@ discard block |
||
| 828 | 857 | if(!$timespan) |
| 829 | 858 | { |
| 830 | 859 | // Try to make time span into appropriate ranges to match |
| 831 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
| 832 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
| 860 | + if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) |
|
| 861 | + { |
|
| 862 | + $template = 'month'; |
|
| 863 | + } |
|
| 864 | + if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) |
|
| 865 | + { |
|
| 866 | + $template = 'week'; |
|
| 867 | + } |
|
| 833 | 868 | //error_log("Detected template $template"); |
| 834 | 869 | switch ($template) |
| 835 | 870 | { |
@@ -910,8 +945,7 @@ discard block |
||
| 910 | 945 | if (class_exists('EGroupware\\collabora\\Bo') && |
| 911 | 946 | $GLOBALS['egw_info']['user']['apps']['collabora'] && |
| 912 | 947 | $discovery = \EGroupware\collabora\Bo::discover() |
| 913 | - ) |
|
| 914 | - { |
|
| 948 | + ) { |
|
| 915 | 949 | $editable_mimes = $discovery; |
| 916 | 950 | } |
| 917 | 951 | } |
@@ -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 | |
@@ -308,7 +326,10 @@ discard block |
||
| 308 | 326 | $types_with_quantity = array(); |
| 309 | 327 | foreach($this->resources as $type => $data) |
| 310 | 328 | { |
| 311 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 329 | + if ($data['max_quantity']) |
|
| 330 | + { |
|
| 331 | + $types_with_quantity[] = $type; |
|
| 332 | + } |
|
| 312 | 333 | } |
| 313 | 334 | // get all NOT rejected participants and evtl. their quantity |
| 314 | 335 | $quantity = $users = array(); |
@@ -316,12 +337,19 @@ discard block |
||
| 316 | 337 | { |
| 317 | 338 | $q = $role = null; |
| 318 | 339 | calendar_so::split_status($status, $q, $role); |
| 319 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 340 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 341 | + { |
|
| 342 | + continue; |
|
| 343 | + } |
|
| 344 | + // ignore rejected or non-participants |
|
| 320 | 345 | |
| 321 | - if ($uid < 0) // group, check it's members too |
|
| 346 | + if ($uid < 0) |
|
| 347 | + { |
|
| 348 | + // group, check it's members too |
|
| 322 | 349 | { |
| 323 | 350 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
| 324 | 351 | } |
| 352 | + } |
|
| 325 | 353 | $users[] = $uid; |
| 326 | 354 | if (in_array($uid[0],$types_with_quantity)) |
| 327 | 355 | { |
@@ -352,18 +380,24 @@ discard block |
||
| 352 | 380 | $startts = $date->format('ts'); |
| 353 | 381 | |
| 354 | 382 | // skip past events or recurrences |
| 355 | - if ($startts+$duration < $this->now_su) continue; |
|
| 383 | + if ($startts+$duration < $this->now_su) |
|
| 384 | + { |
|
| 385 | + continue; |
|
| 386 | + } |
|
| 356 | 387 | |
| 357 | 388 | // abort check if configured limits are exceeded |
| 358 | 389 | if ($event['recur_type'] && |
| 359 | 390 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 360 | 391 | microtime(true) > $start+$max_check_time || // max check time exceeded |
| 361 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
| 392 | + $startts > $this->config['horizont'])) |
|
| 393 | + { |
|
| 394 | + // we are behind horizon for which recurrences are rendered |
|
| 362 | 395 | { |
| 363 | 396 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 364 | 397 | { |
| 365 | 398 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 366 | 399 | $checked, microtime(true)-$start, $date); |
| 400 | + } |
|
| 367 | 401 | } |
| 368 | 402 | $checked_excluding = $date; |
| 369 | 403 | break; |
@@ -387,10 +421,13 @@ discard block |
||
| 387 | 421 | { |
| 388 | 422 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 389 | 423 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 390 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 424 | + $overlap['non_blocking']) |
|
| 425 | + { |
|
| 426 | + // that's a non_blocking event |
|
| 391 | 427 | { |
| 392 | 428 | continue; |
| 393 | 429 | } |
| 430 | + } |
|
| 394 | 431 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 395 | 432 | { |
| 396 | 433 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -903,14 +940,20 @@ discard block |
||
| 903 | 940 | $startdate = new Api\DateTime($event['start']); |
| 904 | 941 | $enddate = new Api\DateTime($event['end']); |
| 905 | 942 | $modified = new Api\DateTime($event['modified']); |
| 906 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
| 943 | + if ($old_event) |
|
| 944 | + { |
|
| 945 | + $olddate = new Api\DateTime($old_event['start']); |
|
| 946 | + } |
|
| 907 | 947 | //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() : '')); |
| 908 | 948 | $owner_prefs = $ics = null; |
| 909 | 949 | foreach($to_notify as $userid => $statusid) |
| 910 | 950 | { |
| 911 | 951 | $res_info = $quantity = $role = null; |
| 912 | 952 | calendar_so::split_status($statusid, $quantity, $role); |
| 913 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 953 | + if ($this->debug > 0) |
|
| 954 | + { |
|
| 955 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 956 | + } |
|
| 914 | 957 | |
| 915 | 958 | if (!is_numeric($userid)) |
| 916 | 959 | { |
@@ -929,7 +972,11 @@ discard block |
||
| 929 | 972 | |
| 930 | 973 | if (!isset($userid)) |
| 931 | 974 | { |
| 932 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 975 | + if (empty($res_info['email'])) |
|
| 976 | + { |
|
| 977 | + continue; |
|
| 978 | + } |
|
| 979 | + // no way to notify |
|
| 933 | 980 | // check if event-owner wants non-EGroupware users notified |
| 934 | 981 | if (is_null($owner_prefs)) |
| 935 | 982 | { |
@@ -1003,7 +1050,10 @@ discard block |
||
| 1003 | 1050 | $details['to-lastname'] = isset($tln)? $tln: ''; |
| 1004 | 1051 | |
| 1005 | 1052 | // 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 |
| 1006 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1053 | + if (!isset($part_prefs['common']['tz'])) |
|
| 1054 | + { |
|
| 1055 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1056 | + } |
|
| 1007 | 1057 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 1008 | 1058 | $timeformat = $part_prefs['common']['timeformat']; |
| 1009 | 1059 | switch($timeformat) |
@@ -1038,9 +1088,12 @@ discard block |
||
| 1038 | 1088 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 1039 | 1089 | { |
| 1040 | 1090 | case 'ical': |
| 1041 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1091 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 1092 | + { |
|
| 1093 | + // need different ical for organizer notification |
|
| 1042 | 1094 | { |
| 1043 | 1095 | $calendar_ical = new calendar_ical(); |
| 1096 | + } |
|
| 1044 | 1097 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 1045 | 1098 | // we need to pass $event[id] so iCal class reads event again, |
| 1046 | 1099 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1056,7 +1109,10 @@ discard block |
||
| 1056 | 1109 | 'encoding' => '8bit', |
| 1057 | 1110 | 'type' => 'text/calendar; method='.$method, |
| 1058 | 1111 | ); |
| 1059 | - if ($m_type != $msg_type) unset($ics); |
|
| 1112 | + if ($m_type != $msg_type) |
|
| 1113 | + { |
|
| 1114 | + unset($ics); |
|
| 1115 | + } |
|
| 1060 | 1116 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 1061 | 1117 | // fall through |
| 1062 | 1118 | case 'extended': |
@@ -1116,11 +1172,16 @@ discard block |
||
| 1116 | 1172 | 'app' => 'calendar' |
| 1117 | 1173 | )); |
| 1118 | 1174 | } |
| 1119 | - if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1175 | + if ($m_type === MSG_ALARM) |
|
| 1176 | + { |
|
| 1177 | + $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1178 | + } |
|
| 1120 | 1179 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
| 1121 | 1180 | $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
| 1122 | 1181 | |
| 1123 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1182 | + if(is_array($attachment)) |
|
| 1183 | + { |
|
| 1184 | +$notification->set_attachments(array($attachment)); } |
|
| 1124 | 1185 | $notification->send(); |
| 1125 | 1186 | foreach(notifications::errors(true) as $error) |
| 1126 | 1187 | { |
@@ -1156,7 +1217,10 @@ discard block |
||
| 1156 | 1217 | Api\Translation::init(); |
| 1157 | 1218 | } |
| 1158 | 1219 | // restore timezone, in case we had to reset it to server-timezone |
| 1159 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1220 | + if ($restore_tz) |
|
| 1221 | + { |
|
| 1222 | + date_default_timezone_set($restore_tz); |
|
| 1223 | + } |
|
| 1160 | 1224 | |
| 1161 | 1225 | return true; |
| 1162 | 1226 | } |
@@ -1191,10 +1255,13 @@ discard block |
||
| 1191 | 1255 | { |
| 1192 | 1256 | $to_notify = $event['participants']; |
| 1193 | 1257 | } |
| 1194 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1258 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
| 1259 | + { |
|
| 1260 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1195 | 1261 | { |
| 1196 | 1262 | $to_notify[$alarm['owner']] = 'A'; |
| 1197 | 1263 | } |
| 1264 | + } |
|
| 1198 | 1265 | else |
| 1199 | 1266 | { |
| 1200 | 1267 | return False; // no rights |
@@ -1244,14 +1311,20 @@ discard block |
||
| 1244 | 1311 | if ($event['id']) |
| 1245 | 1312 | { |
| 1246 | 1313 | // invalidate the read-cache if it contains the event we store now |
| 1247 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1314 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1315 | + { |
|
| 1316 | + self::$cached_event = array(); |
|
| 1317 | + } |
|
| 1248 | 1318 | $old_event = $this->read($event['id'], $event['recurrence'], $ignore_acl, 'server'); |
| 1249 | 1319 | } |
| 1250 | 1320 | else |
| 1251 | 1321 | { |
| 1252 | 1322 | $old_event = null; |
| 1253 | 1323 | } |
| 1254 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1324 | + if (!isset($event['whole_day'])) |
|
| 1325 | + { |
|
| 1326 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1327 | + } |
|
| 1255 | 1328 | |
| 1256 | 1329 | // set recur-enddate/range-end to real end-date of last recurrence |
| 1257 | 1330 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
@@ -1328,7 +1401,10 @@ discard block |
||
| 1328 | 1401 | foreach($timestamps as $ts) |
| 1329 | 1402 | { |
| 1330 | 1403 | // we convert here from user-time to timestamps in server-time! |
| 1331 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1404 | + if (isset($event[$ts])) |
|
| 1405 | + { |
|
| 1406 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1407 | + } |
|
| 1332 | 1408 | } |
| 1333 | 1409 | // convert tzid name to integer tz_id, of set user default |
| 1334 | 1410 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1364,7 +1440,10 @@ discard block |
||
| 1364 | 1440 | if ($alarm['owner'] && isset($expanded['participants'])) |
| 1365 | 1441 | { |
| 1366 | 1442 | // Don't auto-delete alarm if for all users |
| 1367 | - if($alarm['all']) continue; |
|
| 1443 | + if($alarm['all']) |
|
| 1444 | + { |
|
| 1445 | + continue; |
|
| 1446 | + } |
|
| 1368 | 1447 | |
| 1369 | 1448 | $status = $expanded['participants'][$alarm['owner']]; |
| 1370 | 1449 | if (!isset($status) || calendar_so::split_status($status) === 'R') |
@@ -1385,7 +1464,10 @@ discard block |
||
| 1385 | 1464 | if (!isset($event['alarm'][$id])) |
| 1386 | 1465 | { |
| 1387 | 1466 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1388 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1467 | + if ($alarm['time'] < time()) |
|
| 1468 | + { |
|
| 1469 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1470 | + } |
|
| 1389 | 1471 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1390 | 1472 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1391 | 1473 | $old_event['participants'][$alarm['owner']]; |
@@ -1441,7 +1523,10 @@ discard block |
||
| 1441 | 1523 | |
| 1442 | 1524 | // Update history |
| 1443 | 1525 | $tracking = new calendar_tracking($this); |
| 1444 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1526 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1527 | + { |
|
| 1528 | + $event['id']=$cal_id; |
|
| 1529 | + } |
|
| 1445 | 1530 | $tracking->track($save_event, $old_event); |
| 1446 | 1531 | |
| 1447 | 1532 | return $cal_id; |
@@ -1458,9 +1543,12 @@ discard block |
||
| 1458 | 1543 | */ |
| 1459 | 1544 | function check_status_perms($uid,$event) |
| 1460 | 1545 | { |
| 1461 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1546 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1547 | + { |
|
| 1548 | + // for contact we use the owner of the event |
|
| 1462 | 1549 | { |
| 1463 | 1550 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1551 | + } |
|
| 1464 | 1552 | |
| 1465 | 1553 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
| 1466 | 1554 | } |
@@ -1471,13 +1559,19 @@ discard block |
||
| 1471 | 1559 | return $access; |
| 1472 | 1560 | } |
| 1473 | 1561 | // no access or denied access because of category acl --> regular check |
| 1474 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1562 | + if (!is_numeric($uid)) |
|
| 1563 | + { |
|
| 1564 | + // this is eg. for resources (r123) |
|
| 1475 | 1565 | { |
| 1476 | 1566 | $resource = $this->resource_info($uid); |
| 1567 | + } |
|
| 1477 | 1568 | |
| 1478 | 1569 | return Acl::EDIT & $resource['rights']; |
| 1479 | 1570 | } |
| 1480 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1571 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1572 | + { |
|
| 1573 | + return false; |
|
| 1574 | + } |
|
| 1481 | 1575 | |
| 1482 | 1576 | // regular user and groups (need to check memberships too) |
| 1483 | 1577 | if (!isset($event['participants'][$uid])) |
@@ -1501,7 +1595,10 @@ discard block |
||
| 1501 | 1595 | */ |
| 1502 | 1596 | function check_cat_acl($right,$event) |
| 1503 | 1597 | { |
| 1504 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1598 | + if (!is_array($event)) |
|
| 1599 | + { |
|
| 1600 | + $event = $this->read($event); |
|
| 1601 | + } |
|
| 1505 | 1602 | |
| 1506 | 1603 | $ret = null; |
| 1507 | 1604 | if ($event['category']) |
@@ -1558,7 +1655,10 @@ discard block |
||
| 1558 | 1655 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1559 | 1656 | { |
| 1560 | 1657 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1561 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1658 | + if (!isset(self::$cat_rights_cache)) |
|
| 1659 | + { |
|
| 1660 | + self::get_cat_rights($cat_id); |
|
| 1661 | + } |
|
| 1562 | 1662 | |
| 1563 | 1663 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1564 | 1664 | { |
@@ -1570,7 +1670,10 @@ discard block |
||
| 1570 | 1670 | else |
| 1571 | 1671 | { |
| 1572 | 1672 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1573 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1673 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1674 | + { |
|
| 1675 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1676 | + } |
|
| 1574 | 1677 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1575 | 1678 | } |
| 1576 | 1679 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1603,7 +1706,10 @@ discard block |
||
| 1603 | 1706 | foreach($cat_rights as $uid => $value) |
| 1604 | 1707 | { |
| 1605 | 1708 | $all |= $value; |
| 1606 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1709 | + if (in_array($uid,$memberships)) |
|
| 1710 | + { |
|
| 1711 | + $own |= $value; |
|
| 1712 | + } |
|
| 1607 | 1713 | } |
| 1608 | 1714 | } |
| 1609 | 1715 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1650,13 +1756,16 @@ discard block |
||
| 1650 | 1756 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1651 | 1757 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1652 | 1758 | { |
| 1653 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1759 | + if ($status == 'R') |
|
| 1760 | + { |
|
| 1761 | + // remove alarms belonging to rejected participants |
|
| 1654 | 1762 | { |
| 1655 | 1763 | foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1656 | 1764 | { |
| 1657 | 1765 | if ((string)$alarm['owner'] === (string)$uid) |
| 1658 | 1766 | { |
| 1659 | 1767 | $this->so->delete_alarm($id); |
| 1768 | + } |
|
| 1660 | 1769 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1661 | 1770 | } |
| 1662 | 1771 | } |
@@ -1673,8 +1782,15 @@ discard block |
||
| 1673 | 1782 | |
| 1674 | 1783 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1675 | 1784 | { |
| 1676 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1677 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1785 | + if (!is_array($event)) |
|
| 1786 | + { |
|
| 1787 | + $event = $this->read($cal_id); |
|
| 1788 | + } |
|
| 1789 | + if (isset($recur_date)) |
|
| 1790 | + { |
|
| 1791 | + $event = $this->read($event['id'],$recur_date); |
|
| 1792 | + } |
|
| 1793 | + //re-read the actually edited recurring event |
|
| 1678 | 1794 | $user_id = is_numeric($uid) ? (int)$uid : $uid; |
| 1679 | 1795 | $this->send_update($status2msg[$status],$event['participants'],$event, null, $user_id); |
| 1680 | 1796 | } |
@@ -1698,12 +1814,16 @@ discard block |
||
| 1698 | 1814 | */ |
| 1699 | 1815 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1700 | 1816 | { |
| 1701 | - if (!isset($new_event['participants'])) return; |
|
| 1817 | + if (!isset($new_event['participants'])) |
|
| 1818 | + { |
|
| 1819 | + return; |
|
| 1820 | + } |
|
| 1702 | 1821 | |
| 1703 | 1822 | // check the old list against the new list |
| 1704 | 1823 | foreach ($old_event['participants'] as $userid => $status) |
| 1705 | - { |
|
| 1706 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1824 | + { |
|
| 1825 | + if (!isset($new_event['participants'][$userid])) |
|
| 1826 | + { |
|
| 1707 | 1827 | // Attendee will be deleted this way |
| 1708 | 1828 | $new_event['participants'][$userid] = 'G'; |
| 1709 | 1829 | } |
@@ -1786,7 +1906,10 @@ discard block |
||
| 1786 | 1906 | } |
| 1787 | 1907 | else |
| 1788 | 1908 | { |
| 1789 | - if (!($exception = $this->read($id))) continue; |
|
| 1909 | + if (!($exception = $this->read($id))) |
|
| 1910 | + { |
|
| 1911 | + continue; |
|
| 1912 | + } |
|
| 1790 | 1913 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1791 | 1914 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1792 | 1915 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1857,7 +1980,10 @@ discard block |
||
| 1857 | 1980 | $event_arr = $this->event2array($event); |
| 1858 | 1981 | foreach($event_arr as $key => $val) |
| 1859 | 1982 | { |
| 1860 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1983 | + if ($key == 'recur_type') |
|
| 1984 | + { |
|
| 1985 | + $key = 'repetition'; |
|
| 1986 | + } |
|
| 1861 | 1987 | $details[$key] = $val['data']; |
| 1862 | 1988 | } |
| 1863 | 1989 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1866,7 +1992,10 @@ discard block |
||
| 1866 | 1992 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
| 1867 | 1993 | $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'; |
| 1868 | 1994 | // if url is only a path, try guessing the rest ;-) |
| 1869 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
| 1995 | + if ($link[0] == '/') |
|
| 1996 | + { |
|
| 1997 | + $link = Api\Framework::getUrl($link); |
|
| 1998 | + } |
|
| 1870 | 1999 | $event_arr['link']['data'] = $details['link'] = $link; |
| 1871 | 2000 | |
| 1872 | 2001 | /* this is needed for notification-app |
@@ -2039,7 +2168,10 @@ discard block |
||
| 2039 | 2168 | */ |
| 2040 | 2169 | function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
| 2041 | 2170 | { |
| 2042 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 2171 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 2172 | + { |
|
| 2173 | + return; |
|
| 2174 | + } |
|
| 2043 | 2175 | |
| 2044 | 2176 | $time = new Api\DateTime($event['start']); |
| 2045 | 2177 | if(!is_array($event['alarm'])) |
@@ -2122,7 +2254,10 @@ discard block |
||
| 2122 | 2254 | if (is_array($old_event) || $old_event > 0) |
| 2123 | 2255 | { |
| 2124 | 2256 | // preserve categories without users read access |
| 2125 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2257 | + if (!is_array($old_event)) |
|
| 2258 | + { |
|
| 2259 | + $old_event = $this->read($old_event); |
|
| 2260 | + } |
|
| 2126 | 2261 | $old_categories = explode(',',$old_event['category']); |
| 2127 | 2262 | $old_cats_preserve = array(); |
| 2128 | 2263 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2213,7 +2348,10 @@ discard block |
||
| 2213 | 2348 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 2214 | 2349 | } |
| 2215 | 2350 | |
| 2216 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2351 | + if (!isset($event['recurrence'])) |
|
| 2352 | + { |
|
| 2353 | + $event['recurrence'] = 0; |
|
| 2354 | + } |
|
| 2217 | 2355 | |
| 2218 | 2356 | if ($filter == 'master') |
| 2219 | 2357 | { |
@@ -2267,19 +2405,26 @@ discard block |
||
| 2267 | 2405 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2268 | 2406 | } |
| 2269 | 2407 | } |
| 2270 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2408 | + } |
|
| 2409 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2271 | 2410 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2272 | 2411 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2273 | 2412 | { |
| 2274 | 2413 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2275 | 2414 | } |
| 2276 | 2415 | } |
| 2277 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2416 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2417 | + { |
|
| 2418 | + return $matchingEvents; |
|
| 2419 | + } |
|
| 2278 | 2420 | } |
| 2279 | 2421 | unset($event['id']); |
| 2280 | 2422 | |
| 2281 | 2423 | // No chance to find a master without [U]ID |
| 2282 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2424 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2425 | + { |
|
| 2426 | + return $matchingEvents; |
|
| 2427 | + } |
|
| 2283 | 2428 | |
| 2284 | 2429 | // only query calendars of users, we have READ-grants from |
| 2285 | 2430 | $users = array(); |
@@ -2288,17 +2433,23 @@ discard block |
||
| 2288 | 2433 | $user = trim($user); |
| 2289 | 2434 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
| 2290 | 2435 | { |
| 2291 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2436 | + if ($user && !in_array($user,$users)) |
|
| 2437 | + { |
|
| 2438 | + // already added? |
|
| 2292 | 2439 | { |
| 2293 | 2440 | $users[] = $user; |
| 2294 | 2441 | } |
| 2442 | + } |
|
| 2295 | 2443 | } |
| 2296 | 2444 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2297 | 2445 | { |
| 2298 | 2446 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2299 | 2447 | } |
| 2300 | 2448 | // the further code is only for real users |
| 2301 | - if (!is_numeric($user)) continue; |
|
| 2449 | + if (!is_numeric($user)) |
|
| 2450 | + { |
|
| 2451 | + continue; |
|
| 2452 | + } |
|
| 2302 | 2453 | |
| 2303 | 2454 | // for groups we have to include the members |
| 2304 | 2455 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2378,7 +2529,10 @@ discard block |
||
| 2378 | 2529 | } |
| 2379 | 2530 | foreach ($matchFields as $key) |
| 2380 | 2531 | { |
| 2381 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2532 | + if (isset($event[$key])) |
|
| 2533 | + { |
|
| 2534 | + $query['cal_'.$key] = $event[$key]; |
|
| 2535 | + } |
|
| 2382 | 2536 | } |
| 2383 | 2537 | } |
| 2384 | 2538 | |
@@ -2418,7 +2572,10 @@ discard block |
||
| 2418 | 2572 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2419 | 2573 | } |
| 2420 | 2574 | |
| 2421 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2575 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2576 | + { |
|
| 2577 | + continue; |
|
| 2578 | + } |
|
| 2422 | 2579 | |
| 2423 | 2580 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2424 | 2581 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2585,13 +2742,16 @@ discard block |
||
| 2585 | 2742 | foreach ($event['participants'] as $attendee => $status) |
| 2586 | 2743 | { |
| 2587 | 2744 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2588 | - $attendee != $egwEvent['owner']) // || |
|
| 2745 | + $attendee != $egwEvent['owner']) |
|
| 2746 | + { |
|
| 2747 | + // || |
|
| 2589 | 2748 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2590 | 2749 | { |
| 2591 | 2750 | if ($this->log) |
| 2592 | 2751 | { |
| 2593 | 2752 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2594 | 2753 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2754 | + } |
|
| 2595 | 2755 | } |
| 2596 | 2756 | continue 2; |
| 2597 | 2757 | } |
@@ -2913,7 +3073,10 @@ discard block |
||
| 2913 | 3073 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2914 | 3074 | { |
| 2915 | 3075 | // we convert here from server-time to timestamps in user-time! |
| 2916 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3076 | + if (isset($event[$ts])) |
|
| 3077 | + { |
|
| 3078 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3079 | + } |
|
| 2917 | 3080 | } |
| 2918 | 3081 | // same with the recur exceptions |
| 2919 | 3082 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2941,10 +3104,13 @@ discard block |
||
| 2941 | 3104 | */ |
| 2942 | 3105 | function purge($age) |
| 2943 | 3106 | { |
| 2944 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 3107 | + if (is_numeric($age) && $age > 0) |
|
| 3108 | + { |
|
| 3109 | + // just make sure bogus values dont delete everything |
|
| 2945 | 3110 | { |
| 2946 | 3111 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2947 | 3112 | } |
| 3113 | + } |
|
| 2948 | 3114 | } |
| 2949 | 3115 | |
| 2950 | 3116 | /** |
@@ -2986,7 +3152,10 @@ discard block |
||
| 2986 | 3152 | case 'no': |
| 2987 | 3153 | break; |
| 2988 | 3154 | case 'startday': |
| 2989 | - if ($sameday) break; |
|
| 3155 | + if ($sameday) |
|
| 3156 | + { |
|
| 3157 | + break; |
|
| 3158 | + } |
|
| 2990 | 3159 | default: |
| 2991 | 3160 | $status_reset = true; |
| 2992 | 3161 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -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'); |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Do some magic with the participants and recurrance. |
|
| 136 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 137 | - * filter by it later. |
|
| 138 | - */ |
|
| 135 | + * Do some magic with the participants and recurrance. |
|
| 136 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 137 | + * filter by it later. |
|
| 138 | + */ |
|
| 139 | 139 | if(is_array($data['participants'])) |
| 140 | 140 | { |
| 141 | 141 | $participants = $data['participants']; |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | - * Do some magic with the participants and recurrance. |
|
| 199 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 200 | - * filter by it later. |
|
| 201 | - */ |
|
| 198 | + * Do some magic with the participants and recurrance. |
|
| 199 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 200 | + * filter by it later. |
|
| 201 | + */ |
|
| 202 | 202 | protected function alter_participants($participants) |
| 203 | 203 | { |
| 204 | 204 | $data = array(); |
@@ -1528,7 +1528,7 @@ |
||
| 1528 | 1528 | if (!$set_recurrences) |
| 1529 | 1529 | { |
| 1530 | 1530 | $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
| 1531 | - $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1531 | + $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1532 | 1532 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
| 1533 | 1533 | } |
| 1534 | 1534 | |
@@ -159,16 +159,32 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
| 161 | 161 | { |
| 162 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
|
| 162 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) |
|
| 163 | 163 | { |
| 164 | - return $this->cal_table; // no need / use for a view |
|
| 164 | + // using view without start-date is slower! |
|
| 165 | + { |
|
| 166 | + return $this->cal_table; |
|
| 167 | + } |
|
| 168 | + // no need / use for a view |
|
| 165 | 169 | } |
| 166 | 170 | |
| 167 | 171 | $where = array(); |
| 168 | - if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 169 | - if ($end) $where[] = "range_start<".(int)$end; |
|
| 170 | - if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 171 | - if ($_where) $where = array_merge($where, $_where); |
|
| 172 | + if (isset($deleted)) |
|
| 173 | + { |
|
| 174 | + $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 175 | + } |
|
| 176 | + if ($end) |
|
| 177 | + { |
|
| 178 | + $where[] = "range_start<".(int)$end; |
|
| 179 | + } |
|
| 180 | + if ($start) |
|
| 181 | + { |
|
| 182 | + $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 183 | + } |
|
| 184 | + if ($_where) |
|
| 185 | + { |
|
| 186 | + $where = array_merge($where, $_where); |
|
| 187 | + } |
|
| 172 | 188 | |
| 173 | 189 | $sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table"; |
| 174 | 190 | |
@@ -189,16 +205,32 @@ discard block |
||
| 189 | 205 | */ |
| 190 | 206 | protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
| 191 | 207 | { |
| 192 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
|
| 208 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) |
|
| 209 | + { |
|
| 210 | + // using view without start- AND end-date is slower! |
|
| 193 | 211 | { |
| 194 | - return $this->dates_table; // no need / use for a view |
|
| 212 | + return $this->dates_table; |
|
| 213 | + } |
|
| 214 | + // no need / use for a view |
|
| 195 | 215 | } |
| 196 | 216 | |
| 197 | 217 | $where = array(); |
| 198 | - if (isset($deleted)) $where['recur_exception'] = $deleted; |
|
| 199 | - if ($end) $where[] = "cal_start<".(int)$end; |
|
| 200 | - if ($start) $where[] = "cal_end>".(int)$start; |
|
| 201 | - if ($_where) $where = array_merge($where, $_where); |
|
| 218 | + if (isset($deleted)) |
|
| 219 | + { |
|
| 220 | + $where['recur_exception'] = $deleted; |
|
| 221 | + } |
|
| 222 | + if ($end) |
|
| 223 | + { |
|
| 224 | + $where[] = "cal_start<".(int)$end; |
|
| 225 | + } |
|
| 226 | + if ($start) |
|
| 227 | + { |
|
| 228 | + $where[] = "cal_end>".(int)$start; |
|
| 229 | + } |
|
| 230 | + if ($_where) |
|
| 231 | + { |
|
| 232 | + $where = array_merge($where, $_where); |
|
| 233 | + } |
|
| 202 | 234 | |
| 203 | 235 | // Api\Db::union uses Api\Db::select which check if join contains "WHERE" |
| 204 | 236 | // to support old join syntax like ", other_table WHERE ...", |
@@ -248,7 +280,10 @@ discard block |
||
| 248 | 280 | throw new Api\Exception\AssertionFailed("Unsupported value for parameters!"); |
| 249 | 281 | } |
| 250 | 282 | $where = is_array($params['query']) ? $params['query'] : array(); |
| 251 | - if ($cat_id) $where[] = $this->cat_filter($cat_id); |
|
| 283 | + if ($cat_id) |
|
| 284 | + { |
|
| 285 | + $where[] = $this->cat_filter($cat_id); |
|
| 286 | + } |
|
| 252 | 287 | $egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted'); |
| 253 | 288 | |
| 254 | 289 | $status_filter = $this->status_filter($filter, $params['enum_recuring']); |
@@ -269,7 +304,10 @@ discard block |
||
| 269 | 304 | if ($users) |
| 270 | 305 | { |
| 271 | 306 | // fix $users to also prefix system users and groups (with 'u') |
| 272 | - if (!is_array($users)) $users = $users ? (array)$users : array(); |
|
| 307 | + if (!is_array($users)) |
|
| 308 | + { |
|
| 309 | + $users = $users ? (array)$users : array(); |
|
| 310 | + } |
|
| 273 | 311 | foreach($users as &$uid) |
| 274 | 312 | { |
| 275 | 313 | $user_type = $user_id = null; |
@@ -289,15 +327,22 @@ discard block |
||
| 289 | 327 | $sql .= " AND\n ".$params['sql_filter']; |
| 290 | 328 | } |
| 291 | 329 | |
| 292 | - if ($params['order']) // only order if requested |
|
| 330 | + if ($params['order']) |
|
| 293 | 331 | { |
| 294 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 332 | + // only order if requested |
|
| 333 | + { |
|
| 334 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; |
|
| 335 | + } |
|
| 336 | + // gard against SQL injection |
|
| 295 | 337 | $sql .= "\nORDER BY ".$params['order']; |
| 296 | 338 | } |
| 297 | 339 | |
| 298 | - if ($offset === false) // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 340 | + if ($offset === false) |
|
| 341 | + { |
|
| 342 | + // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 299 | 343 | { |
| 300 | 344 | $offset = 0; |
| 345 | + } |
|
| 301 | 346 | $num_rows = -1; |
| 302 | 347 | } |
| 303 | 348 | $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
@@ -324,10 +369,13 @@ discard block |
||
| 324 | 369 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
| 325 | 370 | |
| 326 | 371 | $where = array(); |
| 327 | - if (is_scalar($ids) && !is_numeric($ids)) // a single uid |
|
| 372 | + if (is_scalar($ids) && !is_numeric($ids)) |
|
| 373 | + { |
|
| 374 | + // a single uid |
|
| 328 | 375 | { |
| 329 | 376 | // We want only the parents to match |
| 330 | 377 | $where['cal_uid'] = $ids; |
| 378 | + } |
|
| 331 | 379 | if ($read_recurrence) |
| 332 | 380 | { |
| 333 | 381 | $where['cal_recurrence'] = $recur_date; |
@@ -337,20 +385,26 @@ discard block |
||
| 337 | 385 | $where['cal_reference'] = 0; |
| 338 | 386 | } |
| 339 | 387 | } |
| 340 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
| 388 | + elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) |
|
| 389 | + { |
|
| 390 | + // one or more cal_id's |
|
| 341 | 391 | { |
| 342 | 392 | $where['cal_id'] = $ids; |
| 343 | 393 | } |
| 394 | + } |
|
| 344 | 395 | else // array with column => value pairs |
| 345 | 396 | { |
| 346 | 397 | $where = $ids; |
| 347 | 398 | unset($ids); // otherwise users get not read! |
| 348 | 399 | } |
| 349 | - if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
|
| 400 | + if (isset($where['cal_id'])) |
|
| 401 | + { |
|
| 402 | + // prevent non-unique column-name cal_id |
|
| 350 | 403 | { |
| 351 | 404 | $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
| 352 | 405 | 'cal_id' => $where['cal_id'], |
| 353 | 406 | )); |
| 407 | + } |
|
| 354 | 408 | unset($where['cal_id']); |
| 355 | 409 | } |
| 356 | 410 | if ((int) $recur_date && !$read_recurrence) |
@@ -406,10 +460,16 @@ discard block |
||
| 406 | 460 | $row['recur_exception'] = $row['alarm'] = array(); |
| 407 | 461 | $events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_'); |
| 408 | 462 | } |
| 409 | - if (!$events) return $events; |
|
| 463 | + if (!$events) |
|
| 464 | + { |
|
| 465 | + return $events; |
|
| 466 | + } |
|
| 410 | 467 | |
| 411 | 468 | $ids = array_keys($events); |
| 412 | - if (count($ids) == 1) $ids = $ids[0]; |
|
| 469 | + if (count($ids) == 1) |
|
| 470 | + { |
|
| 471 | + $ids = $ids[0]; |
|
| 472 | + } |
|
| 413 | 473 | |
| 414 | 474 | foreach ($events as &$event) |
| 415 | 475 | { |
@@ -483,10 +543,13 @@ discard block |
||
| 483 | 543 | 'cal_id' => $ids, |
| 484 | 544 | 'cal_recur_date' => $recur_date, |
| 485 | 545 | "cal_status NOT IN ('X','E')", |
| 486 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
| 546 | + ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) |
|
| 547 | + { |
|
| 548 | + // DESC puts users before resources and contacts |
|
| 487 | 549 | { |
| 488 | 550 | // combine all participant data in uid and status values |
| 489 | 551 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 552 | + } |
|
| 490 | 553 | $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
| 491 | 554 | |
| 492 | 555 | $events[$row['cal_id']]['participants'][$uid] = $status; |
@@ -543,7 +606,10 @@ discard block |
||
| 543 | 606 | $last_request = time(); |
| 544 | 607 | } |
| 545 | 608 | $signature = serialize(func_get_args()); |
| 546 | - if (isset($ctags[$signature])) return $ctags[$signature]; |
|
| 609 | + if (isset($ctags[$signature])) |
|
| 610 | + { |
|
| 611 | + return $ctags[$signature]; |
|
| 612 | + } |
|
| 547 | 613 | |
| 548 | 614 | $types = array(); |
| 549 | 615 | foreach((array)$users as $uid) |
@@ -576,7 +642,10 @@ discard block |
||
| 576 | 642 | // owner can only by users, no groups or resources |
| 577 | 643 | foreach($users as $key => $user) |
| 578 | 644 | { |
| 579 | - if (!($user > 0)) unset($users[$key]); |
|
| 645 | + if (!($user > 0)) |
|
| 646 | + { |
|
| 647 | + unset($users[$key]); |
|
| 648 | + } |
|
| 580 | 649 | } |
| 581 | 650 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
| 582 | 651 | $this->db->expression($this->cal_table, array( |
@@ -598,7 +667,10 @@ discard block |
||
| 598 | 667 | */ |
| 599 | 668 | function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
| 600 | 669 | { |
| 601 | - if (!is_array($cols)) $cols = explode(',', $cols); |
|
| 670 | + if (!is_array($cols)) |
|
| 671 | + { |
|
| 672 | + $cols = explode(',', $cols); |
|
| 673 | + } |
|
| 602 | 674 | |
| 603 | 675 | // special handling of cal_user_modified "pseudo" column |
| 604 | 676 | if (($key = array_search('cal_user_modified', $cols)) !== false) |
@@ -627,7 +699,10 @@ discard block |
||
| 627 | 699 | unset($key); // not used, but required by function signature |
| 628 | 700 | $val = (int) $val; |
| 629 | 701 | }); |
| 630 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
| 702 | + if (is_array($cat_id) && count($cat_id)==1) |
|
| 703 | + { |
|
| 704 | + $cat_id = $cat_id[0]; |
|
| 705 | + } |
|
| 631 | 706 | $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
| 632 | 707 | foreach($cats as $cat) |
| 633 | 708 | { |
@@ -686,10 +761,13 @@ discard block |
||
| 686 | 761 | $where[] = "$this->user_table.cal_status NOT IN ('X','E')"; |
| 687 | 762 | break; |
| 688 | 763 | default: |
| 689 | - if ($enum_recuring) // regular UI |
|
| 764 | + if ($enum_recuring) |
|
| 765 | + { |
|
| 766 | + // regular UI |
|
| 690 | 767 | { |
| 691 | 768 | $where[] = "$this->user_table.cal_status NOT IN ('R','X','E')"; |
| 692 | 769 | } |
| 770 | + } |
|
| 693 | 771 | else // CalDAV / eSync / iCal need to include 'E' = exceptions |
| 694 | 772 | { |
| 695 | 773 | $where[] = "$this->user_table.cal_status NOT IN ('R','X')"; |
@@ -831,7 +909,10 @@ discard block |
||
| 831 | 909 | $user_ids = array(); |
| 832 | 910 | foreach($ids as $user_id) |
| 833 | 911 | { |
| 834 | - if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
|
| 912 | + if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') |
|
| 913 | + { |
|
| 914 | + $user_ids[] = $user_id; |
|
| 915 | + } |
|
| 835 | 916 | } |
| 836 | 917 | $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
| 837 | 918 | } |
@@ -851,7 +932,10 @@ discard block |
||
| 851 | 932 | } |
| 852 | 933 | } |
| 853 | 934 | // this is only used, when we cannot use UNIONS |
| 854 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 935 | + if (!$useUnionQuery) |
|
| 936 | + { |
|
| 937 | + $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 938 | + } |
|
| 855 | 939 | |
| 856 | 940 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
| 857 | 941 | } |
@@ -870,7 +954,11 @@ discard block |
||
| 870 | 954 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
| 871 | 955 | } |
| 872 | 956 | } |
| 873 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 957 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) |
|
| 958 | + { |
|
| 959 | + $params['order'] = 'cal_start'; |
|
| 960 | + } |
|
| 961 | + // gard against SQL injection |
|
| 874 | 962 | |
| 875 | 963 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
| 876 | 964 | if (!$params['enum_recuring']) |
@@ -880,9 +968,15 @@ discard block |
||
| 880 | 968 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
| 881 | 969 | $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
| 882 | 970 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
| 883 | - if ($end) $where[] = (int)$end.' > range_start'; |
|
| 971 | + if ($end) |
|
| 972 | + { |
|
| 973 | + $where[] = (int)$end.' > range_start'; |
|
| 974 | + } |
|
| 884 | 975 | } |
| 885 | - elseif ($end) $where[] = (int)$end.' > cal_start'; |
|
| 976 | + elseif ($end) |
|
| 977 | + { |
|
| 978 | + $where[] = (int)$end.' > cal_start'; |
|
| 979 | + } |
|
| 886 | 980 | |
| 887 | 981 | if ($remove_rejected_by_user && $filter != 'everything') |
| 888 | 982 | { |
@@ -896,7 +990,10 @@ discard block |
||
| 896 | 990 | 'rejected_by_user.cal_status IS NULL', |
| 897 | 991 | "rejected_by_user.cal_status NOT IN ('R','X')", |
| 898 | 992 | ); |
| 899 | - if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 993 | + if ($filter == 'owner') |
|
| 994 | + { |
|
| 995 | + $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 996 | + } |
|
| 900 | 997 | $where[] = '('.implode(' OR ',$or_required).')'; |
| 901 | 998 | } |
| 902 | 999 | // using a time-range and deleted attribute limited view instead of full table |
@@ -939,7 +1036,10 @@ discard block |
||
| 939 | 1036 | if ($useUnionQuery) |
| 940 | 1037 | { |
| 941 | 1038 | // allow apps to supply participants and/or icons |
| 942 | - if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 1039 | + if (!isset($params['cols'])) |
|
| 1040 | + { |
|
| 1041 | + $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 1042 | + } |
|
| 943 | 1043 | |
| 944 | 1044 | // changed the original OR in the query into a union, to speed up the query execution under MySQL 5 |
| 945 | 1045 | // with time-range views benefit is now at best slim for huge tables or none at all! |
@@ -994,9 +1094,12 @@ discard block |
||
| 994 | 1094 | $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
| 995 | 1095 | } |
| 996 | 1096 | } |
| 997 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1097 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1098 | + { |
|
| 1099 | + // get the total too |
|
| 998 | 1100 | { |
| 999 | 1101 | $save_selects = $selects; |
| 1102 | + } |
|
| 1000 | 1103 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 1001 | 1104 | foreach(array_keys($selects) as $key) |
| 1002 | 1105 | { |
@@ -1007,14 +1110,20 @@ discard block |
||
| 1007 | 1110 | array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
| 1008 | 1111 | } |
| 1009 | 1112 | } |
| 1010 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1113 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1114 | + { |
|
| 1115 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1116 | + } |
|
| 1011 | 1117 | |
| 1012 | 1118 | $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
| 1013 | 1119 | |
| 1014 | 1120 | // restore original cols / selects |
| 1015 | 1121 | $selects = $save_selects; unset($save_selects); |
| 1016 | 1122 | } |
| 1017 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1123 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1124 | + { |
|
| 1125 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1126 | + } |
|
| 1018 | 1127 | |
| 1019 | 1128 | $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
| 1020 | 1129 | } |
@@ -1032,9 +1141,12 @@ discard block |
||
| 1032 | 1141 | 'table_def' => $cal_table_def, |
| 1033 | 1142 | )); |
| 1034 | 1143 | |
| 1035 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1144 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1145 | + { |
|
| 1146 | + // get the total too |
|
| 1036 | 1147 | { |
| 1037 | 1148 | $save_selects = $selects; |
| 1149 | + } |
|
| 1038 | 1150 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 1039 | 1151 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
| 1040 | 1152 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
@@ -1062,7 +1174,10 @@ discard block |
||
| 1062 | 1174 | foreach($rs as $row) |
| 1063 | 1175 | { |
| 1064 | 1176 | $id = $row['cal_id']; |
| 1065 | - if (is_numeric($id)) $ids[] = $id; |
|
| 1177 | + if (is_numeric($id)) |
|
| 1178 | + { |
|
| 1179 | + $ids[] = $id; |
|
| 1180 | + } |
|
| 1066 | 1181 | |
| 1067 | 1182 | if ($row['cal_recur_date']) |
| 1068 | 1183 | { |
@@ -1082,7 +1197,10 @@ discard block |
||
| 1082 | 1197 | $row['recur_exception'] = $row['alarm'] = array(); |
| 1083 | 1198 | |
| 1084 | 1199 | // compile a list of recurrences per cal_id |
| 1085 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1200 | + if (!in_array($id,(array)$recur_ids[$row['cal_id']])) |
|
| 1201 | + { |
|
| 1202 | + $recur_ids[$row['cal_id']][] = $id; |
|
| 1203 | + } |
|
| 1086 | 1204 | |
| 1087 | 1205 | $events[$id] = Api\Db::strip_array_keys($row,'cal_'); |
| 1088 | 1206 | } |
@@ -1101,10 +1219,16 @@ discard block |
||
| 1101 | 1219 | //'cal_id' => array_unique($ids), |
| 1102 | 1220 | 'cal_recur_date' => $recur_dates, |
| 1103 | 1221 | ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='', |
| 1104 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1222 | + $this->db->get_table_definitions('calendar',$this->user_table)) as $row) |
|
| 1223 | + { |
|
| 1224 | + // DESC puts users before resources and contacts |
|
| 1105 | 1225 | { |
| 1106 | 1226 | $id = $row['cal_id']; |
| 1107 | - if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
|
| 1227 | + } |
|
| 1228 | + if ($row['cal_recur_date']) |
|
| 1229 | + { |
|
| 1230 | + $id .= '-'.$row['cal_recur_date']; |
|
| 1231 | + } |
|
| 1108 | 1232 | |
| 1109 | 1233 | // combine all participant data in uid and status values |
| 1110 | 1234 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
@@ -1123,7 +1247,10 @@ discard block |
||
| 1123 | 1247 | } |
| 1124 | 1248 | |
| 1125 | 1249 | // set data, if recurrence is requested |
| 1126 | - if (isset($events[$id])) $events[$id]['participants'][$uid] = $status; |
|
| 1250 | + if (isset($events[$id])) |
|
| 1251 | + { |
|
| 1252 | + $events[$id]['participants'][$uid] = $status; |
|
| 1253 | + } |
|
| 1127 | 1254 | } |
| 1128 | 1255 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
| 1129 | 1256 | if (!$params['enum_recuring'] || !$params['daywise']) |
@@ -1139,7 +1266,10 @@ discard block |
||
| 1139 | 1266 | { |
| 1140 | 1267 | foreach($events as $id => $event) |
| 1141 | 1268 | { |
| 1142 | - if ($event['id'] == $row['cal_id']) break; |
|
| 1269 | + if ($event['id'] == $row['cal_id']) |
|
| 1270 | + { |
|
| 1271 | + break; |
|
| 1272 | + } |
|
| 1143 | 1273 | } |
| 1144 | 1274 | } |
| 1145 | 1275 | $events[$id]['recur_exception'][] = $row['cal_start']; |
@@ -1149,7 +1279,10 @@ discard block |
||
| 1149 | 1279 | if (!is_null($params['cfs'])) |
| 1150 | 1280 | { |
| 1151 | 1281 | $where = array('cal_id' => $ids); |
| 1152 | - if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
|
| 1282 | + if ($params['cfs']) |
|
| 1283 | + { |
|
| 1284 | + $where['cal_extra_name'] = $params['cfs']; |
|
| 1285 | + } |
|
| 1153 | 1286 | foreach($this->db->select($this->extra_table,'*',$where, |
| 1154 | 1287 | __LINE__,__FILE__,false,'','calendar') as $row) |
| 1155 | 1288 | { |
@@ -1169,14 +1302,20 @@ discard block |
||
| 1169 | 1302 | { |
| 1170 | 1303 | $event_start = $alarm['time'] + $alarm['offset']; |
| 1171 | 1304 | |
| 1172 | - if (isset($events[$cal_id])) // none recuring event |
|
| 1305 | + if (isset($events[$cal_id])) |
|
| 1306 | + { |
|
| 1307 | + // none recuring event |
|
| 1173 | 1308 | { |
| 1174 | 1309 | $events[$cal_id]['alarm'][$id] = $alarm; |
| 1175 | 1310 | } |
| 1176 | - elseif (isset($events[$cal_id.'-'.$event_start])) // recuring event |
|
| 1311 | + } |
|
| 1312 | + elseif (isset($events[$cal_id.'-'.$event_start])) |
|
| 1313 | + { |
|
| 1314 | + // recuring event |
|
| 1177 | 1315 | { |
| 1178 | 1316 | $events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm; |
| 1179 | 1317 | } |
| 1318 | + } |
|
| 1180 | 1319 | } |
| 1181 | 1320 | } |
| 1182 | 1321 | } |
@@ -1276,10 +1415,13 @@ discard block |
||
| 1276 | 1415 | } |
| 1277 | 1416 | foreach((array)$cols as $col) |
| 1278 | 1417 | { |
| 1279 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
| 1418 | + if (substr($col,0,7) == 'egw_cal') |
|
| 1419 | + { |
|
| 1420 | + // remove table name |
|
| 1280 | 1421 | { |
| 1281 | 1422 | $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
| 1282 | 1423 | } |
| 1424 | + } |
|
| 1283 | 1425 | if (isset($app_cols[$col])) |
| 1284 | 1426 | { |
| 1285 | 1427 | $return_cols[] = $app_cols[$col]; |
@@ -1373,7 +1515,11 @@ discard block |
||
| 1373 | 1515 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 1374 | 1516 | { |
| 1375 | 1517 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
| 1376 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1518 | + if (empty($minimum_uid_length) || $minimum_uid_length<=1) |
|
| 1519 | + { |
|
| 1520 | + $minimum_uid_length = 8; |
|
| 1521 | + } |
|
| 1522 | + // we just do not accept no uid, or uid way to short! |
|
| 1377 | 1523 | } |
| 1378 | 1524 | else |
| 1379 | 1525 | { |
@@ -1404,7 +1550,10 @@ discard block |
||
| 1404 | 1550 | } |
| 1405 | 1551 | } |
| 1406 | 1552 | // set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values! |
| 1407 | - if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
|
| 1553 | + if (isset($event['cal_start'])) |
|
| 1554 | + { |
|
| 1555 | + $event['range_start'] = $event['cal_start']; |
|
| 1556 | + } |
|
| 1408 | 1557 | if (isset($event['cal_end'])) |
| 1409 | 1558 | { |
| 1410 | 1559 | $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
@@ -1425,7 +1574,10 @@ discard block |
||
| 1425 | 1574 | $event['cal_category'] = implode(',',$categories); |
| 1426 | 1575 | |
| 1427 | 1576 | // make sure recurring events never reference to an other recurrent event |
| 1428 | - if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
|
| 1577 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1578 | + { |
|
| 1579 | + $event['cal_reference'] = 0; |
|
| 1580 | + } |
|
| 1429 | 1581 | |
| 1430 | 1582 | if ($cal_id) |
| 1431 | 1583 | { |
@@ -1442,7 +1594,10 @@ discard block |
||
| 1442 | 1594 | { |
| 1443 | 1595 | $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
| 1444 | 1596 | } |
| 1445 | - if (!is_null($etag)) $where['cal_etag'] = $etag; |
|
| 1597 | + if (!is_null($etag)) |
|
| 1598 | + { |
|
| 1599 | + $where['cal_etag'] = $etag; |
|
| 1600 | + } |
|
| 1446 | 1601 | |
| 1447 | 1602 | unset($event['cal_etag']); |
| 1448 | 1603 | $event[] = 'cal_etag=COALESCE(cal_etag,0)+1'; // always update the etag, even if none given to check |
@@ -1453,14 +1608,24 @@ discard block |
||
| 1453 | 1608 | { |
| 1454 | 1609 | return 0; // wrong etag, someone else updated the entry |
| 1455 | 1610 | } |
| 1456 | - if (!is_null($etag)) ++$etag; |
|
| 1611 | + if (!is_null($etag)) |
|
| 1612 | + { |
|
| 1613 | + ++$etag; |
|
| 1614 | + } |
|
| 1457 | 1615 | } |
| 1458 | 1616 | else |
| 1459 | 1617 | { |
| 1460 | 1618 | // new event |
| 1461 | - if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1619 | + if (!$event['cal_owner']) |
|
| 1620 | + { |
|
| 1621 | + $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1622 | + } |
|
| 1462 | 1623 | |
| 1463 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1624 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) |
|
| 1625 | + { |
|
| 1626 | + $event['cal_uid'] = ''; |
|
| 1627 | + } |
|
| 1628 | + // uid is NOT NULL! |
|
| 1464 | 1629 | |
| 1465 | 1630 | $event['cal_etag'] = $etag = 0; |
| 1466 | 1631 | $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
@@ -1612,8 +1777,7 @@ discard block |
||
| 1612 | 1777 | // recurrences need to be truncated |
| 1613 | 1778 | if((int)$event['recur_enddate'] > 0 && |
| 1614 | 1779 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
| 1615 | - ) |
|
| 1616 | - { |
|
| 1780 | + ) { |
|
| 1617 | 1781 | $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1618 | 1782 | $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1619 | 1783 | } |
@@ -1621,8 +1785,7 @@ discard block |
||
| 1621 | 1785 | // recurrences need to be expanded |
| 1622 | 1786 | if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
| 1623 | 1787 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
| 1624 | - ) |
|
| 1625 | - { |
|
| 1788 | + ) { |
|
| 1626 | 1789 | $set_recurrences = true; |
| 1627 | 1790 | $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
| 1628 | 1791 | } |
@@ -1771,12 +1934,18 @@ discard block |
||
| 1771 | 1934 | { |
| 1772 | 1935 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
| 1773 | 1936 | |
| 1774 | - if (!(int) $cal_id) return false; |
|
| 1937 | + if (!(int) $cal_id) |
|
| 1938 | + { |
|
| 1939 | + return false; |
|
| 1940 | + } |
|
| 1775 | 1941 | |
| 1776 | 1942 | if (!$old_start) |
| 1777 | 1943 | { |
| 1778 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1944 | + if ($change_since !== false) |
|
| 1945 | + { |
|
| 1946 | + $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1779 | 1947 | array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
| 1948 | + } |
|
| 1780 | 1949 | // if no recurrence found, create one with the new dates |
| 1781 | 1950 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
| 1782 | 1951 | { |
@@ -1878,7 +2047,10 @@ discard block |
||
| 1878 | 2047 | $user_type = $uid[0]; |
| 1879 | 2048 | $email = substr($uid, 1); |
| 1880 | 2049 | $matches = null; |
| 1881 | - if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1]; |
|
| 2050 | + if (preg_match('/<([^<>]+)>$/', $email, $matches)) |
|
| 2051 | + { |
|
| 2052 | + $email = $matches[1]; |
|
| 2053 | + } |
|
| 1882 | 2054 | $user_id = md5(trim(strtolower($email))); |
| 1883 | 2055 | } |
| 1884 | 2056 | else |
@@ -1898,8 +2070,14 @@ discard block |
||
| 1898 | 2070 | */ |
| 1899 | 2071 | static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
| 1900 | 2072 | { |
| 1901 | - if ((int)$quantity > 1) $status .= (int)$quantity; |
|
| 1902 | - if ($role != 'REQ-PARTICIPANT') $status .= $role; |
|
| 2073 | + if ((int)$quantity > 1) |
|
| 2074 | + { |
|
| 2075 | + $status .= (int)$quantity; |
|
| 2076 | + } |
|
| 2077 | + if ($role != 'REQ-PARTICIPANT') |
|
| 2078 | + { |
|
| 2079 | + $status .= $role; |
|
| 2080 | + } |
|
| 1903 | 2081 | |
| 1904 | 2082 | return $status; |
| 1905 | 2083 | } |
@@ -1920,8 +2098,14 @@ discard block |
||
| 1920 | 2098 | $matches = null; |
| 1921 | 2099 | if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
| 1922 | 2100 | { |
| 1923 | - if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
|
| 1924 | - if ($matches[2]) $role = $matches[2]; |
|
| 2101 | + if ((int)$matches[1] > 0) |
|
| 2102 | + { |
|
| 2103 | + $quantity = (int)$matches[1]; |
|
| 2104 | + } |
|
| 2105 | + if ($matches[2]) |
|
| 2106 | + { |
|
| 2107 | + $role = $matches[2]; |
|
| 2108 | + } |
|
| 1925 | 2109 | $status = $status[0]; |
| 1926 | 2110 | } |
| 1927 | 2111 | elseif ($status === true) |
@@ -2032,9 +2216,13 @@ discard block |
||
| 2032 | 2216 | } |
| 2033 | 2217 | } |
| 2034 | 2218 | |
| 2035 | - if (count($participants)) // participants which need to be added |
|
| 2219 | + if (count($participants)) |
|
| 2220 | + { |
|
| 2221 | + // participants which need to be added |
|
| 2036 | 2222 | { |
| 2037 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2223 | + if (!count($recurrences)) $recurrences[] = 0; |
|
| 2224 | + } |
|
| 2225 | + // insert the default recurrence |
|
| 2038 | 2226 | |
| 2039 | 2227 | $delete_deleted = array(); |
| 2040 | 2228 | |
@@ -2106,7 +2294,10 @@ discard block |
||
| 2106 | 2294 | return false; |
| 2107 | 2295 | } |
| 2108 | 2296 | |
| 2109 | - if (is_numeric($status)) $status = $status_code_short[$status]; |
|
| 2297 | + if (is_numeric($status)) |
|
| 2298 | + { |
|
| 2299 | + $status = $status_code_short[$status]; |
|
| 2300 | + } |
|
| 2110 | 2301 | |
| 2111 | 2302 | $uid = self::combine_user($user_type, $user_id); |
| 2112 | 2303 | $user_id_md5 = null; |
@@ -2126,16 +2317,25 @@ discard block |
||
| 2126 | 2317 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')'; |
| 2127 | 2318 | } |
| 2128 | 2319 | |
| 2129 | - if ($status == 'G') // remove group invitations, as we dont store them in the db |
|
| 2320 | + if ($status == 'G') |
|
| 2321 | + { |
|
| 2322 | + // remove group invitations, as we dont store them in the db |
|
| 2130 | 2323 | { |
| 2131 | 2324 | $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
| 2325 | + } |
|
| 2132 | 2326 | $ret = $this->db->affected_rows(); |
| 2133 | 2327 | } |
| 2134 | 2328 | else |
| 2135 | 2329 | { |
| 2136 | 2330 | $set = array('cal_status' => $status); |
| 2137 | - if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2138 | - if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
|
| 2331 | + if ($user_type == 'e' || $attendee) |
|
| 2332 | + { |
|
| 2333 | + $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2334 | + } |
|
| 2335 | + if (!is_null($role) && $role != 'REQ-PARTICIPANT') |
|
| 2336 | + { |
|
| 2337 | + $set['cal_role'] = $role; |
|
| 2338 | + } |
|
| 2139 | 2339 | $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
| 2140 | 2340 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2141 | 2341 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
@@ -2168,7 +2368,10 @@ discard block |
||
| 2168 | 2368 | { |
| 2169 | 2369 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
| 2170 | 2370 | $update = array('cal_end' => $end); |
| 2171 | - if (isset($exception)) $update['recur_exception'] = $exception; |
|
| 2371 | + if (isset($exception)) |
|
| 2372 | + { |
|
| 2373 | + $update['recur_exception'] = $exception; |
|
| 2374 | + } |
|
| 2172 | 2375 | |
| 2173 | 2376 | $this->db->insert($this->dates_table, $update, array( |
| 2174 | 2377 | 'cal_id' => $cal_id, |
@@ -2183,7 +2386,11 @@ discard block |
||
| 2183 | 2386 | { |
| 2184 | 2387 | foreach($participants as $uid => $status) |
| 2185 | 2388 | { |
| 2186 | - if ($status == 'G') continue; // dont save group-invitations |
|
| 2389 | + if ($status == 'G') |
|
| 2390 | + { |
|
| 2391 | + continue; |
|
| 2392 | + } |
|
| 2393 | + // dont save group-invitations |
|
| 2187 | 2394 | |
| 2188 | 2395 | $type = ''; |
| 2189 | 2396 | $id = null; |
@@ -2412,7 +2619,10 @@ discard block |
||
| 2412 | 2619 | $alarm['time'] = $alarm['keep_time'] = time()+self::ALARM_KEEP_TIME; |
| 2413 | 2620 | } |
| 2414 | 2621 | // add an alarm uid, if none is given |
| 2415 | - if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2622 | + if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) |
|
| 2623 | + { |
|
| 2624 | + $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2625 | + } |
|
| 2416 | 2626 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
| 2417 | 2627 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
| 2418 | 2628 | if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner'], false, true)) |
@@ -2421,10 +2631,16 @@ discard block |
||
| 2421 | 2631 | } |
| 2422 | 2632 | |
| 2423 | 2633 | // update the modification information of the related event |
| 2424 | - if ($update_modified) $this->updateModified($cal_id, true); |
|
| 2634 | + if ($update_modified) |
|
| 2635 | + { |
|
| 2636 | + $this->updateModified($cal_id, true); |
|
| 2637 | + } |
|
| 2425 | 2638 | |
| 2426 | 2639 | // update cache, if used |
| 2427 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2640 | + if (isset(self::$alarm_cache)) |
|
| 2641 | + { |
|
| 2642 | + $this->read_alarms($cal_id, true); |
|
| 2643 | + } |
|
| 2428 | 2644 | |
| 2429 | 2645 | return $id; |
| 2430 | 2646 | } |
@@ -2447,7 +2663,10 @@ discard block |
||
| 2447 | 2663 | $this->async->cancel_timer($id); |
| 2448 | 2664 | } |
| 2449 | 2665 | // update cache, if used |
| 2450 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false); |
|
| 2666 | + if (isset(self::$alarm_cache)) |
|
| 2667 | + { |
|
| 2668 | + $this->read_alarms($cal_id, false); |
|
| 2669 | + } |
|
| 2451 | 2670 | } |
| 2452 | 2671 | return count($alarms); |
| 2453 | 2672 | } |
@@ -2470,7 +2689,10 @@ discard block |
||
| 2470 | 2689 | $ret = $this->async->cancel_timer($id); |
| 2471 | 2690 | |
| 2472 | 2691 | // update cache, if used |
| 2473 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2692 | + if (isset(self::$alarm_cache)) |
|
| 2693 | + { |
|
| 2694 | + $this->read_alarms($cal_id, true); |
|
| 2695 | + } |
|
| 2474 | 2696 | |
| 2475 | 2697 | return $ret; |
| 2476 | 2698 | } |
@@ -2494,11 +2716,14 @@ discard block |
||
| 2494 | 2716 | $user_id = null; |
| 2495 | 2717 | self::split_user($old_user,$user_type,$user_id); |
| 2496 | 2718 | |
| 2497 | - if ($user_type == 'u') // only accounts can be owners of events |
|
| 2719 | + if ($user_type == 'u') |
|
| 2720 | + { |
|
| 2721 | + // only accounts can be owners of events |
|
| 2498 | 2722 | { |
| 2499 | 2723 | foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
| 2500 | 2724 | { |
| 2501 | 2725 | $this->delete($row['cal_id']); |
| 2726 | + } |
|
| 2502 | 2727 | } |
| 2503 | 2728 | } |
| 2504 | 2729 | $this->db->delete($this->user_table,array( |
@@ -2526,11 +2751,14 @@ discard block |
||
| 2526 | 2751 | { |
| 2527 | 2752 | $ids[] = $row['cal_id']; |
| 2528 | 2753 | } |
| 2529 | - if ($ids) $this->db->delete($this->user_table,array( |
|
| 2754 | + if ($ids) |
|
| 2755 | + { |
|
| 2756 | + $this->db->delete($this->user_table,array( |
|
| 2530 | 2757 | 'cal_user_type' => 'u', |
| 2531 | 2758 | 'cal_user_id' => $old_user, |
| 2532 | 2759 | 'cal_id' => $ids, |
| 2533 | 2760 | ),__LINE__,__FILE__,'calendar'); |
| 2761 | + } |
|
| 2534 | 2762 | // now change participant in the rest to contain new user instead of old user |
| 2535 | 2763 | $this->db->update($this->user_table,array( |
| 2536 | 2764 | 'cal_user_id' => $new_user, |
@@ -2555,8 +2783,14 @@ discard block |
||
| 2555 | 2783 | { |
| 2556 | 2784 | $participant_status = array(); |
| 2557 | 2785 | $where = array('cal_id' => $cal_id); |
| 2558 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2559 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2786 | + if ($start != 0 && $end == 0) |
|
| 2787 | + { |
|
| 2788 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2789 | + } |
|
| 2790 | + if ($start == 0 && $end != 0) |
|
| 2791 | + { |
|
| 2792 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2793 | + } |
|
| 2560 | 2794 | if ($start != 0 && $end != 0) |
| 2561 | 2795 | { |
| 2562 | 2796 | $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2567,7 +2801,10 @@ discard block |
||
| 2567 | 2801 | // inititalize the array |
| 2568 | 2802 | $participant_status[$row['cal_recur_date']] = null; |
| 2569 | 2803 | } |
| 2570 | - if (is_null($uid)) return $participant_status; |
|
| 2804 | + if (is_null($uid)) |
|
| 2805 | + { |
|
| 2806 | + return $participant_status; |
|
| 2807 | + } |
|
| 2571 | 2808 | $user_type = $user_id = null; |
| 2572 | 2809 | self::split_user($uid, $user_type, $user_id, true); |
| 2573 | 2810 | |
@@ -2576,8 +2813,14 @@ discard block |
||
| 2576 | 2813 | 'cal_user_type' => $user_type ? $user_type : 'u', |
| 2577 | 2814 | 'cal_user_id' => $user_id, |
| 2578 | 2815 | ); |
| 2579 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2580 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2816 | + if ($start != 0 && $end == 0) |
|
| 2817 | + { |
|
| 2818 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2819 | + } |
|
| 2820 | + if ($start == 0 && $end != 0) |
|
| 2821 | + { |
|
| 2822 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2823 | + } |
|
| 2581 | 2824 | if ($start != 0 && $end != 0) |
| 2582 | 2825 | { |
| 2583 | 2826 | $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2667,17 +2910,26 @@ discard block |
||
| 2667 | 2910 | */ |
| 2668 | 2911 | function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
| 2669 | 2912 | { |
| 2670 | - if (!is_array($event)) return false; |
|
| 2913 | + if (!is_array($event)) |
|
| 2914 | + { |
|
| 2915 | + return false; |
|
| 2916 | + } |
|
| 2671 | 2917 | $cal_id = (int) $event['id']; |
| 2672 | 2918 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2673 | 2919 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
| 2674 | - if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
|
| 2920 | + if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) |
|
| 2921 | + { |
|
| 2922 | + return false; |
|
| 2923 | + } |
|
| 2675 | 2924 | |
| 2676 | 2925 | $days = array(); |
| 2677 | 2926 | |
| 2678 | 2927 | $expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']); |
| 2679 | 2928 | |
| 2680 | - if ($filter == 'tz_only' && !$expand_all) return $days; |
|
| 2929 | + if ($filter == 'tz_only' && !$expand_all) |
|
| 2930 | + { |
|
| 2931 | + return $days; |
|
| 2932 | + } |
|
| 2681 | 2933 | |
| 2682 | 2934 | $remote = in_array($filter, array('tz_rrule', 'rrule')); |
| 2683 | 2935 | |
@@ -2720,7 +2972,10 @@ discard block |
||
| 2720 | 2972 | $remote_rrule->next_no_exception(); |
| 2721 | 2973 | } |
| 2722 | 2974 | $egw_rrule->next_no_exception(); |
| 2723 | - if (!$egw_rrule->valid()) return $days; |
|
| 2975 | + if (!$egw_rrule->valid()) |
|
| 2976 | + { |
|
| 2977 | + return $days; |
|
| 2978 | + } |
|
| 2724 | 2979 | } |
| 2725 | 2980 | $day = $egw_rrule->current(); |
| 2726 | 2981 | $locts = (int)Api\DateTime::to($day,'server'); |
@@ -2874,7 +3129,11 @@ discard block |
||
| 2874 | 3129 | } |
| 2875 | 3130 | } |
| 2876 | 3131 | |
| 2877 | - if (empty($participants)) return false; // occurrence does not exist at all yet |
|
| 3132 | + if (empty($participants)) |
|
| 3133 | + { |
|
| 3134 | + return false; |
|
| 3135 | + } |
|
| 3136 | + // occurrence does not exist at all yet |
|
| 2878 | 3137 | |
| 2879 | 3138 | foreach ($recurrence_zero as $uid => $status) |
| 2880 | 3139 | { |
@@ -2931,7 +3190,9 @@ discard block |
||
| 2931 | 3190 | } |
| 2932 | 3191 | if (!isset($participants[$uid]) |
| 2933 | 3192 | || $participants[$uid] != $status) |
| 2934 | - return true; |
|
| 3193 | + { |
|
| 3194 | + return true; |
|
| 3195 | + } |
|
| 2935 | 3196 | unset($participants[$uid]); |
| 2936 | 3197 | } |
| 2937 | 3198 | return (!empty($participants)); |
@@ -2945,7 +3206,10 @@ discard block |
||
| 2945 | 3206 | */ |
| 2946 | 3207 | function isWholeDay($event) |
| 2947 | 3208 | { |
| 2948 | - if (!isset($event['start']) || !isset($event['end'])) return false; |
|
| 3209 | + if (!isset($event['start']) || !isset($event['end'])) |
|
| 3210 | + { |
|
| 3211 | + return false; |
|
| 3212 | + } |
|
| 2949 | 3213 | |
| 2950 | 3214 | if (empty($event['tzid'])) |
| 2951 | 3215 | { |
@@ -3007,8 +3271,14 @@ discard block |
||
| 3007 | 3271 | */ |
| 3008 | 3272 | function updateModified($id, $update_master=false, $time=null, $modifier=null) |
| 3009 | 3273 | { |
| 3010 | - if (is_null($time) || !$time) $time = time(); |
|
| 3011 | - if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3274 | + if (is_null($time) || !$time) |
|
| 3275 | + { |
|
| 3276 | + $time = time(); |
|
| 3277 | + } |
|
| 3278 | + if (is_null($modifier)) |
|
| 3279 | + { |
|
| 3280 | + $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3281 | + } |
|
| 3012 | 3282 | |
| 3013 | 3283 | $this->db->update($this->cal_table, |
| 3014 | 3284 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |