jasperweyne / helpless-kiwi

Manage members, create and manage activities, send mails and more
Apache License 2.0
11 stars 7 forks source link

Nonhierarchical relations #327

Closed jasperweyne closed 1 year ago

jasperweyne commented 1 year ago

Currently, Kiwi provides a group system that allows users to be divided up into user-defined groups. These groups give a user fine-grained control on what activities they can see and edit. These groups may be hierarchical, which means that a parent group may contain child groups. A link between a group and a user is called a relation.

Upon initial creation of this group system, relations were made to be hierarchical as well. This could mean that if a person is the treasurer for committee x, their account could have a relation with the group "Committee X", which was coupled with a child-relation to the group "Treasurers" for example. The intent behind this was that multi-dimensional membership could be stored and visualised.

In practice, this behaviour is never used. Since user capabilities are defined based on membership of a single group, a user needs to be linked to only a single group with that capability. Extending capabilities to be dependent upon linked group memberships at the same time is incredibly complex to implement and therefore hasn't been done. More importantly, since the goals for Kiwi have been shifted towards a leaner product scope, this complexity isn't going to be needed anytime soon.

Since this complex behaviour is both unnecessary and unused, but adds maintenance complexity, this PR is intended to remove the it altogether. The first intent was to simply remove the parent and children fields from the Relation entity and all related functionality. However, when looking at the remaining entity, only an id, an (unused) description and the links to the person and the group are left. Since the id is only there for database structure reasons and the description is unused anyways, this leaves the links to persons and groups. That is a simple ManyToMany relationship, which is directly supported by Doctrine.

This allowed for the deletion of the separate Relation entity definition altogether, as well as a lot of code simplifications. Notably, the findAllFor($user) method from the GroupRepository was removed, since it is now equivalent to $user->getRelations().

By removing the Relation entity, a user's membership to a group will be a simple in-or-out relation, without a hierarchical nature; any hierarchical nature can instead be provided through a hierarchy of groups. This will make development of Kiwi simpler and faster.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

94.7% 94.7% Coverage
0.0% 0.0% Duplication