|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Joas Schilling <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license AGPL-3.0 |
|
8
|
|
|
* |
|
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
11
|
|
|
* as published by the Free Software Foundation. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace OCA\Activity\AppInfo; |
|
24
|
|
|
|
|
25
|
|
|
use OC\Files\View; |
|
26
|
|
|
use OCA\Activity\Capabilities; |
|
27
|
|
|
use OCA\Activity\Consumer; |
|
28
|
|
|
use OCA\Activity\Controller\Activities; |
|
29
|
|
|
use OCA\Activity\Controller\APIv1; |
|
30
|
|
|
use OCA\Activity\Controller\APIv2; |
|
31
|
|
|
use OCA\Activity\Controller\Feed; |
|
32
|
|
|
use OCA\Activity\Controller\RemoteActivity; |
|
33
|
|
|
use OCA\Activity\Controller\Settings; |
|
34
|
|
|
use OCA\Activity\FilesHooksStatic; |
|
35
|
|
|
use OCA\Activity\Hooks; |
|
36
|
|
|
use OCP\AppFramework\App; |
|
37
|
|
|
use OCP\IL10N; |
|
38
|
|
|
use OCP\Util; |
|
39
|
|
|
|
|
40
|
|
|
class Application extends App { |
|
41
|
47 |
|
public function __construct () { |
|
42
|
47 |
|
parent::__construct('activity'); |
|
43
|
47 |
|
$container = $this->getContainer(); |
|
44
|
|
|
|
|
45
|
|
|
// Allow automatic DI for the View, until we migrated to Nodes API |
|
46
|
47 |
|
$container->registerService(View::class, function() { |
|
47
|
23 |
|
return new View(''); |
|
48
|
47 |
|
}, false); |
|
49
|
47 |
|
$container->registerService('isCLI', function() { |
|
50
|
2 |
|
return \OC::$CLI; |
|
51
|
47 |
|
}); |
|
52
|
|
|
|
|
53
|
|
|
// Aliases for the controllers so we can use the automatic DI |
|
54
|
47 |
|
$container->registerAlias('ActivitiesController', Activities::class); |
|
55
|
47 |
|
$container->registerAlias('APIv1Controller', APIv1::class); |
|
56
|
47 |
|
$container->registerAlias('APIv2Controller', APIv2::class); |
|
57
|
47 |
|
$container->registerAlias('FeedController', Feed::class); |
|
58
|
47 |
|
$container->registerAlias('RemoteActivityController', RemoteActivity::class); |
|
59
|
47 |
|
$container->registerAlias('SettingsController', Settings::class); |
|
60
|
|
|
|
|
61
|
47 |
|
$container->registerCapability(Capabilities::class); |
|
62
|
47 |
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Register the different app parts |
|
66
|
|
|
*/ |
|
67
|
|
|
public function register() { |
|
68
|
|
|
$this->registerActivityConsumer(); |
|
69
|
|
|
$this->registerHooksAndEvents(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Registers the consumer to the Activity Manager |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function registerActivityConsumer() { |
|
76
|
|
|
$c = $this->getContainer(); |
|
77
|
|
|
/** @var \OCP\IServerContainer $server */ |
|
78
|
|
|
$server = $c->getServer(); |
|
79
|
|
|
|
|
80
|
1 |
|
$server->getActivityManager()->registerConsumer(function() use ($c) { |
|
81
|
1 |
|
return $c->query(Consumer::class); |
|
82
|
|
|
}); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Register the hooks and events |
|
87
|
|
|
*/ |
|
88
|
|
|
public function registerHooksAndEvents() { |
|
89
|
|
|
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
90
|
|
|
$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', [Hooks::class, 'onLoadFilesAppScripts']); |
|
91
|
|
|
|
|
92
|
|
|
Util::connectHook('OC_User', 'post_deleteUser', Hooks::class, 'deleteUser'); |
|
93
|
|
|
Util::connectHook('OC_User', 'post_login', Hooks::class, 'setDefaultsForUser'); |
|
94
|
|
|
|
|
95
|
|
|
$this->registerFilesActivity(); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Register the hooks for filesystem operations |
|
100
|
|
|
*/ |
|
101
|
|
|
public function registerFilesActivity() { |
|
102
|
|
|
// All other events from other apps have to be send via the Consumer |
|
103
|
|
|
Util::connectHook('OC_Filesystem', 'post_create', FilesHooksStatic::class, 'fileCreate'); |
|
104
|
|
|
Util::connectHook('OC_Filesystem', 'post_update', FilesHooksStatic::class, 'fileUpdate'); |
|
105
|
|
|
Util::connectHook('OC_Filesystem', 'delete', FilesHooksStatic::class, 'fileDelete'); |
|
106
|
|
|
Util::connectHook('OC_Filesystem', 'rename', FilesHooksStatic::class, 'fileMove'); |
|
107
|
|
|
Util::connectHook('OC_Filesystem', 'post_rename', FilesHooksStatic::class, 'fileMovePost'); |
|
108
|
|
|
Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', FilesHooksStatic::class, 'fileRestore'); |
|
109
|
|
|
Util::connectHook('OCP\Share', 'post_shared', FilesHooksStatic::class, 'share'); |
|
110
|
|
|
|
|
111
|
|
|
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
112
|
|
|
$eventDispatcher->addListener('OCP\Share::preUnshare', [FilesHooksStatic::class, 'unShare']); |
|
113
|
|
|
$eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [FilesHooksStatic::class, 'unShare']); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|