コード例 #1
0
ファイル: info_module.php プロジェクト: adonm/learning
 /**
  * Tests against a user list. Users who cannot access the activity due to
  * availability restrictions will be removed from the list.
  *
  * Note this only includes availability restrictions (those handled within
  * this API) and not other ways of restricting access.
  *
  * This test ONLY includes conditions which are marked as being applied to
  * user lists. For example, group conditions are included but date
  * conditions are not included.
  *
  * When called on a module, this test DOES also include restrictions on the
  * section (if any).
  *
  * The function operates reasonably efficiently i.e. should not do per-user
  * database queries. It is however likely to be fairly slow.
  *
  * @param array $users Array of userid => object
  * @return array Filtered version of input array
  */
 public function filter_user_list(array $users)
 {
     global $CFG;
     if (!$CFG->enableavailability) {
         return $users;
     }
     // Apply section filtering first.
     $section = $this->cm->get_modinfo()->get_section_info($this->cm->sectionnum, MUST_EXIST);
     $sectioninfo = new info_section($section);
     $filtered = $sectioninfo->filter_user_list($users);
     // Now do base class (module) filtering on top.
     return parent::filter_user_list($filtered);
 }