Automatic Avatar for registered Users
From Another Web Company
Viewed 1565 times, With a total of 6 Posts
| Have a suggestion, improvement, change or non-beta Forum Entension bug ? Please add them to the todo list
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 1:10:04 PM - Monday 22nd, February 2010 |
|
Hello,
i really love the extension of AWCForum and so far i am happy with it. Of course I am looking forward to the next udate. Currently i only have one question that might already be answered before:
I have a wiki with round about 200 users and for each user i already have an imagefile uploaded to the wiki. It has the same name as the user
example
User = Jack Daniels
Image = Jack_Daniels.jpg (300 x 450 px)
How can i add this image to the user as an automatic avatar, as long as the user did not customized his own avatar yet?
thanks for any hints and
best regards
|
|
|
|
|
|
|
| 2:18:53 PM - Monday 22nd, February 2010 |
|
-
Hello Airsnake, the following information is for the 2.5.x version of the forum.
Quote:Airsnake Feb 22nd 12:02 pmHow can i add this image to the user as an automatic avatar, as long as the user did not customized his own avatar yet
Hummm... the "Yet" part is gonna be alittle tricky.
Heres some information on how things work with the forum...
The forum stores the avatar information (path, file name, size, weather the imgae was uploaded or is a url image link) in the 'awc_f_mem' database table.
If an image is uploaded via the Forums MemCP, the image is saved in the following path.
/extensions/awc/forums/images/avatars
When you install the forum, none of your current Wiki users are added to the 'awc_f_mem' table in-till they "visit" the forum for the first time. During the install process, the forum does not automatically add all wiki users to the forums database table (for efficiency reasons). When a wiki user views any part of the forum, for the first time, at that point, the forum will add them to the awc_f_mem table.
Being you only have around 200 users, it possiable i could make an AdminCP function for you which would automaticly add all your current wiki users to the forums dbase tables along with the url path to there current image.
Or maybe a better way to do this is to create a new Forum Hook and then people could code what ever they wanted for the process when new members are added to the forums databaes... I think that would be the best way to do it.
I have alittle time before i head to work today, ill peek around and see what i can coem up with.
Again, this is for the 2.5.x version of the forum.
None of this will work with the 2.4.x.
Ill post back here just before i go to work and let you know how it stands.
Do you know PHP and/or MySQL coding ?
_
|
|
~ What was once an opinion, became a fact, to be later proven wrong ~
|
|
|
|
|
| 3:52:38 PM - Monday 22nd, February 2010 |
|
Gonna go with a Forum Hook for this.
Forum hooks work the same way a Mediawiki Hook works.
You can add this edit to your current forum file (while will be in the next forum release).
Edit file: extensions/awc/forums/includes/gen_class.php
|
| Find:
|
|
| Below that add:
|
$m_id = $dbw->insertId();
wfRunHooks( 'awcsforum_memAddedToDbase', array($m_id, $this) ); // added 2.5.8
|
That hook is called right after a member is added to the forums awc_f_mem table
$m_id is the row ID of the entry
$this is an object which holds alot of info abuot that member.
You can use that to update the 'awc_f_mem' table with the url to the image you want pre-user.
If you know php and mysql and are not furmulare with mediawiki hooks, search there site, theres alot of info about wiki hooks and how they work. Look into creating your own wiki extension and you should find all you need.
Im off to work now, when i get home ill check back and see how you made out and supply you code if you need it.
Good luck
|
|
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 5:59:48 AM - Tuesday 23rd, February 2010 |
|
Hello and thanks for the information.
First of all today i downloaded the beta 2.5.7 and upgraded the forum. To have a AdminCP Function to set an avatar for a user (According to his name) would be great. But i will test the way you told me (although i do not fully understand right now 
I found the gen_class.php and a i added the script after unset($m_forumoptions); But how can i use this to set a standard avatar for the user named as user.jpg which is already uploaded to my wiki?
thanks for your help!
best regards
by the way: is that a normal behaviour that after upgrading to a new version the AdminCP Member Option tells that the user can not be found?
|
|
|
|
|
|
|
| 2:13:45 PM - Tuesday 23rd, February 2010 |
|
Im sorry but an AdminCP function will not be added, a hook will have to be used for the following reason.
A custom option like this does not seam to be usefull for other people.
By added a hook, other people can use this same hook for different reason and will give other wiki owners more options if they need.
Quote:Airsnake Feb 23rd 4:51 amby the way: is that a normal behaviour that after upgrading to a new version the AdminCP Member Option tells that the user can not be found?
Not sure what you mean, could you explane more ?
Quote:Airsnake Feb 23rd 4:51 amBut how can i use this to set a standard avatar for the user named as user.jpg which is already uploaded to my wiki?
Forget about the forum extension for a minute.
The Mediawiki software has "hooks" (which is the same concept used in the peice of code you added to the gen_class.php file ). These hooks are used so people can write extension to control/customize the core code of a wiki without having to edit wiki files. The reason (as i understand it) is for something like your case, you want custom option which most people will not have a need for, so to add this option as a core part of the software would not make sense for the Devs, so a hook is used. Another reason is so when people want to customize core wiki code, using a hook will preserve their custom code during wiki updates.
Here is a link which explans how to use a hook, by creating an extension:
[edit - wrong link] - http://www.mediawiki.org/wiki/Manual:Extensions
Now, the forum has hooks for this same reason. Heres an article for an extension someone write for the forum using a forum hook.
http://wiki.anotherwebcom.com/Kenyu73%27s_Email_Hook
The person wanted a custom option which i did not feel would be used by too many people so i created a hook for him. He used that hook to write his own "forum addon/extension" to do what he wanted, which is the same thing you will have to do.
Here is another example of a forum hook:
http://wiki.anotherwebcom.com/Special:AWCforum/st/id1210
That person whanted to do some simulare to you, but they did not want to give their members the option to change their avatar's. So a hook was added to the forums code which displays thread posts. When the hook is triggered (during the thread loading process) the person can manipulate the avatar display to their needs, by writing their own extension.
So what you will need to do is create your own extension for the forum...
1) Create a php file and place it in /wiki_root/extension/forumCustomAvatar.php
2) Edit your localsettings.php so that file is loaded require_once( "$IP/extension/forumCustomAvatar.php" );
3) In that forumCustomAvatar.php file add:
// Attach the forum hook ('awcsforum_memAddedToDbase') to your function...
$wgHooks['awcsforum_memAddedToDbase'][] = 'YourFunctionName_awcsforum_memAddedToDbase';
// Write your function...
function YourFunctionName_awcsforum_memAddedToDbase($idToUpdate, $memObjectInfo){
// Print out $memObjectInfo so you can see what it holds
# die(print_r($memObjectInfo));
// 1) SQL search/lookup of current users image with $memObjectInfo->m_IDname
/* $memObjectInfo->m_IDname will hold the current users name.
* You will have to search what ever mediawiki database table that holds the image information
*/
// 2) Update 'awc_f_mem' table with that info using $idToUpdate for the row ID
return true;
}
That hook and code will only be called the first time a user visits the forum, so you will have to do alot of testing by creating new users or keep deleting a user entry from the forum sqlTable 'awc_f_mem'.
Ill work on some code for you over the next day of so. Cant do it now becuase im buzy with house work.
_
|
|
Edited On 3:44:53 PM - Tuesday 23rd, February 2010 by AWC
|
|
|
|
|
|
Just Got Here
Wiki Edits: 0
Threads 1
Posts 3
|
|
| 4:40:32 AM - Wednesday 24th, February 2010 |
|
Thanks for your detailed answer, but i am afraid i do not get the point (probable i am just to dumb).
I understand that an AdminCP option would not be useful for others. Probabl< you can tell me an easy way to do the following:
when a user (Jack Daniels) visits the forum that awc_f_mems is populated or updated like this:
m_adv_size = 100x134
m_advtag = [[File:Jack_Daniels.jpg]]
m_adv = (path to the image like) /images/a/a2/Jack_Daniels.jpg
Could you please give me a hint for that?
Thanks a lot for you support!
|
|
Edited On 4:46:31 AM - Wednesday 24th, February 2010 by Airsnake
|
|
|
|
|
|
|
| 3:40:22 PM - Wednesday 24th, February 2010 |
|
As for getting the current image size, you will have to check if Mediawiki stores that information in one of its database-tables, or use a PHP function.
The code below is un-tested and off the top of my head...
So what you will need to do is create your own extension for the forum...
1) Create a php file and place it in /wiki_root/extension/forumCustomAvatar.php
2) Edit your localsettings.php so that file is loaded require_once( "$IP/extension/forumCustomAvatar.php" );
3) In that forumCustomAvatar.php file add:
// Attach the forum hook ('awcsforum_memAddedToDbase') to your function...
$wgHooks['awcsforum_memAddedToDbase'][] = 'YourFunctionName_awcsforum_memAddedToDbase';
// Write your function...
function YourFunctionName_awcsforum_memAddedToDbase($idToUpdate, $memObjectInfo){
// Print out $memObjectInfo so you can see what it holds
# die(print_r($memObjectInfo));
$m_advtag = "[[File:{$memObjectInfo->m_IDname}.jpg]]";
$m_adv = "[[File:{$memObjectInfo->m_IDname}.jpg]]"; // that might need to be changed... to real file path, dont have time to check, sorry...
// CODE to get image size...
# $m_adv_size = "";
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'awc_f_mems',
array('m_advtag' => $m_advtag,
'm_adv_size' => $m_adv_size,
'm_adv' => $m_adv,),
array('m_ID' => $idToUpdate), '' );
return true;
}
Ive never looked to see how wiki stores its image/file information, so your gonna have to do that.
That hook and code will only be called the first time a user visits the forum, so you will have to do alot of testing by creating new users or keep deleting a user entry from the forum sqlTable 'awc_f_mem'.
Im sorry, but i do not have the time right now to make you fully functional code, maybe in the next few days or next week.
[edit]
You still need to have the file edit above for this to work...
http://wiki.anotherwebcom.com/Special:AWCforum/sp/id5749
_
|
|
Edited On 3:42:14 PM - Wednesday 24th, February 2010 by AWC
|
|
|
AWC's:
2.6.0 MediaWiki - Stand Alone Forum Extension Forum theme style by: AWC
|