Completed
Push — developer ( d7bfd9...1cf1f5 )
by Błażej
520:50 queued 478:32
created
include/utils/utils.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1401,7 +1401,7 @@
 block discarded – undo
1401 1401
 function isRecordExists($recordId, $cache = true)
1402 1402
 {
1403 1403
 	$recordMetaData = vtlib\Functions::getCRMRecordMetadata($recordId);
1404
-	return (isset($recordMetaData) && $recordMetaData['deleted'] == 0 ) ? true : false;
1404
+	return (isset($recordMetaData) && $recordMetaData['deleted'] == 0) ? true : false;
1405 1405
 }
1406 1406
 
1407 1407
 /** Function to set date values compatible to database (YY_MM_DD)
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -367,6 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 /**
369 369
  * Function to find the UI type of a field based on the uitype id
370
+ * @param string $reqtype
370 371
  */
371 372
 function is_uitype($uitype, $reqtype)
372 373
 {
@@ -752,6 +753,8 @@  discard block
 block discarded – undo
752 753
 
753 754
 /**
754 755
  * Function to get the approximate difference between two date time values as string
756
+ * @param integer $d1
757
+ * @param integer $d2
755 758
  */
756 759
 function dateDiffAsString($d1, $d2)
757 760
 {
Please login to merge, or discard this patch.
Braces   +35 added lines, -25 removed lines patch added patch discarded remove patch
@@ -289,13 +289,15 @@  discard block
 block discarded – undo
289 289
 		while (($i--) > 0) {
290 290
 			if ($data != ($a = $data % ($p = pow(64, $i)))) {
291 291
 				$ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
292
-				for ($i; $i > 0; $i--)
293
-					$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
292
+				for ($i; $i > 0; $i--) {
293
+									$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
294
+				}
294 295
 				break;
295 296
 			}
296 297
 		}
297
-	} else
298
-		$ret = "&#$data;";
298
+	} else {
299
+			$ret = "&#$data;";
300
+	}
299 301
 	return $ret;
300 302
 }
301 303
 
@@ -344,8 +346,9 @@  discard block
 block discarded – undo
344 346
  */
345 347
 function escape_single_quotes($value)
346 348
 {
347
-	if (isset($value))
348
-		$value = str_replace("'", "\'", $value);
349
+	if (isset($value)) {
350
+			$value = str_replace("'", "\'", $value);
351
+	}
349 352
 	return $value;
350 353
 }
351 354
 
@@ -366,10 +369,11 @@  discard block
 block discarded – undo
366 369
 			$str = str_replace('_', '\_', $str);
367 370
 			if ($flag == 0) {
368 371
 				// If value what to search is null then we should not add % which will fail
369
-				if (empty($str))
370
-					$str = '' . $str . '';
371
-				else
372
-					$str = '%' . $str . '%';
372
+				if (empty($str)) {
373
+									$str = '' . $str . '';
374
+				} else {
375
+									$str = '%' . $str . '%';
376
+				}
373 377
 			} elseif ($flag == 1) {
374 378
 				$str = '%' . $str;
375 379
 			} elseif ($flag == 2) {
@@ -402,8 +406,9 @@  discard block
 block discarded – undo
402 406
 
403 407
 		$ret_str .= " ifnull($tbl_name.$col_name,'null') = ifnull(temp.$col_name,'null')";
404 408
 
405
-		if (count($field_array) != $i)
406
-			$ret_str .= " and ";
409
+		if (count($field_array) != $i) {
410
+					$ret_str .= " and ";
411
+		}
407 412
 		$i++;
408 413
 	}
409 414
 	return $ret_str;
@@ -430,8 +435,9 @@  discard block
 block discarded – undo
430 435
 	foreach ($name as $module) {
431 436
 		$focus = CRMEntity::getInstance($module);
432 437
 		$query = $focus->buildSearchQueryForFieldTypes(11, $number);
433
-		if (empty($query))
434
-			return;
438
+		if (empty($query)) {
439
+					return;
440
+		}
435 441
 
436 442
 		$result = $adb->pquery($query, []);
437 443
 		if ($adb->num_rows($result) > 0) {
@@ -556,8 +562,9 @@  discard block
 block discarded – undo
556 562
 function relateEntities($focus, $sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds, $relatedName = false)
557 563
 {
558 564
 	\App\Log::trace("Entering relateEntities method ($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds)");
559
-	if (!is_array($destinationRecordIds))
560
-		$destinationRecordIds = [$destinationRecordIds];
565
+	if (!is_array($destinationRecordIds)) {
566
+			$destinationRecordIds = [$destinationRecordIds];
567
+	}
561 568
 
562 569
 	$data = [
563 570
 		'CRMEntity' => $focus,
@@ -600,20 +607,23 @@  discard block
 block discarded – undo
600 607
 	$delim = array('/', '.');
601 608
 	foreach ($delim as $delimiter) {
602 609
 		$x = strpos($value, $delimiter);
603
-		if ($x === false)
604
-			continue;
605
-		else {
610
+		if ($x === false) {
611
+					continue;
612
+		} else {
606 613
 			$value = str_replace($delimiter, '-', $value);
607 614
 			break;
608 615
 		}
609 616
 	}
610 617
 	list($y, $m, $d) = explode('-', $value);
611
-	if (strlen($y) == 1)
612
-		$y = '0' . $y;
613
-	if (strlen($m) == 1)
614
-		$m = '0' . $m;
615
-	if (strlen($d) == 1)
616
-		$d = '0' . $d;
618
+	if (strlen($y) == 1) {
619
+			$y = '0' . $y;
620
+	}
621
+	if (strlen($m) == 1) {
622
+			$m = '0' . $m;
623
+	}
624
+	if (strlen($d) == 1) {
625
+			$d = '0' . $d;
626
+	}
617 627
 	$value = implode('-', array($y, $m, $d));
618 628
 
619 629
 	if (strlen($y) < 4) {
Please login to merge, or discard this patch.
include/ConfigUtils.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@
 block discarded – undo
61 61
 		self::$modules[$module] = $CONFIG;
62 62
 		switch ($argsLength) {
63 63
 			case 2:
64
-				if (!isset($CONFIG[$key]))
65
-					return false;
64
+				if (!isset($CONFIG[$key])) {
65
+									return false;
66
+				}
66 67
 				return $CONFIG[$key];
67 68
 				break;
68 69
 			default:
Please login to merge, or discard this patch.
Doc Comments   +36 added lines patch added patch discarded remove patch
@@ -16,11 +16,17 @@  discard block
 block discarded – undo
16 16
 	protected static $sounds = [];
17 17
 	protected static $search = [];
18 18
 
19
+	/**
20
+	 * @param string $key
21
+	 */
19 22
 	public static function load($key, $config)
20 23
 	{
21 24
 		self::$$key = $config;
22 25
 	}
23 26
 
27
+	/**
28
+	 * @param string $key
29
+	 */
24 30
 	public static function main($key, $value = false)
25 31
 	{
26 32
 		if (isset(self::$main[$key])) {
@@ -75,11 +81,17 @@  discard block
 block discarded – undo
75 81
 		}
76 82
 	}
77 83
 
84
+	/**
85
+	 * @param string $key
86
+	 */
78 87
 	public static function api($key, $defvalue = false)
79 88
 	{
80 89
 		return self::$api[$key];
81 90
 	}
82 91
 
92
+	/**
93
+	 * @param string $key
94
+	 */
83 95
 	public static function debug($key, $defvalue = false)
84 96
 	{
85 97
 		if (empty(self::$debug)) {
@@ -89,6 +101,9 @@  discard block
 block discarded – undo
89 101
 		return isset(self::$debug[$key]) ? self::$debug[$key] : false;
90 102
 	}
91 103
 
104
+	/**
105
+	 * @param string $key
106
+	 */
92 107
 	public static function developer($key, $defvalue = false)
93 108
 	{
94 109
 		if (empty(self::$developer)) {
@@ -98,6 +113,9 @@  discard block
 block discarded – undo
98 113
 		return isset(self::$developer[$key]) ? self::$developer[$key] : false;
99 114
 	}
100 115
 
116
+	/**
117
+	 * @param string $key
118
+	 */
101 119
 	public static function security($key, $defvalue = false)
102 120
 	{
103 121
 		if (empty(self::$security)) {
@@ -107,6 +125,9 @@  discard block
 block discarded – undo
107 125
 		return isset(self::$security[$key]) ? self::$security[$key] : false;
108 126
 	}
109 127
 
128
+	/**
129
+	 * @param string $key
130
+	 */
110 131
 	public static function securityKeys($key, $defvalue = false)
111 132
 	{
112 133
 		if (empty(self::$securityKeys)) {
@@ -116,6 +137,11 @@  discard block
 block discarded – undo
116 137
 		return isset(self::$securityKeys[$key]) ? self::$securityKeys[$key] : false;
117 138
 	}
118 139
 
140
+	/**
141
+	 * @param string $key
142
+	 *
143
+	 * @return integer
144
+	 */
119 145
 	public static function performance($key, $defvalue = false)
120 146
 	{
121 147
 		if (!self::$performance) {
@@ -125,6 +151,9 @@  discard block
 block discarded – undo
125 151
 		return isset(self::$performance[$key]) ? self::$performance[$key] : false;
126 152
 	}
127 153
 
154
+	/**
155
+	 * @param string $key
156
+	 */
128 157
 	public static function relation($key, $defvalue = false)
129 158
 	{
130 159
 		if (empty(self::$relation)) {
@@ -147,6 +176,9 @@  discard block
 block discarded – undo
147 176
 		return self::$sounds[$key];
148 177
 	}
149 178
 
179
+	/**
180
+	 * @param string $key
181
+	 */
150 182
 	public static function search($key, $defvalue = false)
151 183
 	{
152 184
 		if (empty(self::$search)) {
@@ -156,6 +188,10 @@  discard block
 block discarded – undo
156 188
 		return self::$search[$key];
157 189
 	}
158 190
 
191
+	/**
192
+	 * @param string $key
193
+	 * @param integer $value
194
+	 */
159 195
 	public static function iniSet($key, $value)
160 196
 	{
161 197
 		@ini_set($key, $value);
Please login to merge, or discard this patch.
include/Webservices/VtigerCRMObjectMeta.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
 		$adb = PearDatabase::getInstance();
213 213
 
214 214
 		// administrator's have assign privilege
215
-		if (\vtlib\Functions::userIsAdministrator($this->user))
216
-			return true;
215
+		if (\vtlib\Functions::userIsAdministrator($this->user)) {
216
+					return true;
217
+		}
217 218
 
218 219
 		$idComponents = vtws_getIdComponents($webserviceId);
219 220
 		$userId = $idComponents[1];
@@ -353,8 +354,9 @@  discard block
 block discarded – undo
353 354
 		$theme = vtws_preserveGlobal('theme', $this->user->theme);
354 355
 		$default_language = AppConfig::main('default_language');
355 356
 		$current_language = vglobal('current_language');
356
-		if (empty($current_language))
357
-			$current_language = $default_language;
357
+		if (empty($current_language)) {
358
+					$current_language = $default_language;
359
+		}
358 360
 		$current_language = vtws_preserveGlobal('current_language', $current_language);
359 361
 
360 362
 		$this->computeAccess();
Please login to merge, or discard this patch.
include/Webservices/History.php 1 patch
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 	$page = empty($element['page']) ? 0 : intval($element['page']); // Page to start
32 32
 
33 33
 	$acrossAllModule = false;
34
-	if ($moduleName == 'Home')
35
-		$acrossAllModule = true;
34
+	if ($moduleName == 'Home') {
35
+			$acrossAllModule = true;
36
+	}
36 37
 
37 38
 	// Pre-condition check
38 39
 	if (empty($moduleName)) {
@@ -71,8 +72,10 @@  discard block
 block discarded – undo
71 72
 
72 73
 	// Get most recently tracked changes with limit
73 74
 	$start = $page * $MAXLIMIT;
74
-	if ($start > 0)
75
-		$start = $start + 1; // Adjust the start range
75
+	if ($start > 0) {
76
+			$start = $start + 1;
77
+	}
78
+	// Adjust the start range
76 79
 	$sql .= sprintf(' ORDER BY vtiger_modtracker_basic.id DESC LIMIT %s,%s', $start, $MAXLIMIT);
77 80
 
78 81
 	$result = $adb->pquery($sql, $params);
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/ExpandPropertyReport.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -18,86 +18,86 @@
 block discarded – undo
18 18
  */
19 19
 class ExpandPropertyReport implements XmlDeserializable {
20 20
 
21
-    /**
22
-     * An array with requested properties.
23
-     *
24
-     * The requested properties will be used as keys in this array. The value
25
-     * is normally null.
26
-     *
27
-     * If the value is an array though, it means the property must be expanded.
28
-     * Within the array, the sub-properties, which themselves may be null or
29
-     * arrays.
30
-     *
31
-     * @var array
32
-     */
33
-    public $properties;
34
-
35
-    /**
36
-     * The deserialize method is called during xml parsing.
37
-     *
38
-     * This method is called statictly, this is because in theory this method
39
-     * may be used as a type of constructor, or factory method.
40
-     *
41
-     * Often you want to return an instance of the current class, but you are
42
-     * free to return other data as well.
43
-     *
44
-     * You are responsible for advancing the reader to the next element. Not
45
-     * doing anything will result in a never-ending loop.
46
-     *
47
-     * If you just want to skip parsing for this element altogether, you can
48
-     * just call $reader->next();
49
-     *
50
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
51
-     * the next element.
52
-     *
53
-     * @param Reader $reader
54
-     * @return mixed
55
-     */
56
-    static function xmlDeserialize(Reader $reader) {
57
-
58
-        $elems = $reader->parseInnerTree();
59
-
60
-        $obj = new self();
61
-        $obj->properties = self::traverse($elems);
62
-
63
-        return $obj;
64
-
65
-    }
66
-
67
-    /**
68
-     * This method is used by deserializeXml, to recursively parse the
69
-     * {DAV:}property elements.
70
-     *
71
-     * @param array $elems
72
-     * @return void
73
-     */
74
-    private static function traverse($elems) {
75
-
76
-        $result = [];
77
-
78
-        foreach ($elems as $elem) {
79
-
80
-            if ($elem['name'] !== '{DAV:}property') {
81
-                continue;
82
-            }
83
-
84
-            $namespace = isset($elem['attributes']['namespace']) ?
85
-                $elem['attributes']['namespace'] :
86
-                'DAV:';
87
-
88
-            $propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89
-
90
-            $value = null;
91
-            if (is_array($elem['value'])) {
92
-                $value = self::traverse($elem['value']);
93
-            }
94
-
95
-            $result[$propName] = $value;
96
-
97
-        }
98
-
99
-        return $result;
100
-
101
-    }
21
+	/**
22
+	 * An array with requested properties.
23
+	 *
24
+	 * The requested properties will be used as keys in this array. The value
25
+	 * is normally null.
26
+	 *
27
+	 * If the value is an array though, it means the property must be expanded.
28
+	 * Within the array, the sub-properties, which themselves may be null or
29
+	 * arrays.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	public $properties;
34
+
35
+	/**
36
+	 * The deserialize method is called during xml parsing.
37
+	 *
38
+	 * This method is called statictly, this is because in theory this method
39
+	 * may be used as a type of constructor, or factory method.
40
+	 *
41
+	 * Often you want to return an instance of the current class, but you are
42
+	 * free to return other data as well.
43
+	 *
44
+	 * You are responsible for advancing the reader to the next element. Not
45
+	 * doing anything will result in a never-ending loop.
46
+	 *
47
+	 * If you just want to skip parsing for this element altogether, you can
48
+	 * just call $reader->next();
49
+	 *
50
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
51
+	 * the next element.
52
+	 *
53
+	 * @param Reader $reader
54
+	 * @return mixed
55
+	 */
56
+	static function xmlDeserialize(Reader $reader) {
57
+
58
+		$elems = $reader->parseInnerTree();
59
+
60
+		$obj = new self();
61
+		$obj->properties = self::traverse($elems);
62
+
63
+		return $obj;
64
+
65
+	}
66
+
67
+	/**
68
+	 * This method is used by deserializeXml, to recursively parse the
69
+	 * {DAV:}property elements.
70
+	 *
71
+	 * @param array $elems
72
+	 * @return void
73
+	 */
74
+	private static function traverse($elems) {
75
+
76
+		$result = [];
77
+
78
+		foreach ($elems as $elem) {
79
+
80
+			if ($elem['name'] !== '{DAV:}property') {
81
+				continue;
82
+			}
83
+
84
+			$namespace = isset($elem['attributes']['namespace']) ?
85
+				$elem['attributes']['namespace'] :
86
+				'DAV:';
87
+
88
+			$propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89
+
90
+			$value = null;
91
+			if (is_array($elem['value'])) {
92
+				$value = self::traverse($elem['value']);
93
+			}
94
+
95
+			$result[$propName] = $value;
96
+
97
+		}
98
+
99
+		return $result;
100
+
101
+	}
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@
 block discarded – undo
82 82
             }
83 83
 
84 84
             $namespace = isset($elem['attributes']['namespace']) ?
85
-                $elem['attributes']['namespace'] :
86
-                'DAV:';
85
+                $elem['attributes']['namespace'] : 'DAV:';
87 86
 
88 87
             $propName = '{' . $namespace . '}' . $elem['attributes']['name'];
89 88
 
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/PrincipalPropertySearchReport.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
  */
21 21
 class PrincipalPropertySearchReport implements XmlDeserializable {
22 22
 
23
-    /**
24
-     * The requested properties.
25
-     *
26
-     * @var array|null
27
-     */
28
-    public $properties;
29
-
30
-    /**
31
-     * searchProperties
32
-     *
33
-     * @var array
34
-     */
35
-    public $searchProperties = [];
36
-
37
-    /**
38
-     * By default the property search will be conducted on the url of the http
39
-     * request. If this is set to true, it will be applied to the principal
40
-     * collection set instead.
41
-     *
42
-     * @var bool
43
-     */
44
-    public $applyToPrincipalCollectionSet = false;
45
-
46
-    /**
47
-     * Search for principals matching ANY of the properties (OR) or a ALL of
48
-     * the properties (AND).
49
-     *
50
-     * This property is either "anyof" or "allof".
51
-     *
52
-     * @var string
53
-     */
54
-    public $test;
55
-
56
-    /**
57
-     * The deserialize method is called during xml parsing.
58
-     *
59
-     * This method is called statictly, this is because in theory this method
60
-     * may be used as a type of constructor, or factory method.
61
-     *
62
-     * Often you want to return an instance of the current class, but you are
63
-     * free to return other data as well.
64
-     *
65
-     * You are responsible for advancing the reader to the next element. Not
66
-     * doing anything will result in a never-ending loop.
67
-     *
68
-     * If you just want to skip parsing for this element altogether, you can
69
-     * just call $reader->next();
70
-     *
71
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
72
-     * the next element.
73
-     *
74
-     * @param Reader $reader
75
-     * @return mixed
76
-     */
77
-    static function xmlDeserialize(Reader $reader) {
78
-
79
-        $self = new self();
80
-
81
-        $foundSearchProp = false;
82
-        $self->test = 'allof';
83
-        if ($reader->getAttribute('test') === 'anyof') {
84
-            $self->test = 'anyof';
85
-        }
86
-
87
-        $elemMap = [
88
-            '{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue',
89
-            '{DAV:}prop'            => 'Sabre\\Xml\\Element\\KeyValue',
90
-        ];
23
+	/**
24
+	 * The requested properties.
25
+	 *
26
+	 * @var array|null
27
+	 */
28
+	public $properties;
29
+
30
+	/**
31
+	 * searchProperties
32
+	 *
33
+	 * @var array
34
+	 */
35
+	public $searchProperties = [];
36
+
37
+	/**
38
+	 * By default the property search will be conducted on the url of the http
39
+	 * request. If this is set to true, it will be applied to the principal
40
+	 * collection set instead.
41
+	 *
42
+	 * @var bool
43
+	 */
44
+	public $applyToPrincipalCollectionSet = false;
45
+
46
+	/**
47
+	 * Search for principals matching ANY of the properties (OR) or a ALL of
48
+	 * the properties (AND).
49
+	 *
50
+	 * This property is either "anyof" or "allof".
51
+	 *
52
+	 * @var string
53
+	 */
54
+	public $test;
55
+
56
+	/**
57
+	 * The deserialize method is called during xml parsing.
58
+	 *
59
+	 * This method is called statictly, this is because in theory this method
60
+	 * may be used as a type of constructor, or factory method.
61
+	 *
62
+	 * Often you want to return an instance of the current class, but you are
63
+	 * free to return other data as well.
64
+	 *
65
+	 * You are responsible for advancing the reader to the next element. Not
66
+	 * doing anything will result in a never-ending loop.
67
+	 *
68
+	 * If you just want to skip parsing for this element altogether, you can
69
+	 * just call $reader->next();
70
+	 *
71
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
72
+	 * the next element.
73
+	 *
74
+	 * @param Reader $reader
75
+	 * @return mixed
76
+	 */
77
+	static function xmlDeserialize(Reader $reader) {
78
+
79
+		$self = new self();
80
+
81
+		$foundSearchProp = false;
82
+		$self->test = 'allof';
83
+		if ($reader->getAttribute('test') === 'anyof') {
84
+			$self->test = 'anyof';
85
+		}
86
+
87
+		$elemMap = [
88
+			'{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue',
89
+			'{DAV:}prop'            => 'Sabre\\Xml\\Element\\KeyValue',
90
+		];
91 91
         
92
-        foreach ($reader->parseInnerTree($elemMap) as $elem) {
93
-
94
-            switch ($elem['name']) {
95
-
96
-                case '{DAV:}prop' :
97
-                    $self->properties = array_keys($elem['value']);
98
-                    break;
99
-                case '{DAV:}property-search' :
100
-                    $foundSearchProp = true;
101
-                    // This property has two sub-elements:
102
-                    //   {DAV:}prop - The property to be searched on. This may
103
-                    //                also be more than one
104
-                    //   {DAV:}match - The value to match with
105
-                    if (!isset($elem['value']['{DAV:}prop']) || !isset($elem['value']['{DAV:}match'])) {
106
-                        throw new BadRequest('The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element');
107
-                    }
108
-                    foreach ($elem['value']['{DAV:}prop'] as $propName => $discard) {
109
-                        $self->searchProperties[$propName] = $elem['value']['{DAV:}match'];
110
-                    }
111
-                    break;
112
-                case '{DAV:}apply-to-principal-collection-set' :
113
-                    $self->applyToPrincipalCollectionSet = true;
114
-                    break;
115
-
116
-            }
117
-
118
-        }
119
-        if (!$foundSearchProp) {
120
-            throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element');
121
-        }
122
-
123
-        return $self;
124
-
125
-    }
92
+		foreach ($reader->parseInnerTree($elemMap) as $elem) {
93
+
94
+			switch ($elem['name']) {
95
+
96
+				case '{DAV:}prop' :
97
+					$self->properties = array_keys($elem['value']);
98
+					break;
99
+				case '{DAV:}property-search' :
100
+					$foundSearchProp = true;
101
+					// This property has two sub-elements:
102
+					//   {DAV:}prop - The property to be searched on. This may
103
+					//                also be more than one
104
+					//   {DAV:}match - The value to match with
105
+					if (!isset($elem['value']['{DAV:}prop']) || !isset($elem['value']['{DAV:}match'])) {
106
+						throw new BadRequest('The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element');
107
+					}
108
+					foreach ($elem['value']['{DAV:}prop'] as $propName => $discard) {
109
+						$self->searchProperties[$propName] = $elem['value']['{DAV:}match'];
110
+					}
111
+					break;
112
+				case '{DAV:}apply-to-principal-collection-set' :
113
+					$self->applyToPrincipalCollectionSet = true;
114
+					break;
115
+
116
+			}
117
+
118
+		}
119
+		if (!$foundSearchProp) {
120
+			throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element');
121
+		}
122
+
123
+		return $self;
124
+
125
+	}
126 126
 
127 127
 }
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -20,39 +20,39 @@
 block discarded – undo
20 20
  */
21 21
 class PrincipalSearchPropertySetReport implements XmlDeserializable {
22 22
 
23
-    /**
24
-     * The deserialize method is called during xml parsing.
25
-     *
26
-     * This method is called statictly, this is because in theory this method
27
-     * may be used as a type of constructor, or factory method.
28
-     *
29
-     * Often you want to return an instance of the current class, but you are
30
-     * free to return other data as well.
31
-     *
32
-     * You are responsible for advancing the reader to the next element. Not
33
-     * doing anything will result in a never-ending loop.
34
-     *
35
-     * If you just want to skip parsing for this element altogether, you can
36
-     * just call $reader->next();
37
-     *
38
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
39
-     * the next element.
40
-     *
41
-     * @param Reader $reader
42
-     * @return mixed
43
-     */
44
-    static function xmlDeserialize(Reader $reader) {
45
-
46
-        if (!$reader->isEmptyElement) {
47
-            throw new BadRequest('The {DAV:}principal-search-property-set element must be empty');
48
-        }
49
-
50
-        // The element is actually empty, so there's not much to do.
51
-        $reader->next();
52
-
53
-        $self = new self();
54
-        return $self;
55
-
56
-    }
23
+	/**
24
+	 * The deserialize method is called during xml parsing.
25
+	 *
26
+	 * This method is called statictly, this is because in theory this method
27
+	 * may be used as a type of constructor, or factory method.
28
+	 *
29
+	 * Often you want to return an instance of the current class, but you are
30
+	 * free to return other data as well.
31
+	 *
32
+	 * You are responsible for advancing the reader to the next element. Not
33
+	 * doing anything will result in a never-ending loop.
34
+	 *
35
+	 * If you just want to skip parsing for this element altogether, you can
36
+	 * just call $reader->next();
37
+	 *
38
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
39
+	 * the next element.
40
+	 *
41
+	 * @param Reader $reader
42
+	 * @return mixed
43
+	 */
44
+	static function xmlDeserialize(Reader $reader) {
45
+
46
+		if (!$reader->isEmptyElement) {
47
+			throw new BadRequest('The {DAV:}principal-search-property-set element must be empty');
48
+		}
49
+
50
+		// The element is actually empty, so there's not much to do.
51
+		$reader->next();
52
+
53
+		$self = new self();
54
+		return $self;
55
+
56
+	}
57 57
 
58 58
 }
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/Xml/Property/Acl.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 
178 178
         $privileges = [];
179 179
 
180
-        foreach ((array)$reader->parseInnerTree($elementMap) as $element) {
180
+        foreach ((array) $reader->parseInnerTree($elementMap) as $element) {
181 181
 
182 182
             if ($element['name'] !== '{DAV:}ace') {
183 183
                 continue;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,9 @@
 block discarded – undo
136 136
             }
137 137
             echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
138 138
             echo '<td>';
139
-            if (!empty($privilege['protected'])) echo '(protected)';
139
+            if (!empty($privilege['protected'])) {
140
+            	echo '(protected)';
141
+            }
140 142
             echo '</td>';
141 143
             echo '</tr>';
142 144
 
Please login to merge, or discard this patch.
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -27,251 +27,251 @@
 block discarded – undo
27 27
  */
28 28
 class Acl implements Element, HtmlOutput {
29 29
 
30
-    /**
31
-     * List of privileges
32
-     *
33
-     * @var array
34
-     */
35
-    protected $privileges;
36
-
37
-    /**
38
-     * Whether or not the server base url is required to be prefixed when
39
-     * serializing the property.
40
-     *
41
-     * @var bool
42
-     */
43
-    protected $prefixBaseUrl;
44
-
45
-    /**
46
-     * Constructor
47
-     *
48
-     * This object requires a structure similar to the return value from
49
-     * Sabre\DAVACL\Plugin::getACL().
50
-     *
51
-     * Each privilege is a an array with at least a 'privilege' property, and a
52
-     * 'principal' property. A privilege may have a 'protected' property as
53
-     * well.
54
-     *
55
-     * The prefixBaseUrl should be set to false, if the supplied principal urls
56
-     * are already full urls. If this is kept to true, the servers base url
57
-     * will automatically be prefixed.
58
-     *
59
-     * @param array $privileges
60
-     * @param bool $prefixBaseUrl
61
-     */
62
-    public function __construct(array $privileges, $prefixBaseUrl = true) {
63
-
64
-        $this->privileges = $privileges;
65
-        $this->prefixBaseUrl = $prefixBaseUrl;
66
-
67
-    }
68
-
69
-    /**
70
-     * Returns the list of privileges for this property
71
-     *
72
-     * @return array
73
-     */
74
-    public function getPrivileges() {
75
-
76
-        return $this->privileges;
77
-
78
-    }
79
-
80
-    /**
81
-     * The xmlSerialize metod is called during xml writing.
82
-     *
83
-     * Use the $writer argument to write its own xml serialization.
84
-     *
85
-     * An important note: do _not_ create a parent element. Any element
86
-     * implementing XmlSerializble should only ever write what's considered
87
-     * its 'inner xml'.
88
-     *
89
-     * The parent of the current element is responsible for writing a
90
-     * containing element.
91
-     *
92
-     * This allows serializers to be re-used for different element names.
93
-     *
94
-     * If you are opening new elements, you must also close them again.
95
-     *
96
-     * @param Writer $writer
97
-     * @return void
98
-     */
99
-    public function xmlSerialize(Writer $writer) {
100
-
101
-        foreach ($this->privileges as $ace) {
102
-
103
-            $this->serializeAce($writer, $ace);
104
-
105
-        }
106
-
107
-    }
108
-
109
-    /**
110
-     * Generate html representation for this value.
111
-     *
112
-     * The html output is 100% trusted, and no effort is being made to sanitize
113
-     * it. It's up to the implementor to sanitize user provided values.
114
-     *
115
-     * The output must be in UTF-8.
116
-     *
117
-     * The baseUri parameter is a url to the root of the application, and can
118
-     * be used to construct local links.
119
-     *
120
-     * @param HtmlOutputHelper $html
121
-     * @return string
122
-     */
123
-    public function toHtml(HtmlOutputHelper $html) {
124
-
125
-        ob_start();
126
-        echo "<table>";
127
-        echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>";
128
-        foreach ($this->privileges as $privilege) {
129
-
130
-            echo '<tr>';
131
-            // if it starts with a {, it's a special principal
132
-            if ($privilege['principal'][0] === '{') {
133
-                echo '<td>', $html->xmlName($privilege['principal']), '</td>';
134
-            } else {
135
-                echo '<td>', $html->link($privilege['principal']), '</td>';
136
-            }
137
-            echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
138
-            echo '<td>';
139
-            if (!empty($privilege['protected'])) echo '(protected)';
140
-            echo '</td>';
141
-            echo '</tr>';
142
-
143
-        }
144
-        echo "</table>";
145
-        return ob_get_clean();
146
-
147
-    }
148
-
149
-    /**
150
-     * The deserialize method is called during xml parsing.
151
-     *
152
-     * This method is called statictly, this is because in theory this method
153
-     * may be used as a type of constructor, or factory method.
154
-     *
155
-     * Often you want to return an instance of the current class, but you are
156
-     * free to return other data as well.
157
-     *
158
-     * Important note 2: You are responsible for advancing the reader to the
159
-     * next element. Not doing anything will result in a never-ending loop.
160
-     *
161
-     * If you just want to skip parsing for this element altogether, you can
162
-     * just call $reader->next();
163
-     *
164
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
165
-     * the next element.
166
-     *
167
-     * @param Reader $reader
168
-     * @return mixed
169
-     */
170
-    static function xmlDeserialize(Reader $reader) {
171
-
172
-        $elementMap = [
173
-            '{DAV:}ace'       => 'Sabre\Xml\Element\KeyValue',
174
-            '{DAV:}privilege' => 'Sabre\Xml\Element\Elements',
175
-            '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal',
176
-        ];
177
-
178
-        $privileges = [];
179
-
180
-        foreach ((array)$reader->parseInnerTree($elementMap) as $element) {
181
-
182
-            if ($element['name'] !== '{DAV:}ace') {
183
-                continue;
184
-            }
185
-            $ace = $element['value'];
186
-
187
-            if (empty($ace['{DAV:}principal'])) {
188
-                throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
189
-            }
190
-            $principal = $ace['{DAV:}principal'];
191
-
192
-            switch ($principal->getType()) {
193
-                case Principal::HREF :
194
-                    $principal = $principal->getHref();
195
-                    break;
196
-                case Principal::AUTHENTICATED :
197
-                    $principal = '{DAV:}authenticated';
198
-                    break;
199
-                case Principal::UNAUTHENTICATED :
200
-                    $principal = '{DAV:}unauthenticated';
201
-                    break;
202
-                case Principal::ALL :
203
-                    $principal = '{DAV:}all';
204
-                    break;
205
-
206
-            }
207
-
208
-            $protected = array_key_exists('{DAV:}protected', $ace);
209
-
210
-            if (!isset($ace['{DAV:}grant'])) {
211
-                throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
212
-            }
213
-            foreach ($ace['{DAV:}grant'] as $elem) {
214
-                if ($elem['name'] !== '{DAV:}privilege') {
215
-                    continue;
216
-                }
217
-
218
-                foreach ($elem['value'] as $priv) {
219
-                    $privileges[] = [
220
-                        'principal' => $principal,
221
-                        'protected' => $protected,
222
-                        'privilege' => $priv,
223
-                    ];
224
-                }
225
-
226
-            }
227
-
228
-        }
229
-
230
-        return new self($privileges);
231
-
232
-    }
233
-
234
-    /**
235
-     * Serializes a single access control entry.
236
-     *
237
-     * @param Writer $writer
238
-     * @param array $ace
239
-     * @return void
240
-     */
241
-    private function serializeAce(Writer $writer, array $ace) {
242
-
243
-        $writer->startElement('{DAV:}ace');
244
-
245
-        switch ($ace['principal']) {
246
-            case '{DAV:}authenticated' :
247
-                $principal = new Principal(Principal::AUTHENTICATED);
248
-                break;
249
-            case '{DAV:}unauthenticated' :
250
-                $principal = new Principal(Principal::UNAUTHENTICATED);
251
-                break;
252
-            case '{DAV:}all' :
253
-                $principal = new Principal(Principal::ALL);
254
-                break;
255
-            default:
256
-                $principal = new Principal(Principal::HREF, $ace['principal']);
257
-                break;
258
-        }
259
-
260
-        $writer->writeElement('{DAV:}principal', $principal);
261
-        $writer->startElement('{DAV:}grant');
262
-        $writer->startElement('{DAV:}privilege');
263
-
264
-        $writer->writeElement($ace['privilege']);
265
-
266
-        $writer->endElement(); // privilege
267
-        $writer->endElement(); // grant
268
-
269
-        if (!empty($ace['protected'])) {
270
-            $writer->writeElement('{DAV:}protected');
271
-        }
272
-
273
-        $writer->endElement(); // ace
274
-
275
-    }
30
+	/**
31
+	 * List of privileges
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $privileges;
36
+
37
+	/**
38
+	 * Whether or not the server base url is required to be prefixed when
39
+	 * serializing the property.
40
+	 *
41
+	 * @var bool
42
+	 */
43
+	protected $prefixBaseUrl;
44
+
45
+	/**
46
+	 * Constructor
47
+	 *
48
+	 * This object requires a structure similar to the return value from
49
+	 * Sabre\DAVACL\Plugin::getACL().
50
+	 *
51
+	 * Each privilege is a an array with at least a 'privilege' property, and a
52
+	 * 'principal' property. A privilege may have a 'protected' property as
53
+	 * well.
54
+	 *
55
+	 * The prefixBaseUrl should be set to false, if the supplied principal urls
56
+	 * are already full urls. If this is kept to true, the servers base url
57
+	 * will automatically be prefixed.
58
+	 *
59
+	 * @param array $privileges
60
+	 * @param bool $prefixBaseUrl
61
+	 */
62
+	public function __construct(array $privileges, $prefixBaseUrl = true) {
63
+
64
+		$this->privileges = $privileges;
65
+		$this->prefixBaseUrl = $prefixBaseUrl;
66
+
67
+	}
68
+
69
+	/**
70
+	 * Returns the list of privileges for this property
71
+	 *
72
+	 * @return array
73
+	 */
74
+	public function getPrivileges() {
75
+
76
+		return $this->privileges;
77
+
78
+	}
79
+
80
+	/**
81
+	 * The xmlSerialize metod is called during xml writing.
82
+	 *
83
+	 * Use the $writer argument to write its own xml serialization.
84
+	 *
85
+	 * An important note: do _not_ create a parent element. Any element
86
+	 * implementing XmlSerializble should only ever write what's considered
87
+	 * its 'inner xml'.
88
+	 *
89
+	 * The parent of the current element is responsible for writing a
90
+	 * containing element.
91
+	 *
92
+	 * This allows serializers to be re-used for different element names.
93
+	 *
94
+	 * If you are opening new elements, you must also close them again.
95
+	 *
96
+	 * @param Writer $writer
97
+	 * @return void
98
+	 */
99
+	public function xmlSerialize(Writer $writer) {
100
+
101
+		foreach ($this->privileges as $ace) {
102
+
103
+			$this->serializeAce($writer, $ace);
104
+
105
+		}
106
+
107
+	}
108
+
109
+	/**
110
+	 * Generate html representation for this value.
111
+	 *
112
+	 * The html output is 100% trusted, and no effort is being made to sanitize
113
+	 * it. It's up to the implementor to sanitize user provided values.
114
+	 *
115
+	 * The output must be in UTF-8.
116
+	 *
117
+	 * The baseUri parameter is a url to the root of the application, and can
118
+	 * be used to construct local links.
119
+	 *
120
+	 * @param HtmlOutputHelper $html
121
+	 * @return string
122
+	 */
123
+	public function toHtml(HtmlOutputHelper $html) {
124
+
125
+		ob_start();
126
+		echo "<table>";
127
+		echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>";
128
+		foreach ($this->privileges as $privilege) {
129
+
130
+			echo '<tr>';
131
+			// if it starts with a {, it's a special principal
132
+			if ($privilege['principal'][0] === '{') {
133
+				echo '<td>', $html->xmlName($privilege['principal']), '</td>';
134
+			} else {
135
+				echo '<td>', $html->link($privilege['principal']), '</td>';
136
+			}
137
+			echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
138
+			echo '<td>';
139
+			if (!empty($privilege['protected'])) echo '(protected)';
140
+			echo '</td>';
141
+			echo '</tr>';
142
+
143
+		}
144
+		echo "</table>";
145
+		return ob_get_clean();
146
+
147
+	}
148
+
149
+	/**
150
+	 * The deserialize method is called during xml parsing.
151
+	 *
152
+	 * This method is called statictly, this is because in theory this method
153
+	 * may be used as a type of constructor, or factory method.
154
+	 *
155
+	 * Often you want to return an instance of the current class, but you are
156
+	 * free to return other data as well.
157
+	 *
158
+	 * Important note 2: You are responsible for advancing the reader to the
159
+	 * next element. Not doing anything will result in a never-ending loop.
160
+	 *
161
+	 * If you just want to skip parsing for this element altogether, you can
162
+	 * just call $reader->next();
163
+	 *
164
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
165
+	 * the next element.
166
+	 *
167
+	 * @param Reader $reader
168
+	 * @return mixed
169
+	 */
170
+	static function xmlDeserialize(Reader $reader) {
171
+
172
+		$elementMap = [
173
+			'{DAV:}ace'       => 'Sabre\Xml\Element\KeyValue',
174
+			'{DAV:}privilege' => 'Sabre\Xml\Element\Elements',
175
+			'{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal',
176
+		];
177
+
178
+		$privileges = [];
179
+
180
+		foreach ((array)$reader->parseInnerTree($elementMap) as $element) {
181
+
182
+			if ($element['name'] !== '{DAV:}ace') {
183
+				continue;
184
+			}
185
+			$ace = $element['value'];
186
+
187
+			if (empty($ace['{DAV:}principal'])) {
188
+				throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
189
+			}
190
+			$principal = $ace['{DAV:}principal'];
191
+
192
+			switch ($principal->getType()) {
193
+				case Principal::HREF :
194
+					$principal = $principal->getHref();
195
+					break;
196
+				case Principal::AUTHENTICATED :
197
+					$principal = '{DAV:}authenticated';
198
+					break;
199
+				case Principal::UNAUTHENTICATED :
200
+					$principal = '{DAV:}unauthenticated';
201
+					break;
202
+				case Principal::ALL :
203
+					$principal = '{DAV:}all';
204
+					break;
205
+
206
+			}
207
+
208
+			$protected = array_key_exists('{DAV:}protected', $ace);
209
+
210
+			if (!isset($ace['{DAV:}grant'])) {
211
+				throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
212
+			}
213
+			foreach ($ace['{DAV:}grant'] as $elem) {
214
+				if ($elem['name'] !== '{DAV:}privilege') {
215
+					continue;
216
+				}
217
+
218
+				foreach ($elem['value'] as $priv) {
219
+					$privileges[] = [
220
+						'principal' => $principal,
221
+						'protected' => $protected,
222
+						'privilege' => $priv,
223
+					];
224
+				}
225
+
226
+			}
227
+
228
+		}
229
+
230
+		return new self($privileges);
231
+
232
+	}
233
+
234
+	/**
235
+	 * Serializes a single access control entry.
236
+	 *
237
+	 * @param Writer $writer
238
+	 * @param array $ace
239
+	 * @return void
240
+	 */
241
+	private function serializeAce(Writer $writer, array $ace) {
242
+
243
+		$writer->startElement('{DAV:}ace');
244
+
245
+		switch ($ace['principal']) {
246
+			case '{DAV:}authenticated' :
247
+				$principal = new Principal(Principal::AUTHENTICATED);
248
+				break;
249
+			case '{DAV:}unauthenticated' :
250
+				$principal = new Principal(Principal::UNAUTHENTICATED);
251
+				break;
252
+			case '{DAV:}all' :
253
+				$principal = new Principal(Principal::ALL);
254
+				break;
255
+			default:
256
+				$principal = new Principal(Principal::HREF, $ace['principal']);
257
+				break;
258
+		}
259
+
260
+		$writer->writeElement('{DAV:}principal', $principal);
261
+		$writer->startElement('{DAV:}grant');
262
+		$writer->startElement('{DAV:}privilege');
263
+
264
+		$writer->writeElement($ace['privilege']);
265
+
266
+		$writer->endElement(); // privilege
267
+		$writer->endElement(); // grant
268
+
269
+		if (!empty($ace['protected'])) {
270
+			$writer->writeElement('{DAV:}protected');
271
+		}
272
+
273
+		$writer->endElement(); // ace
274
+
275
+	}
276 276
 
277 277
 }
Please login to merge, or discard this patch.
libraries/SabreDAV/DAVACL/FS/Collection.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,8 +59,12 @@
 block discarded – undo
59 59
 
60 60
         $path = $this->path . '/' . $name;
61 61
 
62
-        if (!file_exists($path)) throw new NotFound('File could not be located');
63
-        if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
62
+        if (!file_exists($path)) {
63
+        	throw new NotFound('File could not be located');
64
+        }
65
+        if ($name == '.' || $name == '..') {
66
+        	throw new Forbidden('Permission denied to . and ..');
67
+        }
64 68
 
65 69
         if (is_dir($path)) {
66 70
 
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -16,138 +16,138 @@
 block discarded – undo
16 16
  */
17 17
 class Collection extends BaseCollection implements IACL {
18 18
 
19
-    /**
20
-     * A list of ACL rules.
21
-     *
22
-     * @var array
23
-     */
24
-    protected $acl;
25
-
26
-    /**
27
-     * Owner uri, or null for no owner.
28
-     *
29
-     * @var string|null
30
-     */
31
-    protected $owner;
32
-
33
-    /**
34
-     * Constructor
35
-     *
36
-     * @param string $path on-disk path.
37
-     * @param array $acl ACL rules.
38
-     * @param string|null $owner principal owner string.
39
-     */
40
-    public function __construct($path, array $acl, $owner = null) {
41
-
42
-        parent::__construct($path);
43
-        $this->acl = $acl;
44
-        $this->owner = $owner;
45
-
46
-    }
47
-
48
-    /**
49
-     * Returns a specific child node, referenced by its name
50
-     *
51
-     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
52
-     * exist.
53
-     *
54
-     * @param string $name
55
-     * @throws DAV\Exception\NotFound
56
-     * @return DAV\INode
57
-     */
58
-    public function getChild($name) {
59
-
60
-        $path = $this->path . '/' . $name;
61
-
62
-        if (!file_exists($path)) throw new NotFound('File could not be located');
63
-        if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
64
-
65
-        if (is_dir($path)) {
66
-
67
-            return new self($path, $this->acl, $this->owner);
68
-
69
-        } else {
70
-
71
-            return new File($path, $this->acl, $this->owner);
72
-
73
-        }
74
-
75
-    }
76
-
77
-    /**
78
-     * Returns the owner principal
79
-     *
80
-     * This must be a url to a principal, or null if there's no owner
81
-     *
82
-     * @return string|null
83
-     */
84
-    public function getOwner() {
85
-
86
-        return $this->owner;
87
-
88
-    }
89
-
90
-    /**
91
-     * Returns a group principal
92
-     *
93
-     * This must be a url to a principal, or null if there's no owner
94
-     *
95
-     * @return string|null
96
-     */
97
-    public function getGroup() {
98
-
99
-        return null;
100
-
101
-    }
102
-
103
-    /**
104
-     * Returns a list of ACE's for this node.
105
-     *
106
-     * Each ACE has the following properties:
107
-     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
108
-     *     currently the only supported privileges
109
-     *   * 'principal', a url to the principal who owns the node
110
-     *   * 'protected' (optional), indicating that this ACE is not allowed to
111
-     *      be updated.
112
-     *
113
-     * @return array
114
-     */
115
-    public function getACL() {
116
-
117
-        return $this->acl;
118
-
119
-    }
120
-
121
-    /**
122
-     * Updates the ACL
123
-     *
124
-     * This method will receive a list of new ACE's as an array argument.
125
-     *
126
-     * @param array $acl
127
-     * @return void
128
-     */
129
-    public function setACL(array $acl) {
130
-
131
-        throw new Forbidden('Setting ACL is not allowed here');
132
-
133
-    }
134
-
135
-    /**
136
-     * Returns the list of supported privileges for this node.
137
-     *
138
-     * The returned data structure is a list of nested privileges.
139
-     * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
140
-     * standard structure.
141
-     *
142
-     * If null is returned from this method, the default privilege set is used,
143
-     * which is fine for most common usecases.
144
-     *
145
-     * @return array|null
146
-     */
147
-    public function getSupportedPrivilegeSet() {
148
-
149
-        return null;
150
-
151
-    }
19
+	/**
20
+	 * A list of ACL rules.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $acl;
25
+
26
+	/**
27
+	 * Owner uri, or null for no owner.
28
+	 *
29
+	 * @var string|null
30
+	 */
31
+	protected $owner;
32
+
33
+	/**
34
+	 * Constructor
35
+	 *
36
+	 * @param string $path on-disk path.
37
+	 * @param array $acl ACL rules.
38
+	 * @param string|null $owner principal owner string.
39
+	 */
40
+	public function __construct($path, array $acl, $owner = null) {
41
+
42
+		parent::__construct($path);
43
+		$this->acl = $acl;
44
+		$this->owner = $owner;
45
+
46
+	}
47
+
48
+	/**
49
+	 * Returns a specific child node, referenced by its name
50
+	 *
51
+	 * This method must throw Sabre\DAV\Exception\NotFound if the node does not
52
+	 * exist.
53
+	 *
54
+	 * @param string $name
55
+	 * @throws DAV\Exception\NotFound
56
+	 * @return DAV\INode
57
+	 */
58
+	public function getChild($name) {
59
+
60
+		$path = $this->path . '/' . $name;
61
+
62
+		if (!file_exists($path)) throw new NotFound('File could not be located');
63
+		if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..');
64
+
65
+		if (is_dir($path)) {
66
+
67
+			return new self($path, $this->acl, $this->owner);
68
+
69
+		} else {
70
+
71
+			return new File($path, $this->acl, $this->owner);
72
+
73
+		}
74
+
75
+	}
76
+
77
+	/**
78
+	 * Returns the owner principal
79
+	 *
80
+	 * This must be a url to a principal, or null if there's no owner
81
+	 *
82
+	 * @return string|null
83
+	 */
84
+	public function getOwner() {
85
+
86
+		return $this->owner;
87
+
88
+	}
89
+
90
+	/**
91
+	 * Returns a group principal
92
+	 *
93
+	 * This must be a url to a principal, or null if there's no owner
94
+	 *
95
+	 * @return string|null
96
+	 */
97
+	public function getGroup() {
98
+
99
+		return null;
100
+
101
+	}
102
+
103
+	/**
104
+	 * Returns a list of ACE's for this node.
105
+	 *
106
+	 * Each ACE has the following properties:
107
+	 *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
108
+	 *     currently the only supported privileges
109
+	 *   * 'principal', a url to the principal who owns the node
110
+	 *   * 'protected' (optional), indicating that this ACE is not allowed to
111
+	 *      be updated.
112
+	 *
113
+	 * @return array
114
+	 */
115
+	public function getACL() {
116
+
117
+		return $this->acl;
118
+
119
+	}
120
+
121
+	/**
122
+	 * Updates the ACL
123
+	 *
124
+	 * This method will receive a list of new ACE's as an array argument.
125
+	 *
126
+	 * @param array $acl
127
+	 * @return void
128
+	 */
129
+	public function setACL(array $acl) {
130
+
131
+		throw new Forbidden('Setting ACL is not allowed here');
132
+
133
+	}
134
+
135
+	/**
136
+	 * Returns the list of supported privileges for this node.
137
+	 *
138
+	 * The returned data structure is a list of nested privileges.
139
+	 * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
140
+	 * standard structure.
141
+	 *
142
+	 * If null is returned from this method, the default privilege set is used,
143
+	 * which is fine for most common usecases.
144
+	 *
145
+	 * @return array|null
146
+	 */
147
+	public function getSupportedPrivilegeSet() {
148
+
149
+		return null;
150
+
151
+	}
152 152
 
153 153
 }
Please login to merge, or discard this patch.