@@ -46,290 +46,290 @@ |
||
46 | 46 | */ |
47 | 47 | |
48 | 48 | class NavigationManager implements INavigationManager { |
49 | - protected $entries = []; |
|
50 | - protected $closureEntries = []; |
|
51 | - protected $activeEntry; |
|
52 | - /** @var bool */ |
|
53 | - protected $init = false; |
|
54 | - /** @var IAppManager|AppManager */ |
|
55 | - protected $appManager; |
|
56 | - /** @var IURLGenerator */ |
|
57 | - private $urlGenerator; |
|
58 | - /** @var IFactory */ |
|
59 | - private $l10nFac; |
|
60 | - /** @var IUserSession */ |
|
61 | - private $userSession; |
|
62 | - /** @var IGroupManager|Manager */ |
|
63 | - private $groupManager; |
|
64 | - /** @var IConfig */ |
|
65 | - private $config; |
|
49 | + protected $entries = []; |
|
50 | + protected $closureEntries = []; |
|
51 | + protected $activeEntry; |
|
52 | + /** @var bool */ |
|
53 | + protected $init = false; |
|
54 | + /** @var IAppManager|AppManager */ |
|
55 | + protected $appManager; |
|
56 | + /** @var IURLGenerator */ |
|
57 | + private $urlGenerator; |
|
58 | + /** @var IFactory */ |
|
59 | + private $l10nFac; |
|
60 | + /** @var IUserSession */ |
|
61 | + private $userSession; |
|
62 | + /** @var IGroupManager|Manager */ |
|
63 | + private $groupManager; |
|
64 | + /** @var IConfig */ |
|
65 | + private $config; |
|
66 | 66 | |
67 | - public function __construct(IAppManager $appManager, |
|
68 | - IURLGenerator $urlGenerator, |
|
69 | - IFactory $l10nFac, |
|
70 | - IUserSession $userSession, |
|
71 | - IGroupManager $groupManager, |
|
72 | - IConfig $config) { |
|
73 | - $this->appManager = $appManager; |
|
74 | - $this->urlGenerator = $urlGenerator; |
|
75 | - $this->l10nFac = $l10nFac; |
|
76 | - $this->userSession = $userSession; |
|
77 | - $this->groupManager = $groupManager; |
|
78 | - $this->config = $config; |
|
79 | - } |
|
67 | + public function __construct(IAppManager $appManager, |
|
68 | + IURLGenerator $urlGenerator, |
|
69 | + IFactory $l10nFac, |
|
70 | + IUserSession $userSession, |
|
71 | + IGroupManager $groupManager, |
|
72 | + IConfig $config) { |
|
73 | + $this->appManager = $appManager; |
|
74 | + $this->urlGenerator = $urlGenerator; |
|
75 | + $this->l10nFac = $l10nFac; |
|
76 | + $this->userSession = $userSession; |
|
77 | + $this->groupManager = $groupManager; |
|
78 | + $this->config = $config; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Creates a new navigation entry |
|
83 | - * |
|
84 | - * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
85 | - * The use of a closure is preferred, because it will avoid |
|
86 | - * loading the routing of your app, unless required. |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function add($entry) { |
|
90 | - if ($entry instanceof \Closure) { |
|
91 | - $this->closureEntries[] = $entry; |
|
92 | - return; |
|
93 | - } |
|
81 | + /** |
|
82 | + * Creates a new navigation entry |
|
83 | + * |
|
84 | + * @param array|\Closure $entry Array containing: id, name, order, icon and href key |
|
85 | + * The use of a closure is preferred, because it will avoid |
|
86 | + * loading the routing of your app, unless required. |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function add($entry) { |
|
90 | + if ($entry instanceof \Closure) { |
|
91 | + $this->closureEntries[] = $entry; |
|
92 | + return; |
|
93 | + } |
|
94 | 94 | |
95 | - $entry['active'] = false; |
|
96 | - if(!isset($entry['icon'])) { |
|
97 | - $entry['icon'] = ''; |
|
98 | - } |
|
99 | - if(!isset($entry['classes'])) { |
|
100 | - $entry['classes'] = ''; |
|
101 | - } |
|
102 | - if(!isset($entry['type'])) { |
|
103 | - $entry['type'] = 'link'; |
|
104 | - } |
|
105 | - $this->entries[$entry['id']] = $entry; |
|
106 | - } |
|
95 | + $entry['active'] = false; |
|
96 | + if(!isset($entry['icon'])) { |
|
97 | + $entry['icon'] = ''; |
|
98 | + } |
|
99 | + if(!isset($entry['classes'])) { |
|
100 | + $entry['classes'] = ''; |
|
101 | + } |
|
102 | + if(!isset($entry['type'])) { |
|
103 | + $entry['type'] = 'link'; |
|
104 | + } |
|
105 | + $this->entries[$entry['id']] = $entry; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Get a list of navigation entries |
|
110 | - * |
|
111 | - * @param string $type type of the navigation entries |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public function getAll(string $type = 'link'): array { |
|
115 | - $this->init(); |
|
116 | - foreach ($this->closureEntries as $c) { |
|
117 | - $this->add($c()); |
|
118 | - } |
|
119 | - $this->closureEntries = []; |
|
108 | + /** |
|
109 | + * Get a list of navigation entries |
|
110 | + * |
|
111 | + * @param string $type type of the navigation entries |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public function getAll(string $type = 'link'): array { |
|
115 | + $this->init(); |
|
116 | + foreach ($this->closureEntries as $c) { |
|
117 | + $this->add($c()); |
|
118 | + } |
|
119 | + $this->closureEntries = []; |
|
120 | 120 | |
121 | - $result = $this->entries; |
|
122 | - if ($type !== 'all') { |
|
123 | - $result = array_filter($this->entries, function ($entry) use ($type) { |
|
124 | - return $entry['type'] === $type; |
|
125 | - }); |
|
126 | - } |
|
121 | + $result = $this->entries; |
|
122 | + if ($type !== 'all') { |
|
123 | + $result = array_filter($this->entries, function ($entry) use ($type) { |
|
124 | + return $entry['type'] === $type; |
|
125 | + }); |
|
126 | + } |
|
127 | 127 | |
128 | - return $this->proceedNavigation($result); |
|
129 | - } |
|
128 | + return $this->proceedNavigation($result); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Sort navigation entries by order, name and set active flag |
|
133 | - * |
|
134 | - * @param array $list |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - private function proceedNavigation(array $list): array { |
|
138 | - uasort($list, function ($a, $b) { |
|
139 | - if (isset($a['order']) && isset($b['order'])) { |
|
140 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
141 | - } else if (isset($a['order']) || isset($b['order'])) { |
|
142 | - return isset($a['order']) ? -1 : 1; |
|
143 | - } else { |
|
144 | - return ($a['name'] < $b['name']) ? -1 : 1; |
|
145 | - } |
|
146 | - }); |
|
131 | + /** |
|
132 | + * Sort navigation entries by order, name and set active flag |
|
133 | + * |
|
134 | + * @param array $list |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + private function proceedNavigation(array $list): array { |
|
138 | + uasort($list, function ($a, $b) { |
|
139 | + if (isset($a['order']) && isset($b['order'])) { |
|
140 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
141 | + } else if (isset($a['order']) || isset($b['order'])) { |
|
142 | + return isset($a['order']) ? -1 : 1; |
|
143 | + } else { |
|
144 | + return ($a['name'] < $b['name']) ? -1 : 1; |
|
145 | + } |
|
146 | + }); |
|
147 | 147 | |
148 | - $activeApp = $this->getActiveEntry(); |
|
149 | - if ($activeApp !== null) { |
|
150 | - foreach ($list as $index => &$navEntry) { |
|
151 | - if ($navEntry['id'] == $activeApp) { |
|
152 | - $navEntry['active'] = true; |
|
153 | - } else { |
|
154 | - $navEntry['active'] = false; |
|
155 | - } |
|
156 | - } |
|
157 | - unset($navEntry); |
|
158 | - } |
|
148 | + $activeApp = $this->getActiveEntry(); |
|
149 | + if ($activeApp !== null) { |
|
150 | + foreach ($list as $index => &$navEntry) { |
|
151 | + if ($navEntry['id'] == $activeApp) { |
|
152 | + $navEntry['active'] = true; |
|
153 | + } else { |
|
154 | + $navEntry['active'] = false; |
|
155 | + } |
|
156 | + } |
|
157 | + unset($navEntry); |
|
158 | + } |
|
159 | 159 | |
160 | - return $list; |
|
161 | - } |
|
160 | + return $list; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | - /** |
|
165 | - * removes all the entries |
|
166 | - */ |
|
167 | - public function clear($loadDefaultLinks = true) { |
|
168 | - $this->entries = []; |
|
169 | - $this->closureEntries = []; |
|
170 | - $this->init = !$loadDefaultLinks; |
|
171 | - } |
|
164 | + /** |
|
165 | + * removes all the entries |
|
166 | + */ |
|
167 | + public function clear($loadDefaultLinks = true) { |
|
168 | + $this->entries = []; |
|
169 | + $this->closureEntries = []; |
|
170 | + $this->init = !$loadDefaultLinks; |
|
171 | + } |
|
172 | 172 | |
173 | - /** |
|
174 | - * Sets the current navigation entry of the currently running app |
|
175 | - * @param string $id of the app entry to activate (from added $entry) |
|
176 | - */ |
|
177 | - public function setActiveEntry($id) { |
|
178 | - $this->activeEntry = $id; |
|
179 | - } |
|
173 | + /** |
|
174 | + * Sets the current navigation entry of the currently running app |
|
175 | + * @param string $id of the app entry to activate (from added $entry) |
|
176 | + */ |
|
177 | + public function setActiveEntry($id) { |
|
178 | + $this->activeEntry = $id; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * gets the active Menu entry |
|
183 | - * @return string id or empty string |
|
184 | - * |
|
185 | - * This function returns the id of the active navigation entry (set by |
|
186 | - * setActiveEntry |
|
187 | - */ |
|
188 | - public function getActiveEntry() { |
|
189 | - return $this->activeEntry; |
|
190 | - } |
|
181 | + /** |
|
182 | + * gets the active Menu entry |
|
183 | + * @return string id or empty string |
|
184 | + * |
|
185 | + * This function returns the id of the active navigation entry (set by |
|
186 | + * setActiveEntry |
|
187 | + */ |
|
188 | + public function getActiveEntry() { |
|
189 | + return $this->activeEntry; |
|
190 | + } |
|
191 | 191 | |
192 | - private function init() { |
|
193 | - if ($this->init) { |
|
194 | - return; |
|
195 | - } |
|
196 | - $this->init = true; |
|
192 | + private function init() { |
|
193 | + if ($this->init) { |
|
194 | + return; |
|
195 | + } |
|
196 | + $this->init = true; |
|
197 | 197 | |
198 | - $l = $this->l10nFac->get('lib'); |
|
199 | - if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
200 | - $this->add([ |
|
201 | - 'type' => 'settings', |
|
202 | - 'id' => 'help', |
|
203 | - 'order' => 5, |
|
204 | - 'href' => $this->urlGenerator->linkToRoute('settings.Help.help'), |
|
205 | - 'name' => $l->t('Help'), |
|
206 | - 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
207 | - ]); |
|
208 | - } |
|
198 | + $l = $this->l10nFac->get('lib'); |
|
199 | + if ($this->config->getSystemValue('knowledgebaseenabled', true)) { |
|
200 | + $this->add([ |
|
201 | + 'type' => 'settings', |
|
202 | + 'id' => 'help', |
|
203 | + 'order' => 5, |
|
204 | + 'href' => $this->urlGenerator->linkToRoute('settings.Help.help'), |
|
205 | + 'name' => $l->t('Help'), |
|
206 | + 'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'), |
|
207 | + ]); |
|
208 | + } |
|
209 | 209 | |
210 | - if ($this->userSession->isLoggedIn()) { |
|
211 | - if ($this->isAdmin()) { |
|
212 | - // App management |
|
213 | - $this->add([ |
|
214 | - 'type' => 'settings', |
|
215 | - 'id' => 'core_apps', |
|
216 | - 'order' => 3, |
|
217 | - 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
218 | - 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
219 | - 'name' => $l->t('Apps'), |
|
220 | - ]); |
|
221 | - } |
|
210 | + if ($this->userSession->isLoggedIn()) { |
|
211 | + if ($this->isAdmin()) { |
|
212 | + // App management |
|
213 | + $this->add([ |
|
214 | + 'type' => 'settings', |
|
215 | + 'id' => 'core_apps', |
|
216 | + 'order' => 3, |
|
217 | + 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), |
|
218 | + 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), |
|
219 | + 'name' => $l->t('Apps'), |
|
220 | + ]); |
|
221 | + } |
|
222 | 222 | |
223 | - // Personal and (if applicable) admin settings |
|
224 | - $this->add([ |
|
225 | - 'type' => 'settings', |
|
226 | - 'id' => 'settings', |
|
227 | - 'order' => 1, |
|
228 | - 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
229 | - 'name' => $l->t('Settings'), |
|
230 | - 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
231 | - ]); |
|
223 | + // Personal and (if applicable) admin settings |
|
224 | + $this->add([ |
|
225 | + 'type' => 'settings', |
|
226 | + 'id' => 'settings', |
|
227 | + 'order' => 1, |
|
228 | + 'href' => $this->urlGenerator->linkToRoute('settings.PersonalSettings.index'), |
|
229 | + 'name' => $l->t('Settings'), |
|
230 | + 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), |
|
231 | + ]); |
|
232 | 232 | |
233 | - $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator); |
|
234 | - if($logoutUrl !== '') { |
|
235 | - // Logout |
|
236 | - $this->add([ |
|
237 | - 'type' => 'settings', |
|
238 | - 'id' => 'logout', |
|
239 | - 'order' => 99999, |
|
240 | - 'href' => $logoutUrl, |
|
241 | - 'name' => $l->t('Log out'), |
|
242 | - 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
243 | - ]); |
|
244 | - } |
|
233 | + $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator); |
|
234 | + if($logoutUrl !== '') { |
|
235 | + // Logout |
|
236 | + $this->add([ |
|
237 | + 'type' => 'settings', |
|
238 | + 'id' => 'logout', |
|
239 | + 'order' => 99999, |
|
240 | + 'href' => $logoutUrl, |
|
241 | + 'name' => $l->t('Log out'), |
|
242 | + 'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'), |
|
243 | + ]); |
|
244 | + } |
|
245 | 245 | |
246 | - if ($this->isSubadmin()) { |
|
247 | - // User management |
|
248 | - $this->add([ |
|
249 | - 'type' => 'settings', |
|
250 | - 'id' => 'core_users', |
|
251 | - 'order' => 4, |
|
252 | - 'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'), |
|
253 | - 'name' => $l->t('Users'), |
|
254 | - 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
255 | - ]); |
|
256 | - } |
|
257 | - } |
|
246 | + if ($this->isSubadmin()) { |
|
247 | + // User management |
|
248 | + $this->add([ |
|
249 | + 'type' => 'settings', |
|
250 | + 'id' => 'core_users', |
|
251 | + 'order' => 4, |
|
252 | + 'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'), |
|
253 | + 'name' => $l->t('Users'), |
|
254 | + 'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'), |
|
255 | + ]); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - if ($this->appManager === 'null') { |
|
260 | - return; |
|
261 | - } |
|
259 | + if ($this->appManager === 'null') { |
|
260 | + return; |
|
261 | + } |
|
262 | 262 | |
263 | - if ($this->userSession->isLoggedIn()) { |
|
264 | - $apps = $this->appManager->getEnabledAppsForUser($this->userSession->getUser()); |
|
265 | - } else { |
|
266 | - $apps = $this->appManager->getInstalledApps(); |
|
267 | - } |
|
263 | + if ($this->userSession->isLoggedIn()) { |
|
264 | + $apps = $this->appManager->getEnabledAppsForUser($this->userSession->getUser()); |
|
265 | + } else { |
|
266 | + $apps = $this->appManager->getInstalledApps(); |
|
267 | + } |
|
268 | 268 | |
269 | - foreach ($apps as $app) { |
|
270 | - if (!$this->userSession->isLoggedIn() && !$this->appManager->isEnabledForUser($app, $this->userSession->getUser())) { |
|
271 | - continue; |
|
272 | - } |
|
269 | + foreach ($apps as $app) { |
|
270 | + if (!$this->userSession->isLoggedIn() && !$this->appManager->isEnabledForUser($app, $this->userSession->getUser())) { |
|
271 | + continue; |
|
272 | + } |
|
273 | 273 | |
274 | - // load plugins and collections from info.xml |
|
275 | - $info = $this->appManager->getAppInfo($app); |
|
276 | - if (!isset($info['navigations']['navigation'])) { |
|
277 | - continue; |
|
278 | - } |
|
279 | - foreach ($info['navigations']['navigation'] as $key => $nav) { |
|
280 | - if (!isset($nav['name'])) { |
|
281 | - continue; |
|
282 | - } |
|
283 | - if (!isset($nav['route'])) { |
|
284 | - continue; |
|
285 | - } |
|
286 | - $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
287 | - if ($role === 'admin' && !$this->isAdmin()) { |
|
288 | - continue; |
|
289 | - } |
|
290 | - $l = $this->l10nFac->get($app); |
|
291 | - $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); |
|
292 | - $order = isset($nav['order']) ? $nav['order'] : 100; |
|
293 | - $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
294 | - $route = $nav['route'] !== '' ? $this->urlGenerator->linkToRoute($nav['route']) : ''; |
|
295 | - $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
296 | - foreach ([$icon, "$app.svg"] as $i) { |
|
297 | - try { |
|
298 | - $icon = $this->urlGenerator->imagePath($app, $i); |
|
299 | - break; |
|
300 | - } catch (\RuntimeException $ex) { |
|
301 | - // no icon? - ignore it then |
|
302 | - } |
|
303 | - } |
|
304 | - if ($icon === null) { |
|
305 | - $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
306 | - } |
|
274 | + // load plugins and collections from info.xml |
|
275 | + $info = $this->appManager->getAppInfo($app); |
|
276 | + if (!isset($info['navigations']['navigation'])) { |
|
277 | + continue; |
|
278 | + } |
|
279 | + foreach ($info['navigations']['navigation'] as $key => $nav) { |
|
280 | + if (!isset($nav['name'])) { |
|
281 | + continue; |
|
282 | + } |
|
283 | + if (!isset($nav['route'])) { |
|
284 | + continue; |
|
285 | + } |
|
286 | + $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all'; |
|
287 | + if ($role === 'admin' && !$this->isAdmin()) { |
|
288 | + continue; |
|
289 | + } |
|
290 | + $l = $this->l10nFac->get($app); |
|
291 | + $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); |
|
292 | + $order = isset($nav['order']) ? $nav['order'] : 100; |
|
293 | + $type = isset($nav['type']) ? $nav['type'] : 'link'; |
|
294 | + $route = $nav['route'] !== '' ? $this->urlGenerator->linkToRoute($nav['route']) : ''; |
|
295 | + $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg'; |
|
296 | + foreach ([$icon, "$app.svg"] as $i) { |
|
297 | + try { |
|
298 | + $icon = $this->urlGenerator->imagePath($app, $i); |
|
299 | + break; |
|
300 | + } catch (\RuntimeException $ex) { |
|
301 | + // no icon? - ignore it then |
|
302 | + } |
|
303 | + } |
|
304 | + if ($icon === null) { |
|
305 | + $icon = $this->urlGenerator->imagePath('core', 'default-app-icon'); |
|
306 | + } |
|
307 | 307 | |
308 | - $this->add([ |
|
309 | - 'id' => $id, |
|
310 | - 'order' => $order, |
|
311 | - 'href' => $route, |
|
312 | - 'icon' => $icon, |
|
313 | - 'type' => $type, |
|
314 | - 'name' => $l->t($nav['name']), |
|
315 | - ]); |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
308 | + $this->add([ |
|
309 | + 'id' => $id, |
|
310 | + 'order' => $order, |
|
311 | + 'href' => $route, |
|
312 | + 'icon' => $icon, |
|
313 | + 'type' => $type, |
|
314 | + 'name' => $l->t($nav['name']), |
|
315 | + ]); |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | - private function isAdmin() { |
|
321 | - $user = $this->userSession->getUser(); |
|
322 | - if ($user !== null) { |
|
323 | - return $this->groupManager->isAdmin($user->getUID()); |
|
324 | - } |
|
325 | - return false; |
|
326 | - } |
|
320 | + private function isAdmin() { |
|
321 | + $user = $this->userSession->getUser(); |
|
322 | + if ($user !== null) { |
|
323 | + return $this->groupManager->isAdmin($user->getUID()); |
|
324 | + } |
|
325 | + return false; |
|
326 | + } |
|
327 | 327 | |
328 | - private function isSubadmin() { |
|
329 | - $user = $this->userSession->getUser(); |
|
330 | - if ($user !== null) { |
|
331 | - return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
332 | - } |
|
333 | - return false; |
|
334 | - } |
|
328 | + private function isSubadmin() { |
|
329 | + $user = $this->userSession->getUser(); |
|
330 | + if ($user !== null) { |
|
331 | + return $this->groupManager->getSubAdmin()->isSubAdmin($user); |
|
332 | + } |
|
333 | + return false; |
|
334 | + } |
|
335 | 335 | } |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | $entry['active'] = false; |
96 | - if(!isset($entry['icon'])) { |
|
96 | + if (!isset($entry['icon'])) { |
|
97 | 97 | $entry['icon'] = ''; |
98 | 98 | } |
99 | - if(!isset($entry['classes'])) { |
|
99 | + if (!isset($entry['classes'])) { |
|
100 | 100 | $entry['classes'] = ''; |
101 | 101 | } |
102 | - if(!isset($entry['type'])) { |
|
102 | + if (!isset($entry['type'])) { |
|
103 | 103 | $entry['type'] = 'link'; |
104 | 104 | } |
105 | 105 | $this->entries[$entry['id']] = $entry; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $result = $this->entries; |
122 | 122 | if ($type !== 'all') { |
123 | - $result = array_filter($this->entries, function ($entry) use ($type) { |
|
123 | + $result = array_filter($this->entries, function($entry) use ($type) { |
|
124 | 124 | return $entry['type'] === $type; |
125 | 125 | }); |
126 | 126 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return array |
136 | 136 | */ |
137 | 137 | private function proceedNavigation(array $list): array { |
138 | - uasort($list, function ($a, $b) { |
|
138 | + uasort($list, function($a, $b) { |
|
139 | 139 | if (isset($a['order']) && isset($b['order'])) { |
140 | 140 | return ($a['order'] < $b['order']) ? -1 : 1; |
141 | 141 | } else if (isset($a['order']) || isset($b['order'])) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | ]); |
232 | 232 | |
233 | 233 | $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator); |
234 | - if($logoutUrl !== '') { |
|
234 | + if ($logoutUrl !== '') { |
|
235 | 235 | // Logout |
236 | 236 | $this->add([ |
237 | 237 | 'type' => 'settings', |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | $l = $this->l10nFac->get($app); |
291 | - $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); |
|
291 | + $id = $nav['id'] ?? $app.($key === 0 ? '' : $key); |
|
292 | 292 | $order = isset($nav['order']) ? $nav['order'] : 100; |
293 | 293 | $type = isset($nav['type']) ? $nav['type'] : 'link'; |
294 | 294 | $route = $nav['route'] !== '' ? $this->urlGenerator->linkToRoute($nav['route']) : ''; |
@@ -38,54 +38,54 @@ |
||
38 | 38 | */ |
39 | 39 | class Tag extends Entity { |
40 | 40 | |
41 | - protected $owner; |
|
42 | - protected $type; |
|
43 | - protected $name; |
|
41 | + protected $owner; |
|
42 | + protected $type; |
|
43 | + protected $name; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Constructor. |
|
47 | - * |
|
48 | - * @param string $owner The tag's owner |
|
49 | - * @param string $type The type of item this tag is used for |
|
50 | - * @param string $name The tag's name |
|
51 | - */ |
|
52 | - public function __construct($owner = null, $type = null, $name = null) { |
|
53 | - $this->setOwner($owner); |
|
54 | - $this->setType($type); |
|
55 | - $this->setName($name); |
|
56 | - } |
|
45 | + /** |
|
46 | + * Constructor. |
|
47 | + * |
|
48 | + * @param string $owner The tag's owner |
|
49 | + * @param string $type The type of item this tag is used for |
|
50 | + * @param string $name The tag's name |
|
51 | + */ |
|
52 | + public function __construct($owner = null, $type = null, $name = null) { |
|
53 | + $this->setOwner($owner); |
|
54 | + $this->setType($type); |
|
55 | + $this->setName($name); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Transform a database columnname to a property |
|
60 | - * |
|
61 | - * @param string $columnName the name of the column |
|
62 | - * @return string the property name |
|
63 | - * @todo migrate existing database columns to the correct names |
|
64 | - * to be able to drop this direct mapping |
|
65 | - */ |
|
66 | - public function columnToProperty($columnName) { |
|
67 | - if ($columnName === 'category') { |
|
68 | - return 'name'; |
|
69 | - } elseif ($columnName === 'uid') { |
|
70 | - return 'owner'; |
|
71 | - } else { |
|
72 | - return parent::columnToProperty($columnName); |
|
73 | - } |
|
74 | - } |
|
58 | + /** |
|
59 | + * Transform a database columnname to a property |
|
60 | + * |
|
61 | + * @param string $columnName the name of the column |
|
62 | + * @return string the property name |
|
63 | + * @todo migrate existing database columns to the correct names |
|
64 | + * to be able to drop this direct mapping |
|
65 | + */ |
|
66 | + public function columnToProperty($columnName) { |
|
67 | + if ($columnName === 'category') { |
|
68 | + return 'name'; |
|
69 | + } elseif ($columnName === 'uid') { |
|
70 | + return 'owner'; |
|
71 | + } else { |
|
72 | + return parent::columnToProperty($columnName); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Transform a property to a database column name |
|
78 | - * |
|
79 | - * @param string $property the name of the property |
|
80 | - * @return string the column name |
|
81 | - */ |
|
82 | - public function propertyToColumn($property) { |
|
83 | - if ($property === 'name') { |
|
84 | - return 'category'; |
|
85 | - } elseif ($property === 'owner') { |
|
86 | - return 'uid'; |
|
87 | - } else { |
|
88 | - return parent::propertyToColumn($property); |
|
89 | - } |
|
90 | - } |
|
76 | + /** |
|
77 | + * Transform a property to a database column name |
|
78 | + * |
|
79 | + * @param string $property the name of the property |
|
80 | + * @return string the column name |
|
81 | + */ |
|
82 | + public function propertyToColumn($property) { |
|
83 | + if ($property === 'name') { |
|
84 | + return 'category'; |
|
85 | + } elseif ($property === 'owner') { |
|
86 | + return 'uid'; |
|
87 | + } else { |
|
88 | + return parent::propertyToColumn($property); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | } |
@@ -39,228 +39,228 @@ |
||
39 | 39 | |
40 | 40 | class ContactsStore implements IContactsStore { |
41 | 41 | |
42 | - /** @var IManager */ |
|
43 | - private $contactsManager; |
|
44 | - |
|
45 | - /** @var IConfig */ |
|
46 | - private $config; |
|
47 | - |
|
48 | - /** @var IUserManager */ |
|
49 | - private $userManager; |
|
50 | - |
|
51 | - /** @var IGroupManager */ |
|
52 | - private $groupManager; |
|
53 | - |
|
54 | - /** |
|
55 | - * @param IManager $contactsManager |
|
56 | - * @param IConfig $config |
|
57 | - * @param IUserManager $userManager |
|
58 | - * @param IGroupManager $groupManager |
|
59 | - */ |
|
60 | - public function __construct(IManager $contactsManager, |
|
61 | - IConfig $config, |
|
62 | - IUserManager $userManager, |
|
63 | - IGroupManager $groupManager) { |
|
64 | - $this->contactsManager = $contactsManager; |
|
65 | - $this->config = $config; |
|
66 | - $this->userManager = $userManager; |
|
67 | - $this->groupManager = $groupManager; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @param IUser $user |
|
72 | - * @param string|null $filter |
|
73 | - * @return IEntry[] |
|
74 | - */ |
|
75 | - public function getContacts(IUser $user, $filter) { |
|
76 | - $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
77 | - 'FN', |
|
78 | - 'EMAIL' |
|
79 | - ]); |
|
80 | - |
|
81 | - $entries = array_map(function (array $contact) { |
|
82 | - return $this->contactArrayToEntry($contact); |
|
83 | - }, $allContacts); |
|
84 | - return $this->filterContacts( |
|
85 | - $user, |
|
86 | - $entries, |
|
87 | - $filter |
|
88 | - ); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Filters the contacts. Applies 3 filters: |
|
93 | - * 1. filter the current user |
|
94 | - * 2. if the `shareapi_allow_share_dialog_user_enumeration` config option is |
|
95 | - * enabled it will filter all local users |
|
96 | - * 3. if the `shareapi_exclude_groups` config option is enabled and the |
|
97 | - * current user is in an excluded group it will filter all local users. |
|
98 | - * 4. if the `shareapi_only_share_with_group_members` config option is |
|
99 | - * enabled it will filter all users which doens't have a common group |
|
100 | - * with the current user. |
|
101 | - * |
|
102 | - * @param IUser $self |
|
103 | - * @param Entry[] $entries |
|
104 | - * @param string $filter |
|
105 | - * @return Entry[] the filtered contacts |
|
106 | - */ |
|
107 | - private function filterContacts(IUser $self, |
|
108 | - array $entries, |
|
109 | - $filter) { |
|
110 | - $disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes'; |
|
111 | - $restrictEnumeration = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; |
|
112 | - $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes'; |
|
113 | - |
|
114 | - // whether to filter out local users |
|
115 | - $skipLocal = false; |
|
116 | - // whether to filter out all users which doesn't have the same group as the current user |
|
117 | - $ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes' || $restrictEnumeration; |
|
118 | - |
|
119 | - $selfGroups = $this->groupManager->getUserGroupIds($self); |
|
120 | - |
|
121 | - if ($excludedGroups) { |
|
122 | - $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
123 | - $decodedExcludeGroups = json_decode($excludedGroups, true); |
|
124 | - $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : []; |
|
125 | - |
|
126 | - if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { |
|
127 | - // a group of the current user is excluded -> filter all local users |
|
128 | - $skipLocal = true; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - $selfUID = $self->getUID(); |
|
133 | - |
|
134 | - return array_values(array_filter($entries, function (IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) { |
|
135 | - if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) { |
|
136 | - return false; |
|
137 | - } |
|
138 | - |
|
139 | - // Prevent enumerating local users |
|
140 | - if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) { |
|
141 | - $filterUser = true; |
|
142 | - |
|
143 | - $mailAddresses = $entry->getEMailAddresses(); |
|
144 | - foreach($mailAddresses as $mailAddress) { |
|
145 | - if($mailAddress === $filter) { |
|
146 | - $filterUser = false; |
|
147 | - break; |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) { |
|
152 | - $filterUser = false; |
|
153 | - } |
|
154 | - |
|
155 | - if($filterUser) { |
|
156 | - return false; |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) { |
|
161 | - $uid = $this->userManager->get($entry->getProperty('UID')); |
|
162 | - |
|
163 | - if ($uid === null) { |
|
164 | - return false; |
|
165 | - } |
|
166 | - |
|
167 | - $contactGroups = $this->groupManager->getUserGroupIds($uid); |
|
168 | - if (count(array_intersect($contactGroups, $selfGroups)) === 0) { |
|
169 | - // no groups in common, so shouldn't see the contact |
|
170 | - return false; |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - return $entry->getProperty('UID') !== $selfUID; |
|
175 | - })); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * @param IUser $user |
|
180 | - * @param integer $shareType |
|
181 | - * @param string $shareWith |
|
182 | - * @return IEntry|null |
|
183 | - */ |
|
184 | - public function findOne(IUser $user, $shareType, $shareWith) { |
|
185 | - switch($shareType) { |
|
186 | - case 0: |
|
187 | - case 6: |
|
188 | - $filter = ['UID']; |
|
189 | - break; |
|
190 | - case 4: |
|
191 | - $filter = ['EMAIL']; |
|
192 | - break; |
|
193 | - default: |
|
194 | - return null; |
|
195 | - } |
|
196 | - |
|
197 | - $userId = $user->getUID(); |
|
198 | - $allContacts = $this->contactsManager->search($shareWith, $filter); |
|
199 | - $contacts = array_filter($allContacts, function ($contact) use ($userId) { |
|
200 | - return $contact['UID'] !== $userId; |
|
201 | - }); |
|
202 | - $match = null; |
|
203 | - |
|
204 | - foreach ($contacts as $contact) { |
|
205 | - if ($shareType === 4 && isset($contact['EMAIL'])) { |
|
206 | - if (in_array($shareWith, $contact['EMAIL'])) { |
|
207 | - $match = $contact; |
|
208 | - break; |
|
209 | - } |
|
210 | - } |
|
211 | - if ($shareType === 0 || $shareType === 6) { |
|
212 | - $isLocal = $contact['isLocalSystemBook'] ?? false; |
|
213 | - if ($contact['UID'] === $shareWith && $isLocal === true) { |
|
214 | - $match = $contact; |
|
215 | - break; |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - if ($match) { |
|
221 | - $match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith); |
|
222 | - if (count($match) === 1) { |
|
223 | - $match = $match[0]; |
|
224 | - } else { |
|
225 | - $match = null; |
|
226 | - } |
|
227 | - |
|
228 | - } |
|
229 | - |
|
230 | - return $match; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * @param array $contact |
|
235 | - * @return Entry |
|
236 | - */ |
|
237 | - private function contactArrayToEntry(array $contact) { |
|
238 | - $entry = new Entry(); |
|
239 | - |
|
240 | - if (isset($contact['id'])) { |
|
241 | - $entry->setId($contact['id']); |
|
242 | - } |
|
243 | - |
|
244 | - if (isset($contact['FN'])) { |
|
245 | - $entry->setFullName($contact['FN']); |
|
246 | - } |
|
247 | - |
|
248 | - $avatarPrefix = "VALUE=uri:"; |
|
249 | - if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
250 | - $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
251 | - } |
|
252 | - |
|
253 | - if (isset($contact['EMAIL'])) { |
|
254 | - foreach ($contact['EMAIL'] as $email) { |
|
255 | - $entry->addEMailAddress($email); |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - // Attach all other properties to the entry too because some |
|
260 | - // providers might make use of it. |
|
261 | - $entry->setProperties($contact); |
|
262 | - |
|
263 | - return $entry; |
|
264 | - } |
|
42 | + /** @var IManager */ |
|
43 | + private $contactsManager; |
|
44 | + |
|
45 | + /** @var IConfig */ |
|
46 | + private $config; |
|
47 | + |
|
48 | + /** @var IUserManager */ |
|
49 | + private $userManager; |
|
50 | + |
|
51 | + /** @var IGroupManager */ |
|
52 | + private $groupManager; |
|
53 | + |
|
54 | + /** |
|
55 | + * @param IManager $contactsManager |
|
56 | + * @param IConfig $config |
|
57 | + * @param IUserManager $userManager |
|
58 | + * @param IGroupManager $groupManager |
|
59 | + */ |
|
60 | + public function __construct(IManager $contactsManager, |
|
61 | + IConfig $config, |
|
62 | + IUserManager $userManager, |
|
63 | + IGroupManager $groupManager) { |
|
64 | + $this->contactsManager = $contactsManager; |
|
65 | + $this->config = $config; |
|
66 | + $this->userManager = $userManager; |
|
67 | + $this->groupManager = $groupManager; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @param IUser $user |
|
72 | + * @param string|null $filter |
|
73 | + * @return IEntry[] |
|
74 | + */ |
|
75 | + public function getContacts(IUser $user, $filter) { |
|
76 | + $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
77 | + 'FN', |
|
78 | + 'EMAIL' |
|
79 | + ]); |
|
80 | + |
|
81 | + $entries = array_map(function (array $contact) { |
|
82 | + return $this->contactArrayToEntry($contact); |
|
83 | + }, $allContacts); |
|
84 | + return $this->filterContacts( |
|
85 | + $user, |
|
86 | + $entries, |
|
87 | + $filter |
|
88 | + ); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Filters the contacts. Applies 3 filters: |
|
93 | + * 1. filter the current user |
|
94 | + * 2. if the `shareapi_allow_share_dialog_user_enumeration` config option is |
|
95 | + * enabled it will filter all local users |
|
96 | + * 3. if the `shareapi_exclude_groups` config option is enabled and the |
|
97 | + * current user is in an excluded group it will filter all local users. |
|
98 | + * 4. if the `shareapi_only_share_with_group_members` config option is |
|
99 | + * enabled it will filter all users which doens't have a common group |
|
100 | + * with the current user. |
|
101 | + * |
|
102 | + * @param IUser $self |
|
103 | + * @param Entry[] $entries |
|
104 | + * @param string $filter |
|
105 | + * @return Entry[] the filtered contacts |
|
106 | + */ |
|
107 | + private function filterContacts(IUser $self, |
|
108 | + array $entries, |
|
109 | + $filter) { |
|
110 | + $disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes'; |
|
111 | + $restrictEnumeration = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; |
|
112 | + $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes'; |
|
113 | + |
|
114 | + // whether to filter out local users |
|
115 | + $skipLocal = false; |
|
116 | + // whether to filter out all users which doesn't have the same group as the current user |
|
117 | + $ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes' || $restrictEnumeration; |
|
118 | + |
|
119 | + $selfGroups = $this->groupManager->getUserGroupIds($self); |
|
120 | + |
|
121 | + if ($excludedGroups) { |
|
122 | + $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
123 | + $decodedExcludeGroups = json_decode($excludedGroups, true); |
|
124 | + $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : []; |
|
125 | + |
|
126 | + if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { |
|
127 | + // a group of the current user is excluded -> filter all local users |
|
128 | + $skipLocal = true; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + $selfUID = $self->getUID(); |
|
133 | + |
|
134 | + return array_values(array_filter($entries, function (IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) { |
|
135 | + if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) { |
|
136 | + return false; |
|
137 | + } |
|
138 | + |
|
139 | + // Prevent enumerating local users |
|
140 | + if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) { |
|
141 | + $filterUser = true; |
|
142 | + |
|
143 | + $mailAddresses = $entry->getEMailAddresses(); |
|
144 | + foreach($mailAddresses as $mailAddress) { |
|
145 | + if($mailAddress === $filter) { |
|
146 | + $filterUser = false; |
|
147 | + break; |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) { |
|
152 | + $filterUser = false; |
|
153 | + } |
|
154 | + |
|
155 | + if($filterUser) { |
|
156 | + return false; |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) { |
|
161 | + $uid = $this->userManager->get($entry->getProperty('UID')); |
|
162 | + |
|
163 | + if ($uid === null) { |
|
164 | + return false; |
|
165 | + } |
|
166 | + |
|
167 | + $contactGroups = $this->groupManager->getUserGroupIds($uid); |
|
168 | + if (count(array_intersect($contactGroups, $selfGroups)) === 0) { |
|
169 | + // no groups in common, so shouldn't see the contact |
|
170 | + return false; |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + return $entry->getProperty('UID') !== $selfUID; |
|
175 | + })); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * @param IUser $user |
|
180 | + * @param integer $shareType |
|
181 | + * @param string $shareWith |
|
182 | + * @return IEntry|null |
|
183 | + */ |
|
184 | + public function findOne(IUser $user, $shareType, $shareWith) { |
|
185 | + switch($shareType) { |
|
186 | + case 0: |
|
187 | + case 6: |
|
188 | + $filter = ['UID']; |
|
189 | + break; |
|
190 | + case 4: |
|
191 | + $filter = ['EMAIL']; |
|
192 | + break; |
|
193 | + default: |
|
194 | + return null; |
|
195 | + } |
|
196 | + |
|
197 | + $userId = $user->getUID(); |
|
198 | + $allContacts = $this->contactsManager->search($shareWith, $filter); |
|
199 | + $contacts = array_filter($allContacts, function ($contact) use ($userId) { |
|
200 | + return $contact['UID'] !== $userId; |
|
201 | + }); |
|
202 | + $match = null; |
|
203 | + |
|
204 | + foreach ($contacts as $contact) { |
|
205 | + if ($shareType === 4 && isset($contact['EMAIL'])) { |
|
206 | + if (in_array($shareWith, $contact['EMAIL'])) { |
|
207 | + $match = $contact; |
|
208 | + break; |
|
209 | + } |
|
210 | + } |
|
211 | + if ($shareType === 0 || $shareType === 6) { |
|
212 | + $isLocal = $contact['isLocalSystemBook'] ?? false; |
|
213 | + if ($contact['UID'] === $shareWith && $isLocal === true) { |
|
214 | + $match = $contact; |
|
215 | + break; |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + if ($match) { |
|
221 | + $match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith); |
|
222 | + if (count($match) === 1) { |
|
223 | + $match = $match[0]; |
|
224 | + } else { |
|
225 | + $match = null; |
|
226 | + } |
|
227 | + |
|
228 | + } |
|
229 | + |
|
230 | + return $match; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * @param array $contact |
|
235 | + * @return Entry |
|
236 | + */ |
|
237 | + private function contactArrayToEntry(array $contact) { |
|
238 | + $entry = new Entry(); |
|
239 | + |
|
240 | + if (isset($contact['id'])) { |
|
241 | + $entry->setId($contact['id']); |
|
242 | + } |
|
243 | + |
|
244 | + if (isset($contact['FN'])) { |
|
245 | + $entry->setFullName($contact['FN']); |
|
246 | + } |
|
247 | + |
|
248 | + $avatarPrefix = "VALUE=uri:"; |
|
249 | + if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
250 | + $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
251 | + } |
|
252 | + |
|
253 | + if (isset($contact['EMAIL'])) { |
|
254 | + foreach ($contact['EMAIL'] as $email) { |
|
255 | + $entry->addEMailAddress($email); |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + // Attach all other properties to the entry too because some |
|
260 | + // providers might make use of it. |
|
261 | + $entry->setProperties($contact); |
|
262 | + |
|
263 | + return $entry; |
|
264 | + } |
|
265 | 265 | |
266 | 266 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | 'EMAIL' |
79 | 79 | ]); |
80 | 80 | |
81 | - $entries = array_map(function (array $contact) { |
|
81 | + $entries = array_map(function(array $contact) { |
|
82 | 82 | return $this->contactArrayToEntry($contact); |
83 | 83 | }, $allContacts); |
84 | 84 | return $this->filterContacts( |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | if ($excludedGroups) { |
122 | 122 | $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
123 | 123 | $decodedExcludeGroups = json_decode($excludedGroups, true); |
124 | - $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : []; |
|
124 | + $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : []; |
|
125 | 125 | |
126 | 126 | if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { |
127 | 127 | // a group of the current user is excluded -> filter all local users |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | |
132 | 132 | $selfUID = $self->getUID(); |
133 | 133 | |
134 | - return array_values(array_filter($entries, function (IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) { |
|
134 | + return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) { |
|
135 | 135 | if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) { |
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Prevent enumerating local users |
140 | - if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) { |
|
140 | + if ($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) { |
|
141 | 141 | $filterUser = true; |
142 | 142 | |
143 | 143 | $mailAddresses = $entry->getEMailAddresses(); |
144 | - foreach($mailAddresses as $mailAddress) { |
|
145 | - if($mailAddress === $filter) { |
|
144 | + foreach ($mailAddresses as $mailAddress) { |
|
145 | + if ($mailAddress === $filter) { |
|
146 | 146 | $filterUser = false; |
147 | 147 | break; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) { |
|
151 | + if ($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) { |
|
152 | 152 | $filterUser = false; |
153 | 153 | } |
154 | 154 | |
155 | - if($filterUser) { |
|
155 | + if ($filterUser) { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return IEntry|null |
183 | 183 | */ |
184 | 184 | public function findOne(IUser $user, $shareType, $shareWith) { |
185 | - switch($shareType) { |
|
185 | + switch ($shareType) { |
|
186 | 186 | case 0: |
187 | 187 | case 6: |
188 | 188 | $filter = ['UID']; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $userId = $user->getUID(); |
198 | 198 | $allContacts = $this->contactsManager->search($shareWith, $filter); |
199 | - $contacts = array_filter($allContacts, function ($contact) use ($userId) { |
|
199 | + $contacts = array_filter($allContacts, function($contact) use ($userId) { |
|
200 | 200 | return $contact['UID'] !== $userId; |
201 | 201 | }); |
202 | 202 | $match = null; |
@@ -53,313 +53,313 @@ |
||
53 | 53 | |
54 | 54 | class TemplateLayout extends \OC_Template { |
55 | 55 | |
56 | - private static $versionHash = ''; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var \OCP\IConfig |
|
60 | - */ |
|
61 | - private $config; |
|
62 | - |
|
63 | - /** |
|
64 | - * @param string $renderAs |
|
65 | - * @param string $appId application id |
|
66 | - */ |
|
67 | - public function __construct($renderAs, $appId = '') { |
|
68 | - |
|
69 | - // yes - should be injected .... |
|
70 | - $this->config = \OC::$server->getConfig(); |
|
71 | - |
|
72 | - if(\OCP\Util::isIE()) { |
|
73 | - \OC_Util::addStyle('ie'); |
|
74 | - } |
|
75 | - |
|
76 | - // Decide which page we show |
|
77 | - if($renderAs === 'user') { |
|
78 | - parent::__construct( 'core', 'layout.user' ); |
|
79 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
80 | - $this->assign('bodyid', 'body-settings'); |
|
81 | - }else{ |
|
82 | - $this->assign('bodyid', 'body-user'); |
|
83 | - } |
|
84 | - |
|
85 | - // Add navigation entry |
|
86 | - $this->assign( 'application', ''); |
|
87 | - $this->assign( 'appid', $appId ); |
|
88 | - $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
89 | - $this->assign( 'navigation', $navigation); |
|
90 | - $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
91 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
92 | - foreach($navigation as $entry) { |
|
93 | - if ($entry['active']) { |
|
94 | - $this->assign( 'application', $entry['name'] ); |
|
95 | - break; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - foreach($settingsNavigation as $entry) { |
|
100 | - if ($entry['active']) { |
|
101 | - $this->assign( 'application', $entry['name'] ); |
|
102 | - break; |
|
103 | - } |
|
104 | - } |
|
105 | - $userDisplayName = \OC_User::getDisplayName(); |
|
106 | - $this->assign('user_displayname', $userDisplayName); |
|
107 | - $this->assign('user_uid', \OC_User::getUser()); |
|
108 | - |
|
109 | - if (\OC_User::getUser() === false) { |
|
110 | - $this->assign('userAvatarSet', false); |
|
111 | - } else { |
|
112 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
113 | - $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
114 | - } |
|
115 | - |
|
116 | - // check if app menu icons should be inverted |
|
117 | - try { |
|
118 | - /** @var \OCA\Theming\Util $util */ |
|
119 | - $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
120 | - $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
121 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
122 | - $this->assign('themingInvertMenu', false); |
|
123 | - } catch (\OCP\AutoloadNotAllowedException $e) { |
|
124 | - $this->assign('themingInvertMenu', false); |
|
125 | - } |
|
126 | - |
|
127 | - } else if ($renderAs === 'error') { |
|
128 | - parent::__construct('core', 'layout.guest', '', false); |
|
129 | - $this->assign('bodyid', 'body-login'); |
|
130 | - $this->assign('user_displayname', ''); |
|
131 | - $this->assign('user_uid', ''); |
|
132 | - } else if ($renderAs === 'guest') { |
|
133 | - parent::__construct('core', 'layout.guest'); |
|
134 | - \OC_Util::addStyle('guest'); |
|
135 | - $this->assign('bodyid', 'body-login'); |
|
136 | - |
|
137 | - $userDisplayName = \OC_User::getDisplayName(); |
|
138 | - $this->assign('user_displayname', $userDisplayName); |
|
139 | - $this->assign('user_uid', \OC_User::getUser()); |
|
140 | - } else if ($renderAs === 'public') { |
|
141 | - parent::__construct('core', 'layout.public'); |
|
142 | - $this->assign( 'appid', $appId ); |
|
143 | - $this->assign('bodyid', 'body-public'); |
|
144 | - |
|
145 | - /** @var IRegistry $subscription */ |
|
146 | - $subscription = \OC::$server->query(IRegistry::class); |
|
147 | - $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
148 | - if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
149 | - $showSimpleSignup = false; |
|
150 | - } |
|
151 | - $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
152 | - } else { |
|
153 | - parent::__construct('core', 'layout.base'); |
|
154 | - |
|
155 | - } |
|
156 | - // Send the language and the locale to our layouts |
|
157 | - $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
158 | - $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
159 | - |
|
160 | - $lang = str_replace('_', '-', $lang); |
|
161 | - $this->assign('language', $lang); |
|
162 | - $this->assign('locale', $locale); |
|
163 | - |
|
164 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
165 | - if (empty(self::$versionHash)) { |
|
166 | - $v = \OC_App::getAppVersions(); |
|
167 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
168 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
169 | - } |
|
170 | - } else { |
|
171 | - self::$versionHash = md5('not installed'); |
|
172 | - } |
|
173 | - |
|
174 | - // Add the js files |
|
175 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
176 | - $this->assign('jsfiles', []); |
|
177 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
178 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
179 | - $jsConfigHelper = new JSConfigHelper( |
|
180 | - \OC::$server->getL10N('lib'), |
|
181 | - \OC::$server->query(Defaults::class), |
|
182 | - \OC::$server->getAppManager(), |
|
183 | - \OC::$server->getSession(), |
|
184 | - \OC::$server->getUserSession()->getUser(), |
|
185 | - $this->config, |
|
186 | - \OC::$server->getGroupManager(), |
|
187 | - \OC::$server->getIniWrapper(), |
|
188 | - \OC::$server->getURLGenerator(), |
|
189 | - \OC::$server->getCapabilitiesManager() |
|
190 | - ); |
|
191 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
192 | - } else { |
|
193 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
194 | - } |
|
195 | - } |
|
196 | - foreach($jsFiles as $info) { |
|
197 | - $web = $info[1]; |
|
198 | - $file = $info[2]; |
|
199 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
200 | - } |
|
201 | - |
|
202 | - try { |
|
203 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
204 | - } catch (\Exception $e) { |
|
205 | - $pathInfo = ''; |
|
206 | - } |
|
207 | - |
|
208 | - // Do not initialise scss appdata until we have a fully installed instance |
|
209 | - // Do not load scss for update, errors, installation or login page |
|
210 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
211 | - && !\OCP\Util::needUpgrade() |
|
212 | - && $pathInfo !== '' |
|
213 | - && !preg_match('/^\/login/', $pathInfo) |
|
214 | - && $renderAs !== 'error' |
|
215 | - ) { |
|
216 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
217 | - } else { |
|
218 | - // If we ignore the scss compiler, |
|
219 | - // we need to load the guest css fallback |
|
220 | - \OC_Util::addStyle('guest'); |
|
221 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
222 | - } |
|
223 | - |
|
224 | - $this->assign('cssfiles', []); |
|
225 | - $this->assign('printcssfiles', []); |
|
226 | - $this->assign('versionHash', self::$versionHash); |
|
227 | - foreach($cssFiles as $info) { |
|
228 | - $web = $info[1]; |
|
229 | - $file = $info[2]; |
|
230 | - |
|
231 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
232 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
233 | - } else { |
|
234 | - $suffix = $this->getVersionHashSuffix($web, $file); |
|
235 | - |
|
236 | - if (strpos($file, '?v=') == false) { |
|
237 | - $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
238 | - } else { |
|
239 | - $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
240 | - } |
|
241 | - |
|
242 | - } |
|
243 | - } |
|
244 | - |
|
245 | - /** @var InitialStateService $initialState */ |
|
246 | - $initialState = \OC::$server->query(InitialStateService::class); |
|
247 | - $this->assign('initialStates', $initialState->getInitialStates()); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * @param string $path |
|
252 | - * @param string $file |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
256 | - if ($this->config->getSystemValue('debug', false)) { |
|
257 | - // allows chrome workspace mapping in debug mode |
|
258 | - return ""; |
|
259 | - } |
|
260 | - $themingSuffix = ''; |
|
261 | - $v = []; |
|
262 | - |
|
263 | - if ($this->config->getSystemValue('installed', false)) { |
|
264 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
265 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
266 | - } |
|
267 | - $v = \OC_App::getAppVersions(); |
|
268 | - } |
|
269 | - |
|
270 | - // Try the webroot path for a match |
|
271 | - if ($path !== false && $path !== '') { |
|
272 | - $appName = $this->getAppNamefromPath($path); |
|
273 | - if(array_key_exists($appName, $v)) { |
|
274 | - $appVersion = $v[$appName]; |
|
275 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
276 | - } |
|
277 | - } |
|
278 | - // fallback to the file path instead |
|
279 | - if ($file !== false && $file !== '') { |
|
280 | - $appName = $this->getAppNamefromPath($file); |
|
281 | - if(array_key_exists($appName, $v)) { |
|
282 | - $appVersion = $v[$appName]; |
|
283 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * @param array $styles |
|
292 | - * @return array |
|
293 | - */ |
|
294 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
295 | - // Read the selected theme from the config file |
|
296 | - $theme = \OC_Util::getTheme(); |
|
297 | - |
|
298 | - if($compileScss) { |
|
299 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
300 | - } else { |
|
301 | - $SCSSCacher = null; |
|
302 | - } |
|
303 | - |
|
304 | - $locator = new \OC\Template\CSSResourceLocator( |
|
305 | - \OC::$server->getLogger(), |
|
306 | - $theme, |
|
307 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
308 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
309 | - $SCSSCacher |
|
310 | - ); |
|
311 | - $locator->find($styles); |
|
312 | - return $locator->getResources(); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * @param string $path |
|
317 | - * @return string|boolean |
|
318 | - */ |
|
319 | - public function getAppNamefromPath($path) { |
|
320 | - if ($path !== '' && is_string($path)) { |
|
321 | - $pathParts = explode('/', $path); |
|
322 | - if ($pathParts[0] === 'css') { |
|
323 | - // This is a scss request |
|
324 | - return $pathParts[1]; |
|
325 | - } |
|
326 | - return end($pathParts); |
|
327 | - } |
|
328 | - return false; |
|
329 | - |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * @param array $scripts |
|
334 | - * @return array |
|
335 | - */ |
|
336 | - static public function findJavascriptFiles($scripts) { |
|
337 | - // Read the selected theme from the config file |
|
338 | - $theme = \OC_Util::getTheme(); |
|
339 | - |
|
340 | - $locator = new \OC\Template\JSResourceLocator( |
|
341 | - \OC::$server->getLogger(), |
|
342 | - $theme, |
|
343 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
344 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
345 | - \OC::$server->query(JSCombiner::class) |
|
346 | - ); |
|
347 | - $locator->find($scripts); |
|
348 | - return $locator->getResources(); |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
353 | - * @param string $filePath Absolute path |
|
354 | - * @return string Relative path |
|
355 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
356 | - */ |
|
357 | - public static function convertToRelativePath($filePath) { |
|
358 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
359 | - if(count($relativePath) !== 2) { |
|
360 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
361 | - } |
|
362 | - |
|
363 | - return $relativePath[1]; |
|
364 | - } |
|
56 | + private static $versionHash = ''; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var \OCP\IConfig |
|
60 | + */ |
|
61 | + private $config; |
|
62 | + |
|
63 | + /** |
|
64 | + * @param string $renderAs |
|
65 | + * @param string $appId application id |
|
66 | + */ |
|
67 | + public function __construct($renderAs, $appId = '') { |
|
68 | + |
|
69 | + // yes - should be injected .... |
|
70 | + $this->config = \OC::$server->getConfig(); |
|
71 | + |
|
72 | + if(\OCP\Util::isIE()) { |
|
73 | + \OC_Util::addStyle('ie'); |
|
74 | + } |
|
75 | + |
|
76 | + // Decide which page we show |
|
77 | + if($renderAs === 'user') { |
|
78 | + parent::__construct( 'core', 'layout.user' ); |
|
79 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
80 | + $this->assign('bodyid', 'body-settings'); |
|
81 | + }else{ |
|
82 | + $this->assign('bodyid', 'body-user'); |
|
83 | + } |
|
84 | + |
|
85 | + // Add navigation entry |
|
86 | + $this->assign( 'application', ''); |
|
87 | + $this->assign( 'appid', $appId ); |
|
88 | + $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
89 | + $this->assign( 'navigation', $navigation); |
|
90 | + $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
91 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
92 | + foreach($navigation as $entry) { |
|
93 | + if ($entry['active']) { |
|
94 | + $this->assign( 'application', $entry['name'] ); |
|
95 | + break; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + foreach($settingsNavigation as $entry) { |
|
100 | + if ($entry['active']) { |
|
101 | + $this->assign( 'application', $entry['name'] ); |
|
102 | + break; |
|
103 | + } |
|
104 | + } |
|
105 | + $userDisplayName = \OC_User::getDisplayName(); |
|
106 | + $this->assign('user_displayname', $userDisplayName); |
|
107 | + $this->assign('user_uid', \OC_User::getUser()); |
|
108 | + |
|
109 | + if (\OC_User::getUser() === false) { |
|
110 | + $this->assign('userAvatarSet', false); |
|
111 | + } else { |
|
112 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
113 | + $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
114 | + } |
|
115 | + |
|
116 | + // check if app menu icons should be inverted |
|
117 | + try { |
|
118 | + /** @var \OCA\Theming\Util $util */ |
|
119 | + $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
120 | + $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
121 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
122 | + $this->assign('themingInvertMenu', false); |
|
123 | + } catch (\OCP\AutoloadNotAllowedException $e) { |
|
124 | + $this->assign('themingInvertMenu', false); |
|
125 | + } |
|
126 | + |
|
127 | + } else if ($renderAs === 'error') { |
|
128 | + parent::__construct('core', 'layout.guest', '', false); |
|
129 | + $this->assign('bodyid', 'body-login'); |
|
130 | + $this->assign('user_displayname', ''); |
|
131 | + $this->assign('user_uid', ''); |
|
132 | + } else if ($renderAs === 'guest') { |
|
133 | + parent::__construct('core', 'layout.guest'); |
|
134 | + \OC_Util::addStyle('guest'); |
|
135 | + $this->assign('bodyid', 'body-login'); |
|
136 | + |
|
137 | + $userDisplayName = \OC_User::getDisplayName(); |
|
138 | + $this->assign('user_displayname', $userDisplayName); |
|
139 | + $this->assign('user_uid', \OC_User::getUser()); |
|
140 | + } else if ($renderAs === 'public') { |
|
141 | + parent::__construct('core', 'layout.public'); |
|
142 | + $this->assign( 'appid', $appId ); |
|
143 | + $this->assign('bodyid', 'body-public'); |
|
144 | + |
|
145 | + /** @var IRegistry $subscription */ |
|
146 | + $subscription = \OC::$server->query(IRegistry::class); |
|
147 | + $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
148 | + if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
149 | + $showSimpleSignup = false; |
|
150 | + } |
|
151 | + $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
152 | + } else { |
|
153 | + parent::__construct('core', 'layout.base'); |
|
154 | + |
|
155 | + } |
|
156 | + // Send the language and the locale to our layouts |
|
157 | + $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
158 | + $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
159 | + |
|
160 | + $lang = str_replace('_', '-', $lang); |
|
161 | + $this->assign('language', $lang); |
|
162 | + $this->assign('locale', $locale); |
|
163 | + |
|
164 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
165 | + if (empty(self::$versionHash)) { |
|
166 | + $v = \OC_App::getAppVersions(); |
|
167 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
168 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
169 | + } |
|
170 | + } else { |
|
171 | + self::$versionHash = md5('not installed'); |
|
172 | + } |
|
173 | + |
|
174 | + // Add the js files |
|
175 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
176 | + $this->assign('jsfiles', []); |
|
177 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
178 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
179 | + $jsConfigHelper = new JSConfigHelper( |
|
180 | + \OC::$server->getL10N('lib'), |
|
181 | + \OC::$server->query(Defaults::class), |
|
182 | + \OC::$server->getAppManager(), |
|
183 | + \OC::$server->getSession(), |
|
184 | + \OC::$server->getUserSession()->getUser(), |
|
185 | + $this->config, |
|
186 | + \OC::$server->getGroupManager(), |
|
187 | + \OC::$server->getIniWrapper(), |
|
188 | + \OC::$server->getURLGenerator(), |
|
189 | + \OC::$server->getCapabilitiesManager() |
|
190 | + ); |
|
191 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
192 | + } else { |
|
193 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
194 | + } |
|
195 | + } |
|
196 | + foreach($jsFiles as $info) { |
|
197 | + $web = $info[1]; |
|
198 | + $file = $info[2]; |
|
199 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
200 | + } |
|
201 | + |
|
202 | + try { |
|
203 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
204 | + } catch (\Exception $e) { |
|
205 | + $pathInfo = ''; |
|
206 | + } |
|
207 | + |
|
208 | + // Do not initialise scss appdata until we have a fully installed instance |
|
209 | + // Do not load scss for update, errors, installation or login page |
|
210 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
211 | + && !\OCP\Util::needUpgrade() |
|
212 | + && $pathInfo !== '' |
|
213 | + && !preg_match('/^\/login/', $pathInfo) |
|
214 | + && $renderAs !== 'error' |
|
215 | + ) { |
|
216 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
217 | + } else { |
|
218 | + // If we ignore the scss compiler, |
|
219 | + // we need to load the guest css fallback |
|
220 | + \OC_Util::addStyle('guest'); |
|
221 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
222 | + } |
|
223 | + |
|
224 | + $this->assign('cssfiles', []); |
|
225 | + $this->assign('printcssfiles', []); |
|
226 | + $this->assign('versionHash', self::$versionHash); |
|
227 | + foreach($cssFiles as $info) { |
|
228 | + $web = $info[1]; |
|
229 | + $file = $info[2]; |
|
230 | + |
|
231 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
232 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
233 | + } else { |
|
234 | + $suffix = $this->getVersionHashSuffix($web, $file); |
|
235 | + |
|
236 | + if (strpos($file, '?v=') == false) { |
|
237 | + $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
238 | + } else { |
|
239 | + $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
240 | + } |
|
241 | + |
|
242 | + } |
|
243 | + } |
|
244 | + |
|
245 | + /** @var InitialStateService $initialState */ |
|
246 | + $initialState = \OC::$server->query(InitialStateService::class); |
|
247 | + $this->assign('initialStates', $initialState->getInitialStates()); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * @param string $path |
|
252 | + * @param string $file |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
256 | + if ($this->config->getSystemValue('debug', false)) { |
|
257 | + // allows chrome workspace mapping in debug mode |
|
258 | + return ""; |
|
259 | + } |
|
260 | + $themingSuffix = ''; |
|
261 | + $v = []; |
|
262 | + |
|
263 | + if ($this->config->getSystemValue('installed', false)) { |
|
264 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
265 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
266 | + } |
|
267 | + $v = \OC_App::getAppVersions(); |
|
268 | + } |
|
269 | + |
|
270 | + // Try the webroot path for a match |
|
271 | + if ($path !== false && $path !== '') { |
|
272 | + $appName = $this->getAppNamefromPath($path); |
|
273 | + if(array_key_exists($appName, $v)) { |
|
274 | + $appVersion = $v[$appName]; |
|
275 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
276 | + } |
|
277 | + } |
|
278 | + // fallback to the file path instead |
|
279 | + if ($file !== false && $file !== '') { |
|
280 | + $appName = $this->getAppNamefromPath($file); |
|
281 | + if(array_key_exists($appName, $v)) { |
|
282 | + $appVersion = $v[$appName]; |
|
283 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * @param array $styles |
|
292 | + * @return array |
|
293 | + */ |
|
294 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
295 | + // Read the selected theme from the config file |
|
296 | + $theme = \OC_Util::getTheme(); |
|
297 | + |
|
298 | + if($compileScss) { |
|
299 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
300 | + } else { |
|
301 | + $SCSSCacher = null; |
|
302 | + } |
|
303 | + |
|
304 | + $locator = new \OC\Template\CSSResourceLocator( |
|
305 | + \OC::$server->getLogger(), |
|
306 | + $theme, |
|
307 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
308 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
309 | + $SCSSCacher |
|
310 | + ); |
|
311 | + $locator->find($styles); |
|
312 | + return $locator->getResources(); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * @param string $path |
|
317 | + * @return string|boolean |
|
318 | + */ |
|
319 | + public function getAppNamefromPath($path) { |
|
320 | + if ($path !== '' && is_string($path)) { |
|
321 | + $pathParts = explode('/', $path); |
|
322 | + if ($pathParts[0] === 'css') { |
|
323 | + // This is a scss request |
|
324 | + return $pathParts[1]; |
|
325 | + } |
|
326 | + return end($pathParts); |
|
327 | + } |
|
328 | + return false; |
|
329 | + |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * @param array $scripts |
|
334 | + * @return array |
|
335 | + */ |
|
336 | + static public function findJavascriptFiles($scripts) { |
|
337 | + // Read the selected theme from the config file |
|
338 | + $theme = \OC_Util::getTheme(); |
|
339 | + |
|
340 | + $locator = new \OC\Template\JSResourceLocator( |
|
341 | + \OC::$server->getLogger(), |
|
342 | + $theme, |
|
343 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
344 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
345 | + \OC::$server->query(JSCombiner::class) |
|
346 | + ); |
|
347 | + $locator->find($scripts); |
|
348 | + return $locator->getResources(); |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
353 | + * @param string $filePath Absolute path |
|
354 | + * @return string Relative path |
|
355 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
356 | + */ |
|
357 | + public static function convertToRelativePath($filePath) { |
|
358 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
359 | + if(count($relativePath) !== 2) { |
|
360 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
361 | + } |
|
362 | + |
|
363 | + return $relativePath[1]; |
|
364 | + } |
|
365 | 365 | } |
@@ -69,36 +69,36 @@ discard block |
||
69 | 69 | // yes - should be injected .... |
70 | 70 | $this->config = \OC::$server->getConfig(); |
71 | 71 | |
72 | - if(\OCP\Util::isIE()) { |
|
72 | + if (\OCP\Util::isIE()) { |
|
73 | 73 | \OC_Util::addStyle('ie'); |
74 | 74 | } |
75 | 75 | |
76 | 76 | // Decide which page we show |
77 | - if($renderAs === 'user') { |
|
78 | - parent::__construct( 'core', 'layout.user' ); |
|
79 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
77 | + if ($renderAs === 'user') { |
|
78 | + parent::__construct('core', 'layout.user'); |
|
79 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
80 | 80 | $this->assign('bodyid', 'body-settings'); |
81 | - }else{ |
|
81 | + } else { |
|
82 | 82 | $this->assign('bodyid', 'body-user'); |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Add navigation entry |
86 | - $this->assign( 'application', ''); |
|
87 | - $this->assign( 'appid', $appId ); |
|
86 | + $this->assign('application', ''); |
|
87 | + $this->assign('appid', $appId); |
|
88 | 88 | $navigation = \OC::$server->getNavigationManager()->getAll(); |
89 | - $this->assign( 'navigation', $navigation); |
|
89 | + $this->assign('navigation', $navigation); |
|
90 | 90 | $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
91 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
92 | - foreach($navigation as $entry) { |
|
91 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
92 | + foreach ($navigation as $entry) { |
|
93 | 93 | if ($entry['active']) { |
94 | - $this->assign( 'application', $entry['name'] ); |
|
94 | + $this->assign('application', $entry['name']); |
|
95 | 95 | break; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - foreach($settingsNavigation as $entry) { |
|
99 | + foreach ($settingsNavigation as $entry) { |
|
100 | 100 | if ($entry['active']) { |
101 | - $this->assign( 'application', $entry['name'] ); |
|
101 | + $this->assign('application', $entry['name']); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $this->assign('user_uid', \OC_User::getUser()); |
140 | 140 | } else if ($renderAs === 'public') { |
141 | 141 | parent::__construct('core', 'layout.public'); |
142 | - $this->assign( 'appid', $appId ); |
|
142 | + $this->assign('appid', $appId); |
|
143 | 143 | $this->assign('bodyid', 'body-public'); |
144 | 144 | |
145 | 145 | /** @var IRegistry $subscription */ |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->assign('language', $lang); |
162 | 162 | $this->assign('locale', $locale); |
163 | 163 | |
164 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
164 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
165 | 165 | if (empty(self::$versionHash)) { |
166 | 166 | $v = \OC_App::getAppVersions(); |
167 | 167 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
194 | 194 | } |
195 | 195 | } |
196 | - foreach($jsFiles as $info) { |
|
196 | + foreach ($jsFiles as $info) { |
|
197 | 197 | $web = $info[1]; |
198 | 198 | $file = $info[2]; |
199 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
199 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | try { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | // Do not initialise scss appdata until we have a fully installed instance |
209 | 209 | // Do not load scss for update, errors, installation or login page |
210 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
210 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
211 | 211 | && !\OCP\Util::needUpgrade() |
212 | 212 | && $pathInfo !== '' |
213 | 213 | && !preg_match('/^\/login/', $pathInfo) |
@@ -224,19 +224,19 @@ discard block |
||
224 | 224 | $this->assign('cssfiles', []); |
225 | 225 | $this->assign('printcssfiles', []); |
226 | 226 | $this->assign('versionHash', self::$versionHash); |
227 | - foreach($cssFiles as $info) { |
|
227 | + foreach ($cssFiles as $info) { |
|
228 | 228 | $web = $info[1]; |
229 | 229 | $file = $info[2]; |
230 | 230 | |
231 | 231 | if (substr($file, -strlen('print.css')) === 'print.css') { |
232 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
232 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
233 | 233 | } else { |
234 | 234 | $suffix = $this->getVersionHashSuffix($web, $file); |
235 | 235 | |
236 | 236 | if (strpos($file, '?v=') == false) { |
237 | - $this->append( 'cssfiles', $web.'/'.$file . $suffix); |
|
237 | + $this->append('cssfiles', $web.'/'.$file.$suffix); |
|
238 | 238 | } else { |
239 | - $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
239 | + $this->append('cssfiles', $web.'/'.$file.'-'.substr($suffix, 3)); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | if ($this->config->getSystemValue('installed', false)) { |
264 | 264 | if (\OC::$server->getAppManager()->isInstalled('theming')) { |
265 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
265 | + $themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0'); |
|
266 | 266 | } |
267 | 267 | $v = \OC_App::getAppVersions(); |
268 | 268 | } |
@@ -270,21 +270,21 @@ discard block |
||
270 | 270 | // Try the webroot path for a match |
271 | 271 | if ($path !== false && $path !== '') { |
272 | 272 | $appName = $this->getAppNamefromPath($path); |
273 | - if(array_key_exists($appName, $v)) { |
|
273 | + if (array_key_exists($appName, $v)) { |
|
274 | 274 | $appVersion = $v[$appName]; |
275 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
275 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | // fallback to the file path instead |
279 | 279 | if ($file !== false && $file !== '') { |
280 | 280 | $appName = $this->getAppNamefromPath($file); |
281 | - if(array_key_exists($appName, $v)) { |
|
281 | + if (array_key_exists($appName, $v)) { |
|
282 | 282 | $appVersion = $v[$appName]; |
283 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
283 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
287 | + return '?v='.self::$versionHash.$themingSuffix; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | // Read the selected theme from the config file |
296 | 296 | $theme = \OC_Util::getTheme(); |
297 | 297 | |
298 | - if($compileScss) { |
|
298 | + if ($compileScss) { |
|
299 | 299 | $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
300 | 300 | } else { |
301 | 301 | $SCSSCacher = null; |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | $locator = new \OC\Template\CSSResourceLocator( |
305 | 305 | \OC::$server->getLogger(), |
306 | 306 | $theme, |
307 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
308 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
307 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
308 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
309 | 309 | $SCSSCacher |
310 | 310 | ); |
311 | 311 | $locator->find($styles); |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | $locator = new \OC\Template\JSResourceLocator( |
341 | 341 | \OC::$server->getLogger(), |
342 | 342 | $theme, |
343 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
344 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
343 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
344 | + [\OC::$SERVERROOT => \OC::$WEBROOT], |
|
345 | 345 | \OC::$server->query(JSCombiner::class) |
346 | 346 | ); |
347 | 347 | $locator->find($scripts); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public static function convertToRelativePath($filePath) { |
358 | 358 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
359 | - if(count($relativePath) !== 2) { |
|
359 | + if (count($relativePath) !== 2) { |
|
360 | 360 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
361 | 361 | } |
362 | 362 |
@@ -33,49 +33,49 @@ |
||
33 | 33 | |
34 | 34 | class Account implements IAccount { |
35 | 35 | |
36 | - /** @var IAccountProperty[] */ |
|
37 | - private $properties = []; |
|
36 | + /** @var IAccountProperty[] */ |
|
37 | + private $properties = []; |
|
38 | 38 | |
39 | - /** @var IUser */ |
|
40 | - private $user; |
|
39 | + /** @var IUser */ |
|
40 | + private $user; |
|
41 | 41 | |
42 | - public function __construct(IUser $user) { |
|
43 | - $this->user = $user; |
|
44 | - } |
|
42 | + public function __construct(IUser $user) { |
|
43 | + $this->user = $user; |
|
44 | + } |
|
45 | 45 | |
46 | - public function setProperty(string $property, string $value, string $scope, string $verified): IAccount { |
|
47 | - $this->properties[$property] = new AccountProperty($property, $value, $scope, $verified); |
|
48 | - return $this; |
|
49 | - } |
|
46 | + public function setProperty(string $property, string $value, string $scope, string $verified): IAccount { |
|
47 | + $this->properties[$property] = new AccountProperty($property, $value, $scope, $verified); |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getProperty(string $property): IAccountProperty { |
|
52 | - if (!array_key_exists($property, $this->properties)) { |
|
53 | - throw new PropertyDoesNotExistException($property); |
|
54 | - } |
|
55 | - return $this->properties[$property]; |
|
56 | - } |
|
51 | + public function getProperty(string $property): IAccountProperty { |
|
52 | + if (!array_key_exists($property, $this->properties)) { |
|
53 | + throw new PropertyDoesNotExistException($property); |
|
54 | + } |
|
55 | + return $this->properties[$property]; |
|
56 | + } |
|
57 | 57 | |
58 | - public function getProperties(): array { |
|
59 | - return $this->properties; |
|
60 | - } |
|
58 | + public function getProperties(): array { |
|
59 | + return $this->properties; |
|
60 | + } |
|
61 | 61 | |
62 | - public function getFilteredProperties(string $scope = null, string $verified = null): array { |
|
63 | - return \array_filter($this->properties, function (IAccountProperty $obj) use ($scope, $verified) { |
|
64 | - if ($scope !== null && $scope !== $obj->getScope()) { |
|
65 | - return false; |
|
66 | - } |
|
67 | - if ($verified !== null && $verified !== $obj->getVerified()) { |
|
68 | - return false; |
|
69 | - } |
|
70 | - return true; |
|
71 | - }); |
|
72 | - } |
|
62 | + public function getFilteredProperties(string $scope = null, string $verified = null): array { |
|
63 | + return \array_filter($this->properties, function (IAccountProperty $obj) use ($scope, $verified) { |
|
64 | + if ($scope !== null && $scope !== $obj->getScope()) { |
|
65 | + return false; |
|
66 | + } |
|
67 | + if ($verified !== null && $verified !== $obj->getVerified()) { |
|
68 | + return false; |
|
69 | + } |
|
70 | + return true; |
|
71 | + }); |
|
72 | + } |
|
73 | 73 | |
74 | - public function jsonSerialize() { |
|
75 | - return $this->properties; |
|
76 | - } |
|
74 | + public function jsonSerialize() { |
|
75 | + return $this->properties; |
|
76 | + } |
|
77 | 77 | |
78 | - public function getUser(): IUser { |
|
79 | - return $this->user; |
|
80 | - } |
|
78 | + public function getUser(): IUser { |
|
79 | + return $this->user; |
|
80 | + } |
|
81 | 81 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public function getFilteredProperties(string $scope = null, string $verified = null): array { |
63 | - return \array_filter($this->properties, function (IAccountProperty $obj) use ($scope, $verified) { |
|
63 | + return \array_filter($this->properties, function(IAccountProperty $obj) use ($scope, $verified) { |
|
64 | 64 | if ($scope !== null && $scope !== $obj->getScope()) { |
65 | 65 | return false; |
66 | 66 | } |
@@ -26,37 +26,37 @@ |
||
26 | 26 | namespace OC\Template; |
27 | 27 | |
28 | 28 | class TemplateFileLocator { |
29 | - protected $dirs; |
|
30 | - private $path; |
|
29 | + protected $dirs; |
|
30 | + private $path; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string[] $dirs |
|
34 | - */ |
|
35 | - public function __construct($dirs) { |
|
36 | - $this->dirs = $dirs; |
|
37 | - } |
|
32 | + /** |
|
33 | + * @param string[] $dirs |
|
34 | + */ |
|
35 | + public function __construct($dirs) { |
|
36 | + $this->dirs = $dirs; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $template |
|
41 | - * @return string |
|
42 | - * @throws \Exception |
|
43 | - */ |
|
44 | - public function find($template) { |
|
45 | - if ($template === '') { |
|
46 | - throw new \InvalidArgumentException('Empty template name'); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param string $template |
|
41 | + * @return string |
|
42 | + * @throws \Exception |
|
43 | + */ |
|
44 | + public function find($template) { |
|
45 | + if ($template === '') { |
|
46 | + throw new \InvalidArgumentException('Empty template name'); |
|
47 | + } |
|
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
50 | - $file = $dir.$template.'.php'; |
|
51 | - if (is_file($file)) { |
|
52 | - $this->path = $dir; |
|
53 | - return $file; |
|
54 | - } |
|
55 | - } |
|
56 | - throw new \Exception('template file not found: template:'.$template); |
|
57 | - } |
|
49 | + foreach($this->dirs as $dir) { |
|
50 | + $file = $dir.$template.'.php'; |
|
51 | + if (is_file($file)) { |
|
52 | + $this->path = $dir; |
|
53 | + return $file; |
|
54 | + } |
|
55 | + } |
|
56 | + throw new \Exception('template file not found: template:'.$template); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getPath() { |
|
60 | - return $this->path; |
|
61 | - } |
|
59 | + public function getPath() { |
|
60 | + return $this->path; |
|
61 | + } |
|
62 | 62 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | throw new \InvalidArgumentException('Empty template name'); |
47 | 47 | } |
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
49 | + foreach ($this->dirs as $dir) { |
|
50 | 50 | $file = $dir.$template.'.php'; |
51 | 51 | if (is_file($file)) { |
52 | 52 | $this->path = $dir; |
@@ -33,160 +33,160 @@ |
||
33 | 33 | use OCP\Defaults; |
34 | 34 | |
35 | 35 | class Base { |
36 | - private $template; // The template |
|
37 | - private $vars; // Vars |
|
38 | - |
|
39 | - /** @var \OCP\IL10N */ |
|
40 | - private $l10n; |
|
41 | - |
|
42 | - /** @var Defaults */ |
|
43 | - private $theme; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param string $template |
|
47 | - * @param string $requestToken |
|
48 | - * @param \OCP\IL10N $l10n |
|
49 | - * @param Defaults $theme |
|
50 | - */ |
|
51 | - public function __construct($template, $requestToken, $l10n, $theme) { |
|
52 | - $this->vars = []; |
|
53 | - $this->vars['requesttoken'] = $requestToken; |
|
54 | - $this->l10n = $l10n; |
|
55 | - $this->template = $template; |
|
56 | - $this->theme = $theme; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @param string $serverRoot |
|
61 | - * @param string|false $app_dir |
|
62 | - * @param string $theme |
|
63 | - * @param string $app |
|
64 | - * @return string[] |
|
65 | - */ |
|
66 | - protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
67 | - // Check if the app is in the app folder or in the root |
|
68 | - if( file_exists($app_dir.'/templates/' )) { |
|
69 | - return [ |
|
70 | - $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
71 | - $app_dir.'/templates/', |
|
72 | - ]; |
|
73 | - } |
|
74 | - return [ |
|
75 | - $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
76 | - $serverRoot.'/'.$app.'/templates/', |
|
77 | - ]; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $serverRoot |
|
82 | - * @param string $theme |
|
83 | - * @return string[] |
|
84 | - */ |
|
85 | - protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
86 | - return [ |
|
87 | - $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
88 | - $serverRoot.'/core/templates/', |
|
89 | - ]; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Assign variables |
|
94 | - * @param string $key key |
|
95 | - * @param array|bool|integer|string $value value |
|
96 | - * @return bool |
|
97 | - * |
|
98 | - * This function assigns a variable. It can be accessed via $_[$key] in |
|
99 | - * the template. |
|
100 | - * |
|
101 | - * If the key existed before, it will be overwritten |
|
102 | - */ |
|
103 | - public function assign($key, $value) { |
|
104 | - $this->vars[$key] = $value; |
|
105 | - return true; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Appends a variable |
|
110 | - * @param string $key key |
|
111 | - * @param mixed $value value |
|
112 | - * |
|
113 | - * This function assigns a variable in an array context. If the key already |
|
114 | - * exists, the value will be appended. It can be accessed via |
|
115 | - * $_[$key][$position] in the template. |
|
116 | - */ |
|
117 | - public function append($key, $value) { |
|
118 | - if( array_key_exists( $key, $this->vars )) { |
|
119 | - $this->vars[$key][] = $value; |
|
120 | - } |
|
121 | - else{ |
|
122 | - $this->vars[$key] = [ $value ]; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Prints the proceeded template |
|
128 | - * @return bool |
|
129 | - * |
|
130 | - * This function proceeds the template and prints its output. |
|
131 | - */ |
|
132 | - public function printPage() { |
|
133 | - $data = $this->fetchPage(); |
|
134 | - if( $data === false ) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - else{ |
|
138 | - print $data; |
|
139 | - return true; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Process the template |
|
145 | - * |
|
146 | - * @param array|null $additionalParams |
|
147 | - * @return string This function processes the template. |
|
148 | - * |
|
149 | - * This function processes the template. |
|
150 | - */ |
|
151 | - public function fetchPage($additionalParams = null) { |
|
152 | - return $this->load($this->template, $additionalParams); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * doing the actual work |
|
157 | - * |
|
158 | - * @param string $file |
|
159 | - * @param array|null $additionalParams |
|
160 | - * @return string content |
|
161 | - * |
|
162 | - * Includes the template file, fetches its output |
|
163 | - */ |
|
164 | - protected function load($file, $additionalParams = null) { |
|
165 | - // Register the variables |
|
166 | - $_ = $this->vars; |
|
167 | - $l = $this->l10n; |
|
168 | - $theme = $this->theme; |
|
169 | - |
|
170 | - if(!is_null($additionalParams)) { |
|
171 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
172 | - foreach ($_ as $var => $value) { |
|
173 | - ${$var} = $value; |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - // Include |
|
178 | - ob_start(); |
|
179 | - try { |
|
180 | - include $file; |
|
181 | - $data = ob_get_contents(); |
|
182 | - } catch (\Exception $e) { |
|
183 | - @ob_end_clean(); |
|
184 | - throw $e; |
|
185 | - } |
|
186 | - @ob_end_clean(); |
|
187 | - |
|
188 | - // Return data |
|
189 | - return $data; |
|
190 | - } |
|
36 | + private $template; // The template |
|
37 | + private $vars; // Vars |
|
38 | + |
|
39 | + /** @var \OCP\IL10N */ |
|
40 | + private $l10n; |
|
41 | + |
|
42 | + /** @var Defaults */ |
|
43 | + private $theme; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param string $template |
|
47 | + * @param string $requestToken |
|
48 | + * @param \OCP\IL10N $l10n |
|
49 | + * @param Defaults $theme |
|
50 | + */ |
|
51 | + public function __construct($template, $requestToken, $l10n, $theme) { |
|
52 | + $this->vars = []; |
|
53 | + $this->vars['requesttoken'] = $requestToken; |
|
54 | + $this->l10n = $l10n; |
|
55 | + $this->template = $template; |
|
56 | + $this->theme = $theme; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @param string $serverRoot |
|
61 | + * @param string|false $app_dir |
|
62 | + * @param string $theme |
|
63 | + * @param string $app |
|
64 | + * @return string[] |
|
65 | + */ |
|
66 | + protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
67 | + // Check if the app is in the app folder or in the root |
|
68 | + if( file_exists($app_dir.'/templates/' )) { |
|
69 | + return [ |
|
70 | + $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
71 | + $app_dir.'/templates/', |
|
72 | + ]; |
|
73 | + } |
|
74 | + return [ |
|
75 | + $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
76 | + $serverRoot.'/'.$app.'/templates/', |
|
77 | + ]; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $serverRoot |
|
82 | + * @param string $theme |
|
83 | + * @return string[] |
|
84 | + */ |
|
85 | + protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
86 | + return [ |
|
87 | + $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
88 | + $serverRoot.'/core/templates/', |
|
89 | + ]; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Assign variables |
|
94 | + * @param string $key key |
|
95 | + * @param array|bool|integer|string $value value |
|
96 | + * @return bool |
|
97 | + * |
|
98 | + * This function assigns a variable. It can be accessed via $_[$key] in |
|
99 | + * the template. |
|
100 | + * |
|
101 | + * If the key existed before, it will be overwritten |
|
102 | + */ |
|
103 | + public function assign($key, $value) { |
|
104 | + $this->vars[$key] = $value; |
|
105 | + return true; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Appends a variable |
|
110 | + * @param string $key key |
|
111 | + * @param mixed $value value |
|
112 | + * |
|
113 | + * This function assigns a variable in an array context. If the key already |
|
114 | + * exists, the value will be appended. It can be accessed via |
|
115 | + * $_[$key][$position] in the template. |
|
116 | + */ |
|
117 | + public function append($key, $value) { |
|
118 | + if( array_key_exists( $key, $this->vars )) { |
|
119 | + $this->vars[$key][] = $value; |
|
120 | + } |
|
121 | + else{ |
|
122 | + $this->vars[$key] = [ $value ]; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Prints the proceeded template |
|
128 | + * @return bool |
|
129 | + * |
|
130 | + * This function proceeds the template and prints its output. |
|
131 | + */ |
|
132 | + public function printPage() { |
|
133 | + $data = $this->fetchPage(); |
|
134 | + if( $data === false ) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + else{ |
|
138 | + print $data; |
|
139 | + return true; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Process the template |
|
145 | + * |
|
146 | + * @param array|null $additionalParams |
|
147 | + * @return string This function processes the template. |
|
148 | + * |
|
149 | + * This function processes the template. |
|
150 | + */ |
|
151 | + public function fetchPage($additionalParams = null) { |
|
152 | + return $this->load($this->template, $additionalParams); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * doing the actual work |
|
157 | + * |
|
158 | + * @param string $file |
|
159 | + * @param array|null $additionalParams |
|
160 | + * @return string content |
|
161 | + * |
|
162 | + * Includes the template file, fetches its output |
|
163 | + */ |
|
164 | + protected function load($file, $additionalParams = null) { |
|
165 | + // Register the variables |
|
166 | + $_ = $this->vars; |
|
167 | + $l = $this->l10n; |
|
168 | + $theme = $this->theme; |
|
169 | + |
|
170 | + if(!is_null($additionalParams)) { |
|
171 | + $_ = array_merge( $additionalParams, $this->vars ); |
|
172 | + foreach ($_ as $var => $value) { |
|
173 | + ${$var} = $value; |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + // Include |
|
178 | + ob_start(); |
|
179 | + try { |
|
180 | + include $file; |
|
181 | + $data = ob_get_contents(); |
|
182 | + } catch (\Exception $e) { |
|
183 | + @ob_end_clean(); |
|
184 | + throw $e; |
|
185 | + } |
|
186 | + @ob_end_clean(); |
|
187 | + |
|
188 | + // Return data |
|
189 | + return $data; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
67 | 67 | // Check if the app is in the app folder or in the root |
68 | - if( file_exists($app_dir.'/templates/' )) { |
|
68 | + if (file_exists($app_dir.'/templates/')) { |
|
69 | 69 | return [ |
70 | 70 | $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
71 | 71 | $app_dir.'/templates/', |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | * $_[$key][$position] in the template. |
116 | 116 | */ |
117 | 117 | public function append($key, $value) { |
118 | - if( array_key_exists( $key, $this->vars )) { |
|
118 | + if (array_key_exists($key, $this->vars)) { |
|
119 | 119 | $this->vars[$key][] = $value; |
120 | 120 | } |
121 | - else{ |
|
122 | - $this->vars[$key] = [ $value ]; |
|
121 | + else { |
|
122 | + $this->vars[$key] = [$value]; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function printPage() { |
133 | 133 | $data = $this->fetchPage(); |
134 | - if( $data === false ) { |
|
134 | + if ($data === false) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | - else{ |
|
137 | + else { |
|
138 | 138 | print $data; |
139 | 139 | return true; |
140 | 140 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | $l = $this->l10n; |
168 | 168 | $theme = $this->theme; |
169 | 169 | |
170 | - if(!is_null($additionalParams)) { |
|
171 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
170 | + if (!is_null($additionalParams)) { |
|
171 | + $_ = array_merge($additionalParams, $this->vars); |
|
172 | 172 | foreach ($_ as $var => $value) { |
173 | 173 | ${$var} = $value; |
174 | 174 | } |
@@ -117,8 +117,7 @@ discard block |
||
117 | 117 | public function append($key, $value) { |
118 | 118 | if( array_key_exists( $key, $this->vars )) { |
119 | 119 | $this->vars[$key][] = $value; |
120 | - } |
|
121 | - else{ |
|
120 | + } else{ |
|
122 | 121 | $this->vars[$key] = [ $value ]; |
123 | 122 | } |
124 | 123 | } |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | $data = $this->fetchPage(); |
134 | 133 | if( $data === false ) { |
135 | 134 | return false; |
136 | - } |
|
137 | - else{ |
|
135 | + } else{ |
|
138 | 136 | print $data; |
139 | 137 | return true; |
140 | 138 | } |
@@ -29,42 +29,42 @@ |
||
29 | 29 | |
30 | 30 | class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage { |
31 | 31 | |
32 | - /** |
|
33 | - * The home user storage requires a user object to create a unique storage id |
|
34 | - * @param array $params |
|
35 | - */ |
|
36 | - public function __construct($params) { |
|
37 | - if ( ! isset($params['user']) || ! $params['user'] instanceof User) { |
|
38 | - throw new \Exception('missing user object in parameters'); |
|
39 | - } |
|
40 | - $this->user = $params['user']; |
|
41 | - parent::__construct($params); |
|
42 | - } |
|
32 | + /** |
|
33 | + * The home user storage requires a user object to create a unique storage id |
|
34 | + * @param array $params |
|
35 | + */ |
|
36 | + public function __construct($params) { |
|
37 | + if ( ! isset($params['user']) || ! $params['user'] instanceof User) { |
|
38 | + throw new \Exception('missing user object in parameters'); |
|
39 | + } |
|
40 | + $this->user = $params['user']; |
|
41 | + parent::__construct($params); |
|
42 | + } |
|
43 | 43 | |
44 | - public function getId() { |
|
45 | - return 'object::user:' . $this->user->getUID(); |
|
46 | - } |
|
44 | + public function getId() { |
|
45 | + return 'object::user:' . $this->user->getUID(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * get the owner of a path |
|
50 | - * |
|
51 | - * @param string $path The path to get the owner |
|
52 | - * @return false|string uid |
|
53 | - */ |
|
54 | - public function getOwner($path) { |
|
55 | - if (is_object($this->user)) { |
|
56 | - return $this->user->getUID(); |
|
57 | - } |
|
58 | - return false; |
|
59 | - } |
|
48 | + /** |
|
49 | + * get the owner of a path |
|
50 | + * |
|
51 | + * @param string $path The path to get the owner |
|
52 | + * @return false|string uid |
|
53 | + */ |
|
54 | + public function getOwner($path) { |
|
55 | + if (is_object($this->user)) { |
|
56 | + return $this->user->getUID(); |
|
57 | + } |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $path, optional |
|
63 | - * @return \OC\User\User |
|
64 | - */ |
|
65 | - public function getUser($path = null) { |
|
66 | - return $this->user; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @param string $path, optional |
|
63 | + * @return \OC\User\User |
|
64 | + */ |
|
65 | + public function getUser($path = null) { |
|
66 | + return $this->user; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | 70 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $params |
35 | 35 | */ |
36 | 36 | public function __construct($params) { |
37 | - if ( ! isset($params['user']) || ! $params['user'] instanceof User) { |
|
37 | + if (!isset($params['user']) || !$params['user'] instanceof User) { |
|
38 | 38 | throw new \Exception('missing user object in parameters'); |
39 | 39 | } |
40 | 40 | $this->user = $params['user']; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | public function getId() { |
45 | - return 'object::user:' . $this->user->getUID(); |
|
45 | + return 'object::user:'.$this->user->getUID(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -33,53 +33,53 @@ |
||
33 | 33 | namespace OC\Files\Storage; |
34 | 34 | |
35 | 35 | class CommonTest extends \OC\Files\Storage\Common{ |
36 | - /** |
|
37 | - * underlying local storage used for missing functions |
|
38 | - * @var \OC\Files\Storage\Local |
|
39 | - */ |
|
40 | - private $storage; |
|
36 | + /** |
|
37 | + * underlying local storage used for missing functions |
|
38 | + * @var \OC\Files\Storage\Local |
|
39 | + */ |
|
40 | + private $storage; |
|
41 | 41 | |
42 | - public function __construct($params) { |
|
43 | - $this->storage=new \OC\Files\Storage\Local($params); |
|
44 | - } |
|
42 | + public function __construct($params) { |
|
43 | + $this->storage=new \OC\Files\Storage\Local($params); |
|
44 | + } |
|
45 | 45 | |
46 | - public function getId() { |
|
47 | - return 'test::'.$this->storage->getId(); |
|
48 | - } |
|
49 | - public function mkdir($path) { |
|
50 | - return $this->storage->mkdir($path); |
|
51 | - } |
|
52 | - public function rmdir($path) { |
|
53 | - return $this->storage->rmdir($path); |
|
54 | - } |
|
55 | - public function opendir($path) { |
|
56 | - return $this->storage->opendir($path); |
|
57 | - } |
|
58 | - public function stat($path) { |
|
59 | - return $this->storage->stat($path); |
|
60 | - } |
|
61 | - public function filetype($path) { |
|
62 | - return @$this->storage->filetype($path); |
|
63 | - } |
|
64 | - public function isReadable($path) { |
|
65 | - return $this->storage->isReadable($path); |
|
66 | - } |
|
67 | - public function isUpdatable($path) { |
|
68 | - return $this->storage->isUpdatable($path); |
|
69 | - } |
|
70 | - public function file_exists($path) { |
|
71 | - return $this->storage->file_exists($path); |
|
72 | - } |
|
73 | - public function unlink($path) { |
|
74 | - return $this->storage->unlink($path); |
|
75 | - } |
|
76 | - public function fopen($path, $mode) { |
|
77 | - return $this->storage->fopen($path, $mode); |
|
78 | - } |
|
79 | - public function free_space($path) { |
|
80 | - return $this->storage->free_space($path); |
|
81 | - } |
|
82 | - public function touch($path, $mtime=null) { |
|
83 | - return $this->storage->touch($path, $mtime); |
|
84 | - } |
|
46 | + public function getId() { |
|
47 | + return 'test::'.$this->storage->getId(); |
|
48 | + } |
|
49 | + public function mkdir($path) { |
|
50 | + return $this->storage->mkdir($path); |
|
51 | + } |
|
52 | + public function rmdir($path) { |
|
53 | + return $this->storage->rmdir($path); |
|
54 | + } |
|
55 | + public function opendir($path) { |
|
56 | + return $this->storage->opendir($path); |
|
57 | + } |
|
58 | + public function stat($path) { |
|
59 | + return $this->storage->stat($path); |
|
60 | + } |
|
61 | + public function filetype($path) { |
|
62 | + return @$this->storage->filetype($path); |
|
63 | + } |
|
64 | + public function isReadable($path) { |
|
65 | + return $this->storage->isReadable($path); |
|
66 | + } |
|
67 | + public function isUpdatable($path) { |
|
68 | + return $this->storage->isUpdatable($path); |
|
69 | + } |
|
70 | + public function file_exists($path) { |
|
71 | + return $this->storage->file_exists($path); |
|
72 | + } |
|
73 | + public function unlink($path) { |
|
74 | + return $this->storage->unlink($path); |
|
75 | + } |
|
76 | + public function fopen($path, $mode) { |
|
77 | + return $this->storage->fopen($path, $mode); |
|
78 | + } |
|
79 | + public function free_space($path) { |
|
80 | + return $this->storage->free_space($path); |
|
81 | + } |
|
82 | + public function touch($path, $mtime=null) { |
|
83 | + return $this->storage->touch($path, $mtime); |
|
84 | + } |
|
85 | 85 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | namespace OC\Files\Storage; |
34 | 34 | |
35 | -class CommonTest extends \OC\Files\Storage\Common{ |
|
35 | +class CommonTest extends \OC\Files\Storage\Common { |
|
36 | 36 | /** |
37 | 37 | * underlying local storage used for missing functions |
38 | 38 | * @var \OC\Files\Storage\Local |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | private $storage; |
41 | 41 | |
42 | 42 | public function __construct($params) { |
43 | - $this->storage=new \OC\Files\Storage\Local($params); |
|
43 | + $this->storage = new \OC\Files\Storage\Local($params); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function getId() { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function free_space($path) { |
80 | 80 | return $this->storage->free_space($path); |
81 | 81 | } |
82 | - public function touch($path, $mtime=null) { |
|
82 | + public function touch($path, $mtime = null) { |
|
83 | 83 | return $this->storage->touch($path, $mtime); |
84 | 84 | } |
85 | 85 | } |