We create our own GUI to show the sections'activities. To make sure that user can see only the activities that he has right to access, I call the function $course_module_obj = $modinfo->get_cm($cmid) , then I check the 2 properties called visible and uservisible of the returned object ($course_module_obj->visible && $course_module_obj->uservisible).
It works perfectly. However I found that the function get_cm() retrieves the information from the some kind of cache, and not from the DB itself. In other words, when I change the access right of user - for instance I assign that user to another group, which has no right to access the course module - the above two flags are still valid. I have to purge cache and just after that, the flags will take the correct values.
So how can I purge the cache programmatically ? Or how can I call the get_cm but it will update with the information from DB ?
Many thanks for your helps