Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: Antechinus on September 05, 2008, 04:45:55 AM

Title: Can I find out which members are using which themes?
Post by: Antechinus on September 05, 2008, 04:45:55 AM
Apart from clicking on every single member's profile and checking their look and layout preferences is there some way of telling who is using a particular theme? What I'm after, if possible, is say a listing of the themes with all members using that theme listed beneath it. I assume the information is stored somewhere.

Anything like that available?
Title: Re: Can I find out which members are using which themes?
Post by: H on September 05, 2008, 05:37:42 PM
You've probably seen the approximate count on the change themes page that says how many other people are using the theme.
If you wanted something more complex with actual names this probably wouldn't be too difficult to create (as the preferences are in the DB) although it isn't available by default.

Do you need this integrated with one of the SMF pages or would a quick-n-dirty SSI trick be ok? :)
Title: Re: Can I find out which members are using which themes?
Post by: Antechinus on September 05, 2008, 06:19:51 PM
I'm happy to pull the raw data out of MySQL or whatever as long as I can read the result. Thing is I'd like to prune some of our themes but don't want to annoy active members. If I know who is using what it'll help me decide which ones I can ditch without worrying about fallout. It's not something I'd need to do often so it doesn't mean I need to set up an admin function or anything like that.
Title: Re: Can I find out which members are using which themes?
Post by: H on September 05, 2008, 06:20:58 PM
I'll see if I can come up with something tomorrow, unless someone beats me to it :)
Title: Re: Can I find out which members are using which themes?
Post by: Antechinus on September 05, 2008, 06:23:20 PM
Ok. Thanks.
Title: Re: Can I find out which members are using which themes?
Post by: H on September 06, 2008, 04:18:35 PM
Please let me know if this does the trick. Just place it in your forum folder

<?php
require('SSI.php');
/*
This is a small utility to display available themes along with the users who are using them.
It is a quick and dirty hack that is not good for performance and so isn't a great idea to make public :)
Note that the HTML is practically non-existant too! :)
*/


//Get a list of available themes
$tquery db_query("SELECT ID_THEME, value FROM {$db_prefix}themes WHERE variable = 'name'"__FILE____LINE__);
while(
$row=mysql_fetch_array($tquery))
$availablethemes[] = $row;

//Get the list of users and their chosen themes
$mquerydb_query("SELECT realname, ID_THEME, ID_MEMBER FROM {$db_prefix}members"__FILE____LINE__);
while(
$row=mysql_fetch_array($mquery))
$userthemes2[] = $row;

//If the user is using the default theme then 0 should be the ID of the active theme
$dquery db_query("SELECT value FROM {$db_prefix}settings WHERE variable = 'theme_default'"__FILE____LINE__);
while(
$row=mysql_fetch_array($dquery))
$defaulttheme[] = $row;
$defaulttheme $defaulttheme[0]['value'];

//This is way too hacky
foreach($userthemes2 as $user)
{
if($user['ID_THEME'] == 0)
$user['ID_THEME'] = $defaulttheme;

$userthemes[] = $user;
}

foreach(
$availablethemes as $theme)
{
echo 
'<p>';
echo 'Users using '$theme['value'] ,':<br />';
$temp = array();
foreach($userthemes as $user)
{
if($user['ID_THEME'] == $theme['ID_THEME'])
$temp[] = $user;
}
echo 'There are 'count($temp) ,' user(s) using this theme: ';
foreach($temp as $user)
echo '<a href="'$boardurl ,'?action=profile;u='$user['ID_MEMBER'] ,'">'$user['realname'] ,'</a>, ';
echo 
'</p>';
}
?>
Title: Re: Can I find out which members are using which themes?
Post by: Antechinus on September 06, 2008, 05:32:16 PM
K thanks. I'll test it later today and let you know.
Title: Re: Can I find out which members are using which themes?
Post by: H on September 11, 2008, 04:18:47 PM
Just wondering if this worked successfully? :)
Title: Re: Can I find out which members are using which themes?
Post by: Antechinus on September 11, 2008, 06:56:49 PM
Oops. Sorry, I got sidetracked. I'll get some coffee into me and test it.

ETA: Ok, so the test forum didn't explode. This is a good bit. I don't understand how I'm supposed to use it though.
Having looked through the code I'm currently assuming I'll have to trundle down to phpmyadmin and run database queries manually.
Am I right?

Also give the comments in the file I assume I should delete the thing once it has served its purpose.
Title: Re: Can I find out which members are using which themes?
Post by: Gargoyle on September 11, 2008, 07:45:39 PM
Failed on me... Gave a database error for

Table 'XXXXXXXXXX.themes' doesn't exist
Title: Re: Can I find out which members are using which themes?
Post by: H on September 12, 2008, 03:31:16 PM
You should just be able to put it in your main forum folder and just run it as you would with install.php, repair_settings.php etc :).

Quote from: Gargoyle on September 11, 2008, 07:45:39 PM
Failed on me... Gave a database error for

Table 'XXXXXXXXXX.themes' doesn't exist

Is the prefix displayed in the error your actual DB prefix?

Are you using 1.1.x? This is untested on 2.0
Title: Re: Can I find out which members are using which themes?
Post by: Gargoyle on September 12, 2008, 03:55:10 PM
Yeah using 1.1.5 and it displayed the DB name... But not the prefix.. How odd.. I look around some.
Title: Re: Can I find out which members are using which themes?
Post by: Antechinus on September 12, 2008, 06:35:34 PM
Awesome. Works perfectly on my test forum. Thanks.
Title: Re: Can I find out which members are using which themes?
Post by: H on September 13, 2008, 10:22:33 AM
Glad it worked :D
Title: Re: Can I find out which members are using which themes?
Post by: Gargoyle on September 13, 2008, 10:45:38 AM
Yeah I did it wrong works perfectly..