increment/decrement group and user counts when necessary

supersedes https://github.com/owncloud/core/pull/9272