Status
Not open for further replies.

hornstar

Customer
How would I go about changing things so that instead of the tagging feature checking after the ; it would check after a space?

I have banned spaces in usernames and I am going through all usernames on my site to ensure no one in the past had one. so I feel for my needs the space method would work best.

Thanks.
 
Not everybody takes the same measures as you, though, and it's unfortunately impossible to maintain a number of different delimiters.
 
Yeah, but is there something i can do to manually edit things to make it work as a space or is it way too complicated?
 
To be honest, I don't know. @Deceptor: made the parsing code because I'm rubbish at regular expressions (a kind of programming for doing advanced stuff with text that normal search & replace cannot).
Maybe he can tell you, though I wouldn't count on it because he had enough problems getting the current one to work with strange UTF-8 characters xD
 
Alright fingers crossed then, as my members would love this, they all seem to be doing @username and keep forgetting to close it ^^
 
God Damn Twitter... xD

I wonder if maybe a quick Search and Replace cron job might do the trick for your forum... hmm...
 
If you open/edit /dbtech/usertag/hooks/postdata_presave.php, find:
PHP:
			$find_start = '@';
			$find_end = ';';
Replace with:
PHP:
			$find_start = '@';
			$find_end = ' ';

Edit

Whoops, seems to be more places to change too:
PHP:
$message = preg_replace('/\[\/MENTION\]/i', ';', $message);
Replace With:
PHP:
$message = preg_replace('/\[\/MENTION\]/i', ' ', $message);

PHP:
$message = preg_replace('/@' . preg_quote($username) . ';/i', (($this->registry->options['dbtech_usertag_enableat'] OR !isset($this->registry->options['dbtech_usertag_enableat'])) ? '@' : '') . '[URL=' . $this->registry->options['bburl'] . '/member.php?u=' . $results_r['userid'] . ']' . $username2 . '[/URL]:', $message);
Replace With:
PHP:
$message = preg_replace('/@' . preg_quote($username) . ' /i', (($this->registry->options['dbtech_usertag_enableat'] OR !isset($this->registry->options['dbtech_usertag_enableat'])) ? '@' : '') . '[URL=' . $this->registry->options['bburl'] . '/member.php?u=' . $results_r['userid'] . ']' . $username2 . '[/URL]:', $message);


It should work, but only on new posts or if you re-edit a post :) Let me know if there are any issues.

@Fillip H.: Those start/end variables could link to vboptions?
 
Last edited:
Okay that worked perfect! Thanks.

For anyone that is interested in doing this, you will want to make sure you have spaces banned in your usernames in the registration.

Deceptor just showed me the following:
Add:
Code:
^([a-zA-Z0-9_]+)$
To the vbulletin options -> User Registration Options - > Username Regular Expression
Note: This will ban everything except a-z, A-Z, 0-9 and _
After: Go to your registration page and test it out :)

Also you will then want to check that you have no usernames already registered with spaces in them, to check this you run this query:
Code:
select username from prefix_user where username like '% %'
Just change the prefix.

Hopefully you don't have many or you will be very busy. Myself will be busy for quite some time ^^
 
Last edited:
Thanks for that! I got it sorted and I modified it further. I had been using a mod that wrapped [USER]username[/USER] tags around a username to accomplish the same thing, but it was cumbersome.

So, I edited the script further to wrap those tags around the username instead of the URL tags. The USER tag auto-bolded the username so I didn't have to put in any formatting in the tagging settings.

Code:
$message = preg_replace('/@' . preg_quote($username) . ' /i', (($this->registry->options['dbtech_usertag_enableat'] OR !isset($this->registry->options['dbtech_usertag_enableat'])) ? '@' : '') . '[user]' . $username2 . '[/user] ', $message);

So, since I don't allow users to have any characters except a-z, A-Z, 0-9 and _ in their usernames, I was wondering if it was possible to have the script detect if there is a space, a comma, a period, a colon, or semicolon after a username as well.
 
I doubt we'll do that since the search function needs to trail through based on a specific deliminator, having multiple would mean looping that which would increase processing. I think it's best to stick to one format :)
 
Like Deceptor suggested above, in a future version we intend to allow the start / end delimiters to be customisable :)
 
I think I just found a bug because of the way we have this set up now.

Many of my users always use a default color in there posts.

So for many the user tagging is not working because it does not recognise there name, most likely because it is reading the bbcode that is being added. so it thinks:

@username

I am guessing the system thinks the username is: @username[/COLOR]

So I suppose a work around is for the system to look for multiple different types of characters that are regarded as okay to close the name off. eg. [

I see you have this planned for the next update, so having it in the admincp with something like this:
Opening tag character (put a space between each one): @ # !

Closing tag character (put a space between each one): ; : [ ,
Tick the box if you would like a space to be included as a closing tag (read the warning here first). []

But is there any quick fix for myself? Would it be something like this?
PHP:
            $find_start = '@';
            $find_end = ' ', '[';

and

PHP:
$message = preg_replace('/\[\/MENTION\]/i', ' ', '[', $message);

and

PHP:
no idea with this one lol

or am I way off :D


Edit: I found another problem with having the space feature. People are entering instead of spacing -.- so I need the system to now also recognise the enter :D
 
Last edited:
This code uses preg_replace which means it uses regex. Why can't you use a character_class [\s?\.;:,] to match the ending character?
 
We are testing a way to eliminate the need for any delimiters, making it fully like twitter. @dvsDave - see? @hornstar, thought you might want to see too (comma added as punctuation, not as a delimiter :p)
 
Last edited:
Status
Not open for further replies.

Similar threads

Top