original_string: public function get_instance_name($instance) {
          global $DB;
  
          if (empty($instance)) {
              $enrol = $this->get_name();
              return get_string('pluginname', 'enrol_'.$enrol);
  
          } else if (empty($instance->name)) {
              $enrol = $this->get_name();
              $cohort = $DB->get_record('cohort', array('id'=>$instance->customint1));
              if (!$cohort) {
                  return get_string('pluginname', 'enrol_'.$enrol);
              }
              $cohortname = format_string($cohort->name, true, array('context'=>context::instance_by_id($cohort->contextid)));
              if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) {
                  $role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING));
                  return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ' - ' . $role .')';
              } else {
                  return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ')';
              }
  
          } else {
              return format_string($instance->name, true, array('context'=>context_course::instance($instance->courseid)));
          }
      }
code: public function get_instance_name($instance) {
          global $DB;
  
          if (empty($instance)) {
              $enrol = $this->get_name();
              return get_string('pluginname', 'enrol_'.$enrol);
  
          } else if (empty($instance->name)) {
              $enrol = $this->get_name();
              $cohort = $DB->get_record('cohort', array('id'=>$instance->customint1));
              if (!$cohort) {
                  return get_string('pluginname', 'enrol_'.$enrol);
              }
              $cohortname = format_string($cohort->name, true, array('context'=>context::instance_by_id($cohort->contextid)));
              if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) {
                  $role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING));
                  return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ' - ' . $role .')';
              } else {
                  return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ')';
              }
  
          } else {
              return format_string($instance->name, true, array('context'=>context_course::instance($instance->courseid)));
          }
      }
code_tokens: public function get_instance_name ( $ instance ) { global $ DB ; if ( empty ( $ instance ) ) { $ enrol = $ this -> get_name ( ) ; return get_string ( 'pluginname' , 'enrol_' . $ enrol ) ; } else if ( empty ( $ instance -> name ) ) { $ enrol = $ this -> get_name ( ) ; $ cohort = $ DB -> get_record ( 'cohort' , array ( 'id' => $ instance -> customint1 ) ) ; if ( ! $ cohort ) { return get_string ( 'pluginname' , 'enrol_' . $ enrol ) ; } $ cohortname = format_string ( $ cohort -> name , true , array ( 'context' => context :: instance_by_id ( $ cohort -> contextid ) ) ) ; if ( $ role = $ DB -> get_record ( 'role' , array ( 'id' => $ instance -> roleid ) ) ) { $ role = role_get_name ( $ role , context_course :: instance ( $ instance -> courseid , IGNORE_MISSING ) ) ; return get_string ( 'pluginname' , 'enrol_' . $ enrol ) . ' (' . $ cohortname . ' - ' . $ role . ')' ; } else { return get_string ( 'pluginname' , 'enrol_' . $ enrol ) . ' (' . $ cohortname . ')' ; } } else { return format_string ( $ instance -> name , true , array ( 'context' => context_course :: instance ( $ instance -> courseid ) ) ) ; } }
docstring: Returns localised name of enrol instance.
  
  @param stdClass $instance (null is accepted too)
  @return string
docstring_tokens: Returns localised name of enrol instance .