Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
api/src/WebDAV/Server/Filesystem.php 6 patches
Doc Comments   +11 added lines, -9 removed lines patch added patch discarded remove patch
@@ -254,6 +254,7 @@  discard block
 block discarded – undo
254 254
      *
255 255
      * @param  string  program name
256 256
      * @param  string  optional search path, defaults to $PATH
257
+     * @param string $name
257 258
      * @return bool    true if executable program found in path
258 259
      */
259 260
     function _can_execute($name, $path = false)
@@ -319,6 +320,7 @@  discard block
 block discarded – undo
319 320
      * try to detect the mime type of a file
320 321
      *
321 322
      * @param  string  file path
323
+     * @param string $fspath
322 324
      * @return string  guessed mime type
323 325
      */
324 326
     function _mimetype($fspath)
@@ -416,7 +418,7 @@  discard block
 block discarded – undo
416 418
      * GET method handler
417 419
      *
418 420
      * @param  array  parameter passing array
419
-     * @return bool   true on success
421
+     * @return null|boolean   true on success
420 422
      */
421 423
     function GET(&$options)
422 424
     {
@@ -446,7 +448,7 @@  discard block
 block discarded – undo
446 448
      * See RFC 2518, Section 8.4 on GET/HEAD for collections
447 449
      *
448 450
      * @param  string  directory path
449
-     * @return void    function has to handle HTTP response itself
451
+     * @return null|false    function has to handle HTTP response itself
450 452
      */
451 453
     function GetDir($fspath, &$options)
452 454
     {
@@ -533,7 +535,7 @@  discard block
 block discarded – undo
533 535
      * MKCOL method handler
534 536
      *
535 537
      * @param  array  general parameter passing array
536
-     * @return bool   true on success
538
+     * @return string   true on success
537 539
      */
538 540
     function MKCOL($options)
539 541
     {
@@ -570,7 +572,7 @@  discard block
 block discarded – undo
570 572
      * DELETE method handler
571 573
      *
572 574
      * @param  array  general parameter passing array
573
-     * @return bool   true on success
575
+     * @return string   true on success
574 576
      */
575 577
     function DELETE($options)
576 578
     {
@@ -600,7 +602,7 @@  discard block
 block discarded – undo
600 602
      * MOVE method handler
601 603
      *
602 604
      * @param  array  general parameter passing array
603
-     * @return bool   true on success
605
+     * @return string   true on success
604 606
      */
605 607
     function MOVE($options)
606 608
     {
@@ -611,7 +613,7 @@  discard block
 block discarded – undo
611 613
      * COPY method handler
612 614
      *
613 615
      * @param  array  general parameter passing array
614
-     * @return bool   true on success
616
+     * @return string   true on success
615 617
      */
616 618
     function COPY($options, $del=false)
617 619
     {
@@ -751,7 +753,7 @@  discard block
 block discarded – undo
751 753
      * PROPPATCH method handler
752 754
      *
753 755
      * @param  array  general parameter passing array
754
-     * @return bool   true on success
756
+     * @return string   true on success
755 757
      */
756 758
     function PROPPATCH(&$options)
757 759
     {
@@ -790,7 +792,7 @@  discard block
 block discarded – undo
790 792
      * LOCK method handler
791 793
      *
792 794
      * @param  array  general parameter passing array
793
-     * @return bool   true on success
795
+     * @return string|boolean   true on success
794 796
      */
795 797
     function LOCK(&$options)
796 798
     {
@@ -848,7 +850,7 @@  discard block
 block discarded – undo
848 850
      * UNLOCK method handler
849 851
      *
850 852
      * @param  array  general parameter passing array
851
-     * @return bool   true on success
853
+     * @return string   true on success
852 854
      */
853 855
     function UNLOCK(&$options)
854 856
     {
Please login to merge, or discard this patch.
Indentation   +827 added lines, -827 removed lines patch added patch discarded remove patch
@@ -44,793 +44,793 @@  discard block
 block discarded – undo
44 44
  */
45 45
 class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server
46 46
 {
47
-    /**
48
-     * Root directory for WebDAV access
49
-     *
50
-     * Defaults to webserver document root (set by ServeRequest)
51
-     *
52
-     * @access private
53
-     * @var    string
54
-     */
55
-    var $base = "";
56
-
57
-    /**
58
-     * MySQL Host where property and locking information is stored
59
-     *
60
-     * @access private
61
-     * @var    string
62
-     */
63
-    var $db_host = "localhost";
64
-
65
-    /**
66
-     * MySQL database for property/locking information storage
67
-     *
68
-     * @access private
69
-     * @var    string
70
-     */
71
-    var $db_name = "webdav";
72
-
73
-    /**
74
-     * MySQL table name prefix
75
-     *
76
-     * @access private
77
-     * @var    string
78
-     */
79
-    var $db_prefix = "";
80
-
81
-    /**
82
-     * MySQL user for property/locking db access
83
-     *
84
-     * @access private
85
-     * @var    string
86
-     */
87
-    var $db_user = "root";
88
-
89
-    /**
90
-     * MySQL password for property/locking db access
91
-     *
92
-     * @access private
93
-     * @var    string
94
-     */
95
-    var $db_passwd = "";
96
-
97
-    /**
98
-     * Serve a webdav request
99
-     *
100
-     * @access public
101
-     * @param  string
102
-     */
103
-    function ServeRequest($base = false)
104
-    {
105
-        // special treatment for litmus compliance test
106
-        // reply on its identifier header
107
-        // not needed for the test itself but eases debugging
108
-        if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
109
-            error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110
-            header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111
-        }
112
-
113
-        // set root directory, defaults to webserver document root if not set
114
-        if ($base) {
115
-            $this->base = realpath($base); // TODO throw if not a directory
116
-        } else if (!$this->base) {
117
-            $this->base = $this->_SERVER['DOCUMENT_ROOT'];
118
-        }
119
-
120
-        // establish connection to property/locking db
121
-        mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error());
122
-        mysql_select_db($this->db_name) or die(mysql_error());
123
-        // TODO throw on connection problems
124
-
125
-        // let the base class do all the work
126
-        parent::ServeRequest();
127
-    }
128
-
129
-    /**
130
-     * No authentication is needed here
131
-     *
132
-     * @access private
133
-     * @param  string  HTTP Authentication type (Basic, Digest, ...)
134
-     * @param  string  Username
135
-     * @param  string  Password
136
-     * @return bool    true on successful authentication
137
-     */
138
-    function check_auth($type, $user, $pass)
139
-    {
140
-        return true;
141
-    }
142
-
143
-
144
-    /**
145
-     * PROPFIND method handler
146
-     *
147
-     * @param  array  general parameter passing array
148
-     * @param  array  return array for file properties
149
-     * @return bool   true on success
150
-     */
151
-    function PROPFIND(&$options, &$files)
152
-    {
153
-        // get absolute fs path to requested resource
154
-        $fspath = $this->base . $options["path"];
155
-
156
-        // sanity check
157
-        if (!file_exists($fspath)) {
158
-            return false;
159
-        }
160
-
161
-        // prepare property array
162
-        $files["files"] = array();
163
-
164
-        // store information for the requested path itself
165
-        $files["files"][] = $this->fileinfo($options["path"]);
166
-
167
-        // information for contained resources requested?
168
-        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
169
-
170
-            // make sure path ends with '/'
171
-            $options["path"] = $this->_slashify($options["path"]);
172
-
173
-            // try to open directory
174
-            $handle = opendir($fspath);
175
-
176
-            if ($handle) {
177
-                // ok, now get all its contents
178
-                while ($filename = readdir($handle)) {
179
-                    if ($filename != "." && $filename != "..") {
180
-                        $files["files"][] = $this->fileinfo($options["path"].$filename);
181
-                    }
182
-                }
183
-                // TODO recursion needed if "Depth: infinite"
184
-            	closedir($handle);
185
-            }
186
-        }
187
-
188
-        // ok, all done
189
-        return true;
190
-    }
191
-
192
-    /**
193
-     * Get properties for a single file/resource
194
-     *
195
-     * @param  string  resource path
196
-     * @return array   resource properties
197
-     */
198
-    function fileinfo($path)
199
-    {
200
-        // map URI path to filesystem path
201
-        $fspath = $this->base . $path;
202
-
203
-        // create result array
204
-        $info = array();
205
-        // TODO remove slash append code when base clase is able to do it itself
206
-        $info["path"]  = is_dir($fspath) ? $this->_slashify($path) : $path;
207
-        $info["props"] = array();
208
-
209
-        // no special beautified displayname here ...
210
-        $info["props"][] = $this->mkprop("displayname", strtoupper($path));
211
-
212
-        // creation and modification time
213
-        $info["props"][] = $this->mkprop("creationdate",    filectime($fspath));
214
-        $info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath));
215
-
216
-        // Microsoft extensions: last access time and 'hidden' status
217
-        $info["props"][] = $this->mkprop("lastaccessed",    fileatime($fspath));
218
-        $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219
-
220
-        // type and size (caller already made sure that path exists)
221
-        if (is_dir($fspath)) {
222
-            // directory (WebDAV collection)
223
-            $info["props"][] = $this->mkprop("resourcetype", "collection");
224
-            $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
-        } else {
226
-            // plain file (WebDAV resource)
227
-            $info["props"][] = $this->mkprop("resourcetype", "");
228
-            if ($this->_is_readable($fspath)) {
229
-                $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
-            } else {
231
-                $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232
-            }
233
-            $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
234
-        }
235
-
236
-        // get additional properties from database
237
-        $query = "SELECT ns, name, value
47
+	/**
48
+	 * Root directory for WebDAV access
49
+	 *
50
+	 * Defaults to webserver document root (set by ServeRequest)
51
+	 *
52
+	 * @access private
53
+	 * @var    string
54
+	 */
55
+	var $base = "";
56
+
57
+	/**
58
+	 * MySQL Host where property and locking information is stored
59
+	 *
60
+	 * @access private
61
+	 * @var    string
62
+	 */
63
+	var $db_host = "localhost";
64
+
65
+	/**
66
+	 * MySQL database for property/locking information storage
67
+	 *
68
+	 * @access private
69
+	 * @var    string
70
+	 */
71
+	var $db_name = "webdav";
72
+
73
+	/**
74
+	 * MySQL table name prefix
75
+	 *
76
+	 * @access private
77
+	 * @var    string
78
+	 */
79
+	var $db_prefix = "";
80
+
81
+	/**
82
+	 * MySQL user for property/locking db access
83
+	 *
84
+	 * @access private
85
+	 * @var    string
86
+	 */
87
+	var $db_user = "root";
88
+
89
+	/**
90
+	 * MySQL password for property/locking db access
91
+	 *
92
+	 * @access private
93
+	 * @var    string
94
+	 */
95
+	var $db_passwd = "";
96
+
97
+	/**
98
+	 * Serve a webdav request
99
+	 *
100
+	 * @access public
101
+	 * @param  string
102
+	 */
103
+	function ServeRequest($base = false)
104
+	{
105
+		// special treatment for litmus compliance test
106
+		// reply on its identifier header
107
+		// not needed for the test itself but eases debugging
108
+		if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
109
+			error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110
+			header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111
+		}
112
+
113
+		// set root directory, defaults to webserver document root if not set
114
+		if ($base) {
115
+			$this->base = realpath($base); // TODO throw if not a directory
116
+		} else if (!$this->base) {
117
+			$this->base = $this->_SERVER['DOCUMENT_ROOT'];
118
+		}
119
+
120
+		// establish connection to property/locking db
121
+		mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error());
122
+		mysql_select_db($this->db_name) or die(mysql_error());
123
+		// TODO throw on connection problems
124
+
125
+		// let the base class do all the work
126
+		parent::ServeRequest();
127
+	}
128
+
129
+	/**
130
+	 * No authentication is needed here
131
+	 *
132
+	 * @access private
133
+	 * @param  string  HTTP Authentication type (Basic, Digest, ...)
134
+	 * @param  string  Username
135
+	 * @param  string  Password
136
+	 * @return bool    true on successful authentication
137
+	 */
138
+	function check_auth($type, $user, $pass)
139
+	{
140
+		return true;
141
+	}
142
+
143
+
144
+	/**
145
+	 * PROPFIND method handler
146
+	 *
147
+	 * @param  array  general parameter passing array
148
+	 * @param  array  return array for file properties
149
+	 * @return bool   true on success
150
+	 */
151
+	function PROPFIND(&$options, &$files)
152
+	{
153
+		// get absolute fs path to requested resource
154
+		$fspath = $this->base . $options["path"];
155
+
156
+		// sanity check
157
+		if (!file_exists($fspath)) {
158
+			return false;
159
+		}
160
+
161
+		// prepare property array
162
+		$files["files"] = array();
163
+
164
+		// store information for the requested path itself
165
+		$files["files"][] = $this->fileinfo($options["path"]);
166
+
167
+		// information for contained resources requested?
168
+		if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
169
+
170
+			// make sure path ends with '/'
171
+			$options["path"] = $this->_slashify($options["path"]);
172
+
173
+			// try to open directory
174
+			$handle = opendir($fspath);
175
+
176
+			if ($handle) {
177
+				// ok, now get all its contents
178
+				while ($filename = readdir($handle)) {
179
+					if ($filename != "." && $filename != "..") {
180
+						$files["files"][] = $this->fileinfo($options["path"].$filename);
181
+					}
182
+				}
183
+				// TODO recursion needed if "Depth: infinite"
184
+				closedir($handle);
185
+			}
186
+		}
187
+
188
+		// ok, all done
189
+		return true;
190
+	}
191
+
192
+	/**
193
+	 * Get properties for a single file/resource
194
+	 *
195
+	 * @param  string  resource path
196
+	 * @return array   resource properties
197
+	 */
198
+	function fileinfo($path)
199
+	{
200
+		// map URI path to filesystem path
201
+		$fspath = $this->base . $path;
202
+
203
+		// create result array
204
+		$info = array();
205
+		// TODO remove slash append code when base clase is able to do it itself
206
+		$info["path"]  = is_dir($fspath) ? $this->_slashify($path) : $path;
207
+		$info["props"] = array();
208
+
209
+		// no special beautified displayname here ...
210
+		$info["props"][] = $this->mkprop("displayname", strtoupper($path));
211
+
212
+		// creation and modification time
213
+		$info["props"][] = $this->mkprop("creationdate",    filectime($fspath));
214
+		$info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath));
215
+
216
+		// Microsoft extensions: last access time and 'hidden' status
217
+		$info["props"][] = $this->mkprop("lastaccessed",    fileatime($fspath));
218
+		$info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219
+
220
+		// type and size (caller already made sure that path exists)
221
+		if (is_dir($fspath)) {
222
+			// directory (WebDAV collection)
223
+			$info["props"][] = $this->mkprop("resourcetype", "collection");
224
+			$info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
+		} else {
226
+			// plain file (WebDAV resource)
227
+			$info["props"][] = $this->mkprop("resourcetype", "");
228
+			if ($this->_is_readable($fspath)) {
229
+				$info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
+			} else {
231
+				$info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232
+			}
233
+			$info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
234
+		}
235
+
236
+		// get additional properties from database
237
+		$query = "SELECT ns, name, value
238 238
                         FROM {$this->db_prefix}properties
239 239
                        WHERE path = '$path'";
240
-        $res = mysql_query($query);
241
-        while ($row = mysql_fetch_assoc($res)) {
242
-            $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243
-        }
244
-        mysql_free_result($res);
245
-
246
-        return $info;
247
-    }
248
-
249
-    /**
250
-     * detect if a given program is found in the search PATH
251
-     *
252
-     * helper function used by _mimetype() to detect if the
253
-     * external 'file' utility is available
254
-     *
255
-     * @param  string  program name
256
-     * @param  string  optional search path, defaults to $PATH
257
-     * @return bool    true if executable program found in path
258
-     */
259
-    function _can_execute($name, $path = false)
260
-    {
261
-        // path defaults to PATH from environment if not set
262
-        if ($path === false) {
263
-            $path = getenv("PATH");
264
-        }
265
-
266
-        // check method depends on operating system
267
-        if (!strncmp(PHP_OS, "WIN", 3)) {
268
-            // on Windows an appropriate COM or EXE file needs to exist
269
-            $exts     = array(".exe", ".com");
270
-            $check_fn = "file_exists";
271
-        } else {
272
-            // anywhere else we look for an executable file of that name
273
-            $exts     = array("");
274
-            $check_fn = "is_executable";
275
-        }
276
-
277
-        // now check the directories in the path for the program
278
-        foreach (explode(PATH_SEPARATOR, $path) as $dir) {
279
-            // skip invalid path entries
280
-            if (!file_exists($dir)) continue;
281
-            if (!is_dir($dir)) continue;
282
-
283
-            // and now look for the file
284
-            foreach ($exts as $ext) {
285
-                if ($check_fn("$dir/$name".$ext)) return true;
286
-            }
287
-        }
288
-
289
-        return false;
290
-    }
291
-
292
-    /**
293
-     * Check if path is readable by current user
294
-     *
295
-     * Allow extending classes to overwrite it
296
-     *
297
-     * @param string $fspath
298
-     * @return boolean
299
-     */
300
-    function _is_readable($fspath)
301
-    {
302
-    	return is_readable($fspath);
303
-    }
304
-
305
-    /**
306
-     * Check if path is writable by current user
307
-     *
308
-     * Allow extending classes to overwrite it
309
-     *
310
-     * @param string $fspath
311
-     * @return boolean
312
-     */
313
-    function _is_writable($fspath)
314
-    {
315
-    	return is_writable($fspath);
316
-    }
317
-
318
-    /**
319
-     * try to detect the mime type of a file
320
-     *
321
-     * @param  string  file path
322
-     * @return string  guessed mime type
323
-     */
324
-    function _mimetype($fspath)
325
-    {
326
-        if (is_dir($fspath)) {
327
-            // directories are easy
328
-            return "httpd/unix-directory";
329
-        } else if (function_exists("mime_content_type")) {
330
-            // use mime magic extension if available
331
-            $mime_type = mime_content_type($fspath);
332
-        } else if ($this->_can_execute("file")) {
333
-            // it looks like we have a 'file' command,
334
-            // lets see it it does have mime support
335
-            $fp    = popen("file -i '$fspath' 2>/dev/null", "r");
336
-            $reply = fgets($fp);
337
-            pclose($fp);
338
-
339
-            // popen will not return an error if the binary was not found
340
-            // and find may not have mime support using "-i"
341
-            // so we test the format of the returned string
342
-
343
-            // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
345
-                $reply = substr($reply, strlen($fspath)+2);
346
-                // followed by the mime type (maybe including options)
347
-                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
348
-                    $mime_type = $matches[0];
349
-                }
350
-            }
351
-        }
352
-
353
-        if (empty($mime_type)) {
354
-            // Fallback solution: try to guess the type by the file extension
355
-            // TODO: add more ...
356
-            // TODO: it has been suggested to delegate mimetype detection
357
-            //       to apache but this has at least three issues:
358
-            //       - works only with apache
359
-            //       - needs file to be within the document tree
360
-            //       - requires apache mod_magic
361
-            // TODO: can we use the registry for this on Windows?
362
-            //       OTOH if the server is Windos the clients are likely to
363
-            //       be Windows, too, and tend do ignore the Content-Type
364
-            //       anyway (overriding it with information taken from
365
-            //       the registry)
366
-            // TODO: have a seperate PEAR class for mimetype detection?
367
-            switch (strtolower(strrchr(basename($fspath), "."))) {
368
-            case ".html":
369
-                $mime_type = "text/html";
370
-                break;
371
-            case ".gif":
372
-                $mime_type = "image/gif";
373
-                break;
374
-            case ".jpg":
375
-                $mime_type = "image/jpeg";
376
-                break;
377
-            default:
378
-                $mime_type = "application/octet-stream";
379
-                break;
380
-            }
381
-        }
382
-
383
-        return $mime_type;
384
-    }
385
-
386
-    /**
387
-     * HEAD method handler
388
-     *
389
-     * @param  array  parameter passing array
390
-     * @return bool   true on success
391
-     */
392
-    function HEAD(&$options)
393
-    {
394
-        // get absolute fs path to requested resource
395
-        $fspath = $this->base . $options["path"];
396
-
397
-        // sanity check
398
-        if (!file_exists($fspath)) return false;
399
-
400
-        // detect resource type
401
-        $options['mimetype'] = $this->_mimetype($fspath);
402
-
403
-        // detect modification time
404
-        // see rfc2518, section 13.7
405
-        // some clients seem to treat this as a reverse rule
406
-        // requiering a Last-Modified header if the getlastmodified header was set
407
-        $options['mtime'] = filemtime($fspath);
408
-
409
-        // detect resource size
410
-        $options['size'] = filesize($fspath);
411
-
412
-        return true;
413
-    }
414
-
415
-    /**
416
-     * GET method handler
417
-     *
418
-     * @param  array  parameter passing array
419
-     * @return bool   true on success
420
-     */
421
-    function GET(&$options)
422
-    {
423
-        // get absolute fs path to requested resource
424
-        $fspath = $this->base . $options["path"];
425
-
426
-        // is this a collection?
427
-        if (is_dir($fspath)) {
428
-            return $this->GetDir($fspath, $options);
429
-        }
430
-
431
-        // the header output is the same as for HEAD
432
-        if (!$this->HEAD($options)) {
433
-            return false;
434
-        }
435
-
436
-        // no need to check result here, it is handled by the base class
437
-        $options['stream'] = fopen($fspath, "r");
438
-
439
-        return true;
440
-    }
441
-
442
-    /**
443
-     * GET method handler for directories
444
-     *
445
-     * This is a very simple mod_index lookalike.
446
-     * See RFC 2518, Section 8.4 on GET/HEAD for collections
447
-     *
448
-     * @param  string  directory path
449
-     * @return void    function has to handle HTTP response itself
450
-     */
451
-    function GetDir($fspath, &$options)
452
-    {
453
-        $path = $this->_slashify($options["path"]);
454
-        if ($path != $options["path"]) {
455
-            header("Location: ".$this->base_uri.$path);
456
-            exit;
457
-        }
458
-
459
-        // fixed width directory column format
460
-        $format = "%15s  %-19s  %-s\n";
461
-
462
-        if (!$this->_is_readable($fspath)) {
463
-            return false;
464
-        }
465
-
466
-        $handle = opendir($fspath);
467
-        if (!$handle) {
468
-            return false;
469
-        }
470
-
471
-        echo "<html><head><title>Index of ".htmlspecialchars(urldecode($options['path']))."</title></head>\n";
472
-
473
-        echo "<h1>Index of ".htmlspecialchars($options['path'])."</h1>\n";
474
-
475
-        echo "<pre>";
476
-        printf($format, "Size", "Last modified", "Filename");
477
-        echo "<hr>";
478
-
479
-        while ($filename = readdir($handle)) {
480
-            if ($filename != "." && $filename != "..") {
481
-                $fullpath = $fspath.$filename;
482
-                $name     = htmlspecialchars($filename);
483
-                printf($format,
484
-                       number_format(filesize($fullpath)),
485
-                       strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)),
486
-                       '<a href="'.$name.'">'.urldecode($name).'</a>');
487
-            }
488
-        }
489
-
490
-        echo "</pre>";
491
-
492
-        closedir($handle);
493
-
494
-        echo "</html>\n";
495
-
496
-        exit;
497
-    }
498
-
499
-    /**
500
-     * PUT method handler
501
-     *
502
-     * @param  array  parameter passing array
503
-     * @return bool   true on success
504
-     */
505
-    function PUT(&$options)
506
-    {
507
-        $fspath = $this->base . $options["path"];
508
-
509
-        $dir = dirname($fspath);
510
-        if (!file_exists($dir) || !is_dir($dir)) {
511
-            return "409 Conflict"; // TODO right status code for both?
512
-        }
513
-
514
-        $options["new"] = ! file_exists($fspath);
515
-
516
-        if ($options["new"] && !$this->_is_writable($dir)) {
517
-            return "403 Forbidden";
518
-        }
519
-        if (!$options["new"] && !$this->_is_writable($fspath)) {
520
-            return "403 Forbidden";
521
-        }
522
-        if (!$options["new"] && is_dir($fspath)) {
523
-            return "403 Forbidden";
524
-        }
525
-
526
-        $fp = fopen($fspath, "w");
527
-
528
-        return $fp;
529
-    }
530
-
531
-
532
-    /**
533
-     * MKCOL method handler
534
-     *
535
-     * @param  array  general parameter passing array
536
-     * @return bool   true on success
537
-     */
538
-    function MKCOL($options)
539
-    {
540
-        $path   = $this->base .$options["path"];
541
-        $parent = dirname($path);
542
-        $name   = basename($path);
543
-
544
-        if (!file_exists($parent)) {
545
-            return "409 Conflict";
546
-        }
547
-
548
-        if (!is_dir($parent)) {
549
-            return "403 Forbidden";
550
-        }
551
-
552
-        if ( file_exists($parent."/".$name) ) {
553
-            return "405 Method not allowed";
554
-        }
555
-
556
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
557
-            return "415 Unsupported media type";
558
-        }
559
-
560
-        $stat = mkdir($parent."/".$name, 0777);
561
-        if (!$stat) {
562
-            return "403 Forbidden";
563
-        }
564
-
565
-        return ("201 Created");
566
-    }
567
-
568
-
569
-    /**
570
-     * DELETE method handler
571
-     *
572
-     * @param  array  general parameter passing array
573
-     * @return bool   true on success
574
-     */
575
-    function DELETE($options)
576
-    {
577
-        $path = $this->base . "/" .$options["path"];
578
-
579
-        if (!file_exists($path)) {
580
-            return "404 Not found";
581
-        }
582
-
583
-        if (is_dir($path)) {
584
-            $query = "DELETE FROM {$this->db_prefix}properties
240
+		$res = mysql_query($query);
241
+		while ($row = mysql_fetch_assoc($res)) {
242
+			$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243
+		}
244
+		mysql_free_result($res);
245
+
246
+		return $info;
247
+	}
248
+
249
+	/**
250
+	 * detect if a given program is found in the search PATH
251
+	 *
252
+	 * helper function used by _mimetype() to detect if the
253
+	 * external 'file' utility is available
254
+	 *
255
+	 * @param  string  program name
256
+	 * @param  string  optional search path, defaults to $PATH
257
+	 * @return bool    true if executable program found in path
258
+	 */
259
+	function _can_execute($name, $path = false)
260
+	{
261
+		// path defaults to PATH from environment if not set
262
+		if ($path === false) {
263
+			$path = getenv("PATH");
264
+		}
265
+
266
+		// check method depends on operating system
267
+		if (!strncmp(PHP_OS, "WIN", 3)) {
268
+			// on Windows an appropriate COM or EXE file needs to exist
269
+			$exts     = array(".exe", ".com");
270
+			$check_fn = "file_exists";
271
+		} else {
272
+			// anywhere else we look for an executable file of that name
273
+			$exts     = array("");
274
+			$check_fn = "is_executable";
275
+		}
276
+
277
+		// now check the directories in the path for the program
278
+		foreach (explode(PATH_SEPARATOR, $path) as $dir) {
279
+			// skip invalid path entries
280
+			if (!file_exists($dir)) continue;
281
+			if (!is_dir($dir)) continue;
282
+
283
+			// and now look for the file
284
+			foreach ($exts as $ext) {
285
+				if ($check_fn("$dir/$name".$ext)) return true;
286
+			}
287
+		}
288
+
289
+		return false;
290
+	}
291
+
292
+	/**
293
+	 * Check if path is readable by current user
294
+	 *
295
+	 * Allow extending classes to overwrite it
296
+	 *
297
+	 * @param string $fspath
298
+	 * @return boolean
299
+	 */
300
+	function _is_readable($fspath)
301
+	{
302
+		return is_readable($fspath);
303
+	}
304
+
305
+	/**
306
+	 * Check if path is writable by current user
307
+	 *
308
+	 * Allow extending classes to overwrite it
309
+	 *
310
+	 * @param string $fspath
311
+	 * @return boolean
312
+	 */
313
+	function _is_writable($fspath)
314
+	{
315
+		return is_writable($fspath);
316
+	}
317
+
318
+	/**
319
+	 * try to detect the mime type of a file
320
+	 *
321
+	 * @param  string  file path
322
+	 * @return string  guessed mime type
323
+	 */
324
+	function _mimetype($fspath)
325
+	{
326
+		if (is_dir($fspath)) {
327
+			// directories are easy
328
+			return "httpd/unix-directory";
329
+		} else if (function_exists("mime_content_type")) {
330
+			// use mime magic extension if available
331
+			$mime_type = mime_content_type($fspath);
332
+		} else if ($this->_can_execute("file")) {
333
+			// it looks like we have a 'file' command,
334
+			// lets see it it does have mime support
335
+			$fp    = popen("file -i '$fspath' 2>/dev/null", "r");
336
+			$reply = fgets($fp);
337
+			pclose($fp);
338
+
339
+			// popen will not return an error if the binary was not found
340
+			// and find may not have mime support using "-i"
341
+			// so we test the format of the returned string
342
+
343
+			// the reply begins with the requested filename
344
+			if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
345
+				$reply = substr($reply, strlen($fspath)+2);
346
+				// followed by the mime type (maybe including options)
347
+				if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
348
+					$mime_type = $matches[0];
349
+				}
350
+			}
351
+		}
352
+
353
+		if (empty($mime_type)) {
354
+			// Fallback solution: try to guess the type by the file extension
355
+			// TODO: add more ...
356
+			// TODO: it has been suggested to delegate mimetype detection
357
+			//       to apache but this has at least three issues:
358
+			//       - works only with apache
359
+			//       - needs file to be within the document tree
360
+			//       - requires apache mod_magic
361
+			// TODO: can we use the registry for this on Windows?
362
+			//       OTOH if the server is Windos the clients are likely to
363
+			//       be Windows, too, and tend do ignore the Content-Type
364
+			//       anyway (overriding it with information taken from
365
+			//       the registry)
366
+			// TODO: have a seperate PEAR class for mimetype detection?
367
+			switch (strtolower(strrchr(basename($fspath), "."))) {
368
+			case ".html":
369
+				$mime_type = "text/html";
370
+				break;
371
+			case ".gif":
372
+				$mime_type = "image/gif";
373
+				break;
374
+			case ".jpg":
375
+				$mime_type = "image/jpeg";
376
+				break;
377
+			default:
378
+				$mime_type = "application/octet-stream";
379
+				break;
380
+			}
381
+		}
382
+
383
+		return $mime_type;
384
+	}
385
+
386
+	/**
387
+	 * HEAD method handler
388
+	 *
389
+	 * @param  array  parameter passing array
390
+	 * @return bool   true on success
391
+	 */
392
+	function HEAD(&$options)
393
+	{
394
+		// get absolute fs path to requested resource
395
+		$fspath = $this->base . $options["path"];
396
+
397
+		// sanity check
398
+		if (!file_exists($fspath)) return false;
399
+
400
+		// detect resource type
401
+		$options['mimetype'] = $this->_mimetype($fspath);
402
+
403
+		// detect modification time
404
+		// see rfc2518, section 13.7
405
+		// some clients seem to treat this as a reverse rule
406
+		// requiering a Last-Modified header if the getlastmodified header was set
407
+		$options['mtime'] = filemtime($fspath);
408
+
409
+		// detect resource size
410
+		$options['size'] = filesize($fspath);
411
+
412
+		return true;
413
+	}
414
+
415
+	/**
416
+	 * GET method handler
417
+	 *
418
+	 * @param  array  parameter passing array
419
+	 * @return bool   true on success
420
+	 */
421
+	function GET(&$options)
422
+	{
423
+		// get absolute fs path to requested resource
424
+		$fspath = $this->base . $options["path"];
425
+
426
+		// is this a collection?
427
+		if (is_dir($fspath)) {
428
+			return $this->GetDir($fspath, $options);
429
+		}
430
+
431
+		// the header output is the same as for HEAD
432
+		if (!$this->HEAD($options)) {
433
+			return false;
434
+		}
435
+
436
+		// no need to check result here, it is handled by the base class
437
+		$options['stream'] = fopen($fspath, "r");
438
+
439
+		return true;
440
+	}
441
+
442
+	/**
443
+	 * GET method handler for directories
444
+	 *
445
+	 * This is a very simple mod_index lookalike.
446
+	 * See RFC 2518, Section 8.4 on GET/HEAD for collections
447
+	 *
448
+	 * @param  string  directory path
449
+	 * @return void    function has to handle HTTP response itself
450
+	 */
451
+	function GetDir($fspath, &$options)
452
+	{
453
+		$path = $this->_slashify($options["path"]);
454
+		if ($path != $options["path"]) {
455
+			header("Location: ".$this->base_uri.$path);
456
+			exit;
457
+		}
458
+
459
+		// fixed width directory column format
460
+		$format = "%15s  %-19s  %-s\n";
461
+
462
+		if (!$this->_is_readable($fspath)) {
463
+			return false;
464
+		}
465
+
466
+		$handle = opendir($fspath);
467
+		if (!$handle) {
468
+			return false;
469
+		}
470
+
471
+		echo "<html><head><title>Index of ".htmlspecialchars(urldecode($options['path']))."</title></head>\n";
472
+
473
+		echo "<h1>Index of ".htmlspecialchars($options['path'])."</h1>\n";
474
+
475
+		echo "<pre>";
476
+		printf($format, "Size", "Last modified", "Filename");
477
+		echo "<hr>";
478
+
479
+		while ($filename = readdir($handle)) {
480
+			if ($filename != "." && $filename != "..") {
481
+				$fullpath = $fspath.$filename;
482
+				$name     = htmlspecialchars($filename);
483
+				printf($format,
484
+					   number_format(filesize($fullpath)),
485
+					   strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)),
486
+					   '<a href="'.$name.'">'.urldecode($name).'</a>');
487
+			}
488
+		}
489
+
490
+		echo "</pre>";
491
+
492
+		closedir($handle);
493
+
494
+		echo "</html>\n";
495
+
496
+		exit;
497
+	}
498
+
499
+	/**
500
+	 * PUT method handler
501
+	 *
502
+	 * @param  array  parameter passing array
503
+	 * @return bool   true on success
504
+	 */
505
+	function PUT(&$options)
506
+	{
507
+		$fspath = $this->base . $options["path"];
508
+
509
+		$dir = dirname($fspath);
510
+		if (!file_exists($dir) || !is_dir($dir)) {
511
+			return "409 Conflict"; // TODO right status code for both?
512
+		}
513
+
514
+		$options["new"] = ! file_exists($fspath);
515
+
516
+		if ($options["new"] && !$this->_is_writable($dir)) {
517
+			return "403 Forbidden";
518
+		}
519
+		if (!$options["new"] && !$this->_is_writable($fspath)) {
520
+			return "403 Forbidden";
521
+		}
522
+		if (!$options["new"] && is_dir($fspath)) {
523
+			return "403 Forbidden";
524
+		}
525
+
526
+		$fp = fopen($fspath, "w");
527
+
528
+		return $fp;
529
+	}
530
+
531
+
532
+	/**
533
+	 * MKCOL method handler
534
+	 *
535
+	 * @param  array  general parameter passing array
536
+	 * @return bool   true on success
537
+	 */
538
+	function MKCOL($options)
539
+	{
540
+		$path   = $this->base .$options["path"];
541
+		$parent = dirname($path);
542
+		$name   = basename($path);
543
+
544
+		if (!file_exists($parent)) {
545
+			return "409 Conflict";
546
+		}
547
+
548
+		if (!is_dir($parent)) {
549
+			return "403 Forbidden";
550
+		}
551
+
552
+		if ( file_exists($parent."/".$name) ) {
553
+			return "405 Method not allowed";
554
+		}
555
+
556
+		if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
557
+			return "415 Unsupported media type";
558
+		}
559
+
560
+		$stat = mkdir($parent."/".$name, 0777);
561
+		if (!$stat) {
562
+			return "403 Forbidden";
563
+		}
564
+
565
+		return ("201 Created");
566
+	}
567
+
568
+
569
+	/**
570
+	 * DELETE method handler
571
+	 *
572
+	 * @param  array  general parameter passing array
573
+	 * @return bool   true on success
574
+	 */
575
+	function DELETE($options)
576
+	{
577
+		$path = $this->base . "/" .$options["path"];
578
+
579
+		if (!file_exists($path)) {
580
+			return "404 Not found";
581
+		}
582
+
583
+		if (is_dir($path)) {
584
+			$query = "DELETE FROM {$this->db_prefix}properties
585 585
                            WHERE path LIKE '".$this->_slashify($options["path"])."%'";
586
-            mysql_query($query);
587
-            System::rm(array("-rf", $path));
588
-        } else {
589
-            unlink($path);
590
-        }
591
-        $query = "DELETE FROM {$this->db_prefix}properties
586
+			mysql_query($query);
587
+			System::rm(array("-rf", $path));
588
+		} else {
589
+			unlink($path);
590
+		}
591
+		$query = "DELETE FROM {$this->db_prefix}properties
592 592
                        WHERE path = '$options[path]'";
593
-        mysql_query($query);
594
-
595
-        return "204 No Content";
596
-    }
597
-
598
-
599
-    /**
600
-     * MOVE method handler
601
-     *
602
-     * @param  array  general parameter passing array
603
-     * @return bool   true on success
604
-     */
605
-    function MOVE($options)
606
-    {
607
-        return $this->COPY($options, true);
608
-    }
609
-
610
-    /**
611
-     * COPY method handler
612
-     *
613
-     * @param  array  general parameter passing array
614
-     * @return bool   true on success
615
-     */
616
-    function COPY($options, $del=false)
617
-    {
618
-        // TODO Property updates still broken (Litmus should detect this?)
619
-
620
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
621
-            return "415 Unsupported media type";
622
-        }
623
-
624
-        // no copying to different WebDAV Servers yet
625
-        if (isset($options["dest_url"])) {
626
-            return "502 bad gateway";
627
-        }
628
-
629
-        $source = $this->base . $options["path"];
630
-        if (!file_exists($source)) {
631
-            return "404 Not found";
632
-        }
633
-
634
-        if (is_dir($source)) { // resource is a collection
635
-            switch ($options["depth"]) {
636
-            case "infinity": // valid
637
-                break;
638
-            case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
640
-                    return "400 Bad request";
641
-                }
642
-                break;
643
-            case "1": // invalid for both COPY and MOVE
644
-            default:
645
-                return "400 Bad request";
646
-            }
647
-        }
648
-
649
-        $dest         = $this->base . $options["dest"];
650
-        $destdir      = dirname($dest);
651
-
652
-        if (!file_exists($destdir) || !is_dir($destdir)) {
653
-            return "409 Conflict";
654
-        }
655
-
656
-
657
-        $new          = !file_exists($dest);
658
-        $existing_col = false;
659
-
660
-        if (!$new) {
661
-            if ($del && is_dir($dest)) {
662
-                if (!$options["overwrite"]) {
663
-                    return "412 precondition failed";
664
-                }
665
-                $dest .= basename($source);
666
-                if (file_exists($dest)) {
667
-                    $options["dest"] .= basename($source);
668
-                } else {
669
-                    $new          = true;
670
-                    $existing_col = true;
671
-                }
672
-            }
673
-        }
674
-
675
-        if (!$new) {
676
-            if ($options["overwrite"]) {
677
-                $stat = $this->DELETE(array("path" => $options["dest"]));
678
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
679
-                    return $stat;
680
-                }
681
-            } else {
682
-                return "412 precondition failed";
683
-            }
684
-        }
685
-
686
-        if ($del) {
687
-            if (!rename($source, $dest)) {
688
-                return "500 Internal server error";
689
-            }
690
-            $destpath = $this->_unslashify($options["dest"]);
691
-            if (is_dir($source)) {
692
-                $query = "UPDATE {$this->db_prefix}properties
593
+		mysql_query($query);
594
+
595
+		return "204 No Content";
596
+	}
597
+
598
+
599
+	/**
600
+	 * MOVE method handler
601
+	 *
602
+	 * @param  array  general parameter passing array
603
+	 * @return bool   true on success
604
+	 */
605
+	function MOVE($options)
606
+	{
607
+		return $this->COPY($options, true);
608
+	}
609
+
610
+	/**
611
+	 * COPY method handler
612
+	 *
613
+	 * @param  array  general parameter passing array
614
+	 * @return bool   true on success
615
+	 */
616
+	function COPY($options, $del=false)
617
+	{
618
+		// TODO Property updates still broken (Litmus should detect this?)
619
+
620
+		if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
621
+			return "415 Unsupported media type";
622
+		}
623
+
624
+		// no copying to different WebDAV Servers yet
625
+		if (isset($options["dest_url"])) {
626
+			return "502 bad gateway";
627
+		}
628
+
629
+		$source = $this->base . $options["path"];
630
+		if (!file_exists($source)) {
631
+			return "404 Not found";
632
+		}
633
+
634
+		if (is_dir($source)) { // resource is a collection
635
+			switch ($options["depth"]) {
636
+			case "infinity": // valid
637
+				break;
638
+			case "0": // valid for COPY only
639
+				if ($del) { // MOVE?
640
+					return "400 Bad request";
641
+				}
642
+				break;
643
+			case "1": // invalid for both COPY and MOVE
644
+			default:
645
+				return "400 Bad request";
646
+			}
647
+		}
648
+
649
+		$dest         = $this->base . $options["dest"];
650
+		$destdir      = dirname($dest);
651
+
652
+		if (!file_exists($destdir) || !is_dir($destdir)) {
653
+			return "409 Conflict";
654
+		}
655
+
656
+
657
+		$new          = !file_exists($dest);
658
+		$existing_col = false;
659
+
660
+		if (!$new) {
661
+			if ($del && is_dir($dest)) {
662
+				if (!$options["overwrite"]) {
663
+					return "412 precondition failed";
664
+				}
665
+				$dest .= basename($source);
666
+				if (file_exists($dest)) {
667
+					$options["dest"] .= basename($source);
668
+				} else {
669
+					$new          = true;
670
+					$existing_col = true;
671
+				}
672
+			}
673
+		}
674
+
675
+		if (!$new) {
676
+			if ($options["overwrite"]) {
677
+				$stat = $this->DELETE(array("path" => $options["dest"]));
678
+				if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
679
+					return $stat;
680
+				}
681
+			} else {
682
+				return "412 precondition failed";
683
+			}
684
+		}
685
+
686
+		if ($del) {
687
+			if (!rename($source, $dest)) {
688
+				return "500 Internal server error";
689
+			}
690
+			$destpath = $this->_unslashify($options["dest"]);
691
+			if (is_dir($source)) {
692
+				$query = "UPDATE {$this->db_prefix}properties
693 693
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 694
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
695
-                mysql_query($query);
696
-            }
695
+				mysql_query($query);
696
+			}
697 697
 
698
-            $query = "UPDATE {$this->db_prefix}properties
698
+			$query = "UPDATE {$this->db_prefix}properties
699 699
                              SET path = '".$destpath."'
700 700
                            WHERE path = '".$options["path"]."'";
701
-            mysql_query($query);
702
-        } else {
703
-            if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
704
-                $files = System::find($source);
705
-                $files = array_reverse($files);
706
-            } else {
707
-                $files = array($source);
708
-            }
709
-
710
-            if (!is_array($files) || empty($files)) {
711
-                return "500 Internal server error";
712
-            }
713
-
714
-
715
-            foreach ($files as $file) {
716
-                if (is_dir($file)) {
717
-                    $file = $this->_slashify($file);
718
-                }
719
-
720
-                $destfile = str_replace($source, $dest, $file);
721
-
722
-                if (is_dir($file)) {
723
-                    if (!file_exists($destfile)) {
724
-                        if (!$this->_is_writable(dirname($destfile))) {
725
-                            return "403 Forbidden";
726
-                        }
727
-                        if (!mkdir($destfile)) {
728
-                            return "409 Conflict";
729
-                        }
730
-                    } else if (!is_dir($destfile)) {
731
-                        return "409 Conflict";
732
-                    }
733
-                } else {
734
-
735
-                    if (!copy($file, $destfile)) {
736
-                        return "409 Conflict";
737
-                    }
738
-                }
739
-            }
740
-
741
-            $query = "INSERT INTO {$this->db_prefix}properties
701
+			mysql_query($query);
702
+		} else {
703
+			if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
704
+				$files = System::find($source);
705
+				$files = array_reverse($files);
706
+			} else {
707
+				$files = array($source);
708
+			}
709
+
710
+			if (!is_array($files) || empty($files)) {
711
+				return "500 Internal server error";
712
+			}
713
+
714
+
715
+			foreach ($files as $file) {
716
+				if (is_dir($file)) {
717
+					$file = $this->_slashify($file);
718
+				}
719
+
720
+				$destfile = str_replace($source, $dest, $file);
721
+
722
+				if (is_dir($file)) {
723
+					if (!file_exists($destfile)) {
724
+						if (!$this->_is_writable(dirname($destfile))) {
725
+							return "403 Forbidden";
726
+						}
727
+						if (!mkdir($destfile)) {
728
+							return "409 Conflict";
729
+						}
730
+					} else if (!is_dir($destfile)) {
731
+						return "409 Conflict";
732
+					}
733
+				} else {
734
+
735
+					if (!copy($file, $destfile)) {
736
+						return "409 Conflict";
737
+					}
738
+				}
739
+			}
740
+
741
+			$query = "INSERT INTO {$this->db_prefix}properties
742 742
                                SELECT *
743 743
                                  FROM {$this->db_prefix}properties
744 744
                                 WHERE path = '".$options['path']."'";
745
-        }
746
-
747
-        return ($new && !$existing_col) ? "201 Created" : "204 No Content";
748
-    }
749
-
750
-    /**
751
-     * PROPPATCH method handler
752
-     *
753
-     * @param  array  general parameter passing array
754
-     * @return bool   true on success
755
-     */
756
-    function PROPPATCH(&$options)
757
-    {
758
-        global $prefs, $tab;
759
-
760
-        $msg  = "";
761
-        $path = $options["path"];
762
-        $dir  = dirname($path)."/";
763
-        $base = basename($path);
764
-
765
-        foreach ($options["props"] as $key => $prop) {
766
-            if ($prop["ns"] == "DAV:") {
767
-                $options["props"][$key]['status'] = "403 Forbidden";
768
-            } else {
769
-                if (isset($prop["val"])) {
770
-                    $query = "REPLACE INTO {$this->db_prefix}properties
745
+		}
746
+
747
+		return ($new && !$existing_col) ? "201 Created" : "204 No Content";
748
+	}
749
+
750
+	/**
751
+	 * PROPPATCH method handler
752
+	 *
753
+	 * @param  array  general parameter passing array
754
+	 * @return bool   true on success
755
+	 */
756
+	function PROPPATCH(&$options)
757
+	{
758
+		global $prefs, $tab;
759
+
760
+		$msg  = "";
761
+		$path = $options["path"];
762
+		$dir  = dirname($path)."/";
763
+		$base = basename($path);
764
+
765
+		foreach ($options["props"] as $key => $prop) {
766
+			if ($prop["ns"] == "DAV:") {
767
+				$options["props"][$key]['status'] = "403 Forbidden";
768
+			} else {
769
+				if (isset($prop["val"])) {
770
+					$query = "REPLACE INTO {$this->db_prefix}properties
771 771
                                            SET path = '$options[path]'
772 772
                                              , name = '$prop[name]'
773 773
                                              , ns= '$prop[ns]'
774 774
                                              , value = '$prop[val]'";
775
-                } else {
776
-                    $query = "DELETE FROM {$this->db_prefix}properties
775
+				} else {
776
+					$query = "DELETE FROM {$this->db_prefix}properties
777 777
                                         WHERE path = '$options[path]'
778 778
                                           AND name = '$prop[name]'
779 779
                                           AND ns = '$prop[ns]'";
780
-                }
781
-                mysql_query($query);
782
-            }
783
-        }
784
-
785
-        return "";
786
-    }
787
-
788
-
789
-    /**
790
-     * LOCK method handler
791
-     *
792
-     * @param  array  general parameter passing array
793
-     * @return bool   true on success
794
-     */
795
-    function LOCK(&$options)
796
-    {
797
-        // get absolute fs path to requested resource
798
-        $fspath = $this->base . $options["path"];
799
-
800
-        // TODO recursive locks on directories not supported yet
801
-        // makes litmus test "32. lock_collection" fail
802
-        if (is_dir($fspath) && !empty($options["depth"])) {
803
-            return "409 Conflict";
804
-        }
805
-
806
-        $options["timeout"] = time()+300; // 5min. hardcoded
807
-
808
-        if (isset($options["update"])) { // Lock Update
809
-            $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810
-
811
-            $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
812
-            $res   = mysql_query($query);
813
-            $row   = mysql_fetch_assoc($res);
814
-            mysql_free_result($res);
815
-
816
-            if (is_array($row)) {
817
-                $query = "UPDATE {$this->db_prefix}locks
780
+				}
781
+				mysql_query($query);
782
+			}
783
+		}
784
+
785
+		return "";
786
+	}
787
+
788
+
789
+	/**
790
+	 * LOCK method handler
791
+	 *
792
+	 * @param  array  general parameter passing array
793
+	 * @return bool   true on success
794
+	 */
795
+	function LOCK(&$options)
796
+	{
797
+		// get absolute fs path to requested resource
798
+		$fspath = $this->base . $options["path"];
799
+
800
+		// TODO recursive locks on directories not supported yet
801
+		// makes litmus test "32. lock_collection" fail
802
+		if (is_dir($fspath) && !empty($options["depth"])) {
803
+			return "409 Conflict";
804
+		}
805
+
806
+		$options["timeout"] = time()+300; // 5min. hardcoded
807
+
808
+		if (isset($options["update"])) { // Lock Update
809
+			$where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810
+
811
+			$query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
812
+			$res   = mysql_query($query);
813
+			$row   = mysql_fetch_assoc($res);
814
+			mysql_free_result($res);
815
+
816
+			if (is_array($row)) {
817
+				$query = "UPDATE {$this->db_prefix}locks
818 818
                                  SET expires = '$options[timeout]'
819 819
                                    , modified = ".time()."
820 820
                               $where";
821
-                mysql_query($query);
821
+				mysql_query($query);
822 822
 
823
-                $options['owner'] = $row['owner'];
824
-                $options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared";
825
-                $options['type']  = $row["exclusivelock"] ? "write"     : "read";
823
+				$options['owner'] = $row['owner'];
824
+				$options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared";
825
+				$options['type']  = $row["exclusivelock"] ? "write"     : "read";
826 826
 
827
-                return true;
828
-            } else {
829
-                return false;
830
-            }
831
-        }
827
+				return true;
828
+			} else {
829
+				return false;
830
+			}
831
+		}
832 832
 
833
-        $query = "INSERT INTO {$this->db_prefix}locks
833
+		$query = "INSERT INTO {$this->db_prefix}locks
834 834
                         SET token   = '$options[locktoken]'
835 835
                           , path    = '$options[path]'
836 836
                           , created = ".time()."
@@ -838,76 +838,76 @@  discard block
 block discarded – undo
838 838
                           , owner   = '$options[owner]'
839 839
                           , expires = '$options[timeout]'
840 840
                           , exclusivelock  = " .($options['scope'] === "exclusive" ? "1" : "0")
841
-            ;
842
-        mysql_query($query);
843
-
844
-        return mysql_affected_rows() ? "200 OK" : "409 Conflict";
845
-    }
846
-
847
-    /**
848
-     * UNLOCK method handler
849
-     *
850
-     * @param  array  general parameter passing array
851
-     * @return bool   true on success
852
-     */
853
-    function UNLOCK(&$options)
854
-    {
855
-        $query = "DELETE FROM {$this->db_prefix}locks
841
+			;
842
+		mysql_query($query);
843
+
844
+		return mysql_affected_rows() ? "200 OK" : "409 Conflict";
845
+	}
846
+
847
+	/**
848
+	 * UNLOCK method handler
849
+	 *
850
+	 * @param  array  general parameter passing array
851
+	 * @return bool   true on success
852
+	 */
853
+	function UNLOCK(&$options)
854
+	{
855
+		$query = "DELETE FROM {$this->db_prefix}locks
856 856
                       WHERE path = '$options[path]'
857 857
                         AND token = '$options[token]'";
858
-        mysql_query($query);
859
-
860
-        return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
861
-    }
862
-
863
-    /**
864
-     * checkLock() helper
865
-     *
866
-     * @param  string resource path to check for locks
867
-     * @return bool   true on success
868
-     */
869
-    function checkLock($path)
870
-    {
871
-        $result = false;
872
-
873
-        $query = "SELECT owner, token, created, modified, expires, exclusivelock
858
+		mysql_query($query);
859
+
860
+		return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
861
+	}
862
+
863
+	/**
864
+	 * checkLock() helper
865
+	 *
866
+	 * @param  string resource path to check for locks
867
+	 * @return bool   true on success
868
+	 */
869
+	function checkLock($path)
870
+	{
871
+		$result = false;
872
+
873
+		$query = "SELECT owner, token, created, modified, expires, exclusivelock
874 874
                   FROM {$this->db_prefix}locks
875 875
                  WHERE path = '$path'
876 876
                ";
877
-        $res = mysql_query($query);
878
-
879
-        if ($res) {
880
-            $row = mysql_fetch_array($res);
881
-            mysql_free_result($res);
882
-
883
-            if ($row) {
884
-                $result = array( "type"    => "write",
885
-                                 "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886
-                                 "depth"   => 0,
887
-                                 "owner"   => $row['owner'],
888
-                                 "token"   => $row['token'],
889
-                                 "created" => $row['created'],
890
-                                 "modified" => $row['modified'],
891
-                                 "expires" => $row['expires']
892
-                                 );
893
-            }
894
-        }
895
-
896
-        return $result;
897
-    }
898
-
899
-
900
-    /**
901
-     * create database tables for property and lock storage
902
-     *
903
-     * @param  void
904
-     * @return bool   true on success
905
-     */
906
-    function create_database()
907
-    {
908
-        // TODO
909
-        return false;
910
-    }
877
+		$res = mysql_query($query);
878
+
879
+		if ($res) {
880
+			$row = mysql_fetch_array($res);
881
+			mysql_free_result($res);
882
+
883
+			if ($row) {
884
+				$result = array( "type"    => "write",
885
+								 "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886
+								 "depth"   => 0,
887
+								 "owner"   => $row['owner'],
888
+								 "token"   => $row['token'],
889
+								 "created" => $row['created'],
890
+								 "modified" => $row['modified'],
891
+								 "expires" => $row['expires']
892
+								 );
893
+			}
894
+		}
895
+
896
+		return $result;
897
+	}
898
+
899
+
900
+	/**
901
+	 * create database tables for property and lock storage
902
+	 *
903
+	 * @param  void
904
+	 * @return bool   true on success
905
+	 */
906
+	function create_database()
907
+	{
908
+		// TODO
909
+		return false;
910
+	}
911 911
 }
912 912
 
913 913
 
Please login to merge, or discard this patch.
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -365,18 +365,18 @@  discard block
 block discarded – undo
365 365
             //       the registry)
366 366
             // TODO: have a seperate PEAR class for mimetype detection?
367 367
             switch (strtolower(strrchr(basename($fspath), "."))) {
368
-            case ".html":
369
-                $mime_type = "text/html";
370
-                break;
371
-            case ".gif":
372
-                $mime_type = "image/gif";
373
-                break;
374
-            case ".jpg":
375
-                $mime_type = "image/jpeg";
376
-                break;
377
-            default:
378
-                $mime_type = "application/octet-stream";
379
-                break;
368
+            	case ".html":
369
+                	$mime_type = "text/html";
370
+                	break;
371
+            	case ".gif":
372
+                	$mime_type = "image/gif";
373
+                	break;
374
+            	case ".jpg":
375
+                	$mime_type = "image/jpeg";
376
+                	break;
377
+            	default:
378
+                	$mime_type = "application/octet-stream";
379
+                	break;
380 380
             }
381 381
         }
382 382
 
@@ -633,16 +633,16 @@  discard block
 block discarded – undo
633 633
 
634 634
         if (is_dir($source)) { // resource is a collection
635 635
             switch ($options["depth"]) {
636
-            case "infinity": // valid
637
-                break;
638
-            case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
640
-                    return "400 Bad request";
641
-                }
642
-                break;
643
-            case "1": // invalid for both COPY and MOVE
644
-            default:
645
-                return "400 Bad request";
636
+            	case "infinity": // valid
637
+                	break;
638
+            	case "0": // valid for COPY only
639
+                	if ($del) { // MOVE?
640
+                    	return "400 Bad request";
641
+                	}
642
+                	break;
643
+            	case "1": // invalid for both COPY and MOVE
644
+            	default:
645
+                	return "400 Bad request";
646 646
             }
647 647
         }
648 648
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     function PROPFIND(&$options, &$files)
152 152
     {
153 153
         // get absolute fs path to requested resource
154
-        $fspath = $this->base . $options["path"];
154
+        $fspath = $this->base.$options["path"];
155 155
 
156 156
         // sanity check
157 157
         if (!file_exists($fspath)) {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     function fileinfo($path)
199 199
     {
200 200
         // map URI path to filesystem path
201
-        $fspath = $this->base . $path;
201
+        $fspath = $this->base.$path;
202 202
 
203 203
         // create result array
204 204
         $info = array();
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
         $info["props"][] = $this->mkprop("displayname", strtoupper($path));
211 211
 
212 212
         // creation and modification time
213
-        $info["props"][] = $this->mkprop("creationdate",    filectime($fspath));
213
+        $info["props"][] = $this->mkprop("creationdate", filectime($fspath));
214 214
         $info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath));
215 215
 
216 216
         // Microsoft extensions: last access time and 'hidden' status
217
-        $info["props"][] = $this->mkprop("lastaccessed",    fileatime($fspath));
217
+        $info["props"][] = $this->mkprop("lastaccessed", fileatime($fspath));
218 218
         $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219 219
 
220 220
         // type and size (caller already made sure that path exists)
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
             // so we test the format of the returned string
342 342
 
343 343
             // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
345
-                $reply = substr($reply, strlen($fspath)+2);
344
+            if (!strncmp($reply, "$fspath: ", strlen($fspath) + 2)) {
345
+                $reply = substr($reply, strlen($fspath) + 2);
346 346
                 // followed by the mime type (maybe including options)
347 347
                 if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
348 348
                     $mime_type = $matches[0];
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     function HEAD(&$options)
393 393
     {
394 394
         // get absolute fs path to requested resource
395
-        $fspath = $this->base . $options["path"];
395
+        $fspath = $this->base.$options["path"];
396 396
 
397 397
         // sanity check
398 398
         if (!file_exists($fspath)) return false;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
     function GET(&$options)
422 422
     {
423 423
         // get absolute fs path to requested resource
424
-        $fspath = $this->base . $options["path"];
424
+        $fspath = $this->base.$options["path"];
425 425
 
426 426
         // is this a collection?
427 427
         if (is_dir($fspath)) {
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
      */
505 505
     function PUT(&$options)
506 506
     {
507
-        $fspath = $this->base . $options["path"];
507
+        $fspath = $this->base.$options["path"];
508 508
 
509 509
         $dir = dirname($fspath);
510 510
         if (!file_exists($dir) || !is_dir($dir)) {
511 511
             return "409 Conflict"; // TODO right status code for both?
512 512
         }
513 513
 
514
-        $options["new"] = ! file_exists($fspath);
514
+        $options["new"] = !file_exists($fspath);
515 515
 
516 516
         if ($options["new"] && !$this->_is_writable($dir)) {
517 517
             return "403 Forbidden";
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
      */
538 538
     function MKCOL($options)
539 539
     {
540
-        $path   = $this->base .$options["path"];
540
+        $path   = $this->base.$options["path"];
541 541
         $parent = dirname($path);
542 542
         $name   = basename($path);
543 543
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             return "403 Forbidden";
550 550
         }
551 551
 
552
-        if ( file_exists($parent."/".$name) ) {
552
+        if (file_exists($parent."/".$name)) {
553 553
             return "405 Method not allowed";
554 554
         }
555 555
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
      */
575 575
     function DELETE($options)
576 576
     {
577
-        $path = $this->base . "/" .$options["path"];
577
+        $path = $this->base."/".$options["path"];
578 578
 
579 579
         if (!file_exists($path)) {
580 580
             return "404 Not found";
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      * @param  array  general parameter passing array
614 614
      * @return bool   true on success
615 615
      */
616
-    function COPY($options, $del=false)
616
+    function COPY($options, $del = false)
617 617
     {
618 618
         // TODO Property updates still broken (Litmus should detect this?)
619 619
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
             return "502 bad gateway";
627 627
         }
628 628
 
629
-        $source = $this->base . $options["path"];
629
+        $source = $this->base.$options["path"];
630 630
         if (!file_exists($source)) {
631 631
             return "404 Not found";
632 632
         }
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
             }
647 647
         }
648 648
 
649
-        $dest         = $this->base . $options["dest"];
649
+        $dest         = $this->base.$options["dest"];
650 650
         $destdir      = dirname($dest);
651 651
 
652 652
         if (!file_exists($destdir) || !is_dir($destdir)) {
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
     function LOCK(&$options)
796 796
     {
797 797
         // get absolute fs path to requested resource
798
-        $fspath = $this->base . $options["path"];
798
+        $fspath = $this->base.$options["path"];
799 799
 
800 800
         // TODO recursive locks on directories not supported yet
801 801
         // makes litmus test "32. lock_collection" fail
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
             return "409 Conflict";
804 804
         }
805 805
 
806
-        $options["timeout"] = time()+300; // 5min. hardcoded
806
+        $options["timeout"] = time() + 300; // 5min. hardcoded
807 807
 
808 808
         if (isset($options["update"])) { // Lock Update
809 809
             $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 
823 823
                 $options['owner'] = $row['owner'];
824 824
                 $options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared";
825
-                $options['type']  = $row["exclusivelock"] ? "write"     : "read";
825
+                $options['type']  = $row["exclusivelock"] ? "write" : "read";
826 826
 
827 827
                 return true;
828 828
             } else {
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
                           , modified = ".time()."
838 838
                           , owner   = '$options[owner]'
839 839
                           , expires = '$options[timeout]'
840
-                          , exclusivelock  = " .($options['scope'] === "exclusive" ? "1" : "0")
840
+                          , exclusivelock  = ".($options['scope'] === "exclusive" ? "1" : "0")
841 841
             ;
842 842
         mysql_query($query);
843 843
 
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             mysql_free_result($res);
882 882
 
883 883
             if ($row) {
884
-                $result = array( "type"    => "write",
884
+                $result = array("type"    => "write",
885 885
                                  "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886 886
                                  "depth"   => 0,
887 887
                                  "owner"   => $row['owner'],
Please login to merge, or discard this patch.
Braces   +212 added lines, -91 removed lines patch added patch discarded remove patch
@@ -105,15 +105,19 @@  discard block
 block discarded – undo
105 105
         // special treatment for litmus compliance test
106 106
         // reply on its identifier header
107 107
         // not needed for the test itself but eases debugging
108
-        if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
108
+        if (isset($this->_SERVER['HTTP_X_LITMUS']))
109
+        {
109 110
             error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110 111
             header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111 112
         }
112 113
 
113 114
         // set root directory, defaults to webserver document root if not set
114
-        if ($base) {
115
+        if ($base)
116
+        {
115 117
             $this->base = realpath($base); // TODO throw if not a directory
116
-        } else if (!$this->base) {
118
+        }
119
+        else if (!$this->base)
120
+        {
117 121
             $this->base = $this->_SERVER['DOCUMENT_ROOT'];
118 122
         }
119 123
 
@@ -154,7 +158,8 @@  discard block
 block discarded – undo
154 158
         $fspath = $this->base . $options["path"];
155 159
 
156 160
         // sanity check
157
-        if (!file_exists($fspath)) {
161
+        if (!file_exists($fspath))
162
+        {
158 163
             return false;
159 164
         }
160 165
 
@@ -165,7 +170,8 @@  discard block
 block discarded – undo
165 170
         $files["files"][] = $this->fileinfo($options["path"]);
166 171
 
167 172
         // information for contained resources requested?
168
-        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
173
+        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath))
174
+        {
169 175
 
170 176
             // make sure path ends with '/'
171 177
             $options["path"] = $this->_slashify($options["path"]);
@@ -173,10 +179,13 @@  discard block
 block discarded – undo
173 179
             // try to open directory
174 180
             $handle = opendir($fspath);
175 181
 
176
-            if ($handle) {
182
+            if ($handle)
183
+            {
177 184
                 // ok, now get all its contents
178
-                while ($filename = readdir($handle)) {
179
-                    if ($filename != "." && $filename != "..") {
185
+                while ($filename = readdir($handle))
186
+                {
187
+                    if ($filename != "." && $filename != "..")
188
+                    {
180 189
                         $files["files"][] = $this->fileinfo($options["path"].$filename);
181 190
                     }
182 191
                 }
@@ -218,16 +227,22 @@  discard block
 block discarded – undo
218 227
         $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219 228
 
220 229
         // type and size (caller already made sure that path exists)
221
-        if (is_dir($fspath)) {
230
+        if (is_dir($fspath))
231
+        {
222 232
             // directory (WebDAV collection)
223 233
             $info["props"][] = $this->mkprop("resourcetype", "collection");
224 234
             $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
-        } else {
235
+        }
236
+        else
237
+        {
226 238
             // plain file (WebDAV resource)
227 239
             $info["props"][] = $this->mkprop("resourcetype", "");
228
-            if ($this->_is_readable($fspath)) {
240
+            if ($this->_is_readable($fspath))
241
+            {
229 242
                 $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
-            } else {
243
+            }
244
+            else
245
+            {
231 246
                 $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232 247
             }
233 248
             $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
@@ -238,7 +253,8 @@  discard block
 block discarded – undo
238 253
                         FROM {$this->db_prefix}properties
239 254
                        WHERE path = '$path'";
240 255
         $res = mysql_query($query);
241
-        while ($row = mysql_fetch_assoc($res)) {
256
+        while ($row = mysql_fetch_assoc($res))
257
+        {
242 258
             $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243 259
         }
244 260
         mysql_free_result($res);
@@ -259,30 +275,45 @@  discard block
 block discarded – undo
259 275
     function _can_execute($name, $path = false)
260 276
     {
261 277
         // path defaults to PATH from environment if not set
262
-        if ($path === false) {
278
+        if ($path === false)
279
+        {
263 280
             $path = getenv("PATH");
264 281
         }
265 282
 
266 283
         // check method depends on operating system
267
-        if (!strncmp(PHP_OS, "WIN", 3)) {
284
+        if (!strncmp(PHP_OS, "WIN", 3))
285
+        {
268 286
             // on Windows an appropriate COM or EXE file needs to exist
269 287
             $exts     = array(".exe", ".com");
270 288
             $check_fn = "file_exists";
271
-        } else {
289
+        }
290
+        else
291
+        {
272 292
             // anywhere else we look for an executable file of that name
273 293
             $exts     = array("");
274 294
             $check_fn = "is_executable";
275 295
         }
276 296
 
277 297
         // now check the directories in the path for the program
278
-        foreach (explode(PATH_SEPARATOR, $path) as $dir) {
298
+        foreach (explode(PATH_SEPARATOR, $path) as $dir)
299
+        {
279 300
             // skip invalid path entries
280
-            if (!file_exists($dir)) continue;
281
-            if (!is_dir($dir)) continue;
301
+            if (!file_exists($dir))
302
+            {
303
+            	continue;
304
+            }
305
+            if (!is_dir($dir))
306
+            {
307
+            	continue;
308
+            }
282 309
 
283 310
             // and now look for the file
284
-            foreach ($exts as $ext) {
285
-                if ($check_fn("$dir/$name".$ext)) return true;
311
+            foreach ($exts as $ext)
312
+            {
313
+                if ($check_fn("$dir/$name".$ext))
314
+                {
315
+                	return true;
316
+                }
286 317
             }
287 318
         }
288 319
 
@@ -323,13 +354,18 @@  discard block
 block discarded – undo
323 354
      */
324 355
     function _mimetype($fspath)
325 356
     {
326
-        if (is_dir($fspath)) {
357
+        if (is_dir($fspath))
358
+        {
327 359
             // directories are easy
328 360
             return "httpd/unix-directory";
329
-        } else if (function_exists("mime_content_type")) {
361
+        }
362
+        else if (function_exists("mime_content_type"))
363
+        {
330 364
             // use mime magic extension if available
331 365
             $mime_type = mime_content_type($fspath);
332
-        } else if ($this->_can_execute("file")) {
366
+        }
367
+        else if ($this->_can_execute("file"))
368
+        {
333 369
             // it looks like we have a 'file' command,
334 370
             // lets see it it does have mime support
335 371
             $fp    = popen("file -i '$fspath' 2>/dev/null", "r");
@@ -341,16 +377,19 @@  discard block
 block discarded – undo
341 377
             // so we test the format of the returned string
342 378
 
343 379
             // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
380
+            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2))
381
+            {
345 382
                 $reply = substr($reply, strlen($fspath)+2);
346 383
                 // followed by the mime type (maybe including options)
347
-                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
384
+                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches))
385
+                {
348 386
                     $mime_type = $matches[0];
349 387
                 }
350 388
             }
351 389
         }
352 390
 
353
-        if (empty($mime_type)) {
391
+        if (empty($mime_type))
392
+        {
354 393
             // Fallback solution: try to guess the type by the file extension
355 394
             // TODO: add more ...
356 395
             // TODO: it has been suggested to delegate mimetype detection
@@ -364,7 +403,8 @@  discard block
 block discarded – undo
364 403
             //       anyway (overriding it with information taken from
365 404
             //       the registry)
366 405
             // TODO: have a seperate PEAR class for mimetype detection?
367
-            switch (strtolower(strrchr(basename($fspath), "."))) {
406
+            switch (strtolower(strrchr(basename($fspath), ".")))
407
+            {
368 408
             case ".html":
369 409
                 $mime_type = "text/html";
370 410
                 break;
@@ -395,7 +435,10 @@  discard block
 block discarded – undo
395 435
         $fspath = $this->base . $options["path"];
396 436
 
397 437
         // sanity check
398
-        if (!file_exists($fspath)) return false;
438
+        if (!file_exists($fspath))
439
+        {
440
+        	return false;
441
+        }
399 442
 
400 443
         // detect resource type
401 444
         $options['mimetype'] = $this->_mimetype($fspath);
@@ -424,12 +467,14 @@  discard block
 block discarded – undo
424 467
         $fspath = $this->base . $options["path"];
425 468
 
426 469
         // is this a collection?
427
-        if (is_dir($fspath)) {
470
+        if (is_dir($fspath))
471
+        {
428 472
             return $this->GetDir($fspath, $options);
429 473
         }
430 474
 
431 475
         // the header output is the same as for HEAD
432
-        if (!$this->HEAD($options)) {
476
+        if (!$this->HEAD($options))
477
+        {
433 478
             return false;
434 479
         }
435 480
 
@@ -451,7 +496,8 @@  discard block
 block discarded – undo
451 496
     function GetDir($fspath, &$options)
452 497
     {
453 498
         $path = $this->_slashify($options["path"]);
454
-        if ($path != $options["path"]) {
499
+        if ($path != $options["path"])
500
+        {
455 501
             header("Location: ".$this->base_uri.$path);
456 502
             exit;
457 503
         }
@@ -459,12 +505,14 @@  discard block
 block discarded – undo
459 505
         // fixed width directory column format
460 506
         $format = "%15s  %-19s  %-s\n";
461 507
 
462
-        if (!$this->_is_readable($fspath)) {
508
+        if (!$this->_is_readable($fspath))
509
+        {
463 510
             return false;
464 511
         }
465 512
 
466 513
         $handle = opendir($fspath);
467
-        if (!$handle) {
514
+        if (!$handle)
515
+        {
468 516
             return false;
469 517
         }
470 518
 
@@ -476,8 +524,10 @@  discard block
 block discarded – undo
476 524
         printf($format, "Size", "Last modified", "Filename");
477 525
         echo "<hr>";
478 526
 
479
-        while ($filename = readdir($handle)) {
480
-            if ($filename != "." && $filename != "..") {
527
+        while ($filename = readdir($handle))
528
+        {
529
+            if ($filename != "." && $filename != "..")
530
+            {
481 531
                 $fullpath = $fspath.$filename;
482 532
                 $name     = htmlspecialchars($filename);
483 533
                 printf($format,
@@ -507,19 +557,23 @@  discard block
 block discarded – undo
507 557
         $fspath = $this->base . $options["path"];
508 558
 
509 559
         $dir = dirname($fspath);
510
-        if (!file_exists($dir) || !is_dir($dir)) {
560
+        if (!file_exists($dir) || !is_dir($dir))
561
+        {
511 562
             return "409 Conflict"; // TODO right status code for both?
512 563
         }
513 564
 
514 565
         $options["new"] = ! file_exists($fspath);
515 566
 
516
-        if ($options["new"] && !$this->_is_writable($dir)) {
567
+        if ($options["new"] && !$this->_is_writable($dir))
568
+        {
517 569
             return "403 Forbidden";
518 570
         }
519
-        if (!$options["new"] && !$this->_is_writable($fspath)) {
571
+        if (!$options["new"] && !$this->_is_writable($fspath))
572
+        {
520 573
             return "403 Forbidden";
521 574
         }
522
-        if (!$options["new"] && is_dir($fspath)) {
575
+        if (!$options["new"] && is_dir($fspath))
576
+        {
523 577
             return "403 Forbidden";
524 578
         }
525 579
 
@@ -541,24 +595,30 @@  discard block
 block discarded – undo
541 595
         $parent = dirname($path);
542 596
         $name   = basename($path);
543 597
 
544
-        if (!file_exists($parent)) {
598
+        if (!file_exists($parent))
599
+        {
545 600
             return "409 Conflict";
546 601
         }
547 602
 
548
-        if (!is_dir($parent)) {
603
+        if (!is_dir($parent))
604
+        {
549 605
             return "403 Forbidden";
550 606
         }
551 607
 
552
-        if ( file_exists($parent."/".$name) ) {
608
+        if ( file_exists($parent."/".$name) )
609
+        {
553 610
             return "405 Method not allowed";
554 611
         }
555 612
 
556
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
613
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
614
+        {
615
+// no body parsing yet
557 616
             return "415 Unsupported media type";
558 617
         }
559 618
 
560 619
         $stat = mkdir($parent."/".$name, 0777);
561
-        if (!$stat) {
620
+        if (!$stat)
621
+        {
562 622
             return "403 Forbidden";
563 623
         }
564 624
 
@@ -576,16 +636,20 @@  discard block
 block discarded – undo
576 636
     {
577 637
         $path = $this->base . "/" .$options["path"];
578 638
 
579
-        if (!file_exists($path)) {
639
+        if (!file_exists($path))
640
+        {
580 641
             return "404 Not found";
581 642
         }
582 643
 
583
-        if (is_dir($path)) {
644
+        if (is_dir($path))
645
+        {
584 646
             $query = "DELETE FROM {$this->db_prefix}properties
585 647
                            WHERE path LIKE '".$this->_slashify($options["path"])."%'";
586 648
             mysql_query($query);
587 649
             System::rm(array("-rf", $path));
588
-        } else {
650
+        }
651
+        else
652
+        {
589 653
             unlink($path);
590 654
         }
591 655
         $query = "DELETE FROM {$this->db_prefix}properties
@@ -617,26 +681,35 @@  discard block
 block discarded – undo
617 681
     {
618 682
         // TODO Property updates still broken (Litmus should detect this?)
619 683
 
620
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
684
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
685
+        {
686
+// no body parsing yet
621 687
             return "415 Unsupported media type";
622 688
         }
623 689
 
624 690
         // no copying to different WebDAV Servers yet
625
-        if (isset($options["dest_url"])) {
691
+        if (isset($options["dest_url"]))
692
+        {
626 693
             return "502 bad gateway";
627 694
         }
628 695
 
629 696
         $source = $this->base . $options["path"];
630
-        if (!file_exists($source)) {
697
+        if (!file_exists($source))
698
+        {
631 699
             return "404 Not found";
632 700
         }
633 701
 
634
-        if (is_dir($source)) { // resource is a collection
635
-            switch ($options["depth"]) {
702
+        if (is_dir($source))
703
+        {
704
+// resource is a collection
705
+            switch ($options["depth"])
706
+            {
636 707
             case "infinity": // valid
637 708
                 break;
638 709
             case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
710
+                if ($del)
711
+                {
712
+// MOVE?
640 713
                     return "400 Bad request";
641 714
                 }
642 715
                 break;
@@ -649,7 +722,8 @@  discard block
 block discarded – undo
649 722
         $dest         = $this->base . $options["dest"];
650 723
         $destdir      = dirname($dest);
651 724
 
652
-        if (!file_exists($destdir) || !is_dir($destdir)) {
725
+        if (!file_exists($destdir) || !is_dir($destdir))
726
+        {
653 727
             return "409 Conflict";
654 728
         }
655 729
 
@@ -657,38 +731,52 @@  discard block
 block discarded – undo
657 731
         $new          = !file_exists($dest);
658 732
         $existing_col = false;
659 733
 
660
-        if (!$new) {
661
-            if ($del && is_dir($dest)) {
662
-                if (!$options["overwrite"]) {
734
+        if (!$new)
735
+        {
736
+            if ($del && is_dir($dest))
737
+            {
738
+                if (!$options["overwrite"])
739
+                {
663 740
                     return "412 precondition failed";
664 741
                 }
665 742
                 $dest .= basename($source);
666
-                if (file_exists($dest)) {
743
+                if (file_exists($dest))
744
+                {
667 745
                     $options["dest"] .= basename($source);
668
-                } else {
746
+                }
747
+                else
748
+                {
669 749
                     $new          = true;
670 750
                     $existing_col = true;
671 751
                 }
672 752
             }
673 753
         }
674 754
 
675
-        if (!$new) {
676
-            if ($options["overwrite"]) {
755
+        if (!$new)
756
+        {
757
+            if ($options["overwrite"])
758
+            {
677 759
                 $stat = $this->DELETE(array("path" => $options["dest"]));
678
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
760
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
761
+                {
679 762
                     return $stat;
680 763
                 }
681
-            } else {
764
+            }
765
+            else
766
+            {
682 767
                 return "412 precondition failed";
683 768
             }
684 769
         }
685 770
 
686
-        if ($del) {
687
-            if (!rename($source, $dest)) {
771
+        if ($del)
772
+        {
773
+            if (!rename($source, $dest))
774
+            {
688 775
                 return "500 Internal server error";
689 776
             }
690 777
             $destpath = $this->_unslashify($options["dest"]);
691
-            if (is_dir($source)) {
778
+            if (is_dir($source))
779
+            {
692 780
                 $query = "UPDATE {$this->db_prefix}properties
693 781
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 782
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
@@ -699,40 +787,58 @@  discard block
 block discarded – undo
699 787
                              SET path = '".$destpath."'
700 788
                            WHERE path = '".$options["path"]."'";
701 789
             mysql_query($query);
702
-        } else {
703
-            if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
790
+        }
791
+        else
792
+        {
793
+            if (is_dir($source) && $options["depth"] == "infinity")
794
+            {
795
+// no find for depth="0"
704 796
                 $files = System::find($source);
705 797
                 $files = array_reverse($files);
706
-            } else {
798
+            }
799
+            else
800
+            {
707 801
                 $files = array($source);
708 802
             }
709 803
 
710
-            if (!is_array($files) || empty($files)) {
804
+            if (!is_array($files) || empty($files))
805
+            {
711 806
                 return "500 Internal server error";
712 807
             }
713 808
 
714 809
 
715
-            foreach ($files as $file) {
716
-                if (is_dir($file)) {
810
+            foreach ($files as $file)
811
+            {
812
+                if (is_dir($file))
813
+                {
717 814
                     $file = $this->_slashify($file);
718 815
                 }
719 816
 
720 817
                 $destfile = str_replace($source, $dest, $file);
721 818
 
722
-                if (is_dir($file)) {
723
-                    if (!file_exists($destfile)) {
724
-                        if (!$this->_is_writable(dirname($destfile))) {
819
+                if (is_dir($file))
820
+                {
821
+                    if (!file_exists($destfile))
822
+                    {
823
+                        if (!$this->_is_writable(dirname($destfile)))
824
+                        {
725 825
                             return "403 Forbidden";
726 826
                         }
727
-                        if (!mkdir($destfile)) {
827
+                        if (!mkdir($destfile))
828
+                        {
728 829
                             return "409 Conflict";
729 830
                         }
730
-                    } else if (!is_dir($destfile)) {
831
+                    }
832
+                    else if (!is_dir($destfile))
833
+                    {
731 834
                         return "409 Conflict";
732 835
                     }
733
-                } else {
836
+                }
837
+                else
838
+                {
734 839
 
735
-                    if (!copy($file, $destfile)) {
840
+                    if (!copy($file, $destfile))
841
+                    {
736 842
                         return "409 Conflict";
737 843
                     }
738 844
                 }
@@ -762,17 +868,24 @@  discard block
 block discarded – undo
762 868
         $dir  = dirname($path)."/";
763 869
         $base = basename($path);
764 870
 
765
-        foreach ($options["props"] as $key => $prop) {
766
-            if ($prop["ns"] == "DAV:") {
871
+        foreach ($options["props"] as $key => $prop)
872
+        {
873
+            if ($prop["ns"] == "DAV:")
874
+            {
767 875
                 $options["props"][$key]['status'] = "403 Forbidden";
768
-            } else {
769
-                if (isset($prop["val"])) {
876
+            }
877
+            else
878
+            {
879
+                if (isset($prop["val"]))
880
+                {
770 881
                     $query = "REPLACE INTO {$this->db_prefix}properties
771 882
                                            SET path = '$options[path]'
772 883
                                              , name = '$prop[name]'
773 884
                                              , ns= '$prop[ns]'
774 885
                                              , value = '$prop[val]'";
775
-                } else {
886
+                }
887
+                else
888
+                {
776 889
                     $query = "DELETE FROM {$this->db_prefix}properties
777 890
                                         WHERE path = '$options[path]'
778 891
                                           AND name = '$prop[name]'
@@ -799,13 +912,16 @@  discard block
 block discarded – undo
799 912
 
800 913
         // TODO recursive locks on directories not supported yet
801 914
         // makes litmus test "32. lock_collection" fail
802
-        if (is_dir($fspath) && !empty($options["depth"])) {
915
+        if (is_dir($fspath) && !empty($options["depth"]))
916
+        {
803 917
             return "409 Conflict";
804 918
         }
805 919
 
806 920
         $options["timeout"] = time()+300; // 5min. hardcoded
807 921
 
808
-        if (isset($options["update"])) { // Lock Update
922
+        if (isset($options["update"]))
923
+        {
924
+// Lock Update
809 925
             $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810 926
 
811 927
             $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
@@ -813,7 +929,8 @@  discard block
 block discarded – undo
813 929
             $row   = mysql_fetch_assoc($res);
814 930
             mysql_free_result($res);
815 931
 
816
-            if (is_array($row)) {
932
+            if (is_array($row))
933
+            {
817 934
                 $query = "UPDATE {$this->db_prefix}locks
818 935
                                  SET expires = '$options[timeout]'
819 936
                                    , modified = ".time()."
@@ -825,7 +942,9 @@  discard block
 block discarded – undo
825 942
                 $options['type']  = $row["exclusivelock"] ? "write"     : "read";
826 943
 
827 944
                 return true;
828
-            } else {
945
+            }
946
+            else
947
+            {
829 948
                 return false;
830 949
             }
831 950
         }
@@ -876,11 +995,13 @@  discard block
 block discarded – undo
876 995
                ";
877 996
         $res = mysql_query($query);
878 997
 
879
-        if ($res) {
998
+        if ($res)
999
+        {
880 1000
             $row = mysql_fetch_array($res);
881 1001
             mysql_free_result($res);
882 1002
 
883
-            if ($row) {
1003
+            if ($row)
1004
+            {
884 1005
                 $result = array( "type"    => "write",
885 1006
                                  "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886 1007
                                  "depth"   => 0,
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
             }
690 690
             $destpath = $this->_unslashify($options["dest"]);
691 691
             if (is_dir($source)) {
692
-                $query = "UPDATE {$this->db_prefix}properties
692
+                $query = "update {$this->db_prefix}properties
693 693
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 694
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
695 695
                 mysql_query($query);
696 696
             }
697 697
 
698
-            $query = "UPDATE {$this->db_prefix}properties
698
+            $query = "update {$this->db_prefix}properties
699 699
                              SET path = '".$destpath."'
700 700
                            WHERE path = '".$options["path"]."'";
701 701
             mysql_query($query);
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
             mysql_free_result($res);
815 815
 
816 816
             if (is_array($row)) {
817
-                $query = "UPDATE {$this->db_prefix}locks
817
+                $query = "update {$this->db_prefix}locks
818 818
                                  SET expires = '$options[timeout]'
819 819
                                    , modified = ".time()."
820 820
                               $where";
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_proppatch.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -95,6 +95,7 @@
 block discarded – undo
95 95
      *
96 96
      * @param  string  path of input stream
97 97
      * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
+     * @param string $path
98 99
      * @access public
99 100
      */
100 101
     function __construct($path, $store_request=false)
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -43,198 +43,198 @@
 block discarded – undo
43 43
  */
44 44
 class _parse_proppatch
45 45
 {
46
-    /**
47
-     *
48
-     *
49
-     * @var
50
-     * @access
51
-     */
52
-    var $success;
53
-
54
-    /**
55
-     *
56
-     *
57
-     * @var
58
-     * @access
59
-     */
60
-    var $props;
61
-
62
-    /**
63
-     *
64
-     *
65
-     * @var
66
-     * @access
67
-     */
68
-    var $depth;
69
-
70
-    /**
71
-     *
72
-     *
73
-     * @var
74
-     * @access
75
-     */
76
-    var $mode;
77
-
78
-    /**
79
-     *
80
-     *
81
-     * @var
82
-     * @access
83
-     */
84
-    var $current;
85
-
86
-    /**
87
-     * On return whole request, if $store_request == true was specified in constructor
88
-     *
89
-     * @var string
90
-     */
91
-    var $request;
92
-
93
-    /**
94
-     * constructor
95
-     *
96
-     * @param  string  path of input stream
97
-     * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
-     * @access public
99
-     */
100
-    function __construct($path, $store_request=false)
101
-    {
102
-        $this->success = true;
103
-
104
-        $this->depth = 0;
105
-        $this->props = array();
106
-        $had_input = false;
107
-
108
-        $f_in = fopen($path, "r");
109
-        if (!$f_in) {
110
-            $this->success = false;
111
-            return;
112
-        }
113
-
114
-        $xml_parser = xml_parser_create_ns("UTF-8", " ");
115
-
116
-        xml_set_element_handler($xml_parser,
117
-                                array(&$this, "_startElement"),
118
-                                array(&$this, "_endElement"));
119
-
120
-        xml_set_character_data_handler($xml_parser,
121
-                                       array(&$this, "_data"));
122
-
123
-        xml_parser_set_option($xml_parser,
124
-                              XML_OPTION_CASE_FOLDING, false);
125
-
126
-        while($this->success && !feof($f_in)) {
127
-            $line = fgets($f_in);
128
-            if ($store_request) $this->request .= $line;
129
-            if (is_string($line)) {
130
-                $had_input = true;
131
-                $this->success &= xml_parse($xml_parser, $line, false);
132
-            }
133
-        }
134
-
135
-        if($had_input) {
136
-            $this->success &= xml_parse($xml_parser, "", true);
137
-        }
138
-
139
-        xml_parser_free($xml_parser);
140
-
141
-        fclose($f_in);
142
-    }
143
-
144
-    /**
145
-     * tag start handler
146
-     *
147
-     * @param  resource  parser
148
-     * @param  string    tag name
149
-     * @param  array     tag attributes
150
-     * @return void
151
-     * @access private
152
-     */
153
-    function _startElement($parser, $name, $attrs)
154
-    {
155
-        if (strstr($name, " ")) {
156
-            list($ns, $tag) = explode(" ", $name);
157
-            if ($ns == "")
158
-                $this->success = false;
159
-        } else {
160
-            $ns = "";
161
-            $tag = $name;
162
-        }
163
-
164
-        if ($this->depth == 1) {
165
-            $this->mode = $tag;
166
-        }
167
-
168
-        if ($this->depth == 3) {
169
-            $prop = array("name" => $tag);
170
-            $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
-            if ($this->mode == "set") {
172
-                $this->current["val"] = "";     // default set val
173
-            }
174
-        }
175
-
176
-        if ($this->depth >= 4) {
177
-            $this->current["val"] .= "<$tag";
178
-            if (isset($attr)) {
179
-                foreach ($attr as $key => $val) {
180
-                    $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181
-                }
182
-            }
183
-            $this->current["val"] .= ">";
184
-        }
185
-
186
-
187
-
188
-        $this->depth++;
189
-    }
190
-
191
-    /**
192
-     * tag end handler
193
-     *
194
-     * @param  resource  parser
195
-     * @param  string    tag name
196
-     * @return void
197
-     * @access private
198
-     */
199
-    function _endElement($parser, $name)
200
-    {
201
-        if (strstr($name, " ")) {
202
-            list($ns, $tag) = explode(" ", $name);
203
-            if ($ns == "")
204
-                $this->success = false;
205
-        } else {
206
-            $ns = "";
207
-            $tag = $name;
208
-        }
209
-
210
-        $this->depth--;
211
-
212
-        if ($this->depth >= 4) {
213
-            $this->current["val"] .= "</$tag>";
214
-        }
215
-
216
-        if ($this->depth == 3) {
217
-            if (isset($this->current)) {
218
-                $this->props[] = $this->current;
219
-                unset($this->current);
220
-            }
221
-        }
222
-    }
223
-
224
-    /**
225
-     * input data handler
226
-     *
227
-     * @param  resource  parser
228
-     * @param  string    data
229
-     * @return void
230
-     * @access private
231
-     */
232
-    function _data($parser, $data)
233
-    {
234
-        if (isset($this->current)) {
235
-            $this->current["val"] .= $data;
236
-        }
237
-    }
46
+	/**
47
+	 *
48
+	 *
49
+	 * @var
50
+	 * @access
51
+	 */
52
+	var $success;
53
+
54
+	/**
55
+	 *
56
+	 *
57
+	 * @var
58
+	 * @access
59
+	 */
60
+	var $props;
61
+
62
+	/**
63
+	 *
64
+	 *
65
+	 * @var
66
+	 * @access
67
+	 */
68
+	var $depth;
69
+
70
+	/**
71
+	 *
72
+	 *
73
+	 * @var
74
+	 * @access
75
+	 */
76
+	var $mode;
77
+
78
+	/**
79
+	 *
80
+	 *
81
+	 * @var
82
+	 * @access
83
+	 */
84
+	var $current;
85
+
86
+	/**
87
+	 * On return whole request, if $store_request == true was specified in constructor
88
+	 *
89
+	 * @var string
90
+	 */
91
+	var $request;
92
+
93
+	/**
94
+	 * constructor
95
+	 *
96
+	 * @param  string  path of input stream
97
+	 * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
+	 * @access public
99
+	 */
100
+	function __construct($path, $store_request=false)
101
+	{
102
+		$this->success = true;
103
+
104
+		$this->depth = 0;
105
+		$this->props = array();
106
+		$had_input = false;
107
+
108
+		$f_in = fopen($path, "r");
109
+		if (!$f_in) {
110
+			$this->success = false;
111
+			return;
112
+		}
113
+
114
+		$xml_parser = xml_parser_create_ns("UTF-8", " ");
115
+
116
+		xml_set_element_handler($xml_parser,
117
+								array(&$this, "_startElement"),
118
+								array(&$this, "_endElement"));
119
+
120
+		xml_set_character_data_handler($xml_parser,
121
+									   array(&$this, "_data"));
122
+
123
+		xml_parser_set_option($xml_parser,
124
+							  XML_OPTION_CASE_FOLDING, false);
125
+
126
+		while($this->success && !feof($f_in)) {
127
+			$line = fgets($f_in);
128
+			if ($store_request) $this->request .= $line;
129
+			if (is_string($line)) {
130
+				$had_input = true;
131
+				$this->success &= xml_parse($xml_parser, $line, false);
132
+			}
133
+		}
134
+
135
+		if($had_input) {
136
+			$this->success &= xml_parse($xml_parser, "", true);
137
+		}
138
+
139
+		xml_parser_free($xml_parser);
140
+
141
+		fclose($f_in);
142
+	}
143
+
144
+	/**
145
+	 * tag start handler
146
+	 *
147
+	 * @param  resource  parser
148
+	 * @param  string    tag name
149
+	 * @param  array     tag attributes
150
+	 * @return void
151
+	 * @access private
152
+	 */
153
+	function _startElement($parser, $name, $attrs)
154
+	{
155
+		if (strstr($name, " ")) {
156
+			list($ns, $tag) = explode(" ", $name);
157
+			if ($ns == "")
158
+				$this->success = false;
159
+		} else {
160
+			$ns = "";
161
+			$tag = $name;
162
+		}
163
+
164
+		if ($this->depth == 1) {
165
+			$this->mode = $tag;
166
+		}
167
+
168
+		if ($this->depth == 3) {
169
+			$prop = array("name" => $tag);
170
+			$this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
+			if ($this->mode == "set") {
172
+				$this->current["val"] = "";     // default set val
173
+			}
174
+		}
175
+
176
+		if ($this->depth >= 4) {
177
+			$this->current["val"] .= "<$tag";
178
+			if (isset($attr)) {
179
+				foreach ($attr as $key => $val) {
180
+					$this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181
+				}
182
+			}
183
+			$this->current["val"] .= ">";
184
+		}
185
+
186
+
187
+
188
+		$this->depth++;
189
+	}
190
+
191
+	/**
192
+	 * tag end handler
193
+	 *
194
+	 * @param  resource  parser
195
+	 * @param  string    tag name
196
+	 * @return void
197
+	 * @access private
198
+	 */
199
+	function _endElement($parser, $name)
200
+	{
201
+		if (strstr($name, " ")) {
202
+			list($ns, $tag) = explode(" ", $name);
203
+			if ($ns == "")
204
+				$this->success = false;
205
+		} else {
206
+			$ns = "";
207
+			$tag = $name;
208
+		}
209
+
210
+		$this->depth--;
211
+
212
+		if ($this->depth >= 4) {
213
+			$this->current["val"] .= "</$tag>";
214
+		}
215
+
216
+		if ($this->depth == 3) {
217
+			if (isset($this->current)) {
218
+				$this->props[] = $this->current;
219
+				unset($this->current);
220
+			}
221
+		}
222
+	}
223
+
224
+	/**
225
+	 * input data handler
226
+	 *
227
+	 * @param  resource  parser
228
+	 * @param  string    data
229
+	 * @return void
230
+	 * @access private
231
+	 */
232
+	function _data($parser, $data)
233
+	{
234
+		if (isset($this->current)) {
235
+			$this->current["val"] .= $data;
236
+		}
237
+	}
238 238
 }
239 239
 
240 240
 /*
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param boolean $store_request =false if true whole request data will be made available in $this->request
98 98
      * @access public
99 99
      */
100
-    function __construct($path, $store_request=false)
100
+    function __construct($path, $store_request = false)
101 101
     {
102 102
         $this->success = true;
103 103
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         xml_parser_set_option($xml_parser,
124 124
                               XML_OPTION_CASE_FOLDING, false);
125 125
 
126
-        while($this->success && !feof($f_in)) {
126
+        while ($this->success && !feof($f_in)) {
127 127
             $line = fgets($f_in);
128 128
             if ($store_request) $this->request .= $line;
129 129
             if (is_string($line)) {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             }
133 133
         }
134 134
 
135
-        if($had_input) {
135
+        if ($had_input) {
136 136
             $this->success &= xml_parse($xml_parser, "", true);
137 137
         }
138 138
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $prop = array("name" => $tag);
170 170
             $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171 171
             if ($this->mode == "set") {
172
-                $this->current["val"] = "";     // default set val
172
+                $this->current["val"] = ""; // default set val
173 173
             }
174 174
         }
175 175
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $this->current["val"] .= "<$tag";
178 178
             if (isset($attr)) {
179 179
                 foreach ($attr as $key => $val) {
180
-                    $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
180
+                    $this->current["val"] .= ' '.$key.'="'.str_replace('"', '&quot;', $val).'"';
181 181
                 }
182 182
             }
183 183
             $this->current["val"] .= ">";
Please login to merge, or discard this patch.
Braces   +48 added lines, -21 removed lines patch added patch discarded remove patch
@@ -106,7 +106,8 @@  discard block
 block discarded – undo
106 106
         $had_input = false;
107 107
 
108 108
         $f_in = fopen($path, "r");
109
-        if (!$f_in) {
109
+        if (!$f_in)
110
+        {
110 111
             $this->success = false;
111 112
             return;
112 113
         }
@@ -123,16 +124,22 @@  discard block
 block discarded – undo
123 124
         xml_parser_set_option($xml_parser,
124 125
                               XML_OPTION_CASE_FOLDING, false);
125 126
 
126
-        while($this->success && !feof($f_in)) {
127
+        while($this->success && !feof($f_in))
128
+        {
127 129
             $line = fgets($f_in);
128
-            if ($store_request) $this->request .= $line;
129
-            if (is_string($line)) {
130
+            if ($store_request)
131
+            {
132
+            	$this->request .= $line;
133
+            }
134
+            if (is_string($line))
135
+            {
130 136
                 $had_input = true;
131 137
                 $this->success &= xml_parse($xml_parser, $line, false);
132 138
             }
133 139
         }
134 140
 
135
-        if($had_input) {
141
+        if($had_input)
142
+        {
136 143
             $this->success &= xml_parse($xml_parser, "", true);
137 144
         }
138 145
 
@@ -152,31 +159,42 @@  discard block
 block discarded – undo
152 159
      */
153 160
     function _startElement($parser, $name, $attrs)
154 161
     {
155
-        if (strstr($name, " ")) {
162
+        if (strstr($name, " "))
163
+        {
156 164
             list($ns, $tag) = explode(" ", $name);
157 165
             if ($ns == "")
158
-                $this->success = false;
159
-        } else {
166
+            {
167
+                            $this->success = false;
168
+            }
169
+        }
170
+        else
171
+        {
160 172
             $ns = "";
161 173
             $tag = $name;
162 174
         }
163 175
 
164
-        if ($this->depth == 1) {
176
+        if ($this->depth == 1)
177
+        {
165 178
             $this->mode = $tag;
166 179
         }
167 180
 
168
-        if ($this->depth == 3) {
181
+        if ($this->depth == 3)
182
+        {
169 183
             $prop = array("name" => $tag);
170 184
             $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
-            if ($this->mode == "set") {
185
+            if ($this->mode == "set")
186
+            {
172 187
                 $this->current["val"] = "";     // default set val
173 188
             }
174 189
         }
175 190
 
176
-        if ($this->depth >= 4) {
191
+        if ($this->depth >= 4)
192
+        {
177 193
             $this->current["val"] .= "<$tag";
178
-            if (isset($attr)) {
179
-                foreach ($attr as $key => $val) {
194
+            if (isset($attr))
195
+            {
196
+                foreach ($attr as $key => $val)
197
+                {
180 198
                     $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181 199
                 }
182 200
             }
@@ -198,23 +216,31 @@  discard block
 block discarded – undo
198 216
      */
199 217
     function _endElement($parser, $name)
200 218
     {
201
-        if (strstr($name, " ")) {
219
+        if (strstr($name, " "))
220
+        {
202 221
             list($ns, $tag) = explode(" ", $name);
203 222
             if ($ns == "")
204
-                $this->success = false;
205
-        } else {
223
+            {
224
+                            $this->success = false;
225
+            }
226
+        }
227
+        else
228
+        {
206 229
             $ns = "";
207 230
             $tag = $name;
208 231
         }
209 232
 
210 233
         $this->depth--;
211 234
 
212
-        if ($this->depth >= 4) {
235
+        if ($this->depth >= 4)
236
+        {
213 237
             $this->current["val"] .= "</$tag>";
214 238
         }
215 239
 
216
-        if ($this->depth == 3) {
217
-            if (isset($this->current)) {
240
+        if ($this->depth == 3)
241
+        {
242
+            if (isset($this->current))
243
+            {
218 244
                 $this->props[] = $this->current;
219 245
                 unset($this->current);
220 246
             }
@@ -231,7 +257,8 @@  discard block
 block discarded – undo
231 257
      */
232 258
     function _data($parser, $data)
233 259
     {
234
-        if (isset($this->current)) {
260
+        if (isset($this->current))
261
+        {
235 262
             $this->current["val"] .= $data;
236 263
         }
237 264
     }
Please login to merge, or discard this patch.
api/thumbnail.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -80,6 +80,7 @@
 block discarded – undo
80 80
 
81 81
 /**
82 82
  * Returns the maximum width/height of a thumbnail
83
+ * @return integer|null
83 84
  */
84 85
 function get_maxsize()
85 86
 {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 	}
72 72
 
73
-	if (!preg_match('/^[a-z0-9_-]+$/i',$app))
73
+	if (!preg_match('/^[a-z0-9_-]+$/i', $app))
74 74
 	{
75
-		die('Stop');	// just to prevent someone doing nasty things
75
+		die('Stop'); // just to prevent someone doing nasty things
76 76
 	}
77 77
 
78 78
 	return $app;
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function get_maxsize()
85 85
 {
86
-	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 :
87
-		$GLOBALS['egw_info']['server']['link_list_thumbnail'];
86
+	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail'];
88 87
 
89 88
 	// Another maximum size may be passed if thumbnails are turned on
90 89
 	if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize']))
@@ -150,7 +149,7 @@  discard block
 block discarded – undo
150 149
 	}
151 150
 	$dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize);
152 151
 	$dst_dir = dirname($dst);
153
-	if(file_exists($dst_dir))
152
+	if (file_exists($dst_dir))
154 153
 	{
155 154
 		// Check whether the destination file already exists and is newer than
156 155
 		// the source file. Assume the file doesn't exist if thumbnailing is turned off.
@@ -190,7 +189,7 @@  discard block
 block discarded – undo
190 189
 		{
191 190
 			// Allow client to cache these, makes scrolling in filemanager much nicer
192 191
 			// setting maximum allow caching time of one year, if url contains (non-empty) moditication time
193
-			Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true);	// true = private / browser only caching
192
+			Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching
194 193
 			header('Content-Type: '.$output_mime);
195 194
 			readfile($dst);
196 195
 			return true;
@@ -212,7 +211,7 @@  discard block
 block discarded – undo
212 211
  * @param int $minsize =null
213 212
  * @return string
214 213
  */
215
-function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null)
214
+function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null)
216 215
 {
217 216
 	// Use the egroupware file cache to store the thumbnails on a per instance basis
218 217
 	$cachefile = new Api\Cache\Files(array());
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
  * TODO: As this is a general purpose function, it might probably be moved
239 238
  *   to some other php file or an "image utils" class.
240 239
  */
241
-function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0)
240
+function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0)
242 241
 {
243 242
 	//Scale will contain the factor by which the image has to be scaled down
244 243
 	$scale = 1.0;
@@ -299,7 +298,7 @@  discard block
 block discarded – undo
299 298
  * @param int $maxh the maximum height of the thumbnail
300 299
  * @returns boolean|resource false or a gd_image
301 300
  */
302
-function gd_image_load($file,$maxw,$maxh)
301
+function gd_image_load($file, $maxw, $maxh)
303 302
 {
304 303
 	// Get mime type
305 304
 	list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file));
@@ -307,9 +306,9 @@  discard block
 block discarded – undo
307 306
 	if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
308 307
 
309 308
 	// Call the according gd constructor depending on the file type
310
-	if($type == 'image')
309
+	if ($type == 'image')
311 310
 	{
312
-		if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file)))
311
+		if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file)))
313 312
 		{
314 313
 			return $image;
315 314
 		}
@@ -332,12 +331,12 @@  discard block
 block discarded – undo
332 331
 	else if ($type == 'application')
333 332
 	{
334 333
 		$thumb = false;
335
-		if(strpos($image_type,'vnd.oasis.opendocument.') === 0)
334
+		if (strpos($image_type, 'vnd.oasis.opendocument.') === 0)
336 335
 		{
337 336
 			// OpenDocuments have thumbnails inside already
338 337
 			$thumb = get_opendocument_thumbnail($file);
339 338
 		}
340
-		else if($image_type == 'pdf')
339
+		else if ($image_type == 'pdf')
341 340
 		{
342 341
 			$thumb = get_pdf_thumbnail($file);
343 342
 		}
@@ -347,7 +346,7 @@  discard block
 block discarded – undo
347 346
 			//$thumb = get_msoffice_thumbnail($file);
348 347
 		}
349 348
 		// Mark it with mime type icon
350
-		if($thumb)
349
+		if ($thumb)
351 350
 		{
352 351
 			// Need to scale first, or the mark will be wrong size
353 352
 			$scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh);
@@ -387,8 +386,8 @@  discard block
 block discarded – undo
387 386
 
388 387
 	// Image is already there, but we can't access them directly through VFS
389 388
 	$ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods';
390
-	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-');
391
-	copy($file,$archive);
389
+	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-');
390
+	copy($file, $archive);
392 391
 
393 392
 	$thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png';
394 393
 	$image = imagecreatefromstring(file_get_contents($thumbnail_url));
@@ -442,7 +441,7 @@  discard block
 block discarded – undo
442 441
  */
443 442
 function get_pdf_thumbnail($file)
444 443
 {
445
-	if(!pdf_thumbnails_available()) return false;
444
+	if (!pdf_thumbnails_available()) return false;
446 445
 
447 446
 	// switch off max_excution_time, as some thumbnails take longer and
448 447
 	// will be startet over and over again, if they dont finish
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	$target_height = imagesy($target_image);
472 471
 
473 472
 	// Find mime image, if no tag image set
474
-	if(!$tag_image && $mime)
473
+	if (!$tag_image && $mime)
475 474
 	{
476 475
 		list($app, $icon) = explode('/', Vfs::mime_icon($mime), 2);
477 476
 		list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'],
@@ -482,16 +481,16 @@  discard block
 block discarded – undo
482 481
 
483 482
 	// Find correct size - max 1/3 target
484 483
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
485
-	if(!$tag_size) return;
486
-	list($tag_width,$tag_height) = $tag_size;
484
+	if (!$tag_size) return;
485
+	list($tag_width, $tag_height) = $tag_size;
487 486
 
488 487
 	// Put it in
489
-	if($mime)
488
+	if ($mime)
490 489
 	{
491
-		imagecopyresampled($target_image,$tag_image,
490
+		imagecopyresampled($target_image, $tag_image,
492 491
 			$target_width - $tag_width,
493 492
 			$target_height - $tag_height,
494
-			0,0,
493
+			0, 0,
495 494
 			$tag_width,
496 495
 			$tag_height,
497 496
 			imagesx($tag_image),
@@ -545,7 +544,7 @@  discard block
 block discarded – undo
545 544
 function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh)
546 545
 {
547 546
 	//Load the image
548
-	if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false)
547
+	if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false)
549 548
 	{
550 549
 		//Get the constraints of the image
551 550
 		$w = imagesx($img_src);
@@ -575,14 +574,14 @@  discard block
 block discarded – undo
575 574
 */
576 575
 function gdVersion($user_ver = 0)
577 576
 {
578
-	if (! extension_loaded('gd')) { return; }
577
+	if (!extension_loaded('gd')) { return; }
579 578
 	static $gd_ver = 0;
580 579
 
581 580
 	// Just accept the specified setting if it's 1.
582 581
 	if ($user_ver == 1) { $gd_ver = 1; return 1; }
583 582
 
584 583
 	// Use the static variable if function was called previously.
585
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
584
+	if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; }
586 585
 
587 586
 	// Use the gd_info() function if possible.
588 587
 	if (function_exists('gd_info')) {
Please login to merge, or discard this patch.
Braces   +38 added lines, -12 removed lines patch added patch discarded remove patch
@@ -244,10 +244,13 @@  discard block
 block discarded – undo
244 244
 	$scale = 1.0;
245 245
 
246 246
 	//Select the constraining dimension
247
-	if ($w > $h) // landscape image: constraining factor $minh or $maxw
247
+	if ($w > $h)
248
+	{
249
+		// landscape image: constraining factor $minh or $maxw
248 250
 	{
249 251
 		$scale = $minh ? $minh / $h : $maxw / $w;
250 252
 	}
253
+	}
251 254
 	else // portrail image: constraining factor $minw or $maxh
252 255
 	{
253 256
 		$scale = $minw ? $minw / $w : $maxh / $h;
@@ -304,7 +307,10 @@  discard block
 block discarded – undo
304 307
 	// Get mime type
305 308
 	list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file));
306 309
 	// if $file is not from vfs, use Api\MimeMagic::filename2mime to get mime-type from extension
307
-	if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
310
+	if (!$type)
311
+	{
312
+		list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
313
+	}
308 314
 
309 315
 	// Call the according gd constructor depending on the file type
310 316
 	if($type == 'image')
@@ -442,7 +448,10 @@  discard block
 block discarded – undo
442 448
  */
443 449
 function get_pdf_thumbnail($file)
444 450
 {
445
-	if(!pdf_thumbnails_available()) return false;
451
+	if(!pdf_thumbnails_available())
452
+	{
453
+		return false;
454
+	}
446 455
 
447 456
 	// switch off max_excution_time, as some thumbnails take longer and
448 457
 	// will be startet over and over again, if they dont finish
@@ -482,7 +491,10 @@  discard block
 block discarded – undo
482 491
 
483 492
 	// Find correct size - max 1/3 target
484 493
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
485
-	if(!$tag_size) return;
494
+	if(!$tag_size)
495
+	{
496
+		return;
497
+	}
486 498
 	list($tag_width,$tag_height) = $tag_size;
487 499
 
488 500
 	// Put it in
@@ -575,17 +587,24 @@  discard block
 block discarded – undo
575 587
 */
576 588
 function gdVersion($user_ver = 0)
577 589
 {
578
-	if (! extension_loaded('gd')) { return; }
590
+	if (! extension_loaded('gd'))
591
+	{
592
+return; }
579 593
 	static $gd_ver = 0;
580 594
 
581 595
 	// Just accept the specified setting if it's 1.
582
-	if ($user_ver == 1) { $gd_ver = 1; return 1; }
596
+	if ($user_ver == 1)
597
+	{
598
+$gd_ver = 1; return 1; }
583 599
 
584 600
 	// Use the static variable if function was called previously.
585
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
601
+	if ($user_ver !=2 && $gd_ver > 0 )
602
+	{
603
+return $gd_ver; }
586 604
 
587 605
 	// Use the gd_info() function if possible.
588
-	if (function_exists('gd_info')) {
606
+	if (function_exists('gd_info'))
607
+	{
589 608
 		$ver_info = gd_info();
590 609
 		$match = null;
591 610
 		preg_match('/\d/', $ver_info['GD Version'], $match);
@@ -594,11 +613,15 @@  discard block
 block discarded – undo
594 613
 	}
595 614
 
596 615
 	// If phpinfo() is disabled use a specified / fail-safe choice...
597
-	if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
598
-		if ($user_ver == 2) {
616
+	if (preg_match('/phpinfo/', ini_get('disable_functions')))
617
+	{
618
+		if ($user_ver == 2)
619
+		{
599 620
 			$gd_ver = 2;
600 621
 			return 2;
601
-		} else {
622
+		}
623
+		else
624
+		{
602 625
 			$gd_ver = 1;
603 626
 			return 1;
604 627
 		}
@@ -607,6 +630,9 @@  discard block
 block discarded – undo
607 630
 	ob_start();
608 631
 	phpinfo(8);
609 632
 	$info = stristr(ob_get_clean(), 'gd version');
610
-	if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0];
633
+	if (preg_match('/\d/', $info, $match))
634
+	{
635
+		$gd_ver = $match[0];
636
+	}
611 637
 	return $match[0];
612 638
 }
Please login to merge, or discard this patch.
calendar/importexport/class.import_events_csv.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,6 @@
 block discarded – undo
94 94
 	/**
95 95
 	 * imports entries according to given definition object.
96 96
 	 * @param resource $_stream
97
-	 * @param string $_charset
98 97
 	 * @param definition $_definition
99 98
 	 */
100 99
 	public function import( $_stream, definition $_definition ) {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	private $user = null;
83 83
 
84 84
 	/**
85
-         * List of import errors
86
-         */
87
-        protected $errors = array();
85
+	 * List of import errors
86
+	 */
87
+		protected $errors = array();
88 88
 
89 89
 	/**
90 90
 	 * List of actions, and how many times that action was taken
@@ -305,26 +305,26 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-        * Returns errors that were encountered during importing
309
-        * Maximum of one error message per record, but you can append if you need to
310
-        *
311
-        * @return Array (
312
-        *       record_# => error message
313
-        *       )
314
-        */
315
-        public function get_errors() {
308
+	 * Returns errors that were encountered during importing
309
+	 * Maximum of one error message per record, but you can append if you need to
310
+	 *
311
+	 * @return Array (
312
+	 *       record_# => error message
313
+	 *       )
314
+	 */
315
+		public function get_errors() {
316 316
 		return $this->errors;
317 317
 	}
318 318
 
319 319
 	/**
320
-        * Returns a list of actions taken, and the number of records for that action.
321
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
-        *
323
-        * @return Array (
324
-        *       action => record count
325
-        * )
326
-        */
327
-        public function get_results() {
320
+	 * Returns a list of actions taken, and the number of records for that action.
321
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
+	 *
323
+	 * @return Array (
324
+	 *       action => record count
325
+	 * )
326
+	 */
327
+		public function get_results() {
328 328
 		return $this->results;
329 329
 	}
330 330
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  * @version $Id: $
11 11
  */
12 12
 
13
-require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php');
13
+require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php');
14 14
 require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php');
15 15
 
16 16
 
17 17
 /**
18 18
  * class import_csv for addressbook
19 19
  */
20
-class import_events_csv implements iface_import_plugin  {
20
+class import_events_csv implements iface_import_plugin {
21 21
 
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 			// char
24
-		'charset', 				// string
25
-		'event_owner', 			// int account_id or -1 for leave untuched
26
-		'owner_joins_event',	// bool
27
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'event_owner', // int account_id or -1 for leave untuched
26
+		'owner_joins_event', // bool
27
+		'update_cats', // string {override|add} overides record
28 28
 								// with cat(s) from csv OR add the cat from
29 29
 								// csv file to exeisting cat(s) of record
30
-		'num_header_lines',		// int number of header lines
31
-		'trash_users_records',	// trashes all events of events owner before import
32
-		'field_conversion', 	// array( $csv_col_num => conversion)
33
-		'field_mapping',		// array( $csv_col_num => adb_filed)
34
-		'conditions',			/* => array containing condition arrays:
30
+		'num_header_lines', // int number of header lines
31
+		'trash_users_records', // trashes all events of events owner before import
32
+		'field_conversion', // array( $csv_col_num => conversion)
33
+		'field_mapping', // array( $csv_col_num => adb_filed)
34
+		'conditions', /* => array containing condition arrays:
35 35
 				'type' => exists, // record['uid'] exists
36 36
 				'true' => array(
37 37
 					'action' => update,
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * actions wich could be done to data entries
49 49
 	 */
50
-	private static $actions = array( 'none', 'update', 'insert', 'delete', );
50
+	private static $actions = array('none', 'update', 'insert', 'delete',);
51 51
 
52 52
 	/**
53 53
 	 * conditions for actions
54 54
 	 *
55 55
 	 * @var array
56 56
 	 */
57
-	private static $conditions = array( 'exists', 'empty', );
57
+	private static $conditions = array('exists', 'empty',);
58 58
 
59 59
 	/**
60 60
 	 * @var definition
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param string $_charset
98 98
 	 * @param definition $_definition
99 99
 	 */
100
-	public function import( $_stream, definition $_definition ) {
101
-		$import_csv = new import_csv( $_stream, array(
100
+	public function import($_stream, definition $_definition) {
101
+		$import_csv = new import_csv($_stream, array(
102 102
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
103 103
 			'charset' => $_definition->plugin_options['charset'],
104 104
 		));
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$this->definition = $_definition;
107 107
 
108 108
 		// user, is admin ?
109
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
109
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
110 110
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
111 111
 
112 112
 		// dry run?
113
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
113
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
114 114
 
115 115
 		// fetch the calendar bo
116 116
 		$this->bocalupdate = new calendar_boupdate();
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
123 123
 
124 124
 		//check if file has a header lines
125
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) ) {
126
-			$import_csv->skip_records( $_definition->plugin_options['num_header_lines'] );
125
+		if (isset($_definition->plugin_options['num_header_lines'])) {
126
+			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
127 127
 		}
128 128
 
129 129
 		// set eventOwner
130
-		$_definition->plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ?
130
+		$_definition->plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ?
131 131
 			$_definition->plugin_options['events_owner'] : $this->user;
132 132
 
133 133
 		// trash_users_records ?
134
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
135
-			if ( !$_definition->plugin_options['dry_run'] ) {
134
+		if ($_definition->plugin_options['trash_users_records'] === true) {
135
+			if (!$_definition->plugin_options['dry_run']) {
136 136
 				$socal = new calendar_socal();
137
-				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
138
-				unset( $socal );
137
+				$this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']);
138
+				unset($socal);
139 139
 			} else {
140
-				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
140
+				$lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']);
141 141
 				echo "Attension: All Events of '$lid' would be deleted!\n";
142 142
 			}
143 143
 		}
@@ -145,44 +145,44 @@  discard block
 block discarded – undo
145 145
 		$this->errors = array();
146 146
 		$this->results = array();
147 147
 
148
-		while ( $record = $import_csv->get_record() ) {
148
+		while ($record = $import_csv->get_record()) {
149 149
 
150 150
 			// don't import empty events
151
-			if( count( array_unique( $record ) ) < 2 ) continue;
151
+			if (count(array_unique($record)) < 2) continue;
152 152
 
153
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
153
+			if ($_definition->plugin_options['events_owner'] != -1) {
154 154
 				$record['owner'] = $_definition->plugin_options['events_owner'];
155
-			} else unset( $record['owner'] );
155
+			} else unset($record['owner']);
156 156
 
157
-			if ( $_definition->plugin_options['conditions'] ) {
158
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
159
-					switch ( $condition['type'] ) {
157
+			if ($_definition->plugin_options['conditions']) {
158
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
159
+					switch ($condition['type']) {
160 160
 						// exists
161 161
 						case 'exists' :
162 162
 
163
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
163
+							if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) {
164 164
 								// apply action to event matching this exists condition
165 165
 								$record['id'] = $event['id'];
166 166
 
167
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
168
-									if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] );
169
-									if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
170
-									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
167
+								if ($_definition->plugin_options['update_cats'] == 'add') {
168
+									if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']);
169
+									if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
170
+									$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id'])));
171 171
 								}
172 172
 
173 173
 								// check if entry is modiefied
174
-								$event = array_intersect_key( $event, $record );
175
-								$diff = array_diff( $event, $record );
176
-								if( !empty( $diff ) ) $record['modified'] = time();
174
+								$event = array_intersect_key($event, $record);
175
+								$diff = array_diff($event, $record);
176
+								if (!empty($diff)) $record['modified'] = time();
177 177
 
178 178
 								$action = $condition['true'];
179 179
 							} else $action = $condition['false'];
180 180
 
181
-							$this->action( $action['action'], $record );
181
+							$this->action($action['action'], $record);
182 182
 							break;
183 183
 						case 'empty' :
184
-							$action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false'];
185
-							$this->action( $action['action'], $record );
184
+							$action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false'];
185
+							$this->action($action['action'], $record);
186 186
 							break;
187 187
 
188 188
 						// not supported action
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 				}
195 195
 			} else {
196 196
 				// unconditional insert
197
-				$this->action( 'insert', $record );
197
+				$this->action('insert', $record);
198 198
 			}
199 199
 		}
200 200
 	}
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 * @param array $_data event data for the action
207 207
 	 * @return bool success or not
208 208
 	 */
209
-	private function action ( $_action, $_data ) {
210
-		switch ( $_action ) {
209
+	private function action($_action, $_data) {
210
+		switch ($_action) {
211 211
 			case 'none' :
212 212
 				return true;
213 213
 
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 			case 'insert' :
216 216
 
217 217
 				// paticipants handling
218
-				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
218
+				$participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array();
219 219
 				$_data['participants'] = array();
220
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
220
+				if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) {
221 221
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
222 222
 				}
223
-				foreach( $participants as $participant ) {
224
-					list( $participant, $status ) = explode( '=', $participant );
225
-					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
226
-					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
227
-					if ( $participant && is_numeric($participant ) ) {
223
+				foreach ($participants as $participant) {
224
+					list($participant, $status) = explode('=', $participant);
225
+					$valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T');
226
+					$status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U';
227
+					if ($participant && is_numeric($participant)) {
228 228
 						$_data['participants'][$participant] = $status;
229 229
 					}
230 230
 				}
231 231
 				// no valid participants so far --> add the importing user/owner
232
-				if ( empty( $_data['participants'] ) ) {
232
+				if (empty($_data['participants'])) {
233 233
 					$_data['participants'][$this->user] = 'A';
234 234
 				}
235 235
 
236 236
 				// are we serious?
237
-				if ( $this->dry_run ) {
237
+				if ($this->dry_run) {
238 238
 					print_r($_data);
239 239
 					$this->results[$_action]++;
240 240
 				} else {
241 241
 					$messages = array();
242
-					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
-					if(!$result) {
242
+					$result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
+					if (!$result) {
244 244
 						$this->errors = implode(',', $messages);
245 245
 					} else {
246 246
 						$this->results[$_action]++;
Please login to merge, or discard this patch.
Braces   +94 added lines, -38 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for addressbook
19 19
  */
20
-class import_events_csv implements iface_import_plugin  {
20
+class import_events_csv implements iface_import_plugin
21
+{
21 22
 
22 23
 	private static $plugin_options = array(
23 24
 		'fieldsep', 			// char
@@ -97,7 +98,8 @@  discard block
 block discarded – undo
97 98
 	 * @param string $_charset
98 99
 	 * @param definition $_definition
99 100
 	 */
100
-	public function import( $_stream, definition $_definition ) {
101
+	public function import( $_stream, definition $_definition )
102
+	{
101 103
 		$import_csv = new import_csv( $_stream, array(
102 104
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
103 105
 			'charset' => $_definition->plugin_options['charset'],
@@ -122,7 +124,8 @@  discard block
 block discarded – undo
122 124
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
123 125
 
124 126
 		//check if file has a header lines
125
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) ) {
127
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) )
128
+		{
126 129
 			$import_csv->skip_records( $_definition->plugin_options['num_header_lines'] );
127 130
 		}
128 131
 
@@ -131,12 +134,16 @@  discard block
 block discarded – undo
131 134
 			$_definition->plugin_options['events_owner'] : $this->user;
132 135
 
133 136
 		// trash_users_records ?
134
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
135
-			if ( !$_definition->plugin_options['dry_run'] ) {
137
+		if ( $_definition->plugin_options['trash_users_records'] === true )
138
+		{
139
+			if ( !$_definition->plugin_options['dry_run'] )
140
+			{
136 141
 				$socal = new calendar_socal();
137 142
 				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
138 143
 				unset( $socal );
139
-			} else {
144
+			}
145
+			else
146
+			{
140 147
 				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
141 148
 				echo "Attension: All Events of '$lid' would be deleted!\n";
142 149
 			}
@@ -145,38 +152,63 @@  discard block
 block discarded – undo
145 152
 		$this->errors = array();
146 153
 		$this->results = array();
147 154
 
148
-		while ( $record = $import_csv->get_record() ) {
155
+		while ( $record = $import_csv->get_record() )
156
+		{
149 157
 
150 158
 			// don't import empty events
151
-			if( count( array_unique( $record ) ) < 2 ) continue;
159
+			if( count( array_unique( $record ) ) < 2 )
160
+			{
161
+				continue;
162
+			}
152 163
 
153
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
164
+			if ( $_definition->plugin_options['events_owner'] != -1 )
165
+			{
154 166
 				$record['owner'] = $_definition->plugin_options['events_owner'];
155
-			} else unset( $record['owner'] );
167
+			}
168
+			else {
169
+				unset( $record['owner'] );
170
+			}
156 171
 
157
-			if ( $_definition->plugin_options['conditions'] ) {
158
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
159
-					switch ( $condition['type'] ) {
172
+			if ( $_definition->plugin_options['conditions'] )
173
+			{
174
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
175
+				{
176
+					switch ( $condition['type'] )
177
+					{
160 178
 						// exists
161 179
 						case 'exists' :
162 180
 
163
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
181
+							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) )
182
+							{
164 183
 								// apply action to event matching this exists condition
165 184
 								$record['id'] = $event['id'];
166 185
 
167
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
168
-									if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] );
169
-									if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
186
+								if ( $_definition->plugin_options['update_cats'] == 'add' )
187
+								{
188
+									if ( !is_array( $event['cat_id'] ) )
189
+									{
190
+										$event['cat_id'] = explode( ',', $event['cat_id'] );
191
+									}
192
+									if ( !is_array( $record['cat_id'] ) )
193
+									{
194
+										$record['cat_id'] = explode( ',', $record['cat_id'] );
195
+									}
170 196
 									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
171 197
 								}
172 198
 
173 199
 								// check if entry is modiefied
174 200
 								$event = array_intersect_key( $event, $record );
175 201
 								$diff = array_diff( $event, $record );
176
-								if( !empty( $diff ) ) $record['modified'] = time();
202
+								if( !empty( $diff ) )
203
+								{
204
+									$record['modified'] = time();
205
+								}
177 206
 
178 207
 								$action = $condition['true'];
179
-							} else $action = $condition['false'];
208
+							}
209
+							else {
210
+								$action = $condition['false'];
211
+							}
180 212
 
181 213
 							$this->action( $action['action'], $record );
182 214
 							break;
@@ -190,9 +222,14 @@  discard block
 block discarded – undo
190 222
 							throw new Exception('condition not supported!!!');
191 223
 							break;
192 224
 					}
193
-					if ($action['last']) break;
225
+					if ($action['last'])
226
+					{
227
+						break;
228
+					}
194 229
 				}
195
-			} else {
230
+			}
231
+			else
232
+			{
196 233
 				// unconditional insert
197 234
 				$this->action( 'insert', $record );
198 235
 			}
@@ -206,8 +243,10 @@  discard block
 block discarded – undo
206 243
 	 * @param array $_data event data for the action
207 244
 	 * @return bool success or not
208 245
 	 */
209
-	private function action ( $_action, $_data ) {
210
-		switch ( $_action ) {
246
+	private function action ( $_action, $_data )
247
+	{
248
+		switch ( $_action )
249
+		{
211 250
 			case 'none' :
212 251
 				return true;
213 252
 
@@ -217,32 +256,42 @@  discard block
 block discarded – undo
217 256
 				// paticipants handling
218 257
 				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
219 258
 				$_data['participants'] = array();
220
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
259
+				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 )
260
+				{
221 261
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
222 262
 				}
223
-				foreach( $participants as $participant ) {
263
+				foreach( $participants as $participant )
264
+				{
224 265
 					list( $participant, $status ) = explode( '=', $participant );
225 266
 					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
226 267
 					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
227
-					if ( $participant && is_numeric($participant ) ) {
268
+					if ( $participant && is_numeric($participant ) )
269
+					{
228 270
 						$_data['participants'][$participant] = $status;
229 271
 					}
230 272
 				}
231 273
 				// no valid participants so far --> add the importing user/owner
232
-				if ( empty( $_data['participants'] ) ) {
274
+				if ( empty( $_data['participants'] ) )
275
+				{
233 276
 					$_data['participants'][$this->user] = 'A';
234 277
 				}
235 278
 
236 279
 				// are we serious?
237
-				if ( $this->dry_run ) {
280
+				if ( $this->dry_run )
281
+				{
238 282
 					print_r($_data);
239 283
 					$this->results[$_action]++;
240
-				} else {
284
+				}
285
+				else
286
+				{
241 287
 					$messages = array();
242 288
 					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
-					if(!$result) {
289
+					if(!$result)
290
+					{
244 291
 						$this->errors = implode(',', $messages);
245
-					} else {
292
+					}
293
+					else
294
+					{
246 295
 						$this->results[$_action]++;
247 296
 					}
248 297
 					return $result;
@@ -257,7 +306,8 @@  discard block
 block discarded – undo
257 306
 	 *
258 307
 	 * @return string name
259 308
 	 */
260
-	public static function get_name() {
309
+	public static function get_name()
310
+	{
261 311
 		return lang('Calendar CSV export');
262 312
 	}
263 313
 
@@ -266,7 +316,8 @@  discard block
 block discarded – undo
266 316
 	 *
267 317
 	 * @return string descriprion
268 318
 	 */
269
-	public static function get_description() {
319
+	public static function get_description()
320
+	{
270 321
 		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.");
271 322
 	}
272 323
 
@@ -275,7 +326,8 @@  discard block
 block discarded – undo
275 326
 	 *
276 327
 	 * @return string suffix (comma seperated)
277 328
 	 */
278
-	public static function get_filesuffix() {
329
+	public static function get_filesuffix()
330
+	{
279 331
 		return 'csv';
280 332
 	}
281 333
 
@@ -291,7 +343,8 @@  discard block
 block discarded – undo
291 343
 	 * 		preserv		=> array,
292 344
 	 * )
293 345
 	 */
294
-	public function get_options_etpl() {
346
+	public function get_options_etpl()
347
+	{
295 348
 		// lets do it!
296 349
 	}
297 350
 
@@ -300,7 +353,8 @@  discard block
 block discarded – undo
300 353
 	 *
301 354
 	 * @return string etemplate name
302 355
 	 */
303
-	public function get_selectors_etpl() {
356
+	public function get_selectors_etpl()
357
+	{
304 358
 		// lets do it!
305 359
 	}
306 360
 
@@ -312,7 +366,8 @@  discard block
 block discarded – undo
312 366
         *       record_# => error message
313 367
         *       )
314 368
         */
315
-        public function get_errors() {
369
+        public function get_errors()
370
+        {
316 371
 		return $this->errors;
317 372
 	}
318 373
 
@@ -324,7 +379,8 @@  discard block
 block discarded – undo
324 379
         *       action => record count
325 380
         * )
326 381
         */
327
-        public function get_results() {
382
+        public function get_results()
383
+        {
328 384
 		return $this->results;
329 385
 	}
330 386
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 5 patches
Doc Comments   +8 added lines, -13 removed lines patch added patch discarded remove patch
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	 * or an ExecMethod callback with parameters $id,$event
627 627
 	 *
628 628
 	 * @param string $app
629
-	 * @param int|string $id
630
-	 * @return string
629
+	 * @param string $id
630
+	 * @return boolean
631 631
 	 */
632 632
 	static function integration_get_private($app,$id,$event)
633 633
 	{
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	 * This methods operates in usertime, while $this->config['horizont'] is in servertime!
757 757
 	 *
758 758
 	 * @param array $event
759
-	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
759
+	 * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event
760 760
 	 */
761 761
 	function set_recurrences($event,$start=0)
762 762
 	{
@@ -976,10 +976,9 @@  discard block
 block discarded – undo
976 976
 	 * Recurrences get calculated by rrule iterator implemented in calendar_rrule class.
977 977
 	 *
978 978
 	 * @param array $event repeating event whos repetions should be inserted
979
-	 * @param mixed $start start-date
979
+	 * @param mixed $_start start-date
980 980
 	 * @param mixed $end end-date
981 981
 	 * @param array $events where the repetions get inserted
982
-	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
983 982
 	 */
984 983
 	function insert_all_recurrences($event,$_start,$end,&$events)
985 984
 	{
@@ -1133,7 +1132,7 @@  discard block
 block discarded – undo
1133 1132
 	 *	even if you have no general read-grant from that user.
1134 1133
 	 *
1135 1134
 	 * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE}
1136
-	 * @param mixed $event event as array or the event-id or 0 for a general check
1135
+	 * @param integer $event event as array or the event-id or 0 for a general check
1137 1136
 	 * @param int $other uid to check (if event==0) or 0 to check against $this->user
1138 1137
 	 * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
1139 1138
 	 * @param mixed $date_to_read =null date used for reading, internal param for the caching
@@ -1306,8 +1305,6 @@  discard block
 block discarded – undo
1306 1305
 	 * @param string $msg message with parameters/variables like lang(), eg. '%1'
1307 1306
 	 * @param boolean $backtrace =True include a function-backtrace, default True=On
1308 1307
 	 *	should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!!
1309
-	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1310
-	 *	arrays get serialized with print_r() !
1311 1308
 	 */
1312 1309
 	static function debug_message($msg,$backtrace=True)
1313 1310
 	{
@@ -1370,7 +1367,7 @@  discard block
 block discarded – undo
1370 1367
 	 * Formats one or two dates (range) as long date (full monthname), optionaly with a time
1371 1368
 	 *
1372 1369
 	 * @param mixed $_first first date
1373
-	 * @param mixed $last =0 last date if != 0 (default)
1370
+	 * @param integer $last =0 last date if != 0 (default)
1374 1371
 	 * @param boolean $display_time =false should a time be displayed too
1375 1372
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1376 1373
 	 * @return string with formated date
@@ -1839,7 +1836,6 @@  discard block
 block discarded – undo
1839 1836
 	 *
1840 1837
 	 * Is called as hook to participate in the linking
1841 1838
 	 *
1842
-	 * @param int|array $entry int cal_id or array with event
1843 1839
 	 * @param string|boolean string with title, null if not found or false if not read perms
1844 1840
 	 */
1845 1841
 	function link_title($event)
@@ -2028,7 +2024,8 @@  discard block
 block discarded – undo
2028 2024
 	 *
2029 2025
 	 * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions
2030 2026
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2031
-	 * @return string|boolean string with etag or false
2027
+	 * @param string $schedule_tag
2028
+	 * @return string string with etag or false
2032 2029
 	 */
2033 2030
 	function get_etag($entry, &$schedule_tag=null)
2034 2031
 	{
@@ -2068,7 +2065,6 @@  discard block
 block discarded – undo
2068 2065
 	 * Hook for infolog  to set some extra data and links
2069 2066
 	 *
2070 2067
 	 * @param array $data event-array preset by infolog plus
2071
-	 * @param int $data[id] cal_id
2072 2068
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
2073 2069
 	 */
2074 2070
 	function infolog_set($data)
@@ -2120,7 +2116,6 @@  discard block
 block discarded – undo
2120 2116
 	 * Hook for timesheet to set some extra data and links
2121 2117
 	 *
2122 2118
 	 * @param array $data
2123
-	 * @param int $data[id] cal_id:recurrence
2124 2119
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
2125 2120
 	 */
2126 2121
 	function timesheet_set($data)
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1490,13 +1490,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * @var array recur_types translates MCAL recur-types to verbose labels
124 124
 	 */
125
-	var $recur_types = Array(
125
+	var $recur_types = array(
126 126
 		MCAL_RECUR_NONE         => 'No recurrence',
127 127
 		MCAL_RECUR_DAILY        => 'Daily',
128 128
 		MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 * @param string $pattern pattern to search
1898 1898
 	 * @return array with cal_id - title pairs of the matching entries
1899 1899
 	 */
1900
-	function link_query($pattern, Array &$options = array())
1900
+	function link_query($pattern, array &$options = array())
1901 1901
 	{
1902 1902
 		$result = array();
1903 1903
 		$query = array(
Please login to merge, or discard this patch.
Spacing   +303 added lines, -305 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
19 19
 {
20
-	define('ACL_TYPE_IDENTIFER','***ACL***');
20
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
21 21
 }
22 22
 
23
-define('HOUR_s',60*60);
24
-define('DAY_s',24*HOUR_s);
25
-define('WEEK_s',7*DAY_s);
23
+define('HOUR_s', 60 * 60);
24
+define('DAY_s', 24 * HOUR_s);
25
+define('WEEK_s', 7 * DAY_s);
26 26
 
27 27
 /**
28 28
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
72 72
 	 *	5 = function-calls to private functions
73 73
 	 */
74
-	var $debug=false;
74
+	var $debug = false;
75 75
 
76 76
 	/**
77 77
 	 * @var int $now timestamp in server-time
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var int $user nummerical id of the current user-id
103 103
 	 */
104
-	var $user=0;
104
+	var $user = 0;
105 105
 
106 106
 	/**
107 107
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
108 108
 	 */
109
-	var $grants=array();
109
+	var $grants = array();
110 110
 
111 111
 	/**
112 112
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	function __construct()
224 224
 	{
225
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
225
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
226 226
 
227 227
 		$this->so = new calendar_so();
228 228
 
229
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
230
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
229
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
230
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
231 231
 
232 232
 		$this->now = time();
233
-		$this->now_su = Api\DateTime::server2user($this->now,'ts');
233
+		$this->now_su = Api\DateTime::server2user($this->now, 'ts');
234 234
 
235 235
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
236 236
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
240 240
 		{
241 241
 			$this->resources = array();
242
-			foreach(Api\Hooks::process('calendar_resources') as $app => $data)
242
+			foreach (Api\Hooks::process('calendar_resources') as $app => $data)
243 243
 			{
244 244
 				if ($data && $data['type'])
245 245
 				{
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 				'app'  => 'email',
253 253
 			);
254 254
 			$this->resources['l'] = array(
255
-				'type' => 'l',// one char type-identifier for this resources
256
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
255
+				'type' => 'l', // one char type-identifier for this resources
256
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
257 257
 				'app' => 'Mailing list'
258 258
 			);
259 259
 			$this->resources[''] = array(
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 		}
265 265
 		//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
266 266
 
267
-		$this->config = Api\Config::read('calendar');	// only used for horizont, regular calendar config is under phpgwapi
267
+		$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
268 268
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
269 269
 
270
-		$this->categories = new Api\Categories($this->user,'calendar');
270
+		$this->categories = new Api\Categories($this->user, 'calendar');
271 271
 
272 272
 		$this->customfields = Api\Storage\Customfields::get('calendar');
273 273
 
274
-		foreach($this->alarms as $secs => &$label)
274
+		foreach ($this->alarms as $secs => &$label)
275 275
 		{
276 276
 			$label = self::secs2label($secs);
277 277
 		}
@@ -287,15 +287,15 @@  discard block
 block discarded – undo
287 287
 	{
288 288
 		if ($secs <= 3600)
289 289
 		{
290
-			$label = lang('%1 minutes', $secs/60);
290
+			$label = lang('%1 minutes', $secs / 60);
291 291
 		}
292
-		elseif($secs <= 86400)
292
+		elseif ($secs <= 86400)
293 293
 		{
294
-			$label = lang('%1 hours', $secs/3600);
294
+			$label = lang('%1 hours', $secs / 3600);
295 295
 		}
296 296
 		else
297 297
 		{
298
-			$label = lang('%1 days', $secs/86400);
298
+			$label = lang('%1 days', $secs / 86400);
299 299
 		}
300 300
 		return $label;
301 301
 	}
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 		if (!$ids) return null;
312 312
 
313 313
 		$data = array();
314
-		foreach((array)$ids as $id)
314
+		foreach ((array)$ids as $id)
315 315
 		{
316 316
 			$email = $id;
317 317
 			$name = '';
318 318
 			$matches = null;
319
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
319
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
320 320
 			{
321 321
 				$name = $matches[1];
322 322
 				$email = $matches[2];
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	static function mailing_lists($ids)
342 342
 	{
343
-		if(!is_array($ids))
343
+		if (!is_array($ids))
344 344
 		{
345 345
 			$ids = array($ids);
346 346
 		}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 		// Email list
350 350
 		$contacts_obj = new Api\Contacts();
351
-		foreach($ids as $id)
351
+		foreach ($ids as $id)
352 352
 		{
353 353
 			$list = $contacts_obj->read_list((int)$id);
354 354
 
@@ -374,24 +374,24 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @return array
376 376
 	 */
377
-	public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true)
377
+	public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true)
378 378
 	{
379 379
 		$contact_list = array();
380 380
 		$contacts = new Api\Contacts();
381
-		if($contacts->check_list((int)substr($id,1), ACL::READ))
381
+		if ($contacts->check_list((int)substr($id, 1), ACL::READ))
382 382
 		{
383
-			$options = array('list' => substr($id,1));
384
-			$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
385
-			if(!$lists)
383
+			$options = array('list' => substr($id, 1));
384
+			$lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options);
385
+			if (!$lists)
386 386
 			{
387 387
 				return $contact_list;
388 388
 			}
389
-			foreach($lists as &$contact)
389
+			foreach ($lists as &$contact)
390 390
 			{
391 391
 				$contact = 'c'.$contact['id'];
392
-				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
392
+				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $contact))
393 393
 				{
394
-					if ($contact && !in_array($contact,$contact_list))	// already added?
394
+					if ($contact && !in_array($contact, $contact_list))	// already added?
395 395
 					{
396 396
 						$contact_list[] = $contact;
397 397
 					}
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 	function enum_groups(&$event)
411 411
 	{
412 412
 		$added = 0;
413
-		foreach(array_keys($event['participants']) as $uid)
413
+		foreach (array_keys($event['participants']) as $uid)
414 414
 		{
415 415
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
416 416
 				($members = $GLOBALS['egw']->accounts->members($uid, true)))
417 417
 			{
418
-				foreach($members as $member)
418
+				foreach ($members as $member)
419 419
 				{
420 420
 					if (!isset($event['participants'][$member]))
421 421
 					{
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
438 438
 	 * @return array of user-ids
439 439
 	 */
440
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
440
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
441 441
 	{
442 442
 		if (!is_array($_users))
443 443
 		{
@@ -445,32 +445,32 @@  discard block
 block discarded – undo
445 445
 		}
446 446
 		// only query calendars of users, we have READ-grants from
447 447
 		$users = array();
448
-		foreach($_users as $user)
448
+		foreach ($_users as $user)
449 449
 		{
450 450
 			$user = trim($user);
451 451
 
452 452
 			// Handle email lists
453
-			if(!is_numeric($user) && $user[0] == 'l')
453
+			if (!is_numeric($user) && $user[0] == 'l')
454 454
 			{
455
-				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
455
+				foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
456 456
 				{
457
-					if ($contact && !in_array($contact,$users))	// already added?
457
+					if ($contact && !in_array($contact, $users))	// already added?
458 458
 					{
459 459
 						$users[] = $contact;
460 460
 					}
461 461
 				}
462 462
 				continue;
463 463
 			}
464
-			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
464
+			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $user))
465 465
 			{
466
-				if ($user && !in_array($user,$users))	// already added?
466
+				if ($user && !in_array($user, $users))	// already added?
467 467
 				{
468 468
 					$users[] = $user;
469 469
 				}
470 470
 			}
471 471
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
472 472
 			{
473
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
473
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
474 474
 			}
475 475
 			// the further code is only for real users
476 476
 			if (!is_numeric($user)) continue;
@@ -483,11 +483,11 @@  discard block
 block discarded – undo
483 483
 				$members = $GLOBALS['egw']->accounts->members($user, true);
484 484
 				if (is_array($members))
485 485
 				{
486
-					foreach($members as $member)
486
+					foreach ($members as $member)
487 487
 					{
488 488
 						// use only members which gave the user a read-grant
489 489
 						if (!in_array($member, $users) &&
490
-							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
490
+							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $member)))
491 491
 						{
492 492
 							$users[] = $member;
493 493
 						}
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
500 500
 				if (is_array($memberships))
501 501
 				{
502
-					foreach($memberships as $group)
502
+					foreach ($memberships as $group)
503 503
 					{
504
-						if (!in_array($group,$users))
504
+						if (!in_array($group, $users))
505 505
 						{
506 506
 							$users[] = $group;
507 507
 						}
@@ -542,18 +542,18 @@  discard block
 block discarded – undo
542 542
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
543 543
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
544 544
 	 */
545
-	function &search($params,$sql_filter=null)
545
+	function &search($params, $sql_filter = null)
546 546
 	{
547 547
 		$params_in = $params;
548 548
 
549
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
549
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
550 550
 
551 551
 		// check if any resource wants to hook into
552
-		foreach($this->resources as $data)
552
+		foreach ($this->resources as $data)
553 553
 		{
554 554
 			if (isset($data['search_filter']))
555 555
 			{
556
-				$params = ExecMethod($data['search_filter'],$params);
556
+				$params = ExecMethod($data['search_filter'], $params);
557 557
 			}
558 558
 		}
559 559
 
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 		if (!empty($params['query']))
572 572
 		{
573 573
 			$params['private_grants'] = array();
574
-			foreach($this->grants as $user => $rights)
574
+			foreach ($this->grants as $user => $rights)
575 575
 			{
576
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
576
+				if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user;
577 577
 			}
578 578
 		}
579 579
 
@@ -599,49 +599,49 @@  discard block
 block discarded – undo
599 599
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
600 600
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
601 601
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
602
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
602
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
603 603
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
604 604
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
605 605
 		$users_in = (array)$params_in['users'];
606
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
606
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
607 607
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
608 608
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
609 609
 
610 610
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
611 611
 		{
612 612
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
613
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
613
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
614 614
 		}
615 615
 		// date2ts(,true) converts to server time, db2data converts again to user-time
616
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
617
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
616
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
617
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
618 618
 
619 619
 		if (isset($params['cols']))
620 620
 		{
621 621
 			return $events;
622 622
 		}
623 623
 		$this->total = $this->so->total;
624
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
624
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
625 625
 
626 626
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
627
-		foreach($events as $id => $event)
627
+		foreach ($events as $id => $event)
628 628
 		{
629 629
 			if ($params['enum_groups'] && $this->enum_groups($event))
630 630
 			{
631 631
 				$events[$id] = $event;
632 632
 			}
633 633
 			$matches = null;
634
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
634
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
635 635
 			{
636
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
636
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
637 637
 			}
638 638
 			else
639 639
 			{
640
-				$is_private = !$this->check_perms(Acl::READ,$event);
640
+				$is_private = !$this->check_perms(Acl::READ, $event);
641 641
 			}
642 642
 			if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
643 643
 			{
644
-				$this->clear_private_infos($events[$id],$users);
644
+				$this->clear_private_infos($events[$id], $users);
645 645
 			}
646 646
 		}
647 647
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
 		{
650 650
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
651 651
 			{
652
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
652
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
653 653
 			}
654 654
 			// create empty entries for each day in the reported time
655
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
655
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
656 656
 			{
657 657
 				$daysEvents[$this->date2string($ts)] = array();
658 658
 			}
659
-			foreach($events as $k => $event)
659
+			foreach ($events as $k => $event)
660 660
 			{
661
-				$e_start = max($this->date2ts($event['start']),$start);
661
+				$e_start = max($this->date2ts($event['start']), $start);
662 662
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
663
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
663
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
664 664
 
665 665
 				// add event to each day in the reported time
666 666
 				$ts = $e_start;
@@ -669,23 +669,23 @@  discard block
 block discarded – undo
669 669
 				$ymd = null;
670 670
 				while ($ts <= $e_end)
671 671
 				{
672
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
673
-					$ts = strtotime("+1 day",$ts);
672
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
673
+					$ts = strtotime("+1 day", $ts);
674 674
 				}
675 675
 				if ($ymd != ($last = $this->date2string($e_end)))
676 676
 				{
677
-					$daysEvents[$last][] =& $events[$k];
677
+					$daysEvents[$last][] = & $events[$k];
678 678
 				}
679 679
 			}
680
-			$events =& $daysEvents;
680
+			$events = & $daysEvents;
681 681
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
682 682
 			{
683
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
683
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
684 684
 			}
685 685
 		}
686 686
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
687 687
 		{
688
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
688
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
689 689
 		}
690 690
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
691 691
 		return $events;
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 	 * @param string $part
699 699
 	 * @return array
700 700
 	 */
701
-	static function integration_get_data($app,$part=null)
701
+	static function integration_get_data($app, $part = null)
702 702
 	{
703
-		static $integration_data=null;
703
+		static $integration_data = null;
704 704
 
705 705
 		if (!isset($integration_data))
706 706
 		{
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 	 * @param int|string $id
723 723
 	 * @return string
724 724
 	 */
725
-	static function integration_get_private($app,$id,$event)
725
+	static function integration_get_private($app, $id, $event)
726 726
 	{
727
-		$app_data = self::integration_get_data($app,'is_private');
727
+		$app_data = self::integration_get_data($app, 'is_private');
728 728
 
729 729
 		// no method, fall back to link title
730 730
 		if (is_null($app_data))
731 731
 		{
732
-			$is_private = !Link::title($app,$id);
732
+			$is_private = !Link::title($app, $id);
733 733
 		}
734 734
 		// boolean value to make all events of $app public (false) or private (true)
735 735
 		elseif (is_bool($app_data))
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		else
740 740
 		{
741
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
741
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
742 742
 		}
743 743
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
744 744
 		return $is_private;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @param array &$event
753 753
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
754 754
 	 */
755
-	function clear_private_infos(&$event,$allowed_participants = array())
755
+	function clear_private_infos(&$event, $allowed_participants = array())
756 756
 	{
757 757
 		if ($event == false) return;
758 758
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -768,19 +768,19 @@  discard block
 block discarded – undo
768 768
 			'owner'		=> $event['owner'],
769 769
 			'uid'	=> $event['uid'],
770 770
 			'etag'	=> $event['etag'],
771
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
771
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
772 772
 			'public'=> 0,
773
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
773
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
774 774
 			'non_blocking' => $event['non_blocking'],
775 775
 			'caldav_name' => $event['caldav_name'],
776 776
 		// we need full recurrence information, as they are relevant free/busy information
777
-		)+($event['recur_type'] ? array(
777
+		) + ($event['recur_type'] ? array(
778 778
 			'recur_type'     => $event['recur_type'],
779 779
 			'recur_interval' => $event['recur_interval'],
780 780
 			'recur_data'     => $event['recur_data'],
781 781
 			'recur_enddate'  => $event['recur_enddate'],
782 782
 			'recur_exception'=> $event['recur_exception'],
783
-		):array(
783
+		) : array(
784 784
 			'reference'      => $event['reference'],
785 785
 			'recurrence'     => $event['recurrence'],
786 786
 		));
@@ -794,15 +794,15 @@  discard block
 block discarded – undo
794 794
 	 */
795 795
 	function check_move_horizont($_new_horizont)
796 796
 	{
797
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
797
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
798 798
 		{
799
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
799
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
800 800
 		}
801
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
801
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
802 802
 
803 803
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
804 804
 		{
805
-			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']);
805
+			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']);
806 806
 			return;
807 807
 		}
808 808
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
811 811
 		}
812 812
 		if (empty($maxdays)) $maxdays = 1000; // old default
813
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
813
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
814 814
 		{
815
-			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);
816
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
815
+			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);
816
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays);
817 817
 			return;
818 818
 		}
819
-		if ($new_horizont < time()+31*DAY_s)
819
+		if ($new_horizont < time() + 31 * DAY_s)
820 820
 		{
821
-			$new_horizont = time()+31*DAY_s;
821
+			$new_horizont = time() + 31 * DAY_s;
822 822
 		}
823 823
 		$old_horizont = $this->config['horizont'];
824 824
 		$this->config['horizont'] = $new_horizont;
@@ -826,21 +826,21 @@  discard block
 block discarded – undo
826 826
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
827 827
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
828 828
 		{
829
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
830
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
829
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
830
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
831 831
 			{
832 832
 				if ($this->debug == 'check_move_horizont')
833 833
 				{
834
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
834
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
835 835
 				}
836 836
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
837
-				$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
837
+				$this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
838 838
 			}
839 839
 		}
840 840
 		// update the horizont
841
-		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
841
+		Api\Config::save_value('horizont', $this->config['horizont'], 'calendar');
842 842
 
843
-		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']);
843
+		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']);
844 844
 	}
845 845
 
846 846
 	/**
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 	 * @param array $event
852 852
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
853 853
 	 */
854
-	function set_recurrences($event,$start=0)
854
+	function set_recurrences($event, $start = 0)
855 855
 	{
856
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
856
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
857 857
 		{
858
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
858
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
859 859
 		}
860 860
 		// check if the caller gave us enough information and if not read it from the DB
861 861
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -874,26 +874,26 @@  discard block
 block discarded – undo
874 874
 		if (!$start) $start = $event['start'];
875 875
 
876 876
 		$events = array();
877
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
877
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
878 878
 
879 879
 		$exceptions = array();
880
-		foreach((array)$event['recur_exception'] as $exception)
880
+		foreach ((array)$event['recur_exception'] as $exception)
881 881
 		{
882
-			$exceptions[] = Api\DateTime::to($exception, true);	// true = date
882
+			$exceptions[] = Api\DateTime::to($exception, true); // true = date
883 883
 		}
884
-		foreach($events as $event)
884
+		foreach ($events as $event)
885 885
 		{
886 886
 			$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
887
-			$start = $this->date2ts($event['start'],true);
887
+			$start = $this->date2ts($event['start'], true);
888 888
 			if ($event['whole_day'])
889 889
 			{
890 890
 				$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
891 891
 				$time->setTime(23, 59, 59);
892
-				$end = $this->date2ts($time,true);
892
+				$end = $this->date2ts($time, true);
893 893
 			}
894 894
 			else
895 895
 			{
896
-				$end = $this->date2ts($event['end'],true);
896
+				$end = $this->date2ts($event['end'], true);
897 897
 			}
898 898
 			//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
899 899
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @param array &$events array of event-arrays (reference)
910 910
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
911 911
 	 */
912
-	function db2data(&$events,$date_format='ts')
912
+	function db2data(&$events, $date_format = 'ts')
913 913
 	{
914 914
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
915 915
 		foreach ($events as &$event)
@@ -922,65 +922,65 @@  discard block
 block discarded – undo
922 922
 			// database returns timestamps as string, convert them to integer
923 923
 			// to avoid misinterpretation by Api\DateTime as Ymd string
924 924
 			// (this will fail on 32bit systems for times > 2038!)
925
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls Api\DateTime
925
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
926 926
 			$event['end'] = (int)$event['end'];
927 927
 			$event['whole_day'] = self::isWholeDay($event);
928 928
 			if ($event['whole_day'] && $date_format != 'server')
929 929
 			{
930 930
 				// Adjust dates to user TZ
931
-				$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
931
+				$stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
932 932
 				$event['start'] = Api\DateTime::to($stime, $date_format);
933
-				$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
933
+				$time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
934 934
 				$time->setTime(23, 59, 59);
935 935
 				$event['end'] = Api\DateTime::to($time, $date_format);
936 936
 				if (!empty($event['recurrence']))
937 937
 				{
938
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
938
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
939 939
 					$event['recurrence'] = Api\DateTime::to($time, $date_format);
940 940
 				}
941 941
 				if (!empty($event['recur_enddate']))
942 942
 				{
943
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
943
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
944 944
 					$time->setTime(23, 59, 59);
945 945
 					$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
946 946
 				}
947
-				$timestamps = array('modified','created');
947
+				$timestamps = array('modified', 'created');
948 948
 			}
949 949
 			else
950 950
 			{
951
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date');
951
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date');
952 952
 			}
953 953
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
954 954
 			foreach ($timestamps as $ts)
955 955
 			{
956 956
 				if (!empty($event[$ts]))
957 957
 				{
958
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
958
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
959 959
 				}
960 960
 			}
961 961
 			// same with the recur exceptions
962 962
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
963 963
 			{
964
-				foreach($event['recur_exception'] as &$date)
964
+				foreach ($event['recur_exception'] as &$date)
965 965
 				{
966 966
 					if ($event['whole_day'] && $date_format != 'server')
967 967
 					{
968 968
 						// Adjust dates to user TZ
969
-						$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
969
+						$time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
970 970
 						$date = Api\DateTime::to($time, $date_format);
971 971
 					}
972 972
 					else
973 973
 					{
974
-						$date = $this->date2usertime((int)$date,$date_format);
974
+						$date = $this->date2usertime((int)$date, $date_format);
975 975
 					}
976 976
 				}
977 977
 			}
978 978
 			// same with the alarms
979 979
 			if (isset($event['alarm']) && is_array($event['alarm']))
980 980
 			{
981
-				foreach($event['alarm'] as &$alarm)
981
+				foreach ($event['alarm'] as &$alarm)
982 982
 				{
983
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
983
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
984 984
 				}
985 985
 			}
986 986
 		}
@@ -993,11 +993,11 @@  discard block
 block discarded – undo
993 993
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
994 994
 	 * @return mixed depending of $date_format
995 995
 	 */
996
-	function date2usertime($ts,$date_format='ts')
996
+	function date2usertime($ts, $date_format = 'ts')
997 997
 	{
998 998
 		if (empty($ts) || $date_format == 'server') return $ts;
999 999
 
1000
-		return Api\DateTime::server2user($ts,$date_format);
1000
+		return Api\DateTime::server2user($ts, $date_format);
1001 1001
 	}
1002 1002
 
1003 1003
 	/**
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 	 * 	but call clear_private_infos() with the given users
1012 1012
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
1013 1013
 	 */
1014
-	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1014
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null)
1015 1015
 	{
1016 1016
 		if (!$ids) return false;
1017 1017
 
@@ -1020,21 +1020,21 @@  discard block
 block discarded – undo
1020 1020
 		$return = null;
1021 1021
 
1022 1022
 		$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
1023
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
1023
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
1024 1024
 		{
1025 1025
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
1026 1026
 				self::$cached_event_date_format != $date_format ||
1027 1027
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
1028 1028
 			{
1029
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0);
1029
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0);
1030 1030
 
1031 1031
 				if ($events)
1032 1032
 				{
1033
-					$this->db2data($events,$date_format);
1033
+					$this->db2data($events, $date_format);
1034 1034
 
1035 1035
 					if (is_array($ids))
1036 1036
 					{
1037
-						$return =& $events;
1037
+						$return = & $events;
1038 1038
 					}
1039 1039
 					else
1040 1040
 					{
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 				$return = self::$cached_event;
1051 1051
 			}
1052 1052
 		}
1053
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
1053
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return))
1054 1054
 		{
1055 1055
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
1056 1056
 		}
1057 1057
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
1058 1058
 		{
1059
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
1059
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
1060 1060
 		}
1061 1061
 		return $return;
1062 1062
 	}
@@ -1074,17 +1074,17 @@  discard block
 block discarded – undo
1074 1074
 	 * @param array $events where the repetions get inserted
1075 1075
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
1076 1076
 	 */
1077
-	function insert_all_recurrences($event,$_start,$end,&$events)
1077
+	function insert_all_recurrences($event, $_start, $end, &$events)
1078 1078
 	{
1079
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1079
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1080 1080
 		{
1081
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
1081
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
1082 1082
 		}
1083 1083
 		$end_in = $end;
1084 1084
 
1085 1085
 		$start = $this->date2ts($_start);
1086 1086
 		$event_start_ts = $this->date2ts($event['start']);
1087
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
1087
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
1088 1088
 
1089 1089
 		// if $end is before recur_enddate, use it instead
1090 1090
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1096,27 +1096,27 @@  discard block
 block discarded – undo
1096 1096
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1097 1097
 		unset($event['recur_exception']);
1098 1098
 		// loop over all recurrences and insert them, if they are after $start
1099
-		$rrule = calendar_rrule::event2rrule($event, true);	// true = we operate in usertime, like the rest of calendar_bo
1100
-		foreach($rrule as $time)
1099
+		$rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo
1100
+		foreach ($rrule as $time)
1101 1101
 		{
1102
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1103
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1102
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1103
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1104 1104
 			{
1105 1105
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1106
-				continue;	// to early or original event (returned by interator too)
1106
+				continue; // to early or original event (returned by interator too)
1107 1107
 			}
1108 1108
 
1109 1109
 			$ts_end = $ts + $event_length;
1110 1110
 			// adjust ts_end for whole day events in case it does not fit due to
1111 1111
 			// spans over summer/wintertime adjusted days
1112
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1112
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1113 1113
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1114 1114
 			{
1115 1115
 				$arr_end['hour'] = 23;
1116 1116
 				$arr_end['minute'] = 59;
1117 1117
 				$arr_end['second'] = 59;
1118 1118
 				$ts_end_guess = $this->date2ts($arr_end);
1119
-				if($ts_end_guess - $ts_end > DAY_s/2)
1119
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1120 1120
 				{
1121 1121
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1122 1122
 				}
@@ -1130,11 +1130,11 @@  discard block
 block discarded – undo
1130 1130
 			$event['end'] = $ts_end;
1131 1131
 			$events[] = $event;
1132 1132
 		}
1133
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1133
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1134 1134
 		{
1135 1135
 			$event['start'] = $event_start_ts;
1136 1136
 			$event['end'] = $event_start_ts + $event_length;
1137
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1137
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1138 1138
 		}
1139 1139
 	}
1140 1140
 
@@ -1145,18 +1145,18 @@  discard block
 block discarded – undo
1145 1145
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1146 1146
 	 * @param int|string $date_ymd of the date of the event
1147 1147
 	 */
1148
-	function add_adjusted_event(&$events,$event,$date_ymd)
1148
+	function add_adjusted_event(&$events, $event, $date_ymd)
1149 1149
 	{
1150 1150
 		$event_in = $event;
1151 1151
 		// calculate the new start- and end-time
1152 1152
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1153 1153
 		$event_start_arr = $this->date2array($event['start']);
1154 1154
 
1155
-		$date_arr = $this->date2array((string) $date_ymd);
1155
+		$date_arr = $this->date2array((string)$date_ymd);
1156 1156
 		$date_arr['hour'] = $event_start_arr['hour'];
1157 1157
 		$date_arr['minute'] = $event_start_arr['minute'];
1158 1158
 		$date_arr['second'] = $event_start_arr['second'];
1159
-		unset($date_arr['raw']);	// else date2ts would use it
1159
+		unset($date_arr['raw']); // else date2ts would use it
1160 1160
 		$event['start'] = $this->date2ts($date_arr);
1161 1161
 		$event['end'] = $event['start'] + $length_s;
1162 1162
 
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 
1165 1165
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1166 1166
 		{
1167
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1167
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1168 1168
 		}
1169 1169
 	}
1170 1170
 
@@ -1188,22 +1188,22 @@  discard block
 block discarded – undo
1188 1188
 			{
1189 1189
 				$info = array(
1190 1190
 					'res_id'    => $uid,
1191
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1192
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1193
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1191
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1192
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1193
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1194 1194
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1195 1195
 					'app'   => 'accounts',
1196 1196
 				);
1197 1197
 			}
1198 1198
 			else
1199 1199
 			{
1200
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1200
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1201 1201
 				if ($info)
1202 1202
 				{
1203 1203
 					$info['type'] = $uid[0];
1204 1204
 					if (!$info['email'] && $info['responsible'])
1205 1205
 					{
1206
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1206
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1207 1207
 					}
1208 1208
 					$info['app'] = $this->resources[$uid[0]]['app'];
1209 1209
 				}
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 		}
1213 1213
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1214 1214
 		{
1215
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1215
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1216 1216
 		}
1217 1217
 		return $res_info_cache[$uid];
1218 1218
 	}
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	 * @param int $user =null for which user to check, default current user
1234 1234
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1235 1235
 	 */
1236
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1236
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1237 1237
 	{
1238 1238
 		if (!$user) $user = $this->user;
1239 1239
 		if ($user == $this->user)
@@ -1242,13 +1242,13 @@  discard block
 block discarded – undo
1242 1242
 		}
1243 1243
 		else
1244 1244
 		{
1245
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1245
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1246 1246
 		}
1247 1247
 
1248 1248
 		if ($other && !is_numeric($other))
1249 1249
 		{
1250 1250
 			$resource = $this->resource_info($other);
1251
-			return $needed & $resource['rights'];
1251
+			return $needed&$resource['rights'];
1252 1252
 		}
1253 1253
 		if (is_int($event) && $event == 0)
1254 1254
 		{
@@ -1258,15 +1258,15 @@  discard block
 block discarded – undo
1258 1258
 		{
1259 1259
 			if (!is_array($event))
1260 1260
 			{
1261
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1261
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1262 1262
 			}
1263 1263
 			if (!is_array($event))
1264 1264
 			{
1265 1265
 				if ($this->xmlrpc)
1266 1266
 				{
1267
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1267
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1268 1268
 				}
1269
-				return null;	// event not found
1269
+				return null; // event not found
1270 1270
 			}
1271 1271
 			$owner = $event['owner'];
1272 1272
 			$private = !$event['public'];
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
 		$grant = $grants[$owner];
1275 1275
 
1276 1276
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1277
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1277
+		if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1278 1278
 
1279 1279
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1280 1280
 		{
@@ -1283,15 +1283,15 @@  discard block
 block discarded – undo
1283 1283
 			//
1284 1284
 			if ($event['participants'] && is_array($event['participants']))
1285 1285
 			{
1286
-				foreach(array_keys($event['participants']) as $uid)
1286
+				foreach (array_keys($event['participants']) as $uid)
1287 1287
 				{
1288
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1288
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1289 1289
 					{
1290 1290
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1291
-						$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
1291
+						$grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT;
1292 1292
 						break;
1293 1293
 					}
1294
-					elseif ($grants[$uid] & Acl::READ)
1294
+					elseif ($grants[$uid]&Acl::READ)
1295 1295
 					{
1296 1296
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1297 1297
 						$grant |= Acl::READ;
@@ -1310,12 +1310,12 @@  discard block
 block discarded – undo
1310 1310
 		}
1311 1311
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
1312 1312
 		{
1313
-			$access = False;	// a group can't be the owner of an event
1313
+			$access = False; // a group can't be the owner of an event
1314 1314
 		}
1315 1315
 		else
1316 1316
 		{
1317
-			$access = $user == $owner || $grant & $needed
1318
-				&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
1317
+			$access = $user == $owner || $grant&$needed
1318
+				&& ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT);
1319 1319
 		}
1320 1320
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1321 1321
 		if ($access && $needed == Acl::DELETE && $event['deleted'] &&
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 		}
1327 1327
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1328 1328
 		{
1329
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1329
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1330 1330
 		}
1331 1331
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1332 1332
 		return $access;
@@ -1341,9 +1341,9 @@  discard block
 block discarded – undo
1341 1341
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1342 1342
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1343 1343
 	 */
1344
-	static function date2ts($date,$user2server=False)
1344
+	static function date2ts($date, $user2server = False)
1345 1345
 	{
1346
-		return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
1346
+		return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts');
1347 1347
 	}
1348 1348
 
1349 1349
 	/**
@@ -1353,9 +1353,9 @@  discard block
 block discarded – undo
1353 1353
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1354 1354
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1355 1355
 	 */
1356
-	static function date2array($date,$server2user=False)
1356
+	static function date2array($date, $server2user = False)
1357 1357
 	{
1358
-		return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
1358
+		return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array');
1359 1359
 	}
1360 1360
 
1361 1361
 	/**
@@ -1366,9 +1366,9 @@  discard block
 block discarded – undo
1366 1366
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1367 1367
 	 * @return string date formatted according to $format
1368 1368
 	 */
1369
-	static function date2string($date,$server2user=False,$format='Ymd')
1369
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1370 1370
 	{
1371
-		return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
1371
+		return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format);
1372 1372
 	}
1373 1373
 
1374 1374
 	/**
@@ -1378,9 +1378,9 @@  discard block
 block discarded – undo
1378 1378
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1379 1379
 	 * @return string the formated date (incl. time)
1380 1380
 	 */
1381
-	static function format_date($date,$format='')
1381
+	static function format_date($date, $format = '')
1382 1382
 	{
1383
-		return Api\DateTime::to($date,$format);
1383
+		return Api\DateTime::to($date, $format);
1384 1384
 	}
1385 1385
 
1386 1386
 	/**
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1403 1403
 	 *	arrays get serialized with print_r() !
1404 1404
 	 */
1405
-	static function debug_message($msg,$backtrace=True)
1405
+	static function debug_message($msg, $backtrace = True)
1406 1406
 	{
1407 1407
 		static $acl2string = array(
1408 1408
 			0               => 'ACL-UNKNOWN',
@@ -1413,22 +1413,22 @@  discard block
 block discarded – undo
1413 1413
 			Acl::PRIVAT => 'ACL_PRIVATE',
1414 1414
 			self::ACL_FREEBUSY => 'ACL_FREEBUSY',
1415 1415
 		);
1416
-		for($i = 2; $i < func_num_args(); ++$i)
1416
+		for ($i = 2; $i < func_num_args(); ++$i)
1417 1417
 		{
1418 1418
 			$param = func_get_arg($i);
1419 1419
 
1420 1420
 			if (is_null($param))
1421 1421
 			{
1422
-				$param='NULL';
1422
+				$param = 'NULL';
1423 1423
 			}
1424 1424
 			else
1425 1425
 			{
1426
-				switch(gettype($param))
1426
+				switch (gettype($param))
1427 1427
 				{
1428 1428
 					case 'string':
1429
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1429
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1430 1430
 						{
1431
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1431
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1432 1432
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1433 1433
 						}
1434 1434
 						else
@@ -1451,11 +1451,11 @@  discard block
 block discarded – undo
1451 1451
 						$param = $param ? 'True' : 'False';
1452 1452
 						break;
1453 1453
 					case 'integer':
1454
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1454
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1455 1455
 						break;
1456 1456
 				}
1457 1457
 			}
1458
-			$msg = str_replace('%'.($i-1),$param,$msg);
1458
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1459 1459
 		}
1460 1460
 		error_log($msg);
1461 1461
 		if ($backtrace) error_log(function_backtrace(1));
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1471 1471
 	 * @return string with formated date
1472 1472
 	 */
1473
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1473
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1474 1474
 	{
1475 1475
 		$first = $this->date2array($_first);
1476 1476
 		if ($last)
@@ -1485,27 +1485,27 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
 		if ($display_day)
1487 1487
 		{
1488
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1488
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1489 1489
 		}
1490 1490
 		for ($i = 0; $i < 5; $i += 2)
1491 1491
 		{
1492
-			switch($datefmt[$i])
1492
+			switch ($datefmt[$i])
1493 1493
 			{
1494 1494
 				case 'd':
1495
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1495
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1496 1496
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1497 1497
 					{
1498 1498
 						if (!$month_before_day)
1499 1499
 						{
1500
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1500
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1501 1501
 						}
1502 1502
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1503 1503
 						{
1504
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1504
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1505 1505
 						}
1506 1506
 						if ($display_time)
1507 1507
 						{
1508
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1508
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1509 1509
 						}
1510 1510
 						if (!$last)
1511 1511
 						{
@@ -1515,43 +1515,43 @@  discard block
 block discarded – undo
1515 1515
 
1516 1516
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1517 1517
 						{
1518
-							$range .= $last['year'] . ', ';
1518
+							$range .= $last['year'].', ';
1519 1519
 						}
1520 1520
 
1521 1521
 						if ($month_before_day)
1522 1522
 						{
1523
-							$range .= lang(strftime('%B',$last['raw']));
1523
+							$range .= lang(strftime('%B', $last['raw']));
1524 1524
 						}
1525 1525
 					}
1526 1526
 					else
1527 1527
 					{
1528 1528
 						if ($display_time)
1529 1529
 						{
1530
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1530
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1531 1531
 						}
1532 1532
 						$range .= ' - ';
1533 1533
 					}
1534
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1534
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1535 1535
 					break;
1536 1536
 				case 'm':
1537 1537
 				case 'M':
1538
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1538
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1539 1539
 					break;
1540 1540
 				case 'Y':
1541 1541
 					if ($datefmt[0] != 'm')
1542 1542
 					{
1543
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1543
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1544 1544
 					}
1545 1545
 					break;
1546 1546
 			}
1547 1547
 		}
1548 1548
 		if ($display_time && $last)
1549 1549
 		{
1550
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1550
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1551 1551
 		}
1552 1552
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1553 1553
 		{
1554
-			$range .= ', ' . $last['year'];
1554
+			$range .= ', '.$last['year'];
1555 1555
 		}
1556 1556
 		return $range;
1557 1557
 	}
@@ -1563,25 +1563,25 @@  discard block
 block discarded – undo
1563 1563
 	 * @param int $end_m end time in minutes since 0h
1564 1564
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1565 1565
 	 */
1566
-	function timespan($start_m,$end_m,$both=false)
1566
+	function timespan($start_m, $end_m, $both = false)
1567 1567
 	{
1568 1568
 		$duration = $end_m - $start_m;
1569
-		if ($end_m == 24*60-1) ++$duration;
1570
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1569
+		if ($end_m == 24 * 60 - 1) ++$duration;
1570
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1571 1571
 
1572
-		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1572
+		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false);
1573 1573
 
1574 1574
 		if ($both)	// end-time too
1575 1575
 		{
1576
-			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1576
+			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false);
1577 1577
 			// dont double am/pm if they are the same in both times
1578
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1578
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1579 1579
 			{
1580
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1580
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1581 1581
 			}
1582 1582
 			$timespan .= ':';
1583 1583
 		}
1584
-		return $timespan . ' ' . $duration;
1584
+		return $timespan.' '.$duration;
1585 1585
 	}
1586 1586
 
1587 1587
 	/**
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 	* @param boolean $append_email =false append email (Name <email>)
1593 1593
 	* @return string with name
1594 1594
 	*/
1595
-	function participant_name($id,$use_type=false, $append_email=false)
1595
+	function participant_name($id, $use_type = false, $append_email = false)
1596 1596
 	{
1597 1597
 		static $id2lid = array();
1598 1598
 		static $id2email = array();
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 			else
1614 1614
 			{
1615 1615
 				$id2lid[$id] = Api\Accounts::username($id);
1616
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1616
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1617 1617
 			}
1618 1618
 		}
1619 1619
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1627,37 +1627,37 @@  discard block
 block discarded – undo
1627 1627
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1628 1628
 	* @return array with id / names with status pairs
1629 1629
 	*/
1630
-	function participants($event,$long_status=false,$show_group_invitation=false)
1630
+	function participants($event, $long_status = false, $show_group_invitation = false)
1631 1631
 	{
1632 1632
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1633 1633
 		$names = array();
1634
-		foreach((array)$event['participants'] as $id => $status)
1634
+		foreach ((array)$event['participants'] as $id => $status)
1635 1635
 		{
1636 1636
 			if (!is_string($status)) continue;
1637 1637
 			$quantity = $role = null;
1638
-			calendar_so::split_status($status,$quantity,$role);
1638
+			calendar_so::split_status($status, $quantity, $role);
1639 1639
 
1640
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1640
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1641 1641
 
1642 1642
 			$lang_status = lang($this->verbose_status[$status]);
1643 1643
 			if (!$long_status)
1644 1644
 			{
1645
-				switch($status[0])
1645
+				switch ($status[0])
1646 1646
 				{
1647 1647
 					case 'A':	// accepted
1648
-						$status = Api\Html::image('calendar','accepted',$lang_status);
1648
+						$status = Api\Html::image('calendar', 'accepted', $lang_status);
1649 1649
 						break;
1650 1650
 					case 'R':	// rejected
1651
-						$status = Api\Html::image('calendar','rejected',$lang_status);
1651
+						$status = Api\Html::image('calendar', 'rejected', $lang_status);
1652 1652
 						break;
1653 1653
 					case 'T':	// tentative
1654
-						$status = Api\Html::image('calendar','tentative',$lang_status);
1654
+						$status = Api\Html::image('calendar', 'tentative', $lang_status);
1655 1655
 						break;
1656 1656
 					case 'U':	// no response = unknown
1657
-						$status = Api\Html::image('calendar','needs-action',$lang_status);
1657
+						$status = Api\Html::image('calendar', 'needs-action', $lang_status);
1658 1658
 						break;
1659 1659
 					case 'D':	// delegated
1660
-						$status = Api\Html::image('calendar','forward',$lang_status);
1660
+						$status = Api\Html::image('calendar', 'forward', $lang_status);
1661 1661
 						break;
1662 1662
 					case 'G':	// group invitation
1663 1663
 						// Todo: Image, seems not to be used
@@ -1679,13 +1679,13 @@  discard block
 block discarded – undo
1679 1679
 					$role = lang($this->roles[$role]);
1680 1680
 				}
1681 1681
 				// allow to use cats as roles (beside regular iCal ones)
1682
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1682
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1683 1683
 				{
1684 1684
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1685 1685
 				}
1686 1686
 				else
1687 1687
 				{
1688
-					$role = lang(str_replace('X-','',$role));
1688
+					$role = lang(str_replace('X-', '', $role));
1689 1689
 				}
1690 1690
 				$names[$id] .= ' '.$role;
1691 1691
 			}
@@ -1702,13 +1702,13 @@  discard block
 block discarded – undo
1702 1702
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1703 1703
 	* @return array with id / names
1704 1704
 	*/
1705
-	function categories($category,&$color)
1705
+	function categories($category, &$color)
1706 1706
 	{
1707 1707
 		static $id2cat = array();
1708 1708
 		$cats = array();
1709 1709
 		$color = 0;
1710 1710
 
1711
-		foreach(explode(',',$category) as $cat_id)
1711
+		foreach (explode(',', $category) as $cat_id)
1712 1712
 		{
1713 1713
 			if (!$cat_id) continue;
1714 1714
 
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			{
1724 1724
 				$color = $cat['data']['color'];
1725 1725
 			}
1726
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1726
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1727 1727
 			{
1728 1728
 				$color = $parts[1];
1729 1729
 			}
@@ -1735,12 +1735,12 @@  discard block
 block discarded – undo
1735 1735
 	/**
1736 1736
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1737 1737
 	 */
1738
-	private static function _list_cals_add($id,&$users,&$groups)
1738
+	private static function _list_cals_add($id, &$users, &$groups)
1739 1739
 	{
1740 1740
 		$name = Api\Accounts::username($id);
1741 1741
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1742 1742
 		{
1743
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1743
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1744 1744
 		}
1745 1745
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1746 1746
 		{
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
 		}
1753 1753
 		$arr[$id] = array(
1754 1754
 			'grantor' => $id,
1755
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1755
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1756 1756
 			'name'    => $name,
1757 1757
 			'sname'	  => $egw_name
1758 1758
 		);
@@ -1774,26 +1774,26 @@  discard block
 block discarded – undo
1774 1774
 	 * @param int $user account_id of user to generate list for
1775 1775
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1776 1776
 	 */
1777
-	public static function list_calendars($user, array $grants=null)
1777
+	public static function list_calendars($user, array $grants = null)
1778 1778
 	{
1779 1779
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1780 1780
 
1781 1781
 		$users = $groups = array();
1782
-		foreach(array_keys($grants) as $id)
1782
+		foreach (array_keys($grants) as $id)
1783 1783
 		{
1784
-			self::_list_cals_add($id,$users,$groups);
1784
+			self::_list_cals_add($id, $users, $groups);
1785 1785
 		}
1786 1786
 		if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true)))
1787 1787
 		{
1788
-			foreach($memberships as $group)
1788
+			foreach ($memberships as $group)
1789 1789
 			{
1790
-				self::_list_cals_add($group,$users,$groups);
1790
+				self::_list_cals_add($group, $users, $groups);
1791 1791
 
1792
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
1792
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar')))
1793 1793
 				{
1794
-					foreach($account_perms as $id)
1794
+					foreach ($account_perms as $id)
1795 1795
 					{
1796
-						self::_list_cals_add($id,$users,$groups);
1796
+						self::_list_cals_add($id, $users, $groups);
1797 1797
 					}
1798 1798
 				}
1799 1799
 			}
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
 		usort($users, array(__CLASS__, 'name_cmp'));
1802 1802
 		usort($groups, array(__CLASS__, 'name_cmp'));
1803 1803
 
1804
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1804
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1805 1805
 	}
1806 1806
 
1807 1807
 	/**
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 	 *	month: numerical month
1842 1842
 	 *	occurence: numerical year or 0 for every year
1843 1843
 	 */
1844
-	function read_holidays($year=0)
1844
+	function read_holidays($year = 0)
1845 1845
 	{
1846
-		if (!$year) $year = (int) date('Y',$this->now_su);
1846
+		if (!$year) $year = (int)date('Y', $this->now_su);
1847 1847
 
1848 1848
 		if (!$this->cached_holidays)	// try reading the holidays from the session
1849 1849
 		{
@@ -1853,8 +1853,7 @@  discard block
 block discarded – undo
1853 1853
 		{
1854 1854
 			$this->cached_holidays[$year] = calendar_holidays::read(
1855 1855
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
1856
-				$GLOBALS['egw_info']['server']['ical_holiday_url'] :
1857
-				$GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1856
+				$GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1858 1857
 
1859 1858
 			// search for birthdays
1860 1859
 			if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
@@ -1864,41 +1863,40 @@  discard block
 block discarded – undo
1864 1863
 					'n_family' => "!''",
1865 1864
 					'bday' => "!''",
1866 1865
 				);
1867
-				$bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1868
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter);
1866
+				$bdays = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1867
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter);
1869 1868
 				// search accounts too, if not stored in contacts repository
1870 1869
 				$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
1871 1870
 					!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'];
1872
-				if ($extra_accounts_search && ($bdays2 =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1873
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter+array('owner' => 0))))
1871
+				if ($extra_accounts_search && ($bdays2 = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1872
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter + array('owner' => 0))))
1874 1873
 				{
1875
-					$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
1874
+					$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
1876 1875
 				}
1877 1876
 				if ($bdays)
1878 1877
 				{
1879 1878
 					// sort by month and day only
1880 1879
 					usort($bdays, function($a, $b)
1881 1880
 					{
1882
-						return (int) $a['bday'] == (int) $b['bday'] ?
1883
-							strcmp($a['bday'], $b['bday']) :
1884
-							(int) $a['bday'] - (int) $b['bday'];
1881
+						return (int)$a['bday'] == (int)$b['bday'] ?
1882
+							strcmp($a['bday'], $b['bday']) : (int)$a['bday'] - (int)$b['bday'];
1885 1883
 					});
1886
-					foreach($bdays as $pers)
1884
+					foreach ($bdays as $pers)
1887 1885
 					{
1888
-						if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00')
1886
+						if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00')
1889 1887
 						{
1890 1888
 							//error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
1891 1889
 							continue;
1892 1890
 						}
1893
-						list($y,$m,$d) = explode('-',$pers['bday']);
1894
-						if ($y > $year) continue; 	// not yet born
1895
-						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1891
+						list($y, $m, $d) = explode('-', $pers['bday']);
1892
+						if ($y > $year) continue; // not yet born
1893
+						$this->cached_holidays[$year][sprintf('%04d%02d%02d', $year, $m, $d)][] = array(
1896 1894
 							'day'       => $d,
1897 1895
 							'month'     => $m,
1898 1896
 							'occurence' => 0,
1899 1897
 							'name'      => lang('Birthday').' '.($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']).' '.$pers['n_middle'].' '.
1900 1898
 								$pers['n_family'].($y && !$GLOBALS['egw_info']['server']['hide_birthdays'] ? ' ('.$y.')' : ''),
1901
-							'birthyear' => $y,	// this can be used to identify birthdays from holidays
1899
+							'birthyear' => $y, // this can be used to identify birthdays from holidays
1902 1900
 						);
1903 1901
 					}
1904 1902
 				}
@@ -1906,9 +1904,9 @@  discard block
 block discarded – undo
1906 1904
 			// store holidays and birthdays in the session
1907 1905
 			Api\Cache::setSession('calendar', 'holidays', $this->cached_holidays);
1908 1906
 		}
1909
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1907
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1910 1908
 		{
1911
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$this->cached_holidays[$year]);
1909
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $this->cached_holidays[$year]);
1912 1910
 		}
1913 1911
 		return $this->cached_holidays[$year];
1914 1912
 	}
@@ -1919,10 +1917,10 @@  discard block
 block discarded – undo
1919 1917
 	 * @param type $event
1920 1918
 	 * @return array array of selected calendar fields
1921 1919
 	 */
1922
-	public static function get_link_options ($event = array())
1920
+	public static function get_link_options($event = array())
1923 1921
 	{
1924
-		unset($event);	// not used, but required by function signature
1925
-		$options = array (
1922
+		unset($event); // not used, but required by function signature
1923
+		$options = array(
1926 1924
 			'end' => lang('End date'),
1927 1925
 			'id' => lang('ID'),
1928 1926
 			'owner' => lang('Event owner'),
@@ -1949,7 +1947,7 @@  discard block
 block discarded – undo
1949 1947
 			list($id, $recur) = explode('-', $event, 2);
1950 1948
 			$event = $this->read($id, $recur);
1951 1949
 		}
1952
-		else if (!is_array($event) && (int) $event > 0)
1950
+		else if (!is_array($event) && (int)$event > 0)
1953 1951
 		{
1954 1952
 			$event = $this->read($event);
1955 1953
 		}
@@ -1957,7 +1955,7 @@  discard block
 block discarded – undo
1957 1955
 		{
1958 1956
 			return $event;
1959 1957
 		}
1960
-		$type = explode(',',$this->cal_prefs['link_title']);
1958
+		$type = explode(',', $this->cal_prefs['link_title']);
1961 1959
 		if (is_array($type))
1962 1960
 		{
1963 1961
 			foreach ($type as &$val)
@@ -1983,10 +1981,10 @@  discard block
 block discarded – undo
1983 1981
 						$extra_fields [] = $event[$val];
1984 1982
 				}
1985 1983
 			}
1986
-			$str_fields = implode(', ',$extra_fields);
1987
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
1984
+			$str_fields = implode(', ', $extra_fields);
1985
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
1988 1986
 		}
1989
-		return $this->format_date($event['start']) . ': ' . $event['title'];
1987
+		return $this->format_date($event['start']).': '.$event['title'];
1990 1988
 	}
1991 1989
 
1992 1990
 	/**
@@ -2005,10 +2003,10 @@  discard block
 block discarded – undo
2005 2003
 			'offset' =>	$options['start'],
2006 2004
 			'order' => 'cal_start DESC',
2007 2005
 		);
2008
-		if($options['num_rows']) {
2006
+		if ($options['num_rows']) {
2009 2007
 			$query['num_rows'] = $options['num_rows'];
2010 2008
 		}
2011
-		foreach((array) $this->search($query) as $event)
2009
+		foreach ((array)$this->search($query) as $event)
2012 2010
 		{
2013 2011
 			$result[$event['id']] = $this->link_title($event);
2014 2012
 		}
@@ -2025,11 +2023,11 @@  discard block
 block discarded – undo
2025 2023
 	 * @param int $user =null for which user to check, default current user
2026 2024
 	 * @return boolean true if access is granted or false otherwise
2027 2025
 	 */
2028
-	function file_access($id,$check,$rel_path,$user=null)
2026
+	function file_access($id, $check, $rel_path, $user = null)
2029 2027
 	{
2030
-		unset($rel_path);	// not used, but required by function signature
2028
+		unset($rel_path); // not used, but required by function signature
2031 2029
 
2032
-		return $this->check_perms($check,$id,0,'ts',null,$user);
2030
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
2033 2031
 	}
2034 2032
 
2035 2033
 	/**
@@ -2045,36 +2043,36 @@  discard block
 block discarded – undo
2045 2043
 		}
2046 2044
 		Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
2047 2045
 
2048
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
2049
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
2046
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
2047
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
2050 2048
 
2051
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
2049
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
2052 2050
 		$values = array(
2053
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
2054
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
2055
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
2056
-			'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'),
2057
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
2058
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
2051
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
2052
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
2053
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
2054
+			'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'),
2055
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
2056
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
2059 2057
 			'interval'        => 30,
2060 2058
 		);
2061
-		foreach($values as $var => $default)
2059
+		foreach ($values as $var => $default)
2062 2060
 		{
2063
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
2061
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
2064 2062
 
2065 2063
 			// only set, if neither default nor forced pref exists
2066 2064
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2067 2065
 			{
2068
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2069
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2066
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
2067
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
2070 2068
 				$this->cal_prefs[$var] = $default;
2071 2069
 				$need_save = True;
2072 2070
 			}
2073 2071
 		}
2074 2072
 		if ($need_save)
2075 2073
 		{
2076
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
2077
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
2074
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
2075
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
2078 2076
 		}
2079 2077
 	}
2080 2078
 
@@ -2084,7 +2082,7 @@  discard block
 block discarded – undo
2084 2082
 	 * @param int|string $user account_id or account_lid
2085 2083
 	 * @param string $pw =null password
2086 2084
 	 */
2087
-	static function freebusy_url($user='',$pw=null)
2085
+	static function freebusy_url($user = '', $pw = null)
2088 2086
 	{
2089 2087
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2090 2088
 
@@ -2097,8 +2095,8 @@  discard block
 block discarded – undo
2097 2095
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
2098 2096
 		{
2099 2097
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2100
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2101
-			$credentials = '&cred=' . base64_encode($credentials);
2098
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2099
+			$credentials = '&cred='.base64_encode($credentials);
2102 2100
 		}
2103 2101
 		return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
2104 2102
 			($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
@@ -2130,11 +2128,11 @@  discard block
 block discarded – undo
2130 2128
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2131 2129
 	 * @return string|boolean string with etag or false
2132 2130
 	 */
2133
-	function get_etag($entry, &$schedule_tag=null)
2131
+	function get_etag($entry, &$schedule_tag = null)
2134 2132
 	{
2135 2133
 		if (!is_array($entry))
2136 2134
 		{
2137
-			list($id,$recur_date) = explode(':',$entry);
2135
+			list($id, $recur_date) = explode(':', $entry);
2138 2136
 			$entry = $this->read($id, $recur_date, true, 'server');
2139 2137
 		}
2140 2138
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2152,15 +2150,15 @@  discard block
 block discarded – undo
2152 2150
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2153 2151
 	 * @return integer
2154 2152
 	 */
2155
-	public function get_ctag($user, $filter='owner', $master_only=false)
2153
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2156 2154
 	{
2157 2155
 		if ($this->debug > 1) $startime = microtime(true);
2158 2156
 
2159 2157
 		// resolve users to add memberships for users and members for groups
2160 2158
 		$users = $this->resolve_users($user);
2161
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2159
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2162 2160
 
2163
-		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");
2161
+		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");
2164 2162
 		return $ctag;
2165 2163
 	}
2166 2164
 
@@ -2180,7 +2178,7 @@  discard block
 block discarded – undo
2180 2178
 
2181 2179
 		$content = array(
2182 2180
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
2183
-			'info_priority'  => $calendar['priority'] ,
2181
+			'info_priority'  => $calendar['priority'],
2184 2182
 			'info_public'    => $calendar['public'] != 'private',
2185 2183
 			'info_subject'   => $calendar['title'],
2186 2184
 			'info_des'       => $calendar['description'],
@@ -2195,7 +2193,7 @@  discard block
 block discarded – undo
2195 2193
 		$content['link_app'][] = $calendar['info_link']['app'];
2196 2194
 		$content['link_id'][]  = $calendar['info_link']['id'];
2197 2195
 		// Copy claendar's links
2198
-		foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2196
+		foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2199 2197
 		{
2200 2198
 			if ($link['app'] != Link::VFS_APPNAME)
2201 2199
 			{
@@ -2208,7 +2206,7 @@  discard block
 block discarded – undo
2208 2206
 			}
2209 2207
 		}
2210 2208
 		// Copy same custom fields
2211
-		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2209
+		foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2212 2210
 		{
2213 2211
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2214 2212
 		}
@@ -2226,20 +2224,20 @@  discard block
 block discarded – undo
2226 2224
 	function timesheet_set($data)
2227 2225
 	{
2228 2226
 		$set = array();
2229
-		list($id,$recurrence) = explode(':',$data['id']);
2230
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2227
+		list($id, $recurrence) = explode(':', $data['id']);
2228
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2231 2229
 		{
2232 2230
 			$set['ts_start'] = $event['start'];
2233 2231
 			$set['ts_title'] = $this->link_title($event);
2234
-			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2232
+			$set['start_time'] = Api\DateTime::to($event['start'], 'H:i');
2235 2233
 			$set['ts_description'] = $event['description'];
2236
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2234
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2237 2235
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2238 2236
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2239
-			$set['end_time'] = null;	// unset end-time
2237
+			$set['end_time'] = null; // unset end-time
2240 2238
 			$set['cat_id'] = (int)$event['category'];
2241 2239
 
2242
-			foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2240
+			foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2243 2241
 			{
2244 2242
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
2245 2243
 				{
Please login to merge, or discard this patch.
Braces   +206 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
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);
@@ -222,7 +225,10 @@  discard block
 block discarded – undo
222 225
 	 */
223 226
 	function __construct()
224 227
 	{
225
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
228
+		if ($this->debug > 0)
229
+		{
230
+			$this->debug_message('calendar_bo::bocal() started',True);
231
+		}
226 232
 
227 233
 		$this->so = new calendar_so();
228 234
 
@@ -308,7 +314,10 @@  discard block
 block discarded – undo
308 314
 	 */
309 315
 	static function email_info($ids)
310 316
 	{
311
-		if (!$ids) return null;
317
+		if (!$ids)
318
+		{
319
+			return null;
320
+		}
312 321
 
313 322
 		$data = array();
314 323
 		foreach((array)$ids as $id)
@@ -391,10 +400,13 @@  discard block
 block discarded – undo
391 400
 				$contact = 'c'.$contact['id'];
392 401
 				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
393 402
 				{
394
-					if ($contact && !in_array($contact,$contact_list))	// already added?
403
+					if ($contact && !in_array($contact,$contact_list))
404
+					{
405
+						// already added?
395 406
 					{
396 407
 						$contact_list[] = $contact;
397 408
 					}
409
+					}
398 410
 				}
399 411
 			}
400 412
 		}
@@ -454,31 +466,43 @@  discard block
 block discarded – undo
454 466
 			{
455 467
 				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
456 468
 				{
457
-					if ($contact && !in_array($contact,$users))	// already added?
469
+					if ($contact && !in_array($contact,$users))
470
+					{
471
+						// already added?
458 472
 					{
459 473
 						$users[] = $contact;
460 474
 					}
475
+					}
461 476
 				}
462 477
 				continue;
463 478
 			}
464 479
 			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
465 480
 			{
466
-				if ($user && !in_array($user,$users))	// already added?
481
+				if ($user && !in_array($user,$users))
482
+				{
483
+					// already added?
467 484
 				{
468 485
 					$users[] = $user;
469 486
 				}
487
+				}
470 488
 			}
471 489
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
472 490
 			{
473 491
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
474 492
 			}
475 493
 			// the further code is only for real users
476
-			if (!is_numeric($user)) continue;
494
+			if (!is_numeric($user))
495
+			{
496
+				continue;
497
+			}
477 498
 
478 499
 			// for groups we have to include the members
479 500
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
480 501
 			{
481
-				if ($no_enum_groups) continue;
502
+				if ($no_enum_groups)
503
+				{
504
+					continue;
505
+				}
482 506
 
483 507
 				$members = $GLOBALS['egw']->accounts->members($user, true);
484 508
 				if (is_array($members))
@@ -558,11 +582,14 @@  discard block
 block discarded – undo
558 582
 		}
559 583
 
560 584
 		if (!isset($params['users']) || !$params['users'] ||
561
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
585
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
586
+		{
587
+			// null or '' casted to an array
562 588
 		{
563 589
 			// for a search use all account you have read grants from
564 590
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
565 591
 		}
592
+		}
566 593
 		// resolve users to add memberships for users and members for groups
567 594
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
568 595
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -573,7 +600,10 @@  discard block
 block discarded – undo
573 600
 			$params['private_grants'] = array();
574 601
 			foreach($this->grants as $user => $rights)
575 602
 			{
576
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
603
+				if ($rights & Acl::PRIVAT)
604
+				{
605
+					$params['private_grants'][] = $user;
606
+				}
577 607
 			}
578 608
 		}
579 609
 
@@ -588,7 +618,10 @@  discard block
 block discarded – undo
588 618
 		{
589 619
 			return false;
590 620
 		}
591
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
621
+		if (isset($params['start']))
622
+		{
623
+			$start = $this->date2ts($params['start']);
624
+		}
592 625
 
593 626
 		if (isset($params['end']))
594 627
 		{
@@ -652,10 +685,13 @@  discard block
 block discarded – undo
652 685
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
653 686
 			}
654 687
 			// create empty entries for each day in the reported time
655
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
688
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
689
+			{
690
+				// good enough for array creation, but see while loop below.
656 691
 			{
657 692
 				$daysEvents[$this->date2string($ts)] = array();
658 693
 			}
694
+			}
659 695
 			foreach($events as $k => $event)
660 696
 			{
661 697
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -707,7 +743,10 @@  discard block
 block discarded – undo
707 743
 			$integration_data = calendar_so::get_integration_data();
708 744
 		}
709 745
 
710
-		if (!isset($integration_data[$app])) return null;
746
+		if (!isset($integration_data[$app]))
747
+		{
748
+			return null;
749
+		}
711 750
 
712 751
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
713 752
 	}
@@ -754,8 +793,14 @@  discard block
 block discarded – undo
754 793
 	 */
755 794
 	function clear_private_infos(&$event,$allowed_participants = array())
756 795
 	{
757
-		if ($event == false) return;
758
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
796
+		if ($event == false)
797
+		{
798
+			return;
799
+		}
800
+		if (!is_array($event['participants']))
801
+		{
802
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
803
+		}
759 804
 
760 805
 		$event = array(
761 806
 			'id'    => $event['id'],
@@ -800,19 +845,29 @@  discard block
 block discarded – undo
800 845
 		}
801 846
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
802 847
 
803
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
848
+		if ($new_horizont <= $this->config['horizont'])
849
+		{
850
+			// no move necessary
804 851
 		{
805 852
 			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']);
853
+		}
806 854
 			return;
807 855
 		}
808 856
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
809 857
 		{
810 858
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
811 859
 		}
812
-		if (empty($maxdays)) $maxdays = 1000; // old default
813
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
860
+		if (empty($maxdays))
861
+		{
862
+			$maxdays = 1000;
863
+		}
864
+		// old default
865
+		if ($new_horizont > time()+$maxdays*DAY_s)
866
+		{
867
+			// some user tries to "look" more then the maximum number of days in the future
814 868
 		{
815 869
 			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);
870
+		}
816 871
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
817 872
 			return;
818 873
 		}
@@ -840,7 +895,10 @@  discard block
 block discarded – undo
840 895
 		// update the horizont
841 896
 		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
842 897
 
843
-		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']);
898
+		if ($this->debug == 'check_move_horizont')
899
+		{
900
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
901
+		}
844 902
 	}
845 903
 
846 904
 	/**
@@ -871,7 +929,10 @@  discard block
 block discarded – undo
871 929
 				$event['end'] = $event_read['end'];
872 930
 			}
873 931
 		}
874
-		if (!$start) $start = $event['start'];
932
+		if (!$start)
933
+		{
934
+			$start = $event['start'];
935
+		}
875 936
 
876 937
 		$events = array();
877 938
 		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
@@ -911,7 +972,10 @@  discard block
 block discarded – undo
911 972
 	 */
912 973
 	function db2data(&$events,$date_format='ts')
913 974
 	{
914
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
975
+		if (!is_array($events))
976
+		{
977
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
978
+		}
915 979
 		foreach ($events as &$event)
916 980
 		{
917 981
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -995,7 +1059,10 @@  discard block
 block discarded – undo
995 1059
 	 */
996 1060
 	function date2usertime($ts,$date_format='ts')
997 1061
 	{
998
-		if (empty($ts) || $date_format == 'server') return $ts;
1062
+		if (empty($ts) || $date_format == 'server')
1063
+		{
1064
+			return $ts;
1065
+		}
999 1066
 
1000 1067
 		return Api\DateTime::server2user($ts,$date_format);
1001 1068
 	}
@@ -1013,9 +1080,15 @@  discard block
 block discarded – undo
1013 1080
 	 */
1014 1081
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1015 1082
 	{
1016
-		if (!$ids) return false;
1083
+		if (!$ids)
1084
+		{
1085
+			return false;
1086
+		}
1017 1087
 
1018
-		if ($date) $date = $this->date2ts($date);
1088
+		if ($date)
1089
+		{
1090
+			$date = $this->date2ts($date);
1091
+		}
1019 1092
 
1020 1093
 		$return = null;
1021 1094
 
@@ -1180,7 +1253,10 @@  discard block
 block discarded – undo
1180 1253
 	{
1181 1254
 		static $res_info_cache = array();
1182 1255
 
1183
-		if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1256
+		if (!is_scalar($uid))
1257
+		{
1258
+			throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1259
+		}
1184 1260
 
1185 1261
 		if (!isset($res_info_cache[$uid]))
1186 1262
 		{
@@ -1235,7 +1311,10 @@  discard block
 block discarded – undo
1235 1311
 	 */
1236 1312
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1237 1313
 	{
1238
-		if (!$user) $user = $this->user;
1314
+		if (!$user)
1315
+		{
1316
+			$user = $this->user;
1317
+		}
1239 1318
 		if ($user == $this->user)
1240 1319
 		{
1241 1320
 			$grants = $this->grants;
@@ -1274,7 +1353,10 @@  discard block
 block discarded – undo
1274 1353
 		$grant = $grants[$owner];
1275 1354
 
1276 1355
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1277
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1356
+		if ($grant & ~self::ACL_INVITE)
1357
+		{
1358
+			$grant |= self::ACL_FREEBUSY;
1359
+		}
1278 1360
 
1279 1361
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1280 1362
 		{
@@ -1300,7 +1382,10 @@  discard block
 block discarded – undo
1300 1382
 					elseif (!is_numeric($uid))
1301 1383
 					{
1302 1384
 						// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
1303
-						if ($grant == self::ACL_FREEBUSY) continue;
1385
+						if ($grant == self::ACL_FREEBUSY)
1386
+						{
1387
+							continue;
1388
+						}
1304 1389
 						// if we have a resource as participant
1305 1390
 						$resource = $this->resource_info($uid);
1306 1391
 						$grant |= $resource['rights'];
@@ -1451,14 +1536,20 @@  discard block
 block discarded – undo
1451 1536
 						$param = $param ? 'True' : 'False';
1452 1537
 						break;
1453 1538
 					case 'integer':
1454
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1539
+						if ($param >= mktime(0,0,0,1,1,2000))
1540
+						{
1541
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1542
+						}
1455 1543
 						break;
1456 1544
 				}
1457 1545
 			}
1458 1546
 			$msg = str_replace('%'.($i-1),$param,$msg);
1459 1547
 		}
1460 1548
 		error_log($msg);
1461
-		if ($backtrace) error_log(function_backtrace(1));
1549
+		if ($backtrace)
1550
+		{
1551
+			error_log(function_backtrace(1));
1552
+		}
1462 1553
 	}
1463 1554
 
1464 1555
 	/**
@@ -1566,14 +1657,20 @@  discard block
 block discarded – undo
1566 1657
 	function timespan($start_m,$end_m,$both=false)
1567 1658
 	{
1568 1659
 		$duration = $end_m - $start_m;
1569
-		if ($end_m == 24*60-1) ++$duration;
1660
+		if ($end_m == 24*60-1)
1661
+		{
1662
+			++$duration;
1663
+		}
1570 1664
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1571 1665
 
1572 1666
 		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1573 1667
 
1574
-		if ($both)	// end-time too
1668
+		if ($both)
1669
+		{
1670
+			// end-time too
1575 1671
 		{
1576 1672
 			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1673
+		}
1577 1674
 			// dont double am/pm if they are the same in both times
1578 1675
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1579 1676
 			{
@@ -1597,7 +1694,10 @@  discard block
 block discarded – undo
1597 1694
 		static $id2lid = array();
1598 1695
 		static $id2email = array();
1599 1696
 
1600
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1697
+		if ($use_type && $use_type != 'u')
1698
+		{
1699
+			$id = $use_type.$id;
1700
+		}
1601 1701
 
1602 1702
 		if (!isset($id2lid[$id]))
1603 1703
 		{
@@ -1607,7 +1707,10 @@  discard block
 block discarded – undo
1607 1707
 				if (($info = $this->resource_info($id)))
1608 1708
 				{
1609 1709
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1610
-					if ($info['name']) $id2email[$id] = $info['email'];
1710
+					if ($info['name'])
1711
+					{
1712
+						$id2email[$id] = $info['email'];
1713
+					}
1611 1714
 				}
1612 1715
 			}
1613 1716
 			else
@@ -1633,11 +1736,18 @@  discard block
 block discarded – undo
1633 1736
 		$names = array();
1634 1737
 		foreach((array)$event['participants'] as $id => $status)
1635 1738
 		{
1636
-			if (!is_string($status)) continue;
1739
+			if (!is_string($status))
1740
+			{
1741
+				continue;
1742
+			}
1637 1743
 			$quantity = $role = null;
1638 1744
 			calendar_so::split_status($status,$quantity,$role);
1639 1745
 
1640
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1746
+			if ($status == 'G' && !$show_group_invitation)
1747
+			{
1748
+				continue;
1749
+			}
1750
+			// dont show group-invitation
1641 1751
 
1642 1752
 			$lang_status = lang($this->verbose_status[$status]);
1643 1753
 			if (!$long_status)
@@ -1710,7 +1820,10 @@  discard block
 block discarded – undo
1710 1820
 
1711 1821
 		foreach(explode(',',$category) as $cat_id)
1712 1822
 		{
1713
-			if (!$cat_id) continue;
1823
+			if (!$cat_id)
1824
+			{
1825
+				continue;
1826
+			}
1714 1827
 
1715 1828
 			if (!isset($id2cat[$cat_id]))
1716 1829
 			{
@@ -1776,7 +1889,10 @@  discard block
 block discarded – undo
1776 1889
 	 */
1777 1890
 	public static function list_calendars($user, array $grants=null)
1778 1891
 	{
1779
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1892
+		if (is_null($grants))
1893
+		{
1894
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1895
+		}
1780 1896
 
1781 1897
 		$users = $groups = array();
1782 1898
 		foreach(array_keys($grants) as $id)
@@ -1824,7 +1940,10 @@  discard block
 block discarded – undo
1824 1940
 	 */
1825 1941
 	function recure2string($event)
1826 1942
 	{
1827
-		if (!is_array($event)) return false;
1943
+		if (!is_array($event))
1944
+		{
1945
+			return false;
1946
+		}
1828 1947
 		return (string)calendar_rrule::event2rrule($event);
1829 1948
 	}
1830 1949
 
@@ -1843,12 +1962,18 @@  discard block
 block discarded – undo
1843 1962
 	 */
1844 1963
 	function read_holidays($year=0)
1845 1964
 	{
1846
-		if (!$year) $year = (int) date('Y',$this->now_su);
1965
+		if (!$year)
1966
+		{
1967
+			$year = (int) date('Y',$this->now_su);
1968
+		}
1847 1969
 
1848
-		if (!$this->cached_holidays)	// try reading the holidays from the session
1970
+		if (!$this->cached_holidays)
1971
+		{
1972
+			// try reading the holidays from the session
1849 1973
 		{
1850 1974
 			$this->cached_holidays = Api\Cache::getSession('calendar', 'holidays');
1851 1975
 		}
1976
+		}
1852 1977
 		if (!isset($this->cached_holidays[$year]))
1853 1978
 		{
1854 1979
 			$this->cached_holidays[$year] = calendar_holidays::read(
@@ -1891,7 +2016,11 @@  discard block
 block discarded – undo
1891 2016
 							continue;
1892 2017
 						}
1893 2018
 						list($y,$m,$d) = explode('-',$pers['bday']);
1894
-						if ($y > $year) continue; 	// not yet born
2019
+						if ($y > $year)
2020
+						{
2021
+							continue;
2022
+						}
2023
+						// not yet born
1895 2024
 						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1896 2025
 							'day'       => $d,
1897 2026
 							'month'     => $m,
@@ -1984,7 +2113,10 @@  discard block
 block discarded – undo
1984 2113
 				}
1985 2114
 			}
1986 2115
 			$str_fields = implode(', ',$extra_fields);
1987
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2116
+			if (is_array($extra_fields))
2117
+			{
2118
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2119
+			}
1988 2120
 		}
1989 2121
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1990 2122
 	}
@@ -2005,7 +2137,8 @@  discard block
 block discarded – undo
2005 2137
 			'offset' =>	$options['start'],
2006 2138
 			'order' => 'cal_start DESC',
2007 2139
 		);
2008
-		if($options['num_rows']) {
2140
+		if($options['num_rows'])
2141
+		{
2009 2142
 			$query['num_rows'] = $options['num_rows'];
2010 2143
 		}
2011 2144
 		foreach((array) $this->search($query) as $event)
@@ -2066,7 +2199,10 @@  discard block
 block discarded – undo
2066 2199
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2067 2200
 			{
2068 2201
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2069
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2202
+				if ($type == 'forced')
2203
+				{
2204
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2205
+				}
2070 2206
 				$this->cal_prefs[$var] = $default;
2071 2207
 				$need_save = True;
2072 2208
 			}
@@ -2086,7 +2222,10 @@  discard block
 block discarded – undo
2086 2222
 	 */
2087 2223
 	static function freebusy_url($user='',$pw=null)
2088 2224
 	{
2089
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2225
+		if (is_numeric($user))
2226
+		{
2227
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2228
+		}
2090 2229
 
2091 2230
 		$credentials = '';
2092 2231
 
@@ -2154,13 +2293,19 @@  discard block
 block discarded – undo
2154 2293
 	 */
2155 2294
 	public function get_ctag($user, $filter='owner', $master_only=false)
2156 2295
 	{
2157
-		if ($this->debug > 1) $startime = microtime(true);
2296
+		if ($this->debug > 1)
2297
+		{
2298
+			$startime = microtime(true);
2299
+		}
2158 2300
 
2159 2301
 		// resolve users to add memberships for users and members for groups
2160 2302
 		$users = $this->resolve_users($user);
2161 2303
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2162 2304
 
2163
-		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");
2305
+		if ($this->debug > 1)
2306
+		{
2307
+			error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2308
+		}
2164 2309
 		return $ctag;
2165 2310
 	}
2166 2311
 
@@ -2202,15 +2347,21 @@  discard block
 block discarded – undo
2202 2347
 				$content['link_app'][] = $link['app'];
2203 2348
 				$content['link_id'][]  = $link['id'];
2204 2349
 			}
2205
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2350
+			if ($link['app'] == 'addressbook')
2351
+			{
2352
+				// prefering contact as primary contact over calendar entry set above
2206 2353
 			{
2207 2354
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2208 2355
 			}
2356
+			}
2209 2357
 		}
2210 2358
 		// Copy same custom fields
2211 2359
 		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2212 2360
 		{
2213
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2361
+			if ($this->customfields[$name])
2362
+			{
2363
+				$content['#'.$name] = $calendar['#'.$name];
2364
+			}
2214 2365
 		}
2215 2366
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2216 2367
 		return $content;
@@ -2233,7 +2384,11 @@  discard block
 block discarded – undo
2233 2384
 			$set['ts_title'] = $this->link_title($event);
2234 2385
 			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2235 2386
 			$set['ts_description'] = $event['description'];
2236
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2387
+			if ($this->isWholeDay($event))
2388
+			{
2389
+				$event['end']++;
2390
+			}
2391
+			// whole day events are 1sec short
2237 2392
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2238 2393
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2239 2394
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.
calendar/inc/class.calendar_boupdate.inc.php 5 patches
Doc Comments   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -519,6 +519,7 @@  discard block
 block discarded – undo
519 519
 	 * @param array $new_event Event after the change
520 520
 	 * @param string $role we treat CHAIR like event owners
521 521
 	 * @param string $status of current user
522
+	 * @param integer $msg_type
522 523
 	 * @return boolean true = update requested, false otherwise
523 524
 	 */
524 525
 	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
@@ -594,7 +595,7 @@  discard block
 block discarded – undo
594 595
 	/**
595 596
 	 * Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified
596 597
 	 *
597
-	 * @param int|string $user_or_email
598
+	 * @param string $user_or_email
598 599
 	 * @param string $ical_method ='REQUEST'
599 600
 	 * @param string $role ='REQ-PARTICIPANT'
600 601
 	 * @return boolean true if user requested to be notified, false if not
@@ -645,8 +646,7 @@  discard block
 block discarded – undo
645 646
 	 * Get iCal/iMip method from internal nummeric msg-type plus optional notification message and verbose name
646 647
 	 *
647 648
 	 * @param int $msg_type see MSG_* defines
648
-	 * @param string& $action=null on return verbose name
649
-	 * @param string& $msg=null on return notification message
649
+	 * @param string& $action on return verbose name
650 650
 	 */
651 651
 	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
652 652
 	{
@@ -1011,6 +1011,9 @@  discard block
 block discarded – undo
1011 1011
 		return true;
1012 1012
 	}
1013 1013
 
1014
+	/**
1015
+	 * @param integer $added
1016
+	 */
1014 1017
 	function get_update_message($event,$added)
1015 1018
 	{
1016 1019
 		$nul = null;
@@ -1300,8 +1303,8 @@  discard block
 block discarded – undo
1300 1303
 	 *
1301 1304
 	 * @param int $right self::CAT_ACL_{ADD|STATUS}
1302 1305
 	 * @param int|array $event
1303
-	 * @return boolean true if use has the right, false if not
1304
-	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1306
+	 * @return null|boolean true if use has the right, false if not
1307
+	 * @return null|boolean false=access denied because of cat acl, true access granted because of cat acl,
1305 1308
 	 * 	null = cat has no acl
1306 1309
 	 */
1307 1310
 	function check_cat_acl($right,$event)
@@ -1386,6 +1389,8 @@  discard block
 block discarded – undo
1386 1389
 	 * Check if current user has a given right on a category (if it's restricted!)
1387 1390
 	 *
1388 1391
 	 * @param int $cat_id
1392
+	 * @param integer $right
1393
+	 * @param integer $user
1389 1394
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1390 1395
 	 * 	null = cat has no acl
1391 1396
 	 */
@@ -1647,7 +1652,7 @@  discard block
 block discarded – undo
1647 1652
 	 * @param string $action
1648 1653
 	 * @param array $event_arr
1649 1654
 	 * @param array $disinvited
1650
-	 * @return array
1655
+	 * @return string
1651 1656
 	 */
1652 1657
 	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1653 1658
 	{
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1504,22 +1504,22 @@  discard block
 block discarded – undo
1504 1504
 		// check the old list against the new list
1505 1505
 		foreach ($old_event['participants'] as $userid => $status)
1506 1506
   		{
1507
-            if (!isset($new_event['participants'][$userid])){
1508
-            	// Attendee will be deleted this way
1509
-            	$new_event['participants'][$userid] = 'G';
1510
-            }
1511
-            elseif ($new_event['participants'][$userid] == $status)
1512
-            {
1513
-            	// Same status -- nothing to do.
1514
-            	unset($new_event['participants'][$userid]);
1515
-            }
1507
+			if (!isset($new_event['participants'][$userid])){
1508
+				// Attendee will be deleted this way
1509
+				$new_event['participants'][$userid] = 'G';
1510
+			}
1511
+			elseif ($new_event['participants'][$userid] == $status)
1512
+			{
1513
+				// Same status -- nothing to do.
1514
+				unset($new_event['participants'][$userid]);
1515
+			}
1516 1516
 		}
1517 1517
 		// write the changes
1518 1518
 		foreach ($new_event['participants'] as $userid => $status)
1519 1519
 		{
1520 1520
 			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1521 1521
 		}
1522
-    }
1522
+	}
1523 1523
 
1524 1524
 	/**
1525 1525
 	 * deletes an event
@@ -2493,24 +2493,24 @@  discard block
 block discarded – undo
2493 2493
 	/**
2494 2494
 	 * classifies an incoming event from the eGW point-of-view
2495 2495
 	 *
2496
-     * exceptions: unlike other calendar apps eGW does not create an event exception
2497
-     * if just the participant state changes - therefore we have to distinguish between
2498
-     * real exceptions and status only exceptions
2499
-     *
2500
-     * @param array $event the event to check
2501
-     *
2502
-     * @return array
2503
-     * 	type =>
2504
-     * 		SINGLE a single event
2505
-     * 		SERIES-MASTER the series master
2506
-     * 		SERIES-EXCEPTION event is a real exception
2507
-	  * 		SERIES-PSEUDO-EXCEPTION event is a status only exception
2508
-	  * 		SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception
2509
-	  * 	stored_event => if event already exists in the database array with event data or false
2510
-	  * 	master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE
2511
-	  * 		the corresponding series master event array
2512
-	  * 		NOTE: this param is false if event is of type SERIES-MASTER
2513
-     */
2496
+	 * exceptions: unlike other calendar apps eGW does not create an event exception
2497
+	 * if just the participant state changes - therefore we have to distinguish between
2498
+	 * real exceptions and status only exceptions
2499
+	 *
2500
+	 * @param array $event the event to check
2501
+	 *
2502
+	 * @return array
2503
+	 * 	type =>
2504
+	 * 		SINGLE a single event
2505
+	 * 		SERIES-MASTER the series master
2506
+	 * 		SERIES-EXCEPTION event is a real exception
2507
+	 * 		SERIES-PSEUDO-EXCEPTION event is a status only exception
2508
+	 * 		SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception
2509
+	 * 	stored_event => if event already exists in the database array with event data or false
2510
+	 * 	master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE
2511
+	 * 		the corresponding series master event array
2512
+	 * 		NOTE: this param is false if event is of type SERIES-MASTER
2513
+	 */
2514 2514
 	function get_event_info($event)
2515 2515
 	{
2516 2516
 		$type = 'SINGLE'; // default
@@ -2681,16 +2681,16 @@  discard block
 block discarded – undo
2681 2681
 			'stored_event' => $stored_event,
2682 2682
 			'master_event' => $master_event,
2683 2683
 		);
2684
-    }
2685
-
2686
-    /**
2687
-     * Translates all timestamps for a given event from server-time to user-time.
2688
-     * The update() and save() methods expect timestamps in user-time.
2689
-     * @param &$event	the event we are working on
2690
-     *
2691
-     */
2692
-    function server2usertime (&$event)
2693
-    {
2684
+	}
2685
+
2686
+	/**
2687
+	 * Translates all timestamps for a given event from server-time to user-time.
2688
+	 * The update() and save() methods expect timestamps in user-time.
2689
+	 * @param &$event	the event we are working on
2690
+	 *
2691
+	 */
2692
+	function server2usertime (&$event)
2693
+	{
2694 2694
 		// we run all dates through date2usertime, to adjust to user-time
2695 2695
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2696 2696
 		{
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2714 2714
 			}
2715 2715
 		}
2716
-    }
2716
+	}
2717 2717
 	/**
2718 2718
 	 * Delete events that are more than $age years old
2719 2719
 	 *
Please login to merge, or discard this patch.
Upper-Lower-Casing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1708,12 +1708,12 @@  discard block
 block discarded – undo
1708 1708
 	 */
1709 1709
 	function event2array($event)
1710 1710
 	{
1711
-		$var['title'] = Array(
1711
+		$var['title'] = array(
1712 1712
 			'field'		=> lang('Title'),
1713 1713
 			'data'		=> $event['title']
1714 1714
 		);
1715 1715
 
1716
-		$var['description'] = Array(
1716
+		$var['description'] = array(
1717 1717
 			'field'	=> lang('Description'),
1718 1718
 			'data'	=> $event['description']
1719 1719
 		);
@@ -1722,48 +1722,48 @@  discard block
 block discarded – undo
1722 1722
 		{
1723 1723
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1724 1724
 		}
1725
-		$var['category'] = Array(
1725
+		$var['category'] = array(
1726 1726
 			'field'	=> lang('Category'),
1727 1727
 			'data'	=> implode(', ',$cat_string)
1728 1728
 		);
1729 1729
 
1730
-		$var['location'] = Array(
1730
+		$var['location'] = array(
1731 1731
 			'field'	=> lang('Location'),
1732 1732
 			'data'	=> $event['location']
1733 1733
 		);
1734 1734
 
1735
-		$var['startdate'] = Array(
1735
+		$var['startdate'] = array(
1736 1736
 			'field'	=> lang('Start Date/Time'),
1737 1737
 			'data'	=> $this->format_date($event['start']),
1738 1738
 		);
1739 1739
 
1740
-		$var['enddate'] = Array(
1740
+		$var['enddate'] = array(
1741 1741
 			'field'	=> lang('End Date/Time'),
1742 1742
 			'data'	=> $this->format_date($event['end']),
1743 1743
 		);
1744 1744
 
1745
-		$pri = Array(
1745
+		$pri = array(
1746 1746
 			0   => lang('None'),
1747 1747
 			1	=> lang('Low'),
1748 1748
 			2	=> lang('Normal'),
1749 1749
 			3	=> lang('High')
1750 1750
 		);
1751
-		$var['priority'] = Array(
1751
+		$var['priority'] = array(
1752 1752
 			'field'	=> lang('Priority'),
1753 1753
 			'data'	=> $pri[$event['priority']]
1754 1754
 		);
1755 1755
 
1756
-		$var['owner'] = Array(
1756
+		$var['owner'] = array(
1757 1757
 			'field'	=> lang('Owner'),
1758 1758
 			'data'	=> Api\Accounts::username($event['owner'])
1759 1759
 		);
1760 1760
 
1761
-		$var['updated'] = Array(
1761
+		$var['updated'] = array(
1762 1762
 			'field'	=> lang('Updated'),
1763 1763
 			'data'	=> $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier'])
1764 1764
 		);
1765 1765
 
1766
-		$var['access'] = Array(
1766
+		$var['access'] = array(
1767 1767
 			'field'	=> lang('Access'),
1768 1768
 			'data'	=> $event['public'] ? lang('Public') : lang('Private')
1769 1769
 		);
@@ -1772,13 +1772,13 @@  discard block
 block discarded – undo
1772 1772
 		{
1773 1773
 			$participants = $this->participants($event,true);
1774 1774
 		}
1775
-		$var['participants'] = Array(
1775
+		$var['participants'] = array(
1776 1776
 			'field'	=> lang('Participants'),
1777 1777
 			'data'	=> $participants
1778 1778
 		);
1779 1779
 
1780 1780
 		// Repeated Events
1781
-		$var['recur_type'] = Array(
1781
+		$var['recur_type'] = array(
1782 1782
 			'field'	=> lang('Repetition'),
1783 1783
 			'data'	=> ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '',
1784 1784
 		);
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 	 * @param Api\DateTime $instance_date For recurring events, this is the date we
1829 1829
 	 *	are dealing with
1830 1830
 	 */
1831
-	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1831
+	function check_move_alarms(array &$event, array $old_event = null, Api\DateTime $instance_date = null)
1832 1832
 	{
1833 1833
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1834 1834
 
Please login to merge, or discard this patch.
Spacing   +302 added lines, -304 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 use EGroupware\Api\Acl;
17 17
 
18 18
 // types of messsages send by calendar_boupdate::send_update
19
-define('MSG_DELETED',0);
20
-define('MSG_MODIFIED',1);
21
-define('MSG_ADDED',2);
22
-define('MSG_REJECTED',3);
23
-define('MSG_TENTATIVE',4);
24
-define('MSG_ACCEPTED',5);
25
-define('MSG_ALARM',6);
26
-define('MSG_DISINVITE',7);
27
-define('MSG_DELEGATED',8);
19
+define('MSG_DELETED', 0);
20
+define('MSG_MODIFIED', 1);
21
+define('MSG_ADDED', 2);
22
+define('MSG_REJECTED', 3);
23
+define('MSG_TENTATIVE', 4);
24
+define('MSG_ACCEPTED', 5);
25
+define('MSG_ALARM', 6);
26
+define('MSG_DISINVITE', 7);
27
+define('MSG_DELEGATED', 8);
28 28
 
29 29
 /**
30 30
  * Class to access AND manipulate all calendar data (business object)
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True);
89 89
 
90
-		parent::__construct();	// calling the parent constructor
90
+		parent::__construct(); // calling the parent constructor
91 91
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
92
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True);
93 93
 	}
94 94
 
95 95
 	/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * +      + +  C   +	which is clearly wrong for everything with a maximum quantity > 1
117 117
 	 * ++++++++ ++++++++
118 118
 	 */
119
-	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
119
+	function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
120 120
 	{
121 121
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
122 122
 		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		if ($this->debug > 1 || $this->debug == 'update')
125 125
 		{
126 126
 			$this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)',
127
-				false,$event,$ignore_conflicts,$touch_modified,$ignore_acl);
127
+				false, $event, $ignore_conflicts, $touch_modified, $ignore_acl);
128 128
 		}
129 129
 		// check some minimum requirements:
130 130
 		// - new events need start, end and title
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 		}
153 153
 
154 154
 		// check if user has the permission to update / create the event
155
-		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) ||
156
-			$new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) &&
157
-			!$this->check_perms(Acl::ADD,0,$event['owner']))
155
+		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) ||
156
+			$new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) &&
157
+			!$this->check_perms(Acl::ADD, 0, $event['owner']))
158 158
 		{
159
-			$messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner']));
159
+			$messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner']));
160 160
 			return false;
161 161
 		}
162 162
 		if ($new_event)
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 		else
167 167
 		{
168
-			$old_event = $this->read((int)$event['id'],null,$ignore_acl);
168
+			$old_event = $this->read((int)$event['id'], null, $ignore_acl);
169 169
 		}
170 170
 
171 171
 		// do we need to check, if user is allowed to invite the invited participants
172
-		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event)))
172
+		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event)))
173 173
 		{
174 174
 			// report removed participants back to user
175
-			foreach($removed as $key => $account_id)
175
+			foreach ($removed as $key => $account_id)
176 176
 			{
177 177
 				$removed[$key] = $this->participant_name($account_id);
178 178
 			}
179
-			$messages[] = lang('%1 participants removed because of missing invite grants',count($removed)).
180
-				': '.implode(', ',$removed);
179
+			$messages[] = lang('%1 participants removed because of missing invite grants', count($removed)).
180
+				': '.implode(', ', $removed);
181 181
 		}
182 182
 		// check category based ACL
183 183
 		if ($event['category'])
184 184
 		{
185
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
185
+			if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']);
186 186
 			if (!$old_event || !isset($old_event['category']))
187 187
 			{
188 188
 				$old_event['category'] = array();
@@ -191,38 +191,38 @@  discard block
 block discarded – undo
191 191
 			{
192 192
 				$old_event['category'] = explode(',', $old_event['category']);
193 193
 			}
194
-			foreach($event['category'] as $key => $cat_id)
194
+			foreach ($event['category'] as $key => $cat_id)
195 195
 			{
196 196
 				// check if user is allowed to update event categories
197
-				if ((!$old_event || !in_array($cat_id,$old_event['category'])) &&
198
-					self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false)
197
+				if ((!$old_event || !in_array($cat_id, $old_event['category'])) &&
198
+					self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false)
199 199
 				{
200 200
 					unset($event['category'][$key]);
201 201
 					// report removed category to user
202 202
 					$removed_cats[$cat_id] = $this->categories->id2name($cat_id);
203
-					continue;	// no further check, as cat was removed
203
+					continue; // no further check, as cat was removed
204 204
 				}
205 205
 				// for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown
206 206
 				if (!$status_reset_to_unknown &&
207
-					self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false &&
207
+					self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false &&
208 208
 					(!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end']))
209 209
 				{
210
-					foreach((array)$event['participants'] as $uid => $status)
210
+					foreach ((array)$event['participants'] as $uid => $status)
211 211
 					{
212 212
 						$q = $r = null;
213
-						calendar_so::split_status($status,$q,$r);
213
+						calendar_so::split_status($status, $q, $r);
214 214
 						if ($status != 'U')
215 215
 						{
216
-							$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
216
+							$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
217 217
 							// todo: report reset status to user
218 218
 						}
219 219
 					}
220
-					$status_reset_to_unknown = true;	// once is enough
220
+					$status_reset_to_unknown = true; // once is enough
221 221
 				}
222 222
 			}
223 223
 			if ($removed_cats)
224 224
 			{
225
-				$messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats));
225
+				$messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats));
226 226
 			}
227 227
 			if ($status_reset_to_unknown)
228 228
 			{
@@ -252,33 +252,33 @@  discard block
 block discarded – undo
252 252
 			return $cal_id;
253 253
 		}
254 254
 
255
-		$event = $this->read($cal_id);	// we re-read the event, in case only partial information was update and we need the full info for the notifies
255
+		$event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies
256 256
 		//echo "new $cal_id="; _debug_array($event);
257 257
 
258
-		if($old_event['deleted'] && $event['deleted'] == null)
258
+		if ($old_event['deleted'] && $event['deleted'] == null)
259 259
 		{
260 260
 			// Restored, bring back links
261 261
 			Link::restore('calendar', $cal_id);
262 262
 		}
263 263
 		if ($this->log_file)
264 264
 		{
265
-			$this->log2file($event2save,$event,$old_event);
265
+			$this->log2file($event2save, $event, $old_event);
266 266
 		}
267 267
 		// send notifications
268
-		if(!$skip_notification)
268
+		if (!$skip_notification)
269 269
 		{
270 270
 			if ($new_event)
271 271
 			{
272
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
272
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
273 273
 			}
274 274
 			else // update existing event
275 275
 			{
276
-				$this->check4update($event,$old_event);
276
+				$this->check4update($event, $old_event);
277 277
 			}
278 278
 		}
279 279
 
280 280
 		// notify the link-class about the update, as other apps may be subscribt to it
281
-		Link::notify_update('calendar',$cal_id,$event);
281
+		Link::notify_update('calendar', $cal_id, $event);
282 282
 
283 283
 		return $cal_id;
284 284
 	}
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
 	 * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked
297 297
 	 * @return array or events
298 298
 	 */
299
-	function conflicts(array $event, &$checked_excluding=null)
299
+	function conflicts(array $event, &$checked_excluding = null)
300 300
 	{
301 301
 		$types_with_quantity = array();
302
-		foreach($this->resources as $type => $data)
302
+		foreach ($this->resources as $type => $data)
303 303
 		{
304 304
 			if ($data['max_quantity']) $types_with_quantity[] = $type;
305 305
 		}
306 306
 		// get all NOT rejected participants and evtl. their quantity
307 307
 		$quantity = $users = array();
308
-		foreach($event['participants'] as $uid => $status)
308
+		foreach ($event['participants'] as $uid => $status)
309 309
 		{
310 310
 			$q = $r = null;
311
-			calendar_so::split_status($status,$q,$r);
312
-			if ($status[0] == 'R') continue;	// ignore rejected participants
311
+			calendar_so::split_status($status, $q, $r);
312
+			if ($status[0] == 'R') continue; // ignore rejected participants
313 313
 
314 314
 			if ($uid < 0)	// group, check it's members too
315 315
 			{
316
-				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
316
+				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true)));
317 317
 			}
318 318
 			$users[] = $uid;
319
-			if (in_array($uid[0],$types_with_quantity))
319
+			if (in_array($uid[0], $types_with_quantity))
320 320
 			{
321 321
 				$quantity[$uid] = $q;
322 322
 			}
@@ -339,58 +339,58 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 		$checked = 0;
341 341
 		$start = microtime(true);
342
-		$duration = $event['end']-$event['start'];
343
-		foreach($recurences as $date)
342
+		$duration = $event['end'] - $event['start'];
343
+		foreach ($recurences as $date)
344 344
 		{
345 345
 			$startts = $date->format('ts');
346 346
 
347 347
 			// skip past events or recurrences
348
-			if ($startts+$duration < $this->now_su) continue;
348
+			if ($startts + $duration < $this->now_su) continue;
349 349
 
350 350
 			// abort check if configured limits are exceeded
351 351
 			if ($event['recur_type'] &&
352 352
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
353
-				microtime(true) > $start+$max_check_time ||	// max check time exceeded
353
+				microtime(true) > $start + $max_check_time || // max check time exceeded
354 354
 				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
355 355
 			{
356 356
 				if ($this->debug > 2 || $this->debug == 'conflicts')
357 357
 				{
358 358
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
359
-						$checked, microtime(true)-$start, $date);
359
+						$checked, microtime(true) - $start, $date);
360 360
 				}
361 361
 				$checked_excluding = $date;
362 362
 				break;
363 363
 			}
364
-			$overlapping_events =& $this->search(array(
364
+			$overlapping_events = & $this->search(array(
365 365
 				'start' => $startts,
366
-				'end'   => $startts+$duration,
366
+				'end'   => $startts + $duration,
367 367
 				'users' => $users,
368
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
369
-				'enum_groups' => true,	// otherwise group-events would not block time
368
+				'ignore_acl' => true, // otherwise we get only events readable by the user
369
+				'enum_groups' => true, // otherwise group-events would not block time
370 370
 				'query' => array(
371 371
 					'cal_non_blocking' => 0,
372 372
 				),
373
-				'no_integration' => true,	// do NOT use integration of other apps
373
+				'no_integration' => true, // do NOT use integration of other apps
374 374
 			));
375 375
 			if ($this->debug > 2 || $this->debug == 'conflicts')
376 376
 			{
377
-				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration);
377
+				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration);
378 378
 			}
379
-			foreach((array) $overlapping_events as $k => $overlap)
379
+			foreach ((array)$overlapping_events as $k => $overlap)
380 380
 			{
381
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
382
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
381
+				if ($overlap['id'] == $event['id'] || // that's the event itself
382
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
383 383
 					$overlap['non_blocking'])			// that's a non_blocking event
384 384
 				{
385 385
 					continue;
386 386
 				}
387 387
 				if ($this->debug > 3 || $this->debug == 'conflicts')
388 388
 				{
389
-					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
389
+					$this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap);
390 390
 				}
391 391
 				// check if the overlap is with a rejected participant or within the allowed quantity
392
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
393
-				foreach($common_parts as $n => $uid)
392
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
393
+				foreach ($common_parts as $n => $uid)
394 394
 				{
395 395
 					$status = $overlap['participants'][$uid];
396 396
 					calendar_so::split_status($status, $q, $r);
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 						unset($common_parts[$n]);
400 400
 						continue;
401 401
 					}
402
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
402
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
403 403
 					{
404
-						continue;	// no quantity check: quantity allways 1 ==> conflict
404
+						continue; // no quantity check: quantity allways 1 ==> conflict
405 405
 					}
406 406
 					if (!isset($max_quantity[$uid]))
407 407
 					{
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 					$quantity[$uid] += $q;
412 412
 					if ($quantity[$uid] <= $max_quantity[$uid])
413 413
 					{
414
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
414
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
415 415
 						unset($common_parts[$n]);
416 416
 						continue;
417 417
 					}
@@ -421,22 +421,22 @@  discard block
 block discarded – undo
421 421
 				{
422 422
 					if ($this->debug > 3 || $this->debug == 'conflicts')
423 423
 					{
424
-						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts);
424
+						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts);
425 425
 					}
426
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
426
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
427 427
 				}
428 428
 			}
429 429
 		}
430 430
 		//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
431 431
 		// check if we are withing the allowed quantity and if not add all events using that resource
432 432
 		// seems this function is doing very strange things, it gives empty conflicts
433
-		foreach($max_quantity as $uid => $max)
433
+		foreach ($max_quantity as $uid => $max)
434 434
 		{
435 435
 			if ($quantity[$uid] > $max)
436 436
 			{
437
-				foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
437
+				foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
438 438
 				{
439
-					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
439
+					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
440 440
 				}
441 441
 			}
442 442
 		}
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
 
445 445
 		if (count($conflicts))
446 446
 		{
447
-			foreach($conflicts as $key => $conflict)
447
+			foreach ($conflicts as $key => $conflict)
448 448
 			{
449
-					$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
450
-				if (!$this->check_perms(Acl::READ,$conflict))
449
+					$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
450
+				if (!$this->check_perms(Acl::READ, $conflict))
451 451
 				{
452 452
 					$conflicts[$key] = array(
453 453
 						'id'    => $conflict['id'],
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 			}
461 461
 			if ($this->debug > 2 || $this->debug == 'conflicts')
462 462
 			{
463
-				$this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts);
463
+				$this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts);
464 464
 			}
465 465
 		}
466 466
 		return $conflicts;
@@ -472,22 +472,22 @@  discard block
 block discarded – undo
472 472
 	 * @param array $old_event =null old event with already invited participants
473 473
 	 * @return array removed participants because of missing invite grants
474 474
 	 */
475
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
475
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
476 476
 	{
477 477
 		if (!$this->require_acl_invite)
478 478
 		{
479
-			return array();	// nothing to check, everyone can invite everyone else
479
+			return array(); // nothing to check, everyone can invite everyone else
480 480
 		}
481 481
 		if ($event['id'] && is_null($old_event))
482 482
 		{
483 483
 			$old_event = $this->read($event['id']);
484 484
 		}
485 485
 		$removed = array();
486
-		foreach(array_keys((array)$event['participants']) as $uid)
486
+		foreach (array_keys((array)$event['participants']) as $uid)
487 487
 		{
488 488
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
489 489
 			{
490
-				unset($event['participants'][$uid]);	// remove participant
490
+				unset($event['participants'][$uid]); // remove participant
491 491
 				$removed[] = $uid;
492 492
 			}
493 493
 		}
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	public function check_acl_invite($uid)
505 505
 	{
506
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
506
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
507 507
 
508 508
 		if (!$this->require_acl_invite)
509 509
 		{
510
-			$ret = true;	// no grant required
510
+			$ret = true; // no grant required
511 511
 		}
512 512
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
513 513
 		{
514
-			$ret = true;	// grant only required for groups
514
+			$ret = true; // grant only required for groups
515 515
 		}
516 516
 		else
517 517
 		{
518
-			$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
518
+			$ret = $this->check_perms(self::ACL_INVITE, 0, $uid);
519 519
 		}
520 520
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
521 521
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	 * @param array $old_event the event before the update
530 530
 	 * @todo check if there is a real change, not assume every save is a change
531 531
 	 */
532
-	function check4update($new_event,$old_event)
532
+	function check4update($new_event, $old_event)
533 533
 	{
534 534
 		//error_log(__METHOD__."($new_event[title])");
535 535
 		$modified = $added = $deleted = array();
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
538 538
 
539 539
 		// Find modified and deleted participants ...
540
-		foreach($old_event['participants'] as $old_userid => $old_status)
540
+		foreach ($old_event['participants'] as $old_userid => $old_status)
541 541
 		{
542
-			if(isset($new_event['participants'][$old_userid]))
542
+			if (isset($new_event['participants'][$old_userid]))
543 543
 			{
544 544
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
545 545
 			}
@@ -549,27 +549,27 @@  discard block
 block discarded – undo
549 549
 			}
550 550
 		}
551 551
 		// Find new participants ...
552
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
552
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
553 553
 		{
554
-			if(!isset($old_event['participants'][$new_userid]))
554
+			if (!isset($old_event['participants'][$new_userid]))
555 555
 			{
556 556
 				$added[$new_userid] = 'U';
557 557
 			}
558 558
 		}
559 559
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
560
-		if(count($added) || count($modified) || count($deleted))
560
+		if (count($added) || count($modified) || count($deleted))
561 561
 		{
562
-			if(count($added))
562
+			if (count($added))
563 563
 			{
564
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
564
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
565 565
 			}
566
-			if(count($modified))
566
+			if (count($modified))
567 567
 			{
568
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
568
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
569 569
 			}
570
-			if(count($deleted))
570
+			if (count($deleted))
571 571
 			{
572
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
572
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
573 573
 			}
574 574
 		}
575 575
 	}
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
 	 * @param string $status of current user
587 587
 	 * @return boolean true = update requested, false otherwise
588 588
 	 */
589
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
589
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
590 590
 	{
591 591
 		if ($msg_type == MSG_ALARM)
592 592
 		{
593
-			return True;	// always True for now
593
+			return True; // always True for now
594 594
 		}
595 595
 		$want_update = 0;
596 596
 
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 		//
599 599
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
600 600
 
601
-		switch($ru = $part_prefs['calendar']['receive_updates'])
601
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
602 602
 		{
603 603
 			case 'responses':
604 604
 				++$want_update;
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 			default:
613 613
 				if (is_array($new_event) && is_array($old_event))
614 614
 				{
615
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
616
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
615
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
616
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
617 617
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
618 618
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
619 619
 					{
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
634 634
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
635 635
 				{
636
-					switch($msg_type)
636
+					switch ($msg_type)
637 637
 					{
638 638
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
639 639
 							$msg_type = MSG_REJECTED;
640 640
 							break;
641 641
 						case MSG_ADDED:		// new events use added, but organizer needs status
642
-							switch($status[0])
642
+							switch ($status[0])
643 643
 							{
644 644
 								case 'A': $msg_type = MSG_ACCEPTED; break;
645 645
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	 * @param string $role ='REQ-PARTICIPANT'
665 665
 	 * @return boolean true if user requested to be notified, false if not
666 666
 	 */
667
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
667
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
668 668
 	{
669 669
 		// check if email is from a user
670 670
 		if (is_numeric($user_or_email))
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 				)
689 689
 			);
690 690
 		}
691
-		switch($ical_method)
691
+		switch ($ical_method)
692 692
 		{
693 693
 			default:
694 694
 			case 'REQUEST':
@@ -713,9 +713,9 @@  discard block
 block discarded – undo
713 713
 	 * @param string& $action=null on return verbose name
714 714
 	 * @param string& $msg=null on return notification message
715 715
 	 */
716
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
716
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
717 717
 	{
718
-		switch($msg_type)
718
+		switch ($msg_type)
719 719
 		{
720 720
 			case MSG_DELETED:
721 721
 				$action = 'Canceled';
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		$msg = $this->cal_prefs['notify'.$pref];
768 768
 		if (empty($msg))
769 769
 		{
770
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
770
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
771 771
 		}
772 772
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
773 773
 		return $method;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @param int $user =0 User who started the notify, default current user
784 784
 	 * @return bool true/false
785 785
 	 */
786
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
786
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
787 787
 	{
788 788
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
789 789
 		if (!is_array($to_notify))
@@ -795,11 +795,11 @@  discard block
 block discarded – undo
795 795
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
796 796
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
797 797
 		{
798
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
798
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
799 799
 		}
800 800
 
801 801
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
802
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
802
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
803 803
 		{
804 804
 			return False;
805 805
 		}
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 			$restore_tz = $tz;
810 810
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
811 811
 		}
812
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
812
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
813 813
 
814 814
 		if (!$user)
815 815
 		{
@@ -825,16 +825,16 @@  discard block
 block discarded – undo
825 825
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
826 826
 
827 827
 		// add all group-members to the notification, unless they are already participants
828
-		foreach($to_notify as $userid => $statusid)
828
+		foreach ($to_notify as $userid => $statusid)
829 829
 		{
830 830
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
831 831
 				($members = $GLOBALS['egw']->accounts->members($userid, true)))
832 832
 			{
833
-				foreach($members as $member)
833
+				foreach ($members as $member)
834 834
 				{
835 835
 					if (!isset($to_notify[$member]))
836 836
 					{
837
-						$to_notify[$member] = 'G';	// Group-invitation
837
+						$to_notify[$member] = 'G'; // Group-invitation
838 838
 					}
839 839
 				}
840 840
 			}
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
847 847
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
848 848
 		$owner_prefs = $ics = null;
849
-		foreach($to_notify as $userid => $statusid)
849
+		foreach ($to_notify as $userid => $statusid)
850 850
 		{
851 851
 			$res_info = $quantity = $role = null;
852 852
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -869,14 +869,14 @@  discard block
 block discarded – undo
869 869
 
870 870
 				if (!isset($userid))
871 871
 				{
872
-					if (empty($res_info['email'])) continue;	// no way to notify
872
+					if (empty($res_info['email'])) continue; // no way to notify
873 873
 					// check if event-owner wants non-EGroupware users notified
874 874
 					if (is_null($owner_prefs))
875 875
 					{
876 876
 						$preferences = new Api\Preferences($owner);
877 877
 						$owner_prefs = $preferences->read_repository();
878 878
 					}
879
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
879
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
880 880
 						(empty($owner_prefs['calendar']['notify_externals']) ||
881 881
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
882 882
 					{
@@ -888,12 +888,12 @@  discard block
 block discarded – undo
888 888
 
889 889
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
890 890
 			{
891
-				continue;	// dont notify rejected participants or groups
891
+				continue; // dont notify rejected participants or groups
892 892
 			}
893 893
 
894
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
894
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
895 895
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
896
-					$user_prefs['calendar']['receive_own_updates']==1) ||
896
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
897 897
 				$msg_type == MSG_ALARM)
898 898
 			{
899 899
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 					}
913 913
 					$part_prefs = $owner_prefs;
914 914
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
915
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
915
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
916 916
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
917 917
 				}
918 918
 				$m_type = $msg_type;
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
941 941
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
942 942
 				$timeformat = $part_prefs['common']['timeformat'];
943
-				switch($timeformat)
943
+				switch ($timeformat)
944 944
 				{
945 945
 			  		case '24':
946 946
 						$timeformat = 'H:i';
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 						$timeformat = 'h:i a';
950 950
 						break;
951 951
 				}
952
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
952
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
953 953
 
954 954
 				$startdate->setTimezone($timezone);
955 955
 				$details['startdate'] = $startdate->format($timeformat);
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 				$details['enddate'] = $enddate->format($timeformat);
959 959
 
960 960
 				$modified->setTimezone($timezone);
961
-				$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
961
+				$details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']);
962 962
 
963 963
 				if ($old_event != False)
964 964
 				{
@@ -967,15 +967,14 @@  discard block
 block discarded – undo
967 967
 				}
968 968
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
969 969
 
970
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
970
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
971 971
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
972
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
972
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
973 973
 				{
974
-					case 'ical':
975
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
974
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
976 975
 						{
977 976
 							$calendar_ical = new calendar_ical();
978
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
977
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
979 978
 							// we need to pass $event[id] so iCal class reads event again,
980 979
 							// as event is in user TZ, but iCal class expects server TZ!
981 980
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -994,11 +993,11 @@  discard block
 block discarded – undo
994 993
 					case 'extended':
995 994
 
996 995
 						$details_body = lang('Event Details follow').":\n";
997
-						foreach($event_arr as $key => $val)
996
+						foreach ($event_arr as $key => $val)
998 997
 						{
999
-							if(!empty($details[$key]))
998
+							if (!empty($details[$key]))
1000 999
 							{
1001
-								switch($key)
1000
+								switch ($key)
1002 1001
 								{
1003 1002
 							 		case 'access':
1004 1003
 									case 'priority':
@@ -1007,7 +1006,7 @@  discard block
 block discarded – undo
1007 1006
 									case 'title':
1008 1007
 										break;
1009 1008
 									default:
1010
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
1009
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
1011 1010
 										break;
1012 1011
 							 	}
1013 1012
 							}
@@ -1015,7 +1014,7 @@  discard block
 block discarded – undo
1015 1014
 						break;
1016 1015
 				}
1017 1016
 				// send via notification_app
1018
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1017
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1019 1018
 				{
1020 1019
 					try {
1021 1020
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -1039,7 +1038,7 @@  discard block
 block discarded – undo
1039 1038
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1040 1039
 						$notification->set_popuplinks(array($details['link_arr']));
1041 1040
 
1042
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1041
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1043 1042
 						$notification->send();
1044 1043
 					}
1045 1044
 					catch (Exception $exception) {
@@ -1076,14 +1075,14 @@  discard block
 block discarded – undo
1076 1075
 		return true;
1077 1076
 	}
1078 1077
 
1079
-	function get_update_message($event,$added)
1078
+	function get_update_message($event, $added)
1080 1079
 	{
1081 1080
 		$nul = null;
1082
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1081
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1083 1082
 
1084 1083
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1085 1084
 
1086
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1085
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1087 1086
 	}
1088 1087
 
1089 1088
 	/**
@@ -1097,37 +1096,37 @@  discard block
 block discarded – undo
1097 1096
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1098 1097
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1099 1098
 
1100
-		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1101
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1099
+		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1100
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1102 1101
 		{
1103
-			return False;	// event not found
1102
+			return False; // event not found
1104 1103
 		}
1105 1104
 		if ($alarm['all'])
1106 1105
 		{
1107 1106
 			$to_notify = $event['participants'];
1108 1107
 		}
1109
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1108
+		elseif ($this->check_perms(Acl::READ, $event))	// checks agains $this->owner set to $alarm[owner]
1110 1109
 		{
1111 1110
 			$to_notify[$alarm['owner']] = 'A';
1112 1111
 		}
1113 1112
 		else
1114 1113
 		{
1115
-			return False;	// no rights
1114
+			return False; // no rights
1116 1115
 		}
1117 1116
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1118 1117
 		Api\Translation::add_app('calendar');
1119 1118
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1120 1119
 
1121
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1120
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1122 1121
 
1123 1122
 		// create a new alarm for recuring events for the next event, if one exists
1124
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1123
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1125 1124
 		{
1126 1125
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1127 1126
 			unset($alarm['times']);
1128 1127
 			unset($alarm['next']);
1129 1128
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1130
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1129
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1131 1130
 		}
1132 1131
 		return $ret;
1133 1132
 	}
@@ -1143,15 +1142,15 @@  discard block
 block discarded – undo
1143 1142
 	 * DEPRECATED: we allways (have to) update timestamp, as they are required for sync!
1144 1143
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1145 1144
 	 */
1146
-	function save($event,$ignore_acl=false,$updateTS=true)
1145
+	function save($event, $ignore_acl = false, $updateTS = true)
1147 1146
 	{
1148 1147
 		unset($updateTS);
1149 1148
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1150 1149
 
1151 1150
 		// check if user has the permission to update / create the event
1152
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
1153
-			!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
1154
-			!$this->check_perms(Acl::ADD,0,$event['owner'])))
1151
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) ||
1152
+			!$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) &&
1153
+			!$this->check_perms(Acl::ADD, 0, $event['owner'])))
1155 1154
 		{
1156 1155
 			return false;
1157 1156
 		}
@@ -1196,19 +1195,19 @@  discard block
 block discarded – undo
1196 1195
 				$time->setUser();
1197 1196
 				$save_event['recur_enddate'] = Api\DateTime::to($time, 'ts');
1198 1197
 			}
1199
-			$timestamps = array('modified','created');
1198
+			$timestamps = array('modified', 'created');
1200 1199
 			// all-day events are handled in server time
1201 1200
 			$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
1202 1201
 		}
1203 1202
 		else
1204 1203
 		{
1205
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1204
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1206 1205
 		}
1207 1206
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1208
-		foreach($timestamps as $ts)
1207
+		foreach ($timestamps as $ts)
1209 1208
 		{
1210 1209
 			// we convert here from user-time to timestamps in server-time!
1211
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1210
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1212 1211
 		}
1213 1212
 		// convert tzid name to integer tz_id, of set user default
1214 1213
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1218,7 +1217,7 @@  discard block
 block discarded – undo
1218 1217
 		// same with the recur exceptions
1219 1218
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1220 1219
 		{
1221
-			foreach($event['recur_exception'] as &$date)
1220
+			foreach ($event['recur_exception'] as &$date)
1222 1221
 			{
1223 1222
 				if ($event['whole_day'])
1224 1223
 				{
@@ -1227,7 +1226,7 @@  discard block
 block discarded – undo
1227 1226
 				}
1228 1227
 				else
1229 1228
 				{
1230
-					$date = $this->date2ts($date,true);
1229
+					$date = $this->date2ts($date, true);
1231 1230
 				}
1232 1231
 			}
1233 1232
 			unset($date);
@@ -1235,7 +1234,7 @@  discard block
 block discarded – undo
1235 1234
 		// same with the alarms
1236 1235
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1237 1236
 		{
1238
-			foreach($event['alarm'] as $id => &$alarm)
1237
+			foreach ($event['alarm'] as $id => &$alarm)
1239 1238
 			{
1240 1239
 				// remove alarms belonging to not longer existing or rejected participants
1241 1240
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1253,15 +1252,14 @@  discard block
 block discarded – undo
1253 1252
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1254 1253
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1255 1254
 		{
1256
-			foreach($old_event['alarm'] as $id => &$alarm)
1255
+			foreach ($old_event['alarm'] as $id => &$alarm)
1257 1256
 			{
1258 1257
 				if (!isset($event['alarm'][$id]))
1259 1258
 				{
1260 1259
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1261 1260
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1262 1261
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1263
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1264
-						$old_event['participants'][$alarm['owner']];
1262
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1265 1263
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1266 1264
 					{
1267 1265
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1287,7 +1285,7 @@  discard block
 block discarded – undo
1287 1285
 		}
1288 1286
 		$set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] : false;
1289 1287
 		$set_recurrences_start = 0;
1290
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1288
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1291 1289
 		{
1292 1290
 			$save_event['id'] = $cal_id;
1293 1291
 			// unset participants to enforce the default stati for all added recurrences
@@ -1298,7 +1296,7 @@  discard block
 block discarded – undo
1298 1296
 		// create links for new participants from addressbook, if configured
1299 1297
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1300 1298
 		{
1301
-			foreach($event['participants'] as $uid => $status)
1299
+			foreach ($event['participants'] as $uid => $status)
1302 1300
 			{
1303 1301
 				$user_type = $user_id = null;
1304 1302
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1311,7 +1309,7 @@  discard block
 block discarded – undo
1311 1309
 
1312 1310
 		// Update history
1313 1311
 		$tracking = new calendar_tracking($this);
1314
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1312
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1315 1313
 		$tracking->track($event, $old_event);
1316 1314
 
1317 1315
 		return $cal_id;
@@ -1326,16 +1324,16 @@  discard block
 block discarded – undo
1326 1324
 	 * @param array|int $event event array or id of the event
1327 1325
 	 * @return boolean
1328 1326
 	 */
1329
-	function check_status_perms($uid,$event)
1327
+	function check_status_perms($uid, $event)
1330 1328
 	{
1331 1329
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1332 1330
 		{
1333 1331
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1334 1332
 
1335
-			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1333
+			return $this->check_perms(Acl::EDIT, 0, $event['owner']);
1336 1334
 		}
1337 1335
 		// check if we have a category Acl for the event or not (null)
1338
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1336
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1339 1337
 		if (!is_null($access))
1340 1338
 		{
1341 1339
 			return $access;
@@ -1345,17 +1343,17 @@  discard block
 block discarded – undo
1345 1343
 		{
1346 1344
 			$resource = $this->resource_info($uid);
1347 1345
 
1348
-			return Acl::EDIT & $resource['rights'];
1346
+			return Acl::EDIT&$resource['rights'];
1349 1347
 		}
1350 1348
 		if (!is_array($event) && !($event = $this->read($event))) return false;
1351 1349
 
1352 1350
 		// regular user and groups (need to check memberships too)
1353 1351
 		if (!isset($event['participants'][$uid]))
1354 1352
 		{
1355
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1353
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1356 1354
 		}
1357 1355
 		$memberships[] = $uid;
1358
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
1356
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid);
1359 1357
 	}
1360 1358
 
1361 1359
 	/**
@@ -1369,16 +1367,16 @@  discard block
 block discarded – undo
1369 1367
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1370 1368
 	 * 	null = cat has no acl
1371 1369
 	 */
1372
-	function check_cat_acl($right,$event)
1370
+	function check_cat_acl($right, $event)
1373 1371
 	{
1374 1372
 		if (!is_array($event)) $event = $this->read($event);
1375 1373
 
1376 1374
 		$ret = null;
1377 1375
 		if ($event['category'])
1378 1376
 		{
1379
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1377
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1380 1378
 			{
1381
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1379
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1382 1380
 				if ($access === true)
1383 1381
 				{
1384 1382
 					$ret = true;
@@ -1386,7 +1384,7 @@  discard block
 block discarded – undo
1386 1384
 				}
1387 1385
 				if ($access === false)
1388 1386
 				{
1389
-					$ret = false;	// cat denies access --> check further cats
1387
+					$ret = false; // cat denies access --> check further cats
1390 1388
 				}
1391 1389
 			}
1392 1390
 		}
@@ -1407,12 +1405,12 @@  discard block
 block discarded – undo
1407 1405
 	 * @param int $cat_id =null null to return array with all cats
1408 1406
 	 * @return array with account_id => right pairs
1409 1407
 	 */
1410
-	public static function get_cat_rights($cat_id=null)
1408
+	public static function get_cat_rights($cat_id = null)
1411 1409
 	{
1412 1410
 		if (!isset(self::$cat_rights_cache))
1413 1411
 		{
1414
-			self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
1415
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1412
+			self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights',
1413
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1416 1414
 		}
1417 1415
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1418 1416
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1425,7 +1423,7 @@  discard block
 block discarded – undo
1425 1423
 	 * @param int $user
1426 1424
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1427 1425
 	 */
1428
-	public static function set_cat_rights($cat_id,$user,$rights)
1426
+	public static function set_cat_rights($cat_id, $user, $rights)
1429 1427
 	{
1430 1428
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1431 1429
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1435,15 +1433,15 @@  discard block
 block discarded – undo
1435 1433
 			if ($rights)
1436 1434
 			{
1437 1435
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1438
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1436
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1439 1437
 			}
1440 1438
 			else
1441 1439
 			{
1442 1440
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1443 1441
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1444
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1442
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1445 1443
 			}
1446
-			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1444
+			Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1447 1445
 		}
1448 1446
 	}
1449 1447
 
@@ -1454,9 +1452,9 @@  discard block
 block discarded – undo
1454 1452
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1455 1453
 	 * 	null = cat has no acl
1456 1454
 	 */
1457
-	public static function has_cat_right($right,$cat_id,$user)
1455
+	public static function has_cat_right($right, $cat_id, $user)
1458 1456
 	{
1459
-		static $cache=null;
1457
+		static $cache = null;
1460 1458
 
1461 1459
 		if (!isset($cache[$cat_id]))
1462 1460
 		{
@@ -1464,21 +1462,21 @@  discard block
 block discarded – undo
1464 1462
 			$cat_rights = self::get_cat_rights($cat_id);
1465 1463
 			if (!is_null($cat_rights))
1466 1464
 			{
1467
-				static $memberships=null;
1465
+				static $memberships = null;
1468 1466
 				if (is_null($memberships))
1469 1467
 				{
1470
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1468
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1471 1469
 					$memberships[] = $user;
1472 1470
 				}
1473
-				foreach($cat_rights as $uid => $value)
1471
+				foreach ($cat_rights as $uid => $value)
1474 1472
 				{
1475 1473
 					$all |= $value;
1476
-					if (in_array($uid,$memberships)) $own |= $value;
1474
+					if (in_array($uid, $memberships)) $own |= $value;
1477 1475
 				}
1478 1476
 			}
1479
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1477
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1480 1478
 			{
1481
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1479
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1482 1480
 			}
1483 1481
 		}
1484 1482
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1498,13 +1496,13 @@  discard block
 block discarded – undo
1498 1496
 	 * @param boolean $skip_notification =false true: do not send notification messages
1499 1497
 	 * @return int number of changed recurrences
1500 1498
 	 */
1501
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1499
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1502 1500
 	{
1503 1501
 		unset($updateTS);
1504 1502
 
1505 1503
 		$cal_id = is_array($event) ? $event['id'] : $event;
1506 1504
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1507
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1505
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1508 1506
 		{
1509 1507
 			return false;
1510 1508
 		}
@@ -1513,16 +1511,16 @@  discard block
 block discarded – undo
1513 1511
 		if ($this->log)
1514 1512
 		{
1515 1513
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1516
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1514
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1517 1515
 		}
1518 1516
 		$old_event = $this->read($cal_id, $recur_date, false, 'server');
1519
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1520
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1521
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1517
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1518
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1519
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1522 1520
 		{
1523 1521
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1524 1522
 			{
1525
-				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1523
+				foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1526 1524
 				{
1527 1525
 					if ((string)$alarm['owner'] === (string)$uid)
1528 1526
 					{
@@ -1541,8 +1539,8 @@  discard block
 block discarded – undo
1541 1539
 			if (isset($status2msg[$status]) && !$skip_notification)
1542 1540
 			{
1543 1541
 				if (!is_array($event)) $event = $this->read($cal_id);
1544
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1545
-				$this->send_update($status2msg[$status],$event['participants'],$event);
1542
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1543
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1546 1544
 			}
1547 1545
 
1548 1546
 			// Update history
@@ -1562,14 +1560,14 @@  discard block
 block discarded – undo
1562 1560
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1563 1561
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1564 1562
 	 */
1565
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1563
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1566 1564
 	{
1567 1565
 		if (!isset($new_event['participants'])) return;
1568 1566
 
1569 1567
 		// check the old list against the new list
1570 1568
 		foreach ($old_event['participants'] as $userid => $status)
1571 1569
   		{
1572
-            if (!isset($new_event['participants'][$userid])){
1570
+            if (!isset($new_event['participants'][$userid])) {
1573 1571
             	// Attendee will be deleted this way
1574 1572
             	$new_event['participants'][$userid] = 'G';
1575 1573
             }
@@ -1582,7 +1580,7 @@  discard block
 block discarded – undo
1582 1580
 		// write the changes
1583 1581
 		foreach ($new_event['participants'] as $userid => $status)
1584 1582
 		{
1585
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1583
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1586 1584
 		}
1587 1585
     }
1588 1586
 
@@ -1597,43 +1595,43 @@  discard block
 block discarded – undo
1597 1595
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1598 1596
 	 * @return boolean true on success, false on error (usually permission denied)
1599 1597
 	 */
1600
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1601
-		$delete_exceptions=true, &$exceptions_kept=null)
1598
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1599
+		$delete_exceptions = true, &$exceptions_kept = null)
1602 1600
 	{
1603 1601
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1604
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1605
-			!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
1602
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1603
+			!$ignore_acl && !$this->check_perms(Acl::DELETE, $event))
1606 1604
 		{
1607 1605
 			return false;
1608 1606
 		}
1609 1607
 
1610 1608
 		// Don't send notification if the event has already been deleted
1611
-		if(!$event['deleted'] && !$skip_notification)
1609
+		if (!$event['deleted'] && !$skip_notification)
1612 1610
 		{
1613
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1611
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1614 1612
 		}
1615 1613
 
1616 1614
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1617 1615
 		{
1618 1616
 			$config = Api\Config::read('phpgwapi');
1619
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1617
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1620 1618
 			{
1621 1619
 				$this->so->delete($cal_id);
1622 1620
 
1623 1621
 				// delete all links to the event
1624
-				Link::unlink(0,'calendar',$cal_id);
1622
+				Link::unlink(0, 'calendar', $cal_id);
1625 1623
 			}
1626 1624
 			elseif ($config['calendar_delete_history'])
1627 1625
 			{
1628 1626
 				// mark all links to the event as deleted, but keep them
1629
-				Link::unlink(0,'calendar',$cal_id,'','','',true);
1627
+				Link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1630 1628
 
1631 1629
 				$event['deleted'] = $this->now;
1632 1630
 				$this->save($event, $ignore_acl);
1633 1631
 				// Actually delete alarms
1634 1632
 				if (isset($event['alarm']) && is_array($event['alarm']))
1635 1633
 				{
1636
-					foreach($event['alarm'] as $id => $alarm)
1634
+					foreach ($event['alarm'] as $id => $alarm)
1637 1635
 					{
1638 1636
 						$this->delete_alarm($id);
1639 1637
 					}
@@ -1655,7 +1653,7 @@  discard block
 block discarded – undo
1655 1653
 						if (!($exception = $this->read($id))) continue;
1656 1654
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1657 1655
 						$exception['reference'] = $exception['recurrence'] = 0;
1658
-						$this->update($exception, true, true, false, true, $msg=null, true);
1656
+						$this->update($exception, true, true, false, true, $msg = null, true);
1659 1657
 						++$exceptions_kept;
1660 1658
 					}
1661 1659
 				}
@@ -1667,9 +1665,9 @@  discard block
 block discarded – undo
1667 1665
 			if ($event['alarm'])
1668 1666
 			{
1669 1667
 				$next_recurrance = null;
1670
-				foreach($event['alarm'] as &$alarm)
1668
+				foreach ($event['alarm'] as &$alarm)
1671 1669
 				{
1672
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1670
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1673 1671
 					{
1674 1672
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1675 1673
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1677,12 +1675,12 @@  discard block
 block discarded – undo
1677 1675
 						{
1678 1676
 							$checkdate = $recur_date;
1679 1677
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1680
-							if (($e = $this->read($cal_id,$checkdate+1)))
1678
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1681 1679
 							{
1682 1680
 								$next_recurrance = $this->date2ts($e['start']);
1683 1681
 							}
1684 1682
 						}
1685
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1683
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1686 1684
 						$alarm['cal_id'] = $cal_id;
1687 1685
 						unset($alarm['times']);
1688 1686
 						unset($alarm['next']);
@@ -1696,7 +1694,7 @@  discard block
 block discarded – undo
1696 1694
 			$event = $this->read($cal_id);
1697 1695
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1698 1696
 			$event['recur_exception'][] = $recur_date;
1699
-			$this->save($event);// updates the content-history
1697
+			$this->save($event); // updates the content-history
1700 1698
 		}
1701 1699
 		if ($event['reference'])
1702 1700
 		{
@@ -1714,19 +1712,19 @@  discard block
 block discarded – undo
1714 1712
 	 * @param array $disinvited
1715 1713
 	 * @return array
1716 1714
 	 */
1717
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1715
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1718 1716
 	{
1719 1717
 		$details = array(			// event-details for the notify-msg
1720 1718
 			'id'          => $event['id'],
1721 1719
 			'action'      => lang($action),
1722 1720
 		);
1723 1721
 		$event_arr = $this->event2array($event);
1724
-		foreach($event_arr as $key => $val)
1722
+		foreach ($event_arr as $key => $val)
1725 1723
 		{
1726 1724
 			if ($key == 'recur_type') $key = 'repetition';
1727 1725
 			$details[$key] = $val['data'];
1728 1726
 		}
1729
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1727
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1730 1728
 
1731 1729
 		$event_arr['link']['field'] = lang('URL');
1732 1730
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1747,7 +1745,7 @@  discard block
 block discarded – undo
1747 1745
 		 */
1748 1746
 		$link_arr = array();
1749 1747
 		$link_arr['text'] = $event['title'];
1750
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1748
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1751 1749
 									'cal_id' => $event['id'],
1752 1750
 									'date' => $eventStart_arr['full'],
1753 1751
 									);
@@ -1755,11 +1753,11 @@  discard block
 block discarded – undo
1755 1753
 		$details['link_arr'] = $link_arr;
1756 1754
 
1757 1755
 		$dis = array();
1758
-		foreach($disinvited as $uid)
1756
+		foreach ($disinvited as $uid)
1759 1757
 		{
1760 1758
 			$dis[] = $this->participant_name($uid);
1761 1759
 		}
1762
-		$details['disinvited'] = implode(', ',$dis);
1760
+		$details['disinvited'] = implode(', ', $dis);
1763 1761
 		return $details;
1764 1762
 	}
1765 1763
 
@@ -1783,13 +1781,13 @@  discard block
 block discarded – undo
1783 1781
 			'data'	=> $event['description']
1784 1782
 		);
1785 1783
 
1786
-		foreach(explode(',',$event['category']) as $cat_id)
1784
+		foreach (explode(',', $event['category']) as $cat_id)
1787 1785
 		{
1788 1786
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1789 1787
 		}
1790 1788
 		$var['category'] = Array(
1791 1789
 			'field'	=> lang('Category'),
1792
-			'data'	=> implode(', ',$cat_string)
1790
+			'data'	=> implode(', ', $cat_string)
1793 1791
 		);
1794 1792
 
1795 1793
 		$var['location'] = Array(
@@ -1835,7 +1833,7 @@  discard block
 block discarded – undo
1835 1833
 
1836 1834
 		if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants']))
1837 1835
 		{
1838
-			$participants = $this->participants($event,true);
1836
+			$participants = $this->participants($event, true);
1839 1837
 		}
1840 1838
 		$var['participants'] = Array(
1841 1839
 			'field'	=> lang('Participants'),
@@ -1858,26 +1856,26 @@  discard block
 block discarded – undo
1858 1856
 	 * @param array $old_event =null event-data in the DB before calling save
1859 1857
 	 * @param string $type ='update'
1860 1858
 	 */
1861
-	function log2file($event2save,$event_saved,$old_event=null,$type='update')
1859
+	function log2file($event2save, $event_saved, $old_event = null, $type = 'update')
1862 1860
 	{
1863
-		if (!($f = fopen($this->log_file,'a')))
1861
+		if (!($f = fopen($this->log_file, 'a')))
1864 1862
 		{
1865 1863
 			echo "<p>error opening '$this->log_file' !!!</p>\n";
1866 1864
 			return false;
1867 1865
 		}
1868
-		fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1869
-		fwrite($f,"Time: time to save / saved time read back / old time before save\n");
1870
-		foreach(array('start','end') as $name)
1866
+		fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1867
+		fwrite($f, "Time: time to save / saved time read back / old time before save\n");
1868
+		foreach (array('start', 'end') as $name)
1871 1869
 		{
1872
-			fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1873
-				$this->format_date($event_saved[$name]) .' / '.
1870
+			fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1871
+				$this->format_date($event_saved[$name]).' / '.
1874 1872
 				(is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n");
1875 1873
 		}
1876
-		foreach(array('event2save','event_saved','old_event') as $name)
1874
+		foreach (array('event2save', 'event_saved', 'old_event') as $name)
1877 1875
 		{
1878
-			fwrite($f,$name.' = '.print_r($$name,true));
1876
+			fwrite($f, $name.' = '.print_r($$name, true));
1879 1877
 		}
1880
-		fwrite($f,"\n");
1878
+		fwrite($f, "\n");
1881 1879
 		fclose($f);
1882 1880
 
1883 1881
 		return true;
@@ -1898,14 +1896,14 @@  discard block
 block discarded – undo
1898 1896
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1899 1897
 
1900 1898
 		$time = new Api\DateTime($event['start']);
1901
-		if(!is_array($event['alarm']))
1899
+		if (!is_array($event['alarm']))
1902 1900
 		{
1903 1901
 			$event['alarm'] = $this->so->read_alarms($event['id']);
1904 1902
 		}
1905 1903
 
1906
-		foreach($event['alarm'] as &$alarm)
1904
+		foreach ($event['alarm'] as &$alarm)
1907 1905
 		{
1908
-			if($event['recur_type'] != MCAL_RECUR_NONE)
1906
+			if ($event['recur_type'] != MCAL_RECUR_NONE)
1909 1907
 			{
1910 1908
 				calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts'));
1911 1909
 			}
@@ -1925,14 +1923,14 @@  discard block
 block discarded – undo
1925 1923
 	 * @param boolean $update_modified =true call update modified, default true
1926 1924
 	 * @return string id of the alarm, or false on error (eg. no perms)
1927 1925
 	 */
1928
-	function save_alarm($cal_id, $alarm, $update_modified=true)
1926
+	function save_alarm($cal_id, $alarm, $update_modified = true)
1929 1927
 	{
1930
-		if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1928
+		if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1931 1929
 		{
1932 1930
 			//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
1933
-			return false;	// no rights to add the alarm
1931
+			return false; // no rights to add the alarm
1934 1932
 		}
1935
-		$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1933
+		$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1936 1934
 
1937 1935
 		return $this->so->save_alarm($cal_id, $alarm, $update_modified);
1938 1936
 	}
@@ -1945,11 +1943,11 @@  discard block
 block discarded – undo
1945 1943
 	 */
1946 1944
 	function delete_alarm($id)
1947 1945
 	{
1948
-		list(,$cal_id) = explode(':',$id);
1946
+		list(,$cal_id) = explode(':', $id);
1949 1947
 
1950
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1948
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1951 1949
 		{
1952
-			return false;	// no rights to delete the alarm
1950
+			return false; // no rights to delete the alarm
1953 1951
 		}
1954 1952
 
1955 1953
 		return $this->so->delete_alarm($id);
@@ -1964,13 +1962,13 @@  discard block
 block discarded – undo
1964 1962
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1965 1963
 	 * @return array category ids (found, added and preserved categories)
1966 1964
 	 */
1967
-	function find_or_add_categories($catname_list, $old_event=null)
1965
+	function find_or_add_categories($catname_list, $old_event = null)
1968 1966
 	{
1969 1967
 		if (is_array($old_event) || $old_event > 0)
1970 1968
 		{
1971 1969
 			// preserve categories without users read access
1972 1970
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
1973
-			$old_categories = explode(',',$old_event['category']);
1971
+			$old_categories = explode(',', $old_event['category']);
1974 1972
 			$old_cats_preserve = array();
1975 1973
 			if (is_array($old_categories) && count($old_categories) > 0)
1976 1974
 			{
@@ -2024,7 +2022,7 @@  discard block
 block discarded – undo
2024 2022
 	{
2025 2023
 		if (!is_array($cat_id_list))
2026 2024
 		{
2027
-			$cat_id_list = explode(',',$cat_id_list);
2025
+			$cat_id_list = explode(',', $cat_id_list);
2028 2026
 		}
2029 2027
 		$cat_list = array();
2030 2028
 		foreach ($cat_id_list as $cat_id)
@@ -2049,7 +2047,7 @@  discard block
 block discarded – undo
2049 2047
 	 *                              master	-> try to find a releated series master
2050 2048
 	 * @return array calendar_ids of matching entries
2051 2049
 	 */
2052
-	function find_event($event, $filter='exact')
2050
+	function find_event($event, $filter = 'exact')
2053 2051
 	{
2054 2052
 		$matchingEvents = array();
2055 2053
 		$query = array();
@@ -2057,14 +2055,14 @@  discard block
 block discarded – undo
2057 2055
 		if ($this->log)
2058 2056
 		{
2059 2057
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2060
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2058
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
2061 2059
 		}
2062 2060
 
2063 2061
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2064 2062
 
2065 2063
 		if ($filter == 'master')
2066 2064
 		{
2067
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2065
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2068 2066
 			$query['cal_recurrence'] = 0;
2069 2067
 		}
2070 2068
 		elseif ($filter == 'exact')
@@ -2085,14 +2083,14 @@  discard block
 block discarded – undo
2085 2083
 			if ($this->log)
2086 2084
 			{
2087 2085
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2088
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2086
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2089 2087
 			}
2090 2088
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2091 2089
 			{
2092 2090
 				if ($this->log)
2093 2091
 				{
2094 2092
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2095
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2093
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2096 2094
 				}
2097 2095
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2098 2096
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2111,7 +2109,7 @@  discard block
 block discarded – undo
2111 2109
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2112 2110
 						if (in_array($event['recurrence'], $exceptions))
2113 2111
 						{
2114
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2112
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2115 2113
 						}
2116 2114
 					}
2117 2115
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2130,19 +2128,19 @@  discard block
 block discarded – undo
2130 2128
 
2131 2129
 		// only query calendars of users, we have READ-grants from
2132 2130
 		$users = array();
2133
-		foreach(array_keys($this->grants) as $user)
2131
+		foreach (array_keys($this->grants) as $user)
2134 2132
 		{
2135 2133
 			$user = trim($user);
2136
-			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2134
+			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user))
2137 2135
 			{
2138
-				if ($user && !in_array($user,$users))	// already added?
2136
+				if ($user && !in_array($user, $users))	// already added?
2139 2137
 				{
2140 2138
 					$users[] = $user;
2141 2139
 				}
2142 2140
 			}
2143 2141
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2144 2142
 			{
2145
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2143
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2146 2144
 			}
2147 2145
 			// the further code is only for real users
2148 2146
 			if (!is_numeric($user)) continue;
@@ -2153,7 +2151,7 @@  discard block
 block discarded – undo
2153 2151
 				$members = $GLOBALS['egw']->accounts->members($user, true);
2154 2152
 				if (is_array($members))
2155 2153
 				{
2156
-					foreach($members as $member)
2154
+					foreach ($members as $member)
2157 2155
 					{
2158 2156
 						// use only members which gave the user a read-grant
2159 2157
 						if (!in_array($member, $users) &&
@@ -2169,7 +2167,7 @@  discard block
 block discarded – undo
2169 2167
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
2170 2168
 				if (is_array($memberships))
2171 2169
 				{
2172
-					foreach($memberships as $group)
2170
+					foreach ($memberships as $group)
2173 2171
 					{
2174 2172
 						if (!in_array($group, $users))
2175 2173
 						{
@@ -2195,24 +2193,24 @@  discard block
 block discarded – undo
2195 2193
 
2196 2194
 				// check length with some tolerance
2197 2195
 				$length = $event['end'] - $event['start'] - $delta;
2198
-				$query[] = ('(cal_end-cal_start)>' . $length);
2196
+				$query[] = ('(cal_end-cal_start)>'.$length);
2199 2197
 				$length += 2 * $delta;
2200
-				$query[] = ('(cal_end-cal_start)<' . $length);
2201
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2202
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2198
+				$query[] = ('(cal_end-cal_start)<'.$length);
2199
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2200
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2203 2201
 			}
2204 2202
 			elseif (isset($event['start']))
2205 2203
 			{
2206 2204
 				if ($filter == 'relax')
2207 2205
 				{
2208
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2209
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2206
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2207
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2210 2208
 				}
2211 2209
 				else
2212 2210
 				{
2213 2211
 					// we accept a tiny tolerance
2214
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2215
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2212
+					$query[] = ('cal_start>'.($event['start'] - 2));
2213
+					$query[] = ('cal_start<'.($event['start'] + 2));
2216 2214
 				}
2217 2215
 			}
2218 2216
 			if ($filter == 'relax')
@@ -2235,14 +2233,14 @@  discard block
 block discarded – undo
2235 2233
 			if ($this->log)
2236 2234
 			{
2237 2235
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2238
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2236
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2239 2237
 			}
2240 2238
 		}
2241 2239
 
2242 2240
 		if ($this->log)
2243 2241
 		{
2244 2242
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2245
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2243
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2246 2244
 		}
2247 2245
 		if (!count($users) || !($foundEvents =
2248 2246
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2250,19 +2248,19 @@  discard block
 block discarded – undo
2250 2248
 			if ($this->log)
2251 2249
 			{
2252 2250
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2253
-				"[NO MATCH]\n",3,$this->logfile);
2251
+				"[NO MATCH]\n", 3, $this->logfile);
2254 2252
 			}
2255 2253
 			return $matchingEvents;
2256 2254
 		}
2257 2255
 
2258 2256
 		$pseudos = array();
2259 2257
 
2260
-		foreach($foundEvents as $egwEvent)
2258
+		foreach ($foundEvents as $egwEvent)
2261 2259
 		{
2262 2260
 			if ($this->log)
2263 2261
 			{
2264 2262
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2265
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2263
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2266 2264
 			}
2267 2265
 
2268 2266
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2336,7 +2334,7 @@  discard block
 block discarded – undo
2336 2334
 						if (in_array($event['recurrence'], $exceptions))
2337 2335
 						{
2338 2336
 							// We found a pseudo exception
2339
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2337
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2340 2338
 							break;
2341 2339
 						}
2342 2340
 					}
@@ -2354,7 +2352,7 @@  discard block
 block discarded – undo
2354 2352
 						if ($this->log)
2355 2353
 						{
2356 2354
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2357
-							"() egwEvent length does not match!\n",3,$this->logfile);
2355
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2358 2356
 						}
2359 2357
 						continue;
2360 2358
 					}
@@ -2366,7 +2364,7 @@  discard block
 block discarded – undo
2366 2364
 						if ($this->log)
2367 2365
 						{
2368 2366
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2369
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2367
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2370 2368
 						}
2371 2369
 						continue;
2372 2370
 					}
@@ -2387,8 +2385,8 @@  discard block
 block discarded – undo
2387 2385
 					if ($this->log)
2388 2386
 					{
2389 2387
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2390
-							"() event[$key] differ: '" . $event[$key] .
2391
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2388
+							"() event[$key] differ: '".$event[$key].
2389
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2392 2390
 					}
2393 2391
 					continue 2; // next foundEvent
2394 2392
 				}
@@ -2406,7 +2404,7 @@  discard block
 block discarded – undo
2406 2404
 						if ($this->log)
2407 2405
 						{
2408 2406
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2409
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2407
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2410 2408
 						}
2411 2409
 						continue 2;
2412 2410
 					}
@@ -2418,7 +2416,7 @@  discard block
 block discarded – undo
2418 2416
 					{
2419 2417
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2420 2418
 							'() event has additional categories:'
2421
-							. array2string($newCategories)."\n",3,$this->logfile);
2419
+							. array2string($newCategories)."\n", 3, $this->logfile);
2422 2420
 					}
2423 2421
 					continue;
2424 2422
 				}
@@ -2438,7 +2436,7 @@  discard block
 block discarded – undo
2438 2436
 							if ($this->log)
2439 2437
 							{
2440 2438
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2441
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2439
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2442 2440
 							}
2443 2441
 							continue 2;
2444 2442
 						}
@@ -2461,8 +2459,8 @@  discard block
 block discarded – undo
2461 2459
 						if ($this->log)
2462 2460
 						{
2463 2461
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2464
-								'() missing event[participants]: ' .
2465
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2462
+								'() missing event[participants]: '.
2463
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2466 2464
 						}
2467 2465
 						continue;
2468 2466
 					}
@@ -2474,7 +2472,7 @@  discard block
 block discarded – undo
2474 2472
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2475 2473
 				{
2476 2474
 					// We found a pseudo Exception
2477
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2475
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2478 2476
 					continue;
2479 2477
 				}
2480 2478
 			}
@@ -2496,7 +2494,7 @@  discard block
 block discarded – undo
2496 2494
 							if ($this->log)
2497 2495
 							{
2498 2496
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2499
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2497
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2500 2498
 							}
2501 2499
 							continue 2;
2502 2500
 						}
@@ -2506,8 +2504,8 @@  discard block
 block discarded – undo
2506 2504
 						if ($this->log)
2507 2505
 						{
2508 2506
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2509
-								'() missing event[recur_exception]: ' .
2510
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2507
+								'() missing event[recur_exception]: '.
2508
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2511 2509
 						}
2512 2510
 						continue;
2513 2511
 					}
@@ -2522,8 +2520,8 @@  discard block
 block discarded – undo
2522 2520
 						if ($this->log)
2523 2521
 						{
2524 2522
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2525
-								"() events[$key] differ: " . $event[$key] .
2526
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2523
+								"() events[$key] differ: ".$event[$key].
2524
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2527 2525
 						}
2528 2526
 						continue 2;
2529 2527
 					}
@@ -2539,7 +2537,7 @@  discard block
 block discarded – undo
2539 2537
 			if ($this->log)
2540 2538
 			{
2541 2539
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2542
-					"() new exception for series found.\n",3,$this->logfile);
2540
+					"() new exception for series found.\n", 3, $this->logfile);
2543 2541
 			}
2544 2542
 			$matchingEvents = array();
2545 2543
 		}
@@ -2550,7 +2548,7 @@  discard block
 block discarded – undo
2550 2548
 		if ($this->log)
2551 2549
 		{
2552 2550
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2553
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2551
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2554 2552
 		}
2555 2553
 		return $matches;
2556 2554
 	}
@@ -2623,7 +2621,7 @@  discard block
 block discarded – undo
2623 2621
 				if ($this->log)
2624 2622
 				{
2625 2623
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2626
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2624
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2627 2625
 				}
2628 2626
 				$type = 'SERIES-EXCEPTION';
2629 2627
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2644,7 +2642,7 @@  discard block
 block discarded – undo
2644 2642
 					}
2645 2643
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2646 2644
 					{
2647
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2645
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2648 2646
 						$recurrence_event = $master_event;
2649 2647
 						$recurrence_event['start'] = $event['start'];
2650 2648
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2661,8 +2659,8 @@  discard block
 block discarded – undo
2661 2659
 							if ($this->log)
2662 2660
 							{
2663 2661
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2664
-									'() try occurrence ' . $egw_rrule->current()
2665
-									. " ($occurrence)\n",3,$this->logfile);
2662
+									'() try occurrence '.$egw_rrule->current()
2663
+									. " ($occurrence)\n", 3, $this->logfile);
2666 2664
 							}
2667 2665
 							if ($event['start'] == $occurrence)
2668 2666
 							{
@@ -2695,8 +2693,8 @@  discard block
 block discarded – undo
2695 2693
 			// default if we cannot find a proof for a fundamental change
2696 2694
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2697 2695
 			// check for changed data
2698
-			foreach (array('start','end','uid','title','location','description',
2699
-				'priority','public','special','non_blocking') as $key)
2696
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2697
+				'priority', 'public', 'special', 'non_blocking') as $key)
2700 2698
 			{
2701 2699
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2702 2700
 				{
@@ -2754,10 +2752,10 @@  discard block
 block discarded – undo
2754 2752
      * @param &$event	the event we are working on
2755 2753
      *
2756 2754
      */
2757
-    function server2usertime (&$event)
2755
+    function server2usertime(&$event)
2758 2756
     {
2759 2757
 		// we run all dates through date2usertime, to adjust to user-time
2760
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2758
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2761 2759
 		{
2762 2760
 			// we convert here from server-time to timestamps in user-time!
2763 2761
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2765,7 +2763,7 @@  discard block
 block discarded – undo
2765 2763
 		// same with the recur exceptions
2766 2764
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2767 2765
 		{
2768
-			foreach($event['recur_exception'] as $n => $date)
2766
+			foreach ($event['recur_exception'] as $n => $date)
2769 2767
 			{
2770 2768
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2771 2769
 			}
@@ -2773,7 +2771,7 @@  discard block
 block discarded – undo
2773 2771
 		// same with the alarms
2774 2772
 		if (isset($event['alarm']) && is_array($event['alarm']))
2775 2773
 		{
2776
-			foreach($event['alarm'] as $id => $alarm)
2774
+			foreach ($event['alarm'] as $id => $alarm)
2777 2775
 			{
2778 2776
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2779 2777
 			}
@@ -2790,7 +2788,7 @@  discard block
 block discarded – undo
2790 2788
 	{
2791 2789
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2792 2790
 		{
2793
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2791
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2794 2792
 		}
2795 2793
 	}
2796 2794
 }
Please login to merge, or discard this patch.
Braces   +224 added lines, -57 removed lines patch added patch discarded remove patch
@@ -85,11 +85,17 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0)
89
+		{
90
+			$this->debug_message('calendar_boupdate::__construct() started',True);
91
+		}
89 92
 
90 93
 		parent::__construct();	// calling the parent constructor
91 94
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
95
+		if ($this->debug > 0)
96
+		{
97
+			$this->debug_message('calendar_boupdate::__construct() finished',True);
98
+		}
93 99
 	}
94 100
 
95 101
 	/**
@@ -119,7 +125,10 @@  discard block
 block discarded – undo
119 125
 	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
120 126
 	{
121 127
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
122
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
128
+		if (!is_array($messages))
129
+		{
130
+			$messages = $messages ? (array)$messages : array();
131
+		}
123 132
 
124 133
 		if ($this->debug > 1 || $this->debug == 'update')
125 134
 		{
@@ -139,10 +148,13 @@  discard block
 block discarded – undo
139 148
 
140 149
 		$status_reset_to_unknown = false;
141 150
 
142
-		if (($new_event = !$event['id']))	// some defaults for new entries
151
+		if (($new_event = !$event['id']))
152
+		{
153
+			// some defaults for new entries
143 154
 		{
144 155
 			// if no owner given, set user to owner
145 156
 			if (!$event['owner']) $event['owner'] = $this->user;
157
+		}
146 158
 			// set owner as participant if none is given
147 159
 			if (!is_array($event['participants']) || !count($event['participants']))
148 160
 			{
@@ -182,7 +194,10 @@  discard block
 block discarded – undo
182 194
 		// check category based ACL
183 195
 		if ($event['category'])
184 196
 		{
185
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
197
+			if (!is_array($event['category']))
198
+			{
199
+				$event['category'] = explode(',',$event['category']);
200
+			}
186 201
 			if (!$old_event || !isset($old_event['category']))
187 202
 			{
188 203
 				$old_event['category'] = array();
@@ -234,13 +249,16 @@  discard block
 block discarded – undo
234 249
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) &&
235 250
 			(($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding))
236 251
 		{
237
-			if ($checked_excluding)	// warn user if not all recurrences have been checked
252
+			if ($checked_excluding)
253
+			{
254
+				// warn user if not all recurrences have been checked
238 255
 			{
239 256
 				$conflicts['warning'] = array(
240 257
 					'start' => $checked_excluding,
241 258
 					'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)),
242 259
 				);
243 260
 			}
261
+			}
244 262
 			return $conflicts;
245 263
 		}
246 264
 
@@ -301,7 +319,10 @@  discard block
 block discarded – undo
301 319
 		$types_with_quantity = array();
302 320
 		foreach($this->resources as $type => $data)
303 321
 		{
304
-			if ($data['max_quantity']) $types_with_quantity[] = $type;
322
+			if ($data['max_quantity'])
323
+			{
324
+				$types_with_quantity[] = $type;
325
+			}
305 326
 		}
306 327
 		// get all NOT rejected participants and evtl. their quantity
307 328
 		$quantity = $users = array();
@@ -309,12 +330,19 @@  discard block
 block discarded – undo
309 330
 		{
310 331
 			$q = $r = null;
311 332
 			calendar_so::split_status($status,$q,$r);
312
-			if ($status[0] == 'R') continue;	// ignore rejected participants
333
+			if ($status[0] == 'R')
334
+			{
335
+				continue;
336
+			}
337
+			// ignore rejected participants
313 338
 
314
-			if ($uid < 0)	// group, check it's members too
339
+			if ($uid < 0)
340
+			{
341
+				// group, check it's members too
315 342
 			{
316 343
 				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
317 344
 			}
345
+			}
318 346
 			$users[] = $uid;
319 347
 			if (in_array($uid[0],$types_with_quantity))
320 348
 			{
@@ -345,18 +373,24 @@  discard block
 block discarded – undo
345 373
 			$startts = $date->format('ts');
346 374
 
347 375
 			// skip past events or recurrences
348
-			if ($startts+$duration < $this->now_su) continue;
376
+			if ($startts+$duration < $this->now_su)
377
+			{
378
+				continue;
379
+			}
349 380
 
350 381
 			// abort check if configured limits are exceeded
351 382
 			if ($event['recur_type'] &&
352 383
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
353 384
 				microtime(true) > $start+$max_check_time ||	// max check time exceeded
354
-				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
385
+				$startts > $this->config['horizont']))
386
+			{
387
+				// we are behind horizon for which recurrences are rendered
355 388
 			{
356 389
 				if ($this->debug > 2 || $this->debug == 'conflicts')
357 390
 				{
358 391
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
359 392
 						$checked, microtime(true)-$start, $date);
393
+			}
360 394
 				}
361 395
 				$checked_excluding = $date;
362 396
 				break;
@@ -380,10 +414,13 @@  discard block
 block discarded – undo
380 414
 			{
381 415
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
382 416
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
383
-					$overlap['non_blocking'])			// that's a non_blocking event
417
+					$overlap['non_blocking'])
418
+				{
419
+					// that's a non_blocking event
384 420
 				{
385 421
 					continue;
386 422
 				}
423
+				}
387 424
 				if ($this->debug > 3 || $this->debug == 'conflicts')
388 425
 				{
389 426
 					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
@@ -503,7 +540,11 @@  discard block
 block discarded – undo
503 540
 	 */
504 541
 	public function check_acl_invite($uid)
505 542
 	{
506
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
543
+		if (!is_numeric($uid))
544
+		{
545
+			return true;
546
+		}
547
+		// nothing implemented for resources so far
507 548
 
508 549
 		if (!$this->require_acl_invite)
509 550
 		{
@@ -843,14 +884,20 @@  discard block
 block discarded – undo
843 884
 		$startdate = new Api\DateTime($event['start']);
844 885
 		$enddate = new Api\DateTime($event['end']);
845 886
 		$modified = new Api\DateTime($event['modified']);
846
-		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
887
+		if ($old_event)
888
+		{
889
+			$olddate = new Api\DateTime($old_event['start']);
890
+		}
847 891
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
848 892
 		$owner_prefs = $ics = null;
849 893
 		foreach($to_notify as $userid => $statusid)
850 894
 		{
851 895
 			$res_info = $quantity = $role = null;
852 896
 			calendar_so::split_status($statusid, $quantity, $role);
853
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
897
+			if ($this->debug > 0)
898
+			{
899
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
900
+			}
854 901
 
855 902
 			if (!is_numeric($userid))
856 903
 			{
@@ -869,7 +916,11 @@  discard block
 block discarded – undo
869 916
 
870 917
 				if (!isset($userid))
871 918
 				{
872
-					if (empty($res_info['email'])) continue;	// no way to notify
919
+					if (empty($res_info['email']))
920
+					{
921
+						continue;
922
+					}
923
+					// no way to notify
873 924
 					// check if event-owner wants non-EGroupware users notified
874 925
 					if (is_null($owner_prefs))
875 926
 					{
@@ -933,11 +984,20 @@  discard block
 block discarded – undo
933 984
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
934 985
 					$action, $event_arr, $disinvited);
935 986
 				$details['to-fullname'] = $fullname;
936
-				if (isset($tfn)) $details['to-firstname'] = $tfn;
937
-				if (isset($tln)) $details['to-lastname'] = $tln;
987
+				if (isset($tfn))
988
+				{
989
+					$details['to-firstname'] = $tfn;
990
+				}
991
+				if (isset($tln))
992
+				{
993
+					$details['to-lastname'] = $tln;
994
+				}
938 995
 
939 996
 				// event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account
940
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
997
+				if (!isset($part_prefs['common']['tz']))
998
+				{
999
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1000
+				}
941 1001
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
942 1002
 				$timeformat = $part_prefs['common']['timeformat'];
943 1003
 				switch($timeformat)
@@ -972,9 +1032,12 @@  discard block
 block discarded – undo
972 1032
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
973 1033
 				{
974 1034
 					case 'ical':
975
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
1035
+						if (is_null($ics) || $m_type != $msg_type)
1036
+						{
1037
+							// need different ical for organizer notification
976 1038
 						{
977 1039
 							$calendar_ical = new calendar_ical();
1040
+						}
978 1041
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
979 1042
 							// we need to pass $event[id] so iCal class reads event again,
980 1043
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -988,7 +1051,10 @@  discard block
 block discarded – undo
988 1051
 							'encoding' => '8bit',
989 1052
 							'type' => 'text/calendar; method='.$method,
990 1053
 						);
991
-						if ($m_type != $msg_type) unset($ics);
1054
+						if ($m_type != $msg_type)
1055
+						{
1056
+							unset($ics);
1057
+						}
992 1058
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
993 1059
 						// fall through
994 1060
 					case 'extended':
@@ -1039,7 +1105,9 @@  discard block
 block discarded – undo
1039 1105
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1040 1106
 						$notification->set_popuplinks(array($details['link_arr']));
1041 1107
 
1042
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1108
+						if(is_array($attachment))
1109
+						{
1110
+$notification->set_attachments(array($attachment)); }
1043 1111
 						$notification->send();
1044 1112
 					}
1045 1113
 					catch (Exception $exception) {
@@ -1071,7 +1139,10 @@  discard block
 block discarded – undo
1071 1139
 			Api\Translation::init();
1072 1140
 		}
1073 1141
 		// restore timezone, in case we had to reset it to server-timezone
1074
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1142
+		if ($restore_tz)
1143
+		{
1144
+			date_default_timezone_set($restore_tz);
1145
+		}
1075 1146
 
1076 1147
 		return true;
1077 1148
 	}
@@ -1106,10 +1177,13 @@  discard block
 block discarded – undo
1106 1177
 		{
1107 1178
 			$to_notify = $event['participants'];
1108 1179
 		}
1109
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1180
+		elseif ($this->check_perms(Acl::READ,$event))
1181
+		{
1182
+			// checks agains $this->owner set to $alarm[owner]
1110 1183
 		{
1111 1184
 			$to_notify[$alarm['owner']] = 'A';
1112 1185
 		}
1186
+		}
1113 1187
 		else
1114 1188
 		{
1115 1189
 			return False;	// no rights
@@ -1159,7 +1233,10 @@  discard block
 block discarded – undo
1159 1233
 		if ($event['id'])
1160 1234
 		{
1161 1235
 			// invalidate the read-cache if it contains the event we store now
1162
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1236
+			if ($event['id'] == self::$cached_event['id'])
1237
+			{
1238
+				self::$cached_event = array();
1239
+			}
1163 1240
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1164 1241
 		}
1165 1242
 		else
@@ -1167,7 +1244,10 @@  discard block
 block discarded – undo
1167 1244
 			$old_event = null;
1168 1245
 		}
1169 1246
 
1170
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1247
+		if (!isset($event['whole_day']))
1248
+		{
1249
+			$event['whole_day'] = $this->isWholeDay($event);
1250
+		}
1171 1251
 		$save_event = $event;
1172 1252
 		if ($event['whole_day'])
1173 1253
 		{
@@ -1208,7 +1288,10 @@  discard block
 block discarded – undo
1208 1288
 		foreach($timestamps as $ts)
1209 1289
 		{
1210 1290
 			// we convert here from user-time to timestamps in server-time!
1211
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1291
+			if (isset($event[$ts]))
1292
+			{
1293
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1294
+			}
1212 1295
 		}
1213 1296
 		// convert tzid name to integer tz_id, of set user default
1214 1297
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1258,7 +1341,10 @@  discard block
 block discarded – undo
1258 1341
 				if (!isset($event['alarm'][$id]))
1259 1342
 				{
1260 1343
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1261
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1344
+					if ($alarm['time'] < time())
1345
+					{
1346
+						calendar_so::shift_alarm($event, $alarm);
1347
+					}
1262 1348
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1263 1349
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1264 1350
 						$old_event['participants'][$alarm['owner']];
@@ -1311,7 +1397,10 @@  discard block
 block discarded – undo
1311 1397
 
1312 1398
 		// Update history
1313 1399
 		$tracking = new calendar_tracking($this);
1314
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1400
+		if (empty($event['id']) && !empty($cal_id))
1401
+		{
1402
+			$event['id']=$cal_id;
1403
+		}
1315 1404
 		$tracking->track($event, $old_event);
1316 1405
 
1317 1406
 		return $cal_id;
@@ -1328,9 +1417,12 @@  discard block
 block discarded – undo
1328 1417
 	 */
1329 1418
 	function check_status_perms($uid,$event)
1330 1419
 	{
1331
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1420
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1421
+		{
1422
+			// for contact we use the owner of the event
1332 1423
 		{
1333 1424
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1425
+		}
1334 1426
 
1335 1427
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1336 1428
 		}
@@ -1341,13 +1433,19 @@  discard block
 block discarded – undo
1341 1433
 			return $access;
1342 1434
 		}
1343 1435
 		// no access or denied access because of category acl --> regular check
1344
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1436
+		if (!is_numeric($uid))
1437
+		{
1438
+			// this is eg. for resources (r123)
1345 1439
 		{
1346 1440
 			$resource = $this->resource_info($uid);
1441
+		}
1347 1442
 
1348 1443
 			return Acl::EDIT & $resource['rights'];
1349 1444
 		}
1350
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1445
+		if (!is_array($event) && !($event = $this->read($event)))
1446
+		{
1447
+			return false;
1448
+		}
1351 1449
 
1352 1450
 		// regular user and groups (need to check memberships too)
1353 1451
 		if (!isset($event['participants'][$uid]))
@@ -1371,7 +1469,10 @@  discard block
 block discarded – undo
1371 1469
 	 */
1372 1470
 	function check_cat_acl($right,$event)
1373 1471
 	{
1374
-		if (!is_array($event)) $event = $this->read($event);
1472
+		if (!is_array($event))
1473
+		{
1474
+			$event = $this->read($event);
1475
+		}
1375 1476
 
1376 1477
 		$ret = null;
1377 1478
 		if ($event['category'])
@@ -1428,7 +1529,10 @@  discard block
 block discarded – undo
1428 1529
 	public static function set_cat_rights($cat_id,$user,$rights)
1429 1530
 	{
1430 1531
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1431
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1532
+		if (!isset(self::$cat_rights_cache))
1533
+		{
1534
+			self::get_cat_rights($cat_id);
1535
+		}
1432 1536
 
1433 1537
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1434 1538
 		{
@@ -1440,7 +1544,10 @@  discard block
 block discarded – undo
1440 1544
 			else
1441 1545
 			{
1442 1546
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1443
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1547
+				if (!self::$cat_rights_cache['L'.$cat_id])
1548
+				{
1549
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1550
+				}
1444 1551
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1445 1552
 			}
1446 1553
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1473,7 +1580,10 @@  discard block
 block discarded – undo
1473 1580
 				foreach($cat_rights as $uid => $value)
1474 1581
 				{
1475 1582
 					$all |= $value;
1476
-					if (in_array($uid,$memberships)) $own |= $value;
1583
+					if (in_array($uid,$memberships))
1584
+					{
1585
+						$own |= $value;
1586
+					}
1477 1587
 				}
1478 1588
 			}
1479 1589
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1520,13 +1630,16 @@  discard block
 block discarded – undo
1520 1630
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1521 1631
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1522 1632
 		{
1523
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1633
+			if ($status == 'R')
1634
+			{
1635
+				// remove alarms belonging to rejected participants
1524 1636
 			{
1525 1637
 				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1526 1638
 				{
1527 1639
 					if ((string)$alarm['owner'] === (string)$uid)
1528 1640
 					{
1529 1641
 						$this->so->delete_alarm($id);
1642
+			}
1530 1643
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1531 1644
 					}
1532 1645
 				}
@@ -1540,8 +1653,15 @@  discard block
 block discarded – undo
1540 1653
 			);
1541 1654
 			if (isset($status2msg[$status]) && !$skip_notification)
1542 1655
 			{
1543
-				if (!is_array($event)) $event = $this->read($cal_id);
1544
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1656
+				if (!is_array($event))
1657
+				{
1658
+					$event = $this->read($cal_id);
1659
+				}
1660
+				if (isset($recur_date))
1661
+				{
1662
+					$event = $this->read($event['id'],$recur_date);
1663
+				}
1664
+				//re-read the actually edited recurring event
1545 1665
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1546 1666
 			}
1547 1667
 
@@ -1564,12 +1684,16 @@  discard block
 block discarded – undo
1564 1684
 	 */
1565 1685
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1566 1686
 	{
1567
-		if (!isset($new_event['participants'])) return;
1687
+		if (!isset($new_event['participants']))
1688
+		{
1689
+			return;
1690
+		}
1568 1691
 
1569 1692
 		// check the old list against the new list
1570 1693
 		foreach ($old_event['participants'] as $userid => $status)
1571
-  		{
1572
-            if (!isset($new_event['participants'][$userid])){
1694
+		{
1695
+            if (!isset($new_event['participants'][$userid]))
1696
+            {
1573 1697
             	// Attendee will be deleted this way
1574 1698
             	$new_event['participants'][$userid] = 'G';
1575 1699
             }
@@ -1652,7 +1776,10 @@  discard block
 block discarded – undo
1652 1776
 					}
1653 1777
 					else
1654 1778
 					{
1655
-						if (!($exception = $this->read($id))) continue;
1779
+						if (!($exception = $this->read($id)))
1780
+						{
1781
+							continue;
1782
+						}
1656 1783
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1657 1784
 						$exception['reference'] = $exception['recurrence'] = 0;
1658 1785
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1723,7 +1850,10 @@  discard block
 block discarded – undo
1723 1850
 		$event_arr = $this->event2array($event);
1724 1851
 		foreach($event_arr as $key => $val)
1725 1852
 		{
1726
-			if ($key == 'recur_type') $key = 'repetition';
1853
+			if ($key == 'recur_type')
1854
+			{
1855
+				$key = 'repetition';
1856
+			}
1727 1857
 			$details[$key] = $val['data'];
1728 1858
 		}
1729 1859
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1895,7 +2025,10 @@  discard block
 block discarded – undo
1895 2025
 	 */
1896 2026
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1897 2027
 	{
1898
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
2028
+		if ($old_event !== null && $event['start'] == $old_event['start'])
2029
+		{
2030
+			return;
2031
+		}
1899 2032
 
1900 2033
 		$time = new Api\DateTime($event['start']);
1901 2034
 		if(!is_array($event['alarm']))
@@ -1969,7 +2102,10 @@  discard block
 block discarded – undo
1969 2102
 		if (is_array($old_event) || $old_event > 0)
1970 2103
 		{
1971 2104
 			// preserve categories without users read access
1972
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2105
+			if (!is_array($old_event))
2106
+			{
2107
+				$old_event = $this->read($old_event);
2108
+			}
1973 2109
 			$old_categories = explode(',',$old_event['category']);
1974 2110
 			$old_cats_preserve = array();
1975 2111
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -2060,7 +2196,10 @@  discard block
 block discarded – undo
2060 2196
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2061 2197
 		}
2062 2198
 
2063
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2199
+		if (!isset($event['recurrence']))
2200
+		{
2201
+			$event['recurrence'] = 0;
2202
+		}
2064 2203
 
2065 2204
 		if ($filter == 'master')
2066 2205
 		{
@@ -2114,19 +2253,26 @@  discard block
 block discarded – undo
2114 2253
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2115 2254
 						}
2116 2255
 					}
2117
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2256
+				}
2257
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2118 2258
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2119 2259
 							strpos($egwEvent['title'], $event['title']) === 0))
2120 2260
 				{
2121 2261
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2122 2262
 				}
2123 2263
 			}
2124
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2264
+			if (!empty($matchingEvents) || $filter == 'exact')
2265
+			{
2266
+				return $matchingEvents;
2267
+			}
2125 2268
 		}
2126 2269
 		unset($event['id']);
2127 2270
 
2128 2271
 		// No chance to find a master without [U]ID
2129
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2272
+		if ($filter == 'master' && empty($event['uid']))
2273
+		{
2274
+			return $matchingEvents;
2275
+		}
2130 2276
 
2131 2277
 		// only query calendars of users, we have READ-grants from
2132 2278
 		$users = array();
@@ -2135,17 +2281,23 @@  discard block
 block discarded – undo
2135 2281
 			$user = trim($user);
2136 2282
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2137 2283
 			{
2138
-				if ($user && !in_array($user,$users))	// already added?
2284
+				if ($user && !in_array($user,$users))
2285
+				{
2286
+					// already added?
2139 2287
 				{
2140 2288
 					$users[] = $user;
2141 2289
 				}
2290
+				}
2142 2291
 			}
2143 2292
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2144 2293
 			{
2145 2294
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2146 2295
 			}
2147 2296
 			// the further code is only for real users
2148
-			if (!is_numeric($user)) continue;
2297
+			if (!is_numeric($user))
2298
+			{
2299
+				continue;
2300
+			}
2149 2301
 
2150 2302
 			// for groups we have to include the members
2151 2303
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2225,7 +2377,10 @@  discard block
 block discarded – undo
2225 2377
 			}
2226 2378
 			foreach ($matchFields as $key)
2227 2379
 			{
2228
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2380
+				if (isset($event[$key]))
2381
+				{
2382
+					$query['cal_'.$key] = $event[$key];
2383
+				}
2229 2384
 			}
2230 2385
 		}
2231 2386
 
@@ -2265,7 +2420,10 @@  discard block
 block discarded – undo
2265 2420
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2266 2421
 			}
2267 2422
 
2268
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2423
+			if (in_array($egwEvent['id'], $matchingEvents))
2424
+			{
2425
+				continue;
2426
+			}
2269 2427
 
2270 2428
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2271 2429
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2432,13 +2590,16 @@  discard block
 block discarded – undo
2432 2590
 					foreach ($event['participants'] as $attendee => $status)
2433 2591
 					{
2434 2592
 						if (!isset($egwEvent['participants'][$attendee]) &&
2435
-								$attendee != $egwEvent['owner']) // ||
2593
+								$attendee != $egwEvent['owner'])
2594
+						{
2595
+							// ||
2436 2596
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2437 2597
 						{
2438 2598
 							if ($this->log)
2439 2599
 							{
2440 2600
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2441 2601
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2602
+						}
2442 2603
 							}
2443 2604
 							continue 2;
2444 2605
 						}
@@ -2760,7 +2921,10 @@  discard block
 block discarded – undo
2760 2921
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2761 2922
 		{
2762 2923
 			// we convert here from server-time to timestamps in user-time!
2763
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2924
+			if (isset($event[$ts]))
2925
+			{
2926
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2927
+			}
2764 2928
 		}
2765 2929
 		// same with the recur exceptions
2766 2930
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2788,9 +2952,12 @@  discard block
 block discarded – undo
2788 2952
 	 */
2789 2953
 	function purge($age)
2790 2954
 	{
2791
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2955
+		if (is_numeric($age) && $age > 0)
2956
+		{
2957
+			// just make sure bogus values dont delete everything
2792 2958
 		{
2793 2959
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2794 2960
 		}
2961
+		}
2795 2962
 	}
2796 2963
 }
Please login to merge, or discard this patch.
calendar/inc/class.calendar_groupdav.inc.php 3 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @param string $path
317 317
 	 * @param array $filter
318
-	 * @param array|boolean $start =false false=return all or array(start,num)
318
+	 * @param integer[] $start =false false=return all or array(start,num)
319 319
 	 * @return array with "files" array with values for keys path and props
320 320
 	 */
321 321
 	function propfind_callback($path,array $filter,$start=false)
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @param array &$options
621 621
 	 * @param int $id
622 622
 	 * @param int $user =null account_id
623
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
623
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
624 624
 	 */
625 625
 	function get(&$options,$id,$user=null)
626 626
 	{
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	 * Check if $user is a participant of given $event incl. group-invitations
794 794
 	 *
795 795
 	 * @param array $event
796
-	 * @param int|string $user
796
+	 * @param integer $user
797 797
 	 * @return boolean
798 798
 	 */
799 799
 	public static function isParticipant(array $event, $user)
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	 * @param int $id
811 811
 	 * @param int $user =null account_id of owner, default null
812 812
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
813
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
813
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
814 814
 	 */
815 815
 	function put(&$options,$id,$user=null,$prefix=null)
816 816
 	{
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 	 * @param array &$options
1039 1039
 	 * @param int $id
1040 1040
 	 * @param int $user =null account_id of owner, default null
1041
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1041
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1042 1042
 	 */
1043 1043
 	function post(&$options,$id,$user=null)
1044 1044
 	{
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	 * @param string $charset of ical
1113 1113
 	 * @param int $user account_id of owner
1114 1114
 	 * @param array &$options
1115
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1115
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1116 1116
 	 */
1117 1117
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1118 1118
 	{
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	 * @param string $path
1188 1188
 	 * @param array $options
1189 1189
 	 * @param int $user account_id
1190
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1190
+	 * @return string|null boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1191 1191
 	 */
1192 1192
 	function free_busy_report($path,$options,$user)
1193 1193
 	{
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 	/**
1417 1417
 	 * Query ctag for calendar
1418 1418
 	 *
1419
-	 * @return string
1419
+	 * @return integer
1420 1420
 	 */
1421 1421
 	public function getctag($path,$user)
1422 1422
 	{
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 	 *
1433 1433
 	 * @param array|int $entry array with event or cal_id
1434 1434
 	 * @param string $schedule_tag =null on return schedule-tag
1435
-	 * @return string|boolean string with etag or false
1435
+	 * @return string string with etag or false
1436 1436
 	 */
1437 1437
 	function get_etag($entry, &$schedule_tag=null)
1438 1438
 	{
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	 *
1450 1450
 	 * @param int|array $entry id or array of new created entry
1451 1451
 	 * @param string $path
1452
-	 * @param int|string $retval
1452
+	 * @param string|boolean $retval
1453 1453
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1454 1454
 	 */
1455 1455
 	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
Please login to merge, or discard this patch.
Braces   +225 added lines, -56 removed lines patch added patch discarded remove patch
@@ -120,7 +120,10 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 		else
122 122
 		{
123
-			if (!is_array($event)) $event = $this->bo->read($event);
123
+			if (!is_array($event))
124
+			{
125
+				$event = $this->bo->read($event);
126
+			}
124 127
 			$name = $event[self::$path_attr];
125 128
 		}
126 129
 		$name .= self::$path_extension;
@@ -181,10 +184,13 @@  discard block
 block discarded – undo
181 184
 			}
182 185
 			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
183 186
 		}
184
-		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
187
+		if ($this->client_shared_uid_exceptions)
188
+		{
189
+			// do NOT return (non-virtual) exceptions
185 190
 		{
186 191
 			$filter['query'] = array('cal_reference' => 0);
187 192
 		}
193
+		}
188 194
 
189 195
 		if ($path == '/calendar/')
190 196
 		{
@@ -214,7 +220,11 @@  discard block
 block discarded – undo
214 220
 			// when trying to request not supported components, eg. VTODO on a calendar collection
215 221
 			return true;
216 222
 		}
217
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
223
+		if ($id)
224
+		{
225
+			$path = dirname($path).'/';
226
+		}
227
+		// caldav_name get's added anyway in the callback
218 228
 
219 229
 		if ($this->debug > 1)
220 230
 		{
@@ -276,7 +286,11 @@  discard block
 block discarded – undo
276 286
 		$n = 0;
277 287
 		foreach($files as $file)
278 288
 		{
279
-			if (!$n++) continue;	// first entry is collection itself
289
+			if (!$n++)
290
+			{
291
+				continue;
292
+			}
293
+			// first entry is collection itself
280 294
 
281 295
 			$icalendar = $file['props']['calendar-data']['val'];
282 296
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -320,10 +334,17 @@  discard block
 block discarded – undo
320 334
 	 */
321 335
 	function propfind_callback($path,array $filter,$start=false)
322 336
 	{
323
-		if ($this->debug) $starttime = microtime(true);
337
+		if ($this->debug)
338
+		{
339
+			$starttime = microtime(true);
340
+		}
324 341
 
325 342
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
326
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
343
+		if (!is_array($calendar_data))
344
+		{
345
+			$calendar_data = false;
346
+		}
347
+		// not in allprop or autoindex
327 348
 
328 349
 		$files = array();
329 350
 
@@ -481,7 +502,10 @@  discard block
 block discarded – undo
481 502
 				switch($filter['name'])
482 503
 				{
483 504
 					case 'comp-filter':
484
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
505
+						if ($this->debug > 1)
506
+						{
507
+							error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
508
+						}
485 509
 
486 510
 						switch($filter['attrs']['name'])
487 511
 						{
@@ -496,14 +520,23 @@  discard block
 block discarded – undo
496 520
 						}
497 521
 						break;
498 522
 					case 'prop-filter':
499
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
523
+						if ($this->debug > 1)
524
+						{
525
+							error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
526
+						}
500 527
 						$prop_filter = $filter['attrs']['name'];
501 528
 						break;
502 529
 					case 'text-match':
503
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
530
+						if ($this->debug > 1)
531
+						{
532
+							error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
533
+						}
504 534
 						if (!isset($this->filter_prop2cal[strtoupper($prop_filter)]))
505 535
 						{
506
-							if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
536
+							if ($this->debug)
537
+							{
538
+								error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
539
+							}
507 540
 						}
508 541
 						else
509 542
 						{
@@ -512,10 +545,16 @@  discard block
 block discarded – undo
512 545
 						unset($prop_filter);
513 546
 						break;
514 547
 					case 'param-filter':
515
-						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
548
+						if ($this->debug)
549
+						{
550
+							error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
551
+						}
516 552
 						break;
517 553
 					case 'time-range':
518
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
554
+				 		if ($this->debug > 1)
555
+				 		{
556
+				 			error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
557
+				 		}
519 558
 				 		if (!empty($filter['attrs']['start']))
520 559
 				 		{
521 560
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
@@ -526,13 +565,19 @@  discard block
 block discarded – undo
526 565
 				 		}
527 566
 						break;
528 567
 					default:
529
-						if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
568
+						if ($this->debug)
569
+						{
570
+							error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
571
+						}
530 572
 						break;
531 573
 				}
532 574
 			}
533
-			if (count($cal_filters) == $num_filters)	// no filters set --> restore default start and end time
575
+			if (count($cal_filters) == $num_filters)
576
+			{
577
+				// no filters set --> restore default start and end time
534 578
 			{
535 579
 				$cal_filters['start'] = $cal_start;
580
+			}
536 581
 				$cal_filters['end']   = $cal_end;
537 582
 			}
538 583
 		}
@@ -609,7 +654,10 @@  discard block
 block discarded – undo
609 654
 				}
610 655
 			}
611 656
 
612
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
657
+			if ($this->debug > 1)
658
+			{
659
+				error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
660
+			}
613 661
 		}
614 662
 		return true;
615 663
 	}
@@ -655,9 +703,15 @@  discard block
 block discarded – undo
655 703
 	private function iCal(array $event,$user=null, $method=null, $expand=false)
656 704
 	{
657 705
 		static $handler = null;
658
-		if (is_null($handler)) $handler = $this->_get_handler();
706
+		if (is_null($handler))
707
+		{
708
+			$handler = $this->_get_handler();
709
+		}
659 710
 
660
-		if (!$user) $user = $GLOBALS['egw_info']['user']['account_id'];
711
+		if (!$user)
712
+		{
713
+			$user = $GLOBALS['egw_info']['user']['account_id'];
714
+		}
661 715
 
662 716
 		// only return alarms in own calendar, not other users calendars
663 717
 		if ($user != $GLOBALS['egw_info']['user']['account_id'])
@@ -673,8 +727,14 @@  discard block
 block discarded – undo
673 727
 		{
674 728
 			if (is_array($expand))
675 729
 			{
676
-				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
677
-				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
730
+				if (isset($expand['start']))
731
+				{
732
+					$expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
733
+				}
734
+				if (isset($expand['end']))
735
+				{
736
+					$expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
737
+				}
678 738
 			}
679 739
 			$events =& self::get_series($event['uid'], $this->bo, $expand, $user);
680 740
 		}
@@ -698,7 +758,10 @@  discard block
 block discarded – undo
698 758
 	 */
699 759
 	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null)
700 760
 	{
701
-		if (is_null($bo)) $bo = new calendar_bopdate();
761
+		if (is_null($bo))
762
+		{
763
+			$bo = new calendar_bopdate();
764
+		}
702 765
 
703 766
 		$params = array(
704 767
 			'query' => array('cal_uid' => $uid),
@@ -707,7 +770,10 @@  discard block
 block discarded – undo
707 770
 			'date_format' => 'server',
708 771
 			'cfs' => array(),	// read cfs as we use them to store X- attributes
709 772
 		);
710
-		if (is_array($expand)) $params += $expand;
773
+		if (is_array($expand))
774
+		{
775
+			$params += $expand;
776
+		}
711 777
 
712 778
 		if (!($events =& $bo->search($params)))
713 779
 		{
@@ -728,12 +794,17 @@  discard block
 block discarded – undo
728 794
 			}
729 795
 		}
730 796
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
731
-		if (!isset($master)) $master = $bo->read($uid);
797
+		if (!isset($master))
798
+		{
799
+			$master = $bo->read($uid);
800
+		}
732 801
 
733 802
 		foreach($events as $k => &$recurrence)
734 803
 		{
735 804
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
736
-			if (!$master || $recurrence['id'] != $master['id'])	// real exception
805
+			if (!$master || $recurrence['id'] != $master['id'])
806
+			{
807
+				// real exception
737 808
 			{
738 809
 				// user is NOT participating in this exception
739 810
 				if ($user && !self::isParticipant($recurrence, $user))
@@ -742,6 +813,7 @@  discard block
 block discarded – undo
742 813
 					if (!$master || !self::isParticipant($master, $user))
743 814
 					{
744 815
 						unset($events[$k]);
816
+			}
745 817
 						continue;
746 818
 					}
747 819
 					// otherwise mark him in this exception as rejected
@@ -777,7 +849,10 @@  discard block
 block discarded – undo
777 849
 			// this is a virtual exception now (no extra event/cal_id in DB)
778 850
 			//error_log('virtual exception: '.array2string($recurrence));
779 851
 			$recurrence['recurrence'] = $recurrence['start'];
780
-			if ($master) $recurrence['reference'] = $master['id'];
852
+			if ($master)
853
+			{
854
+				$recurrence['reference'] = $master['id'];
855
+			}
781 856
 			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
782 857
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
783 858
 		}
@@ -814,9 +889,16 @@  discard block
 block discarded – undo
814 889
 	 */
815 890
 	function put(&$options,$id,$user=null,$prefix=null)
816 891
 	{
817
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
892
+		if ($this->debug)
893
+		{
894
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
895
+		}
818 896
 
819
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
897
+		if (!$prefix)
898
+		{
899
+			$user = null;
900
+		}
901
+		// /infolog/ does not imply setting the current user (for new entries it's done anyway)
820 902
 
821 903
 		// fix for iCal4OL using WinHTTP only supporting a certain header length
822 904
 		if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
@@ -828,7 +910,10 @@  discard block
 block discarded – undo
828 910
 			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
829 911
 		if (!is_null($oldEvent) && !is_array($oldEvent))
830 912
 		{
831
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
913
+			if ($this->debug)
914
+			{
915
+				error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
916
+			}
832 917
 			return $oldEvent;
833 918
 		}
834 919
 
@@ -839,7 +924,10 @@  discard block
 block discarded – undo
839 924
 		{
840 925
 			// we have no add permission on this user's calendar
841 926
 			// ToDo: create event in current users calendar and invite only $user
842
-			if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
927
+			if ($this->debug)
928
+			{
929
+				error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
930
+			}
843 931
 			return '403 Forbidden';
844 932
 		}
845 933
 
@@ -887,13 +975,19 @@  discard block
 block discarded – undo
887 975
 			if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
888 976
 			{
889 977
 				$schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'];
890
-				if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1);
978
+				if ($schedule_tag_match[0] == '"')
979
+				{
980
+					$schedule_tag_match = substr($schedule_tag_match, 1, -1);
981
+				}
891 982
 				$schedule_tag = null;
892 983
 				$this->get_etag($oldEvent, $schedule_tag);
893 984
 
894 985
 				if ($schedule_tag_match !== $schedule_tag)
895 986
 				{
896
-					if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
987
+					if ($this->debug)
988
+					{
989
+						error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
990
+					}
897 991
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
898 992
 					$this->check_return_representation($options, $id, $user);
899 993
 					return '412 Precondition Failed';
@@ -908,7 +1002,10 @@  discard block
 block discarded – undo
908 1002
 					// above can be true, if current user is not in master but just a recurrence
909 1003
 					(!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo))))
910 1004
 				{
911
-					if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1005
+					if ($this->debug)
1006
+					{
1007
+						error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1008
+					}
912 1009
 					return '403 Forbidden';
913 1010
 				}
914 1011
 				// update only participant status and alarms of current user
@@ -928,7 +1025,10 @@  discard block
 block discarded – undo
928 1025
 							}
929 1026
 							foreach($series as $oldEvent)
930 1027
 							{
931
-								if ($oldEvent['recurrence'] == $event['recurrence']) break;
1028
+								if ($oldEvent['recurrence'] == $event['recurrence'])
1029
+								{
1030
+									break;
1031
+								}
932 1032
 							}
933 1033
 							// if no exception found, check if it might be just a recurrence (no exception)
934 1034
 							if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence'])
@@ -943,7 +1043,10 @@  discard block
 block discarded – undo
943 1043
 								}
944 1044
 							}
945 1045
 						}
946
-						if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1046
+						if ($this->debug)
1047
+						{
1048
+							error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1049
+						}
947 1050
 						if (isset($event['participants']) && isset($event['participants'][$user]) &&
948 1051
 							$event['participants'][$user] !== $oldEvent['participants'][$user])
949 1052
 						{
@@ -951,13 +1054,19 @@  discard block
 block discarded – undo
951 1054
 								// real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence!
952 1055
 								$recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0))
953 1056
 							{
954
-								if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1057
+								if ($this->debug)
1058
+								{
1059
+									error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1060
+								}
955 1061
 								return '403 Forbidden';
956 1062
 							}
957 1063
 							else
958 1064
 							{
959 1065
 								++$modified;
960
-								if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1066
+								if ($this->debug)
1067
+								{
1068
+									error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1069
+								}
961 1070
 							}
962 1071
 						}
963 1072
 						// import alarms, if given and changed
@@ -967,15 +1076,21 @@  discard block
 block discarded – undo
967 1076
 							$modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user);
968 1077
 						}
969 1078
 					}
970
-					if (!$modified)	// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
1079
+					if (!$modified)
1080
+					{
1081
+						// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
971 1082
 					{
972 1083
 						$this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
973 1084
 					}
1085
+					}
974 1086
 					$this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name');
975 1087
 
976 1088
 					return '204 No Content';
977 1089
 				}
978
-				if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1090
+				if ($this->debug && !isset($events))
1091
+				{
1092
+					error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1093
+				}
979 1094
 			}
980 1095
 			if ($return_no_access)
981 1096
 			{
@@ -1007,17 +1122,23 @@  discard block
 block discarded – undo
1007 1122
 		if (!($cal_id = $handler->importVCal($vCalendar, $eventId,
1008 1123
 			self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id)))
1009 1124
 		{
1010
-			if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1125
+			if ($this->debug)
1126
+			{
1127
+				error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1128
+			}
1011 1129
 			if ($eventId && $cal_id === false)
1012 1130
 			{
1013 1131
 				// ignore import failures
1014 1132
 				$cal_id = $eventId;
1015 1133
 				$retval = true;
1016 1134
 			}
1017
-			elseif ($cal_id === 0)	// etag failure
1135
+			elseif ($cal_id === 0)
1136
+			{
1137
+				// etag failure
1018 1138
 			{
1019 1139
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
1020 1140
 				$this->check_return_representation($options, $id, $user);
1141
+			}
1021 1142
 				return '412 Precondition Failed';
1022 1143
 			}
1023 1144
 			else
@@ -1042,7 +1163,10 @@  discard block
 block discarded – undo
1042 1163
 	 */
1043 1164
 	function post(&$options,$id,$user=null)
1044 1165
 	{
1045
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1166
+		if ($this->debug)
1167
+		{
1168
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
1169
+		}
1046 1170
 
1047 1171
 		$vCalendar = htmlspecialchars_decode($options['content']);
1048 1172
 		$charset = null;
@@ -1097,7 +1221,10 @@  discard block
 block discarded – undo
1097 1221
 				if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null,
1098 1222
 					false, 0, $this->caldav->current_user_principal, $user, $charset)))
1099 1223
 				{
1100
-					if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
1224
+					if ($this->debug)
1225
+					{
1226
+						error_log(__METHOD__."() importVCal($eventId) returned false");
1227
+					}
1101 1228
 				}
1102 1229
 				header('ETag: "'.$this->get_etag($eventId).'"');
1103 1230
 			}
@@ -1265,7 +1392,10 @@  discard block
 block discarded – undo
1265 1392
 		$org_recurrences = $exceptions = array();
1266 1393
 		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1267 1394
 		{
1268
-			if (!$k) $master = $event;
1395
+			if (!$k)
1396
+			{
1397
+				$master = $event;
1398
+			}
1269 1399
 			if ($event['recurrence'])
1270 1400
 			{
1271 1401
 				$org_recurrences[$event['recurrence']] = $event;
@@ -1285,10 +1415,13 @@  discard block
 block discarded – undo
1285 1415
 
1286 1416
 			// from now on we deal with exceptions
1287 1417
 			$org_recurrence = $org_recurrences[$recurrence['recurrence']];
1288
-			if (isset($org_recurrence))	// already existing recurrence
1418
+			if (isset($org_recurrence))
1419
+			{
1420
+				// already existing recurrence
1289 1421
 			{
1290 1422
 				//error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']);
1291 1423
 				$recurrence['id'] = $org_recurrence['id'];
1424
+			}
1292 1425
 
1293 1426
 				// re-add (non-virtual) exceptions to master's recur_exception
1294 1427
 				if ($recurrence['id'] != $master['id'])
@@ -1305,10 +1438,14 @@  discard block
 block discarded – undo
1305 1438
 		// delete not longer existing recurrences
1306 1439
 		foreach($org_recurrences as $org_recurrence)
1307 1440
 		{
1308
-			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1441
+			if ($org_recurrence['id'] != $master['id'])
1442
+			{
1443
+				// non-virtual recurrence
1309 1444
 			{
1310 1445
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1311
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1446
+				$bo->delete($org_recurrence['id']);
1447
+			}
1448
+			// might fail because of permissions
1312 1449
 			}
1313 1450
 			else	// virtual recurrence
1314 1451
 			{
@@ -1339,7 +1476,7 @@  discard block
 block discarded – undo
1339 1476
 		if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access)
1340 1477
 		{
1341 1478
  			if (!$return_no_access)
1342
-			{
1479
+ 			{
1343 1480
 				// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1344 1481
 				$ret = '403 Forbidden';
1345 1482
 				$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
@@ -1362,7 +1499,10 @@  discard block
 block discarded – undo
1362 1499
 		{
1363 1500
 			$ret = $this->bo->delete($event['id']);
1364 1501
 		}
1365
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1502
+		if ($this->debug)
1503
+		{
1504
+			error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1505
+		}
1366 1506
 		return $ret;
1367 1507
 	}
1368 1508
 
@@ -1377,16 +1517,26 @@  discard block
 block discarded – undo
1377 1517
 	 */
1378 1518
 	function read($id)
1379 1519
 	{
1380
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1520
+		if (strpos($column=self::$path_attr,'_') === false)
1521
+		{
1522
+			$column = 'cal_'.$column;
1523
+		}
1381 1524
 
1382 1525
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1383
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1526
+		if ($event)
1527
+		{
1528
+			$event = array_shift($event);
1529
+		}
1530
+		// read with array as 1. param, returns an array of events!
1384 1531
 
1385 1532
 		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1386 1533
 			// above can be true, if current user is not in master but just a recurrence
1387 1534
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1388 1535
 		{
1389
-			if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1536
+			if ($this->debug > 0)
1537
+			{
1538
+				error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1539
+			}
1390 1540
 			return $retval;
1391 1541
 		}
1392 1542
 		if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server'))
@@ -1394,9 +1544,15 @@  discard block
 block discarded – undo
1394 1544
 			$this->bo->clear_private_infos($event, array($this->bo->user, $event['owner']));
1395 1545
 		}
1396 1546
 		// handle deleted events, as not existing
1397
-		if ($event['deleted']) $event = null;
1547
+		if ($event['deleted'])
1548
+		{
1549
+			$event = null;
1550
+		}
1398 1551
 
1399
-		if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event));
1552
+		if ($this->debug > 1)
1553
+		{
1554
+			error_log(__METHOD__."($id) returning ".array2string($event));
1555
+		}
1400 1556
 
1401 1557
 		return $event;
1402 1558
 	}
@@ -1408,7 +1564,10 @@  discard block
 block discarded – undo
1408 1564
 	 */
1409 1565
 	public function update_tags($entry)
1410 1566
 	{
1411
-		if (!is_array($entry)) $entry = $this->read($entry);
1567
+		if (!is_array($entry))
1568
+		{
1569
+			$entry = $this->read($entry);
1570
+		}
1412 1571
 
1413 1572
 		$this->bo->update($entry, true);
1414 1573
 	}
@@ -1422,7 +1581,10 @@  discard block
 block discarded – undo
1422 1581
 	{
1423 1582
 		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1424 1583
 
1425
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1584
+		if ($this->debug > 1)
1585
+		{
1586
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1587
+		}
1426 1588
 
1427 1589
 		return $ctag;
1428 1590
 	}
@@ -1553,7 +1715,10 @@  discard block
 block discarded – undo
1553 1715
 		$handler = new calendar_ical();
1554 1716
 		$handler->setSupportedFields('GroupDAV',$this->agent);
1555 1717
 		$handler->supportedFields['attachments'] = true;	// enabling attachments
1556
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1718
+		if ($this->debug > 1)
1719
+		{
1720
+			error_log("ical Handler called: " . $this->agent);
1721
+		}
1557 1722
 		return $handler;
1558 1723
 	}
1559 1724
 
@@ -1624,7 +1789,11 @@  discard block
 block discarded – undo
1624 1789
 			{
1625 1790
 				$calendars[$entry['grantor']] = $entry['name'];
1626 1791
 			}
1627
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1792
+			if ($user > 0)
1793
+			{
1794
+				unset($calendars[$user]);
1795
+			}
1796
+			// skip current user
1628 1797
 		}
1629 1798
 
1630 1799
 		$settings = array();
Please login to merge, or discard this patch.
Spacing   +148 added lines, -149 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $id =''
142 142
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
143 143
 	 */
144
-	function propfind($path,&$options,&$files,$user,$id='')
144
+	function propfind($path, &$options, &$files, $user, $id = '')
145 145
 	{
146 146
 		if ($this->debug)
147 147
 		{
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 			'enum_recuring' => false,
168 168
 			'daywise' => false,
169 169
 			'date_format' => 'server',
170
-			'no_total' => true,	// we need no total number of rows (saves extra query)
171
-			'cfs' => array(),	// return custom-fields, as we use them to store X- attributes
170
+			'no_total' => true, // we need no total number of rows (saves extra query)
171
+			'cfs' => array(), // return custom-fields, as we use them to store X- attributes
172 172
 		);
173
-		foreach(array(
173
+		foreach (array(
174 174
 			'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'],
175 175
 			'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'],
176 176
 		) as $name => $value)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			{
180 180
 				$value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT;
181 181
 			}
182
-			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
182
+			$filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value);
183 183
 		}
184 184
 		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
185 185
 		{
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 			$filter['filter'] = 'owner';
192 192
 		}
193 193
 		// scheduling inbox, shows only not yet accepted or rejected events
194
-		elseif (substr($path,-7) == '/inbox/')
194
+		elseif (substr($path, -7) == '/inbox/')
195 195
 		{
196 196
 			$filter['filter'] = 'unknown';
197
-			$filter['start'] = $this->bo->now;	// only return future invitations
197
+			$filter['start'] = $this->bo->now; // only return future invitations
198 198
 		}
199 199
 		// ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now
200
-		elseif (substr($path,-8) == '/outbox/')
200
+		elseif (substr($path, -8) == '/outbox/')
201 201
 		{
202 202
 			return true;
203 203
 		}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			// when trying to request not supported components, eg. VTODO on a calendar collection
215 215
 			return true;
216 216
 		}
217
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
217
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
218 218
 
219 219
 		if ($this->debug > 1)
220 220
 		{
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 			$this->sync_collection_token = null;
233 233
 
234
-			$filter['order'] = 'cal_modified ASC';	// return oldest modifications first
234
+			$filter['order'] = 'cal_modified ASC'; // return oldest modifications first
235 235
 			$filter['sync-collection'] = true;
236 236
 			// no end-date / limit into the future, as unchanged entries would never be transferted later on
237 237
 			unset($filter['end']);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 		if (isset($nresults))
241 241
 		{
242
-			unset($filter['no_total']);	// we need the total!
242
+			unset($filter['no_total']); // we need the total!
243 243
 			$files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults));
244 244
 
245 245
 			// hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first)
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
249 249
 			{
250 250
 				--$this->sync_collection_token;
251
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
251
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
252 252
 			}
253 253
 		}
254 254
 		else
255 255
 		{
256 256
 			// return iterator, calling ourself to return result in chunks
257
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
257
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
258 258
 		}
259 259
 		if (isset($_GET['download']))
260 260
 		{
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 		Api\Header\Content::type('calendar.ics', 'text/calendar');
275 275
 
276 276
 		$n = 0;
277
-		foreach($files as $file)
277
+		foreach ($files as $file)
278 278
 		{
279
-			if (!$n++) continue;	// first entry is collection itself
279
+			if (!$n++) continue; // first entry is collection itself
280 280
 
281 281
 			$icalendar = $file['props']['calendar-data']['val'];
282 282
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 						echo substr($icalendar, 0, $start);
301 301
 					}
302 302
 				}
303
-				echo substr($icalendar, $start, $end-$start);
303
+				echo substr($icalendar, $start, $end - $start);
304 304
 			}
305 305
 		}
306 306
 		if ($icalendar && $end)
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 	 * @param array|boolean $start =false false=return all or array(start,num)
319 319
 	 * @return array with "files" array with values for keys path and props
320 320
 	 */
321
-	function &propfind_callback($path,array $filter,$start=false)
321
+	function &propfind_callback($path, array $filter, $start = false)
322 322
 	{
323 323
 		if ($this->debug) $starttime = microtime(true);
324 324
 
325 325
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
326
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
326
+		if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex
327 327
 
328 328
 		$files = array();
329 329
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		$requested_multiget_ids = (array)$filter['query'][self::$path_attr];
336 336
 		$sync_collection = $filter['sync-collection'];
337 337
 
338
-		$events =& $this->bo->search($filter);
338
+		$events = & $this->bo->search($filter);
339 339
 
340 340
 		if ($events)
341 341
 		{
342
-			foreach($events as $event)
342
+			foreach ($events as $event)
343 343
 			{
344 344
 				// remove event from requested multiget ids, to be able to report not found urls
345 345
 				if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 					unset($requested_multiget_ids[$k]);
348 348
 				}
349 349
 				// sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations
350
-				if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R','X'))))
350
+				if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R', 'X'))))
351 351
 				{
352 352
 					$files[] = array('path' => $path.urldecode($this->get_path($event)));
353 353
 					continue;
@@ -375,10 +375,9 @@  discard block
 block discarded – undo
375 375
 				{
376 376
 					$content = $this->iCal($event, $filter['users'],
377 377
 						strpos($path, '/inbox/') !== false ? 'REQUEST' : null,
378
-						!isset($calendar_data['children']['expand']) ? false :
379
-							($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
378
+						!isset($calendar_data['children']['expand']) ? false : ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
380 379
 					$props['getcontentlength'] = bytes($content);
381
-					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
380
+					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
382 381
 				}
383 382
 				/* Calendarserver reports new events with schedule-changes: action: create, which iCal request
384 383
 				 * adding it, unfortunately does not lead to showing the new event in the users inbox
@@ -397,7 +396,7 @@  discard block
 block discarded – undo
397 396
 		// report not found multiget urls
398 397
 		if ($requested_multiget_ids)
399 398
 		{
400
-			foreach($requested_multiget_ids as $id)
399
+			foreach ($requested_multiget_ids as $id)
401 400
 			{
402 401
 				$files[] = array('path' => $path.$id.self::$path_extension);
403 402
 			}
@@ -433,7 +432,7 @@  discard block
 block discarded – undo
433 432
 	private function _created_updated_by_prop($user, $time)
434 433
 	{
435 434
 		$props = array();
436
-		foreach(array(
435
+		foreach (array(
437 436
 			'first-name' => 'account_firstname',
438 437
 			'last-name' => 'account_lastname',
439 438
 			'href' => 'account_email',
@@ -476,23 +475,23 @@  discard block
 block discarded – undo
476 475
 			$cal_end = $cal_filters['end']; unset($cal_filters['end']);
477 476
 			$num_filters = count($cal_filters);
478 477
 
479
-			foreach($options['filters'] as $filter)
478
+			foreach ($options['filters'] as $filter)
480 479
 			{
481
-				switch($filter['name'])
480
+				switch ($filter['name'])
482 481
 				{
483 482
 					case 'comp-filter':
484 483
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
485 484
 
486
-						switch($filter['attrs']['name'])
485
+						switch ($filter['attrs']['name'])
487 486
 						{
488 487
 							case 'VTODO':
489
-								return false;	// return nothing for now, todo: check if we can pass it on to the infolog handler
488
+								return false; // return nothing for now, todo: check if we can pass it on to the infolog handler
490 489
 								// todos are handled by the infolog handler
491 490
 								//$infolog_handler = new groupdav_infolog();
492 491
 								//return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method);
493 492
 							case 'VCALENDAR':
494 493
 							case 'VEVENT':
495
-								break;			// that's our default anyway
494
+								break; // that's our default anyway
496 495
 						}
497 496
 						break;
498 497
 					case 'prop-filter':
@@ -515,14 +514,14 @@  discard block
 block discarded – undo
515 514
 						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
516 515
 						break;
517 516
 					case 'time-range':
518
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
517
+				 		if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
519 518
 				 		if (!empty($filter['attrs']['start']))
520 519
 				 		{
521 520
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
522 521
 				 		}
523 522
 				 		if (!empty($filter['attrs']['end']))
524 523
 				 		{
525
-					 		$cal_filters['end']   = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
524
+					 		$cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
526 525
 				 		}
527 526
 						break;
528 527
 					default:
@@ -543,9 +542,9 @@  discard block
 block discarded – undo
543 542
 		    <B:nresults>10</B:nresults>
544 543
 		  </B:limit>
545 544
 		*/
546
-		foreach((array)$options['other'] as $option)
545
+		foreach ((array)$options['other'] as $option)
547 546
 		{
548
-			switch($option['name'])
547
+			switch ($option['name'])
549 548
 			{
550 549
 				case 'nresults':
551 550
 					$nresults = (int)$option['data'];
@@ -554,7 +553,7 @@  discard block
 block discarded – undo
554 553
 				case 'limit':
555 554
 					break;
556 555
 				case 'href':
557
-					break;	// from addressbook-multiget, handled below
556
+					break; // from addressbook-multiget, handled below
558 557
 				// rfc 6578 sync-report
559 558
 				case 'sync-token':
560 559
 					if (!empty($option['data']))
@@ -562,7 +561,7 @@  discard block
 block discarded – undo
562 561
 						$parts = explode('/', $option['data']);
563 562
 						$sync_token = array_pop($parts);
564 563
 						$cal_filters['query'][] = 'cal_modified>'.(int)$sync_token;
565
-						$cal_filters['filter'] = 'everything';	// to return deleted entries too
564
+						$cal_filters['filter'] = 'everything'; // to return deleted entries too
566 565
 						// no standard time-range!
567 566
 						unset($cal_filters['start']);
568 567
 					}
@@ -591,25 +590,25 @@  discard block
 block discarded – undo
591 590
 			if ($id)
592 591
 			{
593 592
 				$cal_filters['query'][self::$path_attr] = self::$path_extension ?
594
-					basename($id,self::$path_extension) : $id;
593
+					basename($id, self::$path_extension) : $id;
595 594
 			}
596 595
 			else	// fetch all given url's
597 596
 			{
598
-				foreach($options['other'] as $option)
597
+				foreach ($options['other'] as $option)
599 598
 				{
600 599
 					if ($option['name'] == 'href')
601 600
 					{
602
-						$parts = explode('/',$option['data']);
601
+						$parts = explode('/', $option['data']);
603 602
 						if (($id = urldecode(array_pop($parts))))
604 603
 						{
605 604
 							$cal_filters['query'][self::$path_attr][] = self::$path_extension ?
606
-								basename($id,self::$path_extension) : $id;
605
+								basename($id, self::$path_extension) : $id;
607 606
 						}
608 607
 					}
609 608
 				}
610 609
 			}
611 610
 
612
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
611
+			if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters));
613 612
 		}
614 613
 		return true;
615 614
 	}
@@ -622,9 +621,9 @@  discard block
 block discarded – undo
622 621
 	 * @param int $user =null account_id
623 622
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
624 623
 	 */
625
-	function get(&$options,$id,$user=null)
624
+	function get(&$options, $id, $user = null)
626 625
 	{
627
-		if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id)))
626
+		if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id)))
628 627
 		{
629 628
 			return $event;
630 629
 		}
@@ -652,7 +651,7 @@  discard block
 block discarded – undo
652 651
 	 * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences
653 652
 	 * @return string
654 653
 	 */
655
-	private function iCal(array $event,$user=null, $method=null, $expand=false)
654
+	private function iCal(array $event, $user = null, $method = null, $expand = false)
656 655
 	{
657 656
 		static $handler = null;
658 657
 		if (is_null($handler)) $handler = $this->_get_handler();
@@ -676,11 +675,11 @@  discard block
 block discarded – undo
676 675
 				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
677 676
 				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
678 677
 			}
679
-			$events =& self::get_series($event['uid'], $this->bo, $expand, $user);
678
+			$events = & self::get_series($event['uid'], $this->bo, $expand, $user);
680 679
 		}
681
-		elseif(!$this->client_shared_uid_exceptions && $event['reference'])
680
+		elseif (!$this->client_shared_uid_exceptions && $event['reference'])
682 681
 		{
683
-			$events[0]['uid'] .= '-'.$event['id'];	// force a different uid
682
+			$events[0]['uid'] .= '-'.$event['id']; // force a different uid
684 683
 		}
685 684
 		return $handler->exportVCal($events, '2.0', $method);
686 685
 	}
@@ -696,20 +695,20 @@  discard block
 block discarded – undo
696 695
 	 * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in
697 696
 	 * @return array
698 697
 	 */
699
-	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null)
698
+	private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null)
700 699
 	{
701 700
 		if (is_null($bo)) $bo = new calendar_bopdate();
702 701
 
703 702
 		$params = array(
704 703
 			'query' => array('cal_uid' => $uid),
705
-			'filter' => 'owner',  // return all possible entries
704
+			'filter' => 'owner', // return all possible entries
706 705
 			'daywise' => false,
707 706
 			'date_format' => 'server',
708
-			'cfs' => array(),	// read cfs as we use them to store X- attributes
707
+			'cfs' => array(), // read cfs as we use them to store X- attributes
709 708
 		);
710 709
 		if (is_array($expand)) $params += $expand;
711 710
 
712
-		if (!($events =& $bo->search($params)))
711
+		if (!($events = & $bo->search($params)))
713 712
 		{
714 713
 			return array();
715 714
 		}
@@ -717,12 +716,12 @@  discard block
 block discarded – undo
717 716
 		// find master, which is not always first event, eg. when first event is an exception
718 717
 		$master = null;
719 718
 		$exceptions = array();
720
-		foreach($events as $k => &$recurrence)
719
+		foreach ($events as $k => &$recurrence)
721 720
 		{
722 721
 			if ($recurrence['recur_type'])
723 722
 			{
724 723
 				$master = $recurrence;
725
-				$exceptions =& $master['recur_exception'];
724
+				$exceptions = & $master['recur_exception'];
726 725
 				unset($events[$k]);
727 726
 				break;
728 727
 			}
@@ -730,7 +729,7 @@  discard block
 block discarded – undo
730 729
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
731 730
 		if (!isset($master)) $master = $bo->read($uid);
732 731
 
733
-		foreach($events as $k => &$recurrence)
732
+		foreach ($events as $k => &$recurrence)
734 733
 		{
735 734
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
736 735
 			if (!$master || $recurrence['id'] != $master['id'])	// real exception
@@ -752,16 +751,16 @@  discard block
 block discarded – undo
752 751
 				// at least Lightning "understands" EXDATE as exception from what's included
753 752
 				// in the whole resource / VCALENDAR component
754 753
 				// not removing it causes Lightning to remove the exception itself
755
-				if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false)
754
+				if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false)
756 755
 				{
757 756
 					unset($exceptions[$e]);
758 757
 				}
759
-				continue;	// nothing to change
758
+				continue; // nothing to change
760 759
 			}
761 760
 			// alarms are reported on recurrences --> move them to master
762 761
 			if ($master)
763 762
 			{
764
-				foreach($recurrence['alarm'] as $alarm)
763
+				foreach ($recurrence['alarm'] as $alarm)
765 764
 				{
766 765
 					$master['alarm'][] = $alarm;
767 766
 				}
@@ -771,14 +770,14 @@  discard block
 block discarded – undo
771 770
 			if (!$expand && $master && $master['participants'] == $recurrence['participants'])
772 771
 			{
773 772
 				//error_log('NO exception: '.array2string($recurrence));
774
-				unset($events[$k]);	// no exception --> remove it
773
+				unset($events[$k]); // no exception --> remove it
775 774
 				continue;
776 775
 			}
777 776
 			// this is a virtual exception now (no extra event/cal_id in DB)
778 777
 			//error_log('virtual exception: '.array2string($recurrence));
779 778
 			$recurrence['recurrence'] = $recurrence['start'];
780 779
 			if ($master) $recurrence['reference'] = $master['id'];
781
-			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
780
+			$recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master
782 781
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
783 782
 		}
784 783
 		// only add master if we are not expanding and current user participates in master (and not just some exceptions)
@@ -812,23 +811,23 @@  discard block
 block discarded – undo
812 811
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
813 812
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
814 813
 	 */
815
-	function put(&$options,$id,$user=null,$prefix=null)
814
+	function put(&$options, $id, $user = null, $prefix = null)
816 815
 	{
817
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
816
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
818 817
 
819
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
818
+		if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway)
820 819
 
821 820
 		// fix for iCal4OL using WinHTTP only supporting a certain header length
822 821
 		if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
823 822
 		{
824 823
 			$_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE'];
825 824
 		}
826
-		$return_no_access = true;	// as handled by importVCal anyway and allows it to set the status for participants
827
-		$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access,
828
-			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
825
+		$return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants
826
+		$oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access,
827
+			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case
829 828
 		if (!is_null($oldEvent) && !is_array($oldEvent))
830 829
 		{
831
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
830
+			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace());
832 831
 			return $oldEvent;
833 832
 		}
834 833
 
@@ -859,7 +858,7 @@  discard block
 block discarded – undo
859 858
 					switch (strtolower($key))
860 859
 					{
861 860
 						case 'charset':
862
-							$charset = strtoupper(substr($value,1,-1));
861
+							$charset = strtoupper(substr($value, 1, -1));
863 862
 					}
864 863
 				}
865 864
 			}
@@ -915,7 +914,7 @@  discard block
 block discarded – undo
915 914
 				if (($events = $handler->icaltoegw($vCalendar)))
916 915
 				{
917 916
 					$modified = 0;
918
-					foreach($events as $n => $event)
917
+					foreach ($events as $n => $event)
919 918
 					{
920 919
 						// for recurrances of event series, we need to read correct recurrence (or if series master is no first event)
921 920
 						if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series))
@@ -926,7 +925,7 @@  discard block
 block discarded – undo
926 925
 								$series = self::get_series($event['uid'], $this->bo);
927 926
 								//foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent));
928 927
 							}
929
-							foreach($series as $oldEvent)
928
+							foreach ($series as $oldEvent)
930 929
 							{
931 930
 								if ($oldEvent['recurrence'] == $event['recurrence']) break;
932 931
 							}
@@ -991,9 +990,9 @@  discard block
 block discarded – undo
991 990
 					isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']]))
992 991
 				{
993 992
 					// just update etag in database
994
-					$GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array(
993
+					$GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array(
995 994
 						'cal_id' => $eventId,
996
-					),__LINE__,__FILE__,'calendar');
995
+					), __LINE__, __FILE__, 'calendar');
997 996
 				}
998 997
 			}
999 998
 		}
@@ -1040,9 +1039,9 @@  discard block
 block discarded – undo
1040 1039
 	 * @param int $user =null account_id of owner, default null
1041 1040
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1042 1041
 	 */
1043
-	function post(&$options,$id,$user=null)
1042
+	function post(&$options, $id, $user = null)
1044 1043
 	{
1045
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1044
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
1046 1045
 
1047 1046
 		$vCalendar = htmlspecialchars_decode($options['content']);
1048 1047
 		$charset = null;
@@ -1059,13 +1058,13 @@  discard block
 block discarded – undo
1059 1058
 					switch (strtolower($key))
1060 1059
 					{
1061 1060
 						case 'charset':
1062
-							$charset = strtoupper(substr($value,1,-1));
1061
+							$charset = strtoupper(substr($value, 1, -1));
1063 1062
 					}
1064 1063
 				}
1065 1064
 			}
1066 1065
 		}
1067 1066
 
1068
-		if (substr($options['path'],-8) == '/outbox/')
1067
+		if (substr($options['path'], -8) == '/outbox/')
1069 1068
 		{
1070 1069
 			if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar))
1071 1070
 			{
@@ -1116,7 +1115,7 @@  discard block
 block discarded – undo
1116 1115
 	 */
1117 1116
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1118 1117
 	{
1119
-		unset($options);	// not used, but required by function signature
1118
+		unset($options); // not used, but required by function signature
1120 1119
 
1121 1120
 		$vcal = new Horde_Icalendar();
1122 1121
 		if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset))
@@ -1129,7 +1128,7 @@  discard block
 block discarded – undo
1129 1128
 
1130 1129
 		$handler = $this->_get_handler();
1131 1130
 		$handler->setSupportedFields('groupdav');
1132
-		$handler->calendarOwner = $handler->user = 0;	// to NOT default owner/organizer to something
1131
+		$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
1133 1132
 		if (!($component = $vcal->getComponent(0)) ||
1134 1133
 			!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
1135 1134
 		{
@@ -1154,13 +1153,13 @@  discard block
 block discarded – undo
1154 1153
 		$xml->startDocument('1.0', 'UTF-8');
1155 1154
 		$xml->startElementNs('C', 'schedule-response', Api\CalDAV::CALDAV);
1156 1155
 
1157
-		foreach(array_keys($event['participants']) as $uid)
1156
+		foreach (array_keys($event['participants']) as $uid)
1158 1157
 		{
1159 1158
 			$xml->startElementNs('C', 'response', null);
1160 1159
 
1161 1160
 			$xml->startElementNs('C', 'recipient', null);
1162
-			$xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees));
1163
-			$xml->endElement();	// recipient
1161
+			$xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees));
1162
+			$xml->endElement(); // recipient
1164 1163
 
1165 1164
 			$xml->writeElementNs('C', 'request-status', null, '2.0;Success');
1166 1165
 			$xml->writeElementNs('C', 'calendar-data', null,
@@ -1168,13 +1167,13 @@  discard block
 block discarded – undo
1168 1167
 					'UID' => $event['uid'],
1169 1168
 					'ORGANIZER' => $organizer,
1170 1169
 					'ATTENDEE' => $attendee,
1171
-				)+(empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1170
+				) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1172 1171
 					'X-CALENDARSERVER-MASK-UID' => $mask_uid,
1173 1172
 				))));
1174 1173
 
1175
-			$xml->endElement();	// response
1174
+			$xml->endElement(); // response
1176 1175
 		}
1177
-		$xml->endElement();	// schedule-response
1176
+		$xml->endElement(); // schedule-response
1178 1177
 		$xml->endDocument();
1179 1178
 		echo $xml->outputMemory();
1180 1179
 
@@ -1189,14 +1188,14 @@  discard block
 block discarded – undo
1189 1188
 	 * @param int $user account_id
1190 1189
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1191 1190
 	 */
1192
-	function free_busy_report($path,$options,$user)
1191
+	function free_busy_report($path, $options, $user)
1193 1192
 	{
1194
-		unset($path);	// unused, but required by function signature
1193
+		unset($path); // unused, but required by function signature
1195 1194
 		if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
1196 1195
 		{
1197 1196
 			return '403 Forbidden';
1198 1197
 		}
1199
-		foreach($options['other'] as $filter)
1198
+		foreach ($options['other'] as $filter)
1200 1199
 		{
1201 1200
 			if ($filter['name'] == 'time-range')
1202 1201
 			{
@@ -1208,7 +1207,7 @@  discard block
 block discarded – undo
1208 1207
 		header('Content-Type: text/calendar');
1209 1208
 		echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
1210 1209
 
1211
-		exit();	// otherwise we get a 207 multistatus, not 200 Ok
1210
+		exit(); // otherwise we get a 207 multistatus, not 200 Ok
1212 1211
 	}
1213 1212
 
1214 1213
 	/**
@@ -1220,7 +1219,7 @@  discard block
 block discarded – undo
1220 1219
 	 * @param int $user =null owner of the collection, default current user
1221 1220
 	 * @return array with privileges
1222 1221
 	 */
1223
-	public function current_user_privileges($path, $user=null)
1222
+	public function current_user_privileges($path, $user = null)
1224 1223
 	{
1225 1224
 		$privileges = parent::current_user_privileges($path, $user);
1226 1225
 		//error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges));
@@ -1263,7 +1262,7 @@  discard block
 block discarded – undo
1263 1262
 
1264 1263
 		// get array with orginal recurrences indexed by recurrence-id
1265 1264
 		$org_recurrences = $exceptions = array();
1266
-		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1265
+		foreach (self::get_series($events[0]['uid'], $bo) as $k => $event)
1267 1266
 		{
1268 1267
 			if (!$k) $master = $event;
1269 1268
 			if ($event['recurrence'])
@@ -1273,13 +1272,13 @@  discard block
 block discarded – undo
1273 1272
 		}
1274 1273
 
1275 1274
 		// assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master
1276
-		foreach($events as $k => &$recurrence)
1275
+		foreach ($events as $k => &$recurrence)
1277 1276
 		{
1278 1277
 			if (!$recurrence['recurrence'])
1279 1278
 			{
1280 1279
 				// master
1281 1280
 				$recurrence['id'] = $master['id'];
1282
-				$master =& $events[$k];
1281
+				$master = & $events[$k];
1283 1282
 				continue;
1284 1283
 			}
1285 1284
 
@@ -1303,12 +1302,12 @@  discard block
 block discarded – undo
1303 1302
 		$master['recur_exception'] = array_merge($exceptions, $master['recur_exception']);
1304 1303
 
1305 1304
 		// delete not longer existing recurrences
1306
-		foreach($org_recurrences as $org_recurrence)
1305
+		foreach ($org_recurrences as $org_recurrence)
1307 1306
 		{
1308 1307
 			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1309 1308
 			{
1310 1309
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1311
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1310
+				$bo->delete($org_recurrence['id']); // might fail because of permissions
1312 1311
 			}
1313 1312
 			else	// virtual recurrence
1314 1313
 			{
@@ -1329,25 +1328,25 @@  discard block
 block discarded – undo
1329 1328
 	 * @param int $id
1330 1329
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1331 1330
 	 */
1332
-	function delete(&$options,$id)
1331
+	function delete(&$options, $id)
1333 1332
 	{
1334 1333
 		if (strpos($options['path'], '/inbox/') !== false)
1335 1334
 		{
1336
-			return true;	// simply ignore DELETE in inbox for now
1335
+			return true; // simply ignore DELETE in inbox for now
1337 1336
 		}
1338
-		$return_no_access = true;	// to allow to check if current use is a participant and reject the event for him
1339
-		if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access)
1337
+		$return_no_access = true; // to allow to check if current use is a participant and reject the event for him
1338
+		if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access)
1340 1339
 		{
1341 1340
  			if (!$return_no_access)
1342 1341
 			{
1343 1342
 				// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1344 1343
 				$ret = '403 Forbidden';
1345 1344
 				$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
1346
-				foreach(array_keys($event['participants']) as $uid)
1345
+				foreach (array_keys($event['participants']) as $uid)
1347 1346
 				{
1348 1347
 					if ($this->bo->user == $uid || in_array($uid, $memberships))
1349 1348
 					{
1350
-						$this->bo->set_status($event,$this->bo->user, 'R');
1349
+						$this->bo->set_status($event, $this->bo->user, 'R');
1351 1350
 						$ret = true;
1352 1351
 						break;
1353 1352
 					}
@@ -1362,7 +1361,7 @@  discard block
 block discarded – undo
1362 1361
 		{
1363 1362
 			$ret = $this->bo->delete($event['id']);
1364 1363
 		}
1365
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1364
+		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret));
1366 1365
 		return $ret;
1367 1366
 	}
1368 1367
 
@@ -1377,12 +1376,12 @@  discard block
 block discarded – undo
1377 1376
 	 */
1378 1377
 	function read($id)
1379 1378
 	{
1380
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1379
+		if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column;
1381 1380
 
1382 1381
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1383
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1382
+		if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
1384 1383
 
1385
-		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1384
+		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server')) &&
1386 1385
 			// above can be true, if current user is not in master but just a recurrence
1387 1386
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1388 1387
 		{
@@ -1418,11 +1417,11 @@  discard block
 block discarded – undo
1418 1417
 	 *
1419 1418
 	 * @return string
1420 1419
 	 */
1421
-	public function getctag($path,$user)
1420
+	public function getctag($path, $user)
1422 1421
 	{
1423
-		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1422
+		$ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1424 1423
 
1425
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1424
+		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag");
1426 1425
 
1427 1426
 		return $ctag;
1428 1427
 	}
@@ -1434,7 +1433,7 @@  discard block
 block discarded – undo
1434 1433
 	 * @param string $schedule_tag =null on return schedule-tag
1435 1434
 	 * @return string|boolean string with etag or false
1436 1435
 	 */
1437
-	function get_etag($entry, &$schedule_tag=null)
1436
+	function get_etag($entry, &$schedule_tag = null)
1438 1437
 	{
1439 1438
 		$etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions);
1440 1439
 
@@ -1452,7 +1451,7 @@  discard block
 block discarded – undo
1452 1451
 	 * @param int|string $retval
1453 1452
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1454 1453
 	 */
1455
-	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
1454
+	function put_response_headers($entry, $path, $retval, $path_attr_is_name = true)
1456 1455
 	{
1457 1456
 		$schedule_tag = null;
1458 1457
 		$etag = $this->get_etag($entry, $schedule_tag);
@@ -1471,14 +1470,14 @@  discard block
 block discarded – undo
1471 1470
 	 * @param array|int $event event-array or id
1472 1471
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1473 1472
 	 */
1474
-	function check_access($acl,$event)
1473
+	function check_access($acl, $event)
1475 1474
 	{
1476 1475
 		if ($acl == Acl::READ)
1477 1476
 		{
1478 1477
 			// we need at least calendar_bo::ACL_FREEBUSY to get some information
1479 1478
 			$acl = calendar_bo::ACL_FREEBUSY;
1480 1479
 		}
1481
-		return $this->bo->check_perms($acl,$event,0,'server');
1480
+		return $this->bo->check_perms($acl, $event, 0, 'server');
1482 1481
 	}
1483 1482
 
1484 1483
 	/**
@@ -1491,53 +1490,53 @@  discard block
 block discarded – undo
1491 1490
 	 * @param string $path =null path of the collection
1492 1491
 	 * @return array
1493 1492
 	 */
1494
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null)
1493
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null)
1495 1494
 	{
1496
-		unset($base_uri);	// unused, but required by function signature
1495
+		unset($base_uri); // unused, but required by function signature
1497 1496
 		if (!isset($props['calendar-description']))
1498 1497
 		{
1499 1498
 			// default calendar description: can be overwritten via PROPPATCH, in which case it's already set
1500
-			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
1499
+			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
1501 1500
 		}
1502 1501
 		$supported_components = array(
1503
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')),
1504
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')),
1502
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')),
1503
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VEVENT')),
1505 1504
 		);
1506 1505
 		// outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations
1507
-		if (substr($path,-8) == '/outbox/')
1506
+		if (substr($path, -8) == '/outbox/')
1508 1507
 		{
1509
-			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY'));
1508
+			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VFREEBUSY'));
1510 1509
 		}
1511 1510
 		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,
1512
-			'supported-calendar-component-set',$supported_components);
1511
+			'supported-calendar-component-set', $supported_components);
1513 1512
 		// supported reports
1514 1513
 		$props['supported-report-set'] = array(
1515
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
1516
-				Api\CalDAV::mkprop('report',array(
1517
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
1518
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
1519
-				Api\CalDAV::mkprop('report',array(
1520
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
1521
-			'free-busy-query' => Api\CalDAV::mkprop('supported-report',array(
1522
-				Api\CalDAV::mkprop('report',array(
1523
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))),
1514
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
1515
+				Api\CalDAV::mkprop('report', array(
1516
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
1517
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
1518
+				Api\CalDAV::mkprop('report', array(
1519
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
1520
+			'free-busy-query' => Api\CalDAV::mkprop('supported-report', array(
1521
+				Api\CalDAV::mkprop('report', array(
1522
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'free-busy-query', ''))))),
1524 1523
 		);
1525 1524
 		// rfc 6578 sync-collection report for everything but outbox
1526 1525
 		// only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
1527 1526
 		if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history'])
1528 1527
 		{
1529
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
1530
-				Api\CalDAV::mkprop('report',array(
1531
-					Api\CalDAV::mkprop('sync-collection','')))));
1528
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
1529
+				Api\CalDAV::mkprop('report', array(
1530
+					Api\CalDAV::mkprop('sync-collection', '')))));
1532 1531
 		}
1533
-		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array(
1534
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1535
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1532
+		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-data', array(
1533
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1534
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1536 1535
 
1537 1536
 		// get timezone of calendar
1538 1537
 		if ($this->caldav->prop_requested('calendar-timezone'))
1539 1538
 		{
1540
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
1539
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
1541 1540
 				calendar_timezones::user_timezone($user));
1542 1541
 		}
1543 1542
 		return $props;
@@ -1551,9 +1550,9 @@  discard block
 block discarded – undo
1551 1550
 	private function _get_handler()
1552 1551
 	{
1553 1552
 		$handler = new calendar_ical();
1554
-		$handler->setSupportedFields('GroupDAV',$this->agent);
1555
-		$handler->supportedFields['attachments'] = true;	// enabling attachments
1556
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1553
+		$handler->setSupportedFields('GroupDAV', $this->agent);
1554
+		$handler->supportedFields['attachments'] = true; // enabling attachments
1555
+		if ($this->debug > 1) error_log("ical Handler called: ".$this->agent);
1557 1556
 		return $handler;
1558 1557
 	}
1559 1558
 
@@ -1568,7 +1567,7 @@  discard block
 block discarded – undo
1568 1567
 		$pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set'];
1569 1568
 		$calendar_home_set = $pref ? explode(',', $pref) : array();
1570 1569
 		// replace symbolic id's with real nummeric id's
1571
-		foreach(array(
1570
+		foreach (array(
1572 1571
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1573 1572
 		) as $sym => $id)
1574 1573
 		{
@@ -1577,11 +1576,11 @@  discard block
 block discarded – undo
1577 1576
 				$calendar_home_set[$key] = $id;
1578 1577
 			}
1579 1578
 		}
1580
-		foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1579
+		foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1581 1580
 		{
1582 1581
 			$id = $entry['grantor'];
1583
-			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user
1584
-				(in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) &&
1582
+			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user
1583
+				(in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) &&
1585 1584
 				is_numeric($id) && ($owner = $this->accounts->id2name($id)))
1586 1585
 			{
1587 1586
 				$shared[$id] = 'calendar-'.$owner;
@@ -1590,11 +1589,11 @@  discard block
 block discarded – undo
1590 1589
 		// shared locations and resources
1591 1590
 		if ($GLOBALS['egw_info']['user']['apps']['resources'])
1592 1591
 		{
1593
-			foreach(array('locations','resources') as $res)
1592
+			foreach (array('locations', 'resources') as $res)
1594 1593
 			{
1595 1594
 				if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res]))
1596 1595
 				{
1597
-					foreach(explode(',', $pref) as $res_id)
1596
+					foreach (explode(',', $pref) as $res_id)
1598 1597
 					{
1599 1598
 						$is_location = $res == 'locations';
1600 1599
 						$shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location));
@@ -1624,7 +1623,7 @@  discard block
 block discarded – undo
1624 1623
 			{
1625 1624
 				$calendars[$entry['grantor']] = $entry['name'];
1626 1625
 			}
1627
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1626
+			if ($user > 0) unset($calendars[$user]); // skip current user
1628 1627
 		}
1629 1628
 
1630 1629
 		$settings = array();
@@ -1632,7 +1631,7 @@  discard block
 block discarded – undo
1632 1631
 			'type'   => 'multiselect',
1633 1632
 			'label'  => 'Calendars to sync in addition to personal calendar',
1634 1633
 			'name'   => 'calendar-home-set',
1635
-			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1634
+			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1636 1635
 			'values' => $calendars,
1637 1636
 			'xmlrpc' => True,
1638 1637
 			'admin'  => False,
@@ -1658,7 +1657,7 @@  discard block
 block discarded – undo
1658 1657
 		if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = Api\CalDAV\Principals::get_resources()))
1659 1658
 		{
1660 1659
 			$resources = $locations = array();
1661
-			foreach($all_resources as $resource)
1660
+			foreach ($all_resources as $resource)
1662 1661
 			{
1663 1662
 				if (Api\CalDAV\Principals::resource_is_location($resource))
1664 1663
 				{
@@ -1669,7 +1668,7 @@  discard block
 block discarded – undo
1669 1668
 					$resources[$resource['res_id']] = $resource['name'];
1670 1669
 				}
1671 1670
 			}
1672
-			foreach(array(
1671
+			foreach (array(
1673 1672
 				'locations' => $locations,
1674 1673
 				'resources' => $resources,
1675 1674
 			) as $name => $options)
@@ -1682,7 +1681,7 @@  discard block
 block discarded – undo
1682 1681
 						'label'  => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')),
1683 1682
 						'no_lang'=> true,
1684 1683
 						'name'   => 'calendar-home-set-'.$name,
1685
-						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1684
+						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1686 1685
 						'values' => $options,
1687 1686
 						'xmlrpc' => True,
1688 1687
 						'admin'  => False,
Please login to merge, or discard this patch.
calendar/inc/class.calendar_holidays.inc.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -135,6 +135,9 @@
 block discarded – undo
135 135
 		return $until_year ? $years : $years[$year];
136 136
 	}
137 137
 
138
+	/**
139
+	 * @param string $url
140
+	 */
138 141
 	protected static function is_url($url)
139 142
 	{
140 143
 		return $url[0] == '/' || strpos($url, '://') !== false;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param int $year =null default current year
40 40
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
41 41
 	 */
42
-	public static function read($country, $year=null)
42
+	public static function read($country, $year = null)
43 43
 	{
44 44
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
45 45
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
48 48
 
49 49
 		// if we dont find holidays in cache, we render from previous year until next 5 years
50
-		if (!isset($holidays) && ($years = self::render($country, $year-1, $year+5)))
50
+		if (!isset($holidays) && ($years = self::render($country, $year - 1, $year + 5)))
51 51
 		{
52
-			foreach($years as $y => $data)
52
+			foreach ($years as $y => $data)
53 53
 			{
54 54
 				Api\Cache::setCache($level, __CLASS__, $country.':'.$y, $data, self::HOLIDAY_CACHE_TIME);
55 55
 			}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param int $until_year =null default, fetch only one year, if given result is indexed additional by year
67 67
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
68 68
 	 */
69
-	public static function render($country, $year=null, $until_year=null)
69
+	public static function render($country, $year = null, $until_year = null)
70 70
 	{
71 71
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
72 72
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			return array();
78 78
 		}
79 79
 		$years = array();
80
-		foreach($holidays as $event)
80
+		foreach ($holidays as $event)
81 81
 		{
82 82
 			$start = new Api\DateTime($event['start']);
83 83
 			$end = new Api\DateTime($event['end']);
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 			if ($event['recur_type'])
89 89
 			{
90 90
 				// calendar_rrule limits no enddate, to 5 years
91
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
91
+				if (!$event['recur_enddate']) $event['recur_enddate'] = (1 + $end_year).'0101';
92 92
 
93 93
 				$rrule = calendar_rrule::event2rrule($event);
94 94
 				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
95 95
 
96
-				foreach($rrule as $rtime)
96
+				foreach ($rrule as $rtime)
97 97
 				{
98 98
 					if (($y = (int)$rtime->format('Y')) < $year) continue;
99 99
 					if ($y > $end_year) break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			else
112 112
 			{
113 113
 				$end_ymd = (int)$end->format('Ymd');
114
-				while(($ymd = (int)$start->format('Ymd')) <= $end_ymd)
114
+				while (($ymd = (int)$start->format('Ymd')) <= $end_ymd)
115 115
 				{
116 116
 					$y = (int)$start->format('Y');
117 117
 					$years[$y][(string)$ymd][] = array(
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 				}
126 126
 			}
127 127
 		}
128
-		foreach($years as $y => &$data)
128
+		foreach ($years as $y => &$data)
129 129
 		{
130 130
 			ksort($data);
131 131
 		}
132
-		error_log(__METHOD__."('$country', $year, $end_year) took ".  number_format(microtime(true)-$starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events');
132
+		error_log(__METHOD__."('$country', $year, $end_year) took ".number_format(microtime(true) - $starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events');
133 133
 		unset($starttime);
134 134
 
135 135
 		return $until_year ? $years : $years[$year];
Please login to merge, or discard this patch.
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function read($country, $year=null)
43 43
 	{
44
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
44
+		if (!$year)
45
+		{
46
+			$year = (int)Api\DateTime::to('now', 'Y');
47
+		}
45 48
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
46 49
 
47 50
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
@@ -68,7 +71,10 @@  discard block
 block discarded – undo
68 71
 	 */
69 72
 	public static function render($country, $year=null, $until_year=null)
70 73
 	{
71
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
74
+		if (!$year)
75
+		{
76
+			$year = (int)Api\DateTime::to('now', 'Y');
77
+		}
72 78
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
73 79
 
74 80
 		$starttime = microtime(true);
@@ -81,22 +87,40 @@  discard block
 block discarded – undo
81 87
 		{
82 88
 			$start = new Api\DateTime($event['start']);
83 89
 			$end = new Api\DateTime($event['end']);
84
-			if ($start->format('Y') > $end_year) continue;
85
-			if ($end->format('Y') < $year && !$event['recur_type']) continue;
90
+			if ($start->format('Y') > $end_year)
91
+			{
92
+				continue;
93
+			}
94
+			if ($end->format('Y') < $year && !$event['recur_type'])
95
+			{
96
+				continue;
97
+			}
86 98
 
87 99
 			// recuring events
88 100
 			if ($event['recur_type'])
89 101
 			{
90 102
 				// calendar_rrule limits no enddate, to 5 years
91
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
103
+				if (!$event['recur_enddate'])
104
+				{
105
+					$event['recur_enddate'] = (1+$end_year).'0101';
106
+				}
92 107
 
93 108
 				$rrule = calendar_rrule::event2rrule($event);
94
-				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
109
+				if ($rrule->enddate && $rrule->enddate->format('Y') < $year)
110
+				{
111
+					continue;
112
+				}
95 113
 
96 114
 				foreach($rrule as $rtime)
97 115
 				{
98
-					if (($y = (int)$rtime->format('Y')) < $year) continue;
99
-					if ($y > $end_year) break;
116
+					if (($y = (int)$rtime->format('Y')) < $year)
117
+					{
118
+						continue;
119
+					}
120
+					if ($y > $end_year)
121
+					{
122
+						break;
123
+					}
100 124
 
101 125
 					$ymd = (int)$rtime->format('Ymd');
102 126
 					$years[$y][(string)$ymd][] = array(
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 4 patches
Doc Comments   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 *                          default 0 => export whole series (or events, if not recurring)
195 195
 	 * @param string $principalURL ='' Used for CalDAV exports
196 196
 	 * @param string $charset ='UTF-8' encoding of the vcalendar, default UTF-8
197
-	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
197
+	 * @param integer $current_user =0 uid of current user to only export that one as participant for method=REPLY
198 198
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
199 199
 	 */
200 200
 	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
@@ -1094,16 +1094,15 @@  discard block
 block discarded – undo
1094 1094
 	 * Import an iCal
1095 1095
 	 *
1096 1096
 	 * @param string|resource $_vcalData
1097
-	 * @param int $cal_id=-1 must be -1 for new entries!
1098
-	 * @param string $etag=null if an etag is given, it has to match the current etag or the import will fail
1099
-	 * @param boolean $merge=false	merge data with existing entry
1100
-	 * @param int $recur_date=0 if set, import the recurrence at this timestamp,
1097
+	 * @param int $cal_id must be -1 for new entries!
1098
+	 * @param int $recur_date if set, import the recurrence at this timestamp,
1101 1099
 	 *                          default 0 => import whole series (or events, if not recurring)
1102 1100
 	 * @param string $principalURL='' Used for CalDAV imports
1103
-	 * @param int $user=null account_id of owner, default null
1104 1101
 	 * @param string $charset  The encoding charset for $text. Defaults to
1105 1102
 	 *                         utf-8 for new format, iso-8859-1 for old format.
1106
-	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1103
+	 * @param string $caldav_name name from CalDAV client or null (to use default)
1104
+	 * @param integer $etag
1105
+	 * @param integer $user
1107 1106
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1108 1107
 	 */
1109 1108
 	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
@@ -3182,6 +3181,10 @@  discard block
 block discarded – undo
3182 3181
 		return $event;
3183 3182
 	}
3184 3183
 
3184
+	/**
3185
+	 * @param integer $contentID
3186
+	 * @param string $charset
3187
+	 */
3185 3188
 	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3186 3189
 	{
3187 3190
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
@@ -3221,6 +3224,7 @@  discard block
 block discarded – undo
3221 3224
 	 * @param string $method ='PUBLISH' or eg. 'REPLY'
3222 3225
 	 * @param array $extra =null extra attributes to add
3223 3226
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3227
+	 * @return string|null
3224 3228
 	 */
3225 3229
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3226 3230
 	{
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -483,15 +483,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +317 added lines, -81 removed lines patch added patch discarded remove patch
@@ -177,7 +177,10 @@  discard block
 block discarded – undo
177 177
 	function __construct(&$_clientProperties = array())
178 178
 	{
179 179
 		parent::__construct();
180
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
180
+		if ($this->log)
181
+		{
182
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
183
+		}
181 184
 		$this->clientProperties = $_clientProperties;
182 185
 		$this->vCalendar = new Horde_Icalendar;
183 186
 		$this->addressbook = new Api\Contacts;
@@ -226,10 +229,14 @@  discard block
 block discarded – undo
226 229
 			'ATTACH'        => 'attachments',
227 230
 		);
228 231
 
229
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
232
+		if (!is_array($this->supportedFields))
233
+		{
234
+			$this->setSupportedFields();
235
+		}
230 236
 
231 237
 		if ($this->productManufacturer == '' )
232
-		{	// syncevolution is broken
238
+		{
239
+// syncevolution is broken
233 240
 			$version = '2.0';
234 241
 		}
235 242
 
@@ -237,10 +244,16 @@  discard block
 block discarded – undo
237 244
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
238 245
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
239 246
 		$vcal->setAttribute('VERSION', $version);
240
-		if ($method) $vcal->setAttribute('METHOD', $method);
247
+		if ($method)
248
+		{
249
+			$vcal->setAttribute('METHOD', $method);
250
+		}
241 251
 		$events_exported = false;
242 252
 
243
-		if (!is_array($events)) $events = array($events);
253
+		if (!is_array($events))
254
+		{
255
+			$events = array($events);
256
+		}
244 257
 
245 258
 		$vtimezones_added = array();
246 259
 		foreach ($events as $event)
@@ -306,7 +319,10 @@  discard block
 block discarded – undo
306 319
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
307 320
 			}
308 321
 
309
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
322
+			if ($this->so->isWholeDay($event))
323
+			{
324
+				$event['whole_day'] = true;
325
+			}
310 326
 
311 327
 			if ($this->log)
312 328
 			{
@@ -317,7 +333,10 @@  discard block
 block discarded – undo
317 333
 
318 334
 			if ($recurrence)
319 335
 			{
320
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
336
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
337
+				{
338
+					continue;
339
+				}
321 340
 
322 341
 				if (!isset($this->supportedFields['participants']))
323 342
 				{
@@ -374,7 +393,8 @@  discard block
 block discarded – undo
374 393
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
375 394
 			{
376 395
 				// Append UID to DESCRIPTION
377
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
396
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
397
+				{
378 398
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
379 399
 				}
380 400
 			}
@@ -434,11 +454,21 @@  discard block
 block discarded – undo
434 454
 							$quantity = $role = null;
435 455
 							calendar_so::split_status($status, $quantity, $role);
436 456
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
437
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
457
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
458
+							{
459
+								continue;
460
+							}
438 461
 
439
-							if (!($info = $this->resource_info($uid))) continue;
462
+							if (!($info = $this->resource_info($uid)))
463
+							{
464
+								continue;
465
+							}
440 466
 
441
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
467
+							if (in_array($status, array('X','E')))
468
+							{
469
+								continue;
470
+							}
471
+							// dont include deleted participants
442 472
 
443 473
 							if ($this->log)
444 474
 							{
@@ -517,24 +547,49 @@  discard block
 block discarded – undo
517 547
 							}
518 548
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
519 549
 							$options = array();
520
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
521
-							if (!empty($role)) $options['ROLE'] = $role;
522
-							if (!empty($status)) $options['PARTSTAT'] = $status;
523
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
524
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
550
+							if (!empty($participantCN))
551
+							{
552
+								$options['CN'] = $participantCN;
553
+							}
554
+							if (!empty($role))
555
+							{
556
+								$options['ROLE'] = $role;
557
+							}
558
+							if (!empty($status))
559
+							{
560
+								$options['PARTSTAT'] = $status;
561
+							}
562
+							if (!empty($cutype))
563
+							{
564
+								$options['CUTYPE'] = $cutype;
565
+							}
566
+							if (!empty($rsvp))
567
+							{
568
+								$options['RSVP'] = $rsvp;
569
+							}
525 570
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
526 571
 							{
527 572
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
528 573
 							}
529
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
530
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
574
+							if ($info['type'] != 'e')
575
+							{
576
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
577
+							}
578
+							if ($quantity > 1)
579
+							{
580
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
581
+							}
531 582
 							$attributes['ATTENDEE'][] = $participantURL;
532 583
 							$parameters['ATTENDEE'][] = $options;
533 584
 						}
534 585
 						break;
535 586
 
536 587
 					case 'CLASS':
537
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
588
+						if ($event['public'])
589
+						{
590
+							continue;
591
+						}
592
+						// public is default, no need to export, fails CalDAVTester if added as default
538 593
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
539 594
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
540 595
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -566,9 +621,18 @@  discard block
 block discarded – undo
566 621
 									'CUTYPE'   => 'INDIVIDUAL',
567 622
 									//'RSVP'     => 'FALSE',
568 623
 									);
569
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
570
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
571
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
624
+								if (!empty($organizerCN))
625
+								{
626
+									$options['CN'] = $organizerCN;
627
+								}
628
+								if (!empty($organizerEMail))
629
+								{
630
+									$options['EMAIL'] = $organizerEMail;
631
+								}
632
+								if (!empty($event['owner']))
633
+								{
634
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
635
+								}
572 636
 								$attributes['ATTENDEE'][] = $organizerURL;
573 637
 			    				$parameters['ATTENDEE'][] = $options;
574 638
 		    				}
@@ -597,9 +661,12 @@  discard block
 block discarded – undo
597 661
 						{
598 662
 							// Hack for CalDAVTester to export duration instead of endtime
599 663
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
600
-								$attributes['duration'] = $event['end'] - $event['start'];
601
-							else
602
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
664
+							{
665
+															$attributes['duration'] = $event['end'] - $event['start'];
666
+							}
667
+							else {
668
+														$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
669
+							}
603 670
 						}
604 671
 						else
605 672
 						{
@@ -619,7 +686,11 @@  discard block
 block discarded – undo
619 686
 						break;
620 687
 
621 688
 					case 'RRULE':
622
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
689
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
690
+						{
691
+							break;
692
+						}
693
+						// no recuring event
623 694
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
624 695
 						$rrule = $rriter->generate_rrule($version);
625 696
 						if ($event['recur_enddate'])
@@ -653,7 +724,10 @@  discard block
 block discarded – undo
653 724
 						break;
654 725
 
655 726
 					case 'EXDATE':
656
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
727
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
728
+						{
729
+							break;
730
+						}
657 731
 						if (!empty($event['recur_exception']))
658 732
 						{
659 733
 							if (empty($event['whole_day']))
@@ -680,14 +754,21 @@  discard block
 block discarded – undo
680 754
 									);
681 755
 								}
682 756
 								$event['recur_exception'] = $days;
683
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
757
+								if ($version != '1.0')
758
+								{
759
+									$parameters['EXDATE']['VALUE'] = 'DATE';
760
+								}
684 761
 							}
685 762
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
686 763
 						}
687 764
 						break;
688 765
 
689 766
 					case 'PRIORITY':
690
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
767
+						if (!$event['priority'])
768
+						{
769
+							continue;
770
+						}
771
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
691 772
 						if ($this->productManufacturer == 'funambol' &&
692 773
 							(strpos($this->productName, 'outlook') !== false
693 774
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -701,7 +782,11 @@  discard block
 block discarded – undo
701 782
 						break;
702 783
 
703 784
 					case 'TRANSP':
704
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
785
+						if (!$event['non_blocking'])
786
+						{
787
+							continue;
788
+						}
789
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
705 790
 						if ($version == '1.0')
706 791
 						{
707 792
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -758,7 +843,11 @@  discard block
 block discarded – undo
758 843
 						elseif ($event['recurrence'] && $event['reference'])
759 844
 						{
760 845
 							// $event['reference'] is a calendar_id, not a timestamp
761
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
846
+							if (!($revent = $this->read($event['reference'])))
847
+							{
848
+								break;
849
+							}
850
+							// referenced event does not exist
762 851
 
763 852
 							if (empty($revent['whole_day']))
764 853
 							{
@@ -884,7 +973,10 @@  discard block
 block discarded – undo
884 973
 			foreach ((array)$event['alarm'] as $alarmData)
885 974
 			{
886 975
 				// skip over alarms that don't have the minimum required info
887
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
976
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
977
+				{
978
+					continue;
979
+				}
888 980
 
889 981
 				// skip alarms not being set for all users and alarms owned by other users
890 982
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -901,7 +993,10 @@  discard block
 block discarded – undo
901 993
 
902 994
 				if ($version == '1.0')
903 995
 				{
904
-					if ($event['title']) $description = $event['title'];
996
+					if ($event['title'])
997
+					{
998
+						$description = $event['title'];
999
+					}
905 1000
 					if ($description)
906 1001
 					{
907 1002
 						$values['DALARM']['snooze_time'] = '';
@@ -921,7 +1016,10 @@  discard block
 block discarded – undo
921 1016
 					// VCalendar 2.0 / RFC 2445
922 1017
 
923 1018
 					// RFC requires DESCRIPTION for DISPLAY
924
-					if (!$event['title'] && !$description) $description = 'Alarm';
1019
+					if (!$event['title'] && !$description)
1020
+					{
1021
+						$description = 'Alarm';
1022
+					}
925 1023
 
926 1024
 					/* Disabling for now
927 1025
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1112,13 +1210,20 @@  discard block
 block discarded – undo
1112 1210
 		$this->events_imported = 0;
1113 1211
 		$replace = $delete_exceptions= false;
1114 1212
 
1115
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1213
+		if (!is_array($this->supportedFields))
1214
+		{
1215
+			$this->setSupportedFields();
1216
+		}
1116 1217
 
1117 1218
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1118 1219
 		{
1119 1220
 			return false;
1120 1221
 		}
1121
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1222
+		if (!is_array($events))
1223
+		{
1224
+			$cal_id = -1;
1225
+		}
1226
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1122 1227
 
1123 1228
 		if ($cal_id > 0)
1124 1229
 		{
@@ -1126,8 +1231,14 @@  discard block
 block discarded – undo
1126 1231
 			{
1127 1232
 				$replace = $recur_date == 0;
1128 1233
 				$events[0]['id'] = $cal_id;
1129
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1130
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1234
+				if (!is_null($etag))
1235
+				{
1236
+					$events[0]['etag'] = (int) $etag;
1237
+				}
1238
+				if ($recur_date)
1239
+				{
1240
+					$events[0]['recurrence'] = $recur_date;
1241
+				}
1131 1242
 			}
1132 1243
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1133 1244
 					($eventId = array_shift($foundEvent)) &&
@@ -1135,7 +1246,10 @@  discard block
 block discarded – undo
1135 1246
 			{
1136 1247
 				foreach ($events as $k => $event)
1137 1248
 				{
1138
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1249
+					if (!isset($event['uid']))
1250
+					{
1251
+						$events[$k]['uid'] = $egwEvent['uid'];
1252
+					}
1139 1253
 				}
1140 1254
 			}
1141 1255
 		}
@@ -1165,10 +1279,17 @@  discard block
 block discarded – undo
1165 1279
 		$msg = null;
1166 1280
 		foreach ($events as $event)
1167 1281
 		{
1168
-			if (!is_array($event)) continue; // the iterator may return false
1282
+			if (!is_array($event))
1283
+			{
1284
+				continue;
1285
+			}
1286
+			// the iterator may return false
1169 1287
 			++$this->events_imported;
1170 1288
 
1171
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1289
+			if ($this->so->isWholeDay($event))
1290
+			{
1291
+				$event['whole_day'] = true;
1292
+			}
1172 1293
 			if (is_array($event['category']))
1173 1294
 			{
1174 1295
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1205,7 +1326,10 @@  discard block
 block discarded – undo
1205 1326
 						}
1206 1327
 						else
1207 1328
 						{
1208
-							if (!($exception = $this->read($id))) continue;
1329
+							if (!($exception = $this->read($id)))
1330
+							{
1331
+								continue;
1332
+							}
1209 1333
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1210 1334
 							$exception['reference'] = $exception['recurrence'] = 0;
1211 1335
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1294,7 +1418,10 @@  discard block
 block discarded – undo
1294 1418
 								break;
1295 1419
 
1296 1420
 							default:
1297
-								if (!empty($value)) $event[$key] = $value;
1421
+								if (!empty($value))
1422
+								{
1423
+									$event[$key] = $value;
1424
+								}
1298 1425
 						}
1299 1426
 					}
1300 1427
 				}
@@ -1392,7 +1519,10 @@  discard block
 block discarded – undo
1392 1519
 			else // common adjustments for new events
1393 1520
 			{
1394 1521
 				unset($event['id']);
1395
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1522
+				if ($caldav_name)
1523
+				{
1524
+					$event['caldav_name'] = $caldav_name;
1525
+				}
1396 1526
 				// set non blocking all day depending on the user setting
1397 1527
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1398 1528
 				{
@@ -1440,7 +1570,10 @@  discard block
 block discarded – undo
1440 1570
 					|| !isset($event['participants'][$event['owner']]))
1441 1571
 				{
1442 1572
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1443
-					if (!is_array($event['participants'])) $event['participants'] = array();
1573
+					if (!is_array($event['participants']))
1574
+					{
1575
+						$event['participants'] = array();
1576
+					}
1444 1577
 					$event['participants'][$event['owner']] = $status;
1445 1578
 				}
1446 1579
 				else
@@ -1593,7 +1726,10 @@  discard block
 block discarded – undo
1593 1726
 								$occurence = $exception = false;
1594 1727
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1595 1728
 								{
1596
-									if ($exception > $event['start']) break;
1729
+									if ($exception > $event['start'])
1730
+									{
1731
+										break;
1732
+									}
1597 1733
 									$occurence = $exception;
1598 1734
 								}
1599 1735
 								if (!$occurence)
@@ -1683,12 +1819,15 @@  discard block
 block discarded – undo
1683 1819
 					case 'SERIES-MASTER':
1684 1820
 					case 'SERIES-EXCEPTION':
1685 1821
 					case 'SERIES-EXCEPTION-PROPAGATE':
1686
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1822
+						if (is_array($event_info['stored_event']))
1823
+						{
1824
+							// status update requires a stored event
1687 1825
 						{
1688 1826
 							if ($event_info['acl_edit'])
1689 1827
 							{
1690 1828
 								// update all participants if we have the right to do that
1691 1829
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1830
+						}
1692 1831
 							}
1693 1832
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1694 1833
 							{
@@ -1700,9 +1839,12 @@  discard block
 block discarded – undo
1700 1839
 						break;
1701 1840
 
1702 1841
 					case 'SERIES-PSEUDO-EXCEPTION':
1703
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1842
+						if (is_array($event_info['master_event']))
1843
+						{
1844
+							// status update requires a stored master event
1704 1845
 						{
1705 1846
 							$recurrence = $this->date2usertime($event['recurrence']);
1847
+						}
1706 1848
 							if ($event_info['acl_edit'])
1707 1849
 							{
1708 1850
 								// update all participants if we have the right to do that
@@ -1775,7 +1917,10 @@  discard block
 block discarded – undo
1775 1917
 	 */
1776 1918
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1777 1919
 	{
1778
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1920
+		if ($this->debug)
1921
+		{
1922
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1923
+		}
1779 1924
 		$modified = 0;
1780 1925
 		foreach($event['alarm'] as &$alarm)
1781 1926
 		{
@@ -1799,19 +1944,40 @@  discard block
 block discarded – undo
1799 1944
 			if ($alarm['offset'] != $old_alarm['offset'] || $old_alarm['owner'] != $user && !$alarm['all'])
1800 1945
 			{
1801 1946
 				$alarm['owner'] = $user;
1802
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1803
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1804
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1805
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
1947
+				if (!isset($alarm['time']))
1948
+				{
1949
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1950
+				}
1951
+				if ($alarm['time'] < time())
1952
+				{
1953
+					calendar_so::shift_alarm($event, $alarm);
1954
+				}
1955
+				if ($this->debug)
1956
+				{
1957
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1958
+				}
1959
+				if ($event['id'])
1960
+				{
1961
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1962
+				}
1806 1963
 				++$modified;
1807 1964
 			}
1808 1965
 			// existing alarm --> update it
1809 1966
 			elseif ($alarm['offset'] == $old_alarm['offset'] && ($old_alarm['owner'] == $user || $old_alarm['all']))
1810 1967
 			{
1811
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1812
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1968
+				if (!isset($alarm['time']))
1969
+				{
1970
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1971
+				}
1972
+				if ($alarm['time'] < time())
1973
+				{
1974
+					calendar_so::shift_alarm($event, $alarm);
1975
+				}
1813 1976
 				$alarm = array_merge($old_alarm, $alarm);
1814
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1977
+				if ($this->debug)
1978
+				{
1979
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1980
+				}
1815 1981
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1816 1982
 				++$modified;
1817 1983
 			}
@@ -1825,7 +1991,10 @@  discard block
 block discarded – undo
1825 1991
 				unset($old_alarm[$id]);
1826 1992
 				continue;
1827 1993
 			}
1828
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1994
+			if ($this->debug)
1995
+			{
1996
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1997
+			}
1829 1998
 			$this->delete_alarm($id);
1830 1999
 			++$modified;
1831 2000
 		}
@@ -2244,7 +2413,10 @@  discard block
 block discarded – undo
2244 2413
 				array2string($_vcalData)."\n",3,$this->logfile);
2245 2414
 		}
2246 2415
 
2247
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2416
+		if (!is_array($this->supportedFields))
2417
+		{
2418
+			$this->setSupportedFields();
2419
+		}
2248 2420
 
2249 2421
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2250 2422
 		if (is_resource($_vcalData))
@@ -2589,19 +2761,27 @@  discard block
 block discarded – undo
2589 2761
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2590 2762
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2591 2763
 							}
2592
-							else break;
2764
+							else {
2765
+								break;
2766
+							}
2593 2767
 							// fall-through
2594 2768
 						case 'DAILY':	// 2.0
2595 2769
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2596
-							if (stripos($recurence, 'BYDAY') === false) break;
2770
+							if (stripos($recurence, 'BYDAY') === false)
2771
+							{
2772
+								break;
2773
+							}
2597 2774
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2598 2775
 							// fall-through
2599 2776
 						case 'W':
2600 2777
 						case 'WEEKLY':
2601 2778
 							$days = array();
2602
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2779
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2780
+							{
2781
+								// 1.0
2603 2782
 							{
2604 2783
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2784
+							}
2605 2785
 								if (empty($recurenceMatches[2]))
2606 2786
 								{
2607 2787
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2614,7 +2794,10 @@  discard block
 block discarded – undo
2614 2794
 								$repeatMatches = null;
2615 2795
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2616 2796
 								{
2617
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2797
+									if ($repeatMatches[1])
2798
+									{
2799
+										$vcardData['recur_count'] = $repeatMatches[1];
2800
+									}
2618 2801
 								}
2619 2802
 								else
2620 2803
 								{
@@ -2623,9 +2806,12 @@  discard block
 block discarded – undo
2623 2806
 
2624 2807
 								$recur_days = $this->recur_days_1_0;
2625 2808
 							}
2626
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2809
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2810
+							{
2811
+								// 2.0
2627 2812
 							{
2628 2813
 								$days = explode(',',$recurenceMatches[1]);
2814
+							}
2629 2815
 								$recur_days = $this->recur_days;
2630 2816
 							}
2631 2817
 							else	// no day given, use the day of dtstart
@@ -2684,7 +2870,10 @@  discard block
 block discarded – undo
2684 2870
 							{
2685 2871
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2686 2872
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2687
-							} else break;
2873
+							}
2874
+							else {
2875
+								break;
2876
+							}
2688 2877
 							// fall-through
2689 2878
 						case 'YEARLY':	// 2.0
2690 2879
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2704,7 +2893,10 @@  discard block
 block discarded – undo
2704 2893
 					}
2705 2894
 					break;
2706 2895
 				case 'EXDATE':
2707
-					if (!$attributes['value']) break;
2896
+					if (!$attributes['value'])
2897
+					{
2898
+						break;
2899
+					}
2708 2900
 					if ((isset($attributes['params']['VALUE'])
2709 2901
 							&& $attributes['params']['VALUE'] == 'DATE') ||
2710 2902
 						(!isset($attributes['params']['VALUE']) && $isDate))
@@ -2784,13 +2976,16 @@  discard block
 block discarded – undo
2784 2976
 					// fall throught
2785 2977
 				case 'ATTENDEE':
2786 2978
 					if (isset($attributes['params']['PARTSTAT']))
2787
-				    {
2979
+					{
2788 2980
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2789 2981
 				    }
2790 2982
 				    if (isset($attributes['params']['STATUS']))
2791
-					{
2983
+				    {
2792 2984
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2793
-						if (empty($status)) $status = 'X';
2985
+						if (empty($status))
2986
+						{
2987
+							$status = 'X';
2988
+						}
2794 2989
 					}
2795 2990
 					else
2796 2991
 					{
@@ -2850,7 +3045,10 @@  discard block
 block discarded – undo
2850 3045
 							$uid = $this->user;
2851 3046
 					}
2852 3047
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2853
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3048
+					if (!$uid)
3049
+					{
3050
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3051
+					}
2854 3052
 
2855 3053
 					// try to find an email address
2856 3054
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2918,7 +3116,10 @@  discard block
 block discarded – undo
2918 3116
 								}
2919 3117
 								$status = 'U'; // keep the group
2920 3118
 							}
2921
-							else continue; // can't find this group
3119
+							else {
3120
+								continue;
3121
+							}
3122
+							// can't find this group
2922 3123
 						}
2923 3124
 						elseif (empty($searcharray))
2924 3125
 						{
@@ -2977,7 +3178,9 @@  discard block
 block discarded – undo
2977 3178
 
2978 3179
 								try {
2979 3180
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2980
-										$component->getAttribute('ORGANIZER');
3181
+									{
3182
+																			$component->getAttribute('ORGANIZER');
3183
+									}
2981 3184
 								}
2982 3185
 								catch(Horde_Icalendar_Exception $e)
2983 3186
 								{
@@ -3014,7 +3217,10 @@  discard block
 block discarded – undo
3014 3217
 					}
3015 3218
 					break;
3016 3219
 				case 'CREATED':		// will be written direct to the event
3017
-					if ($event['modified']) break;
3220
+					if ($event['modified'])
3221
+					{
3222
+						break;
3223
+					}
3018 3224
 					// fall through
3019 3225
 				case 'LAST-MODIFIED':	// will be written direct to the event
3020 3226
 					$event['modified'] = $attributes['value'];
@@ -3035,7 +3241,11 @@  discard block
 block discarded – undo
3035 3241
 					break;
3036 3242
 
3037 3243
 				case 'ATTACH':
3038
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3244
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3245
+					{
3246
+						break;
3247
+					}
3248
+					// handeled by managed attachment code
3039 3249
 					// fall throught to store external attachment url
3040 3250
 				default:	// X- attribute or other by EGroupware unsupported property
3041 3251
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3166,7 +3376,10 @@  discard block
 block discarded – undo
3166 3376
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3167 3377
 		}
3168 3378
 
3169
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3379
+		if ($this->calendarOwner)
3380
+		{
3381
+			$event['owner'] = $this->calendarOwner;
3382
+		}
3170 3383
 
3171 3384
 		// parsing ATTACH attributes for managed attachments
3172 3385
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3192,7 +3405,10 @@  discard block
 block discarded – undo
3192 3405
 				$filter = $relax ? 'relax' : 'check';
3193 3406
 				$event = array_shift($events);
3194 3407
 				$eventId = -1;
3195
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3408
+				if ($this->so->isWholeDay($event))
3409
+				{
3410
+					$event['whole_day'] = true;
3411
+				}
3196 3412
 				if ($contentID)
3197 3413
 				{
3198 3414
 					$parts = preg_split('/:/', $contentID);
@@ -3224,8 +3440,16 @@  discard block
 block discarded – undo
3224 3440
 	 */
3225 3441
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3226 3442
 	{
3227
-		if (!$start) $start = time();	// default now
3228
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3443
+		if (!$start)
3444
+		{
3445
+			$start = time();
3446
+		}
3447
+		// default now
3448
+		if (!$end)
3449
+		{
3450
+			$end = time() + 100*DAY_s;
3451
+		}
3452
+		// default next 100 days
3229 3453
 
3230 3454
 		$vcal = new Horde_Icalendar;
3231 3455
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3247,10 +3471,13 @@  discard block
 block discarded – undo
3247 3471
 				$attributes[$attr] = date('Ymd\THis', $value);
3248 3472
 			}
3249 3473
 		}
3250
-		if (is_null($extra)) $extra = array(
3474
+		if (is_null($extra))
3475
+		{
3476
+			$extra = array(
3251 3477
 			'URL' => $this->freebusy_url($user),
3252 3478
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3253 3479
 		);
3480
+		}
3254 3481
 		foreach($attributes+$extra as $attr => $value)
3255 3482
 		{
3256 3483
 			$vfreebusy->setAttribute($attr, $value);
@@ -3266,9 +3493,18 @@  discard block
 block discarded – undo
3266 3493
 		{
3267 3494
 			foreach ($fbdata as $event)
3268 3495
 			{
3269
-				if ($event['non_blocking']) continue;
3270
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3271
-				if ($event['participants'][$user] == 'R') continue;
3496
+				if ($event['non_blocking'])
3497
+				{
3498
+					continue;
3499
+				}
3500
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3501
+				{
3502
+					continue;
3503
+				}
3504
+				if ($event['participants'][$user] == 'R')
3505
+				{
3506
+					continue;
3507
+				}
3272 3508
 
3273 3509
 				$fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3274 3510
 
Please login to merge, or discard this patch.
Spacing   +268 added lines, -269 removed lines patch added patch discarded remove patch
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
65 65
 	 */
66 66
 	var $priority_egw2ical = array(
67
-		0 => 0,		// undefined
68
-		1 => 9,		// low
69
-		2 => 5,		// normal
70
-		3 => 1,		// high
67
+		0 => 0, // undefined
68
+		1 => 9, // low
69
+		2 => 5, // normal
70
+		3 => 1, // high
71 71
 	);
72 72
 
73 73
 	/**
74 74
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
75 75
 	 */
76 76
 	var $priority_ical2egw = array(
77
-		0 => 0,		// undefined
78
-		9 => 1,	8 => 1, 7 => 1, 6 => 1,	// low
79
-		5 => 2,		// normal
80
-		4 => 3, 3 => 3, 2 => 3, 1 => 3,	// high
77
+		0 => 0, // undefined
78
+		9 => 1, 8 => 1, 7 => 1, 6 => 1, // low
79
+		5 => 2, // normal
80
+		4 => 3, 3 => 3, 2 => 3, 1 => 3, // high
81 81
 	);
82 82
 
83 83
 	/**
84 84
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
85 85
 	 */
86 86
 	var $priority_egw2funambol = array(
87
-		0 => 1,		// undefined (mapped to normal since undefined does not exist)
88
-		1 => 0,		// low
89
-		2 => 1,		// normal
90
-		3 => 2,		// high
87
+		0 => 1, // undefined (mapped to normal since undefined does not exist)
88
+		1 => 0, // low
89
+		2 => 1, // normal
90
+		3 => 2, // high
91 91
 	);
92 92
 
93 93
 	/**
94 94
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
95 95
 	 */
96 96
 	var $priority_funambol2egw = array(
97
-		0 => 1,		// low
98
-		1 => 2,		// normal
99
-		2 => 3,		// high
97
+		0 => 1, // low
98
+		1 => 2, // normal
99
+		2 => 3, // high
100 100
 	);
101 101
 
102 102
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @var boolean
167 167
 	 */
168 168
 	var $log = false;
169
-	var $logfile="/tmp/log-vcal";
169
+	var $logfile = "/tmp/log-vcal";
170 170
 
171 171
 	/**
172 172
 	 * Conflict callback
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
204 204
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
205 205
 	 */
206
-	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
206
+	function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0)
207 207
 	{
208 208
 		if ($this->log)
209 209
 		{
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 
235 235
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
236 236
 
237
-		if ($this->productManufacturer == '' )
237
+		if ($this->productManufacturer == '')
238 238
 		{	// syncevolution is broken
239 239
 			$version = '2.0';
240 240
 		}
241 241
 
242 242
 		$vcal = new Horde_Icalendar;
243
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
243
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
244 244
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
245 245
 		$vcal->setAttribute('VERSION', $version);
246 246
 		if ($method) $vcal->setAttribute('METHOD', $method);
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 						if ($this->log)
271 271
 						{
272 272
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
273
-								'() User does not have the permission to read event ' . $event['id']. "\n",
274
-								3,$this->logfile);
273
+								'() User does not have the permission to read event '.$event['id']."\n",
274
+								3, $this->logfile);
275 275
 						}
276 276
 						return -1; // Permission denied
277 277
 					}
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$retval = false;  // Entry does not exist
281
+					$retval = false; // Entry does not exist
282 282
 					if ($this->log)
283 283
 					{
284 284
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			if ($this->log)
293 293
 			{
294 294
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
295
-					'() export event UID: ' . $event['uid'] . ".\n",
295
+					'() export event UID: '.$event['uid'].".\n",
296 296
 					3, $this->logfile);
297 297
 			}
298 298
 
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 			if ($this->log)
318 318
 			{
319 319
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
320
-					'(' . $event['id']. ',' . $recurrence . ")\n" .
321
-					array2string($event)."\n",3,$this->logfile);
320
+					'('.$event['id'].','.$recurrence.")\n".
321
+					array2string($event)."\n", 3, $this->logfile);
322 322
 			}
323 323
 
324 324
 			if ($recurrence)
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 						{
340 340
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
341 341
 								"(, $recurrence) Gratuitous pseudo exception, skipped ...\n",
342
-								3,$this->logfile);
342
+								3, $this->logfile);
343 343
 						}
344 344
 						continue; // unsupported status only exception
345 345
 					}
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 					$days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule');
350 350
 					if ($this->log)
351 351
 					{
352
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
353
-							array2string($days)."\n",3,$this->logfile);
352
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
353
+							array2string($days)."\n", 3, $this->logfile);
354 354
 					}
355 355
 					$recurrence = $days[$recurrence]; // use remote representation
356 356
 				}
357 357
 				// force single event
358
-				foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name)
358
+				foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name)
359 359
 				{
360 360
 					unset($event[$name]);
361 361
 				}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 			}
364 364
 
365 365
 			// check if tzid of event (not only recuring ones) is already added to export
366
-			if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
366
+			if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added))
367 367
 			{
368 368
 				// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
369 369
 				if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 			{
382 382
 				// Append UID to DESCRIPTION
383 383
 				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
384
-					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
384
+					$event['description'] .= "\n[UID:".$event['uid']."]";
385 385
 				}
386 386
 			}
387 387
 
@@ -402,14 +402,14 @@  discard block
 block discarded – undo
402 402
 				$exceptions = array();
403 403
 
404 404
 				// dont use "virtual" exceptions created by participant status for GroupDAV or file export
405
-				if (!in_array($this->productManufacturer,array('file','groupdav')))
405
+				if (!in_array($this->productManufacturer, array('file', 'groupdav')))
406 406
 				{
407 407
 					$filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule';
408 408
 					$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter);
409 409
 					if ($this->log)
410 410
 					{
411
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
412
-							array2string($exceptions)."\n",3,$this->logfile);
411
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
412
+							array2string($exceptions)."\n", 3, $this->logfile);
413 413
 					}
414 414
 				}
415 415
 				elseif (is_array($event['recur_exception']))
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 					if ($this->log)
427 427
 					{
428 428
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
429
-							'(' . $event['id'] . ") [$icalFieldName] not supported\n",
430
-							3,$this->logfile);
429
+							'('.$event['id'].") [$icalFieldName] not supported\n",
430
+							3, $this->logfile);
431 431
 					}
432 432
 					continue;
433 433
 				}
@@ -444,23 +444,23 @@  discard block
 block discarded – undo
444 444
 
445 445
 							if (!($info = $this->resource_info($uid))) continue;
446 446
 
447
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
447
+							if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants
448 448
 
449 449
 							if ($this->log)
450 450
 							{
451
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
452
-									'()attendee:' . array2string($info) ."\n",3,$this->logfile);
451
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
452
+									'()attendee:'.array2string($info)."\n", 3, $this->logfile);
453 453
 							}
454 454
 							$participantCN = str_replace(array('\\', ',', ';', ':'),
455 455
 												array('\\\\', '\\,', '\\;', '\\:'),
456 456
 												trim(empty($info['cn']) ? $info['name'] : $info['cn']));
457 457
 							if ($version == '1.0')
458 458
 							{
459
-								$participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>'));
459
+								$participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>'));
460 460
 							}
461 461
 							else
462 462
 							{
463
-								$participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email'];
463
+								$participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email'];
464 464
 							}
465 465
 							// RSVP={TRUE|FALSE}	// resonse expected, not set in eGW => status=U
466 466
 							$rsvp = $status == 'U' ? 'TRUE' : 'FALSE';
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 										($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members))
489 489
 									{
490 490
 										$user = $this->resource_info($this->user);
491
-										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
491
+										$attributes['ATTENDEE'][] = 'mailto:'.$user['email'];
492 492
 			    						$parameters['ATTENDEE'][] = array(
493 493
 			    							'CN'		=>	$user['name'],
494 494
 			    							'ROLE'		=> 'REQ-PARTICIPANT',
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
531 531
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
532 532
 							{
533
-								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
533
+								$options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
534 534
 							}
535 535
 							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
536 536
 							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 						break;
541 541
 
542 542
 					case 'CLASS':
543
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
543
+						if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default
544 544
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
545 545
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
546 546
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -552,16 +552,16 @@  discard block
 block discarded – undo
552 552
     				case 'ORGANIZER':
553 553
 	    				if (!$organizerURL)
554 554
 	    				{
555
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
556
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
557
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
555
+	    					$organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname')
556
+			    				. ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"';
557
+			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
558 558
 			    			if ($version == '1.0')
559 559
 			    			{
560
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
560
+		    					$organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>'));
561 561
 			    			}
562 562
 			    			else
563 563
 			    			{
564
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
564
+		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail;
565 565
 			    			}
566 566
 			    			$organizerUID = $event['owner'];
567 567
 		    				if (!isset($event['participants'][$event['owner']]))
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 					case 'DTSTART':
595 595
 						if (empty($event['whole_day']))
596 596
 						{
597
-							$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
597
+							$attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']);
598 598
 						}
599 599
 						break;
600 600
 
@@ -605,27 +605,27 @@  discard block
 block discarded – undo
605 605
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
606 606
 								$attributes['duration'] = $event['end'] - $event['start'];
607 607
 							else
608
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
608
+							$attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']);
609 609
 						}
610 610
 						else
611 611
 						{
612 612
 							// write start + end of whole day events as dates
613
-							$event['end-nextday'] = $event['end'] + 12*3600;	// we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
614
-							foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
613
+							$event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
614
+							foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t)
615 615
 							{
616
-								$time = new Api\DateTime($event[$f],Api\DateTime::$server_timezone);
617
-								$arr = Api\DateTime::to($time,'array');
618
-								$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
616
+								$time = new Api\DateTime($event[$f], Api\DateTime::$server_timezone);
617
+								$arr = Api\DateTime::to($time, 'array');
618
+								$vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']),
619 619
 									array('VALUE' => 'DATE'));
620 620
 							}
621 621
 							unset($attributes['DTSTART']);
622 622
 							// Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event
623
-							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE');
623
+							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
624 624
 						}
625 625
 						break;
626 626
 
627 627
 					case 'RRULE':
628
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
628
+						if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
629 629
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
630 630
 						$rrule = $rriter->generate_rrule($version);
631 631
 						if ($event['recur_enddate'])
@@ -644,16 +644,16 @@  discard block
 block discarded – undo
644 644
 						{
645 645
 							if ($event['recur_enddate'] && $tzid)
646 646
 							{
647
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
647
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
648 648
 							}
649 649
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
650 650
 						}
651 651
 						else // $version == '2.0'
652 652
 						{
653 653
 							$attributes['RRULE'] = '';
654
-							foreach($rrule as $n => $v)
654
+							foreach ($rrule as $n => $v)
655 655
 							{
656
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
656
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
657 657
 							}
658 658
 						}
659 659
 						break;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 								{
669 669
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
670 670
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
671
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
671
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
672 672
 								}
673 673
 							}
674 674
 							else
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
677 677
 								foreach ($event['recur_exception'] as $id => $timestamp)
678 678
 								{
679
-									$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
679
+									$time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone);
680 680
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
681
-									$arr = Api\DateTime::to($time,'array');
681
+									$arr = Api\DateTime::to($time, 'array');
682 682
 									$days[$id] = array(
683 683
 										'year'  => $arr['year'],
684 684
 										'month' => $arr['month'],
@@ -693,21 +693,21 @@  discard block
 block discarded – undo
693 693
 						break;
694 694
 
695 695
 					case 'PRIORITY':
696
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
696
+						if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
697 697
 						if ($this->productManufacturer == 'funambol' &&
698 698
 							(strpos($this->productName, 'outlook') !== false
699 699
 								|| strpos($this->productName, 'pocket pc') !== false))
700 700
 						{
701
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
701
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
702 702
 						}
703 703
 						else
704 704
 						{
705
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
705
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
706 706
 						}
707 707
 						break;
708 708
 
709 709
 					case 'TRANSP':
710
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
710
+						if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
711 711
 						if ($version == '1.0')
712 712
 						{
713 713
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 							// We handle a pseudo exception
747 747
 							if (empty($event['whole_day']))
748 748
 							{
749
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
749
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
750 750
 							}
751 751
 							else
752 752
 							{
753
-								$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
753
+								$time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone);
754 754
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
755
-								$arr = Api\DateTime::to($time,'array');
755
+								$arr = Api\DateTime::to($time, 'array');
756 756
 								$vevent->setAttribute($icalFieldName, array(
757 757
 									'year' => $arr['year'],
758 758
 									'month' => $arr['month'],
@@ -764,17 +764,17 @@  discard block
 block discarded – undo
764 764
 						elseif ($event['recurrence'] && $event['reference'])
765 765
 						{
766 766
 							// $event['reference'] is a calendar_id, not a timestamp
767
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
767
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
768 768
 
769 769
 							if (empty($revent['whole_day']))
770 770
 							{
771
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
771
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
772 772
 							}
773 773
 							else
774 774
 							{
775
-								$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
775
+								$time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone);
776 776
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
777
-								$arr = Api\DateTime::to($time,'array');
777
+								$arr = Api\DateTime::to($time, 'array');
778 778
 								$vevent->setAttribute($icalFieldName, array(
779 779
 									'year' => $arr['year'],
780 780
 									'month' => $arr['month'],
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
799 799
 							if ($this->log && $size > 0)
800 800
 							{
801
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
802
-									"() $icalFieldName Size: $size, NoTruncate: " .
803
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
801
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
802
+									"() $icalFieldName Size: $size, NoTruncate: ".
803
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
804 804
 							}
805 805
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
806 806
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 							{
819 819
 								if ($this->log)
820 820
 								{
821
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
822
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
821
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
822
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
823 823
 								}
824 824
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
825 825
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 							$value = substr($value, 0, $size - 1);
830 830
 							if ($this->log)
831 831
 							{
832
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
833
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
832
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
833
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
834 834
 							}
835 835
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
836 836
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 			// for CalDAV add all X-Properties previously parsed
846 846
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
847 847
 			{
848
-				foreach($event as $name => $value)
848
+				foreach ($event as $name => $value)
849 849
 				{
850 850
 					if (substr($name, 0, 2) == '##')
851 851
 					{
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 						$values['AALARM']['repeat count'] = '';
918 918
 						$values['AALARM']['display text'] = $description;
919 919
 					}
920
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
921
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
920
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
921
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
922 922
 					// lets take only the first alarm
923 923
 					break;
924 924
 				}
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 						$alarmData['offset'] = false;
956 956
 					}
957 957
 
958
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
958
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
959 959
 					if ($alarmData['offset'] !== false)
960 960
 					{
961 961
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 					else
965 965
 					{
966 966
 						$params = array('VALUE' => 'DATE-TIME');
967
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
967
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
968 968
 						$valarm->setAttribute('TRIGGER', $value, $params);
969 969
 					}
970 970
 					if (!empty($alarmData['uid']))
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
976 976
 					if (isset($alarmData['attrs']))
977 977
 					{
978
-						foreach($alarmData['attrs'] as $attr => $data)
978
+						foreach ($alarmData['attrs'] as $attr => $data)
979 979
 						{
980 980
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
981 981
 						}
@@ -983,11 +983,11 @@  discard block
 block discarded – undo
983 983
 					// set default ACTION and DESCRIPTION, if not set by a client
984 984
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
985 985
 					{
986
-						$valarm->setAttribute('ACTION','DISPLAY');
986
+						$valarm->setAttribute('ACTION', 'DISPLAY');
987 987
 					}
988 988
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
989 989
 					{
990
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
990
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
991 991
 					}
992 992
 					$vevent->addComponent($valarm);
993 993
 				}
@@ -995,15 +995,15 @@  discard block
 block discarded – undo
995 995
 
996 996
 			foreach ($attributes as $key => $value)
997 997
 			{
998
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
998
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
999 999
 				{
1000
-					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
1001
-                    $paramData = (array) Api\Translation::convert(is_array($value) ?
1000
+					$valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset);
1001
+                    $paramData = (array)Api\Translation::convert(is_array($value) ?
1002 1002
                     		$parameters[$key][$valueID] : $parameters[$key],
1003
-                            Api\Translation::charset(),$charset);
1004
-                    $valuesData = (array) Api\Translation::convert($values[$key],
1005
-                    		Api\Translation::charset(),$charset);
1006
-                    $content = $valueData . implode(';', $valuesData);
1003
+                            Api\Translation::charset(), $charset);
1004
+                    $valuesData = (array)Api\Translation::convert($values[$key],
1005
+                    		Api\Translation::charset(), $charset);
1006
+                    $content = $valueData.implode(';', $valuesData);
1007 1007
 
1008 1008
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1009 1009
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1053,10 +1053,10 @@  discard block
 block discarded – undo
1053 1053
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1054 1054
  		if ($this->log)
1055 1055
  		{
1056
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1057
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1058
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1059
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1056
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1057
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1058
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1059
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1060 1060
  		}
1061 1061
 		return $retval;
1062 1062
 	}
@@ -1069,15 +1069,15 @@  discard block
 block discarded – undo
1069 1069
 	 * @param array &$params=null parameter array to set TZID
1070 1070
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1071 1071
 	 */
1072
-	static function getDateTime($time,$tzid,array &$params=null)
1072
+	static function getDateTime($time, $tzid, array &$params = null)
1073 1073
 	{
1074 1074
 		if (empty($tzid) || $tzid == 'UTC')
1075 1075
 		{
1076
-			return Api\DateTime::to($time,'ts');
1076
+			return Api\DateTime::to($time, 'ts');
1077 1077
 		}
1078
-		if (!is_a($time,'DateTime'))
1078
+		if (!is_a($time, 'DateTime'))
1079 1079
 		{
1080
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
1080
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
1081 1081
 		}
1082 1082
 		if (!isset(self::$tz_cache[$tzid]))
1083 1083
 		{
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1113 1113
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1114 1114
 	 */
1115
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1115
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1116 1116
 	{
1117 1117
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1118 1118
 		$this->events_imported = 0;
1119
-		$replace = $delete_exceptions= false;
1119
+		$replace = $delete_exceptions = false;
1120 1120
 
1121 1121
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1122 1122
 
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		{
1125 1125
 			return false;
1126 1126
 		}
1127
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1127
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1128 1128
 
1129 1129
 		if ($cal_id > 0)
1130 1130
 		{
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 			{
1133 1133
 				$replace = $recur_date == 0;
1134 1134
 				$events[0]['id'] = $cal_id;
1135
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1135
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1136 1136
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1137 1137
 			}
1138 1138
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 			{
1185 1185
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1186 1186
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1187
-					. array2string($event)."\n",3,$this->logfile);
1187
+					. array2string($event)."\n", 3, $this->logfile);
1188 1188
 			}
1189 1189
 
1190 1190
 			$updated_id = false;
@@ -1207,14 +1207,14 @@  discard block
 block discarded – undo
1207 1207
 					{
1208 1208
 						if ($delete_exceptions)
1209 1209
 						{
1210
-							$this->delete($id,0,false,$skip_notification);
1210
+							$this->delete($id, 0, false, $skip_notification);
1211 1211
 						}
1212 1212
 						else
1213 1213
 						{
1214 1214
 							if (!($exception = $this->read($id))) continue;
1215 1215
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1216 1216
 							$exception['reference'] = $exception['recurrence'] = 0;
1217
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1217
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1218 1218
 						}
1219 1219
 					}
1220 1220
 				}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 				{
1232 1232
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1233 1233
 						. "(UPDATE Event)\n"
1234
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1234
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1235 1235
 				}
1236 1236
 				if (empty($event['uid']))
1237 1237
 				{
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 								if ($this->log)
1254 1254
 								{
1255 1255
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1256
-										"() Restore status for $uid\n",3,$this->logfile);
1256
+										"() Restore status for $uid\n", 3, $this->logfile);
1257 1257
 								}
1258 1258
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1259 1259
 							}
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 					if ($this->log)
1278 1278
 					{
1279 1279
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1280
-							"()[MERGE]\n",3,$this->logfile);
1280
+							"()[MERGE]\n", 3, $this->logfile);
1281 1281
 					}
1282 1282
 					// overwrite with server data for merge
1283 1283
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
 				else
1308 1308
 				{
1309 1309
 					// no merge
1310
-					if(!isset($this->supportedFields['category']) || !isset($event['category']))
1310
+					if (!isset($this->supportedFields['category']) || !isset($event['category']))
1311 1311
 					{
1312 1312
 						$event['category'] = $event_info['stored_event']['category'];
1313 1313
 					}
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 						if ($this->log)
1320 1320
 						{
1321 1321
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1322
-							"() No participants\n",3,$this->logfile);
1322
+							"() No participants\n", 3, $this->logfile);
1323 1323
 						}
1324 1324
 
1325 1325
 						// If this is an updated meeting, and the client doesn't support
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 								if ($this->log)
1339 1339
 								{
1340 1340
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1341
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1341
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1342 1342
 								}
1343 1343
 								// Add it back in
1344 1344
 								$event['participants'][$uid] = $status;
@@ -1426,8 +1426,7 @@  discard block
 block discarded – undo
1426 1426
 						}
1427 1427
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1428 1428
 						$event['participants'][$user] = calendar_so::combine_status(
1429
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1430
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1429
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1431 1430
 					}
1432 1431
 				}
1433 1432
 				// check if an owner is set and the current user has add rights
@@ -1492,9 +1491,9 @@  discard block
 block discarded – undo
1492 1491
 
1493 1492
 			if ($this->log)
1494 1493
 			{
1495
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1496
-					. $event_info['type'] . ")\n"
1497
-					. array2string($event)."\n",3,$this->logfile);
1494
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1495
+					. $event_info['type'].")\n"
1496
+					. array2string($event)."\n", 3, $this->logfile);
1498 1497
 			}
1499 1498
 
1500 1499
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1502,10 +1501,10 @@  discard block
 block discarded – undo
1502 1501
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1503 1502
 				$event['status'] == 'CANCELLED')
1504 1503
 			{
1505
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1504
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1506 1505
 				{
1507 1506
 					// delete fails (because no rights), reject recurrence
1508
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1507
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1509 1508
 				}
1510 1509
 				continue;
1511 1510
 			}
@@ -1517,7 +1516,7 @@  discard block
 block discarded – undo
1517 1516
 					if ($this->log)
1518 1517
 					{
1519 1518
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1520
-							"(): event SINGLE\n",3,$this->logfile);
1519
+							"(): event SINGLE\n", 3, $this->logfile);
1521 1520
 					}
1522 1521
 
1523 1522
 					// update the event
@@ -1527,7 +1526,7 @@  discard block
 block discarded – undo
1527 1526
 						$event['reference'] = 0;
1528 1527
 						$event_to_store = $event; // prevent $event from being changed by the update method
1529 1528
 						$this->server2usertime($event_to_store);
1530
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1529
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1531 1530
 						unset($event_to_store);
1532 1531
 					}
1533 1532
 					break;
@@ -1536,7 +1535,7 @@  discard block
 block discarded – undo
1536 1535
 					if ($this->log)
1537 1536
 					{
1538 1537
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1539
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1538
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1540 1539
 					}
1541 1540
 
1542 1541
 					// remove all known pseudo exceptions and update the event
@@ -1546,8 +1545,8 @@  discard block
 block discarded – undo
1546 1545
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1547 1546
 						if ($this->log)
1548 1547
 						{
1549
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1550
-								array2string($days)."\n",3,$this->logfile);
1548
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1549
+								array2string($days)."\n", 3, $this->logfile);
1551 1550
 						}
1552 1551
 						if (is_array($days))
1553 1552
 						{
@@ -1565,7 +1564,7 @@  discard block
 block discarded – undo
1565 1564
 
1566 1565
 						$event_to_store = $event; // prevent $event from being changed by the update method
1567 1566
 						$this->server2usertime($event_to_store);
1568
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1567
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1569 1568
 						unset($event_to_store);
1570 1569
 					}
1571 1570
 					break;
@@ -1575,7 +1574,7 @@  discard block
 block discarded – undo
1575 1574
 					if ($this->log)
1576 1575
 					{
1577 1576
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1578
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1577
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1579 1578
 					}
1580 1579
 
1581 1580
 					// update event
@@ -1631,13 +1630,13 @@  discard block
 block discarded – undo
1631 1630
 							$event['owner'] = $event_info['master_event']['owner'];
1632 1631
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1633 1632
 							$this->server2usertime($event_to_store);
1634
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1633
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1635 1634
 							unset($event_to_store);
1636 1635
 						}
1637 1636
 
1638 1637
 						$event_to_store = $event; // prevent $event from being changed by update method
1639 1638
 						$this->server2usertime($event_to_store);
1640
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1639
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1641 1640
 						unset($event_to_store);
1642 1641
 					}
1643 1642
 					break;
@@ -1646,7 +1645,7 @@  discard block
 block discarded – undo
1646 1645
 					if ($this->log)
1647 1646
 					{
1648 1647
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1649
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1648
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1650 1649
 					}
1651 1650
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1652 1651
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1667,7 +1666,7 @@  discard block
 block discarded – undo
1667 1666
 						// save the series master with the adjusted exceptions
1668 1667
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1669 1668
 						$this->server2usertime($event_to_store);
1670
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1669
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1671 1670
 						unset($event_to_store);
1672 1671
 					}
1673 1672
 
@@ -1694,13 +1693,13 @@  discard block
 block discarded – undo
1694 1693
 							if ($event_info['acl_edit'])
1695 1694
 							{
1696 1695
 								// update all participants if we have the right to do that
1697
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1696
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1698 1697
 							}
1699 1698
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1700 1699
 							{
1701 1700
 								// update the users status only
1702 1701
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1703
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1702
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1704 1703
 							}
1705 1704
 						}
1706 1705
 						break;
@@ -1712,13 +1711,13 @@  discard block
 block discarded – undo
1712 1711
 							if ($event_info['acl_edit'])
1713 1712
 							{
1714 1713
 								// update all participants if we have the right to do that
1715
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1714
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1716 1715
 							}
1717 1716
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1718 1717
 							{
1719 1718
 								// update the users status only
1720 1719
 								$this->set_status($event_info['master_event']['id'], $this->user,
1721
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1720
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1722 1721
 							}
1723 1722
 						}
1724 1723
 						break;
@@ -1735,7 +1734,7 @@  discard block
 block discarded – undo
1735 1734
 					break;
1736 1735
 
1737 1736
 				case 'SERIES-PSEUDO-EXCEPTION':
1738
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1737
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1739 1738
 					break;
1740 1739
 
1741 1740
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1748,7 +1747,7 @@  discard block
 block discarded – undo
1748 1747
 					{
1749 1748
 						// we did not have sufficient rights to propagate the status only exception to a real one
1750 1749
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1751
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1750
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1752 1751
 					}
1753 1752
 					break;
1754 1753
 			}
@@ -1762,8 +1761,8 @@  discard block
 block discarded – undo
1762 1761
 			if ($this->log)
1763 1762
 			{
1764 1763
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1765
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1766
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1764
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1765
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1767 1766
 			}
1768 1767
 		}
1769 1768
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1785,19 +1784,19 @@  discard block
 block discarded – undo
1785 1784
 	 * @return mixed on success: int $cal_id > 0, on error or conflicts false.
1786 1785
 	 *	Conflicts are passed to $this->conflict_callback
1787 1786
 	 */
1788
-	public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
1787
+	public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
1789 1788
 	{
1790
-		if($this->conflict_callback !== null)
1789
+		if ($this->conflict_callback !== null)
1791 1790
 		{
1792 1791
 			// calendar_ical overrides search(), which breaks conflict checking
1793 1792
 			// so we make sure to use the original from parent
1794 1793
 			static $bo;
1795
-			if(!$bo)
1794
+			if (!$bo)
1796 1795
 			{
1797 1796
 				$bo = new calendar_boupdate();
1798 1797
 			}
1799 1798
 			$conflicts = $bo->conflicts($event);
1800
-			if(is_array($conflicts) && count($conflicts) > 0)
1799
+			if (is_array($conflicts) && count($conflicts) > 0)
1801 1800
 			{
1802 1801
 				call_user_func_array($this->conflict_callback, array(&$event, &$conflicts));
1803 1802
 				return false;
@@ -1818,10 +1817,10 @@  discard block
 block discarded – undo
1818 1817
 	{
1819 1818
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1820 1819
 		$modified = 0;
1821
-		foreach($event['alarm'] as &$alarm)
1820
+		foreach ($event['alarm'] as &$alarm)
1822 1821
 		{
1823 1822
 			// check if alarm is already stored or from other users
1824
-			foreach($old_alarms as $id => $old_alarm)
1823
+			foreach ($old_alarms as $id => $old_alarm)
1825 1824
 			{
1826 1825
 				// not current users alarm --> ignore
1827 1826
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1858,7 +1857,7 @@  discard block
 block discarded – undo
1858 1857
 			}
1859 1858
 		}
1860 1859
 		// remove all old alarms left from current user
1861
-		foreach($old_alarms as $id => $old_alarm)
1860
+		foreach ($old_alarms as $id => $old_alarm)
1862 1861
 		{
1863 1862
 			// not current users alarm --> ignore
1864 1863
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1881,7 +1880,7 @@  discard block
 block discarded – undo
1881 1880
 	 * @param string $what ='value'
1882 1881
 	 * @return mixed
1883 1882
 	 */
1884
-	static function _get_attribute($components,$name,$what='value')
1883
+	static function _get_attribute($components, $name, $what = 'value')
1885 1884
 	{
1886 1885
 		foreach ($components as $attribute)
1887 1886
 		{
@@ -1916,7 +1915,7 @@  discard block
 block discarded – undo
1916 1915
 						case 'DURATION':
1917 1916
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1918 1917
 							{
1919
-								$alarm['offset'] = $duration -$vattr['value'];
1918
+								$alarm['offset'] = $duration - $vattr['value'];
1920 1919
 							}
1921 1920
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1922 1921
 							{
@@ -1932,7 +1931,7 @@  discard block
 block discarded – undo
1932 1931
 							$alarm['time'] = $vattr['value'];
1933 1932
 							break;
1934 1933
 						default:
1935
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1934
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1936 1935
 					}
1937 1936
 					break;
1938 1937
 
@@ -1957,9 +1956,9 @@  discard block
 block discarded – undo
1957 1956
 		return 0;
1958 1957
 	}
1959 1958
 
1960
-	function setSupportedFields($_productManufacturer='', $_productName='')
1959
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1961 1960
 	{
1962
-		$state =& $_SESSION['SyncML.state'];
1961
+		$state = & $_SESSION['SyncML.state'];
1963 1962
 		if (isset($state))
1964 1963
 		{
1965 1964
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2256,10 +2255,10 @@  discard block
 block discarded – undo
2256 2255
 		if ($this->log)
2257 2256
 		{
2258 2257
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2259
-				'(' . $this->productManufacturer .
2260
-				', '. $this->productName .', ' .
2261
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
2262
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2258
+				'('.$this->productManufacturer.
2259
+				', '.$this->productName.', '.
2260
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
2261
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2263 2262
 		}
2264 2263
 
2265 2264
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2277,12 +2276,12 @@  discard block
 block discarded – undo
2277 2276
      *                         utf-8 for new format, iso-8859-1 for old format.
2278 2277
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2279 2278
 	 */
2280
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2279
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2281 2280
 	{
2282 2281
 		if ($this->log)
2283 2282
 		{
2284
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2285
-				array2string($_vcalData)."\n",3,$this->logfile);
2283
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2284
+				array2string($_vcalData)."\n", 3, $this->logfile);
2286 2285
 		}
2287 2286
 
2288 2287
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2317,14 +2316,14 @@  discard block
 block discarded – undo
2317 2316
 			if ($this->log)
2318 2317
 			{
2319 2318
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2320
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2319
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2321 2320
 			}
2322 2321
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2323 2322
 			return false;
2324 2323
 		}
2325 2324
 		foreach ($vcal->getComponents() as $component)
2326 2325
 		{
2327
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2326
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2328 2327
 			{
2329 2328
 				$events[] = $event;
2330 2329
 			}
@@ -2369,13 +2368,13 @@  discard block
 block discarded – undo
2369 2368
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2370 2369
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2371 2370
 	 */
2372
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2371
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2373 2372
 	{
2374 2373
 		//unset($component->_container); _debug_array($component);
2375 2374
 
2376 2375
 		if ($this->log)
2377 2376
 		{
2378
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2377
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2379 2378
 		}
2380 2379
 
2381 2380
 		// eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component
@@ -2430,16 +2429,16 @@  discard block
 block discarded – undo
2430 2429
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2431 2430
 	 * @return array|boolean			event on success, false on failure
2432 2431
 	 */
2433
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2432
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2434 2433
 	{
2435
-		unset($principalURL);	// not longer used, but required in function signature
2434
+		unset($principalURL); // not longer used, but required in function signature
2436 2435
 
2437 2436
 		if ($check_component && !is_a($component, $check_component))
2438 2437
 		{
2439 2438
 			if ($this->log)
2440 2439
 			{
2441
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2442
-					get_class($component)." found\n",3,$this->logfile);
2440
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2441
+					get_class($component)." found\n", 3, $this->logfile);
2443 2442
 			}
2444 2443
 			return false;
2445 2444
 		}
@@ -2455,11 +2454,11 @@  discard block
 block discarded – undo
2455 2454
 
2456 2455
 		$isDate = false;
2457 2456
 		$event		= array();
2458
-		$alarms		= array();
2459
-		$vcardData	= array(
2457
+		$alarms = array();
2458
+		$vcardData = array(
2460 2459
 			'recur_type'		=> MCAL_RECUR_NONE,
2461 2460
 			'recur_exception'	=> array(),
2462
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2461
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2463 2462
 		);
2464 2463
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
2465 2464
 		foreach (array_merge(
@@ -2476,7 +2475,7 @@  discard block
 block discarded – undo
2476 2475
 						$isDate = true;
2477 2476
 					}
2478 2477
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2479
-					$vcardData['start']	= $dtstart_ts;
2478
+					$vcardData['start'] = $dtstart_ts;
2480 2479
 
2481 2480
 					if ($this->tzid)
2482 2481
 					{
@@ -2499,18 +2498,18 @@  discard block
 block discarded – undo
2499 2498
 								}
2500 2499
 								else
2501 2500
 								{
2502
-									error_log(__METHOD__ . '() unknown TZID='
2503
-										. $attributes['params']['TZID'] . ', defaulting to timezone "'
2504
-										. date_default_timezone_get() . '".'.array2string($tz));
2505
-									$event['tzid'] = date_default_timezone_get();	// default to current timezone
2501
+									error_log(__METHOD__.'() unknown TZID='
2502
+										. $attributes['params']['TZID'].', defaulting to timezone "'
2503
+										. date_default_timezone_get().'".'.array2string($tz));
2504
+									$event['tzid'] = date_default_timezone_get(); // default to current timezone
2506 2505
 								}
2507 2506
 							}
2508
-							catch(Exception $e)
2507
+							catch (Exception $e)
2509 2508
 							{
2510
-								error_log(__METHOD__ . '() unknown TZID='
2511
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2512
-									. date_default_timezone_get() . '".'.$e->getMessage());
2513
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2509
+								error_log(__METHOD__.'() unknown TZID='
2510
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2511
+									. date_default_timezone_get().'".'.$e->getMessage());
2512
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2514 2513
 							}
2515 2514
 						}
2516 2515
 						else
@@ -2525,11 +2524,11 @@  discard block
 block discarded – undo
2525 2524
 
2526 2525
 				case 'DTEND':
2527 2526
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2528
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2527
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2529 2528
 					{
2530 2529
 						$dtend_ts -= 1;
2531 2530
 					}
2532
-					$vcardData['end']	= $dtend_ts;
2531
+					$vcardData['end'] = $dtend_ts;
2533 2532
 					break;
2534 2533
 
2535 2534
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2549,7 +2548,7 @@  discard block
 block discarded – undo
2549 2548
 			if ($this->log)
2550 2549
 			{
2551 2550
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2552
-					. "() DTSTART missing!\n",3,$this->logfile);
2551
+					. "() DTSTART missing!\n", 3, $this->logfile);
2553 2552
 			}
2554 2553
 			return false; // not a valid entry
2555 2554
 		}
@@ -2561,7 +2560,7 @@  discard block
 block discarded – undo
2561 2560
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2562 2561
 					if (isset($supportedFields['whole_day']))
2563 2562
 					{
2564
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2563
+						$event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true);
2565 2564
 					}
2566 2565
 					break;
2567 2566
 				case 'AALARM':
@@ -2591,32 +2590,32 @@  discard block
 block discarded – undo
2591 2590
 					$vcardData['recurrence'] = $attributes['value'];
2592 2591
 					break;
2593 2592
 				case 'LOCATION':
2594
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2593
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2595 2594
 					break;
2596 2595
 				case 'RRULE':
2597 2596
 					$recurence = $attributes['value'];
2598 2597
 					$vcardData['recur_interval'] = 1;
2599
-					$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0];
2598
+					$type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0];
2600 2599
 					// vCard 2.0 values for all types
2601
-					if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches))
2600
+					if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches))
2602 2601
 					{
2603 2602
 						$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]);
2604 2603
 						// If it couldn't be parsed, treat it as not set
2605
-						if(is_string($vcardData['recur_enddate']))
2604
+						if (is_string($vcardData['recur_enddate']))
2606 2605
 						{
2607 2606
 							unset($vcardData['recur_enddate']);
2608 2607
 						}
2609 2608
 					}
2610
-					elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches))
2609
+					elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches))
2611 2610
 					{
2612 2611
 						$vcardData['recur_count'] = (int)$matches[1];
2613 2612
 					}
2614
-					if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
2613
+					if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches))
2615 2614
 					{
2616
-						$vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1;
2615
+						$vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1;
2617 2616
 					}
2618 2617
 					$vcardData['recur_data'] = 0;
2619
-					switch($type)
2618
+					switch ($type)
2620 2619
 					{
2621 2620
 						case 'D':	// 1.0
2622 2621
 							$recurenceMatches = null;
@@ -2640,20 +2639,20 @@  discard block
 block discarded – undo
2640 2639
 						case 'W':
2641 2640
 						case 'WEEKLY':
2642 2641
 							$days = array();
2643
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2642
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches))		// 1.0
2644 2643
 							{
2645 2644
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2646 2645
 								if (empty($recurenceMatches[2]))
2647 2646
 								{
2648
-									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
2647
+									$days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2));
2649 2648
 								}
2650 2649
 								else
2651 2650
 								{
2652
-									$days = explode(' ',trim($recurenceMatches[2]));
2651
+									$days = explode(' ', trim($recurenceMatches[2]));
2653 2652
 								}
2654 2653
 
2655 2654
 								$repeatMatches = null;
2656
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2655
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches))
2657 2656
 								{
2658 2657
 									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2659 2658
 								}
@@ -2664,21 +2663,21 @@  discard block
 block discarded – undo
2664 2663
 
2665 2664
 								$recur_days = $this->recur_days_1_0;
2666 2665
 							}
2667
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2666
+							elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches))	// 2.0
2668 2667
 							{
2669
-								$days = explode(',',$recurenceMatches[1]);
2668
+								$days = explode(',', $recurenceMatches[1]);
2670 2669
 								$recur_days = $this->recur_days;
2671 2670
 							}
2672 2671
 							else	// no day given, use the day of dtstart
2673 2672
 							{
2674
-								$vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']);
2673
+								$vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']);
2675 2674
 								$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
2676 2675
 							}
2677 2676
 							if ($days)
2678 2677
 							{
2679 2678
 								foreach ($recur_days as $id => $day)
2680 2679
 								{
2681
-									if (in_array(strtoupper(substr($day,0,2)),$days))
2680
+									if (in_array(strtoupper(substr($day, 0, 2)), $days))
2682 2681
 									{
2683 2682
 										$vcardData['recur_data'] |= $id;
2684 2683
 									}
@@ -2694,17 +2693,17 @@  discard block
 block discarded – undo
2694 2693
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2695 2694
 								$vcardData['recur_count'] = $recurenceMatches[2];
2696 2695
 							}
2697
-							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2696
+							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2698 2697
 							{
2699 2698
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
2700 2699
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2701 2700
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2702 2701
 							}
2703
-							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
2702
+							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches))
2704 2703
 							{
2705 2704
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
2706 2705
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2707
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches))
2706
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches))
2708 2707
 								{
2709 2708
 									$vcardData['recur_count'] = $recurenceMatches[1];
2710 2709
 								}
@@ -2721,7 +2720,7 @@  discard block
 block discarded – undo
2721 2720
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2722 2721
 								$vcardData['recur_count'] = $recurenceMatches[2];
2723 2722
 							}
2724
-							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2723
+							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2725 2724
 							{
2726 2725
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2727 2726
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
@@ -2735,11 +2734,11 @@  discard block
 block discarded – undo
2735 2734
 							}
2736 2735
 							// handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL
2737 2736
 							$vcardData['recur_interval'] = $vcardData['recur_interval'] ?
2738
-								12*$vcardData['recur_interval'] : 12;
2737
+								12 * $vcardData['recur_interval'] : 12;
2739 2738
 							// fall-through
2740 2739
 						case 'MONTHLY':
2741 2740
 							// does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART
2742
-							$vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ?
2741
+							$vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ?
2743 2742
 								MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
2744 2743
 							break;
2745 2744
 					}
@@ -2795,11 +2794,11 @@  discard block
 block discarded – undo
2795 2794
 						(strpos($this->productName, 'outlook') !== false
2796 2795
 							|| strpos($this->productName, 'pocket pc') !== false))
2797 2796
 					{
2798
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2797
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2799 2798
 					}
2800 2799
 					else
2801 2800
 					{
2802
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2801
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2803 2802
 					}
2804 2803
 					break;
2805 2804
 				case 'CATEGORIES':
@@ -2813,10 +2812,10 @@  discard block
 block discarded – undo
2813 2812
 					}
2814 2813
 					break;
2815 2814
 				case 'ORGANIZER':
2816
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2817
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2815
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2816
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2818 2817
 					{
2819
-						$event['organizer'] = substr($event['organizer'],7);
2818
+						$event['organizer'] = substr($event['organizer'], 7);
2820 2819
 					}
2821 2820
 					if (!empty($attributes['params']['CN']))
2822 2821
 					{
@@ -2853,19 +2852,19 @@  discard block
 block discarded – undo
2853 2852
 					}
2854 2853
 					// try parsing email and cn from attendee
2855 2854
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2856
-						$attributes['value'],$matches))
2855
+						$attributes['value'], $matches))
2857 2856
 					{
2858 2857
 						$email = $matches[1] ? $matches[1] : $matches[3];
2859
-						$cn = isset($matches[2]) ? $matches[2]: '';
2858
+						$cn = isset($matches[2]) ? $matches[2] : '';
2860 2859
 					}
2861 2860
 					elseif (!empty($attributes['value']) &&
2862 2861
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2863
-						$attributes['value'],$matches))
2862
+						$attributes['value'], $matches))
2864 2863
 					{
2865 2864
 						$cn = $matches[1];
2866 2865
 						$email = $matches[2];
2867 2866
 					}
2868
-					elseif (strpos($attributes['value'],'@') !== false)
2867
+					elseif (strpos($attributes['value'], '@') !== false)
2869 2868
 					{
2870 2869
 						$email = $attributes['value'];
2871 2870
 					}
@@ -2882,7 +2881,7 @@  discard block
 block discarded – undo
2882 2881
 						if ($this->log)
2883 2882
 						{
2884 2883
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2885
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2884
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2886 2885
 						}
2887 2886
 					}
2888 2887
 					elseif ($attributes['value'] == 'Unknown')
@@ -2900,7 +2899,7 @@  discard block
 block discarded – undo
2900 2899
 						if ($this->log)
2901 2900
 						{
2902 2901
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2903
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2902
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2904 2903
 						}
2905 2904
 					}
2906 2905
 					if (!$uid)
@@ -2917,9 +2916,9 @@  discard block
 block discarded – undo
2917 2916
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2918 2917
 										array(',', ';', ':', '\\'),
2919 2918
 										$attributes['params']['CN']);
2920
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2919
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2921 2920
 							{
2922
-								$cn = substr($cn,1,-1);
2921
+								$cn = substr($cn, 1, -1);
2923 2922
 							}
2924 2923
 							// not searching for $cn, as match can be not unique or without an email address
2925 2924
 							// --> notification will fail, better store just as email
@@ -2928,19 +2927,19 @@  discard block
 block discarded – undo
2928 2927
 						if ($this->log)
2929 2928
 						{
2930 2929
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2931
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2930
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2932 2931
 						}
2933 2932
 
2934 2933
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2935
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2934
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2936 2935
 						{
2937 2936
 							// we found a group
2938 2937
 							if ($this->log)
2939 2938
 							{
2940 2939
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2941
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2940
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2942 2941
 							}
2943
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2942
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2944 2943
 							{
2945 2944
 								//Horde::logMessage("vevent2egw: group participant $uid",
2946 2945
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2954,7 +2953,7 @@  discard block
 block discarded – undo
2954 2953
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2955 2954
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2956 2955
 										$vcardData['participants'][$this->user] =
2957
-											calendar_so::combine_status($status,$quantity,$role);
2956
+											calendar_so::combine_status($status, $quantity, $role);
2958 2957
 									}
2959 2958
 								}
2960 2959
 								$status = 'U'; // keep the group
@@ -2963,36 +2962,36 @@  discard block
 block discarded – undo
2963 2962
 						}
2964 2963
 						elseif (empty($searcharray))
2965 2964
 						{
2966
-							continue;	// participants without email AND CN --> ignore it
2965
+							continue; // participants without email AND CN --> ignore it
2967 2966
 						}
2968 2967
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2969
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2968
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2970 2969
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2971
-							'','',false,'OR')))
2970
+							'', '', false, 'OR')))
2972 2971
 						{
2973 2972
 							// found an addressbook entry
2974 2973
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2975 2974
 							if ($this->log)
2976 2975
 							{
2977 2976
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2978
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2977
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2979 2978
 							}
2980 2979
 						}
2981 2980
 						else
2982 2981
 						{
2983 2982
 							if (!$email)
2984 2983
 							{
2985
-								$email = '[email protected]';	// set dummy email to store the CN
2984
+								$email = '[email protected]'; // set dummy email to store the CN
2986 2985
 							}
2987
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2986
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2988 2987
 							if ($this->log)
2989 2988
 							{
2990 2989
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2991
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2990
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2992 2991
 							}
2993 2992
 						}
2994 2993
 					}
2995
-					switch($attributes['name'])
2994
+					switch ($attributes['name'])
2996 2995
 					{
2997 2996
 						case 'ATTENDEE':
2998 2997
 							if (!isset($attributes['params']['ROLE']) &&
@@ -3006,7 +3005,7 @@  discard block
 block discarded – undo
3006 3005
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
3007 3006
 								// as this is currently the only way to store an external organizer and send him iMip responses
3008 3007
 								$q = $r = null;
3009
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
3008
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
3010 3009
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
3011 3010
 								{
3012 3011
 									$role = 'CHAIR';
@@ -3020,7 +3019,7 @@  discard block
 block discarded – undo
3020 3019
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3021 3020
 										$component->getAttribute('ORGANIZER');
3022 3021
 								}
3023
-								catch(Horde_Icalendar_Exception $e)
3022
+								catch (Horde_Icalendar_Exception $e)
3024 3023
 								{
3025 3024
 									// we can store the ORGANIZER as event owner
3026 3025
 									$event['owner'] = $uid;
@@ -3076,7 +3075,7 @@  discard block
 block discarded – undo
3076 3075
 					break;
3077 3076
 
3078 3077
 				case 'ATTACH':
3079
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3078
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3080 3079
 					// fall throught to store external attachment url
3081 3080
 				default:	// X- attribute or other by EGroupware unsupported property
3082 3081
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3134,7 +3133,7 @@  discard block
 block discarded – undo
3134 3133
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3135 3134
 					{
3136 3135
 						$event['reference'] = 0;
3137
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3136
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3138 3137
 						{
3139 3138
 							if (isset($vcardData[$r]))
3140 3139
 							{
@@ -3157,12 +3156,12 @@  discard block
 block discarded – undo
3157 3156
 			// reset recure_enddate to 00:00:00 on the last day
3158 3157
 			$rriter = calendar_rrule::event2rrule($event, false);
3159 3158
 			$last = $rriter->normalize_enddate();
3160
-			if(!is_object($last))
3159
+			if (!is_object($last))
3161 3160
 			{
3162
-				if($this->log)
3161
+				if ($this->log)
3163 3162
 				{
3164
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3165
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3163
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3164
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3166 3165
 				}
3167 3166
 				return false;
3168 3167
 			}
@@ -3171,16 +3170,16 @@  discard block
 block discarded – undo
3171 3170
 			$event['recur_enddate'] = Api\DateTime::to($last, 'server');
3172 3171
 		}
3173 3172
 		// translate COUNT into an enddate, as we only store enddates
3174
-		elseif($event['recur_count'])
3173
+		elseif ($event['recur_count'])
3175 3174
 		{
3176 3175
 			$rriter = calendar_rrule::event2rrule($event, false);
3177 3176
 			$last = $rriter->count2date($event['recur_count']);
3178
-			if(!is_object($last))
3177
+			if (!is_object($last))
3179 3178
 			{
3180
-				if($this->log)
3179
+				if ($this->log)
3181 3180
 				{
3182 3181
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3183
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3182
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3184 3183
 				}
3185 3184
 				return false;
3186 3185
 			}
@@ -3194,7 +3193,7 @@  discard block
 block discarded – undo
3194 3193
 			if ($this->productManufacturer == 'groupdav' && $container &&
3195 3194
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3196 3195
 			{
3197
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3196
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3198 3197
 			}
3199 3198
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3200 3199
 		}
@@ -3215,15 +3214,15 @@  discard block
 block discarded – undo
3215 3214
 
3216 3215
 		if ($this->log)
3217 3216
 		{
3218
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3219
-				array2string($event)."\n",3,$this->logfile);
3217
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3218
+				array2string($event)."\n", 3, $this->logfile);
3220 3219
 		}
3221 3220
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3222 3221
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3223 3222
 		return $event;
3224 3223
 	}
3225 3224
 
3226
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3225
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3227 3226
 	{
3228 3227
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3229 3228
 		{
@@ -3244,8 +3243,8 @@  discard block
 block discarded – undo
3244 3243
 			}
3245 3244
 			if ($this->log)
3246 3245
 			{
3247
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3248
-					array2string($events)."\n",3,$this->logfile);
3246
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3247
+					array2string($events)."\n", 3, $this->logfile);
3249 3248
 			}
3250 3249
 		}
3251 3250
 		return array();
@@ -3263,23 +3262,23 @@  discard block
 block discarded – undo
3263 3262
 	 * @param array $extra =null extra attributes to add
3264 3263
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3265 3264
 	 */
3266
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3265
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3267 3266
 	{
3268
-		if (!$start) $start = time();	// default now
3269
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3267
+		if (!$start) $start = time(); // default now
3268
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3270 3269
 
3271 3270
 		$vcal = new Horde_Icalendar;
3272
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3271
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3273 3272
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3274
-		$vcal->setAttribute('VERSION','2.0');
3275
-		$vcal->setAttribute('METHOD',$method);
3273
+		$vcal->setAttribute('VERSION', '2.0');
3274
+		$vcal->setAttribute('METHOD', $method);
3276 3275
 
3277
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3276
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3278 3277
 
3279 3278
 		$attributes = array(
3280 3279
 			'DTSTAMP' => time(),
3281
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3282
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3280
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3281
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3283 3282
 		);
3284 3283
 		if (!$utc)
3285 3284
 		{
@@ -3290,9 +3289,9 @@  discard block
 block discarded – undo
3290 3289
 		}
3291 3290
 		if (is_null($extra)) $extra = array(
3292 3291
 			'URL' => $this->freebusy_url($user),
3293
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3292
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3294 3293
 		);
3295
-		foreach($attributes+$extra as $attr => $value)
3294
+		foreach ($attributes + $extra as $attr => $value)
3296 3295
 		{
3297 3296
 			$vfreebusy->setAttribute($attr, $value);
3298 3297
 		}
@@ -3315,16 +3314,16 @@  discard block
 block discarded – undo
3315 3314
 
3316 3315
 				if ($utc)
3317 3316
 				{
3318
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3317
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3319 3318
 						'start' => $event['start'],
3320 3319
 						'end' => $event['end'],
3321 3320
 					)), array('FBTYPE' => $fbtype));
3322 3321
 				}
3323 3322
 				else
3324 3323
 				{
3325
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3326
-						'start' => date('Ymd\THis',$event['start']),
3327
-						'end' => date('Ymd\THis',$event['end']),
3324
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3325
+						'start' => date('Ymd\THis', $event['start']),
3326
+						'end' => date('Ymd\THis', $event['end']),
3328 3327
 					)), array('FBTYPE' => $fbtype));
3329 3328
 				}
3330 3329
 			}
Please login to merge, or discard this patch.