plainblack.com
Username Password
search
Bookmark and Share

Karma Macro

Now you too can have a nifty karma display on your website, just like on PlainBlack's.  Simple unzip the file in your WebGUI root directory (typically /data/WebGUI), enable the macro in your WebGUI.conf file and restart your server.

This macro has it all

  • Displays amount of karma that a user has.
  • Built-in help file
  • Internationalized text display (currently only translated for English)
  • Light weight templating so that the karma display can be customized.
  • Test suite
 

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
Comments
0bartjol: "I altered it slightly, so you can/must also give a parameter userId, so you can also dislpay karma in posts or profiles. Mind that for using the last parameter (userId) the alternate text should be purposely left empty or filled in:


package WebGUI::Macro::KarmaUser;

=head1 DESCRIPTION

Macro for displaying the amount of karma the current user has

=head2 process

=head3 text

The text to be displayed to the user.  The text will be processed by
sprintf, using %d to represent the integer karma.

=cut

use WebGUI::User;

#-------------------------------------------------------------------
sub process {
       my $session = shift;
       my $text = shift;
       my $userId = shift || $session->user->userId;
       my $user = WebGUI::User->new($session,$userId);
my $i18n = WebGUI::International->new($session, 'Macro_Karma');
       $text = $text || $i18n->get('karma message');
       return sprintf($text, $user->karma);
}

1;
"
Downloadkarma_macro.zip karma_macro.zip
LinksNo Support Offered
Statistics Downloads: 458
Views: 4232
Rating: 0
Updated: 11/9/2006
Keywords macros
NavigationBack to the Bazaar
© 2018 Plain Black Corporation | All Rights Reserved