2929import org .labkey .announcements .model .AnnouncementManager ;
3030import org .labkey .announcements .model .AnnouncementModel ;
3131import org .labkey .announcements .model .DailyDigestEmailPrefsSelector ;
32- import org .labkey .announcements .model .DiscussionServiceImpl ;
3332import org .labkey .announcements .model .IndividualEmailPrefsSelector ;
3433import org .labkey .announcements .model .InsertMessagePermission ;
3534import org .labkey .announcements .model .Permissions ;
35+ import org .labkey .announcements .model .Settings ;
3636import org .labkey .announcements .query .AnnouncementSchema ;
3737import org .labkey .api .action .ApiResponse ;
3838import org .labkey .api .action .ApiSimpleResponse ;
5050import org .labkey .api .action .SpringActionController ;
5151import org .labkey .api .admin .AdminUrls ;
5252import org .labkey .api .announcements .CommSchema ;
53- import org .labkey .api .announcements .DiscussionService ;
54- import org .labkey .api .announcements .DiscussionService .Settings ;
55- import org .labkey .api .announcements .DiscussionService .StatusOption ;
5653import org .labkey .api .announcements .EmailOption ;
5754import org .labkey .api .announcements .api .AnnouncementService ;
5855import org .labkey .api .announcements .api .DiscussionSrcTypeProvider ;
@@ -832,17 +829,8 @@ public boolean handlePost(AnnouncementForm form, BindException errors)
832829 if (null != insert .getParent ())
833830 thread = AnnouncementManager .getAnnouncement (getContainer (), insert .getParent ());
834831
835- if (form .isFromDiscussion () && null != thread .getDiscussionSrcIdentifier ())
836- {
837- returnUrl = DiscussionServiceImpl .fromSaved (thread .getDiscussionSrcURL ());
838- returnUrl .addParameter ("discussion.id" , "" + thread .getRowId ());
839- returnUrl .addParameter ("_anchor" , "discussionArea" ); // TODO: insert.getRowId() instead? -- target just inserted response
840- }
841- else
842- {
843- String threadId = thread .getEntityId ();
844- returnUrl = getThreadURL (c , threadId , insert .getRowId ());
845- }
832+ String threadId = thread .getEntityId ();
833+ returnUrl = getThreadURL (c , threadId , insert .getRowId ());
846834 }
847835
848836 _attachmentErrorView = AttachmentService .get ().getErrorView (files , errors , returnUrl );
@@ -873,18 +861,6 @@ public static ActionURL getInsertURL(Container c)
873861 @ RequiresAnyOf ({InsertMessagePermission .class , InsertPermission .class })
874862 public class InsertAction extends BaseInsertAction
875863 {
876- @ Override
877- public void validateCommand (AnnouncementForm form , Errors errors )
878- {
879- super .validateCommand (form , errors );
880-
881- if (form .isFromDiscussion () && !form .allowMultipleDiscussions ())
882- {
883- if (DiscussionService .get ().hasDiscussions (getContainer (), form .getBean ().getDiscussionSrcIdentifier ()))
884- errors .reject (ERROR_MSG , "Can't post a new discussion -- a discussion already exists and multiple discussions are not allowed" );
885- }
886- }
887-
888864 @ Override
889865 public ModelAndView getInsertUpdateView (AnnouncementForm form , boolean reshow , BindException errors )
890866 {
@@ -897,7 +873,7 @@ public ModelAndView getInsertUpdateView(AnnouncementForm form, boolean reshow, B
897873 throw new UnauthorizedException ();
898874 }
899875
900- InsertMessageView insertView = new InsertMessageView (form , "New " + settings .getConversationName (), errors , reshow , form .getReturnUrlHelper (), false , true );
876+ InsertMessageView insertView = new InsertMessageView (form , "New " + settings .getConversationName (), errors , reshow , form .getReturnUrlHelper ());
901877 insertView .setShowTitle (false );
902878
903879 getPageConfig ().setFocusId ("title" );
@@ -958,7 +934,7 @@ public ModelAndView getInsertUpdateView(AnnouncementForm form, boolean reshow, B
958934 ThreadView threadView = new ThreadView (c , getActionURL (), parent , perm );
959935 threadView .setFrame (WebPartView .FrameType .DIV );
960936
961- HttpView <?> respondView = new RespondView (c , parent , form , form .getReturnUrlHelper (), errors , reshow , false );
937+ HttpView <?> respondView = new RespondView (c , parent , form , form .getReturnUrlHelper (), errors , reshow );
962938
963939 getPageConfig ().setFocusId ("body" );
964940 _parent = parent ;
@@ -981,7 +957,7 @@ public void addNavTrail(NavTree root)
981957 private static SelectBuilder getStatusSelect (String currentValue )
982958 {
983959 return new SelectBuilder ().name ("status" ).id ("status" ).className (null ).selected (currentValue )
984- .addOptions (Arrays .stream (StatusOption .values ()).map (Enum ::name ));
960+ .addOptions (Arrays .stream (AnnouncementService . StatusOption .values ()).map (Enum ::name ));
985961 }
986962
987963
@@ -1081,7 +1057,7 @@ private static ActionURL getInsertURL(Container c, @Nullable ActionURL returnUrl
10811057
10821058 public abstract static class BaseInsertView extends JspView <BaseInsertView .InsertBean >
10831059 {
1084- public BaseInsertView (String page , InsertBean bean , AnnouncementForm form , URLHelper cancelURL , String title , BindException errors , @ Nullable AnnouncementModel latestPost , boolean reshow , boolean fromDiscussion )
1060+ public BaseInsertView (String page , InsertBean bean , AnnouncementForm form , URLHelper cancelURL , String title , BindException errors , @ Nullable AnnouncementModel latestPost , boolean reshow )
10851061 {
10861062 super (page , bean , errors );
10871063 setTitle (title );
@@ -1135,7 +1111,6 @@ else if (null == latestPost)
11351111 bean .memberList = getMemberList (u , c , latestPost , reshow ? form .get ("memberList" ) : null );
11361112 bean .form = form ;
11371113 bean .cancelURL = cancelURL ;
1138- bean .fromDiscussion = fromDiscussion ;
11391114
11401115 // If default email option is "all messages" (or "all messages daily digest") then gently warn
11411116 // that a bunch of users are about to be emailed.
@@ -1158,38 +1133,28 @@ public static class InsertBean
11581133 public AnnouncementForm form ;
11591134 public URLHelper cancelURL ;
11601135 public AnnouncementModel parentAnnouncementModel ; // Used by RespondView only... move to subclass?
1161- public boolean fromDiscussion ;
1162- public boolean allowMultipleDiscussions = true ;
11631136 public Integer emailUsers = null ;
11641137 }
11651138 }
11661139
11671140
11681141 public static class InsertMessageView extends BaseInsertView
11691142 {
1170- public InsertMessageView (AnnouncementForm form , String title , BindException errors , boolean reshow , URLHelper cancelURL , boolean fromDiscussion , boolean allowMultipleDiscussions )
1143+ public InsertMessageView (AnnouncementForm form , String title , BindException errors , boolean reshow , URLHelper cancelURL )
11711144 {
1172- super ("/org/labkey/announcements/insert.jsp" , new InsertBean (), form , cancelURL , title , errors , null , reshow , fromDiscussion );
1173-
1174- InsertBean bean = getModelBean ();
1175- bean .allowMultipleDiscussions = allowMultipleDiscussions ;
1145+ super ("/org/labkey/announcements/insert.jsp" , new InsertBean (), form , cancelURL , title , errors , null , reshow );
11761146 }
11771147 }
11781148
11791149
11801150 public static class RespondView extends BaseInsertView
11811151 {
1182- public RespondView (Container c , AnnouncementModel parent , AnnouncementForm form , URLHelper cancelURL , BindException errors , boolean reshow , boolean fromDiscussion )
1152+ public RespondView (Container c , AnnouncementModel parent , AnnouncementForm form , URLHelper cancelURL , BindException errors , boolean reshow )
11831153 {
1184- super ("/org/labkey/announcements/respond.jsp" , new InsertBean (), form , cancelURL , "Response" , errors , AnnouncementManager .getLatestPost (c , parent ), reshow , fromDiscussion );
1154+ super ("/org/labkey/announcements/respond.jsp" , new InsertBean (), form , cancelURL , "Response" , errors , AnnouncementManager .getLatestPost (c , parent ), reshow );
11851155
11861156 getModelBean ().parentAnnouncementModel = parent ;
11871157 }
1188-
1189- public RespondView (Container c , AnnouncementModel parent , URLHelper cancelURL , boolean fromDiscussion )
1190- {
1191- this (c , parent , new AnnouncementForm (), cancelURL , null , false , fromDiscussion );
1192- }
11931158 }
11941159
11951160
@@ -1387,27 +1352,6 @@ public void addNavTrail(NavTree root)
13871352 }
13881353 }
13891354
1390-
1391- @ RequiresPermission (ReadPermission .class )
1392- public class ThreadBareAction extends ThreadAction
1393- {
1394- @ Override
1395- public ThreadView getView (AnnouncementForm form , BindException errors ) throws Exception
1396- {
1397- getPageConfig ().setTemplate (PageConfig .Template .None );
1398- ThreadView tv = super .getView (form , errors );
1399- tv .setFrame (WebPartView .FrameType .NONE );
1400- tv .getModelBean ().embedded = true ;
1401- return tv ;
1402- }
1403-
1404- @ Override
1405- public void addNavTrail (NavTree root )
1406- {
1407- }
1408- }
1409-
1410-
14111355 @ RequiresPermission (ReadPermission .class )
14121356 public class RssAction extends SimpleViewAction <Object >
14131357 {
@@ -1736,19 +1680,8 @@ public void validate(Errors errors)
17361680 errors .reject (ERROR_MSG , "Expires must be blank or a valid date." );
17371681 }
17381682 }
1739-
1740- public boolean isFromDiscussion ()
1741- {
1742- return Boolean .parseBoolean (get ("fromDiscussion" ));
1743- }
1744-
1745- public boolean allowMultipleDiscussions ()
1746- {
1747- return Boolean .parseBoolean (get ("allowMultipleDiscussions" ));
1748- }
17491683 }
17501684
1751-
17521685 public static class EmailOptionsForm extends ViewForm
17531686 {
17541687 private int _emailPreference = EmailOption .MESSAGES_NONE .getValue ();
@@ -2318,7 +2251,6 @@ public static class ThreadViewBean
23182251 public URLHelper currentURL ;
23192252 public boolean print = false ;
23202253 public boolean includeGroups ;
2321- public boolean embedded ;
23222254 }
23232255
23242256
@@ -2329,12 +2261,6 @@ private ThreadView()
23292261 super ("/org/labkey/announcements/announcementThread.jsp" , new ThreadViewBean ());
23302262 }
23312263
2332- public ThreadView (Container c , URLHelper currentURL , User user , String rowId , String entityId )
2333- {
2334- this ();
2335- init (c , findThread (c , rowId , entityId ), currentURL , getPermissions (c , user , getSettings (c )), false , false );
2336- }
2337-
23382264 public ThreadView (Container c , ActionURL url , AnnouncementModel ann , Permissions perm )
23392265 {
23402266 this ();
@@ -2370,9 +2296,8 @@ protected void init(Container c, AnnouncementModel ann, URLHelper currentURL, Pe
23702296 bean .printURL = null == currentURL ? null : currentURL .clone ().replaceParameter (ActionURL .Param ._print .name (), "1" );
23712297 bean .print = print ;
23722298 bean .includeGroups = perm .includeGroups ();
2373- bean .embedded = (null != ann .getDiscussionSrcURL () && !getViewContext ().getActionURL ().getController ().equalsIgnoreCase ("announcements" )); // TODO: Should have explicit flag for discussion case
23742299
2375- if (!bean .print && ! bean . embedded )
2300+ if (!bean .print )
23762301 {
23772302 NavTree buttons = new NavTree ();
23782303 if (null != bean .listURL )
0 commit comments