SMF Shop
SMFShop => Completed Additions => Items => Topic started by: celadore on March 07, 2007, 07:17:30 am
-
Save this as AddMembergroup.php under shop items.
I wanted to allow users to purchase additional membergroups. The only solutions I found were the ChangeMembergroup in default SMF 3.0 and the BuyMembergroup by Chad (which didn;t work for me). So I used both these to create a AddMembergroup item (I have only been using SMFShop for 20 minutes, but it appears to work for me).
What the Buyer gets: The member who uses this item will have himself ADDED to the 1 membergroup for which the item was set-up for. It will leave his primary membergroup unchanged. The user does NOT get to choose which membergroup he wants to be added to NOR is he assigned to a random one.
<?php
//File: AddMembergroup.php
// Item
//DATE: Mar 07, 2007
//Author Taj
class item_AddMembergroup extends itemTemplate {
function getItemDetails() {
$this->authorName = "Taj";
$this->authorWeb = "http://www.hostadore.com/";
$this->authorEmail = "admin@hostadore.com";
$this->name = "Add Membergroup";
$this->desc = "Allows you to add yourself to a membergroup!";
$this->price = 1;
$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;
$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'].", ".$item_info[1];
} else {
$additionalGroups['additionalGroups'] = $item_info[1];
}
echo $additionalGroups['additionalGroups'];
$result = db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
WHERE ID_MEMBER={$ID_MEMBER}",__FILE__, __LINE__);
return "You have joined new membergroup {$item_info[1]}!!";
}
}
?>
-
the only issue I see (and i may be mistaken) is that you even allow them to choose the admin membergroup which could cause a serious security risk on a forum.
-
No, you are mistaken. You either have not tried it out yet or you specified the admin group yourself when you set it up.
This item allows the buyer to be added to only 1 membergroup which the administrator chooses when he create the item. When you set up this item in the admin, it asks you which membergroup you want the purchaser to be added to. So it is PRE-SET! The buyer is ONLY added to the membergroup that you have set the item up for and does NOT have the option to join any membergroup he pleases.
The good thing about this one is that you can create a different item for EACH membergroup you want your members to be able to BUY their way into and at DIFFERENT prices too!
So no security leak here as far as I can see.
-
nice item man, pretty clean code.
very nice
-
No, you are mistaken. You either have not tried it out yet or you specified the admin group yourself when you set it up.
This item allows the buyer to be added to only 1 membergroup which the administrator chooses when he create the item. When you set up this item in the admin, it asks you which membergroup you want the purchaser to be added to. So it is PRE-SET! The buyer is ONLY added to the membergroup that you have set the item up for and does NOT have the option to join any membergroup he pleases.
The good thing about this one is that you can create a different item for EACH membergroup you want your members to be able to BUY their way into and at DIFFERENT prices too!
So no security leak here as far as I can see.
Ok, my bad, I was just trying to read the code posted to see what it did, didn't notice that! Very cool item then!
-
The BuyMembergroup by Chad (which didn;t work for me).
It may work If you replace this
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$item_info[1];
By
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].",".$item_info[1];
-
So can anyone code it that member stays in group just for a time set by admin? :(
I understand it needs a cron job but my idea is to make Premium membergroup without ads, with unlimited PM box etc. ant if a member wants to stay in that membergroup, he/she has to buy it every month or week or...
-
Sounds like a bit of a pain in the rear for your members to have to buy this every week or month, it would really p me off anyway if I had to do that unless being part of this special membergroup was absolutely essential (not just to get rid of ads and send PMs).
A simple solution would be to allow members to buy their way into the membergroup using this item and then purge the membergroup at the end of the month ready for next month.
To set-up a cron to do this for you does not require SMFShop in anyway, its to do with the Forum itself, so is kinda off topic.
If you are looking for something that logs the time when the person uses this item, counts down the time that he/she is a member of the member group and then removes them, you will probably have to hire a programmer to do that for you. It's prob not difficult, but more than I would want to do :)
-
Hi Celadore
This is very nice item for sure and I might use it on my FRP based web site to sell people this membergroups as let say "house". : D For example I would name a member group as "Mountain farm" or "A Secret Cave" and sale it to my users. BUT I wonder when these guys buy this memeber group can they include some other members to it themself. Or after a user buy this group can other one buy an join in the member group whitout the first members permition.
It would be really nice for clan based FRP site. You could charge up to 99 members to join in to your memeber group. If it has these functions I would gladly install it.
But even like these this is a very good item.
Thanks for listening...
-
Very nice Item!
hmmm... can you do a little modification?
i want, that they can buy the 'real' membergroup.
that the MAIN-group is changed, not just added to one.
hope you understand my bad english skills :)
thanks!
TomTheBig
-
Very nice Item! thanks! ;)
-
So can anyone code it that member stays in group just for a time set by admin? :(
I understand it needs a cron job but my idea is to make Premium membergroup without ads, with unlimited PM box etc. ant if a member wants to stay in that membergroup, he/she has to buy it every month or week or...
Awe id really like this too - and thought maybe it can be done like the SMF Arcade passes for the SMFshop which allows access for a certain amount of time? Is there anyone who can look into this? Please....
;)
-
Does this item works on new SA Shop for SMF 2.0 (since I know it's based on this MOD)?
-
Sakae, SMFShop an SA Shop are two totally different mods. I looked in the code for SA Shop and didn't find much that was similar... Nice item though!
-
Too bad this is an item for the older shop mods. I use shop version 3.1.4 and this item isn't working with it. When i add this item in the right directory i get a white screen on the add item page of the shop administration screen.
Couldn't solve it myself. Tried it for 2 days now. :(
-
Thanks to TimeVortex i got it working again. Thanks for that!!
-
Thanks to TimeVortex i got it working again. Thanks for that!!
Can you tell me how you solved this?
I have the same problem
-
Bump!
Anybody?
Plz!
-
No one even works on SMF shop anymore. I've had support requests and ideas in for a week or more and no replies whatsoever. I'm pretty much going to give up soon.
-
I think you are very wrong about that.
There is a new update for the new forum version, so that means it is still used.
The problem is more that there is few support and/or community.
Once the system is running nice on their forums, nobody cares about the further development of things.
It is the only working credit controlled mod.
Nevertheless is still love it.
-
I still love it too but i'm getting absolutely no support at all.
-
Here the code fixed:
<?php
//File: AddMembergroup.php
// Item
//DATE: Mar 07, 2007
//Author Taj
class item_AddMembergroup extends itemTemplate {
function getItemDetails() {
$this->authorName = "Taj";
$this->authorWeb = "http://www.hostadore.com/";
$this->authorEmail = "admin@hostadore.com";
$this->name = "Add Membergroup";
$this->desc = "Allows you to add yourself to a membergroup!";
$this->price = 1;
$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;
$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'].",".$item_info[1];
} else {
$additionalGroups['additionalGroups'] = $item_info[1];
}
echo $additionalGroups['additionalGroups'];
$result = db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
WHERE ID_MEMBER={$ID_MEMBER}",__FILE__, __LINE__);
return "You have joined new membergroup {$item_info[1]}!!";
}
}
?>
Thanks to Sakuragi: http://smfshop.com/forum/index.php/topic,659.msg3505.html#msg3505
I just made what he said and it works fine.
Bye.
-
hi there.. i got this error:
Fatal error: Call to undefined function db_query() in /home/public_html/Sources/shop/items/AddMembergroup.php on line 30
when try to use it.
my SMF version is 2.0RC3, please can modify?
-
Igualmente tengo el mismo problema y me interesa mucho el item.
Yo pienso que el error esta aqui:
Ejemplo para SMF 1.1
$result = db_query("SELECT ID_GROUP, groupName
FROM {$db_prefix}membergroups
WHERE minPosts = -1",
__FILE__, __LINE__);
Ejemplo para SMF 2.0
// Get all the topics in board 1
$result = $smcFunc['db_query']('', "
SELECT t.id_topic, m.poster_name, m.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_board = {int:id_board}
LIMIT 10",
array(
'id_board' => 1,
));
¿Quedaria asi el nuevo codigo para addmembergroup en SMF 2.0?:
// Get all non post-based membergroups
$result = $smcFunc['db_query']('', "
SELECT id_group, group_name
FROM {db_prefix}membergroups
WHERE min_posts = -1",
);
Mas lineas de codigo necesitan nuevos comandos.
RE-FIX este item please.
MAS INFO (Changes in SMF 2.0 ):
http://docs.simplemachines.org/index.php?topic=1433.0#post_db
The main functions are listed below:
Function used in SMF 1.1
db_query
mysql_fetch_assoc
mysql_fetch_row
mysql_num_rows
mysql_free_result
mysql_real_escape_string or mysql_escape_string
SMF 2.0 equivalent
$smcFunc['db_query']
$smcFunc['db_fetch_assoc']
$smcFunc['db_fetch_row']
$smcFunc['db_num_rows']
$smcFunc['db_free_result']
$smcFunc['db_escape_string']