Buy Me A Beer v1.4

Started by karlbenson, July 16, 2007, 01:04:43 PM

Previous topic - Next topic

karlbenson


Compatibility
For SMF 1.1.x versions only

Introduction
Allows users to reward other users for their posts by buying them a beer (or at least donating enough money via Paypal to buy one).

Where the user has entered their paypal address, A 'beer glass' icon appear in the poster information area of users posts.  The alt text when hovering over the icon states 'Buy Me A Beer Through Paypal' [must be logged in to see] and when clicked takes the user to the paypal page.

Features
o Adds a paypal donation field to each users profile
o Adds a clickable beer icon to take user to donation page.
o Supports Languages
- English/English-utf8
- English_British/English_British-utf8
I welcome translations for other languages. Please post the translated language strings in the Support Topic.

Installation
Simply install the package to install on the SMF Default Core Theme ONLY.
All other themes will require manual edits for Profile.template.php and Display.template.php
AND you will need to place a copy of the image buymeabeer.gif in the image folder of each of your themes (Themes/{themename}/images/)

Open Themes/{themename}/Profile.template.php, and FIND:

// All the messenger type contact info.

ADD BEFORE:

// Paypal Address For 'Buy Me A Beer Mod
echo ' <tr>
<td width="40%"><b>', $txt['buymeabeer'], ': </b><div class="smalltext">', $txt['buymeabeer_desc'], '</div></td>
<td><input type="text" name="buymeabeer" size="24" value="', $context['member']['buymeabeer']['name'], '" /></td>
</tr><tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
';


Open Themes/{themename}/Display.template.php, and FIND:

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])

ADD BEFORE:

// SHOW BUY ME A BEER
if (!$message['member']['is_guest'] && $context['user']['is_logged'] && !empty($message['member']['buymeabeer']))
{
$priceofbeer = 5 ; // In US Dollars no cents
echo'<br/>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=' , htmlentities ($message['member']['buymeabeer'], ENT_NOQUOTES, "UTF-8") , '&item_name=' , htmlentities ($txt['pleasebuymeabeer'], ENT_NOQUOTES, "UTF-8") , '&amount=', $priceofbeer ,'%2e00&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8" rel="nofollow" title="', $txt['buymeabeeralt'] ,'"><img alt="', $txt['buymeabeeralt'] ,'" border="0" src="', $settings['images_url'] , '/buymeabeer.gif" border="0"/></a><br/>';
}


If your theme has its own versions of the language files Modifications.english.php and/or Modifications.english-utf8.php, OR if your using a language other than those supported (listed above) by the mod then you will need to copy the language strings into each custom version of those files.
$txt['pleasebuymeabeer'] = 'Buy Me A Beer';
$txt['buymeabeeralt'] = 'Buy Me A Beer Through Paypal';
$txt['buymeabeer'] = 'PayPal Address For Users To Buy You A Beer';
$txt['profile_error_bad_paypal'] = 'The PayPal Address you entered was not a valid email address';
$txt['profile_error_paypal_taken'] = 'The PayPal Address you entered is already in use by another member';
$txt['buymeabeer_desc'] = 'Allows users to reward you for your posts';


Useful Links
SMF Package Parser
Manual Installation Of Mods
How Do I Modify Files?

Customization
$5 for a beer?  Seems reasonable, but if you want to change it you can do so easily by editing the Display.template.php and FIND the line below and REPLACE the 5 with another digit (must be a whole number, no decimals).
$priceofbeer = 5 ; // In US Dollars no cents

Donate
Has this modification helped you? Support the developer by Donating

Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
v1.0
o Initial release made per SMF user request.
v1.1
o Ensured it removes the buymeabeer.gif image on uninstall (as per SMF Modification Guidelines)
o Wrote out the manual edits
o Improved the readme/documentation for this mod
v1.2
o Fixed install bug where had previous install
v1.3
o Fixed install bug, not installing column
o Added english-utf8 support.
v1.4 - 25th December
o Added english_british/english_british-utf8 support.

sturmkatze

My problem is that when settingup your profile, the field doesn't say "Paypal" it just has a colon : and that's IT. Also, there is no mouse-over text on the graphic. :-( I love the idea of this mod. How can I fix it?

karlbenson

What language file are you using?

Are you using english UTF-8?

Copy the language strings from modifications.english.php in the language directory to modifications.englishutf8.php

RAV TUX

#3
Quote from: karlbenson on July 16, 2007, 01:04:43 PM
Link to Mod



BUY ME A BEER v1.1
By Karl Benson


Link to Mod | Comment On This Mod

Introduction
Allows users to reward other users for their posts by buying them a beer (or at least donating enough money via Paypal to buy one).

Warning!
This mod is an initial release. Please report any bugs you find, no matter how trivial.
Remember to backup your database AND files before installing any modifications, especially initial releases and betas

Installation
Simply install the package to install this modification on the Default theme.

Manual edits will be required for themes which have a custom profile (1x edit) and/or custom display template (1x edit)
AND you will need to place a copy of the image buymeabeer.gif in the image folder of each of your themes (Themes/{themename}/images/)

Open Themes/{themename}/Profile.template.php, and FIND:

// All the messenger type contact info.

ADD BEFORE:

// Paypal Address For 'Buy Me A Beer Mod
echo ' <tr>
<td width="40%"><b>', $txt['buymeabeer'], ': </b><div class="smalltext">', $txt['buymeabeer_desc'], '</div></td>
<td><input type="text" name="buymeabeer" size="24" value="', $context['member']['buymeabeer']['name'], '" /></td>
</tr><tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
';


Open Themes/{themename}/Display.template.php, and FIND:

// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])

ADD BEFORE:

// SHOW BUY ME A BEER
if (!$message['member']['is_guest'] && $context['user']['is_logged'] && !empty($message['member']['buymeabeer']))
{
$priceofbeer = 5 ; // In US Dollars no cents
echo'<br/>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=' , htmlentities ($message['member']['buymeabeer'], ENT_NOQUOTES, "UTF-8") , '&item_name=' , htmlentities ($txt['pleasebuymeabeer'], ENT_NOQUOTES, "UTF-8") , '&amount=', $priceofbeer ,'%2e00&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8" rel="nofollow" title="', $txt['buymeabeeralt'] ,'"><img alt="', $txt['buymeabeeralt'] ,'" border="0" src="', $settings['images_url'] , '/buymeabeer.gif" border="0"/></a><br/>';
}


If you are still having trouble, I recommend the Modification Parser/ [nofollow] by Daniel 15

How Do I Use This Mod?
An additional option is added to the users profile to enter their paypal address.
Where the user has entered their paypal address, a 'beer glass' icon appear in the poster information area of users posts.  The alt text when hovering over the icon states 'Buy Me A Beer Through Paypal' [must be logged in to see] and when clicked takes the user to the paypal page.

Screenshots
On the profile area

In the poster information area of posts


Customisation
$5 for a beer?  Seems reasonable, but if you want to change it you can do so easily by editing the Display.template.php and FIND the line below and REPLACE the 5 with another digit (must be a whole number, no decimals).

$priceofbeer = 5 ; // In US Dollars no cents


Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0 BETA
o Initial release made per SMF user request.
1.1
o Ensured it removes the buymeabeer.gif image on uninstall (as per SMF Modification Guidelines)
o Wrote out the manual edits
o Improved the readme/documentation for this mod

Awesome Mod. works like a dream without fail!

Check out this mod in action at The CafeLinux.org [nofollow] Forum:
http://cafelinux.org/forum/index.php [nofollow]

My user name is ravtux....while there feel free to "Buy me a Beer"  ;D

(joking of course, overall nice mod. I am not sure if it works yet, I tried buying myself a beer but PayPal wouldn't let me)

brianjw

The staff at TinyPortal Admin Resources would like to know if we can add your module to the download section of our forum.

Please let us know.
Thanks.

karlbenson

As long as you BUY ME A BEER. (joking)

You are welcome to add ANY of my mods.  I would myself, but theres not enough time in the day. ;)

In the last week I've uploaded new versions of all my mods (except one - the AdRevenueSharing Mod - I'm 60% through a major re-write of that one.) [so all of mine will work for the current version of smf.]

judithshakes

Getting lots of great feedback from members for this one! Thanks so much!

karlbenson

I'll glad someone is making use of this mod ;)

Robert.Moss

Hi karlbenson,

nice mod you have made, many thanks  :D

Is it possible to restrict the function only to special groups or members?

Robert

karlbenson

Its isnt possible with the current version.

BogeyOne

I am getting this when I try to apply this mod:

Type     Action     Description
1.    Execute Modification    ./Sources/Load.php    Test successful
2.    Execute Modification    ./Sources/Profile.php    Test successful
3.    Execute Modification    ./Themes/default/Profile.template.php    Test successful
4.    Execute Modification    ./Themes/default/Display.template.php    Test failed
5.    Execute Modification    ./Themes/default/languages/Modifications.english.php    Test successful
6.    Execute Code    install.php    
7.    Extract File    ./Themes/default/images/buymeabeer.gif


What could I be doing wrong?  My forum is at www.moderatedsciastroamateur.org [nofollow] if that helps answer things.


Thanks,


Martin

karlbenson

its probably conflicting with another mod which you have installed.

From the look of your forum, it looks like its conflicting with your weather/flags mods.

You either a) not install the mod or b) install the mod and make the manual edits to the display.template.php
Always remember to backup first

BogeyOne

Thanks.  I am a little squeamish about manually working things so I guess I will have to pass on this mod.  But thanks for the very nice work and I am sure it is a great mod to have.


--
Martin

karlbenson

I've not used it myself.

I originally created it when it was requested by another user. ;)

Thanks for having a look at the mod anyway. ;)

abda53

this is an awesome idea.

i will be adding this tonight

ApplianceJunk

This mod was easy to install and it works great!

This will be great for our members to use. I was trying to think of a way that our members could donate via paypal to the technicians that help them.

I was going to just let them post there own paypal donation link, but this is a much better idea.

Here is how I posted the info to our forums.

What is the beer glass icon about and how do I get one?

Thanks again,,

karlbenson


bins

how can you change the currency on this great mod?

WXWP

Gotta love it! A mod after my own heart.  ;D
Works great in Helios TP..
- John

Admin:SMF 1.1 RC3

karlbenson

@ bins

There isnt a setting to change, currency, but you can alter the link manually

Open DISPLAY.template.php
FIND the paypal link


<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=' , htmlentities ($message['member']['buymeabeer'], ENT_NOQUOTES, "UTF-8") , '&item_name=' , htmlentities ($txt['pleasebuymeabeer'], ENT_NOQUOTES, "UTF-8") , '&amount=', $priceofbeer ,'%2e00&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8" rel="nofollow" title="', $txt['buymeabeeralt'] ,'


In the link find currency_code=USD and change it to GBP for example.

Note this will change it for ALL users.  Users who's account are not in that language can have ebay convert the funds to their currency code.

Advertisement: