@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | ); |
| 106 | 106 | if ($location == 'admin') |
| 107 | 107 | { |
| 108 | - display_section(self::$appname,$file); |
|
| 108 | + display_section(self::$appname,$file); |
|
| 109 | 109 | } |
| 110 | 110 | else |
| 111 | 111 | { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | 'yes' => lang('Yes') |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - $settings = array( |
|
| 131 | + $settings = array( |
|
| 132 | 132 | 'startfolder' => array( |
| 133 | 133 | 'type' => 'input', |
| 134 | 134 | 'name' => 'startfolder', |
@@ -85,7 +85,10 @@ discard block |
||
| 85 | 85 | $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
| 86 | 86 | display_sidebox(self::$appname,$title,$file); |
| 87 | 87 | } |
| 88 | - if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
|
| 88 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 89 | + { |
|
| 90 | + self::admin(self::$appname); |
|
| 91 | + } |
|
| 89 | 92 | } |
| 90 | 93 | |
| 91 | 94 | /** |
@@ -95,7 +98,10 @@ discard block |
||
| 95 | 98 | */ |
| 96 | 99 | static function admin($location = 'admin') |
| 97 | 100 | { |
| 98 | - if (is_array($location)) $location = $location['location']; |
|
| 101 | + if (is_array($location)) |
|
| 102 | + { |
|
| 103 | + $location = $location['location']; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $file = Array( |
| 101 | 107 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
@@ -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 |
@@ -211,7 +216,10 @@ discard block |
||
| 211 | 216 | // Add markers |
| 212 | 217 | foreach($file as $key => &$value) |
| 213 | 218 | { |
| 214 | - if(!$value) $value = ''; |
|
| 219 | + if(!$value) |
|
| 220 | + { |
|
| 221 | + $value = ''; |
|
| 222 | + } |
|
| 215 | 223 | $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
| 216 | 224 | } |
| 217 | 225 | if($app_placeholders) |
@@ -252,9 +260,15 @@ discard block |
||
| 252 | 260 | ); |
| 253 | 261 | foreach($fields as $name => $label) |
| 254 | 262 | { |
| 255 | - if (!($n&1)) echo '<tr>'; |
|
| 263 | + if (!($n&1)) |
|
| 264 | + { |
|
| 265 | + echo '<tr>'; |
|
| 266 | + } |
|
| 256 | 267 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
| 257 | - if ($n&1) echo "</tr>\n"; |
|
| 268 | + if ($n&1) |
|
| 269 | + { |
|
| 270 | + echo "</tr>\n"; |
|
| 271 | + } |
|
| 258 | 272 | $n++; |
| 259 | 273 | } |
| 260 | 274 | |
@@ -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'; |
@@ -1429,13 +1429,18 @@ discard block |
||
| 1429 | 1429 | function calendar_upgrade1_0_1_008() |
| 1430 | 1430 | { |
| 1431 | 1431 | $config_data = Api\Config::read('calendar'); |
| 1432 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1432 | + if (isset($config_data['fields'])) |
|
| 1433 | + { |
|
| 1434 | + // old custom fields |
|
| 1433 | 1435 | { |
| 1434 | 1436 | $customfields = array(); |
| 1437 | + } |
|
| 1435 | 1438 | $order = 0; |
| 1436 | 1439 | foreach($config_data['fields'] as $name => $data) |
| 1437 | 1440 | { |
| 1438 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1441 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1442 | + { |
|
| 1443 | + // real not-disabled custom field |
|
| 1439 | 1444 | { |
| 1440 | 1445 | $customfields[substr($name,1)] = array( |
| 1441 | 1446 | 'type' => 'text', |
@@ -1444,6 +1449,7 @@ discard block |
||
| 1444 | 1449 | 'order' => ($order += 10), |
| 1445 | 1450 | ); |
| 1446 | 1451 | } |
| 1452 | + } |
|
| 1447 | 1453 | } |
| 1448 | 1454 | if (count($customfields)) |
| 1449 | 1455 | { |
@@ -2584,9 +2590,12 @@ discard block |
||
| 2584 | 2590 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2585 | 2591 | 'cal_user_type' => 'e', |
| 2586 | 2592 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2587 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2593 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2594 | + { |
|
| 2595 | + // order A, T, U, X |
|
| 2588 | 2596 | { |
| 2589 | 2597 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2598 | + } |
|
| 2590 | 2599 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2591 | 2600 | array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
| 2592 | 2601 | __LINE__, __FILE__, 'calendar'); |
@@ -2736,8 +2745,12 @@ discard block |
||
| 2736 | 2745 | function calendar_upgrade16_1_002() |
| 2737 | 2746 | { |
| 2738 | 2747 | // Explicitly add months as showing list of events, no times |
| 2739 | - $change = function($attr, $old_value, $owner) { |
|
| 2740 | - if($owner == Api\Preferences::FORCED_ID) return; |
|
| 2748 | + $change = function($attr, $old_value, $owner) |
|
| 2749 | + { |
|
| 2750 | + if($owner == Api\Preferences::FORCED_ID) |
|
| 2751 | + { |
|
| 2752 | + return; |
|
| 2753 | + } |
|
| 2741 | 2754 | if(is_array($old_value) && !in_array('month', $old_value)) |
| 2742 | 2755 | { |
| 2743 | 2756 | $old_value[] = 'month'; |
@@ -483,15 +483,15 @@ discard block |
||
| 483 | 483 | { |
| 484 | 484 | $user = $this->resource_info($this->user); |
| 485 | 485 | $attributes['ATTENDEE'][] = 'mailto:' . $user['email']; |
| 486 | - $parameters['ATTENDEE'][] = array( |
|
| 487 | - 'CN' => $user['name'], |
|
| 488 | - 'ROLE' => 'REQ-PARTICIPANT', |
|
| 486 | + $parameters['ATTENDEE'][] = array( |
|
| 487 | + 'CN' => $user['name'], |
|
| 488 | + 'ROLE' => 'REQ-PARTICIPANT', |
|
| 489 | 489 | 'PARTSTAT' => 'NEEDS-ACTION', |
| 490 | 490 | 'CUTYPE' => 'INDIVIDUAL', |
| 491 | 491 | 'RSVP' => 'TRUE', |
| 492 | 492 | 'X-EGROUPWARE-UID' => (string)$this->user, |
| 493 | - ); |
|
| 494 | - $event['participants'][$this->user] = true; |
|
| 493 | + ); |
|
| 494 | + $event['participants'][$this->user] = true; |
|
| 495 | 495 | } |
| 496 | 496 | break; |
| 497 | 497 | case 'r': |
@@ -543,24 +543,24 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | - case 'ORGANIZER': |
|
| 547 | - if (!$organizerURL) |
|
| 548 | - { |
|
| 549 | - $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
| 550 | - . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
| 551 | - $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
| 552 | - if ($version == '1.0') |
|
| 553 | - { |
|
| 554 | - $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
| 555 | - } |
|
| 556 | - else |
|
| 557 | - { |
|
| 558 | - $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
| 559 | - } |
|
| 560 | - $organizerUID = $event['owner']; |
|
| 561 | - if (!isset($event['participants'][$event['owner']])) |
|
| 562 | - { |
|
| 563 | - $options = array( |
|
| 546 | + case 'ORGANIZER': |
|
| 547 | + if (!$organizerURL) |
|
| 548 | + { |
|
| 549 | + $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
| 550 | + . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
| 551 | + $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
| 552 | + if ($version == '1.0') |
|
| 553 | + { |
|
| 554 | + $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
| 555 | + } |
|
| 556 | + else |
|
| 557 | + { |
|
| 558 | + $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
| 559 | + } |
|
| 560 | + $organizerUID = $event['owner']; |
|
| 561 | + if (!isset($event['participants'][$event['owner']])) |
|
| 562 | + { |
|
| 563 | + $options = array( |
|
| 564 | 564 | 'ROLE' => 'CHAIR', |
| 565 | 565 | 'PARTSTAT' => 'DELEGATED', |
| 566 | 566 | 'CUTYPE' => 'INDIVIDUAL', |
@@ -570,20 +570,20 @@ discard block |
||
| 570 | 570 | if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail; |
| 571 | 571 | if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner']; |
| 572 | 572 | $attributes['ATTENDEE'][] = $organizerURL; |
| 573 | - $parameters['ATTENDEE'][] = $options; |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - // do NOT use ORGANIZER for events without further participants or a different organizer |
|
| 577 | - if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
| 578 | - { |
|
| 579 | - $attributes['ORGANIZER'] = $organizerURL; |
|
| 580 | - $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
| 581 | - if (!empty($organizerUID)) |
|
| 582 | - { |
|
| 583 | - $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
| 584 | - } |
|
| 585 | - } |
|
| 586 | - break; |
|
| 573 | + $parameters['ATTENDEE'][] = $options; |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + // do NOT use ORGANIZER for events without further participants or a different organizer |
|
| 577 | + if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
| 578 | + { |
|
| 579 | + $attributes['ORGANIZER'] = $organizerURL; |
|
| 580 | + $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
| 581 | + if (!empty($organizerUID)) |
|
| 582 | + { |
|
| 583 | + $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | + break; |
|
| 587 | 587 | |
| 588 | 588 | case 'DTSTART': |
| 589 | 589 | if (empty($event['whole_day'])) |
@@ -992,12 +992,12 @@ discard block |
||
| 992 | 992 | foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) |
| 993 | 993 | { |
| 994 | 994 | $valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset); |
| 995 | - $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
| 996 | - $parameters[$key][$valueID] : $parameters[$key], |
|
| 997 | - Api\Translation::charset(),$charset); |
|
| 998 | - $valuesData = (array) Api\Translation::convert($values[$key], |
|
| 999 | - Api\Translation::charset(),$charset); |
|
| 1000 | - $content = $valueData . implode(';', $valuesData); |
|
| 995 | + $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
| 996 | + $parameters[$key][$valueID] : $parameters[$key], |
|
| 997 | + Api\Translation::charset(),$charset); |
|
| 998 | + $valuesData = (array) Api\Translation::convert($values[$key], |
|
| 999 | + Api\Translation::charset(),$charset); |
|
| 1000 | + $content = $valueData . implode(';', $valuesData); |
|
| 1001 | 1001 | |
| 1002 | 1002 | if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) || |
| 1003 | 1003 | ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))) |
@@ -2233,7 +2233,7 @@ discard block |
||
| 2233 | 2233 | * @param string|resource $_vcalData |
| 2234 | 2234 | * @param string $principalURL ='' Used for CalDAV imports |
| 2235 | 2235 | * @param string $charset The encoding charset for $text. Defaults to |
| 2236 | - * utf-8 for new format, iso-8859-1 for old format. |
|
| 2236 | + * utf-8 for new format, iso-8859-1 for old format. |
|
| 2237 | 2237 | * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure |
| 2238 | 2238 | */ |
| 2239 | 2239 | function icaltoegw($_vcalData, $principalURL='', $charset=null) |
@@ -2784,10 +2784,10 @@ discard block |
||
| 2784 | 2784 | // fall throught |
| 2785 | 2785 | case 'ATTENDEE': |
| 2786 | 2786 | if (isset($attributes['params']['PARTSTAT'])) |
| 2787 | - { |
|
| 2788 | - $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
| 2789 | - } |
|
| 2790 | - if (isset($attributes['params']['STATUS'])) |
|
| 2787 | + { |
|
| 2788 | + $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
| 2789 | + } |
|
| 2790 | + if (isset($attributes['params']['STATUS'])) |
|
| 2791 | 2791 | { |
| 2792 | 2792 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
| 2793 | 2793 | if (empty($status)) $status = 'X'; |
@@ -3178,7 +3178,7 @@ discard block |
||
| 3178 | 3178 | array2string($event)."\n",3,$this->logfile); |
| 3179 | 3179 | } |
| 3180 | 3180 | //Horde::logMessage("vevent2egw:\n" . print_r($event, true), |
| 3181 | - // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
| 3181 | + // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
| 3182 | 3182 | return $event; |
| 3183 | 3183 | } |
| 3184 | 3184 | |
@@ -183,7 +183,10 @@ discard block |
||
| 183 | 183 | function __construct(&$_clientProperties = array()) |
| 184 | 184 | { |
| 185 | 185 | parent::__construct(); |
| 186 | - if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 186 | + if ($this->log) |
|
| 187 | + { |
|
| 188 | + $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 189 | + } |
|
| 187 | 190 | $this->clientProperties = $_clientProperties; |
| 188 | 191 | $this->vCalendar = new Horde_Icalendar; |
| 189 | 192 | $this->addressbook = new Api\Contacts; |
@@ -232,10 +235,14 @@ discard block |
||
| 232 | 235 | 'ATTACH' => 'attachments', |
| 233 | 236 | ); |
| 234 | 237 | |
| 235 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 238 | + if (!is_array($this->supportedFields)) |
|
| 239 | + { |
|
| 240 | + $this->setSupportedFields(); |
|
| 241 | + } |
|
| 236 | 242 | |
| 237 | 243 | if ($this->productManufacturer == '' ) |
| 238 | - { // syncevolution is broken |
|
| 244 | + { |
|
| 245 | +// syncevolution is broken |
|
| 239 | 246 | $version = '2.0'; |
| 240 | 247 | } |
| 241 | 248 | |
@@ -243,10 +250,16 @@ discard block |
||
| 243 | 250 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
| 244 | 251 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 245 | 252 | $vcal->setAttribute('VERSION', $version); |
| 246 | - if ($method) $vcal->setAttribute('METHOD', $method); |
|
| 253 | + if ($method) |
|
| 254 | + { |
|
| 255 | + $vcal->setAttribute('METHOD', $method); |
|
| 256 | + } |
|
| 247 | 257 | $events_exported = false; |
| 248 | 258 | |
| 249 | - if (!is_array($events)) $events = array($events); |
|
| 259 | + if (!is_array($events)) |
|
| 260 | + { |
|
| 261 | + $events = array($events); |
|
| 262 | + } |
|
| 250 | 263 | |
| 251 | 264 | $vtimezones_added = array(); |
| 252 | 265 | foreach ($events as $event) |
@@ -312,7 +325,10 @@ discard block |
||
| 312 | 325 | self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']); |
| 313 | 326 | } |
| 314 | 327 | |
| 315 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 328 | + if ($this->so->isWholeDay($event)) |
|
| 329 | + { |
|
| 330 | + $event['whole_day'] = true; |
|
| 331 | + } |
|
| 316 | 332 | |
| 317 | 333 | if ($this->log) |
| 318 | 334 | { |
@@ -323,7 +339,10 @@ discard block |
||
| 323 | 339 | |
| 324 | 340 | if ($recurrence) |
| 325 | 341 | { |
| 326 | - if (!($master = $this->read($event['id'], 0, true, 'server'))) continue; |
|
| 342 | + if (!($master = $this->read($event['id'], 0, true, 'server'))) |
|
| 343 | + { |
|
| 344 | + continue; |
|
| 345 | + } |
|
| 327 | 346 | |
| 328 | 347 | if (!isset($this->supportedFields['participants'])) |
| 329 | 348 | { |
@@ -380,7 +399,8 @@ discard block |
||
| 380 | 399 | if ($this->productManufacturer != 'file' && $this->uidExtension) |
| 381 | 400 | { |
| 382 | 401 | // Append UID to DESCRIPTION |
| 383 | - if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
|
| 402 | + if (!preg_match('/\[UID:.+\]/m', $event['description'])) |
|
| 403 | + { |
|
| 384 | 404 | $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
| 385 | 405 | } |
| 386 | 406 | } |
@@ -440,11 +460,21 @@ discard block |
||
| 440 | 460 | $quantity = $role = null; |
| 441 | 461 | calendar_so::split_status($status, $quantity, $role); |
| 442 | 462 | // do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant |
| 443 | - if (count($event['participants']) == 1 && $event['owner'] == $uid) continue; |
|
| 463 | + if (count($event['participants']) == 1 && $event['owner'] == $uid) |
|
| 464 | + { |
|
| 465 | + continue; |
|
| 466 | + } |
|
| 444 | 467 | |
| 445 | - if (!($info = $this->resource_info($uid))) continue; |
|
| 468 | + if (!($info = $this->resource_info($uid))) |
|
| 469 | + { |
|
| 470 | + continue; |
|
| 471 | + } |
|
| 446 | 472 | |
| 447 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
| 473 | + if (in_array($status, array('X','E'))) |
|
| 474 | + { |
|
| 475 | + continue; |
|
| 476 | + } |
|
| 477 | + // dont include deleted participants |
|
| 448 | 478 | |
| 449 | 479 | if ($this->log) |
| 450 | 480 | { |
@@ -523,24 +553,49 @@ discard block |
||
| 523 | 553 | } |
| 524 | 554 | // ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*} |
| 525 | 555 | $options = array(); |
| 526 | - if (!empty($participantCN)) $options['CN'] = $participantCN; |
|
| 527 | - if (!empty($role)) $options['ROLE'] = $role; |
|
| 528 | - if (!empty($status)) $options['PARTSTAT'] = $status; |
|
| 529 | - if (!empty($cutype)) $options['CUTYPE'] = $cutype; |
|
| 530 | - if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
|
| 556 | + if (!empty($participantCN)) |
|
| 557 | + { |
|
| 558 | + $options['CN'] = $participantCN; |
|
| 559 | + } |
|
| 560 | + if (!empty($role)) |
|
| 561 | + { |
|
| 562 | + $options['ROLE'] = $role; |
|
| 563 | + } |
|
| 564 | + if (!empty($status)) |
|
| 565 | + { |
|
| 566 | + $options['PARTSTAT'] = $status; |
|
| 567 | + } |
|
| 568 | + if (!empty($cutype)) |
|
| 569 | + { |
|
| 570 | + $options['CUTYPE'] = $cutype; |
|
| 571 | + } |
|
| 572 | + if (!empty($rsvp)) |
|
| 573 | + { |
|
| 574 | + $options['RSVP'] = $rsvp; |
|
| 575 | + } |
|
| 531 | 576 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
| 532 | 577 | { |
| 533 | 578 | $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
| 534 | 579 | } |
| 535 | - if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 536 | - if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 580 | + if ($info['type'] != 'e') |
|
| 581 | + { |
|
| 582 | + $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 583 | + } |
|
| 584 | + if ($quantity > 1) |
|
| 585 | + { |
|
| 586 | + $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 587 | + } |
|
| 537 | 588 | $attributes['ATTENDEE'][] = $participantURL; |
| 538 | 589 | $parameters['ATTENDEE'][] = $options; |
| 539 | 590 | } |
| 540 | 591 | break; |
| 541 | 592 | |
| 542 | 593 | case 'CLASS': |
| 543 | - if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
| 594 | + if ($event['public']) |
|
| 595 | + { |
|
| 596 | + continue; |
|
| 597 | + } |
|
| 598 | + // public is default, no need to export, fails CalDAVTester if added as default |
|
| 544 | 599 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
| 545 | 600 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
| 546 | 601 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -572,9 +627,18 @@ discard block |
||
| 572 | 627 | 'CUTYPE' => 'INDIVIDUAL', |
| 573 | 628 | //'RSVP' => 'FALSE', |
| 574 | 629 | ); |
| 575 | - if (!empty($organizerCN)) $options['CN'] = $organizerCN; |
|
| 576 | - if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail; |
|
| 577 | - if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 630 | + if (!empty($organizerCN)) |
|
| 631 | + { |
|
| 632 | + $options['CN'] = $organizerCN; |
|
| 633 | + } |
|
| 634 | + if (!empty($organizerEMail)) |
|
| 635 | + { |
|
| 636 | + $options['EMAIL'] = $organizerEMail; |
|
| 637 | + } |
|
| 638 | + if (!empty($event['owner'])) |
|
| 639 | + { |
|
| 640 | + $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 641 | + } |
|
| 578 | 642 | $attributes['ATTENDEE'][] = $organizerURL; |
| 579 | 643 | $parameters['ATTENDEE'][] = $options; |
| 580 | 644 | } |
@@ -603,9 +667,12 @@ discard block |
||
| 603 | 667 | { |
| 604 | 668 | // Hack for CalDAVTester to export duration instead of endtime |
| 605 | 669 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
| 606 | - $attributes['duration'] = $event['end'] - $event['start']; |
|
| 607 | - else |
|
| 608 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 670 | + { |
|
| 671 | + $attributes['duration'] = $event['end'] - $event['start']; |
|
| 672 | + } |
|
| 673 | + else { |
|
| 674 | + $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 675 | + } |
|
| 609 | 676 | } |
| 610 | 677 | else |
| 611 | 678 | { |
@@ -625,7 +692,11 @@ discard block |
||
| 625 | 692 | break; |
| 626 | 693 | |
| 627 | 694 | case 'RRULE': |
| 628 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
| 695 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 696 | + { |
|
| 697 | + break; |
|
| 698 | + } |
|
| 699 | + // no recuring event |
|
| 629 | 700 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
| 630 | 701 | $rrule = $rriter->generate_rrule($version); |
| 631 | 702 | if ($event['recur_enddate']) |
@@ -667,7 +738,10 @@ discard block |
||
| 667 | 738 | break; |
| 668 | 739 | |
| 669 | 740 | case 'EXDATE': |
| 670 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; |
|
| 741 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 742 | + { |
|
| 743 | + break; |
|
| 744 | + } |
|
| 671 | 745 | if (!empty($event['recur_exception'])) |
| 672 | 746 | { |
| 673 | 747 | if (empty($event['whole_day'])) |
@@ -694,14 +768,21 @@ discard block |
||
| 694 | 768 | ); |
| 695 | 769 | } |
| 696 | 770 | $event['recur_exception'] = $days; |
| 697 | - if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 771 | + if ($version != '1.0') |
|
| 772 | + { |
|
| 773 | + $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 774 | + } |
|
| 698 | 775 | } |
| 699 | 776 | $vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']); |
| 700 | 777 | } |
| 701 | 778 | break; |
| 702 | 779 | |
| 703 | 780 | case 'PRIORITY': |
| 704 | - if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 781 | + if (!$event['priority']) |
|
| 782 | + { |
|
| 783 | + continue; |
|
| 784 | + } |
|
| 785 | + // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 705 | 786 | if ($this->productManufacturer == 'funambol' && |
| 706 | 787 | (strpos($this->productName, 'outlook') !== false |
| 707 | 788 | || strpos($this->productName, 'pocket pc') !== false)) |
@@ -715,7 +796,11 @@ discard block |
||
| 715 | 796 | break; |
| 716 | 797 | |
| 717 | 798 | case 'TRANSP': |
| 718 | - if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 799 | + if (!$event['non_blocking']) |
|
| 800 | + { |
|
| 801 | + continue; |
|
| 802 | + } |
|
| 803 | + // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 719 | 804 | if ($version == '1.0') |
| 720 | 805 | { |
| 721 | 806 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -772,7 +857,11 @@ discard block |
||
| 772 | 857 | elseif ($event['recurrence'] && $event['reference']) |
| 773 | 858 | { |
| 774 | 859 | // $event['reference'] is a calendar_id, not a timestamp |
| 775 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
| 860 | + if (!($revent = $this->read($event['reference']))) |
|
| 861 | + { |
|
| 862 | + break; |
|
| 863 | + } |
|
| 864 | + // referenced event does not exist |
|
| 776 | 865 | |
| 777 | 866 | if (empty($revent['whole_day'])) |
| 778 | 867 | { |
@@ -898,7 +987,10 @@ discard block |
||
| 898 | 987 | foreach ((array)$event['alarm'] as $alarmData) |
| 899 | 988 | { |
| 900 | 989 | // skip over alarms that don't have the minimum required info |
| 901 | - if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue; |
|
| 990 | + if (!isset($alarmData['offset']) && !isset($alarmData['time'])) |
|
| 991 | + { |
|
| 992 | + continue; |
|
| 993 | + } |
|
| 902 | 994 | |
| 903 | 995 | // skip alarms not being set for all users and alarms owned by other users |
| 904 | 996 | if ($alarmData['all'] != true && $alarmData['owner'] != $this->user) |
@@ -915,7 +1007,10 @@ discard block |
||
| 915 | 1007 | |
| 916 | 1008 | if ($version == '1.0') |
| 917 | 1009 | { |
| 918 | - if ($event['title']) $description = $event['title']; |
|
| 1010 | + if ($event['title']) |
|
| 1011 | + { |
|
| 1012 | + $description = $event['title']; |
|
| 1013 | + } |
|
| 919 | 1014 | if ($description) |
| 920 | 1015 | { |
| 921 | 1016 | $values['DALARM']['snooze_time'] = ''; |
@@ -935,7 +1030,10 @@ discard block |
||
| 935 | 1030 | // VCalendar 2.0 / RFC 2445 |
| 936 | 1031 | |
| 937 | 1032 | // RFC requires DESCRIPTION for DISPLAY |
| 938 | - if (!$event['title'] && !$description) $description = 'Alarm'; |
|
| 1033 | + if (!$event['title'] && !$description) |
|
| 1034 | + { |
|
| 1035 | + $description = 'Alarm'; |
|
| 1036 | + } |
|
| 939 | 1037 | |
| 940 | 1038 | /* Disabling for now |
| 941 | 1039 | // Lightning infinitly pops up alarms for recuring events, if the only use an offset |
@@ -1126,13 +1224,20 @@ discard block |
||
| 1126 | 1224 | $this->events_imported = 0; |
| 1127 | 1225 | $replace = $delete_exceptions= false; |
| 1128 | 1226 | |
| 1129 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 1227 | + if (!is_array($this->supportedFields)) |
|
| 1228 | + { |
|
| 1229 | + $this->setSupportedFields(); |
|
| 1230 | + } |
|
| 1130 | 1231 | |
| 1131 | 1232 | if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset))) |
| 1132 | 1233 | { |
| 1133 | 1234 | return false; |
| 1134 | 1235 | } |
| 1135 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1236 | + if (!is_array($events)) |
|
| 1237 | + { |
|
| 1238 | + $cal_id = -1; |
|
| 1239 | + } |
|
| 1240 | + // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1136 | 1241 | |
| 1137 | 1242 | if ($cal_id > 0) |
| 1138 | 1243 | { |
@@ -1140,8 +1245,14 @@ discard block |
||
| 1140 | 1245 | { |
| 1141 | 1246 | $replace = $recur_date == 0; |
| 1142 | 1247 | $events[0]['id'] = $cal_id; |
| 1143 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
| 1144 | - if ($recur_date) $events[0]['recurrence'] = $recur_date; |
|
| 1248 | + if (!is_null($etag)) |
|
| 1249 | + { |
|
| 1250 | + $events[0]['etag'] = (int) $etag; |
|
| 1251 | + } |
|
| 1252 | + if ($recur_date) |
|
| 1253 | + { |
|
| 1254 | + $events[0]['recurrence'] = $recur_date; |
|
| 1255 | + } |
|
| 1145 | 1256 | } |
| 1146 | 1257 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
| 1147 | 1258 | ($eventId = array_shift($foundEvent)) && |
@@ -1149,7 +1260,10 @@ discard block |
||
| 1149 | 1260 | { |
| 1150 | 1261 | foreach ($events as $k => $event) |
| 1151 | 1262 | { |
| 1152 | - if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1263 | + if (!isset($event['uid'])) |
|
| 1264 | + { |
|
| 1265 | + $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1266 | + } |
|
| 1153 | 1267 | } |
| 1154 | 1268 | } |
| 1155 | 1269 | } |
@@ -1179,10 +1293,17 @@ discard block |
||
| 1179 | 1293 | $msg = null; |
| 1180 | 1294 | foreach ($events as $event) |
| 1181 | 1295 | { |
| 1182 | - if (!is_array($event)) continue; // the iterator may return false |
|
| 1296 | + if (!is_array($event)) |
|
| 1297 | + { |
|
| 1298 | + continue; |
|
| 1299 | + } |
|
| 1300 | + // the iterator may return false |
|
| 1183 | 1301 | ++$this->events_imported; |
| 1184 | 1302 | |
| 1185 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 1303 | + if ($this->so->isWholeDay($event)) |
|
| 1304 | + { |
|
| 1305 | + $event['whole_day'] = true; |
|
| 1306 | + } |
|
| 1186 | 1307 | if (is_array($event['category'])) |
| 1187 | 1308 | { |
| 1188 | 1309 | $event['category'] = $this->find_or_add_categories($event['category'], |
@@ -1219,7 +1340,10 @@ discard block |
||
| 1219 | 1340 | } |
| 1220 | 1341 | else |
| 1221 | 1342 | { |
| 1222 | - if (!($exception = $this->read($id))) continue; |
|
| 1343 | + if (!($exception = $this->read($id))) |
|
| 1344 | + { |
|
| 1345 | + continue; |
|
| 1346 | + } |
|
| 1223 | 1347 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1224 | 1348 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1225 | 1349 | $this->update($exception, true,true,false,true,$msg,$skip_notification); |
@@ -1308,7 +1432,10 @@ discard block |
||
| 1308 | 1432 | break; |
| 1309 | 1433 | |
| 1310 | 1434 | default: |
| 1311 | - if (!empty($value)) $event[$key] = $value; |
|
| 1435 | + if (!empty($value)) |
|
| 1436 | + { |
|
| 1437 | + $event[$key] = $value; |
|
| 1438 | + } |
|
| 1312 | 1439 | } |
| 1313 | 1440 | } |
| 1314 | 1441 | } |
@@ -1406,7 +1533,10 @@ discard block |
||
| 1406 | 1533 | else // common adjustments for new events |
| 1407 | 1534 | { |
| 1408 | 1535 | unset($event['id']); |
| 1409 | - if ($caldav_name) $event['caldav_name'] = $caldav_name; |
|
| 1536 | + if ($caldav_name) |
|
| 1537 | + { |
|
| 1538 | + $event['caldav_name'] = $caldav_name; |
|
| 1539 | + } |
|
| 1410 | 1540 | // set non blocking all day depending on the user setting |
| 1411 | 1541 | if (!empty($event['whole_day']) && $this->nonBlockingAllday) |
| 1412 | 1542 | { |
@@ -1454,7 +1584,10 @@ discard block |
||
| 1454 | 1584 | || !isset($event['participants'][$event['owner']])) |
| 1455 | 1585 | { |
| 1456 | 1586 | $status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR'); |
| 1457 | - if (!is_array($event['participants'])) $event['participants'] = array(); |
|
| 1587 | + if (!is_array($event['participants'])) |
|
| 1588 | + { |
|
| 1589 | + $event['participants'] = array(); |
|
| 1590 | + } |
|
| 1458 | 1591 | $event['participants'][$event['owner']] = $status; |
| 1459 | 1592 | } |
| 1460 | 1593 | else |
@@ -1607,7 +1740,10 @@ discard block |
||
| 1607 | 1740 | $occurence = $exception = false; |
| 1608 | 1741 | foreach ($event_info['master_event']['recur_exception'] as $exception) |
| 1609 | 1742 | { |
| 1610 | - if ($exception > $event['start']) break; |
|
| 1743 | + if ($exception > $event['start']) |
|
| 1744 | + { |
|
| 1745 | + break; |
|
| 1746 | + } |
|
| 1611 | 1747 | $occurence = $exception; |
| 1612 | 1748 | } |
| 1613 | 1749 | if (!$occurence) |
@@ -1697,12 +1833,15 @@ discard block |
||
| 1697 | 1833 | case 'SERIES-MASTER': |
| 1698 | 1834 | case 'SERIES-EXCEPTION': |
| 1699 | 1835 | case 'SERIES-EXCEPTION-PROPAGATE': |
| 1700 | - if (is_array($event_info['stored_event'])) // status update requires a stored event |
|
| 1836 | + if (is_array($event_info['stored_event'])) |
|
| 1837 | + { |
|
| 1838 | + // status update requires a stored event |
|
| 1701 | 1839 | { |
| 1702 | 1840 | if ($event_info['acl_edit']) |
| 1703 | 1841 | { |
| 1704 | 1842 | // update all participants if we have the right to do that |
| 1705 | 1843 | $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
| 1844 | + } |
|
| 1706 | 1845 | } |
| 1707 | 1846 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
| 1708 | 1847 | { |
@@ -1714,9 +1853,12 @@ discard block |
||
| 1714 | 1853 | break; |
| 1715 | 1854 | |
| 1716 | 1855 | case 'SERIES-PSEUDO-EXCEPTION': |
| 1717 | - if (is_array($event_info['master_event'])) // status update requires a stored master event |
|
| 1856 | + if (is_array($event_info['master_event'])) |
|
| 1857 | + { |
|
| 1858 | + // status update requires a stored master event |
|
| 1718 | 1859 | { |
| 1719 | 1860 | $recurrence = $this->date2usertime($event['recurrence']); |
| 1861 | + } |
|
| 1720 | 1862 | if ($event_info['acl_edit']) |
| 1721 | 1863 | { |
| 1722 | 1864 | // update all participants if we have the right to do that |
@@ -1824,7 +1966,10 @@ discard block |
||
| 1824 | 1966 | */ |
| 1825 | 1967 | public function sync_alarms(array &$event, array $old_alarms, $user) |
| 1826 | 1968 | { |
| 1827 | - if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1969 | + if ($this->debug) |
|
| 1970 | + { |
|
| 1971 | + error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1972 | + } |
|
| 1828 | 1973 | $modified = 0; |
| 1829 | 1974 | foreach($event['alarm'] as &$alarm) |
| 1830 | 1975 | { |
@@ -1846,29 +1991,56 @@ discard block |
||
| 1846 | 1991 | break; |
| 1847 | 1992 | } |
| 1848 | 1993 | } |
| 1849 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
| 1994 | + if ($this->debug) |
|
| 1995 | + { |
|
| 1996 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
| 1997 | + } |
|
| 1850 | 1998 | if (!empty($alarm['attrs']['X-LIC-ERROR'])) |
| 1851 | 1999 | { |
| 1852 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
| 2000 | + if ($this->debug) |
|
| 2001 | + { |
|
| 2002 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
| 2003 | + } |
|
| 1853 | 2004 | unset($alarm['attrs']['X-LIC-ERROR']); |
| 1854 | 2005 | } |
| 1855 | 2006 | // alarm not found --> add it |
| 1856 | 2007 | if (!$found) |
| 1857 | 2008 | { |
| 1858 | 2009 | $alarm['owner'] = $user; |
| 1859 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1860 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1861 | - if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 1862 | - if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 2010 | + if (!isset($alarm['time'])) |
|
| 2011 | + { |
|
| 2012 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 2013 | + } |
|
| 2014 | + if ($alarm['time'] < time()) |
|
| 2015 | + { |
|
| 2016 | + calendar_so::shift_alarm($event, $alarm); |
|
| 2017 | + } |
|
| 2018 | + if ($this->debug) |
|
| 2019 | + { |
|
| 2020 | + error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 2021 | + } |
|
| 2022 | + if ($event['id']) |
|
| 2023 | + { |
|
| 2024 | + $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 2025 | + } |
|
| 1863 | 2026 | ++$modified; |
| 1864 | 2027 | } |
| 1865 | 2028 | // existing alarm --> update it |
| 1866 | 2029 | else |
| 1867 | 2030 | { |
| 1868 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1869 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 2031 | + if (!isset($alarm['time'])) |
|
| 2032 | + { |
|
| 2033 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 2034 | + } |
|
| 2035 | + if ($alarm['time'] < time()) |
|
| 2036 | + { |
|
| 2037 | + calendar_so::shift_alarm($event, $alarm); |
|
| 2038 | + } |
|
| 1870 | 2039 | $alarm = array_merge($old_alarm, $alarm); |
| 1871 | - if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 2040 | + if ($this->debug) |
|
| 2041 | + { |
|
| 2042 | + error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 2043 | + } |
|
| 1872 | 2044 | $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
| 1873 | 2045 | ++$modified; |
| 1874 | 2046 | } |
@@ -1882,7 +2054,10 @@ discard block |
||
| 1882 | 2054 | unset($old_alarm[$id]); |
| 1883 | 2055 | continue; |
| 1884 | 2056 | } |
| 1885 | - if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 2057 | + if ($this->debug) |
|
| 2058 | + { |
|
| 2059 | + error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 2060 | + } |
|
| 1886 | 2061 | $this->delete_alarm($id); |
| 1887 | 2062 | ++$modified; |
| 1888 | 2063 | } |
@@ -2301,7 +2476,10 @@ discard block |
||
| 2301 | 2476 | array2string($_vcalData)."\n",3,$this->logfile); |
| 2302 | 2477 | } |
| 2303 | 2478 | |
| 2304 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 2479 | + if (!is_array($this->supportedFields)) |
|
| 2480 | + { |
|
| 2481 | + $this->setSupportedFields(); |
|
| 2482 | + } |
|
| 2305 | 2483 | |
| 2306 | 2484 | // we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0]) |
| 2307 | 2485 | if (is_resource($_vcalData)) |
@@ -2667,19 +2845,27 @@ discard block |
||
| 2667 | 2845 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2668 | 2846 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2])); |
| 2669 | 2847 | } |
| 2670 | - else break; |
|
| 2848 | + else { |
|
| 2849 | + break; |
|
| 2850 | + } |
|
| 2671 | 2851 | // fall-through |
| 2672 | 2852 | case 'DAILY': // 2.0 |
| 2673 | 2853 | $vcardData['recur_type'] = MCAL_RECUR_DAILY; |
| 2674 | - if (stripos($recurence, 'BYDAY') === false) break; |
|
| 2854 | + if (stripos($recurence, 'BYDAY') === false) |
|
| 2855 | + { |
|
| 2856 | + break; |
|
| 2857 | + } |
|
| 2675 | 2858 | // hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval |
| 2676 | 2859 | // fall-through |
| 2677 | 2860 | case 'W': |
| 2678 | 2861 | case 'WEEKLY': |
| 2679 | 2862 | $days = array(); |
| 2680 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
| 2863 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) |
|
| 2864 | + { |
|
| 2865 | + // 1.0 |
|
| 2681 | 2866 | { |
| 2682 | 2867 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2868 | + } |
|
| 2683 | 2869 | if (empty($recurenceMatches[2])) |
| 2684 | 2870 | { |
| 2685 | 2871 | $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
@@ -2692,7 +2878,10 @@ discard block |
||
| 2692 | 2878 | $repeatMatches = null; |
| 2693 | 2879 | if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
| 2694 | 2880 | { |
| 2695 | - if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2881 | + if ($repeatMatches[1]) |
|
| 2882 | + { |
|
| 2883 | + $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2884 | + } |
|
| 2696 | 2885 | } |
| 2697 | 2886 | else |
| 2698 | 2887 | { |
@@ -2701,9 +2890,12 @@ discard block |
||
| 2701 | 2890 | |
| 2702 | 2891 | $recur_days = $this->recur_days_1_0; |
| 2703 | 2892 | } |
| 2704 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
| 2893 | + elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) |
|
| 2894 | + { |
|
| 2895 | + // 2.0 |
|
| 2705 | 2896 | { |
| 2706 | 2897 | $days = explode(',',$recurenceMatches[1]); |
| 2898 | + } |
|
| 2707 | 2899 | $recur_days = $this->recur_days; |
| 2708 | 2900 | } |
| 2709 | 2901 | else // no day given, use the day of dtstart |
@@ -2762,7 +2954,10 @@ discard block |
||
| 2762 | 2954 | { |
| 2763 | 2955 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2764 | 2956 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
| 2765 | - } else break; |
|
| 2957 | + } |
|
| 2958 | + else { |
|
| 2959 | + break; |
|
| 2960 | + } |
|
| 2766 | 2961 | // fall-through |
| 2767 | 2962 | case 'YEARLY': // 2.0 |
| 2768 | 2963 | if (strpos($recurence, 'BYDAY') === false) |
@@ -2855,13 +3050,16 @@ discard block |
||
| 2855 | 3050 | // fall throught |
| 2856 | 3051 | case 'ATTENDEE': |
| 2857 | 3052 | if (isset($attributes['params']['PARTSTAT'])) |
| 2858 | - { |
|
| 3053 | + { |
|
| 2859 | 3054 | $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
| 2860 | 3055 | } |
| 2861 | 3056 | if (isset($attributes['params']['STATUS'])) |
| 2862 | - { |
|
| 3057 | + { |
|
| 2863 | 3058 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
| 2864 | - if (empty($status)) $status = 'X'; |
|
| 3059 | + if (empty($status)) |
|
| 3060 | + { |
|
| 3061 | + $status = 'X'; |
|
| 3062 | + } |
|
| 2865 | 3063 | } |
| 2866 | 3064 | else |
| 2867 | 3065 | { |
@@ -2921,7 +3119,10 @@ discard block |
||
| 2921 | 3119 | $uid = $this->user; |
| 2922 | 3120 | } |
| 2923 | 3121 | // check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY |
| 2924 | - if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3122 | + if (!$uid) |
|
| 3123 | + { |
|
| 3124 | + $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3125 | + } |
|
| 2925 | 3126 | |
| 2926 | 3127 | // try to find an email address |
| 2927 | 3128 | if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email'))) |
@@ -2989,7 +3190,10 @@ discard block |
||
| 2989 | 3190 | } |
| 2990 | 3191 | $status = 'U'; // keep the group |
| 2991 | 3192 | } |
| 2992 | - else continue; // can't find this group |
|
| 3193 | + else { |
|
| 3194 | + continue; |
|
| 3195 | + } |
|
| 3196 | + // can't find this group |
|
| 2993 | 3197 | } |
| 2994 | 3198 | elseif (empty($searcharray)) |
| 2995 | 3199 | { |
@@ -3048,7 +3252,9 @@ discard block |
||
| 3048 | 3252 | |
| 3049 | 3253 | try { |
| 3050 | 3254 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
| 3051 | - $component->getAttribute('ORGANIZER'); |
|
| 3255 | + { |
|
| 3256 | + $component->getAttribute('ORGANIZER'); |
|
| 3257 | + } |
|
| 3052 | 3258 | } |
| 3053 | 3259 | catch(Horde_Icalendar_Exception $e) |
| 3054 | 3260 | { |
@@ -3085,7 +3291,10 @@ discard block |
||
| 3085 | 3291 | } |
| 3086 | 3292 | break; |
| 3087 | 3293 | case 'CREATED': // will be written direct to the event |
| 3088 | - if ($event['modified']) break; |
|
| 3294 | + if ($event['modified']) |
|
| 3295 | + { |
|
| 3296 | + break; |
|
| 3297 | + } |
|
| 3089 | 3298 | // fall through |
| 3090 | 3299 | case 'LAST-MODIFIED': // will be written direct to the event |
| 3091 | 3300 | $event['modified'] = $attributes['value']; |
@@ -3106,7 +3315,11 @@ discard block |
||
| 3106 | 3315 | break; |
| 3107 | 3316 | |
| 3108 | 3317 | case 'ATTACH': |
| 3109 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
| 3318 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) |
|
| 3319 | + { |
|
| 3320 | + break; |
|
| 3321 | + } |
|
| 3322 | + // handeled by managed attachment code |
|
| 3110 | 3323 | // fall throught to store external attachment url |
| 3111 | 3324 | default: // X- attribute or other by EGroupware unsupported property |
| 3112 | 3325 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3237,7 +3450,10 @@ discard block |
||
| 3237 | 3450 | $event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength']; |
| 3238 | 3451 | } |
| 3239 | 3452 | |
| 3240 | - if ($this->calendarOwner) $event['owner'] = $this->calendarOwner; |
|
| 3453 | + if ($this->calendarOwner) |
|
| 3454 | + { |
|
| 3455 | + $event['owner'] = $this->calendarOwner; |
|
| 3456 | + } |
|
| 3241 | 3457 | |
| 3242 | 3458 | // parsing ATTACH attributes for managed attachments |
| 3243 | 3459 | $event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE'; |
@@ -3263,7 +3479,10 @@ discard block |
||
| 3263 | 3479 | $filter = $relax ? 'relax' : 'check'; |
| 3264 | 3480 | $event = array_shift($events); |
| 3265 | 3481 | $eventId = -1; |
| 3266 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 3482 | + if ($this->so->isWholeDay($event)) |
|
| 3483 | + { |
|
| 3484 | + $event['whole_day'] = true; |
|
| 3485 | + } |
|
| 3267 | 3486 | if ($contentID) |
| 3268 | 3487 | { |
| 3269 | 3488 | $parts = preg_split('/:/', $contentID); |
@@ -3316,8 +3535,16 @@ discard block |
||
| 3316 | 3535 | */ |
| 3317 | 3536 | function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
| 3318 | 3537 | { |
| 3319 | - if (!$start) $start = time(); // default now |
|
| 3320 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
| 3538 | + if (!$start) |
|
| 3539 | + { |
|
| 3540 | + $start = time(); |
|
| 3541 | + } |
|
| 3542 | + // default now |
|
| 3543 | + if (!$end) |
|
| 3544 | + { |
|
| 3545 | + $end = time() + 100*DAY_s; |
|
| 3546 | + } |
|
| 3547 | + // default next 100 days |
|
| 3321 | 3548 | |
| 3322 | 3549 | $vcal = new Horde_Icalendar; |
| 3323 | 3550 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
@@ -3339,10 +3566,13 @@ discard block |
||
| 3339 | 3566 | $attributes[$attr] = date('Ymd\THis', $value); |
| 3340 | 3567 | } |
| 3341 | 3568 | } |
| 3342 | - if (is_null($extra)) $extra = array( |
|
| 3569 | + if (is_null($extra)) |
|
| 3570 | + { |
|
| 3571 | + $extra = array( |
|
| 3343 | 3572 | 'URL' => $this->freebusy_url($user), |
| 3344 | 3573 | 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
| 3345 | 3574 | ); |
| 3575 | + } |
|
| 3346 | 3576 | foreach($attributes+$extra as $attr => $value) |
| 3347 | 3577 | { |
| 3348 | 3578 | $vfreebusy->setAttribute($attr, $value); |
@@ -3358,12 +3588,21 @@ discard block |
||
| 3358 | 3588 | { |
| 3359 | 3589 | foreach ($fbdata as $event) |
| 3360 | 3590 | { |
| 3361 | - if ($event['non_blocking']) continue; |
|
| 3362 | - if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue; |
|
| 3591 | + if ($event['non_blocking']) |
|
| 3592 | + { |
|
| 3593 | + continue; |
|
| 3594 | + } |
|
| 3595 | + if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) |
|
| 3596 | + { |
|
| 3597 | + continue; |
|
| 3598 | + } |
|
| 3363 | 3599 | $status = $event['participants'][$user]; |
| 3364 | 3600 | $quantity = $role = null; |
| 3365 | 3601 | calendar_so::split_status($status, $quantity, $role); |
| 3366 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
| 3602 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 3603 | + { |
|
| 3604 | + continue; |
|
| 3605 | + } |
|
| 3367 | 3606 | |
| 3368 | 3607 | $fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY'; |
| 3369 | 3608 | |
@@ -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,14 +109,16 @@ 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 | // Importing participants in human friendly format: |
| 111 | 115 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
| 112 | 116 | preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
| 113 | 117 | $p_participants = array(); |
| 114 | 118 | $missing = array(); |
| 115 | 119 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
| 116 | - foreach($names as $key => $name) { |
|
| 120 | + foreach($names as $key => $name) |
|
| 121 | + { |
|
| 117 | 122 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
| 118 | 123 | |
| 119 | 124 | // Search for direct account name, then user in accounts first |
@@ -121,9 +126,13 @@ discard block |
||
| 121 | 126 | $id = importexport_helper_functions::account_name2id($name); |
| 122 | 127 | |
| 123 | 128 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
| 124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 129 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
| 130 | + { |
|
| 125 | 131 | $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
| 126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 132 | + if($contacts) |
|
| 133 | + { |
|
| 134 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | if(!$id) |
| 129 | 138 | { |
@@ -131,7 +140,10 @@ discard block |
||
| 131 | 140 | foreach($this->bo->resources as $resource) |
| 132 | 141 | { |
| 133 | 142 | // Can't search for email |
| 134 | - if($resource['app'] == 'email') continue; |
|
| 143 | + if($resource['app'] == 'email') |
|
| 144 | + { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 135 | 147 | // Special resource search, since it does special stuff in link_query |
| 136 | 148 | if($resource['app'] == 'resources') |
| 137 | 149 | { |
@@ -140,7 +152,8 @@ discard block |
||
| 140 | 152 | $this->resource_so = new resources_so(); |
| 141 | 153 | } |
| 142 | 154 | $result = $this->resource_so->search($search,'res_id'); |
| 143 | - if(count($result) >= 1) { |
|
| 155 | + if(count($result) >= 1) |
|
| 156 | + { |
|
| 144 | 157 | $id = $resource['type'].$result[0]['res_id']; |
| 145 | 158 | break; |
| 146 | 159 | } |
@@ -159,7 +172,8 @@ discard block |
||
| 159 | 172 | } |
| 160 | 173 | } |
| 161 | 174 | } |
| 162 | - if($id) { |
|
| 175 | + if($id) |
|
| 176 | + { |
|
| 163 | 177 | $p_participants[$id] = calendar_so::combine_status( |
| 164 | 178 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
| 165 | 179 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -188,27 +202,38 @@ discard block |
||
| 188 | 202 | } |
| 189 | 203 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
| 190 | 204 | |
| 191 | - if ( $options['conditions'] ) { |
|
| 192 | - foreach ( $options['conditions'] as $condition ) { |
|
| 205 | + if ( $options['conditions'] ) |
|
| 206 | + { |
|
| 207 | + foreach ( $options['conditions'] as $condition ) |
|
| 208 | + { |
|
| 193 | 209 | $records = array(); |
| 194 | - switch ( $condition['type'] ) { |
|
| 210 | + switch ( $condition['type'] ) |
|
| 211 | + { |
|
| 195 | 212 | // exists |
| 196 | 213 | case 'exists' : |
| 197 | 214 | // Check for that record |
| 198 | 215 | $result = $this->exists($record, $condition, $records); |
| 199 | 216 | |
| 200 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 217 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 218 | + { |
|
| 201 | 219 | // apply action to all records matching this exists condition |
| 202 | 220 | $action = $condition['true']; |
| 203 | - foreach ( (array)$records as $event ) { |
|
| 221 | + foreach ( (array)$records as $event ) |
|
| 222 | + { |
|
| 204 | 223 | $record->id = $event['id']; |
| 205 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 206 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
| 224 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
| 225 | + { |
|
| 226 | + if ( !is_array( $record->category ) ) |
|
| 227 | + { |
|
| 228 | + $record->category = explode( ',', $record->category ); |
|
| 229 | + } |
|
| 207 | 230 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
| 208 | 231 | } |
| 209 | 232 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 210 | 233 | } |
| 211 | - } else { |
|
| 234 | + } |
|
| 235 | + else |
|
| 236 | + { |
|
| 212 | 237 | $action = $condition['false']; |
| 213 | 238 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 214 | 239 | } |
@@ -219,9 +244,14 @@ discard block |
||
| 219 | 244 | die('condition / action not supported!!!'); |
| 220 | 245 | break; |
| 221 | 246 | } |
| 222 | - if ($action['last']) break; |
|
| 247 | + if ($action['last']) |
|
| 248 | + { |
|
| 249 | + break; |
|
| 250 | + } |
|
| 223 | 251 | } |
| 224 | - } else { |
|
| 252 | + } |
|
| 253 | + else |
|
| 254 | + { |
|
| 225 | 255 | // unconditional insert |
| 226 | 256 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 227 | 257 | } |
@@ -240,12 +270,14 @@ discard block |
||
| 240 | 270 | */ |
| 241 | 271 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
| 242 | 272 | { |
| 243 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 273 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
| 274 | + { |
|
| 244 | 275 | $event = $this->bo->read($record->__get($condition['string'])); |
| 245 | 276 | $records = array($event); |
| 246 | 277 | } |
| 247 | 278 | |
| 248 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 279 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 280 | + { |
|
| 249 | 281 | return true; |
| 250 | 282 | } |
| 251 | 283 | return false; |
@@ -261,7 +293,8 @@ discard block |
||
| 261 | 293 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
| 262 | 294 | { |
| 263 | 295 | $_data = $record->get_record_array(); |
| 264 | - switch ($_action) { |
|
| 296 | + switch ($_action) |
|
| 297 | + { |
|
| 265 | 298 | case 'none' : |
| 266 | 299 | return true; |
| 267 | 300 | case 'update' : |
@@ -269,7 +302,8 @@ discard block |
||
| 269 | 302 | $old = $this->bo->read($_data['id']); |
| 270 | 303 | |
| 271 | 304 | // Don't change a user account into a record |
| 272 | - if(!$this->definition->plugin_options['change_owner']) { |
|
| 305 | + if(!$this->definition->plugin_options['change_owner']) |
|
| 306 | + { |
|
| 273 | 307 | // Don't change owner of an existing record |
| 274 | 308 | unset($_data['owner']); |
| 275 | 309 | } |
@@ -277,23 +311,27 @@ discard block |
||
| 277 | 311 | // Merge to deal with fields not in import record |
| 278 | 312 | $_data = array_merge($old, $_data); |
| 279 | 313 | $changed = $this->tracking->changed_fields($_data, $old); |
| 280 | - if(count($changed) == 0) { |
|
| 314 | + if(count($changed) == 0) |
|
| 315 | + { |
|
| 281 | 316 | return true; |
| 282 | 317 | } |
| 283 | 318 | // Fall through |
| 284 | 319 | case 'insert' : |
| 285 | - if($_action == 'insert') { |
|
| 320 | + if($_action == 'insert') |
|
| 321 | + { |
|
| 286 | 322 | // Backend doesn't like inserting with ID specified, can overwrite existing |
| 287 | 323 | unset($_data['id']); |
| 288 | 324 | } |
| 289 | 325 | // Make sure participants are set |
| 290 | - if(!$_data['participants']) { |
|
| 326 | + if(!$_data['participants']) |
|
| 327 | + { |
|
| 291 | 328 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
| 292 | 329 | $_data['participants'] = array( |
| 293 | 330 | $user => 'U' |
| 294 | 331 | ); |
| 295 | 332 | } |
| 296 | - if ( $this->dry_run ) { |
|
| 333 | + if ( $this->dry_run ) |
|
| 334 | + { |
|
| 297 | 335 | //print_r($_data); |
| 298 | 336 | // User is interested in conflict checks, do so for dry run |
| 299 | 337 | // Otherwise, conflicts are just ignored and imported anyway |
@@ -309,7 +347,9 @@ discard block |
||
| 309 | 347 | } |
| 310 | 348 | $this->results[$_action]++; |
| 311 | 349 | return true; |
| 312 | - } else { |
|
| 350 | + } |
|
| 351 | + else |
|
| 352 | + { |
|
| 313 | 353 | $messages = null; |
| 314 | 354 | $result = $this->bo->update( $_data, |
| 315 | 355 | !$this->definition->plugin_options['skip_conflicts'], |
@@ -360,7 +400,8 @@ discard block |
||
| 360 | 400 | * |
| 361 | 401 | * @return string name |
| 362 | 402 | */ |
| 363 | - public static function get_name() { |
|
| 403 | + public static function get_name() |
|
| 404 | + { |
|
| 364 | 405 | return lang('Calendar CSV import'); |
| 365 | 406 | } |
| 366 | 407 | |
@@ -369,7 +410,8 @@ discard block |
||
| 369 | 410 | * |
| 370 | 411 | * @return string descriprion |
| 371 | 412 | */ |
| 372 | - public static function get_description() { |
|
| 413 | + public static function get_description() |
|
| 414 | + { |
|
| 373 | 415 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
| 374 | 416 | } |
| 375 | 417 | |
@@ -378,7 +420,8 @@ discard block |
||
| 378 | 420 | * |
| 379 | 421 | * @return string suffix (comma seperated) |
| 380 | 422 | */ |
| 381 | - public static function get_filesuffix() { |
|
| 423 | + public static function get_filesuffix() |
|
| 424 | + { |
|
| 382 | 425 | return 'csv'; |
| 383 | 426 | } |
| 384 | 427 | |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | * @param int $cutoffdate =null |
| 178 | 178 | * @param array $not_uids =null uids NOT to return for meeting requests |
| 179 | 179 | * @return array |
| 180 | - */ |
|
| 180 | + */ |
|
| 181 | 181 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
| 182 | 182 | { |
| 183 | 183 | if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
@@ -20,8 +20,12 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
| 22 | 22 | { |
| 23 | - interface activesync_plugin_write {} |
|
| 24 | - interface activesync_plugin_meeting_requests {} |
|
| 23 | + interface activesync_plugin_write |
|
| 24 | + { |
|
| 25 | +} |
|
| 26 | + interface activesync_plugin_meeting_requests |
|
| 27 | + { |
|
| 28 | +} |
|
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | /** |
@@ -81,7 +85,10 @@ discard block |
||
| 81 | 85 | */ |
| 82 | 86 | public function GetFolderList() |
| 83 | 87 | { |
| 84 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 88 | + if (!isset($this->calendar)) |
|
| 89 | + { |
|
| 90 | + $this->calendar = new calendar_boupdate(); |
|
| 91 | + } |
|
| 85 | 92 | |
| 86 | 93 | $cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals']; |
| 87 | 94 | $cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P' |
@@ -180,13 +187,20 @@ discard block |
||
| 180 | 187 | */ |
| 181 | 188 | function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null) |
| 182 | 189 | { |
| 183 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 190 | + if (!isset($this->calendar)) |
|
| 191 | + { |
|
| 192 | + $this->calendar = new calendar_boupdate(); |
|
| 193 | + } |
|
| 184 | 194 | |
| 185 | 195 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)"); |
| 186 | 196 | $type = $user = null; |
| 187 | 197 | $this->backend->splitID($id,$type,$user); |
| 188 | 198 | |
| 189 | - if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600; // default three month back -30 breaks all sync recurrences |
|
| 199 | + if (!$cutoffdate) |
|
| 200 | + { |
|
| 201 | + $cutoffdate = $this->bo->now - 100*24*3600; |
|
| 202 | + } |
|
| 203 | + // default three month back -30 breaks all sync recurrences |
|
| 190 | 204 | |
| 191 | 205 | $filter = array( |
| 192 | 206 | 'users' => $user, |
@@ -212,7 +226,10 @@ discard block |
||
| 212 | 226 | { |
| 213 | 227 | foreach ($events as $event) |
| 214 | 228 | { |
| 215 | - if ($not_uids && in_array($event['uid'], $not_uids)) continue; |
|
| 229 | + if ($not_uids && in_array($event['uid'], $not_uids)) |
|
| 230 | + { |
|
| 231 | + continue; |
|
| 232 | + } |
|
| 216 | 233 | $messagelist[] = $this->StatMessage($id, $event); |
| 217 | 234 | |
| 218 | 235 | // add virtual exceptions for recuring events too |
@@ -227,7 +244,10 @@ discard block |
||
| 227 | 244 | } |
| 228 | 245 | }*/ |
| 229 | 246 | } |
| 230 | - if (count($events) < $num_rows) break; |
|
| 247 | + if (count($events) < $num_rows) |
|
| 248 | + { |
|
| 249 | + break; |
|
| 250 | + } |
|
| 231 | 251 | } |
| 232 | 252 | //error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace()); |
| 233 | 253 | return $messagelist; |
@@ -289,7 +309,10 @@ discard block |
||
| 289 | 309 | { |
| 290 | 310 | unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature |
| 291 | 311 | |
| 292 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 312 | + if (!isset($this->calendar)) |
|
| 313 | + { |
|
| 314 | + $this->calendar = new calendar_boupdate(); |
|
| 315 | + } |
|
| 293 | 316 | |
| 294 | 317 | if (!($event = $this->calendar->read(abs($id), 0, false, 'server'))) |
| 295 | 318 | { |
@@ -367,7 +390,10 @@ discard block |
||
| 367 | 390 | 'created' => 'dtstamp', |
| 368 | 391 | ) as $key => $attr) |
| 369 | 392 | { |
| 370 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 393 | + if (!empty($event[$key])) |
|
| 394 | + { |
|
| 395 | + $message->$attr = $event[$key]; |
|
| 396 | + } |
|
| 371 | 397 | } |
| 372 | 398 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 373 | 399 | { |
@@ -379,7 +405,10 @@ discard block |
||
| 379 | 405 | 'location' => 'location', |
| 380 | 406 | ) as $key => $attr) |
| 381 | 407 | { |
| 382 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 408 | + if (!empty($event[$key])) |
|
| 409 | + { |
|
| 410 | + $message->$attr = $event[$key]; |
|
| 411 | + } |
|
| 383 | 412 | } |
| 384 | 413 | $message->organizer = $event['organizer']; |
| 385 | 414 | |
@@ -414,7 +443,10 @@ discard block |
||
| 414 | 443 | */ |
| 415 | 444 | function MeetingResponse($folderid, $requestid, $response) |
| 416 | 445 | { |
| 417 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 446 | + if (!isset($this->calendar)) |
|
| 447 | + { |
|
| 448 | + $this->calendar = new calendar_boupdate(); |
|
| 449 | + } |
|
| 418 | 450 | |
| 419 | 451 | static $as2status = array( // different from self::$status2as! |
| 420 | 452 | 1 => 'A', |
@@ -424,9 +456,12 @@ discard block |
||
| 424 | 456 | $status_in = isset($as2status[$response]) ? $as2status[$response] : 'U'; |
| 425 | 457 | $uid = $GLOBALS['egw_info']['user']['account_id']; |
| 426 | 458 | |
| 427 | - if (!is_numeric($requestid)) // iCal from fmail |
|
| 459 | + if (!is_numeric($requestid)) |
|
| 460 | + { |
|
| 461 | + // iCal from fmail |
|
| 428 | 462 | { |
| 429 | 463 | $ical = new calendar_ical(); |
| 464 | + } |
|
| 430 | 465 | if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1) |
| 431 | 466 | { |
| 432 | 467 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!"); |
@@ -536,7 +571,10 @@ discard block |
||
| 536 | 571 | { |
| 537 | 572 | unset($contentParameters); // unused, but required by function signature |
| 538 | 573 | |
| 539 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 574 | + if (!isset($this->calendar)) |
|
| 575 | + { |
|
| 576 | + $this->calendar = new calendar_boupdate(); |
|
| 577 | + } |
|
| 540 | 578 | |
| 541 | 579 | $old_event = array(); |
| 542 | 580 | $type = $account = null; |
@@ -551,10 +589,13 @@ discard block |
||
| 551 | 589 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing"); |
| 552 | 590 | return false; |
| 553 | 591 | } |
| 554 | - if ($recur_date) // virtual exception |
|
| 592 | + if ($recur_date) |
|
| 593 | + { |
|
| 594 | + // virtual exception |
|
| 555 | 595 | { |
| 556 | 596 | // @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed |
| 557 | 597 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 598 | + } |
|
| 558 | 599 | //error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!"); |
| 559 | 600 | } |
| 560 | 601 | if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account)) |
@@ -564,7 +605,11 @@ discard block |
||
| 564 | 605 | //error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!"); |
| 565 | 606 | return false; |
| 566 | 607 | } |
| 567 | - if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events |
|
| 608 | + if (!$id) |
|
| 609 | + { |
|
| 610 | + $old_event['owner'] = $account; |
|
| 611 | + } |
|
| 612 | + // we do NOT allow to change the owner of existing events |
|
| 568 | 613 | |
| 569 | 614 | $event = $this->message2event($message, $account, $old_event); |
| 570 | 615 | |
@@ -593,7 +638,10 @@ discard block |
||
| 593 | 638 | unset($ex_event['etag']); |
| 594 | 639 | foreach(array_keys($ex_event) as $name) |
| 595 | 640 | { |
| 596 | - if (substr($name,0,6) == 'recur_') unset($ex_event[$name]); |
|
| 641 | + if (substr($name,0,6) == 'recur_') |
|
| 642 | + { |
|
| 643 | + unset($ex_event[$name]); |
|
| 644 | + } |
|
| 597 | 645 | } |
| 598 | 646 | $ex_event['recur_type'] = calendar_rrule::NONE; |
| 599 | 647 | |
@@ -646,7 +694,10 @@ discard block |
||
| 646 | 694 | 'end' => 'endtime', |
| 647 | 695 | ) as $key => $attr) |
| 648 | 696 | { |
| 649 | - if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 697 | + if (isset($message->$attr)) |
|
| 698 | + { |
|
| 699 | + $event[$key] = Api\DateTime::server2user($message->$attr); |
|
| 700 | + } |
|
| 650 | 701 | } |
| 651 | 702 | // copying strings |
| 652 | 703 | foreach(array( |
@@ -655,7 +706,10 @@ discard block |
||
| 655 | 706 | 'location' => 'location', |
| 656 | 707 | ) as $key => $attr) |
| 657 | 708 | { |
| 658 | - if (isset($message->$attr)) $event[$key] = $message->$attr; |
|
| 709 | + if (isset($message->$attr)) |
|
| 710 | + { |
|
| 711 | + $event[$key] = $message->$attr; |
|
| 712 | + } |
|
| 659 | 713 | } |
| 660 | 714 | |
| 661 | 715 | // only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse |
@@ -674,14 +728,22 @@ discard block |
||
| 674 | 728 | |
| 675 | 729 | if (($event['whole_day'] = $message->alldayevent)) |
| 676 | 730 | { |
| 677 | - if ($event['end'] == $event['start']) $event['end'] += 24*3600; // some clients send equal start&end for 1day |
|
| 731 | + if ($event['end'] == $event['start']) |
|
| 732 | + { |
|
| 733 | + $event['end'] += 24*3600; |
|
| 734 | + } |
|
| 735 | + // some clients send equal start&end for 1day |
|
| 678 | 736 | $event['end']--; // otherwise our whole-day event code in save makes it one more day! |
| 679 | 737 | } |
| 680 | 738 | |
| 681 | 739 | $participants = array(); |
| 682 | 740 | foreach((array)$message->attendees as $attendee) |
| 683 | 741 | { |
| 684 | - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later |
|
| 742 | + if ($attendee->type == 3) |
|
| 743 | + { |
|
| 744 | + continue; |
|
| 745 | + } |
|
| 746 | + // we can not identify resources and re-add them anyway later |
|
| 685 | 747 | |
| 686 | 748 | $matches = null; |
| 687 | 749 | if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches)) |
@@ -696,7 +758,10 @@ discard block |
||
| 696 | 758 | //'n_fn' => $attendee->name, // not sure if we want matches without email |
| 697 | 759 | ); |
| 698 | 760 | // search addressbook for participant |
| 699 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
| 761 | + if (!isset($this->addressbook)) |
|
| 762 | + { |
|
| 763 | + $this->addressbook = new Api\Contacts(); |
|
| 764 | + } |
|
| 700 | 765 | if ((list($data) = $this->addressbook->search($search, |
| 701 | 766 | array('id','egw_addressbook.account_id as account_id','n_fn'), |
| 702 | 767 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
@@ -704,10 +769,13 @@ discard block |
||
| 704 | 769 | { |
| 705 | 770 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
| 706 | 771 | } |
| 707 | - elseif($attendee->name === $attendee->email || empty($attendee->name)) // dont store empty or email as name |
|
| 772 | + elseif($attendee->name === $attendee->email || empty($attendee->name)) |
|
| 773 | + { |
|
| 774 | + // dont store empty or email as name |
|
| 708 | 775 | { |
| 709 | 776 | $uid = 'e'.$attendee->email; |
| 710 | 777 | } |
| 778 | + } |
|
| 711 | 779 | else // store just the email |
| 712 | 780 | { |
| 713 | 781 | $uid = 'e'.$attendee->name.' <'.$attendee->email.'>'; |
@@ -736,7 +804,11 @@ discard block |
||
| 736 | 804 | $role = 'REQ-PARTICIPANT'; |
| 737 | 805 | //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); |
| 738 | 806 | } |
| 739 | - if ($role == 'CHAIR') $chair_set = true; // by role from existing participant |
|
| 807 | + if ($role == 'CHAIR') |
|
| 808 | + { |
|
| 809 | + $chair_set = true; |
|
| 810 | + } |
|
| 811 | + // by role from existing participant |
|
| 740 | 812 | |
| 741 | 813 | if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as))) |
| 742 | 814 | { |
@@ -750,10 +822,13 @@ discard block |
||
| 750 | 822 | elseif (isset($attendee->attendeetype) && |
| 751 | 823 | !($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER |
| 752 | 824 | ($r = array_search($attendee->attendeetype,self::$role2as)) && |
| 753 | - (int)self::$role2as[$role] != $attendee->attendeetype) // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 825 | + (int)self::$role2as[$role] != $attendee->attendeetype) |
|
| 826 | + { |
|
| 827 | + // if old role gives same type, use old role, as we have a lot more roles then AS |
|
| 754 | 828 | { |
| 755 | 829 | $role = $r; |
| 756 | 830 | } |
| 831 | + } |
|
| 757 | 832 | //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); |
| 758 | 833 | $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); |
| 759 | 834 | } |
@@ -768,12 +843,19 @@ discard block |
||
| 768 | 843 | // $account is also preserved, as AS does not add him as participant! |
| 769 | 844 | foreach((array)$event['participant_types'] as $type => $parts) |
| 770 | 845 | { |
| 771 | - if (in_array($type,array('c','e'))) continue; // they are correctly representable in AS |
|
| 846 | + if (in_array($type,array('c','e'))) |
|
| 847 | + { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 850 | + // they are correctly representable in AS |
|
| 772 | 851 | |
| 773 | 852 | foreach($parts as $id => $status) |
| 774 | 853 | { |
| 775 | 854 | // accounts are represented correctly, but the event owner which is no participant in AS |
| 776 | - if ($type == 'u' && $id != $account) continue; |
|
| 855 | + if ($type == 'u' && $id != $account) |
|
| 856 | + { |
|
| 857 | + continue; |
|
| 858 | + } |
|
| 777 | 859 | |
| 778 | 860 | $uid = calendar_so::combine_user($type, $id); |
| 779 | 861 | if (!isset($participants[$uid])) |
@@ -798,10 +880,13 @@ discard block |
||
| 798 | 880 | // check if event is recurring and import recur information (incl. timezone) |
| 799 | 881 | if ($message->recurrence) |
| 800 | 882 | { |
| 801 | - if ($message->timezone && !$event['id']) // dont care for timezone, if no new and recurring event |
|
| 883 | + if ($message->timezone && !$event['id']) |
|
| 884 | + { |
|
| 885 | + // dont care for timezone, if no new and recurring event |
|
| 802 | 886 | { |
| 803 | 887 | $event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone))); |
| 804 | 888 | } |
| 889 | + } |
|
| 805 | 890 | $event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : |
| 806 | 891 | array_search($message->recurrence->type, self::$recur_type2as); |
| 807 | 892 | $event['recur_interval'] = $message->recurrence->interval; |
@@ -838,10 +923,13 @@ discard block |
||
| 838 | 923 | { |
| 839 | 924 | // calculate enddate from occurences count, as we only support enddate |
| 840 | 925 | $count = $message->recurrence->occurrences; |
| 841 | - foreach(calendar_rrule::event2rrule($event, true) as $rtime) // true = timestamps are user time here, because of save! |
|
| 926 | + foreach(calendar_rrule::event2rrule($event, true) as $rtime) |
|
| 927 | + { |
|
| 928 | + // true = timestamps are user time here, because of save! |
|
| 842 | 929 | { |
| 843 | 930 | if (--$count <= 0) break; |
| 844 | 931 | } |
| 932 | + } |
|
| 845 | 933 | $event['recur_enddate'] = $rtime->format('ts'); |
| 846 | 934 | } |
| 847 | 935 | } |
@@ -856,7 +944,9 @@ discard block |
||
| 856 | 944 | break; |
| 857 | 945 | } |
| 858 | 946 | } |
| 859 | - if ($alarm !== true) // new alarm |
|
| 947 | + if ($alarm !== true) |
|
| 948 | + { |
|
| 949 | + // new alarm |
|
| 860 | 950 | { |
| 861 | 951 | // delete all earlier alarms of that user |
| 862 | 952 | // user get's per AS only the earliest alarm, as AS only supports one alarm |
@@ -866,6 +956,7 @@ discard block |
||
| 866 | 956 | if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder) |
| 867 | 957 | { |
| 868 | 958 | unset($event['alarm'][$key]); |
| 959 | + } |
|
| 869 | 960 | } |
| 870 | 961 | } |
| 871 | 962 | $event['alarm'][] = $alarm = array( |
@@ -946,7 +1037,10 @@ discard block |
||
| 946 | 1037 | { |
| 947 | 1038 | unset($contentParameters); // not used, but required by function signature |
| 948 | 1039 | |
| 949 | - if (!isset($this->caledar)) $this->calendar = new calendar_boupdate(); |
|
| 1040 | + if (!isset($this->caledar)) |
|
| 1041 | + { |
|
| 1042 | + $this->calendar = new calendar_boupdate(); |
|
| 1043 | + } |
|
| 950 | 1044 | |
| 951 | 1045 | $ret = $this->calendar->delete($id); |
| 952 | 1046 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -1008,7 +1102,10 @@ discard block |
||
| 1008 | 1102 | */ |
| 1009 | 1103 | public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment') |
| 1010 | 1104 | { |
| 1011 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1105 | + if (!isset($this->calendar)) |
|
| 1106 | + { |
|
| 1107 | + $this->calendar = new calendar_boupdate(); |
|
| 1108 | + } |
|
| 1012 | 1109 | //error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace()); |
| 1013 | 1110 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 1014 | 1111 | $mimesupport = $contentparameters->GetMimeSupport(); |
@@ -1046,7 +1143,10 @@ discard block |
||
| 1046 | 1143 | catch(Exception $e) { |
| 1047 | 1144 | unset($e); |
| 1048 | 1145 | // z-push (2.3 at least) requires a timezone for recurring events |
| 1049 | - if ($event['recur_type']) $message->timezone = self::UTC_BLOB; |
|
| 1146 | + if ($event['recur_type']) |
|
| 1147 | + { |
|
| 1148 | + $message->timezone = self::UTC_BLOB; |
|
| 1149 | + } |
|
| 1050 | 1150 | } |
| 1051 | 1151 | |
| 1052 | 1152 | // copying timestamps (they are already read in servertime, so non tz conversation) |
@@ -1057,7 +1157,10 @@ discard block |
||
| 1057 | 1157 | 'modified' => 'dtstamp', |
| 1058 | 1158 | ) as $key => $attr) |
| 1059 | 1159 | { |
| 1060 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1160 | + if (!empty($event[$key])) |
|
| 1161 | + { |
|
| 1162 | + $message->$attr = $event[$key]; |
|
| 1163 | + } |
|
| 1061 | 1164 | } |
| 1062 | 1165 | if (($message->alldayevent = (int)calendar_bo::isWholeDay($event))) |
| 1063 | 1166 | { |
@@ -1070,7 +1173,10 @@ discard block |
||
| 1070 | 1173 | 'location' => 'location', |
| 1071 | 1174 | ) as $key => $attr) |
| 1072 | 1175 | { |
| 1073 | - if (!empty($event[$key])) $message->$attr = $event[$key]; |
|
| 1176 | + if (!empty($event[$key])) |
|
| 1177 | + { |
|
| 1178 | + $message->$attr = $event[$key]; |
|
| 1179 | + } |
|
| 1074 | 1180 | } |
| 1075 | 1181 | |
| 1076 | 1182 | // appoint description |
@@ -1103,7 +1209,10 @@ discard block |
||
| 1103 | 1209 | foreach($event['participants'] as $uid => $status) |
| 1104 | 1210 | { |
| 1105 | 1211 | // AS does NOT want calendar owner as participant |
| 1106 | - if ($uid == $account) continue; |
|
| 1212 | + if ($uid == $account) |
|
| 1213 | + { |
|
| 1214 | + continue; |
|
| 1215 | + } |
|
| 1107 | 1216 | $quantity = $role = null; |
| 1108 | 1217 | calendar_so::split_status($status, $quantity, $role); |
| 1109 | 1218 | |
@@ -1120,7 +1229,10 @@ discard block |
||
| 1120 | 1229 | list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ? |
| 1121 | 1230 | ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false); |
| 1122 | 1231 | |
| 1123 | - if (!$info) continue; |
|
| 1232 | + if (!$info) |
|
| 1233 | + { |
|
| 1234 | + continue; |
|
| 1235 | + } |
|
| 1124 | 1236 | |
| 1125 | 1237 | if (!$info['email'] && $info['responsible']) |
| 1126 | 1238 | { |
@@ -1136,10 +1248,17 @@ discard block |
||
| 1136 | 1248 | $message->organizeremail = $attendee->email; |
| 1137 | 1249 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>"); |
| 1138 | 1250 | } |
| 1139 | - if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource |
|
| 1251 | + if ($uid[0] == 'r') |
|
| 1252 | + { |
|
| 1253 | + $attendee->type = 3; |
|
| 1254 | + } |
|
| 1255 | + // 3 = resource |
|
| 1140 | 1256 | } |
| 1141 | 1257 | // email must NOT be empty, but MAY be an arbitrary text |
| 1142 | - if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1258 | + if (empty($attendee->email)) |
|
| 1259 | + { |
|
| 1260 | + $attendee->email = 'noreply-'.$uid.'[email protected]'; |
|
| 1261 | + } |
|
| 1143 | 1262 | |
| 1144 | 1263 | $message->attendees[] = $attendee; |
| 1145 | 1264 | } |
@@ -1174,9 +1293,12 @@ discard block |
||
| 1174 | 1293 | $recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12 |
| 1175 | 1294 | break; |
| 1176 | 1295 | } |
| 1177 | - if ($rrule->enddate) // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1296 | + if ($rrule->enddate) |
|
| 1297 | + { |
|
| 1298 | + // enddate is only a date, but AS needs a time incl. correct starttime! |
|
| 1178 | 1299 | { |
| 1179 | 1300 | $enddate = clone $rrule->time; |
| 1301 | + } |
|
| 1180 | 1302 | $enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'), |
| 1181 | 1303 | $rrule->enddate->format('d')); |
| 1182 | 1304 | $recurrence->until = $enddate->format('server'); |
@@ -1198,12 +1320,19 @@ discard block |
||
| 1198 | 1320 | { |
| 1199 | 1321 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception'])); |
| 1200 | 1322 | } |
| 1201 | - if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1323 | + if (count($ex_events)>=1) |
|
| 1324 | + { |
|
| 1325 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']); |
|
| 1326 | + } |
|
| 1202 | 1327 | |
| 1203 | 1328 | $message->exceptions = array(); |
| 1204 | 1329 | foreach($ex_events as $ex_event) |
| 1205 | 1330 | { |
| 1206 | - if ($ex_event['id'] == $event['id']) continue; // ignore series master |
|
| 1331 | + if ($ex_event['id'] == $event['id']) |
|
| 1332 | + { |
|
| 1333 | + continue; |
|
| 1334 | + } |
|
| 1335 | + // ignore series master |
|
| 1207 | 1336 | $exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException'); |
| 1208 | 1337 | $exception->exceptionstarttime = $exception_time = $ex_event['recurrence']; |
| 1209 | 1338 | foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported) |
@@ -1223,7 +1352,10 @@ discard block |
||
| 1223 | 1352 | { |
| 1224 | 1353 | if (!empty($exception_time)) |
| 1225 | 1354 | { |
| 1226 | - if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1355 | + if (empty($event['uid'])) |
|
| 1356 | + { |
|
| 1357 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time); |
|
| 1358 | + } |
|
| 1227 | 1359 | $exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required |
| 1228 | 1360 | $exception->deleted = 1; |
| 1229 | 1361 | $exception->exceptionstarttime = $exception_time; |
@@ -1279,12 +1411,18 @@ discard block |
||
| 1279 | 1411 | { |
| 1280 | 1412 | unset($folderid); // not used ($id is unique), but required by function signature |
| 1281 | 1413 | |
| 1282 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1414 | + if (!isset($this->calendar)) |
|
| 1415 | + { |
|
| 1416 | + $this->calendar = new calendar_boupdate(); |
|
| 1417 | + } |
|
| 1283 | 1418 | |
| 1284 | 1419 | $nul = null; |
| 1285 | - if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) // last true: $only_master=true |
|
| 1420 | + if (!($etag = $this->calendar->get_etag($id, $nul, true, true))) |
|
| 1421 | + { |
|
| 1422 | + // last true: $only_master=true |
|
| 1286 | 1423 | { |
| 1287 | 1424 | $stat = false; |
| 1425 | + } |
|
| 1288 | 1426 | // error_log why access is denied (should never happen for everything returned by calendar_bo::search) |
| 1289 | 1427 | $backup = $this->calendar->debug; |
| 1290 | 1428 | //$this->calendar->debug = 2; |
@@ -1318,13 +1456,22 @@ discard block |
||
| 1318 | 1456 | $type = $owner = null; |
| 1319 | 1457 | $this->backend->splitID($folderid, $type, $owner); |
| 1320 | 1458 | |
| 1321 | - if ($type != 'calendar') return false; |
|
| 1459 | + if ($type != 'calendar') |
|
| 1460 | + { |
|
| 1461 | + return false; |
|
| 1462 | + } |
|
| 1322 | 1463 | |
| 1323 | - if (!isset($this->calendar)) $this->calendar = new calendar_boupdate(); |
|
| 1464 | + if (!isset($this->calendar)) |
|
| 1465 | + { |
|
| 1466 | + $this->calendar = new calendar_boupdate(); |
|
| 1467 | + } |
|
| 1324 | 1468 | //$ctag = $this->calendar->get_ctag($owner,'owner',true); // true only consider recurrence master |
| 1325 | 1469 | $syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too |
| 1326 | 1470 | // workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop |
| 1327 | - if ($syncstate == 0) $syncstate = 1; |
|
| 1471 | + if ($syncstate == 0) |
|
| 1472 | + { |
|
| 1473 | + $syncstate = 1; |
|
| 1474 | + } |
|
| 1328 | 1475 | |
| 1329 | 1476 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'"); |
| 1330 | 1477 | } |
@@ -1400,10 +1547,16 @@ discard block |
||
| 1400 | 1547 | 'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0, |
| 1401 | 1548 | ); |
| 1402 | 1549 | |
| 1403 | - if ($tz === 'UTC') return $data; |
|
| 1550 | + if ($tz === 'UTC') |
|
| 1551 | + { |
|
| 1552 | + return $data; |
|
| 1553 | + } |
|
| 1404 | 1554 | |
| 1405 | 1555 | $name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz; |
| 1406 | - if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component'); |
|
| 1556 | + if (strpos($component, 'VTIMEZONE') === false) |
|
| 1557 | + { |
|
| 1558 | + $component = calendar_timezones::tz2id($name,'component'); |
|
| 1559 | + } |
|
| 1407 | 1560 | // parse ical timezone defintion |
| 1408 | 1561 | $ical = self::ical2array($component); |
| 1409 | 1562 | $standard = $ical['VTIMEZONE']['STANDARD']; |
@@ -1446,11 +1599,17 @@ discard block |
||
| 1446 | 1599 | $data[$prefix.'week'] = 5; |
| 1447 | 1600 | } |
| 1448 | 1601 | // if both start and end use 1SU use week=5 and decrement month |
| 1449 | - if ($prefix == 'dststart') $start_byday = $matches[1]; |
|
| 1602 | + if ($prefix == 'dststart') |
|
| 1603 | + { |
|
| 1604 | + $start_byday = $matches[1]; |
|
| 1605 | + } |
|
| 1450 | 1606 | if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU') |
| 1451 | 1607 | { |
| 1452 | 1608 | $data[$prefix.'week'] = 5; |
| 1453 | - if ($prefix == 'dstend') $data[$prefix.'month'] -= 1; |
|
| 1609 | + if ($prefix == 'dstend') |
|
| 1610 | + { |
|
| 1611 | + $data[$prefix.'month'] -= 1; |
|
| 1612 | + } |
|
| 1454 | 1613 | } |
| 1455 | 1614 | static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6); |
| 1456 | 1615 | $data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)]; |
@@ -1526,7 +1685,10 @@ discard block |
||
| 1526 | 1685 | static public function ical2array(&$ical,$section=null) |
| 1527 | 1686 | { |
| 1528 | 1687 | $arr = array(); |
| 1529 | - if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1688 | + if (!is_array($ical)) |
|
| 1689 | + { |
|
| 1690 | + $ical = preg_split("/[\r\n]+/m", $ical); |
|
| 1691 | + } |
|
| 1530 | 1692 | while (($line = array_shift($ical))) |
| 1531 | 1693 | { |
| 1532 | 1694 | list($name,$value) = explode(':',$line,2); |
@@ -1536,7 +1698,10 @@ discard block |
||
| 1536 | 1698 | } |
| 1537 | 1699 | elseif($name == 'END') |
| 1538 | 1700 | { |
| 1539 | - if ($section && $section==$value) return $arr; |
|
| 1701 | + if ($section && $section==$value) |
|
| 1702 | + { |
|
| 1703 | + return $arr; |
|
| 1704 | + } |
|
| 1540 | 1705 | break; |
| 1541 | 1706 | } |
| 1542 | 1707 | else |
@@ -1567,13 +1732,19 @@ discard block |
||
| 1567 | 1732 | |
| 1568 | 1733 | for($n = 0; !isset($cache[$key]); ++$n) |
| 1569 | 1734 | { |
| 1570 | - if (!$n) // check users timezone first |
|
| 1735 | + if (!$n) |
|
| 1736 | + { |
|
| 1737 | + // check users timezone first |
|
| 1571 | 1738 | { |
| 1572 | 1739 | $tz = Api\DateTime::$user_timezone->getName(); |
| 1573 | 1740 | } |
| 1574 | - elseif (!($tz = calendar_timezones::id2tz($n))) // no further timezones to check |
|
| 1741 | + } |
|
| 1742 | + elseif (!($tz = calendar_timezones::id2tz($n))) |
|
| 1743 | + { |
|
| 1744 | + // no further timezones to check |
|
| 1575 | 1745 | { |
| 1576 | 1746 | $cache[$key] = 'UTC'; |
| 1747 | + } |
|
| 1577 | 1748 | error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!'); |
| 1578 | 1749 | break; |
| 1579 | 1750 | } |
@@ -1637,7 +1808,11 @@ discard block |
||
| 1637 | 1808 | $account_id = $entry['grantor']; |
| 1638 | 1809 | $cals[$account_id] = $entry['name']; |
| 1639 | 1810 | } |
| 1640 | - if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user |
|
| 1811 | + if ($hook_data['account_id'] > 0) |
|
| 1812 | + { |
|
| 1813 | + unset($cals[$hook_data['account_id']]); |
|
| 1814 | + } |
|
| 1815 | + // skip current user |
|
| 1641 | 1816 | } |
| 1642 | 1817 | $cals['G'] = lang('Primary group'); |
| 1643 | 1818 | $cals['A'] = lang('All'); |
@@ -1665,13 +1840,16 @@ discard block |
||
| 1665 | 1840 | * |
| 1666 | 1841 | * You need to comment implements activesync_plugin_write |
| 1667 | 1842 | */ |
| 1668 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
| 1843 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
| 1844 | +{ |
|
| 1845 | + // some tests |
|
| 1669 | 1846 | { |
| 1670 | 1847 | $GLOBALS['egw_info'] = array( |
| 1671 | 1848 | 'flags' => array( |
| 1672 | 1849 | 'currentapp' => 'login' |
| 1673 | 1850 | ) |
| 1674 | 1851 | ); |
| 1852 | +} |
|
| 1675 | 1853 | require_once('../../header.inc.php'); |
| 1676 | 1854 | ini_set('display_errors',1); |
| 1677 | 1855 | error_reporting(E_ALL & ~E_NOTICE); |
@@ -387,11 +387,11 @@ |
||
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | - * gets the icons displayed for a given event |
|
| 391 | - * |
|
| 392 | - * @param array $event |
|
| 393 | - * @return array of 'img' / 'title' pairs |
|
| 394 | - */ |
|
| 390 | + * gets the icons displayed for a given event |
|
| 391 | + * |
|
| 392 | + * @param array $event |
|
| 393 | + * @return array of 'img' / 'title' pairs |
|
| 394 | + */ |
|
| 395 | 395 | function event_icons($event) |
| 396 | 396 | { |
| 397 | 397 | $is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event); |
@@ -166,7 +166,10 @@ discard block |
||
| 166 | 166 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 167 | 167 | |
| 168 | 168 | // make sure the hook for export_limit is registered |
| 169 | - if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true); |
|
| 169 | + if (!Api\Hooks::exists('export_limit','calendar')) |
|
| 170 | + { |
|
| 171 | + Api\Hooks::read(true); |
|
| 172 | + } |
|
| 170 | 173 | } |
| 171 | 174 | |
| 172 | 175 | /** |
@@ -279,11 +282,15 @@ discard block |
||
| 279 | 282 | { |
| 280 | 283 | // only change the owners of the same resource-type as given in set_state[owner] |
| 281 | 284 | $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']); |
| 282 | - if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) |
|
| 285 | + if ((string)$set_owners[0] === '0') |
|
| 286 | + { |
|
| 287 | + // set exactly the specified owners (without the 0) |
|
| 283 | 288 | { |
| 284 | 289 | if ($set_states['owner'] === '0,r0') // small fix for resources |
| 285 | 290 | { |
| 286 | - $set_states['owner'] = $default; // --> set default, instead of none |
|
| 291 | + $set_states['owner'] = $default; |
|
| 292 | + } |
|
| 293 | + // --> set default, instead of none |
|
| 287 | 294 | } |
| 288 | 295 | else |
| 289 | 296 | { |
@@ -369,7 +376,10 @@ discard block |
||
| 369 | 376 | } |
| 370 | 377 | $this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index'; |
| 371 | 378 | |
| 372 | - if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 379 | + if ($this->debug > 0 || $this->debug == 'manage_states') |
|
| 380 | + { |
|
| 381 | + $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 382 | + } |
|
| 373 | 383 | // save the states in the session only when we are in calendar |
| 374 | 384 | if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar') |
| 375 | 385 | { |
@@ -505,8 +515,11 @@ discard block |
||
| 505 | 515 | |
| 506 | 516 | // resources menu hooks |
| 507 | 517 | foreach ($this->bo->resources as $resource) |
| 508 | - { |
|
| 509 | - if(!is_array($resource['cal_sidebox'])) continue; |
|
| 518 | + { |
|
| 519 | + if(!is_array($resource['cal_sidebox'])) |
|
| 520 | + { |
|
| 521 | + continue; |
|
| 522 | + } |
|
| 510 | 523 | $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']); |
| 511 | 524 | $file = ExecMethod($resource['cal_sidebox']['file'],array( |
| 512 | 525 | 'menuaction' => $this->view_menuaction, |
@@ -556,7 +569,10 @@ discard block |
||
| 556 | 569 | $sidebox = new Etemplate('calendar.sidebox'); |
| 557 | 570 | |
| 558 | 571 | $cont = $this->cal_prefs['saved_states']; |
| 559 | - if (!is_array($cont)) $cont = array(); |
|
| 572 | + if (!is_array($cont)) |
|
| 573 | + { |
|
| 574 | + $cont = array(); |
|
| 575 | + } |
|
| 560 | 576 | $cont['view'] = $this->view ? $this->view : 'week'; |
| 561 | 577 | $cont['date'] = $this->date ? $this->date : new Api\DateTime(); |
| 562 | 578 | $cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner']; |
@@ -616,7 +632,10 @@ discard block |
||
| 616 | 632 | */ |
| 617 | 633 | public function update_client($event_id, Api\DateTime $recurrence_date = null) |
| 618 | 634 | { |
| 619 | - if(!$event_id) return false; |
|
| 635 | + if(!$event_id) |
|
| 636 | + { |
|
| 637 | + return false; |
|
| 638 | + } |
|
| 620 | 639 | if(is_string($event_id) && strpos($event_id,':') !== FALSE) |
| 621 | 640 | { |
| 622 | 641 | list($event_id, $date) = explode(':',$event_id); |
@@ -687,7 +706,10 @@ discard block |
||
| 687 | 706 | */ |
| 688 | 707 | public function to_client(&$event) |
| 689 | 708 | { |
| 690 | - if(!$event || !is_array($event)) return false; |
|
| 709 | + if(!$event || !is_array($event)) |
|
| 710 | + { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 691 | 713 | |
| 692 | 714 | if (!$this->bo->check_perms(Acl::EDIT,$event)) |
| 693 | 715 | { |
@@ -708,8 +730,16 @@ discard block |
||
| 708 | 730 | |
| 709 | 731 | $event['recure'] = $this->bo->recure2string($event); |
| 710 | 732 | |
| 711 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
| 712 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
| 733 | + if (empty($event['description'])) |
|
| 734 | + { |
|
| 735 | + $event['description'] = ' '; |
|
| 736 | + } |
|
| 737 | + // no description screws the titles horz. alignment |
|
| 738 | + if (empty($event['location'])) |
|
| 739 | + { |
|
| 740 | + $event['location'] = ' '; |
|
| 741 | + } |
|
| 742 | + // no location screws the owner horz. alignment |
|
| 713 | 743 | |
| 714 | 744 | // respect category permissions |
| 715 | 745 | if(!empty($event['category'])) |
@@ -796,8 +826,14 @@ discard block |
||
| 796 | 826 | if(!$timespan) |
| 797 | 827 | { |
| 798 | 828 | // Try to make time span into appropriate ranges to match |
| 799 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
| 800 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
| 829 | + if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) |
|
| 830 | + { |
|
| 831 | + $template = 'month'; |
|
| 832 | + } |
|
| 833 | + if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) |
|
| 834 | + { |
|
| 835 | + $template = 'week'; |
|
| 836 | + } |
|
| 801 | 837 | //error_log("Detected template $template"); |
| 802 | 838 | switch ($template) |
| 803 | 839 | { |
@@ -2415,14 +2415,14 @@ discard block |
||
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | /** |
| 2418 | - * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | - * |
|
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | - * @return string error-msg if $return_error |
|
| 2423 | - */ |
|
| 2424 | - function export($content=0,$return_error=false) |
|
| 2425 | - { |
|
| 2418 | + * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | + * |
|
| 2420 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | + * @return string error-msg if $return_error |
|
| 2423 | + */ |
|
| 2424 | + function export($content=0,$return_error=false) |
|
| 2425 | + { |
|
| 2426 | 2426 | $boical = new calendar_ical(); |
| 2427 | 2427 | #error_log(__METHOD__.print_r($content,true)); |
| 2428 | 2428 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
| 2477 | 2477 | $etpl = new etemplate_new('calendar.export'); |
| 2478 | 2478 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
| 2479 | - } |
|
| 2479 | + } |
|
| 2480 | 2480 | |
| 2481 | 2481 | /** |
| 2482 | 2482 | * Edit category ACL (admin only) |
@@ -2548,8 +2548,8 @@ discard block |
||
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
| 2551 | - * Set up the required fields to get the history tab |
|
| 2552 | - */ |
|
| 2551 | + * Set up the required fields to get the history tab |
|
| 2552 | + */ |
|
| 2553 | 2553 | public function setup_history(&$content, &$sel_options) |
| 2554 | 2554 | { |
| 2555 | 2555 | $status = 'history_status'; |
@@ -121,11 +121,14 @@ discard block |
||
| 121 | 121 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 122 | 122 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 123 | 123 | { |
| 124 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 124 | + if ($owner) |
|
| 125 | + { |
|
| 126 | + // make an owner who is no user or we have no add-rights a participant |
|
| 125 | 127 | { |
| 126 | 128 | if(!is_array($owner)) |
| 127 | 129 | { |
| 128 | 130 | $owner = explode(',',$owner); |
| 131 | + } |
|
| 129 | 132 | } |
| 130 | 133 | // if we come from ressources we don't need any users selected in calendar |
| 131 | 134 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -157,9 +160,17 @@ discard block |
||
| 157 | 160 | $participant_types['u'] = $participant_types = $participants = array(); |
| 158 | 161 | foreach($extra_participants as $uid) |
| 159 | 162 | { |
| 160 | - if (isset($participants[$uid])) continue; // already included |
|
| 163 | + if (isset($participants[$uid])) |
|
| 164 | + { |
|
| 165 | + continue; |
|
| 166 | + } |
|
| 167 | + // already included |
|
| 161 | 168 | |
| 162 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 169 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 170 | + { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 173 | + // no right to invite --> ignored |
|
| 163 | 174 | |
| 164 | 175 | if (is_numeric($uid)) |
| 165 | 176 | { |
@@ -197,10 +208,13 @@ discard block |
||
| 197 | 208 | } |
| 198 | 209 | } |
| 199 | 210 | } |
| 200 | - if (!$participants) // if all participants got removed, include current user |
|
| 211 | + if (!$participants) |
|
| 212 | + { |
|
| 213 | + // if all participants got removed, include current user |
|
| 201 | 214 | { |
| 202 | 215 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 203 | 216 | } |
| 217 | + } |
|
| 204 | 218 | if(isset($_GET['cat_id'])) |
| 205 | 219 | { |
| 206 | 220 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -250,10 +264,13 @@ discard block |
||
| 250 | 264 | */ |
| 251 | 265 | function process_edit($content) |
| 252 | 266 | { |
| 253 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 267 | + if (!is_array($content)) |
|
| 268 | + { |
|
| 269 | + // redirect from etemplate, if POST empty |
|
| 254 | 270 | { |
| 255 | 271 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 256 | 272 | } |
| 273 | + } |
|
| 257 | 274 | // clear notification errors |
| 258 | 275 | notifications::errors(true); |
| 259 | 276 | $messages = null; |
@@ -266,7 +283,11 @@ discard block |
||
| 266 | 283 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 267 | 284 | |
| 268 | 285 | list($button) = @each($content['button']); |
| 269 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 286 | + if (!$button && $content['action']) |
|
| 287 | + { |
|
| 288 | + $button = $content['action']; |
|
| 289 | + } |
|
| 290 | + // action selectbox |
|
| 270 | 291 | unset($content['button']); unset($content['action']); |
| 271 | 292 | |
| 272 | 293 | $view = $content['view']; |
@@ -279,7 +300,10 @@ discard block |
||
| 279 | 300 | { |
| 280 | 301 | list($date) = each($content['recur_exception']['delete_exception']); |
| 281 | 302 | // eT2 converts time to |
| 282 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 303 | + if (!is_numeric($date)) |
|
| 304 | + { |
|
| 305 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 306 | + } |
|
| 283 | 307 | unset($content['recur_exception']['delete_exception']); |
| 284 | 308 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 285 | 309 | { |
@@ -288,7 +312,10 @@ discard block |
||
| 288 | 312 | foreach ($recur_exceptions as $id) |
| 289 | 313 | { |
| 290 | 314 | if (!($exception = $this->bo->read($id)) || |
| 291 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 315 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 316 | + { |
|
| 317 | + continue; |
|
| 318 | + } |
|
| 292 | 319 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 293 | 320 | $exception['reference'] = $exception['recurrence'] = 0; |
| 294 | 321 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -363,7 +390,10 @@ discard block |
||
| 363 | 390 | $event['end'] = $this->bo->date2ts($event['end']); |
| 364 | 391 | } |
| 365 | 392 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 366 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 393 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 394 | + { |
|
| 395 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 396 | + } |
|
| 367 | 397 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 368 | 398 | { |
| 369 | 399 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -490,7 +520,11 @@ discard block |
||
| 490 | 520 | break; |
| 491 | 521 | |
| 492 | 522 | default: // existing participant row |
| 493 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 523 | + if (!is_array($data)) |
|
| 524 | + { |
|
| 525 | + continue; |
|
| 526 | + } |
|
| 527 | + // widgets in participant tab, above participant list |
|
| 494 | 528 | foreach(array('uid','status','quantity','role') as $name) |
| 495 | 529 | { |
| 496 | 530 | $$name = $data[$name]; |
@@ -622,7 +656,10 @@ discard block |
||
| 622 | 656 | { |
| 623 | 657 | foreach($participants as $id => &$p_response) |
| 624 | 658 | { |
| 625 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 659 | + if($type == 'u' && $id == $event['owner']) |
|
| 660 | + { |
|
| 661 | + continue; |
|
| 662 | + } |
|
| 626 | 663 | calendar_so::split_status($p_response, $quantity, $role); |
| 627 | 664 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 628 | 665 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -704,17 +741,23 @@ discard block |
||
| 704 | 741 | { |
| 705 | 742 | foreach (array_keys($event['participants']) as $uid) |
| 706 | 743 | { |
| 707 | - if ($uid[0] == 'r') //ressource detection |
|
| 744 | + if ($uid[0] == 'r') |
|
| 745 | + { |
|
| 746 | + //ressource detection |
|
| 708 | 747 | { |
| 709 | 748 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 749 | + } |
|
| 710 | 750 | $button = ''; |
| 711 | 751 | break 2; //break foreach and case |
| 712 | 752 | } |
| 713 | 753 | } |
| 714 | 754 | } |
| 715 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 755 | + if ($content['edit_single']) |
|
| 756 | + { |
|
| 757 | + // we edited a single event from a series |
|
| 716 | 758 | { |
| 717 | 759 | $event['reference'] = $event['id']; |
| 760 | + } |
|
| 718 | 761 | $event['recurrence'] = $content['edit_single']; |
| 719 | 762 | unset($event['id']); |
| 720 | 763 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -816,7 +859,10 @@ discard block |
||
| 816 | 859 | case 'no': |
| 817 | 860 | break; |
| 818 | 861 | case 'startday': |
| 819 | - if ($sameday) break; |
|
| 862 | + if ($sameday) |
|
| 863 | + { |
|
| 864 | + break; |
|
| 865 | + } |
|
| 820 | 866 | default: |
| 821 | 867 | $status_reset_to_unknown = true; |
| 822 | 868 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -984,7 +1030,10 @@ discard block |
||
| 984 | 1030 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 985 | 1031 | { |
| 986 | 1032 | $msg = lang('Series deleted'); |
| 987 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 1033 | + if ($exceptions_kept) |
|
| 1034 | + { |
|
| 1035 | + $msg .= lang(', exceptions preserved'); |
|
| 1036 | + } |
|
| 988 | 1037 | } |
| 989 | 1038 | else |
| 990 | 1039 | { |
@@ -1020,11 +1069,14 @@ discard block |
||
| 1020 | 1069 | { |
| 1021 | 1070 | $msg = lang("Can't add alarms in the past !!!"); |
| 1022 | 1071 | } |
| 1023 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1072 | + elseif ($event['id']) |
|
| 1073 | + { |
|
| 1074 | + // save the alarm immediatly |
|
| 1024 | 1075 | { |
| 1025 | 1076 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 1026 | 1077 | { |
| 1027 | 1078 | $alarm['id'] = $alarm_id; |
| 1079 | + } |
|
| 1028 | 1080 | $event['alarm'][$alarm_id] = $alarm; |
| 1029 | 1081 | |
| 1030 | 1082 | $msg = lang('Alarm added'); |
@@ -1037,7 +1089,9 @@ discard block |
||
| 1037 | 1089 | } |
| 1038 | 1090 | else |
| 1039 | 1091 | { |
| 1040 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1092 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1093 | + { |
|
| 1094 | +} // get a temporary non-conflicting, numeric id |
|
| 1041 | 1095 | $event['alarm'][$alarm['id']] = $alarm; |
| 1042 | 1096 | } |
| 1043 | 1097 | } |
@@ -1060,10 +1114,13 @@ discard block |
||
| 1060 | 1114 | } |
| 1061 | 1115 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1062 | 1116 | { |
| 1063 | - if ($content['lock_token']) // remove an existing lock |
|
| 1117 | + if ($content['lock_token']) |
|
| 1118 | + { |
|
| 1119 | + // remove an existing lock |
|
| 1064 | 1120 | { |
| 1065 | 1121 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1066 | 1122 | } |
| 1123 | + } |
|
| 1067 | 1124 | if ($content['no_popup']) |
| 1068 | 1125 | { |
| 1069 | 1126 | Egw::redirect_link('/index.php',array( |
@@ -1120,13 +1177,19 @@ discard block |
||
| 1120 | 1177 | } |
| 1121 | 1178 | |
| 1122 | 1179 | // Copy links |
| 1123 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1180 | + if(!is_array($event['link_to'])) |
|
| 1181 | + { |
|
| 1182 | + $event['link_to'] = array(); |
|
| 1183 | + } |
|
| 1124 | 1184 | $event['link_to']['to_app'] = 'calendar'; |
| 1125 | 1185 | $event['link_to']['to_id'] = 0; |
| 1126 | 1186 | |
| 1127 | 1187 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
| 1128 | 1188 | { |
| 1129 | - if(!$link['id']) continue; |
|
| 1189 | + if(!$link['id']) |
|
| 1190 | + { |
|
| 1191 | + continue; |
|
| 1192 | + } |
|
| 1130 | 1193 | if ($link['app'] != Link::VFS_APPNAME) |
| 1131 | 1194 | { |
| 1132 | 1195 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1194,8 +1257,7 @@ discard block |
||
| 1194 | 1257 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1195 | 1258 | // Adjust for requested date in the past |
| 1196 | 1259 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1197 | - ) |
|
| 1198 | - { |
|
| 1260 | + ) { |
|
| 1199 | 1261 | |
| 1200 | 1262 | unset($orig_event); |
| 1201 | 1263 | // copy event by unsetting the id(s) |
@@ -1283,30 +1345,48 @@ discard block |
||
| 1283 | 1345 | foreach($event['participants'] as $uid => $status) |
| 1284 | 1346 | { |
| 1285 | 1347 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1286 | - if (empty($status)) continue; |
|
| 1348 | + if (empty($status)) |
|
| 1349 | + { |
|
| 1350 | + continue; |
|
| 1351 | + } |
|
| 1287 | 1352 | $toadd = ''; |
| 1288 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1353 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1354 | + { |
|
| 1355 | + continue; |
|
| 1356 | + } |
|
| 1289 | 1357 | |
| 1290 | 1358 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1291 | 1359 | { |
| 1292 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1360 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1361 | + { |
|
| 1362 | + continue; |
|
| 1363 | + } |
|
| 1293 | 1364 | |
| 1294 | 1365 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1295 | 1366 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1296 | 1367 | |
| 1297 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1368 | + if (!in_array($toadd,$to)) |
|
| 1369 | + { |
|
| 1370 | + $to[] = $toadd; |
|
| 1371 | + } |
|
| 1298 | 1372 | } |
| 1299 | 1373 | elseif ($uid < 0) |
| 1300 | 1374 | { |
| 1301 | 1375 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1302 | 1376 | { |
| 1303 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1377 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1378 | + { |
|
| 1379 | + continue; |
|
| 1380 | + } |
|
| 1304 | 1381 | |
| 1305 | 1382 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1306 | 1383 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1307 | 1384 | |
| 1308 | 1385 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1309 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1386 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1387 | + { |
|
| 1388 | + $to[] = $toadd; |
|
| 1389 | + } |
|
| 1310 | 1390 | } |
| 1311 | 1391 | } |
| 1312 | 1392 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1358,7 +1438,10 @@ discard block |
||
| 1358 | 1438 | 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
| 1359 | 1439 | 'preset[size]' => filesize($ics_file), |
| 1360 | 1440 | ); |
| 1361 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1441 | + if ($asrequest) |
|
| 1442 | + { |
|
| 1443 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1444 | + } |
|
| 1362 | 1445 | $response = Api\Json\Response::get(); |
| 1363 | 1446 | $response->call('app.calendar.custom_mail', $vars); |
| 1364 | 1447 | } |
@@ -1544,9 +1627,15 @@ discard block |
||
| 1544 | 1627 | } |
| 1545 | 1628 | } |
| 1546 | 1629 | // set new start and end if given by $_GET |
| 1547 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1548 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1549 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1630 | + if(isset($_GET['start'])) |
|
| 1631 | + { |
|
| 1632 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1633 | + if(isset($_GET['end'])) |
|
| 1634 | + { |
|
| 1635 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1636 | + if(isset($_GET['non_blocking'])) |
|
| 1637 | + { |
|
| 1638 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1550 | 1639 | // check if the event is the whole day |
| 1551 | 1640 | $start = $this->bo->date2array($event['start']); |
| 1552 | 1641 | $end = $this->bo->date2array($event['end']); |
@@ -1559,10 +1648,13 @@ discard block |
||
| 1559 | 1648 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1560 | 1649 | { |
| 1561 | 1650 | $link_id = $link_ids[$n]; |
| 1562 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1651 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1652 | + { |
|
| 1653 | + // guard against XSS |
|
| 1563 | 1654 | { |
| 1564 | 1655 | continue; |
| 1565 | 1656 | } |
| 1657 | + } |
|
| 1566 | 1658 | if(!$n) |
| 1567 | 1659 | { |
| 1568 | 1660 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1571,7 +1663,10 @@ discard block |
||
| 1571 | 1663 | { |
| 1572 | 1664 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1573 | 1665 | { |
| 1574 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1666 | + if (($l_id=$set['link_id'][$i])) |
|
| 1667 | + { |
|
| 1668 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1669 | + } |
|
| 1575 | 1670 | } |
| 1576 | 1671 | unset($set['link_app']); |
| 1577 | 1672 | unset($set['link_id']); |
@@ -1597,10 +1692,13 @@ discard block |
||
| 1597 | 1692 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1598 | 1693 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1599 | 1694 | |
| 1600 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1695 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1696 | + { |
|
| 1697 | + // already locked --> refresh the lock |
|
| 1601 | 1698 | { |
| 1602 | 1699 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1603 | 1700 | } |
| 1701 | + } |
|
| 1604 | 1702 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1605 | 1703 | { |
| 1606 | 1704 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1634,14 +1732,20 @@ discard block |
||
| 1634 | 1732 | )); |
| 1635 | 1733 | Framework::message($msg, $msg_type); |
| 1636 | 1734 | $content['duration'] = $content['end'] - $content['start']; |
| 1637 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1735 | + if (isset($this->durations[$content['duration']])) |
|
| 1736 | + { |
|
| 1737 | + $content['end'] = ''; |
|
| 1738 | + } |
|
| 1638 | 1739 | |
| 1639 | 1740 | $row = 3; |
| 1640 | 1741 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1641 | 1742 | // preserve some ui elements, if set eg. under error-conditions |
| 1642 | 1743 | foreach(array('quantity','resource','role') as $n) |
| 1643 | 1744 | { |
| 1644 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1745 | + if (isset($event['participants'][$n])) |
|
| 1746 | + { |
|
| 1747 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1748 | + } |
|
| 1645 | 1749 | } |
| 1646 | 1750 | foreach($event['participant_types'] as $type => $participants) |
| 1647 | 1751 | { |
@@ -1683,9 +1787,13 @@ discard block |
||
| 1683 | 1787 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1684 | 1788 | |
| 1685 | 1789 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1686 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1790 | + { |
|
| 1791 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1792 | + } |
|
| 1687 | 1793 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1688 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1794 | + { |
|
| 1795 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1796 | + } |
|
| 1689 | 1797 | // todo: make the participants available as links with email as title |
| 1690 | 1798 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1691 | 1799 | // enumerate group-invitations, so people can accept/reject them |
@@ -1716,7 +1824,11 @@ discard block |
||
| 1716 | 1824 | $content['participants']['cal_resources'] = ''; |
| 1717 | 1825 | foreach($this->bo->resources as $data) |
| 1718 | 1826 | { |
| 1719 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1827 | + if ($data['app'] == 'email') |
|
| 1828 | + { |
|
| 1829 | + continue; |
|
| 1830 | + } |
|
| 1831 | + // make no sense, as we cant search for email |
|
| 1720 | 1832 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1721 | 1833 | } |
| 1722 | 1834 | } |
@@ -1744,9 +1856,18 @@ discard block |
||
| 1744 | 1856 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1745 | 1857 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1746 | 1858 | $label = array(); |
| 1747 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1748 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1749 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1859 | + if ($days) |
|
| 1860 | + { |
|
| 1861 | + $label[] = $days.' '.lang('days'); |
|
| 1862 | + } |
|
| 1863 | + if ($hours) |
|
| 1864 | + { |
|
| 1865 | + $label[] = $hours.' '.lang('hours'); |
|
| 1866 | + } |
|
| 1867 | + if ($minutes) |
|
| 1868 | + { |
|
| 1869 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1870 | + } |
|
| 1750 | 1871 | $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
| 1751 | 1872 | $content['alarm'][] = $alarm; |
| 1752 | 1873 | |
@@ -1809,25 +1930,34 @@ discard block |
||
| 1809 | 1930 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1810 | 1931 | 'history' => !$event['id'], |
| 1811 | 1932 | ); |
| 1812 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1933 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1934 | + { |
|
| 1935 | + // no mail without mail-app |
|
| 1813 | 1936 | { |
| 1814 | 1937 | unset($sel_options['action']['mail']); |
| 1938 | + } |
|
| 1815 | 1939 | unset($sel_options['action']['sendmeetingrequest']); |
| 1816 | 1940 | } |
| 1817 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1941 | + if (!$event['id']) |
|
| 1942 | + { |
|
| 1943 | + // no ical export for new (not saved) events |
|
| 1818 | 1944 | { |
| 1819 | 1945 | $readonlys['action'] = true; |
| 1820 | 1946 | } |
| 1947 | + } |
|
| 1821 | 1948 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
| 1822 | 1949 | { |
| 1823 | 1950 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1824 | 1951 | } |
| 1825 | 1952 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1826 | 1953 | |
| 1827 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1954 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1955 | + { |
|
| 1956 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1828 | 1957 | { |
| 1829 | 1958 | $sel_options['owner'][0] = lang('All participants'); |
| 1830 | 1959 | } |
| 1960 | + } |
|
| 1831 | 1961 | if (isset($event['participant_types']['u'][$this->user])) |
| 1832 | 1962 | { |
| 1833 | 1963 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1870,7 +2000,10 @@ discard block |
||
| 1870 | 2000 | |
| 1871 | 2001 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1872 | 2002 | |
| 1873 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 2003 | + if (!empty($preserved['lock_token'])) |
|
| 2004 | + { |
|
| 2005 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 2006 | + } |
|
| 1874 | 2007 | |
| 1875 | 2008 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1876 | 2009 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2072,7 +2205,10 @@ discard block |
||
| 2072 | 2205 | // set status and send notification / meeting response |
| 2073 | 2206 | if ($this->bo->set_status($event['id'], $user, $status)) |
| 2074 | 2207 | { |
| 2075 | - if (!$msg) $msg = lang('Status changed'); |
|
| 2208 | + if (!$msg) |
|
| 2209 | + { |
|
| 2210 | + $msg = lang('Status changed'); |
|
| 2211 | + } |
|
| 2076 | 2212 | } |
| 2077 | 2213 | break; |
| 2078 | 2214 | |
@@ -2151,13 +2287,16 @@ discard block |
||
| 2151 | 2287 | |
| 2152 | 2288 | foreach (array_keys($allConflicts) as $pId) |
| 2153 | 2289 | { |
| 2154 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2290 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2291 | + { |
|
| 2292 | + // resources Allow ignore conflicts |
|
| 2155 | 2293 | { |
| 2156 | 2294 | |
| 2157 | 2295 | switch ($resources_config['ignoreconflicts']) |
| 2158 | 2296 | { |
| 2159 | 2297 | case 'no': |
| 2160 | 2298 | $readonlys['button[ignore]'] = true; |
| 2299 | + } |
|
| 2161 | 2300 | break; |
| 2162 | 2301 | case 'allusers': |
| 2163 | 2302 | $readonlys['button[ignore]'] = false; |
@@ -2301,7 +2440,10 @@ discard block |
||
| 2301 | 2440 | } |
| 2302 | 2441 | else |
| 2303 | 2442 | { |
| 2304 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2443 | + if (!$content['duration']) |
|
| 2444 | + { |
|
| 2445 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2446 | + } |
|
| 2305 | 2447 | $weekds = 0; |
| 2306 | 2448 | foreach ($content['weekdays'] as &$wdays) |
| 2307 | 2449 | { |
@@ -2323,7 +2465,10 @@ discard block |
||
| 2323 | 2465 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2324 | 2466 | |
| 2325 | 2467 | $sel_options['duration'] = $this->durations; |
| 2326 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2468 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2469 | + { |
|
| 2470 | + $content['end'] = ''; |
|
| 2471 | + } |
|
| 2327 | 2472 | |
| 2328 | 2473 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2329 | 2474 | 'participants' => $content['participants'], |
@@ -2344,7 +2489,10 @@ discard block |
||
| 2344 | 2489 | */ |
| 2345 | 2490 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2346 | 2491 | { |
| 2347 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2492 | + if ($this->debug > 2) |
|
| 2493 | + { |
|
| 2494 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2495 | + } |
|
| 2348 | 2496 | |
| 2349 | 2497 | $busy = $this->bo->search(array( |
| 2350 | 2498 | 'start' => $start, |
@@ -2361,9 +2509,17 @@ discard block |
||
| 2361 | 2509 | $n = 0; |
| 2362 | 2510 | foreach($busy as $event) |
| 2363 | 2511 | { |
| 2364 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2512 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2513 | + { |
|
| 2514 | + continue; |
|
| 2515 | + } |
|
| 2516 | + // ignore our own event |
|
| 2365 | 2517 | |
| 2366 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2518 | + if ($event['non_blocking']) |
|
| 2519 | + { |
|
| 2520 | + continue; |
|
| 2521 | + } |
|
| 2522 | + // ignore non_blocking events |
|
| 2367 | 2523 | |
| 2368 | 2524 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2369 | 2525 | $non_rejected_found = false; |
@@ -2372,7 +2528,10 @@ discard block |
||
| 2372 | 2528 | $status = $event['participants'][$uid]; |
| 2373 | 2529 | $quantity = $role = null; |
| 2374 | 2530 | calendar_so::split_status($status, $quantity, $role); |
| 2375 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
| 2531 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 2532 | + { |
|
| 2533 | + continue; |
|
| 2534 | + } |
|
| 2376 | 2535 | |
| 2377 | 2536 | if (isset($event['participants'][$uid]) || |
| 2378 | 2537 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2382,7 +2541,10 @@ discard block |
||
| 2382 | 2541 | break; |
| 2383 | 2542 | } |
| 2384 | 2543 | } |
| 2385 | - if (!$non_rejected_found) continue; |
|
| 2544 | + if (!$non_rejected_found) |
|
| 2545 | + { |
|
| 2546 | + continue; |
|
| 2547 | + } |
|
| 2386 | 2548 | |
| 2387 | 2549 | if ($this->debug) |
| 2388 | 2550 | { |
@@ -2413,11 +2575,17 @@ discard block |
||
| 2413 | 2575 | 'start' => $ft_start, |
| 2414 | 2576 | 'end' => $ft_end, |
| 2415 | 2577 | ); |
| 2416 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2578 | + if ($this->debug > 1) |
|
| 2579 | + { |
|
| 2580 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2581 | + } |
|
| 2417 | 2582 | } |
| 2418 | 2583 | $ft_start = $event['end']; |
| 2419 | 2584 | } |
| 2420 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2585 | + if ($this->debug > 0) |
|
| 2586 | + { |
|
| 2587 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2588 | + } |
|
| 2421 | 2589 | |
| 2422 | 2590 | return $freetime; |
| 2423 | 2591 | } |
@@ -2437,10 +2605,16 @@ discard block |
||
| 2437 | 2605 | */ |
| 2438 | 2606 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2439 | 2607 | { |
| 2440 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2608 | + if ($this->debug > 1) |
|
| 2609 | + { |
|
| 2610 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2611 | + } |
|
| 2441 | 2612 | |
| 2442 | 2613 | $freetime_daywise = array(); |
| 2443 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2614 | + if (!is_array($sel_options)) |
|
| 2615 | + { |
|
| 2616 | + $sel_options = array(); |
|
| 2617 | + } |
|
| 2444 | 2618 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2445 | 2619 | |
| 2446 | 2620 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2450,7 +2624,10 @@ discard block |
||
| 2450 | 2624 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2451 | 2625 | { |
| 2452 | 2626 | $end_time = 0; |
| 2453 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2627 | + if ($this->debug > 1) |
|
| 2628 | + { |
|
| 2629 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2630 | + } |
|
| 2454 | 2631 | } |
| 2455 | 2632 | $n = 0; |
| 2456 | 2633 | foreach($freetime as $ft) |
@@ -2471,13 +2648,19 @@ discard block |
||
| 2471 | 2648 | } |
| 2472 | 2649 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2473 | 2650 | |
| 2474 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2651 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2652 | + { |
|
| 2653 | + // start earlier then start_time |
|
| 2475 | 2654 | { |
| 2476 | 2655 | $start = $daybegin + $start_time*HOUR_s; |
| 2477 | 2656 | } |
| 2657 | + } |
|
| 2478 | 2658 | // if end_time given use it, else the original slot's end |
| 2479 | 2659 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2480 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2660 | + if ($end > $ft['end']) |
|
| 2661 | + { |
|
| 2662 | + $end = $ft['end']; |
|
| 2663 | + } |
|
| 2481 | 2664 | |
| 2482 | 2665 | // slot to small for duration |
| 2483 | 2666 | if ($end - $start < $duration) |
@@ -2519,7 +2702,10 @@ discard block |
||
| 2519 | 2702 | { |
| 2520 | 2703 | $msg = lang('Permission denied'); |
| 2521 | 2704 | |
| 2522 | - if ($return_error) return $msg; |
|
| 2705 | + if ($return_error) |
|
| 2706 | + { |
|
| 2707 | + return $msg; |
|
| 2708 | + } |
|
| 2523 | 2709 | } |
| 2524 | 2710 | else |
| 2525 | 2711 | { |
@@ -2581,27 +2767,42 @@ discard block |
||
| 2581 | 2767 | { |
| 2582 | 2768 | list($button) = each($_content['button']); |
| 2583 | 2769 | unset($_content['button']); |
| 2584 | - if ($button != 'cancel') // store changed Acl |
|
| 2770 | + if ($button != 'cancel') |
|
| 2771 | + { |
|
| 2772 | + // store changed Acl |
|
| 2585 | 2773 | { |
| 2586 | 2774 | foreach($_content as $data) |
| 2587 | 2775 | { |
| 2588 | 2776 | if (!($cat_id = $data['cat_id'])) continue; |
| 2777 | + } |
|
| 2589 | 2778 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2590 | 2779 | { |
| 2591 | 2780 | $rights = 0; |
| 2592 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2593 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2594 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2781 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2782 | + { |
|
| 2783 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2784 | + } |
|
| 2785 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2786 | + { |
|
| 2787 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2788 | + } |
|
| 2789 | + if ($account_id) |
|
| 2790 | + { |
|
| 2791 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2792 | + } |
|
| 2595 | 2793 | } |
| 2596 | 2794 | } |
| 2597 | 2795 | } |
| 2598 | - if ($button != 'apply') // end dialog |
|
| 2796 | + if ($button != 'apply') |
|
| 2797 | + { |
|
| 2798 | + // end dialog |
|
| 2599 | 2799 | { |
| 2600 | 2800 | Egw::redirect_link('/index.php', array( |
| 2601 | 2801 | 'menuaction' => 'admin.admin_ui.index', |
| 2602 | 2802 | 'ajax' => 'true' |
| 2603 | 2803 | ), 'admin'); |
| 2604 | 2804 | } |
| 2805 | + } |
|
| 2605 | 2806 | } |
| 2606 | 2807 | $content= $preserv = array(); |
| 2607 | 2808 | $n = 1; |
@@ -2615,8 +2816,14 @@ discard block |
||
| 2615 | 2816 | ); |
| 2616 | 2817 | foreach($data as $account_id => $rights) |
| 2617 | 2818 | { |
| 2618 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2619 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2819 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2820 | + { |
|
| 2821 | + $row['add'][] = $account_id; |
|
| 2822 | + } |
|
| 2823 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2824 | + { |
|
| 2825 | + $row['status'][] = $account_id; |
|
| 2826 | + } |
|
| 2620 | 2827 | } |
| 2621 | 2828 | $content[$n] = $row; |
| 2622 | 2829 | $preserv[$n] = array( |
@@ -2744,7 +2951,10 @@ discard block |
||
| 2744 | 2951 | break; |
| 2745 | 2952 | } |
| 2746 | 2953 | } |
| 2747 | - if($return) return; |
|
| 2954 | + if($return) |
|
| 2955 | + { |
|
| 2956 | + return; |
|
| 2957 | + } |
|
| 2748 | 2958 | } |
| 2749 | 2959 | $old_event=$event=$this->bo->read($eventId); |
| 2750 | 2960 | if (!$durationT) |
@@ -2838,7 +3048,10 @@ discard block |
||
| 2838 | 3048 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2839 | 3049 | |
| 2840 | 3050 | // Whole day non blocking with DAY_s would add a day |
| 2841 | - if($duration==DAY_s) $duration=0; |
|
| 3051 | + if($duration==DAY_s) |
|
| 3052 | + { |
|
| 3053 | + $duration=0; |
|
| 3054 | + } |
|
| 2842 | 3055 | } |
| 2843 | 3056 | |
| 2844 | 3057 | $status_reset_to_unknown = false; |
@@ -2856,7 +3069,10 @@ discard block |
||
| 2856 | 3069 | case 'no': |
| 2857 | 3070 | break; |
| 2858 | 3071 | case 'startday': |
| 2859 | - if ($sameday) break; |
|
| 3072 | + if ($sameday) |
|
| 3073 | + { |
|
| 3074 | + break; |
|
| 3075 | + } |
|
| 2860 | 3076 | default: |
| 2861 | 3077 | $status_reset_to_unknown = true; |
| 2862 | 3078 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -2900,7 +3116,10 @@ discard block |
||
| 2900 | 3116 | { |
| 2901 | 3117 | $response->call('egw.message', implode('<br />', $message)); |
| 2902 | 3118 | } |
| 2903 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3119 | + if($event['id'] != $eventId ) |
|
| 3120 | + { |
|
| 3121 | + $this->update_client($_eventId); |
|
| 3122 | + } |
|
| 2904 | 3123 | if ($status_reset_to_unknown) |
| 2905 | 3124 | { |
| 2906 | 3125 | foreach((array)$event['participants'] as $uid => $status) |
@@ -1490,13 +1490,13 @@ discard block |
||
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | - * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | - * |
|
| 1495 | - * @param string|int $id id of user or resource |
|
| 1496 | - * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | - * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | - * @return string with name |
|
| 1499 | - */ |
|
| 1493 | + * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | + * |
|
| 1495 | + * @param string|int $id id of user or resource |
|
| 1496 | + * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | + * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | + * @return string with name |
|
| 1499 | + */ |
|
| 1500 | 1500 | function participant_name($id,$use_type=false, $append_email=false) |
| 1501 | 1501 | { |
| 1502 | 1502 | static $id2lid = array(); |
@@ -1525,13 +1525,13 @@ discard block |
||
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
| 1528 | - * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | - * |
|
| 1530 | - * @param array $event event-data |
|
| 1531 | - * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | - * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | - * @return array with id / names with status pairs |
|
| 1534 | - */ |
|
| 1528 | + * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | + * |
|
| 1530 | + * @param array $event event-data |
|
| 1531 | + * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | + * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | + * @return array with id / names with status pairs |
|
| 1534 | + */ |
|
| 1535 | 1535 | function participants($event,$long_status=false,$show_group_invitation=false) |
| 1536 | 1536 | { |
| 1537 | 1537 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
@@ -1601,12 +1601,12 @@ discard block |
||
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | /** |
| 1604 | - * Converts category string of an event into array of (readable) category-names |
|
| 1605 | - * |
|
| 1606 | - * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | - * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | - * @return array with id / names |
|
| 1609 | - */ |
|
| 1604 | + * Converts category string of an event into array of (readable) category-names |
|
| 1605 | + * |
|
| 1606 | + * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | + * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | + * @return array with id / names |
|
| 1609 | + */ |
|
| 1610 | 1610 | function categories($category,&$color) |
| 1611 | 1611 | { |
| 1612 | 1612 | static $id2cat = array(); |
@@ -15,10 +15,13 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Link; |
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | -if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
|
| 18 | +if (!defined('ACL_TYPE_IDENTIFER')) |
|
| 19 | +{ |
|
| 20 | + // used to mark ACL-values for the debug_message methode |
|
| 19 | 21 | { |
| 20 | 22 | define('ACL_TYPE_IDENTIFER','***ACL***'); |
| 21 | 23 | } |
| 24 | +} |
|
| 22 | 25 | |
| 23 | 26 | define('HOUR_s',60*60); |
| 24 | 27 | define('DAY_s',24*HOUR_s); |
@@ -219,7 +222,10 @@ discard block |
||
| 219 | 222 | */ |
| 220 | 223 | function __construct() |
| 221 | 224 | { |
| 222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
| 225 | + if ($this->debug > 0) |
|
| 226 | + { |
|
| 227 | + $this->debug_message('calendar_bo::bocal() started',True); |
|
| 228 | + } |
|
| 223 | 229 | |
| 224 | 230 | $this->so = new calendar_so(); |
| 225 | 231 | |
@@ -305,7 +311,10 @@ discard block |
||
| 305 | 311 | */ |
| 306 | 312 | static function email_info($ids) |
| 307 | 313 | { |
| 308 | - if (!$ids) return null; |
|
| 314 | + if (!$ids) |
|
| 315 | + { |
|
| 316 | + return null; |
|
| 317 | + } |
|
| 309 | 318 | |
| 310 | 319 | $data = array(); |
| 311 | 320 | foreach((array)$ids as $id) |
@@ -398,10 +407,13 @@ discard block |
||
| 398 | 407 | } |
| 399 | 408 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
| 400 | 409 | { |
| 401 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
| 410 | + if ($contact && !in_array($contact,$contact_list)) |
|
| 411 | + { |
|
| 412 | + // already added? |
|
| 402 | 413 | { |
| 403 | 414 | $contact_list[] = $contact; |
| 404 | 415 | } |
| 416 | + } |
|
| 405 | 417 | } |
| 406 | 418 | } |
| 407 | 419 | } |
@@ -461,21 +473,27 @@ discard block |
||
| 461 | 473 | { |
| 462 | 474 | foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
| 463 | 475 | { |
| 464 | - if ($contact && !in_array($contact,$users)) // already added? |
|
| 476 | + if ($contact && !in_array($contact,$users)) |
|
| 477 | + { |
|
| 478 | + // already added? |
|
| 465 | 479 | { |
| 466 | 480 | $users[] = $contact; |
| 467 | 481 | } |
| 482 | + } |
|
| 468 | 483 | } |
| 469 | 484 | continue; |
| 470 | 485 | } |
| 471 | 486 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
| 472 | 487 | { |
| 473 | - if ($user && !in_array($user,$users)) // already added? |
|
| 488 | + if ($user && !in_array($user,$users)) |
|
| 489 | + { |
|
| 490 | + // already added? |
|
| 474 | 491 | { |
| 475 | 492 | // General expansion check |
| 476 | 493 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
| 477 | 494 | { |
| 478 | 495 | $info = $this->resource_info($user); |
| 496 | + } |
|
| 479 | 497 | if($info && $info['resources']) |
| 480 | 498 | { |
| 481 | 499 | foreach($info['resources'] as $_user) |
@@ -496,12 +514,18 @@ discard block |
||
| 496 | 514 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 497 | 515 | } |
| 498 | 516 | // the further code is only for real users |
| 499 | - if (!is_numeric($user)) continue; |
|
| 517 | + if (!is_numeric($user)) |
|
| 518 | + { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 500 | 521 | |
| 501 | 522 | // for groups we have to include the members |
| 502 | 523 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
| 503 | 524 | { |
| 504 | - if ($no_enum_groups) continue; |
|
| 525 | + if ($no_enum_groups) |
|
| 526 | + { |
|
| 527 | + continue; |
|
| 528 | + } |
|
| 505 | 529 | |
| 506 | 530 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 507 | 531 | if (is_array($members)) |
@@ -581,11 +605,14 @@ discard block |
||
| 581 | 605 | } |
| 582 | 606 | |
| 583 | 607 | if (!isset($params['users']) || !$params['users'] || |
| 584 | - count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) // null or '' casted to an array |
|
| 608 | + count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) |
|
| 609 | + { |
|
| 610 | + // null or '' casted to an array |
|
| 585 | 611 | { |
| 586 | 612 | // for a search use all account you have read grants from |
| 587 | 613 | $params['users'] = $params['query'] ? array_keys($this->grants) : $this->user; |
| 588 | 614 | } |
| 615 | + } |
|
| 589 | 616 | // resolve users to add memberships for users and members for groups |
| 590 | 617 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
| 591 | 618 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
@@ -596,7 +623,10 @@ discard block |
||
| 596 | 623 | $params['private_grants'] = array(); |
| 597 | 624 | foreach($this->grants as $user => $rights) |
| 598 | 625 | { |
| 599 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 626 | + if ($rights & Acl::PRIVAT) |
|
| 627 | + { |
|
| 628 | + $params['private_grants'][] = $user; |
|
| 629 | + } |
|
| 600 | 630 | } |
| 601 | 631 | } |
| 602 | 632 | |
@@ -611,7 +641,10 @@ discard block |
||
| 611 | 641 | { |
| 612 | 642 | return false; |
| 613 | 643 | } |
| 614 | - if (isset($params['start'])) $start = $this->date2ts($params['start']); |
|
| 644 | + if (isset($params['start'])) |
|
| 645 | + { |
|
| 646 | + $start = $this->date2ts($params['start']); |
|
| 647 | + } |
|
| 615 | 648 | |
| 616 | 649 | if (isset($params['end'])) |
| 617 | 650 | { |
@@ -675,10 +708,13 @@ discard block |
||
| 675 | 708 | $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
| 676 | 709 | } |
| 677 | 710 | // create empty entries for each day in the reported time |
| 678 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 711 | + for($ts = $start; $ts <= $end; $ts += DAY_s) |
|
| 712 | + { |
|
| 713 | + // good enough for array creation, but see while loop below. |
|
| 679 | 714 | { |
| 680 | 715 | $daysEvents[$this->date2string($ts)] = array(); |
| 681 | 716 | } |
| 717 | + } |
|
| 682 | 718 | foreach($events as $k => $event) |
| 683 | 719 | { |
| 684 | 720 | $e_start = max($this->date2ts($event['start']),$start); |
@@ -730,7 +766,10 @@ discard block |
||
| 730 | 766 | $integration_data = calendar_so::get_integration_data(); |
| 731 | 767 | } |
| 732 | 768 | |
| 733 | - if (!isset($integration_data[$app])) return null; |
|
| 769 | + if (!isset($integration_data[$app])) |
|
| 770 | + { |
|
| 771 | + return null; |
|
| 772 | + } |
|
| 734 | 773 | |
| 735 | 774 | return $part ? $integration_data[$app][$part] : $integration_data[$app]; |
| 736 | 775 | } |
@@ -777,8 +816,14 @@ discard block |
||
| 777 | 816 | */ |
| 778 | 817 | function clear_private_infos(&$event,$allowed_participants = array()) |
| 779 | 818 | { |
| 780 | - if ($event == false) return; |
|
| 781 | - if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 819 | + if ($event == false) |
|
| 820 | + { |
|
| 821 | + return; |
|
| 822 | + } |
|
| 823 | + if (!is_array($event['participants'])) |
|
| 824 | + { |
|
| 825 | + error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 826 | + } |
|
| 782 | 827 | |
| 783 | 828 | $event = array( |
| 784 | 829 | 'id' => $event['id'], |
@@ -823,19 +868,29 @@ discard block |
||
| 823 | 868 | } |
| 824 | 869 | $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
| 825 | 870 | |
| 826 | - if ($new_horizont <= $this->config['horizont']) // no move necessary |
|
| 871 | + if ($new_horizont <= $this->config['horizont']) |
|
| 872 | + { |
|
| 873 | + // no move necessary |
|
| 827 | 874 | { |
| 828 | 875 | 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']); |
| 876 | + } |
|
| 829 | 877 | return; |
| 830 | 878 | } |
| 831 | 879 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
| 832 | 880 | { |
| 833 | 881 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 834 | 882 | } |
| 835 | - if (empty($maxdays)) $maxdays = 1000; // old default |
|
| 836 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 883 | + if (empty($maxdays)) |
|
| 884 | + { |
|
| 885 | + $maxdays = 1000; |
|
| 886 | + } |
|
| 887 | + // old default |
|
| 888 | + if ($new_horizont > time()+$maxdays*DAY_s) |
|
| 889 | + { |
|
| 890 | + // some user tries to "look" more then the maximum number of days in the future |
|
| 837 | 891 | { |
| 838 | 892 | 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); |
| 893 | + } |
|
| 839 | 894 | $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
| 840 | 895 | return; |
| 841 | 896 | } |
@@ -863,7 +918,10 @@ discard block |
||
| 863 | 918 | // update the horizont |
| 864 | 919 | Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
| 865 | 920 | |
| 866 | - 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']); |
|
| 921 | + if ($this->debug == 'check_move_horizont') |
|
| 922 | + { |
|
| 923 | + $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 924 | + } |
|
| 867 | 925 | } |
| 868 | 926 | |
| 869 | 927 | /** |
@@ -894,7 +952,10 @@ discard block |
||
| 894 | 952 | $event['end'] = $this->date2usertime($event_read['end']); |
| 895 | 953 | } |
| 896 | 954 | } |
| 897 | - if (!$start) $start = $event['start']; |
|
| 955 | + if (!$start) |
|
| 956 | + { |
|
| 957 | + $start = $event['start']; |
|
| 958 | + } |
|
| 898 | 959 | $start_obj = new Api\DateTime($start); |
| 899 | 960 | $read_start = new Api\DateTime($event_read['start']); |
| 900 | 961 | |
@@ -936,7 +997,10 @@ discard block |
||
| 936 | 997 | */ |
| 937 | 998 | function db2data(&$events,$date_format='ts') |
| 938 | 999 | { |
| 939 | - if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1000 | + if (!is_array($events)) |
|
| 1001 | + { |
|
| 1002 | + echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1003 | + } |
|
| 940 | 1004 | foreach ($events as &$event) |
| 941 | 1005 | { |
| 942 | 1006 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
@@ -1020,7 +1084,10 @@ discard block |
||
| 1020 | 1084 | */ |
| 1021 | 1085 | function date2usertime($ts,$date_format='ts') |
| 1022 | 1086 | { |
| 1023 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
| 1087 | + if (empty($ts) || $date_format == 'server') |
|
| 1088 | + { |
|
| 1089 | + return $ts; |
|
| 1090 | + } |
|
| 1024 | 1091 | |
| 1025 | 1092 | return Api\DateTime::server2user($ts,$date_format); |
| 1026 | 1093 | } |
@@ -1038,9 +1105,15 @@ discard block |
||
| 1038 | 1105 | */ |
| 1039 | 1106 | function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
| 1040 | 1107 | { |
| 1041 | - if (!$ids) return false; |
|
| 1108 | + if (!$ids) |
|
| 1109 | + { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1042 | 1112 | |
| 1043 | - if ($date) $date = $this->date2ts($date); |
|
| 1113 | + if ($date) |
|
| 1114 | + { |
|
| 1115 | + $date = $this->date2ts($date); |
|
| 1116 | + } |
|
| 1044 | 1117 | |
| 1045 | 1118 | $return = null; |
| 1046 | 1119 | |
@@ -1205,7 +1278,10 @@ discard block |
||
| 1205 | 1278 | { |
| 1206 | 1279 | static $res_info_cache = array(); |
| 1207 | 1280 | |
| 1208 | - if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1281 | + if (!is_scalar($uid)) |
|
| 1282 | + { |
|
| 1283 | + throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1284 | + } |
|
| 1209 | 1285 | |
| 1210 | 1286 | if (!isset($res_info_cache[$uid])) |
| 1211 | 1287 | { |
@@ -1260,7 +1336,10 @@ discard block |
||
| 1260 | 1336 | */ |
| 1261 | 1337 | function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
| 1262 | 1338 | { |
| 1263 | - if (!$user) $user = $this->user; |
|
| 1339 | + if (!$user) |
|
| 1340 | + { |
|
| 1341 | + $user = $this->user; |
|
| 1342 | + } |
|
| 1264 | 1343 | if ($user == $this->user) |
| 1265 | 1344 | { |
| 1266 | 1345 | $grants = $this->grants; |
@@ -1299,7 +1378,10 @@ discard block |
||
| 1299 | 1378 | $grant = $grants[$owner]; |
| 1300 | 1379 | |
| 1301 | 1380 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1302 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1381 | + if ($grant & ~self::ACL_INVITE) |
|
| 1382 | + { |
|
| 1383 | + $grant |= self::ACL_FREEBUSY; |
|
| 1384 | + } |
|
| 1303 | 1385 | |
| 1304 | 1386 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1305 | 1387 | { |
@@ -1325,7 +1407,10 @@ discard block |
||
| 1325 | 1407 | elseif (!is_numeric($uid)) |
| 1326 | 1408 | { |
| 1327 | 1409 | // if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights |
| 1328 | - if ($grant == self::ACL_FREEBUSY) continue; |
|
| 1410 | + if ($grant == self::ACL_FREEBUSY) |
|
| 1411 | + { |
|
| 1412 | + continue; |
|
| 1413 | + } |
|
| 1329 | 1414 | // if we have a resource as participant |
| 1330 | 1415 | $resource = $this->resource_info($uid); |
| 1331 | 1416 | $grant |= $resource['rights']; |
@@ -1476,14 +1561,20 @@ discard block |
||
| 1476 | 1561 | $param = $param ? 'True' : 'False'; |
| 1477 | 1562 | break; |
| 1478 | 1563 | case 'integer': |
| 1479 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1564 | + if ($param >= mktime(0,0,0,1,1,2000)) |
|
| 1565 | + { |
|
| 1566 | + $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1567 | + } |
|
| 1480 | 1568 | break; |
| 1481 | 1569 | } |
| 1482 | 1570 | } |
| 1483 | 1571 | $msg = str_replace('%'.($i-1),$param,$msg); |
| 1484 | 1572 | } |
| 1485 | 1573 | error_log($msg); |
| 1486 | - if ($backtrace) error_log(function_backtrace(1)); |
|
| 1574 | + if ($backtrace) |
|
| 1575 | + { |
|
| 1576 | + error_log(function_backtrace(1)); |
|
| 1577 | + } |
|
| 1487 | 1578 | } |
| 1488 | 1579 | |
| 1489 | 1580 | /** |
@@ -1591,14 +1682,20 @@ discard block |
||
| 1591 | 1682 | function timespan($start_m,$end_m,$both=false) |
| 1592 | 1683 | { |
| 1593 | 1684 | $duration = $end_m - $start_m; |
| 1594 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1685 | + if ($end_m == 24*60-1) |
|
| 1686 | + { |
|
| 1687 | + ++$duration; |
|
| 1688 | + } |
|
| 1595 | 1689 | $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
| 1596 | 1690 | |
| 1597 | 1691 | $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
| 1598 | 1692 | |
| 1599 | - if ($both) // end-time too |
|
| 1693 | + if ($both) |
|
| 1694 | + { |
|
| 1695 | + // end-time too |
|
| 1600 | 1696 | { |
| 1601 | 1697 | $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
| 1698 | + } |
|
| 1602 | 1699 | // dont double am/pm if they are the same in both times |
| 1603 | 1700 | if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
| 1604 | 1701 | { |
@@ -1622,7 +1719,10 @@ discard block |
||
| 1622 | 1719 | static $id2lid = array(); |
| 1623 | 1720 | static $id2email = array(); |
| 1624 | 1721 | |
| 1625 | - if ($use_type && $use_type != 'u') $id = $use_type.$id; |
|
| 1722 | + if ($use_type && $use_type != 'u') |
|
| 1723 | + { |
|
| 1724 | + $id = $use_type.$id; |
|
| 1725 | + } |
|
| 1626 | 1726 | |
| 1627 | 1727 | if (!isset($id2lid[$id])) |
| 1628 | 1728 | { |
@@ -1632,7 +1732,10 @@ discard block |
||
| 1632 | 1732 | if (($info = $this->resource_info($id))) |
| 1633 | 1733 | { |
| 1634 | 1734 | $id2lid[$id] = $info['name'] ? $info['name'] : $info['email']; |
| 1635 | - if ($info['name']) $id2email[$id] = $info['email']; |
|
| 1735 | + if ($info['name']) |
|
| 1736 | + { |
|
| 1737 | + $id2email[$id] = $info['email']; |
|
| 1738 | + } |
|
| 1636 | 1739 | } |
| 1637 | 1740 | } |
| 1638 | 1741 | else |
@@ -1658,11 +1761,18 @@ discard block |
||
| 1658 | 1761 | $names = array(); |
| 1659 | 1762 | foreach((array)$event['participants'] as $id => $status) |
| 1660 | 1763 | { |
| 1661 | - if (!is_string($status)) continue; |
|
| 1764 | + if (!is_string($status)) |
|
| 1765 | + { |
|
| 1766 | + continue; |
|
| 1767 | + } |
|
| 1662 | 1768 | $quantity = $role = null; |
| 1663 | 1769 | calendar_so::split_status($status,$quantity,$role); |
| 1664 | 1770 | |
| 1665 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1771 | + if ($status == 'G' && !$show_group_invitation) |
|
| 1772 | + { |
|
| 1773 | + continue; |
|
| 1774 | + } |
|
| 1775 | + // dont show group-invitation |
|
| 1666 | 1776 | |
| 1667 | 1777 | $lang_status = lang($this->verbose_status[$status]); |
| 1668 | 1778 | if (!$long_status) |
@@ -1735,7 +1845,10 @@ discard block |
||
| 1735 | 1845 | |
| 1736 | 1846 | foreach(explode(',',$category) as $cat_id) |
| 1737 | 1847 | { |
| 1738 | - if (!$cat_id) continue; |
|
| 1848 | + if (!$cat_id) |
|
| 1849 | + { |
|
| 1850 | + continue; |
|
| 1851 | + } |
|
| 1739 | 1852 | |
| 1740 | 1853 | if (!isset($id2cat[$cat_id])) |
| 1741 | 1854 | { |
@@ -1801,7 +1914,10 @@ discard block |
||
| 1801 | 1914 | */ |
| 1802 | 1915 | public static function list_calendars($user, array $grants=null) |
| 1803 | 1916 | { |
| 1804 | - if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1917 | + if (is_null($grants)) |
|
| 1918 | + { |
|
| 1919 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1920 | + } |
|
| 1805 | 1921 | |
| 1806 | 1922 | $users = $groups = array(); |
| 1807 | 1923 | foreach(array_keys($grants) as $id) |
@@ -1849,7 +1965,10 @@ discard block |
||
| 1849 | 1965 | */ |
| 1850 | 1966 | function recure2string($event) |
| 1851 | 1967 | { |
| 1852 | - if (!is_array($event)) return false; |
|
| 1968 | + if (!is_array($event)) |
|
| 1969 | + { |
|
| 1970 | + return false; |
|
| 1971 | + } |
|
| 1853 | 1972 | return (string)calendar_rrule::event2rrule($event); |
| 1854 | 1973 | } |
| 1855 | 1974 | |
@@ -1868,7 +1987,10 @@ discard block |
||
| 1868 | 1987 | */ |
| 1869 | 1988 | function read_holidays($year=0) |
| 1870 | 1989 | { |
| 1871 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 1990 | + if (!$year) |
|
| 1991 | + { |
|
| 1992 | + $year = (int) date('Y',$this->now_su); |
|
| 1993 | + } |
|
| 1872 | 1994 | |
| 1873 | 1995 | $holidays = calendar_holidays::read( |
| 1874 | 1996 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
@@ -1963,7 +2085,10 @@ discard block |
||
| 1963 | 2085 | } |
| 1964 | 2086 | } |
| 1965 | 2087 | $str_fields = implode(', ',$extra_fields); |
| 1966 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2088 | + if (is_array($extra_fields)) |
|
| 2089 | + { |
|
| 2090 | + return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2091 | + } |
|
| 1967 | 2092 | } |
| 1968 | 2093 | return $this->format_date($event['start']) . ': ' . $event['title']; |
| 1969 | 2094 | } |
@@ -1984,7 +2109,8 @@ discard block |
||
| 1984 | 2109 | 'offset' => $options['start'], |
| 1985 | 2110 | 'order' => 'cal_start DESC', |
| 1986 | 2111 | ); |
| 1987 | - if($options['num_rows']) { |
|
| 2112 | + if($options['num_rows']) |
|
| 2113 | + { |
|
| 1988 | 2114 | $query['num_rows'] = $options['num_rows']; |
| 1989 | 2115 | } |
| 1990 | 2116 | foreach((array) $this->search($query) as $event) |
@@ -2045,7 +2171,10 @@ discard block |
||
| 2045 | 2171 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 2046 | 2172 | { |
| 2047 | 2173 | $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
| 2048 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2174 | + if ($type == 'forced') |
|
| 2175 | + { |
|
| 2176 | + $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2177 | + } |
|
| 2049 | 2178 | $this->cal_prefs[$var] = $default; |
| 2050 | 2179 | $need_save = True; |
| 2051 | 2180 | } |
@@ -2065,7 +2194,10 @@ discard block |
||
| 2065 | 2194 | */ |
| 2066 | 2195 | static function freebusy_url($user='',$pw=null) |
| 2067 | 2196 | { |
| 2068 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2197 | + if (is_numeric($user)) |
|
| 2198 | + { |
|
| 2199 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2200 | + } |
|
| 2069 | 2201 | |
| 2070 | 2202 | $credentials = ''; |
| 2071 | 2203 | |
@@ -2133,13 +2265,19 @@ discard block |
||
| 2133 | 2265 | */ |
| 2134 | 2266 | public function get_ctag($user, $filter='owner', $master_only=false) |
| 2135 | 2267 | { |
| 2136 | - if ($this->debug > 1) $startime = microtime(true); |
|
| 2268 | + if ($this->debug > 1) |
|
| 2269 | + { |
|
| 2270 | + $startime = microtime(true); |
|
| 2271 | + } |
|
| 2137 | 2272 | |
| 2138 | 2273 | // resolve users to add memberships for users and members for groups |
| 2139 | 2274 | $users = $this->resolve_users($user); |
| 2140 | 2275 | $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
| 2141 | 2276 | |
| 2142 | - 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"); |
|
| 2277 | + if ($this->debug > 1) |
|
| 2278 | + { |
|
| 2279 | + error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2280 | + } |
|
| 2143 | 2281 | return $ctag; |
| 2144 | 2282 | } |
| 2145 | 2283 | |
@@ -2181,15 +2319,21 @@ discard block |
||
| 2181 | 2319 | $content['link_app'][] = $link['app']; |
| 2182 | 2320 | $content['link_id'][] = $link['id']; |
| 2183 | 2321 | } |
| 2184 | - if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above |
|
| 2322 | + if ($link['app'] == 'addressbook') |
|
| 2323 | + { |
|
| 2324 | + // prefering contact as primary contact over calendar entry set above |
|
| 2185 | 2325 | { |
| 2186 | 2326 | $content['info_contact'] = 'addressbook:'.$link['id']; |
| 2187 | 2327 | } |
| 2328 | + } |
|
| 2188 | 2329 | } |
| 2189 | 2330 | // Copy same custom fields |
| 2190 | 2331 | foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
| 2191 | 2332 | { |
| 2192 | - if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
|
| 2333 | + if ($this->customfields[$name]) |
|
| 2334 | + { |
|
| 2335 | + $content['#'.$name] = $calendar['#'.$name]; |
|
| 2336 | + } |
|
| 2193 | 2337 | } |
| 2194 | 2338 | //error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content)); |
| 2195 | 2339 | return $content; |
@@ -2212,7 +2356,11 @@ discard block |
||
| 2212 | 2356 | $set['ts_title'] = $this->link_title($event); |
| 2213 | 2357 | $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
| 2214 | 2358 | $set['ts_description'] = $event['description']; |
| 2215 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2359 | + if ($this->isWholeDay($event)) |
|
| 2360 | + { |
|
| 2361 | + $event['end']++; |
|
| 2362 | + } |
|
| 2363 | + // whole day events are 1sec short |
|
| 2216 | 2364 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2217 | 2365 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2218 | 2366 | $set['end_time'] = null; // unset end-time |