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 - macphisto

Pages: [1]
1
Items / Re: New Item: Add membergroup
« on: September 18, 2010, 09:46:17 am »
Here the code fixed:

Code: [Select]
<?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.

Pages: [1]