drachels / moodle-mod_mootyper

4 stars 18 forks source link

Capabilities view edit category #79

Closed pmaneggia closed 4 years ago

pmaneggia commented 4 years ago

We need to be able to prevent a (editing) teacher to create lessons that are available across the whole moodle instance. To do this we simply introduced two new capabilities mootyper:viewcategory and mootyper:editcategory and used them to guard the dropdown menu in eins.php. In this way everything works as usual, but we can configure our instance as we need. Maybe you would like to add this change to your code. It was a previous version of this issue that was preventing us from simply follow your updates.

drachels commented 4 years ago

What is the purpose of this change? Are you wanting to make it so that all teachers and managers can only create and edit in their course? Please let me know, because if that is what you want to do, I have a much simpler way to do that, which does not need the two new strings, nor does it need the two new access capabilities. Just need to check if the user is_siteadmin(), in the same two places you inserted your if's.

Correct me if I am wrong, but after looking at your changes, I think you made a mistake for the editcategory in file eeins.php at line 169. You have the option value 0 listed both outside and inside the if statement. The code you currently have is going to always show value 0.

I have always felt that the site admin should be the only person who can make or edit across the whole site. But, since no one has complained, I have left it alone. Due to your concern, I think checking is_siteadmin() might be the better way to go.

Let me know what you think.