Author Topic: Problem defining an item  (Read 2996 times)

Offline samurai-lupin

Problem defining an item
« on: March 28, 2008, 12:28:27 pm »
Hello,

I was trying to define an item based on the EmailAdmin.php code:

My item is supposed to do the following:

When a member uses it, he will be asked for his name, e-maill and address (through input fields). This data should be sent to me (webmaster). Finally the item should get removed from the uses inventory.

The cause for this is that members can exchange their credits for real things in my shop and I will mail those to them. Therefore I need their name, address etc.

I have tried to modify the EmailAdmin item but encountered a problem:

The item will ask the user only for his e-mail but NOT his name and address?

I am attaching my item's code and am wondering what I did wrong? Thanks for any thoughts!

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: EmailAdmin.php 79 2007-01-18 08:26:55Z daniel15                         $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_EmailAdmin extends itemTemplate
{

function getItemDetails()
{
$this->authorName '';
$this->authorWeb '';
$this->authorEmail 'Neuer Artikel';

$this->name '';
$this->desc '';
$this->price 10;

$this->require_input true;
$this->can_use_item true;
$this->addInput_editable true;
}

function getAddInput()
{
global $item_info;
if ($item_info[3] == ''$item_info[3] = 'Ihre e-mail: <input type="text" name="e-mail" />';
            if (
$item_info[4] == ''$item_info[4] = 'Ihr Name: <input type="text" name="name" />';
            if (
$item_info[5] == ''$item_info[5] = 'Ihre Adresse: <input type="text" name="adresse" />';

    return '<br>
                        <br>
<table cellpadding=2 cellspacing=0 border=0>

<tr><td>Ihre e-mail:</td><td><input type="text" name="info1" size="50" value="webmaster@thunting.com" /></td></tr>
<tr><td>Betreff:<br></td><td><input type="text" name="info2" size="50" value="detektorforum.de Shop Artikel Versand" /></td></tr>
<tr><td>Nachricht:</td><td><textarea name="info6" rows="1" cols="50"/>Folgender Artikel wurde eben gekauft</textarea></td></tr>
                          
                        </table>

<br>
                        <br>

Zusatzfelder:
<p/>
<textarea name="info3" rows="1" cols="50">' 
$item_info[3] . '</textarea><br />

<textarea name="info4" rows="1" cols="50">' 
$item_info[4] . '</textarea><br />

<textarea name="info5" rows="1" cols="50">' 
$item_info[5] . '</textarea><br />

'
;
}

function getUseInput()
{
global $item_info;
// The 'additional fields needed' entered during item setup
return $item_info[3];
return $item_info[4];
return $item_info[5];
}

function onUse()
{
global $sourcedir$item_info;
$to $item_info[1];
$subject $item_info[2];
$message $item_info[3];
$message $item_info[4];
            
$message $item_info[5];

// We need sendmail!
require_once($sourcedir '/Subs-Post.php');

// Hack put in place to allow $_POST and $_GET vars in the $message var
// --Daniel15, 4 Septemeber 2005 2:15PM
foreach ($_POST as $postKey => $postVar)
$message str_replace('{$_POST["' $postKey '"]}'$postVar$message);
  
foreach ($_GET as $getKey => $getVar)
$message str_replace('{$_GET["' $getKey '"]}'$getVar$message);

// Send the email!
sendmail($to$subject$message) or die('Error sending message to admin! Please inform the Admin of this error. This item will still be available in your inventory.');

return 'Message sent to admin!';
}
}


?>


Thank you!

Offline xns

Re: Problem defining an item
« Reply #1 on: April 04, 2008, 07:28:20 pm »
I am also in need of this to work.. for some reason it wont send the inputs.. plz help someone
A new web service site to be available soon!! -http://www.xudas.net/index1.php