@@ -183,12 +183,7 @@ public function discussionsController_beforeDiscussionMetaData_handler($sender,
183
183
public function base_render_before ($ sender ) {
184
184
$ sender ->addJsFile ('vendors/prettify/prettify.js ' , 'plugins/Groups ' );
185
185
$ sender ->addJsFile ('dashboard.js ' , 'plugins/Groups ' );
186
-
187
- $ categoryModel = new CategoryModel ();
188
-
189
- self ::log ('a list of IDs of categories visible to the current user ' , ['visibleCategories ' => $ categoryModel ->getVisibleCategories ([])]);
190
-
191
- }
186
+ }
192
187
193
188
public function base_groupOptionsDropdown_handler ($ sender , $ args ){
194
189
$ group = $ args ['Group ' ];
@@ -534,6 +529,44 @@ public function categoryModel_hasWatched_create(CategoryModel $sender) {
534
529
}
535
530
return false ;
536
531
}
532
+
533
+ /**
534
+ * New discussion has been posted
535
+ * @param $sender
536
+ * @param $args
537
+ */
538
+ public function discussionModel_beforeNotification_handler ($ sender , $ args ) {
539
+ $ data = &$ args ['Activity ' ];
540
+ if (($ data ['ActivityType ' ] == 'Discussion ' && $ data ['RecordType ' ] == 'Discussion ' )) {
541
+ $ discussion = $ args ['Discussion ' ];
542
+ self ::log (' discussionModel_beforeNotification_handler ' , ['data ' => $ args ['Activity ' ],
543
+ 'category ' => array_values (CategoryModel::getAncestors ($ discussion ['CategoryID ' ]))]);
544
+ $ userModel = new UserModel ();
545
+ $ author = $ userModel ->getID ($ discussion ['InsertUserID ' ]);
546
+ $ category = CategoryModel::categories ($ discussion ['CategoryID ' ]);
547
+ $ categoryName = $ category ['Name ' ];
548
+ $ categoryBreadcrumbs = array_column (array_values (CategoryModel::getAncestors ($ discussion ['CategoryID ' ])), 'Name ' );
549
+ $ dateInserted = Gdn_Format::dateFull ($ discussion ['DateInserted ' ]);
550
+ $ data ["HeadlineFormat " ] = 'The new discussion has been posted in the category ' . $ categoryName . '. ' ;
551
+ // Format to Html
552
+ $ story = condense (Gdn_Format::to ($ discussion ['Body ' ], $ discussion ['Format ' ]));
553
+ $ message = $ story ; // htmlspecialchars(Gdn_Format::plainText($story, 'Html'));
554
+ // We just converted it to HTML. Make sure everything downstream knows it.
555
+ // Taking this HTML and feeding it into the Rich Format for example, would be invalid.
556
+ $ data ['Format ' ] = 'Html ' ;
557
+ $ data ["Story " ] =
558
+ 'You are watching the category ' . $ categoryName . ', ' .
559
+ 'which was updated ' . $ dateInserted . ' by ' . $ author ->Name . ':<br/> ' .
560
+ '<span>----------------------------------------------------------------------------</span> ' .
561
+ '<p> ' .
562
+ 'Discussion: ' . $ discussion ['Name ' ] . ' <br/> ' .
563
+ 'Author: ' . $ author ->Name . ' <br/> ' .
564
+ 'Category: ' . implode ('› ' , $ categoryBreadcrumbs ) . ' <br/> ' .
565
+ 'Message: <br/> ' . $ message .
566
+ '</p> ' .
567
+ '<span>----------------------------------------------------------------------------</span> ' ;
568
+ }
569
+ }
537
570
/**
538
571
* Add Topcoder Roles
539
572
* @param $sender
0 commit comments