X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fmv%2Fplugins%2Fagendav.rb;h=a2fb05438dd0cb5808b45d9d64f80d323fa0b037;hp=0324e6dc9e5003141ccf7ec6c8aacda1b3eb7130;hb=HEAD;hpb=f819b178c5c1cb8adda0182c610e5c52fad8bea7 diff --git a/lib/mv/plugins/agendav.rb b/lib/mv/plugins/agendav.rb deleted file mode 100644 index 0324e6d..0000000 --- a/lib/mv/plugins/agendav.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'pg' - -require 'common/agendav_plugin' -require 'mv/mv_plugin' - -class AgendavMv - - include AgendavPlugin - include MvPlugin - - def mv_user(src, dst) - # It's obviously an error if the source user does not exist. It - # would also be an error if the destination domain didn't exist; - # however, Agendav doesn't know about domains, so we let that slide. - raise NonexistentUserError.new(src.to_s()) if not user_exists(src) - - # And it's an error if the destination user exists already. - raise UserAlreadyExistsError.new(dst.to_s()) if user_exists(dst) - - sql_queries = ['UPDATE prefs SET username = $1 WHERE username = $2;'] - sql_queries << 'UPDATE shared SET user_from = $1 WHERE user_from = $2;' - sql_queries << 'UPDATE shared SET user_which = $1 WHERE user_which = $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, [dst.to_s(), src.to_s()]) - end - - connection.close() - - rescue PGError => e - # Pretend like we're database-agnostic in case we ever are. - raise DatabaseError.new(e) - end - end - -end