@@ -42,7 +42,10 @@ discard block |
||
| 42 | 42 | public static function isJSONRequest($set=null) |
| 43 | 43 | { |
| 44 | 44 | $ret = self::$_hadJSONRequest; |
| 45 | - if (isset($set)) self::$_hadJSONRequest = $set; |
|
| 45 | + if (isset($set)) |
|
| 46 | + { |
|
| 47 | + self::$_hadJSONRequest = $set; |
|
| 48 | + } |
|
| 46 | 49 | return $ret; |
| 47 | 50 | } |
| 48 | 51 | |
@@ -60,7 +63,10 @@ discard block |
||
| 60 | 63 | // Remember that we currently are in a JSON request - e.g. used in the redirect code |
| 61 | 64 | self::$_hadJSONRequest = true; |
| 62 | 65 | |
| 63 | - if (get_magic_quotes_gpc()) $input_data = stripslashes($input_data); |
|
| 66 | + if (get_magic_quotes_gpc()) |
|
| 67 | + { |
|
| 68 | + $input_data = stripslashes($input_data); |
|
| 69 | + } |
|
| 64 | 70 | |
| 65 | 71 | $json_data = json_decode($input_data,true); |
| 66 | 72 | if (is_array($json_data) && isset($json_data['request']) && isset($json_data['request']['parameters']) && is_array($json_data['request']['parameters'])) |
@@ -100,9 +106,12 @@ discard block |
||
| 100 | 106 | */ |
| 101 | 107 | public function handleRequest($menuaction, array $parameters) |
| 102 | 108 | { |
| 103 | - if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false) // static method name app_something::method |
|
| 109 | + if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false) |
|
| 110 | + { |
|
| 111 | + // static method name app_something::method |
|
| 104 | 112 | { |
| 105 | 113 | @list($className,$functionName,$handler) = explode('::',$menuaction); |
| 114 | + } |
|
| 106 | 115 | if (substr($className, 0, 11) == 'EGroupware\\') |
| 107 | 116 | { |
| 108 | 117 | list(,$appName) = explode('\\', strtolower($className)); |
@@ -179,6 +188,9 @@ discard block |
||
| 179 | 188 | Api\Translation::convert($parameters, 'utf-8')); |
| 180 | 189 | |
| 181 | 190 | // check if we have push notifications, if notifications app available |
| 182 | - if (class_exists('notifications_push')) notifications_push::get(); |
|
| 191 | + if (class_exists('notifications_push')) |
|
| 192 | + { |
|
| 193 | + notifications_push::get(); |
|
| 194 | + } |
|
| 183 | 195 | } |
| 184 | 196 | } |
@@ -268,7 +268,10 @@ |
||
| 268 | 268 | */ |
| 269 | 269 | public static function fix_content($var, $prefix='') |
| 270 | 270 | { |
| 271 | - if (json_encode($var) !== false) return $var; |
|
| 271 | + if (json_encode($var) !== false) |
|
| 272 | + { |
|
| 273 | + return $var; |
|
| 274 | + } |
|
| 272 | 275 | |
| 273 | 276 | if (is_scalar($var)) |
| 274 | 277 | { |
@@ -76,7 +76,10 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $this->filename = $filename; |
| 78 | 78 | |
| 79 | - if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename; |
|
| 79 | + if (!$this->filenames || !in_array($filename,$this->filenames)) |
|
| 80 | + { |
|
| 81 | + $this->filenames[] = $filename; |
|
| 82 | + } |
|
| 80 | 83 | } |
| 81 | 84 | } |
| 82 | 85 | |
@@ -93,7 +96,10 @@ discard block |
||
| 93 | 96 | { |
| 94 | 97 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
| 95 | 98 | } |
| 96 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 99 | + if ($filename[0] != '/') |
|
| 100 | + { |
|
| 101 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | if (file_exists($filename)) |
| 99 | 105 | { |
@@ -101,7 +107,10 @@ discard block |
||
| 101 | 107 | if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE) |
| 102 | 108 | { |
| 103 | 109 | $start = $size - 4*self::MAX_CHUNK_SIZE; |
| 104 | - if ($start < 0) $start = 0; |
|
| 110 | + if ($start < 0) |
|
| 111 | + { |
|
| 112 | + $start = 0; |
|
| 113 | + } |
|
| 105 | 114 | } |
| 106 | 115 | $hsize = Api\Vfs::hsize($size); |
| 107 | 116 | $content = file_get_contents($filename, false, null, $start, self::MAX_CHUNK_SIZE); |
@@ -137,7 +146,10 @@ discard block |
||
| 137 | 146 | { |
| 138 | 147 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
| 139 | 148 | } |
| 140 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 149 | + if ($filename[0] != '/') |
|
| 150 | + { |
|
| 151 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 152 | + } |
|
| 141 | 153 | if ($truncate) |
| 142 | 154 | { |
| 143 | 155 | file_put_contents($filename, ''); |
@@ -161,7 +173,10 @@ discard block |
||
| 161 | 173 | { |
| 162 | 174 | throw new Api\Exception\WrongParameter("Must be instanciated with filename!"); |
| 163 | 175 | } |
| 164 | - if (is_null($header)) $header = $this->filename; |
|
| 176 | + if (is_null($header)) |
|
| 177 | + { |
|
| 178 | + $header = $this->filename; |
|
| 179 | + } |
|
| 165 | 180 | |
| 166 | 181 | return ' |
| 167 | 182 | <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p> |
@@ -192,7 +207,10 @@ discard block |
||
| 192 | 207 | throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!"); |
| 193 | 208 | } |
| 194 | 209 | Api\Header\Content::type(basename($filename), 'text/plain'); |
| 195 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 210 | + if ($filename[0] != '/') |
|
| 211 | + { |
|
| 212 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
| 213 | + } |
|
| 196 | 214 | for($n=ob_get_level(); $n > 0; --$n) |
| 197 | 215 | { |
| 198 | 216 | ob_end_clean(); // stop all output buffering, to NOT run into memory_limit |
@@ -20,4 +20,6 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * As you get this only by an error in the code or during development, the message does not need to be translated |
| 22 | 22 | */ |
| 23 | -class Exception extends Api\Exception\WrongParameter { } |
|
| 23 | +class Exception extends Api\Exception\WrongParameter |
|
| 24 | +{ |
|
| 25 | +} |
|
@@ -97,7 +97,10 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
| 99 | 99 | { |
| 100 | - if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
| 100 | + if ($this->debug) |
|
| 101 | + { |
|
| 102 | + error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
| 103 | + } |
|
| 101 | 104 | $this->path = $path; |
| 102 | 105 | $this->handler = $handler; |
| 103 | 106 | $this->filter = $filter; |
@@ -112,7 +115,10 @@ discard block |
||
| 112 | 115 | */ |
| 113 | 116 | public function current() |
| 114 | 117 | { |
| 115 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
| 118 | + if ($this->debug) |
|
| 119 | + { |
|
| 120 | + error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
| 121 | + } |
|
| 116 | 122 | return current($this->files); |
| 117 | 123 | } |
| 118 | 124 | |
@@ -125,7 +131,10 @@ discard block |
||
| 125 | 131 | { |
| 126 | 132 | $current = current($this->files); |
| 127 | 133 | |
| 128 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
| 134 | + if ($this->debug) |
|
| 135 | + { |
|
| 136 | + error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
| 137 | + } |
|
| 129 | 138 | return $current['path']; // we return path as key |
| 130 | 139 | } |
| 131 | 140 | |
@@ -136,26 +145,38 @@ discard block |
||
| 136 | 145 | { |
| 137 | 146 | if (next($this->files) !== false) |
| 138 | 147 | { |
| 139 | - if ($this->debug) error_log(__METHOD__."() returning TRUE"); |
|
| 148 | + if ($this->debug) |
|
| 149 | + { |
|
| 150 | + error_log(__METHOD__."() returning TRUE"); |
|
| 151 | + } |
|
| 140 | 152 | return true; |
| 141 | 153 | } |
| 142 | 154 | // check if previous query gave less then CHUNK_SIZE entries --> we're done |
| 143 | 155 | if ($this->start && count($this->files) < self::CHUNK_SIZE) |
| 144 | 156 | { |
| 145 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
| 157 | + if ($this->debug) |
|
| 158 | + { |
|
| 159 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
| 160 | + } |
|
| 146 | 161 | return false; |
| 147 | 162 | } |
| 148 | 163 | // try query further files via propfind callback of handler and store result in $this->files |
| 149 | 164 | $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
| 150 | 165 | if (!is_array($this->files) || !($entries = count($this->files))) |
| 151 | 166 | { |
| 152 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
| 167 | + if ($this->debug) |
|
| 168 | + { |
|
| 169 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
| 170 | + } |
|
| 153 | 171 | return false; // no further entries |
| 154 | 172 | } |
| 155 | 173 | $this->start += self::CHUNK_SIZE; |
| 156 | 174 | reset($this->files); |
| 157 | 175 | |
| 158 | - if ($this->debug) error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
| 176 | + if ($this->debug) |
|
| 177 | + { |
|
| 178 | + error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
| 179 | + } |
|
| 159 | 180 | |
| 160 | 181 | return current($this->files) !== false; |
| 161 | 182 | } |
@@ -165,11 +186,18 @@ discard block |
||
| 165 | 186 | */ |
| 166 | 187 | public function rewind() |
| 167 | 188 | { |
| 168 | - if ($this->debug) error_log(__METHOD__."()"); |
|
| 189 | + if ($this->debug) |
|
| 190 | + { |
|
| 191 | + error_log(__METHOD__."()"); |
|
| 192 | + } |
|
| 169 | 193 | |
| 170 | 194 | $this->start = 0; |
| 171 | 195 | $this->files = $this->common_files; |
| 172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
| 196 | + if (!$this->files) |
|
| 197 | + { |
|
| 198 | + $this->next(); |
|
| 199 | + } |
|
| 200 | + // otherwise valid will return false and nothing get returned |
|
| 173 | 201 | reset($this->files); |
| 174 | 202 | } |
| 175 | 203 | |
@@ -180,7 +208,10 @@ discard block |
||
| 180 | 208 | */ |
| 181 | 209 | public function valid () |
| 182 | 210 | { |
| 183 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
| 211 | + if ($this->debug) |
|
| 212 | + { |
|
| 213 | + error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
| 214 | + } |
|
| 184 | 215 | return current($this->files) !== false; |
| 185 | 216 | } |
| 186 | 217 | } |
@@ -116,7 +116,10 @@ discard block |
||
| 116 | 116 | if (is_callable($callback)) |
| 117 | 117 | { |
| 118 | 118 | $this->callback = $callback; |
| 119 | - if ($add_container) $callback_params[] = $this; |
|
| 119 | + if ($add_container) |
|
| 120 | + { |
|
| 121 | + $callback_params[] = $this; |
|
| 122 | + } |
|
| 120 | 123 | $this->callback_params = $callback_params; |
| 121 | 124 | } |
| 122 | 125 | if (is_string($ical_file)) |
@@ -197,8 +200,14 @@ discard block |
||
| 197 | 200 | { |
| 198 | 201 | $ret = is_a($this->component,'Horde_Icalendar'); |
| 199 | 202 | do { |
| 200 | - if ($ret === false) $this->next(); |
|
| 201 | - if (!is_a($this->component,'Horde_Icalendar')) return false; |
|
| 203 | + if ($ret === false) |
|
| 204 | + { |
|
| 205 | + $this->next(); |
|
| 206 | + } |
|
| 207 | + if (!is_a($this->component,'Horde_Icalendar')) |
|
| 208 | + { |
|
| 209 | + return false; |
|
| 210 | + } |
|
| 202 | 211 | $params = $this->callback_params; |
| 203 | 212 | array_unshift($params,$this->component); |
| 204 | 213 | } |
@@ -231,9 +240,12 @@ discard block |
||
| 231 | 240 | { |
| 232 | 241 | // ignore it |
| 233 | 242 | } |
| 234 | - if ($line === false) // end-of-file or end-of-container |
|
| 243 | + if ($line === false) |
|
| 244 | + { |
|
| 245 | + // end-of-file or end-of-container |
|
| 235 | 246 | { |
| 236 | 247 | $this->component = false; |
| 248 | + } |
|
| 237 | 249 | return; |
| 238 | 250 | } |
| 239 | 251 | $type = substr(trim($line),6); |
@@ -309,7 +321,10 @@ discard block |
||
| 309 | 321 | //error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')"); |
| 310 | 322 | $this->parsevCalendar($data,$this->base,$this->charset); |
| 311 | 323 | } |
| 312 | - if ($line) $this->unread_line($line); |
|
| 324 | + if ($line) |
|
| 325 | + { |
|
| 326 | + $this->unread_line($line); |
|
| 327 | + } |
|
| 313 | 328 | |
| 314 | 329 | // advance to first element |
| 315 | 330 | $this->next(); |
@@ -438,7 +453,10 @@ discard block |
||
| 438 | 453 | '; |
| 439 | 454 | echo $GLOBALS['egw']->framework->header(); |
| 440 | 455 | //$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics'); |
| 441 | - if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n"; |
|
| 456 | + if (!is_resource($ical_file)) |
|
| 457 | + { |
|
| 458 | + echo "<pre>$ical_file</pre>\n"; |
|
| 459 | + } |
|
| 442 | 460 | //$calendar_ical = new calendar_ical(); |
| 443 | 461 | //$calendar_ical->setSupportedFields('file'); |
| 444 | 462 | $ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
@@ -446,5 +464,8 @@ discard block |
||
| 446 | 464 | { |
| 447 | 465 | echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n"; |
| 448 | 466 | } |
| 449 | - if (is_resource($ical_file)) fclose($ical_file); |
|
| 450 | -} |
|
| 451 | 467 | \ No newline at end of file |
| 468 | + if (is_resource($ical_file)) |
|
| 469 | + { |
|
| 470 | + fclose($ical_file); |
|
| 471 | + } |
|
| 472 | + } |
|
| 452 | 473 | \ No newline at end of file |
@@ -123,7 +123,10 @@ discard block |
||
| 123 | 123 | function __construct($app, Api\CalDAV $caldav) |
| 124 | 124 | { |
| 125 | 125 | $this->app = $app; |
| 126 | - if (!is_null($caldav->debug)) $this->debug = $caldav->debug; |
|
| 126 | + if (!is_null($caldav->debug)) |
|
| 127 | + { |
|
| 128 | + $this->debug = $caldav->debug; |
|
| 129 | + } |
|
| 127 | 130 | $this->base_uri = $caldav->base_uri; |
| 128 | 131 | $this->caldav = $caldav; |
| 129 | 132 | |
@@ -282,11 +285,17 @@ discard block |
||
| 282 | 285 | */ |
| 283 | 286 | function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false) |
| 284 | 287 | { |
| 285 | - if (self::$path_extension) $id = basename($id,self::$path_extension); |
|
| 288 | + if (self::$path_extension) |
|
| 289 | + { |
|
| 290 | + $id = basename($id,self::$path_extension); |
|
| 291 | + } |
|
| 286 | 292 | |
| 287 | 293 | if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app]) |
| 288 | 294 | { |
| 289 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
| 295 | + if ($this->debug) |
|
| 296 | + { |
|
| 297 | + error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
| 298 | + } |
|
| 290 | 299 | return '403 Forbidden'; // no app rights |
| 291 | 300 | } |
| 292 | 301 | $extra_acl = $this->method2acl[$method]; |
@@ -295,12 +304,18 @@ discard block |
||
| 295 | 304 | { |
| 296 | 305 | if ($return_no_access && !is_null($entry)) |
| 297 | 306 | { |
| 298 | - if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
| 307 | + if ($this->debug) |
|
| 308 | + { |
|
| 309 | + error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
| 310 | + } |
|
| 299 | 311 | $return_no_access = false; |
| 300 | 312 | } |
| 301 | 313 | else |
| 302 | 314 | { |
| 303 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
| 315 | + if ($this->debug) |
|
| 316 | + { |
|
| 317 | + error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
| 318 | + } |
|
| 304 | 319 | return !is_null($entry) ? '403 Forbidden' : '404 Not Found'; |
| 305 | 320 | } |
| 306 | 321 | } |
@@ -313,11 +328,17 @@ discard block |
||
| 313 | 328 | { |
| 314 | 329 | $this->http_if_match = $_SERVER['HTTP_IF_MATCH']; |
| 315 | 330 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
| 316 | - if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
| 331 | + if ($this->http_if_match[0] == '"') |
|
| 332 | + { |
|
| 333 | + $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
| 334 | + } |
|
| 317 | 335 | |
| 318 | 336 | if ($this->http_if_match !== $etag) |
| 319 | 337 | { |
| 320 | - if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
| 338 | + if ($this->debug) |
|
| 339 | + { |
|
| 340 | + error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
| 341 | + } |
|
| 321 | 342 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 322 | 343 | $this->check_return_representation($options, $id); |
| 323 | 344 | return '412 Precondition Failed'; |
@@ -327,17 +348,26 @@ discard block |
||
| 327 | 348 | { |
| 328 | 349 | $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; |
| 329 | 350 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
| 330 | - if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1); |
|
| 351 | + if ($if_none_match[0] == '"') |
|
| 352 | + { |
|
| 353 | + $if_none_match = substr($if_none_match, 1, -1); |
|
| 354 | + } |
|
| 331 | 355 | |
| 332 | 356 | // if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date |
| 333 | 357 | if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match) |
| 334 | 358 | { |
| 335 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
| 359 | + if ($this->debug) |
|
| 360 | + { |
|
| 361 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
| 362 | + } |
|
| 336 | 363 | return '304 Not Modified'; |
| 337 | 364 | } |
| 338 | 365 | if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag)) |
| 339 | 366 | { |
| 340 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
| 367 | + if ($this->debug) |
|
| 368 | + { |
|
| 369 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
| 370 | + } |
|
| 341 | 371 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 342 | 372 | $this->check_return_representation($options, $id); |
| 343 | 373 | return '412 Precondition Failed'; |
@@ -376,7 +406,10 @@ discard block |
||
| 376 | 406 | |
| 377 | 407 | if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data'])) |
| 378 | 408 | { |
| 379 | - if (!$this->caldav->use_compression()) header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
| 409 | + if (!$this->caldav->use_compression()) |
|
| 410 | + { |
|
| 411 | + header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
| 412 | + } |
|
| 380 | 413 | header('Content-Type: '.$options['mimetype']); |
| 381 | 414 | echo $options['data']; |
| 382 | 415 | } |
@@ -412,7 +445,10 @@ discard block |
||
| 412 | 445 | if (!array_key_exists($app,$handler_cache)) |
| 413 | 446 | { |
| 414 | 447 | $class = $app.'_groupdav'; |
| 415 | - if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) return null; |
|
| 448 | + if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) |
|
| 449 | + { |
|
| 450 | + return null; |
|
| 451 | + } |
|
| 416 | 452 | |
| 417 | 453 | $handler_cache[$app] = new $class($app, $groupdav); |
| 418 | 454 | } |
@@ -474,7 +510,10 @@ discard block |
||
| 474 | 510 | $matches = null; |
| 475 | 511 | if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches)) |
| 476 | 512 | { |
| 477 | - if ((int)$matches[1] < 868) $agent .= '_old'; |
|
| 513 | + if ((int)$matches[1] < 868) |
|
| 514 | + { |
|
| 515 | + $agent .= '_old'; |
|
| 516 | + } |
|
| 478 | 517 | } |
| 479 | 518 | break; |
| 480 | 519 | case 'kde': |
@@ -575,7 +614,10 @@ discard block |
||
| 575 | 614 | // --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte |
| 576 | 615 | //if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning'))) |
| 577 | 616 | { |
| 578 | - if (is_null($etag)) $etag = $this->get_etag($entry); |
|
| 617 | + if (is_null($etag)) |
|
| 618 | + { |
|
| 619 | + $etag = $this->get_etag($entry); |
|
| 620 | + } |
|
| 579 | 621 | header('ETag: "'.$etag.'"'); |
| 580 | 622 | } |
| 581 | 623 | |
@@ -741,7 +783,10 @@ discard block |
||
| 741 | 783 | */ |
| 742 | 784 | public function get_sync_token($path, $user, $token=null) |
| 743 | 785 | { |
| 744 | - if (!isset($token)) $token = $this->getctag($path, $user); |
|
| 786 | + if (!isset($token)) |
|
| 787 | + { |
|
| 788 | + $token = $this->getctag($path, $user); |
|
| 789 | + } |
|
| 745 | 790 | |
| 746 | 791 | // never return current time, as more modifications might happen due to second granularity --> return 1sec less |
| 747 | 792 | if ($token >= (int)$GLOBALS['egw_info']['flags']['page_start_time']) |
@@ -49,7 +49,10 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | parent::__construct($app, $caldav); |
| 51 | 51 | |
| 52 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
| 52 | + if (!isset(self::$resources)) |
|
| 53 | + { |
|
| 54 | + self::$resources = new resources_bo(); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | /** |
@@ -93,7 +96,10 @@ discard block |
||
| 93 | 96 | { |
| 94 | 97 | unset($path); // not used, but required by function signature |
| 95 | 98 | |
| 96 | - if (is_null($reports)) $reports = $this->supported_reports; |
|
| 99 | + if (is_null($reports)) |
|
| 100 | + { |
|
| 101 | + $reports = $this->supported_reports; |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | $supported = array(); |
| 99 | 105 | foreach($reports as $name => $data) |
@@ -264,7 +270,10 @@ discard block |
||
| 264 | 270 | $requested_props = $options['other']; |
| 265 | 271 | while(($requested_prop = array_shift($requested_props))) |
| 266 | 272 | { |
| 267 | - if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue; |
|
| 273 | + if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) |
|
| 274 | + { |
|
| 275 | + continue; |
|
| 276 | + } |
|
| 268 | 277 | |
| 269 | 278 | $prop_ns = $requested_prop['attrs']['namespace']; |
| 270 | 279 | $prop_name = $requested_prop['attrs']['name']; |
@@ -303,7 +312,10 @@ discard block |
||
| 303 | 312 | // find prop to expand |
| 304 | 313 | foreach($prop_files['files'][0]['props'] as $expand_prop) |
| 305 | 314 | { |
| 306 | - if ($expand_prop['name'] === $prop_name) break; |
|
| 315 | + if ($expand_prop['name'] === $prop_name) |
|
| 316 | + { |
|
| 317 | + break; |
|
| 318 | + } |
|
| 307 | 319 | } |
| 308 | 320 | if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) || |
| 309 | 321 | $expand_prop['val'] && $expand_prop['val'][0]['name'] !== 'href') |
@@ -319,10 +331,13 @@ discard block |
||
| 319 | 331 | { |
| 320 | 332 | if ($prop['name'] == 'property' && $prop['depth'] == 2) |
| 321 | 333 | { |
| 322 | - if (!is_array($options2['props'])) // is "all" initially |
|
| 334 | + if (!is_array($options2['props'])) |
|
| 335 | + { |
|
| 336 | + // is "all" initially |
|
| 323 | 337 | { |
| 324 | 338 | $options2['props'] = array(); |
| 325 | 339 | } |
| 340 | + } |
|
| 326 | 341 | $options2['props'][] = array( |
| 327 | 342 | 'name' => $prop['attrs']['name'], |
| 328 | 343 | 'xmlns' => isset($prop['attrs']['namespace']) ? $prop['attrs']['namespace'] : $prop['xmlns'], |
@@ -330,7 +345,10 @@ discard block |
||
| 330 | 345 | } |
| 331 | 346 | } |
| 332 | 347 | // put back evtl. read top-level property |
| 333 | - if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop); |
|
| 348 | + if ($prop && $prop['depth'] == 1) |
|
| 349 | + { |
|
| 350 | + array_unshift($requested_props, $prop); |
|
| 351 | + } |
|
| 334 | 352 | $this->caldav->options = $options2; // also modify global variable |
| 335 | 353 | |
| 336 | 354 | // run regular profind to get requested 2.-level properties for each href |
@@ -526,9 +544,12 @@ discard block |
||
| 526 | 544 | // now filter out not matching "files" |
| 527 | 545 | foreach($files['files'] as $n => $resource) |
| 528 | 546 | { |
| 529 | - if (count(explode('/', $resource['path'])) < 5) // hack to only return principals, not the collections itself |
|
| 547 | + if (count(explode('/', $resource['path'])) < 5) |
|
| 548 | + { |
|
| 549 | + // hack to only return principals, not the collections itself |
|
| 530 | 550 | { |
| 531 | 551 | unset($files['files'][$n]); |
| 552 | + } |
|
| 532 | 553 | continue; |
| 533 | 554 | } |
| 534 | 555 | // match with $search_props |
@@ -538,16 +559,26 @@ discard block |
||
| 538 | 559 | // search resource for $search_prop |
| 539 | 560 | foreach($resource['props'] as $prop) |
| 540 | 561 | { |
| 541 | - if ($prop['name'] === $search_prop['name']) break; |
|
| 562 | + if ($prop['name'] === $search_prop['name']) |
|
| 563 | + { |
|
| 564 | + break; |
|
| 565 | + } |
|
| 542 | 566 | } |
| 543 | - if ($prop['name'] === $search_prop['name']) // search_prop NOT found |
|
| 567 | + if ($prop['name'] === $search_prop['name']) |
|
| 568 | + { |
|
| 569 | + // search_prop NOT found |
|
| 544 | 570 | { |
| 545 | 571 | foreach((array)$prop['val'] as $value) |
| 546 | 572 | { |
| 547 | - if (is_array($value)) $value = $value['val']; // eg. href prop |
|
| 548 | - if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) // prop does match |
|
| 573 | + if (is_array($value)) $value = $value['val']; |
|
| 574 | + } |
|
| 575 | + // eg. href prop |
|
| 576 | + if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) |
|
| 577 | + { |
|
| 578 | + // prop does match |
|
| 549 | 579 | { |
| 550 | 580 | ++$matches; |
| 581 | + } |
|
| 551 | 582 | //error_log("$matches: $resource[path]: $search_prop[name]=".array2string($prop['name'] !== $search_prop['name'] ? null : $prop['val'])." does match '$search_prop[match]'"); |
| 552 | 583 | break; |
| 553 | 584 | } |
@@ -749,7 +780,10 @@ discard block |
||
| 749 | 780 | { |
| 750 | 781 | foreach($resource['props']['resourcetype']['val'] as $prop) |
| 751 | 782 | { |
| 752 | - if ($prop['name'] == 'principal') continue 2; |
|
| 783 | + if ($prop['name'] == 'principal') |
|
| 784 | + { |
|
| 785 | + continue 2; |
|
| 786 | + } |
|
| 753 | 787 | } |
| 754 | 788 | unset($files['files'][$n]); // not a principal --> do not return |
| 755 | 789 | } |
@@ -903,7 +937,11 @@ discard block |
||
| 903 | 937 | { |
| 904 | 938 | $addressbooks = array(); |
| 905 | 939 | $ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
| 906 | - if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
| 940 | + if (empty($ab_home_set)) |
|
| 941 | + { |
|
| 942 | + $ab_home_set = 'P'; |
|
| 943 | + } |
|
| 944 | + // personal addressbook |
|
| 907 | 945 | $addressbook_home_set = explode(',', $ab_home_set); |
| 908 | 946 | // replace symbolic id's with real nummeric id's |
| 909 | 947 | foreach(array( |
@@ -917,10 +955,13 @@ discard block |
||
| 917 | 955 | $addressbook_home_set[$key] = $id; |
| 918 | 956 | } |
| 919 | 957 | } |
| 920 | - if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
| 958 | + if (in_array('O',$addressbook_home_set)) |
|
| 959 | + { |
|
| 960 | + // "all in one" from groupdav.php/addressbook/ |
|
| 921 | 961 | { |
| 922 | 962 | $addressbooks[] = '/'; |
| 923 | 963 | } |
| 964 | + } |
|
| 924 | 965 | foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
| 925 | 966 | { |
| 926 | 967 | if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && |
@@ -999,7 +1040,10 @@ discard block |
||
| 999 | 1040 | */ |
| 1000 | 1041 | static public function url2uid($url, $only_type=null, $cn=null) |
| 1001 | 1042 | { |
| 1002 | - if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
| 1043 | + if (!$only_type) |
|
| 1044 | + { |
|
| 1045 | + $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
| 1046 | + } |
|
| 1003 | 1047 | |
| 1004 | 1048 | if ($url[0] == '/') |
| 1005 | 1049 | { |
@@ -1009,7 +1053,10 @@ discard block |
||
| 1009 | 1053 | { |
| 1010 | 1054 | list($schema, $rest) = explode(':', $url, 2); |
| 1011 | 1055 | } |
| 1012 | - if (empty($rest)) return false; |
|
| 1056 | + if (empty($rest)) |
|
| 1057 | + { |
|
| 1058 | + return false; |
|
| 1059 | + } |
|
| 1013 | 1060 | |
| 1014 | 1061 | switch(strtolower($schema)) |
| 1015 | 1062 | { |
@@ -1056,9 +1103,12 @@ discard block |
||
| 1056 | 1103 | case 'urn': |
| 1057 | 1104 | list($urn_type, $uid) = explode(':', $rest, 2); |
| 1058 | 1105 | list($type, $id, $install_id) = explode('-', $uid); |
| 1059 | - if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
| 1106 | + if ($type == 'accounts' && empty($id)) |
|
| 1107 | + { |
|
| 1108 | + // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
| 1060 | 1109 | { |
| 1061 | 1110 | list($type, , $id_abs, $install_id) = explode('-', $uid); |
| 1111 | + } |
|
| 1062 | 1112 | $id = -$id_abs; |
| 1063 | 1113 | } |
| 1064 | 1114 | // own urn |
@@ -1072,7 +1122,10 @@ discard block |
||
| 1072 | 1122 | else |
| 1073 | 1123 | { |
| 1074 | 1124 | static $calendar_bo=null; |
| 1075 | - if (is_null($calendar_bo)) $calendar_bo = new calendar_bo(); |
|
| 1125 | + if (is_null($calendar_bo)) |
|
| 1126 | + { |
|
| 1127 | + $calendar_bo = new calendar_bo(); |
|
| 1128 | + } |
|
| 1076 | 1129 | foreach($calendar_bo->resources as $letter => $info) |
| 1077 | 1130 | { |
| 1078 | 1131 | if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location') |
@@ -1179,7 +1232,10 @@ discard block |
||
| 1179 | 1232 | { |
| 1180 | 1233 | return null; |
| 1181 | 1234 | } |
| 1182 | - if (is_null($is_location)) $is_location = self::resource_is_location($resource); |
|
| 1235 | + if (is_null($is_location)) |
|
| 1236 | + { |
|
| 1237 | + $is_location = self::resource_is_location($resource); |
|
| 1238 | + } |
|
| 1183 | 1239 | |
| 1184 | 1240 | $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
| 1185 | 1241 | |
@@ -1225,7 +1281,10 @@ discard block |
||
| 1225 | 1281 | |
| 1226 | 1282 | if (!isset($cache[$res_id])) |
| 1227 | 1283 | { |
| 1228 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
| 1284 | + if (!isset(self::$resources)) |
|
| 1285 | + { |
|
| 1286 | + self::$resources = new resources_bo(); |
|
| 1287 | + } |
|
| 1229 | 1288 | |
| 1230 | 1289 | if (!($cache[$res_id] = self::$resources->read($res_id))) |
| 1231 | 1290 | { |
@@ -1262,7 +1321,10 @@ discard block |
||
| 1262 | 1321 | { |
| 1263 | 1322 | if (!isset(self::$all_resources)) |
| 1264 | 1323 | { |
| 1265 | - if (!isset(self::$resources)) self::$resources = new resources_bo($user); |
|
| 1324 | + if (!isset(self::$resources)) |
|
| 1325 | + { |
|
| 1326 | + self::$resources = new resources_bo($user); |
|
| 1327 | + } |
|
| 1266 | 1328 | |
| 1267 | 1329 | self::$all_resources = array(); |
| 1268 | 1330 | $query = array( |
@@ -1333,9 +1395,15 @@ discard block |
||
| 1333 | 1395 | // required props per WebDAV ACL |
| 1334 | 1396 | foreach(array('alternate-URI-set', 'group-membership') as $name) |
| 1335 | 1397 | { |
| 1336 | - if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,''); |
|
| 1398 | + if (!isset($props[$name])) |
|
| 1399 | + { |
|
| 1400 | + $props[$name] = Api\CalDAV::mkprop($name,''); |
|
| 1401 | + } |
|
| 1402 | + } |
|
| 1403 | + if (!$principal_url) |
|
| 1404 | + { |
|
| 1405 | + $principal_url = $principal; |
|
| 1337 | 1406 | } |
| 1338 | - if (!$principal_url) $principal_url = $principal; |
|
| 1339 | 1407 | |
| 1340 | 1408 | $props['principal-URL'] = array( |
| 1341 | 1409 | Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/')); |
@@ -1358,7 +1426,11 @@ discard block |
||
| 1358 | 1426 | { |
| 1359 | 1427 | list($app,,$what) = explode('-', $type); |
| 1360 | 1428 | |
| 1361 | - if (true) $proxys = array(); // ignore parameter! |
|
| 1429 | + if (true) |
|
| 1430 | + { |
|
| 1431 | + $proxys = array(); |
|
| 1432 | + } |
|
| 1433 | + // ignore parameter! |
|
| 1362 | 1434 | list($account_type,$account) = explode('/', $principal); |
| 1363 | 1435 | |
| 1364 | 1436 | switch($account_type) |
@@ -1440,16 +1512,22 @@ discard block |
||
| 1440 | 1512 | $set = array(); |
| 1441 | 1513 | foreach($accounts as $account_id => $account_lid) |
| 1442 | 1514 | { |
| 1443 | - if ($this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
| 1515 | + if ($this->accounts->visible($account_lid)) |
|
| 1516 | + { |
|
| 1517 | + // only add visible accounts, gives error in iCal otherwise |
|
| 1444 | 1518 | { |
| 1445 | 1519 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/'); |
| 1446 | 1520 | } |
| 1521 | + } |
|
| 1447 | 1522 | } |
| 1448 | 1523 | if ($app_proxys) |
| 1449 | 1524 | { |
| 1450 | 1525 | foreach((array)$app_proxys as $app) |
| 1451 | 1526 | { |
| 1452 | - if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue; |
|
| 1527 | + if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
| 1528 | + { |
|
| 1529 | + continue; |
|
| 1530 | + } |
|
| 1453 | 1531 | |
| 1454 | 1532 | switch($app) |
| 1455 | 1533 | { |
@@ -1490,7 +1568,10 @@ discard block |
||
| 1490 | 1568 | if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) && // we only care for these rights |
| 1491 | 1569 | ($account_id == $account || in_array($account_id, $memberships))) |
| 1492 | 1570 | { |
| 1493 | - if (!isset($location_grants[$location])) $location_grants[$location] = 0; |
|
| 1571 | + if (!isset($location_grants[$location])) |
|
| 1572 | + { |
|
| 1573 | + $location_grants[$location] = 0; |
|
| 1574 | + } |
|
| 1494 | 1575 | $location_grants[$location] |= $rights; |
| 1495 | 1576 | } |
| 1496 | 1577 | } |
@@ -1524,12 +1605,15 @@ discard block |
||
| 1524 | 1605 | { |
| 1525 | 1606 | if ($account_id != $account && ($rights & Api\Acl::READ) && |
| 1526 | 1607 | ($account_lid = $this->accounts->id2name($account_id)) && |
| 1527 | - $this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
| 1608 | + $this->accounts->visible($account_lid)) |
|
| 1609 | + { |
|
| 1610 | + // only add visible accounts, gives error in iCal otherwise |
|
| 1528 | 1611 | { |
| 1529 | 1612 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'. |
| 1530 | 1613 | ($account_id < 0 ? 'groups/' : 'users/'). |
| 1531 | 1614 | $account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/'); |
| 1532 | 1615 | } |
| 1616 | + } |
|
| 1533 | 1617 | } |
| 1534 | 1618 | return $set; |
| 1535 | 1619 | } |
@@ -1621,7 +1705,10 @@ discard block |
||
| 1621 | 1705 | |
| 1622 | 1706 | if ($options['depth']) |
| 1623 | 1707 | { |
| 1624 | - if (is_numeric($options['depth'])) --$options['depth']; |
|
| 1708 | + if (is_numeric($options['depth'])) |
|
| 1709 | + { |
|
| 1710 | + --$options['depth']; |
|
| 1711 | + } |
|
| 1625 | 1712 | $files = array_merge($files, $this->propfind_users('','',$options), |
| 1626 | 1713 | $this->propfind_groups('','',$options)); |
| 1627 | 1714 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
@@ -117,10 +117,13 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | 119 | { |
| 120 | - if (!($this->account = Mail\Account::get_default(true))) // true = need an SMTP (not just IMAP) account |
|
| 120 | + if (!($this->account = Mail\Account::get_default(true))) |
|
| 121 | + { |
|
| 122 | + // true = need an SMTP (not just IMAP) account |
|
| 121 | 123 | { |
| 122 | 124 | throw new Exception\NotFound('SMTP: '.lang('Account not found!')); |
| 123 | 125 | } |
| 126 | + } |
|
| 124 | 127 | } |
| 125 | 128 | |
| 126 | 129 | try |
@@ -167,7 +170,10 @@ discard block |
||
| 167 | 170 | { |
| 168 | 171 | throw new Exception\WrongParameter("Unknown type '$type'!"); |
| 169 | 172 | } |
| 170 | - if ($personal) $address = self::add_personal ($address, $personal); |
|
| 173 | + if ($personal) |
|
| 174 | + { |
|
| 175 | + $address = self::add_personal ($address, $personal); |
|
| 176 | + } |
|
| 171 | 177 | |
| 172 | 178 | // add to our local list |
| 173 | 179 | $this->$type->add($address); |
@@ -239,10 +245,13 @@ discard block |
||
| 239 | 245 | if (is_string($address) && !empty($personal)) |
| 240 | 246 | { |
| 241 | 247 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
| 242 | - if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
|
| 248 | + if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) |
|
| 249 | + { |
|
| 250 | + // but quoting is never wrong, so quote more then necessary |
|
| 243 | 251 | { |
| 244 | 252 | $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
| 245 | 253 | } |
| 254 | + } |
|
| 246 | 255 | $address = ($personal ? $personal.' <' : '').$address.($personal ? '>' : ''); |
| 247 | 256 | } |
| 248 | 257 | return $address; |
@@ -345,7 +354,10 @@ discard block |
||
| 345 | 354 | throw new Exception\NotFound("File '$data' not found!"); |
| 346 | 355 | } |
| 347 | 356 | |
| 348 | - if (empty($type) && !is_resource($data)) $type = Vfs::mime_content_type($data); |
|
| 357 | + if (empty($type) && !is_resource($data)) |
|
| 358 | + { |
|
| 359 | + $type = Vfs::mime_content_type($data); |
|
| 360 | + } |
|
| 349 | 361 | |
| 350 | 362 | // set "text/calendar; method=*" as alternativ body |
| 351 | 363 | $matches = null; |
@@ -368,11 +380,17 @@ discard block |
||
| 368 | 380 | $part->setContents($resource); |
| 369 | 381 | |
| 370 | 382 | // setting name, also sets content-disposition attachment (!), therefore we have to do it after "text/calendar; method=" handling |
| 371 | - if ($name || !is_resource($data)) $part->setName($name ? $name : Vfs::basename($data)); |
|
| 383 | + if ($name || !is_resource($data)) |
|
| 384 | + { |
|
| 385 | + $part->setName($name ? $name : Vfs::basename($data)); |
|
| 386 | + } |
|
| 372 | 387 | |
| 373 | 388 | // this should not be necessary, because binary data get detected by mime-type, |
| 374 | 389 | // but at least Cyrus complains about NUL characters |
| 375 | - if (substr($type, 0, 5) != 'text/') $part->setTransferEncoding('base64', array('send' => true)); |
|
| 390 | + if (substr($type, 0, 5) != 'text/') |
|
| 391 | + { |
|
| 392 | + $part->setTransferEncoding('base64', array('send' => true)); |
|
| 393 | + } |
|
| 376 | 394 | $part->setDisposition('attachment'); |
| 377 | 395 | |
| 378 | 396 | return $this->addMimePart($part); |
@@ -496,9 +514,12 @@ discard block |
||
| 496 | 514 | unset($resend); // parameter is not used, but required by function signature |
| 497 | 515 | |
| 498 | 516 | if (!($message_id = $this->getHeader('Message-ID')) && |
| 499 | - class_exists('Horde_Mime_Headers_MessageId')) // since 2.5.0 |
|
| 517 | + class_exists('Horde_Mime_Headers_MessageId')) |
|
| 518 | + { |
|
| 519 | + // since 2.5.0 |
|
| 500 | 520 | { |
| 501 | 521 | $message_id = Horde_Mime_Headers_MessageId::create('EGroupware'); |
| 522 | + } |
|
| 502 | 523 | $this->addHeader('Message-ID', $message_id); |
| 503 | 524 | } |
| 504 | 525 | $body_sha1 = null; // skip sha1, it requires whole mail in memory, which we traing to avoid now |
@@ -538,7 +559,10 @@ discard block |
||
| 538 | 559 | |
| 539 | 560 | try { |
| 540 | 561 | // no flowed for encrypted messages |
| 541 | - if (!isset($flowed)) $flowed = $this->_body && $this->_body->getType() != 'multipart/encrypted'; |
|
| 562 | + if (!isset($flowed)) |
|
| 563 | + { |
|
| 564 | + $flowed = $this->_body && $this->_body->getType() != 'multipart/encrypted'; |
|
| 565 | + } |
|
| 542 | 566 | |
| 543 | 567 | // check if flowed is disabled in mail site configuration |
| 544 | 568 | if (($config = Config::read('mail')) && $config['disable_rfc3676_flowed']) |
@@ -612,13 +636,19 @@ discard block |
||
| 612 | 636 | $msg .= 'ERROR '.$e->getMessage(); |
| 613 | 637 | } |
| 614 | 638 | $msg .= ' cc='.implode(', ', $cc).', bcc='.implode(', ', $bcc); |
| 615 | - if ($GLOBALS['egw_info']['server']['log_mail'] !== true) $msg .= "\n\n"; |
|
| 639 | + if ($GLOBALS['egw_info']['server']['log_mail'] !== true) |
|
| 640 | + { |
|
| 641 | + $msg .= "\n\n"; |
|
| 642 | + } |
|
| 616 | 643 | |
| 617 | 644 | error_log($msg,$GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3, |
| 618 | 645 | $GLOBALS['egw_info']['server']['log_mail']); |
| 619 | 646 | } |
| 620 | 647 | // rethrow error |
| 621 | - if (isset($e)) throw $e; |
|
| 648 | + if (isset($e)) |
|
| 649 | + { |
|
| 650 | + throw $e; |
|
| 651 | + } |
|
| 622 | 652 | } |
| 623 | 653 | |
| 624 | 654 | |
@@ -663,7 +693,8 @@ discard block |
||
| 663 | 693 | } |
| 664 | 694 | // code copied from Horde_Mime_Mail::getRaw(), as there is no way to inject charset in |
| 665 | 695 | // _headers->toString(), which is required to encode headers containing non-ascii chars correct |
| 666 | - if ($stream) { |
|
| 696 | + if ($stream) |
|
| 697 | + { |
|
| 667 | 698 | $hdr = new Horde_Stream(); |
| 668 | 699 | $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
| 669 | 700 | return Horde_Stream_Wrapper_Combine::getStream( |
@@ -740,7 +771,10 @@ discard block |
||
| 740 | 771 | { |
| 741 | 772 | try { |
| 742 | 773 | $base = $this->getBasePart(); |
| 743 | - if (!($part_id = $base->findBody($subtype))) return null; |
|
| 774 | + if (!($part_id = $base->findBody($subtype))) |
|
| 775 | + { |
|
| 776 | + return null; |
|
| 777 | + } |
|
| 744 | 778 | return $base->getPart($part_id); |
| 745 | 779 | } |
| 746 | 780 | catch (Exception $e) { |
@@ -854,7 +888,10 @@ discard block |
||
| 854 | 888 | */ |
| 855 | 889 | public function addMimePart($part) |
| 856 | 890 | { |
| 857 | - if ($this->_base) $this->parseBasePart(); |
|
| 891 | + if ($this->_base) |
|
| 892 | + { |
|
| 893 | + $this->parseBasePart(); |
|
| 894 | + } |
|
| 858 | 895 | |
| 859 | 896 | return parent::addMimePart($part); |
| 860 | 897 | } |