Skip to content

Commit 3e57c35

Browse files
authored
Merge pull request #85 from topcoder-platform/issues-577
Issues-577: Watching feature
2 parents a588bad + fb14169 commit 3e57c35

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

class.groups.plugin.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,43 @@ public function categoryModel_hasWatched_create(CategoryModel $sender) {
601601
return false;
602602
}
603603

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+
604641
//
605642
// EMAIL TEMPLATES
606643
//

0 commit comments

Comments
 (0)