Skip to content

Commit

Permalink
feat(Contexts): repair step to set existing default nav modes to visi…
Browse files Browse the repository at this point in the history
…ble for all

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Jan 9, 2025
1 parent a39289d commit 3666012
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Have a good time and manage whatever you want.
<nextcloud min-version="29" max-version="31"/>
</dependencies>
<repair-steps>
<pre-migration>
<step>OCA\Tables\Migration\FixContextsDefaults</step>
</pre-migration>
<post-migration>
<step>OCA\Tables\Migration\NewDbStructureRepairStep</step>
<step>OCA\Tables\Migration\DbRowSleeveSequence</step>
Expand Down
51 changes: 51 additions & 0 deletions lib/Migration/FixContextsDefaults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types = 1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Tables\Migration;

use OCA\Tables\AppInfo\Application;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class FixContextsDefaults implements IRepairStep {

public function __construct(
protected IConfig $config,
protected IDBConnection $dbc,
) {
}

/**
* @inheritDoc
*/
public function getName() {
return 'Fix navigation bar default of existing contexts to show for all';
}

/**
* @inheritDoc
*/
public function run(IOutput $output) {
$appVersion = $this->config->getAppValue(Application::APP_ID, 'installed_version', '0.0');
if (\version_compare($appVersion, '0.8.0-beta.1', '>')) {
$output->info('Not applicable, skipping.');
return;
}

$qb = $this->dbc->getQueryBuilder();
$qb->update('tables_contexts_navigation')
->set('display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_ALL, IQueryBuilder::PARAM_INT))
->where($qb->expr()->eq('display_mode', $qb->createNamedParameter(Application::NAV_ENTRY_MODE_HIDDEN, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter('', IQueryBuilder::PARAM_STR)))
->executeStatement();
}
}

0 comments on commit 3666012

Please sign in to comment.