Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/comments/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
*/

$application = new \OCA\Comments\AppInfo\Application();
$application->register();
1 change: 1 addition & 0 deletions apps/comments/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'OCA\\Comments\\EventHandler' => $baseDir . '/../lib/EventHandler.php',
'OCA\\Comments\\JSSettingsHelper' => $baseDir . '/../lib/JSSettingsHelper.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Comments\\Listener\\LoadSidebarScript' => $baseDir . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Comments\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Comments\\Search\\Provider' => $baseDir . '/../lib/Search/Provider.php',
Expand Down
1 change: 1 addition & 0 deletions apps/comments/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ComposerStaticInitComments
'OCA\\Comments\\EventHandler' => __DIR__ . '/..' . '/../lib/EventHandler.php',
'OCA\\Comments\\JSSettingsHelper' => __DIR__ . '/..' . '/../lib/JSSettingsHelper.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Comments\\Listener\\LoadSidebarScript' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Comments\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
'OCA\\Comments\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Comments\\Search\\Provider' => __DIR__ . '/..' . '/../lib/Search/Provider.php',
Expand Down
28 changes: 17 additions & 11 deletions apps/comments/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,49 @@
use OCA\Comments\Notification\Notifier;
use OCA\Comments\Search\Provider;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCP\AppFramework\App;
use OCP\Comments\CommentsEntityEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Util;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class Application extends App {

const appID = 'comments';

public function __construct (array $urlParams = array()) {
parent::__construct('comments', $urlParams);
parent::__construct(self::appID, $urlParams);

$container = $this->getContainer();

$container->registerAlias('NotificationsController', Notifications::class);

$jsSettingsHelper = new JSSettingsHelper($container->getServer());
Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');

$this->register();
}

public function register() {
$server = $this->getContainer()->getServer();
$container = $this->getContainer();
$server = $container->getServer();
$eventDispatcher = $server->query(IEventDispatcher::class);

/** @var IEventDispatcher $newDispatcher */
$dispatcher = $server->query(IEventDispatcher::class);
$this->registerSidebarScripts($dispatcher);
$this->registerDavEntity($dispatcher);
$this->registerSidebarScripts($eventDispatcher);
$this->registerDavEntity($eventDispatcher);
$this->registerNotifier();
$this->registerCommentsEventHandler();

$server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
}

protected function registerSidebarScripts(IEventDispatcher $dispatcher) {
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
protected function registerSidebarScripts(IEventDispatcher $eventDispatcher) {
$eventDispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
$eventDispatcher->addServiceListener(LoadSidebar::class, LoadSidebarScript::class);
}

protected function registerDavEntity(IEventDispatcher $dispatcher) {
$dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
protected function registerDavEntity(IEventDispatcher $eventDispatcher) {
$eventDispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
$event->addEntityCollection('files', function($name) {
$nodes = \OC::$server->getUserFolder()->getById((int)$name);
return !empty($nodes);
Expand Down
44 changes: 44 additions & 0 deletions apps/comments/lib/Listener/LoadSidebarScript.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Comments\Listener;

use OCA\Comments\AppInfo\Application;
use OCA\Files\Event\LoadSidebar;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class LoadSidebarScript implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
}

// Comments is not migrated to vue and still uses only ONE
// entry point for the files plugin and the sidebar scripts
// TODO: when properly split, make sure to adapt this script
// TODO: and only load the necessary files
Util::addScript(Application::appID, 'comments');
}
}
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
'OCA\\Files\\Event\\LoadSidebar' => $baseDir . '/../lib/Event/LoadSidebar.php',
'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarScript' => $baseDir . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php',
);
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Event\\LoadSidebar' => __DIR__ . '/..' . '/../lib/Event/LoadSidebar.php',
'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarScript' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php',
);

Expand Down
31 changes: 21 additions & 10 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand All @@ -24,25 +25,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files\AppInfo;

use OCA\Files\Activity\Helper;
use OCA\Files\Service\TagService;
use OCP\IContainer;
use OCA\Files\Capabilities;
use OCA\Files\Collaboration\Resources\Listener;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\Controller\ApiController;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
use OCA\Files\Listener\LoadSidebarScript;
use OCP\AppFramework\App;
use \OCA\Files\Service\TagService;
use OCP\Collaboration\Resources\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use \OCP\IContainer;
use OCA\Files\Controller\ViewController;
use OCA\Files\Capabilities;

class Application extends App {
public function __construct(array $urlParams=array()) {
parent::__construct('files', $urlParams);

const appID = 'files';

public function __construct(array $urlParams = []) {

parent::__construct(self::appID, $urlParams);

$container = $this->getContainer();
$server = $container->getServer();

Expand All @@ -65,7 +72,7 @@ public function __construct(array $urlParams=array()) {
/**
* Services
*/
$container->registerService('TagService', function(IContainer $c) use ($server) {
$container->registerService('TagService', function (IContainer $c) use ($server) {
$homeFolder = $c->query('ServerContainer')->getUserFolder();
return new TagService(
$c->query('ServerContainer')->getUserSession(),
Expand All @@ -89,8 +96,12 @@ public function __construct(array $urlParams=array()) {
$resourceManager->registerResourceProvider(ResourceProvider::class);
Listener::register($server->getEventDispatcher());

/**
* Register Events listeners
*/
/** @var IEventDispatcher $dispatcher */
$dispatcher = $container->query(IEventDispatcher::class);
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
$eventDispatcher = $container->query(IEventDispatcher::class);
$eventDispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
$eventDispatcher->addServiceListener(LoadSidebar::class, LoadSidebarScript::class);
}
}
40 changes: 40 additions & 0 deletions apps/files/lib/Listener/LoadSidebarScript.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Files\Listener;

use OCA\Files\AppInfo\Application;
use OCA\Files\Event\LoadSidebar;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class LoadSidebarScript implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
}

Util::addScript(Application::appID, 'dist/sidebar');
}
}
15 changes: 1 addition & 14 deletions apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,7 @@
\OC\Share\Share::registerBackend('file', File::class);
\OC\Share\Share::registerBackend('folder', Folder::class, 'file');

$application = new \OCA\Files_Sharing\AppInfo\Application();
$application->registerMountProviders();

$eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener(
'OCA\Files::loadAdditionalScripts',
function() {
\OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
\OCP\Util::addStyle('files_sharing', 'icons');
}
);
\OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
\OCP\Util::addScript('files_sharing', 'dist/collaboration');
});
\OC::$server->query(\OCA\Files_Sharing\AppInfo\Application::class);

$config = \OC::$server->getConfig();
$shareManager = \OC::$server->getShareManager();
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php',
'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php',
'OCA\\Files_Sharing\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Files_Sharing\\Listener\\LoadSidebarScript' => $baseDir . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php',
'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php',
'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir . '/../lib/Middleware/SharingCheckMiddleware.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ComposerStaticInitFiles_Sharing
'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php',
'OCA\\Files_Sharing\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
'OCA\\Files_Sharing\\Listener\\LoadSidebarScript' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScript.php',
'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php',
'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php',
'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SharingCheckMiddleware.php',
Expand Down
57 changes: 48 additions & 9 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,33 @@

namespace OCA\Files_Sharing\AppInfo;

use OCA\Files_Sharing\Middleware\OCSShareAPIMiddleware;
use OCA\Files_Sharing\Middleware\ShareInfoMiddleware;
use OCA\Files_Sharing\MountProvider;
use OCP\AppFramework\App;
use OC\AppFramework\Utility\SimpleContainer;
use OCA\Files_Sharing\Capabilities;
use OCA\Files_Sharing\Controller\ExternalSharesController;
use OCA\Files_Sharing\Controller\ShareController;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\Listener\LoadAdditionalScripts;
use OCA\Files_Sharing\Listener\LoadSidebarScript;
use OCA\Files_Sharing\Middleware\OCSShareAPIMiddleware;
use OCA\Files_Sharing\Middleware\ShareInfoMiddleware;
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
use OCA\Files_Sharing\MountProvider;
use OCA\Files\Event\LoadSidebar;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use \OCP\IContainer;
use OCP\IContainer;
use OCP\IServerContainer;
use OCA\Files_Sharing\Capabilities;
use OCA\Files_Sharing\External\Manager;

class Application extends App {

const appID = 'files_sharing';

public function __construct(array $urlParams = array()) {
parent::__construct('files_sharing', $urlParams);
parent::__construct(self::appID, $urlParams);

$container = $this->getContainer();
/** @var IServerContainer $server */
Expand Down Expand Up @@ -160,10 +168,21 @@ function() use ($c) {
);
});

/*
/**
* Register capabilities
*/
$container->registerCapability(Capabilities::class);

/**
* Register mounts providers
*/
$this->registerMountProviders();

/**
* Register events
*/
$this->registerEvents();

}

public function registerMountProviders() {
Expand All @@ -173,4 +192,24 @@ public function registerMountProviders() {
$mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider'));
$mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
}

/**
* Register events
*/
public function registerEvents() {
$container = $this->getContainer();
$server = $container->getServer();
$eventDispatcher = $server->query(IEventDispatcher::class);

$eventDispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);

$eventDispatcher->addListener(
'\OCP\Collaboration\Resources::loadAdditionalScripts',
function () {
\OCP\Util::addScript('files_sharing', 'dist/collaboration');
}
);

$eventDispatcher->addServiceListener(LoadSidebar::class, LoadSidebarScript::class);
}
}
Loading