@@ -2066,6 +2066,62 @@ public static function log($message, $data = []) {
2066
2066
);
2067
2067
}
2068
2068
}
2069
+
2070
+ // MAGIC EVENTS TO OVERRIDE VANILLA CONTROLLER METHODS
2071
+
2072
+ /**
2073
+ * Allows user to announce or unannounce a discussion.
2074
+ * FIX: https://github.com/topcoder-platform/forums/issues/456
2075
+ * @param int $discussionID Unique discussion ID.
2076
+ * @param string $TransientKey Single-use hash to prove intent.
2077
+ */
2078
+ public function discussionController_announce_create ($ sender , $ discussionID = '' , $ announce =true ,$ target = '' ) {
2079
+ // Make sure we are posting back.
2080
+ if (!$ sender ->Request ->isAuthenticatedPostBack ()) {
2081
+ throw permissionException ('Javascript ' );
2082
+ }
2083
+
2084
+ $ discussion = $ sender ->DiscussionModel ->getID ($ discussionID );
2085
+ if (!$ discussion ) {
2086
+ throw notFoundException ('Discussion ' );
2087
+ }
2088
+
2089
+ //$sender->categoryPermission($discussion->CategoryID, 'Vanilla.Discussions.Announce');// protected
2090
+ if (!CategoryModel::checkPermission ($ discussion ->CategoryID , 'Vanilla.Discussions.Announce ' )) {
2091
+ $ sender ->permission ('Vanilla.Discussions.Announce ' , true , 'Category ' , $ discussion ->CategoryID );
2092
+ }
2093
+
2094
+ // Save the property.
2095
+ // 0 - Don't Announce Discussion
2096
+ // 2 - Announce Discussion in the current category
2097
+ $ newAnnounceValue = (bool )$ announce ? 2 : 0 ;
2098
+ $ sender ->DiscussionModel ->setField ($ discussionID , 'Announce ' , $ newAnnounceValue );
2099
+ $ discussion ->Announce = $ newAnnounceValue ;
2100
+
2101
+ // Redirect to the front page
2102
+ if ($ sender ->_DeliveryType === DELIVERY_TYPE_ALL ) {
2103
+ $ target = getIncomingValue ('Target ' , 'discussions ' );
2104
+ redirectTo ($ target );
2105
+ }
2106
+
2107
+ $ sender ->sendOptions ($ discussion );
2108
+ if ($ newAnnounceValue == 2 ) {
2109
+ require_once $ sender ->fetchViewLocation ('helper_functions ' , 'Discussions ' , 'vanilla ' );
2110
+ $ dataHtml = tag ($ discussion , 'Announce ' , 'Announcement ' );
2111
+ // Remove if exists
2112
+ $ sender ->jsonTarget (".Section-DiscussionList #Discussion_ $ discussionID .Meta-Discussion " , $ dataHtml , 'Prepend ' );
2113
+ $ sender ->jsonTarget (".Section-DiscussionList #Discussion_ $ discussionID " , 'Announcement ' , 'AddClass ' );
2114
+ } else {
2115
+ $ sender ->jsonTarget (".Section-DiscussionList #Discussion_ $ discussionID .Tag-Announcement " , null , 'Remove ' );
2116
+ $ sender ->jsonTarget (".Section-DiscussionList #Discussion_ $ discussionID " , 'Announcement ' , 'RemoveClass ' );
2117
+
2118
+ }
2119
+
2120
+ $ sender ->jsonTarget ("#Discussion_ $ discussionID " , null , 'Highlight ' );
2121
+ $ sender ->jsonTarget (".Discussion #Item_0 " , null , 'Highlight ' );
2122
+
2123
+ $ sender ->render ('Blank ' , 'Utility ' , 'Dashboard ' );
2124
+ }
2069
2125
}
2070
2126
2071
2127
if (!function_exists ('topcoderRatingCssClass ' )) {
0 commit comments