Completed
Push — 16.1 ( da3266...d5e8cd )
by Klaus
19:17
created
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.
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.
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,24 +122,24 @@  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 130
 		$plugin_options = $_definition->plugin_options;
131
-		$plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ?
131
+		$plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ?
132 132
 			$_definition->plugin_options['events_owner'] : $this->user;
133 133
 		$_definition->plugin_options = $plugin_options;
134 134
 
135 135
 		// trash_users_records ?
136
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
137
-			if ( !$_definition->plugin_options['dry_run'] ) {
136
+		if ($_definition->plugin_options['trash_users_records'] === true) {
137
+			if (!$_definition->plugin_options['dry_run']) {
138 138
 				$socal = new calendar_socal();
139
-				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
140
-				unset( $socal );
139
+				$this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']);
140
+				unset($socal);
141 141
 			} else {
142
-				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
142
+				$lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']);
143 143
 				echo "Attension: All Events of '$lid' would be deleted!\n";
144 144
 			}
145 145
 		}
@@ -147,44 +147,44 @@  discard block
 block discarded – undo
147 147
 		$this->errors = array();
148 148
 		$this->results = array();
149 149
 
150
-		while ( $record = $import_csv->get_record() ) {
150
+		while ($record = $import_csv->get_record()) {
151 151
 
152 152
 			// don't import empty events
153
-			if( count( array_unique( $record ) ) < 2 ) continue;
153
+			if (count(array_unique($record)) < 2) continue;
154 154
 
155
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
155
+			if ($_definition->plugin_options['events_owner'] != -1) {
156 156
 				$record['owner'] = $_definition->plugin_options['events_owner'];
157
-			} else unset( $record['owner'] );
157
+			} else unset($record['owner']);
158 158
 
159
-			if ( $_definition->plugin_options['conditions'] ) {
160
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
161
-					switch ( $condition['type'] ) {
159
+			if ($_definition->plugin_options['conditions']) {
160
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
161
+					switch ($condition['type']) {
162 162
 						// exists
163 163
 						case 'exists' :
164 164
 
165
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
165
+							if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) {
166 166
 								// apply action to event matching this exists condition
167 167
 								$record['id'] = $event['id'];
168 168
 
169
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
170
-									if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] );
171
-									if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
172
-									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
169
+								if ($_definition->plugin_options['update_cats'] == 'add') {
170
+									if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']);
171
+									if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
172
+									$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id'])));
173 173
 								}
174 174
 
175 175
 								// check if entry is modiefied
176
-								$event = array_intersect_key( $event, $record );
177
-								$diff = array_diff( $event, $record );
178
-								if( !empty( $diff ) ) $record['modified'] = time();
176
+								$event = array_intersect_key($event, $record);
177
+								$diff = array_diff($event, $record);
178
+								if (!empty($diff)) $record['modified'] = time();
179 179
 
180 180
 								$action = $condition['true'];
181 181
 							} else $action = $condition['false'];
182 182
 
183
-							$this->action( $action['action'], $record );
183
+							$this->action($action['action'], $record);
184 184
 							break;
185 185
 						case 'empty' :
186
-							$action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false'];
187
-							$this->action( $action['action'], $record );
186
+							$action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false'];
187
+							$this->action($action['action'], $record);
188 188
 							break;
189 189
 
190 190
 						// not supported action
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				}
197 197
 			} else {
198 198
 				// unconditional insert
199
-				$this->action( 'insert', $record );
199
+				$this->action('insert', $record);
200 200
 			}
201 201
 		}
202 202
 	}
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param array $_data event data for the action
209 209
 	 * @return bool success or not
210 210
 	 */
211
-	private function action ( $_action, $_data ) {
212
-		switch ( $_action ) {
211
+	private function action($_action, $_data) {
212
+		switch ($_action) {
213 213
 			case 'none' :
214 214
 				return true;
215 215
 
@@ -217,32 +217,32 @@  discard block
 block discarded – undo
217 217
 			case 'insert' :
218 218
 
219 219
 				// paticipants handling
220
-				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
220
+				$participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array();
221 221
 				$_data['participants'] = array();
222
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
222
+				if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) {
223 223
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
224 224
 				}
225
-				foreach( $participants as $participant ) {
226
-					list( $participant, $status ) = explode( '=', $participant );
227
-					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
228
-					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
229
-					if ( $participant && is_numeric($participant ) ) {
225
+				foreach ($participants as $participant) {
226
+					list($participant, $status) = explode('=', $participant);
227
+					$valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T');
228
+					$status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U';
229
+					if ($participant && is_numeric($participant)) {
230 230
 						$_data['participants'][$participant] = $status;
231 231
 					}
232 232
 				}
233 233
 				// no valid participants so far --> add the importing user/owner
234
-				if ( empty( $_data['participants'] ) ) {
234
+				if (empty($_data['participants'])) {
235 235
 					$_data['participants'][$this->user] = 'A';
236 236
 				}
237 237
 
238 238
 				// are we serious?
239
-				if ( $this->dry_run ) {
239
+				if ($this->dry_run) {
240 240
 					print_r($_data);
241 241
 					$this->results[$_action]++;
242 242
 				} else {
243 243
 					$messages = array();
244
-					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
245
-					if(!$result) {
244
+					$result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages);
245
+					if (!$result) {
246 246
 						$this->errors = implode(',', $messages);
247 247
 					} else {
248 248
 						$this->results[$_action]++;
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.
Braces   +216 added lines, -55 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
 
@@ -304,7 +322,10 @@  discard block
 block discarded – undo
304 322
 		$types_with_quantity = array();
305 323
 		foreach($this->resources as $type => $data)
306 324
 		{
307
-			if ($data['max_quantity']) $types_with_quantity[] = $type;
325
+			if ($data['max_quantity'])
326
+			{
327
+				$types_with_quantity[] = $type;
328
+			}
308 329
 		}
309 330
 		// get all NOT rejected participants and evtl. their quantity
310 331
 		$quantity = $users = array();
@@ -312,12 +333,19 @@  discard block
 block discarded – undo
312 333
 		{
313 334
 			$q = $r = null;
314 335
 			calendar_so::split_status($status,$q,$r);
315
-			if ($status[0] == 'R') continue;	// ignore rejected participants
336
+			if ($status[0] == 'R')
337
+			{
338
+				continue;
339
+			}
340
+			// ignore rejected participants
316 341
 
317
-			if ($uid < 0)	// group, check it's members too
342
+			if ($uid < 0)
343
+			{
344
+				// group, check it's members too
318 345
 			{
319 346
 				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
320 347
 			}
348
+			}
321 349
 			$users[] = $uid;
322 350
 			if (in_array($uid[0],$types_with_quantity))
323 351
 			{
@@ -348,18 +376,24 @@  discard block
 block discarded – undo
348 376
 			$startts = $date->format('ts');
349 377
 
350 378
 			// skip past events or recurrences
351
-			if ($startts+$duration < $this->now_su) continue;
379
+			if ($startts+$duration < $this->now_su)
380
+			{
381
+				continue;
382
+			}
352 383
 
353 384
 			// abort check if configured limits are exceeded
354 385
 			if ($event['recur_type'] &&
355 386
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
356 387
 				microtime(true) > $start+$max_check_time ||	// max check time exceeded
357
-				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
388
+				$startts > $this->config['horizont']))
389
+			{
390
+				// we are behind horizon for which recurrences are rendered
358 391
 			{
359 392
 				if ($this->debug > 2 || $this->debug == 'conflicts')
360 393
 				{
361 394
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
362 395
 						$checked, microtime(true)-$start, $date);
396
+			}
363 397
 				}
364 398
 				$checked_excluding = $date;
365 399
 				break;
@@ -383,10 +417,13 @@  discard block
 block discarded – undo
383 417
 			{
384 418
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
385 419
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
386
-					$overlap['non_blocking'])			// that's a non_blocking event
420
+					$overlap['non_blocking'])
421
+				{
422
+					// that's a non_blocking event
387 423
 				{
388 424
 					continue;
389 425
 				}
426
+				}
390 427
 				if ($this->debug > 3 || $this->debug == 'conflicts')
391 428
 				{
392 429
 					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
@@ -506,7 +543,11 @@  discard block
 block discarded – undo
506 543
 	 */
507 544
 	public function check_acl_invite($uid)
508 545
 	{
509
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
546
+		if (!is_numeric($uid))
547
+		{
548
+			return true;
549
+		}
550
+		// nothing implemented for resources so far
510 551
 
511 552
 		if (!$this->require_acl_invite)
512 553
 		{
@@ -847,14 +888,20 @@  discard block
 block discarded – undo
847 888
 		$startdate = new Api\DateTime($event['start']);
848 889
 		$enddate = new Api\DateTime($event['end']);
849 890
 		$modified = new Api\DateTime($event['modified']);
850
-		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
891
+		if ($old_event)
892
+		{
893
+			$olddate = new Api\DateTime($old_event['start']);
894
+		}
851 895
 		//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() : ''));
852 896
 		$owner_prefs = $ics = null;
853 897
 		foreach($to_notify as $userid => $statusid)
854 898
 		{
855 899
 			$res_info = $quantity = $role = null;
856 900
 			calendar_so::split_status($statusid, $quantity, $role);
857
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
901
+			if ($this->debug > 0)
902
+			{
903
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
904
+			}
858 905
 
859 906
 			if (!is_numeric($userid))
860 907
 			{
@@ -873,7 +920,11 @@  discard block
 block discarded – undo
873 920
 
874 921
 				if (!isset($userid))
875 922
 				{
876
-					if (empty($res_info['email'])) continue;	// no way to notify
923
+					if (empty($res_info['email']))
924
+					{
925
+						continue;
926
+					}
927
+					// no way to notify
877 928
 					// check if event-owner wants non-EGroupware users notified
878 929
 					if (is_null($owner_prefs))
879 930
 					{
@@ -943,7 +994,10 @@  discard block
 block discarded – undo
943 994
 				$details['to-lastname'] = isset($tln)? $tln: '';
944 995
 
945 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
946
-				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
+				}
947 1001
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
948 1002
 				$timeformat = $part_prefs['common']['timeformat'];
949 1003
 				switch($timeformat)
@@ -978,9 +1032,12 @@  discard block
 block discarded – undo
978 1032
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
979 1033
 				{
980 1034
 					case 'ical':
981
-						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
982 1038
 						{
983 1039
 							$calendar_ical = new calendar_ical();
1040
+						}
984 1041
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
985 1042
 							// we need to pass $event[id] so iCal class reads event again,
986 1043
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -994,7 +1051,10 @@  discard block
 block discarded – undo
994 1051
 							'encoding' => '8bit',
995 1052
 							'type' => 'text/calendar; method='.$method,
996 1053
 						);
997
-						if ($m_type != $msg_type) unset($ics);
1054
+						if ($m_type != $msg_type)
1055
+						{
1056
+							unset($ics);
1057
+						}
998 1058
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
999 1059
 						// fall through
1000 1060
 					case 'extended':
@@ -1045,7 +1105,9 @@  discard block
 block discarded – undo
1045 1105
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1046 1106
 						$notification->set_popuplinks(array($details['link_arr']));
1047 1107
 
1048
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1108
+						if(is_array($attachment))
1109
+						{
1110
+$notification->set_attachments(array($attachment)); }
1049 1111
 						$notification->send();
1050 1112
 					}
1051 1113
 					catch (Exception $exception) {
@@ -1077,7 +1139,10 @@  discard block
 block discarded – undo
1077 1139
 			Api\Translation::init();
1078 1140
 		}
1079 1141
 		// restore timezone, in case we had to reset it to server-timezone
1080
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1142
+		if ($restore_tz)
1143
+		{
1144
+			date_default_timezone_set($restore_tz);
1145
+		}
1081 1146
 
1082 1147
 		return true;
1083 1148
 	}
@@ -1112,10 +1177,13 @@  discard block
 block discarded – undo
1112 1177
 		{
1113 1178
 			$to_notify = $event['participants'];
1114 1179
 		}
1115
-		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]
1116 1183
 		{
1117 1184
 			$to_notify[$alarm['owner']] = 'A';
1118 1185
 		}
1186
+		}
1119 1187
 		else
1120 1188
 		{
1121 1189
 			return False;	// no rights
@@ -1165,7 +1233,10 @@  discard block
 block discarded – undo
1165 1233
 		if ($event['id'])
1166 1234
 		{
1167 1235
 			// invalidate the read-cache if it contains the event we store now
1168
-			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
+			}
1169 1240
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1170 1241
 		}
1171 1242
 		else
@@ -1173,7 +1244,10 @@  discard block
 block discarded – undo
1173 1244
 			$old_event = null;
1174 1245
 		}
1175 1246
 
1176
-		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
+		}
1177 1251
 		$save_event = $event;
1178 1252
 		if ($event['whole_day'])
1179 1253
 		{
@@ -1214,7 +1288,10 @@  discard block
 block discarded – undo
1214 1288
 		foreach($timestamps as $ts)
1215 1289
 		{
1216 1290
 			// we convert here from user-time to timestamps in server-time!
1217
-			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
+			}
1218 1295
 		}
1219 1296
 		// convert tzid name to integer tz_id, of set user default
1220 1297
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1264,7 +1341,10 @@  discard block
 block discarded – undo
1264 1341
 				if (!isset($event['alarm'][$id]))
1265 1342
 				{
1266 1343
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1267
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1344
+					if ($alarm['time'] < time())
1345
+					{
1346
+						calendar_so::shift_alarm($event, $alarm);
1347
+					}
1268 1348
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1269 1349
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1270 1350
 						$old_event['participants'][$alarm['owner']];
@@ -1317,7 +1397,10 @@  discard block
 block discarded – undo
1317 1397
 
1318 1398
 		// Update history
1319 1399
 		$tracking = new calendar_tracking($this);
1320
-		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
+		}
1321 1404
 		$tracking->track($event, $old_event);
1322 1405
 
1323 1406
 		return $cal_id;
@@ -1334,9 +1417,12 @@  discard block
 block discarded – undo
1334 1417
 	 */
1335 1418
 	function check_status_perms($uid,$event)
1336 1419
 	{
1337
-		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
1338 1423
 		{
1339 1424
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1425
+		}
1340 1426
 
1341 1427
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1342 1428
 		}
@@ -1347,13 +1433,19 @@  discard block
 block discarded – undo
1347 1433
 			return $access;
1348 1434
 		}
1349 1435
 		// no access or denied access because of category acl --> regular check
1350
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1436
+		if (!is_numeric($uid))
1437
+		{
1438
+			// this is eg. for resources (r123)
1351 1439
 		{
1352 1440
 			$resource = $this->resource_info($uid);
1441
+		}
1353 1442
 
1354 1443
 			return Acl::EDIT & $resource['rights'];
1355 1444
 		}
1356
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1445
+		if (!is_array($event) && !($event = $this->read($event)))
1446
+		{
1447
+			return false;
1448
+		}
1357 1449
 
1358 1450
 		// regular user and groups (need to check memberships too)
1359 1451
 		if (!isset($event['participants'][$uid]))
@@ -1377,7 +1469,10 @@  discard block
 block discarded – undo
1377 1469
 	 */
1378 1470
 	function check_cat_acl($right,$event)
1379 1471
 	{
1380
-		if (!is_array($event)) $event = $this->read($event);
1472
+		if (!is_array($event))
1473
+		{
1474
+			$event = $this->read($event);
1475
+		}
1381 1476
 
1382 1477
 		$ret = null;
1383 1478
 		if ($event['category'])
@@ -1434,7 +1529,10 @@  discard block
 block discarded – undo
1434 1529
 	public static function set_cat_rights($cat_id,$user,$rights)
1435 1530
 	{
1436 1531
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1437
-		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
+		}
1438 1536
 
1439 1537
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1440 1538
 		{
@@ -1446,7 +1544,10 @@  discard block
 block discarded – undo
1446 1544
 			else
1447 1545
 			{
1448 1546
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1449
-				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
+				}
1450 1551
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1451 1552
 			}
1452 1553
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1479,7 +1580,10 @@  discard block
 block discarded – undo
1479 1580
 				foreach($cat_rights as $uid => $value)
1480 1581
 				{
1481 1582
 					$all |= $value;
1482
-					if (in_array($uid,$memberships)) $own |= $value;
1583
+					if (in_array($uid,$memberships))
1584
+					{
1585
+						$own |= $value;
1586
+					}
1483 1587
 				}
1484 1588
 			}
1485 1589
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1526,13 +1630,16 @@  discard block
 block discarded – undo
1526 1630
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1527 1631
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1528 1632
 		{
1529
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1633
+			if ($status == 'R')
1634
+			{
1635
+				// remove alarms belonging to rejected participants
1530 1636
 			{
1531 1637
 				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1532 1638
 				{
1533 1639
 					if ((string)$alarm['owner'] === (string)$uid)
1534 1640
 					{
1535 1641
 						$this->so->delete_alarm($id);
1642
+			}
1536 1643
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1537 1644
 					}
1538 1645
 				}
@@ -1546,8 +1653,15 @@  discard block
 block discarded – undo
1546 1653
 			);
1547 1654
 			if (isset($status2msg[$status]) && !$skip_notification)
1548 1655
 			{
1549
-				if (!is_array($event)) $event = $this->read($cal_id);
1550
-				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
1551 1665
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1552 1666
 			}
1553 1667
 
@@ -1570,12 +1684,16 @@  discard block
 block discarded – undo
1570 1684
 	 */
1571 1685
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1572 1686
 	{
1573
-		if (!isset($new_event['participants'])) return;
1687
+		if (!isset($new_event['participants']))
1688
+		{
1689
+			return;
1690
+		}
1574 1691
 
1575 1692
 		// check the old list against the new list
1576 1693
 		foreach ($old_event['participants'] as $userid => $status)
1577
-  		{
1578
-            if (!isset($new_event['participants'][$userid])){
1694
+		{
1695
+            if (!isset($new_event['participants'][$userid]))
1696
+            {
1579 1697
             	// Attendee will be deleted this way
1580 1698
             	$new_event['participants'][$userid] = 'G';
1581 1699
             }
@@ -1658,7 +1776,10 @@  discard block
 block discarded – undo
1658 1776
 					}
1659 1777
 					else
1660 1778
 					{
1661
-						if (!($exception = $this->read($id))) continue;
1779
+						if (!($exception = $this->read($id)))
1780
+						{
1781
+							continue;
1782
+						}
1662 1783
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1663 1784
 						$exception['reference'] = $exception['recurrence'] = 0;
1664 1785
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1729,7 +1850,10 @@  discard block
 block discarded – undo
1729 1850
 		$event_arr = $this->event2array($event);
1730 1851
 		foreach($event_arr as $key => $val)
1731 1852
 		{
1732
-			if ($key == 'recur_type') $key = 'repetition';
1853
+			if ($key == 'recur_type')
1854
+			{
1855
+				$key = 'repetition';
1856
+			}
1733 1857
 			$details[$key] = $val['data'];
1734 1858
 		}
1735 1859
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1901,7 +2025,10 @@  discard block
 block discarded – undo
1901 2025
 	 */
1902 2026
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1903 2027
 	{
1904
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
2028
+		if ($old_event !== null && $event['start'] == $old_event['start'])
2029
+		{
2030
+			return;
2031
+		}
1905 2032
 
1906 2033
 		$time = new Api\DateTime($event['start']);
1907 2034
 		if(!is_array($event['alarm']))
@@ -1975,7 +2102,10 @@  discard block
 block discarded – undo
1975 2102
 		if (is_array($old_event) || $old_event > 0)
1976 2103
 		{
1977 2104
 			// preserve categories without users read access
1978
-			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
+			}
1979 2109
 			$old_categories = explode(',',$old_event['category']);
1980 2110
 			$old_cats_preserve = array();
1981 2111
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -2066,7 +2196,10 @@  discard block
 block discarded – undo
2066 2196
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2067 2197
 		}
2068 2198
 
2069
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2199
+		if (!isset($event['recurrence']))
2200
+		{
2201
+			$event['recurrence'] = 0;
2202
+		}
2070 2203
 
2071 2204
 		if ($filter == 'master')
2072 2205
 		{
@@ -2120,19 +2253,26 @@  discard block
 block discarded – undo
2120 2253
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2121 2254
 						}
2122 2255
 					}
2123
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2256
+				}
2257
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2124 2258
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2125 2259
 							strpos($egwEvent['title'], $event['title']) === 0))
2126 2260
 				{
2127 2261
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2128 2262
 				}
2129 2263
 			}
2130
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2264
+			if (!empty($matchingEvents) || $filter == 'exact')
2265
+			{
2266
+				return $matchingEvents;
2267
+			}
2131 2268
 		}
2132 2269
 		unset($event['id']);
2133 2270
 
2134 2271
 		// No chance to find a master without [U]ID
2135
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2272
+		if ($filter == 'master' && empty($event['uid']))
2273
+		{
2274
+			return $matchingEvents;
2275
+		}
2136 2276
 
2137 2277
 		// only query calendars of users, we have READ-grants from
2138 2278
 		$users = array();
@@ -2141,17 +2281,23 @@  discard block
 block discarded – undo
2141 2281
 			$user = trim($user);
2142 2282
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2143 2283
 			{
2144
-				if ($user && !in_array($user,$users))	// already added?
2284
+				if ($user && !in_array($user,$users))
2285
+				{
2286
+					// already added?
2145 2287
 				{
2146 2288
 					$users[] = $user;
2147 2289
 				}
2290
+				}
2148 2291
 			}
2149 2292
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2150 2293
 			{
2151 2294
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2152 2295
 			}
2153 2296
 			// the further code is only for real users
2154
-			if (!is_numeric($user)) continue;
2297
+			if (!is_numeric($user))
2298
+			{
2299
+				continue;
2300
+			}
2155 2301
 
2156 2302
 			// for groups we have to include the members
2157 2303
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2231,7 +2377,10 @@  discard block
 block discarded – undo
2231 2377
 			}
2232 2378
 			foreach ($matchFields as $key)
2233 2379
 			{
2234
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2380
+				if (isset($event[$key]))
2381
+				{
2382
+					$query['cal_'.$key] = $event[$key];
2383
+				}
2235 2384
 			}
2236 2385
 		}
2237 2386
 
@@ -2271,7 +2420,10 @@  discard block
 block discarded – undo
2271 2420
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2272 2421
 			}
2273 2422
 
2274
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2423
+			if (in_array($egwEvent['id'], $matchingEvents))
2424
+			{
2425
+				continue;
2426
+			}
2275 2427
 
2276 2428
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2277 2429
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2438,13 +2590,16 @@  discard block
 block discarded – undo
2438 2590
 					foreach ($event['participants'] as $attendee => $status)
2439 2591
 					{
2440 2592
 						if (!isset($egwEvent['participants'][$attendee]) &&
2441
-								$attendee != $egwEvent['owner']) // ||
2593
+								$attendee != $egwEvent['owner'])
2594
+						{
2595
+							// ||
2442 2596
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2443 2597
 						{
2444 2598
 							if ($this->log)
2445 2599
 							{
2446 2600
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2447 2601
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2602
+						}
2448 2603
 							}
2449 2604
 							continue 2;
2450 2605
 						}
@@ -2766,7 +2921,10 @@  discard block
 block discarded – undo
2766 2921
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2767 2922
 		{
2768 2923
 			// we convert here from server-time to timestamps in user-time!
2769
-			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
+			}
2770 2928
 		}
2771 2929
 		// same with the recur exceptions
2772 2930
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2794,9 +2952,12 @@  discard block
 block discarded – undo
2794 2952
 	 */
2795 2953
 	function purge($age)
2796 2954
 	{
2797
-		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
2798 2958
 		{
2799 2959
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2800 2960
 		}
2961
+		}
2801 2962
 	}
2802 2963
 }
Please login to merge, or discard this patch.
Spacing   +306 added lines, -308 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
 			{
@@ -258,30 +258,30 @@  discard block
 block discarded – undo
258 258
 		$event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null);
259 259
 		//error_log("new $cal_id=". array2string($event));
260 260
 
261
-		if($old_event['deleted'] && $event['deleted'] == null)
261
+		if ($old_event['deleted'] && $event['deleted'] == null)
262 262
 		{
263 263
 			// Restored, bring back links
264 264
 			Link::restore('calendar', $cal_id);
265 265
 		}
266 266
 		if ($this->log_file)
267 267
 		{
268
-			$this->log2file($event2save,$event,$old_event);
268
+			$this->log2file($event2save, $event, $old_event);
269 269
 		}
270 270
 		// send notifications
271
-		if(!$skip_notification)
271
+		if (!$skip_notification)
272 272
 		{
273 273
 			if ($new_event)
274 274
 			{
275
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
275
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
276 276
 			}
277 277
 			else // update existing event
278 278
 			{
279
-				$this->check4update($event,$old_event);
279
+				$this->check4update($event, $old_event);
280 280
 			}
281 281
 		}
282 282
 
283 283
 		// notify the link-class about the update, as other apps may be subscribt to it
284
-		Link::notify_update('calendar',$cal_id,$event);
284
+		Link::notify_update('calendar', $cal_id, $event);
285 285
 
286 286
 		return $cal_id;
287 287
 	}
@@ -299,27 +299,27 @@  discard block
 block discarded – undo
299 299
 	 * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked
300 300
 	 * @return array or events
301 301
 	 */
302
-	function conflicts(array $event, &$checked_excluding=null)
302
+	function conflicts(array $event, &$checked_excluding = null)
303 303
 	{
304 304
 		$types_with_quantity = array();
305
-		foreach($this->resources as $type => $data)
305
+		foreach ($this->resources as $type => $data)
306 306
 		{
307 307
 			if ($data['max_quantity']) $types_with_quantity[] = $type;
308 308
 		}
309 309
 		// get all NOT rejected participants and evtl. their quantity
310 310
 		$quantity = $users = array();
311
-		foreach($event['participants'] as $uid => $status)
311
+		foreach ($event['participants'] as $uid => $status)
312 312
 		{
313 313
 			$q = $r = null;
314
-			calendar_so::split_status($status,$q,$r);
315
-			if ($status[0] == 'R') continue;	// ignore rejected participants
314
+			calendar_so::split_status($status, $q, $r);
315
+			if ($status[0] == 'R') continue; // ignore rejected participants
316 316
 
317 317
 			if ($uid < 0)	// group, check it's members too
318 318
 			{
319
-				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
319
+				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true)));
320 320
 			}
321 321
 			$users[] = $uid;
322
-			if (in_array($uid[0],$types_with_quantity))
322
+			if (in_array($uid[0], $types_with_quantity))
323 323
 			{
324 324
 				$quantity[$uid] = $q;
325 325
 			}
@@ -342,58 +342,58 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 		$checked = 0;
344 344
 		$start = microtime(true);
345
-		$duration = $event['end']-$event['start'];
346
-		foreach($recurences as $date)
345
+		$duration = $event['end'] - $event['start'];
346
+		foreach ($recurences as $date)
347 347
 		{
348 348
 			$startts = $date->format('ts');
349 349
 
350 350
 			// skip past events or recurrences
351
-			if ($startts+$duration < $this->now_su) continue;
351
+			if ($startts + $duration < $this->now_su) continue;
352 352
 
353 353
 			// abort check if configured limits are exceeded
354 354
 			if ($event['recur_type'] &&
355 355
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
356
-				microtime(true) > $start+$max_check_time ||	// max check time exceeded
356
+				microtime(true) > $start + $max_check_time || // max check time exceeded
357 357
 				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
358 358
 			{
359 359
 				if ($this->debug > 2 || $this->debug == 'conflicts')
360 360
 				{
361 361
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
362
-						$checked, microtime(true)-$start, $date);
362
+						$checked, microtime(true) - $start, $date);
363 363
 				}
364 364
 				$checked_excluding = $date;
365 365
 				break;
366 366
 			}
367
-			$overlapping_events =& $this->search(array(
367
+			$overlapping_events = & $this->search(array(
368 368
 				'start' => $startts,
369
-				'end'   => $startts+$duration,
369
+				'end'   => $startts + $duration,
370 370
 				'users' => $users,
371
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
372
-				'enum_groups' => true,	// otherwise group-events would not block time
371
+				'ignore_acl' => true, // otherwise we get only events readable by the user
372
+				'enum_groups' => true, // otherwise group-events would not block time
373 373
 				'query' => array(
374 374
 					'cal_non_blocking' => 0,
375 375
 				),
376
-				'no_integration' => true,	// do NOT use integration of other apps
376
+				'no_integration' => true, // do NOT use integration of other apps
377 377
 			));
378 378
 			if ($this->debug > 2 || $this->debug == 'conflicts')
379 379
 			{
380
-				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration);
380
+				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration);
381 381
 			}
382
-			foreach((array) $overlapping_events as $k => $overlap)
382
+			foreach ((array)$overlapping_events as $k => $overlap)
383 383
 			{
384
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
385
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
384
+				if ($overlap['id'] == $event['id'] || // that's the event itself
385
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
386 386
 					$overlap['non_blocking'])			// that's a non_blocking event
387 387
 				{
388 388
 					continue;
389 389
 				}
390 390
 				if ($this->debug > 3 || $this->debug == 'conflicts')
391 391
 				{
392
-					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
392
+					$this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap);
393 393
 				}
394 394
 				// check if the overlap is with a rejected participant or within the allowed quantity
395
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
396
-				foreach($common_parts as $n => $uid)
395
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
396
+				foreach ($common_parts as $n => $uid)
397 397
 				{
398 398
 					$status = $overlap['participants'][$uid];
399 399
 					calendar_so::split_status($status, $q, $r);
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 						unset($common_parts[$n]);
403 403
 						continue;
404 404
 					}
405
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
405
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
406 406
 					{
407
-						continue;	// no quantity check: quantity allways 1 ==> conflict
407
+						continue; // no quantity check: quantity allways 1 ==> conflict
408 408
 					}
409 409
 					if (!isset($max_quantity[$uid]))
410 410
 					{
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 					$quantity[$uid] += $q;
415 415
 					if ($quantity[$uid] <= $max_quantity[$uid])
416 416
 					{
417
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
417
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
418 418
 						unset($common_parts[$n]);
419 419
 						continue;
420 420
 					}
@@ -424,22 +424,22 @@  discard block
 block discarded – undo
424 424
 				{
425 425
 					if ($this->debug > 3 || $this->debug == 'conflicts')
426 426
 					{
427
-						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts);
427
+						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts);
428 428
 					}
429
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
429
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
430 430
 				}
431 431
 			}
432 432
 		}
433 433
 		//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
434 434
 		// check if we are withing the allowed quantity and if not add all events using that resource
435 435
 		// seems this function is doing very strange things, it gives empty conflicts
436
-		foreach($max_quantity as $uid => $max)
436
+		foreach ($max_quantity as $uid => $max)
437 437
 		{
438 438
 			if ($quantity[$uid] > $max)
439 439
 			{
440
-				foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
440
+				foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
441 441
 				{
442
-					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
442
+					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
443 443
 				}
444 444
 			}
445 445
 		}
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
 
448 448
 		if (count($conflicts))
449 449
 		{
450
-			foreach($conflicts as $key => $conflict)
450
+			foreach ($conflicts as $key => $conflict)
451 451
 			{
452
-					$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
453
-				if (!$this->check_perms(Acl::READ,$conflict))
452
+					$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
453
+				if (!$this->check_perms(Acl::READ, $conflict))
454 454
 				{
455 455
 					$conflicts[$key] = array(
456 456
 						'id'    => $conflict['id'],
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			}
464 464
 			if ($this->debug > 2 || $this->debug == 'conflicts')
465 465
 			{
466
-				$this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts);
466
+				$this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts);
467 467
 			}
468 468
 		}
469 469
 		return $conflicts;
@@ -475,22 +475,22 @@  discard block
 block discarded – undo
475 475
 	 * @param array $old_event =null old event with already invited participants
476 476
 	 * @return array removed participants because of missing invite grants
477 477
 	 */
478
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
478
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
479 479
 	{
480 480
 		if (!$this->require_acl_invite)
481 481
 		{
482
-			return array();	// nothing to check, everyone can invite everyone else
482
+			return array(); // nothing to check, everyone can invite everyone else
483 483
 		}
484 484
 		if ($event['id'] && is_null($old_event))
485 485
 		{
486 486
 			$old_event = $this->read($event['id']);
487 487
 		}
488 488
 		$removed = array();
489
-		foreach(array_keys((array)$event['participants']) as $uid)
489
+		foreach (array_keys((array)$event['participants']) as $uid)
490 490
 		{
491 491
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
492 492
 			{
493
-				unset($event['participants'][$uid]);	// remove participant
493
+				unset($event['participants'][$uid]); // remove participant
494 494
 				$removed[] = $uid;
495 495
 			}
496 496
 		}
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 	 */
507 507
 	public function check_acl_invite($uid)
508 508
 	{
509
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
509
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
510 510
 
511 511
 		if (!$this->require_acl_invite)
512 512
 		{
513
-			$ret = true;	// no grant required
513
+			$ret = true; // no grant required
514 514
 		}
515 515
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
516 516
 		{
517
-			$ret = true;	// grant only required for groups
517
+			$ret = true; // grant only required for groups
518 518
 		}
519 519
 		else
520 520
 		{
521
-			$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
521
+			$ret = $this->check_perms(self::ACL_INVITE, 0, $uid);
522 522
 		}
523 523
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
524 524
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 * @param array $old_event the event before the update
533 533
 	 * @todo check if there is a real change, not assume every save is a change
534 534
 	 */
535
-	function check4update($new_event,$old_event)
535
+	function check4update($new_event, $old_event)
536 536
 	{
537 537
 		//error_log(__METHOD__."($new_event[title])");
538 538
 		$modified = $added = $deleted = array();
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
541 541
 
542 542
 		// Find modified and deleted participants ...
543
-		foreach($old_event['participants'] as $old_userid => $old_status)
543
+		foreach ($old_event['participants'] as $old_userid => $old_status)
544 544
 		{
545
-			if(isset($new_event['participants'][$old_userid]))
545
+			if (isset($new_event['participants'][$old_userid]))
546 546
 			{
547 547
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
548 548
 			}
@@ -552,27 +552,27 @@  discard block
 block discarded – undo
552 552
 			}
553 553
 		}
554 554
 		// Find new participants ...
555
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
555
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
556 556
 		{
557
-			if(!isset($old_event['participants'][$new_userid]))
557
+			if (!isset($old_event['participants'][$new_userid]))
558 558
 			{
559 559
 				$added[$new_userid] = 'U';
560 560
 			}
561 561
 		}
562 562
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
563
-		if(count($added) || count($modified) || count($deleted))
563
+		if (count($added) || count($modified) || count($deleted))
564 564
 		{
565
-			if(count($added))
565
+			if (count($added))
566 566
 			{
567
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
567
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
568 568
 			}
569
-			if(count($modified))
569
+			if (count($modified))
570 570
 			{
571
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
571
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
572 572
 			}
573
-			if(count($deleted))
573
+			if (count($deleted))
574 574
 			{
575
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
575
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
576 576
 			}
577 577
 		}
578 578
 	}
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 	 * @param string $status of current user
590 590
 	 * @return boolean true = update requested, false otherwise
591 591
 	 */
592
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
592
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
593 593
 	{
594 594
 		if ($msg_type == MSG_ALARM)
595 595
 		{
596
-			return True;	// always True for now
596
+			return True; // always True for now
597 597
 		}
598 598
 		$want_update = 0;
599 599
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		//
602 602
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
603 603
 
604
-		switch($ru = $part_prefs['calendar']['receive_updates'])
604
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
605 605
 		{
606 606
 			case 'responses':
607 607
 				++$want_update;
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
 			default:
616 616
 				if (is_array($new_event) && is_array($old_event))
617 617
 				{
618
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
619
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
618
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
619
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
620 620
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
621 621
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
622 622
 					{
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
637 637
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
638 638
 				{
639
-					switch($msg_type)
639
+					switch ($msg_type)
640 640
 					{
641 641
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
642 642
 							$msg_type = MSG_REJECTED;
643 643
 							break;
644 644
 						case MSG_ADDED:		// new events use added, but organizer needs status
645
-							switch($status[0])
645
+							switch ($status[0])
646 646
 							{
647 647
 								case 'A': $msg_type = MSG_ACCEPTED; break;
648 648
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 * @param string $role ='REQ-PARTICIPANT'
668 668
 	 * @return boolean true if user requested to be notified, false if not
669 669
 	 */
670
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
670
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
671 671
 	{
672 672
 		// check if email is from a user
673 673
 		if (is_numeric($user_or_email))
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 				)
692 692
 			);
693 693
 		}
694
-		switch($ical_method)
694
+		switch ($ical_method)
695 695
 		{
696 696
 			default:
697 697
 			case 'REQUEST':
@@ -716,9 +716,9 @@  discard block
 block discarded – undo
716 716
 	 * @param string& $action=null on return verbose name
717 717
 	 * @param string& $msg=null on return notification message
718 718
 	 */
719
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
719
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
720 720
 	{
721
-		switch($msg_type)
721
+		switch ($msg_type)
722 722
 		{
723 723
 			case MSG_DELETED:
724 724
 				$action = 'Canceled';
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 		$msg = $this->cal_prefs['notify'.$pref];
771 771
 		if (empty($msg))
772 772
 		{
773
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
773
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
774 774
 		}
775 775
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
776 776
 		return $method;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 	 * @param int $user =0 User who started the notify, default current user
787 787
 	 * @return bool true/false
788 788
 	 */
789
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
789
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
790 790
 	{
791 791
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
792 792
 		if (!is_array($to_notify))
@@ -798,11 +798,11 @@  discard block
 block discarded – undo
798 798
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
799 799
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
800 800
 		{
801
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
801
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
802 802
 		}
803 803
 
804 804
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
805
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
805
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
806 806
 		{
807 807
 			return False;
808 808
 		}
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 			$restore_tz = $tz;
813 813
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
814 814
 		}
815
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
815
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
816 816
 
817 817
 		if (!$user)
818 818
 		{
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
829 829
 
830 830
 		// add all group-members to the notification, unless they are already participants
831
-		foreach($to_notify as $userid => $statusid)
831
+		foreach ($to_notify as $userid => $statusid)
832 832
 		{
833 833
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
834 834
 				($members = $GLOBALS['egw']->accounts->members($userid, true)))
835 835
 			{
836
-				foreach($members as $member)
836
+				foreach ($members as $member)
837 837
 				{
838 838
 					if (!isset($to_notify[$member]))
839 839
 					{
840
-						$to_notify[$member] = 'G';	// Group-invitation
840
+						$to_notify[$member] = 'G'; // Group-invitation
841 841
 					}
842 842
 				}
843 843
 			}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
850 850
 		//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() : ''));
851 851
 		$owner_prefs = $ics = null;
852
-		foreach($to_notify as $userid => $statusid)
852
+		foreach ($to_notify as $userid => $statusid)
853 853
 		{
854 854
 			$res_info = $quantity = $role = null;
855 855
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -872,14 +872,14 @@  discard block
 block discarded – undo
872 872
 
873 873
 				if (!isset($userid))
874 874
 				{
875
-					if (empty($res_info['email'])) continue;	// no way to notify
875
+					if (empty($res_info['email'])) continue; // no way to notify
876 876
 					// check if event-owner wants non-EGroupware users notified
877 877
 					if (is_null($owner_prefs))
878 878
 					{
879 879
 						$preferences = new Api\Preferences($owner);
880 880
 						$owner_prefs = $preferences->read_repository();
881 881
 					}
882
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
882
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
883 883
 						(empty($owner_prefs['calendar']['notify_externals']) ||
884 884
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
885 885
 					{
@@ -891,12 +891,12 @@  discard block
 block discarded – undo
891 891
 
892 892
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
893 893
 			{
894
-				continue;	// dont notify rejected participants or groups
894
+				continue; // dont notify rejected participants or groups
895 895
 			}
896 896
 
897
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
897
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
898 898
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
899
-					$user_prefs['calendar']['receive_own_updates']==1) ||
899
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
900 900
 				$msg_type == MSG_ALARM)
901 901
 			{
902 902
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 					$preferences = new Api\Preferences($userid);
906 906
 					$GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository();
907 907
 					$fullname = Api\Accounts::username($userid);
908
-					$tfn = Api\Accounts::id2name($userid,'account_firstname');
909
-					$tln = Api\Accounts::id2name($userid,'account_lastname');
908
+					$tfn = Api\Accounts::id2name($userid, 'account_firstname');
909
+					$tln = Api\Accounts::id2name($userid, 'account_lastname');
910 910
 				}
911 911
 				else	// external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification)
912 912
 				{
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 					}
918 918
 					$part_prefs = $owner_prefs;
919 919
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
920
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
920
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
921 921
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
922 922
 				}
923 923
 				$m_type = $msg_type;
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
939 939
 					$action, $event_arr, $disinvited);
940 940
 				$details['to-fullname'] = $fullname;
941
-				$details['to-firstname'] = isset($tfn)? $tfn: '';
942
-				$details['to-lastname'] = isset($tln)? $tln: '';
941
+				$details['to-firstname'] = isset($tfn) ? $tfn : '';
942
+				$details['to-lastname'] = isset($tln) ? $tln : '';
943 943
 
944 944
 				// 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
945 945
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
946 946
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
947 947
 				$timeformat = $part_prefs['common']['timeformat'];
948
-				switch($timeformat)
948
+				switch ($timeformat)
949 949
 				{
950 950
 			  		case '24':
951 951
 						$timeformat = 'H:i';
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 						$timeformat = 'h:i a';
955 955
 						break;
956 956
 				}
957
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
957
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
958 958
 
959 959
 				$startdate->setTimezone($timezone);
960 960
 				$details['startdate'] = $startdate->format($timeformat);
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 				$details['enddate'] = $enddate->format($timeformat);
964 964
 
965 965
 				$modified->setTimezone($timezone);
966
-				$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
966
+				$details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']);
967 967
 
968 968
 				if ($old_event != False)
969 969
 				{
@@ -972,15 +972,14 @@  discard block
 block discarded – undo
972 972
 				}
973 973
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
974 974
 
975
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
975
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
976 976
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
977
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
977
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
978 978
 				{
979
-					case 'ical':
980
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
979
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
981 980
 						{
982 981
 							$calendar_ical = new calendar_ical();
983
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
982
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
984 983
 							// we need to pass $event[id] so iCal class reads event again,
985 984
 							// as event is in user TZ, but iCal class expects server TZ!
986 985
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -999,11 +998,11 @@  discard block
 block discarded – undo
999 998
 					case 'extended':
1000 999
 
1001 1000
 						$details_body = lang('Event Details follow').":\n";
1002
-						foreach($event_arr as $key => $val)
1001
+						foreach ($event_arr as $key => $val)
1003 1002
 						{
1004
-							if(!empty($details[$key]))
1003
+							if (!empty($details[$key]))
1005 1004
 							{
1006
-								switch($key)
1005
+								switch ($key)
1007 1006
 								{
1008 1007
 							 		case 'access':
1009 1008
 									case 'priority':
@@ -1012,7 +1011,7 @@  discard block
 block discarded – undo
1012 1011
 									case 'title':
1013 1012
 										break;
1014 1013
 									default:
1015
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
1014
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
1016 1015
 										break;
1017 1016
 							 	}
1018 1017
 							}
@@ -1020,7 +1019,7 @@  discard block
 block discarded – undo
1020 1019
 						break;
1021 1020
 				}
1022 1021
 				// send via notification_app
1023
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1022
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1024 1023
 				{
1025 1024
 					try {
1026 1025
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -1044,9 +1043,9 @@  discard block
 block discarded – undo
1044 1043
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1045 1044
 						$notification->set_popuplinks(array($details['link_arr']));
1046 1045
 
1047
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1046
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1048 1047
 						$notification->send();
1049
-						foreach(notifications::errors(true) as $error)
1048
+						foreach (notifications::errors(true) as $error)
1050 1049
 						{
1051 1050
 							error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error");
1052 1051
 						}
@@ -1085,14 +1084,14 @@  discard block
 block discarded – undo
1085 1084
 		return true;
1086 1085
 	}
1087 1086
 
1088
-	function get_update_message($event,$added)
1087
+	function get_update_message($event, $added)
1089 1088
 	{
1090 1089
 		$nul = null;
1091
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1090
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1092 1091
 
1093 1092
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1094 1093
 
1095
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1094
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1096 1095
 	}
1097 1096
 
1098 1097
 	/**
@@ -1106,37 +1105,37 @@  discard block
 block discarded – undo
1106 1105
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1107 1106
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1108 1107
 
1109
-		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1110
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1108
+		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1109
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1111 1110
 		{
1112
-			return False;	// event not found
1111
+			return False; // event not found
1113 1112
 		}
1114 1113
 		if ($alarm['all'])
1115 1114
 		{
1116 1115
 			$to_notify = $event['participants'];
1117 1116
 		}
1118
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1117
+		elseif ($this->check_perms(Acl::READ, $event))	// checks agains $this->owner set to $alarm[owner]
1119 1118
 		{
1120 1119
 			$to_notify[$alarm['owner']] = 'A';
1121 1120
 		}
1122 1121
 		else
1123 1122
 		{
1124
-			return False;	// no rights
1123
+			return False; // no rights
1125 1124
 		}
1126 1125
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1127 1126
 		Api\Translation::add_app('calendar');
1128 1127
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1129 1128
 
1130
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1129
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1131 1130
 
1132 1131
 		// create a new alarm for recuring events for the next event, if one exists
1133
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1132
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1134 1133
 		{
1135 1134
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1136 1135
 			unset($alarm['times']);
1137 1136
 			unset($alarm['next']);
1138 1137
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1139
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1138
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1140 1139
 		}
1141 1140
 		return $ret;
1142 1141
 	}
@@ -1152,15 +1151,15 @@  discard block
 block discarded – undo
1152 1151
 	 * DEPRECATED: we allways (have to) update timestamp, as they are required for sync!
1153 1152
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1154 1153
 	 */
1155
-	function save($event,$ignore_acl=false,$updateTS=true)
1154
+	function save($event, $ignore_acl = false, $updateTS = true)
1156 1155
 	{
1157 1156
 		unset($updateTS);
1158 1157
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1159 1158
 
1160 1159
 		// check if user has the permission to update / create the event
1161
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
1162
-			!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
1163
-			!$this->check_perms(Acl::ADD,0,$event['owner'])))
1160
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) ||
1161
+			!$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) &&
1162
+			!$this->check_perms(Acl::ADD, 0, $event['owner'])))
1164 1163
 		{
1165 1164
 			return false;
1166 1165
 		}
@@ -1205,19 +1204,19 @@  discard block
 block discarded – undo
1205 1204
 				$time->setUser();
1206 1205
 				$save_event['recur_enddate'] = Api\DateTime::to($time, 'ts');
1207 1206
 			}
1208
-			$timestamps = array('modified','created');
1207
+			$timestamps = array('modified', 'created');
1209 1208
 			// all-day events are handled in server time
1210 1209
 			$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
1211 1210
 		}
1212 1211
 		else
1213 1212
 		{
1214
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1213
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1215 1214
 		}
1216 1215
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1217
-		foreach($timestamps as $ts)
1216
+		foreach ($timestamps as $ts)
1218 1217
 		{
1219 1218
 			// we convert here from user-time to timestamps in server-time!
1220
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1219
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1221 1220
 		}
1222 1221
 		// convert tzid name to integer tz_id, of set user default
1223 1222
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1227,7 +1226,7 @@  discard block
 block discarded – undo
1227 1226
 		// same with the recur exceptions
1228 1227
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1229 1228
 		{
1230
-			foreach($event['recur_exception'] as &$date)
1229
+			foreach ($event['recur_exception'] as &$date)
1231 1230
 			{
1232 1231
 				if ($event['whole_day'])
1233 1232
 				{
@@ -1236,7 +1235,7 @@  discard block
 block discarded – undo
1236 1235
 				}
1237 1236
 				else
1238 1237
 				{
1239
-					$date = $this->date2ts($date,true);
1238
+					$date = $this->date2ts($date, true);
1240 1239
 				}
1241 1240
 			}
1242 1241
 			unset($date);
@@ -1244,7 +1243,7 @@  discard block
 block discarded – undo
1244 1243
 		// same with the alarms
1245 1244
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1246 1245
 		{
1247
-			foreach($event['alarm'] as $id => &$alarm)
1246
+			foreach ($event['alarm'] as $id => &$alarm)
1248 1247
 			{
1249 1248
 				// remove alarms belonging to not longer existing or rejected participants
1250 1249
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1262,15 +1261,14 @@  discard block
 block discarded – undo
1262 1261
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1263 1262
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1264 1263
 		{
1265
-			foreach($old_event['alarm'] as $id => &$alarm)
1264
+			foreach ($old_event['alarm'] as $id => &$alarm)
1266 1265
 			{
1267 1266
 				if (!isset($event['alarm'][$id]))
1268 1267
 				{
1269 1268
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1270 1269
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1271 1270
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1272
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1273
-						$old_event['participants'][$alarm['owner']];
1271
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1274 1272
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1275 1273
 					{
1276 1274
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1296,7 +1294,7 @@  discard block
 block discarded – undo
1296 1294
 		}
1297 1295
 		$set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] : false;
1298 1296
 		$set_recurrences_start = 0;
1299
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1297
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1300 1298
 		{
1301 1299
 			$save_event['id'] = $cal_id;
1302 1300
 			// unset participants to enforce the default stati for all added recurrences
@@ -1307,7 +1305,7 @@  discard block
 block discarded – undo
1307 1305
 		// create links for new participants from addressbook, if configured
1308 1306
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1309 1307
 		{
1310
-			foreach($event['participants'] as $uid => $status)
1308
+			foreach ($event['participants'] as $uid => $status)
1311 1309
 			{
1312 1310
 				$user_type = $user_id = null;
1313 1311
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1320,7 +1318,7 @@  discard block
 block discarded – undo
1320 1318
 
1321 1319
 		// Update history
1322 1320
 		$tracking = new calendar_tracking($this);
1323
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1321
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1324 1322
 		$tracking->track($event, $old_event);
1325 1323
 
1326 1324
 		return $cal_id;
@@ -1335,16 +1333,16 @@  discard block
 block discarded – undo
1335 1333
 	 * @param array|int $event event array or id of the event
1336 1334
 	 * @return boolean
1337 1335
 	 */
1338
-	function check_status_perms($uid,$event)
1336
+	function check_status_perms($uid, $event)
1339 1337
 	{
1340 1338
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1341 1339
 		{
1342 1340
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1343 1341
 
1344
-			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1342
+			return $this->check_perms(Acl::EDIT, 0, $event['owner']);
1345 1343
 		}
1346 1344
 		// check if we have a category Acl for the event or not (null)
1347
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1345
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1348 1346
 		if (!is_null($access))
1349 1347
 		{
1350 1348
 			return $access;
@@ -1354,17 +1352,17 @@  discard block
 block discarded – undo
1354 1352
 		{
1355 1353
 			$resource = $this->resource_info($uid);
1356 1354
 
1357
-			return Acl::EDIT & $resource['rights'];
1355
+			return Acl::EDIT&$resource['rights'];
1358 1356
 		}
1359 1357
 		if (!is_array($event) && !($event = $this->read($event))) return false;
1360 1358
 
1361 1359
 		// regular user and groups (need to check memberships too)
1362 1360
 		if (!isset($event['participants'][$uid]))
1363 1361
 		{
1364
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1362
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1365 1363
 		}
1366 1364
 		$memberships[] = $uid;
1367
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
1365
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid);
1368 1366
 	}
1369 1367
 
1370 1368
 	/**
@@ -1378,16 +1376,16 @@  discard block
 block discarded – undo
1378 1376
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1379 1377
 	 * 	null = cat has no acl
1380 1378
 	 */
1381
-	function check_cat_acl($right,$event)
1379
+	function check_cat_acl($right, $event)
1382 1380
 	{
1383 1381
 		if (!is_array($event)) $event = $this->read($event);
1384 1382
 
1385 1383
 		$ret = null;
1386 1384
 		if ($event['category'])
1387 1385
 		{
1388
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1386
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1389 1387
 			{
1390
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1388
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1391 1389
 				if ($access === true)
1392 1390
 				{
1393 1391
 					$ret = true;
@@ -1395,7 +1393,7 @@  discard block
 block discarded – undo
1395 1393
 				}
1396 1394
 				if ($access === false)
1397 1395
 				{
1398
-					$ret = false;	// cat denies access --> check further cats
1396
+					$ret = false; // cat denies access --> check further cats
1399 1397
 				}
1400 1398
 			}
1401 1399
 		}
@@ -1416,12 +1414,12 @@  discard block
 block discarded – undo
1416 1414
 	 * @param int $cat_id =null null to return array with all cats
1417 1415
 	 * @return array with account_id => right pairs
1418 1416
 	 */
1419
-	public static function get_cat_rights($cat_id=null)
1417
+	public static function get_cat_rights($cat_id = null)
1420 1418
 	{
1421 1419
 		if (!isset(self::$cat_rights_cache))
1422 1420
 		{
1423
-			self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
1424
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1421
+			self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights',
1422
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1425 1423
 		}
1426 1424
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1427 1425
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1434,7 +1432,7 @@  discard block
 block discarded – undo
1434 1432
 	 * @param int $user
1435 1433
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1436 1434
 	 */
1437
-	public static function set_cat_rights($cat_id,$user,$rights)
1435
+	public static function set_cat_rights($cat_id, $user, $rights)
1438 1436
 	{
1439 1437
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1440 1438
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1444,15 +1442,15 @@  discard block
 block discarded – undo
1444 1442
 			if ($rights)
1445 1443
 			{
1446 1444
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1447
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1445
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1448 1446
 			}
1449 1447
 			else
1450 1448
 			{
1451 1449
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1452 1450
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1453
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1451
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1454 1452
 			}
1455
-			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1453
+			Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1456 1454
 		}
1457 1455
 	}
1458 1456
 
@@ -1463,9 +1461,9 @@  discard block
 block discarded – undo
1463 1461
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1464 1462
 	 * 	null = cat has no acl
1465 1463
 	 */
1466
-	public static function has_cat_right($right,$cat_id,$user)
1464
+	public static function has_cat_right($right, $cat_id, $user)
1467 1465
 	{
1468
-		static $cache=null;
1466
+		static $cache = null;
1469 1467
 
1470 1468
 		if (!isset($cache[$cat_id]))
1471 1469
 		{
@@ -1473,21 +1471,21 @@  discard block
 block discarded – undo
1473 1471
 			$cat_rights = self::get_cat_rights($cat_id);
1474 1472
 			if (!is_null($cat_rights))
1475 1473
 			{
1476
-				static $memberships=null;
1474
+				static $memberships = null;
1477 1475
 				if (is_null($memberships))
1478 1476
 				{
1479
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1477
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1480 1478
 					$memberships[] = $user;
1481 1479
 				}
1482
-				foreach($cat_rights as $uid => $value)
1480
+				foreach ($cat_rights as $uid => $value)
1483 1481
 				{
1484 1482
 					$all |= $value;
1485
-					if (in_array($uid,$memberships)) $own |= $value;
1483
+					if (in_array($uid, $memberships)) $own |= $value;
1486 1484
 				}
1487 1485
 			}
1488
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1486
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1489 1487
 			{
1490
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1488
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1491 1489
 			}
1492 1490
 		}
1493 1491
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1507,13 +1505,13 @@  discard block
 block discarded – undo
1507 1505
 	 * @param boolean $skip_notification =false true: do not send notification messages
1508 1506
 	 * @return int number of changed recurrences
1509 1507
 	 */
1510
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1508
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1511 1509
 	{
1512 1510
 		unset($updateTS);
1513 1511
 
1514 1512
 		$cal_id = is_array($event) ? $event['id'] : $event;
1515 1513
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1516
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1514
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1517 1515
 		{
1518 1516
 			return false;
1519 1517
 		}
@@ -1522,16 +1520,16 @@  discard block
 block discarded – undo
1522 1520
 		if ($this->log)
1523 1521
 		{
1524 1522
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1525
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1523
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1526 1524
 		}
1527 1525
 		$old_event = $this->read($cal_id, $recur_date, false, 'server');
1528
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1529
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1530
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1526
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1527
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1528
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1531 1529
 		{
1532 1530
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1533 1531
 			{
1534
-				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1532
+				foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1535 1533
 				{
1536 1534
 					if ((string)$alarm['owner'] === (string)$uid)
1537 1535
 					{
@@ -1550,8 +1548,8 @@  discard block
 block discarded – undo
1550 1548
 			if (isset($status2msg[$status]) && !$skip_notification)
1551 1549
 			{
1552 1550
 				if (!is_array($event)) $event = $this->read($cal_id);
1553
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1554
-				$this->send_update($status2msg[$status],$event['participants'],$event);
1551
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1552
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1555 1553
 			}
1556 1554
 
1557 1555
 			// Update history
@@ -1571,14 +1569,14 @@  discard block
 block discarded – undo
1571 1569
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1572 1570
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1573 1571
 	 */
1574
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1572
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1575 1573
 	{
1576 1574
 		if (!isset($new_event['participants'])) return;
1577 1575
 
1578 1576
 		// check the old list against the new list
1579 1577
 		foreach ($old_event['participants'] as $userid => $status)
1580 1578
   		{
1581
-            if (!isset($new_event['participants'][$userid])){
1579
+            if (!isset($new_event['participants'][$userid])) {
1582 1580
             	// Attendee will be deleted this way
1583 1581
             	$new_event['participants'][$userid] = 'G';
1584 1582
             }
@@ -1591,7 +1589,7 @@  discard block
 block discarded – undo
1591 1589
 		// write the changes
1592 1590
 		foreach ($new_event['participants'] as $userid => $status)
1593 1591
 		{
1594
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1592
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1595 1593
 		}
1596 1594
     }
1597 1595
 
@@ -1606,43 +1604,43 @@  discard block
 block discarded – undo
1606 1604
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1607 1605
 	 * @return boolean true on success, false on error (usually permission denied)
1608 1606
 	 */
1609
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1610
-		$delete_exceptions=true, &$exceptions_kept=null)
1607
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1608
+		$delete_exceptions = true, &$exceptions_kept = null)
1611 1609
 	{
1612 1610
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1613
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1614
-			!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
1611
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1612
+			!$ignore_acl && !$this->check_perms(Acl::DELETE, $event))
1615 1613
 		{
1616 1614
 			return false;
1617 1615
 		}
1618 1616
 
1619 1617
 		// Don't send notification if the event has already been deleted
1620
-		if(!$event['deleted'] && !$skip_notification)
1618
+		if (!$event['deleted'] && !$skip_notification)
1621 1619
 		{
1622
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1620
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1623 1621
 		}
1624 1622
 
1625 1623
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1626 1624
 		{
1627 1625
 			$config = Api\Config::read('phpgwapi');
1628
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1626
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1629 1627
 			{
1630 1628
 				$this->so->delete($cal_id);
1631 1629
 
1632 1630
 				// delete all links to the event
1633
-				Link::unlink(0,'calendar',$cal_id);
1631
+				Link::unlink(0, 'calendar', $cal_id);
1634 1632
 			}
1635 1633
 			elseif ($config['calendar_delete_history'])
1636 1634
 			{
1637 1635
 				// mark all links to the event as deleted, but keep them
1638
-				Link::unlink(0,'calendar',$cal_id,'','','',true);
1636
+				Link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1639 1637
 
1640 1638
 				$event['deleted'] = $this->now;
1641 1639
 				$this->save($event, $ignore_acl);
1642 1640
 				// Actually delete alarms
1643 1641
 				if (isset($event['alarm']) && is_array($event['alarm']))
1644 1642
 				{
1645
-					foreach($event['alarm'] as $id => $alarm)
1643
+					foreach ($event['alarm'] as $id => $alarm)
1646 1644
 					{
1647 1645
 						$this->delete_alarm($id);
1648 1646
 					}
@@ -1664,7 +1662,7 @@  discard block
 block discarded – undo
1664 1662
 						if (!($exception = $this->read($id))) continue;
1665 1663
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1666 1664
 						$exception['reference'] = $exception['recurrence'] = 0;
1667
-						$this->update($exception, true, true, false, true, $msg=null, true);
1665
+						$this->update($exception, true, true, false, true, $msg = null, true);
1668 1666
 						++$exceptions_kept;
1669 1667
 					}
1670 1668
 				}
@@ -1676,9 +1674,9 @@  discard block
 block discarded – undo
1676 1674
 			if ($event['alarm'])
1677 1675
 			{
1678 1676
 				$next_recurrance = null;
1679
-				foreach($event['alarm'] as &$alarm)
1677
+				foreach ($event['alarm'] as &$alarm)
1680 1678
 				{
1681
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1679
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1682 1680
 					{
1683 1681
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1684 1682
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1686,12 +1684,12 @@  discard block
 block discarded – undo
1686 1684
 						{
1687 1685
 							$checkdate = $recur_date;
1688 1686
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1689
-							if (($e = $this->read($cal_id,$checkdate+1)))
1687
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1690 1688
 							{
1691 1689
 								$next_recurrance = $this->date2ts($e['start']);
1692 1690
 							}
1693 1691
 						}
1694
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1692
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1695 1693
 						$alarm['cal_id'] = $cal_id;
1696 1694
 						unset($alarm['times']);
1697 1695
 						unset($alarm['next']);
@@ -1705,7 +1703,7 @@  discard block
 block discarded – undo
1705 1703
 			$event = $this->read($cal_id);
1706 1704
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1707 1705
 			$event['recur_exception'][] = $recur_date;
1708
-			$this->save($event);// updates the content-history
1706
+			$this->save($event); // updates the content-history
1709 1707
 		}
1710 1708
 		if ($event['reference'])
1711 1709
 		{
@@ -1723,19 +1721,19 @@  discard block
 block discarded – undo
1723 1721
 	 * @param array $disinvited
1724 1722
 	 * @return array
1725 1723
 	 */
1726
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1724
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1727 1725
 	{
1728 1726
 		$details = array(			// event-details for the notify-msg
1729 1727
 			'id'          => $event['id'],
1730 1728
 			'action'      => lang($action),
1731 1729
 		);
1732 1730
 		$event_arr = $this->event2array($event);
1733
-		foreach($event_arr as $key => $val)
1731
+		foreach ($event_arr as $key => $val)
1734 1732
 		{
1735 1733
 			if ($key == 'recur_type') $key = 'repetition';
1736 1734
 			$details[$key] = $val['data'];
1737 1735
 		}
1738
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1736
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1739 1737
 
1740 1738
 		$event_arr['link']['field'] = lang('URL');
1741 1739
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1756,7 +1754,7 @@  discard block
 block discarded – undo
1756 1754
 		 */
1757 1755
 		$link_arr = array();
1758 1756
 		$link_arr['text'] = $event['title'];
1759
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1757
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1760 1758
 									'cal_id' => $event['id'],
1761 1759
 									'date' => $eventStart_arr['full'],
1762 1760
 									);
@@ -1764,11 +1762,11 @@  discard block
 block discarded – undo
1764 1762
 		$details['link_arr'] = $link_arr;
1765 1763
 
1766 1764
 		$dis = array();
1767
-		foreach($disinvited as $uid)
1765
+		foreach ($disinvited as $uid)
1768 1766
 		{
1769 1767
 			$dis[] = $this->participant_name($uid);
1770 1768
 		}
1771
-		$details['disinvited'] = implode(', ',$dis);
1769
+		$details['disinvited'] = implode(', ', $dis);
1772 1770
 		return $details;
1773 1771
 	}
1774 1772
 
@@ -1792,13 +1790,13 @@  discard block
 block discarded – undo
1792 1790
 			'data'	=> $event['description']
1793 1791
 		);
1794 1792
 
1795
-		foreach(explode(',',$event['category']) as $cat_id)
1793
+		foreach (explode(',', $event['category']) as $cat_id)
1796 1794
 		{
1797 1795
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1798 1796
 		}
1799 1797
 		$var['category'] = Array(
1800 1798
 			'field'	=> lang('Category'),
1801
-			'data'	=> implode(', ',$cat_string)
1799
+			'data'	=> implode(', ', $cat_string)
1802 1800
 		);
1803 1801
 
1804 1802
 		$var['location'] = Array(
@@ -1844,7 +1842,7 @@  discard block
 block discarded – undo
1844 1842
 
1845 1843
 		if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants']))
1846 1844
 		{
1847
-			$participants = $this->participants($event,true);
1845
+			$participants = $this->participants($event, true);
1848 1846
 		}
1849 1847
 		$var['participants'] = Array(
1850 1848
 			'field'	=> lang('Participants'),
@@ -1867,26 +1865,26 @@  discard block
 block discarded – undo
1867 1865
 	 * @param array $old_event =null event-data in the DB before calling save
1868 1866
 	 * @param string $type ='update'
1869 1867
 	 */
1870
-	function log2file($event2save,$event_saved,$old_event=null,$type='update')
1868
+	function log2file($event2save, $event_saved, $old_event = null, $type = 'update')
1871 1869
 	{
1872
-		if (!($f = fopen($this->log_file,'a')))
1870
+		if (!($f = fopen($this->log_file, 'a')))
1873 1871
 		{
1874 1872
 			echo "<p>error opening '$this->log_file' !!!</p>\n";
1875 1873
 			return false;
1876 1874
 		}
1877
-		fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1878
-		fwrite($f,"Time: time to save / saved time read back / old time before save\n");
1879
-		foreach(array('start','end') as $name)
1875
+		fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1876
+		fwrite($f, "Time: time to save / saved time read back / old time before save\n");
1877
+		foreach (array('start', 'end') as $name)
1880 1878
 		{
1881
-			fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1882
-				$this->format_date($event_saved[$name]) .' / '.
1879
+			fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1880
+				$this->format_date($event_saved[$name]).' / '.
1883 1881
 				(is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n");
1884 1882
 		}
1885
-		foreach(array('event2save','event_saved','old_event') as $name)
1883
+		foreach (array('event2save', 'event_saved', 'old_event') as $name)
1886 1884
 		{
1887
-			fwrite($f,$name.' = '.print_r($$name,true));
1885
+			fwrite($f, $name.' = '.print_r($$name, true));
1888 1886
 		}
1889
-		fwrite($f,"\n");
1887
+		fwrite($f, "\n");
1890 1888
 		fclose($f);
1891 1889
 
1892 1890
 		return true;
@@ -1907,14 +1905,14 @@  discard block
 block discarded – undo
1907 1905
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1908 1906
 
1909 1907
 		$time = new Api\DateTime($event['start']);
1910
-		if(!is_array($event['alarm']))
1908
+		if (!is_array($event['alarm']))
1911 1909
 		{
1912 1910
 			$event['alarm'] = $this->so->read_alarms($event['id']);
1913 1911
 		}
1914 1912
 
1915
-		foreach($event['alarm'] as &$alarm)
1913
+		foreach ($event['alarm'] as &$alarm)
1916 1914
 		{
1917
-			if($event['recur_type'] != MCAL_RECUR_NONE)
1915
+			if ($event['recur_type'] != MCAL_RECUR_NONE)
1918 1916
 			{
1919 1917
 				calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts'));
1920 1918
 			}
@@ -1934,14 +1932,14 @@  discard block
 block discarded – undo
1934 1932
 	 * @param boolean $update_modified =true call update modified, default true
1935 1933
 	 * @return string id of the alarm, or false on error (eg. no perms)
1936 1934
 	 */
1937
-	function save_alarm($cal_id, $alarm, $update_modified=true)
1935
+	function save_alarm($cal_id, $alarm, $update_modified = true)
1938 1936
 	{
1939
-		if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1937
+		if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1940 1938
 		{
1941 1939
 			//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
1942
-			return false;	// no rights to add the alarm
1940
+			return false; // no rights to add the alarm
1943 1941
 		}
1944
-		$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1942
+		$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1945 1943
 
1946 1944
 		return $this->so->save_alarm($cal_id, $alarm, $update_modified);
1947 1945
 	}
@@ -1954,11 +1952,11 @@  discard block
 block discarded – undo
1954 1952
 	 */
1955 1953
 	function delete_alarm($id)
1956 1954
 	{
1957
-		list(,$cal_id) = explode(':',$id);
1955
+		list(,$cal_id) = explode(':', $id);
1958 1956
 
1959
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1957
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1960 1958
 		{
1961
-			return false;	// no rights to delete the alarm
1959
+			return false; // no rights to delete the alarm
1962 1960
 		}
1963 1961
 
1964 1962
 		return $this->so->delete_alarm($id);
@@ -1973,13 +1971,13 @@  discard block
 block discarded – undo
1973 1971
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1974 1972
 	 * @return array category ids (found, added and preserved categories)
1975 1973
 	 */
1976
-	function find_or_add_categories($catname_list, $old_event=null)
1974
+	function find_or_add_categories($catname_list, $old_event = null)
1977 1975
 	{
1978 1976
 		if (is_array($old_event) || $old_event > 0)
1979 1977
 		{
1980 1978
 			// preserve categories without users read access
1981 1979
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
1982
-			$old_categories = explode(',',$old_event['category']);
1980
+			$old_categories = explode(',', $old_event['category']);
1983 1981
 			$old_cats_preserve = array();
1984 1982
 			if (is_array($old_categories) && count($old_categories) > 0)
1985 1983
 			{
@@ -2033,7 +2031,7 @@  discard block
 block discarded – undo
2033 2031
 	{
2034 2032
 		if (!is_array($cat_id_list))
2035 2033
 		{
2036
-			$cat_id_list = explode(',',$cat_id_list);
2034
+			$cat_id_list = explode(',', $cat_id_list);
2037 2035
 		}
2038 2036
 		$cat_list = array();
2039 2037
 		foreach ($cat_id_list as $cat_id)
@@ -2058,7 +2056,7 @@  discard block
 block discarded – undo
2058 2056
 	 *                              master	-> try to find a releated series master
2059 2057
 	 * @return array calendar_ids of matching entries
2060 2058
 	 */
2061
-	function find_event($event, $filter='exact')
2059
+	function find_event($event, $filter = 'exact')
2062 2060
 	{
2063 2061
 		$matchingEvents = array();
2064 2062
 		$query = array();
@@ -2066,14 +2064,14 @@  discard block
 block discarded – undo
2066 2064
 		if ($this->log)
2067 2065
 		{
2068 2066
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2069
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2067
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
2070 2068
 		}
2071 2069
 
2072 2070
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2073 2071
 
2074 2072
 		if ($filter == 'master')
2075 2073
 		{
2076
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2074
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2077 2075
 			$query['cal_recurrence'] = 0;
2078 2076
 		}
2079 2077
 		elseif ($filter == 'exact')
@@ -2094,14 +2092,14 @@  discard block
 block discarded – undo
2094 2092
 			if ($this->log)
2095 2093
 			{
2096 2094
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2097
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2095
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2098 2096
 			}
2099 2097
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2100 2098
 			{
2101 2099
 				if ($this->log)
2102 2100
 				{
2103 2101
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2104
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2102
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2105 2103
 				}
2106 2104
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2107 2105
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2120,7 +2118,7 @@  discard block
 block discarded – undo
2120 2118
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2121 2119
 						if (in_array($event['recurrence'], $exceptions))
2122 2120
 						{
2123
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2121
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2124 2122
 						}
2125 2123
 					}
2126 2124
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2139,19 +2137,19 @@  discard block
 block discarded – undo
2139 2137
 
2140 2138
 		// only query calendars of users, we have READ-grants from
2141 2139
 		$users = array();
2142
-		foreach(array_keys($this->grants) as $user)
2140
+		foreach (array_keys($this->grants) as $user)
2143 2141
 		{
2144 2142
 			$user = trim($user);
2145
-			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2143
+			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user))
2146 2144
 			{
2147
-				if ($user && !in_array($user,$users))	// already added?
2145
+				if ($user && !in_array($user, $users))	// already added?
2148 2146
 				{
2149 2147
 					$users[] = $user;
2150 2148
 				}
2151 2149
 			}
2152 2150
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2153 2151
 			{
2154
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2152
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2155 2153
 			}
2156 2154
 			// the further code is only for real users
2157 2155
 			if (!is_numeric($user)) continue;
@@ -2162,7 +2160,7 @@  discard block
 block discarded – undo
2162 2160
 				$members = $GLOBALS['egw']->accounts->members($user, true);
2163 2161
 				if (is_array($members))
2164 2162
 				{
2165
-					foreach($members as $member)
2163
+					foreach ($members as $member)
2166 2164
 					{
2167 2165
 						// use only members which gave the user a read-grant
2168 2166
 						if (!in_array($member, $users) &&
@@ -2178,7 +2176,7 @@  discard block
 block discarded – undo
2178 2176
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
2179 2177
 				if (is_array($memberships))
2180 2178
 				{
2181
-					foreach($memberships as $group)
2179
+					foreach ($memberships as $group)
2182 2180
 					{
2183 2181
 						if (!in_array($group, $users))
2184 2182
 						{
@@ -2204,24 +2202,24 @@  discard block
 block discarded – undo
2204 2202
 
2205 2203
 				// check length with some tolerance
2206 2204
 				$length = $event['end'] - $event['start'] - $delta;
2207
-				$query[] = ('(cal_end-cal_start)>' . $length);
2205
+				$query[] = ('(cal_end-cal_start)>'.$length);
2208 2206
 				$length += 2 * $delta;
2209
-				$query[] = ('(cal_end-cal_start)<' . $length);
2210
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2211
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2207
+				$query[] = ('(cal_end-cal_start)<'.$length);
2208
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2209
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2212 2210
 			}
2213 2211
 			elseif (isset($event['start']))
2214 2212
 			{
2215 2213
 				if ($filter == 'relax')
2216 2214
 				{
2217
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2218
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2215
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2216
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2219 2217
 				}
2220 2218
 				else
2221 2219
 				{
2222 2220
 					// we accept a tiny tolerance
2223
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2224
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2221
+					$query[] = ('cal_start>'.($event['start'] - 2));
2222
+					$query[] = ('cal_start<'.($event['start'] + 2));
2225 2223
 				}
2226 2224
 			}
2227 2225
 			if ($filter == 'relax')
@@ -2244,14 +2242,14 @@  discard block
 block discarded – undo
2244 2242
 			if ($this->log)
2245 2243
 			{
2246 2244
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2247
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2245
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2248 2246
 			}
2249 2247
 		}
2250 2248
 
2251 2249
 		if ($this->log)
2252 2250
 		{
2253 2251
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2254
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2252
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2255 2253
 		}
2256 2254
 		if (!count($users) || !($foundEvents =
2257 2255
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2259,19 +2257,19 @@  discard block
 block discarded – undo
2259 2257
 			if ($this->log)
2260 2258
 			{
2261 2259
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2262
-				"[NO MATCH]\n",3,$this->logfile);
2260
+				"[NO MATCH]\n", 3, $this->logfile);
2263 2261
 			}
2264 2262
 			return $matchingEvents;
2265 2263
 		}
2266 2264
 
2267 2265
 		$pseudos = array();
2268 2266
 
2269
-		foreach($foundEvents as $egwEvent)
2267
+		foreach ($foundEvents as $egwEvent)
2270 2268
 		{
2271 2269
 			if ($this->log)
2272 2270
 			{
2273 2271
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2274
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2272
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2275 2273
 			}
2276 2274
 
2277 2275
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2345,7 +2343,7 @@  discard block
 block discarded – undo
2345 2343
 						if (in_array($event['recurrence'], $exceptions))
2346 2344
 						{
2347 2345
 							// We found a pseudo exception
2348
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2346
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2349 2347
 							break;
2350 2348
 						}
2351 2349
 					}
@@ -2363,7 +2361,7 @@  discard block
 block discarded – undo
2363 2361
 						if ($this->log)
2364 2362
 						{
2365 2363
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2366
-							"() egwEvent length does not match!\n",3,$this->logfile);
2364
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2367 2365
 						}
2368 2366
 						continue;
2369 2367
 					}
@@ -2375,7 +2373,7 @@  discard block
 block discarded – undo
2375 2373
 						if ($this->log)
2376 2374
 						{
2377 2375
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2378
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2376
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2379 2377
 						}
2380 2378
 						continue;
2381 2379
 					}
@@ -2396,8 +2394,8 @@  discard block
 block discarded – undo
2396 2394
 					if ($this->log)
2397 2395
 					{
2398 2396
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2399
-							"() event[$key] differ: '" . $event[$key] .
2400
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2397
+							"() event[$key] differ: '".$event[$key].
2398
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2401 2399
 					}
2402 2400
 					continue 2; // next foundEvent
2403 2401
 				}
@@ -2415,7 +2413,7 @@  discard block
 block discarded – undo
2415 2413
 						if ($this->log)
2416 2414
 						{
2417 2415
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2418
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2416
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2419 2417
 						}
2420 2418
 						continue 2;
2421 2419
 					}
@@ -2427,7 +2425,7 @@  discard block
 block discarded – undo
2427 2425
 					{
2428 2426
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2429 2427
 							'() event has additional categories:'
2430
-							. array2string($newCategories)."\n",3,$this->logfile);
2428
+							. array2string($newCategories)."\n", 3, $this->logfile);
2431 2429
 					}
2432 2430
 					continue;
2433 2431
 				}
@@ -2447,7 +2445,7 @@  discard block
 block discarded – undo
2447 2445
 							if ($this->log)
2448 2446
 							{
2449 2447
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2450
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2448
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2451 2449
 							}
2452 2450
 							continue 2;
2453 2451
 						}
@@ -2470,8 +2468,8 @@  discard block
 block discarded – undo
2470 2468
 						if ($this->log)
2471 2469
 						{
2472 2470
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2473
-								'() missing event[participants]: ' .
2474
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2471
+								'() missing event[participants]: '.
2472
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2475 2473
 						}
2476 2474
 						continue;
2477 2475
 					}
@@ -2483,7 +2481,7 @@  discard block
 block discarded – undo
2483 2481
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2484 2482
 				{
2485 2483
 					// We found a pseudo Exception
2486
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2484
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2487 2485
 					continue;
2488 2486
 				}
2489 2487
 			}
@@ -2505,7 +2503,7 @@  discard block
 block discarded – undo
2505 2503
 							if ($this->log)
2506 2504
 							{
2507 2505
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2508
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2506
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2509 2507
 							}
2510 2508
 							continue 2;
2511 2509
 						}
@@ -2515,8 +2513,8 @@  discard block
 block discarded – undo
2515 2513
 						if ($this->log)
2516 2514
 						{
2517 2515
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2518
-								'() missing event[recur_exception]: ' .
2519
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2516
+								'() missing event[recur_exception]: '.
2517
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2520 2518
 						}
2521 2519
 						continue;
2522 2520
 					}
@@ -2531,8 +2529,8 @@  discard block
 block discarded – undo
2531 2529
 						if ($this->log)
2532 2530
 						{
2533 2531
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2534
-								"() events[$key] differ: " . $event[$key] .
2535
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2532
+								"() events[$key] differ: ".$event[$key].
2533
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2536 2534
 						}
2537 2535
 						continue 2;
2538 2536
 					}
@@ -2548,7 +2546,7 @@  discard block
 block discarded – undo
2548 2546
 			if ($this->log)
2549 2547
 			{
2550 2548
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2551
-					"() new exception for series found.\n",3,$this->logfile);
2549
+					"() new exception for series found.\n", 3, $this->logfile);
2552 2550
 			}
2553 2551
 			$matchingEvents = array();
2554 2552
 		}
@@ -2559,7 +2557,7 @@  discard block
 block discarded – undo
2559 2557
 		if ($this->log)
2560 2558
 		{
2561 2559
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2562
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2560
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2563 2561
 		}
2564 2562
 		return $matches;
2565 2563
 	}
@@ -2632,7 +2630,7 @@  discard block
 block discarded – undo
2632 2630
 				if ($this->log)
2633 2631
 				{
2634 2632
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2635
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2633
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2636 2634
 				}
2637 2635
 				$type = 'SERIES-EXCEPTION';
2638 2636
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2653,7 +2651,7 @@  discard block
 block discarded – undo
2653 2651
 					}
2654 2652
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2655 2653
 					{
2656
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2654
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2657 2655
 						$recurrence_event = $master_event;
2658 2656
 						$recurrence_event['start'] = $event['start'];
2659 2657
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2670,8 +2668,8 @@  discard block
 block discarded – undo
2670 2668
 							if ($this->log)
2671 2669
 							{
2672 2670
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2673
-									'() try occurrence ' . $egw_rrule->current()
2674
-									. " ($occurrence)\n",3,$this->logfile);
2671
+									'() try occurrence '.$egw_rrule->current()
2672
+									. " ($occurrence)\n", 3, $this->logfile);
2675 2673
 							}
2676 2674
 							if ($event['start'] == $occurrence)
2677 2675
 							{
@@ -2704,8 +2702,8 @@  discard block
 block discarded – undo
2704 2702
 			// default if we cannot find a proof for a fundamental change
2705 2703
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2706 2704
 			// check for changed data
2707
-			foreach (array('start','end','uid','title','location','description',
2708
-				'priority','public','special','non_blocking') as $key)
2705
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2706
+				'priority', 'public', 'special', 'non_blocking') as $key)
2709 2707
 			{
2710 2708
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2711 2709
 				{
@@ -2763,10 +2761,10 @@  discard block
 block discarded – undo
2763 2761
      * @param &$event	the event we are working on
2764 2762
      *
2765 2763
      */
2766
-    function server2usertime (&$event)
2764
+    function server2usertime(&$event)
2767 2765
     {
2768 2766
 		// we run all dates through date2usertime, to adjust to user-time
2769
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2767
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2770 2768
 		{
2771 2769
 			// we convert here from server-time to timestamps in user-time!
2772 2770
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2774,7 +2772,7 @@  discard block
 block discarded – undo
2774 2772
 		// same with the recur exceptions
2775 2773
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2776 2774
 		{
2777
-			foreach($event['recur_exception'] as $n => $date)
2775
+			foreach ($event['recur_exception'] as $n => $date)
2778 2776
 			{
2779 2777
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2780 2778
 			}
@@ -2782,7 +2780,7 @@  discard block
 block discarded – undo
2782 2780
 		// same with the alarms
2783 2781
 		if (isset($event['alarm']) && is_array($event['alarm']))
2784 2782
 		{
2785
-			foreach($event['alarm'] as $id => $alarm)
2783
+			foreach ($event['alarm'] as $id => $alarm)
2786 2784
 			{
2787 2785
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2788 2786
 			}
@@ -2799,7 +2797,7 @@  discard block
 block discarded – undo
2799 2797
 	{
2800 2798
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2801 2799
 		{
2802
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2800
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2803 2801
 		}
2804 2802
 	}
2805 2803
 }
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.
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.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param int $year =null default current year
45 45
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
46 46
 	 */
47
-	public static function read($country, $year=null)
47
+	public static function read($country, $year = null)
48 48
 	{
49 49
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
50 50
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
53 53
 
54 54
 		// if we dont find holidays in cache, we render from previous year until next 5 years
55
-		if (!isset($holidays) && ($years = self::render($country, $year-1, $year+5)))
55
+		if (!isset($holidays) && ($years = self::render($country, $year - 1, $year + 5)))
56 56
 		{
57
-			foreach($years as $y => $data)
57
+			foreach ($years as $y => $data)
58 58
 			{
59 59
 				Api\Cache::setCache($level, __CLASS__, $country.':'.$y, $data, self::HOLIDAY_CACHE_TIME);
60 60
 			}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param int $until_year =null default, fetch only one year, if given result is indexed additional by year
72 72
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
73 73
 	 */
74
-	public static function render($country, $year=null, $until_year=null)
74
+	public static function render($country, $year = null, $until_year = null)
75 75
 	{
76 76
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
77 77
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			return array();
83 83
 		}
84 84
 		$years = array();
85
-		foreach($holidays as $event)
85
+		foreach ($holidays as $event)
86 86
 		{
87 87
 			$start = new Api\DateTime($event['start']);
88 88
 			$end = new Api\DateTime($event['end']);
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 			if ($event['recur_type'])
94 94
 			{
95 95
 				// calendar_rrule limits no enddate, to 5 years
96
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
96
+				if (!$event['recur_enddate']) $event['recur_enddate'] = (1 + $end_year).'0101';
97 97
 
98 98
 				$rrule = calendar_rrule::event2rrule($event);
99 99
 				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
100 100
 
101
-				foreach($rrule as $rtime)
101
+				foreach ($rrule as $rtime)
102 102
 				{
103 103
 					if (($y = (int)$rtime->format('Y')) < $year) continue;
104 104
 					if ($y > $end_year) break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			else
117 117
 			{
118 118
 				$end_ymd = (int)$end->format('Ymd');
119
-				while(($ymd = (int)$start->format('Ymd')) <= $end_ymd)
119
+				while (($ymd = (int)$start->format('Ymd')) <= $end_ymd)
120 120
 				{
121 121
 					$y = (int)$start->format('Y');
122 122
 					$years[$y][(string)$ymd][] = array(
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 				}
131 131
 			}
132 132
 		}
133
-		foreach($years as $y => &$data)
133
+		foreach ($years as $y => &$data)
134 134
 		{
135 135
 			ksort($data);
136 136
 		}
137
-		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');
137
+		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');
138 138
 		unset($starttime);
139 139
 
140 140
 		return $until_year ? $years : $years[$year];
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 		// php does not automatic gzip decode, but it does not accept that in request headers
167 167
 		// iCloud eg. always gzip compresses: https://p16-calendars.icloud.com/holidays/au_en-au.ics
168
-		foreach($http_response_header as $h)
168
+		foreach ($http_response_header as $h)
169 169
 		{
170 170
 			if (preg_match('/^content-encoding:.*gzip/i', $h))
171 171
 			{
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.
calendar/inc/class.calendar_import_csv.inc.php 5 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param importepport_iface_egw_record record The egw_record object being imported
75 75
 	 * @param importexport_iface_import_record import_csv Import object contains current state
76 76
 	 *
77
-	 * @return boolean success
77
+	 * @return null|boolean success
78 78
 	 */
79 79
 	public function import_record(\importexport_iface_egw_record &$record, &$import_csv)
80 80
 	{
@@ -254,7 +254,6 @@  discard block
 block discarded – undo
254 254
 	 * perform the required action
255 255
 	 *
256 256
 	 * @param int $_action one of $this->actions
257
-	 * @param array $_data record data for the action
258 257
 	 * @return bool success or not
259 258
 	 */
260 259
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
@@ -343,7 +342,7 @@  discard block
 block discarded – undo
343 342
 	/**
344 343
 	 * Alter a row for preview to show multiple participants instead of Array
345 344
 	 *
346
-	 * @param egw_record $row_entry
345
+	 * @param importexport_iface_egw_record $row_entry
347 346
 	 */
348 347
 	protected function row_preview(importexport_iface_egw_record &$row_entry)
349 348
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
 	protected static $conditions = array('exists');
33 33
 
34 34
 	/**
35
-	* For figuring out if an entry has changed
36
-	*/
35
+	 * For figuring out if an entry has changed
36
+	 */
37 37
 	protected $tracking;
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		$this->role_map = array_flip($this->bo->roles);
58 58
 
59 59
 		$this->lookups = array(
60
-			'priority'	=> Array(
60
+			'priority'	=> array(
61 61
 				0 => lang('None'),
62 62
 				1 => lang('Low'),
63 63
 				2 => lang('Normal'),
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return boolean
239 239
 	 */
240
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
240
+	protected function exists(importexport_iface_egw_record &$record, array &$condition, &$records = array())
241 241
 	{
242 242
 		if($record->__get($condition['string']) && $condition['string'] == 'id') {
243 243
 			$event = $this->bo->read($record->__get($condition['string']));
Please login to merge, or discard this patch.
Braces   +75 added lines, -32 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 calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv
21
+{
21 22
 
22 23
 	/**
23 24
 	 * actions wich could be done to data entries
@@ -83,8 +84,10 @@  discard block
 block discarded – undo
83 84
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 85
 
85 86
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
87
+		if($options['owner_from_csv'])
88
+		{
89
+			if(!is_numeric($record['owner']))
90
+			{
88 91
 				$this->errors[$import_csv->get_current_position()] = lang(
89 92
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 93
 					$record->owner,
@@ -106,14 +109,16 @@  discard block
 block discarded – undo
106 109
 		}
107 110
 
108 111
 		// Parse particpants
109
-		if ($record->participants && !is_array($record->participants)) {
112
+		if ($record->participants && !is_array($record->participants))
113
+		{
110 114
 			// Importing participants in human friendly format:
111 115
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112 116
 			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
113 117
 			$p_participants = array();
114 118
 			$missing = array();
115 119
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
120
+			foreach($names as $key => $name)
121
+			{
117 122
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 123
 
119 124
 				// Search for direct account name, then user in accounts first
@@ -121,9 +126,13 @@  discard block
 block discarded – undo
121 126
 				$id = importexport_helper_functions::account_name2id($name);
122 127
 
123 128
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
129
+				if(!$id || $names[$key] !== $this->bo->participant_name($id))
130
+				{
125 131
 					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
132
+					if($contacts)
133
+					{
134
+						$id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
135
+					}
127 136
 				}
128 137
 				if(!$id)
129 138
 				{
@@ -131,7 +140,10 @@  discard block
 block discarded – undo
131 140
 					foreach($this->bo->resources as $resource)
132 141
 					{
133 142
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
143
+						if($resource['app'] == 'email')
144
+						{
145
+							continue;
146
+						}
135 147
 						// Special resource search, since it does special stuff in link_query
136 148
 						if($resource['app'] == 'resources')
137 149
 						{
@@ -140,7 +152,8 @@  discard block
 block discarded – undo
140 152
 								$this->resource_so = new resources_so();
141 153
 							}
142 154
 							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
155
+							if(count($result) >= 1)
156
+							{
144 157
 								$id = $resource['type'].$result[0]['res_id'];
145 158
 								break;
146 159
 							}
@@ -159,7 +172,8 @@  discard block
 block discarded – undo
159 172
 						}
160 173
 					}
161 174
 				}
162
-				if($id) {
175
+				if($id)
176
+				{
163 177
 					$p_participants[$id] = calendar_so::combine_status(
164 178
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 179
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -188,27 +202,38 @@  discard block
 block discarded – undo
188 202
 		}
189 203
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 204
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
205
+		if ( $options['conditions'] )
206
+		{
207
+			foreach ( $options['conditions'] as $condition )
208
+			{
193 209
 				$records = array();
194
-				switch ( $condition['type'] ) {
210
+				switch ( $condition['type'] )
211
+				{
195 212
 					// exists
196 213
 					case 'exists' :
197 214
 						// Check for that record
198 215
 						$result = $this->exists($record, $condition, $records);
199 216
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
217
+						if ( is_array( $records ) && count( $records ) >= 1)
218
+						{
201 219
 							// apply action to all records matching this exists condition
202 220
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
221
+							foreach ( (array)$records as $event )
222
+							{
204 223
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
224
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
225
+								{
226
+									if ( !is_array( $record->category ) )
227
+									{
228
+										$record->category = explode( ',', $record->category );
229
+									}
207 230
 									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
208 231
 								}
209 232
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
210 233
 							}
211
-						} else {
234
+						}
235
+						else
236
+						{
212 237
 							$action = $condition['false'];
213 238
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
214 239
 						}
@@ -219,9 +244,14 @@  discard block
 block discarded – undo
219 244
 						die('condition / action not supported!!!');
220 245
 						break;
221 246
 				}
222
-				if ($action['last']) break;
247
+				if ($action['last'])
248
+				{
249
+					break;
250
+				}
223 251
 			}
224
-		} else {
252
+		}
253
+		else
254
+		{
225 255
 			// unconditional insert
226 256
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
227 257
 		}
@@ -240,12 +270,14 @@  discard block
 block discarded – undo
240 270
 	 */
241 271
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
242 272
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
273
+		if($record->__get($condition['string']) && $condition['string'] == 'id')
274
+		{
244 275
 			$event = $this->bo->read($record->__get($condition['string']));
245 276
 			$records = array($event);
246 277
 		}
247 278
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
279
+		if ( is_array( $records ) && count( $records ) >= 1)
280
+		{
249 281
 			return true;
250 282
 		}
251 283
 		return false;
@@ -261,7 +293,8 @@  discard block
 block discarded – undo
261 293
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
262 294
 	{
263 295
 		$_data = $record->get_record_array();
264
-		switch ($_action) {
296
+		switch ($_action)
297
+		{
265 298
 			case 'none' :
266 299
 				return true;
267 300
 			case 'update' :
@@ -269,7 +302,8 @@  discard block
 block discarded – undo
269 302
 				$old = $this->bo->read($_data['id']);
270 303
 
271 304
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
305
+				if(!$this->definition->plugin_options['change_owner'])
306
+				{
273 307
 					// Don't change owner of an existing record
274 308
 					unset($_data['owner']);
275 309
 				}
@@ -277,23 +311,27 @@  discard block
 block discarded – undo
277 311
 				// Merge to deal with fields not in import record
278 312
 				$_data = array_merge($old, $_data);
279 313
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
314
+				if(count($changed) == 0)
315
+				{
281 316
 					return true;
282 317
 				}
283 318
 				// Fall through
284 319
 			case 'insert' :
285
-				if($_action == 'insert') {
320
+				if($_action == 'insert')
321
+				{
286 322
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 323
 					unset($_data['id']);
288 324
 				}
289 325
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
326
+				if(!$_data['participants'])
327
+				{
291 328
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 329
 					$_data['participants'] = array(
293 330
 						$user => 'U'
294 331
 					);
295 332
 				}
296
-				if ( $this->dry_run ) {
333
+				if ( $this->dry_run )
334
+				{
297 335
 					//print_r($_data);
298 336
 					// User is interested in conflict checks, do so for dry run
299 337
 					// Otherwise, conflicts are just ignored and imported anyway
@@ -309,7 +347,9 @@  discard block
 block discarded – undo
309 347
 					}
310 348
 					$this->results[$_action]++;
311 349
 					return true;
312
-				} else {
350
+				}
351
+				else
352
+				{
313 353
 					$messages = null;
314 354
 					$result = $this->bo->update( $_data, 
315 355
 						!$this->definition->plugin_options['skip_conflicts'],
@@ -360,7 +400,8 @@  discard block
 block discarded – undo
360 400
 	 *
361 401
 	 * @return string name
362 402
 	 */
363
-	public static function get_name() {
403
+	public static function get_name()
404
+	{
364 405
 		return lang('Calendar CSV import');
365 406
 	}
366 407
 
@@ -369,7 +410,8 @@  discard block
 block discarded – undo
369 410
 	 *
370 411
 	 * @return string descriprion
371 412
 	 */
372
-	public static function get_description() {
413
+	public static function get_description()
414
+	{
373 415
 		return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
374 416
 	}
375 417
 
@@ -378,7 +420,8 @@  discard block
 block discarded – undo
378 420
 	 *
379 421
 	 * @return string suffix (comma seperated)
380 422
 	 */
381
-	public static function get_filesuffix() {
423
+	public static function get_filesuffix()
424
+	{
382 425
 		return 'csv';
383 426
 	}
384 427
 
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv {
21 21
 
22 22
 	/**
23 23
 	 * actions wich could be done to data entries
24 24
 	 */
25
-	protected static $actions = array( 'none', 'update', 'insert' );
25
+	protected static $actions = array('none', 'update', 'insert');
26 26
 
27 27
 	/**
28 28
 	 * conditions for actions
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Set up tracker
46 46
 	 */
47
-	protected function init(importexport_definition &$definition)
47
+	protected function init(importexport_definition&$definition)
48 48
 	{
49 49
 		// fetch the addressbook bo
50
-		$this->bo= new calendar_boupdate();
50
+		$this->bo = new calendar_boupdate();
51 51
 
52 52
 		// Get the tracker for changes
53 53
 		$this->tracking = new calendar_tracking();
54 54
 
55 55
 		// Used for participants
56
-		$this->status_map = array_flip(array_map('lang',$this->bo->verbose_status));
56
+		$this->status_map = array_flip(array_map('lang', $this->bo->verbose_status));
57 57
 		$this->role_map = array_flip($this->bo->roles);
58 58
 
59 59
 		$this->lookups = array(
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return boolean success
78 78
 	 */
79
-	public function import_record(\importexport_iface_egw_record &$record, &$import_csv)
79
+	public function import_record(\importexport_iface_egw_record&$record, &$import_csv)
80 80
 	{
81 81
 		// set eventOwner
82
-		$options =& $this->definition->plugin_options;
82
+		$options = & $this->definition->plugin_options;
83 83
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 84
 
85 85
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
86
+		if ($options['owner_from_csv']) {
87
+			if (!is_numeric($record['owner'])) {
88 88
 				$this->errors[$import_csv->get_current_position()] = lang(
89 89
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 90
 					$record->owner,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		}
100 100
 		
101 101
 		// Handle errors in length or start/end date
102
-		if($record->start > $record->end)
102
+		if ($record->start > $record->end)
103 103
 		{
104 104
 			$record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
105 105
 			$this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!');
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		if ($record->participants && !is_array($record->participants)) {
110 110
 			// Importing participants in human friendly format:
111 111
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112
-			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
112
+			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants);
113 113
 			$p_participants = array();
114 114
 			$missing = array();
115 115
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
116
+			foreach ($names as $key => $name) {
117 117
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 118
 
119 119
 				// Search for direct account name, then user in accounts first
@@ -121,26 +121,26 @@  discard block
 block discarded – undo
121 121
 				$id = importexport_helper_functions::account_name2id($name);
122 122
 
123 123
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
-					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
124
+				if (!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
+					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1));
126
+					if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
127 127
 				}
128
-				if(!$id)
128
+				if (!$id)
129 129
 				{
130 130
 					// Use calendar's registered resources to find participant
131
-					foreach($this->bo->resources as $resource)
131
+					foreach ($this->bo->resources as $resource)
132 132
 					{
133 133
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
134
+						if ($resource['app'] == 'email') continue;
135 135
 						// Special resource search, since it does special stuff in link_query
136
-						if($resource['app'] == 'resources')
136
+						if ($resource['app'] == 'resources')
137 137
 						{
138
-							if(!$this->resource_so)
138
+							if (!$this->resource_so)
139 139
 							{
140 140
 								$this->resource_so = new resources_so();
141 141
 							}
142
-							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
142
+							$result = $this->resource_so->search($search, 'res_id');
143
+							if (count($result) >= 1) {
144 144
 								$id = $resource['type'].$result[0]['res_id'];
145 145
 								break;
146 146
 							}
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 							$link_options = array();
152 152
 							$result = Link::query($resource['app'], $search, $link_options);
153 153
 
154
-							if($result)
154
+							if ($result)
155 155
 							{
156
-								$id = $resource['type'] . key($result);
156
+								$id = $resource['type'].key($result);
157 157
 								break;
158 158
 							}
159 159
 						}
160 160
 					}
161 161
 				}
162
-				if($id) {
162
+				if ($id) {
163 163
 					$p_participants[$id] = calendar_so::combine_status(
164 164
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 165
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -170,47 +170,47 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$missing[] = $name;
172 172
 				}
173
-				if(count($missing) > 0)
173
+				if (count($missing) > 0)
174 174
 				{
175
-					$this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' .
176
-						lang('Contact not found!') . '<br />'.implode(", ",$missing);
175
+					$this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '.
176
+						lang('Contact not found!').'<br />'.implode(", ", $missing);
177 177
 				}
178 178
 			}
179 179
 			$record->participants = $p_participants;
180 180
 		}
181 181
 
182
-		if($record->recurrence)
182
+		if ($record->recurrence)
183 183
 		{
184
-			list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2);
184
+			list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2);
185 185
 			$record->recur_interval = trim($record->recur_interval);
186
-			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence']));
186
+			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence']));
187 187
 			unset($record->recurrence);
188 188
 		}
189 189
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 190
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
191
+		if ($options['conditions']) {
192
+			foreach ($options['conditions'] as $condition) {
193 193
 				$records = array();
194
-				switch ( $condition['type'] ) {
194
+				switch ($condition['type']) {
195 195
 					// exists
196 196
 					case 'exists' :
197 197
 						// Check for that record
198 198
 						$result = $this->exists($record, $condition, $records);
199 199
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
200
+						if (is_array($records) && count($records) >= 1) {
201 201
 							// apply action to all records matching this exists condition
202 202
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
203
+							foreach ((array)$records as $event) {
204 204
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
207
-									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
205
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
206
+									if (!is_array($record->category)) $record->category = explode(',', $record->category);
207
+									$record->category = implode(',', array_unique(array_merge($record->category, $event['category'])));
208 208
 								}
209
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
209
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
210 210
 							}
211 211
 						} else {
212 212
 							$action = $condition['false'];
213
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
213
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
214 214
 						}
215 215
 						break;
216 216
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			}
224 224
 		} else {
225 225
 			// unconditional insert
226
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
226
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
227 227
 		}
228 228
 
229 229
 		return $success;
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return boolean
240 240
 	 */
241
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
241
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array())
242 242
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
243
+		if ($record->__get($condition['string']) && $condition['string'] == 'id') {
244 244
 			$event = $this->bo->read($record->__get($condition['string']));
245 245
 			$records = array($event);
246 246
 		}
247 247
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
248
+		if (is_array($records) && count($records) >= 1) {
249 249
 			return true;
250 250
 		}
251 251
 		return false;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @param array $_data record data for the action
259 259
 	 * @return bool success or not
260 260
 	 */
261
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
261
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0)
262 262
 	{
263 263
 		$_data = $record->get_record_array();
264 264
 		switch ($_action) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				$old = $this->bo->read($_data['id']);
270 270
 
271 271
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
272
+				if (!$this->definition->plugin_options['change_owner']) {
273 273
 					// Don't change owner of an existing record
274 274
 					unset($_data['owner']);
275 275
 				}
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 				// Merge to deal with fields not in import record
278 278
 				$_data = array_merge($old, $_data);
279 279
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
280
+				if (count($changed) == 0) {
281 281
 					return true;
282 282
 				}
283 283
 				// Fall through
284 284
 			case 'insert' :
285
-				if($_action == 'insert') {
285
+				if ($_action == 'insert') {
286 286
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 287
 					unset($_data['id']);
288 288
 				}
289 289
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
290
+				if (!$_data['participants']) {
291 291
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 292
 					$_data['participants'] = array(
293 293
 						$user => 'U'
294 294
 					);
295 295
 				}
296
-				if ( $this->dry_run ) {
296
+				if ($this->dry_run) {
297 297
 					//print_r($_data);
298 298
 					// User is interested in conflict checks, do so for dry run
299 299
 					// Otherwise, conflicts are just ignored and imported anyway
300
-					if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
300
+					if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
301 301
 					{
302 302
 						$conflicts = $this->bo->conflicts($_data);
303
-						if($conflicts)
303
+						if ($conflicts)
304 304
 						{
305 305
 							$this->conflict_warning($record_num, $conflicts);
306 306
 							$this->results['skipped']++;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 					return true;
312 312
 				} else {
313 313
 					$messages = null;
314
-					$result = $this->bo->update( $_data, 
314
+					$result = $this->bo->update($_data, 
315 315
 						!$this->definition->plugin_options['skip_conflicts'],
316 316
 						true, $this->is_admin, true, $messages,
317 317
 						$this->definition->plugin_options['no_notification']
318 318
 					);
319
-					if(!$result)
319
+					if (!$result)
320 320
 					{
321
-						$this->errors[$record_num] = lang('Unable to save') . "\n" .
322
-							implode("\n",$messages);
321
+						$this->errors[$record_num] = lang('Unable to save')."\n".
322
+							implode("\n", $messages);
323 323
 					}
324 324
 					else if (is_array($result))
325 325
 					{
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	protected function conflict_warning($record_num, &$conflicts)
351 351
 	{
352
-		$this->warnings[$record_num] = lang('Conflicts') . ':';
353
-		foreach($conflicts as $conflict)
352
+		$this->warnings[$record_num] = lang('Conflicts').':';
353
+		foreach ($conflicts as $conflict)
354 354
 		{
355
-			$this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title'];
355
+			$this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title'];
356 356
 		}
357 357
 	}
358 358
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @param egw_record $row_entry
390 390
 	 */
391
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
391
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
392 392
 	{
393
-		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
393
+		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
394 394
 	}
395 395
 
396 396
 }
397 397
\ No newline at end of file
Please login to merge, or discard this patch.
calendar/inc/class.calendar_timezones.inc.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -204,6 +204,7 @@
 block discarded – undo
204 204
 	 *
205 205
 	 * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
206 206
 	 * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT
207
+	 * @param boolean $updated
207 208
 	 * @return string message about update
208 209
 	 * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version
209 210
 	 * @throws Api\Exception\WrongUserinput if no PDO sqlite support
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public static function DateTimeZone($tzid)
73 73
 	{
74
-		if (($id = self::tz2id($tzid,'alias')))
74
+		if (($id = self::tz2id($tzid, 'alias')))
75 75
 		{
76 76
 			$tzid = self::id2tz($id);
77 77
 		}
@@ -89,34 +89,34 @@  discard block
 block discarded – undo
89 89
 	 * @param string $what ='id' what to return, default id, null for whole array
90 90
 	 * @return int tz_id or null if not found
91 91
 	 */
92
-	public static function tz2id($tzid,$what='id')
92
+	public static function tz2id($tzid, $what = 'id')
93 93
 	{
94
-		$id =& self::$tz2id[$tzid];
94
+		$id = & self::$tz2id[$tzid];
95 95
 
96 96
 		if (!isset($id))
97 97
 		{
98
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
98
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
99 99
 				'tz_tzid' => $tzid,
100
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
100
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
101 101
 			{
102 102
 				$id = $data['tz_id'];
103
-				self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_');
103
+				self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_');
104 104
 			}
105 105
 		}
106 106
 		// check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires'
107 107
 		if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2)
108 108
 		{
109
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
109
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
110 110
 				'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]),
111
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
111
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
112 112
 			{
113 113
 				$id = $data['tz_id'];
114
-				self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_');
114
+				self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_');
115 115
 			}
116 116
 		}
117 117
 		if (isset($id) && $what != 'id')
118 118
 		{
119
-			return self::id2tz($id,$what);
119
+			return self::id2tz($id, $what);
120 120
 		}
121 121
 		return $id;
122 122
 	}
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
 	 * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude'
135 135
 	 * @return mixed false: if not found
136 136
 	 */
137
-	public static function id2tz($id,$what='tzid')
137
+	public static function id2tz($id, $what = 'tzid')
138 138
 	{
139
-		$data =& self::$tz_cache[$id];
139
+		$data = & self::$tz_cache[$id];
140 140
 
141 141
 		if (!isset($data))
142 142
 		{
143
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
143
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
144 144
 				'tz_id' => $id,
145
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
145
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
146 146
 			{
147
-				$data = Api\Db::strip_array_keys($data,'tz_');
147
+				$data = Api\Db::strip_array_keys($data, 'tz_');
148 148
 				self::$tz2id[$data['tzid']] = $id;
149 149
 			}
150 150
 		}
151 151
 		// if not tzid queried, resolve aliases automatically
152 152
 		if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias')
153 153
 		{
154
-			$data = self::id2tz($data['alias'],null);
154
+			$data = self::id2tz($data['alias'], null);
155 155
 		}
156 156
 		return !$data ? $data : ($what ? $data[$what] : $data);
157 157
 	}
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public static function init_static()
172 172
 	{
173
-		self::$tz_cache =& Api\Cache::getSession(__CLASS__,'tz_cache');
174
-		self::$tz2id =& Api\Cache::getSession(__CLASS__,'tz2id');
173
+		self::$tz_cache = & Api\Cache::getSession(__CLASS__, 'tz_cache');
174
+		self::$tz2id = & Api\Cache::getSession(__CLASS__, 'tz2id');
175 175
 
176 176
 		// init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar
177 177
 		if (!is_array(self::$tz2id))
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			$updated = false;
190 190
 			$msg = self::import_zones($updated);
191
-			if ($updated) error_log($msg);	// log that timezones have been updated
191
+			if ($updated) error_log($msg); // log that timezones have been updated
192 192
 
193 193
 			$alias_msg = self::import_tz_aliases($updated);
194
-			if ($updated) error_log($alias_msg);	// log that timezone aliases have been updated
194
+			if ($updated) error_log($alias_msg); // log that timezone aliases have been updated
195 195
 
196 196
 			self::$import_msg = $msg.'<br/>'.$alias_msg;
197 197
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @throws Api\Exception\WrongUserinput for broken sqlite extension
211 211
 	 * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json
212 212
 	 */
213
-	public static function import_zones(&$updated=null, $file='calendar/setup/zones.json')
213
+	public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json')
214 214
 	{
215 215
 		$path = EGW_SERVER_ROOT.'/'.$file;
216 216
 
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 		{
233 233
 			$updated = false;
234 234
 			fclose($fp);
235
-			return lang('Nothing to update, version is already %1.',$config['tz_version']);	// we already have the right
235
+			return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right
236 236
 		}
237
-		$json .= fread($fp, 1024*1024);
237
+		$json .= fread($fp, 1024 * 1024);
238 238
 		fclose($fp);
239 239
 		if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones']))
240 240
 		{
@@ -242,38 +242,38 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 		// import zones first and then aliases
244 244
 		$tz2id = array();
245
-		foreach(array('zones', 'aliases') as $type)
245
+		foreach (array('zones', 'aliases') as $type)
246 246
 		{
247
-			foreach($zones[$type] as $tzid => $data)
247
+			foreach ($zones[$type] as $tzid => $data)
248 248
 			{
249 249
 				if ($type == 'aliases')
250 250
 				{
251 251
 					$data = array('alias' => $tz2id[$data['aliasTo']]);
252
-					if (!$data['alias']) continue;	// there's no such tzid
252
+					if (!$data['alias']) continue; // there's no such tzid
253 253
 				}
254 254
 				// check if already in database
255
-				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array(
255
+				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array(
256 256
 						'tz_tzid' => $tzid,
257
-					),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
257
+					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
258 258
 
259
-				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
259
+				$GLOBALS['egw']->db->insert('egw_cal_timezones', array(
260 260
 					'tz_alias' => $data['alias'],
261 261
 					'tz_latitude' => $data['latitude'],
262 262
 					'tz_longitude' => $data['longitude'],
263 263
 					'tz_component' => $data['ics'],
264
-				),array(
264
+				), array(
265 265
 					'tz_tzid' => $tzid,
266
-				),__LINE__,__FILE__,'calendar');
266
+				), __LINE__, __FILE__, 'calendar');
267 267
 
268 268
 				// only query last insert id, if not already in database (gives warning for PostgreSQL)
269
-				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
269
+				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id');
270 270
 			}
271 271
 		}
272 272
 		Api\Config::save_value('tz_version', $tz_version, 'phpgwapi');
273 273
 
274 274
 		//_debug_array($tz2id);
275 275
 		$updated = true;
276
-		return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id));
276
+		return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id));
277 277
 	}
278 278
 
279 279
 	/**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @return string message about update
285 285
 	 * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version
286 286
 	 */
287
-	public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php')
287
+	public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php')
288 288
 	{
289 289
 		$path = EGW_SERVER_ROOT.'/'.$file;
290 290
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
 		if ($tz_aliases_mtime === $config['tz_aliases_mtime'])
298 298
 		{
299 299
 			$updated = false;
300
-			return lang('Nothing to update, version is already %1.',$tz_aliases_mtime);
300
+			return lang('Nothing to update, version is already %1.', $tz_aliases_mtime);
301 301
 		}
302 302
 		$tz_aliases = array();
303
-		include($path);	// sets $tz_aliases
303
+		include($path); // sets $tz_aliases
304 304
 
305 305
 		$updates = 0;
306
-		foreach($tz_aliases as $alias => $tzid)
306
+		foreach ($tz_aliases as $alias => $tzid)
307 307
 		{
308
-			if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) &&	// not in DB or different
308
+			if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different
309 309
 				($tz_id = self::tz2id($tzid)))	// given tzid for alias exists in DB
310 310
 			{
311
-				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
311
+				$GLOBALS['egw']->db->insert('egw_cal_timezones', array(
312 312
 					'tz_alias' => $tz_id,
313
-				),array(
313
+				), array(
314 314
 					'tz_tzid' => $alias,
315
-				),__LINE__,__FILE__,'calendar');
315
+				), __LINE__, __FILE__, 'calendar');
316 316
 				++$updates;
317 317
 			}
318 318
 			//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).",  self::tz2id('$tzid')=".array2string($tz_id));
319 319
 		}
320
-		Api\Config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi');
320
+		Api\Config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi');
321 321
 
322 322
 		//_debug_array($tz2id);
323 323
 		$updated = true;
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 		}
359 359
 		// $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly
360 360
 		// --> we have to parse it and let Horde_Icalendar add it again
361
-		$horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false);
362
-		$horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE');
361
+		$horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false);
362
+		$horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE');
363 363
 		// DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing
364 364
 		$standard = $horde_vtimezone->findComponent('STANDARD');
365 365
 		if (is_a($standard, 'Horde_Icalendar'))
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component
391 391
 	 * @return string
392 392
 	 */
393
-	public static function user_timezone($user=null, $type='vcalendar')
393
+	public static function user_timezone($user = null, $type = 'vcalendar')
394 394
 	{
395 395
 		if (!$user || $user == $GLOBALS['egw_info']['user']['account_id'])
396 396
 		{
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 			case 'vcalendar':
410 410
 				// checking type of $val, now we included the object definition (no need to always include it!)
411 411
 				$vcal = new Horde_Icalendar;
412
-				$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
412
+				$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
413 413
 					strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
414 414
 				self::add_vtimezone($vcal, $tzid);
415 415
 				$tzid = $vcal->exportvCalendar('utf-8');
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 			case 'tzid':
418 418
 				break;
419 419
 			default:
420
-				$tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type);
420
+				$tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type);
421 421
 				break;
422 422
 		}
423 423
 		return $tzid;
Please login to merge, or discard this patch.
Braces   +27 added lines, -6 removed lines patch added patch discarded remove patch
@@ -188,10 +188,18 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			$updated = false;
190 190
 			$msg = self::import_zones($updated);
191
-			if ($updated) error_log($msg);	// log that timezones have been updated
191
+			if ($updated)
192
+			{
193
+				error_log($msg);
194
+			}
195
+			// log that timezones have been updated
192 196
 
193 197
 			$alias_msg = self::import_tz_aliases($updated);
194
-			if ($updated) error_log($alias_msg);	// log that timezone aliases have been updated
198
+			if ($updated)
199
+			{
200
+				error_log($alias_msg);
201
+			}
202
+			// log that timezone aliases have been updated
195 203
 
196 204
 			self::$import_msg = $msg.'<br/>'.$alias_msg;
197 205
 
@@ -249,7 +257,11 @@  discard block
 block discarded – undo
249 257
 				if ($type == 'aliases')
250 258
 				{
251 259
 					$data = array('alias' => $tz2id[$data['aliasTo']]);
252
-					if (!$data['alias']) continue;	// there's no such tzid
260
+					if (!$data['alias'])
261
+					{
262
+						continue;
263
+					}
264
+					// there's no such tzid
253 265
 				}
254 266
 				// check if already in database
255 267
 				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array(
@@ -266,7 +278,10 @@  discard block
 block discarded – undo
266 278
 				),__LINE__,__FILE__,'calendar');
267 279
 
268 280
 				// only query last insert id, if not already in database (gives warning for PostgreSQL)
269
-				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
281
+				if (!$tz2id[$tzid])
282
+				{
283
+					$tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
284
+				}
270 285
 			}
271 286
 		}
272 287
 		Api\Config::save_value('tz_version', $tz_version, 'phpgwapi');
@@ -306,13 +321,16 @@  discard block
 block discarded – undo
306 321
 		foreach($tz_aliases as $alias => $tzid)
307 322
 		{
308 323
 			if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) &&	// not in DB or different
309
-				($tz_id = self::tz2id($tzid)))	// given tzid for alias exists in DB
324
+				($tz_id = self::tz2id($tzid)))
325
+			{
326
+				// given tzid for alias exists in DB
310 327
 			{
311 328
 				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
312 329
 					'tz_alias' => $tz_id,
313 330
 				),array(
314 331
 					'tz_tzid' => $alias,
315 332
 				),__LINE__,__FILE__,'calendar');
333
+			}
316 334
 				++$updates;
317 335
 			}
318 336
 			//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).",  self::tz2id('$tzid')=".array2string($tz_id));
@@ -402,7 +420,10 @@  discard block
 block discarded – undo
402 420
 			$prefs = $prefs_obj->read();
403 421
 			$tzid = $prefs['common']['tz'];
404 422
 		}
405
-		if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName();
423
+		if (!$tzid)
424
+		{
425
+			$tzid = Api\DateTime::$server_timezone->getName();
426
+		}
406 427
 
407 428
 		switch ($type)
408 429
 		{
Please login to merge, or discard this patch.
calendar/inc/class.calendar_uiforms.inc.php 6 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 	 *	date instead of today
1078 1078
 	 * @param boolean $no_notifications Toggle notifications to participants
1079 1079
 	 *
1080
-	 * @return false or error message
1080
+	 * @return string|false or error message
1081 1081
 	 */
1082 1082
 	function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true)
1083 1083
 	{
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 	 * Freetime search
2174 2174
 	 *
2175 2175
 	 * As the function is called in a popup via javascript, parametes get initialy transfered via the url
2176
-	 * @param array $content=null array with parameters or false (default) to use the get-params
2176
+	 * @param array $content array with parameters or false (default) to use the get-params
2177 2177
 	 * @param string start[str] start-date
2178 2178
 	 * @param string start[hour] start-hour
2179 2179
 	 * @param string start[min] start-minutes
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
 	/**
2418 2418
      * Export events as vCalendar version 2.0 files (iCal)
2419 2419
      *
2420
-     * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2420
+     * @param integer $content numeric cal_id or submitted content from etempalte::exec
2421 2421
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422 2422
      * @return string error-msg if $return_error
2423 2423
      */
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2415,14 +2415,14 @@  discard block
 block discarded – undo
2415 2415
 	}
2416 2416
 
2417 2417
 	/**
2418
-     * Export events as vCalendar version 2.0 files (iCal)
2419
-     *
2420
-     * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2421
-     * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422
-     * @return string error-msg if $return_error
2423
-     */
2424
-    function export($content=0,$return_error=false)
2425
-    {
2418
+	 * Export events as vCalendar version 2.0 files (iCal)
2419
+	 *
2420
+	 * @param int|array $content numeric cal_id or submitted content from etempalte::exec
2421
+	 * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2422
+	 * @return string error-msg if $return_error
2423
+	 */
2424
+	function export($content=0,$return_error=false)
2425
+	{
2426 2426
 		$boical = new calendar_ical();
2427 2427
 		#error_log(__METHOD__.print_r($content,true));
2428 2428
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2477 2477
 		$etpl = new etemplate_new('calendar.export');
2478 2478
 		$etpl->exec('calendar.calendar_uiforms.export',$content);
2479
-    }
2479
+	}
2480 2480
 	
2481 2481
 	/**
2482 2482
 	 * Edit category ACL (admin only)
@@ -2548,8 +2548,8 @@  discard block
 block discarded – undo
2548 2548
 	}
2549 2549
 
2550 2550
 	/**
2551
-	* Set up the required fields to get the history tab
2552
-	*/
2551
+	 * Set up the required fields to get the history tab
2552
+	 */
2553 2553
 	public function setup_history(&$content, &$sel_options)
2554 2554
 	{
2555 2555
 		$status = 'history_status';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2890,11 +2890,11 @@
 block discarded – undo
2890 2890
 			{
2891 2891
 				$msg = lang('Event deleted');
2892 2892
 			}
2893
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2893
+			$response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete'));
2894 2894
 		}
2895 2895
 		else
2896 2896
 		{
2897
-			$response->apply('egw.message', Array(lang('Error')),'error');
2897
+			$response->apply('egw.message', array(lang('Error')),'error');
2898 2898
 		}
2899 2899
 	}
2900 2900
 
Please login to merge, or discard this patch.
Braces   +286 added lines, -73 removed lines patch added patch discarded remove patch
@@ -110,11 +110,14 @@  discard block
 block discarded – undo
110 110
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
111 111
 			!$this->bo->check_perms(Acl::ADD,0,$owner))
112 112
 		{
113
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
113
+			if ($owner)
114
+			{
115
+				// make an owner who is no user or we have no add-rights a participant
114 116
 			{
115 117
 				if(!is_array($owner))
116 118
 				{
117 119
 					$owner = explode(',',$owner);
120
+			}
118 121
 				}
119 122
 				// if we come from ressources we don't need any users selected in calendar
120 123
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -146,9 +149,17 @@  discard block
 block discarded – undo
146 149
 		$participant_types['u'] = $participant_types = $participants = array();
147 150
 		foreach($extra_participants as $uid)
148 151
 		{
149
-			if (isset($participants[$uid])) continue;	// already included
152
+			if (isset($participants[$uid]))
153
+			{
154
+				continue;
155
+			}
156
+			// already included
150 157
 
151
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
158
+			if (!$this->bo->check_acl_invite($uid))
159
+			{
160
+				continue;
161
+			}
162
+			// no right to invite --> ignored
152 163
 
153 164
 			if (is_numeric($uid))
154 165
 			{
@@ -186,10 +197,13 @@  discard block
 block discarded – undo
186 197
 				}
187 198
 			}
188 199
 		}
189
-		if (!$participants)	// if all participants got removed, include current user
200
+		if (!$participants)
201
+		{
202
+			// if all participants got removed, include current user
190 203
 		{
191 204
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
192 205
 		}
206
+		}
193 207
 		if(isset($_GET['cat_id']))
194 208
 		{
195 209
 			$cat_id = explode(',',$_GET['cat_id']);
@@ -239,10 +253,13 @@  discard block
 block discarded – undo
239 253
 	 */
240 254
 	function process_edit($content)
241 255
 	{
242
-		if (!is_array($content))	// redirect from etemplate, if POST empty
256
+		if (!is_array($content))
257
+		{
258
+			// redirect from etemplate, if POST empty
243 259
 		{
244 260
 			return $this->edit(null,null,strip_tags($_GET['msg']));
245 261
 		}
262
+		}
246 263
 		// clear notification errors
247 264
 		notifications::errors(true);
248 265
 		$messages = null;
@@ -255,7 +272,11 @@  discard block
 block discarded – undo
255 272
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
256 273
 
257 274
 		list($button) = @each($content['button']);
258
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
275
+		if (!$button && $content['action'])
276
+		{
277
+			$button = $content['action'];
278
+		}
279
+		// action selectbox
259 280
 		unset($content['button']); unset($content['action']);
260 281
 
261 282
 		$view = $content['view'];
@@ -268,7 +289,10 @@  discard block
 block discarded – undo
268 289
 		{
269 290
 			list($date) = each($content['recur_exception']['delete_exception']);
270 291
 			// eT2 converts time to
271
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
292
+			if (!is_numeric($date))
293
+			{
294
+				$date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
295
+			}
272 296
 			unset($content['recur_exception']['delete_exception']);
273 297
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
274 298
 			{
@@ -277,7 +301,10 @@  discard block
 block discarded – undo
277 301
 				foreach ($recur_exceptions as $id)
278 302
 				{
279 303
 					if (!($exception = $this->bo->read($id)) ||
280
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
304
+							$exception['recurrence'] != $content['recur_exception'][$key])
305
+					{
306
+						continue;
307
+					}
281 308
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
282 309
 					$exception['reference'] = $exception['recurrence'] = 0;
283 310
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -352,7 +379,10 @@  discard block
 block discarded – undo
352 379
 				$event['end'] = $this->bo->date2ts($event['end']);
353 380
 			}
354 381
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
355
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
382
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
383
+			{
384
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
385
+			}
356 386
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
357 387
 			{
358 388
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -475,7 +505,11 @@  discard block
 block discarded – undo
475 505
 							break;
476 506
 
477 507
 						default:		// existing participant row
478
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
508
+							if (!is_array($data))
509
+							{
510
+								continue;
511
+							}
512
+							// widgets in participant tab, above participant list
479 513
 							foreach(array('uid','status','quantity','role') as $name)
480 514
 							{
481 515
 								$$name = $data[$name];
@@ -607,7 +641,10 @@  discard block
 block discarded – undo
607 641
 			{
608 642
 				foreach($participants as $id => &$p_response)
609 643
 				{
610
-					if($type == 'u' && $id == $event['owner']) continue;
644
+					if($type == 'u' && $id == $event['owner'])
645
+					{
646
+						continue;
647
+					}
611 648
 					calendar_so::split_status($p_response, $quantity, $role);
612 649
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
613 650
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -689,17 +726,23 @@  discard block
 block discarded – undo
689 726
 			{
690 727
 				foreach (array_keys($event['participants']) as $uid)
691 728
 				{
692
-					if ($uid[0] == 'r') //ressource detection
729
+					if ($uid[0] == 'r')
730
+					{
731
+						//ressource detection
693 732
 					{
694 733
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
734
+					}
695 735
 						$button = '';
696 736
 						break 2; //break foreach and case
697 737
 					}
698 738
 				}
699 739
 			}
700
-			if ($content['edit_single'])	// we edited a single event from a series
740
+			if ($content['edit_single'])
741
+			{
742
+				// we edited a single event from a series
701 743
 			{
702 744
 				$event['reference'] = $event['id'];
745
+			}
703 746
 				$event['recurrence'] = $content['edit_single'];
704 747
 				unset($event['id']);
705 748
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -795,7 +838,10 @@  discard block
 block discarded – undo
795 838
 										case 'no':
796 839
 											break;
797 840
 										case 'startday':
798
-											if ($sameday) break;
841
+											if ($sameday)
842
+											{
843
+												break;
844
+											}
799 845
 										default:
800 846
 											$status_reset_to_unknown = true;
801 847
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -957,7 +1003,10 @@  discard block
 block discarded – undo
957 1003
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
958 1004
 				{
959 1005
 					$msg = lang('Series deleted');
960
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
1006
+					if ($exceptions_kept)
1007
+					{
1008
+						$msg .= lang(', exceptions preserved');
1009
+					}
961 1010
 				}
962 1011
 				else
963 1012
 				{
@@ -993,11 +1042,14 @@  discard block
 block discarded – undo
993 1042
 				{
994 1043
 					$msg = lang("Can't add alarms in the past !!!");
995 1044
 				}
996
-				elseif ($event['id'])	// save the alarm immediatly
1045
+				elseif ($event['id'])
1046
+				{
1047
+					// save the alarm immediatly
997 1048
 				{
998 1049
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
999 1050
 					{
1000 1051
 						$alarm['id'] = $alarm_id;
1052
+				}
1001 1053
 						$event['alarm'][$alarm_id] = $alarm;
1002 1054
 
1003 1055
 						$msg = lang('Alarm added');
@@ -1010,7 +1062,9 @@  discard block
 block discarded – undo
1010 1062
 				}
1011 1063
 				else
1012 1064
 				{
1013
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1065
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1066
+					{
1067
+}	// get a temporary non-conflicting, numeric id
1014 1068
 					$event['alarm'][$alarm['id']] = $alarm;
1015 1069
 				}
1016 1070
 			}
@@ -1033,10 +1087,13 @@  discard block
 block discarded – undo
1033 1087
 		}
1034 1088
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1035 1089
 		{
1036
-			if ($content['lock_token'])	// remove an existing lock
1090
+			if ($content['lock_token'])
1091
+			{
1092
+				// remove an existing lock
1037 1093
 			{
1038 1094
 				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1039 1095
 			}
1096
+			}
1040 1097
 			if ($content['no_popup'])
1041 1098
 			{
1042 1099
 				Egw::redirect_link('/index.php',array(
@@ -1143,8 +1200,7 @@  discard block
 block discarded – undo
1143 1200
 		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1144 1201
 			// Adjust for requested date in the past
1145 1202
 			Api\DateTime::to($as_of_date,'ts') < time()
1146
-		)
1147
-		{
1203
+		) {
1148 1204
 
1149 1205
 			unset($orig_event);
1150 1206
 			// copy event by unsetting the id(s)
@@ -1232,32 +1288,50 @@  discard block
 block discarded – undo
1232 1288
 		foreach($event['participants'] as $uid => $status)
1233 1289
 		{
1234 1290
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1235
-			if (empty($status)) continue;
1291
+			if (empty($status))
1292
+			{
1293
+				continue;
1294
+			}
1236 1295
 			$toadd = '';
1237
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1296
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1297
+			{
1298
+				continue;
1299
+			}
1238 1300
 
1239 1301
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1240 1302
 			{
1241
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1303
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1304
+				{
1305
+					continue;
1306
+				}
1242 1307
 
1243 1308
 				$lid = $firstname = $lastname = null;
1244 1309
 				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1245 1310
 
1246 1311
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1247
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1312
+				if (!in_array($toadd,$to))
1313
+				{
1314
+					$to[] = $toadd;
1315
+				}
1248 1316
 				//error_log(__METHOD__.__LINE__.array2string($to));
1249 1317
 			}
1250 1318
 			elseif ($uid < 0)
1251 1319
 			{
1252 1320
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1253 1321
 				{
1254
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1322
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1323
+					{
1324
+						continue;
1325
+					}
1255 1326
 
1256 1327
 					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1257 1328
 
1258 1329
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1259 1330
 					// dont add groupmembers if they already rejected the event, or are the current user
1260
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1331
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1332
+					{
1333
+						$to[] = $toadd;
1334
+					}
1261 1335
 					//error_log(__METHOD__.__LINE__.array2string($to));
1262 1336
 				}
1263 1337
 			}
@@ -1310,7 +1384,10 @@  discard block
 block discarded – undo
1310 1384
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1311 1385
 			'preset[size]'    => filesize($ics_file),
1312 1386
 		);
1313
-		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1387
+		if ($asrequest)
1388
+		{
1389
+			$vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1390
+		}
1314 1391
 		$response = Api\Json\Response::get();
1315 1392
 		$response->call('app.calendar.custom_mail', $vars);
1316 1393
 	}
@@ -1496,9 +1573,15 @@  discard block
 block discarded – undo
1496 1573
 				}
1497 1574
 			}
1498 1575
 			// set new start and end if given by $_GET
1499
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1500
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1501
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1576
+			if(isset($_GET['start']))
1577
+			{
1578
+$event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1579
+			if(isset($_GET['end']))
1580
+			{
1581
+$event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1582
+			if(isset($_GET['non_blocking']))
1583
+			{
1584
+$event['non_blocking'] = (bool)$_GET['non_blocking']; }
1502 1585
 			// check if the event is the whole day
1503 1586
 			$start = $this->bo->date2array($event['start']);
1504 1587
 			$end = $this->bo->date2array($event['end']);
@@ -1511,10 +1594,13 @@  discard block
 block discarded – undo
1511 1594
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1512 1595
 				{
1513 1596
 					$link_id = $link_ids[$n];
1514
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1597
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1598
+					{
1599
+						// guard against XSS
1515 1600
 					{
1516 1601
 						continue;
1517 1602
 					}
1603
+					}
1518 1604
 					if(!$n)
1519 1605
 					{
1520 1606
 						$event['title'] = Link::title($link_app,$link_id);
@@ -1523,7 +1609,10 @@  discard block
 block discarded – undo
1523 1609
 						{
1524 1610
 							foreach((array)$set['link_app'] as $i => $l_app)
1525 1611
 							{
1526
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1612
+								if (($l_id=$set['link_id'][$i]))
1613
+								{
1614
+									Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1615
+								}
1527 1616
 							}
1528 1617
 							unset($set['link_app']);
1529 1618
 							unset($set['link_id']);
@@ -1549,10 +1638,13 @@  discard block
 block discarded – undo
1549 1638
 			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1550 1639
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1551 1640
 
1552
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1641
+			if (($preserv['lock_token'] = $event['lock_token']))
1642
+			{
1643
+				// already locked --> refresh the lock
1553 1644
 			{
1554 1645
 				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1555 1646
 			}
1647
+			}
1556 1648
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1557 1649
 			{
1558 1650
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1585,14 +1677,20 @@  discard block
 block discarded – undo
1585 1677
 		));
1586 1678
 		Framework::message($msg, $msg_type);
1587 1679
 		$content['duration'] = $content['end'] - $content['start'];
1588
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1680
+		if (isset($this->durations[$content['duration']]))
1681
+		{
1682
+			$content['end'] = '';
1683
+		}
1589 1684
 
1590 1685
 		$row = 3;
1591 1686
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1592 1687
 		// preserve some ui elements, if set eg. under error-conditions
1593 1688
 		foreach(array('quantity','resource','role') as $n)
1594 1689
 		{
1595
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1690
+			if (isset($event['participants'][$n]))
1691
+			{
1692
+				$content['participants'][$n] = $event['participants'][$n];
1693
+			}
1596 1694
 		}
1597 1695
 		foreach($event['participant_types'] as $type => $participants)
1598 1696
 		{
@@ -1634,9 +1732,13 @@  discard block
 block discarded – undo
1634 1732
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1635 1733
 
1636 1734
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1637
-					$readonlys['participants'][$row]['status'] = $no_status;
1735
+				{
1736
+									$readonlys['participants'][$row]['status'] = $no_status;
1737
+				}
1638 1738
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1639
-					$readonlys['participants']['delete'][$uid] = true;
1739
+				{
1740
+									$readonlys['participants']['delete'][$uid] = true;
1741
+				}
1640 1742
 				// todo: make the participants available as links with email as title
1641 1743
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1642 1744
 				// enumerate group-invitations, so people can accept/reject them
@@ -1667,7 +1769,11 @@  discard block
 block discarded – undo
1667 1769
 			$content['participants']['cal_resources'] = '';
1668 1770
 			foreach($this->bo->resources as $data)
1669 1771
 			{
1670
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1772
+				if ($data['app'] == 'email')
1773
+				{
1774
+					continue;
1775
+				}
1776
+				// make no sense, as we cant search for email
1671 1777
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1672 1778
 			}
1673 1779
 		}
@@ -1695,9 +1801,18 @@  discard block
 block discarded – undo
1695 1801
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1696 1802
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1697 1803
 				$label = array();
1698
-				if ($days) $label[] = $days.' '.lang('days');
1699
-				if ($hours) $label[] = $hours.' '.lang('hours');
1700
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1804
+				if ($days)
1805
+				{
1806
+					$label[] = $days.' '.lang('days');
1807
+				}
1808
+				if ($hours)
1809
+				{
1810
+					$label[] = $hours.' '.lang('hours');
1811
+				}
1812
+				if ($minutes)
1813
+				{
1814
+					$label[] = $minutes.' '.lang('Minutes');
1815
+				}
1701 1816
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1702 1817
 				$content['alarm'][] = $alarm;
1703 1818
 
@@ -1760,25 +1875,34 @@  discard block
 block discarded – undo
1760 1875
 			'participants' => $this->accountsel->account_selection == 'none',
1761 1876
 			'history' => !$event['id'],
1762 1877
 		);
1763
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1878
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1879
+		{
1880
+			// no mail without mail-app
1764 1881
 		{
1765 1882
 			unset($sel_options['action']['mail']);
1883
+		}
1766 1884
 			unset($sel_options['action']['sendmeetingrequest']);
1767 1885
 		}
1768
-		if (!$event['id'])	// no ical export for new (not saved) events
1886
+		if (!$event['id'])
1887
+		{
1888
+			// no ical export for new (not saved) events
1769 1889
 		{
1770 1890
 			$readonlys['action'] = true;
1771 1891
 		}
1892
+		}
1772 1893
 		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1773 1894
 		{
1774 1895
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1775 1896
 		}
1776 1897
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1777 1898
 
1778
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1899
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))
1900
+		{
1901
+			// new event or edit rights to the event ==> allow to add alarm for all users
1779 1902
 		{
1780 1903
 			$sel_options['owner'][0] = lang('All participants');
1781 1904
 		}
1905
+		}
1782 1906
 		if (isset($event['participant_types']['u'][$this->user]))
1783 1907
 		{
1784 1908
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1820,7 +1944,10 @@  discard block
 block discarded – undo
1820 1944
 
1821 1945
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1822 1946
 
1823
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1947
+		if (!empty($preserved['lock_token']))
1948
+		{
1949
+			$content['lock_token'] = $preserved['lock_token'];
1950
+		}
1824 1951
 
1825 1952
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1826 1953
 		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
@@ -2022,7 +2149,10 @@  discard block
 block discarded – undo
2022 2149
 					// set status and send notification / meeting response
2023 2150
 					if ($this->bo->set_status($event['id'], $user, $status))
2024 2151
 					{
2025
-						if (!$msg) $msg = lang('Status changed');
2152
+						if (!$msg)
2153
+						{
2154
+							$msg = lang('Status changed');
2155
+						}
2026 2156
 					}
2027 2157
 					break;
2028 2158
 
@@ -2101,13 +2231,16 @@  discard block
 block discarded – undo
2101 2231
 
2102 2232
 		foreach (array_keys($allConflicts) as $pId)
2103 2233
 		{
2104
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2234
+			if(substr($pId,0,1) == 'r' && $resources_config )
2235
+			{
2236
+				// resources Allow ignore conflicts
2105 2237
 			{
2106 2238
 
2107 2239
 				switch ($resources_config['ignoreconflicts'])
2108 2240
 				{
2109 2241
 					case 'no':
2110 2242
 						$readonlys['button[ignore]'] = true;
2243
+			}
2111 2244
 						break;
2112 2245
 					case 'allusers':
2113 2246
 						$readonlys['button[ignore]'] = false;
@@ -2251,7 +2384,10 @@  discard block
 block discarded – undo
2251 2384
 		}
2252 2385
 		else
2253 2386
 		{
2254
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2387
+			if (!$content['duration'])
2388
+			{
2389
+				$content['duration'] = $content['end'] - $content['start'];
2390
+			}
2255 2391
 			$weekds = 0;
2256 2392
 			foreach ($content['weekdays'] as &$wdays)
2257 2393
 			{
@@ -2273,7 +2409,10 @@  discard block
 block discarded – undo
2273 2409
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2274 2410
 
2275 2411
 		$sel_options['duration'] = $this->durations;
2276
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2412
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2413
+		{
2414
+			$content['end'] = '';
2415
+		}
2277 2416
 
2278 2417
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2279 2418
 				'participants'	=> $content['participants'],
@@ -2294,7 +2433,10 @@  discard block
 block discarded – undo
2294 2433
 	 */
2295 2434
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2296 2435
 	{
2297
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2436
+		if ($this->debug > 2)
2437
+		{
2438
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2439
+		}
2298 2440
 
2299 2441
 		$busy = $this->bo->search(array(
2300 2442
 			'start' => $start,
@@ -2311,15 +2453,26 @@  discard block
 block discarded – undo
2311 2453
 		$n = 0;
2312 2454
 		foreach($busy as $event)
2313 2455
 		{
2314
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2456
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2457
+			{
2458
+				continue;
2459
+			}
2460
+			// ignore our own event
2315 2461
 
2316
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2462
+ 			if ($event['non_blocking'])
2463
+ 			{
2464
+ 				continue;
2465
+ 			}
2466
+ 			// ignore non_blocking events
2317 2467
 
2318 2468
 			// check if from all wanted participants at least one has a not rejected status in found event
2319 2469
 			$non_rejected_found = false;
2320 2470
 			foreach($participants as $uid)
2321 2471
 			{
2322
-				if ($event['participants'][$uid] == 'R') continue;
2472
+				if ($event['participants'][$uid] == 'R')
2473
+				{
2474
+					continue;
2475
+				}
2323 2476
 
2324 2477
 				if (isset($event['participants'][$uid]) ||
2325 2478
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2329,7 +2482,10 @@  discard block
 block discarded – undo
2329 2482
 					break;
2330 2483
 				}
2331 2484
 			}
2332
-			if (!$non_rejected_found) continue;
2485
+			if (!$non_rejected_found)
2486
+			{
2487
+				continue;
2488
+			}
2333 2489
 
2334 2490
 			if ($this->debug)
2335 2491
 			{
@@ -2360,11 +2516,17 @@  discard block
 block discarded – undo
2360 2516
 					'start'	=> $ft_start,
2361 2517
 					'end'	=> $ft_end,
2362 2518
 				);
2363
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2519
+				if ($this->debug > 1)
2520
+				{
2521
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2522
+				}
2364 2523
 			}
2365 2524
 			$ft_start = $event['end'];
2366 2525
 		}
2367
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2526
+		if ($this->debug > 0)
2527
+		{
2528
+			$this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2529
+		}
2368 2530
 
2369 2531
 		return $freetime;
2370 2532
 	}
@@ -2384,10 +2546,16 @@  discard block
 block discarded – undo
2384 2546
 	 */
2385 2547
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2386 2548
 	{
2387
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2549
+		if ($this->debug > 1)
2550
+		{
2551
+			$this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2552
+		}
2388 2553
 
2389 2554
 		$freetime_daywise = array();
2390
-		if (!is_array($sel_options)) $sel_options = array();
2555
+		if (!is_array($sel_options))
2556
+		{
2557
+			$sel_options = array();
2558
+		}
2391 2559
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2392 2560
 
2393 2561
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2397,7 +2565,10 @@  discard block
 block discarded – undo
2397 2565
 		if (($end_time - $start_time)*HOUR_s < $duration)
2398 2566
 		{
2399 2567
 			$end_time = 0;
2400
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2568
+			if ($this->debug > 1)
2569
+			{
2570
+				$this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2571
+			}
2401 2572
 		}
2402 2573
 		$n = 0;
2403 2574
 		foreach($freetime as $ft)
@@ -2418,13 +2589,19 @@  discard block
 block discarded – undo
2418 2589
 				}
2419 2590
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2420 2591
 
2421
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2592
+				if ($start-$daybegin < $start_time*HOUR_s)
2593
+				{
2594
+					// start earlier then start_time
2422 2595
 				{
2423 2596
 					$start = $daybegin + $start_time*HOUR_s;
2424 2597
 				}
2598
+				}
2425 2599
 				// if end_time given use it, else the original slot's end
2426 2600
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2427
-				if ($end > $ft['end']) $end = $ft['end'];
2601
+				if ($end > $ft['end'])
2602
+				{
2603
+					$end = $ft['end'];
2604
+				}
2428 2605
 
2429 2606
 				// slot to small for duration
2430 2607
 				if ($end - $start < $duration)
@@ -2466,7 +2643,10 @@  discard block
 block discarded – undo
2466 2643
 			{
2467 2644
 				$msg = lang('Permission denied');
2468 2645
 
2469
-				if ($return_error) return $msg;
2646
+				if ($return_error)
2647
+				{
2648
+					return $msg;
2649
+				}
2470 2650
 			}
2471 2651
 			else
2472 2652
 			{
@@ -2528,27 +2708,42 @@  discard block
 block discarded – undo
2528 2708
 		{
2529 2709
 			list($button) = each($_content['button']);
2530 2710
 			unset($_content['button']);
2531
-			if ($button != 'cancel')	// store changed Acl
2711
+			if ($button != 'cancel')
2712
+			{
2713
+				// store changed Acl
2532 2714
 			{
2533 2715
 				foreach($_content as $data)
2534 2716
 				{
2535 2717
 					if (!($cat_id = $data['cat_id'])) continue;
2718
+			}
2536 2719
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2537 2720
 					{
2538 2721
 						$rights = 0;
2539
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2540
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2541
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2722
+						if (in_array($account_id,(array)$data['add']))
2723
+						{
2724
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2725
+						}
2726
+						if (in_array($account_id,(array)$data['status']))
2727
+						{
2728
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2729
+						}
2730
+						if ($account_id)
2731
+						{
2732
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2733
+						}
2542 2734
 					}
2543 2735
 				}
2544 2736
 			}
2545
-			if ($button != 'apply')	// end dialog
2737
+			if ($button != 'apply')
2738
+			{
2739
+				// end dialog
2546 2740
 			{
2547 2741
 				Egw::redirect_link('/index.php', array(
2548 2742
 					'menuaction' => 'admin.admin_ui.index',
2549 2743
 					'ajax' => 'true'
2550 2744
 				), 'admin');
2551 2745
 			}
2746
+			}
2552 2747
 		}
2553 2748
 		$content= $preserv = array();
2554 2749
 		$n = 1;
@@ -2562,8 +2757,14 @@  discard block
 block discarded – undo
2562 2757
 			);
2563 2758
 			foreach($data as $account_id => $rights)
2564 2759
 			{
2565
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2566
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2760
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2761
+				{
2762
+					$row['add'][] = $account_id;
2763
+				}
2764
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2765
+				{
2766
+					$row['status'][] = $account_id;
2767
+				}
2567 2768
 			}
2568 2769
 			$content[$n] = $row;
2569 2770
 			$preserv[$n] = array(
@@ -2691,7 +2892,10 @@  discard block
 block discarded – undo
2691 2892
 					break;
2692 2893
 				}
2693 2894
 			}
2694
-			if($return) return;
2895
+			if($return)
2896
+			{
2897
+				return;
2898
+			}
2695 2899
 		}
2696 2900
 		$old_event=$event=$this->bo->read($eventId);
2697 2901
 		if (!$durationT)
@@ -2784,7 +2988,10 @@  discard block
 block discarded – undo
2784 2988
 			$this->bo->update($event,true, true, false, true, $message,true);
2785 2989
 
2786 2990
 			// Whole day non blocking with DAY_s would add a day
2787
-			if($duration==DAY_s) $duration=0;
2991
+			if($duration==DAY_s)
2992
+			{
2993
+				$duration=0;
2994
+			}
2788 2995
 		}
2789 2996
 
2790 2997
 		$status_reset_to_unknown = false;
@@ -2802,7 +3009,10 @@  discard block
 block discarded – undo
2802 3009
 					case 'no':
2803 3010
 						break;
2804 3011
 					case 'startday':
2805
-						if ($sameday) break;
3012
+						if ($sameday)
3013
+						{
3014
+							break;
3015
+						}
2806 3016
 					default:
2807 3017
 						$status_reset_to_unknown = true;
2808 3018
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2840,7 +3050,10 @@  discard block
 block discarded – undo
2840 3050
 		{
2841 3051
 			$response->call('egw.message',  implode('<br />', $message));
2842 3052
 		}
2843
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
3053
+		if($event['id'] != $eventId )
3054
+		{
3055
+			$this->update_client($_eventId);
3056
+		}
2844 3057
 		if ($status_reset_to_unknown)
2845 3058
 		{
2846 3059
 			foreach((array)$event['participants'] as $uid => $status)
Please login to merge, or discard this patch.
Switch Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -584,214 +584,214 @@  discard block
 block discarded – undo
584 584
 
585 585
 		switch((string)$button)
586 586
 		{
587
-		case 'exception':	// create an exception in a recuring event
588
-			$msg = $this->_create_exception($event,$preserv);
589
-			break;
587
+			case 'exception':	// create an exception in a recuring event
588
+				$msg = $this->_create_exception($event,$preserv);
589
+				break;
590 590
 
591
-		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
592
-			unset($event['id']);
593
-			unset($event['uid']);
594
-			unset($event['reference']);
595
-			unset($preserv['reference']);
596
-			unset($event['recurrence']);
597
-			unset($preserv['recurrence']);
598
-			unset($event['recur_exception']);
599
-			unset($event['edit_single']);	// in case it has been set
600
-			unset($event['modified']);
601
-			unset($event['modifier']);
602
-			unset($event['caldav_name']);
603
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
591
+			case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
592
+				unset($event['id']);
593
+				unset($event['uid']);
594
+				unset($event['reference']);
595
+				unset($preserv['reference']);
596
+				unset($event['recurrence']);
597
+				unset($preserv['recurrence']);
598
+				unset($event['recur_exception']);
599
+				unset($event['edit_single']);	// in case it has been set
600
+				unset($event['modified']);
601
+				unset($event['modifier']);
602
+				unset($event['caldav_name']);
603
+				$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
604
+
605
+				// Clear participant stati
606
+				foreach($event['participant_types'] as $type => &$participants)
607
+				{
608
+					foreach($participants as $id => &$p_response)
609
+					{
610
+						if($type == 'u' && $id == $event['owner']) continue;
611
+						calendar_so::split_status($p_response, $quantity, $role);
612
+						// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
613
+						$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
614
+						$p_response = calendar_so::combine_status($status,$quantity,$role);
615
+					}
616
+				}
604 617
 
605
-			// Clear participant stati
606
-			foreach($event['participant_types'] as $type => &$participants)
607
-			{
608
-				foreach($participants as $id => &$p_response)
618
+				// Copy alarms
619
+				if (is_array($event['alarm']))
609 620
 				{
610
-					if($type == 'u' && $id == $event['owner']) continue;
611
-					calendar_so::split_status($p_response, $quantity, $role);
612
-					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
613
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
614
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
621
+					foreach($event['alarm'] as $n => &$alarm)
622
+					{
623
+						unset($alarm['id']);
624
+						unset($alarm['cal_id']);
625
+					}
615 626
 				}
616
-			}
617 627
 
618
-			// Copy alarms
619
-			if (is_array($event['alarm']))
620
-			{
621
-				foreach($event['alarm'] as $n => &$alarm)
628
+				// Get links to be copied
629
+				// With no ID, $content['link_to']['to_id'] is used
630
+				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
631
+				foreach(Link::get_links('calendar', $content['id']) as $link)
622 632
 				{
623
-					unset($alarm['id']);
624
-					unset($alarm['cal_id']);
633
+					if ($link['app'] != Link::VFS_APPNAME)
634
+					{
635
+						Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
636
+					}
637
+					elseif ($link['app'] == Link::VFS_APPNAME)
638
+					{
639
+						Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
640
+							'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
641
+							'name' => $link['id'],
642
+						), $link['remark']);
643
+					}
625 644
 				}
626
-			}
645
+				unset($link);
646
+				$preserv['view'] = $preserv['edit_single'] = false;
647
+				$msg = lang('Event copied - the copy can now be edited');
648
+				$event['title'] = lang('Copy of:').' '.$event['title'];
649
+				break;
627 650
 
628
-			// Get links to be copied
629
-			// With no ID, $content['link_to']['to_id'] is used
630
-			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
631
-			foreach(Link::get_links('calendar', $content['id']) as $link)
632
-			{
633
-				if ($link['app'] != Link::VFS_APPNAME)
651
+			case 'mail':
652
+			case 'sendrequest':
653
+			case 'save':
654
+			case 'print':
655
+			case 'apply':
656
+			case 'infolog':
657
+				if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
634 658
 				{
635
-					Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
659
+					$msg = lang('Permission denied');
660
+					$button = '';
661
+					break;
636 662
 				}
637
-				elseif ($link['app'] == Link::VFS_APPNAME)
663
+				if ($event['start'] > $event['end'])
638 664
 				{
639
-					Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
640
-						'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
641
-						'name' => $link['id'],
642
-					), $link['remark']);
665
+					$msg = lang('Error: Starttime has to be before the endtime !!!');
666
+					$button = '';
667
+					break;
643 668
 				}
644
-			}
645
-			unset($link);
646
-			$preserv['view'] = $preserv['edit_single'] = false;
647
-			$msg = lang('Event copied - the copy can now be edited');
648
-			$event['title'] = lang('Copy of:').' '.$event['title'];
649
-			break;
650
-
651
-		case 'mail':
652
-		case 'sendrequest':
653
-		case 'save':
654
-		case 'print':
655
-		case 'apply':
656
-		case 'infolog':
657
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
658
-			{
659
-				$msg = lang('Permission denied');
660
-				$button = '';
661
-				break;
662
-			}
663
-			if ($event['start'] > $event['end'])
664
-			{
665
-				$msg = lang('Error: Starttime has to be before the endtime !!!');
666
-				$button = '';
667
-				break;
668
-			}
669
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
670
-			{
671
-				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
672
-				$button = '';
673
-				break;
674
-			}
675
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
676
-			{
677
-				$msg = lang('Error: Duration of event longer then recurrence interval!');
678
-				$button = '';
679
-				break;
680
-			}
681
-			if (!$event['participants'])
682
-			{
683
-				$msg = lang('Error: no participants selected !!!');
684
-				$button = '';
685
-				break;
686
-			}
687
-			// if private event with ressource reservation is forbidden
688
-			if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
689
-			{
690
-				foreach (array_keys($event['participants']) as $uid)
669
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
691 670
 				{
692
-					if ($uid[0] == 'r') //ressource detection
671
+					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
672
+					$button = '';
673
+					break;
674
+				}
675
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
676
+				{
677
+					$msg = lang('Error: Duration of event longer then recurrence interval!');
678
+					$button = '';
679
+					break;
680
+				}
681
+				if (!$event['participants'])
682
+				{
683
+					$msg = lang('Error: no participants selected !!!');
684
+					$button = '';
685
+					break;
686
+				}
687
+				// if private event with ressource reservation is forbidden
688
+				if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
689
+				{
690
+					foreach (array_keys($event['participants']) as $uid)
693 691
 					{
694
-						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
695
-						$button = '';
696
-						break 2; //break foreach and case
692
+						if ($uid[0] == 'r') //ressource detection
693
+						{
694
+							$msg = lang('Error: ressources reservation in private events is not allowed!!!');
695
+							$button = '';
696
+							break 2; //break foreach and case
697
+						}
697 698
 					}
698 699
 				}
699
-			}
700
-			if ($content['edit_single'])	// we edited a single event from a series
701
-			{
702
-				$event['reference'] = $event['id'];
703
-				$event['recurrence'] = $content['edit_single'];
704
-				unset($event['id']);
705
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
706
-				if (!is_array($conflicts) && $conflicts)
700
+				if ($content['edit_single'])	// we edited a single event from a series
707 701
 				{
708
-					// now we need to add the original start as recur-execption to the series
709
-					$recur_event = $this->bo->read($event['reference']);
710
-					$recur_event['recur_exception'][] = $content['edit_single'];
711
-					// check if we need to move the alarms, because they are next on that exception
712
-					foreach($recur_event['alarm'] as $id => $alarm)
702
+					$event['reference'] = $event['id'];
703
+					$event['recurrence'] = $content['edit_single'];
704
+					unset($event['id']);
705
+					$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
706
+					if (!is_array($conflicts) && $conflicts)
713 707
 					{
714
-						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
708
+						// now we need to add the original start as recur-execption to the series
709
+						$recur_event = $this->bo->read($event['reference']);
710
+						$recur_event['recur_exception'][] = $content['edit_single'];
711
+						// check if we need to move the alarms, because they are next on that exception
712
+						foreach($recur_event['alarm'] as $id => $alarm)
715 713
 						{
716
-							$rrule = calendar_rrule::event2rrule($recur_event, true);
717
-							foreach ($rrule as $time)
714
+							if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
718 715
 							{
719
-								if ($content['edit_single'] < $time->format('ts'))
716
+								$rrule = calendar_rrule::event2rrule($recur_event, true);
717
+								foreach ($rrule as $time)
720 718
 								{
721
-									$alarm['time'] = $time->format('ts') - $alarm['offset'];
722
-									$this->bo->save_alarm($event['reference'], $alarm);
723
-									break;
719
+									if ($content['edit_single'] < $time->format('ts'))
720
+									{
721
+										$alarm['time'] = $time->format('ts') - $alarm['offset'];
722
+										$this->bo->save_alarm($event['reference'], $alarm);
723
+										break;
724
+									}
724 725
 								}
725 726
 							}
726 727
 						}
727
-					}
728
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
729
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
730
-					$this->bo->update($recur_event,true);	// no conflict check here
728
+						unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
729
+						unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
730
+						$this->bo->update($recur_event,true);	// no conflict check here
731 731
 
732
-					if(Api\Json\Response::isJSONResponse())
732
+						if(Api\Json\Response::isJSONResponse())
733
+						{
734
+							// Sending null will trigger a removal of the original
735
+							// for that date
736
+							Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
737
+						}
738
+
739
+						unset($recur_event);
740
+						unset($event['edit_single']);			// if we further edit it, it's just a single event
741
+						unset($preserv['edit_single']);
742
+					}
743
+					else	// conflict or error, we need to reset everything to the state befor we tried to save it
733 744
 					{
734
-						// Sending null will trigger a removal of the original
735
-						// for that date
736
-						Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
745
+						$event['id'] = $event['reference'];
746
+						$event['reference'] = $event['recurrence'] = 0;
747
+						$event['uid'] = $content['uid'];
737 748
 					}
738
-
739
-					unset($recur_event);
740
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
741
-					unset($preserv['edit_single']);
742
-				}
743
-				else	// conflict or error, we need to reset everything to the state befor we tried to save it
744
-				{
745
-					$event['id'] = $event['reference'];
746
-					$event['reference'] = $event['recurrence'] = 0;
747
-					$event['uid'] = $content['uid'];
749
+					$update_type = 'edit';
748 750
 				}
749
-				$update_type = 'edit';
750
-			}
751
-			else	// we edited a non-reccuring event or the whole series
752
-			{
753
-				if (($old_event = $this->bo->read($event['id'])))
751
+				else	// we edited a non-reccuring event or the whole series
754 752
 				{
755
-					if ($event['recur_type'] != MCAL_RECUR_NONE)
753
+					if (($old_event = $this->bo->read($event['id'])))
756 754
 					{
757
-						$update_type = 'edit';
758
-
759
-						// we edit a existing series event
760
-						if ($event['start'] != $old_event['start'] ||
761
-							$event['whole_day'] != $old_event['whole_day'] ||
762
-							$event['end'] != $old_event['end'])
755
+						if ($event['recur_type'] != MCAL_RECUR_NONE)
763 756
 						{
764
-							// calculate offset against old series start or clicked recurrance,
765
-							// depending on which is smaller
766
-							$offset = $event['start'] - $old_event['start'];
767
-							if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
768
-							{
769
-								$offset = $off2;
770
-							}
771
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
772
-							if($msg)
757
+							$update_type = 'edit';
758
+
759
+							// we edit a existing series event
760
+							if ($event['start'] != $old_event['start'] ||
761
+								$event['whole_day'] != $old_event['whole_day'] ||
762
+								$event['end'] != $old_event['end'])
773 763
 							{
774
-								$noerror = false;
764
+								// calculate offset against old series start or clicked recurrance,
765
+								// depending on which is smaller
766
+								$offset = $event['start'] - $old_event['start'];
767
+								if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
768
+								{
769
+									$offset = $off2;
770
+								}
771
+								$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
772
+								if($msg)
773
+								{
774
+									$noerror = false;
775
+								}
775 776
 							}
776 777
 						}
777
-					}
778
-					else
779
-					{
780
-						if ($old_event['start'] != $event['start'] ||
781
-							$old_event['end'] != $event['end'] ||
782
-							$event['whole_day'] != $old_event['whole_day'])
778
+						else
783 779
 						{
784
-							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
785
-							foreach((array)$event['participants'] as $uid => $status)
780
+							if ($old_event['start'] != $event['start'] ||
781
+								$old_event['end'] != $event['end'] ||
782
+								$event['whole_day'] != $old_event['whole_day'])
786 783
 							{
787
-								$q = $r = null;
788
-								calendar_so::split_status($status,$q,$r);
789
-								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
784
+								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
785
+								foreach((array)$event['participants'] as $uid => $status)
790 786
 								{
791
-									$preferences = new Api\Preferences($uid);
792
-									$part_prefs = $preferences->read_repository();
793
-									switch ($part_prefs['calendar']['reset_stati'])
787
+									$q = $r = null;
788
+									calendar_so::split_status($status,$q,$r);
789
+									if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
794 790
 									{
791
+										$preferences = new Api\Preferences($uid);
792
+										$part_prefs = $preferences->read_repository();
793
+										switch ($part_prefs['calendar']['reset_stati'])
794
+										{
795 795
 										case 'no':
796 796
 											break;
797 797
 										case 'startday':
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 											$status_reset_to_unknown = true;
801 801
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
802 802
 											// todo: report reset status to user
803
-									}
803
+										}
804 804
 								}
805 805
 							}
806 806
 							// check if we need to move the alarms, because they are relative
@@ -942,83 +942,83 @@  discard block
 block discarded – undo
942 942
 			}
943 943
 			break;
944 944
 
945
-		case 'cancel':
946
-			if($content['cancel_needs_refresh'])
947
-			{
948
-				Framework::refresh_opener($msg, 'calendar');
949
-			}
950
-			break;
951
-
952
-		case 'delete':					// delete of event (regular or series)
953
-			$exceptions_kept = null;
954
-			if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
955
-				$content['delete_exceptions'] == 'true', $exceptions_kept))
956
-			{
957
-				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
945
+			case 'cancel':
946
+				if($content['cancel_needs_refresh'])
958 947
 				{
959
-					$msg = lang('Series deleted');
960
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
948
+					Framework::refresh_opener($msg, 'calendar');
961 949
 				}
962
-				else
950
+				break;
951
+
952
+			case 'delete':					// delete of event (regular or series)
953
+				$exceptions_kept = null;
954
+				if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
955
+					$content['delete_exceptions'] == 'true', $exceptions_kept))
963 956
 				{
964
-					$msg = lang('Event deleted');
965
-				}
957
+					if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
958
+					{
959
+						$msg = lang('Series deleted');
960
+						if ($exceptions_kept) $msg .= lang(', exceptions preserved');
961
+					}
962
+					else
963
+					{
964
+						$msg = lang('Event deleted');
965
+					}
966 966
 
967
-			}
968
-			break;
967
+				}
968
+				break;
969 969
 
970
-		case 'freetime':
971
-			// the "click" has to be in onload, to make sure the button is already created
972
-			$event['button_was'] = $button;
973
-			break;
970
+			case 'freetime':
971
+				// the "click" has to be in onload, to make sure the button is already created
972
+				$event['button_was'] = $button;
973
+				break;
974 974
 
975
-		case 'add_alarm':
976
-			$time = $content['start'];
977
-			$offset = $time - $content['new_alarm']['date'];
978
-			if ($event['recur_type'] != MCAL_RECUR_NONE &&
979
-				($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
980
-				$time < $next_occurrence['start'])
981
-			{
982
-				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
983
-			}
984
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
985
-			{
986
-				$alarm = array(
987
-					'offset' => $offset,
988
-					'time'   => $content['new_alarm']['date'],
989
-					'all'    => !$content['new_alarm']['owner'],
990
-					'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
991
-				);
992
-				if ($alarm['time'] < $this->bo->now_su)
975
+			case 'add_alarm':
976
+				$time = $content['start'];
977
+				$offset = $time - $content['new_alarm']['date'];
978
+				if ($event['recur_type'] != MCAL_RECUR_NONE &&
979
+					($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
980
+					$time < $next_occurrence['start'])
993 981
 				{
994
-					$msg = lang("Can't add alarms in the past !!!");
982
+					$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
995 983
 				}
996
-				elseif ($event['id'])	// save the alarm immediatly
984
+				if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
997 985
 				{
998
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
986
+					$alarm = array(
987
+						'offset' => $offset,
988
+						'time'   => $content['new_alarm']['date'],
989
+						'all'    => !$content['new_alarm']['owner'],
990
+						'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
991
+					);
992
+					if ($alarm['time'] < $this->bo->now_su)
993
+					{
994
+						$msg = lang("Can't add alarms in the past !!!");
995
+					}
996
+					elseif ($event['id'])	// save the alarm immediatly
999 997
 					{
1000
-						$alarm['id'] = $alarm_id;
1001
-						$event['alarm'][$alarm_id] = $alarm;
998
+						if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
999
+						{
1000
+							$alarm['id'] = $alarm_id;
1001
+							$event['alarm'][$alarm_id] = $alarm;
1002 1002
 
1003
-						$msg = lang('Alarm added');
1004
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1003
+							$msg = lang('Alarm added');
1004
+							Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1005
+						}
1006
+						else
1007
+						{
1008
+							$msg = lang('Error adding the alarm');
1009
+						}
1005 1010
 					}
1006 1011
 					else
1007 1012
 					{
1008
-						$msg = lang('Error adding the alarm');
1013
+						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1014
+						$event['alarm'][$alarm['id']] = $alarm;
1009 1015
 					}
1010 1016
 				}
1011 1017
 				else
1012 1018
 				{
1013
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1014
-					$event['alarm'][$alarm['id']] = $alarm;
1019
+					$msg = lang('Permission denied');
1015 1020
 				}
1016
-			}
1017
-			else
1018
-			{
1019
-				$msg = lang('Permission denied');
1020
-			}
1021
-			break;
1021
+				break;
1022 1022
 		}
1023 1023
 		// add notification-errors, if we have some
1024 1024
 		if (($notification_errors = notifications::errors(true)))
Please login to merge, or discard this patch.
Spacing   +462 added lines, -464 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var locktime in seconds
57 57
 	 */
58
-	var $locktime_default=1;
58
+	var $locktime_default = 1;
59 59
 
60 60
 	/**
61 61
 	 * Constructor
62 62
 	 */
63 63
 	function __construct()
64 64
 	{
65
-		parent::__construct(true);	// call the parent's constructor
65
+		parent::__construct(true); // call the parent's constructor
66 66
 
67
-		for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
67
+		for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
68 68
 		{
69
-			$this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60);
69
+			$this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60);
70 70
 		}
71 71
 	}
72 72
 
@@ -78,11 +78,10 @@  discard block
 block discarded – undo
78 78
 	function &default_add_event()
79 79
 	{
80 80
 		$extra_participants = $_GET['participants'] ?
81
-			(!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) :
82
-			array();
81
+			(!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array();
83 82
 
84 83
 		// if participant is a contact, add its link title as title
85
-		foreach($extra_participants as $uid)
84
+		foreach ($extra_participants as $uid)
86 85
 		{
87 86
 			if ($uid[0] == 'c')
88 87
 			{
@@ -94,14 +93,14 @@  discard block
 block discarded – undo
94 93
 		if (isset($_GET['owner']))
95 94
 		{
96 95
 			$owner = $_GET['owner'];
97
-			if(!is_array($owner) && strpos($owner, ','))
96
+			if (!is_array($owner) && strpos($owner, ','))
98 97
 			{
99
-				$owner = explode(',',$owner);
98
+				$owner = explode(',', $owner);
100 99
 			}
101
-			if(is_array($owner))
100
+			if (is_array($owner))
102 101
 			{
103 102
 				// old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0'
104
-				if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
103
+				if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
105 104
 				{
106 105
 					$extra_participants += $owner;
107 106
 				}
@@ -117,21 +116,21 @@  discard block
 block discarded – undo
117 116
 			// old behavior "selected" should also be used for not set preference, therefore we need to test for === '0'
118 117
 			$owner = $this->cal_prefs['default_participant'] === '0' ? $this->user : $this->owner;
119 118
 		}
120
-		error_log(__METHOD__ . ' owner: ' . array2string($owner));
119
+		error_log(__METHOD__.' owner: '.array2string($owner));
121 120
 
122 121
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
123
-			!$this->bo->check_perms(Acl::ADD,0,$owner))
122
+			!$this->bo->check_perms(Acl::ADD, 0, $owner))
124 123
 		{
125 124
 			if ($owner)	// make an owner who is no user or we have no add-rights a participant
126 125
 			{
127
-				if(!is_array($owner))
126
+				if (!is_array($owner))
128 127
 				{
129
-					$owner = explode(',',$owner);
128
+					$owner = explode(',', $owner);
130 129
 				}
131 130
 				// if we come from ressources we don't need any users selected in calendar
132 131
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
133 132
 				{
134
-					foreach($owner as $uid)
133
+					foreach ($owner as $uid)
135 134
 					{
136 135
 						$extra_participants[] = $uid;
137 136
 					}
@@ -141,71 +140,71 @@  discard block
 block discarded – undo
141 140
 		}
142 141
 		//error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")");
143 142
 
144
-		if(isset($_GET['start']))
143
+		if (isset($_GET['start']))
145 144
 		{
146 145
 			$start = Api\DateTime::to($_GET['start'], 'ts');
147 146
 		}
148 147
 		else
149 148
 		{
150 149
 			$start = $this->bo->date2ts(array(
151
-				'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date,
152
-				'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
153
-				'minute' => (int) $_GET['minute'],
150
+				'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date,
151
+				'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
152
+				'minute' => (int)$_GET['minute'],
154 153
 			));
155 154
 		}
156 155
 		//echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n";
157 156
 
158 157
 		$participant_types['u'] = $participant_types = $participants = array();
159
-		foreach($extra_participants as $uid)
158
+		foreach ($extra_participants as $uid)
160 159
 		{
161
-			if (isset($participants[$uid])) continue;	// already included
160
+			if (isset($participants[$uid])) continue; // already included
162 161
 
163
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
162
+			if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored
164 163
 
165 164
 			if (is_numeric($uid))
166 165
 			{
167 166
 				$participants[$uid] = $participant_types['u'][$uid] =
168
-					calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
169
-					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
167
+					calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
168
+					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
170 169
 			}
171 170
 			elseif (is_array($this->bo->resources[$uid[0]]))
172 171
 			{
173 172
 				// Expand mailing lists
174
-				if($uid[0] == 'l')
173
+				if ($uid[0] == 'l')
175 174
 				{
176
-					foreach($this->bo->enum_mailing_list($uid) as $contact)
175
+					foreach ($this->bo->enum_mailing_list($uid) as $contact)
177 176
 					{
178
-						$participants[$contact] = $participant_types['c'][substr($contact,1)] =
179
-							calendar_so::combine_status('U',1,'REQ-PARTICIPANT');
177
+						$participants[$contact] = $participant_types['c'][substr($contact, 1)] =
178
+							calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT');
180 179
 					}
181 180
 					continue;
182 181
 				}
183 182
 				// if contact is a user, use the user instead (as the GUI)
184
-				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
183
+				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id')))
185 184
 				{
186 185
 					$uid = $account_id;
187 186
 					$participants[$uid] = $participant_types['u'][$uid] =
188
-						calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
189
-						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
187
+						calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
188
+						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
190 189
 					continue;
191 190
 				}
192 191
 				$res_data = $this->bo->resources[$uid[0]];
193
-				list($id,$quantity) = explode(':',substr($uid,1));
194
-				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U'))
192
+				list($id, $quantity) = explode(':', substr($uid, 1));
193
+				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U'))
195 194
 				{
196 195
 					$participants[$uid] = $participant_types[$uid[0]][$id] =
197
-						calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT');
196
+						calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT');
198 197
 				}
199 198
 			}
200 199
 		}
201 200
 		if (!$participants)	// if all participants got removed, include current user
202 201
 		{
203
-			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
202
+			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR');
204 203
 		}
205
-		if(isset($_GET['cat_id']))
204
+		if (isset($_GET['cat_id']))
206 205
 		{
207
-			$cat_id = explode(',',$_GET['cat_id']);
208
-			foreach($cat_id as &$cat)
206
+			$cat_id = explode(',', $_GET['cat_id']);
207
+			foreach ($cat_id as &$cat)
209 208
 			{
210 209
 				$cat = (int)$cat;
211 210
 			}
@@ -216,16 +215,16 @@  discard block
 block discarded – undo
216 215
 		if ((string)$this->cal_prefs['default-alarm'] !== '')
217 216
 		{
218 217
 			$offset = 60 * $this->cal_prefs['default-alarm'];
219
-			$alarms[1] =  array(
218
+			$alarms[1] = array(
220 219
 				'default' => 1,
221
-				'offset' => $offset ,
220
+				'offset' => $offset,
222 221
 				'time'   => $start - $offset,
223 222
 				'all'    => false,
224 223
 				'owner'  => $owner,
225 224
 				'id'	=> 1,
226 225
 			);
227 226
 		}
228
-		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60;
227
+		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60;
229 228
 		$end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration;
230 229
 		return array(
231 230
 			'participant_types' => $participant_types,
@@ -234,7 +233,7 @@  discard block
 block discarded – undo
234 233
 			'start' => $start,
235 234
 			'end'   => $end,
236 235
 			'tzid'  => $this->bo->common_prefs['tz'],
237
-			'priority' => 2,	// normal
236
+			'priority' => 2, // normal
238 237
 			'public'=> $this->cal_prefs['default_private'] ? 0 : 1,
239 238
 			'alarm' => $alarms,
240 239
 			'recur_exception' => array(),
@@ -253,7 +252,7 @@  discard block
 block discarded – undo
253 252
 	{
254 253
 		if (!is_array($content))	// redirect from etemplate, if POST empty
255 254
 		{
256
-			return $this->edit(null,null,strip_tags($_GET['msg']));
255
+			return $this->edit(null, null, strip_tags($_GET['msg']));
257 256
 		}
258 257
 		// clear notification errors
259 258
 		notifications::errors(true);
@@ -267,22 +266,22 @@  discard block
 block discarded – undo
267 266
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
268 267
 
269 268
 		list($button) = @each($content['button']);
270
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
269
+		if (!$button && $content['action']) $button = $content['action']; // action selectbox
271 270
 		unset($content['button']); unset($content['action']);
272 271
 
273 272
 		$view = $content['view'];
274 273
 		if ($button == 'ical')
275 274
 		{
276
-			$msg = $this->export($content['id'],true);
275
+			$msg = $this->export($content['id'], true);
277 276
 		}
278 277
 		// delete a recur-exception
279 278
 		if ($content['recur_exception']['delete_exception'])
280 279
 		{
281 280
 			list($date) = each($content['recur_exception']['delete_exception']);
282 281
 			// eT2 converts time to
283
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
282
+			if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts');
284 283
 			unset($content['recur_exception']['delete_exception']);
285
-			if (($key = array_search($date,$content['recur_exception'])) !== false)
284
+			if (($key = array_search($date, $content['recur_exception'])) !== false)
286 285
 			{
287 286
 				// propagate the exception to a single event
288 287
 				$recur_exceptions = $this->bo->so->get_related($content['uid']);
@@ -292,7 +291,7 @@  discard block
 block discarded – undo
292 291
 							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
293 292
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
294 293
 					$exception['reference'] = $exception['recurrence'] = 0;
295
-					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
294
+					$this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']);
296 295
 					break;
297 296
 				}
298 297
 				unset($content['recur_exception'][$key]);
@@ -333,7 +332,7 @@  discard block
 block discarded – undo
333 332
 			$def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')];
334 333
 			if ((string)$def_alarm === '')
335 334
 			{
336
-				unset($content['alarm'][1]);	// '' = no alarm on whole day --> delete it
335
+				unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it
337 336
 			}
338 337
 			else
339 338
 			{
@@ -347,7 +346,7 @@  discard block
 block discarded – undo
347 346
 		unset($event['alarm']['delete_alarm']);
348 347
 		unset($event['duration']);
349 348
 
350
-		if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series')))
349
+		if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series')))
351 350
 		{
352 351
 			// no conversation necessary, event is already in the right format
353 352
 		}
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
 			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
368 367
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
369 368
 			{
370
-				$event['recur_data'] = 1 << (int)date('w',$event['start']);
369
+				$event['recur_data'] = 1 << (int)date('w', $event['start']);
371 370
 			}
372 371
 			if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate']))
373 372
 			{
@@ -379,9 +378,9 @@  discard block
 block discarded – undo
379 378
 
380 379
 				$event['participants'] = $event['participant_types'] = array();
381 380
 
382
-				foreach($content['participants'] as $key => $data)
381
+				foreach ($content['participants'] as $key => $data)
383 382
 				{
384
-					switch($key)
383
+					switch ($key)
385 384
 					{
386 385
 						case 'delete':		// handled in default
387 386
 						case 'quantity':	// handled in new_resource
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
 						case 'status_date':
391 390
 							break;
392 391
 						case 'participant':
393
-							foreach($data as $participant)
392
+							foreach ($data as $participant)
394 393
 							{
395 394
 								if (is_null($participant))
396 395
 								{
@@ -399,17 +398,17 @@  discard block
 block discarded – undo
399 398
 
400 399
 								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
401 400
 								$email = array();
402
-								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
401
+								if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email))
403 402
 								{
404
-									$status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']);
405
-									if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data))
403
+									$status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']);
404
+									if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data))
406 405
 									{
407 406
 										$event['participants'][$data] = $event['participant_types']['u'][$data] = $status;
408 407
 									}
409
-									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array(
408
+									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array(
410 409
 										'email' => $email[2],
411 410
 										'email_home' => $email[2],
412
-									),true,'','','',false,'OR')))
411
+									), true, '', '', '', false, 'OR')))
413 412
 									{
414 413
 										$event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status;
415 414
 									}
@@ -420,7 +419,7 @@  discard block
 block discarded – undo
420 419
 								}
421 420
 								else
422 421
 								{
423
-									if(is_numeric($participant))
422
+									if (is_numeric($participant))
424 423
 									{
425 424
 										$uid = 'u'.$participant;
426 425
 										$id = $participant;
@@ -429,12 +428,12 @@  discard block
 block discarded – undo
429 428
 									else
430 429
 									{
431 430
 										$uid = $participant;
432
-										$id = substr($participant,1);
431
+										$id = substr($participant, 1);
433 432
 										$resource = $this->bo->resources[$participant[0]];
434 433
 									}
435
-									if(!$this->bo->check_acl_invite($uid))
434
+									if (!$this->bo->check_acl_invite($uid))
436 435
 									{
437
-										if(!$msg_permission_denied_added)
436
+										if (!$msg_permission_denied_added)
438 437
 										{
439 438
 											$msg .= lang('Permission denied!');
440 439
 											$msg_permission_denied_added = true;
@@ -444,19 +443,18 @@  discard block
 block discarded – undo
444 443
 
445 444
 									$type = $resource['type'];
446 445
 									$status = isset($this->bo->resources[$type]['new_status']) ?
447
-										ExecMethod($this->bo->resources[$type]['new_status'],$id) :
448
-										($uid == $this->bo->user ? 'A' : 'U');
446
+										ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U');
449 447
 
450 448
 									// Expand mailing lists
451
-									if($type == 'l')
449
+									if ($type == 'l')
452 450
 									{
453
-										foreach($this->bo->enum_mailing_list($participant) as $contact)
451
+										foreach ($this->bo->enum_mailing_list($participant) as $contact)
454 452
 										{
455 453
 											// Mailing lists can contain users, so allow for that possibility
456 454
 											$_type = is_numeric($contact) ? '' : $contact[0];
457
-											$_uid = is_numeric($contact) ? $contact : substr($contact,1);
455
+											$_uid = is_numeric($contact) ? $contact : substr($contact, 1);
458 456
 											$event['participants'][$contact] = $event['participant_types'][$_type][$_uid] =
459
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
457
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
460 458
 										}
461 459
 										continue;
462 460
 									}
@@ -466,8 +464,8 @@  discard block
 block discarded – undo
466 464
 										// todo check real availability = maximum - already booked quantity
467 465
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
468 466
 										{
469
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
470
-											foreach(array('quantity','resource','role') as $n)
467
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
468
+											foreach (array('quantity', 'resource', 'role') as $n)
471 469
 											{
472 470
 												$event['participants'][$n] = $content['participants'][$n];
473 471
 											}
@@ -476,7 +474,7 @@  discard block
 block discarded – undo
476 474
 										else
477 475
 										{
478 476
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
479
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
477
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
480 478
 										}
481 479
 									}
482 480
 								}
@@ -490,14 +488,14 @@  discard block
 block discarded – undo
490 488
 							break;
491 489
 
492 490
 						default:		// existing participant row
493
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
494
-							foreach(array('uid','status','quantity','role') as $name)
491
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
492
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
495 493
 							{
496 494
 								$$name = $data[$name];
497 495
 							}
498 496
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
499 497
 							{
500
-								$uid = false;	// entry has been deleted
498
+								$uid = false; // entry has been deleted
501 499
 							}
502 500
 							elseif ($uid)
503 501
 							{
@@ -508,7 +506,7 @@  discard block
 block discarded – undo
508 506
 								}
509 507
 								else
510 508
 								{
511
-									$id = substr($uid,1);
509
+									$id = substr($uid, 1);
512 510
 									$type = $uid[0];
513 511
 								}
514 512
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
@@ -516,20 +514,20 @@  discard block
 block discarded – undo
516 514
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
517 515
 									$quantity = $role = null;
518 516
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
519
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
517
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
520 518
 									{
521 519
 										// Update main window
522 520
 										$d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone);
523 521
 										$client_updated = $this->update_client($event['id'], $d);
524 522
 
525 523
 										// refreshing the calendar-view with the changed participant-status
526
-										if($event['recur_type'] != MCAL_RECUR_NONE)
524
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
527 525
 										{
528 526
 											$msg = lang('Status for all future scheduled days changed');
529 527
 										}
530 528
 										else
531 529
 										{
532
-											if(isset($content['edit_single']))
530
+											if (isset($content['edit_single']))
533 531
 											{
534 532
 												$msg = lang('Status for this particular day changed');
535 533
 												// prevent accidentally creating a real exception afterwards
@@ -550,7 +548,7 @@  discard block
 block discarded – undo
550 548
 										if ($status == 'R' && $event['alarm'])
551 549
 										{
552 550
 											// remove from bo->set_status deleted alarms of rejected users from UI too
553
-											foreach($event['alarm'] as $alarm_id => $alarm)
551
+											foreach ($event['alarm'] as $alarm_id => $alarm)
554 552
 											{
555 553
 												if ((string)$alarm['owner'] === (string)$uid)
556 554
 												{
@@ -563,7 +561,7 @@  discard block
 block discarded – undo
563 561
 								if ($uid && $status != 'G')
564 562
 								{
565 563
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
566
-										calendar_so::combine_status($status,$quantity,$role);
564
+										calendar_so::combine_status($status, $quantity, $role);
567 565
 								}
568 566
 							}
569 567
 							break;
@@ -582,26 +580,26 @@  discard block
 block discarded – undo
582 580
 			'tabs'			=> $content['tabs'],
583 581
 			'template'      => $content['template'],
584 582
 		);
585
-		$noerror=true;
583
+		$noerror = true;
586 584
 
587 585
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
588 586
 
589 587
 		$ignore_conflicts = $status_reset_to_unknown = false;
590 588
 
591
-		switch((string)$button)
589
+		switch ((string)$button)
592 590
 		{
593 591
 			case 'ignore':
594 592
 				$ignore_conflicts = true;
595
-				$button = $event['button_was'];	// save or apply
593
+				$button = $event['button_was']; // save or apply
596 594
 				unset($event['button_was']);
597 595
 				break;
598 596
 
599 597
 		}
600 598
 
601
-		switch((string)$button)
599
+		switch ((string)$button)
602 600
 		{
603 601
 		case 'exception':	// create an exception in a recuring event
604
-			$msg = $this->_create_exception($event,$preserv);
602
+			$msg = $this->_create_exception($event, $preserv);
605 603
 			break;
606 604
 
607 605
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -612,29 +610,29 @@  discard block
 block discarded – undo
612 610
 			unset($event['recurrence']);
613 611
 			unset($preserv['recurrence']);
614 612
 			unset($event['recur_exception']);
615
-			unset($event['edit_single']);	// in case it has been set
613
+			unset($event['edit_single']); // in case it has been set
616 614
 			unset($event['modified']);
617 615
 			unset($event['modifier']);
618 616
 			unset($event['caldav_name']);
619
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
617
+			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner'];
620 618
 
621 619
 			// Clear participant stati
622
-			foreach($event['participant_types'] as $type => &$participants)
620
+			foreach ($event['participant_types'] as $type => &$participants)
623 621
 			{
624
-				foreach($participants as $id => &$p_response)
622
+				foreach ($participants as $id => &$p_response)
625 623
 				{
626
-					if($type == 'u' && $id == $event['owner']) continue;
624
+					if ($type == 'u' && $id == $event['owner']) continue;
627 625
 					calendar_so::split_status($p_response, $quantity, $role);
628 626
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
629
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
630
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
627
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
628
+					$p_response = calendar_so::combine_status($status, $quantity, $role);
631 629
 				}
632 630
 			}
633 631
 
634 632
 			// Copy alarms
635 633
 			if (is_array($event['alarm']))
636 634
 			{
637
-				foreach($event['alarm'] as $n => &$alarm)
635
+				foreach ($event['alarm'] as $n => &$alarm)
638 636
 				{
639 637
 					unset($alarm['id']);
640 638
 					unset($alarm['cal_id']);
@@ -644,7 +642,7 @@  discard block
 block discarded – undo
644 642
 			// Get links to be copied
645 643
 			// With no ID, $content['link_to']['to_id'] is used
646 644
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
647
-			foreach(Link::get_links('calendar', $content['id']) as $link)
645
+			foreach (Link::get_links('calendar', $content['id']) as $link)
648 646
 			{
649 647
 				if ($link['app'] != Link::VFS_APPNAME)
650 648
 				{
@@ -670,7 +668,7 @@  discard block
 block discarded – undo
670 668
 		case 'print':
671 669
 		case 'apply':
672 670
 		case 'infolog':
673
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
671
+			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event))
674 672
 			{
675 673
 				$msg = lang('Permission denied');
676 674
 				$button = '';
@@ -688,7 +686,7 @@  discard block
 block discarded – undo
688 686
 				$button = '';
689 687
 				break;
690 688
 			}
691
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
689
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
692 690
 			{
693 691
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
694 692
 				$button = '';
@@ -718,14 +716,14 @@  discard block
 block discarded – undo
718 716
 				$event['reference'] = $event['id'];
719 717
 				$event['recurrence'] = $content['edit_single'];
720 718
 				unset($event['id']);
721
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
719
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
722 720
 				if (!is_array($conflicts) && $conflicts)
723 721
 				{
724 722
 					// now we need to add the original start as recur-execption to the series
725 723
 					$recur_event = $this->bo->read($event['reference']);
726 724
 					$recur_event['recur_exception'][] = $content['edit_single'];
727 725
 					// check if we need to move the alarms, because they are next on that exception
728
-					foreach($recur_event['alarm'] as $id => $alarm)
726
+					foreach ($recur_event['alarm'] as $id => $alarm)
729 727
 					{
730 728
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
731 729
 						{
@@ -741,11 +739,11 @@  discard block
 block discarded – undo
741 739
 							}
742 740
 						}
743 741
 					}
744
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
745
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
746
-					$this->bo->update($recur_event,true);	// no conflict check here
742
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
743
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
744
+					$this->bo->update($recur_event, true); // no conflict check here
747 745
 
748
-					if(Api\Json\Response::isJSONResponse())
746
+					if (Api\Json\Response::isJSONResponse())
749 747
 					{
750 748
 						// Sending null will trigger a removal of the original
751 749
 						// for that date
@@ -753,7 +751,7 @@  discard block
 block discarded – undo
753 751
 					}
754 752
 
755 753
 					unset($recur_event);
756
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
754
+					unset($event['edit_single']); // if we further edit it, it's just a single event
757 755
 					unset($preserv['edit_single']);
758 756
 				}
759 757
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -784,8 +782,8 @@  discard block
 block discarded – undo
784 782
 							{
785 783
 								$offset = $off2;
786 784
 							}
787
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
788
-							if($msg)
785
+							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']);
786
+							if ($msg)
789 787
 							{
790 788
 								$noerror = false;
791 789
 							}
@@ -798,10 +796,10 @@  discard block
 block discarded – undo
798 796
 							$event['whole_day'] != $old_event['whole_day'])
799 797
 						{
800 798
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
801
-							foreach((array)$event['participants'] as $uid => $status)
799
+							foreach ((array)$event['participants'] as $uid => $status)
802 800
 							{
803 801
 								$q = $r = null;
804
-								calendar_so::split_status($status,$q,$r);
802
+								calendar_so::split_status($status, $q, $r);
805 803
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
806 804
 								{
807 805
 									$preferences = new Api\Preferences($uid);
@@ -814,7 +812,7 @@  discard block
 block discarded – undo
814 812
 											if ($sameday) break;
815 813
 										default:
816 814
 											$status_reset_to_unknown = true;
817
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
815
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
818 816
 											// todo: report reset status to user
819 817
 									}
820 818
 								}
@@ -826,43 +824,43 @@  discard block
 block discarded – undo
826 824
 				}
827 825
 				// Adding participants needs to be done as an edit, in case we
828 826
 				// have participants visible in seperate calendars
829
-				if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
827
+				if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
830 828
 				{
831 829
 					$update_type = 'edit';
832 830
 				}
833 831
 				// Changing category may affect event filtering
834
-				if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
832
+				if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
835 833
 				{
836 834
 					$update_type = 'edit';
837 835
 				}
838
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
836
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
839 837
 				unset($event['ignore']);
840 838
 			}
841 839
 			if (is_array($conflicts))
842 840
 			{
843
-				$event['button_was'] = $button;	// remember for ignore
844
-				return $this->conflicts($event,$conflicts,$preserv);
841
+				$event['button_was'] = $button; // remember for ignore
842
+				return $this->conflicts($event, $conflicts, $preserv);
845 843
 			}
846 844
 
847 845
 			// Event spans multiple days, need an edit to make sure they all get updated
848 846
 			// We could check old date, as removing from days could still be an update
849
-			if(date('Ymd', $event['start']) != date('Ymd', $event['end']))
847
+			if (date('Ymd', $event['start']) != date('Ymd', $event['end']))
850 848
 			{
851 849
 				$update_type = 'edit';
852 850
 			}
853 851
 			// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
854 852
 			if ($messages)
855 853
 			{
856
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
854
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
857 855
 			}
858 856
 			if ($conflicts === 0)
859 857
 			{
860
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
861
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
862
-								htmlspecialchars(Egw::link('/index.php',array(
858
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
859
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
860
+								htmlspecialchars(Egw::link('/index.php', array(
863 861
 								'menuaction' => 'calendar.calendar_uiforms.edit',
864 862
 								'cal_id'    => $content['id'],
865
-							))).'">','</a>');
863
+							))).'">', '</a>');
866 864
 				$noerror = false;
867 865
 			}
868 866
 			elseif ($conflicts > 0)
@@ -884,19 +882,19 @@  discard block
 block discarded – undo
884 882
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
885 883
 						if ($alarm['time'] < $this->bo->now_su)
886 884
 						{
887
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
885
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
888 886
 							{
889
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
887
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
890 888
 							}
891 889
 							else
892 890
 							{
893
-								$alarm = false;	// no (further) recurence found --> ignore alarm
891
+								$alarm = false; // no (further) recurence found --> ignore alarm
894 892
 							}
895 893
 						}
896 894
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
897 895
 						elseif ($event_time < $event['start'])
898 896
 						{
899
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
897
+							$alarm['time'] = $event['start'] - $alarm['offset'];
900 898
 						}
901 899
 						if ($alarm)
902 900
 						{
@@ -905,9 +903,9 @@  discard block
 block discarded – undo
905 903
 						}
906 904
 					}
907 905
 					// attach all future exceptions to the new series
908
-					$events =& $this->bo->search(array(
906
+					$events = & $this->bo->search(array(
909 907
 						'query' => array('cal_uid' => $old_event['uid']),
910
-						'filter' => 'owner',  // return all possible entries
908
+						'filter' => 'owner', // return all possible entries
911 909
 						'daywise' => false,
912 910
 						'date_format' => 'ts',
913 911
 					));
@@ -918,7 +916,7 @@  discard block
 block discarded – undo
918 916
 							$exception['recurrence'] += $offset;
919 917
 							$exception['reference'] = $event['id'];
920 918
 							$exception['uid'] = $event['uid'];
921
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
919
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
922 920
 						}
923 921
 					}
924 922
 				}
@@ -926,12 +924,12 @@  discard block
 block discarded – undo
926 924
 				$message = lang('Event saved');
927 925
 				if ($status_reset_to_unknown)
928 926
 				{
929
-					foreach((array)$event['participants'] as $uid => $status)
927
+					foreach ((array)$event['participants'] as $uid => $status)
930 928
 					{
931 929
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
932 930
 						{
933
-							calendar_so::split_status($status,$q,$r);
934
-							$status = calendar_so::combine_status('U',$q,$r);
931
+							calendar_so::split_status($status, $q, $r);
932
+							$status = calendar_so::combine_status('U', $q, $r);
935 933
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
936 934
 						}
937 935
 					}
@@ -939,17 +937,17 @@  discard block
 block discarded – undo
939 937
 				}
940 938
 
941 939
 				$response = Api\Json\Response::get();
942
-				if($response && $update_type != 'delete')
940
+				if ($response && $update_type != 'delete')
943 941
 				{
944 942
 					$client_updated = $this->update_client($event['id']);
945 943
 				}
946 944
 
947
-				$msg = $message . ($msg ? ', ' . $msg : '');
945
+				$msg = $message.($msg ? ', '.$msg : '');
948 946
 				Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete');
949 947
 				// writing links for new entry, existing ones are handled by the widget itself
950 948
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
951 949
 				{
952
-					Link::link('calendar',$event['id'],$content['link_to']['to_id']);
950
+					Link::link('calendar', $event['id'], $content['link_to']['to_id']);
953 951
 				}
954 952
 			}
955 953
 			else
@@ -959,7 +957,7 @@  discard block
 block discarded – undo
959 957
 			break;
960 958
 
961 959
 		case 'cancel':
962
-			if($content['cancel_needs_refresh'])
960
+			if ($content['cancel_needs_refresh'])
963 961
 			{
964 962
 				Framework::refresh_opener($msg, 'calendar');
965 963
 			}
@@ -997,7 +995,7 @@  discard block
 block discarded – undo
997 995
 			{
998 996
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
999 997
 			}
1000
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
998
+			if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
1001 999
 			{
1002 1000
 				$alarm = array(
1003 1001
 					'offset' => $offset,
@@ -1011,13 +1009,13 @@  discard block
 block discarded – undo
1011 1009
 				}
1012 1010
 				elseif ($event['id'])	// save the alarm immediatly
1013 1011
 				{
1014
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1012
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
1015 1013
 					{
1016 1014
 						$alarm['id'] = $alarm_id;
1017 1015
 						$event['alarm'][$alarm_id] = $alarm;
1018 1016
 
1019 1017
 						$msg = lang('Alarm added');
1020
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1018
+						Framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
1021 1019
 					}
1022 1020
 					else
1023 1021
 					{
@@ -1026,7 +1024,7 @@  discard block
 block discarded – undo
1026 1024
 				}
1027 1025
 				else
1028 1026
 				{
1029
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1027
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1030 1028
 					$event['alarm'][$alarm['id']] = $alarm;
1031 1029
 				}
1032 1030
 			}
@@ -1043,31 +1041,31 @@  discard block
 block discarded – undo
1043 1041
 		}
1044 1042
 		// New event, send data before updating so it's there
1045 1043
 		$response = Api\Json\Response::get();
1046
-		if($response && !$content['id'] && $event['id'])
1044
+		if ($response && !$content['id'] && $event['id'])
1047 1045
 		{
1048 1046
 			$client_updated = $this->update_client($event['id']);
1049 1047
 		}
1050
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1048
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1051 1049
 		{
1052 1050
 			if ($content['lock_token'])	// remove an existing lock
1053 1051
 			{
1054
-				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1052
+				Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1055 1053
 			}
1056 1054
 			if ($content['no_popup'])
1057 1055
 			{
1058
-				Egw::redirect_link('/index.php',array(
1056
+				Egw::redirect_link('/index.php', array(
1059 1057
 					'menuaction' => 'calendar.calendar_uiviews.index',
1060 1058
 					'msg'        => $msg,
1061 1059
 				));
1062 1060
 			}
1063
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1061
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1064 1062
 			{
1065
-				Framework::refresh_opener($msg,'calendar');
1063
+				Framework::refresh_opener($msg, 'calendar');
1066 1064
 			}
1067 1065
 			else
1068 1066
 			{
1069 1067
 				Framework::refresh_opener($msg, 'calendar',
1070
-					$event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ),
1068
+					$event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''),
1071 1069
 					$button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete'
1072 1070
 				);
1073 1071
 			}
@@ -1075,7 +1073,7 @@  discard block
 block discarded – undo
1075 1073
 			exit();
1076 1074
 		}
1077 1075
 		unset($event['no_notifications']);
1078
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1076
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1079 1077
 	}
1080 1078
 
1081 1079
 	/**
@@ -1087,7 +1085,7 @@  discard block
 block discarded – undo
1087 1085
 	 * @param array &$preserv
1088 1086
 	 * @return string message that exception was created
1089 1087
 	 */
1090
-	function _create_exception(&$event,&$preserv)
1088
+	function _create_exception(&$event, &$preserv)
1091 1089
 	{
1092 1090
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1093 1091
 		$preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1097,17 +1095,17 @@  discard block
 block discarded – undo
1097 1095
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1098 1096
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1099 1097
 		$event['recur_type'] = MCAL_RECUR_NONE;
1100
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1098
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1101 1099
 		{
1102 1100
 			unset($event[$name]);
1103 1101
 		}
1104 1102
 		// add all alarms as new alarms to execption
1105 1103
 		$event['alarm'] = array_values((array)$event['alarm']);
1106
-		foreach($event['alarm'] as &$alarm)
1104
+		foreach ($event['alarm'] as &$alarm)
1107 1105
 		{
1108 1106
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1109 1107
 		}
1110
-		if($this->bo->check_perms(Acl::EDIT,$event))
1108
+		if ($this->bo->check_perms(Acl::EDIT, $event))
1111 1109
 		{
1112 1110
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1113 1111
 		}
@@ -1134,14 +1132,14 @@  discard block
 block discarded – undo
1134 1132
 	{
1135 1133
 		$msg = false;
1136 1134
 
1137
-		if(!$as_of_date )
1135
+		if (!$as_of_date)
1138 1136
 		{
1139 1137
 			$as_of_date = time();
1140 1138
 		}
1141 1139
 
1142 1140
 		//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
1143 1141
 
1144
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1142
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1145 1143
 		{
1146 1144
 			$msg = lang("Error: You can't shift a series from the past!");
1147 1145
 			return $msg;
@@ -1154,11 +1152,11 @@  discard block
 block discarded – undo
1154 1152
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1155 1153
 
1156 1154
 		// base start-date of new series on actual / clicked date
1157
-		$event['start'] = $as_of_date ;
1155
+		$event['start'] = $as_of_date;
1158 1156
 
1159
-		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1157
+		if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') ||
1160 1158
 			// Adjust for requested date in the past
1161
-			Api\DateTime::to($as_of_date,'ts') < time()
1159
+			Api\DateTime::to($as_of_date, 'ts') < time()
1162 1160
 		)
1163 1161
 		{
1164 1162
 
@@ -1178,17 +1176,17 @@  discard block
 block discarded – undo
1178 1176
 				$rriter->next_no_exception();
1179 1177
 				$occurrence = $rriter->current();
1180 1178
 			}
1181
-			while ($rriter->valid()  && (
1179
+			while ($rriter->valid() && (
1182 1180
 				Api\DateTime::to($occurrence, 'ts') <= time() ||
1183
-				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
1181
+				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd')
1184 1182
 			) && ($last = $occurrence));
1185 1183
 
1186 1184
 
1187 1185
 			// Make sure as_of_date is still valid, may have to move forward
1188
-			if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
1186
+			if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') ||
1189 1187
 				Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
1190 1188
 			{
1191
-				$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
1189
+				$event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset;
1192 1190
 			}
1193 1191
 
1194 1192
 			//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
@@ -1196,7 +1194,7 @@  discard block
 block discarded – undo
1196 1194
 			{
1197 1195
 				$event['end'] = $event['start'] + $duration;
1198 1196
 			}
1199
-			elseif($event['end'] < $event['start'])
1197
+			elseif ($event['end'] < $event['start'])
1200 1198
 			{
1201 1199
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1202 1200
 			}
@@ -1205,7 +1203,7 @@  discard block
 block discarded – undo
1205 1203
 			$event['participants'] = $old_event['participants'];
1206 1204
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1207 1205
 			{
1208
-				if ($exdate > Api\DateTime::to($last,'ts'))
1206
+				if ($exdate > Api\DateTime::to($last, 'ts'))
1209 1207
 				{
1210 1208
 					//error_log("Moved exception on " . Api\DateTime::to($exdate));
1211 1209
 					unset($old_event['recur_exception'][$key]);
@@ -1219,18 +1217,18 @@  discard block
 block discarded – undo
1219 1217
 			}
1220 1218
 			$last->setTime(0, 0, 0);
1221 1219
 			$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
1222
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1220
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1223 1221
 			{
1224
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1225
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1226
-						htmlspecialchars(Egw::link('/index.php',array(
1222
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1223
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1224
+						htmlspecialchars(Egw::link('/index.php', array(
1227 1225
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1228 1226
 							'cal_id'    => $event['id'],
1229
-						))).'">','</a>');
1227
+						))).'">', '</a>');
1230 1228
 				$event = $orig_event;
1231 1229
 			}
1232 1230
 		}
1233
-		$event['start'] = Api\DateTime::to($event['start'],'ts');
1231
+		$event['start'] = Api\DateTime::to($event['start'], 'ts');
1234 1232
 		return $msg;
1235 1233
 	}
1236 1234
 
@@ -1241,11 +1239,11 @@  discard block
 block discarded – undo
1241 1239
 	 * @param boolean $added
1242 1240
 	 * @return string javascript window.open command
1243 1241
 	 */
1244
-	function ajax_custom_mail($event,$added,$asrequest=false)
1242
+	function ajax_custom_mail($event, $added, $asrequest = false)
1245 1243
 	{
1246 1244
 		$to = array();
1247 1245
 
1248
-		foreach($event['participants'] as $uid => $status)
1246
+		foreach ($event['participants'] as $uid => $status)
1249 1247
 		{
1250 1248
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1251 1249
 			if (empty($status)) continue;
@@ -1254,35 +1252,35 @@  discard block
 block discarded – undo
1254 1252
 
1255 1253
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1256 1254
 			{
1257
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1255
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1258 1256
 
1259 1257
 				$lid = $firstname = $lastname = null;
1260
-				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1258
+				$GLOBALS['egw']->accounts->get_account_name($status['uid'], $lid, $firstname, $lastname);
1261 1259
 
1262 1260
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1263
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1261
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1264 1262
 				//error_log(__METHOD__.__LINE__.array2string($to));
1265 1263
 			}
1266 1264
 			elseif ($uid < 0)
1267 1265
 			{
1268
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1266
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1269 1267
 				{
1270
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1268
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1271 1269
 
1272
-					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1270
+					$GLOBALS['egw']->accounts->get_account_name($uid, $lid, $firstname, $lastname);
1273 1271
 
1274 1272
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1275 1273
 					// dont add groupmembers if they already rejected the event, or are the current user
1276
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1274
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1277 1275
 					//error_log(__METHOD__.__LINE__.array2string($to));
1278 1276
 				}
1279 1277
 			}
1280
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1278
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1281 1279
 			{
1282 1280
 				$to[] = $info['email'];
1283 1281
 				//error_log(__METHOD__.__LINE__.array2string($to));
1284 1282
 			}
1285
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1283
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1286 1284
 			{
1287 1285
 				$to[] = $info['email'];
1288 1286
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1291,7 +1289,7 @@  discard block
 block discarded – undo
1291 1289
 		// prefer event description over standard notification text
1292 1290
 		if (empty($event['description']))
1293 1291
 		{
1294
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1292
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1295 1293
 		}
1296 1294
 		else
1297 1295
 		{
@@ -1306,12 +1304,12 @@  discard block
 block discarded – undo
1306 1304
 		$boical = new calendar_ical();
1307 1305
 		// we need to pass $event[id] so iCal class reads event again,
1308 1306
 		// as event is in user TZ, but iCal class expects server TZ!
1309
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1307
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1310 1308
 
1311
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1312
-		if(($f = fopen($ics_file,'w')))
1309
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1310
+		if (($f = fopen($ics_file, 'w')))
1313 1311
 		{
1314
-			fwrite($f,$ics);
1312
+			fwrite($f, $ics);
1315 1313
 			fclose($f);
1316 1314
 		}
1317 1315
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1323,7 +1321,7 @@  discard block
 block discarded – undo
1323 1321
 			'preset[body]'    => $body,
1324 1322
 			'preset[name]'    => 'event.ics',
1325 1323
 			'preset[file]'    => $ics_file,
1326
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1324
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1327 1325
 			'preset[size]'    => filesize($ics_file),
1328 1326
 		);
1329 1327
 		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
@@ -1379,7 +1377,7 @@  discard block
 block discarded – undo
1379 1377
 	 * @param mixed $link_to_id ='' from or for the link-widget
1380 1378
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1381 1379
 	 */
1382
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1380
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1383 1381
 	{
1384 1382
 		$sel_options = array(
1385 1383
 			'recur_type' => &$this->bo->recur_types,
@@ -1403,8 +1401,8 @@  discard block
 block discarded – undo
1403 1401
 				'no_popup' => isset($_GET['no_popup']),
1404 1402
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1405 1403
 			);
1406
-			$cal_id = (int) $_GET['cal_id'];
1407
-			if($_GET['action'])
1404
+			$cal_id = (int)$_GET['cal_id'];
1405
+			if ($_GET['action'])
1408 1406
 			{
1409 1407
 				$event = $this->bo->read($cal_id);
1410 1408
 				$event['action'] = $_GET['action'];
@@ -1422,14 +1420,14 @@  discard block
 block discarded – undo
1422 1420
 			{
1423 1421
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1424 1422
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1425
-				$event =& $this->default_add_event();
1423
+				$event = & $this->default_add_event();
1426 1424
 			}
1427 1425
 			if (!empty($_GET['ical_data']) &&
1428 1426
 				!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
1429 1427
 			{
1430 1428
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1431 1429
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1432
-				$event =& $this->default_add_event();
1430
+				$event = & $this->default_add_event();
1433 1431
 			}
1434 1432
 			if (!empty($_GET['ical']))
1435 1433
 			{
@@ -1438,14 +1436,14 @@  discard block
 block discarded – undo
1438 1436
 				{
1439 1437
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1440 1438
 					$msg = lang('Error: importing the iCal');
1441
-					$event =& $this->default_add_event();
1439
+					$event = & $this->default_add_event();
1442 1440
 				}
1443 1441
 				else
1444 1442
 				{
1445 1443
 					if (count($events) > 1)
1446 1444
 					{
1447 1445
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1448
-						$msg_type = 'notice';	// no not hide automatic
1446
+						$msg_type = 'notice'; // no not hide automatic
1449 1447
 					}
1450 1448
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1451 1449
 					$this->bo->db2data($events, 'ts');
@@ -1458,7 +1456,7 @@  discard block
 block discarded – undo
1458 1456
 					else
1459 1457
 					{
1460 1458
 						$event['participant_types'] = array();
1461
-						foreach($event['participants'] as $uid => $status)
1459
+						foreach ($event['participants'] as $uid => $status)
1462 1460
 						{
1463 1461
 							$user_type = $user_id = null;
1464 1462
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1479,15 +1477,15 @@  discard block
 block discarded – undo
1479 1477
 					}
1480 1478
 					else
1481 1479
 					{
1482
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1480
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1483 1481
 						exit();
1484 1482
 					}
1485 1483
 				}
1486
-				$event =& $this->default_add_event();
1484
+				$event = & $this->default_add_event();
1487 1485
 			}
1488 1486
 			else
1489 1487
 			{
1490
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1488
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1491 1489
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1492 1490
 				{
1493 1491
 					if (empty($event['whole_day']))
@@ -1500,10 +1498,10 @@  discard block
 block discarded – undo
1500 1498
 						$date->setUser();
1501 1499
 					}
1502 1500
 					$event = $this->bo->read($cal_id, $date, true);
1503
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1501
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1504 1502
 					if ($_GET['exception'])
1505 1503
 					{
1506
-						$msg = $this->_create_exception($event,$preserv);
1504
+						$msg = $this->_create_exception($event, $preserv);
1507 1505
 					}
1508 1506
 					else
1509 1507
 					{
@@ -1512,9 +1510,9 @@  discard block
 block discarded – undo
1512 1510
 				}
1513 1511
 			}
1514 1512
 			// set new start and end if given by $_GET
1515
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1516
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1517
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1513
+			if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); }
1514
+			if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); }
1515
+			if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1518 1516
 			// check if the event is the whole day
1519 1517
 			$start = $this->bo->date2array($event['start']);
1520 1518
 			$end = $this->bo->date2array($event['end']);
@@ -1524,30 +1522,30 @@  discard block
 block discarded – undo
1524 1522
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1525 1523
 			{
1526 1524
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1527
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1525
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1528 1526
 				{
1529 1527
 					$link_id = $link_ids[$n];
1530
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1528
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1531 1529
 					{
1532 1530
 						continue;
1533 1531
 					}
1534
-					if(!$n)
1532
+					if (!$n)
1535 1533
 					{
1536
-						$event['title'] = Link::title($link_app,$link_id);
1534
+						$event['title'] = Link::title($link_app, $link_id);
1537 1535
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1538
-						if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1536
+						if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1539 1537
 						{
1540
-							foreach((array)$set['link_app'] as $i => $l_app)
1538
+							foreach ((array)$set['link_app'] as $i => $l_app)
1541 1539
 							{
1542
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1540
+								if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1543 1541
 							}
1544 1542
 							unset($set['link_app']);
1545 1543
 							unset($set['link_id']);
1546 1544
 
1547
-							$event = array_merge($event,$set);
1545
+							$event = array_merge($event, $set);
1548 1546
 						}
1549 1547
 					}
1550
-					Link::link('calendar',$link_to_id,$link_app,$link_id);
1548
+					Link::link('calendar', $link_to_id, $link_app, $link_id);
1551 1549
 				}
1552 1550
 			}
1553 1551
 		}
@@ -1557,44 +1555,44 @@  discard block
 block discarded – undo
1557 1555
 		{
1558 1556
 			$etpl->read($preserv['template'] = 'calendar.edit');
1559 1557
 		}
1560
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
1558
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event);
1561 1559
 		//echo "view=$view, event="; _debug_array($event);
1562 1560
 		// shared locking of entries to edit
1563 1561
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1564 1562
 		{
1565
-			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1563
+			$lock_path = Vfs::app_entry_lock_path('calendar', $event['id']);
1566 1564
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1567 1565
 
1568 1566
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1569 1567
 			{
1570
-				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1568
+				Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1571 1569
 			}
1572 1570
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1573 1571
 			{
1574 1572
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1575
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1573
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1576 1574
 					Api\Accounts::username($lock_uid) : $lock['owner']));
1577 1575
 			}
1578
-			elseif($lock)
1576
+			elseif ($lock)
1579 1577
 			{
1580 1578
 				$preserv['lock_token'] = $lock['token'];
1581 1579
 			}
1582
-			elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1580
+			elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1583 1581
 			{
1584 1582
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1585 1583
 			}
1586 1584
 			else
1587 1585
 			{
1588
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1586
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1589 1587
 				$view = true;
1590 1588
 			}
1591 1589
 		}
1592
-		$content = array_merge($event,array(
1590
+		$content = array_merge($event, array(
1593 1591
 			'link_to' => array(
1594 1592
 				'to_id'  => $link_to_id,
1595 1593
 				'to_app' => 'calendar',
1596 1594
 			),
1597
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1595
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1598 1596
 			'tabs'   => $preserv['tabs'],
1599 1597
 			'view' => $view,
1600 1598
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1606,11 +1604,11 @@  discard block
 block discarded – undo
1606 1604
 		$row = 3;
1607 1605
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1608 1606
 		// preserve some ui elements, if set eg. under error-conditions
1609
-		foreach(array('quantity','resource','role') as $n)
1607
+		foreach (array('quantity', 'resource', 'role') as $n)
1610 1608
 		{
1611 1609
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1612 1610
 		}
1613
-		foreach($event['participant_types'] as $type => $participants)
1611
+		foreach ($event['participant_types'] as $type => $participants)
1614 1612
 		{
1615 1613
 			$name = 'accounts';
1616 1614
 			if (isset($this->bo->resources[$type]))
@@ -1619,17 +1617,17 @@  discard block
 block discarded – undo
1619 1617
 			}
1620 1618
 			// sort participants (in there group/app) by title
1621 1619
 			uksort($participants, array($this, 'uid_title_cmp'));
1622
-			foreach($participants as $id => $status)
1620
+			foreach ($participants as $id => $status)
1623 1621
 			{
1624 1622
 				$uid = $type == 'u' ? $id : $type.$id;
1625 1623
 				$quantity = $role = null;
1626
-				calendar_so::split_status($status,$quantity,$role);
1624
+				calendar_so::split_status($status, $quantity, $role);
1627 1625
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1628 1626
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1629 1627
 					'uid'      => $uid,
1630 1628
 					'status'   => $status,
1631 1629
 					'old_status' => $status,
1632
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1630
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1633 1631
 					'role'     => $role,
1634 1632
 				);
1635 1633
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1638,33 +1636,33 @@  discard block
 block discarded – undo
1638 1636
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1639 1637
 				}
1640 1638
 				// allow third party apps to use categories for roles
1641
-				elseif(substr($role,0,6) == 'X-CAT-')
1639
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1642 1640
 				{
1643
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1641
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1644 1642
 				}
1645 1643
 				else
1646 1644
 				{
1647
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1645
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1648 1646
 				}
1649
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1647
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1650 1648
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1651 1649
 
1652
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1650
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1653 1651
 					$readonlys['participants'][$row]['status'] = $no_status;
1654
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1652
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event))
1655 1653
 					$readonlys['participants']['delete'][$uid] = true;
1656 1654
 				// todo: make the participants available as links with email as title
1657 1655
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1658 1656
 				// enumerate group-invitations, so people can accept/reject them
1659 1657
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1660
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1658
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1661 1659
 				{
1662 1660
 					$sel_options['status']['G'] = lang('Select one');
1663 1661
 					// sort members by title
1664 1662
 					usort($members, array($this, 'uid_title_cmp'));
1665
-					foreach($members as $member)
1663
+					foreach ($members as $member)
1666 1664
 					{
1667
-						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
1665
+						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member))
1668 1666
 						{
1669 1667
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1670 1668
 								'app'      => 'Group invitation',
@@ -1673,7 +1671,7 @@  discard block
 block discarded – undo
1673 1671
 							);
1674 1672
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1675 1673
 							// read access is enough to invite participants, but you need edit rights to change status
1676
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
1674
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member);
1677 1675
 							$content['participants'][$row++]['title'] = Api\Accounts::username($member);
1678 1676
 						}
1679 1677
 					}
@@ -1681,43 +1679,43 @@  discard block
 block discarded – undo
1681 1679
 			}
1682 1680
 			// resouces / apps we shedule, atm. resources and addressbook
1683 1681
 			$content['participants']['cal_resources'] = '';
1684
-			foreach($this->bo->resources as $data)
1682
+			foreach ($this->bo->resources as $data)
1685 1683
 			{
1686
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1684
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1687 1685
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1688 1686
 			}
1689 1687
 		}
1690 1688
 		$content['participants']['status_date'] = $preserv['actual_date'];
1691
-		$preserved = array_merge($preserv,$content);
1689
+		$preserved = array_merge($preserv, $content);
1692 1690
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1693 1691
 		if ($event['alarm'])
1694 1692
 		{
1695 1693
 			// makes keys of the alarm-array starting with 1
1696 1694
 			$content['alarm'] = array(false);
1697
-			foreach(array_values($event['alarm']) as $id => $alarm)
1695
+			foreach (array_values($event['alarm']) as $id => $alarm)
1698 1696
 			{
1699
-				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
1697
+				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
1700 1698
 				{
1701
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1699
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1702 1700
 				}
1703
-				$alarm['all'] = (int) $alarm['all'];
1701
+				$alarm['all'] = (int)$alarm['all'];
1704 1702
 				$after = false;
1705
-				if($alarm['offset'] < 0)
1703
+				if ($alarm['offset'] < 0)
1706 1704
 				{
1707 1705
 					$after = true;
1708 1706
 					$alarm['offset'] = -1 * $alarm['offset'];
1709 1707
 				}
1710
-				$days = (int) ($alarm['offset'] / DAY_s);
1711
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1712
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1708
+				$days = (int)($alarm['offset'] / DAY_s);
1709
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1710
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1713 1711
 				$label = array();
1714 1712
 				if ($days) $label[] = $days.' '.lang('days');
1715 1713
 				if ($hours) $label[] = $hours.' '.lang('hours');
1716 1714
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1717
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1715
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1718 1716
 				$content['alarm'][] = $alarm;
1719 1717
 
1720
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1718
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1721 1719
 			}
1722 1720
 			if (count($content['alarm']) == 1)
1723 1721
 			{
@@ -1732,20 +1730,20 @@  discard block
 block discarded – undo
1732 1730
 
1733 1731
 		if ($view)
1734 1732
 		{
1735
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1733
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1736 1734
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1737 1735
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1738 1736
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1739 1737
 
1740 1738
 			$content['participants']['no_add'] = true;
1741 1739
 
1742
-			if(!$event['whole_day'])
1740
+			if (!$event['whole_day'])
1743 1741
 			{
1744 1742
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1745 1743
 			}
1746 1744
 
1747 1745
 			// respect category permissions
1748
-			if(!empty($event['category']))
1746
+			if (!empty($event['category']))
1749 1747
 			{
1750 1748
 				$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
1751 1749
 			}
@@ -1756,7 +1754,7 @@  discard block
 block discarded – undo
1756 1754
 
1757 1755
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1758 1756
 			{
1759
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1757
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1760 1758
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1761 1759
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1762 1760
 			}
@@ -1766,9 +1764,9 @@  discard block
 block discarded – undo
1766 1764
 				$readonlys['recur_interval'] = $readonlys['recur_data'] = true;
1767 1765
 			}
1768 1766
 		}
1769
-		if($content['category'] && !is_array($content['category']))
1767
+		if ($content['category'] && !is_array($content['category']))
1770 1768
 		{
1771
-			$content['category'] = explode(',',$event['category']);
1769
+			$content['category'] = explode(',', $event['category']);
1772 1770
 		}
1773 1771
 		// disabling the custom fields tab, if there are none
1774 1772
 		$readonlys['tabs'] = array(
@@ -1785,13 +1783,13 @@  discard block
 block discarded – undo
1785 1783
 		{
1786 1784
 			$readonlys['action'] = true;
1787 1785
 		}
1788
-		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1786
+		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate'])))
1789 1787
 		{
1790 1788
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1791 1789
 		}
1792
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1790
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event);
1793 1791
 
1794
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1792
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event))	// new event or edit rights to the event ==> allow to add alarm for all users
1795 1793
 		{
1796 1794
 			$sel_options['owner'][0] = lang('All participants');
1797 1795
 		}
@@ -1799,25 +1797,25 @@  discard block
 block discarded – undo
1799 1797
 		{
1800 1798
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1801 1799
 		}
1802
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1800
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1803 1801
 		{
1804
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
1802
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid))
1805 1803
 			{
1806 1804
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1807 1805
 			}
1808 1806
 		}
1809
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1807
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1810 1808
 		if (!$event['id'])
1811 1809
 		{
1812
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1810
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1813 1811
 		}
1814 1812
 		if ($preserved['no_popup'])
1815 1813
 		{
1816
-			$etpl->set_cell_attribute('button[cancel]','onclick','');
1814
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', '');
1817 1815
 		}
1818 1816
 
1819 1817
 		// Allow admins to restore deleted events
1820
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1818
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1821 1819
 		{
1822 1820
 			$content['deleted'] = $preserved['deleted'] = null;
1823 1821
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1829,7 +1827,7 @@  discard block
 block discarded – undo
1829 1827
 		// Setup history tab
1830 1828
 		$this->setup_history($content, $sel_options);
1831 1829
 
1832
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1830
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1833 1831
 			. (!$event['id'] ? lang('Add')
1834 1832
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1835 1833
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1839,15 +1837,15 @@  discard block
 block discarded – undo
1839 1837
 		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1840 1838
 
1841 1839
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1842
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1840
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1843 1841
 		{
1844
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1842
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1845 1843
 			$content['button']['save'] = true;
1846
-			$this->process_edit(array_merge($content,$preserved));
1844
+			$this->process_edit(array_merge($content, $preserved));
1847 1845
 		}
1848 1846
 		else
1849 1847
 		{
1850
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1848
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1851 1849
 		}
1852 1850
 	}
1853 1851
 
@@ -1857,14 +1855,14 @@  discard block
 block discarded – undo
1857 1855
 	 * @param int $id
1858 1856
 	 * @param string $token
1859 1857
 	 */
1860
-	function ajax_unlock($id,$token)
1858
+	function ajax_unlock($id, $token)
1861 1859
 	{
1862
-		$lock_path = Vfs::app_entry_lock_path('calendar',$id);
1860
+		$lock_path = Vfs::app_entry_lock_path('calendar', $id);
1863 1861
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1864 1862
 
1865 1863
 		if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1866 1864
 		{
1867
-			Vfs::unlock($lock_path,$token,false);
1865
+			Vfs::unlock($lock_path, $token, false);
1868 1866
 		}
1869 1867
 	}
1870 1868
 
@@ -1876,17 +1874,17 @@  discard block
 block discarded – undo
1876 1874
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1877 1875
 	 * @param string $msg = null
1878 1876
 	 */
1879
-	function meeting(array $event=null, $msg=null)
1877
+	function meeting(array $event = null, $msg = null)
1880 1878
 	{
1881 1879
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1882 1880
 		$readonlys['button[apply]'] = true;
1883
-		$_usesession=!is_array($event);
1881
+		$_usesession = !is_array($event);
1884 1882
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1885 1883
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1886
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1884
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1887 1885
 		{
1888
-			$event=null; // set to null
1889
-			$_usesession=true; // trigger session read
1886
+			$event = null; // set to null
1887
+			$_usesession = true; // trigger session read
1890 1888
 		}
1891 1889
 		if (!is_array($event))
1892 1890
 		{
@@ -1915,7 +1913,7 @@  discard block
 block discarded – undo
1915 1913
 
1916 1914
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1917 1915
 			{
1918
-				switch(strtolower($ical_method))
1916
+				switch (strtolower($ical_method))
1919 1917
 				{
1920 1918
 					case 'reply':
1921 1919
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -1969,19 +1967,19 @@  discard block
 block discarded – undo
1969 1967
 			}
1970 1968
 			else	// event not in calendar
1971 1969
 			{
1972
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
1970
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
1973 1971
 			}
1974 1972
 			$event['participant_types'] = array();
1975
-			foreach($event['participants'] as $uid => $status)
1973
+			foreach ($event['participants'] as $uid => $status)
1976 1974
 			{
1977 1975
 				$user_type = $user_id = null;
1978 1976
 				calendar_so::split_user($uid, $user_type, $user_id);
1979 1977
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
1980
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
1978
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
1981 1979
 			}
1982 1980
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
1983 1981
 			$event['recure'] = $this->bo->recure2string($event);
1984
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
1982
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
1985 1983
 
1986 1984
 			// ignore events in the past (for recurring events check enddate!)
1987 1985
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -2001,23 +1999,23 @@  discard block
 block discarded – undo
2001 1999
 			// clear notification errors
2002 2000
 			notifications::errors(true);
2003 2001
 
2004
-			switch($button)
2002
+			switch ($button)
2005 2003
 			{
2006 2004
 				case 'reject':
2007 2005
 					if (!$event['id'])
2008 2006
 					{
2009 2007
 						// send reply to organizer
2010
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
2011
-						break;	// no need to store rejected event
2008
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
2009
+						break; // no need to store rejected event
2012 2010
 					}
2013 2011
 					// fall-through
2014 2012
 				case 'accept':
2015 2013
 				case 'tentativ':
2016
-					$status = strtoupper($button[0]);	// A, R or T
2014
+					$status = strtoupper($button[0]); // A, R or T
2017 2015
 					if (!$event['id'])
2018 2016
 					{
2019 2017
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
2020
-						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
2018
+						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner']))
2021 2019
 						{
2022 2020
 							// --> make organize a participant with role chair and current user the owner
2023 2021
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -2025,7 +2023,7 @@  discard block
 block discarded – undo
2025 2023
 							$event['owner'] = $this->user;
2026 2024
 						}
2027 2025
 						// store event without notifications!
2028
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
2026
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
2029 2027
 						{
2030 2028
 							$msg[] = lang('Event saved');
2031 2029
 						}
@@ -2063,7 +2061,7 @@  discard block
 block discarded – undo
2063 2061
 		Framework::message(implode("\n", (array)$msg));
2064 2062
 		$readonlys['button[edit]'] = !$event['id'];
2065 2063
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2066
-		switch(strtolower($ical_method))
2064
+		switch (strtolower($ical_method))
2067 2065
 		{
2068 2066
 			case 'reply':
2069 2067
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2087,37 +2085,37 @@  discard block
 block discarded – undo
2087 2085
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2088 2086
 	 * @param array $preserv data to preserv
2089 2087
 	 */
2090
-	function conflicts($event,$conflicts,$preserv)
2088
+	function conflicts($event, $conflicts, $preserv)
2091 2089
 	{
2092 2090
 		$etpl = new Etemplate('calendar.conflicts');
2093 2091
 		$allConflicts = array();
2094 2092
 
2095
-		foreach($conflicts as $k => $conflict)
2093
+		foreach ($conflicts as $k => $conflict)
2096 2094
 		{
2097
-			$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
2095
+			$is_readable = $this->bo->check_perms(Acl::READ, $conflict);
2098 2096
 
2099 2097
 			$conflicts[$k] += array(
2100 2098
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2101
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2102
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2103
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2104
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2105
-				),true,true)),	// show group invitations too
2099
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2100
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2101
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2102
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2103
+				), true, true)), // show group invitations too
2106 2104
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2107 2105
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2108 2106
 			);
2109
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2107
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2110 2108
 			}
2111 2109
 		$content = $event + array(
2112
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2110
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2113 2111
 		);
2114
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2112
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2115 2113
 		$resources_config = Api\Config::read('resources');
2116 2114
 		$readonlys = array();
2117 2115
 
2118 2116
 		foreach (array_keys($allConflicts) as $pId)
2119 2117
 		{
2120
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2118
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2121 2119
 			{
2122 2120
 
2123 2121
 				switch ($resources_config['ignoreconflicts'])
@@ -2137,7 +2135,7 @@  discard block
 block discarded – undo
2137 2135
 				}
2138 2136
 			}
2139 2137
 		}
2140
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2138
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2141 2139
 	}
2142 2140
 
2143 2141
 	/**
@@ -2155,7 +2153,7 @@  discard block
 block discarded – undo
2155 2153
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2156 2154
 
2157 2155
 		// convert start/end date-time values to timestamps
2158
-		foreach(array('start', 'end') as $name)
2156
+		foreach (array('start', 'end') as $name)
2159 2157
 		{
2160 2158
 			if (!empty($edit_content[$name]))
2161 2159
 			{
@@ -2185,7 +2183,7 @@  discard block
 block discarded – undo
2185 2183
 			'recur_type'   => $edit_content['recur_type'],
2186 2184
 			'participants' => array(),
2187 2185
 		);
2188
-		foreach($edit_content['participants'] as $key => $data)
2186
+		foreach ($edit_content['participants'] as $key => $data)
2189 2187
 		{
2190 2188
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2191 2189
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2200,21 +2198,21 @@  discard block
 block discarded – undo
2200 2198
 		// default search parameters
2201 2199
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2202 2200
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2203
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2201
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2204 2202
 		{
2205
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2203
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2206 2204
 		}
2207 2205
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2208 2206
 
2209 2207
 		$content['search_window'] = 7 * DAY_s;
2210 2208
 
2211 2209
 		// store content in session
2212
-		Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2210
+		Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2213 2211
 
2214 2212
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2215
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2213
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2216 2214
 
2217
-		$response->call('app.calendar.freetime_search_popup',$link);
2215
+		$response->call('app.calendar.freetime_search_popup', $link);
2218 2216
 
2219 2217
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2220 2218
 
@@ -2237,26 +2235,26 @@  discard block
 block discarded – undo
2237 2235
 	{
2238 2236
 		$etpl = new Etemplate('calendar.freetimesearch');
2239 2237
 		$sel_options['search_window'] = array(
2240
-			7*DAY_s		=> lang('one week'),
2241
-			14*DAY_s	=> lang('two weeks'),
2242
-			31*DAY_s	=> lang('one month'),
2243
-			92*DAY_s	=> lang('three month'),
2244
-			365*DAY_s	=> lang('one year'),
2238
+			7 * DAY_s		=> lang('one week'),
2239
+			14 * DAY_s	=> lang('two weeks'),
2240
+			31 * DAY_s	=> lang('one month'),
2241
+			92 * DAY_s	=> lang('three month'),
2242
+			365 * DAY_s	=> lang('one year'),
2245 2243
 		);
2246 2244
 		if (!is_array($content))
2247 2245
 		{
2248 2246
 			// get content from session (and delete it immediatly)
2249
-			$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2250
-			Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2247
+			$content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2248
+			Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2251 2249
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2252 2250
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2253 2251
 			$sTime = $content['start_time'];
2254 2252
 			$eTime = $content['end_time'];
2255
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2256
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2253
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2254
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2257 2255
 
2258 2256
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2259
-			foreach(array_keys($sel_options['search_window']) as $window)
2257
+			foreach (array_keys($sel_options['search_window']) as $window)
2260 2258
 			{
2261 2259
 				if ($window > $content['duration'])
2262 2260
 				{
@@ -2283,19 +2281,19 @@  discard block
 block discarded – undo
2283 2281
 		{
2284 2282
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2285 2283
 		}
2286
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2287
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2284
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2285
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2288 2286
 
2289
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2287
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2290 2288
 
2291 2289
 		$sel_options['duration'] = $this->durations;
2292 2290
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2293 2291
 
2294
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2292
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2295 2293
 				'participants'	=> $content['participants'],
2296 2294
 				'cal_id'		=> $content['cal_id'],
2297 2295
 				'recur_type'	=> $content['recur_type'],
2298
-			),2);
2296
+			), 2);
2299 2297
 	}
2300 2298
 
2301 2299
 	/**
@@ -2308,15 +2306,15 @@  discard block
 block discarded – undo
2308 2306
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2309 2307
 	 * @return array of free time-slots: array with start and end values
2310 2308
 	 */
2311
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2309
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2312 2310
 	{
2313
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2311
+		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id);
2314 2312
 
2315 2313
 		$busy = $this->bo->search(array(
2316 2314
 			'start' => $start,
2317 2315
 			'end'	=> $end,
2318 2316
 			'users'	=> $participants,
2319
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2317
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2320 2318
 		));
2321 2319
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2322 2320
 			'start'	=> $end,
@@ -2325,15 +2323,15 @@  discard block
 block discarded – undo
2325 2323
 		$ft_start = $start;
2326 2324
 		$freetime = array();
2327 2325
 		$n = 0;
2328
-		foreach($busy as $event)
2326
+		foreach ($busy as $event)
2329 2327
 		{
2330
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2328
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2331 2329
 
2332 2330
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2333 2331
 
2334 2332
 			// check if from all wanted participants at least one has a not rejected status in found event
2335 2333
 			$non_rejected_found = false;
2336
-			foreach($participants as $uid)
2334
+			foreach ($participants as $uid)
2337 2335
 			{
2338 2336
 				if ($event['participants'][$uid] == 'R') continue;
2339 2337
 
@@ -2349,10 +2347,10 @@  discard block
 block discarded – undo
2349 2347
 
2350 2348
 			if ($this->debug)
2351 2349
 			{
2352
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2350
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2353 2351
 				echo "event[title]=$event[title]<br>\n";
2354
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2355
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2352
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2353
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2356 2354
 			}
2357 2355
 			// $events ends before our actual position ==> ignore it
2358 2356
 			if ($event['end'] < $ft_start)
@@ -2376,11 +2374,11 @@  discard block
 block discarded – undo
2376 2374
 					'start'	=> $ft_start,
2377 2375
 					'end'	=> $ft_end,
2378 2376
 				);
2379
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2377
+				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n";
2380 2378
 			}
2381 2379
 			$ft_start = $event['end'];
2382 2380
 		}
2383
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2381
+		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime);
2384 2382
 
2385 2383
 		return $freetime;
2386 2384
 	}
@@ -2400,46 +2398,46 @@  discard block
 block discarded – undo
2400 2398
 	 */
2401 2399
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2402 2400
 	{
2403
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2401
+		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time);
2404 2402
 
2405 2403
 		$freetime_daywise = array();
2406 2404
 		if (!is_array($sel_options)) $sel_options = array();
2407 2405
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2408 2406
 
2409
-		$start_time = (int) $_start_time;	// ignore leading zeros
2410
-		$end_time   = (int) $_end_time;
2407
+		$start_time = (int)$_start_time; // ignore leading zeros
2408
+		$end_time   = (int)$_end_time;
2411 2409
 
2412 2410
 		// ignore the end_time, if duration would never fit
2413
-		if (($end_time - $start_time)*HOUR_s < $duration)
2411
+		if (($end_time - $start_time) * HOUR_s < $duration)
2414 2412
 		{
2415 2413
 			$end_time = 0;
2416
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2414
+			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time);
2417 2415
 		}
2418 2416
 		$n = 0;
2419
-		foreach($freetime as $ft)
2417
+		foreach ($freetime as $ft)
2420 2418
 		{
2421 2419
 			$adaybegin = $this->bo->date2array($ft['start']);
2422 2420
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2423 2421
 			unset($adaybegin['raw']);
2424 2422
 			$daybegin = $this->bo->date2ts($adaybegin);
2425 2423
 
2426
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2424
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2427 2425
 			{
2428
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2429
-				$mcal_dow = pow(2,$dow);
2430
-				if (!($weekdays & $mcal_dow))
2426
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2427
+				$mcal_dow = pow(2, $dow);
2428
+				if (!($weekdays&$mcal_dow))
2431 2429
 				{
2432 2430
 					//echo "wrong day of week $dow<br>\n";
2433
-					continue;	// wrong day of week
2431
+					continue; // wrong day of week
2434 2432
 				}
2435 2433
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2436 2434
 
2437
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2435
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2438 2436
 				{
2439
-					$start = $daybegin + $start_time*HOUR_s;
2437
+					$start = $daybegin + $start_time * HOUR_s;
2440 2438
 				}
2441 2439
 				// if end_time given use it, else the original slot's end
2442
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2440
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2443 2441
 				if ($end > $ft['end']) $end = $ft['end'];
2444 2442
 
2445 2443
 				// slot to small for duration
@@ -2453,11 +2451,11 @@  discard block
 block discarded – undo
2453 2451
 					'end'	=> $end,
2454 2452
 				);
2455 2453
 				$times = array();
2456
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2454
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2457 2455
 				{
2458 2456
 					$e = $s + $duration;
2459
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2460
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2457
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2458
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2461 2459
 				}
2462 2460
 				$sel_options[$n.'start'] = $times;
2463 2461
 			}
@@ -2472,13 +2470,13 @@  discard block
 block discarded – undo
2472 2470
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2473 2471
      * @return string error-msg if $return_error
2474 2472
      */
2475
-    function export($content=0,$return_error=false)
2473
+    function export($content = 0, $return_error = false)
2476 2474
     {
2477 2475
 		$boical = new calendar_ical();
2478 2476
 		#error_log(__METHOD__.print_r($content,true));
2479 2477
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2480 2478
 		{
2481
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2479
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2482 2480
 			{
2483 2481
 				$msg = lang('Permission denied');
2484 2482
 
@@ -2486,20 +2484,20 @@  discard block
 block discarded – undo
2486 2484
 			}
2487 2485
 			else
2488 2486
 			{
2489
-				html::content_header('event.ics','text/calendar',bytes($ical));
2487
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2490 2488
 				echo $ical;
2491 2489
 				common::egw_exit();
2492 2490
 			}
2493 2491
 		}
2494 2492
 		if (is_array($content))
2495 2493
 		{
2496
-			$events =& $this->bo->search(array(
2494
+			$events = & $this->bo->search(array(
2497 2495
 				'start' => $content['start'],
2498 2496
 				'end'   => $content['end'],
2499 2497
 				'enum_recuring' => false,
2500 2498
 				'daywise'       => false,
2501 2499
 				'owner'         => $this->owner,
2502
-				'date_format'   => 'server',    // timestamp in server time for boical class
2500
+				'date_format'   => 'server', // timestamp in server time for boical class
2503 2501
 			));
2504 2502
 			if (!$events)
2505 2503
 			{
@@ -2507,8 +2505,8 @@  discard block
 block discarded – undo
2507 2505
 			}
2508 2506
 			else
2509 2507
 			{
2510
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2511
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2508
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2509
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2512 2510
 				echo $ical;
2513 2511
 				common::egw_exit();
2514 2512
 			}
@@ -2524,9 +2522,9 @@  discard block
 block discarded – undo
2524 2522
 		}
2525 2523
 		$content['msg'] = $msg;
2526 2524
 
2527
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2525
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2528 2526
 		$etpl = new etemplate_new('calendar.export');
2529
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2527
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2530 2528
     }
2531 2529
 
2532 2530
 	/**
@@ -2534,7 +2532,7 @@  discard block
 block discarded – undo
2534 2532
 	 *
2535 2533
 	 * @param array $_content
2536 2534
 	 */
2537
-	function cat_acl(array $_content=null)
2535
+	function cat_acl(array $_content = null)
2538 2536
 	{
2539 2537
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2540 2538
 		{
@@ -2546,15 +2544,15 @@  discard block
 block discarded – undo
2546 2544
 			unset($_content['button']);
2547 2545
 			if ($button != 'cancel')	// store changed Acl
2548 2546
 			{
2549
-				foreach($_content as $data)
2547
+				foreach ($_content as $data)
2550 2548
 				{
2551 2549
 					if (!($cat_id = $data['cat_id'])) continue;
2552
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2550
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2553 2551
 					{
2554 2552
 						$rights = 0;
2555
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2556
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2557
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2553
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2554
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2555
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2558 2556
 					}
2559 2557
 				}
2560 2558
 			}
@@ -2566,20 +2564,20 @@  discard block
 block discarded – undo
2566 2564
 				), 'admin');
2567 2565
 			}
2568 2566
 		}
2569
-		$content= $preserv = array();
2567
+		$content = $preserv = array();
2570 2568
 		$n = 1;
2571
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2569
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2572 2570
 		{
2573
-			$cat_id = substr($Lcat_id,1);
2571
+			$cat_id = substr($Lcat_id, 1);
2574 2572
 			$row = array(
2575 2573
 				'cat_id' => $cat_id,
2576 2574
 				'add' => array(),
2577 2575
 				'status' => array(),
2578 2576
 			);
2579
-			foreach($data as $account_id => $rights)
2577
+			foreach ($data as $account_id => $rights)
2580 2578
 			{
2581
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2582
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2579
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2580
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2583 2581
 			}
2584 2582
 			$content[$n] = $row;
2585 2583
 			$preserv[$n] = array(
@@ -2595,7 +2593,7 @@  discard block
 block discarded – undo
2595 2593
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2596 2594
 		$tmp = new Etemplate('calendar.cat_acl');
2597 2595
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2598
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2596
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2599 2597
 	}
2600 2598
 
2601 2599
 	/**
@@ -2645,18 +2643,18 @@  discard block
 block discarded – undo
2645 2643
 
2646 2644
 
2647 2645
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2648
-		if($content['recur_type'] || $content['recurrence'])
2646
+		if ($content['recur_type'] || $content['recurrence'])
2649 2647
 		{
2650 2648
 			$content['history']['filter'] = array(
2651 2649
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2652
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2653
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2650
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2651
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2654 2652
 			);
2655 2653
 		}
2656 2654
 
2657 2655
 		// Translate labels
2658 2656
 		$tracking = new calendar_tracking();
2659
-		foreach($tracking->field2label as $field => $label)
2657
+		foreach ($tracking->field2label as $field => $label)
2660 2658
 		{
2661 2659
 			$sel_options[$status][$field] = lang($label);
2662 2660
 		}
@@ -2675,44 +2673,44 @@  discard block
 block discarded – undo
2675 2673
 	 *	which particular instance was dragged
2676 2674
 	 * @return string XML response if no error occurs
2677 2675
 	 */
2678
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2676
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2679 2677
 	{
2680
-		list($eventId, $date) = explode(':', $_eventId,2);
2678
+		list($eventId, $date) = explode(':', $_eventId, 2);
2681 2679
 		$ignore_conflicts = false;
2682 2680
 
2683 2681
 		// we do not allow dragging into another users calendar ATM
2684
-		if($targetOwner < 0)
2682
+		if ($targetOwner < 0)
2685 2683
 		{
2686 2684
 			$targetOwner = array($targetOwner);
2687 2685
 		}
2688
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2686
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2689 2687
 		{
2690 2688
 			$targetOwner = $calendarOwner;
2691 2689
 		}
2692 2690
 		// But you may be viewing multiple users, or a group calendar and
2693 2691
 		// dragging your event - dragging across calendars does not change owner
2694
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2692
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2695 2693
 		{
2696 2694
 			$return = true;
2697
-			foreach($targetOwner as $owner)
2695
+			foreach ($targetOwner as $owner)
2698 2696
 			{
2699
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2697
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2700 2698
 				{
2701 2699
 					$return = false;
2702 2700
 					break;
2703 2701
 				}
2704
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2702
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2705 2703
 				{
2706 2704
 					$return = false;
2707 2705
 					break;
2708 2706
 				}
2709 2707
 			}
2710
-			if($return) return;
2708
+			if ($return) return;
2711 2709
 		}
2712
-		$old_event=$event=$this->bo->read($eventId);
2710
+		$old_event = $event = $this->bo->read($eventId);
2713 2711
 		if (!$durationT)
2714 2712
 		{
2715
-			$duration=$event['end']-$event['start'];
2713
+			$duration = $event['end'] - $event['start'];
2716 2714
 		}
2717 2715
 		// Drag a normal event to whole day non-blocking
2718 2716
 		else if ($durationT == 'whole_day')
@@ -2720,7 +2718,7 @@  discard block
 block discarded – undo
2720 2718
 			$event['whole_day'] = true;
2721 2719
 			$event['non_blocking'] = true;
2722 2720
 			// Make duration whole days, less 1 second
2723
-			$duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1;
2721
+			$duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1;
2724 2722
 		}
2725 2723
 		else
2726 2724
 		{
@@ -2733,18 +2731,18 @@  discard block
 block discarded – undo
2733 2731
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2734 2732
 			if (!empty($event['whole_day']))
2735 2733
 			{
2736
-				$d =& $this->bo->so->startOfDay($d);
2734
+				$d = & $this->bo->so->startOfDay($d);
2737 2735
 				$d->setUser();
2738 2736
 			}
2739 2737
 			$event = $this->bo->read($eventId, $d, true);
2740 2738
 
2741 2739
 			// For DnD, create an exception if they gave the date
2742 2740
 			$preserv = null;
2743
-			$this->_create_exception($event,$preserv);
2741
+			$this->_create_exception($event, $preserv);
2744 2742
 			unset($event['id']);
2745 2743
 
2746 2744
 			$messages = null;
2747
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2745
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2748 2746
 			if (!is_array($conflicts) && $conflicts)
2749 2747
 			{
2750 2748
 				// now we need to add the original start as recur-execption to the series
@@ -2752,28 +2750,28 @@  discard block
 block discarded – undo
2752 2750
 				$recur_event['recur_exception'][] = $d->format('ts');
2753 2751
 				// check if we need to move the alarms, because they are next on that exception
2754 2752
 				$this->bo->check_move_alarms($recur_event, null, $d);
2755
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2756
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2757
-				$this->bo->update($recur_event,true);	// no conflict check here
2753
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2754
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2755
+				$this->bo->update($recur_event, true); // no conflict check here
2758 2756
 
2759 2757
 				// Sending null will trigger a removal of the original for that date
2760 2758
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2761 2759
 
2762 2760
 				unset($recur_event);
2763
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2761
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2764 2762
 				unset($preserv['edit_single']);
2765 2763
 			}
2766 2764
 		}
2767 2765
 
2768 2766
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2769 2767
 		$event['start'] = $d->format('ts');
2770
-		$event['end'] = $event['start']+$duration;
2768
+		$event['end'] = $event['start'] + $duration;
2771 2769
 
2772 2770
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2773 2771
 		{
2774 2772
 			// calculate offset against clicked recurrance,
2775 2773
 			// depending on which is smaller
2776
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2774
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2777 2775
 			$event['start'] = $old_event['start'] + $offset;
2778 2776
 			$event['duration'] = $duration;
2779 2777
 
@@ -2784,31 +2782,31 @@  discard block
 block discarded – undo
2784 2782
 			// Can't handle conflict.  Just ignore it.
2785 2783
 			$ignore_conflicts = true;
2786 2784
 		}
2787
-		if(!$event['recur_type'])
2785
+		if (!$event['recur_type'])
2788 2786
 		{
2789 2787
 			$this->bo->check_move_alarms($event, $old_event);
2790 2788
 		}
2791 2789
 
2792 2790
 		// Drag a whole day to a time
2793
-		if($durationT && $durationT != 'whole_day')
2791
+		if ($durationT && $durationT != 'whole_day')
2794 2792
 		{
2795 2793
 			$event['whole_day'] = ($duration == DAY_s);
2796 2794
 			$event['non_blocking'] = false;
2797 2795
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2798 2796
 			// so save the change now, and then let the conflict check happen.
2799 2797
 			$message = null;
2800
-			$this->bo->update($event,true, true, false, true, $message,true);
2798
+			$this->bo->update($event, true, true, false, true, $message, true);
2801 2799
 
2802 2800
 			// Whole day non blocking with DAY_s would add a day
2803
-			if($duration==DAY_s) $duration=0;
2801
+			if ($duration == DAY_s) $duration = 0;
2804 2802
 		}
2805 2803
 
2806 2804
 		$status_reset_to_unknown = false;
2807 2805
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2808
-		foreach((array)$event['participants'] as $uid => $status)
2806
+		foreach ((array)$event['participants'] as $uid => $status)
2809 2807
 		{
2810 2808
 			$q = $r = null;
2811
-			calendar_so::split_status($status,$q,$r);
2809
+			calendar_so::split_status($status, $q, $r);
2812 2810
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2813 2811
 			{
2814 2812
 				$preferences = new Api\Preferences($uid);
@@ -2821,23 +2819,23 @@  discard block
 block discarded – undo
2821 2819
 						if ($sameday) break;
2822 2820
 					default:
2823 2821
 						$status_reset_to_unknown = true;
2824
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2822
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2825 2823
 						// todo: report reset status to user
2826 2824
 				}
2827 2825
 			}
2828 2826
 		}
2829 2827
 
2830 2828
 		$message = false;
2831
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2829
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2832 2830
 
2833
-		$this->update_client($event['id'],$d);
2831
+		$this->update_client($event['id'], $d);
2834 2832
 		$response = Api\Json\Response::get();
2835
-		if(!is_array($conflicts) && $conflicts)
2833
+		if (!is_array($conflicts) && $conflicts)
2836 2834
 		{
2837
-			if(is_int($conflicts))
2835
+			if (is_int($conflicts))
2838 2836
 			{
2839 2837
 				$event['id'] = $conflicts;
2840
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2838
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2841 2839
 			}
2842 2840
 		}
2843 2841
 		else if ($conflicts)
@@ -2850,21 +2848,21 @@  discard block
 block discarded – undo
2850 2848
 					.'&end='.$event['end']
2851 2849
 					.'&non_interactive=true'
2852 2850
 					.'&cancel_needs_refresh=true',
2853
-				'',750,410);
2851
+				'', 750, 410);
2854 2852
 		}
2855 2853
 		else if ($message)
2856 2854
 		{
2857
-			$response->call('egw.message',  implode('<br />', $message));
2855
+			$response->call('egw.message', implode('<br />', $message));
2858 2856
 		}
2859
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2857
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2860 2858
 		if ($status_reset_to_unknown)
2861 2859
 		{
2862
-			foreach((array)$event['participants'] as $uid => $status)
2860
+			foreach ((array)$event['participants'] as $uid => $status)
2863 2861
 			{
2864 2862
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2865 2863
 				{
2866
-					calendar_so::split_status($status,$q,$r);
2867
-					$status = calendar_so::combine_status('U',$q,$r);
2864
+					calendar_so::split_status($status, $q, $r);
2865
+					$status = calendar_so::combine_status('U', $q, $r);
2868 2866
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2869 2867
 				}
2870 2868
 			}
@@ -2881,7 +2879,7 @@  discard block
 block discarded – undo
2881 2879
 	{
2882 2880
 		list($eventId, $date) = explode(':', $_eventId);
2883 2881
 		$event = $this->bo->read($eventId);
2884
-		if($date)
2882
+		if ($date)
2885 2883
 		{
2886 2884
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2887 2885
 		}
@@ -2891,29 +2889,29 @@  discard block
 block discarded – undo
2891 2889
 		{
2892 2890
 			if (!empty($event['whole_day']))
2893 2891
 			{
2894
-				$d =& $this->bo->so->startOfDay($date);
2892
+				$d = & $this->bo->so->startOfDay($date);
2895 2893
 				$d->setUser();
2896 2894
 			}
2897 2895
 			$event = $this->bo->read($eventId, $d, true);
2898 2896
 			$date = $d->format('ts');
2899 2897
 		}
2900
-		if($event['participants'][$uid])
2898
+		if ($event['participants'][$uid])
2901 2899
 		{
2902 2900
 			$q = $r = null;
2903
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2904
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2905
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2901
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2902
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2903
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2906 2904
 		}
2907 2905
 		else
2908 2906
 		{
2909 2907
 			// Group membership
2910
-			foreach($event['participants'] as $id => $status)
2908
+			foreach ($event['participants'] as $id => $status)
2911 2909
 			{
2912
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2910
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2913 2911
 				{
2914
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2915
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2916
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2912
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2913
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2914
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2917 2915
 					break;
2918 2916
 				}
2919 2917
 			}
@@ -2921,7 +2919,7 @@  discard block
 block discarded – undo
2921 2919
 
2922 2920
 		// Directly update stored data.  If event is still visible, it will
2923 2921
 		// be notified & update itself.
2924
-		$this->update_client($eventId,$d);
2922
+		$this->update_client($eventId, $d);
2925 2923
 	}
2926 2924
 
2927 2925
 	/**
@@ -2929,8 +2927,8 @@  discard block
 block discarded – undo
2929 2927
 	 */
2930 2928
 	public function ajax_delete($eventId)
2931 2929
 	{
2932
-		list($id, $date) = explode(':',$eventId);
2933
-		$event=$this->bo->read($id);
2930
+		list($id, $date) = explode(':', $eventId);
2931
+		$event = $this->bo->read($id);
2934 2932
 		$response = Api\Json\Response::get();
2935 2933
 
2936 2934
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2943,11 +2941,11 @@  discard block
 block discarded – undo
2943 2941
 			{
2944 2942
 				$msg = lang('Event deleted');
2945 2943
 			}
2946
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2944
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2947 2945
 		}
2948 2946
 		else
2949 2947
 		{
2950
-			$response->apply('egw.message', Array(lang('Error')),'error');
2948
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2951 2949
 		}
2952 2950
 	}
2953 2951
 
@@ -2960,10 +2958,10 @@  discard block
 block discarded – undo
2960 2958
 	 */
2961 2959
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
2962 2960
 	{
2963
-		list($eventId, $date) = explode(':', $_eventId,2);
2961
+		list($eventId, $date) = explode(':', $_eventId, 2);
2964 2962
 
2965 2963
 		$event = $this->bo->read($eventId);
2966
-		if($date)
2964
+		if ($date)
2967 2965
 		{
2968 2966
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2969 2967
 		}
@@ -2973,17 +2971,17 @@  discard block
 block discarded – undo
2973 2971
 		{
2974 2972
 			if (!empty($event['whole_day']))
2975 2973
 			{
2976
-				$d =& $this->bo->so->startOfDay($date);
2974
+				$d = & $this->bo->so->startOfDay($date);
2977 2975
 				$d->setUser();
2978 2976
 			}
2979 2977
 			$event = $this->bo->read($eventId, $d, true);
2980 2978
 			// For DnD, create an exception if they gave the date
2981 2979
 			$preserv = null;
2982
-			$this->_create_exception($event,$preserv);
2980
+			$this->_create_exception($event, $preserv);
2983 2981
 			unset($event['id']);
2984 2982
 
2985 2983
 			$messages = null;
2986
-			$conflicts = $this->bo->update($event,true,true,false,true,$messages);
2984
+			$conflicts = $this->bo->update($event, true, true, false, true, $messages);
2987 2985
 			if (!is_array($conflicts) && $conflicts)
2988 2986
 			{
2989 2987
 				// now we need to add the original start as recur-execption to the series
@@ -2991,28 +2989,28 @@  discard block
 block discarded – undo
2991 2989
 				$recur_event['recur_exception'][] = $d->format('ts');
2992 2990
 				// check if we need to move the alarms, because they are next on that exception
2993 2991
 				$this->bo->check_move_alarms($recur_event, null, $d);
2994
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2995
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2996
-				$this->bo->update($recur_event,true);	// no conflict check here
2992
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2993
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2994
+				$this->bo->update($recur_event, true); // no conflict check here
2997 2995
 
2998 2996
 				// Sending null will trigger a removal of the original for that date
2999 2997
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
3000 2998
 
3001 2999
 				unset($recur_event);
3002
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
3000
+				unset($event['edit_single']); // if we further edit it, it's just a single event
3003 3001
 				unset($preserv['edit_single']);
3004 3002
 			}
3005 3003
 		}
3006
-		foreach($remove as $participant)
3004
+		foreach ($remove as $participant)
3007 3005
 		{
3008 3006
 			unset($event['participants'][$participant]);
3009 3007
 		}
3010
-		foreach($invite as $participant)
3008
+		foreach ($invite as $participant)
3011 3009
 		{
3012 3010
 			$event['participants'][$participant] = 'U';
3013 3011
 		}
3014 3012
 		$message = null;
3015
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
3013
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
3016 3014
 
3017 3015
 		$response = Api\Json\Response::get();
3018 3016
 
@@ -3020,8 +3018,8 @@  discard block
 block discarded – undo
3020 3018
 		{
3021 3019
 			// Save it anyway, was done with explicit user interaction,
3022 3020
 			// and if we don't we lose the invite
3023
-			$this->bo->update($event,true);	// no conflict check here
3024
-			$this->update_client($event['id'],$d);
3021
+			$this->bo->update($event, true); // no conflict check here
3022
+			$this->update_client($event['id'], $d);
3025 3023
 			$response->call(
3026 3024
 				'egw_openWindowCentered2',
3027 3025
 				$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
@@ -3030,22 +3028,22 @@  discard block
 block discarded – undo
3030 3028
 					.'&end='.$event['end']
3031 3029
 					.'&non_interactive=true'
3032 3030
 					.'&cancel_needs_refresh=true',
3033
-				'',750,410);
3031
+				'', 750, 410);
3034 3032
 		}
3035 3033
 		else if ($message)
3036 3034
 		{
3037
-			$response->call('egw.message',  implode('<br />', $message));
3035
+			$response->call('egw.message', implode('<br />', $message));
3038 3036
 		}
3039
-		if($conflicts)
3037
+		if ($conflicts)
3040 3038
 		{
3041
-			$this->update_client($event['id'],$d);
3042
-			if(is_int($conflicts))
3039
+			$this->update_client($event['id'], $d);
3040
+			if (is_int($conflicts))
3043 3041
 			{
3044 3042
 				$event['id'] = $conflicts;
3045 3043
 			}
3046
-			if($event['id'])
3044
+			if ($event['id'])
3047 3045
 			{
3048
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
3046
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
3049 3047
 			}
3050 3048
 		}
3051 3049
 	}
@@ -3056,13 +3054,13 @@  discard block
 block discarded – undo
3056 3054
 	 * @param array $mailContent = null mail content
3057 3055
 	 * @return  array
3058 3056
 	 */
3059
-	function mail_import(array $mailContent=null)
3057
+	function mail_import(array $mailContent = null)
3060 3058
 	{
3061 3059
 		// It would get called from compose as a popup with egw_data
3062 3060
 		if (!is_array($mailContent) && ($_GET['egw_data']))
3063 3061
 		{
3064 3062
 			// get raw mail data
3065
-			Link::get_data ($_GET['egw_data']);
3063
+			Link::get_data($_GET['egw_data']);
3066 3064
 			return false;
3067 3065
 		}
3068 3066
 
@@ -3072,7 +3070,7 @@  discard block
 block discarded – undo
3072 3070
 			$AB = new Api\Contacts();
3073 3071
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
3074 3072
 
3075
-			$participants[0] = array (
3073
+			$participants[0] = array(
3076 3074
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
3077 3075
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
3078 3076
 				'status' => 'A',
@@ -3080,23 +3078,23 @@  discard block
 block discarded – undo
3080 3078
 				'app' => 'User',
3081 3079
 				'role' => 'REQ-PARTICIPANT'
3082 3080
 			);
3083
-			foreach($mailContent['addresses'] as $address)
3081
+			foreach ($mailContent['addresses'] as $address)
3084 3082
 			{
3085 3083
 				// Get available contacts from the email
3086 3084
 				$contacts = $AB->search(array(
3087 3085
 						'email' => $address['email'],
3088 3086
 						'email_home' => $address['email']
3089
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
3087
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
3090 3088
 				if (is_array($contacts))
3091 3089
 				{
3092
-					foreach($contacts as $account)
3090
+					foreach ($contacts as $account)
3093 3091
 					{
3094 3092
 						$accounts[] = $account['account_id'];
3095 3093
 					}
3096 3094
 				}
3097 3095
 				else
3098 3096
 				{
3099
-					$participants []= array (
3097
+					$participants [] = array(
3100 3098
 						'app' => 'email',
3101 3099
 						'uid' => 'e'.$address['email'],
3102 3100
 						'status' => 'U',
@@ -3104,7 +3102,7 @@  discard block
 block discarded – undo
3104 3102
 					);
3105 3103
 				}
3106 3104
 			}
3107
-			$participants = array_merge($participants , array(
3105
+			$participants = array_merge($participants, array(
3108 3106
 				"participant" => $accounts,
3109 3107
 				"role" => "REQ-PARTICIPANT",
3110 3108
 				"add" => "pressed"
@@ -3128,14 +3126,14 @@  discard block
 block discarded – undo
3128 3126
 			{
3129 3127
 				foreach ($mailContent['attachments'] as $attachment)
3130 3128
 				{
3131
-					if($attachment['egw_data'])
3129
+					if ($attachment['egw_data'])
3132 3130
 					{
3133
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3131
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3134 3132
 					}
3135
-					else if(is_readable($attachment['tmp_name']) ||
3133
+					else if (is_readable($attachment['tmp_name']) ||
3136 3134
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3137 3135
 					{
3138
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3136
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3139 3137
 					}
3140 3138
 				}
3141 3139
 			}
Please login to merge, or discard this patch.