Completed
Branch master (c3ca5f)
by Seth
04:51
created
phpicalendar/print.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 	'getdate'			=> $getdate,
65 65
 	'calendar_name'		=> $cal_displayname,
66 66
 	'current_view'		=> $current_view,
67
-    'printview'         => $printview,
67
+	'printview'         => $printview,
68 68
 	'display_date'		=> $display_date,
69 69
 	'sidebar_date'		=> @$sidebar_date,
70 70
 	'rss_powered'	 	=> $rss_powered,
Please login to merge, or discard this patch.
phpicalendar/functions/init/sanitize.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
  * @return mixed
15 15
  */
16 16
 function recursiveSanitize($value) {
17
-    if (is_array($value)) {
18
-        $valmod = array();
19
-        foreach ($value as $key => $subval) {
20
-            if (is_array($subval)) {
21
-                $subval = recursiveSanitize($subval);
22
-            } else {
23
-                $subval = strip_tags($subval);
24
-            }
25
-            $valmod[$key] = $subval;
26
-        }
27
-        $value = $valmod;
28
-    } else {
29
-        $value = strip_tags($value);
30
-    }
17
+	if (is_array($value)) {
18
+		$valmod = array();
19
+		foreach ($value as $key => $subval) {
20
+			if (is_array($subval)) {
21
+				$subval = recursiveSanitize($subval);
22
+			} else {
23
+				$subval = strip_tags($subval);
24
+			}
25
+			$valmod[$key] = $subval;
26
+		}
27
+		$value = $valmod;
28
+	} else {
29
+		$value = strip_tags($value);
30
+	}
31 31
     
32
-    return $value;
32
+	return $value;
33 33
 }
34 34
 
35 35
 
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
  * Truncate a string to a specific number of words
38 38
  */
39 39
 function chopToWordCount($string, $count) {
40
-    $wc = str_word_count($string);
41
-    if ($wc > $count) {
40
+	$wc = str_word_count($string);
41
+	if ($wc > $count) {
42 42
 	$words = str_word_count($string, 2);
43 43
 	$last_word = array_slice($words, $count, 1, true);
44 44
 	$pos = key($last_word);
45 45
 	$string = substr($string, 0, $pos) . '...';
46
-    }
47
-    return $string;
46
+	}
47
+	return $string;
48 48
 }
49 49
 
50 50
 /**
51 51
  * Strip "dangerous" HTML to make it safe to print to web browsers
52 52
  */
53 53
 function sanitizeForWeb($string) {
54
-    $string = preg_replace('/<br\s*\/?>/', "\n", $string);
54
+	$string = preg_replace('/<br\s*\/?>/', "\n", $string);
55 55
 
56
-    $string = str_replace('&#36;', '$', $string);
57
-    $string = str_replace('&', '&amp;', $string);
58
-    $string = str_replace('<', '&lt;', $string);
59
-    $string = str_replace('>', '&gt;', $string);
60
-    $string = str_replace('\'', '&#39;', $string);
61
-    $string = str_replace('"', '&#34;', $string);
62
-    $string = str_replace('$', '&#36;', $string);
56
+	$string = str_replace('&#36;', '$', $string);
57
+	$string = str_replace('&', '&amp;', $string);
58
+	$string = str_replace('<', '&lt;', $string);
59
+	$string = str_replace('>', '&gt;', $string);
60
+	$string = str_replace('\'', '&#39;', $string);
61
+	$string = str_replace('"', '&#34;', $string);
62
+	$string = str_replace('$', '&#36;', $string);
63 63
 
64
-    $string = str_replace("\n", '<br />', $string);
65
-    $string = str_replace("\t", ' &nbsp; &nbsp; ', $string);
64
+	$string = str_replace("\n", '<br />', $string);
65
+	$string = str_replace("\t", ' &nbsp; &nbsp; ', $string);
66 66
 
67
-    return $string;
67
+	return $string;
68 68
 }
69 69
 
70 70
 
Please login to merge, or discard this patch.
phpicalendar/functions/ical_parser.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -458,9 +458,9 @@
 block discarded – undo
458 458
 
459 459
 							$attendee[] = array ('name'     => stripslashes($name),
460 460
 												 'email'    => stripslashes($email),
461
-									        	 'RSVP'     => stripslashes($rsvp),
462
-									        	 'PARTSTAT' => stripslashes($partstat),
463
-								         		 'ROLE'     => stripslashes($role)
461
+												 'RSVP'     => stripslashes($rsvp),
462
+												 'PARTSTAT' => stripslashes($partstat),
463
+										 		 'ROLE'     => stripslashes($role)
464 464
 												);
465 465
 							break;
466 466
 						case 'ORGANIZER':
Please login to merge, or discard this patch.
phpicalendar/functions/admin_functions.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -222,15 +222,15 @@
 block discarded – undo
222 222
 // arg0: string filename
223 223
 // returns boolean is the uploaded a file
224 224
 function is_uploaded_file_v4 ($filename) {
225
-    if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
226
-        $tmp_file = dirname(tempnam('', ''));
227
-    }
228
-    $tmp_file .= '/' . basename($filename);
229
-    // For Windows compat
230
-    $filename = str_replace ("\\", "/", $filename);
231
-    $tmp_file = str_replace ("\\", "/", $tmp_file);
232
-    // User might have trailing slash in php.ini... 
233
-    return (ereg_replace('/+', '/', $tmp_file) == $filename);
225
+	if (!$tmp_file = get_cfg_var('upload_tmp_dir')) {
226
+		$tmp_file = dirname(tempnam('', ''));
227
+	}
228
+	$tmp_file .= '/' . basename($filename);
229
+	// For Windows compat
230
+	$filename = str_replace ("\\", "/", $filename);
231
+	$tmp_file = str_replace ("\\", "/", $tmp_file);
232
+	// User might have trailing slash in php.ini... 
233
+	return (ereg_replace('/+', '/', $tmp_file) == $filename);
234 234
 }
235 235
 
236 236
 // return the appropriate error message if the file upload had an error
Please login to merge, or discard this patch.
phpicalendar/search.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 						foreach ($time_tmp as $uid_tmp => $event_tmp) {
50 50
 							if (is_array($event_tmp)) {
51 51
 								if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) {
52
-                                                                        #print_r($format_search_arr);
53
-                                                                        #print_r($event_tmp);
54
-                                                                        #echo "<br>this event:".$event_tmp['event_text']."<br>";
52
+																		#print_r($format_search_arr);
53
+																		#print_r($event_tmp);
54
+																		#echo "<br>this event:".$event_tmp['event_text']."<br>";
55 55
 									$results1 = false;
56 56
 									$results2 = false;
57 57
 									if (isset($event_tmp['event_text'])) {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if ($is_false) return false;
217 217
 	}
218 218
 	// if we haven't returned false, then we return true
219
-       # echo "return true<br>";
219
+	   # echo "return true<br>";
220 220
 	return true;
221 221
 }
222 222
 
Please login to merge, or discard this patch.
phpicalendar/day.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@
 block discarded – undo
57 57
 	'header'			=> BASE.'templates/'.$phpiCal_config->template.'/header.tpl',
58 58
 	'event_js'			=> BASE.'functions/event.js',
59 59
 	'footer'			=> BASE.'templates/'.$phpiCal_config->template.'/footer.tpl',
60
-    'sidebar'           => BASE.'templates/'.$phpiCal_config->template.'/sidebar.tpl',
61
-    'search_box'        => BASE.'templates/'.$phpiCal_config->template.'/search_box.tpl'
60
+	'sidebar'           => BASE.'templates/'.$phpiCal_config->template.'/sidebar.tpl',
61
+	'search_box'        => BASE.'templates/'.$phpiCal_config->template.'/search_box.tpl'
62 62
 	));
63 63
 
64 64
 $page->replace_tags(array(
Please login to merge, or discard this patch.
phpicalendar/config.inc.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 
26 26
 The salt parameter is used to obfuscate things like webcal links that may have usernames and passwords.  This should be changed.
27 27
 */
28
-     'calendar_path'        => '/var/www-data/canvas/ics-sync',
28
+	 'calendar_path'        => '/var/www-data/canvas/ics-sync',
29 29
 #     'default_path'         => '', 	
30 30
 #     'save_parsed_cals'     => 'yes', 
31 31
 #     'cookie_uri'           => '', 
32 32
 #     'download_uri'         => '', 	
33
-     'allow_webcals'          => 'yes',
33
+	 'allow_webcals'          => 'yes',
34 34
 #     'recursive_path'          => 'yes',
35
-     'salt'                => 'AjeoRZ9rC5pDzV6xk9nD',
35
+	 'salt'                => 'AjeoRZ9rC5pDzV6xk9nD',
36 36
 
37 37
 /*     ** Timezones **
38 38
 If timezone is not set, all events show in the local time of the source calendar.  This isn't a problem if all your calendars are in the same timezone.  If you set a timezone for the server, events in other timezones are shown when they occur at the server's time.
39 39
 */
40
-     'timezone'             => 'US/Eastern',
40
+	 'timezone'             => 'US/Eastern',
41 41
 #     'second_offset'        => $secs,
42 42
 
43 43
 /*     ** Appearance **      
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 #     'language'             => 'English',
52 52
 #     'default_cal'          => 'US Holidays',	   // Exact filename of calendar without .ics.
53 53
 #     'template'             => 'green',           // Template support: change this to have a different "skin" for your installation.     
54
-    'default_view'         => 'year',           // Default view for calendars'     => 'day', 'week', 'month', 'year'
54
+	'default_view'         => 'year',           // Default view for calendars'     => 'day', 'week', 'month', 'year'
55 55
 #      'printview_default'    => 'yes',	           // Set print view as the default view. Uses'default_view (listed above).
56 56
 #     'gridLength'           => 10,                // Grid size in day and week views. Allowed values are 1,2,3,4,10,12,15,20,30,60. Default is 15
57 57
 #     'minical_view'         => 'current',	       // Where do the mini-calendars go when clicked?'     => 'day', 'week', 'month', 'current'
Please login to merge, or discard this patch.
phpicalendar/preferences.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@
 block discarded – undo
58 58
 			include(BASE.'languages/'.strtolower($_POST['cookie_language']).'.inc.php');
59 59
 	}
60 60
 	$_COOKIE[$cookie_name] = $the_cookie;
61
-    $cpath = $cookie_cpath;
62
-    $cal = $cookie_calendar;
61
+	$cpath = $cookie_cpath;
62
+	$cal = $cookie_calendar;
63 63
 }
64 64
 
65 65
 if (isset($_COOKIE[$cookie_name])) {
Please login to merge, or discard this patch.
phpicalendar/lib/HTTP/CalDAV/Server.php 1 patch
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -44,298 +44,298 @@
 block discarded – undo
44 44
  */
45 45
 class HTTP_CalDAV_Server extends HTTP_WebDAV_Server
46 46
 {
47
-    /**
48
-     * Make a property in the CalDAV namespace
49
-     *
50
-     * @param string property name
51
-     * @param string property value
52
-     * @return array string property namespace
53
-     *               string property name
54
-     *               string property value
55
-     */
56
-    function calDavProp($name, $value=null, $status=null) {
57
-        return $this->mkprop('urn:ietf:params:xml:ns:caldav', $name, $value,
58
-            $status);
59
-    }
60
-
61
-    /**
62
-     * REPORT request helper - prepares data-structures from REPORT requests
63
-     *
64
-     * @param options
65
-     * @return void
66
-     * @access public
67
-     */
68
-    function report_request_helper(&$options)
69
-    {
70
-        $options = array();
71
-        $options['path'] = $this->path;
72
-
73
-        /* The request MAY include a Depth header.  If no Depth header is
47
+	/**
48
+	 * Make a property in the CalDAV namespace
49
+	 *
50
+	 * @param string property name
51
+	 * @param string property value
52
+	 * @return array string property namespace
53
+	 *               string property name
54
+	 *               string property value
55
+	 */
56
+	function calDavProp($name, $value=null, $status=null) {
57
+		return $this->mkprop('urn:ietf:params:xml:ns:caldav', $name, $value,
58
+			$status);
59
+	}
60
+
61
+	/**
62
+	 * REPORT request helper - prepares data-structures from REPORT requests
63
+	 *
64
+	 * @param options
65
+	 * @return void
66
+	 * @access public
67
+	 */
68
+	function report_request_helper(&$options)
69
+	{
70
+		$options = array();
71
+		$options['path'] = $this->path;
72
+
73
+		/* The request MAY include a Depth header.  If no Depth header is
74 74
            included, Depth:0 is assumed. */
75
-        $options['depth'] = 0;
76
-        if (isset($_SERVER['HTTP_DEPTH'])) {
77
-            $options['depth'] = $_SERVER['HTTP_DEPTH'];
78
-        }
79
-
80
-        $parser = new ReportParser('php://input');
81
-        if (!$parser->success) {
82
-            $this->http_status('400 Bad Request');
83
-            return;
84
-        }
85
-
86
-        $options['props'] = $parser->props;
87
-        $options['filters'] = $parser->filters;
88
-
89
-        return true;
90
-    }
91
-
92
-    /**
93
-     * REPORT method wrapper
94
-     *
95
-     * @param void
96
-     * @return void
97
-     * @access public
98
-     */
99
-    function report_wrapper()
100
-    {
101
-        /* Prepare data-structure from REPORT request */
102
-        if (!$this->report_request_helper($options)) {
103
-            return;
104
-        }
105
-
106
-        /* Call user handler */
107
-        if (method_exists($this, 'report')) {
108
-            if (!$this->report($options, $files)) {
109
-                return;
110
-            }
111
-        } else {
112
-
113
-            /* Empulate REPORT using PROPFIND */
114
-            if (!$this->propfind($options, $files)) {
115
-                return;
116
-            }
117
-        }
118
-
119
-        /* Format REPORT response */
120
-
121
-        // TODO Make ns_hash a class variable so we can prettify C:
122
-        // Or make getNsName so we can return C:
123
-        $this->propfind_response_helper($options, $files);
124
-    }
125
-
126
-    function getProp($reqprop, $file, $options)
127
-    {
128
-        // check if property exists in response
129
-        foreach ($file['props'] as $prop) {
130
-            if ($reqprop['name'] == $prop['name'] &&
131
-                    $reqprop['ns'] == $prop['ns']) {
132
-                return $prop;
133
-            }
134
-        }
135
-
136
-        if ($reqprop['name'] == 'lockdiscovery' &&
137
-                $reqprop['ns'] == 'DAV:' &&
138
-                method_exists($this, 'getLocks')) {
139
-            return $this->mkprop('DAV:', 'lockdiscovery',
140
-                $this->getLocks($file['path']));
141
-        }
142
-
143
-        if ($reqprop['name'] == 'calendar-data' &&
144
-                $reqprop['ns'] == 'urn:ietf:params:xml:ns:caldav' &&
145
-                method_exists($this, 'get')) {
146
-            $filters = $options['filters'];
147
-
148
-            $options = array();
149
-            $options['path'] = $file['path'];
150
-
151
-            $status = $this->get($options);
152
-            if (empty($status)) {
153
-                $status = '404 Not Found';
154
-            }
155
-
156
-            if ($status !== true) {
157
-                return $this->calDavProp('calendar-data', null, $status);
158
-            }
159
-
160
-            if ($options['mimetype'] != 'text/calendar') {
161
-                return $this->calDavProp('calendar-data', null,
162
-                    '404 Not Found');
163
-            }
164
-
165
-            if ($options['stream']) {
166
-                $handle = $options['stream'];
167
-            } else if ($options['data']) {
168
-                // What about data?
169
-            } else {
170
-                return $this->calDavProp('calendar-data', null,
171
-                    '404 Not Found');
172
-            }
173
-
174
-            $parser = new ICalendarParser($handle, null, $reqprop['value'],
175
-                $filters);
176
-            if (!$parser->success) {
177
-                return $this->calDavProp('calendar-data', null,
178
-                    '404 Not Found');
179
-            }
180
-
181
-            return HTTP_CalDAV_Server::calDavProp('calendar-data',
182
-                $parser->comps[count($parser->comps) - 1]);
183
-        }
184
-
185
-        // incase the requested property had a value, like calendar-data
186
-        unset($reqprop['value']);
187
-        $reqprop['status'] = '404 Not Found';
188
-        return $reqprop;
189
-    }
190
-
191
-    function _multistatus($responses)
192
-    {
193
-        // now we generate the response header...
194
-        $this->http_status('207 Multi-Status');
195
-        header('Content-Type: text/xml; charset="utf-8"');
196
-
197
-        // ...and payload
198
-        echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
199
-        echo "<D:multistatus xmlns:D=\"DAV:\">\n";
200
-
201
-        foreach ($responses as $response) {
202
-
203
-            // ignore empty or incomplete entries
204
-            if (!is_array($response) || empty($response)) {
205
-                continue;
206
-            }
207
-
208
-            $ns_defs = array();
209
-            foreach ($response['ns_hash'] as $name => $prefix) {
210
-                $ns_defs[] = "xmlns:$prefix=\"$name\"";
211
-            }
212
-            echo ' <D:response ' . implode(' ', $ns_defs) . ">\n";
213
-            echo "  <D:href>$response[href]</D:href>\n";
214
-
215
-            // report all found properties and their values (if any)
216
-            // nothing to do if no properties were returend for a file
217
-            if (isset($response['propstat']) &&
218
-                    is_array($response['propstat'])) {
219
-
220
-                foreach ($response['propstat'] as $status => $props) {
221
-                    echo "  <D:propstat>\n";
222
-                    echo "   <D:prop>\n";
223
-
224
-                    foreach ($props as $prop) {
225
-                        if (!is_array($prop) || !isset($prop['name'])) {
226
-                            continue;
227
-                        }
228
-
229
-                        // empty properties (cannot use empty for check as '0'
230
-                        // is a legal value here)
231
-                        if (!isset($prop['value']) || empty($prop['value']) &&
232
-                                $prop['value'] !== 0) {
233
-                            if ($prop['ns'] == 'DAV:') {
234
-                                echo "    <D:$prop[name]/>\n";
235
-                                continue;
236
-                            }
237
-
238
-                            if (!empty($prop['ns'])) {
239
-                                echo '    <' .
240
-                                    $response['ns_hash'][$prop['ns']] .
241
-                                    ":$prop[name]/>\n";
242
-                                continue;
243
-                            }
244
-
245
-                            echo "    <$prop[name] xmlns=\"\"/>";
246
-                            continue;
247
-                        }
248
-
249
-                        // some WebDAV properties need special treatment
250
-                        if ($prop['ns'] == 'DAV:') {
251
-
252
-                            switch ($prop['name']) {
253
-                            case 'creationdate':
254
-                                echo "    <D:creationdate ns0:dt=\"dateTime.tz\">\n";
255
-                                echo '     ' . gmdate('Y-m-d\TH:i:s\Z', $prop['value']) . "\n";
256
-                                echo "    </D:creationdate>\n";
257
-                                break;
258
-
259
-                            case 'getlastmodified':
260
-                                echo "    <D:getlastmodified ns0:dt=\"dateTime.rfc1123\">\n";
261
-                                echo '     ' . gmdate('D, d M Y H:i:s', $prop['value']) . " GMT\n";
262
-                                echo "    </D:getlastmodified>\n";
263
-                                break;
264
-
265
-                            case 'resourcetype':
266
-                                echo "    <D:resourcetype>\n";
267
-                                echo "     <D:$prop[value]/>\n";
268
-                                echo "    </D:resourcetype>\n";
269
-                                break;
270
-
271
-                            case 'supportedlock':
272
-
273
-                                if (is_array($prop[value])) {
274
-                                    $prop[value] = $this->_lockentries($prop[value]);
275
-                                }
276
-                                echo "    <D:supportedlock>\n";
277
-                                echo "     $prop[value]\n";
278
-                                echo "    </D:supportedlock>\n";
279
-                                break;
280
-
281
-                            case 'lockdiscovery':
282
-
283
-                                if (is_array($prop[value])) {
284
-                                    $prop[value] = $this->_activelocks($prop[value]);
285
-                                }
286
-                                echo "    <D:lockdiscovery>\n";
287
-                                echo "     $prop[value]\n";
288
-                                echo "    </D:lockdiscovery>\n";
289
-                                break;
290
-
291
-                            default:
292
-                                echo "    <D:$prop[name]>\n";
293
-                                echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
294
-                                echo "    </D:$prop[name]>\n";
295
-                            }
296
-
297
-                            continue;
298
-                        }
299
-
300
-                        if ($prop['name'] == 'calendar-data' &&
301
-                                is_object($prop['value'])) {
302
-                            $prop['value'] = $prop['value']->serialize();
303
-                        }
304
-
305
-                        if (!empty($prop['ns'])) {
306
-                            echo '    <' . $response['ns_hash'][$prop['ns']] . ":$prop[name]>\n";
307
-                            echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
308
-                            echo '    </' . $response['ns_hash'][$prop['ns']] . ":$prop[name]>\n";
309
-
310
-                            continue;
311
-                        }
312
-
313
-                        echo "    <$prop[name] xmlns=\"\">\n";
314
-                        echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
315
-                        echo "    </$prop[name]>\n";
316
-                    }
317
-
318
-                    echo "   </D:prop>\n";
319
-                    echo "   <D:status>HTTP/1.1 $status</D:status>\n";
320
-                    echo "  </D:propstat>\n";
321
-                }
322
-            }
323
-
324
-            if (isset($response['status'])) {
325
-                echo "  <D:status>HTTP/1.1 $status</D:status>\n";
326
-            }
327
-
328
-            if (isset($response['responsedescription'])) {
329
-                echo "  <D:responsedescription>\n";
330
-                echo '   ' . $this->_prop_encode(htmlspecialchars($response['responsedescription'])) . "\n";
331
-                echo "  </D:responsedescription>\n";
332
-            }
333
-
334
-            echo " </D:response>\n";
335
-        }
336
-
337
-        echo "</D:multistatus>\n";
338
-    }
75
+		$options['depth'] = 0;
76
+		if (isset($_SERVER['HTTP_DEPTH'])) {
77
+			$options['depth'] = $_SERVER['HTTP_DEPTH'];
78
+		}
79
+
80
+		$parser = new ReportParser('php://input');
81
+		if (!$parser->success) {
82
+			$this->http_status('400 Bad Request');
83
+			return;
84
+		}
85
+
86
+		$options['props'] = $parser->props;
87
+		$options['filters'] = $parser->filters;
88
+
89
+		return true;
90
+	}
91
+
92
+	/**
93
+	 * REPORT method wrapper
94
+	 *
95
+	 * @param void
96
+	 * @return void
97
+	 * @access public
98
+	 */
99
+	function report_wrapper()
100
+	{
101
+		/* Prepare data-structure from REPORT request */
102
+		if (!$this->report_request_helper($options)) {
103
+			return;
104
+		}
105
+
106
+		/* Call user handler */
107
+		if (method_exists($this, 'report')) {
108
+			if (!$this->report($options, $files)) {
109
+				return;
110
+			}
111
+		} else {
112
+
113
+			/* Empulate REPORT using PROPFIND */
114
+			if (!$this->propfind($options, $files)) {
115
+				return;
116
+			}
117
+		}
118
+
119
+		/* Format REPORT response */
120
+
121
+		// TODO Make ns_hash a class variable so we can prettify C:
122
+		// Or make getNsName so we can return C:
123
+		$this->propfind_response_helper($options, $files);
124
+	}
125
+
126
+	function getProp($reqprop, $file, $options)
127
+	{
128
+		// check if property exists in response
129
+		foreach ($file['props'] as $prop) {
130
+			if ($reqprop['name'] == $prop['name'] &&
131
+					$reqprop['ns'] == $prop['ns']) {
132
+				return $prop;
133
+			}
134
+		}
135
+
136
+		if ($reqprop['name'] == 'lockdiscovery' &&
137
+				$reqprop['ns'] == 'DAV:' &&
138
+				method_exists($this, 'getLocks')) {
139
+			return $this->mkprop('DAV:', 'lockdiscovery',
140
+				$this->getLocks($file['path']));
141
+		}
142
+
143
+		if ($reqprop['name'] == 'calendar-data' &&
144
+				$reqprop['ns'] == 'urn:ietf:params:xml:ns:caldav' &&
145
+				method_exists($this, 'get')) {
146
+			$filters = $options['filters'];
147
+
148
+			$options = array();
149
+			$options['path'] = $file['path'];
150
+
151
+			$status = $this->get($options);
152
+			if (empty($status)) {
153
+				$status = '404 Not Found';
154
+			}
155
+
156
+			if ($status !== true) {
157
+				return $this->calDavProp('calendar-data', null, $status);
158
+			}
159
+
160
+			if ($options['mimetype'] != 'text/calendar') {
161
+				return $this->calDavProp('calendar-data', null,
162
+					'404 Not Found');
163
+			}
164
+
165
+			if ($options['stream']) {
166
+				$handle = $options['stream'];
167
+			} else if ($options['data']) {
168
+				// What about data?
169
+			} else {
170
+				return $this->calDavProp('calendar-data', null,
171
+					'404 Not Found');
172
+			}
173
+
174
+			$parser = new ICalendarParser($handle, null, $reqprop['value'],
175
+				$filters);
176
+			if (!$parser->success) {
177
+				return $this->calDavProp('calendar-data', null,
178
+					'404 Not Found');
179
+			}
180
+
181
+			return HTTP_CalDAV_Server::calDavProp('calendar-data',
182
+				$parser->comps[count($parser->comps) - 1]);
183
+		}
184
+
185
+		// incase the requested property had a value, like calendar-data
186
+		unset($reqprop['value']);
187
+		$reqprop['status'] = '404 Not Found';
188
+		return $reqprop;
189
+	}
190
+
191
+	function _multistatus($responses)
192
+	{
193
+		// now we generate the response header...
194
+		$this->http_status('207 Multi-Status');
195
+		header('Content-Type: text/xml; charset="utf-8"');
196
+
197
+		// ...and payload
198
+		echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
199
+		echo "<D:multistatus xmlns:D=\"DAV:\">\n";
200
+
201
+		foreach ($responses as $response) {
202
+
203
+			// ignore empty or incomplete entries
204
+			if (!is_array($response) || empty($response)) {
205
+				continue;
206
+			}
207
+
208
+			$ns_defs = array();
209
+			foreach ($response['ns_hash'] as $name => $prefix) {
210
+				$ns_defs[] = "xmlns:$prefix=\"$name\"";
211
+			}
212
+			echo ' <D:response ' . implode(' ', $ns_defs) . ">\n";
213
+			echo "  <D:href>$response[href]</D:href>\n";
214
+
215
+			// report all found properties and their values (if any)
216
+			// nothing to do if no properties were returend for a file
217
+			if (isset($response['propstat']) &&
218
+					is_array($response['propstat'])) {
219
+
220
+				foreach ($response['propstat'] as $status => $props) {
221
+					echo "  <D:propstat>\n";
222
+					echo "   <D:prop>\n";
223
+
224
+					foreach ($props as $prop) {
225
+						if (!is_array($prop) || !isset($prop['name'])) {
226
+							continue;
227
+						}
228
+
229
+						// empty properties (cannot use empty for check as '0'
230
+						// is a legal value here)
231
+						if (!isset($prop['value']) || empty($prop['value']) &&
232
+								$prop['value'] !== 0) {
233
+							if ($prop['ns'] == 'DAV:') {
234
+								echo "    <D:$prop[name]/>\n";
235
+								continue;
236
+							}
237
+
238
+							if (!empty($prop['ns'])) {
239
+								echo '    <' .
240
+									$response['ns_hash'][$prop['ns']] .
241
+									":$prop[name]/>\n";
242
+								continue;
243
+							}
244
+
245
+							echo "    <$prop[name] xmlns=\"\"/>";
246
+							continue;
247
+						}
248
+
249
+						// some WebDAV properties need special treatment
250
+						if ($prop['ns'] == 'DAV:') {
251
+
252
+							switch ($prop['name']) {
253
+							case 'creationdate':
254
+								echo "    <D:creationdate ns0:dt=\"dateTime.tz\">\n";
255
+								echo '     ' . gmdate('Y-m-d\TH:i:s\Z', $prop['value']) . "\n";
256
+								echo "    </D:creationdate>\n";
257
+								break;
258
+
259
+							case 'getlastmodified':
260
+								echo "    <D:getlastmodified ns0:dt=\"dateTime.rfc1123\">\n";
261
+								echo '     ' . gmdate('D, d M Y H:i:s', $prop['value']) . " GMT\n";
262
+								echo "    </D:getlastmodified>\n";
263
+								break;
264
+
265
+							case 'resourcetype':
266
+								echo "    <D:resourcetype>\n";
267
+								echo "     <D:$prop[value]/>\n";
268
+								echo "    </D:resourcetype>\n";
269
+								break;
270
+
271
+							case 'supportedlock':
272
+
273
+								if (is_array($prop[value])) {
274
+									$prop[value] = $this->_lockentries($prop[value]);
275
+								}
276
+								echo "    <D:supportedlock>\n";
277
+								echo "     $prop[value]\n";
278
+								echo "    </D:supportedlock>\n";
279
+								break;
280
+
281
+							case 'lockdiscovery':
282
+
283
+								if (is_array($prop[value])) {
284
+									$prop[value] = $this->_activelocks($prop[value]);
285
+								}
286
+								echo "    <D:lockdiscovery>\n";
287
+								echo "     $prop[value]\n";
288
+								echo "    </D:lockdiscovery>\n";
289
+								break;
290
+
291
+							default:
292
+								echo "    <D:$prop[name]>\n";
293
+								echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
294
+								echo "    </D:$prop[name]>\n";
295
+							}
296
+
297
+							continue;
298
+						}
299
+
300
+						if ($prop['name'] == 'calendar-data' &&
301
+								is_object($prop['value'])) {
302
+							$prop['value'] = $prop['value']->serialize();
303
+						}
304
+
305
+						if (!empty($prop['ns'])) {
306
+							echo '    <' . $response['ns_hash'][$prop['ns']] . ":$prop[name]>\n";
307
+							echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
308
+							echo '    </' . $response['ns_hash'][$prop['ns']] . ":$prop[name]>\n";
309
+
310
+							continue;
311
+						}
312
+
313
+						echo "    <$prop[name] xmlns=\"\">\n";
314
+						echo '     ' . $this->_prop_encode(htmlspecialchars($prop['value'])) . "\n";
315
+						echo "    </$prop[name]>\n";
316
+					}
317
+
318
+					echo "   </D:prop>\n";
319
+					echo "   <D:status>HTTP/1.1 $status</D:status>\n";
320
+					echo "  </D:propstat>\n";
321
+				}
322
+			}
323
+
324
+			if (isset($response['status'])) {
325
+				echo "  <D:status>HTTP/1.1 $status</D:status>\n";
326
+			}
327
+
328
+			if (isset($response['responsedescription'])) {
329
+				echo "  <D:responsedescription>\n";
330
+				echo '   ' . $this->_prop_encode(htmlspecialchars($response['responsedescription'])) . "\n";
331
+				echo "  </D:responsedescription>\n";
332
+			}
333
+
334
+			echo " </D:response>\n";
335
+		}
336
+
337
+		echo "</D:multistatus>\n";
338
+	}
339 339
 }
340 340
 
341 341
 /*
Please login to merge, or discard this patch.