]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/mv/plugins/roundcube.rb
Rename PostfixadminDb, RoundcubeDb without the Db suffix.
[mailshears.git] / lib / mv / plugins / roundcube.rb
diff --git a/lib/mv/plugins/roundcube.rb b/lib/mv/plugins/roundcube.rb
new file mode 100644 (file)
index 0000000..50a52c3
--- /dev/null
@@ -0,0 +1,41 @@
+require 'pg'
+
+require 'common/roundcube_plugin'
+require 'mv/mv_plugin'
+
+class RoundcubeMv
+
+  include RoundcubePlugin
+  include MvPlugin
+
+
+  def mv_domain(from, to)
+    # Roundcube doesn't have a concept of domains.
+  end
+
+  def mv_account(from, to)
+    sql_queries = ['UPDATE users SET username = $1 WHERE username = $2;']
+
+    begin
+      connection = PGconn.connect(@db_host,
+                                  @db_port,
+                                  @db_opts,
+                                  @db_tty,
+                                  @db_name,
+                                  @db_user,
+                                  @db_pass)
+
+      sql_queries.each do |sql_query|
+        connection.query(sql_query, [to, from])
+      end
+
+      connection.close()
+
+    rescue PGError => e
+      # Pretend like we're database-agnostic in case we ever are.
+      raise DatabaseError.new(e)
+    end
+
+  end
+
+end