original_string: public function can_add_instance($courseid) {
          global $CFG, $DB;
          require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
  
          $service = mnetservice_enrol::get_instance();
          if (!$service->is_available()) {
              return false;
          }
          $coursecontext = context_course::instance($courseid);
          if (!has_capability('moodle/course:enrolconfig', $coursecontext)) {
              return false;
          }
          $subscribers = $service->get_remote_subscribers();
          if (empty($subscribers)) {
              return false;
          }
  
          return true;
      }
code: public function can_add_instance($courseid) {
          global $CFG, $DB;
          require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
  
          $service = mnetservice_enrol::get_instance();
          if (!$service->is_available()) {
              return false;
          }
          $coursecontext = context_course::instance($courseid);
          if (!has_capability('moodle/course:enrolconfig', $coursecontext)) {
              return false;
          }
          $subscribers = $service->get_remote_subscribers();
          if (empty($subscribers)) {
              return false;
          }
  
          return true;
      }
code_tokens: public function can_add_instance ( $ courseid ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/service/enrol/locallib.php' ) ; $ service = mnetservice_enrol :: get_instance ( ) ; if ( ! $ service -> is_available ( ) ) { return false ; } $ coursecontext = context_course :: instance ( $ courseid ) ; if ( ! has_capability ( 'moodle/course:enrolconfig' , $ coursecontext ) ) { return false ; } $ subscribers = $ service -> get_remote_subscribers ( ) ; if ( empty ( $ subscribers ) ) { return false ; } return true ; }
docstring: Returns true if a new instance can be added to this course.
  
  The link is returned only if there are some MNet peers that we publish enrolment service to.
  
  @param int $courseid id of the course to add the instance to
  @return boolean
docstring_tokens: Returns true if a new instance can be added to this course .