This repository was archived by the owner on Oct 13, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
Automatically remove badges based on criteria #24
Copy link
Copy link
Open
Labels
CRONRelated to CRON jobsRelated to CRON jobsUI:ACPRelated to UI (Admin)Related to UI (Admin)XF 2.2.xXenForo Version 2.2.xXenForo Version 2.2.xbugSomething isn't workingSomething isn't working
Description
Badges currently only award badges, it is up to the administrator/moderators to remove any badges that have been assigned.
Suggested Solution: Add a "automatic removal" option to badges which will trigger a cron process that will validate the criteria (and either remove or assign). Option should ONLY be toggleable on a per-badge basis.
Related Code:
Lines 40 to 60 in 1e9605e
| foreach ($users as $user) { | |
| /** @var UserBadge $userBadgeRepo */ | |
| $userBadgeRepo = XF::repository(C::__('UserBadge')); | |
| $awardedIds = $userBadgeRepo->getAwardedBadgeIds($user->user_id); | |
| /** @var \CMTV\Badges\Entity\Badge $badge */ | |
| foreach ($badges as $badge) { | |
| if (in_array($badge->badge_id, $awardedIds)) { | |
| continue; | |
| } | |
| $userCriteria = XF::app()->criteria('XF:User', $badge->user_criteria); | |
| $userCriteria->setMatchOnEmpty(false); | |
| if ($userCriteria->isMatched($user)) { | |
| $userBadgeRepo->awardWithBadge($user, $badge->badge_id); | |
| } | |
| } | |
| } | |
| } |
Additional Requirements: ACP:UI option to allow toggle.
Reported by Bulbagarden on XenForo Community Post 42
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
CRONRelated to CRON jobsRelated to CRON jobsUI:ACPRelated to UI (Admin)Related to UI (Admin)XF 2.2.xXenForo Version 2.2.xXenForo Version 2.2.xbugSomething isn't workingSomething isn't working