Skip to content

Commit

Permalink
Use default values when prefix options are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
smarinier committed Apr 22, 2024
1 parent 7dcca0b commit f5da02b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Migration/FixMigrationToV300.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OCA\Workspace\Migration;

use OCA\Workspace\AppInfo\Application;
use OCA\Workspace\Service\Group\GroupsWorkspace;
use OCA\Workspace\Upgrade\Upgrade;
use OCA\Workspace\Upgrade\UpgradeFixV300V301;
use OCP\AppFramework\Services\IAppConfig as ServiceIAppConfig;
Expand Down Expand Up @@ -37,8 +38,8 @@ public function run(IOutput $output): void {

if (!$this->appConfigManager->hasKey(Application::APP_ID, 'DISPLAY_PREFIX_MANAGER_GROUP')
&& !$this->appConfigManager->hasKey(Application::APP_ID, 'DISPLAY_PREFIX_USER_GROUP')) {
$this->appConfig->setAppValue('DISPLAY_PREFIX_MANAGER_GROUP', 'WM-');
$this->appConfig->setAppValue('DISPLAY_PREFIX_USER_GROUP', 'U-');
$this->appConfig->setAppValue('DISPLAY_PREFIX_MANAGER_GROUP', GroupsWorkspace::DEFAULT_DISPLAY_PREFIX_MANAGER_GROUP);
$this->appConfig->setAppValue('DISPLAY_PREFIX_USER_GROUP', GroupsWorkspace::DEFAULT_DISPLAY_PREFIX_USER_GROUP);
}

$this->upgrade->upgrade();
Expand Down
6 changes: 4 additions & 2 deletions lib/Service/Group/GroupsWorkspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ abstract class GroupsWorkspace {
private const GID_SPACE_MANAGER = 'GE-';
private const GID_SPACE_USERS = 'U-';
private const GID_SPACE = 'SPACE-';
public const DEFAULT_DISPLAY_PREFIX_MANAGER_GROUP = 'WM-';
public const DEFAULT_DISPLAY_PREFIX_USER_GROUP = 'U-';

protected const PREFIX_GID_MANAGERS = self::GID_SPACE . self::GID_SPACE_MANAGER;
protected const PREFIX_GID_USERS = self::GID_SPACE . self::GID_SPACE_USERS;
Expand All @@ -39,8 +41,8 @@ abstract class GroupsWorkspace {
protected static string $DISPLAY_PREFIX_USER_GROUP;

public function __construct(IAppConfig $appConfig) {
self::$DISPLAY_PREFIX_MANAGER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_MANAGER_GROUP');
self::$DISPLAY_PREFIX_USER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_USER_GROUP');
self::$DISPLAY_PREFIX_MANAGER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_MANAGER_GROUP', self::DEFAULT_DISPLAY_PREFIX_MANAGER_GROUP);
self::$DISPLAY_PREFIX_USER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_USER_GROUP', self::DEFAULT_DISPLAY_PREFIX_USER_GROUP);
}

public static function getDisplayPrefixManagerGroup(): string {
Expand Down

0 comments on commit f5da02b

Please sign in to comment.