UNIMOODLE / moodle-local_notificationsagent

Unimoodle L5 P4
Other
3 stars 3 forks source link

Error "You don't have permission to view this list of courses." #120

Closed LuksAO closed 2 weeks ago

LuksAO commented 4 weeks ago

Moodle version: 4.1.11+ (Build: 20240614) local_notificationsagent version: 0.6.0

When you enter to "My assistant" in a course as a user with Teacher role (not admin) and the course's direct parent category is marked as not visible, the page shows the following error:

You don't have permission to view this list of courses.

Debug info:
Error code: cannotviewcategory×Dismiss this notification
Stack trace:
line 281 of /course/classes/category.php: moodle_exception thrown
line 404 of /local/notificationsagent/classes/helper/helper.php: call to core_course_category::get()
line 1778 of /local/notificationsagent/classes/rule.php: call to local_notificationsagent\helper\helper::get_parents_categories_course()
line 301 of /local/notificationsagent/classes/rule.php: call to local_notificationsagent\rule::get_course_rules()
line 154 of /local/notificationsagent/index.php: call to local_notificationsagent\rule::get_rules_index()

image

fpano commented 2 weeks ago

This is because your teacher does not have the capability ‘moodle/category:viewhiddencategories’ and as the rules are bounded to a context, when we look for rules to display in category contexts and the user does not have the above capability, the error is displayed as expected. We have added a control to check whether or not to display the rules based on that capability, so the error won't be shown. Thanks for pointing us this out, @LuksAO.