original_string: public function is_available(&$information, $grabthelot = false, $userid = 0,
              \course_modinfo $modinfo = null) {
          global $USER;
  
          // Default to no information.
          $information = '';
  
          // Do nothing if there are no availability restrictions.
          if (is_null($this->availability)) {
              return true;
          }
  
          // Resolve optional parameters.
          if (!$userid) {
              $userid = $USER->id;
          }
          if (!$modinfo) {
              $modinfo = get_fast_modinfo($this->course, $userid);
          }
          $this->modinfo = $modinfo;
  
          // Get availability from tree.
          try {
              $tree = $this->get_availability_tree();
              $result = $tree->check_available(false, $this, $grabthelot, $userid);
          } catch (\coding_exception $e) {
              $this->warn_about_invalid_availability($e);
              $this->modinfo = null;
              return false;
          }
  
          // See if there are any messages.
          if ($result->is_available()) {
              $this->modinfo = null;
              return true;
          } else {
              // If the item is marked as 'not visible' then we don't change the available
              // flag (visible/available are treated distinctly), but we remove any
              // availability info. If the item is hidden with the eye icon, it doesn't
              // make sense to show 'Available from <date>' or similar, because even
              // when that date arrives it will still not be available unless somebody
              // toggles the eye icon.
              if ($this->visible) {
                  $information = $tree->get_result_information($this, $result);
              }
  
              $this->modinfo = null;
              return false;
          }
      }
code: public function is_available(&$information, $grabthelot = false, $userid = 0,
              \course_modinfo $modinfo = null) {
          global $USER;
  
          // Default to no information.
          $information = '';
  
          // Do nothing if there are no availability restrictions.
          if (is_null($this->availability)) {
              return true;
          }
  
          // Resolve optional parameters.
          if (!$userid) {
              $userid = $USER->id;
          }
          if (!$modinfo) {
              $modinfo = get_fast_modinfo($this->course, $userid);
          }
          $this->modinfo = $modinfo;
  
          // Get availability from tree.
          try {
              $tree = $this->get_availability_tree();
              $result = $tree->check_available(false, $this, $grabthelot, $userid);
          } catch (\coding_exception $e) {
              $this->warn_about_invalid_availability($e);
              $this->modinfo = null;
              return false;
          }
  
          // See if there are any messages.
          if ($result->is_available()) {
              $this->modinfo = null;
              return true;
          } else {
              // If the item is marked as 'not visible' then we don't change the available
              // flag (visible/available are treated distinctly), but we remove any
              // availability info. If the item is hidden with the eye icon, it doesn't
              // make sense to show 'Available from <date>' or similar, because even
              // when that date arrives it will still not be available unless somebody
              // toggles the eye icon.
              if ($this->visible) {
                  $information = $tree->get_result_information($this, $result);
              }
  
              $this->modinfo = null;
              return false;
          }
      }
code_tokens: public function is_available ( & $ information , $ grabthelot = false , $ userid = 0 , \ course_modinfo $ modinfo = null ) { global $ USER ; // Default to no information. $ information = '' ; // Do nothing if there are no availability restrictions. if ( is_null ( $ this -> availability ) ) { return true ; } // Resolve optional parameters. if ( ! $ userid ) { $ userid = $ USER -> id ; } if ( ! $ modinfo ) { $ modinfo = get_fast_modinfo ( $ this -> course , $ userid ) ; } $ this -> modinfo = $ modinfo ; // Get availability from tree. try { $ tree = $ this -> get_availability_tree ( ) ; $ result = $ tree -> check_available ( false , $ this , $ grabthelot , $ userid ) ; } catch ( \ coding_exception $ e ) { $ this -> warn_about_invalid_availability ( $ e ) ; $ this -> modinfo = null ; return false ; } // See if there are any messages. if ( $ result -> is_available ( ) ) { $ this -> modinfo = null ; return true ; } else { // If the item is marked as 'not visible' then we don't change the available // flag (visible/available are treated distinctly), but we remove any // availability info. If the item is hidden with the eye icon, it doesn't // make sense to show 'Available from <date>' or similar, because even // when that date arrives it will still not be available unless somebody // toggles the eye icon. if ( $ this -> visible ) { $ information = $ tree -> get_result_information ( $ this , $ result ) ; } $ this -> modinfo = null ; return false ; } }
docstring: Determines whether this particular item is currently available
  according to the availability criteria.
  
  - This does not include the 'visible' setting (i.e. this might return
  true even if visible is false); visible is handled independently.
  - This does not take account of the viewhiddenactivities capability.
  That should apply later.
  
  Depending on options selected, a description of the restrictions which
  mean the student can't view it (in HTML format) may be stored in
  $information. If there is nothing in $information and this function
  returns false, then the activity should not be displayed at all.
  
  This function displays debugging() messages if the availability
  information is invalid.
  
  @param string $information String describing restrictions in HTML format
  @param bool $grabthelot Performance hint: if true, caches information
  required for all course-modules, to make the front page and similar
  pages work more quickly (works only for current user)
  @param int $userid If set, specifies a different user ID to check availability for
  @param \course_modinfo $modinfo Usually leave as null for default. Specify when
  calling recursively from inside get_fast_modinfo()
  @return bool True if this item is available to the user, false otherwise
docstring_tokens: Determines whether this particular item is currently available according to the availability criteria .