|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Piotr Mrowczynski <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) 2017, ownCloud GmbH |
|
6
|
|
|
* @license AGPL-3.0 |
|
7
|
|
|
* |
|
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
10
|
|
|
* as published by the Free Software Foundation. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace OCA\Files_PaperHive\AppInfo; |
|
23
|
|
|
|
|
24
|
|
|
use OC\Files\View; |
|
25
|
|
|
use OCA\Files_PaperHive\PaperHiveMetadata; |
|
26
|
|
|
use OCP\AppFramework\App; |
|
27
|
|
|
use OCA\Files_PaperHive\Controller\PaperHiveController; |
|
28
|
|
|
use OCP\AppFramework\IAppContainer; |
|
29
|
|
|
|
|
30
|
|
|
class Application extends App { |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param array $urlParams |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(array $urlParams = array()) { |
|
36
|
|
|
parent::__construct('files_paperhive', $urlParams); |
|
37
|
|
|
$this->registerServices(); |
|
38
|
|
|
$this->registerHooks(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
private function registerServices() { |
|
42
|
|
|
$container = $this->getContainer(); |
|
43
|
|
|
$server = $container->getServer(); |
|
44
|
|
|
|
|
45
|
|
|
$container->registerService('PaperHiveController', function (IAppContainer $c) use ($server) { |
|
46
|
|
|
$user = $server->getUserSession()->getUser(); |
|
47
|
|
|
if ($user) { |
|
48
|
|
|
$uid = $user->getUID(); |
|
49
|
|
|
} else { |
|
50
|
|
|
throw new \BadMethodCallException('no user logged in'); |
|
51
|
|
|
} |
|
52
|
|
|
return new PaperHiveController( |
|
53
|
|
|
$c->getAppName(), |
|
54
|
|
|
$server->getRequest(), |
|
55
|
|
|
$server->getL10N($c->getAppName()), |
|
56
|
|
|
new View('/' . $uid . '/files'), |
|
57
|
|
|
$server->getLogger(), |
|
58
|
|
|
\OC::$server->getHTTPClientService()->newClient(), |
|
59
|
|
|
new PaperHiveMetadata( |
|
60
|
|
|
\OC::$server->getDatabaseConnection(), |
|
61
|
|
|
\OC::$server->getLogger() |
|
62
|
|
|
) |
|
63
|
|
|
); |
|
64
|
|
|
}); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
private function registerHooks() { |
|
68
|
|
|
\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_PaperHive\Hooks', 'delete_metadata_hook'); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|