[dokuwiki] redesigning the canDo function (was: [PATCH] MySQL canDo() patch)

Hey guys!

No need to struggle ;-)

For me it looks like we have just two different views on what the canDo
function does. Chris came from where canDo() just checked for the
existance of certain methods available in the plain backend. Matthias
looked at what is checked and what is done in the User Management
plugin...

I just did what I should have done in the first place - I had a look at
the code ;-)

So what I can see is that the functions leaveGroup() and joinGroup() are
never called from the User Management plugin. This implies they
shouldn't be defined in the base class, because they are not part of the
used interface to communicate with the auth backend.

However I can understand Chris' argument that there may be an auth
backend needed, which is able to modify group memberships, but can not
modify any other user data. Eg. a derived LDAP backend using plaintext
files for managing DokuWiki groups... This couldn't be handled with a
modifyUser and modifyUserProfile function as suggested.

So handling this could be done in two ways:

- we change the default of the canDo() method in the base class to stop
  thinking about existing or nonexisting methods and instead use it as a
  real capability reporter which needs to be able to answer the
  following queries:

  addUser     - can Users be created?
  delUser     - can Users be deleted?
  modLogin    - can login names be changed?
  modPass     - can passwords be changed?
  modName     - can real names be changed?
  modMail     - can emails be changed?
  getUsers    - can a (filtered) list of users be retrieved?
  multiGroups - can users be Members of multiple groups?
  setGroups   - can groups be set as a whole list?
  joinGroup   - can a user be added to a group?
  leaveGroup  - can a user be removed from a group?
  addGroup    - can new groups be added?
  delGroup    - can groups be deleted?
  external    - has nothing to do with the rest but is for external auth
                checking

  (I probably forgot one or two others)

  All modification of a user and it's groups then would be done inside
  the modifyUser function (BTW. thats pretty similar to LDAPs
  ldap_modify_user ;-)).

- we never modify group memberships through the modifyUser function
  but instead use the leaveGroup and joinGroup functions

I'm slightly in favor of the first solution. I think it would make
absolutely clear what an auth backend is capable of. It would also mean
we can get rid of the commented methods in the base class and use
proper inheritance like in the plugin system.

Andi

Other related posts: