Author Topic: Chame Theme User  (Read 4987 times)

Offline speak121

Chame Theme User
« on: July 02, 2007, 12:28:41 am »
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.

Code: [Select]
<?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!  ;)

Offline inkstains

Re: Chame Theme User
« Reply #1 on: August 30, 2007, 02:11:16 am »
just tried this but it seems you have to have "Allow members to select their own themes." turned on in which case the user can just go to their profile and change the theme bypassing the shop altogether. works fine as admin though.

maybe i've missed something any help appreciated

Offline speak121

Re: Chame Theme User
« Reply #2 on: August 30, 2007, 09:53:51 am »
sorry i dont speak english well but you have to have "Allow members to select their own themes." turned OFF, when the user go shop and buy item he must go to use it. Then the theme of the forum change for him. If he wants to return to the fist theme he must pay for do it.

Offline inkstains

Re: Chame Theme User
« Reply #3 on: August 30, 2007, 06:08:48 pm »

yeh that's what i was trying to say. if i have "Allow members to select their own themes." turned off the user cannot change the theme using the item. it will purchase go to inventory and appear to use correctly but won't actually change the theme. if i have "Allow members to select their own themes." on the item works as specified but the user can just as easily go to their profile and change the theme. i'll have a look at it later and see what i come up with haven't had a chance yet.