Author Topic: Teddy Bear Item  (Read 6812 times)

Offline brianjw

Teddy Bear Item
« on: January 06, 2008, 07:20:36 am »
I give most credit to Daniel15 for helping me to allow this item to send pms and fix an error of the pm function. I give me credit for the idea and the input part (except pm part of it)

Simply, copy and paste the following code into your favorite php editor. Then save it as teddy.php and upload it to your /Sources/shop/items/ folder. Then you will need to enable it in the shop admin panel.
Code: [Select]
// Teddy Bear Item
// The author of this item is brianjw and authors name, email, and website must remain in place.
// This is just to make sure that the item is used through SMF, and people aren't accessing it directly
// Additionally, this is used elsewhere in SMF (in almost all the files)
if (!defined('SMF'))
die('Hacking attempt...');

item_teddy extends itemTemplate
// When this function is called, you should set all the item's
// variables (see inside this example)
function getItemDetails() {

// The author's name
$this->authorName 'brianjw';
// The author's email address
$this->authorEmail '';
// The author's website
$this->authorWeb '';

// --- Values changeable from within the SMFShop admin panel ---
// The name of the item
$this->name "Teddy Bear";
// The item's description
$this->desc "Buy a Teddy Bear! It will be in your pm inbox to visit you!";
// The item's price
$this->price 100;

// --- Unchageable values ---
// These values can not be changed when adding the item, they are stuck on what you set them to here.

// Whether inputs are required by this item. In this case, we get some inputs,
// so set this to 'true'.
$this->require_input true;
// Set this to 'false' if the item is unusable. This is good for display
// items.
$this->can_use_item true;

 * This function is called when the user tries to use the item.
 * If your item needs any further user input then you can get that 
 * input here (eg. if it's a "Change username" item then you have
 * to ask the user what they'd like to change their username to).
 * Any text you return will get shown to the user (DON'T ECHO STUFF).
function getUseInput()
return '<b>Name your teddy bear:</b> <input type="text" name="teddy_name" /><br /><b>Your Teddy Bear\'s favorite color:</b> <select name="tcolor">
  <option selected="selected">Blue</option>
</select><br />Your teddy bear will also be in your PM inbox so you can see me everytime you go there.'

// This is where all the fun begins. This function is called when 
// the user actually uses the item. Return stuff, DON'T ECHO!
function onUse()
global $context;

// Who is sending the IM
$pmfrom = array(
'id' => 0,
'name' => $_POST['teddy_name'],
'username' => $_POST['teddy_name']

// Who is receiving the IM
$pmto = array(
'to' => array($context['user']['id']),
'bcc' => array()
// The message subject
$subject 'Your Teddy Bear, ' $_POST['teddy_name'] . '!';
// The actual message
$message '[center][img width=95 height=90][/img][/center][br]I am your teddy bear, ' $_POST['teddy_name'] . '. I will be able to see you every time you stop by your pm inbox. My favorite color is [color=' $_POST['tcolor'] . ']' $_POST['tcolor'] . '[/color]! You can have more than one of me, but Gamerz Garage doesn\'t recommend it as it will fill up your pm box.<br /><br />Your new friend,<br />' $_POST['teddy_name'] . '';
// Send the PM

return '<b>' $_POST['teddy_name'] . ' is speaking (your teddy bear):</b><br><br>Hello, my name is ' $_POST['teddy_name'] . '!<br>I am your teddy bear and my favorite things to do are to be loved and cared for. ' $_POST['teddy_pm'] . '';


If you'd like to edit some of what the pm sends to you or members:
Code: [Select]
// The actual message
$message = '
and edit the message after that to what you want. If you're keeping the image that is already sent through pm, please change to your correct paths.

If you'd like to edit some of what the message is after the user inputs:
Code: [Select]
return '<b>' . $_POST['teddy_name'] . ' is speaking (your teddy bear):</b><br><br>Hello, my name is ' . $_POST['teddy_name'] . '!<br>I am your teddy bear and my favorite things to do are to be loved and cared for. ' . $_POST['teddy_pm'] . '';
and edit it as desired.

You can also add more colors to the drop down list that are SMF BBC colors...meaning SMF must have that color in coding somewhere. If the user chooses a color, we will say green...from the drop down:
Code: [Select]
<select name="tcolor"> It will pull the color the user chose into the pm:
Code: [Select]
My favorite color is [color=' . $_POST['tcolor'] . ']' . $_POST['tcolor'] . '[/color]!
I am open for suggestions and comments :) Enjoy :)


Offline Hipphappsero

Re: Teddy Bear Item
« Reply #1 on: January 15, 2008, 03:01:19 am »
This mod sounds very interesting.
But could you (or anyone) post a print screen?

Offline brianjw

Re: Teddy Bear Item
« Reply #2 on: January 15, 2008, 05:03:33 am »
The teddy bear item is located on my live sites shop which is currently in maintenance so unfortunately I can not give you any screenshots. Try it out for yourself! :)

Offline mike dijital

Re: Teddy Bear Item
« Reply #3 on: October 17, 2008, 06:57:43 am »
Is this a reocuring email, or just the one time

ps works great on 1.1.6 with mods

Offline Argentin

Re: Teddy Bear Item
« Reply #4 on: November 13, 2008, 06:49:21 am »
use this image