Advertisement:

Author Topic: Can I find out which members are using which themes?  (Read 2891 times)

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Can I find out which members are using which themes?
« 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?

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #1 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? :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Re: Can I find out which members are using which themes?
« Reply #2 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.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #3 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 :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Re: Can I find out which members are using which themes?
« Reply #4 on: September 05, 2008, 06:23:20 PM »
Ok. Thanks.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #5 on: September 06, 2008, 04:18:35 PM »
Please let me know if this does the trick. Just place it in your forum folder

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

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Re: Can I find out which members are using which themes?
« Reply #6 on: September 06, 2008, 05:32:16 PM »
K thanks. I'll test it later today and let you know.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #7 on: September 11, 2008, 04:18:47 PM »
Just wondering if this worked successfully? :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Re: Can I find out which members are using which themes?
« Reply #8 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.
« Last Edit: September 11, 2008, 07:10:24 PM by antechinus »

Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: Can I find out which members are using which themes?
« Reply #9 on: September 11, 2008, 07:45:39 PM »
Failed on me... Gave a database error for

Table 'XXXXXXXXXX.themes' doesn't exist

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #10 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 :).

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)
                             

Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: Can I find out which members are using which themes?
« Reply #11 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.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,860
  • Master of BBC Abuse
Re: Can I find out which members are using which themes?
« Reply #12 on: September 12, 2008, 06:35:34 PM »
Awesome. Works perfectly on my test forum. Thanks.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Can I find out which members are using which themes?
« Reply #13 on: September 13, 2008, 10:22:33 AM »
Glad it worked :D
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: Can I find out which members are using which themes?
« Reply #14 on: September 13, 2008, 10:45:38 AM »
Yeah I did it wrong works perfectly..