diff options
author | 2016-07-10 22:56:58 +0300 | |
---|---|---|
committer | 2016-07-10 22:56:58 +0300 | |
commit | 156ab97673d7552c11784d0cdd53f8f37923a294 (patch) | |
tree | 2ae4a8928c869cc428eb5a48cf1bda6606e9f2ea /juick-www/src/main/java | |
parent | a0fa66fd9587407030d1c1ed3c5ee57d15c280fb (diff) |
fix getUserByHash usage, part 2
Diffstat (limited to 'juick-www/src/main/java')
5 files changed, 16 insertions, 18 deletions
diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java index 1811951b..240d0fdd 100644 --- a/juick-www/src/main/java/com/juick/www/Discover.java +++ b/juick-www/src/main/java/com/juick/www/Discover.java @@ -91,7 +91,7 @@ public class Discover { out.println("<section id=\"content\">"); if (mids.size() > 0) { - int vuid = visitor != null ? visitor.getUID() : 0; + int vuid = visitor.getUID(); int ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java index 9241c5e6..b0013202 100644 --- a/juick-www/src/main/java/com/juick/www/Home.java +++ b/juick-www/src/main/java/com/juick/www/Home.java @@ -58,7 +58,7 @@ public class Home { title = "Поиск: " + Utils.encodeHTML(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); } else if (paramShow == null) { - if (visitor != null) { + if (visitor.getUID() > 0) { title = "Популярные"; mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore); } else { @@ -116,7 +116,7 @@ public class Home { out.println("<!--noindex-->"); } - if (visitor != null) { + if (visitor.getUID() > 0) { out.println("<form action=\"/post\" method=\"post\" enctype=\"multipart/form-data\" onsubmit=\"return onsubmitNewMessage()\">"); out.println("<section id=\"newmessage\">"); out.println(" <textarea name=\"body\" placeholder=\"Новое сообщение...\" onclick=\"$('#newmessage>div').css('display','block');$('#newmessage textarea').css('min-height','70px');\" onkeypress=\"postformListener(this.form,event)\"></textarea>"); @@ -132,7 +132,7 @@ public class Home { if (mids.size() > 0) { int ad_mid = 0; if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) { - int vuid = visitor != null ? visitor.getUID() : 0; + int vuid = visitor.getUID(); ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); @@ -142,7 +142,7 @@ public class Home { } } - PageTemplates.printMessages(out, sql, null, mids, visitor, visitor == null ? 2 : 3, ad_mid); + PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUID() == 0 ? 2 : 3, ad_mid); } if (mids.size() >= 20) { diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 4d340cd8..e69d3c02 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -136,7 +136,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor != null) { + if (visitor.getUID() > 0) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { Utils.sendTemporaryRedirect(response, "/login"); diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java index f2483ac0..b7883a79 100644 --- a/juick-www/src/main/java/com/juick/www/PageTemplates.java +++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java @@ -87,7 +87,7 @@ public class PageTemplates { } out.println("/></form></div>"); out.println(" <section id=\"headdiv\">"); - if (visitor != null) { + if (visitor.getUID() > 0) { out.print(" <nav id=\"user\"><ul>"); out.print("<li><a href=\"/?show=my\">Моя лента</a></li>"); out.print("<li><a href=\"/pm/inbox\">Приватные</a></li>"); @@ -145,7 +145,7 @@ public class PageTemplates { String queryString = request.getQueryString(); String requestURI = request.getRequestURI(); - if (sapeon && sape != null && (visitor == null || visitor.getUID() == 1) && queryString == null) { + if (sapeon && sape != null && (visitor.getUID() == 0 || visitor.getUID() == 1) && queryString == null) { String links = sape.getPageLinks(requestURI, request.getCookies()).render(); if (links != null && !links.isEmpty()) { out.print("<br/>Спонсоры: " + links); @@ -155,7 +155,7 @@ public class PageTemplates { out.println("</div>"); out.println("</div>"); - if (visitor != null) { + if (visitor.getUID() > 0) { out.println("<script type=\"text/javascript\">"); out.println("var hash=\"" + visitor.getAuthHash() + "\";"); out.println("</script>"); @@ -412,11 +412,9 @@ public class PageTemplates { blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs); } - for (int i = 0; i < msgs.size(); i++) { - - com.juick.Message msg = msgs.get(i); + for (Message msg : msgs) { - List<com.juick.Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMID()); + List<Tag> tags = MessagesQueries.getMessageTags(sql, msg.getMID()); String tagsStr = formatTags(tags); if (msg.ReadOnly) { tagsStr += " *readonly"; @@ -450,15 +448,15 @@ public class PageTemplates { out.print(" <nav class=\"l\">"); msg.ReadOnly |= blUIDs.contains(msg.getUser().getUID()); out.print("<a href=\"#\" onclick=\"return likeMessage(this," + msg.getMID() + ")\">Мне нравится</a>"); - if (visitor == null && !msg.ReadOnly) { + if (visitor.getUID() == 0 && !msg.ReadOnly) { out.print("<a href=\"#\" onclick=\"return openDialogLogin()\">Комментировать</a> "); - } else if (visitor != null && (!msg.ReadOnly || visitor.getUID() == msg.getUser().getUID())) { + } else if (visitor.getUID() > 0 && (!msg.ReadOnly || visitor.getUID() == msg.getUser().getUID())) { out.print("<a href=\"#\" onclick=\"return showCommentFooter(this)\">Комментировать</a> "); } - if (visitor != null && msg.Privacy < 0 && msg.getUser().getUID() == visitor.getUID()) { + if (visitor.getUID() > 0 && msg.Privacy < 0 && msg.getUser().getUID() == visitor.getUID()) { out.print(" <a href=\"#\" onclick=\"return setPrivacy(this," + msg.getMID() + ")\">Открыть доступ</a>"); } - if (visitor != null && visitor.getUID() == 3694) { + if (visitor.getUID() > 0 && visitor.getUID() == 3694) { out.print(" <a href=\"#\" onclick=\"return setPopular(this," + msg.getMID() + ",2)\">+</a>"); out.print(" <a href=\"#\" onclick=\"return setPopular(this," + msg.getMID() + ",-1)\">-</a>"); out.print(" <a href=\"#\" onclick=\"return setPopular(this," + msg.getMID() + ",-2)\">x</a>"); diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java index f782d988..ce2a5826 100644 --- a/juick-www/src/main/java/com/juick/www/User.java +++ b/juick-www/src/main/java/com/juick/www/User.java @@ -158,7 +158,7 @@ public class User { protected void doGetTags(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor == null) { + if (visitor.getUID() == 0) { pageUserRefCookie(request, response, user.getUID()); } |