@Autowired
private TopicDao topicDao;
@RequestMapping(value="/people/{nick}/profile", method = {RequestMethod.GET, RequestMethod.HEAD})
public ModelAndView getInfoNew(@PathVariable String nick, HttpServletRequest request, HttpServletResponse response) throws Exception {
Template tmpl = Template.getTemplate(request);
User user = userDao.getUser(nick);
if (user.isBlocked() && !tmpl.isSessionAuthorized()) {
throw new UserBanedException(user, userDao.getBanInfoClass(user));
}
ModelAndView mv = new ModelAndView("whois");
mv.getModel().put("user", user);
mv.getModel().put("userInfo", userDao.getUserInfoClass(user));
mv.getModel().put("userpic", userService.getUserpic(
user,
request.isSecure(),
tmpl.getProf().getAvatarMode(),
true
));
if (user.isBlocked()) {
mv.getModel().put("banInfo", userDao.getBanInfoClass(user));
}
boolean currentUser = tmpl.isSessionAuthorized() && tmpl.getNick().equals(nick);
if (!user.isAnonymous()) {
UserStats userStat = userStatisticsService.getStats(user);
mv.getModel().put("userStat", userStat);
mv.getModel().put("watchPresent", memoriesDao.isWatchPresetForUser(user));
mv.getModel().put("favPresent", memoriesDao.isFavPresetForUser(user));
if (currentUser || tmpl.isModeratorSession()) {
mv.getModel().put("hasDrafts", topicDao.hasDrafts(user));
}
}
mv.getModel().put("moderatorOrCurrentUser", currentUser || tmpl.isModeratorSession());
mv.getModel().put("currentUser", currentUser);
if (tmpl.isSessionAuthorized() && !currentUser) {
Set<Integer> ignoreList = ignoreListDao.get(tmpl.getCurrentUser());
mv.getModel().put("ignored", ignoreList.contains(user.getId()));
mv.getModel().put("remark", userDao.getRemark(tmpl.getCurrentUser() , user) );
}
if (tmpl.isSessionAuthorized() && currentUser) {
mv.getModel().put("hasRemarks", ( userDao.getRemarkCount(tmpl.getCurrentUser()) > 0 ) );
}
String userinfo = userDao.getUserInfo(user);
if (!Strings.isNullOrEmpty(userinfo)) {
mv.getModel().put(
"userInfoText",
lorCodeService.parseComment(
userinfo,
request.isSecure(),
!topicPermissionService.followAuthorLinks(user)
)
);
}
mv.addObject("favoriteTags", userTagService.favoritesGet(user));
if (currentUser || tmpl.isModeratorSession()) {
mv.addObject("ignoreTags", userTagService.ignoresGet(user));
}
if (currentUser || tmpl.isModeratorSession()) {
List<UserLogItem> logItems = userLogDao.getLogItems(user, tmpl.isModeratorSession());
if (!logItems.isEmpty()) {
mv.addObject("userlog", userLogPrepareService.prepare(logItems));
}
}