diff --git a/controllers/class.configurecontroller.php b/controllers/class.configurecontroller.php index 18f7b00..3f2b4ae 100644 --- a/controllers/class.configurecontroller.php +++ b/controllers/class.configurecontroller.php @@ -50,7 +50,9 @@ class ConfigureController extends DashboardController { $ConfigModule->Initialize(array( 'Yaga.Reactions.Enabled' => array('LabelCode' => 'Use Reactions', 'Control' => 'Checkbox'), 'Yaga.Badges.Enabled' => array('LabelCode' => 'Use Badges', 'Control' => 'Checkbox'), - 'Yaga.Ranks.Enabled' => array('LabelCode' => 'Use Ranks', 'Control' => 'Checkbox') + 'Yaga.Ranks.Enabled' => array('LabelCode' => 'Use Ranks', 'Control' => 'Checkbox'), + 'Yaga.LeaderBoard.Enabled' => array('LabelCode' => 'Show leaderboard on activity page', 'Control' => 'Checkbox'), + 'Yaga.LeaderBoard.Limit' => array('LabelCode' => 'Maximum number of leaders to show', 'Control' => 'Textbox', 'Options' => array('Size' => 45, 'class' => 'SmallInput')) )); $this->AddSideMenu('configure'); $this->SetData('Title', 'Gamification Settings'); diff --git a/modules/class.leaderboardmodule.php b/modules/class.leaderboardmodule.php index 331280a..00d5ac6 100755 --- a/modules/class.leaderboardmodule.php +++ b/modules/class.leaderboardmodule.php @@ -25,7 +25,7 @@ class LeaderBoardModule extends Gdn_Module { ->Where('up.TimeSlot', gmdate('Y-m-d', Gdn_Statistics::TimeSlotStamp($SlotType))) ->Where('up.Source', 'Total') ->OrderBy('up.Points', 'desc') - ->Limit(10, 0) + ->Limit(C('Yaga.LeaderBoard.Limit', 10), 0) ->Get() ->Result(); diff --git a/settings/class.hooks.php b/settings/class.hooks.php index a3faf88..74fafcf 100755 --- a/settings/class.hooks.php +++ b/settings/class.hooks.php @@ -7,8 +7,6 @@ */ class YagaHooks implements Gdn_IPlugin { - static $_ReactionModel = NULL; - /** * Add the settings page links * @@ -48,11 +46,12 @@ class YagaHooks implements Gdn_IPlugin { echo Wrap(T('Yaga.Reactions', 'Reactions'), 'h2', array('class' => 'H')); // insert the reaction totals in the profile - $Actions = $this->_ReactionModel->GetActions(); + $ReactionModel = Yaga::ReactionModel(); + $Actions = $ReactionModel->GetActions(); $String = ''; foreach($Actions as $Action) { $Selected = ($ActionID == $Action->ActionID) ? ' Selected' : ''; - $Count = $this->_ReactionModel->GetUserReactionCount($User->UserID, $Action->ActionID); + $Count = $ReactionModel->GetUserReactionCount($User->UserID, $Action->ActionID); $TempString = Wrap(Wrap(Gdn_Format::BigNumber($Count), 'span', array('title' => $Count)), 'span', array('class' => 'Yaga_ReactionCount CountTotal')); $TempString .= Wrap($Action->Name, 'span', array('class' => 'Yaga_ReactionName CountLabel')); @@ -70,13 +69,14 @@ class YagaHooks implements Gdn_IPlugin { public function UserInfoModule_OnBasicInfo_Handler($Sender) { $UserID = $Sender->User->UserID; $BadgeCount = Yaga::BadgeModel()->GetUserBadgeAwardCount($UserID); - echo '
Badges
'; + echo '
'. T('Yaga.Badges', 'Badges') .'
'; echo '
' . $BadgeCount . '
'; } /** * @todo document * @todo Add a pager + * @todo call the best of controller to take this on * @param type $Sender * @param type $UserReference * @param type $Username @@ -325,13 +325,22 @@ class YagaHooks implements Gdn_IPlugin { * @param object $Sender */ public function ProfileController_BeforeProfileOptions_Handler($Sender) { - if(Gdn::Session()->IsValid() && CheckPermission('Yaga.Badges.Add')) { - //decho($Sender->EventArguments); - $Sender->EventArguments['ProfileOptions'][] = array( - 'Text' => Sprite('SpModeratorActivities') . ' ' . T('Give Badge'), - 'Url' => '/badge/award/' . $Sender->User->UserID, - 'CssClass' => 'Popup' - ); + if(Gdn::Session()->IsValid()) { + if(CheckPermission('Yaga.Badges.Add')) { + $Sender->EventArguments['ProfileOptions'][] = array( + 'Text' => Sprite('SpRibbon') . ' ' . T('Give Badge'), + 'Url' => '/badge/award/' . $Sender->User->UserID, + 'CssClass' => 'Popup' + ); + } + + if(CheckPermission('Yaga.Ranks.Add')) { + $Sender->EventArguments['ProfileOptions'][] = array( + 'Text' => Sprite('SpModeratorActivities') . ' ' . T('Promote'), + 'Url' => '/rank/promote/' . $Sender->User->UserID, + 'CssClass' => 'Popup' + ); + } } } @@ -458,12 +467,14 @@ class YagaHooks implements Gdn_IPlugin { public function ActivityController_Render_Before($Sender) { $this->_AddResources($Sender); - // add leaderboard modules to the activity page - $Module = new LeaderBoardModule(); - $Module->GetData('w'); - $Sender->AddModule($Module); - $Module = new LeaderBoardModule(); - $Sender->AddModule($Module); + if(C('Yaga.LeaderBoard.Enabled', FALSE)) { + // add leaderboard modules to the activity page + $Module = new LeaderBoardModule(); + $Module->GetData('w'); + $Sender->AddModule($Module); + $Module = new LeaderBoardModule(); + $Sender->AddModule($Module); + } } /** @@ -565,10 +576,6 @@ class YagaHooks implements Gdn_IPlugin { * @param object $Sender */ private function _AddResources($Sender) { - if(empty($this->_ReactionModel)) { - $this->_ReactionModel = new ReactionModel(); - } - $Sender->AddCssFile('reactions.css', 'yaga'); }