Skip to content

Commit

Permalink
Merge pull request #995 from nextcloud/workflow-section
Browse files Browse the repository at this point in the history
Workflow section + hidden empty sections
  • Loading branch information
LukasReschke committed Aug 23, 2016
2 parents d85e678 + 94432c0 commit 3ed1024
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/systemtags/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<licence>AGPL</licence>
<author>Vincent Petry, Joas Schilling</author>
<default_enable/>
<version>1.1.2</version>
<version>1.1.3</version>
<dependencies>
<owncloud min-version="9.2" max-version="9.2" />
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getForm() {
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'additional';
return 'workflow';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testGetForm() {
}

public function testGetSection() {
$this->assertSame('additional', $this->admin->getSection());
$this->assertSame('workflow', $this->admin->getSection());
}

public function testGetPriority() {
Expand Down
6 changes: 5 additions & 1 deletion apps/workflowengine/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description></description>
<licence>AGPL</licence>
<author>Morris Jobke</author>
<version>1.1.0</version>
<version>1.1.1</version>
<namespace>WorkflowEngine</namespace>

<category>other</category>
Expand All @@ -20,4 +20,8 @@
<dependencies>
<owncloud min-version="9.2" max-version="9.2" />
</dependencies>

<settings>
<admin-section>OCA\WorkflowEngine\Settings\Section</admin-section>
</settings>
</info>
57 changes: 57 additions & 0 deletions apps/workflowengine/lib/Settings/Section.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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\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;
}
}
3 changes: 2 additions & 1 deletion lib/private/ServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace OC;


use OC\AppFramework\App;
use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Utility\SimpleContainer;
use OCP\AppFramework\QueryException;
Expand All @@ -49,7 +50,7 @@ public function __construct() {
* @param DIContainer $container
*/
public function registerAppContainer($appName, DIContainer $container) {
$this->appContainers[$appName] = $container;
$this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container;
}

/**
Expand Down
14 changes: 9 additions & 5 deletions lib/private/Settings/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function onAppDisabled($appId) {
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]);
}
}
Expand Down Expand Up @@ -327,10 +327,6 @@ private function query($className) {
* @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)],
Expand All @@ -341,7 +337,15 @@ public function getAdminSections() {
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']] = [];
Expand Down
19 changes: 16 additions & 3 deletions tests/lib/Settings/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,28 @@ public function testSetupSettings() {

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'])
->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')
->with('admin_sections')
->willReturn($qb);
$qb
->expects($this->once())
->method('expr')
->willReturn($expr);
$qb
->expects($this->once())
->method('where')
->willReturn($qb);
$stmt = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')->getMock();
$qb
Expand Down

0 comments on commit 3ed1024

Please sign in to comment.