Forgot to save all :(, more badge model refactoring
This commit is contained in:
parent
44256fe261
commit
51b8dadb9f
@ -263,14 +263,14 @@ class BadgeController extends DashboardController {
|
||||
$Validation->ApplyRule('BadgeID', 'ValidateRequired');
|
||||
if($Validation->Validate($this->Request->Post())) {
|
||||
$FormValues = $this->Form->FormValues();
|
||||
if($this->BadgeModel->UserHasBadge($FormValues['UserID'], $FormValues['BadgeID'])) {
|
||||
if($this->BadgeAwardModel->Exists($FormValues['UserID'], $FormValues['BadgeID'])) {
|
||||
$this->Form->AddError(sprintf(T('Yaga.BadgeAlreadyAwarded'), $User->Name), 'BadgeID');
|
||||
// Need to respecify the user id
|
||||
$this->Form->AddHidden('UserID', $User->UserID);
|
||||
}
|
||||
|
||||
if($this->Form->ErrorCount() == 0) {
|
||||
$this->BadgeModel->AwardBadge($FormValues['BadgeID'], $FormValues['UserID'], Gdn::Session()->UserID, $FormValues['Reason']);
|
||||
$this->BadgeAwardModel->Award($FormValues['BadgeID'], $FormValues['UserID'], Gdn::Session()->UserID, $FormValues['Reason']);
|
||||
|
||||
if($this->Request->Get('Target')) {
|
||||
$this->RedirectUrl = $this->Request->Get('Target');
|
||||
|
@ -13,7 +13,7 @@ class BadgesController extends Gdn_Controller {
|
||||
* @var array These objects will be created on instantiation and available via
|
||||
* $this->ObjectName
|
||||
*/
|
||||
public $Uses = array('BadgeModel');
|
||||
public $Uses = array('BadgeModel', 'BadgeAwardModel');
|
||||
|
||||
public function Initialize() {
|
||||
parent::Initialize();
|
||||
@ -49,7 +49,7 @@ class BadgesController extends Gdn_Controller {
|
||||
|
||||
$UserID = Gdn::Session()->UserID;
|
||||
// Get list of badges from the model and pass to the view
|
||||
$this->SetData('Badges', $this->BadgeModel->GetAllBadgesUserAwards($UserID));
|
||||
$this->SetData('Badges', $this->BadgeAwardModel->GetEarnedJoinAll($UserID));
|
||||
|
||||
$this->Render('all');
|
||||
}
|
||||
@ -62,10 +62,10 @@ class BadgesController extends Gdn_Controller {
|
||||
*/
|
||||
public function Detail($BadgeID, $Slug = NULL) {
|
||||
$UserID = Gdn::Session()->UserID;
|
||||
$Badge = $this->BadgeModel->GetBadge($BadgeID);
|
||||
$AwardCount = $this->BadgeModel->GetBadgeAwardCount($BadgeID);
|
||||
$UserBadgeAward = $this->BadgeModel->GetUserBadgeAward($UserID, $BadgeID);
|
||||
$RecentAwards = $this->BadgeModel->GetRecentBadgeAwards($BadgeID);
|
||||
$Badge = $this->BadgeModel->GetByID($BadgeID);
|
||||
$AwardCount = $this->BadgeAwardModel->GetCount($BadgeID);
|
||||
$UserBadgeAward = $this->BadgeAwardModel->Exists($UserID, $BadgeID);
|
||||
$RecentAwards = $this->BadgeAwardModel->GetRecent($BadgeID);
|
||||
|
||||
if(!$Badge) {
|
||||
throw NotFoundException('Badge');
|
||||
|
@ -25,8 +25,8 @@ class BadgesModule extends Gdn_Module {
|
||||
$this->Title = T('Yaga.Badges');
|
||||
}
|
||||
|
||||
$BadgeModel = Yaga::BadgeModel();
|
||||
$this->Data = $BadgeModel->GetUserBadgeAwards($UserID);
|
||||
$BadgeAwardModel = Yaga::BadgeAwardModel();
|
||||
$this->Data = $BadgeAwardModel->GetByUser($UserID);
|
||||
}
|
||||
|
||||
public function AssetTarget() {
|
||||
|
@ -10,14 +10,14 @@ Yet Another Gamification Application
|
||||
* ~~Finish inline ToDos~~
|
||||
* ~~Move badge count to user table column~~
|
||||
* ~~Translate every static string~~
|
||||
* Create a badgeaward model
|
||||
* ~~Create a badgeaward model~~
|
||||
* Fix all badges page query to be right
|
||||
* Fix reaction method on profile page to show more than one page of discussion/comments
|
||||
** Also show the reaction record
|
||||
** Also refactor that method, really messy right now
|
||||
* Rule tooltip help
|
||||
* Rework badge settings page to streamline badges of the same rule type
|
||||
* Create/find reusable badge images
|
||||
* Fix all badges page query to be right
|
||||
* Mention who gave you the badge on the badge detail page
|
||||
* Refactor reaction CSS
|
||||
* Refactor all models to get rid of uneeded/duplicate methods
|
||||
|
@ -602,8 +602,8 @@ class YagaHooks implements Gdn_IPlugin {
|
||||
$UserModel = new UserModel();
|
||||
$User = $UserModel->GetID($UserID);
|
||||
|
||||
$BadgeModel = Yaga::BadgeModel();
|
||||
$Badges = $BadgeModel->GetAllBadgesUserAwards($UserID);
|
||||
$BadgeAwardModel = Yaga::BadgeAwardModel();
|
||||
$Badges = $BadgeAwardModel->GetUnearned($UserID);
|
||||
|
||||
$Rules = array();
|
||||
foreach($Badges as $Badge) {
|
||||
@ -629,7 +629,7 @@ class YagaHooks implements Gdn_IPlugin {
|
||||
else {
|
||||
$AwardedUserID = $UserID;
|
||||
}
|
||||
$BadgeModel->AwardBadge($Badge->BadgeID, $AwardedUserID, $UserID);
|
||||
$BadgeAwardModel->Award($Badge->BadgeID, $AwardedUserID, $UserID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user