Rewrote parts of save() to handle empty group definitions properly and make sure all edit groups have view access too

Access inheritance wasn't rebuilt when manage_access was checked but no groups were selected, this is now fixed. Another commit adds a line making sure all edit groups have view access as well. There would have been other ways around this, but this was the most straightforward at this point. Another option would have been to change viewable() to check for edit groups as well.

I was supposed to add more fixes/additions to this same pr but it turns out I need to get around that circular reference problem first. Stay tuned :).