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;
    }