vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Profile Enhancements - Unique Avatars (https://vborg.vbsupport.ru/showthread.php?t=148711)

mfyvie 06-01-2007 10:00 PM

Unique Avatars
 
*** Staff note: The author of this modification has passed away in a diving accident. We wish his family all strength in dealing with this traggic issue. ***

Have you ever been frustrated by the fact that many of your users choose the same avatars from your pre-defined avatars?

Now you can prevent users from selecting avatars that others are already using.



Features
  • No template or file edits, just a single .xml file to install
  • Phrase-based - update language strings as you like
  • Can either omit the used avatars from the display, or show them as unavailable
  • Can optionally display a count of how many times each avatar is used
  • All options configurable via the admin control panel
  • Install routine adds an additional index to ensure database performance not impacted on larger boards
The inspiration from this mod came from a similar one for vBulletin 3.0 by VBDev. Even though there is almost no code in common between these mods I've sought and obtained his permission to release this.



Installation (30 seconds)
  • Download the attached .xml file
  • Go into your admin control panel -> Plugins & Products -> Manage Products -> Add/Import Product.
  • Press the browse button to locate the .xml file you just downloaded click OK.
  • Ensure that "Allow Overwrite" is set to "Yes" and press "Import"
  • Note: requires MySQL version 4.1 or higher.
Configuration
VBulletin Options -> Unique Avatar

Version History
1.0 - Initial release (02.06.2007)
1.1 - 1 minor bugfix (20.01.2008)

See screenshots for further details.

rayw 06-01-2007 11:23 PM

That is a great idea. I like it!

If two people on the board already have the same avatar and you install this, what effect will it have on those two people??

SMO 06-01-2007 11:30 PM

I like this idea....nice of ya to rls it.

mfyvie 06-01-2007 11:32 PM

No effect, but if one of them selects a different avatar, then they won't be able to reselect it (since at least one other person is using it).

If you configure the mod to show the count of how many people are using a given avatar you can get an overview of which avatars are used.

It would be possible to craft some queries to show you which users were using a duplicate avatar (count of 2 or higher), and theoretically it would be possible to make a query which removed the avatar from these users (forcing them to choose again, and therefore no more duplicates possible from that point on).

Nutz 06-01-2007 11:35 PM

Nice idea.

Thanks for the share,
Mat

gforce75 06-02-2007 12:14 AM

Not a bad idea. Once I get my forum going with some more advatars, I'll give this hack a crack.

TTG 06-02-2007 12:37 AM

Great idea .. thanks mfyvie

Clicked install.

FreshFroot 06-02-2007 01:06 AM

i love the idea, great one mate!

rjmjr69 06-02-2007 02:35 AM

Nice thank you installed

tehPARADOX 06-02-2007 03:16 AM

Very nice! Can't believe this isn't a default feature.

SuperTaz 06-02-2007 05:33 AM

very nice...installed

VBDev 06-02-2007 05:54 AM

Nice buddy :)

projectego 06-02-2007 09:39 AM

Awesome idea, mfyvie! Great work. :)

Dr. Bantham 06-02-2007 10:45 AM

Yes! I have been asking for this of late, here and within the vBulletin forums. Many thanks!

mfyvie 06-02-2007 12:31 PM

Here is a query that will allow you to quickly identify existing users on your board that have the same avatars as others.

If you don't know how to run an SQL query, in your admincp go to Maintenance -> Execute SQL Query, then copy and paste the query below:

Code:

/*
This query will return a list of all of those users on your board who share an avatar with
at least one other person. This will allow you to contact them, edit them, or do whatever
you like with the information.

If this query doesn't work, you may be using prefixes in front of your table names. In this
case you'll have to edit the table names in the FROM line.
For example if your table prefix was vb then the FROM line would look like this:
FROM vbavatar av1,vbuser usr1, vbuser usr2
If you don't use table prefixes (most people), just do nothing and run this query as is
*/

SELECT distinct usr1.userid ,usr1.username, av1.title, av1.avatarid, av1.imagecategoryid
FROM avatar av1, user usr1, user usr2
WHERE av1.avatarid=usr1.avatarid
AND av1.avatarid=usr2.avatarid
AND usr1.userid <> usr2.userid
and usr1.avatarid>0
and usr2.avatarid>0
order by 4 asc

It can sometimes be interesting to see just how much you actually needed this mod :)

Note: I found that when I ran this inside the admincp it only gave me the number of rows returned. If you run it in another mysql tool you'll get the full results, including the usernames affected, etc.

Barakat 06-02-2007 09:10 PM

What if u have a thousand member ,! Installed indeed .

CCWBumper 06-02-2007 10:16 PM

Installing now!

PoetJA-1975 06-03-2007 08:38 AM

Ha! This is very nice - I was looking for something similar.
This will do just fine - Thanx very much for the sharing!

Jacquii.

william99 06-03-2007 08:40 AM

Installed, awesome idea, I have been waiting for something like this for a long time :-)

Andyucs 06-03-2007 01:05 PM

i get this error when i enable it

in my usercp change avata

PHP Code:

Database error in vBulletin 3.6.7:

Invalid SQL:

            
SELECT avatar.avataridavatar.titleavatar.minimumpostsavatar.avatarpathavatar.imagecategoryidavatar.displayordercount(1)
            
FROM user avatar
            WHERE user
.avatarid avatar.avatarid
            
AND avatar.imagecategoryid 3
            
AND minimumposts <= 1167
            GROUP by avatar
.avatarid
            UNION
            SELECT avatarid
titleminimumpostsavatarpathimagecategoryiddisplayorder0
            FROM avatar
            WHERE avatarid not in 
(select distinct avatarid from user)
            AND 
imagecategoryid 3
            
AND minimumposts <= 1167
            ORDER by displayorder
title
            LIMIT 0
,10;

MySQL Error  You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select distinct avatarid from user)
            AND imagecateg
Error Number : 1064
Date         : Sunday, June 3rd 2007 @ 02:53:25 PM
Script       : http://www.ucsclan.co.uk/forum/profile.php?do=editavatar
Referrer     : http://www.ucsclan.co.uk/forum/profile.php?do=editoptions
IP Address   : 83.100.253.11
Username     : FlatLiner
Classname    : vb_database 


mfyvie 06-03-2007 01:15 PM

Hi Andy, I can't think why that is happening. The query is correct. Can you confirm that you aren't using any table prefixes (in other words, the tables in your database are actually called avatar and user). Also please tell us the version of php and mysql that you are using. You are the first to report any problems with this, so I'm interested to know if there is something different about your setup.

Mark

txspaderz 06-03-2007 01:54 PM

Does this conflict at all with the default Avatar / No Avatar image?

mfyvie 06-03-2007 01:58 PM

Quote:

Originally Posted by txspaderz (Post 1260313)
Does this conflict at all with the default Avatar / No Avatar image?

I don't know - try it and see. It's fairly specific in what it does, so chances are there won't be a conflict. Please update this thread with the result.

Andyucs 06-03-2007 02:15 PM

Quote:

Originally Posted by mfyvie (Post 1260297)
Hi Andy, I can't think why that is happening. The query is correct. Can you confirm that you aren't using any table prefixes (in other words, the tables in your database are actually called avatar and user). Also please tell us the version of php and mysql that you are using. You are the first to report any problems with this, so I'm interested to know if there is something different about your setup.

Mark

phpMyAdmin - 2.10.0.2

PHP 4.3.11

no table prefixes

hope that helps

mfyvie 06-03-2007 02:28 PM

Quote:

Originally Posted by Andyucs (Post 1260322)
phpMyAdmin - 2.10.0.2

PHP 4.3.11

no table prefixes

hope that helps

Mysql version?

Andyucs 06-03-2007 02:39 PM

sorry

MySQL client version: 4.1.21

mfyvie 06-05-2007 05:29 AM

Quote:

Originally Posted by Andyucs (Post 1260347)
sorry

MySQL client version: 4.1.21

Hi Andy, I sent you a PM a couple of days ago offering to help. If I don't hear back from you via this PM then I'll assume you've resolved this issue.

mfyvie 06-05-2007 11:38 AM

Would you like something that will automatically REMOVE the avatar for those users who already have the same avatar as others?

The following two queries will do this. The first one will report how many duplicates you have, the second will delete the avatars.

WARNING: The second query will actually change your database. I've tested it on my system and am confident that it works. However, if you run this query on a live system and it breaks it, and you didn't back it up - don't come running to me about it!

First query:
Code:

select avatarid,count(1) from user
where avatarid>0
group by avatarid
having count(1) > 1
order by 2 desc

This will simply report how many cases of duplication you have. Once you can see the extent of the problem you can run this:

Second query:
Quote:

update user u1, user u2
set u1.avatarid=0
where u1.avatarid=u2.avatarid
and u1.userid!=u2.userid
and u1.userid>u2.userid
and u1.avatarid>0
and u2.avatarid>0
You can then re-run the first query to confirm that it worked - if it did, you'll get 0 rows returned.

Note that these queries, as well as the one I posted a few days back will work even if you don't have this mod installed (might be a bit slow due to lack of an extra index though).

If there are two users using the same avatar it won't delete both of their avatars - the lowest userID (usually the oldest member) gets to keep theirs, only the "new" guy will lose theirs.

Once you've used this to eliminate all the duplicates you can be sure that no more will happen when you are running this mod.

The only side effect is the users might wonder where their avatar went...

By the way - in case anyone thinks I am any good at making or changing these queries - I'm not. I gave it to some database gurus to do. They had to scratch their heads a bit before coming up with the final solution. They said it wasn't so simple to figure out.

JD45 06-05-2007 04:24 PM

Thanks for the hack and agreed, this should be a default feature in VB.

JordanT 06-05-2007 08:33 PM

I have the same problem as Andy:

Code:

Database error in vBulletin 3.6.6:

Invalid SQL:

            SELECT avatar.avatarid, avatar.title, avatar.minimumposts, avatar.avatarpath, avatar.imagecategoryid, avatar.displayorder, count(1)
            FROM vb_user , vb_avatar
            WHERE user.avatarid = avatar.avatarid
            AND avatar.imagecategoryid = 4
            AND minimumposts <= 64
            GROUP by avatar.avatarid
            UNION
            SELECT avatarid, title, minimumposts, avatarpath, imagecategoryid, displayorder, 0
            FROM vb_avatar
            WHERE avatarid not in (select distinct avatarid from user)
            AND imagecategoryid = 4
            AND minimumposts <= 64
            ORDER by displayorder, title
            LIMIT 0,10;

MySQL Error  : Table 'host4_vb.user' doesn't exist
Error Number : 1146
Date        : Tuesday, June 5th 2007 @ 05:32:23 PM
Script      : http://www.host4posts.com/profile.php?do=editavatar
Referrer    : http://www.host4posts.com/usercp.php
IP Address  : 66.170.53.178
Username    : Jordan
Classname    : vB_Database

:(

mfyvie 06-06-2007 07:23 AM

JordanT - your issue is not the same as Andy's - the error message is totally different.

It looks like you are the first guy to use table prefixes, and I see a small mistake in the query, I'll work on a fix soon, but am still looking at Andy's issue. I'll update this thread with more info soon.

ABMAC 06-06-2007 08:03 AM

I'm also having trouble getting this mod to work. I would appreciate any help you can offer.

PHP version 4.4.7
MySQL version 4.0.23

Code:

Database error in vBulletin 3.6.7:

Invalid SQL:

            SELECT avatar.avatarid, avatar.title, avatar.minimumposts, avatar.avatarpath, avatar.imagecategoryid, avatar.displayorder, count(1)
            FROM user , avatar
            WHERE user.avatarid = avatar.avatarid
            AND avatar.imagecategoryid = 3
            AND minimumposts <= 8681
            GROUP by avatar.avatarid
            UNION
            SELECT avatarid, title, minimumposts, avatarpath, imagecategoryid, displayorder, 0
            FROM avatar
            WHERE avatarid not in (select distinct avatarid from user)
            AND imagecategoryid = 3
            AND minimumposts <= 8681
            ORDER by displayorder, title
            LIMIT 50,10;

MySQL Error  : You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select distinct avatarid from user)
            AND imagecateg
Error Number : 1064
Date        : Tuesday, June 5th 2007 @ 04:04:37 PM
Script      : http://megomuseum.com/community/profile.php?do=editavatar&categoryid=3&page=6
Referrer    : http://megomuseum.com/community/profile.php?do=editavatar&categoryid=3&page=5
IP Address  : ***.***.***.***
Username    : ABMAC
Classname    : vb_database


mfyvie 06-06-2007 08:17 AM

Ok, so far we've had two people with error 1064 - reporting a syntax error. This is very strange, since the syntax seems to be correct. Please run a repair / optimise on your database to see if it corrects the issue. To be honest this is a stab in the dark, but I can't think what else would cause this.

The report of error 1146 is a bug which affects people with table prefixes. I've made some changes, but waiting for the guy who reported it to get back to me so I can get him to test it.

ABMAC - please report back after running a repair/optimise

mfyvie 06-06-2007 09:12 AM

ABMAC - apparently subqueries (which this one is using) are only available in mysql 4.1 and up. You are running 4.0 - would you consider upgrading? Andy is running 4.1 and having the same issue, but the cause may be different.

mfyvie 06-06-2007 09:23 AM

Ok, I've updated the XML file - it was not handling situations where people are using table prefixes. This will resolve JordanT's issue, but not the issue seen by ABMAC or Andy.

Andyucs 06-06-2007 09:35 AM

just like to say thanks for your work trying to resole this matter

Andyucs 06-06-2007 10:09 AM

ok installed on another site and get the same

as soon as i enable Force unique avatars? to yes i get the error

runs fine as in the screen shot

ABMAC 06-06-2007 03:20 PM

Thanks, mfyvie, I'll see about getting MySQL 4.1 installed. Should I still run repair/optimise on my database? My board is fairly new and shouldn't have any problems yet.

mfyvie 06-06-2007 03:29 PM

You don't have to, but it probably wouldn't hurt. I wasn't able to figure out Andy's issue, but he has no control over his mysql settings so we were limited in what we could do. Your issue should be fixed by an upgrade though.

I'm going to look at re-writing the query so that people with < mysql 4.1 can also use this mod, but it's not simple.

JordanT 06-06-2007 08:17 PM

Thanks for fixing my problem. Much appreciated!


All times are GMT. The time now is 07:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02148 seconds
  • Memory Usage 1,841KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete