Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.138.2.23 -r1.138.2.24
--- lams_central/conf/language/lams/ApplicationResources.properties 21 Apr 2016 09:13:16 -0000 1.138.2.23
+++ lams_central/conf/language/lams/ApplicationResources.properties 27 Apr 2016 00:05:37 -0000 1.138.2.24
@@ -677,7 +677,8 @@
label.no.comments=No Comments
label.newest.first=Newest First
label.top.comments=Top Comments
-
+label.add.sticky=Stick To Top
+label.remove.sticky=Remove Sticky
label.private.notifications.title =Notifications
label.private.notifications.messages =Messages
label.private.notifications.read =Read
Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources_en_AU.properties,v
diff -u -r1.111.2.7 -r1.111.2.8
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 12 Jan 2016 13:14:21 -0000 1.111.2.7
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 27 Apr 2016 00:05:37 -0000 1.111.2.8
@@ -664,4 +664,12 @@
label.no.comments=No Comments
label.newest.first=Newest First
label.top.comments=Top Comments
+label.add.sticky=Stick To Top
+label.remove.sticky=Remove Sticky
+label.private.notifications.title =Notifications
+label.private.notifications.messages =Messages
+label.private.notifications.read =Read
+label.private.notifications.read.hint =Mark notification as read
+label.private.notifications.read.all.hint =Mark all notifications as read
+
#======= End labels: Exported 439 labels for en AU =====
\ No newline at end of file
Index: lams_central/conf/xdoclet/struts-actions.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/struts-actions.xml,v
diff -u -r1.7.2.2 -r1.7.2.3
--- lams_central/conf/xdoclet/struts-actions.xml 16 Mar 2016 12:14:03 -0000 1.7.2.2
+++ lams_central/conf/xdoclet/struts-actions.xml 27 Apr 2016 00:05:37 -0000 1.7.2.3
@@ -7,6 +7,7 @@
scope="request"
>
+
+
+
+
+
\ No newline at end of file
Index: lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java
===================================================================
RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java,v
diff -u -r1.3.2.2 -r1.3.2.3
--- lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java 12 Jan 2016 12:19:52 -0000 1.3.2.2
+++ lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java 27 Apr 2016 00:05:37 -0000 1.3.2.3
@@ -43,6 +43,7 @@
public static final String ATTR_LIKE_AND_DISLIKE = "likeAndDislike";
public static final String ATTR_READ_ONLY = "readOnly";
public static final String ATTR_SORT_BY = "sortBy"; // 0 date, 1 likes
+ public static final String ATTR_STICKY = "sticky"; // 0 date, 1 likes
// for paging long topics & inlining reply
public static final String PAGE_LAST_ID = "pageLastId";
Index: lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java,v
diff -u -r1.4.2.2 -r1.4.2.3
--- lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java 12 Jan 2016 12:19:52 -0000 1.4.2.2
+++ lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java 27 Apr 2016 00:05:37 -0000 1.4.2.3
@@ -112,6 +112,9 @@
if (param.equals("hide")) {
return hideComment(mapping, form, request, response, false);
}
+ if (param.equals("makeSticky")) {
+ return makeSticky(mapping, form, request, response);
+ }
return mapping.findForward("error");
}
@@ -188,23 +191,34 @@
Comment rootComment = getCommentService().createOrGetRoot(externalId, externalType, externalSignature, user);
sessionMap.put(CommentConstants.ATTR_ROOT_COMMENT_UID, rootComment.getUid());
- return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy);
+ return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy, true);
}
private void throwException(String msg, String loginName, Long externalId, Integer externalType, String externalSignature) throws ServletException {
String error = msg+" User "+loginName+" "+externalId+":"+externalType+":"+externalSignature;
log.error(error);
throw new ServletException(error);
}
-
+
+ private void throwException(String msg, String loginName) throws ServletException {
+ String error = msg+" User "+loginName;
+ log.error(error);
+ throw new ServletException(error);
+ }
+
private boolean learnerInToolSession(Long toolSessionId, User user) {
GroupedToolSession toolSession = (GroupedToolSession) getCoreToolService().getToolSessionById(toolSessionId);
return toolSession.getSessionGroup().getUsers().contains(user);
}
- private boolean monitorInToolSession(Long toolSessionId, User user) {
- GroupedToolSession toolSession = (GroupedToolSession) getCoreToolService().getToolSessionById(toolSessionId);
- return getSecurityService().isLessonMonitor(toolSession.getLesson().getLessonId(), user.getUserId(), "Comment Monitoring Tasks", false);
+ private boolean monitorInToolSession(Long toolSessionId, User user, SessionMap sessionMap) {
+
+ if ( ToolAccessMode.TEACHER.equals(WebUtil.getToolAccessMode((String)sessionMap.get(AttributeNames.ATTR_MODE))) ) {
+ GroupedToolSession toolSession = (GroupedToolSession) getCoreToolService().getToolSessionById(toolSessionId);
+ return getSecurityService().isLessonMonitor(toolSession.getLesson().getLessonId(), user.getUserId(), "Comment Monitoring Tasks", false);
+ } else {
+ return false;
+ }
}
/**
@@ -226,14 +240,15 @@
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
Integer pageSize = WebUtil.readIntParam(request, CommentConstants.PAGE_SIZE, true);
Integer sortBy = WebUtil.readIntParam(request, CommentConstants.ATTR_SORT_BY, true);
+ Boolean sticky = WebUtil.readBooleanParam(request, CommentConstants.ATTR_STICKY, false);
if ( sortBy != null )
sessionMap.put( CommentConstants.ATTR_SORT_BY, sortBy);
- return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy);
+ return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy, sticky);
}
private ActionForward viewTopicImpl(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response, SessionMap sessionMap, Integer pageSize, Integer sortBy) {
+ HttpServletResponse response, SessionMap sessionMap, Integer pageSize, Integer sortBy, boolean includeSticky) {
Long externalId = (Long) sessionMap.get(CommentConstants.ATTR_EXTERNAL_ID);
Integer externalType = (Integer) sessionMap.get(CommentConstants.ATTR_EXTERNAL_TYPE);
@@ -256,11 +271,17 @@
List msgDtoList = commentService.getTopicThread(externalId, externalType, externalSignature, lastMsgSeqId, pageSize, sortBy, currentLikeCount, user.getUserID());
updateMessageFlag(msgDtoList, user.getUserID());
request.setAttribute(CommentConstants.ATTR_COMMENT_THREAD, msgDtoList);
+
+ if ( includeSticky ) {
+ List stickyList = commentService.getTopicStickyThread(externalId, externalType, externalSignature,sortBy, currentLikeCount, user.getUserID());
+ updateMessageFlag(stickyList, user.getUserID());
+ request.setAttribute(CommentConstants.ATTR_STICKY, stickyList);
+ }
// transfer SessionMapID as well
request.setAttribute(CommentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
- return mapping.findForward("success");
+ return mapping.findForward(includeSticky ? "successAll" : "success");
}
@SuppressWarnings("unchecked")
@@ -363,7 +384,8 @@
commentService = getCommentService();
User user = getCurrentUser(request);
- if ( ! learnerInToolSession(externalId, user) )
+ boolean monitoringMode = ToolAccessMode.TEACHER.equals(WebUtil.getToolAccessMode((String)sessionMap.get(AttributeNames.ATTR_MODE)));
+ if ( ! learnerInToolSession(externalId, user) && ! monitorInToolSession(externalId, user, sessionMap) )
throwException("New comment: User does not have the rights to access the comments. ", user.getLogin(), externalId, externalType, externalSignature );
Comment rootSeq = commentService.getRoot(externalId, externalType, externalSignature);
@@ -435,7 +457,7 @@
commentService = getCommentService();
User user = getCurrentUser(request);
- if ( ! learnerInToolSession(externalId, user) )
+ if ( ! learnerInToolSession(externalId, user) && ! monitorInToolSession(externalId, user, sessionMap) )
throwException("New comment: User does not have the rights to access the comments. ", user.getLogin(), externalId, externalType, externalSignature );
// save message into database
@@ -517,12 +539,12 @@
CommentDTO originalComment = commentService.getComment(commentId);
- boolean monitoringMode = ToolAccessMode.TEACHER.equals(WebUtil.getToolAccessMode((String)sessionMap.get(AttributeNames.ATTR_MODE)));
User user = getCurrentUser(request);
- if ( ! originalComment.getComment().getCreatedBy().equals(user) && ! ( monitoringMode && monitorInToolSession(externalId, user) ) )
+ if ( ! originalComment.getComment().getCreatedBy().equals(user) && ! monitorInToolSession(externalId, user, sessionMap) )
throwException("Update comment: User does not have the rights to update the comment "+commentId+". ", user.getLogin(), externalId, externalType, externalSignature );
- Comment updatedComment = commentService.updateComment(commentId, commentText, user, monitoringMode);
+ Comment updatedComment = commentService.updateComment(commentId, commentText, user,
+ ToolAccessMode.TEACHER.equals(WebUtil.getToolAccessMode((String)sessionMap.get(AttributeNames.ATTR_MODE))));
JSONObject = new JSONObject();
JSONObject.put(CommentConstants.ATTR_COMMENT_ID, commentId);
@@ -579,9 +601,8 @@
commentService = getCommentService();
- boolean monitoringMode = ToolAccessMode.TEACHER.equals(WebUtil.getToolAccessMode((String)sessionMap.get(AttributeNames.ATTR_MODE)));
User user = getCurrentUser(request);
- if ( ! monitoringMode || ! monitorInToolSession(externalId, user) )
+ if ( ! monitorInToolSession(externalId, user, sessionMap) )
throwException("Update comment: User does not have the rights to hide the comment "+commentId+". ", user.getLogin(), externalId,
(Integer) sessionMap.get(CommentConstants.ATTR_EXTERNAL_TYPE), (String) sessionMap.get(CommentConstants.ATTR_EXTERNAL_SIG) );
@@ -599,6 +620,39 @@
}
/**
+ * Make a topic sticky - the topic should be level 1 only.
+ * @throws ServletException
+ */
+ public ActionForward makeSticky(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws JSONException, IOException, ServletException {
+
+ commentService = getCommentService();
+ SessionMap sessionMap = getSessionMap(request);
+ Long commentId = WebUtil.readLongParam(request, CommentConstants.ATTR_COMMENT_ID);
+ Boolean sticky = WebUtil.readBooleanParam(request, CommentConstants.ATTR_STICKY);
+ Long externalId = (Long) sessionMap.get(CommentConstants.ATTR_EXTERNAL_ID);
+
+ CommentDTO originalComment = commentService.getComment(commentId);
+ User user = getCurrentUser(request);
+
+ if ( ! monitorInToolSession(externalId, user, sessionMap))
+ throwException("Make comment sticky: User does not have the rights to make the comment stick to the top of the list "+commentId+". ", user.getLogin());
+ if ( originalComment.getComment().getCommentLevel() != 1)
+ throwException("Make comment sticky: Comment much be level 1 to stick to the top of the list "+commentId+" level "+originalComment.getLevel()+". ", user.getLogin());
+
+ Comment updatedComment = commentService.updateSticky(commentId, sticky);
+
+ JSONObject JSONObject = new JSONObject();
+ JSONObject.put(CommentConstants.ATTR_COMMENT_ID, commentId);
+ JSONObject.put(CommentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
+ JSONObject.put(CommentConstants.ATTR_THREAD_ID, updatedComment.getThreadComment().getUid());
+ JSONObject.put(CommentConstants.ATTR_PARENT_COMMENT_ID, updatedComment.getParent().getUid());
+
+ response.setContentType("application/json;charset=utf-8");
+ response.getWriter().print(JSONObject);
+ return null;
+ }
+ /**
* Get login user information from system level session.
*/
private User getCurrentUser(HttpServletRequest request) {
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_central/web/comments/allview.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_central/web/comments/allviewwrapper.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_central/web/comments/comments.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/comments/comments.jsp,v
diff -u -r1.6.2.6 -r1.6.2.7
--- lams_central/web/comments/comments.jsp 24 Feb 2016 12:35:44 -0000 1.6.2.6
+++ lams_central/web/comments/comments.jsp 27 Apr 2016 00:05:37 -0000 1.6.2.7
@@ -34,22 +34,19 @@
scrollDoneCallback();
$('#sortMenu').change(function(){
- var url = "comments/viewTopic.do?sessionMapID=${sessionMapID}&sortBy="+$(this).find("option:selected").attr('value');
- reloadScroll(url);
+ var url = "comments/viewTopic.do?pageSize=2&sessionMapID=${sessionMapID}&sticky=true&sortBy="+$(this).find("option:selected").attr('value');
+ reloadDivs(url);
});
});
function refreshComments(){
var reqIDVar = new Date();
- reloadScroll('comments/viewTopic.do?sessionMapID=${sessionMapID}&reqUid='+reqIDVar.getTime());
+ reloadDivs('comments/viewTopic.do?pageSize=2&sessionMapID=${sessionMapID}&sticky=true&reqUid='+reqIDVar.getTime());
}
- function reloadScroll(url) {
- $('#newcomments').children().remove();
- $('.scroll').load(url, function() {
- $('.scroll').data('jscroll', null);
- $('.scroll').jscroll({loadingHtml: '
${loading_words}',padding:30,autoTrigger:false,callback:scrollDoneCallback});
- });
+ function reloadDivs(url) {
+ $('.scroll').data('jscroll', null);
+ $('#commentDiv').load(url);
}
function scrollDoneCallback() {
@@ -59,7 +56,7 @@
-
+
-
- -
+
+
+
+
+
+
+
+
+
+
+
+ -
">
| ( )
-
+
+