Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117834006
D5541.1775304661.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D5541.1775304661.diff
View Options
diff --git a/src/app/Backends/IMAP.php b/src/app/Backends/IMAP.php
--- a/src/app/Backends/IMAP.php
+++ b/src/app/Backends/IMAP.php
@@ -502,6 +502,38 @@
return $result;
}
+
+ /**
+ * List groupware mailboxes.
+ *
+ * @param string $user The user
+ *
+ * @return array List of mailboxes
+ *
+ * @throws \Exception
+ */
+ public static function listGroupwareMailboxes(string $user): array
+ {
+ $config = self::getConfig();
+ $imap = self::initIMAP($config);
+
+ $mailboxes = $imap->listMailboxes('', self::userMailbox($user, "*"));
+ $result = [];
+ foreach ($mailboxes as $folder) {
+ $metadata = $imap->getMetadata($folder, ['/shared/vendor/kolab/folder-type']);
+ if (!empty($metadata)) {
+ $metadata = implode(" ", $metadata[$folder]);
+ if (!empty($metadata) && !str_contains($metadata, "mail")) {
+ $result[] = $folder;
+ }
+ }
+ }
+
+ $imap->closeConnection();
+
+ return $result;
+ }
+
/**
* Convert UTF8 string to UTF7-IMAP encoding
*/
diff --git a/src/app/Console/Commands/Imap/DeleteCommand.php b/src/app/Console/Commands/Imap/DeleteCommand.php
--- a/src/app/Console/Commands/Imap/DeleteCommand.php
+++ b/src/app/Console/Commands/Imap/DeleteCommand.php
@@ -12,7 +12,7 @@
*
* @var string
*/
- protected $signature = 'imap:delete {user} {mailbox} {--clear : Clear mailbox instead}';
+ protected $signature = 'imap:delete {user} {mailbox} {--clear : Clear mailbox instead} {--groupware : Only match groupware mailboxes}';
/**
* The console command description.
@@ -31,8 +31,13 @@
$user = $this->argument('user');
$mailbox = $this->argument('mailbox');
if ($mailbox == "*") {
+ if ($this->option('clear')) {
+ $mailboxes = IMAP::listMailboxes($user);
+ } else {
+ $mailboxes = IMAP::listGroupwareMailboxes($user);
+ }
// Reverse so subfolders are deleted before parent folders
- foreach (array_reverse(IMAP::listMailboxes($user)) as $mailbox) {
+ foreach (array_reverse($mailboxes) as $mailbox) {
if ($this->option('clear')) {
IMAP::clearMailbox($mailbox);
} else {
diff --git a/src/app/Console/Commands/Imap/ListCommand.php b/src/app/Console/Commands/Imap/ListCommand.php
--- a/src/app/Console/Commands/Imap/ListCommand.php
+++ b/src/app/Console/Commands/Imap/ListCommand.php
@@ -12,7 +12,7 @@
*
* @var string
*/
- protected $signature = 'imap:list {user}';
+ protected $signature = 'imap:list {user} {--groupware}';
/**
* The console command description.
@@ -29,8 +29,14 @@
public function handle()
{
$user = $this->argument('user');
- foreach (IMAP::listMailboxes($user) as $mailbox) {
- $this->info("{$mailbox}");
+ if ($this->option("groupware")) {
+ foreach (IMAP::listGroupwareMailboxes($user) as $mailbox) {
+ $this->info("{$mailbox}");
+ }
+ } else {
+ foreach (IMAP::listMailboxes($user) as $mailbox) {
+ $this->info("{$mailbox}");
+ }
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 12:11 PM (12 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18829372
Default Alt Text
D5541.1775304661.diff (3 KB)
Attached To
Mode
D5541: Imap commands to delete groupware mailboxes
Attached
Detach File
Event Timeline