For 1.6, let's review and fix the existing specified unsubscribe functionality. (Subsequently we can look at re-architecting the relationship between Groups and Mailings....)
Here's how things should be working...
- Unsubscribe should set the contact's civicrm_group_contact.status to "Removed" for EACH GROUP that is a target of the mailing they are unsubscribing from. This applies to both static and smart groups. The code should check if a group_contact record exists for that group_id + contact_id. If exists, update status to "Removed", if not then INSERT a group_contact record with status = Removed. Note that this will always result in an INSERT for mailing recipients where they got the mailing due to being a "smart group" member. It will also result in INSERTs of a removed status for the case where the mailing was sent to 2+ static groups and contact was only a member of one (they will wind up being "Removed" from both). Lobo and I discussed this and feel that this simpler broad-brush approach is the best for now.
- opt-out should set the civicrm_contact.is_opt_out to TRUE (1)
- subsequent mailings to a GROUP (smart or static) should exclude
contacts with status="Removed"
- all mailing should exclude contacts with is_opt_out = TRUE