@@ -601,6 +601,43 @@ public function categoryModel_hasWatched_create(CategoryModel $sender) {
601
601
return false ;
602
602
}
603
603
604
+ /**
605
+ * Get user notification preferences
606
+ *
607
+ * @param $userID
608
+ * @param $categoryIDs array|int
609
+ * @return array The list of categories with all preference keys.
610
+ */
611
+ public function categoryModel_getCategoryNotificationPreferences_create (CategoryModel $ sender ) {
612
+ $ categoryIDs = val (0 , $ sender ->EventArguments );
613
+ $ userID = val (1 , $ sender ->EventArguments );
614
+
615
+ if (is_numeric ($ categoryIDs ) ) {
616
+ $ categoryIDs = [$ categoryIDs ];
617
+ }
618
+ $ result = [];
619
+ $ userMetaModel = new UserMetaModel ();
620
+ foreach ($ categoryIDs as $ categoryID ) {
621
+ // need to cast to int, by default all values are strings
622
+ $ newEmailDiscussionKey = 'Preferences.Email.NewDiscussion. ' . $ categoryID ;
623
+ $ newEmailDiscussionValue = $ userMetaModel ->getUserMeta ($ userID , $ newEmailDiscussionKey , null );
624
+ $ result [$ categoryID ][$ newEmailDiscussionKey ] = $ newEmailDiscussionValue [$ newEmailDiscussionKey ];
625
+
626
+ $ newEmailCommentKey = 'Preferences.Email.NewComment. ' . $ categoryID ;
627
+ $ newEmailCommentValue = $ userMetaModel ->getUserMeta ($ userID , $ newEmailCommentKey , null );
628
+ $ result [$ categoryID ][$ newEmailCommentKey ] = $ newEmailCommentValue [$ newEmailCommentKey ];
629
+
630
+ $ newPopupDiscussionKey = 'Preferences.Popup.NewDiscussion. ' . $ categoryID ;
631
+ $ newPopupDiscussionValue = $ userMetaModel ->getUserMeta ($ userID , $ newPopupDiscussionKey , null );
632
+ $ result [$ categoryID ][$ newPopupDiscussionKey ] = $ newPopupDiscussionValue [$ newPopupDiscussionKey ];
633
+
634
+ $ newPopupCommentKey = 'Preferences.Popup.NewComment. ' . $ categoryID ;
635
+ $ newPopupCommentValue = $ userMetaModel ->getUserMeta ($ userID , $ newPopupCommentKey , null );
636
+ $ result [$ categoryID ][$ newPopupCommentKey ] = $ newPopupCommentValue [$ newPopupCommentKey ];
637
+ }
638
+ return $ result ;
639
+ }
640
+
604
641
//
605
642
// EMAIL TEMPLATES
606
643
//
0 commit comments