Add support for after_success and after_failure to email notifications

This allows you to restrict email notifications to only be sent after the build changes from success to failure or failure to success.  It errs on the side of sending the notification; if the build is in another state (hung, for instance) or there was no previous build on the branch the email will also be sent.

Since the notify plugin shouldn't really have any responsibility for querying the database to find the previous commit's status, we store it on the commit when we save it.

As a side note, it seems like on_success, on_failure, etc would be better living in the notify plugin than the email plugin; that way they could be used to restrict all types of notifications.