Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Unsolved problems in roles.

Obsolete:Unsolved problems in roles: Difference between revisions

From MoodleDocs
(Removed a section because capabilities should never be used negatively)
Line 25: Line 25:
* rewrite require_login() or obsolete it by has_capability() with parameter to login if needed.
* rewrite require_login() or obsolete it by has_capability() with parameter to login if needed.


==moodle/site:doanything capability trouble==
moodle/site:doanything was supposed to allow admin to do anything. The problem is that we have also ''negative capabilities'' - for example moodle/legacy:guest prevents people from doing something.
===Possible solutions===
# remove moodle/site:doanything and set sensible defaults for admin role, this might need other changes in code (big change)
# make all roles positive - moodle/site:nonguest? (maintenance problems in future)
# add ''positive''/''negative'' marker to each role and change doanything overriding to check it
# sprinkle the code with or hascapability('moodle/site:doanything')
# did I forget anything?


==Enrollments==
==Enrollments==


==Backup/Restore==
==Backup/Restore==

Revision as of 09:05, 27 August 2006

Yesterday I wanted to start full conversion of modules to new roles, mainly remove isteacher(), isguest(), iseditingteacher() and isstudent(). I stopped sooner than expected. Here is the list of problems we should solve before going ahead with roles conversion.


Guest access

Originally we used require_login() and isguest() combination. require_login() to be discussed later. I guess we should move to capability checks only and stop doing special checks in modules. We can not assign guest user to Guest role now. Part of the upgrade should be assignment of guest user to guest role if we had open guest access.

Solution

  • allow assignment of guest user to at least Guest role
  • fix upgrade to assign guest role if needed
  • fix course config GUI

Access without login

Till now we used empty($USER->id) or isloggedin(). If we want to control everything using capabilities we need new notlogged user and Not logged role plus legacy capability site/legacy:loggedin.

We should also eliminate $CFG->forcelogin that was used when we wanted to give access without login to resources at site level.

Solution

  • automatically create user notlogged - either in memory only or in database
  • load notlogged user in $USER if not logged
  • do some automatic assignment or capability overrides in upgrade
  • remove empty($USER->id) from core
  • rewrite require_login() or obsolete it by has_capability() with parameter to login if needed.


Enrollments

Backup/Restore