require 'common/postfixadmin_plugin'
require 'mv/mv_plugin'
+
+# Handle moving (renaming) of users in the Postfixadmin database.
+#
class PostfixadminMv
include PostfixadminPlugin
include MvPlugin
+
+ # Move the user *src* to *dst* within the Postfixadmin
+ # database. This should "rename" him in _every_ table where he is
+ # referenced. Unfortunately that must be done manually.
+ #
+ # This can fail is *src* does not exist, or if *dst* already exists
+ # before the move. It will also fail if the domain associated with
+ # the user *dst* does not exist.
+ #
+ # @param src [User] the source user to be moved.
+ #
+ # @param dst [User] the destination user being moved to.
+ #
def mv_user(src, dst)
- # It's obviously an error if the source user does not exist.
raise NonexistentUserError.new(src.to_s()) if not user_exists(src)
- # And if the destination domain does not exist.
if not domain_exists(dst.domain())
raise NonexistentDomainError.new(dst.domain.to_s())
end
- # But the destination *user* should *not* exist.
- # And it's an error if the destination user exists already.
raise UserAlreadyExistsError.new(dst.to_s()) if user_exists(dst)
mailbox_query = 'UPDATE mailbox SET '