Completed
Push — 16.1 ( 592c74...b502d4 )
by Ralf
43:09 queued 19:16
created
api/src/WebDAV/Tools/_parse_lockinfo.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -87,6 +87,7 @@
 block discarded – undo
87 87
      * constructor
88 88
      *
89 89
      * @param  string  path of stream to read
90
+     * @param string $path
90 91
      * @access public
91 92
      */
92 93
     function __construct($path)
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -43,209 +43,209 @@
 block discarded – undo
43 43
  */
44 44
 class _parse_lockinfo
45 45
 {
46
-    /**
47
-     * success state flag
48
-     *
49
-     * @var bool
50
-     * @access public
51
-     */
52
-    var $success = false;
53
-
54
-    /**
55
-     * lock type, currently only "write"
56
-     *
57
-     * @var string
58
-     * @access public
59
-     */
60
-    var $locktype = "";
61
-
62
-    /**
63
-     * lock scope, "shared" or "exclusive"
64
-     *
65
-     * @var string
66
-     * @access public
67
-     */
68
-    var $lockscope = "";
69
-
70
-    /**
71
-     * lock owner information
72
-     *
73
-     * @var string
74
-     * @access public
75
-     */
76
-    var $owner = "";
77
-
78
-    /**
79
-     * flag that is set during lock owner read
80
-     *
81
-     * @var bool
82
-     * @access private
83
-     */
84
-    var $collect_owner = false;
85
-
86
-    /**
87
-     * constructor
88
-     *
89
-     * @param  string  path of stream to read
90
-     * @access public
91
-     */
92
-    function __construct($path)
93
-    {
94
-        // we assume success unless problems occur
95
-        $this->success = true;
96
-
97
-        // remember if any input was parsed
98
-        $had_input = false;
99
-
100
-        // open stream
101
-        $f_in = fopen($path, "r");
102
-        if (!$f_in) {
103
-            $this->success = false;
104
-            return;
105
-        }
106
-
107
-        // create namespace aware parser
108
-        $xml_parser = xml_parser_create_ns("UTF-8", " ");
109
-
110
-        // set tag and data handlers
111
-        xml_set_element_handler($xml_parser,
112
-                                array(&$this, "_startElement"),
113
-                                array(&$this, "_endElement"));
114
-        xml_set_character_data_handler($xml_parser,
115
-                                       array(&$this, "_data"));
116
-
117
-        // we want a case sensitive parser
118
-        xml_parser_set_option($xml_parser,
119
-                              XML_OPTION_CASE_FOLDING, false);
120
-
121
-        // parse input
122
-        while ($this->success && !feof($f_in)) {
123
-            $line = fgets($f_in);
124
-            if (is_string($line)) {
125
-                $had_input = true;
126
-                $this->success &= xml_parse($xml_parser, $line, false);
127
-            }
128
-        }
129
-
130
-        // finish parsing
131
-        if ($had_input) {
132
-            $this->success &= xml_parse($xml_parser, "", true);
133
-        }
134
-
135
-        // check if required tags where found
136
-        $this->success &= !empty($this->locktype);
137
-        $this->success &= !empty($this->lockscope);
138
-
139
-        // free parser resource
140
-        xml_parser_free($xml_parser);
141
-
142
-        // close input stream
143
-        fclose($f_in);
144
-    }
145
-
146
-
147
-    /**
148
-     * tag start handler
149
-     *
150
-     * @param  resource  parser
151
-     * @param  string    tag name
152
-     * @param  array     tag attributes
153
-     * @return void
154
-     * @access private
155
-     */
156
-    function _startElement($parser, $name, $attrs)
157
-    {
158
-        // namespace handling
159
-        if (strstr($name, " ")) {
160
-            list($ns, $tag) = explode(" ", $name);
161
-        } else {
162
-            $ns  = "";
163
-            $tag = $name;
164
-        }
165
-
166
-
167
-        if ($this->collect_owner) {
168
-            // everything within the <owner> tag needs to be collected
169
-            $ns_short = "";
170
-            $ns_attr  = "";
171
-            if ($ns) {
172
-                if ($ns == "DAV:") {
173
-                    $ns_short = "D:";
174
-                } else {
175
-                    $ns_attr = " xmlns='$ns'";
176
-                }
177
-            }
178
-            $this->owner .= "<$ns_short$tag$ns_attr>";
179
-        } else if ($ns == "DAV:") {
180
-            // parse only the essential tags
181
-            switch ($tag) {
182
-            case "write":
183
-                $this->locktype = $tag;
184
-                break;
185
-            case "exclusive":
186
-            case "shared":
187
-                $this->lockscope = $tag;
188
-                break;
189
-            case "owner":
190
-                $this->collect_owner = true;
191
-                break;
192
-            }
193
-        }
194
-    }
195
-
196
-    /**
197
-     * data handler
198
-     *
199
-     * @param  resource  parser
200
-     * @param  string    data
201
-     * @return void
202
-     * @access private
203
-     */
204
-    function _data($parser, $data)
205
-    {
206
-        // only the <owner> tag has data content
207
-        if ($this->collect_owner) {
208
-            $this->owner .= $data;
209
-        }
210
-    }
211
-
212
-    /**
213
-     * tag end handler
214
-     *
215
-     * @param  resource  parser
216
-     * @param  string    tag name
217
-     * @return void
218
-     * @access private
219
-     */
220
-    function _endElement($parser, $name)
221
-    {
222
-        // namespace handling
223
-        if (strstr($name, " ")) {
224
-            list($ns, $tag) = explode(" ", $name);
225
-        } else {
226
-            $ns  = "";
227
-            $tag = $name;
228
-        }
229
-
230
-        // <owner> finished?
231
-        if (($ns == "DAV:") && ($tag == "owner")) {
232
-            $this->collect_owner = false;
233
-        }
234
-
235
-        // within <owner> we have to collect everything
236
-        if ($this->collect_owner) {
237
-            $ns_short = "";
238
-            $ns_attr  = "";
239
-            if ($ns) {
240
-                if ($ns == "DAV:") {
241
-                    $ns_short = "D:";
242
-                } else {
243
-                    $ns_attr = " xmlns='$ns'";
244
-                }
245
-            }
246
-            $this->owner .= "</$ns_short$tag$ns_attr>";
247
-        }
248
-    }
46
+	/**
47
+	 * success state flag
48
+	 *
49
+	 * @var bool
50
+	 * @access public
51
+	 */
52
+	var $success = false;
53
+
54
+	/**
55
+	 * lock type, currently only "write"
56
+	 *
57
+	 * @var string
58
+	 * @access public
59
+	 */
60
+	var $locktype = "";
61
+
62
+	/**
63
+	 * lock scope, "shared" or "exclusive"
64
+	 *
65
+	 * @var string
66
+	 * @access public
67
+	 */
68
+	var $lockscope = "";
69
+
70
+	/**
71
+	 * lock owner information
72
+	 *
73
+	 * @var string
74
+	 * @access public
75
+	 */
76
+	var $owner = "";
77
+
78
+	/**
79
+	 * flag that is set during lock owner read
80
+	 *
81
+	 * @var bool
82
+	 * @access private
83
+	 */
84
+	var $collect_owner = false;
85
+
86
+	/**
87
+	 * constructor
88
+	 *
89
+	 * @param  string  path of stream to read
90
+	 * @access public
91
+	 */
92
+	function __construct($path)
93
+	{
94
+		// we assume success unless problems occur
95
+		$this->success = true;
96
+
97
+		// remember if any input was parsed
98
+		$had_input = false;
99
+
100
+		// open stream
101
+		$f_in = fopen($path, "r");
102
+		if (!$f_in) {
103
+			$this->success = false;
104
+			return;
105
+		}
106
+
107
+		// create namespace aware parser
108
+		$xml_parser = xml_parser_create_ns("UTF-8", " ");
109
+
110
+		// set tag and data handlers
111
+		xml_set_element_handler($xml_parser,
112
+								array(&$this, "_startElement"),
113
+								array(&$this, "_endElement"));
114
+		xml_set_character_data_handler($xml_parser,
115
+									   array(&$this, "_data"));
116
+
117
+		// we want a case sensitive parser
118
+		xml_parser_set_option($xml_parser,
119
+							  XML_OPTION_CASE_FOLDING, false);
120
+
121
+		// parse input
122
+		while ($this->success && !feof($f_in)) {
123
+			$line = fgets($f_in);
124
+			if (is_string($line)) {
125
+				$had_input = true;
126
+				$this->success &= xml_parse($xml_parser, $line, false);
127
+			}
128
+		}
129
+
130
+		// finish parsing
131
+		if ($had_input) {
132
+			$this->success &= xml_parse($xml_parser, "", true);
133
+		}
134
+
135
+		// check if required tags where found
136
+		$this->success &= !empty($this->locktype);
137
+		$this->success &= !empty($this->lockscope);
138
+
139
+		// free parser resource
140
+		xml_parser_free($xml_parser);
141
+
142
+		// close input stream
143
+		fclose($f_in);
144
+	}
145
+
146
+
147
+	/**
148
+	 * tag start handler
149
+	 *
150
+	 * @param  resource  parser
151
+	 * @param  string    tag name
152
+	 * @param  array     tag attributes
153
+	 * @return void
154
+	 * @access private
155
+	 */
156
+	function _startElement($parser, $name, $attrs)
157
+	{
158
+		// namespace handling
159
+		if (strstr($name, " ")) {
160
+			list($ns, $tag) = explode(" ", $name);
161
+		} else {
162
+			$ns  = "";
163
+			$tag = $name;
164
+		}
165
+
166
+
167
+		if ($this->collect_owner) {
168
+			// everything within the <owner> tag needs to be collected
169
+			$ns_short = "";
170
+			$ns_attr  = "";
171
+			if ($ns) {
172
+				if ($ns == "DAV:") {
173
+					$ns_short = "D:";
174
+				} else {
175
+					$ns_attr = " xmlns='$ns'";
176
+				}
177
+			}
178
+			$this->owner .= "<$ns_short$tag$ns_attr>";
179
+		} else if ($ns == "DAV:") {
180
+			// parse only the essential tags
181
+			switch ($tag) {
182
+			case "write":
183
+				$this->locktype = $tag;
184
+				break;
185
+			case "exclusive":
186
+			case "shared":
187
+				$this->lockscope = $tag;
188
+				break;
189
+			case "owner":
190
+				$this->collect_owner = true;
191
+				break;
192
+			}
193
+		}
194
+	}
195
+
196
+	/**
197
+	 * data handler
198
+	 *
199
+	 * @param  resource  parser
200
+	 * @param  string    data
201
+	 * @return void
202
+	 * @access private
203
+	 */
204
+	function _data($parser, $data)
205
+	{
206
+		// only the <owner> tag has data content
207
+		if ($this->collect_owner) {
208
+			$this->owner .= $data;
209
+		}
210
+	}
211
+
212
+	/**
213
+	 * tag end handler
214
+	 *
215
+	 * @param  resource  parser
216
+	 * @param  string    tag name
217
+	 * @return void
218
+	 * @access private
219
+	 */
220
+	function _endElement($parser, $name)
221
+	{
222
+		// namespace handling
223
+		if (strstr($name, " ")) {
224
+			list($ns, $tag) = explode(" ", $name);
225
+		} else {
226
+			$ns  = "";
227
+			$tag = $name;
228
+		}
229
+
230
+		// <owner> finished?
231
+		if (($ns == "DAV:") && ($tag == "owner")) {
232
+			$this->collect_owner = false;
233
+		}
234
+
235
+		// within <owner> we have to collect everything
236
+		if ($this->collect_owner) {
237
+			$ns_short = "";
238
+			$ns_attr  = "";
239
+			if ($ns) {
240
+				if ($ns == "DAV:") {
241
+					$ns_short = "D:";
242
+				} else {
243
+					$ns_attr = " xmlns='$ns'";
244
+				}
245
+			}
246
+			$this->owner .= "</$ns_short$tag$ns_attr>";
247
+		}
248
+	}
249 249
 }
250 250
 
251 251
 ?>
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -179,16 +179,16 @@
 block discarded – undo
179 179
         } else if ($ns == "DAV:") {
180 180
             // parse only the essential tags
181 181
             switch ($tag) {
182
-            case "write":
183
-                $this->locktype = $tag;
184
-                break;
185
-            case "exclusive":
186
-            case "shared":
187
-                $this->lockscope = $tag;
188
-                break;
189
-            case "owner":
190
-                $this->collect_owner = true;
191
-                break;
182
+            	case "write":
183
+                	$this->locktype = $tag;
184
+                	break;
185
+            	case "exclusive":
186
+            	case "shared":
187
+                	$this->lockscope = $tag;
188
+                	break;
189
+            	case "owner":
190
+                	$this->collect_owner = true;
191
+                	break;
192 192
             }
193 193
         }
194 194
     }
Please login to merge, or discard this patch.
Braces   +45 added lines, -20 removed lines patch added patch discarded remove patch
@@ -99,7 +99,8 @@  discard block
 block discarded – undo
99 99
 
100 100
         // open stream
101 101
         $f_in = fopen($path, "r");
102
-        if (!$f_in) {
102
+        if (!$f_in)
103
+        {
103 104
             $this->success = false;
104 105
             return;
105 106
         }
@@ -119,16 +120,19 @@  discard block
 block discarded – undo
119 120
                               XML_OPTION_CASE_FOLDING, false);
120 121
 
121 122
         // parse input
122
-        while ($this->success && !feof($f_in)) {
123
+        while ($this->success && !feof($f_in))
124
+        {
123 125
             $line = fgets($f_in);
124
-            if (is_string($line)) {
126
+            if (is_string($line))
127
+            {
125 128
                 $had_input = true;
126 129
                 $this->success &= xml_parse($xml_parser, $line, false);
127 130
             }
128 131
         }
129 132
 
130 133
         // finish parsing
131
-        if ($had_input) {
134
+        if ($had_input)
135
+        {
132 136
             $this->success &= xml_parse($xml_parser, "", true);
133 137
         }
134 138
 
@@ -156,29 +160,40 @@  discard block
 block discarded – undo
156 160
     function _startElement($parser, $name, $attrs)
157 161
     {
158 162
         // namespace handling
159
-        if (strstr($name, " ")) {
163
+        if (strstr($name, " "))
164
+        {
160 165
             list($ns, $tag) = explode(" ", $name);
161
-        } else {
166
+        }
167
+        else
168
+        {
162 169
             $ns  = "";
163 170
             $tag = $name;
164 171
         }
165 172
 
166 173
 
167
-        if ($this->collect_owner) {
174
+        if ($this->collect_owner)
175
+        {
168 176
             // everything within the <owner> tag needs to be collected
169 177
             $ns_short = "";
170 178
             $ns_attr  = "";
171
-            if ($ns) {
172
-                if ($ns == "DAV:") {
179
+            if ($ns)
180
+            {
181
+                if ($ns == "DAV:")
182
+                {
173 183
                     $ns_short = "D:";
174
-                } else {
184
+                }
185
+                else
186
+                {
175 187
                     $ns_attr = " xmlns='$ns'";
176 188
                 }
177 189
             }
178 190
             $this->owner .= "<$ns_short$tag$ns_attr>";
179
-        } else if ($ns == "DAV:") {
191
+        }
192
+        else if ($ns == "DAV:")
193
+        {
180 194
             // parse only the essential tags
181
-            switch ($tag) {
195
+            switch ($tag)
196
+            {
182 197
             case "write":
183 198
                 $this->locktype = $tag;
184 199
                 break;
@@ -204,7 +219,8 @@  discard block
 block discarded – undo
204 219
     function _data($parser, $data)
205 220
     {
206 221
         // only the <owner> tag has data content
207
-        if ($this->collect_owner) {
222
+        if ($this->collect_owner)
223
+        {
208 224
             $this->owner .= $data;
209 225
         }
210 226
     }
@@ -220,26 +236,35 @@  discard block
 block discarded – undo
220 236
     function _endElement($parser, $name)
221 237
     {
222 238
         // namespace handling
223
-        if (strstr($name, " ")) {
239
+        if (strstr($name, " "))
240
+        {
224 241
             list($ns, $tag) = explode(" ", $name);
225
-        } else {
242
+        }
243
+        else
244
+        {
226 245
             $ns  = "";
227 246
             $tag = $name;
228 247
         }
229 248
 
230 249
         // <owner> finished?
231
-        if (($ns == "DAV:") && ($tag == "owner")) {
250
+        if (($ns == "DAV:") && ($tag == "owner"))
251
+        {
232 252
             $this->collect_owner = false;
233 253
         }
234 254
 
235 255
         // within <owner> we have to collect everything
236
-        if ($this->collect_owner) {
256
+        if ($this->collect_owner)
257
+        {
237 258
             $ns_short = "";
238 259
             $ns_attr  = "";
239
-            if ($ns) {
240
-                if ($ns == "DAV:") {
260
+            if ($ns)
261
+            {
262
+                if ($ns == "DAV:")
263
+                {
241 264
                     $ns_short = "D:";
242
-                } else {
265
+                }
266
+                else
267
+                {
243 268
                     $ns_attr = " xmlns='$ns'";
244 269
                 }
245 270
             }
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_proppatch.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -95,6 +95,7 @@
 block discarded – undo
95 95
      *
96 96
      * @param  string  path of input stream
97 97
      * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
+     * @param string $path
98 99
      * @access public
99 100
      */
100 101
     function __construct($path, $store_request=false)
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -43,198 +43,198 @@
 block discarded – undo
43 43
  */
44 44
 class _parse_proppatch
45 45
 {
46
-    /**
47
-     *
48
-     *
49
-     * @var
50
-     * @access
51
-     */
52
-    var $success;
53
-
54
-    /**
55
-     *
56
-     *
57
-     * @var
58
-     * @access
59
-     */
60
-    var $props;
61
-
62
-    /**
63
-     *
64
-     *
65
-     * @var
66
-     * @access
67
-     */
68
-    var $depth;
69
-
70
-    /**
71
-     *
72
-     *
73
-     * @var
74
-     * @access
75
-     */
76
-    var $mode;
77
-
78
-    /**
79
-     *
80
-     *
81
-     * @var
82
-     * @access
83
-     */
84
-    var $current;
85
-
86
-    /**
87
-     * On return whole request, if $store_request == true was specified in constructor
88
-     *
89
-     * @var string
90
-     */
91
-    var $request;
92
-
93
-    /**
94
-     * constructor
95
-     *
96
-     * @param  string  path of input stream
97
-     * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
-     * @access public
99
-     */
100
-    function __construct($path, $store_request=false)
101
-    {
102
-        $this->success = true;
103
-
104
-        $this->depth = 0;
105
-        $this->props = array();
106
-        $had_input = false;
107
-
108
-        $f_in = fopen($path, "r");
109
-        if (!$f_in) {
110
-            $this->success = false;
111
-            return;
112
-        }
113
-
114
-        $xml_parser = xml_parser_create_ns("UTF-8", " ");
115
-
116
-        xml_set_element_handler($xml_parser,
117
-                                array(&$this, "_startElement"),
118
-                                array(&$this, "_endElement"));
119
-
120
-        xml_set_character_data_handler($xml_parser,
121
-                                       array(&$this, "_data"));
122
-
123
-        xml_parser_set_option($xml_parser,
124
-                              XML_OPTION_CASE_FOLDING, false);
125
-
126
-        while($this->success && !feof($f_in)) {
127
-            $line = fgets($f_in);
128
-            if ($store_request) $this->request .= $line;
129
-            if (is_string($line)) {
130
-                $had_input = true;
131
-                $this->success &= xml_parse($xml_parser, $line, false);
132
-            }
133
-        }
134
-
135
-        if($had_input) {
136
-            $this->success &= xml_parse($xml_parser, "", true);
137
-        }
138
-
139
-        xml_parser_free($xml_parser);
140
-
141
-        fclose($f_in);
142
-    }
143
-
144
-    /**
145
-     * tag start handler
146
-     *
147
-     * @param  resource  parser
148
-     * @param  string    tag name
149
-     * @param  array     tag attributes
150
-     * @return void
151
-     * @access private
152
-     */
153
-    function _startElement($parser, $name, $attrs)
154
-    {
155
-        if (strstr($name, " ")) {
156
-            list($ns, $tag) = explode(" ", $name);
157
-            if ($ns == "")
158
-                $this->success = false;
159
-        } else {
160
-            $ns = "";
161
-            $tag = $name;
162
-        }
163
-
164
-        if ($this->depth == 1) {
165
-            $this->mode = $tag;
166
-        }
167
-
168
-        if ($this->depth == 3) {
169
-            $prop = array("name" => $tag);
170
-            $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
-            if ($this->mode == "set") {
172
-                $this->current["val"] = "";     // default set val
173
-            }
174
-        }
175
-
176
-        if ($this->depth >= 4) {
177
-            $this->current["val"] .= "<$tag";
178
-            if (isset($attr)) {
179
-                foreach ($attr as $key => $val) {
180
-                    $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181
-                }
182
-            }
183
-            $this->current["val"] .= ">";
184
-        }
185
-
186
-
187
-
188
-        $this->depth++;
189
-    }
190
-
191
-    /**
192
-     * tag end handler
193
-     *
194
-     * @param  resource  parser
195
-     * @param  string    tag name
196
-     * @return void
197
-     * @access private
198
-     */
199
-    function _endElement($parser, $name)
200
-    {
201
-        if (strstr($name, " ")) {
202
-            list($ns, $tag) = explode(" ", $name);
203
-            if ($ns == "")
204
-                $this->success = false;
205
-        } else {
206
-            $ns = "";
207
-            $tag = $name;
208
-        }
209
-
210
-        $this->depth--;
211
-
212
-        if ($this->depth >= 4) {
213
-            $this->current["val"] .= "</$tag>";
214
-        }
215
-
216
-        if ($this->depth == 3) {
217
-            if (isset($this->current)) {
218
-                $this->props[] = $this->current;
219
-                unset($this->current);
220
-            }
221
-        }
222
-    }
223
-
224
-    /**
225
-     * input data handler
226
-     *
227
-     * @param  resource  parser
228
-     * @param  string    data
229
-     * @return void
230
-     * @access private
231
-     */
232
-    function _data($parser, $data)
233
-    {
234
-        if (isset($this->current)) {
235
-            $this->current["val"] .= $data;
236
-        }
237
-    }
46
+	/**
47
+	 *
48
+	 *
49
+	 * @var
50
+	 * @access
51
+	 */
52
+	var $success;
53
+
54
+	/**
55
+	 *
56
+	 *
57
+	 * @var
58
+	 * @access
59
+	 */
60
+	var $props;
61
+
62
+	/**
63
+	 *
64
+	 *
65
+	 * @var
66
+	 * @access
67
+	 */
68
+	var $depth;
69
+
70
+	/**
71
+	 *
72
+	 *
73
+	 * @var
74
+	 * @access
75
+	 */
76
+	var $mode;
77
+
78
+	/**
79
+	 *
80
+	 *
81
+	 * @var
82
+	 * @access
83
+	 */
84
+	var $current;
85
+
86
+	/**
87
+	 * On return whole request, if $store_request == true was specified in constructor
88
+	 *
89
+	 * @var string
90
+	 */
91
+	var $request;
92
+
93
+	/**
94
+	 * constructor
95
+	 *
96
+	 * @param  string  path of input stream
97
+	 * @param boolean $store_request =false if true whole request data will be made available in $this->request
98
+	 * @access public
99
+	 */
100
+	function __construct($path, $store_request=false)
101
+	{
102
+		$this->success = true;
103
+
104
+		$this->depth = 0;
105
+		$this->props = array();
106
+		$had_input = false;
107
+
108
+		$f_in = fopen($path, "r");
109
+		if (!$f_in) {
110
+			$this->success = false;
111
+			return;
112
+		}
113
+
114
+		$xml_parser = xml_parser_create_ns("UTF-8", " ");
115
+
116
+		xml_set_element_handler($xml_parser,
117
+								array(&$this, "_startElement"),
118
+								array(&$this, "_endElement"));
119
+
120
+		xml_set_character_data_handler($xml_parser,
121
+									   array(&$this, "_data"));
122
+
123
+		xml_parser_set_option($xml_parser,
124
+							  XML_OPTION_CASE_FOLDING, false);
125
+
126
+		while($this->success && !feof($f_in)) {
127
+			$line = fgets($f_in);
128
+			if ($store_request) $this->request .= $line;
129
+			if (is_string($line)) {
130
+				$had_input = true;
131
+				$this->success &= xml_parse($xml_parser, $line, false);
132
+			}
133
+		}
134
+
135
+		if($had_input) {
136
+			$this->success &= xml_parse($xml_parser, "", true);
137
+		}
138
+
139
+		xml_parser_free($xml_parser);
140
+
141
+		fclose($f_in);
142
+	}
143
+
144
+	/**
145
+	 * tag start handler
146
+	 *
147
+	 * @param  resource  parser
148
+	 * @param  string    tag name
149
+	 * @param  array     tag attributes
150
+	 * @return void
151
+	 * @access private
152
+	 */
153
+	function _startElement($parser, $name, $attrs)
154
+	{
155
+		if (strstr($name, " ")) {
156
+			list($ns, $tag) = explode(" ", $name);
157
+			if ($ns == "")
158
+				$this->success = false;
159
+		} else {
160
+			$ns = "";
161
+			$tag = $name;
162
+		}
163
+
164
+		if ($this->depth == 1) {
165
+			$this->mode = $tag;
166
+		}
167
+
168
+		if ($this->depth == 3) {
169
+			$prop = array("name" => $tag);
170
+			$this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
+			if ($this->mode == "set") {
172
+				$this->current["val"] = "";     // default set val
173
+			}
174
+		}
175
+
176
+		if ($this->depth >= 4) {
177
+			$this->current["val"] .= "<$tag";
178
+			if (isset($attr)) {
179
+				foreach ($attr as $key => $val) {
180
+					$this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181
+				}
182
+			}
183
+			$this->current["val"] .= ">";
184
+		}
185
+
186
+
187
+
188
+		$this->depth++;
189
+	}
190
+
191
+	/**
192
+	 * tag end handler
193
+	 *
194
+	 * @param  resource  parser
195
+	 * @param  string    tag name
196
+	 * @return void
197
+	 * @access private
198
+	 */
199
+	function _endElement($parser, $name)
200
+	{
201
+		if (strstr($name, " ")) {
202
+			list($ns, $tag) = explode(" ", $name);
203
+			if ($ns == "")
204
+				$this->success = false;
205
+		} else {
206
+			$ns = "";
207
+			$tag = $name;
208
+		}
209
+
210
+		$this->depth--;
211
+
212
+		if ($this->depth >= 4) {
213
+			$this->current["val"] .= "</$tag>";
214
+		}
215
+
216
+		if ($this->depth == 3) {
217
+			if (isset($this->current)) {
218
+				$this->props[] = $this->current;
219
+				unset($this->current);
220
+			}
221
+		}
222
+	}
223
+
224
+	/**
225
+	 * input data handler
226
+	 *
227
+	 * @param  resource  parser
228
+	 * @param  string    data
229
+	 * @return void
230
+	 * @access private
231
+	 */
232
+	function _data($parser, $data)
233
+	{
234
+		if (isset($this->current)) {
235
+			$this->current["val"] .= $data;
236
+		}
237
+	}
238 238
 }
239 239
 
240 240
 /*
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param boolean $store_request =false if true whole request data will be made available in $this->request
98 98
      * @access public
99 99
      */
100
-    function __construct($path, $store_request=false)
100
+    function __construct($path, $store_request = false)
101 101
     {
102 102
         $this->success = true;
103 103
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         xml_parser_set_option($xml_parser,
124 124
                               XML_OPTION_CASE_FOLDING, false);
125 125
 
126
-        while($this->success && !feof($f_in)) {
126
+        while ($this->success && !feof($f_in)) {
127 127
             $line = fgets($f_in);
128 128
             if ($store_request) $this->request .= $line;
129 129
             if (is_string($line)) {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             }
133 133
         }
134 134
 
135
-        if($had_input) {
135
+        if ($had_input) {
136 136
             $this->success &= xml_parse($xml_parser, "", true);
137 137
         }
138 138
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $prop = array("name" => $tag);
170 170
             $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171 171
             if ($this->mode == "set") {
172
-                $this->current["val"] = "";     // default set val
172
+                $this->current["val"] = ""; // default set val
173 173
             }
174 174
         }
175 175
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $this->current["val"] .= "<$tag";
178 178
             if (isset($attr)) {
179 179
                 foreach ($attr as $key => $val) {
180
-                    $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
180
+                    $this->current["val"] .= ' '.$key.'="'.str_replace('"', '&quot;', $val).'"';
181 181
                 }
182 182
             }
183 183
             $this->current["val"] .= ">";
Please login to merge, or discard this patch.
Braces   +48 added lines, -21 removed lines patch added patch discarded remove patch
@@ -106,7 +106,8 @@  discard block
 block discarded – undo
106 106
         $had_input = false;
107 107
 
108 108
         $f_in = fopen($path, "r");
109
-        if (!$f_in) {
109
+        if (!$f_in)
110
+        {
110 111
             $this->success = false;
111 112
             return;
112 113
         }
@@ -123,16 +124,22 @@  discard block
 block discarded – undo
123 124
         xml_parser_set_option($xml_parser,
124 125
                               XML_OPTION_CASE_FOLDING, false);
125 126
 
126
-        while($this->success && !feof($f_in)) {
127
+        while($this->success && !feof($f_in))
128
+        {
127 129
             $line = fgets($f_in);
128
-            if ($store_request) $this->request .= $line;
129
-            if (is_string($line)) {
130
+            if ($store_request)
131
+            {
132
+            	$this->request .= $line;
133
+            }
134
+            if (is_string($line))
135
+            {
130 136
                 $had_input = true;
131 137
                 $this->success &= xml_parse($xml_parser, $line, false);
132 138
             }
133 139
         }
134 140
 
135
-        if($had_input) {
141
+        if($had_input)
142
+        {
136 143
             $this->success &= xml_parse($xml_parser, "", true);
137 144
         }
138 145
 
@@ -152,31 +159,42 @@  discard block
 block discarded – undo
152 159
      */
153 160
     function _startElement($parser, $name, $attrs)
154 161
     {
155
-        if (strstr($name, " ")) {
162
+        if (strstr($name, " "))
163
+        {
156 164
             list($ns, $tag) = explode(" ", $name);
157 165
             if ($ns == "")
158
-                $this->success = false;
159
-        } else {
166
+            {
167
+                            $this->success = false;
168
+            }
169
+        }
170
+        else
171
+        {
160 172
             $ns = "";
161 173
             $tag = $name;
162 174
         }
163 175
 
164
-        if ($this->depth == 1) {
176
+        if ($this->depth == 1)
177
+        {
165 178
             $this->mode = $tag;
166 179
         }
167 180
 
168
-        if ($this->depth == 3) {
181
+        if ($this->depth == 3)
182
+        {
169 183
             $prop = array("name" => $tag);
170 184
             $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
-            if ($this->mode == "set") {
185
+            if ($this->mode == "set")
186
+            {
172 187
                 $this->current["val"] = "";     // default set val
173 188
             }
174 189
         }
175 190
 
176
-        if ($this->depth >= 4) {
191
+        if ($this->depth >= 4)
192
+        {
177 193
             $this->current["val"] .= "<$tag";
178
-            if (isset($attr)) {
179
-                foreach ($attr as $key => $val) {
194
+            if (isset($attr))
195
+            {
196
+                foreach ($attr as $key => $val)
197
+                {
180 198
                     $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181 199
                 }
182 200
             }
@@ -198,23 +216,31 @@  discard block
 block discarded – undo
198 216
      */
199 217
     function _endElement($parser, $name)
200 218
     {
201
-        if (strstr($name, " ")) {
219
+        if (strstr($name, " "))
220
+        {
202 221
             list($ns, $tag) = explode(" ", $name);
203 222
             if ($ns == "")
204
-                $this->success = false;
205
-        } else {
223
+            {
224
+                            $this->success = false;
225
+            }
226
+        }
227
+        else
228
+        {
206 229
             $ns = "";
207 230
             $tag = $name;
208 231
         }
209 232
 
210 233
         $this->depth--;
211 234
 
212
-        if ($this->depth >= 4) {
235
+        if ($this->depth >= 4)
236
+        {
213 237
             $this->current["val"] .= "</$tag>";
214 238
         }
215 239
 
216
-        if ($this->depth == 3) {
217
-            if (isset($this->current)) {
240
+        if ($this->depth == 3)
241
+        {
242
+            if (isset($this->current))
243
+            {
218 244
                 $this->props[] = $this->current;
219 245
                 unset($this->current);
220 246
             }
@@ -231,7 +257,8 @@  discard block
 block discarded – undo
231 257
      */
232 258
     function _data($parser, $data)
233 259
     {
234
-        if (isset($this->current)) {
260
+        if (isset($this->current))
261
+        {
235 262
             $this->current["val"] .= $data;
236 263
         }
237 264
     }
Please login to merge, or discard this patch.
api/thumbnail.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -80,6 +80,7 @@
 block discarded – undo
80 80
 
81 81
 /**
82 82
  * Returns the maximum width/height of a thumbnail
83
+ * @return integer|null
83 84
  */
84 85
 function get_maxsize()
85 86
 {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 	}
72 72
 
73
-	if (!preg_match('/^[a-z0-9_-]+$/i',$app))
73
+	if (!preg_match('/^[a-z0-9_-]+$/i', $app))
74 74
 	{
75
-		die('Stop');	// just to prevent someone doing nasty things
75
+		die('Stop'); // just to prevent someone doing nasty things
76 76
 	}
77 77
 
78 78
 	return $app;
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function get_maxsize()
85 85
 {
86
-	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 :
87
-		$GLOBALS['egw_info']['server']['link_list_thumbnail'];
86
+	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail'];
88 87
 
89 88
 	// Another maximum size may be passed if thumbnails are turned on
90 89
 	if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize']))
@@ -150,7 +149,7 @@  discard block
 block discarded – undo
150 149
 	}
151 150
 	$dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize);
152 151
 	$dst_dir = dirname($dst);
153
-	if(file_exists($dst_dir))
152
+	if (file_exists($dst_dir))
154 153
 	{
155 154
 		// Check whether the destination file already exists and is newer than
156 155
 		// the source file. Assume the file doesn't exist if thumbnailing is turned off.
@@ -190,7 +189,7 @@  discard block
 block discarded – undo
190 189
 		{
191 190
 			// Allow client to cache these, makes scrolling in filemanager much nicer
192 191
 			// setting maximum allow caching time of one year, if url contains (non-empty) moditication time
193
-			Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true);	// true = private / browser only caching
192
+			Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching
194 193
 			header('Content-Type: '.$output_mime);
195 194
 			readfile($dst);
196 195
 			return true;
@@ -212,7 +211,7 @@  discard block
 block discarded – undo
212 211
  * @param int $minsize =null
213 212
  * @return string
214 213
  */
215
-function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null)
214
+function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null)
216 215
 {
217 216
 	// Use the egroupware file cache to store the thumbnails on a per instance basis
218 217
 	$cachefile = new Api\Cache\Files(array());
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
  * TODO: As this is a general purpose function, it might probably be moved
239 238
  *   to some other php file or an "image utils" class.
240 239
  */
241
-function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0)
240
+function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0)
242 241
 {
243 242
 	//Scale will contain the factor by which the image has to be scaled down
244 243
 	$scale = 1.0;
@@ -299,7 +298,7 @@  discard block
 block discarded – undo
299 298
  * @param int $maxh the maximum height of the thumbnail
300 299
  * @returns boolean|resource false or a gd_image
301 300
  */
302
-function gd_image_load($file,$maxw,$maxh)
301
+function gd_image_load($file, $maxw, $maxh)
303 302
 {
304 303
 	// Get mime type
305 304
 	list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file));
@@ -307,9 +306,9 @@  discard block
 block discarded – undo
307 306
 	if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
308 307
 
309 308
 	// Call the according gd constructor depending on the file type
310
-	if($type == 'image')
309
+	if ($type == 'image')
311 310
 	{
312
-		if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file)))
311
+		if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file)))
313 312
 		{
314 313
 			return $image;
315 314
 		}
@@ -332,12 +331,12 @@  discard block
 block discarded – undo
332 331
 	else if ($type == 'application')
333 332
 	{
334 333
 		$thumb = false;
335
-		if(strpos($image_type,'vnd.oasis.opendocument.') === 0)
334
+		if (strpos($image_type, 'vnd.oasis.opendocument.') === 0)
336 335
 		{
337 336
 			// OpenDocuments have thumbnails inside already
338 337
 			$thumb = get_opendocument_thumbnail($file);
339 338
 		}
340
-		else if($image_type == 'pdf')
339
+		else if ($image_type == 'pdf')
341 340
 		{
342 341
 			$thumb = get_pdf_thumbnail($file);
343 342
 		}
@@ -347,7 +346,7 @@  discard block
 block discarded – undo
347 346
 			//$thumb = get_msoffice_thumbnail($file);
348 347
 		}
349 348
 		// Mark it with mime type icon
350
-		if($thumb)
349
+		if ($thumb)
351 350
 		{
352 351
 			// Need to scale first, or the mark will be wrong size
353 352
 			$scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh);
@@ -387,8 +386,8 @@  discard block
 block discarded – undo
387 386
 
388 387
 	// Image is already there, but we can't access them directly through VFS
389 388
 	$ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods';
390
-	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-');
391
-	copy($file,$archive);
389
+	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-');
390
+	copy($file, $archive);
392 391
 
393 392
 	$thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png';
394 393
 	$image = imagecreatefromstring(file_get_contents($thumbnail_url));
@@ -442,7 +441,7 @@  discard block
 block discarded – undo
442 441
  */
443 442
 function get_pdf_thumbnail($file)
444 443
 {
445
-	if(!pdf_thumbnails_available()) return false;
444
+	if (!pdf_thumbnails_available()) return false;
446 445
 
447 446
 	// switch off max_excution_time, as some thumbnails take longer and
448 447
 	// will be startet over and over again, if they dont finish
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	$target_height = imagesy($target_image);
472 471
 
473 472
 	// Find mime image, if no tag image set
474
-	if(!$tag_image && $mime)
473
+	if (!$tag_image && $mime)
475 474
 	{
476 475
 		list($app, $icon) = explode('/', Vfs::mime_icon($mime), 2);
477 476
 		list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'],
@@ -482,16 +481,16 @@  discard block
 block discarded – undo
482 481
 
483 482
 	// Find correct size - max 1/3 target
484 483
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
485
-	if(!$tag_size) return;
486
-	list($tag_width,$tag_height) = $tag_size;
484
+	if (!$tag_size) return;
485
+	list($tag_width, $tag_height) = $tag_size;
487 486
 
488 487
 	// Put it in
489
-	if($mime)
488
+	if ($mime)
490 489
 	{
491
-		imagecopyresampled($target_image,$tag_image,
490
+		imagecopyresampled($target_image, $tag_image,
492 491
 			$target_width - $tag_width,
493 492
 			$target_height - $tag_height,
494
-			0,0,
493
+			0, 0,
495 494
 			$tag_width,
496 495
 			$tag_height,
497 496
 			imagesx($tag_image),
@@ -545,7 +544,7 @@  discard block
 block discarded – undo
545 544
 function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh)
546 545
 {
547 546
 	//Load the image
548
-	if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false)
547
+	if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false)
549 548
 	{
550 549
 		//Get the constraints of the image
551 550
 		$w = imagesx($img_src);
@@ -575,14 +574,14 @@  discard block
 block discarded – undo
575 574
 */
576 575
 function gdVersion($user_ver = 0)
577 576
 {
578
-	if (! extension_loaded('gd')) { return; }
577
+	if (!extension_loaded('gd')) { return; }
579 578
 	static $gd_ver = 0;
580 579
 
581 580
 	// Just accept the specified setting if it's 1.
582 581
 	if ($user_ver == 1) { $gd_ver = 1; return 1; }
583 582
 
584 583
 	// Use the static variable if function was called previously.
585
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
584
+	if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; }
586 585
 
587 586
 	// Use the gd_info() function if possible.
588 587
 	if (function_exists('gd_info')) {
Please login to merge, or discard this patch.
Braces   +38 added lines, -12 removed lines patch added patch discarded remove patch
@@ -244,10 +244,13 @@  discard block
 block discarded – undo
244 244
 	$scale = 1.0;
245 245
 
246 246
 	//Select the constraining dimension
247
-	if ($w > $h) // landscape image: constraining factor $minh or $maxw
247
+	if ($w > $h)
248
+	{
249
+		// landscape image: constraining factor $minh or $maxw
248 250
 	{
249 251
 		$scale = $minh ? $minh / $h : $maxw / $w;
250 252
 	}
253
+	}
251 254
 	else // portrail image: constraining factor $minw or $maxh
252 255
 	{
253 256
 		$scale = $minw ? $minw / $w : $maxh / $h;
@@ -304,7 +307,10 @@  discard block
 block discarded – undo
304 307
 	// Get mime type
305 308
 	list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file));
306 309
 	// if $file is not from vfs, use Api\MimeMagic::filename2mime to get mime-type from extension
307
-	if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
310
+	if (!$type)
311
+	{
312
+		list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file));
313
+	}
308 314
 
309 315
 	// Call the according gd constructor depending on the file type
310 316
 	if($type == 'image')
@@ -442,7 +448,10 @@  discard block
 block discarded – undo
442 448
  */
443 449
 function get_pdf_thumbnail($file)
444 450
 {
445
-	if(!pdf_thumbnails_available()) return false;
451
+	if(!pdf_thumbnails_available())
452
+	{
453
+		return false;
454
+	}
446 455
 
447 456
 	// switch off max_excution_time, as some thumbnails take longer and
448 457
 	// will be startet over and over again, if they dont finish
@@ -482,7 +491,10 @@  discard block
 block discarded – undo
482 491
 
483 492
 	// Find correct size - max 1/3 target
484 493
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
485
-	if(!$tag_size) return;
494
+	if(!$tag_size)
495
+	{
496
+		return;
497
+	}
486 498
 	list($tag_width,$tag_height) = $tag_size;
487 499
 
488 500
 	// Put it in
@@ -575,17 +587,24 @@  discard block
 block discarded – undo
575 587
 */
576 588
 function gdVersion($user_ver = 0)
577 589
 {
578
-	if (! extension_loaded('gd')) { return; }
590
+	if (! extension_loaded('gd'))
591
+	{
592
+return; }
579 593
 	static $gd_ver = 0;
580 594
 
581 595
 	// Just accept the specified setting if it's 1.
582
-	if ($user_ver == 1) { $gd_ver = 1; return 1; }
596
+	if ($user_ver == 1)
597
+	{
598
+$gd_ver = 1; return 1; }
583 599
 
584 600
 	// Use the static variable if function was called previously.
585
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
601
+	if ($user_ver !=2 && $gd_ver > 0 )
602
+	{
603
+return $gd_ver; }
586 604
 
587 605
 	// Use the gd_info() function if possible.
588
-	if (function_exists('gd_info')) {
606
+	if (function_exists('gd_info'))
607
+	{
589 608
 		$ver_info = gd_info();
590 609
 		$match = null;
591 610
 		preg_match('/\d/', $ver_info['GD Version'], $match);
@@ -594,11 +613,15 @@  discard block
 block discarded – undo
594 613
 	}
595 614
 
596 615
 	// If phpinfo() is disabled use a specified / fail-safe choice...
597
-	if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
598
-		if ($user_ver == 2) {
616
+	if (preg_match('/phpinfo/', ini_get('disable_functions')))
617
+	{
618
+		if ($user_ver == 2)
619
+		{
599 620
 			$gd_ver = 2;
600 621
 			return 2;
601
-		} else {
622
+		}
623
+		else
624
+		{
602 625
 			$gd_ver = 1;
603 626
 			return 1;
604 627
 		}
@@ -607,6 +630,9 @@  discard block
 block discarded – undo
607 630
 	ob_start();
608 631
 	phpinfo(8);
609 632
 	$info = stristr(ob_get_clean(), 'gd version');
610
-	if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0];
633
+	if (preg_match('/\d/', $info, $match))
634
+	{
635
+		$gd_ver = $match[0];
636
+	}
611 637
 	return $match[0];
612 638
 }
Please login to merge, or discard this patch.
calendar/importexport/class.import_events_csv.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,6 @@
 block discarded – undo
94 94
 	/**
95 95
 	 * imports entries according to given definition object.
96 96
 	 * @param resource $_stream
97
-	 * @param string $_charset
98 97
 	 * @param definition $_definition
99 98
 	 */
100 99
 	public function import( $_stream, definition $_definition ) {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	private $user = null;
83 83
 
84 84
 	/**
85
-         * List of import errors
86
-         */
87
-        protected $errors = array();
85
+	 * List of import errors
86
+	 */
87
+		protected $errors = array();
88 88
 
89 89
 	/**
90 90
 	 * List of actions, and how many times that action was taken
@@ -305,26 +305,26 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-        * Returns errors that were encountered during importing
309
-        * Maximum of one error message per record, but you can append if you need to
310
-        *
311
-        * @return Array (
312
-        *       record_# => error message
313
-        *       )
314
-        */
315
-        public function get_errors() {
308
+	 * Returns errors that were encountered during importing
309
+	 * Maximum of one error message per record, but you can append if you need to
310
+	 *
311
+	 * @return Array (
312
+	 *       record_# => error message
313
+	 *       )
314
+	 */
315
+		public function get_errors() {
316 316
 		return $this->errors;
317 317
 	}
318 318
 
319 319
 	/**
320
-        * Returns a list of actions taken, and the number of records for that action.
321
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
-        *
323
-        * @return Array (
324
-        *       action => record count
325
-        * )
326
-        */
327
-        public function get_results() {
320
+	 * Returns a list of actions taken, and the number of records for that action.
321
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
+	 *
323
+	 * @return Array (
324
+	 *       action => record count
325
+	 * )
326
+	 */
327
+		public function get_results() {
328 328
 		return $this->results;
329 329
 	}
330 330
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  * @version $Id: $
11 11
  */
12 12
 
13
-require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php');
13
+require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php');
14 14
 require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php');
15 15
 
16 16
 
17 17
 /**
18 18
  * class import_csv for addressbook
19 19
  */
20
-class import_events_csv implements iface_import_plugin  {
20
+class import_events_csv implements iface_import_plugin {
21 21
 
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 			// char
24
-		'charset', 				// string
25
-		'event_owner', 			// int account_id or -1 for leave untuched
26
-		'owner_joins_event',	// bool
27
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'event_owner', // int account_id or -1 for leave untuched
26
+		'owner_joins_event', // bool
27
+		'update_cats', // string {override|add} overides record
28 28
 								// with cat(s) from csv OR add the cat from
29 29
 								// csv file to exeisting cat(s) of record
30
-		'num_header_lines',		// int number of header lines
31
-		'trash_users_records',	// trashes all events of events owner before import
32
-		'field_conversion', 	// array( $csv_col_num => conversion)
33
-		'field_mapping',		// array( $csv_col_num => adb_filed)
34
-		'conditions',			/* => array containing condition arrays:
30
+		'num_header_lines', // int number of header lines
31
+		'trash_users_records', // trashes all events of events owner before import
32
+		'field_conversion', // array( $csv_col_num => conversion)
33
+		'field_mapping', // array( $csv_col_num => adb_filed)
34
+		'conditions', /* => array containing condition arrays:
35 35
 				'type' => exists, // record['uid'] exists
36 36
 				'true' => array(
37 37
 					'action' => update,
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * actions wich could be done to data entries
49 49
 	 */
50
-	private static $actions = array( 'none', 'update', 'insert', 'delete', );
50
+	private static $actions = array('none', 'update', 'insert', 'delete',);
51 51
 
52 52
 	/**
53 53
 	 * conditions for actions
54 54
 	 *
55 55
 	 * @var array
56 56
 	 */
57
-	private static $conditions = array( 'exists', 'empty', );
57
+	private static $conditions = array('exists', 'empty',);
58 58
 
59 59
 	/**
60 60
 	 * @var definition
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param string $_charset
98 98
 	 * @param definition $_definition
99 99
 	 */
100
-	public function import( $_stream, definition $_definition ) {
101
-		$import_csv = new import_csv( $_stream, array(
100
+	public function import($_stream, definition $_definition) {
101
+		$import_csv = new import_csv($_stream, array(
102 102
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
103 103
 			'charset' => $_definition->plugin_options['charset'],
104 104
 		));
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$this->definition = $_definition;
107 107
 
108 108
 		// user, is admin ?
109
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
109
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
110 110
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
111 111
 
112 112
 		// dry run?
113
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
113
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
114 114
 
115 115
 		// fetch the calendar bo
116 116
 		$this->bocalupdate = new calendar_boupdate();
@@ -122,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.
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
 
@@ -133,12 +136,16 @@  discard block
 block discarded – undo
133 136
 		$_definition->plugin_options = $plugin_options;
134 137
 
135 138
 		// trash_users_records ?
136
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
137
-			if ( !$_definition->plugin_options['dry_run'] ) {
139
+		if ( $_definition->plugin_options['trash_users_records'] === true )
140
+		{
141
+			if ( !$_definition->plugin_options['dry_run'] )
142
+			{
138 143
 				$socal = new calendar_socal();
139 144
 				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
140 145
 				unset( $socal );
141
-			} else {
146
+			}
147
+			else
148
+			{
142 149
 				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
143 150
 				echo "Attension: All Events of '$lid' would be deleted!\n";
144 151
 			}
@@ -147,38 +154,63 @@  discard block
 block discarded – undo
147 154
 		$this->errors = array();
148 155
 		$this->results = array();
149 156
 
150
-		while ( $record = $import_csv->get_record() ) {
157
+		while ( $record = $import_csv->get_record() )
158
+		{
151 159
 
152 160
 			// don't import empty events
153
-			if( count( array_unique( $record ) ) < 2 ) continue;
161
+			if( count( array_unique( $record ) ) < 2 )
162
+			{
163
+				continue;
164
+			}
154 165
 
155
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
166
+			if ( $_definition->plugin_options['events_owner'] != -1 )
167
+			{
156 168
 				$record['owner'] = $_definition->plugin_options['events_owner'];
157
-			} else unset( $record['owner'] );
169
+			}
170
+			else {
171
+				unset( $record['owner'] );
172
+			}
158 173
 
159
-			if ( $_definition->plugin_options['conditions'] ) {
160
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
161
-					switch ( $condition['type'] ) {
174
+			if ( $_definition->plugin_options['conditions'] )
175
+			{
176
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
177
+				{
178
+					switch ( $condition['type'] )
179
+					{
162 180
 						// exists
163 181
 						case 'exists' :
164 182
 
165
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
183
+							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) )
184
+							{
166 185
 								// apply action to event matching this exists condition
167 186
 								$record['id'] = $event['id'];
168 187
 
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'] );
188
+								if ( $_definition->plugin_options['update_cats'] == 'add' )
189
+								{
190
+									if ( !is_array( $event['cat_id'] ) )
191
+									{
192
+										$event['cat_id'] = explode( ',', $event['cat_id'] );
193
+									}
194
+									if ( !is_array( $record['cat_id'] ) )
195
+									{
196
+										$record['cat_id'] = explode( ',', $record['cat_id'] );
197
+									}
172 198
 									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
173 199
 								}
174 200
 
175 201
 								// check if entry is modiefied
176 202
 								$event = array_intersect_key( $event, $record );
177 203
 								$diff = array_diff( $event, $record );
178
-								if( !empty( $diff ) ) $record['modified'] = time();
204
+								if( !empty( $diff ) )
205
+								{
206
+									$record['modified'] = time();
207
+								}
179 208
 
180 209
 								$action = $condition['true'];
181
-							} else $action = $condition['false'];
210
+							}
211
+							else {
212
+								$action = $condition['false'];
213
+							}
182 214
 
183 215
 							$this->action( $action['action'], $record );
184 216
 							break;
@@ -192,9 +224,14 @@  discard block
 block discarded – undo
192 224
 							throw new Exception('condition not supported!!!');
193 225
 							break;
194 226
 					}
195
-					if ($action['last']) break;
227
+					if ($action['last'])
228
+					{
229
+						break;
230
+					}
196 231
 				}
197
-			} else {
232
+			}
233
+			else
234
+			{
198 235
 				// unconditional insert
199 236
 				$this->action( 'insert', $record );
200 237
 			}
@@ -208,8 +245,10 @@  discard block
 block discarded – undo
208 245
 	 * @param array $_data event data for the action
209 246
 	 * @return bool success or not
210 247
 	 */
211
-	private function action ( $_action, $_data ) {
212
-		switch ( $_action ) {
248
+	private function action ( $_action, $_data )
249
+	{
250
+		switch ( $_action )
251
+		{
213 252
 			case 'none' :
214 253
 				return true;
215 254
 
@@ -219,32 +258,42 @@  discard block
 block discarded – undo
219 258
 				// paticipants handling
220 259
 				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
221 260
 				$_data['participants'] = array();
222
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
261
+				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 )
262
+				{
223 263
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
224 264
 				}
225
-				foreach( $participants as $participant ) {
265
+				foreach( $participants as $participant )
266
+				{
226 267
 					list( $participant, $status ) = explode( '=', $participant );
227 268
 					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
228 269
 					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
229
-					if ( $participant && is_numeric($participant ) ) {
270
+					if ( $participant && is_numeric($participant ) )
271
+					{
230 272
 						$_data['participants'][$participant] = $status;
231 273
 					}
232 274
 				}
233 275
 				// no valid participants so far --> add the importing user/owner
234
-				if ( empty( $_data['participants'] ) ) {
276
+				if ( empty( $_data['participants'] ) )
277
+				{
235 278
 					$_data['participants'][$this->user] = 'A';
236 279
 				}
237 280
 
238 281
 				// are we serious?
239
-				if ( $this->dry_run ) {
282
+				if ( $this->dry_run )
283
+				{
240 284
 					print_r($_data);
241 285
 					$this->results[$_action]++;
242
-				} else {
286
+				}
287
+				else
288
+				{
243 289
 					$messages = array();
244 290
 					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
245
-					if(!$result) {
291
+					if(!$result)
292
+					{
246 293
 						$this->errors = implode(',', $messages);
247
-					} else {
294
+					}
295
+					else
296
+					{
248 297
 						$this->results[$_action]++;
249 298
 					}
250 299
 					return $result;
@@ -259,7 +308,8 @@  discard block
 block discarded – undo
259 308
 	 *
260 309
 	 * @return string name
261 310
 	 */
262
-	public static function get_name() {
311
+	public static function get_name()
312
+	{
263 313
 		return lang('Calendar CSV export');
264 314
 	}
265 315
 
@@ -268,7 +318,8 @@  discard block
 block discarded – undo
268 318
 	 *
269 319
 	 * @return string descriprion
270 320
 	 */
271
-	public static function get_description() {
321
+	public static function get_description()
322
+	{
272 323
 		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.");
273 324
 	}
274 325
 
@@ -277,7 +328,8 @@  discard block
 block discarded – undo
277 328
 	 *
278 329
 	 * @return string suffix (comma seperated)
279 330
 	 */
280
-	public static function get_filesuffix() {
331
+	public static function get_filesuffix()
332
+	{
281 333
 		return 'csv';
282 334
 	}
283 335
 
@@ -293,7 +345,8 @@  discard block
 block discarded – undo
293 345
 	 * 		preserv		=> array,
294 346
 	 * )
295 347
 	 */
296
-	public function get_options_etpl() {
348
+	public function get_options_etpl()
349
+	{
297 350
 		// lets do it!
298 351
 	}
299 352
 
@@ -302,7 +355,8 @@  discard block
 block discarded – undo
302 355
 	 *
303 356
 	 * @return string etemplate name
304 357
 	 */
305
-	public function get_selectors_etpl() {
358
+	public function get_selectors_etpl()
359
+	{
306 360
 		// lets do it!
307 361
 	}
308 362
 
@@ -314,7 +368,8 @@  discard block
 block discarded – undo
314 368
         *       record_# => error message
315 369
         *       )
316 370
         */
317
-        public function get_errors() {
371
+        public function get_errors()
372
+        {
318 373
 		return $this->errors;
319 374
 	}
320 375
 
@@ -326,7 +381,8 @@  discard block
 block discarded – undo
326 381
         *       action => record count
327 382
         * )
328 383
         */
329
-        public function get_results() {
384
+        public function get_results()
385
+        {
330 386
 		return $this->results;
331 387
 	}
332 388
 } // end of iface_export_plugin
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
 	/**
@@ -120,7 +126,10 @@  discard block
 block discarded – undo
120 126
 	{
121 127
 		unset($updateTS);	// ignored, as updating timestamps is required for sync!
122 128
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
123
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
129
+		if (!is_array($messages))
130
+		{
131
+			$messages = $messages ? (array)$messages : array();
132
+		}
124 133
 
125 134
 		if ($this->debug > 1 || $this->debug == 'update')
126 135
 		{
@@ -140,10 +149,13 @@  discard block
 block discarded – undo
140 149
 
141 150
 		$status_reset_to_unknown = false;
142 151
 
143
-		if (($new_event = !$event['id']))	// some defaults for new entries
152
+		if (($new_event = !$event['id']))
153
+		{
154
+			// some defaults for new entries
144 155
 		{
145 156
 			// if no owner given, set user to owner
146 157
 			if (!$event['owner']) $event['owner'] = $this->user;
158
+		}
147 159
 			// set owner as participant if none is given
148 160
 			if (!is_array($event['participants']) || !count($event['participants']))
149 161
 			{
@@ -183,7 +195,10 @@  discard block
 block discarded – undo
183 195
 		// check category based ACL
184 196
 		if ($event['category'])
185 197
 		{
186
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
198
+			if (!is_array($event['category']))
199
+			{
200
+				$event['category'] = explode(',',$event['category']);
201
+			}
187 202
 			if (!$old_event || !isset($old_event['category']))
188 203
 			{
189 204
 				$old_event['category'] = array();
@@ -235,13 +250,16 @@  discard block
 block discarded – undo
235 250
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) &&
236 251
 			(($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding))
237 252
 		{
238
-			if ($checked_excluding)	// warn user if not all recurrences have been checked
253
+			if ($checked_excluding)
254
+			{
255
+				// warn user if not all recurrences have been checked
239 256
 			{
240 257
 				$conflicts['warning'] = array(
241 258
 					'start' => $checked_excluding,
242 259
 					'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)),
243 260
 				);
244 261
 			}
262
+			}
245 263
 			return $conflicts;
246 264
 		}
247 265
 
@@ -305,7 +323,10 @@  discard block
 block discarded – undo
305 323
 		$types_with_quantity = array();
306 324
 		foreach($this->resources as $type => $data)
307 325
 		{
308
-			if ($data['max_quantity']) $types_with_quantity[] = $type;
326
+			if ($data['max_quantity'])
327
+			{
328
+				$types_with_quantity[] = $type;
329
+			}
309 330
 		}
310 331
 		// get all NOT rejected participants and evtl. their quantity
311 332
 		$quantity = $users = array();
@@ -313,12 +334,19 @@  discard block
 block discarded – undo
313 334
 		{
314 335
 			$q = $role = null;
315 336
 			calendar_so::split_status($status, $q, $role);
316
-			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;	// ignore rejected or non-participants
337
+			if ($status == 'R' || $role == 'NON-PARTICIPANT')
338
+			{
339
+				continue;
340
+			}
341
+			// ignore rejected or non-participants
317 342
 
318
-			if ($uid < 0)	// group, check it's members too
343
+			if ($uid < 0)
344
+			{
345
+				// group, check it's members too
319 346
 			{
320 347
 				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
321 348
 			}
349
+			}
322 350
 			$users[] = $uid;
323 351
 			if (in_array($uid[0],$types_with_quantity))
324 352
 			{
@@ -349,18 +377,24 @@  discard block
 block discarded – undo
349 377
 			$startts = $date->format('ts');
350 378
 
351 379
 			// skip past events or recurrences
352
-			if ($startts+$duration < $this->now_su) continue;
380
+			if ($startts+$duration < $this->now_su)
381
+			{
382
+				continue;
383
+			}
353 384
 
354 385
 			// abort check if configured limits are exceeded
355 386
 			if ($event['recur_type'] &&
356 387
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
357 388
 				microtime(true) > $start+$max_check_time ||	// max check time exceeded
358
-				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
389
+				$startts > $this->config['horizont']))
390
+			{
391
+				// we are behind horizon for which recurrences are rendered
359 392
 			{
360 393
 				if ($this->debug > 2 || $this->debug == 'conflicts')
361 394
 				{
362 395
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
363 396
 						$checked, microtime(true)-$start, $date);
397
+			}
364 398
 				}
365 399
 				$checked_excluding = $date;
366 400
 				break;
@@ -384,10 +418,13 @@  discard block
 block discarded – undo
384 418
 			{
385 419
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
386 420
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
387
-					$overlap['non_blocking'])			// that's a non_blocking event
421
+					$overlap['non_blocking'])
422
+				{
423
+					// that's a non_blocking event
388 424
 				{
389 425
 					continue;
390 426
 				}
427
+				}
391 428
 				if ($this->debug > 3 || $this->debug == 'conflicts')
392 429
 				{
393 430
 					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
@@ -507,7 +544,11 @@  discard block
 block discarded – undo
507 544
 	 */
508 545
 	public function check_acl_invite($uid)
509 546
 	{
510
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
547
+		if (!is_numeric($uid))
548
+		{
549
+			return true;
550
+		}
551
+		// nothing implemented for resources so far
511 552
 
512 553
 		if (!$this->require_acl_invite)
513 554
 		{
@@ -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
 					{
@@ -947,7 +998,10 @@  discard block
 block discarded – undo
947 998
 				$details['to-lastname'] = isset($tln)? $tln: '';
948 999
 
949 1000
 				// 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
950
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1001
+				if (!isset($part_prefs['common']['tz']))
1002
+				{
1003
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1004
+				}
951 1005
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
952 1006
 				$timeformat = $part_prefs['common']['timeformat'];
953 1007
 				switch($timeformat)
@@ -982,9 +1036,12 @@  discard block
 block discarded – undo
982 1036
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
983 1037
 				{
984 1038
 					case 'ical':
985
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
1039
+						if (is_null($ics) || $m_type != $msg_type)
1040
+						{
1041
+							// need different ical for organizer notification
986 1042
 						{
987 1043
 							$calendar_ical = new calendar_ical();
1044
+						}
988 1045
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
989 1046
 							// we need to pass $event[id] so iCal class reads event again,
990 1047
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -998,7 +1055,10 @@  discard block
 block discarded – undo
998 1055
 							'encoding' => '8bit',
999 1056
 							'type' => 'text/calendar; method='.$method,
1000 1057
 						);
1001
-						if ($m_type != $msg_type) unset($ics);
1058
+						if ($m_type != $msg_type)
1059
+						{
1060
+							unset($ics);
1061
+						}
1002 1062
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
1003 1063
 						// fall through
1004 1064
 					case 'extended':
@@ -1049,7 +1109,9 @@  discard block
 block discarded – undo
1049 1109
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1050 1110
 						$notification->set_popuplinks(array($details['link_arr']));
1051 1111
 
1052
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1112
+						if(is_array($attachment))
1113
+						{
1114
+$notification->set_attachments(array($attachment)); }
1053 1115
 						$notification->send();
1054 1116
 						foreach(notifications::errors(true) as $error)
1055 1117
 						{
@@ -1085,7 +1147,10 @@  discard block
 block discarded – undo
1085 1147
 			Api\Translation::init();
1086 1148
 		}
1087 1149
 		// restore timezone, in case we had to reset it to server-timezone
1088
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1150
+		if ($restore_tz)
1151
+		{
1152
+			date_default_timezone_set($restore_tz);
1153
+		}
1089 1154
 
1090 1155
 		return true;
1091 1156
 	}
@@ -1120,10 +1185,13 @@  discard block
 block discarded – undo
1120 1185
 		{
1121 1186
 			$to_notify = $event['participants'];
1122 1187
 		}
1123
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1188
+		elseif ($this->check_perms(Acl::READ,$event))
1189
+		{
1190
+			// checks agains $this->owner set to $alarm[owner]
1124 1191
 		{
1125 1192
 			$to_notify[$alarm['owner']] = 'A';
1126 1193
 		}
1194
+		}
1127 1195
 		else
1128 1196
 		{
1129 1197
 			return False;	// no rights
@@ -1172,14 +1240,20 @@  discard block
 block discarded – undo
1172 1240
 		if ($event['id'])
1173 1241
 		{
1174 1242
 			// invalidate the read-cache if it contains the event we store now
1175
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1243
+			if ($event['id'] == self::$cached_event['id'])
1244
+			{
1245
+				self::$cached_event = array();
1246
+			}
1176 1247
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1177 1248
 		}
1178 1249
 		else
1179 1250
 		{
1180 1251
 			$old_event = null;
1181 1252
 		}
1182
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1253
+		if (!isset($event['whole_day']))
1254
+		{
1255
+			$event['whole_day'] = $this->isWholeDay($event);
1256
+		}
1183 1257
 
1184 1258
 		// set recur-enddate/range-end to real end-date of last recurrence
1185 1259
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'])
@@ -1256,7 +1330,10 @@  discard block
 block discarded – undo
1256 1330
 		foreach($timestamps as $ts)
1257 1331
 		{
1258 1332
 			// we convert here from user-time to timestamps in server-time!
1259
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1333
+			if (isset($event[$ts]))
1334
+			{
1335
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1336
+			}
1260 1337
 		}
1261 1338
 		// convert tzid name to integer tz_id, of set user default
1262 1339
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1306,7 +1383,10 @@  discard block
 block discarded – undo
1306 1383
 				if (!isset($event['alarm'][$id]))
1307 1384
 				{
1308 1385
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1309
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1386
+					if ($alarm['time'] < time())
1387
+					{
1388
+						calendar_so::shift_alarm($event, $alarm);
1389
+					}
1310 1390
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1311 1391
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1312 1392
 						$old_event['participants'][$alarm['owner']];
@@ -1362,7 +1442,10 @@  discard block
 block discarded – undo
1362 1442
 
1363 1443
 		// Update history
1364 1444
 		$tracking = new calendar_tracking($this);
1365
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1445
+		if (empty($event['id']) && !empty($cal_id))
1446
+		{
1447
+			$event['id']=$cal_id;
1448
+		}
1366 1449
 		$tracking->track($event, $old_event);
1367 1450
 
1368 1451
 		return $cal_id;
@@ -1379,9 +1462,12 @@  discard block
 block discarded – undo
1379 1462
 	 */
1380 1463
 	function check_status_perms($uid,$event)
1381 1464
 	{
1382
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1465
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1466
+		{
1467
+			// for contact we use the owner of the event
1383 1468
 		{
1384 1469
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1470
+		}
1385 1471
 
1386 1472
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1387 1473
 		}
@@ -1392,13 +1478,19 @@  discard block
 block discarded – undo
1392 1478
 			return $access;
1393 1479
 		}
1394 1480
 		// no access or denied access because of category acl --> regular check
1395
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1481
+		if (!is_numeric($uid))
1482
+		{
1483
+			// this is eg. for resources (r123)
1396 1484
 		{
1397 1485
 			$resource = $this->resource_info($uid);
1486
+		}
1398 1487
 
1399 1488
 			return Acl::EDIT & $resource['rights'];
1400 1489
 		}
1401
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1490
+		if (!is_array($event) && !($event = $this->read($event)))
1491
+		{
1492
+			return false;
1493
+		}
1402 1494
 
1403 1495
 		// regular user and groups (need to check memberships too)
1404 1496
 		if (!isset($event['participants'][$uid]))
@@ -1422,7 +1514,10 @@  discard block
 block discarded – undo
1422 1514
 	 */
1423 1515
 	function check_cat_acl($right,$event)
1424 1516
 	{
1425
-		if (!is_array($event)) $event = $this->read($event);
1517
+		if (!is_array($event))
1518
+		{
1519
+			$event = $this->read($event);
1520
+		}
1426 1521
 
1427 1522
 		$ret = null;
1428 1523
 		if ($event['category'])
@@ -1479,7 +1574,10 @@  discard block
 block discarded – undo
1479 1574
 	public static function set_cat_rights($cat_id,$user,$rights)
1480 1575
 	{
1481 1576
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1482
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1577
+		if (!isset(self::$cat_rights_cache))
1578
+		{
1579
+			self::get_cat_rights($cat_id);
1580
+		}
1483 1581
 
1484 1582
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1485 1583
 		{
@@ -1491,7 +1589,10 @@  discard block
 block discarded – undo
1491 1589
 			else
1492 1590
 			{
1493 1591
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1494
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1592
+				if (!self::$cat_rights_cache['L'.$cat_id])
1593
+				{
1594
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1595
+				}
1495 1596
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1496 1597
 			}
1497 1598
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1524,7 +1625,10 @@  discard block
 block discarded – undo
1524 1625
 				foreach($cat_rights as $uid => $value)
1525 1626
 				{
1526 1627
 					$all |= $value;
1527
-					if (in_array($uid,$memberships)) $own |= $value;
1628
+					if (in_array($uid,$memberships))
1629
+					{
1630
+						$own |= $value;
1631
+					}
1528 1632
 				}
1529 1633
 			}
1530 1634
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1571,13 +1675,16 @@  discard block
 block discarded – undo
1571 1675
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1572 1676
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1573 1677
 		{
1574
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1678
+			if ($status == 'R')
1679
+			{
1680
+				// remove alarms belonging to rejected participants
1575 1681
 			{
1576 1682
 				foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1577 1683
 				{
1578 1684
 					if ((string)$alarm['owner'] === (string)$uid)
1579 1685
 					{
1580 1686
 						$this->so->delete_alarm($id);
1687
+			}
1581 1688
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1582 1689
 					}
1583 1690
 				}
@@ -1594,8 +1701,15 @@  discard block
 block discarded – undo
1594 1701
 			
1595 1702
 			if (isset($status2msg[$status]) && !$skip_notification)
1596 1703
 			{
1597
-				if (!is_array($event)) $event = $this->read($cal_id);
1598
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1704
+				if (!is_array($event))
1705
+				{
1706
+					$event = $this->read($cal_id);
1707
+				}
1708
+				if (isset($recur_date))
1709
+				{
1710
+					$event = $this->read($event['id'],$recur_date);
1711
+				}
1712
+				//re-read the actually edited recurring event
1599 1713
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1600 1714
 			}
1601 1715
 
@@ -1618,12 +1732,16 @@  discard block
 block discarded – undo
1618 1732
 	 */
1619 1733
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1620 1734
 	{
1621
-		if (!isset($new_event['participants'])) return;
1735
+		if (!isset($new_event['participants']))
1736
+		{
1737
+			return;
1738
+		}
1622 1739
 
1623 1740
 		// check the old list against the new list
1624 1741
 		foreach ($old_event['participants'] as $userid => $status)
1625
-  		{
1626
-            if (!isset($new_event['participants'][$userid])){
1742
+		{
1743
+            if (!isset($new_event['participants'][$userid]))
1744
+            {
1627 1745
             	// Attendee will be deleted this way
1628 1746
             	$new_event['participants'][$userid] = 'G';
1629 1747
             }
@@ -1706,7 +1824,10 @@  discard block
 block discarded – undo
1706 1824
 					}
1707 1825
 					else
1708 1826
 					{
1709
-						if (!($exception = $this->read($id))) continue;
1827
+						if (!($exception = $this->read($id)))
1828
+						{
1829
+							continue;
1830
+						}
1710 1831
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1711 1832
 						$exception['reference'] = $exception['recurrence'] = 0;
1712 1833
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1777,7 +1898,10 @@  discard block
 block discarded – undo
1777 1898
 		$event_arr = $this->event2array($event);
1778 1899
 		foreach($event_arr as $key => $val)
1779 1900
 		{
1780
-			if ($key == 'recur_type') $key = 'repetition';
1901
+			if ($key == 'recur_type')
1902
+			{
1903
+				$key = 'repetition';
1904
+			}
1781 1905
 			$details[$key] = $val['data'];
1782 1906
 		}
1783 1907
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1950,7 +2074,10 @@  discard block
 block discarded – undo
1950 2074
 	 */
1951 2075
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1952 2076
 	{
1953
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
2077
+		if ($old_event !== null && $event['start'] == $old_event['start'])
2078
+		{
2079
+			return;
2080
+		}
1954 2081
 
1955 2082
 		$time = new Api\DateTime($event['start']);
1956 2083
 		if(!is_array($event['alarm']))
@@ -2024,7 +2151,10 @@  discard block
 block discarded – undo
2024 2151
 		if (is_array($old_event) || $old_event > 0)
2025 2152
 		{
2026 2153
 			// preserve categories without users read access
2027
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2154
+			if (!is_array($old_event))
2155
+			{
2156
+				$old_event = $this->read($old_event);
2157
+			}
2028 2158
 			$old_categories = explode(',',$old_event['category']);
2029 2159
 			$old_cats_preserve = array();
2030 2160
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -2115,7 +2245,10 @@  discard block
 block discarded – undo
2115 2245
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2116 2246
 		}
2117 2247
 
2118
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2248
+		if (!isset($event['recurrence']))
2249
+		{
2250
+			$event['recurrence'] = 0;
2251
+		}
2119 2252
 
2120 2253
 		if ($filter == 'master')
2121 2254
 		{
@@ -2169,19 +2302,26 @@  discard block
 block discarded – undo
2169 2302
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2170 2303
 						}
2171 2304
 					}
2172
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2305
+				}
2306
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2173 2307
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2174 2308
 							strpos($egwEvent['title'], $event['title']) === 0))
2175 2309
 				{
2176 2310
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2177 2311
 				}
2178 2312
 			}
2179
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2313
+			if (!empty($matchingEvents) || $filter == 'exact')
2314
+			{
2315
+				return $matchingEvents;
2316
+			}
2180 2317
 		}
2181 2318
 		unset($event['id']);
2182 2319
 
2183 2320
 		// No chance to find a master without [U]ID
2184
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2321
+		if ($filter == 'master' && empty($event['uid']))
2322
+		{
2323
+			return $matchingEvents;
2324
+		}
2185 2325
 
2186 2326
 		// only query calendars of users, we have READ-grants from
2187 2327
 		$users = array();
@@ -2190,17 +2330,23 @@  discard block
 block discarded – undo
2190 2330
 			$user = trim($user);
2191 2331
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2192 2332
 			{
2193
-				if ($user && !in_array($user,$users))	// already added?
2333
+				if ($user && !in_array($user,$users))
2334
+				{
2335
+					// already added?
2194 2336
 				{
2195 2337
 					$users[] = $user;
2196 2338
 				}
2339
+				}
2197 2340
 			}
2198 2341
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2199 2342
 			{
2200 2343
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2201 2344
 			}
2202 2345
 			// the further code is only for real users
2203
-			if (!is_numeric($user)) continue;
2346
+			if (!is_numeric($user))
2347
+			{
2348
+				continue;
2349
+			}
2204 2350
 
2205 2351
 			// for groups we have to include the members
2206 2352
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2280,7 +2426,10 @@  discard block
 block discarded – undo
2280 2426
 			}
2281 2427
 			foreach ($matchFields as $key)
2282 2428
 			{
2283
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2429
+				if (isset($event[$key]))
2430
+				{
2431
+					$query['cal_'.$key] = $event[$key];
2432
+				}
2284 2433
 			}
2285 2434
 		}
2286 2435
 
@@ -2320,7 +2469,10 @@  discard block
 block discarded – undo
2320 2469
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2321 2470
 			}
2322 2471
 
2323
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2472
+			if (in_array($egwEvent['id'], $matchingEvents))
2473
+			{
2474
+				continue;
2475
+			}
2324 2476
 
2325 2477
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2326 2478
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2487,13 +2639,16 @@  discard block
 block discarded – undo
2487 2639
 					foreach ($event['participants'] as $attendee => $status)
2488 2640
 					{
2489 2641
 						if (!isset($egwEvent['participants'][$attendee]) &&
2490
-								$attendee != $egwEvent['owner']) // ||
2642
+								$attendee != $egwEvent['owner'])
2643
+						{
2644
+							// ||
2491 2645
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2492 2646
 						{
2493 2647
 							if ($this->log)
2494 2648
 							{
2495 2649
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2496 2650
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2651
+						}
2497 2652
 							}
2498 2653
 							continue 2;
2499 2654
 						}
@@ -2815,7 +2970,10 @@  discard block
 block discarded – undo
2815 2970
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2816 2971
 		{
2817 2972
 			// we convert here from server-time to timestamps in user-time!
2818
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2973
+			if (isset($event[$ts]))
2974
+			{
2975
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2976
+			}
2819 2977
 		}
2820 2978
 		// same with the recur exceptions
2821 2979
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2843,9 +3001,12 @@  discard block
 block discarded – undo
2843 3001
 	 */
2844 3002
 	function purge($age)
2845 3003
 	{
2846
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
3004
+		if (is_numeric($age) && $age > 0)
3005
+		{
3006
+			// just make sure bogus values dont delete everything
2847 3007
 		{
2848 3008
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2849 3009
 		}
3010
+		}
2850 3011
 	}
2851 3012
 }
Please login to merge, or discard this patch.
Spacing   +307 added lines, -309 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,16 +116,16 @@  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
-		unset($updateTS);	// ignored, as updating timestamps is required for sync!
121
+		unset($updateTS); // ignored, as updating timestamps is required for sync!
122 122
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
123 123
 		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
124 124
 
125 125
 		if ($this->debug > 1 || $this->debug == 'update')
126 126
 		{
127 127
 			$this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)',
128
-				false,$event,$ignore_conflicts,$touch_modified,$ignore_acl);
128
+				false, $event, $ignore_conflicts, $touch_modified, $ignore_acl);
129 129
 		}
130 130
 		// check some minimum requirements:
131 131
 		// - new events need start, end and title
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 
155 155
 		// check if user has the permission to update / create the event
156
-		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) ||
157
-			$new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) &&
158
-			!$this->check_perms(Acl::ADD,0,$event['owner']))
156
+		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) ||
157
+			$new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) &&
158
+			!$this->check_perms(Acl::ADD, 0, $event['owner']))
159 159
 		{
160
-			$messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner']));
160
+			$messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner']));
161 161
 			return false;
162 162
 		}
163 163
 		if ($new_event)
@@ -166,24 +166,24 @@  discard block
 block discarded – undo
166 166
 		}
167 167
 		else
168 168
 		{
169
-			$old_event = $this->read((int)$event['id'],null,$ignore_acl);
169
+			$old_event = $this->read((int)$event['id'], null, $ignore_acl);
170 170
 		}
171 171
 
172 172
 		// do we need to check, if user is allowed to invite the invited participants
173
-		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event)))
173
+		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event)))
174 174
 		{
175 175
 			// report removed participants back to user
176
-			foreach($removed as $key => $account_id)
176
+			foreach ($removed as $key => $account_id)
177 177
 			{
178 178
 				$removed[$key] = $this->participant_name($account_id);
179 179
 			}
180
-			$messages[] = lang('%1 participants removed because of missing invite grants',count($removed)).
181
-				': '.implode(', ',$removed);
180
+			$messages[] = lang('%1 participants removed because of missing invite grants', count($removed)).
181
+				': '.implode(', ', $removed);
182 182
 		}
183 183
 		// check category based ACL
184 184
 		if ($event['category'])
185 185
 		{
186
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
186
+			if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']);
187 187
 			if (!$old_event || !isset($old_event['category']))
188 188
 			{
189 189
 				$old_event['category'] = array();
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 			{
193 193
 				$old_event['category'] = explode(',', $old_event['category']);
194 194
 			}
195
-			foreach($event['category'] as $key => $cat_id)
195
+			foreach ($event['category'] as $key => $cat_id)
196 196
 			{
197 197
 				// check if user is allowed to update event categories
198
-				if ((!$old_event || !in_array($cat_id,$old_event['category'])) &&
199
-					self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false)
198
+				if ((!$old_event || !in_array($cat_id, $old_event['category'])) &&
199
+					self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false)
200 200
 				{
201 201
 					unset($event['category'][$key]);
202 202
 					// report removed category to user
203 203
 					$removed_cats[$cat_id] = $this->categories->id2name($cat_id);
204
-					continue;	// no further check, as cat was removed
204
+					continue; // no further check, as cat was removed
205 205
 				}
206 206
 				// for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown
207 207
 				if (!$status_reset_to_unknown &&
208
-					self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false &&
208
+					self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false &&
209 209
 					(!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end']))
210 210
 				{
211
-					foreach((array)$event['participants'] as $uid => $status)
211
+					foreach ((array)$event['participants'] as $uid => $status)
212 212
 					{
213 213
 						$q = $r = null;
214
-						calendar_so::split_status($status,$q,$r);
214
+						calendar_so::split_status($status, $q, $r);
215 215
 						if ($status != 'U')
216 216
 						{
217
-							$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
217
+							$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
218 218
 							// todo: report reset status to user
219 219
 						}
220 220
 					}
221
-					$status_reset_to_unknown = true;	// once is enough
221
+					$status_reset_to_unknown = true; // once is enough
222 222
 				}
223 223
 			}
224 224
 			if ($removed_cats)
225 225
 			{
226
-				$messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats));
226
+				$messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats));
227 227
 			}
228 228
 			if ($status_reset_to_unknown)
229 229
 			{
@@ -259,30 +259,30 @@  discard block
 block discarded – undo
259 259
 		$event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null);
260 260
 		//error_log("new $cal_id=". array2string($event));
261 261
 
262
-		if($old_event['deleted'] && $event['deleted'] == null)
262
+		if ($old_event['deleted'] && $event['deleted'] == null)
263 263
 		{
264 264
 			// Restored, bring back links
265 265
 			Link::restore('calendar', $cal_id);
266 266
 		}
267 267
 		if ($this->log_file)
268 268
 		{
269
-			$this->log2file($event2save,$event,$old_event);
269
+			$this->log2file($event2save, $event, $old_event);
270 270
 		}
271 271
 		// send notifications
272
-		if(!$skip_notification)
272
+		if (!$skip_notification)
273 273
 		{
274 274
 			if ($new_event)
275 275
 			{
276
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
276
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
277 277
 			}
278 278
 			else // update existing event
279 279
 			{
280
-				$this->check4update($event,$old_event);
280
+				$this->check4update($event, $old_event);
281 281
 			}
282 282
 		}
283 283
 
284 284
 		// notify the link-class about the update, as other apps may be subscribt to it
285
-		Link::notify_update('calendar',$cal_id,$event);
285
+		Link::notify_update('calendar', $cal_id, $event);
286 286
 
287 287
 		return $cal_id;
288 288
 	}
@@ -300,27 +300,27 @@  discard block
 block discarded – undo
300 300
 	 * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked
301 301
 	 * @return array or events
302 302
 	 */
303
-	function conflicts(array $event, &$checked_excluding=null)
303
+	function conflicts(array $event, &$checked_excluding = null)
304 304
 	{
305 305
 		$types_with_quantity = array();
306
-		foreach($this->resources as $type => $data)
306
+		foreach ($this->resources as $type => $data)
307 307
 		{
308 308
 			if ($data['max_quantity']) $types_with_quantity[] = $type;
309 309
 		}
310 310
 		// get all NOT rejected participants and evtl. their quantity
311 311
 		$quantity = $users = array();
312
-		foreach($event['participants'] as $uid => $status)
312
+		foreach ($event['participants'] as $uid => $status)
313 313
 		{
314 314
 			$q = $role = null;
315 315
 			calendar_so::split_status($status, $q, $role);
316
-			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;	// ignore rejected or non-participants
316
+			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants
317 317
 
318 318
 			if ($uid < 0)	// group, check it's members too
319 319
 			{
320
-				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
320
+				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true)));
321 321
 			}
322 322
 			$users[] = $uid;
323
-			if (in_array($uid[0],$types_with_quantity))
323
+			if (in_array($uid[0], $types_with_quantity))
324 324
 			{
325 325
 				$quantity[$uid] = $q;
326 326
 			}
@@ -343,58 +343,58 @@  discard block
 block discarded – undo
343 343
 		}
344 344
 		$checked = 0;
345 345
 		$start = microtime(true);
346
-		$duration = $event['end']-$event['start'];
347
-		foreach($recurences as $date)
346
+		$duration = $event['end'] - $event['start'];
347
+		foreach ($recurences as $date)
348 348
 		{
349 349
 			$startts = $date->format('ts');
350 350
 
351 351
 			// skip past events or recurrences
352
-			if ($startts+$duration < $this->now_su) continue;
352
+			if ($startts + $duration < $this->now_su) continue;
353 353
 
354 354
 			// abort check if configured limits are exceeded
355 355
 			if ($event['recur_type'] &&
356 356
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
357
-				microtime(true) > $start+$max_check_time ||	// max check time exceeded
357
+				microtime(true) > $start + $max_check_time || // max check time exceeded
358 358
 				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
359 359
 			{
360 360
 				if ($this->debug > 2 || $this->debug == 'conflicts')
361 361
 				{
362 362
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
363
-						$checked, microtime(true)-$start, $date);
363
+						$checked, microtime(true) - $start, $date);
364 364
 				}
365 365
 				$checked_excluding = $date;
366 366
 				break;
367 367
 			}
368
-			$overlapping_events =& $this->search(array(
368
+			$overlapping_events = & $this->search(array(
369 369
 				'start' => $startts,
370
-				'end'   => $startts+$duration,
370
+				'end'   => $startts + $duration,
371 371
 				'users' => $users,
372
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
373
-				'enum_groups' => true,	// otherwise group-events would not block time
372
+				'ignore_acl' => true, // otherwise we get only events readable by the user
373
+				'enum_groups' => true, // otherwise group-events would not block time
374 374
 				'query' => array(
375 375
 					'cal_non_blocking' => 0,
376 376
 				),
377
-				'no_integration' => true,	// do NOT use integration of other apps
377
+				'no_integration' => true, // do NOT use integration of other apps
378 378
 			));
379 379
 			if ($this->debug > 2 || $this->debug == 'conflicts')
380 380
 			{
381
-				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration);
381
+				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration);
382 382
 			}
383
-			foreach((array) $overlapping_events as $k => $overlap)
383
+			foreach ((array)$overlapping_events as $k => $overlap)
384 384
 			{
385
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
386
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
385
+				if ($overlap['id'] == $event['id'] || // that's the event itself
386
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
387 387
 					$overlap['non_blocking'])			// that's a non_blocking event
388 388
 				{
389 389
 					continue;
390 390
 				}
391 391
 				if ($this->debug > 3 || $this->debug == 'conflicts')
392 392
 				{
393
-					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
393
+					$this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap);
394 394
 				}
395 395
 				// check if the overlap is with a rejected participant or within the allowed quantity
396
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
397
-				foreach($common_parts as $n => $uid)
396
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
397
+				foreach ($common_parts as $n => $uid)
398 398
 				{
399 399
 					$status = $overlap['participants'][$uid];
400 400
 					calendar_so::split_status($status, $q, $role);
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 						unset($common_parts[$n]);
404 404
 						continue;
405 405
 					}
406
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
406
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
407 407
 					{
408
-						continue;	// no quantity check: quantity allways 1 ==> conflict
408
+						continue; // no quantity check: quantity allways 1 ==> conflict
409 409
 					}
410 410
 					if (!isset($max_quantity[$uid]))
411 411
 					{
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					$quantity[$uid] += $q;
416 416
 					if ($quantity[$uid] <= $max_quantity[$uid])
417 417
 					{
418
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
418
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
419 419
 						unset($common_parts[$n]);
420 420
 						continue;
421 421
 					}
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 				{
426 426
 					if ($this->debug > 3 || $this->debug == 'conflicts')
427 427
 					{
428
-						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts);
428
+						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts);
429 429
 					}
430
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
430
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
431 431
 				}
432 432
 			}
433 433
 		}
434 434
 		//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
435 435
 		// check if we are withing the allowed quantity and if not add all events using that resource
436 436
 		// seems this function is doing very strange things, it gives empty conflicts
437
-		foreach($max_quantity as $uid => $max)
437
+		foreach ($max_quantity as $uid => $max)
438 438
 		{
439 439
 			if ($quantity[$uid] > $max)
440 440
 			{
441
-				foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
441
+				foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
442 442
 				{
443
-					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
443
+					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
444 444
 				}
445 445
 			}
446 446
 		}
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 
449 449
 		if (count($conflicts))
450 450
 		{
451
-			foreach($conflicts as $key => $conflict)
451
+			foreach ($conflicts as $key => $conflict)
452 452
 			{
453
-					$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
454
-				if (!$this->check_perms(Acl::READ,$conflict))
453
+					$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
454
+				if (!$this->check_perms(Acl::READ, $conflict))
455 455
 				{
456 456
 					$conflicts[$key] = array(
457 457
 						'id'    => $conflict['id'],
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 			}
465 465
 			if ($this->debug > 2 || $this->debug == 'conflicts')
466 466
 			{
467
-				$this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts);
467
+				$this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts);
468 468
 			}
469 469
 		}
470 470
 		return $conflicts;
@@ -476,22 +476,22 @@  discard block
 block discarded – undo
476 476
 	 * @param array $old_event =null old event with already invited participants
477 477
 	 * @return array removed participants because of missing invite grants
478 478
 	 */
479
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
479
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
480 480
 	{
481 481
 		if (!$this->require_acl_invite)
482 482
 		{
483
-			return array();	// nothing to check, everyone can invite everyone else
483
+			return array(); // nothing to check, everyone can invite everyone else
484 484
 		}
485 485
 		if ($event['id'] && is_null($old_event))
486 486
 		{
487 487
 			$old_event = $this->read($event['id']);
488 488
 		}
489 489
 		$removed = array();
490
-		foreach(array_keys((array)$event['participants']) as $uid)
490
+		foreach (array_keys((array)$event['participants']) as $uid)
491 491
 		{
492 492
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
493 493
 			{
494
-				unset($event['participants'][$uid]);	// remove participant
494
+				unset($event['participants'][$uid]); // remove participant
495 495
 				$removed[] = $uid;
496 496
 			}
497 497
 		}
@@ -507,19 +507,19 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	public function check_acl_invite($uid)
509 509
 	{
510
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
510
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
511 511
 
512 512
 		if (!$this->require_acl_invite)
513 513
 		{
514
-			$ret = true;	// no grant required
514
+			$ret = true; // no grant required
515 515
 		}
516 516
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
517 517
 		{
518
-			$ret = true;	// grant only required for groups
518
+			$ret = true; // grant only required for groups
519 519
 		}
520 520
 		else
521 521
 		{
522
-			$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
522
+			$ret = $this->check_perms(self::ACL_INVITE, 0, $uid);
523 523
 		}
524 524
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
525 525
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	 * @param array $old_event the event before the update
534 534
 	 * @todo check if there is a real change, not assume every save is a change
535 535
 	 */
536
-	function check4update($new_event,$old_event)
536
+	function check4update($new_event, $old_event)
537 537
 	{
538 538
 		//error_log(__METHOD__."($new_event[title])");
539 539
 		$modified = $added = $deleted = array();
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
542 542
 
543 543
 		// Find modified and deleted participants ...
544
-		foreach($old_event['participants'] as $old_userid => $old_status)
544
+		foreach ($old_event['participants'] as $old_userid => $old_status)
545 545
 		{
546
-			if(isset($new_event['participants'][$old_userid]))
546
+			if (isset($new_event['participants'][$old_userid]))
547 547
 			{
548 548
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
549 549
 			}
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
 			}
554 554
 		}
555 555
 		// Find new participants ...
556
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
556
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
557 557
 		{
558
-			if(!isset($old_event['participants'][$new_userid]))
558
+			if (!isset($old_event['participants'][$new_userid]))
559 559
 			{
560 560
 				$added[$new_userid] = 'U';
561 561
 			}
562 562
 		}
563 563
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
564
-		if(count($added) || count($modified) || count($deleted))
564
+		if (count($added) || count($modified) || count($deleted))
565 565
 		{
566
-			if(count($added))
566
+			if (count($added))
567 567
 			{
568
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
568
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
569 569
 			}
570
-			if(count($modified))
570
+			if (count($modified))
571 571
 			{
572
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
572
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
573 573
 			}
574
-			if(count($deleted))
574
+			if (count($deleted))
575 575
 			{
576
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
576
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
577 577
 			}
578 578
 		}
579 579
 	}
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
 	 * @param string $status of current user
591 591
 	 * @return boolean true = update requested, false otherwise
592 592
 	 */
593
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
593
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
594 594
 	{
595 595
 		if ($msg_type == MSG_ALARM)
596 596
 		{
597
-			return True;	// always True for now
597
+			return True; // always True for now
598 598
 		}
599 599
 		$want_update = 0;
600 600
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		//
603 603
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
604 604
 
605
-		switch($ru = $part_prefs['calendar']['receive_updates'])
605
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
606 606
 		{
607 607
 			case 'responses':
608 608
 				++$want_update;
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 			default:
617 617
 				if (is_array($new_event) && is_array($old_event))
618 618
 				{
619
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
620
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
619
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
620
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
621 621
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
622 622
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
623 623
 					{
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
638 638
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
639 639
 				{
640
-					switch($msg_type)
640
+					switch ($msg_type)
641 641
 					{
642 642
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
643 643
 							$msg_type = MSG_REJECTED;
644 644
 							break;
645 645
 						case MSG_ADDED:		// new events use added, but organizer needs status
646
-							switch($status[0])
646
+							switch ($status[0])
647 647
 							{
648 648
 								case 'A': $msg_type = MSG_ACCEPTED; break;
649 649
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 	 * @param string $role ='REQ-PARTICIPANT'
669 669
 	 * @return boolean true if user requested to be notified, false if not
670 670
 	 */
671
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
671
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
672 672
 	{
673 673
 		// check if email is from a user
674 674
 		if (is_numeric($user_or_email))
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 				)
693 693
 			);
694 694
 		}
695
-		switch($ical_method)
695
+		switch ($ical_method)
696 696
 		{
697 697
 			default:
698 698
 			case 'REQUEST':
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
 	 * @param string& $action=null on return verbose name
718 718
 	 * @param string& $msg=null on return notification message
719 719
 	 */
720
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
720
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
721 721
 	{
722
-		switch($msg_type)
722
+		switch ($msg_type)
723 723
 		{
724 724
 			case MSG_DELETED:
725 725
 				$action = 'Canceled';
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		$msg = $this->cal_prefs['notify'.$pref];
772 772
 		if (empty($msg))
773 773
 		{
774
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
774
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
775 775
 		}
776 776
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
777 777
 		return $method;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 * @param int $user =0 User who started the notify, default current user
788 788
 	 * @return bool true/false
789 789
 	 */
790
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
790
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
791 791
 	{
792 792
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
793 793
 		if (!is_array($to_notify))
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
800 800
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
801 801
 		{
802
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
802
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
803 803
 		}
804 804
 
805 805
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
806
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
806
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
807 807
 		{
808 808
 			return False;
809 809
 		}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 			$restore_tz = $tz;
814 814
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
815 815
 		}
816
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
816
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
817 817
 
818 818
 		if (!$user)
819 819
 		{
@@ -829,16 +829,16 @@  discard block
 block discarded – undo
829 829
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
830 830
 
831 831
 		// add all group-members to the notification, unless they are already participants
832
-		foreach($to_notify as $userid => $statusid)
832
+		foreach ($to_notify as $userid => $statusid)
833 833
 		{
834 834
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
835 835
 				($members = $GLOBALS['egw']->accounts->members($userid, true)))
836 836
 			{
837
-				foreach($members as $member)
837
+				foreach ($members as $member)
838 838
 				{
839 839
 					if (!isset($to_notify[$member]))
840 840
 					{
841
-						$to_notify[$member] = 'G';	// Group-invitation
841
+						$to_notify[$member] = 'G'; // Group-invitation
842 842
 					}
843 843
 				}
844 844
 			}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
851 851
 		//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 852
 		$owner_prefs = $ics = null;
853
-		foreach($to_notify as $userid => $statusid)
853
+		foreach ($to_notify as $userid => $statusid)
854 854
 		{
855 855
 			$res_info = $quantity = $role = null;
856 856
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -873,14 +873,14 @@  discard block
 block discarded – undo
873 873
 
874 874
 				if (!isset($userid))
875 875
 				{
876
-					if (empty($res_info['email'])) continue;	// no way to notify
876
+					if (empty($res_info['email'])) continue; // no way to notify
877 877
 					// check if event-owner wants non-EGroupware users notified
878 878
 					if (is_null($owner_prefs))
879 879
 					{
880 880
 						$preferences = new Api\Preferences($owner);
881 881
 						$owner_prefs = $preferences->read_repository();
882 882
 					}
883
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
883
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
884 884
 						(empty($owner_prefs['calendar']['notify_externals']) ||
885 885
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
886 886
 					{
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
 
893 893
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
894 894
 			{
895
-				continue;	// dont notify rejected participants or groups
895
+				continue; // dont notify rejected participants or groups
896 896
 			}
897 897
 
898
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
898
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
899 899
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
900
-					$user_prefs['calendar']['receive_own_updates']==1) ||
900
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
901 901
 				$msg_type == MSG_ALARM)
902 902
 			{
903 903
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 					$preferences = new Api\Preferences($userid);
907 907
 					$GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository();
908 908
 					$fullname = Api\Accounts::username($userid);
909
-					$tfn = Api\Accounts::id2name($userid,'account_firstname');
910
-					$tln = Api\Accounts::id2name($userid,'account_lastname');
909
+					$tfn = Api\Accounts::id2name($userid, 'account_firstname');
910
+					$tln = Api\Accounts::id2name($userid, 'account_lastname');
911 911
 				}
912 912
 				else	// external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification)
913 913
 				{
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 					}
919 919
 					$part_prefs = $owner_prefs;
920 920
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
921
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
921
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
922 922
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
923 923
 				}
924 924
 				$m_type = $msg_type;
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
944 944
 					$action, $event_arr, $disinvited);
945 945
 				$details['to-fullname'] = $fullname;
946
-				$details['to-firstname'] = isset($tfn)? $tfn: '';
947
-				$details['to-lastname'] = isset($tln)? $tln: '';
946
+				$details['to-firstname'] = isset($tfn) ? $tfn : '';
947
+				$details['to-lastname'] = isset($tln) ? $tln : '';
948 948
 
949 949
 				// 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
950 950
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
951 951
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
952 952
 				$timeformat = $part_prefs['common']['timeformat'];
953
-				switch($timeformat)
953
+				switch ($timeformat)
954 954
 				{
955 955
 			  		case '24':
956 956
 						$timeformat = 'H:i';
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 						$timeformat = 'h:i a';
960 960
 						break;
961 961
 				}
962
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
962
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
963 963
 
964 964
 				$startdate->setTimezone($timezone);
965 965
 				$details['startdate'] = $startdate->format($timeformat);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 				$details['enddate'] = $enddate->format($timeformat);
969 969
 
970 970
 				$modified->setTimezone($timezone);
971
-				$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
971
+				$details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']);
972 972
 
973 973
 				if ($old_event != False)
974 974
 				{
@@ -977,15 +977,14 @@  discard block
 block discarded – undo
977 977
 				}
978 978
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
979 979
 
980
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
980
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
981 981
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
982
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
982
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
983 983
 				{
984
-					case 'ical':
985
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
984
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
986 985
 						{
987 986
 							$calendar_ical = new calendar_ical();
988
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
987
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
989 988
 							// we need to pass $event[id] so iCal class reads event again,
990 989
 							// as event is in user TZ, but iCal class expects server TZ!
991 990
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -1004,11 +1003,11 @@  discard block
 block discarded – undo
1004 1003
 					case 'extended':
1005 1004
 
1006 1005
 						$details_body = lang('Event Details follow').":\n";
1007
-						foreach($event_arr as $key => $val)
1006
+						foreach ($event_arr as $key => $val)
1008 1007
 						{
1009
-							if(!empty($details[$key]))
1008
+							if (!empty($details[$key]))
1010 1009
 							{
1011
-								switch($key)
1010
+								switch ($key)
1012 1011
 								{
1013 1012
 							 		case 'access':
1014 1013
 									case 'priority':
@@ -1017,7 +1016,7 @@  discard block
 block discarded – undo
1017 1016
 									case 'title':
1018 1017
 										break;
1019 1018
 									default:
1020
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
1019
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
1021 1020
 										break;
1022 1021
 							 	}
1023 1022
 							}
@@ -1025,7 +1024,7 @@  discard block
 block discarded – undo
1025 1024
 						break;
1026 1025
 				}
1027 1026
 				// send via notification_app
1028
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1027
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1029 1028
 				{
1030 1029
 					try {
1031 1030
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -1049,9 +1048,9 @@  discard block
 block discarded – undo
1049 1048
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1050 1049
 						$notification->set_popuplinks(array($details['link_arr']));
1051 1050
 
1052
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1051
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1053 1052
 						$notification->send();
1054
-						foreach(notifications::errors(true) as $error)
1053
+						foreach (notifications::errors(true) as $error)
1055 1054
 						{
1056 1055
 							error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error");
1057 1056
 						}
@@ -1090,14 +1089,14 @@  discard block
 block discarded – undo
1090 1089
 		return true;
1091 1090
 	}
1092 1091
 
1093
-	function get_update_message($event,$added)
1092
+	function get_update_message($event, $added)
1094 1093
 	{
1095 1094
 		$nul = null;
1096
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1095
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1097 1096
 
1098 1097
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1099 1098
 
1100
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1099
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1101 1100
 	}
1102 1101
 
1103 1102
 	/**
@@ -1111,37 +1110,37 @@  discard block
 block discarded – undo
1111 1110
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1112 1111
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1113 1112
 
1114
-		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1115
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1113
+		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1114
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1116 1115
 		{
1117
-			return False;	// event not found
1116
+			return False; // event not found
1118 1117
 		}
1119 1118
 		if ($alarm['all'])
1120 1119
 		{
1121 1120
 			$to_notify = $event['participants'];
1122 1121
 		}
1123
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1122
+		elseif ($this->check_perms(Acl::READ, $event))	// checks agains $this->owner set to $alarm[owner]
1124 1123
 		{
1125 1124
 			$to_notify[$alarm['owner']] = 'A';
1126 1125
 		}
1127 1126
 		else
1128 1127
 		{
1129
-			return False;	// no rights
1128
+			return False; // no rights
1130 1129
 		}
1131 1130
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1132 1131
 		Api\Translation::add_app('calendar');
1133 1132
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1134 1133
 
1135
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1134
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1136 1135
 
1137 1136
 		// create a new alarm for recuring events for the next event, if one exists
1138
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1137
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1139 1138
 		{
1140 1139
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1141 1140
 			unset($alarm['times']);
1142 1141
 			unset($alarm['next']);
1143 1142
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1144
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1143
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1145 1144
 		}
1146 1145
 		return $ret;
1147 1146
 	}
@@ -1157,14 +1156,14 @@  discard block
 block discarded – undo
1157 1156
 	 * Please note: you should ALLWAYS update timestamps, as they are required for sync!
1158 1157
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1159 1158
 	 */
1160
-	function save($event,$ignore_acl=false,$updateTS=true)
1159
+	function save($event, $ignore_acl = false, $updateTS = true)
1161 1160
 	{
1162 1161
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1163 1162
 
1164 1163
 		// check if user has the permission to update / create the event
1165
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
1166
-			!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
1167
-			!$this->check_perms(Acl::ADD,0,$event['owner'])))
1164
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) ||
1165
+			!$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) &&
1166
+			!$this->check_perms(Acl::ADD, 0, $event['owner'])))
1168 1167
 		{
1169 1168
 			return false;
1170 1169
 		}
@@ -1185,7 +1184,7 @@  discard block
 block discarded – undo
1185 1184
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'])
1186 1185
 		{
1187 1186
 			$event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1188
-			$event['recur_enddate']->setTime(23,59,59);
1187
+			$event['recur_enddate']->setTime(23, 59, 59);
1189 1188
 			$rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName());
1190 1189
 			$rrule->rewind();
1191 1190
 			$enddate = $rrule->current();
@@ -1244,19 +1243,19 @@  discard block
 block discarded – undo
1244 1243
 
1245 1244
 				$event['recur_enddate'] = $save_event['recur_enddate'] = $time;
1246 1245
 			}
1247
-			$timestamps = array('modified','created');
1246
+			$timestamps = array('modified', 'created');
1248 1247
 			// all-day events are handled in server time
1249 1248
 		//	$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
1250 1249
 		}
1251 1250
 		else
1252 1251
 		{
1253
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1252
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1254 1253
 		}
1255 1254
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1256
-		foreach($timestamps as $ts)
1255
+		foreach ($timestamps as $ts)
1257 1256
 		{
1258 1257
 			// we convert here from user-time to timestamps in server-time!
1259
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1258
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1260 1259
 		}
1261 1260
 		// convert tzid name to integer tz_id, of set user default
1262 1261
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
 		// same with the recur exceptions
1267 1266
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1268 1267
 		{
1269
-			foreach($event['recur_exception'] as &$date)
1268
+			foreach ($event['recur_exception'] as &$date)
1270 1269
 			{
1271 1270
 				if ($event['whole_day'])
1272 1271
 				{
@@ -1275,7 +1274,7 @@  discard block
 block discarded – undo
1275 1274
 				}
1276 1275
 				else
1277 1276
 				{
1278
-					$date = $this->date2ts($date,true);
1277
+					$date = $this->date2ts($date, true);
1279 1278
 				}
1280 1279
 			}
1281 1280
 			unset($date);
@@ -1283,7 +1282,7 @@  discard block
 block discarded – undo
1283 1282
 		// same with the alarms
1284 1283
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1285 1284
 		{
1286
-			foreach($event['alarm'] as $id => &$alarm)
1285
+			foreach ($event['alarm'] as $id => &$alarm)
1287 1286
 			{
1288 1287
 				// remove alarms belonging to not longer existing or rejected participants
1289 1288
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1296,21 +1295,20 @@  discard block
 block discarded – undo
1296 1295
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1297 1296
 					}
1298 1297
 				}
1299
-				$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1298
+				$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1300 1299
 			}
1301 1300
 		}
1302 1301
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1303 1302
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1304 1303
 		{
1305
-			foreach($old_event['alarm'] as $id => &$alarm)
1304
+			foreach ($old_event['alarm'] as $id => &$alarm)
1306 1305
 			{
1307 1306
 				if (!isset($event['alarm'][$id]))
1308 1307
 				{
1309 1308
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1310 1309
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1311 1310
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1312
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1313
-						$old_event['participants'][$alarm['owner']];
1311
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1314 1312
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1315 1313
 					{
1316 1314
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1339,7 +1337,7 @@  discard block
 block discarded – undo
1339 1337
 		}
1340 1338
 		$set_recurrences = $old_event ? abs($event['recur_enddate'] - $old_event['recur_enddate']) > 1 : false;
1341 1339
 		$set_recurrences_start = 0;
1342
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1340
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1343 1341
 		{
1344 1342
 			$save_event['id'] = $cal_id;
1345 1343
 			// unset participants to enforce the default stati for all added recurrences
@@ -1350,7 +1348,7 @@  discard block
 block discarded – undo
1350 1348
 		// create links for new participants from addressbook, if configured
1351 1349
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1352 1350
 		{
1353
-			foreach($event['participants'] as $uid => $status)
1351
+			foreach ($event['participants'] as $uid => $status)
1354 1352
 			{
1355 1353
 				$user_type = $user_id = null;
1356 1354
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1363,7 +1361,7 @@  discard block
 block discarded – undo
1363 1361
 
1364 1362
 		// Update history
1365 1363
 		$tracking = new calendar_tracking($this);
1366
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1364
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1367 1365
 		$tracking->track($event, $old_event);
1368 1366
 
1369 1367
 		return $cal_id;
@@ -1378,16 +1376,16 @@  discard block
 block discarded – undo
1378 1376
 	 * @param array|int $event event array or id of the event
1379 1377
 	 * @return boolean
1380 1378
 	 */
1381
-	function check_status_perms($uid,$event)
1379
+	function check_status_perms($uid, $event)
1382 1380
 	{
1383 1381
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1384 1382
 		{
1385 1383
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1386 1384
 
1387
-			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1385
+			return $this->check_perms(Acl::EDIT, 0, $event['owner']);
1388 1386
 		}
1389 1387
 		// check if we have a category Acl for the event or not (null)
1390
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1388
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1391 1389
 		if (!is_null($access))
1392 1390
 		{
1393 1391
 			return $access;
@@ -1404,10 +1402,10 @@  discard block
 block discarded – undo
1404 1402
 		// regular user and groups (need to check memberships too)
1405 1403
 		if (!isset($event['participants'][$uid]))
1406 1404
 		{
1407
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1405
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1408 1406
 		}
1409 1407
 		$memberships[] = $uid;
1410
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
1408
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid);
1411 1409
 	}
1412 1410
 
1413 1411
 	/**
@@ -1421,16 +1419,16 @@  discard block
 block discarded – undo
1421 1419
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1422 1420
 	 * 	null = cat has no acl
1423 1421
 	 */
1424
-	function check_cat_acl($right,$event)
1422
+	function check_cat_acl($right, $event)
1425 1423
 	{
1426 1424
 		if (!is_array($event)) $event = $this->read($event);
1427 1425
 
1428 1426
 		$ret = null;
1429 1427
 		if ($event['category'])
1430 1428
 		{
1431
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1429
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1432 1430
 			{
1433
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1431
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1434 1432
 				if ($access === true)
1435 1433
 				{
1436 1434
 					$ret = true;
@@ -1438,7 +1436,7 @@  discard block
 block discarded – undo
1438 1436
 				}
1439 1437
 				if ($access === false)
1440 1438
 				{
1441
-					$ret = false;	// cat denies access --> check further cats
1439
+					$ret = false; // cat denies access --> check further cats
1442 1440
 				}
1443 1441
 			}
1444 1442
 		}
@@ -1459,12 +1457,12 @@  discard block
 block discarded – undo
1459 1457
 	 * @param int $cat_id =null null to return array with all cats
1460 1458
 	 * @return array with account_id => right pairs
1461 1459
 	 */
1462
-	public static function get_cat_rights($cat_id=null)
1460
+	public static function get_cat_rights($cat_id = null)
1463 1461
 	{
1464 1462
 		if (!isset(self::$cat_rights_cache))
1465 1463
 		{
1466
-			self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
1467
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1464
+			self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights',
1465
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1468 1466
 		}
1469 1467
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1470 1468
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1477,7 +1475,7 @@  discard block
 block discarded – undo
1477 1475
 	 * @param int $user
1478 1476
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1479 1477
 	 */
1480
-	public static function set_cat_rights($cat_id,$user,$rights)
1478
+	public static function set_cat_rights($cat_id, $user, $rights)
1481 1479
 	{
1482 1480
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1483 1481
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1487,15 +1485,15 @@  discard block
 block discarded – undo
1487 1485
 			if ($rights)
1488 1486
 			{
1489 1487
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1490
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1488
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1491 1489
 			}
1492 1490
 			else
1493 1491
 			{
1494 1492
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1495 1493
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1496
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1494
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1497 1495
 			}
1498
-			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1496
+			Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1499 1497
 		}
1500 1498
 	}
1501 1499
 
@@ -1506,9 +1504,9 @@  discard block
 block discarded – undo
1506 1504
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1507 1505
 	 * 	null = cat has no acl
1508 1506
 	 */
1509
-	public static function has_cat_right($right,$cat_id,$user)
1507
+	public static function has_cat_right($right, $cat_id, $user)
1510 1508
 	{
1511
-		static $cache=null;
1509
+		static $cache = null;
1512 1510
 
1513 1511
 		if (!isset($cache[$cat_id]))
1514 1512
 		{
@@ -1516,21 +1514,21 @@  discard block
 block discarded – undo
1516 1514
 			$cat_rights = self::get_cat_rights($cat_id);
1517 1515
 			if (!is_null($cat_rights))
1518 1516
 			{
1519
-				static $memberships=null;
1517
+				static $memberships = null;
1520 1518
 				if (is_null($memberships))
1521 1519
 				{
1522
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1520
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1523 1521
 					$memberships[] = $user;
1524 1522
 				}
1525
-				foreach($cat_rights as $uid => $value)
1523
+				foreach ($cat_rights as $uid => $value)
1526 1524
 				{
1527 1525
 					$all |= $value;
1528
-					if (in_array($uid,$memberships)) $own |= $value;
1526
+					if (in_array($uid, $memberships)) $own |= $value;
1529 1527
 				}
1530 1528
 			}
1531
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1529
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1532 1530
 			{
1533
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1531
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1534 1532
 			}
1535 1533
 		}
1536 1534
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1550,13 +1548,13 @@  discard block
 block discarded – undo
1550 1548
 	 * @param boolean $skip_notification =false true: do not send notification messages
1551 1549
 	 * @return int number of changed recurrences
1552 1550
 	 */
1553
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1551
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1554 1552
 	{
1555 1553
 		unset($updateTS);
1556 1554
 
1557 1555
 		$cal_id = is_array($event) ? $event['id'] : $event;
1558 1556
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1559
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1557
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1560 1558
 		{
1561 1559
 			return false;
1562 1560
 		}
@@ -1565,16 +1563,16 @@  discard block
 block discarded – undo
1565 1563
 		if ($this->log)
1566 1564
 		{
1567 1565
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1568
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1566
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1569 1567
 		}
1570 1568
 		$old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server');
1571
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1572
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1573
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1569
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1570
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1571
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1574 1572
 		{
1575 1573
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1576 1574
 			{
1577
-				foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1575
+				foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1578 1576
 				{
1579 1577
 					if ((string)$alarm['owner'] === (string)$uid)
1580 1578
 					{
@@ -1596,8 +1594,8 @@  discard block
 block discarded – undo
1596 1594
 			if (isset($status2msg[$status]) && !$skip_notification)
1597 1595
 			{
1598 1596
 				if (!is_array($event)) $event = $this->read($cal_id);
1599
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1600
-				$this->send_update($status2msg[$status],$event['participants'],$event);
1597
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1598
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1601 1599
 			}
1602 1600
 
1603 1601
 			// Update history
@@ -1617,14 +1615,14 @@  discard block
 block discarded – undo
1617 1615
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1618 1616
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1619 1617
 	 */
1620
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1618
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1621 1619
 	{
1622 1620
 		if (!isset($new_event['participants'])) return;
1623 1621
 
1624 1622
 		// check the old list against the new list
1625 1623
 		foreach ($old_event['participants'] as $userid => $status)
1626 1624
   		{
1627
-            if (!isset($new_event['participants'][$userid])){
1625
+            if (!isset($new_event['participants'][$userid])) {
1628 1626
             	// Attendee will be deleted this way
1629 1627
             	$new_event['participants'][$userid] = 'G';
1630 1628
             }
@@ -1637,7 +1635,7 @@  discard block
 block discarded – undo
1637 1635
 		// write the changes
1638 1636
 		foreach ($new_event['participants'] as $userid => $status)
1639 1637
 		{
1640
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1638
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1641 1639
 		}
1642 1640
     }
1643 1641
 
@@ -1652,43 +1650,43 @@  discard block
 block discarded – undo
1652 1650
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1653 1651
 	 * @return boolean true on success, false on error (usually permission denied)
1654 1652
 	 */
1655
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1656
-		$delete_exceptions=true, &$exceptions_kept=null)
1653
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1654
+		$delete_exceptions = true, &$exceptions_kept = null)
1657 1655
 	{
1658 1656
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1659
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1660
-			!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
1657
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1658
+			!$ignore_acl && !$this->check_perms(Acl::DELETE, $event))
1661 1659
 		{
1662 1660
 			return false;
1663 1661
 		}
1664 1662
 
1665 1663
 		// Don't send notification if the event has already been deleted
1666
-		if(!$event['deleted'] && !$skip_notification)
1664
+		if (!$event['deleted'] && !$skip_notification)
1667 1665
 		{
1668
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1666
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1669 1667
 		}
1670 1668
 
1671 1669
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1672 1670
 		{
1673 1671
 			$config = Api\Config::read('phpgwapi');
1674
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1672
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1675 1673
 			{
1676 1674
 				$this->so->delete($cal_id);
1677 1675
 
1678 1676
 				// delete all links to the event
1679
-				Link::unlink(0,'calendar',$cal_id);
1677
+				Link::unlink(0, 'calendar', $cal_id);
1680 1678
 			}
1681 1679
 			elseif ($config['calendar_delete_history'])
1682 1680
 			{
1683 1681
 				// mark all links to the event as deleted, but keep them
1684
-				Link::unlink(0,'calendar',$cal_id,'','','',true);
1682
+				Link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1685 1683
 
1686 1684
 				$event['deleted'] = $this->now;
1687 1685
 				$this->save($event, $ignore_acl);
1688 1686
 				// Actually delete alarms
1689 1687
 				if (isset($event['alarm']) && is_array($event['alarm']))
1690 1688
 				{
1691
-					foreach($event['alarm'] as $id => $alarm)
1689
+					foreach ($event['alarm'] as $id => $alarm)
1692 1690
 					{
1693 1691
 						$this->delete_alarm($id);
1694 1692
 					}
@@ -1710,7 +1708,7 @@  discard block
 block discarded – undo
1710 1708
 						if (!($exception = $this->read($id))) continue;
1711 1709
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1712 1710
 						$exception['reference'] = $exception['recurrence'] = 0;
1713
-						$this->update($exception, true, true, false, true, $msg=null, true);
1711
+						$this->update($exception, true, true, false, true, $msg = null, true);
1714 1712
 						++$exceptions_kept;
1715 1713
 					}
1716 1714
 				}
@@ -1722,9 +1720,9 @@  discard block
 block discarded – undo
1722 1720
 			if ($event['alarm'])
1723 1721
 			{
1724 1722
 				$next_recurrance = null;
1725
-				foreach($event['alarm'] as &$alarm)
1723
+				foreach ($event['alarm'] as &$alarm)
1726 1724
 				{
1727
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1725
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1728 1726
 					{
1729 1727
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1730 1728
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1732,12 +1730,12 @@  discard block
 block discarded – undo
1732 1730
 						{
1733 1731
 							$checkdate = $recur_date;
1734 1732
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1735
-							if (($e = $this->read($cal_id,$checkdate+1)))
1733
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1736 1734
 							{
1737 1735
 								$next_recurrance = $this->date2ts($e['start']);
1738 1736
 							}
1739 1737
 						}
1740
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1738
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1741 1739
 						$alarm['cal_id'] = $cal_id;
1742 1740
 						unset($alarm['times']);
1743 1741
 						unset($alarm['next']);
@@ -1751,7 +1749,7 @@  discard block
 block discarded – undo
1751 1749
 			$event = $this->read($cal_id);
1752 1750
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1753 1751
 			$event['recur_exception'][] = $recur_date;
1754
-			$this->save($event);// updates the content-history
1752
+			$this->save($event); // updates the content-history
1755 1753
 		}
1756 1754
 		if ($event['reference'])
1757 1755
 		{
@@ -1769,19 +1767,19 @@  discard block
 block discarded – undo
1769 1767
 	 * @param array $disinvited
1770 1768
 	 * @return array
1771 1769
 	 */
1772
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1770
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1773 1771
 	{
1774 1772
 		$details = array(			// event-details for the notify-msg
1775 1773
 			'id'          => $event['id'],
1776 1774
 			'action'      => lang($action),
1777 1775
 		);
1778 1776
 		$event_arr = $this->event2array($event);
1779
-		foreach($event_arr as $key => $val)
1777
+		foreach ($event_arr as $key => $val)
1780 1778
 		{
1781 1779
 			if ($key == 'recur_type') $key = 'repetition';
1782 1780
 			$details[$key] = $val['data'];
1783 1781
 		}
1784
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1782
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1785 1783
 
1786 1784
 		$event_arr['link']['field'] = lang('URL');
1787 1785
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1802,7 +1800,7 @@  discard block
 block discarded – undo
1802 1800
 		 */
1803 1801
 		$link_arr = array();
1804 1802
 		$link_arr['text'] = $event['title'];
1805
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1803
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1806 1804
 									'cal_id' => $event['id'],
1807 1805
 									'date' => $eventStart_arr['full'],
1808 1806
 									'ajax' => true
@@ -1811,11 +1809,11 @@  discard block
 block discarded – undo
1811 1809
 		$details['link_arr'] = $link_arr;
1812 1810
 
1813 1811
 		$dis = array();
1814
-		foreach($disinvited as $uid)
1812
+		foreach ($disinvited as $uid)
1815 1813
 		{
1816 1814
 			$dis[] = $this->participant_name($uid);
1817 1815
 		}
1818
-		$details['disinvited'] = implode(', ',$dis);
1816
+		$details['disinvited'] = implode(', ', $dis);
1819 1817
 		return $details;
1820 1818
 	}
1821 1819
 
@@ -1839,13 +1837,13 @@  discard block
 block discarded – undo
1839 1837
 			'data'	=> $event['description']
1840 1838
 		);
1841 1839
 
1842
-		foreach(explode(',',$event['category']) as $cat_id)
1840
+		foreach (explode(',', $event['category']) as $cat_id)
1843 1841
 		{
1844 1842
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1845 1843
 		}
1846 1844
 		$var['category'] = Array(
1847 1845
 			'field'	=> lang('Category'),
1848
-			'data'	=> implode(', ',$cat_string)
1846
+			'data'	=> implode(', ', $cat_string)
1849 1847
 		);
1850 1848
 
1851 1849
 		$var['location'] = Array(
@@ -1891,7 +1889,7 @@  discard block
 block discarded – undo
1891 1889
 
1892 1890
 		if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants']))
1893 1891
 		{
1894
-			$participants = $this->participants($event,true);
1892
+			$participants = $this->participants($event, true);
1895 1893
 		}
1896 1894
 		$var['participants'] = Array(
1897 1895
 			'field'	=> lang('Participants'),
@@ -1914,26 +1912,26 @@  discard block
 block discarded – undo
1914 1912
 	 * @param array $old_event =null event-data in the DB before calling save
1915 1913
 	 * @param string $type ='update'
1916 1914
 	 */
1917
-	function log2file($event2save,$event_saved,$old_event=null,$type='update')
1915
+	function log2file($event2save, $event_saved, $old_event = null, $type = 'update')
1918 1916
 	{
1919
-		if (!($f = fopen($this->log_file,'a')))
1917
+		if (!($f = fopen($this->log_file, 'a')))
1920 1918
 		{
1921 1919
 			echo "<p>error opening '$this->log_file' !!!</p>\n";
1922 1920
 			return false;
1923 1921
 		}
1924
-		fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1925
-		fwrite($f,"Time: time to save / saved time read back / old time before save\n");
1926
-		foreach(array('start','end') as $name)
1922
+		fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1923
+		fwrite($f, "Time: time to save / saved time read back / old time before save\n");
1924
+		foreach (array('start', 'end') as $name)
1927 1925
 		{
1928
-			fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1929
-				$this->format_date($event_saved[$name]) .' / '.
1926
+			fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1927
+				$this->format_date($event_saved[$name]).' / '.
1930 1928
 				(is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n");
1931 1929
 		}
1932
-		foreach(array('event2save','event_saved','old_event') as $name)
1930
+		foreach (array('event2save', 'event_saved', 'old_event') as $name)
1933 1931
 		{
1934
-			fwrite($f,$name.' = '.print_r($$name,true));
1932
+			fwrite($f, $name.' = '.print_r($$name, true));
1935 1933
 		}
1936
-		fwrite($f,"\n");
1934
+		fwrite($f, "\n");
1937 1935
 		fclose($f);
1938 1936
 
1939 1937
 		return true;
@@ -1954,14 +1952,14 @@  discard block
 block discarded – undo
1954 1952
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1955 1953
 
1956 1954
 		$time = new Api\DateTime($event['start']);
1957
-		if(!is_array($event['alarm']))
1955
+		if (!is_array($event['alarm']))
1958 1956
 		{
1959 1957
 			$event['alarm'] = $this->so->read_alarms($event['id']);
1960 1958
 		}
1961 1959
 
1962
-		foreach($event['alarm'] as &$alarm)
1960
+		foreach ($event['alarm'] as &$alarm)
1963 1961
 		{
1964
-			if($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date))
1962
+			if ($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date))
1965 1963
 			{
1966 1964
 				calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts'));
1967 1965
 			}
@@ -1981,14 +1979,14 @@  discard block
 block discarded – undo
1981 1979
 	 * @param boolean $update_modified =true call update modified, default true
1982 1980
 	 * @return string id of the alarm, or false on error (eg. no perms)
1983 1981
 	 */
1984
-	function save_alarm($cal_id, $alarm, $update_modified=true)
1982
+	function save_alarm($cal_id, $alarm, $update_modified = true)
1985 1983
 	{
1986
-		if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1984
+		if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1987 1985
 		{
1988 1986
 			//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
1989
-			return false;	// no rights to add the alarm
1987
+			return false; // no rights to add the alarm
1990 1988
 		}
1991
-		$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1989
+		$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1992 1990
 
1993 1991
 		return $this->so->save_alarm($cal_id, $alarm, $update_modified);
1994 1992
 	}
@@ -2001,11 +1999,11 @@  discard block
 block discarded – undo
2001 1999
 	 */
2002 2000
 	function delete_alarm($id)
2003 2001
 	{
2004
-		list(,$cal_id) = explode(':',$id);
2002
+		list(,$cal_id) = explode(':', $id);
2005 2003
 
2006
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
2004
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
2007 2005
 		{
2008
-			return false;	// no rights to delete the alarm
2006
+			return false; // no rights to delete the alarm
2009 2007
 		}
2010 2008
 
2011 2009
 		return $this->so->delete_alarm($id);
@@ -2020,13 +2018,13 @@  discard block
 block discarded – undo
2020 2018
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
2021 2019
 	 * @return array category ids (found, added and preserved categories)
2022 2020
 	 */
2023
-	function find_or_add_categories($catname_list, $old_event=null)
2021
+	function find_or_add_categories($catname_list, $old_event = null)
2024 2022
 	{
2025 2023
 		if (is_array($old_event) || $old_event > 0)
2026 2024
 		{
2027 2025
 			// preserve categories without users read access
2028 2026
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
2029
-			$old_categories = explode(',',$old_event['category']);
2027
+			$old_categories = explode(',', $old_event['category']);
2030 2028
 			$old_cats_preserve = array();
2031 2029
 			if (is_array($old_categories) && count($old_categories) > 0)
2032 2030
 			{
@@ -2080,7 +2078,7 @@  discard block
 block discarded – undo
2080 2078
 	{
2081 2079
 		if (!is_array($cat_id_list))
2082 2080
 		{
2083
-			$cat_id_list = explode(',',$cat_id_list);
2081
+			$cat_id_list = explode(',', $cat_id_list);
2084 2082
 		}
2085 2083
 		$cat_list = array();
2086 2084
 		foreach ($cat_id_list as $cat_id)
@@ -2105,7 +2103,7 @@  discard block
 block discarded – undo
2105 2103
 	 *                              master	-> try to find a releated series master
2106 2104
 	 * @return array calendar_ids of matching entries
2107 2105
 	 */
2108
-	function find_event($event, $filter='exact')
2106
+	function find_event($event, $filter = 'exact')
2109 2107
 	{
2110 2108
 		$matchingEvents = array();
2111 2109
 		$query = array();
@@ -2113,14 +2111,14 @@  discard block
 block discarded – undo
2113 2111
 		if ($this->log)
2114 2112
 		{
2115 2113
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2116
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2114
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
2117 2115
 		}
2118 2116
 
2119 2117
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2120 2118
 
2121 2119
 		if ($filter == 'master')
2122 2120
 		{
2123
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2121
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2124 2122
 			$query['cal_recurrence'] = 0;
2125 2123
 		}
2126 2124
 		elseif ($filter == 'exact')
@@ -2141,14 +2139,14 @@  discard block
 block discarded – undo
2141 2139
 			if ($this->log)
2142 2140
 			{
2143 2141
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2144
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2142
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2145 2143
 			}
2146 2144
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2147 2145
 			{
2148 2146
 				if ($this->log)
2149 2147
 				{
2150 2148
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2151
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2149
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2152 2150
 				}
2153 2151
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2154 2152
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2167,7 +2165,7 @@  discard block
 block discarded – undo
2167 2165
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2168 2166
 						if (in_array($event['recurrence'], $exceptions))
2169 2167
 						{
2170
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2168
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2171 2169
 						}
2172 2170
 					}
2173 2171
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2186,19 +2184,19 @@  discard block
 block discarded – undo
2186 2184
 
2187 2185
 		// only query calendars of users, we have READ-grants from
2188 2186
 		$users = array();
2189
-		foreach(array_keys($this->grants) as $user)
2187
+		foreach (array_keys($this->grants) as $user)
2190 2188
 		{
2191 2189
 			$user = trim($user);
2192
-			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2190
+			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user))
2193 2191
 			{
2194
-				if ($user && !in_array($user,$users))	// already added?
2192
+				if ($user && !in_array($user, $users))	// already added?
2195 2193
 				{
2196 2194
 					$users[] = $user;
2197 2195
 				}
2198 2196
 			}
2199 2197
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2200 2198
 			{
2201
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2199
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2202 2200
 			}
2203 2201
 			// the further code is only for real users
2204 2202
 			if (!is_numeric($user)) continue;
@@ -2209,7 +2207,7 @@  discard block
 block discarded – undo
2209 2207
 				$members = $GLOBALS['egw']->accounts->members($user, true);
2210 2208
 				if (is_array($members))
2211 2209
 				{
2212
-					foreach($members as $member)
2210
+					foreach ($members as $member)
2213 2211
 					{
2214 2212
 						// use only members which gave the user a read-grant
2215 2213
 						if (!in_array($member, $users) &&
@@ -2225,7 +2223,7 @@  discard block
 block discarded – undo
2225 2223
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
2226 2224
 				if (is_array($memberships))
2227 2225
 				{
2228
-					foreach($memberships as $group)
2226
+					foreach ($memberships as $group)
2229 2227
 					{
2230 2228
 						if (!in_array($group, $users))
2231 2229
 						{
@@ -2251,24 +2249,24 @@  discard block
 block discarded – undo
2251 2249
 
2252 2250
 				// check length with some tolerance
2253 2251
 				$length = $event['end'] - $event['start'] - $delta;
2254
-				$query[] = ('(cal_end-cal_start)>' . $length);
2252
+				$query[] = ('(cal_end-cal_start)>'.$length);
2255 2253
 				$length += 2 * $delta;
2256
-				$query[] = ('(cal_end-cal_start)<' . $length);
2257
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2258
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2254
+				$query[] = ('(cal_end-cal_start)<'.$length);
2255
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2256
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2259 2257
 			}
2260 2258
 			elseif (isset($event['start']))
2261 2259
 			{
2262 2260
 				if ($filter == 'relax')
2263 2261
 				{
2264
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2265
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2262
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2263
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2266 2264
 				}
2267 2265
 				else
2268 2266
 				{
2269 2267
 					// we accept a tiny tolerance
2270
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2271
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2268
+					$query[] = ('cal_start>'.($event['start'] - 2));
2269
+					$query[] = ('cal_start<'.($event['start'] + 2));
2272 2270
 				}
2273 2271
 			}
2274 2272
 			if ($filter == 'relax')
@@ -2291,14 +2289,14 @@  discard block
 block discarded – undo
2291 2289
 			if ($this->log)
2292 2290
 			{
2293 2291
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2294
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2292
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2295 2293
 			}
2296 2294
 		}
2297 2295
 
2298 2296
 		if ($this->log)
2299 2297
 		{
2300 2298
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2301
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2299
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2302 2300
 		}
2303 2301
 		if (!count($users) || !($foundEvents =
2304 2302
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2306,19 +2304,19 @@  discard block
 block discarded – undo
2306 2304
 			if ($this->log)
2307 2305
 			{
2308 2306
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2309
-				"[NO MATCH]\n",3,$this->logfile);
2307
+				"[NO MATCH]\n", 3, $this->logfile);
2310 2308
 			}
2311 2309
 			return $matchingEvents;
2312 2310
 		}
2313 2311
 
2314 2312
 		$pseudos = array();
2315 2313
 
2316
-		foreach($foundEvents as $egwEvent)
2314
+		foreach ($foundEvents as $egwEvent)
2317 2315
 		{
2318 2316
 			if ($this->log)
2319 2317
 			{
2320 2318
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2321
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2319
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2322 2320
 			}
2323 2321
 
2324 2322
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2392,7 +2390,7 @@  discard block
 block discarded – undo
2392 2390
 						if (in_array($event['recurrence'], $exceptions))
2393 2391
 						{
2394 2392
 							// We found a pseudo exception
2395
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2393
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2396 2394
 							break;
2397 2395
 						}
2398 2396
 					}
@@ -2410,7 +2408,7 @@  discard block
 block discarded – undo
2410 2408
 						if ($this->log)
2411 2409
 						{
2412 2410
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2413
-							"() egwEvent length does not match!\n",3,$this->logfile);
2411
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2414 2412
 						}
2415 2413
 						continue;
2416 2414
 					}
@@ -2422,7 +2420,7 @@  discard block
 block discarded – undo
2422 2420
 						if ($this->log)
2423 2421
 						{
2424 2422
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2425
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2423
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2426 2424
 						}
2427 2425
 						continue;
2428 2426
 					}
@@ -2443,8 +2441,8 @@  discard block
 block discarded – undo
2443 2441
 					if ($this->log)
2444 2442
 					{
2445 2443
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2446
-							"() event[$key] differ: '" . $event[$key] .
2447
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2444
+							"() event[$key] differ: '".$event[$key].
2445
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2448 2446
 					}
2449 2447
 					continue 2; // next foundEvent
2450 2448
 				}
@@ -2462,7 +2460,7 @@  discard block
 block discarded – undo
2462 2460
 						if ($this->log)
2463 2461
 						{
2464 2462
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2465
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2463
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2466 2464
 						}
2467 2465
 						continue 2;
2468 2466
 					}
@@ -2474,7 +2472,7 @@  discard block
 block discarded – undo
2474 2472
 					{
2475 2473
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2476 2474
 							'() event has additional categories:'
2477
-							. array2string($newCategories)."\n",3,$this->logfile);
2475
+							. array2string($newCategories)."\n", 3, $this->logfile);
2478 2476
 					}
2479 2477
 					continue;
2480 2478
 				}
@@ -2494,7 +2492,7 @@  discard block
 block discarded – undo
2494 2492
 							if ($this->log)
2495 2493
 							{
2496 2494
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2497
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2495
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2498 2496
 							}
2499 2497
 							continue 2;
2500 2498
 						}
@@ -2517,8 +2515,8 @@  discard block
 block discarded – undo
2517 2515
 						if ($this->log)
2518 2516
 						{
2519 2517
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2520
-								'() missing event[participants]: ' .
2521
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2518
+								'() missing event[participants]: '.
2519
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2522 2520
 						}
2523 2521
 						continue;
2524 2522
 					}
@@ -2530,7 +2528,7 @@  discard block
 block discarded – undo
2530 2528
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2531 2529
 				{
2532 2530
 					// We found a pseudo Exception
2533
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2531
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2534 2532
 					continue;
2535 2533
 				}
2536 2534
 			}
@@ -2552,7 +2550,7 @@  discard block
 block discarded – undo
2552 2550
 							if ($this->log)
2553 2551
 							{
2554 2552
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2555
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2553
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2556 2554
 							}
2557 2555
 							continue 2;
2558 2556
 						}
@@ -2562,8 +2560,8 @@  discard block
 block discarded – undo
2562 2560
 						if ($this->log)
2563 2561
 						{
2564 2562
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2565
-								'() missing event[recur_exception]: ' .
2566
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2563
+								'() missing event[recur_exception]: '.
2564
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2567 2565
 						}
2568 2566
 						continue;
2569 2567
 					}
@@ -2578,8 +2576,8 @@  discard block
 block discarded – undo
2578 2576
 						if ($this->log)
2579 2577
 						{
2580 2578
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2581
-								"() events[$key] differ: " . $event[$key] .
2582
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2579
+								"() events[$key] differ: ".$event[$key].
2580
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2583 2581
 						}
2584 2582
 						continue 2;
2585 2583
 					}
@@ -2595,7 +2593,7 @@  discard block
 block discarded – undo
2595 2593
 			if ($this->log)
2596 2594
 			{
2597 2595
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2598
-					"() new exception for series found.\n",3,$this->logfile);
2596
+					"() new exception for series found.\n", 3, $this->logfile);
2599 2597
 			}
2600 2598
 			$matchingEvents = array();
2601 2599
 		}
@@ -2606,7 +2604,7 @@  discard block
 block discarded – undo
2606 2604
 		if ($this->log)
2607 2605
 		{
2608 2606
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2609
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2607
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2610 2608
 		}
2611 2609
 		return $matches;
2612 2610
 	}
@@ -2679,7 +2677,7 @@  discard block
 block discarded – undo
2679 2677
 				if ($this->log)
2680 2678
 				{
2681 2679
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2682
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2680
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2683 2681
 				}
2684 2682
 				$type = 'SERIES-EXCEPTION';
2685 2683
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2700,7 +2698,7 @@  discard block
 block discarded – undo
2700 2698
 					}
2701 2699
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2702 2700
 					{
2703
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2701
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2704 2702
 						$recurrence_event = $master_event;
2705 2703
 						$recurrence_event['start'] = $event['start'];
2706 2704
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2717,8 +2715,8 @@  discard block
 block discarded – undo
2717 2715
 							if ($this->log)
2718 2716
 							{
2719 2717
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2720
-									'() try occurrence ' . $egw_rrule->current()
2721
-									. " ($occurrence)\n",3,$this->logfile);
2718
+									'() try occurrence '.$egw_rrule->current()
2719
+									. " ($occurrence)\n", 3, $this->logfile);
2722 2720
 							}
2723 2721
 							if ($event['start'] == $occurrence)
2724 2722
 							{
@@ -2751,8 +2749,8 @@  discard block
 block discarded – undo
2751 2749
 			// default if we cannot find a proof for a fundamental change
2752 2750
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2753 2751
 			// check for changed data
2754
-			foreach (array('start','end','uid','title','location','description',
2755
-				'priority','public','special','non_blocking') as $key)
2752
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2753
+				'priority', 'public', 'special', 'non_blocking') as $key)
2756 2754
 			{
2757 2755
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2758 2756
 				{
@@ -2810,10 +2808,10 @@  discard block
 block discarded – undo
2810 2808
      * @param &$event	the event we are working on
2811 2809
      *
2812 2810
      */
2813
-    function server2usertime (&$event)
2811
+    function server2usertime(&$event)
2814 2812
     {
2815 2813
 		// we run all dates through date2usertime, to adjust to user-time
2816
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2814
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2817 2815
 		{
2818 2816
 			// we convert here from server-time to timestamps in user-time!
2819 2817
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2821,7 +2819,7 @@  discard block
 block discarded – undo
2821 2819
 		// same with the recur exceptions
2822 2820
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2823 2821
 		{
2824
-			foreach($event['recur_exception'] as $n => $date)
2822
+			foreach ($event['recur_exception'] as $n => $date)
2825 2823
 			{
2826 2824
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2827 2825
 			}
@@ -2829,7 +2827,7 @@  discard block
 block discarded – undo
2829 2827
 		// same with the alarms
2830 2828
 		if (isset($event['alarm']) && is_array($event['alarm']))
2831 2829
 		{
2832
-			foreach($event['alarm'] as $id => $alarm)
2830
+			foreach ($event['alarm'] as $id => $alarm)
2833 2831
 			{
2834 2832
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2835 2833
 			}
@@ -2846,7 +2844,7 @@  discard block
 block discarded – undo
2846 2844
 	{
2847 2845
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2848 2846
 		{
2849
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2847
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2850 2848
 		}
2851 2849
 	}
2852 2850
 }
Please login to merge, or discard this patch.
calendar/inc/class.calendar_export_csv.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	/**
28 28
 	 * Exports records as defined in $_definition
29 29
 	 *
30
-	 * @param egw_record $_definition
30
+	 * @param importexport_definition $_definition
31 31
 	 */
32 32
 	public function export( $_stream, importexport_definition $_definition) {
33 33
 		$options = $_definition->plugin_options;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	protected function get_selects()
368 368
 	{
369
-		$this->selects['priority'] = Array(
369
+		$this->selects['priority'] = array(
370 370
 			0 => lang('None'),
371 371
 			1 => lang('Low'),
372 372
 			2 => lang('Normal'),
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	/**
395 395
 	 * Adjust automatically generated field filters
396 396
 	 */
397
-	public function get_filter_fields(Array &$filters)
397
+	public function get_filter_fields(array &$filters)
398 398
 	{
399 399
 
400 400
 		// Calendar SO doesn't support filtering by column, so we have to remove pretty much everything
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param egw_record $_definition
31 31
 	 */
32
-	public function export( $_stream, importexport_definition $_definition) {
32
+	public function export($_stream, importexport_definition $_definition) {
33 33
 		$options = $_definition->plugin_options;
34 34
 
35 35
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
36 36
 		if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar');
37 37
 		// Custom fields need to be specifically requested
38 38
 		$cfs = array();
39
-		foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
40
-			if($key[0] == '#') $cfs[] = substr($key,1);
39
+		foreach ($options['mapping'] + (array)$_definition->filter as $key => $label) {
40
+			if ($key[0] == '#') $cfs[] = substr($key, 1);
41 41
 		}
42 42
 
43 43
 		$query = array(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 			'num_rows'	=> -1,
46 46
 			'csv_export'	=> true
47 47
 		);
48
-		switch($options['selection'])
48
+		switch ($options['selection'])
49 49
 		{
50 50
 			case 'criteria':
51 51
 				$query = array(
@@ -55,33 +55,33 @@  discard block
 block discarded – undo
55 55
 					'users'         => $options['criteria']['owner'],
56 56
 					'cfs'		=> $cfs // Otherwise we shouldn't get any custom fields
57 57
 				);
58
-				if($options['criteria']['start'])
58
+				if ($options['criteria']['start'])
59 59
 				{
60 60
 					$query['start'] = $options['criteria']['start'];
61 61
 				}
62
-				if($options['criteria']['end'])
62
+				if ($options['criteria']['end'])
63 63
 				{
64
-					$query['end'] = strtotime('+1 day',$options['criteria']['end'])-1;
64
+					$query['end'] = strtotime('+1 day', $options['criteria']['end']) - 1;
65 65
 				}
66
-				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
66
+				if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
67 67
 					$query['offset'] = 0;
68 68
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
69 69
 				}
70
-				$events =& $this->bo->search($query);
70
+				$events = & $this->bo->search($query);
71 71
 				break;
72 72
 			case 'search_results':
73 73
 				$states = $this->bo->cal_prefs['saved_states'];
74 74
 				$query = Api\Cache::getSession('calendar', 'calendar_list');
75
-				$query['num_rows'] = -1;        // all
76
-				$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
75
+				$query['num_rows'] = -1; // all
76
+				$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
77 77
 				$query['start'] = 0;
78 78
 				$query['cfs'] = $cfs;
79
-				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
79
+				if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
80 80
 				{
81 81
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
82 82
 				}
83 83
 				$ui = new calendar_uilist();
84
-				if($states['view'] == 'listview')
84
+				if ($states['view'] == 'listview')
85 85
 				{
86 86
 					$ui->get_rows($query, $events, $unused);
87 87
 				} 
@@ -98,35 +98,35 @@  discard block
 block discarded – undo
98 98
 				$filter = $_definition->filter;
99 99
 
100 100
 				// Handle ranges
101
-				foreach($filter as $field => $value)
101
+				foreach ($filter as $field => $value)
102 102
 				{
103
-					if($field == 'filter' && $value)
103
+					if ($field == 'filter' && $value)
104 104
 					{
105 105
 						$query['filter'] = $value;
106 106
 						continue;
107 107
 					}
108
-					if(!is_array($value) || (!$value['from'] && !$value['to']))
108
+					if (!is_array($value) || (!$value['from'] && !$value['to']))
109 109
 					{
110 110
 						$query['query']["cal_$field"] = $value;
111 111
 						continue;
112 112
 					}
113 113
 
114 114
 					// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
115
-					if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
116
-					if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
115
+					if ($value['from']) $query['sql_filter'][] = "cal_$field >= ".(int)$value['from'];
116
+					if ($value['to']) $query['sql_filter'][] = "cal_$field <= ".(int)$value['to'];
117 117
 
118 118
 				}
119
-				if($query['sql_filter'] && is_array($query['sql_filter']))
119
+				if ($query['sql_filter'] && is_array($query['sql_filter']))
120 120
 				{
121 121
 					// Set as an extra parameter
122
-					$sql_filter = implode(' AND ',$query['sql_filter']);
122
+					$sql_filter = implode(' AND ', $query['sql_filter']);
123 123
 				}
124 124
 
125 125
 			case 'all':
126 126
 				$events = $this->bo->search($query + array(
127 127
 					'offset' => 0,
128 128
 					'order' => 'cal_start',
129
-				),$sql_filter);
129
+				), $sql_filter);
130 130
 				break;
131 131
 		}
132 132
 
@@ -145,30 +145,30 @@  discard block
 block discarded – undo
145 145
 			// Get rid of yearly recurring events that don't belong
146 146
 			//if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue;
147 147
 			// Add in participants
148
-			if($options['mapping']['participants'])
148
+			if ($options['mapping']['participants'])
149 149
 			{
150
-				$event['participants'] = implode(", ",$this->bo->participants($event,true));
150
+				$event['participants'] = implode(", ", $this->bo->participants($event, true));
151 151
 			}
152 152
 			if (is_array($event))
153 153
 			{
154 154
 				$record->set_record($event);
155
-				if($options['mapping']['recurrence'])
155
+				if ($options['mapping']['recurrence'])
156 156
 				{
157 157
 					$rrule = calendar_rrule::event2rrule($event);
158 158
 					$record->recurrence = $rrule->__toString();
159 159
 				}
160 160
 
161 161
 				// Standard stuff
162
-				if($options['convert'])
162
+				if ($options['convert'])
163 163
 				{
164 164
 					importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects);
165 165
 				}
166 166
 				else
167 167
 				{
168 168
 					// Implode arrays, so they don't say 'Array'
169
-					foreach($record->get_record_array() as $key => $value)
169
+					foreach ($record->get_record_array() as $key => $value)
170 170
 					{
171
-						if(is_array($value)) $record->$key = implode(',', $value);
171
+						if (is_array($value)) $record->$key = implode(',', $value);
172 172
 					}
173 173
 	 			}
174 174
 				$export_object->export_record($record);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		$states = $this->bo->cal_prefs['saved_states'];
231 231
 		$list = Api\Cache::getSession('calendar', 'calendar_list');
232 232
 		
233
-		$start= new Api\DateTime($list['startdate']);
233
+		$start = new Api\DateTime($list['startdate']);
234 234
 		$end = new Api\DateTime($list['enddate']);
235 235
 		
236 236
 		if ($states['view'] == 'listview')
@@ -239,24 +239,24 @@  discard block
 block discarded – undo
239 239
 
240 240
 			// Use UI to get dates
241 241
 			$ui = new calendar_uilist();
242
-			$list['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
243
-			$ui->get_rows($list,$rows,$readonlys);
242
+			$list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
243
+			$ui->get_rows($list, $rows, $readonlys);
244 244
 			$start = $ui->first ? $ui->first : new Api\DateTime($ui->date);
245 245
 			$end = $ui->last;
246 246
 
247 247
 			// Special handling
248
-			if($list['filter'] == 'all') $start = $end = null;
249
-			if($list['filter'] == 'before')
248
+			if ($list['filter'] == 'all') $start = $end = null;
249
+			if ($list['filter'] == 'before')
250 250
 			{
251 251
 				$end = $start;
252 252
 				$start = null;
253 253
 			}
254 254
 			$ui = null;
255 255
 		}
256
-		else if(!$end)
256
+		else if (!$end)
257 257
 		{
258
-			$end = '+1 ' . $states['view'];
259
-			$end = strtotime($end, $start->format('ts'))-1;
258
+			$end = '+1 '.$states['view'];
259
+			$end = strtotime($end, $start->format('ts')) - 1;
260 260
 		}
261 261
 		$prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]);
262 262
 		$data = array(
@@ -322,17 +322,17 @@  discard block
 block discarded – undo
322 322
 		);
323 323
 		$filters = array_reverse($filters, true);
324 324
 
325
-		foreach($filters as $field_name => &$settings)
325
+		foreach ($filters as $field_name => &$settings)
326 326
 		{
327 327
 			// Can't filter on a custom field
328
-			if(strpos($field_name, '#') === 0)
328
+			if (strpos($field_name, '#') === 0)
329 329
 			{
330 330
 				unset($filters[$field_name]);
331 331
 				continue;
332 332
 			}
333 333
 
334 334
 			// Pass on select options
335
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
335
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
336 336
 		}
337 337
 
338 338
 	}
Please login to merge, or discard this patch.
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,9 +16,11 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * export CSV plugin of calendar
18 18
  */
19
-class calendar_export_csv implements importexport_iface_export_plugin {
19
+class calendar_export_csv implements importexport_iface_export_plugin
20
+{
20 21
 
21
-	public function __construct() {
22
+	public function __construct()
23
+	{
22 24
 		Api\Translation::add_app('calendar');
23 25
 		$this->bo = new calendar_bo();
24 26
 		$this->get_selects();
@@ -29,15 +31,23 @@  discard block
 block discarded – undo
29 31
 	 *
30 32
 	 * @param egw_record $_definition
31 33
 	 */
32
-	public function export( $_stream, importexport_definition $_definition) {
34
+	public function export( $_stream, importexport_definition $_definition)
35
+	{
33 36
 		$options = $_definition->plugin_options;
34 37
 
35 38
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
36
-		if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar');
39
+		if (!$limit_exception)
40
+		{
41
+			$export_limit = Api\Storage\Merge::getExportLimit('calendar');
42
+		}
37 43
 		// Custom fields need to be specifically requested
38 44
 		$cfs = array();
39
-		foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
40
-			if($key[0] == '#') $cfs[] = substr($key,1);
45
+		foreach($options['mapping'] + (array)$_definition->filter as $key => $label)
46
+		{
47
+			if($key[0] == '#')
48
+			{
49
+				$cfs[] = substr($key,1);
50
+			}
41 51
 		}
42 52
 
43 53
 		$query = array(
@@ -63,7 +73,8 @@  discard block
 block discarded – undo
63 73
 				{
64 74
 					$query['end'] = strtotime('+1 day',$options['criteria']['end'])-1;
65 75
 				}
66
-				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
76
+				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
77
+				{
67 78
 					$query['offset'] = 0;
68 79
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
69 80
 				}
@@ -84,7 +95,7 @@  discard block
 block discarded – undo
84 95
 				if($states['view'] == 'listview')
85 96
 				{
86 97
 					$ui->get_rows($query, $events, $unused);
87
-				} 
98
+				}
88 99
 				else
89 100
 				{
90 101
 					$query['filter'] = 'custom';
@@ -112,8 +123,14 @@  discard block
 block discarded – undo
112 123
 					}
113 124
 
114 125
 					// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
115
-					if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
116
-					if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
126
+					if($value['from'])
127
+					{
128
+						$query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
129
+					}
130
+					if($value['to'])
131
+					{
132
+						$query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
133
+					}
117 134
 
118 135
 				}
119 136
 				if($query['sql_filter'] && is_array($query['sql_filter']))
@@ -168,7 +185,10 @@  discard block
 block discarded – undo
168 185
 					// Implode arrays, so they don't say 'Array'
169 186
 					foreach($record->get_record_array() as $key => $value)
170 187
 					{
171
-						if(is_array($value)) $record->$key = implode(',', $value);
188
+						if(is_array($value))
189
+						{
190
+							$record->$key = implode(',', $value);
191
+						}
172 192
 					}
173 193
 	 			}
174 194
 				$export_object->export_record($record);
@@ -245,7 +265,10 @@  discard block
 block discarded – undo
245 265
 			$end = $ui->last;
246 266
 
247 267
 			// Special handling
248
-			if($list['filter'] == 'all') $start = $end = null;
268
+			if($list['filter'] == 'all')
269
+			{
270
+				$start = $end = null;
271
+			}
249 272
 			if($list['filter'] == 'before')
250 273
 			{
251 274
 				$end = $start;
@@ -332,7 +355,10 @@  discard block
 block discarded – undo
332 355
 			}
333 356
 
334 357
 			// Pass on select options
335
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
358
+			if($this->selects[$field_name])
359
+			{
360
+				$settings['values'] = $this->selects[$field_name];
361
+			}
336 362
 		}
337 363
 
338 364
 	}
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.
Spacing   +269 added lines, -270 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'])
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 						{
653 653
 							if ($event['recur_enddate'] && $tzid)
654 654
 							{
655
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
655
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
656 656
 							}
657 657
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
658 658
 						}
659 659
 						else // $version == '2.0'
660 660
 						{
661 661
 							$attributes['RRULE'] = '';
662
-							foreach($rrule as $n => $v)
662
+							foreach ($rrule as $n => $v)
663 663
 							{
664
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
664
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
665 665
 							}
666 666
 						}
667 667
 						break;
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 								{
677 677
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
678 678
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
679
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
679
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
680 680
 								}
681 681
 							}
682 682
 							else
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
685 685
 								foreach ($event['recur_exception'] as $id => $timestamp)
686 686
 								{
687
-									$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
687
+									$time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone);
688 688
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
689
-									$arr = Api\DateTime::to($time,'array');
689
+									$arr = Api\DateTime::to($time, 'array');
690 690
 									$days[$id] = array(
691 691
 										'year'  => $arr['year'],
692 692
 										'month' => $arr['month'],
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
 						break;
702 702
 
703 703
 					case 'PRIORITY':
704
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
704
+						if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
705 705
 						if ($this->productManufacturer == 'funambol' &&
706 706
 							(strpos($this->productName, 'outlook') !== false
707 707
 								|| strpos($this->productName, 'pocket pc') !== false))
708 708
 						{
709
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
709
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
710 710
 						}
711 711
 						else
712 712
 						{
713
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
713
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
714 714
 						}
715 715
 						break;
716 716
 
717 717
 					case 'TRANSP':
718
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
718
+						if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
719 719
 						if ($version == '1.0')
720 720
 						{
721 721
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
 							// We handle a pseudo exception
755 755
 							if (empty($event['whole_day']))
756 756
 							{
757
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
757
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
758 758
 							}
759 759
 							else
760 760
 							{
761
-								$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
761
+								$time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone);
762 762
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
763
-								$arr = Api\DateTime::to($time,'array');
763
+								$arr = Api\DateTime::to($time, 'array');
764 764
 								$vevent->setAttribute($icalFieldName, array(
765 765
 									'year' => $arr['year'],
766 766
 									'month' => $arr['month'],
@@ -772,17 +772,17 @@  discard block
 block discarded – undo
772 772
 						elseif ($event['recurrence'] && $event['reference'])
773 773
 						{
774 774
 							// $event['reference'] is a calendar_id, not a timestamp
775
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
775
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
776 776
 
777 777
 							if (empty($revent['whole_day']))
778 778
 							{
779
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
779
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
780 780
 							}
781 781
 							else
782 782
 							{
783
-								$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
783
+								$time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone);
784 784
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
785
-								$arr = Api\DateTime::to($time,'array');
785
+								$arr = Api\DateTime::to($time, 'array');
786 786
 								$vevent->setAttribute($icalFieldName, array(
787 787
 									'year' => $arr['year'],
788 788
 									'month' => $arr['month'],
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
807 807
 							if ($this->log && $size > 0)
808 808
 							{
809
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
810
-									"() $icalFieldName Size: $size, NoTruncate: " .
811
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
809
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
810
+									"() $icalFieldName Size: $size, NoTruncate: ".
811
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
812 812
 							}
813 813
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
814 814
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 							{
827 827
 								if ($this->log)
828 828
 								{
829
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
830
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
829
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
830
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
831 831
 								}
832 832
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
833 833
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 							$value = substr($value, 0, $size - 1);
838 838
 							if ($this->log)
839 839
 							{
840
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
841
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
840
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
841
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
842 842
 							}
843 843
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
844 844
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 			// for CalDAV add all X-Properties previously parsed
854 854
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
855 855
 			{
856
-				foreach($event as $name => $value)
856
+				foreach ($event as $name => $value)
857 857
 				{
858 858
 					if (substr($name, 0, 2) == '##')
859 859
 					{
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 						$values['AALARM']['repeat count'] = '';
926 926
 						$values['AALARM']['display text'] = $description;
927 927
 					}
928
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
929
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
928
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
929
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
930 930
 					// lets take only the first alarm
931 931
 					break;
932 932
 				}
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 						$alarmData['offset'] = false;
964 964
 					}
965 965
 
966
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
966
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
967 967
 					if ($alarmData['offset'] !== false)
968 968
 					{
969 969
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 					else
973 973
 					{
974 974
 						$params = array('VALUE' => 'DATE-TIME');
975
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
975
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
976 976
 						$valarm->setAttribute('TRIGGER', $value, $params);
977 977
 					}
978 978
 					if (!empty($alarmData['uid']))
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
984 984
 					if (isset($alarmData['attrs']))
985 985
 					{
986
-						foreach($alarmData['attrs'] as $attr => $data)
986
+						foreach ($alarmData['attrs'] as $attr => $data)
987 987
 						{
988 988
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
989 989
 						}
@@ -991,11 +991,11 @@  discard block
 block discarded – undo
991 991
 					// set default ACTION and DESCRIPTION, if not set by a client
992 992
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
993 993
 					{
994
-						$valarm->setAttribute('ACTION','DISPLAY');
994
+						$valarm->setAttribute('ACTION', 'DISPLAY');
995 995
 					}
996 996
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
997 997
 					{
998
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
998
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
999 999
 					}
1000 1000
 					$vevent->addComponent($valarm);
1001 1001
 				}
@@ -1003,15 +1003,15 @@  discard block
 block discarded – undo
1003 1003
 
1004 1004
 			foreach ($attributes as $key => $value)
1005 1005
 			{
1006
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
1006
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
1007 1007
 				{
1008
-					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
1009
-                    $paramData = (array) Api\Translation::convert(is_array($value) ?
1008
+					$valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset);
1009
+                    $paramData = (array)Api\Translation::convert(is_array($value) ?
1010 1010
                     		$parameters[$key][$valueID] : $parameters[$key],
1011
-                            Api\Translation::charset(),$charset);
1012
-                    $valuesData = (array) Api\Translation::convert($values[$key],
1013
-                    		Api\Translation::charset(),$charset);
1014
-                    $content = $valueData . implode(';', $valuesData);
1011
+                            Api\Translation::charset(), $charset);
1012
+                    $valuesData = (array)Api\Translation::convert($values[$key],
1013
+                    		Api\Translation::charset(), $charset);
1014
+                    $content = $valueData.implode(';', $valuesData);
1015 1015
 
1016 1016
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1017 1017
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1061,10 +1061,10 @@  discard block
 block discarded – undo
1061 1061
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1062 1062
  		if ($this->log)
1063 1063
  		{
1064
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1065
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1066
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1067
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1064
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1065
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1066
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1067
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1068 1068
  		}
1069 1069
 		return $retval;
1070 1070
 	}
@@ -1077,15 +1077,15 @@  discard block
 block discarded – undo
1077 1077
 	 * @param array &$params=null parameter array to set TZID
1078 1078
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1079 1079
 	 */
1080
-	static function getDateTime($time,$tzid,array &$params=null)
1080
+	static function getDateTime($time, $tzid, array &$params = null)
1081 1081
 	{
1082 1082
 		if (empty($tzid) || $tzid == 'UTC')
1083 1083
 		{
1084
-			return Api\DateTime::to($time,'ts');
1084
+			return Api\DateTime::to($time, 'ts');
1085 1085
 		}
1086
-		if (!is_a($time,'DateTime'))
1086
+		if (!is_a($time, 'DateTime'))
1087 1087
 		{
1088
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
1088
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
1089 1089
 		}
1090 1090
 		if (!isset(self::$tz_cache[$tzid]))
1091 1091
 		{
@@ -1120,11 +1120,11 @@  discard block
 block discarded – undo
1120 1120
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1121 1121
 	 * @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"
1122 1122
 	 */
1123
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1123
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1124 1124
 	{
1125 1125
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1126 1126
 		$this->events_imported = 0;
1127
-		$replace = $delete_exceptions= false;
1127
+		$replace = $delete_exceptions = false;
1128 1128
 
1129 1129
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1130 1130
 
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		{
1133 1133
 			return false;
1134 1134
 		}
1135
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1135
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1136 1136
 
1137 1137
 		if ($cal_id > 0)
1138 1138
 		{
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 			{
1141 1141
 				$replace = $recur_date == 0;
1142 1142
 				$events[0]['id'] = $cal_id;
1143
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1143
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1144 1144
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1145 1145
 			}
1146 1146
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			{
1193 1193
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1194 1194
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1195
-					. array2string($event)."\n",3,$this->logfile);
1195
+					. array2string($event)."\n", 3, $this->logfile);
1196 1196
 			}
1197 1197
 
1198 1198
 			$updated_id = false;
@@ -1215,14 +1215,14 @@  discard block
 block discarded – undo
1215 1215
 					{
1216 1216
 						if ($delete_exceptions)
1217 1217
 						{
1218
-							$this->delete($id,0,false,$skip_notification);
1218
+							$this->delete($id, 0, false, $skip_notification);
1219 1219
 						}
1220 1220
 						else
1221 1221
 						{
1222 1222
 							if (!($exception = $this->read($id))) continue;
1223 1223
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1224 1224
 							$exception['reference'] = $exception['recurrence'] = 0;
1225
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1225
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1226 1226
 						}
1227 1227
 					}
1228 1228
 				}
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 				{
1240 1240
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1241 1241
 						. "(UPDATE Event)\n"
1242
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1242
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1243 1243
 				}
1244 1244
 				if (empty($event['uid']))
1245 1245
 				{
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 								if ($this->log)
1262 1262
 								{
1263 1263
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1264
-										"() Restore status for $uid\n",3,$this->logfile);
1264
+										"() Restore status for $uid\n", 3, $this->logfile);
1265 1265
 								}
1266 1266
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1267 1267
 							}
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 					if ($this->log)
1286 1286
 					{
1287 1287
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1288
-							"()[MERGE]\n",3,$this->logfile);
1288
+							"()[MERGE]\n", 3, $this->logfile);
1289 1289
 					}
1290 1290
 					// overwrite with server data for merge
1291 1291
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
 				else
1316 1316
 				{
1317 1317
 					// no merge
1318
-					if(!isset($this->supportedFields['category']) || !isset($event['category']))
1318
+					if (!isset($this->supportedFields['category']) || !isset($event['category']))
1319 1319
 					{
1320 1320
 						$event['category'] = $event_info['stored_event']['category'];
1321 1321
 					}
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 						if ($this->log)
1328 1328
 						{
1329 1329
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1330
-							"() No participants\n",3,$this->logfile);
1330
+							"() No participants\n", 3, $this->logfile);
1331 1331
 						}
1332 1332
 
1333 1333
 						// If this is an updated meeting, and the client doesn't support
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 								if ($this->log)
1347 1347
 								{
1348 1348
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1349
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1349
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1350 1350
 								}
1351 1351
 								// Add it back in
1352 1352
 								$event['participants'][$uid] = $status;
@@ -1434,8 +1434,7 @@  discard block
 block discarded – undo
1434 1434
 						}
1435 1435
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1436 1436
 						$event['participants'][$user] = calendar_so::combine_status(
1437
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1438
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1437
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1439 1438
 					}
1440 1439
 				}
1441 1440
 				// check if an owner is set and the current user has add rights
@@ -1500,9 +1499,9 @@  discard block
 block discarded – undo
1500 1499
 
1501 1500
 			if ($this->log)
1502 1501
 			{
1503
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1504
-					. $event_info['type'] . ")\n"
1505
-					. array2string($event)."\n",3,$this->logfile);
1502
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1503
+					. $event_info['type'].")\n"
1504
+					. array2string($event)."\n", 3, $this->logfile);
1506 1505
 			}
1507 1506
 
1508 1507
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1510,10 +1509,10 @@  discard block
 block discarded – undo
1510 1509
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1511 1510
 				$event['status'] == 'CANCELLED')
1512 1511
 			{
1513
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1512
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1514 1513
 				{
1515 1514
 					// delete fails (because no rights), reject recurrence
1516
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1515
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1517 1516
 				}
1518 1517
 				continue;
1519 1518
 			}
@@ -1525,7 +1524,7 @@  discard block
 block discarded – undo
1525 1524
 					if ($this->log)
1526 1525
 					{
1527 1526
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1528
-							"(): event SINGLE\n",3,$this->logfile);
1527
+							"(): event SINGLE\n", 3, $this->logfile);
1529 1528
 					}
1530 1529
 
1531 1530
 					// update the event
@@ -1535,7 +1534,7 @@  discard block
 block discarded – undo
1535 1534
 						$event['reference'] = 0;
1536 1535
 						$event_to_store = $event; // prevent $event from being changed by the update method
1537 1536
 						$this->server2usertime($event_to_store);
1538
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1537
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1539 1538
 						unset($event_to_store);
1540 1539
 					}
1541 1540
 					break;
@@ -1544,7 +1543,7 @@  discard block
 block discarded – undo
1544 1543
 					if ($this->log)
1545 1544
 					{
1546 1545
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1547
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1546
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1548 1547
 					}
1549 1548
 
1550 1549
 					// remove all known pseudo exceptions and update the event
@@ -1554,8 +1553,8 @@  discard block
 block discarded – undo
1554 1553
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1555 1554
 						if ($this->log)
1556 1555
 						{
1557
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1558
-								array2string($days)."\n",3,$this->logfile);
1556
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1557
+								array2string($days)."\n", 3, $this->logfile);
1559 1558
 						}
1560 1559
 						if (is_array($days))
1561 1560
 						{
@@ -1573,7 +1572,7 @@  discard block
 block discarded – undo
1573 1572
 
1574 1573
 						$event_to_store = $event; // prevent $event from being changed by the update method
1575 1574
 						$this->server2usertime($event_to_store);
1576
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1575
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1577 1576
 						unset($event_to_store);
1578 1577
 					}
1579 1578
 					break;
@@ -1583,7 +1582,7 @@  discard block
 block discarded – undo
1583 1582
 					if ($this->log)
1584 1583
 					{
1585 1584
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1586
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1585
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1587 1586
 					}
1588 1587
 
1589 1588
 					// update event
@@ -1639,13 +1638,13 @@  discard block
 block discarded – undo
1639 1638
 							$event['owner'] = $event_info['master_event']['owner'];
1640 1639
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1641 1640
 							$this->server2usertime($event_to_store);
1642
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1641
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1643 1642
 							unset($event_to_store);
1644 1643
 						}
1645 1644
 
1646 1645
 						$event_to_store = $event; // prevent $event from being changed by update method
1647 1646
 						$this->server2usertime($event_to_store);
1648
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1647
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1649 1648
 						unset($event_to_store);
1650 1649
 					}
1651 1650
 					break;
@@ -1654,7 +1653,7 @@  discard block
 block discarded – undo
1654 1653
 					if ($this->log)
1655 1654
 					{
1656 1655
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1657
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1656
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1658 1657
 					}
1659 1658
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1660 1659
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1675,7 +1674,7 @@  discard block
 block discarded – undo
1675 1674
 						// save the series master with the adjusted exceptions
1676 1675
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1677 1676
 						$this->server2usertime($event_to_store);
1678
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1677
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1679 1678
 						unset($event_to_store);
1680 1679
 					}
1681 1680
 
@@ -1702,13 +1701,13 @@  discard block
 block discarded – undo
1702 1701
 							if ($event_info['acl_edit'])
1703 1702
 							{
1704 1703
 								// update all participants if we have the right to do that
1705
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1704
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1706 1705
 							}
1707 1706
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1708 1707
 							{
1709 1708
 								// update the users status only
1710 1709
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1711
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1710
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1712 1711
 							}
1713 1712
 						}
1714 1713
 						break;
@@ -1720,13 +1719,13 @@  discard block
 block discarded – undo
1720 1719
 							if ($event_info['acl_edit'])
1721 1720
 							{
1722 1721
 								// update all participants if we have the right to do that
1723
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1722
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1724 1723
 							}
1725 1724
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1726 1725
 							{
1727 1726
 								// update the users status only
1728 1727
 								$this->set_status($event_info['master_event']['id'], $this->user,
1729
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1728
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1730 1729
 							}
1731 1730
 						}
1732 1731
 						break;
@@ -1743,7 +1742,7 @@  discard block
 block discarded – undo
1743 1742
 					break;
1744 1743
 
1745 1744
 				case 'SERIES-PSEUDO-EXCEPTION':
1746
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1745
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1747 1746
 					break;
1748 1747
 
1749 1748
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1756,7 +1755,7 @@  discard block
 block discarded – undo
1756 1755
 					{
1757 1756
 						// we did not have sufficient rights to propagate the status only exception to a real one
1758 1757
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1759
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1758
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1760 1759
 					}
1761 1760
 					break;
1762 1761
 			}
@@ -1770,8 +1769,8 @@  discard block
 block discarded – undo
1770 1769
 			if ($this->log)
1771 1770
 			{
1772 1771
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1773
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1774
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1772
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1773
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1775 1774
 			}
1776 1775
 		}
1777 1776
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1793,19 +1792,19 @@  discard block
 block discarded – undo
1793 1792
 	 * @return mixed on success: int $cal_id > 0, on error or conflicts false.
1794 1793
 	 *	Conflicts are passed to $this->conflict_callback
1795 1794
 	 */
1796
-	public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
1795
+	public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
1797 1796
 	{
1798
-		if($this->conflict_callback !== null)
1797
+		if ($this->conflict_callback !== null)
1799 1798
 		{
1800 1799
 			// calendar_ical overrides search(), which breaks conflict checking
1801 1800
 			// so we make sure to use the original from parent
1802 1801
 			static $bo = null;
1803
-			if(!$bo)
1802
+			if (!$bo)
1804 1803
 			{
1805 1804
 				$bo = new calendar_boupdate();
1806 1805
 			}
1807 1806
 			$conflicts = $bo->conflicts($event);
1808
-			if(is_array($conflicts) && count($conflicts) > 0)
1807
+			if (is_array($conflicts) && count($conflicts) > 0)
1809 1808
 			{
1810 1809
 				call_user_func_array($this->conflict_callback, array(&$event, &$conflicts));
1811 1810
 				return false;
@@ -1826,11 +1825,11 @@  discard block
 block discarded – undo
1826 1825
 	{
1827 1826
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1828 1827
 		$modified = 0;
1829
-		foreach($event['alarm'] as &$alarm)
1828
+		foreach ($event['alarm'] as &$alarm)
1830 1829
 		{
1831 1830
 			// check if alarm is already stored or from other users
1832 1831
 			$found = false;
1833
-			foreach($old_alarms as $id => $old_alarm)
1832
+			foreach ($old_alarms as $id => $old_alarm)
1834 1833
 			{
1835 1834
 				// not current users alarm --> ignore
1836 1835
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1846,7 +1845,7 @@  discard block
 block discarded – undo
1846 1845
 					break;
1847 1846
 				}
1848 1847
 			}
1849
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
1848
+			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found ? 'existing' : 'new')." alarm ".array2string($alarm));
1850 1849
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1851 1850
 			{
1852 1851
 				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
@@ -1874,7 +1873,7 @@  discard block
 block discarded – undo
1874 1873
 			}
1875 1874
 		}
1876 1875
 		// remove all old alarms left from current user
1877
-		foreach($old_alarms as $id => $old_alarm)
1876
+		foreach ($old_alarms as $id => $old_alarm)
1878 1877
 		{
1879 1878
 			// not current users alarm --> ignore
1880 1879
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1897,7 +1896,7 @@  discard block
 block discarded – undo
1897 1896
 	 * @param string $what ='value'
1898 1897
 	 * @return mixed
1899 1898
 	 */
1900
-	static function _get_attribute($components,$name,$what='value')
1899
+	static function _get_attribute($components, $name, $what = 'value')
1901 1900
 	{
1902 1901
 		foreach ($components as $attribute)
1903 1902
 		{
@@ -1932,7 +1931,7 @@  discard block
 block discarded – undo
1932 1931
 						case 'DURATION':
1933 1932
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1934 1933
 							{
1935
-								$alarm['offset'] = $duration -$vattr['value'];
1934
+								$alarm['offset'] = $duration - $vattr['value'];
1936 1935
 							}
1937 1936
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1938 1937
 							{
@@ -1948,7 +1947,7 @@  discard block
 block discarded – undo
1948 1947
 							$alarm['time'] = $vattr['value'];
1949 1948
 							break;
1950 1949
 						default:
1951
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1950
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1952 1951
 					}
1953 1952
 					break;
1954 1953
 
@@ -1973,9 +1972,9 @@  discard block
 block discarded – undo
1973 1972
 		return 0;
1974 1973
 	}
1975 1974
 
1976
-	function setSupportedFields($_productManufacturer='', $_productName='')
1975
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1977 1976
 	{
1978
-		$state =& $_SESSION['SyncML.state'];
1977
+		$state = & $_SESSION['SyncML.state'];
1979 1978
 		if (isset($state))
1980 1979
 		{
1981 1980
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2272,10 +2271,10 @@  discard block
 block discarded – undo
2272 2271
 		if ($this->log)
2273 2272
 		{
2274 2273
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2275
-				'(' . $this->productManufacturer .
2276
-				', '. $this->productName .', ' .
2277
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
2278
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2274
+				'('.$this->productManufacturer.
2275
+				', '.$this->productName.', '.
2276
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
2277
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2279 2278
 		}
2280 2279
 
2281 2280
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2293,12 +2292,12 @@  discard block
 block discarded – undo
2293 2292
      *                         utf-8 for new format, iso-8859-1 for old format.
2294 2293
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2295 2294
 	 */
2296
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2295
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2297 2296
 	{
2298 2297
 		if ($this->log)
2299 2298
 		{
2300
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2301
-				array2string($_vcalData)."\n",3,$this->logfile);
2299
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2300
+				array2string($_vcalData)."\n", 3, $this->logfile);
2302 2301
 		}
2303 2302
 
2304 2303
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2333,14 +2332,14 @@  discard block
 block discarded – undo
2333 2332
 			if ($this->log)
2334 2333
 			{
2335 2334
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2336
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2335
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2337 2336
 			}
2338 2337
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2339 2338
 			return false;
2340 2339
 		}
2341 2340
 		foreach ($vcal->getComponents() as $component)
2342 2341
 		{
2343
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2342
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2344 2343
 			{
2345 2344
 				$events[] = $event;
2346 2345
 			}
@@ -2385,13 +2384,13 @@  discard block
 block discarded – undo
2385 2384
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2386 2385
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2387 2386
 	 */
2388
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2387
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2389 2388
 	{
2390 2389
 		//unset($component->_container); _debug_array($component);
2391 2390
 
2392 2391
 		if ($this->log)
2393 2392
 		{
2394
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2393
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2395 2394
 		}
2396 2395
 
2397 2396
 		// eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component
@@ -2451,16 +2450,16 @@  discard block
 block discarded – undo
2451 2450
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2452 2451
 	 * @return array|boolean			event on success, false on failure
2453 2452
 	 */
2454
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2453
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2455 2454
 	{
2456
-		unset($principalURL);	// not longer used, but required in function signature
2455
+		unset($principalURL); // not longer used, but required in function signature
2457 2456
 
2458 2457
 		if ($check_component && !is_a($component, $check_component))
2459 2458
 		{
2460 2459
 			if ($this->log)
2461 2460
 			{
2462
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2463
-					get_class($component)." found\n",3,$this->logfile);
2461
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2462
+					get_class($component)." found\n", 3, $this->logfile);
2464 2463
 			}
2465 2464
 			return false;
2466 2465
 		}
@@ -2476,11 +2475,11 @@  discard block
 block discarded – undo
2476 2475
 
2477 2476
 		$isDate = false;
2478 2477
 		$event		= array();
2479
-		$alarms		= array();
2480
-		$vcardData	= array(
2478
+		$alarms = array();
2479
+		$vcardData = array(
2481 2480
 			'recur_type'		=> MCAL_RECUR_NONE,
2482 2481
 			'recur_exception'	=> array(),
2483
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2482
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2484 2483
 		);
2485 2484
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
2486 2485
 		foreach (array_merge(
@@ -2497,7 +2496,7 @@  discard block
 block discarded – undo
2497 2496
 						$isDate = true;
2498 2497
 					}
2499 2498
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2500
-					$vcardData['start']	= $dtstart_ts;
2499
+					$vcardData['start'] = $dtstart_ts;
2501 2500
 
2502 2501
 					// set event timezone from dtstart, if specified there
2503 2502
 					if (!empty($attributes['params']['TZID']))
@@ -2515,18 +2514,18 @@  discard block
 block discarded – undo
2515 2514
 							}
2516 2515
 							else
2517 2516
 							{
2518
-								error_log(__METHOD__ . '() unknown TZID='
2519
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2520
-									. date_default_timezone_get() . '".'.array2string($tz));
2521
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2517
+								error_log(__METHOD__.'() unknown TZID='
2518
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2519
+									. date_default_timezone_get().'".'.array2string($tz));
2520
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2522 2521
 							}
2523 2522
 						}
2524
-						catch(Exception $e)
2523
+						catch (Exception $e)
2525 2524
 						{
2526
-							error_log(__METHOD__ . '() unknown TZID='
2527
-								. $attributes['params']['TZID'] . ', defaulting to timezone "'
2528
-								. date_default_timezone_get() . '".'.$e->getMessage());
2529
-							$event['tzid'] = date_default_timezone_get();	// default to current timezone
2525
+							error_log(__METHOD__.'() unknown TZID='
2526
+								. $attributes['params']['TZID'].', defaulting to timezone "'
2527
+								. date_default_timezone_get().'".'.$e->getMessage());
2528
+							$event['tzid'] = date_default_timezone_get(); // default to current timezone
2530 2529
 						}
2531 2530
 					}
2532 2531
 					// if no timezone given and one is specified in class (never the case for CalDAV)
@@ -2550,11 +2549,11 @@  discard block
 block discarded – undo
2550 2549
 
2551 2550
 				case 'DTEND':
2552 2551
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2553
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2552
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2554 2553
 					{
2555 2554
 						$dtend_ts -= 1;
2556 2555
 					}
2557
-					$vcardData['end']	= $dtend_ts;
2556
+					$vcardData['end'] = $dtend_ts;
2558 2557
 					break;
2559 2558
 
2560 2559
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2574,7 +2573,7 @@  discard block
 block discarded – undo
2574 2573
 			if ($this->log)
2575 2574
 			{
2576 2575
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2577
-					. "() DTSTART missing!\n",3,$this->logfile);
2576
+					. "() DTSTART missing!\n", 3, $this->logfile);
2578 2577
 			}
2579 2578
 			return false; // not a valid entry
2580 2579
 		}
@@ -2593,7 +2592,7 @@  discard block
 block discarded – undo
2593 2592
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2594 2593
 					if (isset($supportedFields['whole_day']))
2595 2594
 					{
2596
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2595
+						$event['whole_day'] = (isset($attributes['value']) ?strtoupper($attributes['value']) == 'TRUE' : true);
2597 2596
 					}
2598 2597
 					break;
2599 2598
 				case 'AALARM':
@@ -2623,18 +2622,18 @@  discard block
 block discarded – undo
2623 2622
 					$vcardData['recurrence'] = $attributes['value'];
2624 2623
 					break;
2625 2624
 				case 'LOCATION':
2626
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2625
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2627 2626
 					break;
2628 2627
 				case 'RRULE':
2629 2628
 					$recurence = $attributes['value'];
2630 2629
 					$vcardData['recur_interval'] = 1;
2631
-					$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0];
2630
+					$type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0];
2632 2631
 					// vCard 2.0 values for all types
2633
-					if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches))
2632
+					if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches))
2634 2633
 					{
2635 2634
 						$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]);
2636 2635
 						// If it couldn't be parsed, treat it as not set
2637
-						if(is_string($vcardData['recur_enddate']))
2636
+						if (is_string($vcardData['recur_enddate']))
2638 2637
 						{
2639 2638
 							unset($vcardData['recur_enddate']);
2640 2639
 						}
@@ -2644,16 +2643,16 @@  discard block
 block discarded – undo
2644 2643
 							self::check_fix_endate($vcardData);
2645 2644
 						}
2646 2645
 					}
2647
-					elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches))
2646
+					elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches))
2648 2647
 					{
2649 2648
 						$vcardData['recur_count'] = (int)$matches[1];
2650 2649
 					}
2651
-					if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
2650
+					if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches))
2652 2651
 					{
2653
-						$vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1;
2652
+						$vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1;
2654 2653
 					}
2655 2654
 					$vcardData['recur_data'] = 0;
2656
-					switch($type)
2655
+					switch ($type)
2657 2656
 					{
2658 2657
 						case 'D':	// 1.0
2659 2658
 							$recurenceMatches = null;
@@ -2677,20 +2676,20 @@  discard block
 block discarded – undo
2677 2676
 						case 'W':
2678 2677
 						case 'WEEKLY':
2679 2678
 							$days = array();
2680
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2679
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches))		// 1.0
2681 2680
 							{
2682 2681
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2683 2682
 								if (empty($recurenceMatches[2]))
2684 2683
 								{
2685
-									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
2684
+									$days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2));
2686 2685
 								}
2687 2686
 								else
2688 2687
 								{
2689
-									$days = explode(' ',trim($recurenceMatches[2]));
2688
+									$days = explode(' ', trim($recurenceMatches[2]));
2690 2689
 								}
2691 2690
 
2692 2691
 								$repeatMatches = null;
2693
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2692
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches))
2694 2693
 								{
2695 2694
 									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2696 2695
 								}
@@ -2701,21 +2700,21 @@  discard block
 block discarded – undo
2701 2700
 
2702 2701
 								$recur_days = $this->recur_days_1_0;
2703 2702
 							}
2704
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2703
+							elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches))	// 2.0
2705 2704
 							{
2706
-								$days = explode(',',$recurenceMatches[1]);
2705
+								$days = explode(',', $recurenceMatches[1]);
2707 2706
 								$recur_days = $this->recur_days;
2708 2707
 							}
2709 2708
 							else	// no day given, use the day of dtstart
2710 2709
 							{
2711
-								$vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']);
2710
+								$vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']);
2712 2711
 								$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
2713 2712
 							}
2714 2713
 							if ($days)
2715 2714
 							{
2716 2715
 								foreach ($recur_days as $id => $day)
2717 2716
 								{
2718
-									if (in_array(strtoupper(substr($day,0,2)),$days))
2717
+									if (in_array(strtoupper(substr($day, 0, 2)), $days))
2719 2718
 									{
2720 2719
 										$vcardData['recur_data'] |= $id;
2721 2720
 									}
@@ -2731,17 +2730,17 @@  discard block
 block discarded – undo
2731 2730
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2732 2731
 								$vcardData['recur_count'] = $recurenceMatches[2];
2733 2732
 							}
2734
-							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2733
+							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2735 2734
 							{
2736 2735
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
2737 2736
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2738 2737
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2739 2738
 							}
2740
-							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
2739
+							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches))
2741 2740
 							{
2742 2741
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
2743 2742
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2744
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches))
2743
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches))
2745 2744
 								{
2746 2745
 									$vcardData['recur_count'] = $recurenceMatches[1];
2747 2746
 								}
@@ -2758,7 +2757,7 @@  discard block
 block discarded – undo
2758 2757
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2759 2758
 								$vcardData['recur_count'] = $recurenceMatches[2];
2760 2759
 							}
2761
-							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2760
+							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2762 2761
 							{
2763 2762
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2764 2763
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
@@ -2772,11 +2771,11 @@  discard block
 block discarded – undo
2772 2771
 							}
2773 2772
 							// handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL
2774 2773
 							$vcardData['recur_interval'] = $vcardData['recur_interval'] ?
2775
-								12*$vcardData['recur_interval'] : 12;
2774
+								12 * $vcardData['recur_interval'] : 12;
2776 2775
 							// fall-through
2777 2776
 						case 'MONTHLY':
2778 2777
 							// does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART
2779
-							$vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ?
2778
+							$vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ?
2780 2779
 								MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
2781 2780
 							break;
2782 2781
 					}
@@ -2832,11 +2831,11 @@  discard block
 block discarded – undo
2832 2831
 						(strpos($this->productName, 'outlook') !== false
2833 2832
 							|| strpos($this->productName, 'pocket pc') !== false))
2834 2833
 					{
2835
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2834
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2836 2835
 					}
2837 2836
 					else
2838 2837
 					{
2839
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2838
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2840 2839
 					}
2841 2840
 					break;
2842 2841
 				case 'CATEGORIES':
@@ -2850,10 +2849,10 @@  discard block
 block discarded – undo
2850 2849
 					}
2851 2850
 					break;
2852 2851
 				case 'ORGANIZER':
2853
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2854
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2852
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2853
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2855 2854
 					{
2856
-						$event['organizer'] = substr($event['organizer'],7);
2855
+						$event['organizer'] = substr($event['organizer'], 7);
2857 2856
 					}
2858 2857
 					if (!empty($attributes['params']['CN']))
2859 2858
 					{
@@ -2890,19 +2889,19 @@  discard block
 block discarded – undo
2890 2889
 					}
2891 2890
 					// try parsing email and cn from attendee
2892 2891
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2893
-						$attributes['value'],$matches))
2892
+						$attributes['value'], $matches))
2894 2893
 					{
2895 2894
 						$email = $matches[1] ? $matches[1] : $matches[3];
2896
-						$cn = isset($matches[2]) ? $matches[2]: '';
2895
+						$cn = isset($matches[2]) ? $matches[2] : '';
2897 2896
 					}
2898 2897
 					elseif (!empty($attributes['value']) &&
2899 2898
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2900
-						$attributes['value'],$matches))
2899
+						$attributes['value'], $matches))
2901 2900
 					{
2902 2901
 						$cn = $matches[1];
2903 2902
 						$email = $matches[2];
2904 2903
 					}
2905
-					elseif (strpos($attributes['value'],'@') !== false)
2904
+					elseif (strpos($attributes['value'], '@') !== false)
2906 2905
 					{
2907 2906
 						$email = $attributes['value'];
2908 2907
 					}
@@ -2919,7 +2918,7 @@  discard block
 block discarded – undo
2919 2918
 						if ($this->log)
2920 2919
 						{
2921 2920
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2922
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2921
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2923 2922
 						}
2924 2923
 					}
2925 2924
 					elseif ($attributes['value'] == 'Unknown')
@@ -2937,7 +2936,7 @@  discard block
 block discarded – undo
2937 2936
 						if ($this->log)
2938 2937
 						{
2939 2938
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2940
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2939
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2941 2940
 						}
2942 2941
 					}
2943 2942
 					if (!$uid)
@@ -2954,9 +2953,9 @@  discard block
 block discarded – undo
2954 2953
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2955 2954
 										array(',', ';', ':', '\\'),
2956 2955
 										$attributes['params']['CN']);
2957
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2956
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2958 2957
 							{
2959
-								$cn = substr($cn,1,-1);
2958
+								$cn = substr($cn, 1, -1);
2960 2959
 							}
2961 2960
 							// not searching for $cn, as match can be not unique or without an email address
2962 2961
 							// --> notification will fail, better store just as email
@@ -2965,19 +2964,19 @@  discard block
 block discarded – undo
2965 2964
 						if ($this->log)
2966 2965
 						{
2967 2966
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2968
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2967
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2969 2968
 						}
2970 2969
 
2971 2970
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2972
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2971
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2973 2972
 						{
2974 2973
 							// we found a group
2975 2974
 							if ($this->log)
2976 2975
 							{
2977 2976
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2978
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2977
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2979 2978
 							}
2980
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2979
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2981 2980
 							{
2982 2981
 								//Horde::logMessage("vevent2egw: group participant $uid",
2983 2982
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2991,7 +2990,7 @@  discard block
 block discarded – undo
2991 2990
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2992 2991
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2993 2992
 										$vcardData['participants'][$this->user] =
2994
-											calendar_so::combine_status($status,$quantity,$role);
2993
+											calendar_so::combine_status($status, $quantity, $role);
2995 2994
 									}
2996 2995
 								}
2997 2996
 								$status = 'U'; // keep the group
@@ -3000,36 +2999,36 @@  discard block
 block discarded – undo
3000 2999
 						}
3001 3000
 						elseif (empty($searcharray))
3002 3001
 						{
3003
-							continue;	// participants without email AND CN --> ignore it
3002
+							continue; // participants without email AND CN --> ignore it
3004 3003
 						}
3005 3004
 						elseif ((list($data) = $this->addressbook->search($searcharray,
3006
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
3005
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
3007 3006
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
3008
-							'','',false,'OR')))
3007
+							'', '', false, 'OR')))
3009 3008
 						{
3010 3009
 							// found an addressbook entry
3011 3010
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
3012 3011
 							if ($this->log)
3013 3012
 							{
3014 3013
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
3015
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
3014
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
3016 3015
 							}
3017 3016
 						}
3018 3017
 						else
3019 3018
 						{
3020 3019
 							if (!$email)
3021 3020
 							{
3022
-								$email = '[email protected]';	// set dummy email to store the CN
3021
+								$email = '[email protected]'; // set dummy email to store the CN
3023 3022
 							}
3024
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
3023
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
3025 3024
 							if ($this->log)
3026 3025
 							{
3027 3026
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
3028
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
3027
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
3029 3028
 							}
3030 3029
 						}
3031 3030
 					}
3032
-					switch($attributes['name'])
3031
+					switch ($attributes['name'])
3033 3032
 					{
3034 3033
 						case 'ATTENDEE':
3035 3034
 							if (!isset($attributes['params']['ROLE']) &&
@@ -3043,7 +3042,7 @@  discard block
 block discarded – undo
3043 3042
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
3044 3043
 								// as this is currently the only way to store an external organizer and send him iMip responses
3045 3044
 								$q = $r = null;
3046
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
3045
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
3047 3046
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
3048 3047
 								{
3049 3048
 									$role = 'CHAIR';
@@ -3057,7 +3056,7 @@  discard block
 block discarded – undo
3057 3056
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3058 3057
 										$component->getAttribute('ORGANIZER');
3059 3058
 								}
3060
-								catch(Horde_Icalendar_Exception $e)
3059
+								catch (Horde_Icalendar_Exception $e)
3061 3060
 								{
3062 3061
 									// we can store the ORGANIZER as event owner
3063 3062
 									$event['owner'] = $uid;
@@ -3113,7 +3112,7 @@  discard block
 block discarded – undo
3113 3112
 					break;
3114 3113
 
3115 3114
 				case 'ATTACH':
3116
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3115
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3117 3116
 					// fall throught to store external attachment url
3118 3117
 				default:	// X- attribute or other by EGroupware unsupported property
3119 3118
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3171,7 +3170,7 @@  discard block
 block discarded – undo
3171 3170
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3172 3171
 					{
3173 3172
 						$event['reference'] = 0;
3174
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3173
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3175 3174
 						{
3176 3175
 							if (isset($vcardData[$r]))
3177 3176
 							{
@@ -3194,12 +3193,12 @@  discard block
 block discarded – undo
3194 3193
 			// reset recure_enddate to 00:00:00 on the last day
3195 3194
 			$rriter = calendar_rrule::event2rrule($event, false);
3196 3195
 			$last = $rriter->normalize_enddate();
3197
-			if(!is_object($last))
3196
+			if (!is_object($last))
3198 3197
 			{
3199
-				if($this->log)
3198
+				if ($this->log)
3200 3199
 				{
3201
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3202
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3200
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3201
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3203 3202
 				}
3204 3203
 				return false;
3205 3204
 			}
@@ -3208,16 +3207,16 @@  discard block
 block discarded – undo
3208 3207
 			$event['recur_enddate'] = Api\DateTime::to($last, 'server');
3209 3208
 		}
3210 3209
 		// translate COUNT into an enddate, as we only store enddates
3211
-		elseif($event['recur_count'])
3210
+		elseif ($event['recur_count'])
3212 3211
 		{
3213 3212
 			$rriter = calendar_rrule::event2rrule($event, false);
3214 3213
 			$last = $rriter->count2date($event['recur_count']);
3215
-			if(!is_object($last))
3214
+			if (!is_object($last))
3216 3215
 			{
3217
-				if($this->log)
3216
+				if ($this->log)
3218 3217
 				{
3219 3218
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3220
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3219
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3221 3220
 				}
3222 3221
 				return false;
3223 3222
 			}
@@ -3231,7 +3230,7 @@  discard block
 block discarded – undo
3231 3230
 			if ($this->productManufacturer == 'groupdav' && $container &&
3232 3231
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3233 3232
 			{
3234
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3233
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3235 3234
 			}
3236 3235
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3237 3236
 		}
@@ -3252,15 +3251,15 @@  discard block
 block discarded – undo
3252 3251
 
3253 3252
 		if ($this->log)
3254 3253
 		{
3255
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3256
-				array2string($event)."\n",3,$this->logfile);
3254
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3255
+				array2string($event)."\n", 3, $this->logfile);
3257 3256
 		}
3258 3257
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3259 3258
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3260 3259
 		return $event;
3261 3260
 	}
3262 3261
 
3263
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3262
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3264 3263
 	{
3265 3264
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3266 3265
 		{
@@ -3281,8 +3280,8 @@  discard block
 block discarded – undo
3281 3280
 			}
3282 3281
 			if ($this->log)
3283 3282
 			{
3284
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3285
-					array2string($events)."\n",3,$this->logfile);
3283
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3284
+					array2string($events)."\n", 3, $this->logfile);
3286 3285
 			}
3287 3286
 		}
3288 3287
 		return array();
@@ -3321,23 +3320,23 @@  discard block
 block discarded – undo
3321 3320
 	 * @param array $extra =null extra attributes to add
3322 3321
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3323 3322
 	 */
3324
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3323
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3325 3324
 	{
3326
-		if (!$start) $start = time();	// default now
3327
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3325
+		if (!$start) $start = time(); // default now
3326
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3328 3327
 
3329 3328
 		$vcal = new Horde_Icalendar;
3330
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3329
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3331 3330
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3332
-		$vcal->setAttribute('VERSION','2.0');
3333
-		$vcal->setAttribute('METHOD',$method);
3331
+		$vcal->setAttribute('VERSION', '2.0');
3332
+		$vcal->setAttribute('METHOD', $method);
3334 3333
 
3335
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3334
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3336 3335
 
3337 3336
 		$attributes = array(
3338 3337
 			'DTSTAMP' => time(),
3339
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3340
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3338
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3339
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3341 3340
 		);
3342 3341
 		if (!$utc)
3343 3342
 		{
@@ -3348,9 +3347,9 @@  discard block
 block discarded – undo
3348 3347
 		}
3349 3348
 		if (is_null($extra)) $extra = array(
3350 3349
 			'URL' => $this->freebusy_url($user),
3351
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3350
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3352 3351
 		);
3353
-		foreach($attributes+$extra as $attr => $value)
3352
+		foreach ($attributes + $extra as $attr => $value)
3354 3353
 		{
3355 3354
 			$vfreebusy->setAttribute($attr, $value);
3356 3355
 		}
@@ -3376,16 +3375,16 @@  discard block
 block discarded – undo
3376 3375
 
3377 3376
 				if ($utc)
3378 3377
 				{
3379
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3378
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3380 3379
 						'start' => $event['start'],
3381 3380
 						'end' => $event['end'],
3382 3381
 					)), array('FBTYPE' => $fbtype));
3383 3382
 				}
3384 3383
 				else
3385 3384
 				{
3386
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3387
-						'start' => date('Ymd\THis',$event['start']),
3388
-						'end' => date('Ymd\THis',$event['end']),
3385
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3386
+						'start' => date('Ymd\THis', $event['start']),
3387
+						'end' => date('Ymd\THis', $event['end']),
3389 3388
 					)), array('FBTYPE' => $fbtype));
3390 3389
 				}
3391 3390
 			}
Please login to merge, or discard this patch.
Braces   +326 added lines, -84 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 	function __construct(&$_clientProperties = array())
184 184
 	{
185 185
 		parent::__construct();
186
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
186
+		if ($this->log)
187
+		{
188
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
189
+		}
187 190
 		$this->clientProperties = $_clientProperties;
188 191
 		$this->vCalendar = new Horde_Icalendar;
189 192
 		$this->addressbook = new Api\Contacts;
@@ -232,10 +235,14 @@  discard block
 block discarded – undo
232 235
 			'ATTACH'        => 'attachments',
233 236
 		);
234 237
 
235
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
238
+		if (!is_array($this->supportedFields))
239
+		{
240
+			$this->setSupportedFields();
241
+		}
236 242
 
237 243
 		if ($this->productManufacturer == '' )
238
-		{	// syncevolution is broken
244
+		{
245
+// syncevolution is broken
239 246
 			$version = '2.0';
240 247
 		}
241 248
 
@@ -243,10 +250,16 @@  discard block
 block discarded – undo
243 250
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
244 251
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
245 252
 		$vcal->setAttribute('VERSION', $version);
246
-		if ($method) $vcal->setAttribute('METHOD', $method);
253
+		if ($method)
254
+		{
255
+			$vcal->setAttribute('METHOD', $method);
256
+		}
247 257
 		$events_exported = false;
248 258
 
249
-		if (!is_array($events)) $events = array($events);
259
+		if (!is_array($events))
260
+		{
261
+			$events = array($events);
262
+		}
250 263
 
251 264
 		$vtimezones_added = array();
252 265
 		foreach ($events as $event)
@@ -312,15 +325,21 @@  discard block
 block discarded – undo
312 325
 				try {
313 326
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
314 327
 			}
315
-				catch (Exception $e) {
328
+			catch (Exception $e) {
316 329
 					// log unknown timezones
317
-					if (!empty($event['tzid'])) _egw_log_exception($e);
330
+					if (!empty($event['tzid']))
331
+					{
332
+						_egw_log_exception($e);
333
+					}
318 334
 					// default for no timezone and unkown to user timezone
319 335
 					self::$tz_cache[$event['tzid']] = Api\DateTime::$user_timezone;
320 336
 				}
321 337
 			}
322 338
 
323
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
339
+			if ($this->so->isWholeDay($event))
340
+			{
341
+				$event['whole_day'] = true;
342
+			}
324 343
 
325 344
 			if ($this->log)
326 345
 			{
@@ -331,7 +350,10 @@  discard block
 block discarded – undo
331 350
 
332 351
 			if ($recurrence)
333 352
 			{
334
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
353
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
354
+				{
355
+					continue;
356
+				}
335 357
 
336 358
 				if (!isset($this->supportedFields['participants']))
337 359
 				{
@@ -388,7 +410,8 @@  discard block
 block discarded – undo
388 410
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
389 411
 			{
390 412
 				// Append UID to DESCRIPTION
391
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
413
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
414
+				{
392 415
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
393 416
 				}
394 417
 			}
@@ -448,11 +471,21 @@  discard block
 block discarded – undo
448 471
 							$quantity = $role = null;
449 472
 							calendar_so::split_status($status, $quantity, $role);
450 473
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
451
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
474
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
475
+							{
476
+								continue;
477
+							}
452 478
 
453
-							if (!($info = $this->resource_info($uid))) continue;
479
+							if (!($info = $this->resource_info($uid)))
480
+							{
481
+								continue;
482
+							}
454 483
 
455
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
484
+							if (in_array($status, array('X','E')))
485
+							{
486
+								continue;
487
+							}
488
+							// dont include deleted participants
456 489
 
457 490
 							if ($this->log)
458 491
 							{
@@ -531,24 +564,49 @@  discard block
 block discarded – undo
531 564
 							}
532 565
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
533 566
 							$options = array();
534
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
535
-							if (!empty($role)) $options['ROLE'] = $role;
536
-							if (!empty($status)) $options['PARTSTAT'] = $status;
537
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
538
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
567
+							if (!empty($participantCN))
568
+							{
569
+								$options['CN'] = $participantCN;
570
+							}
571
+							if (!empty($role))
572
+							{
573
+								$options['ROLE'] = $role;
574
+							}
575
+							if (!empty($status))
576
+							{
577
+								$options['PARTSTAT'] = $status;
578
+							}
579
+							if (!empty($cutype))
580
+							{
581
+								$options['CUTYPE'] = $cutype;
582
+							}
583
+							if (!empty($rsvp))
584
+							{
585
+								$options['RSVP'] = $rsvp;
586
+							}
539 587
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
540 588
 							{
541 589
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
542 590
 							}
543
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
544
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
591
+							if ($info['type'] != 'e')
592
+							{
593
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
594
+							}
595
+							if ($quantity > 1)
596
+							{
597
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
598
+							}
545 599
 							$attributes['ATTENDEE'][] = $participantURL;
546 600
 							$parameters['ATTENDEE'][] = $options;
547 601
 						}
548 602
 						break;
549 603
 
550 604
 					case 'CLASS':
551
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
605
+						if ($event['public'])
606
+						{
607
+							continue;
608
+						}
609
+						// public is default, no need to export, fails CalDAVTester if added as default
552 610
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
553 611
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
554 612
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -580,9 +638,18 @@  discard block
 block discarded – undo
580 638
 									'CUTYPE'   => 'INDIVIDUAL',
581 639
 									//'RSVP'     => 'FALSE',
582 640
 									);
583
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
584
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
585
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
641
+								if (!empty($organizerCN))
642
+								{
643
+									$options['CN'] = $organizerCN;
644
+								}
645
+								if (!empty($organizerEMail))
646
+								{
647
+									$options['EMAIL'] = $organizerEMail;
648
+								}
649
+								if (!empty($event['owner']))
650
+								{
651
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
652
+								}
586 653
 								$attributes['ATTENDEE'][] = $organizerURL;
587 654
 			    				$parameters['ATTENDEE'][] = $options;
588 655
 		    				}
@@ -611,9 +678,12 @@  discard block
 block discarded – undo
611 678
 						{
612 679
 							// Hack for CalDAVTester to export duration instead of endtime
613 680
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
614
-								$attributes['duration'] = $event['end'] - $event['start'];
615
-							else
616
-								$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
681
+							{
682
+															$attributes['duration'] = $event['end'] - $event['start'];
683
+							}
684
+							else {
685
+															$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
686
+							}
617 687
 						}
618 688
 						else
619 689
 						{
@@ -633,7 +703,11 @@  discard block
 block discarded – undo
633 703
 						break;
634 704
 
635 705
 					case 'RRULE':
636
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
706
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
707
+						{
708
+							break;
709
+						}
710
+						// no recuring event
637 711
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
638 712
 						$rrule = $rriter->generate_rrule($version);
639 713
 						if ($event['recur_enddate'])
@@ -675,7 +749,10 @@  discard block
 block discarded – undo
675 749
 						break;
676 750
 
677 751
 					case 'EXDATE':
678
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
752
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
753
+						{
754
+							break;
755
+						}
679 756
 						if (!empty($event['recur_exception']))
680 757
 						{
681 758
 							if (empty($event['whole_day']))
@@ -702,14 +779,21 @@  discard block
 block discarded – undo
702 779
 									);
703 780
 								}
704 781
 								$event['recur_exception'] = $days;
705
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
782
+								if ($version != '1.0')
783
+								{
784
+									$parameters['EXDATE']['VALUE'] = 'DATE';
785
+								}
706 786
 							}
707 787
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
708 788
 						}
709 789
 						break;
710 790
 
711 791
 					case 'PRIORITY':
712
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
792
+						if (!$event['priority'])
793
+						{
794
+							continue;
795
+						}
796
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
713 797
 						if ($this->productManufacturer == 'funambol' &&
714 798
 							(strpos($this->productName, 'outlook') !== false
715 799
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -723,7 +807,11 @@  discard block
 block discarded – undo
723 807
 						break;
724 808
 
725 809
 					case 'TRANSP':
726
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
810
+						if (!$event['non_blocking'])
811
+						{
812
+							continue;
813
+						}
814
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
727 815
 						if ($version == '1.0')
728 816
 						{
729 817
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -780,7 +868,11 @@  discard block
 block discarded – undo
780 868
 						elseif ($event['recurrence'] && $event['reference'])
781 869
 						{
782 870
 							// $event['reference'] is a calendar_id, not a timestamp
783
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
871
+							if (!($revent = $this->read($event['reference'])))
872
+							{
873
+								break;
874
+							}
875
+							// referenced event does not exist
784 876
 
785 877
 							if (empty($revent['whole_day']))
786 878
 							{
@@ -906,7 +998,10 @@  discard block
 block discarded – undo
906 998
 			foreach ((array)$event['alarm'] as $alarmData)
907 999
 			{
908 1000
 				// skip over alarms that don't have the minimum required info
909
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
1001
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
1002
+				{
1003
+					continue;
1004
+				}
910 1005
 
911 1006
 				// skip alarms not being set for all users and alarms owned by other users
912 1007
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -923,7 +1018,10 @@  discard block
 block discarded – undo
923 1018
 
924 1019
 				if ($version == '1.0')
925 1020
 				{
926
-					if ($event['title']) $description = $event['title'];
1021
+					if ($event['title'])
1022
+					{
1023
+						$description = $event['title'];
1024
+					}
927 1025
 					if ($description)
928 1026
 					{
929 1027
 						$values['DALARM']['snooze_time'] = '';
@@ -943,7 +1041,10 @@  discard block
 block discarded – undo
943 1041
 					// VCalendar 2.0 / RFC 2445
944 1042
 
945 1043
 					// RFC requires DESCRIPTION for DISPLAY
946
-					if (!$event['title'] && !$description) $description = 'Alarm';
1044
+					if (!$event['title'] && !$description)
1045
+					{
1046
+						$description = 'Alarm';
1047
+					}
947 1048
 
948 1049
 					/* Disabling for now
949 1050
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1134,13 +1235,20 @@  discard block
 block discarded – undo
1134 1235
 		$this->events_imported = 0;
1135 1236
 		$replace = $delete_exceptions= false;
1136 1237
 
1137
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1238
+		if (!is_array($this->supportedFields))
1239
+		{
1240
+			$this->setSupportedFields();
1241
+		}
1138 1242
 
1139 1243
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1140 1244
 		{
1141 1245
 			return false;
1142 1246
 		}
1143
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1247
+		if (!is_array($events))
1248
+		{
1249
+			$cal_id = -1;
1250
+		}
1251
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1144 1252
 
1145 1253
 		if ($cal_id > 0)
1146 1254
 		{
@@ -1148,8 +1256,14 @@  discard block
 block discarded – undo
1148 1256
 			{
1149 1257
 				$replace = $recur_date == 0;
1150 1258
 				$events[0]['id'] = $cal_id;
1151
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1152
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1259
+				if (!is_null($etag))
1260
+				{
1261
+					$events[0]['etag'] = (int) $etag;
1262
+				}
1263
+				if ($recur_date)
1264
+				{
1265
+					$events[0]['recurrence'] = $recur_date;
1266
+				}
1153 1267
 			}
1154 1268
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1155 1269
 					($eventId = array_shift($foundEvent)) &&
@@ -1157,7 +1271,10 @@  discard block
 block discarded – undo
1157 1271
 			{
1158 1272
 				foreach ($events as $k => $event)
1159 1273
 				{
1160
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1274
+					if (!isset($event['uid']))
1275
+					{
1276
+						$events[$k]['uid'] = $egwEvent['uid'];
1277
+					}
1161 1278
 				}
1162 1279
 			}
1163 1280
 		}
@@ -1187,10 +1304,17 @@  discard block
 block discarded – undo
1187 1304
 		$msg = null;
1188 1305
 		foreach ($events as $event)
1189 1306
 		{
1190
-			if (!is_array($event)) continue; // the iterator may return false
1307
+			if (!is_array($event))
1308
+			{
1309
+				continue;
1310
+			}
1311
+			// the iterator may return false
1191 1312
 			++$this->events_imported;
1192 1313
 
1193
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1314
+			if ($this->so->isWholeDay($event))
1315
+			{
1316
+				$event['whole_day'] = true;
1317
+			}
1194 1318
 			if (is_array($event['category']))
1195 1319
 			{
1196 1320
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1227,7 +1351,10 @@  discard block
 block discarded – undo
1227 1351
 						}
1228 1352
 						else
1229 1353
 						{
1230
-							if (!($exception = $this->read($id))) continue;
1354
+							if (!($exception = $this->read($id)))
1355
+							{
1356
+								continue;
1357
+							}
1231 1358
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1232 1359
 							$exception['reference'] = $exception['recurrence'] = 0;
1233 1360
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1316,7 +1443,10 @@  discard block
 block discarded – undo
1316 1443
 								break;
1317 1444
 
1318 1445
 							default:
1319
-								if (!empty($value)) $event[$key] = $value;
1446
+								if (!empty($value))
1447
+								{
1448
+									$event[$key] = $value;
1449
+								}
1320 1450
 						}
1321 1451
 					}
1322 1452
 				}
@@ -1414,7 +1544,10 @@  discard block
 block discarded – undo
1414 1544
 			else // common adjustments for new events
1415 1545
 			{
1416 1546
 				unset($event['id']);
1417
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1547
+				if ($caldav_name)
1548
+				{
1549
+					$event['caldav_name'] = $caldav_name;
1550
+				}
1418 1551
 				// set non blocking all day depending on the user setting
1419 1552
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1420 1553
 				{
@@ -1462,7 +1595,10 @@  discard block
 block discarded – undo
1462 1595
 					|| !isset($event['participants'][$event['owner']]))
1463 1596
 				{
1464 1597
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1465
-					if (!is_array($event['participants'])) $event['participants'] = array();
1598
+					if (!is_array($event['participants']))
1599
+					{
1600
+						$event['participants'] = array();
1601
+					}
1466 1602
 					$event['participants'][$event['owner']] = $status;
1467 1603
 				}
1468 1604
 				else
@@ -1615,7 +1751,10 @@  discard block
 block discarded – undo
1615 1751
 								$occurence = $exception = false;
1616 1752
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1617 1753
 								{
1618
-									if ($exception > $event['start']) break;
1754
+									if ($exception > $event['start'])
1755
+									{
1756
+										break;
1757
+									}
1619 1758
 									$occurence = $exception;
1620 1759
 								}
1621 1760
 								if (!$occurence)
@@ -1705,12 +1844,15 @@  discard block
 block discarded – undo
1705 1844
 					case 'SERIES-MASTER':
1706 1845
 					case 'SERIES-EXCEPTION':
1707 1846
 					case 'SERIES-EXCEPTION-PROPAGATE':
1708
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1847
+						if (is_array($event_info['stored_event']))
1848
+						{
1849
+							// status update requires a stored event
1709 1850
 						{
1710 1851
 							if ($event_info['acl_edit'])
1711 1852
 							{
1712 1853
 								// update all participants if we have the right to do that
1713 1854
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1855
+						}
1714 1856
 							}
1715 1857
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1716 1858
 							{
@@ -1722,9 +1864,12 @@  discard block
 block discarded – undo
1722 1864
 						break;
1723 1865
 
1724 1866
 					case 'SERIES-PSEUDO-EXCEPTION':
1725
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1867
+						if (is_array($event_info['master_event']))
1868
+						{
1869
+							// status update requires a stored master event
1726 1870
 						{
1727 1871
 							$recurrence = $this->date2usertime($event['recurrence']);
1872
+						}
1728 1873
 							if ($event_info['acl_edit'])
1729 1874
 							{
1730 1875
 								// update all participants if we have the right to do that
@@ -1832,7 +1977,10 @@  discard block
 block discarded – undo
1832 1977
 	 */
1833 1978
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1834 1979
 	{
1835
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1980
+		if ($this->debug)
1981
+		{
1982
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1983
+		}
1836 1984
 		$modified = 0;
1837 1985
 		foreach($event['alarm'] as &$alarm)
1838 1986
 		{
@@ -1854,29 +2002,56 @@  discard block
 block discarded – undo
1854 2002
 					break;
1855 2003
 				}
1856 2004
 			}
1857
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2005
+			if ($this->debug)
2006
+			{
2007
+				error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2008
+			}
1858 2009
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1859 2010
 			{
1860
-				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2011
+				if ($this->debug)
2012
+				{
2013
+					error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2014
+				}
1861 2015
 				unset($alarm['attrs']['X-LIC-ERROR']);
1862 2016
 			}
1863 2017
 			// alarm not found --> add it
1864 2018
 			if (!$found)
1865 2019
 			{
1866 2020
 				$alarm['owner'] = $user;
1867
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1868
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1869
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1870
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
2021
+				if (!isset($alarm['time']))
2022
+				{
2023
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2024
+				}
2025
+				if ($alarm['time'] < time())
2026
+				{
2027
+					calendar_so::shift_alarm($event, $alarm);
2028
+				}
2029
+				if ($this->debug)
2030
+				{
2031
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
2032
+				}
2033
+				if ($event['id'])
2034
+				{
2035
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
2036
+				}
1871 2037
 				++$modified;
1872 2038
 			}
1873 2039
 			// existing alarm --> update it
1874 2040
 			else
1875 2041
 			{
1876
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1877
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
2042
+				if (!isset($alarm['time']))
2043
+				{
2044
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2045
+				}
2046
+				if ($alarm['time'] < time())
2047
+				{
2048
+					calendar_so::shift_alarm($event, $alarm);
2049
+				}
1878 2050
 				$alarm = array_merge($old_alarm, $alarm);
1879
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2051
+				if ($this->debug)
2052
+				{
2053
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2054
+				}
1880 2055
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1881 2056
 				++$modified;
1882 2057
 			}
@@ -1890,7 +2065,10 @@  discard block
 block discarded – undo
1890 2065
 				unset($old_alarm[$id]);
1891 2066
 				continue;
1892 2067
 			}
1893
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2068
+			if ($this->debug)
2069
+			{
2070
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2071
+			}
1894 2072
 			$this->delete_alarm($id);
1895 2073
 			++$modified;
1896 2074
 		}
@@ -2309,7 +2487,10 @@  discard block
 block discarded – undo
2309 2487
 				array2string($_vcalData)."\n",3,$this->logfile);
2310 2488
 		}
2311 2489
 
2312
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2490
+		if (!is_array($this->supportedFields))
2491
+		{
2492
+			$this->setSupportedFields();
2493
+		}
2313 2494
 
2314 2495
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2315 2496
 		if (is_resource($_vcalData))
@@ -2675,19 +2856,27 @@  discard block
 block discarded – undo
2675 2856
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2676 2857
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2677 2858
 							}
2678
-							else break;
2859
+							else {
2860
+								break;
2861
+							}
2679 2862
 							// fall-through
2680 2863
 						case 'DAILY':	// 2.0
2681 2864
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2682
-							if (stripos($recurence, 'BYDAY') === false) break;
2865
+							if (stripos($recurence, 'BYDAY') === false)
2866
+							{
2867
+								break;
2868
+							}
2683 2869
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2684 2870
 							// fall-through
2685 2871
 						case 'W':
2686 2872
 						case 'WEEKLY':
2687 2873
 							$days = array();
2688
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2874
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2875
+							{
2876
+								// 1.0
2689 2877
 							{
2690 2878
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2879
+							}
2691 2880
 								if (empty($recurenceMatches[2]))
2692 2881
 								{
2693 2882
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2700,7 +2889,10 @@  discard block
 block discarded – undo
2700 2889
 								$repeatMatches = null;
2701 2890
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2702 2891
 								{
2703
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2892
+									if ($repeatMatches[1])
2893
+									{
2894
+										$vcardData['recur_count'] = $repeatMatches[1];
2895
+									}
2704 2896
 								}
2705 2897
 								else
2706 2898
 								{
@@ -2709,9 +2901,12 @@  discard block
 block discarded – undo
2709 2901
 
2710 2902
 								$recur_days = $this->recur_days_1_0;
2711 2903
 							}
2712
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2904
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2905
+							{
2906
+								// 2.0
2713 2907
 							{
2714 2908
 								$days = explode(',',$recurenceMatches[1]);
2909
+							}
2715 2910
 								$recur_days = $this->recur_days;
2716 2911
 							}
2717 2912
 							else	// no day given, use the day of dtstart
@@ -2770,7 +2965,10 @@  discard block
 block discarded – undo
2770 2965
 							{
2771 2966
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2772 2967
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2773
-							} else break;
2968
+							}
2969
+							else {
2970
+								break;
2971
+							}
2774 2972
 							// fall-through
2775 2973
 						case 'YEARLY':	// 2.0
2776 2974
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2863,13 +3061,16 @@  discard block
 block discarded – undo
2863 3061
 					// fall throught
2864 3062
 				case 'ATTENDEE':
2865 3063
 					if (isset($attributes['params']['PARTSTAT']))
2866
-				    {
3064
+					{
2867 3065
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2868 3066
 				    }
2869 3067
 				    if (isset($attributes['params']['STATUS']))
2870
-					{
3068
+				    {
2871 3069
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2872
-						if (empty($status)) $status = 'X';
3070
+						if (empty($status))
3071
+						{
3072
+							$status = 'X';
3073
+						}
2873 3074
 					}
2874 3075
 					else
2875 3076
 					{
@@ -2929,7 +3130,10 @@  discard block
 block discarded – undo
2929 3130
 							$uid = $this->user;
2930 3131
 					}
2931 3132
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2932
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3133
+					if (!$uid)
3134
+					{
3135
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3136
+					}
2933 3137
 
2934 3138
 					// try to find an email address
2935 3139
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2997,7 +3201,10 @@  discard block
 block discarded – undo
2997 3201
 								}
2998 3202
 								$status = 'U'; // keep the group
2999 3203
 							}
3000
-							else continue; // can't find this group
3204
+							else {
3205
+								continue;
3206
+							}
3207
+							// can't find this group
3001 3208
 						}
3002 3209
 						elseif (empty($searcharray))
3003 3210
 						{
@@ -3056,7 +3263,9 @@  discard block
 block discarded – undo
3056 3263
 
3057 3264
 								try {
3058 3265
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3059
-										$component->getAttribute('ORGANIZER');
3266
+									{
3267
+																			$component->getAttribute('ORGANIZER');
3268
+									}
3060 3269
 								}
3061 3270
 								catch(Horde_Icalendar_Exception $e)
3062 3271
 								{
@@ -3093,7 +3302,10 @@  discard block
 block discarded – undo
3093 3302
 					}
3094 3303
 					break;
3095 3304
 				case 'CREATED':		// will be written direct to the event
3096
-					if ($event['modified']) break;
3305
+					if ($event['modified'])
3306
+					{
3307
+						break;
3308
+					}
3097 3309
 					// fall through
3098 3310
 				case 'LAST-MODIFIED':	// will be written direct to the event
3099 3311
 					$event['modified'] = $attributes['value'];
@@ -3114,7 +3326,11 @@  discard block
 block discarded – undo
3114 3326
 					break;
3115 3327
 
3116 3328
 				case 'ATTACH':
3117
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3329
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3330
+					{
3331
+						break;
3332
+					}
3333
+					// handeled by managed attachment code
3118 3334
 					// fall throught to store external attachment url
3119 3335
 				default:	// X- attribute or other by EGroupware unsupported property
3120 3336
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3245,7 +3461,10 @@  discard block
 block discarded – undo
3245 3461
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3246 3462
 		}
3247 3463
 
3248
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3464
+		if ($this->calendarOwner)
3465
+		{
3466
+			$event['owner'] = $this->calendarOwner;
3467
+		}
3249 3468
 
3250 3469
 		// parsing ATTACH attributes for managed attachments
3251 3470
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3271,7 +3490,10 @@  discard block
 block discarded – undo
3271 3490
 				$filter = $relax ? 'relax' : 'check';
3272 3491
 				$event = array_shift($events);
3273 3492
 				$eventId = -1;
3274
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3493
+				if ($this->so->isWholeDay($event))
3494
+				{
3495
+					$event['whole_day'] = true;
3496
+				}
3275 3497
 				if ($contentID)
3276 3498
 				{
3277 3499
 					$parts = preg_split('/:/', $contentID);
@@ -3324,8 +3546,16 @@  discard block
 block discarded – undo
3324 3546
 	 */
3325 3547
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3326 3548
 	{
3327
-		if (!$start) $start = time();	// default now
3328
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3549
+		if (!$start)
3550
+		{
3551
+			$start = time();
3552
+		}
3553
+		// default now
3554
+		if (!$end)
3555
+		{
3556
+			$end = time() + 100*DAY_s;
3557
+		}
3558
+		// default next 100 days
3329 3559
 
3330 3560
 		$vcal = new Horde_Icalendar;
3331 3561
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3347,10 +3577,13 @@  discard block
 block discarded – undo
3347 3577
 				$attributes[$attr] = date('Ymd\THis', $value);
3348 3578
 			}
3349 3579
 		}
3350
-		if (is_null($extra)) $extra = array(
3580
+		if (is_null($extra))
3581
+		{
3582
+			$extra = array(
3351 3583
 			'URL' => $this->freebusy_url($user),
3352 3584
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3353 3585
 		);
3586
+		}
3354 3587
 		foreach($attributes+$extra as $attr => $value)
3355 3588
 		{
3356 3589
 			$vfreebusy->setAttribute($attr, $value);
@@ -3366,12 +3599,21 @@  discard block
 block discarded – undo
3366 3599
 		{
3367 3600
 			foreach ($fbdata as $event)
3368 3601
 			{
3369
-				if ($event['non_blocking']) continue;
3370
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3602
+				if ($event['non_blocking'])
3603
+				{
3604
+					continue;
3605
+				}
3606
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3607
+				{
3608
+					continue;
3609
+				}
3371 3610
 				$status = $event['participants'][$user];
3372 3611
 				$quantity = $role = null;
3373 3612
 				calendar_so::split_status($status, $quantity, $role);
3374
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
3613
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
3614
+				{
3615
+					continue;
3616
+				}
3375 3617
 
3376 3618
 				$fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3377 3619
 
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   +58 added lines, -58 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
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 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(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 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,16 +170,16 @@  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 184
 			$start = new Api\DateTime($record->start);
185 185
 			try
@@ -194,37 +194,37 @@  discard block
 block discarded – undo
194 194
 			catch (Exception $e)
195 195
 			{
196 196
 				// Try old way from export using just recur_type / interval
197
-				list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2);
197
+				list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2);
198 198
 				$record->recur_interval = trim($record->recur_interval);
199
-				$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence']));
199
+				$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence']));
200 200
 			}
201 201
 			unset($record->recurrence);
202 202
 		}
203 203
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
204 204
 
205
-		if ( $options['conditions'] ) {
206
-			foreach ( $options['conditions'] as $condition ) {
205
+		if ($options['conditions']) {
206
+			foreach ($options['conditions'] as $condition) {
207 207
 				$records = array();
208
-				switch ( $condition['type'] ) {
208
+				switch ($condition['type']) {
209 209
 					// exists
210 210
 					case 'exists' :
211 211
 						// Check for that record
212 212
 						$result = $this->exists($record, $condition, $records);
213 213
 
214
-						if ( is_array( $records ) && count( $records ) >= 1) {
214
+						if (is_array($records) && count($records) >= 1) {
215 215
 							// apply action to all records matching this exists condition
216 216
 							$action = $condition['true'];
217
-							foreach ( (array)$records as $event ) {
217
+							foreach ((array)$records as $event) {
218 218
 								$record->id = $event['id'];
219
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
220
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
221
-									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
219
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
220
+									if (!is_array($record->category)) $record->category = explode(',', $record->category);
221
+									$record->category = implode(',', array_unique(array_merge($record->category, $event['category'])));
222 222
 								}
223
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
223
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
224 224
 							}
225 225
 						} else {
226 226
 							$action = $condition['false'];
227
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
227
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
228 228
 						}
229 229
 						break;
230 230
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			}
238 238
 		} else {
239 239
 			// unconditional insert
240
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
240
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
241 241
 		}
242 242
 
243 243
 		return $success;
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
256 256
 	{
257
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
257
+		if ($record->__get($condition['string']) && $condition['string'] == 'id') {
258 258
 			$event = $this->bo->read($record->__get($condition['string']));
259 259
 			$records = array($event);
260 260
 		}
261 261
 
262
-		if ( is_array( $records ) && count( $records ) >= 1) {
262
+		if (is_array($records) && count($records) >= 1) {
263 263
 			return true;
264 264
 		}
265 265
 		return false;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @param array $_data record data for the action
273 273
 	 * @return bool success or not
274 274
 	 */
275
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
275
+	protected function action($_action, importexport_iface_egw_record &$record, $record_num = 0)
276 276
 	{
277 277
 		$_data = $record->get_record_array();
278 278
 		switch ($_action) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 				$old = $this->bo->read($_data['id']);
284 284
 
285 285
 				// Don't change a user account into a record
286
-				if(!$this->definition->plugin_options['change_owner']) {
286
+				if (!$this->definition->plugin_options['change_owner']) {
287 287
 					// Don't change owner of an existing record
288 288
 					unset($_data['owner']);
289 289
 				}
@@ -291,30 +291,30 @@  discard block
 block discarded – undo
291 291
 				// Merge to deal with fields not in import record
292 292
 				$_data = array_merge($old, $_data);
293 293
 				$changed = $this->tracking->changed_fields($_data, $old);
294
-				if(count($changed) == 0) {
294
+				if (count($changed) == 0) {
295 295
 					return true;
296 296
 				}
297 297
 				// Fall through
298 298
 			case 'insert' :
299
-				if($_action == 'insert') {
299
+				if ($_action == 'insert') {
300 300
 					// Backend doesn't like inserting with ID specified, can overwrite existing
301 301
 					unset($_data['id']);
302 302
 				}
303 303
 				// Make sure participants are set
304
-				if(!$_data['participants']) {
304
+				if (!$_data['participants']) {
305 305
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
306 306
 					$_data['participants'] = array(
307 307
 						$user => 'U'
308 308
 					);
309 309
 				}
310
-				if ( $this->dry_run ) {
310
+				if ($this->dry_run) {
311 311
 					//print_r($_data);
312 312
 					// User is interested in conflict checks, do so for dry run
313 313
 					// Otherwise, conflicts are just ignored and imported anyway
314
-					if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
314
+					if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
315 315
 					{
316 316
 						$conflicts = $this->bo->conflicts($_data);
317
-						if($conflicts)
317
+						if ($conflicts)
318 318
 						{
319 319
 							$this->conflict_warning($record_num, $conflicts);
320 320
 							$this->results['skipped']++;
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 					return true;
326 326
 				} else {
327 327
 					$messages = null;
328
-					$result = $this->bo->update( $_data, 
328
+					$result = $this->bo->update($_data, 
329 329
 						!$this->definition->plugin_options['skip_conflicts'],
330 330
 						true, $this->is_admin, true, $messages,
331 331
 						$this->definition->plugin_options['no_notification']
332 332
 					);
333
-					if(!$result)
333
+					if (!$result)
334 334
 					{
335
-						$this->errors[$record_num] = lang('Unable to save') . "\n" .
336
-							implode("\n",$messages);
335
+						$this->errors[$record_num] = lang('Unable to save')."\n".
336
+							implode("\n", $messages);
337 337
 					}
338 338
 					else if (is_array($result))
339 339
 					{
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	protected function conflict_warning($record_num, &$conflicts)
365 365
 	{
366
-		$this->warnings[$record_num] = lang('Conflicts') . ':';
367
-		foreach($conflicts as $conflict)
366
+		$this->warnings[$record_num] = lang('Conflicts').':';
367
+		foreach ($conflicts as $conflict)
368 368
 		{
369
-			$this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title'];
369
+			$this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title'];
370 370
 		}
371 371
 	}
372 372
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	protected function row_preview(importexport_iface_egw_record &$row_entry)
406 406
 	{
407
-		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
407
+		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
408 408
 	}
409 409
 
410 410
 }
411 411
\ 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.