MDL-58188 mod_assign: added missing require_once and updated docs
authorMark Nelson <markn@moodle.com>
Fri, 24 Mar 2017 05:44:20 +0000 (13:44 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 4 Apr 2017 10:01:45 +0000 (11:01 +0100)
The only reason the exclusion of require_once was not exploding before
is because the call to provider_event_action() was being triggered first
which required the file. We can't rely on this happening all the time.

The doc update describes when the usage of is_event_visible() is appropriate.

Part of MDL-55611 epic.

mod/assign/lib.php

index a8b69dc..70b211a 100644 (file)
@@ -1710,11 +1710,17 @@ function assign_check_updates_since(cm_info $cm, $from, $filter = array()) {
 /**
  * Is the event visible?
  *
+ * This is used to determine global visibility of an event in all places throughout Moodle. For example,
+ * the ASSIGN_EVENT_TYPE_GRADINGDUE event will not be shown to students on their calendar, and
+ * ASSIGN_EVENT_TYPE_DUE events will not be shown to teachers.
+ *
  * @param \core_calendar\event $event
  * @return bool Returns true if the event is visible to the current user, false otherwise.
  */
 function mod_assign_core_calendar_is_event_visible(\core_calendar\event $event) {
-    global $USER;
+    global $CFG, $USER;
+
+    require_once($CFG->dirroot . '/mod/assign/locallib.php');
 
     $cm = get_fast_modinfo($event->courseid)->instances['assign'][$event->instance];
     $context = context_module::instance($cm->id);