original_string: protected function username($user, $profilelink = true) {
          $canviewfullnames = has_capability('moodle/site:viewfullnames', \context_system::instance()) ||
              has_capability('moodle/site:viewfullnames', \context_user::instance($user->id));
          $name = fullname($user, $canviewfullnames);
          if (!$this->is_downloading() && $profilelink) {
              $profileurl = new \moodle_url('/user/profile.php', array('id' => $user->id));
              return \html_writer::link($profileurl, $name);
          }
          return $name;
      }
code: protected function username($user, $profilelink = true) {
          $canviewfullnames = has_capability('moodle/site:viewfullnames', \context_system::instance()) ||
              has_capability('moodle/site:viewfullnames', \context_user::instance($user->id));
          $name = fullname($user, $canviewfullnames);
          if (!$this->is_downloading() && $profilelink) {
              $profileurl = new \moodle_url('/user/profile.php', array('id' => $user->id));
              return \html_writer::link($profileurl, $name);
          }
          return $name;
      }
code_tokens: protected function username ( $ user , $ profilelink = true ) { $ canviewfullnames = has_capability ( 'moodle/site:viewfullnames' , \ context_system :: instance ( ) ) || has_capability ( 'moodle/site:viewfullnames' , \ context_user :: instance ( $ user -> id ) ) ; $ name = fullname ( $ user , $ canviewfullnames ) ; if ( ! $ this -> is_downloading ( ) && $ profilelink ) { $ profileurl = new \ moodle_url ( '/user/profile.php' , array ( 'id' => $ user -> id ) ) ; return \ html_writer :: link ( $ profileurl , $ name ) ; } return $ name ; }
docstring: User name with a link to profile
  
  @param stdClass $user
  @param bool $profilelink show link to profile (when we are downloading never show links)
  @return string
docstring_tokens: User name with a link to profile