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;
    }
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;
    }
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 ; }
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
User name with a link to profile