Save as Sources\shop\items\BuyMembergroup.php
Look for :
/////////////NOTICE change the following ID or your item will fail.
$shophistoryID=98;//Set this to 0 if you don't have a shop history forum
and edit the 98 to your own shop history forum ID, if you don't use this feature, edit it to 0.
Enjoy.
<?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 = false;
$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($result, MYSQL_ASSOC);
while ($row = mysql_fetch_array($result, MYSQL_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=98;//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]}!!";
}
}
?>