Can I find out which members are using which themes?

Started by Antechinus, September 05, 2008, 04:45:55 AM

Previous topic - Next topic

Antechinus

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?

H

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? :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Antechinus

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.

H

I'll see if I can come up with something tomorrow, unless someone beats me to it :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             


H

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>';
}
?>
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Antechinus

K thanks. I'll test it later today and let you know.

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Antechinus

#8
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.

Gargoyle

Failed on me... Gave a database error for

Table 'XXXXXXXXXX.themes' doesn't exist

H

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
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Gargoyle

Yeah using 1.1.5 and it displayed the DB name... But not the prefix.. How odd.. I look around some.

Antechinus

Awesome. Works perfectly on my test forum. Thanks.

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Gargoyle


Advertisement: