diff --git a/controllers/class.badgescontroller.php b/controllers/class.badgescontroller.php index 9389272..8012994 100644 --- a/controllers/class.badgescontroller.php +++ b/controllers/class.badgescontroller.php @@ -25,7 +25,7 @@ class BadgesController extends Gdn_Controller { $this->AddJsFile('global.js'); $this->AddCssFile('style.css'); $this->AddCssFile('badges.css'); - $this->AddModule('MyBadgesModule'); + $this->AddModule('BadgesModule'); } /** diff --git a/modules/class.badgesmodule.php b/modules/class.badgesmodule.php new file mode 100755 index 0000000..bd1e557 --- /dev/null +++ b/modules/class.badgesmodule.php @@ -0,0 +1,42 @@ +User->UserID; + } + else { + $UserID = Gdn::Session()->UserID; + } + $BadgeModel = new BadgeModel(); + $this->Data = $BadgeModel->GetUserBadgeAwards($UserID); + } + + public function AssetTarget() { + return 'Panel'; + } + + public function ToString() { + if($this->Data) { + if($this->Visible) { + $ViewPath = $this->FetchViewLocation('badges', 'yaga'); + $String = ''; + ob_start(); + include ($ViewPath); + $String = ob_get_contents(); + @ob_end_clean(); + return $String; + } + } + return ''; + } + +} \ No newline at end of file diff --git a/modules/class.mybadgesmodule.php b/modules/class.mybadgesmodule.php deleted file mode 100755 index 3082356..0000000 --- a/modules/class.mybadgesmodule.php +++ /dev/null @@ -1,34 +0,0 @@ -Data = FALSE; - if(Gdn::Session()->IsValid()) { - $UserID = Gdn::Session()->UserID; - $BadgeModel = new BadgeModel(); - - $Data = $BadgeModel->GetUserBadgeAwards($UserID); - $this->Data = $Data; - } - } - - public function AssetTarget() { - return 'Panel'; - } - - public function ToString() { - if($this->Data) - return parent::ToString(); - - return ''; - } - -} \ No newline at end of file diff --git a/settings/class.hooks.php b/settings/class.hooks.php index e501ee9..4b7e583 100755 --- a/settings/class.hooks.php +++ b/settings/class.hooks.php @@ -235,6 +235,12 @@ class YagaHooks implements Gdn_IPlugin { */ public function ProfileController_Render_Before($Sender) { $this->_AddResources($Sender); + +// $UserID = $Sender->User->UserID; +// $Module = new BadgesModule(); +// $Module->SetUser($UserID); + + $Sender->AddModule('BadgesModule'); } public function DiscussionController_Render_Before($Sender) { @@ -286,6 +292,7 @@ class YagaHooks implements Gdn_IPlugin { if(!C('Yaga.Badges.Enabled', FALSE)) { return; } + $Session = Gdn::Session(); if(!$Session->IsValid()) return; diff --git a/views/modules/mybadges.php b/views/modules/badges.php similarity index 100% rename from views/modules/mybadges.php rename to views/modules/badges.php