2013-11-13 11:08:51 -06:00
|
|
|
<?php if(!defined('APPLICATION')) exit();
|
|
|
|
/* Copyright 2013 Zachary Doll */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a users badges in a nice grid in the panel
|
|
|
|
*/
|
|
|
|
class BadgesModule extends Gdn_Module {
|
|
|
|
|
|
|
|
public function __construct($Sender = '') {
|
|
|
|
parent::__construct($Sender);
|
|
|
|
|
|
|
|
// default to the user object on the controller/the currently logged in user
|
2013-11-13 16:17:08 -06:00
|
|
|
if(property_exists($Sender, 'User')
|
|
|
|
&& $Sender->User) {
|
2013-11-13 11:08:51 -06:00
|
|
|
$UserID = $Sender->User->UserID;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$UserID = Gdn::Session()->UserID;
|
|
|
|
}
|
2013-11-13 11:14:53 -06:00
|
|
|
|
|
|
|
if(Gdn::Session()->UserID == $UserID) {
|
|
|
|
$this->Title = 'My Badges';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->Title = 'Badges';
|
|
|
|
}
|
|
|
|
|
2013-11-13 11:08:51 -06:00
|
|
|
$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 '';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|