Author Topic: [SOLVED] Shop items  (Read 2108 times)

Offline tfalbb

[SOLVED] Shop items
« on: August 31, 2007, 08:47:01 pm »
In the sample shop items, one is Change Membergroup. Ths sounded like what I wanted so I configured an item using that.

On testing however, it does exactly that. How would I modify this so that when a member buys the item it adds a Membergroup as an additional group to their existing permissions?

Offline tfalbb

Re: Shop items
« Reply #1 on: September 10, 2007, 01:25:52 pm »
So.

1. Is this so blindingly simple, no one can be bothered to tell me?
2. Is it possible, but tricky, and no one has the time?
3. Is it not possible?

I'd love to know.  :(

Offline inkstains

Re: Shop items
« Reply #2 on: September 10, 2007, 02:00:27 pm »
this boards pretty dead lately so it can take a while to get a response anyways

not exactly sure what you're trying to do but try this

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:40:57 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: PrimaryMemberGroup.php 80 2007-01-18 08:40:57Z 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.                                                  *
**********************************************************************************/

// Item to add to a members additional membergroup
// Based off code originally posted to http://www.daniel15.com/forum/index.php/topic,316.msg1583.html#msg1583

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

class 
item_AdditionalMemberGroup extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail 'dansoft@dansoftaustralia.net';

$this->name 'Add Additional Membergroup';
$this->desc 'Add Additional Membergroup!';
$this->price 50000;

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

function getAddInput()
{
global $db_prefix;

$selectBox '
<select name="info1">'
;

// Get all non post-based membergroups
$result db_query("SELECT ID_GROUP, groupName
FROM 
{$db_prefix}membergroups
WHERE minPosts = -1"
__FILE____LINE__);

// For each membergroup, add it to the list
while ($row mysql_fetch_assoc($result))
$selectBox .= '
<option value="' 
$row['ID_GROUP'] . '">' $row['groupName'] . '</option>';

$selectBox .= '
</select>'
;
return 'Membergroup: ' $selectBox;
}

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

$result db_query("UPDATE {$db_prefix}members
SET additionalGroups = 
{$item_info[1]}
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);
return 'Changed Additional Member Group!';
}

}

?>

save as AdditionalMemberGroup.php and put in your items folder
« Last Edit: September 10, 2007, 02:09:22 pm by inkstains »

Offline tfalbb

Re: [SOLVED] Shop items
« Reply #3 on: September 10, 2007, 07:15:40 pm »
That's perfect, thanks very much.  O0 O0 O0

Offline inkstains

Re: [SOLVED] Shop items
« Reply #4 on: September 10, 2007, 09:05:38 pm »
 glad it worked :)