@@ -535,11 +535,11 @@ public function categoryModel_hasWatched_create(CategoryModel $sender) {
535
535
* @param $sender
536
536
* @param $args
537
537
*/
538
- public function discussionModel_beforeNotification_handler ($ sender , $ args ) {
538
+ public function discussionModel_beforeRecordAdvancedNotification_handler ($ sender , $ args ) {
539
539
$ data = &$ args ['Activity ' ];
540
540
if (($ data ['ActivityType ' ] == 'Discussion ' && $ data ['RecordType ' ] == 'Discussion ' )) {
541
541
$ discussion = $ args ['Discussion ' ];
542
- self ::log (' discussionModel_beforeNotification_handler ' , ['data ' => $ args ['Activity ' ],
542
+ self ::log (' discussionModel_BeforeRecordAdvancedNotification_handler ' , ['data ' => $ args ['Activity ' ],
543
543
'category ' => array_values (CategoryModel::getAncestors ($ discussion ['CategoryID ' ]))]);
544
544
$ userModel = new UserModel ();
545
545
$ author = $ userModel ->getID ($ discussion ['InsertUserID ' ]);
@@ -555,18 +555,67 @@ public function discussionModel_beforeNotification_handler($sender, $args) {
555
555
// Taking this HTML and feeding it into the Rich Format for example, would be invalid.
556
556
$ data ['Format ' ] = 'Html ' ;
557
557
$ data ["Story " ] =
558
- 'You are watching the category ' . $ categoryName . ', ' .
559
- 'which was updated ' . $ dateInserted . ' by ' . $ author ->Name . ':<br /> ' .
558
+ '<p> You are watching the category " ' . $ categoryName . '" , ' .
559
+ 'which was updated ' . $ dateInserted . ' by ' . $ author ->Name . ':<p /> ' .
560
560
'<span>----------------------------------------------------------------------------</span> ' .
561
561
'<p> ' .
562
- ' Discussion: ' . $ discussion ['Name ' ] . ' <br/> ' .
563
- ' Author: ' . $ author ->Name . ' <br/> ' .
564
- ' Category: ' . implode ('› ' , $ categoryBreadcrumbs ) . ' <br/> ' .
565
- ' Message: <br/> ' . $ message .
562
+ ' <span> Discussion: ' . $ discussion ['Name ' ] . '</span> <br/> ' .
563
+ ' <span> Author: ' . $ author ->Name . '</span> <br/> ' .
564
+ ' <span> Category: ' . implode ('› ' , $ categoryBreadcrumbs ) . '</span> <br/> ' .
565
+ ' <span> Message:</span> <br/> ' . $ message .
566
566
'</p> ' .
567
567
'<span>----------------------------------------------------------------------------</span> ' ;
568
568
}
569
569
}
570
+
571
+ public function commentModel_beforeRecordAdvancedNotification ($ sender , $ args ){
572
+
573
+ $ data = &$ args ['Activity ' ];
574
+ if (($ data ['ActivityType ' ] == 'Comment ' && $ data ['RecordType ' ] == 'Comment ' )) {
575
+ $ discussion = $ args ['Discussion ' ];
576
+ $ comment = $ args ["Comment " ];
577
+ self ::log (' commentModel_beforeNotification_handler ' , ['data ' => $ args ['Activity ' ],
578
+ 'category ' => array_values (CategoryModel::getAncestors ($ discussion ['CategoryID ' ]))]);
579
+ $ userModel = new UserModel ();
580
+ $ discussionAuthor = $ userModel ->getID ($ discussion ['InsertUserID ' ]);
581
+ $ commentAuthor = $ userModel ->getID ($ comment ['InsertUserID ' ]);
582
+ $ category = CategoryModel::categories ($ discussion ['CategoryID ' ]);
583
+ $ discussionName = $ discussion ['Name ' ];
584
+ $ categoryName = $ category ['Name ' ];
585
+ $ categoryBreadcrumbs = array_column (array_values (CategoryModel::getAncestors ($ discussion ['CategoryID ' ])), 'Name ' );
586
+ $ discussionDateInserted = Gdn_Format::dateFull ($ discussion ['DateInserted ' ]);
587
+ $ commentDateInserted = Gdn_Format::dateFull ($ comment ['DateInserted ' ]);
588
+ // $data["HeadlineFormat"] = 'The new discussion has been posted in the category ' . $categoryName . '.';
589
+ // Format to Html
590
+ $ discussionStory = condense (Gdn_Format::to ($ discussion ['Body ' ], $ discussion ['Format ' ]));
591
+ $ commentStory = condense (Gdn_Format::to ($ comment ['Body ' ], $ comment ['Format ' ]));
592
+ // We just converted it to HTML. Make sure everything downstream knows it.
593
+ // Taking this HTML and feeding it into the Rich Format for example, would be invalid.
594
+ $ data ['Format ' ] = 'Html ' ;
595
+ $ data ["Story " ] =
596
+ '<p>You are watching the discussion " ' . $ discussionName . '" in the category " ' .$ categoryName .'" ' .
597
+ 'which was updated ' . $ commentDateInserted . ' by ' . $ commentAuthor ->Name . ':</p> ' .
598
+ '<span>----------------------------------------------------------------------------</span> ' .
599
+ '<p>Message: </p> ' .
600
+ '<p> ' .
601
+ $ commentStory .
602
+ '</p> ' .
603
+ '<span>----------------------------------------------------------------------------</span> ' ;
604
+ $ parentCommentID = (int )$ comment ['ParentCommentID ' ];
605
+ if ($ parentCommentID > 0 ) {
606
+ $ commentModel = new CommentModel ();
607
+ $ parentComment = $ commentModel ->getID ($ parentCommentID , DATASET_TYPE_ARRAY );
608
+ $ parentCommentAuthor = $ userModel ->getID ($ comment ['InsertUserID ' ]);
609
+ $ parentCommentStory = condense (Gdn_Format::to ($ parentComment ['Body ' ], $ parentComment ['Format ' ]));
610
+ $ data ['Story ' ] .=
611
+ '<p>Original Message (by ' .$ parentCommentAuthor ->Name .' ):</p> ' .
612
+ '<p> ' .
613
+ $ parentCommentStory .
614
+ '</p> ' .
615
+ '<span>----------------------------------------------------------------------------</span> ' ;
616
+ }
617
+ }
618
+ }
570
619
/**
571
620
* Add Topcoder Roles
572
621
* @param $sender
0 commit comments