summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php32
-rw-r--r--apps/files/js/breadcrumb.js5
-rw-r--r--apps/files_sharing/js/public.js2
-rw-r--r--apps/systemtags/js/filesplugin.js4
-rw-r--r--apps/systemtags/js/systemtagsinfoviewtoggleview.js1
-rw-r--r--core/js/js.js27
-rw-r--r--lib/private/Calendar/Resource/Manager.php54
-rw-r--r--lib/private/Calendar/Room/Manager.php54
-rw-r--r--lib/public/Calendar/Resource/IManager.php12
-rw-r--r--lib/public/Calendar/Room/IManager.php12
-rw-r--r--tests/lib/Calendar/Resource/ManagerTest.php45
-rw-r--r--tests/lib/Calendar/Room/ManagerTest.php45
12 files changed, 197 insertions, 96 deletions
diff --git a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
index c5f8f6586e9..3a9e3def05d 100644
--- a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
+++ b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
@@ -113,8 +113,12 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
foreach($sortedResources['new'] as $backendId => $newResources) {
foreach ($newResources as $newResource) {
- $resource = $this->resourceManager->getBackend($backendId)
- ->getResource($newResource);
+ $backend = $this->resourceManager->getBackend($backendId);
+ if ($backend === null) {
+ continue;
+ }
+
+ $resource = $backend->getResource($newResource);
$this->addToCache($this->resourceDbTable, $resource);
}
}
@@ -126,8 +130,12 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
}
foreach($sortedResources['edited'] as $backendId => $editedResources) {
foreach ($editedResources as $editedResource) {
- $resource = $this->resourceManager->getBackend($backendId)
- ->getResource($editedResource);
+ $backend = $this->resourceManager->getBackend($backendId);
+ if ($backend === null) {
+ continue;
+ }
+
+ $resource = $backend->getResource($editedResource);
$this->updateCache($this->resourceDbTable, $resource);
}
}
@@ -157,8 +165,12 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
foreach($sortedRooms['new'] as $backendId => $newRooms) {
foreach ($newRooms as $newRoom) {
- $resource = $this->roomManager->getBackend($backendId)
- ->getRoom($newRoom);
+ $backend = $this->roomManager->getBackend($backendId);
+ if ($backend === null) {
+ continue;
+ }
+
+ $resource = $backend->getRoom($newRoom);
$this->addToCache($this->roomDbTable, $resource);
}
}
@@ -170,8 +182,12 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
}
foreach($sortedRooms['edited'] as $backendId => $editedRooms) {
foreach ($editedRooms as $editedRoom) {
- $resource = $this->roomManager->getBackend($backendId)
- ->getRoom($editedRoom);
+ $backend = $this->roomManager->getBackend($backendId);
+ if ($backend === null) {
+ continue;
+ }
+
+ $resource = $backend->getRoom($editedRoom);
$this->updateCache($this->roomDbTable, $resource);
}
}
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 319425b67bd..e1193e79b28 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -178,11 +178,6 @@
$crumb.append(view.$el);
}, this);
- // in case svg is not supported by the browser we need to execute the fallback mechanism
- if (!OC.Util.hasSVGSupport()) {
- OC.Util.replaceSVG(this.$el);
- }
-
// setup drag and drop
if (this.onDrop) {
this.$el.find('.crumb:not(:last-child):not(.crumbmenu), .crumblist:not(:last-child)').droppable({
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 64ffe8bbf2e..3328b1663d1 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -168,7 +168,7 @@ OCA.Sharing.PublicApp = {
img.attr('src', OC.generateUrl('/apps/files_sharing/publicpreview/' + token + '?' + OC.buildQueryString(params)));
imgcontainer.appendTo('#imgframe');
} else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') {
- img.attr('src', OC.Util.replaceSVGIcon(mimetypeIcon));
+ img.attr('src', mimetypeIcon);
img.attr('width', 128);
imgcontainer.appendTo('#imgframe');
}
diff --git a/apps/systemtags/js/filesplugin.js b/apps/systemtags/js/filesplugin.js
index fc2a227b5be..ca706775121 100644
--- a/apps/systemtags/js/filesplugin.js
+++ b/apps/systemtags/js/filesplugin.js
@@ -49,10 +49,10 @@
systemTagsInfoViewToggleView.$el.detach();
});
systemTagsInfoViewToggleView.listenTo(detailView, 'post-render', function() {
+ var clicker = _.bind(systemTagsInfoViewToggleView.click, systemTagsInfoViewToggleView);
+ systemTagsInfoViewToggleView.$el.click(clicker);
detailView.$el.find('.file-details').append(systemTagsInfoViewToggleView.$el);
});
-
- return;
}
});
}
diff --git a/apps/systemtags/js/systemtagsinfoviewtoggleview.js b/apps/systemtags/js/systemtagsinfoviewtoggleview.js
index a3261e7994d..ec9ac1a216b 100644
--- a/apps/systemtags/js/systemtagsinfoviewtoggleview.js
+++ b/apps/systemtags/js/systemtagsinfoviewtoggleview.js
@@ -56,7 +56,6 @@
* references the SystemTagsInfoView to associate to this toggle view.
*/
initialize: function(options) {
- var self = this;
options = options || {};
this._systemTagsInfoView = options.systemTagsInfoView;
diff --git a/core/js/js.js b/core/js/js.js
index 2527f474ea3..bc6c0781754 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1981,33 +1981,6 @@ OC.Util = {
}
return moment(timestamp).fromNow();
},
- /**
- * Returns whether the browser supports SVG
- * @deprecated SVG is always supported (since 9.0)
- * @return {boolean} true if the browser supports SVG, false otherwise
- */
- hasSVGSupport: function(){
- return true;
- },
- /**
- * If SVG is not supported, replaces the given icon's extension
- * from ".svg" to ".png".
- * If SVG is supported, return the image path as is.
- * @param {string} file image path with svg extension
- * @deprecated SVG is always supported (since 9.0)
- * @return {string} fixed image path with png extension if SVG is not supported
- */
- replaceSVGIcon: function(file) {
- return file;
- },
- /**
- * Replace SVG images in all elements that have the "svg" class set
- * with PNG images.
- *
- * @param $el root element from which to search, defaults to $('body')
- * @deprecated SVG is always supported (since 9.0)
- */
- replaceSVG: function($el) {},
/**
* Fix image scaling for IE8, since background-size is not supported.
diff --git a/lib/private/Calendar/Resource/Manager.php b/lib/private/Calendar/Resource/Manager.php
index baa8117e85a..224ca2a4390 100644
--- a/lib/private/Calendar/Resource/Manager.php
+++ b/lib/private/Calendar/Resource/Manager.php
@@ -24,52 +24,81 @@
namespace OC\Calendar\Resource;
use OCP\Calendar\Resource\IBackend;
+use OCP\IServerContainer;
class Manager implements \OCP\Calendar\Resource\IManager {
- /** @var IBackend[] holds all registered resource backends */
+ /** @var IServerContainer */
+ private $server;
+
+ /** @var string[] holds all registered resource backends */
private $backends = [];
+ /** @var IBackend[] holds all backends that have been initialized already */
+ private $initializedBackends = [];
+
+ /**
+ * Manager constructor.
+ *
+ * @param IServerContainer $server
+ */
+ public function __construct(IServerContainer $server) {
+ $this->server = $server;
+ }
+
/**
* Registers a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function registerBackend(IBackend $backend) {
- $this->backends[$backend->getBackendIdentifier()] = $backend;
+ public function registerBackend(string $backendClass) {
+ $this->backends[$backendClass] = $backendClass;
}
/**
* Unregisters a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function unregisterBackend(IBackend $backend) {
- unset($this->backends[$backend->getBackendIdentifier()]);
+ public function unregisterBackend(string $backendClass) {
+ unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]);
}
/**
* @return IBackend[]
+ * @throws \OCP\AppFramework\QueryException
* @since 14.0.0
*/
public function getBackends():array {
- return array_values($this->backends);
+ foreach($this->backends as $backend) {
+ if (isset($this->initializedBackends[$backend])) {
+ continue;
+ }
+
+ $this->initializedBackends[$backend] = $this->server->query($backend);
+ }
+
+ return array_values($this->initializedBackends);
}
/**
* @param string $backendId
+ * @throws \OCP\AppFramework\QueryException
* @return IBackend|null
*/
- public function getBackend($backendId):IBackend {
- if (!isset($this->backends[$backendId])) {
- return null;
+ public function getBackend($backendId) {
+ $backends = $this->getBackends();
+ foreach($backends as $backend) {
+ if ($backend->getBackendIdentifier() === $backendId) {
+ return $backend;
+ }
}
- return $this->backends[$backendId];
+ return null;
}
/**
@@ -79,5 +108,6 @@ class Manager implements \OCP\Calendar\Resource\IManager {
*/
public function clear() {
$this->backends = [];
+ $this->initializedBackends = [];
}
}
diff --git a/lib/private/Calendar/Room/Manager.php b/lib/private/Calendar/Room/Manager.php
index aef9f2ed32b..d73b52cfb16 100644
--- a/lib/private/Calendar/Room/Manager.php
+++ b/lib/private/Calendar/Room/Manager.php
@@ -24,52 +24,81 @@
namespace OC\Calendar\Room;
use OCP\Calendar\Room\IBackend;
+use OCP\IServerContainer;
class Manager implements \OCP\Calendar\Room\IManager {
- /** @var IBackend[] holds all registered resource backends */
+ /** @var IServerContainer */
+ private $server;
+
+ /** @var string[] holds all registered resource backends */
private $backends = [];
+ /** @var IBackend[] holds all backends that have been initialized already */
+ private $initializedBackends = [];
+
+ /**
+ * Manager constructor.
+ *
+ * @param IServerContainer $server
+ */
+ public function __construct(IServerContainer $server) {
+ $this->server = $server;
+ }
+
/**
* Registers a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function registerBackend(IBackend $backend) {
- $this->backends[$backend->getBackendIdentifier()] = $backend;
+ public function registerBackend(string $backendClass) {
+ $this->backends[$backendClass] = $backendClass;
}
/**
* Unregisters a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function unregisterBackend(IBackend $backend) {
- unset($this->backends[$backend->getBackendIdentifier()]);
+ public function unregisterBackend(string $backendClass) {
+ unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]);
}
/**
* @return IBackend[]
+ * @throws \OCP\AppFramework\QueryException
* @since 14.0.0
*/
public function getBackends():array {
- return array_values($this->backends);
+ foreach($this->backends as $backend) {
+ if (isset($this->initializedBackends[$backend])) {
+ continue;
+ }
+
+ $this->initializedBackends[$backend] = $this->server->query($backend);
+ }
+
+ return array_values($this->initializedBackends);
}
/**
* @param string $backendId
+ * @throws \OCP\AppFramework\QueryException
* @return IBackend|null
*/
- public function getBackend($backendId):IBackend {
- if (!isset($this->backends[$backendId])) {
- return null;
+ public function getBackend($backendId) {
+ $backends = $this->getBackends();
+ foreach($backends as $backend) {
+ if ($backend->getBackendIdentifier() === $backendId) {
+ return $backend;
+ }
}
- return $this->backends[$backendId];
+ return null;
}
/**
@@ -79,5 +108,6 @@ class Manager implements \OCP\Calendar\Room\IManager {
*/
public function clear() {
$this->backends = [];
+ $this->initializedBackends = [];
}
}
diff --git a/lib/public/Calendar/Resource/IManager.php b/lib/public/Calendar/Resource/IManager.php
index 8542e13eba7..b59cb6c797a 100644
--- a/lib/public/Calendar/Resource/IManager.php
+++ b/lib/public/Calendar/Resource/IManager.php
@@ -34,20 +34,20 @@ interface IManager {
/**
* Registers a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function registerBackend(IBackend $backend);
+ public function registerBackend(string $backendClass);
/**
* Unregisters a resource backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function unregisterBackend(IBackend $backend);
+ public function unregisterBackend(string $backendClass);
/**
* @return IBackend[]
@@ -57,10 +57,10 @@ interface IManager {
/**
* @param string $backendId
- * @return IBackend
+ * @return IBackend|null
* @since 14.0.0
*/
- public function getBackend($backendId):IBackend;
+ public function getBackend($backendId);
/**
* removes all registered backend instances
diff --git a/lib/public/Calendar/Room/IManager.php b/lib/public/Calendar/Room/IManager.php
index 39e85c43e45..9aa61aa3f66 100644
--- a/lib/public/Calendar/Room/IManager.php
+++ b/lib/public/Calendar/Room/IManager.php
@@ -34,20 +34,20 @@ interface IManager {
/**
* Registers a room backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function registerBackend(IBackend $backend);
+ public function registerBackend(string $backendClass);
/**
* Unregisters a room backend
*
- * @param IBackend $backend
+ * @param string $backendClass
* @return void
* @since 14.0.0
*/
- public function unregisterBackend(IBackend $backend);
+ public function unregisterBackend(string $backendClass);
/**
* @return IBackend[]
@@ -57,10 +57,10 @@ interface IManager {
/**
* @param string $backendId
- * @return IBackend
+ * @return IBackend|null
* @since 14.0.0
*/
- public function getBackend($backendId):IBackend;
+ public function getBackend($backendId);
/**
* removes all registered backend instances
diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php
index ccc6bbf182b..1d9229856db 100644
--- a/tests/lib/Calendar/Resource/ManagerTest.php
+++ b/tests/lib/Calendar/Resource/ManagerTest.php
@@ -25,6 +25,7 @@ namespace Test\Calendar\Resource;
use \OC\Calendar\Resource\Manager;
use \OCP\Calendar\Resource\IBackend;
+use OCP\IServerContainer;
use \Test\TestCase;
class ManagerTest extends TestCase {
@@ -32,27 +33,39 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
+ /** @var IServerContainer */
+ private $server;
+
protected function setUp() {
parent::setUp();
- $this->manager = new Manager();
+ $this->server = $this->createMock(IServerContainer::class);
+ $this->manager = new Manager($this->server);
}
public function testRegisterUnregisterBackend() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_resource_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_resource_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_resource_backend1');
+ $this->manager->registerBackend('calendar_resource_backend2');
$this->assertEquals([
$backend1, $backend2
], $this->manager->getBackends());
- $this->manager->unregisterBackend($backend1);
+ $this->manager->unregisterBackend('calendar_resource_backend1');
$this->assertEquals([
$backend2
@@ -62,12 +75,20 @@ class ManagerTest extends TestCase {
public function testGetBackend() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_resource_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_resource_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_resource_backend1');
+ $this->manager->registerBackend('calendar_resource_backend2');
$this->assertEquals($backend1, $this->manager->getBackend('backend_1'));
$this->assertEquals($backend2, $this->manager->getBackend('backend_2'));
@@ -76,12 +97,20 @@ class ManagerTest extends TestCase {
public function testClear() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_resource_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_resource_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_resource_backend1');
+ $this->manager->registerBackend('calendar_resource_backend2');
$this->assertEquals([
$backend1, $backend2
diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php
index 34d69d127e2..52347f439fa 100644
--- a/tests/lib/Calendar/Room/ManagerTest.php
+++ b/tests/lib/Calendar/Room/ManagerTest.php
@@ -25,6 +25,7 @@ namespace Test\Calendar\Room;
use \OC\Calendar\Room\Manager;
use \OCP\Calendar\Room\IBackend;
+use OCP\IServerContainer;
use \Test\TestCase;
class ManagerTest extends TestCase {
@@ -32,27 +33,39 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
+ /** @var IServerContainer */
+ private $server;
+
protected function setUp() {
parent::setUp();
- $this->manager = new Manager();
+ $this->server = $this->createMock(IServerContainer::class);
+ $this->manager = new Manager($this->server);
}
public function testRegisterUnregisterBackend() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_room_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_room_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_room_backend1');
+ $this->manager->registerBackend('calendar_room_backend2');
$this->assertEquals([
$backend1, $backend2
], $this->manager->getBackends());
- $this->manager->unregisterBackend($backend1);
+ $this->manager->unregisterBackend('calendar_room_backend1');
$this->assertEquals([
$backend2
@@ -62,12 +75,20 @@ class ManagerTest extends TestCase {
public function testGetBackend() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_room_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_room_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_room_backend1');
+ $this->manager->registerBackend('calendar_room_backend2');
$this->assertEquals($backend1, $this->manager->getBackend('backend_1'));
$this->assertEquals($backend2, $this->manager->getBackend('backend_2'));
@@ -76,12 +97,20 @@ class ManagerTest extends TestCase {
public function testClear() {
$backend1 = $this->createMock(IBackend::class);
$backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+ $this->server->expects($this->at(0))
+ ->method('query')
+ ->with('calendar_room_backend1')
+ ->will($this->returnValue($backend1));
$backend2 = $this->createMock(IBackend::class);
$backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+ $this->server->expects($this->at(1))
+ ->method('query')
+ ->with('calendar_room_backend2')
+ ->will($this->returnValue($backend2));
- $this->manager->registerBackend($backend1);
- $this->manager->registerBackend($backend2);
+ $this->manager->registerBackend('calendar_room_backend1');
+ $this->manager->registerBackend('calendar_room_backend2');
$this->assertEquals([
$backend1, $backend2