Move invitations to the database to work better with resque

Invitation objects were being passed to mailers to format emails. With resque,
ideally only the identifiers should be passed to the mailers, that should then
fetch the objects. Moved the invitations to the database so we can do it.

refs #811, refs #371