Hi All,
I am using Moodle 2.7.I am creating a block that could display some information for teachers and stuff only, and display another text for students. After searching in Google, I found this code that could do the job:
$context = get_context_instance(CONTEXT_COURSE, $courseid); if(has_capability('moodle/legacy:student', $context, $sel_user_id)) |
Where $sel_user_id is the selected user id been fetched from the database.
After running the code, I got this error message:
Legacy capabilities can not be used any more! |
After searching in Moodle source code for what generating this error, I found in the "\moodle\lib\accesslib.php" at line 367 this code:
if (strpos($capability, 'moodle/legacy:') === 0) { throw new coding_exception('Legacy capabilities can not be used any more!'); } |
After commenting this code, the code works fine.
Is anyone have any idea about this, and why Moodle developers stopped legacy capabilities?
Thanks in advance ;)
Best regards,
Ahmed