Hi!, This is the first item i do! Is very simple but.. it serves me.. ^^
This items change the theme used by user to another determinated by administrator.
<?php
/**********************************************************************************
* SMFShop item *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum *
* =============================================================================== *
* Software Version: SMFShop 3.0 (Build 12) *
* 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. *
**********************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');
class item_ChangeTheme extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'speak121';
$this->authorEmail = 'speak121@gmail.com';
$this->name = 'Change the Theme used by user to xxx by speak121';
$this->desc = 'Change the Theme used by user to xxx';
$this->price = 400;
$this->require_input = false;
$this->can_use_item = true;
$this->addInput_editable = true;
}
function getAddInput()
{
global $db_prefix;
$selectBox = '
<select name="info1">';
// Get all themes
$result = db_query("SELECT ID_THEME, value
FROM {$db_prefix}themes
WHERE variable = 'name'", __FILE__, __LINE__);
// For each theme, add it to the list
while ($row = mysql_fetch_assoc($result))
$selectBox .= '
<option value="' . $row['ID_THEME'] . '">' . $row['value'] . '</option>';
$selectBox .= '
</select>';
return 'Theme selected: ' . $selectBox;
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
$result = db_query("UPDATE {$db_prefix}members
SET ID_THEME = {$item_info[1]}
WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return 'The change is done!!!';
}
}
?>
Put it in ChangeTheme.php!