1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
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\Notifications\AppInfo; |
23
|
|
|
|
24
|
|
|
use OC\Authentication\Token\IProvider; |
25
|
|
|
use OCA\Notifications\App; |
26
|
|
|
use OCA\Notifications\Capabilities; |
27
|
|
|
use OCA\Notifications\Controller\EndpointController; |
28
|
|
|
use OCP\AppFramework\IAppContainer; |
29
|
|
|
use OCP\Util; |
30
|
|
|
|
31
|
|
|
class Application extends \OCP\AppFramework\App { |
32
|
16 |
|
public function __construct() { |
33
|
16 |
|
parent::__construct('notifications'); |
34
|
16 |
|
$container = $this->getContainer(); |
35
|
|
|
|
36
|
16 |
|
$container->registerCapability(Capabilities::class); |
37
|
|
|
|
38
|
|
|
// FIXME this is for automatic DI because it is not in DIContainer |
39
|
16 |
|
$container->registerService(IProvider::class, function(IAppContainer $c) { |
40
|
6 |
|
return $c->getServer()->query(IProvider::class); |
41
|
16 |
|
}); |
42
|
16 |
|
} |
43
|
|
|
|
44
|
6 |
|
public function register() { |
45
|
6 |
|
$this->registerNotificationApp(); |
46
|
6 |
|
$this->registerUserInterface(); |
47
|
6 |
|
} |
48
|
|
|
|
49
|
6 |
|
protected function registerNotificationApp() { |
50
|
6 |
|
$container = $this->getContainer(); |
51
|
6 |
|
$container->getServer()->getNotificationManager()->registerApp(function() use($container) { |
52
|
1 |
|
return $container->query(App::class); |
53
|
6 |
|
}); |
54
|
6 |
|
} |
55
|
|
|
|
56
|
6 |
|
protected function registerUserInterface() { |
57
|
|
|
// Only display the app on index.php except for public shares |
58
|
6 |
|
$server = $this->getContainer()->getServer(); |
59
|
6 |
|
$request = $server->getRequest(); |
60
|
|
|
|
61
|
6 |
|
if ($server->getUserSession()->getUser() !== null |
62
|
6 |
|
&& substr($request->getScriptName(), 0 - strlen('/index.php')) === '/index.php' |
63
|
6 |
|
&& substr($request->getPathInfo(), 0, strlen('/s/')) !== '/s/' |
64
|
6 |
|
&& substr($request->getPathInfo(), 0, strlen('/login/')) !== '/login/') { |
65
|
|
|
|
66
|
1 |
|
if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
67
|
|
|
Util::addScript('notifications', 'vue'); |
68
|
|
|
} else { |
69
|
1 |
|
Util::addScript('notifications', 'vue.min'); |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
Util::addScript('notifications', 'merged'); |
73
|
1 |
|
Util::addStyle('notifications', 'styles'); |
74
|
|
|
} |
75
|
|
|
|
76
|
6 |
|
} |
77
|
|
|
} |
78
|
|
|
|