original_string: public function get_manual_enrol_link($instance) {
          $name = $this->get_name();
          if ($instance->enrol !== $name) {
              throw new coding_exception('invalid enrol instance!');
          }
  
          if (!enrol_is_enabled($name)) {
              return NULL;
          }
  
          $context = context_course::instance($instance->courseid, MUST_EXIST);
  
          if (!has_capability('enrol/manual:enrol', $context)) {
              // Note: manage capability not used here because it is used for editing
              // of existing enrolments which is not possible here.
              return NULL;
          }
  
          return new moodle_url('/enrol/manual/manage.php', array('enrolid'=>$instance->id, 'id'=>$instance->courseid));
      }
code: public function get_manual_enrol_link($instance) {
          $name = $this->get_name();
          if ($instance->enrol !== $name) {
              throw new coding_exception('invalid enrol instance!');
          }
  
          if (!enrol_is_enabled($name)) {
              return NULL;
          }
  
          $context = context_course::instance($instance->courseid, MUST_EXIST);
  
          if (!has_capability('enrol/manual:enrol', $context)) {
              // Note: manage capability not used here because it is used for editing
              // of existing enrolments which is not possible here.
              return NULL;
          }
  
          return new moodle_url('/enrol/manual/manage.php', array('enrolid'=>$instance->id, 'id'=>$instance->courseid));
      }
code_tokens: public function get_manual_enrol_link ( $ instance ) { $ name = $ this -> get_name ( ) ; if ( $ instance -> enrol !== $ name ) { throw new coding_exception ( 'invalid enrol instance!' ) ; } if ( ! enrol_is_enabled ( $ name ) ) { return NULL ; } $ context = context_course :: instance ( $ instance -> courseid , MUST_EXIST ) ; if ( ! has_capability ( 'enrol/manual:enrol' , $ context ) ) { // Note: manage capability not used here because it is used for editing // of existing enrolments which is not possible here. return NULL ; } return new moodle_url ( '/enrol/manual/manage.php' , array ( 'enrolid' => $ instance -> id , 'id' => $ instance -> courseid ) ) ; }
docstring: Returns link to manual enrol UI if exists.
  Does the access control tests automatically.
  
  @param stdClass $instance
  @return moodle_url
docstring_tokens: Returns link to manual enrol UI if exists . Does the access control tests automatically .