]> git.joonet.de Git - adminer.git/commitdiff
IMAP: Create, drop, truncate
authorJakub Vrana <jakub@vrana.cz>
Tue, 18 Mar 2025 12:10:45 +0000 (13:10 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 18 Mar 2025 12:10:45 +0000 (13:10 +0100)
plugins/drivers/imap.php

index d61f37b83750847a526994290faf91901bfb7427..6fe22214c38ccd8bf843e233800a1bf5f92ebf55 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /** Experimental driver for IMAP created just for fun. Features:
 * - list mailboxes with number of messages (Rows) and unread messages (Data Free)
+* - creating and dropping mailboxes work, truncate does expunge on all mailboxes
 * - list messages in each mailbox - limit and offset works but there's no search and order
 * - for each message, there's subject, from, to, date and some flags
 * - editing the message shows some other information
@@ -96,6 +97,18 @@ if (isset($_GET["imap"])) {
                                        "Data_free" => $return->unseen,
                                );
                        }
+
+                       function create($name) {
+                               return imap_createmailbox($this->imap, $this->mailbox . $name);
+                       }
+
+                       function drop($name) {
+                               return imap_deletemailbox($this->imap, $this->mailbox . $name);
+                       }
+
+                       function expunge($name) {
+                               return imap_expunge($this->imap);
+                       }
                }
 
                class Result {
@@ -235,6 +248,33 @@ if (isset($_GET["imap"])) {
                return $table_status["Rows"];
        }
 
+       function fk_support($table_status) {
+       }
+
+       function engines() {
+               return array();
+       }
+
+       function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
+               return connection()->create($name);
+       }
+
+       function drop_tables($tables) {
+               $return = true;
+               foreach ($tables as $name) {
+                       $return = $return && connection()->drop($name);
+               }
+               return $return;
+       }
+
+       function truncate_tables($tables) {
+               $return = true;
+               foreach ($tables as $name) {
+                       $return = $return && connection()->expunge($name);
+               }
+               return $return;
+       }
+
        function connect($credentials) {
                $connection = new Db;
                if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {