0
|
1 <%
|
|
2 package nabble.view.web.user;
|
|
3
|
|
4 import nabble.model.Node;
|
|
5 import nabble.model.User;
|
|
6 import nabble.view.lib.Jtp;
|
|
7 import nabble.view.lib.Shared;
|
|
8 import nabble.view.lib.HtmlViewUtils;
|
|
9
|
|
10 import javax.servlet.ServletException;
|
|
11 import javax.servlet.http.HttpServlet;
|
|
12 import javax.servlet.http.HttpServletRequest;
|
|
13 import javax.servlet.http.HttpServletResponse;
|
|
14 import java.io.IOException;
|
|
15 import java.io.PrintWriter;
|
|
16 import java.util.ArrayList;
|
|
17 import java.util.List;
|
|
18
|
|
19
|
|
20 public final class UserPendingNodes extends HttpServlet {
|
|
21
|
|
22 private static final int MAX_ROWS = 20;
|
|
23
|
|
24 protected void service(HttpServletRequest request, HttpServletResponse response)
|
|
25 throws ServletException, IOException
|
|
26 {
|
|
27 PrintWriter out = response.getWriter();
|
|
28 User user = Jtp.getUser(request, response);
|
|
29
|
|
30 if ( user == null ) {
|
|
31 Jtp.login("You must register/login to edit your profile.", request, response);
|
|
32 return;
|
|
33 }
|
|
34
|
|
35 String iRecS = request.getParameter("i");
|
|
36 int iRec = iRecS == null? 0 : Integer.valueOf(iRecS);
|
|
37
|
|
38 List<Node> nodeArray = user.getPendingPosts().get(0, 1000);
|
|
39 SearchResults searchResults = cutResults(nodeArray, iRec);
|
|
40
|
|
41 String title = "Pending Posts of ";
|
|
42 title += user.getName();
|
|
43
|
|
44 String url = "/user/UserPendingNodes.jtp";
|
|
45 HtmlViewUtils.GenericPagingPath pagingPath = new HtmlViewUtils.GenericPagingPath(url);
|
|
46 %>
|
|
47 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
48 <html>
|
|
49 <head>
|
|
50 <% Shared.title(request, response, title); %>
|
|
51 </head>
|
|
52 <body>
|
|
53 <% Shared.minHeaderGlobal(request, response); %>
|
|
54 <table>
|
|
55 <tr valign="top">
|
|
56 <td><img src="<%=Shared.getAvatarImageURL(user, false)%>" class="avatar light-border-color" width=100 height=100/></td>
|
|
57 <td style="width:100%">
|
|
58 <div class="second-font" style="font-size:170%">
|
|
59 <%=user.getNameHtml()%>
|
|
60 </div>
|
|
61 <div style="margin-top:.5em">
|
|
62 <a href="/template/NamlServlet.jtp?macro=user_profile">Account Settings</a>
|
|
63 </div>
|
|
64 </td>
|
|
65 </tr>
|
|
66 </table>
|
|
67
|
|
68 <table style="border-collapse:collapse;width:100%;margin-top:.5em">
|
|
69 <tr>
|
|
70 <td class="title-row light-border-color" colspan=3>
|
|
71 <div style="float:left;padding-top:.2em">
|
|
72 <b>Pending Messages</b>
|
|
73 </div>
|
|
74 <% HtmlViewUtils.genericPaging(request, response, searchResults.getCount(), iRec, MAX_ROWS, pagingPath, ".4em 0 0 0"); %>
|
|
75 </td>
|
|
76 </tr>
|
|
77 </table>
|
|
78
|
|
79 <style type="text/css">
|
|
80 table.nodes {
|
|
81 width:100%;
|
|
82 border-width: 1px;
|
|
83 border-style: solid;
|
|
84 border-collapse:collapse;
|
|
85 margin-top:.5em;
|
|
86 }
|
|
87
|
|
88 table.nodes td {
|
|
89 padding:.1em;
|
|
90 }
|
|
91
|
|
92 table.nodes td.header {
|
|
93 padding: .2em .3em;
|
|
94 border-bottom-width: 1px;
|
|
95 border-bottom-style: solid;
|
|
96 }
|
|
97 </style>
|
|
98
|
|
99 <%
|
|
100 String[] columns = new String[] { "Message", "Pending Since", "Forum" };
|
|
101 %>
|
|
102
|
|
103 <table class="nodes medium-border-color">
|
|
104 <tr class="shaded-bg-color" style="font-weight: bold">
|
|
105 <td class="header" style="width:16px"></td>
|
|
106 <td class="header"><%=columns[0]%></td>
|
|
107 <td class="header"><%=columns[1]%></td>
|
|
108 <td class="header"><%=columns[2]%></td>
|
|
109 </tr>
|
|
110 <%
|
|
111 Node[] nodes = searchResults.getNodes();
|
|
112 int i = 0;
|
|
113 if (nodes.length > 0) {
|
|
114 for (Node node : nodes) {
|
|
115 %>
|
|
116 <tr <%=i++%2==1?"class=\"light-bg-color\"":""%>>
|
|
117 <td align="center">
|
|
118 <%Shared.showPending(out, node);%>
|
|
119 </td>
|
|
120 <td style="padding:.3em .4em;">
|
|
121 <a href="<%=Jtp.url(node)%>"><%=node.getSubjectHtml()%></a>
|
|
122 </td>
|
|
123 <td style="padding:.2em">
|
|
124 <%=node.getMailToList() == null? "" : Jtp.formatDateLong(node.getMailToList().getWhenSent())%>
|
|
125 </td>
|
|
126 <td style="padding:.2em">
|
|
127 <%=Jtp.link(node.getApp())%>
|
|
128 </td>
|
|
129 </tr>
|
|
130 <%
|
|
131 }
|
|
132 } else {
|
|
133 %>
|
|
134 <tr><td colspan=4 style="padding:.3em">None</td></tr>
|
|
135 <%
|
|
136 }
|
|
137 %>
|
|
138 </table>
|
|
139 <% HtmlViewUtils.genericPaging(request, response, searchResults.getCount(), iRec, MAX_ROWS, pagingPath, ".5em 0 0 0"); %>
|
|
140
|
|
141 <% Shared.footer(request,response); %>
|
|
142 <% Shared.analytics(request,response); %>
|
|
143 </body>
|
|
144 </html>
|
|
145 <%
|
|
146 }
|
|
147
|
|
148 private class SearchResults {
|
|
149 private int count;
|
|
150 private Node[] nodes;
|
|
151
|
|
152 public SearchResults() {}
|
|
153
|
|
154 public SearchResults(int count, Node[] nodes) {
|
|
155 this.count = count;
|
|
156 this.nodes = nodes;
|
|
157 }
|
|
158
|
|
159 public int getCount() { return count; }
|
|
160 public void setCount(int count) { this.count = count; }
|
|
161 public Node[] getNodes() { return nodes; }
|
|
162 public void setNodes(Node[] nodes) { this.nodes = nodes; }
|
|
163 }
|
|
164
|
|
165 private SearchResults cutResults(List<Node> array, int iRec) {
|
|
166 int i = iRec;
|
|
167 int count = 0;
|
|
168 List<Node> nodes = new ArrayList<Node>();
|
|
169 while (count < MAX_ROWS) {
|
|
170 if (array.size()-1 < i)
|
|
171 break;
|
|
172 nodes.add(array.get(i++));
|
|
173 count++;
|
|
174 }
|
|
175 Node[] nodesArray = nodes.toArray(new Node[0]);
|
|
176 return new SearchResults(array.size(), nodesArray);
|
|
177 }
|
|
178 }
|
|
179 %>
|