@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\AppFramework\Http; |
26 | 26 | |
27 | 27 | class RateLimitExceededException extends SecurityException { |
28 | - public function __construct() { |
|
29 | - parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | - } |
|
28 | + public function __construct() { |
|
29 | + parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | + } |
|
31 | 31 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | case '{DAV:}prop': |
108 | 108 | $newProps['properties'] = array_keys($elem['value']); |
109 | 109 | break; |
110 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
110 | + case '{'.SearchPlugin::NS_Nextcloud.'}filter': |
|
111 | 111 | foreach ($elem['value'] as $subElem) { |
112 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
112 | + if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') { |
|
113 | 113 | if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
114 | 114 | $newProps['filters']['comps'] = []; |
115 | 115 | } |
116 | 116 | $newProps['filters']['comps'][] = $subElem['value']; |
117 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
117 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') { |
|
118 | 118 | if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
119 | 119 | $newProps['filters']['props'] = []; |
120 | 120 | } |
121 | 121 | $newProps['filters']['props'][] = $subElem['value']; |
122 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
122 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') { |
|
123 | 123 | if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
124 | 124 | $newProps['filters']['params'] = []; |
125 | 125 | } |
126 | 126 | $newProps['filters']['params'][] = $subElem['value']; |
127 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
127 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') { |
|
128 | 128 | $newProps['filters']['search-term'] = $subElem['value']; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | break; |
132 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
132 | + case '{'.SearchPlugin::NS_Nextcloud.'}limit': |
|
133 | 133 | $newProps['limit'] = $elem['value']; |
134 | 134 | break; |
135 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
135 | + case '{'.SearchPlugin::NS_Nextcloud.'}offset': |
|
136 | 136 | $newProps['offset'] = $elem['value']; |
137 | 137 | break; |
138 | 138 | |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | if (empty($newProps['filters'])) { |
143 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
143 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
147 | 147 | $noCompsDefined = empty($newProps['filters']['comps']); |
148 | 148 | if ($propsOrParamsDefined && $noCompsDefined) { |
149 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
149 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | if (!isset($newProps['filters']['search-term'])) { |
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
153 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
157 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
157 | + throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |
@@ -35,133 +35,133 @@ |
||
35 | 35 | */ |
36 | 36 | class CalendarSearchReport implements XmlDeserializable { |
37 | 37 | |
38 | - /** |
|
39 | - * An array with requested properties. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $properties; |
|
44 | - |
|
45 | - /** |
|
46 | - * List of property/component filters. |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - public $filters; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var int |
|
54 | - */ |
|
55 | - public $limit; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var int |
|
59 | - */ |
|
60 | - public $offset; |
|
61 | - |
|
62 | - /** |
|
63 | - * The deserialize method is called during xml parsing. |
|
64 | - * |
|
65 | - * This method is called statically, this is because in theory this method |
|
66 | - * may be used as a type of constructor, or factory method. |
|
67 | - * |
|
68 | - * Often you want to return an instance of the current class, but you are |
|
69 | - * free to return other data as well. |
|
70 | - * |
|
71 | - * You are responsible for advancing the reader to the next element. Not |
|
72 | - * doing anything will result in a never-ending loop. |
|
73 | - * |
|
74 | - * If you just want to skip parsing for this element altogether, you can |
|
75 | - * just call $reader->next(); |
|
76 | - * |
|
77 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
78 | - * the next element. |
|
79 | - * |
|
80 | - * @param Reader $reader |
|
81 | - * @return mixed |
|
82 | - */ |
|
83 | - public static function xmlDeserialize(Reader $reader) { |
|
84 | - $elems = $reader->parseInnerTree([ |
|
85 | - '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
86 | - '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
87 | - '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
88 | - '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
89 | - '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
90 | - '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
91 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
92 | - ]); |
|
93 | - |
|
94 | - $newProps = [ |
|
95 | - 'filters' => [], |
|
96 | - 'properties' => [], |
|
97 | - 'limit' => null, |
|
98 | - 'offset' => null |
|
99 | - ]; |
|
100 | - |
|
101 | - if (!is_array($elems)) { |
|
102 | - $elems = []; |
|
103 | - } |
|
104 | - |
|
105 | - foreach ($elems as $elem) { |
|
106 | - switch ($elem['name']) { |
|
107 | - case '{DAV:}prop': |
|
108 | - $newProps['properties'] = array_keys($elem['value']); |
|
109 | - break; |
|
110 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
111 | - foreach ($elem['value'] as $subElem) { |
|
112 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
113 | - if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
114 | - $newProps['filters']['comps'] = []; |
|
115 | - } |
|
116 | - $newProps['filters']['comps'][] = $subElem['value']; |
|
117 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
118 | - if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
119 | - $newProps['filters']['props'] = []; |
|
120 | - } |
|
121 | - $newProps['filters']['props'][] = $subElem['value']; |
|
122 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
123 | - if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
124 | - $newProps['filters']['params'] = []; |
|
125 | - } |
|
126 | - $newProps['filters']['params'][] = $subElem['value']; |
|
127 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
128 | - $newProps['filters']['search-term'] = $subElem['value']; |
|
129 | - } |
|
130 | - } |
|
131 | - break; |
|
132 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
133 | - $newProps['limit'] = $elem['value']; |
|
134 | - break; |
|
135 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
136 | - $newProps['offset'] = $elem['value']; |
|
137 | - break; |
|
138 | - |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - if (empty($newProps['filters'])) { |
|
143 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
144 | - } |
|
145 | - |
|
146 | - $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
147 | - $noCompsDefined = empty($newProps['filters']['comps']); |
|
148 | - if ($propsOrParamsDefined && $noCompsDefined) { |
|
149 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
150 | - } |
|
151 | - |
|
152 | - if (!isset($newProps['filters']['search-term'])) { |
|
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
154 | - } |
|
155 | - |
|
156 | - if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
157 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - $obj = new self(); |
|
162 | - foreach ($newProps as $key => $value) { |
|
163 | - $obj->$key = $value; |
|
164 | - } |
|
165 | - return $obj; |
|
166 | - } |
|
38 | + /** |
|
39 | + * An array with requested properties. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $properties; |
|
44 | + |
|
45 | + /** |
|
46 | + * List of property/component filters. |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + public $filters; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var int |
|
54 | + */ |
|
55 | + public $limit; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var int |
|
59 | + */ |
|
60 | + public $offset; |
|
61 | + |
|
62 | + /** |
|
63 | + * The deserialize method is called during xml parsing. |
|
64 | + * |
|
65 | + * This method is called statically, this is because in theory this method |
|
66 | + * may be used as a type of constructor, or factory method. |
|
67 | + * |
|
68 | + * Often you want to return an instance of the current class, but you are |
|
69 | + * free to return other data as well. |
|
70 | + * |
|
71 | + * You are responsible for advancing the reader to the next element. Not |
|
72 | + * doing anything will result in a never-ending loop. |
|
73 | + * |
|
74 | + * If you just want to skip parsing for this element altogether, you can |
|
75 | + * just call $reader->next(); |
|
76 | + * |
|
77 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
78 | + * the next element. |
|
79 | + * |
|
80 | + * @param Reader $reader |
|
81 | + * @return mixed |
|
82 | + */ |
|
83 | + public static function xmlDeserialize(Reader $reader) { |
|
84 | + $elems = $reader->parseInnerTree([ |
|
85 | + '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
86 | + '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
87 | + '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
88 | + '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
89 | + '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
90 | + '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
91 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
92 | + ]); |
|
93 | + |
|
94 | + $newProps = [ |
|
95 | + 'filters' => [], |
|
96 | + 'properties' => [], |
|
97 | + 'limit' => null, |
|
98 | + 'offset' => null |
|
99 | + ]; |
|
100 | + |
|
101 | + if (!is_array($elems)) { |
|
102 | + $elems = []; |
|
103 | + } |
|
104 | + |
|
105 | + foreach ($elems as $elem) { |
|
106 | + switch ($elem['name']) { |
|
107 | + case '{DAV:}prop': |
|
108 | + $newProps['properties'] = array_keys($elem['value']); |
|
109 | + break; |
|
110 | + case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
111 | + foreach ($elem['value'] as $subElem) { |
|
112 | + if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
113 | + if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
114 | + $newProps['filters']['comps'] = []; |
|
115 | + } |
|
116 | + $newProps['filters']['comps'][] = $subElem['value']; |
|
117 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
118 | + if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
119 | + $newProps['filters']['props'] = []; |
|
120 | + } |
|
121 | + $newProps['filters']['props'][] = $subElem['value']; |
|
122 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
123 | + if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
124 | + $newProps['filters']['params'] = []; |
|
125 | + } |
|
126 | + $newProps['filters']['params'][] = $subElem['value']; |
|
127 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
128 | + $newProps['filters']['search-term'] = $subElem['value']; |
|
129 | + } |
|
130 | + } |
|
131 | + break; |
|
132 | + case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
133 | + $newProps['limit'] = $elem['value']; |
|
134 | + break; |
|
135 | + case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
136 | + $newProps['offset'] = $elem['value']; |
|
137 | + break; |
|
138 | + |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + if (empty($newProps['filters'])) { |
|
143 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
144 | + } |
|
145 | + |
|
146 | + $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
147 | + $noCompsDefined = empty($newProps['filters']['comps']); |
|
148 | + if ($propsOrParamsDefined && $noCompsDefined) { |
|
149 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
150 | + } |
|
151 | + |
|
152 | + if (!isset($newProps['filters']['search-term'])) { |
|
153 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
154 | + } |
|
155 | + |
|
156 | + if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
157 | + throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + $obj = new self(); |
|
162 | + foreach ($newProps as $key => $value) { |
|
163 | + $obj->$key = $value; |
|
164 | + } |
|
165 | + return $obj; |
|
166 | + } |
|
167 | 167 | } |
@@ -35,55 +35,55 @@ |
||
35 | 35 | * @since 8.0.0 |
36 | 36 | */ |
37 | 37 | interface IEventLogger { |
38 | - /** |
|
39 | - * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | - * |
|
41 | - * @param string $id |
|
42 | - * @param string $description |
|
43 | - * @since 8.0.0 |
|
44 | - */ |
|
45 | - public function start($id, $description); |
|
38 | + /** |
|
39 | + * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | + * |
|
41 | + * @param string $id |
|
42 | + * @param string $description |
|
43 | + * @since 8.0.0 |
|
44 | + */ |
|
45 | + public function start($id, $description); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | - * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | - * be returned with getEvents() method. |
|
51 | - * |
|
52 | - * @param string $id |
|
53 | - * @since 8.0.0 |
|
54 | - */ |
|
55 | - public function end($id); |
|
47 | + /** |
|
48 | + * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | + * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | + * be returned with getEvents() method. |
|
51 | + * |
|
52 | + * @param string $id |
|
53 | + * @since 8.0.0 |
|
54 | + */ |
|
55 | + public function end($id); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | - * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | - * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | - * be returned with getEvents() method. |
|
62 | - * |
|
63 | - * @param string $id |
|
64 | - * @param string $description |
|
65 | - * @param float $start |
|
66 | - * @param float $end |
|
67 | - * @since 8.0.0 |
|
68 | - */ |
|
69 | - public function log($id, $description, $start, $end); |
|
57 | + /** |
|
58 | + * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | + * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | + * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | + * be returned with getEvents() method. |
|
62 | + * |
|
63 | + * @param string $id |
|
64 | + * @param string $description |
|
65 | + * @param float $start |
|
66 | + * @param float $end |
|
67 | + * @since 8.0.0 |
|
68 | + */ |
|
69 | + public function log($id, $description, $start, $end); |
|
70 | 70 | |
71 | - /** |
|
72 | - * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | - * start()/end() or log() methods |
|
74 | - * |
|
75 | - * @return \OCP\Diagnostics\IEvent[] |
|
76 | - * @since 8.0.0 |
|
77 | - */ |
|
78 | - public function getEvents(); |
|
71 | + /** |
|
72 | + * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | + * start()/end() or log() methods |
|
74 | + * |
|
75 | + * @return \OCP\Diagnostics\IEvent[] |
|
76 | + * @since 8.0.0 |
|
77 | + */ |
|
78 | + public function getEvents(); |
|
79 | 79 | |
80 | - /** |
|
81 | - * Activate the module for the duration of the request. Deactivated module |
|
82 | - * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | - * Only activated module should create and store objects to be |
|
84 | - * returned with getEvents() call. |
|
85 | - * |
|
86 | - * @since 12.0.0 |
|
87 | - */ |
|
88 | - public function activate(); |
|
80 | + /** |
|
81 | + * Activate the module for the duration of the request. Deactivated module |
|
82 | + * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | + * Only activated module should create and store objects to be |
|
84 | + * returned with getEvents() call. |
|
85 | + * |
|
86 | + * @since 12.0.0 |
|
87 | + */ |
|
88 | + public function activate(); |
|
89 | 89 | } |
@@ -30,38 +30,38 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IQuery { |
33 | - /** |
|
34 | - * @return string |
|
35 | - * @since 8.0.0 |
|
36 | - */ |
|
37 | - public function getSql(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + * @since 8.0.0 |
|
36 | + */ |
|
37 | + public function getSql(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since 8.0.0 |
|
42 | - */ |
|
43 | - public function getParams(); |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since 8.0.0 |
|
42 | + */ |
|
43 | + public function getParams(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return float |
|
47 | - * @since 8.0.0 |
|
48 | - */ |
|
49 | - public function getDuration(); |
|
45 | + /** |
|
46 | + * @return float |
|
47 | + * @since 8.0.0 |
|
48 | + */ |
|
49 | + public function getDuration(); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return float |
|
53 | - * @since 11.0.0 |
|
54 | - */ |
|
55 | - public function getStartTime(); |
|
51 | + /** |
|
52 | + * @return float |
|
53 | + * @since 11.0.0 |
|
54 | + */ |
|
55 | + public function getStartTime(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return array |
|
59 | - * @since 11.0.0 |
|
60 | - */ |
|
61 | - public function getStacktrace(); |
|
62 | - /** |
|
63 | - * @return array |
|
64 | - * @since 12.0.0 |
|
65 | - */ |
|
66 | - public function getStart(); |
|
57 | + /** |
|
58 | + * @return array |
|
59 | + * @since 11.0.0 |
|
60 | + */ |
|
61 | + public function getStacktrace(); |
|
62 | + /** |
|
63 | + * @return array |
|
64 | + * @since 12.0.0 |
|
65 | + */ |
|
66 | + public function getStart(); |
|
67 | 67 | } |
@@ -26,65 +26,65 @@ |
||
26 | 26 | use OCP\Diagnostics\IQuery; |
27 | 27 | |
28 | 28 | class Query implements IQuery { |
29 | - private $sql; |
|
29 | + private $sql; |
|
30 | 30 | |
31 | - private $params; |
|
31 | + private $params; |
|
32 | 32 | |
33 | - private $start; |
|
33 | + private $start; |
|
34 | 34 | |
35 | - private $end; |
|
35 | + private $end; |
|
36 | 36 | |
37 | - private $stack; |
|
37 | + private $stack; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $sql |
|
41 | - * @param array $params |
|
42 | - * @param int $start |
|
43 | - */ |
|
44 | - public function __construct($sql, $params, $start, array $stack) { |
|
45 | - $this->sql = $sql; |
|
46 | - $this->params = $params; |
|
47 | - $this->start = $start; |
|
48 | - $this->stack = $stack; |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param string $sql |
|
41 | + * @param array $params |
|
42 | + * @param int $start |
|
43 | + */ |
|
44 | + public function __construct($sql, $params, $start, array $stack) { |
|
45 | + $this->sql = $sql; |
|
46 | + $this->params = $params; |
|
47 | + $this->start = $start; |
|
48 | + $this->stack = $stack; |
|
49 | + } |
|
50 | 50 | |
51 | - public function end($time) { |
|
52 | - $this->end = $time; |
|
53 | - } |
|
51 | + public function end($time) { |
|
52 | + $this->end = $time; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function getParams() { |
|
59 | - return $this->params; |
|
60 | - } |
|
55 | + /** |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function getParams() { |
|
59 | + return $this->params; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function getSql() { |
|
66 | - return $this->sql; |
|
67 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function getSql() { |
|
66 | + return $this->sql; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return float |
|
71 | - */ |
|
72 | - public function getStart() { |
|
73 | - return $this->start; |
|
74 | - } |
|
69 | + /** |
|
70 | + * @return float |
|
71 | + */ |
|
72 | + public function getStart() { |
|
73 | + return $this->start; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return float |
|
78 | - */ |
|
79 | - public function getDuration() { |
|
80 | - return $this->end - $this->start; |
|
81 | - } |
|
76 | + /** |
|
77 | + * @return float |
|
78 | + */ |
|
79 | + public function getDuration() { |
|
80 | + return $this->end - $this->start; |
|
81 | + } |
|
82 | 82 | |
83 | - public function getStartTime() { |
|
84 | - return $this->start; |
|
85 | - } |
|
83 | + public function getStartTime() { |
|
84 | + return $this->start; |
|
85 | + } |
|
86 | 86 | |
87 | - public function getStacktrace() { |
|
88 | - return $this->stack; |
|
89 | - } |
|
87 | + public function getStacktrace() { |
|
88 | + return $this->stack; |
|
89 | + } |
|
90 | 90 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $json = file_get_contents('php://stdin'); |
113 | 113 | } else { |
114 | 114 | if (!file_exists($path)) { |
115 | - $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
115 | + $output->writeln('<error>File not found: '.$path.'</error>'); |
|
116 | 116 | return 1; |
117 | 117 | } |
118 | 118 | $json = file_get_contents($path); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
165 | 165 | $existingMount->getBackendOptions() === $mount->getBackendOptions() |
166 | 166 | ) { |
167 | - $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
167 | + $output->writeln("<error>Duplicate mount (".$mount->getMountPoint().")</error>"); |
|
168 | 168 | return 1; |
169 | 169 | } |
170 | 170 | } |
@@ -40,168 +40,168 @@ |
||
40 | 40 | use Symfony\Component\Console\Output\OutputInterface; |
41 | 41 | |
42 | 42 | class Import extends Base { |
43 | - private GlobalStoragesService $globalService; |
|
44 | - private UserStoragesService $userService; |
|
45 | - private IUserSession $userSession; |
|
46 | - private IUserManager $userManager; |
|
47 | - private ImportLegacyStoragesService $importLegacyStorageService; |
|
48 | - private BackendService $backendService; |
|
43 | + private GlobalStoragesService $globalService; |
|
44 | + private UserStoragesService $userService; |
|
45 | + private IUserSession $userSession; |
|
46 | + private IUserManager $userManager; |
|
47 | + private ImportLegacyStoragesService $importLegacyStorageService; |
|
48 | + private BackendService $backendService; |
|
49 | 49 | |
50 | - public function __construct(GlobalStoragesService $globalService, |
|
51 | - UserStoragesService $userService, |
|
52 | - IUserSession $userSession, |
|
53 | - IUserManager $userManager, |
|
54 | - ImportLegacyStoragesService $importLegacyStorageService, |
|
55 | - BackendService $backendService |
|
56 | - ) { |
|
57 | - parent::__construct(); |
|
58 | - $this->globalService = $globalService; |
|
59 | - $this->userService = $userService; |
|
60 | - $this->userSession = $userSession; |
|
61 | - $this->userManager = $userManager; |
|
62 | - $this->importLegacyStorageService = $importLegacyStorageService; |
|
63 | - $this->backendService = $backendService; |
|
64 | - } |
|
50 | + public function __construct(GlobalStoragesService $globalService, |
|
51 | + UserStoragesService $userService, |
|
52 | + IUserSession $userSession, |
|
53 | + IUserManager $userManager, |
|
54 | + ImportLegacyStoragesService $importLegacyStorageService, |
|
55 | + BackendService $backendService |
|
56 | + ) { |
|
57 | + parent::__construct(); |
|
58 | + $this->globalService = $globalService; |
|
59 | + $this->userService = $userService; |
|
60 | + $this->userSession = $userSession; |
|
61 | + $this->userManager = $userManager; |
|
62 | + $this->importLegacyStorageService = $importLegacyStorageService; |
|
63 | + $this->backendService = $backendService; |
|
64 | + } |
|
65 | 65 | |
66 | - protected function configure(): void { |
|
67 | - $this |
|
68 | - ->setName('files_external:import') |
|
69 | - ->setDescription('Import mount configurations') |
|
70 | - ->addOption( |
|
71 | - 'user', |
|
72 | - '', |
|
73 | - InputOption::VALUE_OPTIONAL, |
|
74 | - 'user to add the mount configurations for, if not set the mount will be added as system mount' |
|
75 | - ) |
|
76 | - ->addArgument( |
|
77 | - 'path', |
|
78 | - InputArgument::REQUIRED, |
|
79 | - 'path to a json file containing the mounts to import, use "-" to read from stdin' |
|
80 | - ) |
|
81 | - ->addOption( |
|
82 | - 'dry', |
|
83 | - '', |
|
84 | - InputOption::VALUE_NONE, |
|
85 | - 'Don\'t save the imported mounts, only list the new mounts' |
|
86 | - ); |
|
87 | - parent::configure(); |
|
88 | - } |
|
66 | + protected function configure(): void { |
|
67 | + $this |
|
68 | + ->setName('files_external:import') |
|
69 | + ->setDescription('Import mount configurations') |
|
70 | + ->addOption( |
|
71 | + 'user', |
|
72 | + '', |
|
73 | + InputOption::VALUE_OPTIONAL, |
|
74 | + 'user to add the mount configurations for, if not set the mount will be added as system mount' |
|
75 | + ) |
|
76 | + ->addArgument( |
|
77 | + 'path', |
|
78 | + InputArgument::REQUIRED, |
|
79 | + 'path to a json file containing the mounts to import, use "-" to read from stdin' |
|
80 | + ) |
|
81 | + ->addOption( |
|
82 | + 'dry', |
|
83 | + '', |
|
84 | + InputOption::VALUE_NONE, |
|
85 | + 'Don\'t save the imported mounts, only list the new mounts' |
|
86 | + ); |
|
87 | + parent::configure(); |
|
88 | + } |
|
89 | 89 | |
90 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
91 | - $user = (string) $input->getOption('user'); |
|
92 | - $path = $input->getArgument('path'); |
|
93 | - if ($path === '-') { |
|
94 | - $json = file_get_contents('php://stdin'); |
|
95 | - } else { |
|
96 | - if (!file_exists($path)) { |
|
97 | - $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
98 | - return 1; |
|
99 | - } |
|
100 | - $json = file_get_contents($path); |
|
101 | - } |
|
102 | - if (!is_string($json) || strlen($json) < 2) { |
|
103 | - $output->writeln('<error>Error while reading json</error>'); |
|
104 | - return 1; |
|
105 | - } |
|
106 | - $data = json_decode($json, true); |
|
107 | - if (!is_array($data)) { |
|
108 | - $output->writeln('<error>Error while parsing json</error>'); |
|
109 | - return 1; |
|
110 | - } |
|
90 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
91 | + $user = (string) $input->getOption('user'); |
|
92 | + $path = $input->getArgument('path'); |
|
93 | + if ($path === '-') { |
|
94 | + $json = file_get_contents('php://stdin'); |
|
95 | + } else { |
|
96 | + if (!file_exists($path)) { |
|
97 | + $output->writeln('<error>File not found: ' . $path . '</error>'); |
|
98 | + return 1; |
|
99 | + } |
|
100 | + $json = file_get_contents($path); |
|
101 | + } |
|
102 | + if (!is_string($json) || strlen($json) < 2) { |
|
103 | + $output->writeln('<error>Error while reading json</error>'); |
|
104 | + return 1; |
|
105 | + } |
|
106 | + $data = json_decode($json, true); |
|
107 | + if (!is_array($data)) { |
|
108 | + $output->writeln('<error>Error while parsing json</error>'); |
|
109 | + return 1; |
|
110 | + } |
|
111 | 111 | |
112 | - $isLegacy = isset($data['user']) || isset($data['group']); |
|
113 | - if ($isLegacy) { |
|
114 | - $this->importLegacyStorageService->setData($data); |
|
115 | - $mounts = $this->importLegacyStorageService->getAllStorages(); |
|
116 | - foreach ($mounts as $mount) { |
|
117 | - if ($mount->getBackendOption('password') === false) { |
|
118 | - $output->writeln('<error>Failed to decrypt password</error>'); |
|
119 | - return 1; |
|
120 | - } |
|
121 | - } |
|
122 | - } else { |
|
123 | - if (!isset($data[0])) { //normalize to an array of mounts |
|
124 | - $data = [$data]; |
|
125 | - } |
|
126 | - $mounts = array_map([$this, 'parseData'], $data); |
|
127 | - } |
|
112 | + $isLegacy = isset($data['user']) || isset($data['group']); |
|
113 | + if ($isLegacy) { |
|
114 | + $this->importLegacyStorageService->setData($data); |
|
115 | + $mounts = $this->importLegacyStorageService->getAllStorages(); |
|
116 | + foreach ($mounts as $mount) { |
|
117 | + if ($mount->getBackendOption('password') === false) { |
|
118 | + $output->writeln('<error>Failed to decrypt password</error>'); |
|
119 | + return 1; |
|
120 | + } |
|
121 | + } |
|
122 | + } else { |
|
123 | + if (!isset($data[0])) { //normalize to an array of mounts |
|
124 | + $data = [$data]; |
|
125 | + } |
|
126 | + $mounts = array_map([$this, 'parseData'], $data); |
|
127 | + } |
|
128 | 128 | |
129 | - if ($user) { |
|
130 | - // ensure applicables are correct for personal mounts |
|
131 | - foreach ($mounts as $mount) { |
|
132 | - $mount->setApplicableGroups([]); |
|
133 | - $mount->setApplicableUsers([$user]); |
|
134 | - } |
|
135 | - } |
|
129 | + if ($user) { |
|
130 | + // ensure applicables are correct for personal mounts |
|
131 | + foreach ($mounts as $mount) { |
|
132 | + $mount->setApplicableGroups([]); |
|
133 | + $mount->setApplicableUsers([$user]); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - $storageService = $this->getStorageService($user); |
|
137 | + $storageService = $this->getStorageService($user); |
|
138 | 138 | |
139 | - $existingMounts = $storageService->getAllStorages(); |
|
139 | + $existingMounts = $storageService->getAllStorages(); |
|
140 | 140 | |
141 | - foreach ($mounts as $mount) { |
|
142 | - foreach ($existingMounts as $existingMount) { |
|
143 | - if ( |
|
144 | - $existingMount->getMountPoint() === $mount->getMountPoint() && |
|
145 | - $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && |
|
146 | - $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
|
147 | - $existingMount->getBackendOptions() === $mount->getBackendOptions() |
|
148 | - ) { |
|
149 | - $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
150 | - return 1; |
|
151 | - } |
|
152 | - } |
|
153 | - } |
|
141 | + foreach ($mounts as $mount) { |
|
142 | + foreach ($existingMounts as $existingMount) { |
|
143 | + if ( |
|
144 | + $existingMount->getMountPoint() === $mount->getMountPoint() && |
|
145 | + $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && |
|
146 | + $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && |
|
147 | + $existingMount->getBackendOptions() === $mount->getBackendOptions() |
|
148 | + ) { |
|
149 | + $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); |
|
150 | + return 1; |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - if ($input->getOption('dry')) { |
|
156 | - if (count($mounts) === 0) { |
|
157 | - $output->writeln('<error>No mounts to be imported</error>'); |
|
158 | - return 1; |
|
159 | - } |
|
160 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
161 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
162 | - $listInput->setOption('output', $input->getOption('output')); |
|
163 | - $listInput->setOption('show-password', true); |
|
164 | - $listCommand->listMounts($user, $mounts, $listInput, $output); |
|
165 | - } else { |
|
166 | - foreach ($mounts as $mount) { |
|
167 | - $storageService->addStorage($mount); |
|
168 | - } |
|
169 | - } |
|
170 | - return 0; |
|
171 | - } |
|
155 | + if ($input->getOption('dry')) { |
|
156 | + if (count($mounts) === 0) { |
|
157 | + $output->writeln('<error>No mounts to be imported</error>'); |
|
158 | + return 1; |
|
159 | + } |
|
160 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
161 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
162 | + $listInput->setOption('output', $input->getOption('output')); |
|
163 | + $listInput->setOption('show-password', true); |
|
164 | + $listCommand->listMounts($user, $mounts, $listInput, $output); |
|
165 | + } else { |
|
166 | + foreach ($mounts as $mount) { |
|
167 | + $storageService->addStorage($mount); |
|
168 | + } |
|
169 | + } |
|
170 | + return 0; |
|
171 | + } |
|
172 | 172 | |
173 | - private function parseData(array $data): StorageConfig { |
|
174 | - $mount = new StorageConfig($data['mount_id']); |
|
175 | - $mount->setMountPoint($data['mount_point']); |
|
176 | - $mount->setBackend($this->getBackendByClass($data['storage'])); |
|
177 | - $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']); |
|
178 | - $mount->setAuthMechanism($authBackend); |
|
179 | - $mount->setBackendOptions($data['configuration']); |
|
180 | - $mount->setMountOptions($data['options']); |
|
181 | - $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []); |
|
182 | - $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []); |
|
183 | - return $mount; |
|
184 | - } |
|
173 | + private function parseData(array $data): StorageConfig { |
|
174 | + $mount = new StorageConfig($data['mount_id']); |
|
175 | + $mount->setMountPoint($data['mount_point']); |
|
176 | + $mount->setBackend($this->getBackendByClass($data['storage'])); |
|
177 | + $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']); |
|
178 | + $mount->setAuthMechanism($authBackend); |
|
179 | + $mount->setBackendOptions($data['configuration']); |
|
180 | + $mount->setMountOptions($data['options']); |
|
181 | + $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []); |
|
182 | + $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []); |
|
183 | + return $mount; |
|
184 | + } |
|
185 | 185 | |
186 | - private function getBackendByClass(string $className) { |
|
187 | - $backends = $this->backendService->getBackends(); |
|
188 | - foreach ($backends as $backend) { |
|
189 | - if ($backend->getStorageClass() === $className) { |
|
190 | - return $backend; |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
186 | + private function getBackendByClass(string $className) { |
|
187 | + $backends = $this->backendService->getBackends(); |
|
188 | + foreach ($backends as $backend) { |
|
189 | + if ($backend->getStorageClass() === $className) { |
|
190 | + return $backend; |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - protected function getStorageService($userId) { |
|
196 | - if (!empty($userId)) { |
|
197 | - $user = $this->userManager->get($userId); |
|
198 | - if (is_null($user)) { |
|
199 | - throw new NoUserException("user $userId not found"); |
|
200 | - } |
|
201 | - $this->userSession->setUser($user); |
|
202 | - return $this->userService; |
|
203 | - } else { |
|
204 | - return $this->globalService; |
|
205 | - } |
|
206 | - } |
|
195 | + protected function getStorageService($userId) { |
|
196 | + if (!empty($userId)) { |
|
197 | + $user = $this->userManager->get($userId); |
|
198 | + if (is_null($user)) { |
|
199 | + throw new NoUserException("user $userId not found"); |
|
200 | + } |
|
201 | + $this->userSession->setUser($user); |
|
202 | + return $this->userService; |
|
203 | + } else { |
|
204 | + return $this->globalService; |
|
205 | + } |
|
206 | + } |
|
207 | 207 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OC\Files\Cache\Wrapper; |
25 | 25 | |
26 | 26 | class CachePermissionsMask extends CacheWrapper { |
27 | - /** |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $mask; |
|
27 | + /** |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $mask; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param \OCP\Files\Cache\ICache $cache |
|
34 | - * @param int $mask |
|
35 | - */ |
|
36 | - public function __construct($cache, $mask) { |
|
37 | - parent::__construct($cache); |
|
38 | - $this->mask = $mask; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param \OCP\Files\Cache\ICache $cache |
|
34 | + * @param int $mask |
|
35 | + */ |
|
36 | + public function __construct($cache, $mask) { |
|
37 | + parent::__construct($cache); |
|
38 | + $this->mask = $mask; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function formatCacheEntry($entry) { |
|
42 | - if (isset($entry['permissions'])) { |
|
43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
44 | - $entry['permissions'] &= $this->mask; |
|
45 | - } |
|
46 | - return $entry; |
|
47 | - } |
|
41 | + protected function formatCacheEntry($entry) { |
|
42 | + if (isset($entry['permissions'])) { |
|
43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
44 | + $entry['permissions'] &= $this->mask; |
|
45 | + } |
|
46 | + return $entry; |
|
47 | + } |
|
48 | 48 | } |
@@ -27,45 +27,45 @@ |
||
27 | 27 | |
28 | 28 | class Config implements \OCP\GlobalScale\IConfig { |
29 | 29 | |
30 | - /** @var IConfig */ |
|
31 | - private $config; |
|
30 | + /** @var IConfig */ |
|
31 | + private $config; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Config constructor. |
|
35 | - * |
|
36 | - * @param IConfig $config |
|
37 | - */ |
|
38 | - public function __construct(IConfig $config) { |
|
39 | - $this->config = $config; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Config constructor. |
|
35 | + * |
|
36 | + * @param IConfig $config |
|
37 | + */ |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + $this->config = $config; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * check if global scale is enabled |
|
44 | - * |
|
45 | - * @since 12.0.1 |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function isGlobalScaleEnabled() { |
|
49 | - $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | - return $enabled !== false; |
|
51 | - } |
|
42 | + /** |
|
43 | + * check if global scale is enabled |
|
44 | + * |
|
45 | + * @since 12.0.1 |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function isGlobalScaleEnabled() { |
|
49 | + $enabled = $this->config->getSystemValue('gs.enabled', false); |
|
50 | + return $enabled !== false; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if federation should only be used internally in a global scale setup |
|
55 | - * |
|
56 | - * @since 12.0.1 |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function onlyInternalFederation() { |
|
60 | - // if global scale is disabled federation works always globally |
|
61 | - $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | - if ($gsEnabled === false) { |
|
63 | - return false; |
|
64 | - } |
|
53 | + /** |
|
54 | + * check if federation should only be used internally in a global scale setup |
|
55 | + * |
|
56 | + * @since 12.0.1 |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function onlyInternalFederation() { |
|
60 | + // if global scale is disabled federation works always globally |
|
61 | + $gsEnabled = $this->isGlobalScaleEnabled(); |
|
62 | + if ($gsEnabled === false) { |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | |
66 | - $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
66 | + $enabled = $this->config->getSystemValue('gs.federation', 'internal'); |
|
67 | 67 | |
68 | - return $enabled === 'internal'; |
|
69 | - } |
|
68 | + return $enabled === 'internal'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -32,20 +32,20 @@ |
||
32 | 32 | */ |
33 | 33 | interface IConfig { |
34 | 34 | |
35 | - /** |
|
36 | - * check if global scale is enabled |
|
37 | - * |
|
38 | - * @since 12.0.1 |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - public function isGlobalScaleEnabled(); |
|
35 | + /** |
|
36 | + * check if global scale is enabled |
|
37 | + * |
|
38 | + * @since 12.0.1 |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + public function isGlobalScaleEnabled(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * check if federation should only be used internally in a global scale setup |
|
45 | - * |
|
46 | - * @since 12.0.1 |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public function onlyInternalFederation(); |
|
43 | + /** |
|
44 | + * check if federation should only be used internally in a global scale setup |
|
45 | + * |
|
46 | + * @since 12.0.1 |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public function onlyInternalFederation(); |
|
50 | 50 | |
51 | 51 | } |