Skip to content

Issues-577: Watching feature #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions class.groups.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,43 @@ public function categoryModel_hasWatched_create(CategoryModel $sender) {
return false;
}

/**
* Get user notification preferences
*
* @param $userID
* @param $categoryIDs array|int
* @return array The list of categories with all preference keys.
*/
public function categoryModel_getCategoryNotificationPreferences_create(CategoryModel $sender) {
$categoryIDs = val(0, $sender->EventArguments);
$userID = val(1, $sender->EventArguments);

if(is_numeric($categoryIDs) ) {
$categoryIDs = [$categoryIDs];
}
$result = [];
$userMetaModel = new UserMetaModel();
foreach ($categoryIDs as $categoryID) {
// need to cast to int, by default all values are strings
$newEmailDiscussionKey = 'Preferences.Email.NewDiscussion.' . $categoryID;
$newEmailDiscussionValue = $userMetaModel->getUserMeta($userID, $newEmailDiscussionKey, null);
$result[$categoryID][$newEmailDiscussionKey] = $newEmailDiscussionValue[$newEmailDiscussionKey];

$newEmailCommentKey = 'Preferences.Email.NewComment.' . $categoryID;
$newEmailCommentValue = $userMetaModel->getUserMeta($userID, $newEmailCommentKey, null);
$result[$categoryID][$newEmailCommentKey] = $newEmailCommentValue[$newEmailCommentKey];

$newPopupDiscussionKey = 'Preferences.Popup.NewDiscussion.' . $categoryID;
$newPopupDiscussionValue = $userMetaModel->getUserMeta($userID, $newPopupDiscussionKey, null);
$result[$categoryID][$newPopupDiscussionKey] = $newPopupDiscussionValue[$newPopupDiscussionKey];

$newPopupCommentKey = 'Preferences.Popup.NewComment.' . $categoryID;
$newPopupCommentValue = $userMetaModel->getUserMeta($userID, $newPopupCommentKey, null);
$result[$categoryID][$newPopupCommentKey] = $newPopupCommentValue[$newPopupCommentKey];
}
return $result;
}

//
// EMAIL TEMPLATES
//
Expand Down