From cb3c1eee976711d21724de819b9b365fd9e6badb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 19 Aug 2016 17:44:24 +0200 Subject: [PATCH 1/6] add section to worklfowengine --- apps/workflowengine/appinfo/info.xml | 6 ++- apps/workflowengine/lib/Settings/Section.php | 57 ++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 apps/workflowengine/lib/Settings/Section.php diff --git a/apps/workflowengine/appinfo/info.xml b/apps/workflowengine/appinfo/info.xml index b53f8aedb16..aae234cc717 100644 --- a/apps/workflowengine/appinfo/info.xml +++ b/apps/workflowengine/appinfo/info.xml @@ -5,7 +5,7 @@ AGPL Morris Jobke - 1.1.0 + 1.1.1 WorkflowEngine other @@ -20,4 +20,8 @@ + + + OCA\WorkflowEngine\Settings\Section + diff --git a/apps/workflowengine/lib/Settings/Section.php b/apps/workflowengine/lib/Settings/Section.php new file mode 100644 index 00000000000..df8bb807134 --- /dev/null +++ b/apps/workflowengine/lib/Settings/Section.php @@ -0,0 +1,57 @@ + + * + * @author Lukas Reschke + * + * @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 . + * + */ + +namespace OCA\WorkflowEngine\Settings; + +use OCP\IL10N; +use OCP\Settings\ISection; + +class Section implements ISection { + /** @var IL10N */ + private $l; + + public function __construct(IL10N $l) { + $this->l = $l; + } + + /** + * {@inheritdoc} + */ + public function getID() { + return 'workflow'; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return $this->l->t('Workflow'); + } + + /** + * {@inheritdoc} + */ + public function getPriority() { + return 55; + } +} From 7972fa552724ce63a4f51b864c28bd086fc15cb7 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 19 Aug 2016 17:52:33 +0200 Subject: [PATCH 2/6] enlist only registered sections that also have settings registered to --- lib/private/Settings/Manager.php | 12 ++++++++---- tests/lib/Settings/ManagerTest.php | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 7574695d709..8451e965955 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -327,10 +327,6 @@ class Manager implements IManager { * @inheritdoc */ public function getAdminSections() { - $query = $this->dbc->getQueryBuilder(); - $query->select(['class', 'priority']) - ->from(self::TABLE_ADMIN_SECTIONS); - // built-in sections $sections = [ 0 => [new Section('server', $this->l->t('Server settings'), 0)], @@ -341,7 +337,15 @@ class Manager implements IManager { 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0)], ]; + $query = $this->dbc->getQueryBuilder(); + $query->selectDistinct('s.class') + ->addSelect('s.priority') + ->from(self::TABLE_ADMIN_SECTIONS, 's') + ->from(self::TABLE_ADMIN_SETTINGS, 'f') + ->where($query->expr()->eq('s.id', 'f.section')) + ; $result = $query->execute(); + while($row = $result->fetch()) { if(!isset($sections[$row['priority']])) { $sections[$row['priority']] = []; diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index cd5100eff6d..4728784167a 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -136,15 +136,33 @@ class ManagerTest extends TestCase { public function testGetAdminSections() { $qb = $this->getMockBuilder('\OCP\DB\QueryBuilder\IQueryBuilder')->getMock(); + $expr = $this->getMockBuilder('OCP\DB\QueryBuilder\IExpressionBuilder')->getMock(); $qb ->expects($this->once()) ->method('select') - ->with(['class', 'priority']) + ->with(['s.class', 's.priority']) + ->willReturn($qb); + $qb + ->expects($this->exactly(2)) + ->method('from') + ->willReturn($qb); + $qb + ->expects($this->at(1)) + ->method('from') + ->with('admin_sections', 's') + ->willReturn($qb); + $qb + ->expects($this->at(2)) + ->method('from') + ->with('admin_settings', 'f') ->willReturn($qb); $qb ->expects($this->once()) - ->method('from') - ->with('admin_sections') + ->method('expr') + ->willReturn($expr); + $qb + ->expects($this->once()) + ->method('where') ->willReturn($qb); $stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock(); $qb From baa91809bd11a78a53c8b39e6b2f73ff41b7f925 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Sat, 20 Aug 2016 23:45:31 +0200 Subject: [PATCH 3/6] adjust test --- tests/lib/Settings/ManagerTest.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 4728784167a..942a2bb63e7 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -139,23 +139,18 @@ class ManagerTest extends TestCase { $expr = $this->getMockBuilder('OCP\DB\QueryBuilder\IExpressionBuilder')->getMock(); $qb ->expects($this->once()) - ->method('select') - ->with(['s.class', 's.priority']) + ->method('selectDistinct') + ->with('s.class') + ->willReturn($qb); + $qb + ->expects($this->once()) + ->method('addSelect') + ->with('s.priority') ->willReturn($qb); $qb ->expects($this->exactly(2)) ->method('from') ->willReturn($qb); - $qb - ->expects($this->at(1)) - ->method('from') - ->with('admin_sections', 's') - ->willReturn($qb); - $qb - ->expects($this->at(2)) - ->method('from') - ->with('admin_settings', 'f') - ->willReturn($qb); $qb ->expects($this->once()) ->method('expr') From d1c9f744e1904a0761a4dfaa4a6137b54984585a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Aug 2016 08:31:25 +0200 Subject: [PATCH 4/6] Move admin settings to workflow section --- apps/systemtags/appinfo/info.xml | 2 +- apps/systemtags/lib/Settings/Admin.php | 2 +- apps/systemtags/tests/Settings/AdminTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/systemtags/appinfo/info.xml b/apps/systemtags/appinfo/info.xml index 15b9abed0d4..0a98d7ae680 100644 --- a/apps/systemtags/appinfo/info.xml +++ b/apps/systemtags/appinfo/info.xml @@ -7,7 +7,7 @@ AGPL Vincent Petry, Joas Schilling - 1.1.2 + 1.1.3 diff --git a/apps/systemtags/lib/Settings/Admin.php b/apps/systemtags/lib/Settings/Admin.php index c8d986414e6..9e21dafed8b 100644 --- a/apps/systemtags/lib/Settings/Admin.php +++ b/apps/systemtags/lib/Settings/Admin.php @@ -39,7 +39,7 @@ class Admin implements ISettings { * @return string the section ID, e.g. 'sharing' */ public function getSection() { - return 'additional'; + return 'workflow'; } /** diff --git a/apps/systemtags/tests/Settings/AdminTest.php b/apps/systemtags/tests/Settings/AdminTest.php index 174fd382159..d768ad86272 100644 --- a/apps/systemtags/tests/Settings/AdminTest.php +++ b/apps/systemtags/tests/Settings/AdminTest.php @@ -43,7 +43,7 @@ class AdminTest extends TestCase { } public function testGetSection() { - $this->assertSame('additional', $this->admin->getSection()); + $this->assertSame('workflow', $this->admin->getSection()); } public function testGetPriority() { From 056c1ab03516b406b29912e9b7975e9ef6342526 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 22 Aug 2016 11:24:48 +0200 Subject: [PATCH 5/6] fix wrong var name --- lib/private/Settings/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 8451e965955..df2f52f816d 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -107,7 +107,7 @@ class Manager implements IManager { if(isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) { $this->remove(self::TABLE_ADMIN_SECTIONS, $appInfo['settings'][IManager::KEY_ADMIN_SECTION]); } - if(isset($settings['settings'][IManager::KEY_ADMIN_SETTINGS])) { + if(isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) { $this->remove(self::TABLE_ADMIN_SETTINGS, $appInfo['settings'][IManager::KEY_ADMIN_SETTINGS]); } } From 94432c089f0a598ed2e96d086731b44dc2897918 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Aug 2016 14:25:43 +0200 Subject: [PATCH 6/6] Save the container with the app's namespace so we can resolve it --- lib/private/ServerContainer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index 1bab2587e8d..df0293addf7 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -23,6 +23,7 @@ namespace OC; +use OC\AppFramework\App; use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Utility\SimpleContainer; use OCP\AppFramework\QueryException; @@ -49,7 +50,7 @@ class ServerContainer extends SimpleContainer { * @param DIContainer $container */ public function registerAppContainer($appName, DIContainer $container) { - $this->appContainers[$appName] = $container; + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; } /**