Author Topic: please help me modify the "emailadmin" shop item  (Read 3005 times)

Offline jessirose

please help me modify the "emailadmin" shop item
« on: June 14, 2006, 08:48:45 am »
hi, i'm not very good at coding so i was wondering if someone could help me,

i wish to create dead items that do only one thing,

all i want them to do is when you click on the "use" button what it does is send an instant IM to every admin (or just my personally member number) with maybe just a simple "member x brought an item from the shop"... or if at all possible... "member x brought item x from the shop" listing who brought it and what they brought so that i may then at my leisure go and do the actioning myself (for example go and give them access to a private room for 2 weeks).... then once the member clicks the "buy" button and it sends the IM off i wish it to return to there inventory with the item still there, i don't want the item to be deleted once they click the buy button, i want to do the removing myself...

is this at all possible and could anyone help me with this at all??

« Last Edit: June 14, 2006, 12:40:47 pm by jessirose »

Offline jessirose

Re: need help with an item action
« Reply #1 on: June 14, 2006, 12:39:41 pm »
i just noticed the "emailadmin" item which is almost what i'm looking for... i was just wondering if someone might be able to help me modify it...

this is the original code

Code: [Select]
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
|         (c) 2005 DanSoft Australia           |
|      http://www.dansoftaus.uni.cc/           |
\**********************************************/

//File: EmailAdmin.php
//      Email the admin item

//VERSION: 2.0 (Build 8)
//DATE: 26th December 2005

class item_EmailAdmin extends itemTemplate {

    function getItemDetails() {
        $this->name "Send Email to Admin v2";
        $this->desc "Send off an email to the admin. A good use for this (for a web host) is an 'Add 100MB of Webspace to your hosting account'";
        $this->price 10;
    }

    function getAddInput() {
        return 'Your email address: <input type="text" name="info1" size="50"><br>
                Subject of message: <input type="text" name="info2" size="50"><br>
                Additional fields needed:<br>
                    <textarea name="info3" rows="6" cols="40">
Web Hosting Username: <input type="text" name="host_user">
                    </textarea><br>

                Message to send:<br>
                    <textarea name="info4" rows="10" cols="80">
100MB Extra webspace has been bought from the Forum Shop by user {$_POST["host_user"]}. Please add it to his/her account
  --Shop Mailer
                    </textarea><br>

<b>NOTE:</b> The additional fields will be filled in by the user when they use the item.
To use one of your additional fields in either the message or subject, use the {$_POST["varname"]}
format, where "varname" is the name of the field (see the above dummy data for an example)'
;
    }
    function getUseInput() {
        global $item_info;
        //the 'additional fields needed' entered during item setup
        return $item_info[3];
    }

    function onUse() {
        global $item_info;
        $to $item_info[1];
        $subject $item_info[2];

        $message $item_info[4];

        //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);
//            $message = str_replace("{$_POST['".$postKey."']}", $postVar, $message);
        }
          
        
foreach ($_GET as $getKey => $getVar){
            $message str_replace('{$_GET["'.$getKey.'"]}'$getVar$message);
//            $message = str_replace("{$_GET['".$getKey."']}", $getVar, $message);
        }


        mail($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!";
    }
}


?>


i would like something much simplier, instead of requiring the user to put in a name like the above does, is there any possible way of taking out the user input altogether and instead using $ID_member or whatever the code is for the username/display name and just shoving that directly in the email that gets sent so that you do not require user input whatsoever...

and in saying that is it also possible to make the message

100MB Extra webspace has been bought from the Forum Shop by user {$_POST["host_user"]}. Please add it to his/her account
  --Shop Mailer

have the username as a link to their profile like all SMF emails usually have.

Of course it would be much simplier i think if we skipped the email and instead send a PM but i really have no idea how to do that.

all i have worked out how to do is stop the item from dissapearing out of the users inventory... by changing

Code: [Select]
return "Message sent to admin!";

to

Code: [Select]
die ("Message sent to admin!");

however that is a bit messy and requires the user to then click the back button and then refresh but i know no other way



Offline bipsmith

Re: please help me modify the "emailadmin" shop item
« Reply #2 on: June 16, 2006, 02:21:08 am »
If someone figured this out, I know I'd use it!

Quixjote

  • Guest
Re: please help me modify the "emailadmin" shop item
« Reply #3 on: June 16, 2006, 03:12:22 am »
I have made a mod that uses the admin mail to make a lottery that another member on my forum moderates... However it makes changes to the index template as well (to sticky the username).  It has been working flawlessly so far, but am still tweaking it.  Currently it will sticky the name and then send the email to the admin saying "[username] has just activated a lottery ticket"

Offline jessirose

Re: please help me modify the "emailadmin" shop item
« Reply #4 on: June 16, 2006, 09:34:11 am »
that sounds like exactly what i need....

you wouldn't be able to just give me the bits of code that are required to send the email to the admin would you?

basicly i want to make that feature as a base feature for all my items so that whenever a user uses any of their items i will be notified by PM or email :)

i wouldn't've thought it would be very hard... i think i'm just missing some vital step