Quote:
Originally Posted by cheesegrits
Kentaurus ... do you have any kind of standard guidelines for coders who want to support MySmilies in other mods?
-- hugh
|
The code for parsing the smilies is inside bbcode_parse, the routine that vbulletin uses for parsing bbcodes, smilies, and parsing any kind of post content. Most hacks use a call to bbcode_parse, via using a BBcode parser class that is already available or creating a new one.
Because of that, the MySmilies functionality is already there. It's just that it's not being called because the hack needs to know that the userid is, the user that owns the smilies, that is. Since I didn't want to modify the function call to the bbcode_parse functions I used a global variable instead of adding parameters to the function. This is by far not the best design approach, but it is the most flexible since it requires no code modifications.
For any other hack, before your call to bbcode_parse, issue a:
$GLOBALS['mysmiliesvb_userid'] = USERID;
Where userid is the id of the user that owns the smilies. That would vary depending on the context, $vbulletin->userinfo['userid'] holds the user that is currently logged in, but most of the times that's not good, since the custom smilies are user-based then each hack needs to figure out, depending on the context, what user to store in the global variable.
After the bbcode_parse call, I usually do an unset($GLOBALS['mysmiliesvb_userid']). This is not required, it's only polite, to clean up the global variable (since nobody else should be using it after the parsing).
Feel free to PM me if you want me to look at any hack and check if MySmilies could be enabled. Most of the times, if the hack keeps a userid around, it's really easy, and just one line of code.