Page MenuHomePhorge

D5355.1775448985.diff
No OneTemporary

Authored By
Unknown
Size
9 KB
Referenced Files
None
Subscribers
None

D5355.1775448985.diff

diff --git a/src/app/Console/Commands/Data/Import/LdifCommand.php b/src/app/Console/Commands/Data/Import/LdifCommand.php
--- a/src/app/Console/Commands/Data/Import/LdifCommand.php
+++ b/src/app/Console/Commands/Data/Import/LdifCommand.php
@@ -896,6 +896,10 @@
if (!empty($entry['kolabfoldertype'])) {
$result['type'] = $this->attrStringValue($entry, 'kolabfoldertype');
+
+ if (!in_array($result['type'], \config('app.shared_folder_types'))) {
+ $error = "Unsupported shared folder type: {$result['type']}";
+ }
}
if (!empty($entry['kolabtargetfolder'])) {
diff --git a/src/app/Rules/SharedFolderType.php b/src/app/Rules/SharedFolderType.php
--- a/src/app/Rules/SharedFolderType.php
+++ b/src/app/Rules/SharedFolderType.php
@@ -2,7 +2,6 @@
namespace App\Rules;
-use App\SharedFolder;
use Illuminate\Contracts\Validation\Rule;
class SharedFolderType implements Rule
@@ -17,7 +16,7 @@
*/
public function passes($attribute, $type): bool
{
- if (empty($type) || !is_string($type) || !in_array($type, SharedFolder::SUPPORTED_TYPES)) {
+ if (empty($type) || !is_string($type) || !in_array($type, \config('app.shared_folder_types'))) {
$this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]);
return false;
}
diff --git a/src/app/SharedFolder.php b/src/app/SharedFolder.php
--- a/src/app/SharedFolder.php
+++ b/src/app/SharedFolder.php
@@ -48,9 +48,6 @@
// folder has been created in IMAP
public const STATUS_IMAP_READY = 1 << 8;
- /** @const array Supported folder type labels */
- public const SUPPORTED_TYPES = ['mail', 'event', 'contact', 'task', 'note', 'file'];
-
/** @const string A template for the email attribute on a folder creation */
public const EMAIL_TEMPLATE = '{type}-{id}@{domainName}';
@@ -83,7 +80,7 @@
*/
public function setTypeAttribute($type)
{
- if (!in_array($type, self::SUPPORTED_TYPES)) {
+ if (!in_array($type, \config('app.shared_folder_types'))) {
throw new \Exception("Invalid shared folder type: {$type}");
}
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -499,6 +499,7 @@
'app.support_email',
'app.company.copyright',
'app.companion_download_link',
+ 'app.shared_folder_types',
'app.with_signup',
'mail.from.address',
];
diff --git a/src/config/app.php b/src/config/app.php
--- a/src/config/app.php
+++ b/src/config/app.php
@@ -283,4 +283,9 @@
],
'mta_sts' => env('MTA_STS'),
+
+ 'shared_folder_types' => array_merge(
+ ['mail'],
+ \env('IMAP_WITH_GROUPWARE_DEFAULT_FOLDERS', true) ? ['event', 'contact', 'task', 'note', 'file'] : []
+ ),
];
diff --git a/src/resources/vue/SharedFolder/Info.vue b/src/resources/vue/SharedFolder/Info.vue
--- a/src/resources/vue/SharedFolder/Info.vue
+++ b/src/resources/vue/SharedFolder/Info.vue
@@ -95,7 +95,7 @@
folder_id: null,
folder: { type: 'mail', config: {}, aliases: [] },
status: {},
- types: [ 'mail', 'event', 'task', 'contact', 'note', 'file' ]
+ types: window.config['app.shared_folder_types'],
}
},
created() {
diff --git a/src/tests/Browser/SharedFolderTest.php b/src/tests/Browser/SharedFolderTest.php
--- a/src/tests/Browser/SharedFolderTest.php
+++ b/src/tests/Browser/SharedFolderTest.php
@@ -95,25 +95,25 @@
public function testCreateUpdateDelete(): void
{
$this->browse(function (Browser $browser) {
+ $cfg = ['app.shared_folder_types' => ['mail', 'event', 'task', 'contact']];
+
// Create a folder
- $browser->visit(new SharedFolderList())
+ $browser->withConfig($cfg)
+ ->visit(new SharedFolderList())
->assertSeeIn('button.shared-folder-new', 'Create folder')
->click('button.shared-folder-new')
->on(new SharedFolderInfo())
->assertSeeIn('#folder-info .card-title', 'New shared folder')
->assertSeeIn('@nav #tab-general', 'General')
->assertMissing('@nav #tab-settings')
- ->with('@general', static function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) use ($cfg) {
// Assert form content
$browser->assertMissing('#status')
->assertFocused('#name')
->assertSeeIn('div.row:nth-child(1) label', 'Name')
->assertValue('div.row:nth-child(1) input[type=text]', '')
->assertSeeIn('div.row:nth-child(2) label', 'Type')
- ->assertSelectHasOptions(
- 'div.row:nth-child(2) select',
- ['mail', 'event', 'task', 'contact', 'note', 'file']
- )
+ ->assertSelectHasOptions('div.row:nth-child(2) select', $cfg['app.shared_folder_types'])
->assertValue('div.row:nth-child(2) select', 'mail')
->assertSeeIn('div.row:nth-child(3) label', 'Domain')
->assertSelectHasOptions('div.row:nth-child(3) select', ['kolab.org'])
diff --git a/src/tests/Feature/Console/Data/Import/LdifTest.php b/src/tests/Feature/Console/Data/Import/LdifTest.php
--- a/src/tests/Feature/Console/Data/Import/LdifTest.php
+++ b/src/tests/Feature/Console/Data/Import/LdifTest.php
@@ -33,6 +33,8 @@
*/
public function testHandle(): void
{
+ \config(['app.shared_folder_types' => ['mail', 'event']]);
+
$code = \Artisan::call("data:import:ldif tests/data/kolab3.ldif owner@kolab3.com");
$output = trim(\Artisan::output());
@@ -412,6 +414,7 @@
*/
public function testParseLDAPSharedFolder(): void
{
+ \config(['app.shared_folder_types' => ['mail', 'event']]);
$command = new LdifCommand();
$entry = [];
diff --git a/src/tests/Feature/Console/SharedFolder/CreateTest.php b/src/tests/Feature/Console/SharedFolder/CreateTest.php
--- a/src/tests/Feature/Console/SharedFolder/CreateTest.php
+++ b/src/tests/Feature/Console/SharedFolder/CreateTest.php
@@ -62,6 +62,8 @@
$this->assertSame(1, $code);
$this->assertSame("The specified type is invalid.", $output);
+ \config(['app.shared_folder_types' => ['mail', 'task']]);
+
// Invalid acl
$code = \Artisan::call("sharedfolder:create kolab.org Test --type=task --acl=\"anyone,unknown\"");
$output = trim(\Artisan::output());
diff --git a/src/tests/Feature/Controller/SharedFoldersTest.php b/src/tests/Feature/Controller/SharedFoldersTest.php
--- a/src/tests/Feature/Controller/SharedFoldersTest.php
+++ b/src/tests/Feature/Controller/SharedFoldersTest.php
@@ -508,6 +508,8 @@
$this->assertSame(["The specified domain is invalid."], $json['errors']['aliases']);
$this->assertCount(3, $json['errors']);
+ \config(['app.shared_folder_types' => ['mail', 'event']]);
+
// Test successful folder creation
$post['name'] = 'Test Folder';
$post['type'] = 'event';
diff --git a/src/tests/Unit/Rules/SharedFolderTypeTest.php b/src/tests/Unit/Rules/SharedFolderTypeTest.php
--- a/src/tests/Unit/Rules/SharedFolderTypeTest.php
+++ b/src/tests/Unit/Rules/SharedFolderTypeTest.php
@@ -3,7 +3,6 @@
namespace Tests\Unit\Rules;
use App\Rules\SharedFolderType;
-use App\SharedFolder;
use Illuminate\Support\Facades\Validator;
use Tests\TestCase;
@@ -26,10 +25,15 @@
$v = Validator::make(['type' => 'Test'], $rules);
$this->assertSame(['type' => ["The specified type is invalid."]], $v->errors()->toArray());
- // Valid type
- foreach (SharedFolder::SUPPORTED_TYPES as $type) {
- $v = Validator::make(['type' => $type], $rules);
- $this->assertSame([], $v->errors()->toArray());
- }
+ // Types list configuration
+ \config(['app.shared_folder_types' => ['mail']]);
+ $v = Validator::make(['type' => 'mail'], $rules);
+ $this->assertSame([], $v->errors()->toArray());
+ $v = Validator::make(['type' => 'event'], $rules);
+ $this->assertSame(['type' => ["The specified type is invalid."]], $v->errors()->toArray());
+
+ \config(['app.shared_folder_types' => ['mail', 'event']]);
+ $v = Validator::make(['type' => 'event'], $rules);
+ $this->assertSame([], $v->errors()->toArray());
}
}
diff --git a/src/tests/Unit/SharedFolderTest.php b/src/tests/Unit/SharedFolderTest.php
--- a/src/tests/Unit/SharedFolderTest.php
+++ b/src/tests/Unit/SharedFolderTest.php
@@ -76,7 +76,7 @@
{
$folder = new SharedFolder(['name' => 'test']);
- foreach (SharedFolder::SUPPORTED_TYPES as $type) {
+ foreach (\config('app.shared_folder_types') as $type) {
$folder->type = $type;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 6, 4:16 AM (1 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18835558
Default Alt Text
D5355.1775448985.diff (9 KB)

Event Timeline