Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - E-boy

Pages: [1]
1
Items / Could someone edit Chad's Membergroup item?
« on: October 25, 2009, 08:47:07 am »
Right now you can only buy your OWN membergroup. But I'd like someone to edit the item, so that you need to input a username. Then the user you inputted 'buys' the new membergroup, not you.

Oh yeah, I forgot the code:

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

//File: BuyMembergroup.php
//      Item

//VERSION: 1.0 (Build 1)
//DATE: Oct 22, 2006
//Author Chad

class item_BuyMembergroup extends itemTemplate {
    function 
getItemDetails() {
       
$this->authorName "Chad";

   
$this->authorWeb "http://www.aviary.info/";

   
$this->authorEmail "generalchad@gmail.com";
   
        
$this->name "Buy Membergroup";
        
$this->desc "Allows you to buy your way into a membergroup!";
        
$this->price 250;

        
$this->require_input true;
        
$this->can_use_item true;
    }
    
function 
getAddInput() {
   global 
$db_prefix$item_info;

            
$result db_query("SELECT groupName 
                                FROM 
{$db_prefix}membergroups"__FILE____LINE__);
            
$row mysql_fetch_array($resultMYSQL_ASSOC);

while (
$row mysql_fetch_array($resultMYSQL_NUM)) {
   
$groups.=("<OPTION id='x{$i}' value='{$row[0]}'>{$row[0]}");
   
$i++; 
}
           
   return 
"Which Membergroup ID do you want to grant users access to?: <SELECT name='info1'>{$groups}</SELECT>";

}


    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info$user$sourcedir;

/////////////NOTICE  change the following ID or your item will fail.
$shophistoryID=0;//Set this to 0 if you don't have a shop history forum

//Begin Shop history
if ($shophistoryID) {
   require_once(
$sourcedir '/Subs-Post.php');
   
$topicOptions['board'] = $shophistoryID//SHOP history forum
   
$topicOptions['id']=0//NEW topic
   
$msgOptions['subject'] = "I just bought my way into the {$item_info[1]} membergroup!"//Subject
   
$msgOptions['body'] = "Yep!"
   
$posterOptions['id']=$ID_MEMBER//Current user's ID
   
createPost(&$msgOptions, &$topicOptions, &$posterOptions); //create the post using the SMF posting function
}
//End Shop history

$groupID=mysql_fetch_array(db_query("SELECT `ID_GROUP` FROM {$db_prefix}membergroups WHERE groupName = '{$item_info[1]}'"__FILE____LINE__),MYSQL_ASSOC);
$additionalGroups mysql_fetch_array(db_query("SELECT `additionalGroups` FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__),MYSQL_ASSOC);

if(
$additionalGroups['additionalGroups']) {
   
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$groupID['ID_GROUP'];
} else {
   
$additionalGroups['additionalGroups'] = $groupID['ID_GROUP'];
}   
echo 
$groupID['ID_GROUP'].":";
echo 
$additionalGroups['additionalGroups'];          
        
$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
                 WHERE ID_MEMBER=
{$ID_MEMBER}",__FILE____LINE__);

        return 
"You're in the new group, {$item_info[1]}!!";
    }
}
?>

Pages: [1]