miniBB Support Forums | 15 years on The Web
miniBB ®

miniBB

®
 
 | Forums | Register | Reply | Search | Statistics | Manual |
Specific miniBB Support Forums / Specific /   
 

How to check duplicated title while starting a new topic.

 
 
Page  Page 1 of 2:  1  2  Next »

Author Guest
#1 | Posted: 18 Dec 2015 04:21 
Hello all!
I'm trying to find a way for avoiding duplicated title while starting a new topic for a closed project. So, if there's a topic titled as "miniBB", another user may not be able to create a topic with exact same title. I'm not great with php but I'm sure it'd be done with a single line code added to bb_func_pthread.php. Is there anyone here to help me? Thanks!

Author kuopassa
Partaker
#2 | Posted: 18 Dec 2015 18:27 | Edited by: kuopassa 
Some SQL query to database should be done when a user is submitting (saving) a new topic, and if similar title already exists... then something should happen. Should the topic not be saved? Or should the title have an incremental number added to the end, like "minibb #2"?

I think the best arrangement would be to have a small plugin that makes using Ajax a query to database when user has typed the title. So when the title is written, the plugin would give a message to the user warning that "this title already exists" or something like that.

Author tom322
Active Member
#3 | Posted: 18 Dec 2015 20:21 
This feature has a good potential as an addon; let the best programmer here (probably kuo) start doing it and maybe Paul will fix it for us as a New Year gift ; ). Just make sure to do it without including the jQuery though; it's not worth just for this single feature. Maybe when a title exists, the input should change to pink color. And/Or by a simple alert('This title already exists; please be more creative!').

It's also important to determine what is a 'duplicated title' - it could be either exactly the same (make sure to ignore special characters, numbers, and letter capitalization in this case) or similar. If similar, a function to check in % how similar it is may be needed. I'd suggest a similar to avoid users adding some 'Lol' or 'Thanks' to the title.

Author Paul
Lead Developer
#4 | Posted: 18 Dec 2015 20:34 | Edited by: Paul 
kuopassa:
I think the best arrangement would be to have a small plugin that makes using Ajax a query to database when user has typed the title. So when the title is written, the plugin would give a message to the user warning that "this title already exists" or something like that.

That's a nice idea, but if you introduce some Ajax tools, keep in mind it will go out of miniBB's free software concepts :)

tom322:
It's also important to determine what is a 'duplicated title' - it could be either exactly the same (make sure to ignore special characters, numbers, and letter capitalization in this case) or similar. If similar, a function to check in % how similar it is may be needed. I'd suggest a similar to avoid users adding some 'Lol' or 'Thanks' to the title.

Yes... that could add more "principles" to this add-on.

I'm out of the office at the moment, but as I remember, mySQL has a possibility to search by similar text, still a special column type should be introduced for this. Type "mysql similar text" to search, and you will find lots of dedicated results.

Here, the most important question is what you would consider as "duplicated'? If you're about just exact phrases or words, then it could be a simple implementation (but it's easy to tweak on the user's end then, just adding comma or one extra char...). If you're about something what mySQL could provide by similarity, then it's more complicated.

Anyway, it's definitely not about a single line code added to bb_func_pthread.php as you propose. And it shouldn't be added to bb_func_pthread.php, in general, it could be coded at the add-on's level.

It's not an easy add-on, in general, because it needs more coding than you might expect...

Author Batu
Guest
#5 | Posted: 18 Dec 2015 23:30 
I'm OP. What I'm talking about duplicated is only "exact" topic title. It's somehow almost impossible to detect similarity percentage by only words. If it was that easy, Google suggestion'd have been perfect in 2015, right? :)
What should happen after detecting similarity as kuopassa asked is goes 2 ways in my opinion.
First one is - displaying error like "This topic is already created." or something and blocking user to do this action.
Second is a bit complicated. The script will detect it as duplicated title AND add this topic body as a new reply to existed topic. So there will be no duplicated topic + user will not try to find the existed topic.

Author tom322
Active Member
#6 | Posted: 18 Dec 2015 23:45 
I think you're misinformed - it is surely possible to detect similarity %. If you only want to match the "exact" topic title then I doubt it is worth our time and it would make this addon useless (when adding a '.' or similar to the title suddenly makes it 'not duplicated' then it's good for a 5-year-olds ;). You need to check the suggestions of the experienced users above again since they cover what should be covered in an useful addon.

Author Batu
Guest
#7 | Posted: 19 Dec 2015 00:50 
tom322
Well I need this addon for a closed project so when user is writing something to topic title, my script will suggest something to user by picking a title from a database. (there will be thousands of entry by the way) That's why, avoiding exact title would work for me but yes, you are right about very slight diferences between two titles would break my idea.

Author kuopassa
Partaker
#8 | Posted: 19 Dec 2015 02:22 
I've coded a little plugin that should be placed inside bb_plugins.php. It's here. It works so that when user is saving a new topic that has exactly the same title as an existing topic, then user's message will be saved to the end of that existing topic. This will work with MySQLi connection. Maybe Paul or someone who knows PHP could improve it...

Author Batu
Guest
#9 | Posted: 19 Dec 2015 11:30 
kuopassa
Wow, that was quick! Thank you, but I had no chance to try this because I'm not at home. I'll try and reply again as soon as I got back home. Thanks again!

Author kuopassa
Partaker
#10 | Posted: 19 Dec 2015 16:48 
No problem, Batu. The code was just slightly upgraded so that it now updates topic counts etc. better. The code isn't quite perfect yet, especially single quot marks and perhaps other special characters as well in the titles cause problems. The code could be improved, but I have other things to do today. :-)

Author tom322
Active Member
#11 | Posted: 20 Dec 2015 01:02 
It is a good draft, but it doesn't meet miniBB SQL requests (I think ;). Too much code, but maybe Paul will find time to improve it ; )

Author Paul
Lead Developer
#12 | Posted: 20 Dec 2015 19:16 
From my end, specific tasks which go out of miniBB standard engine, could be done for a fee only.

In this case, I couldn't check kuopassa's code right now, but it just should do the following:

- check for existing topic's title
- determine the latest post's ID in this topic
- concatenate the latest post with the newest contents posted
- forward user to this topic and the message in result.

Author Batu
Partaker
#13 | Posted: 20 Dec 2015 21:33 
kuopassa
I tried your code in different circumstances, it works but except the topic contains " - ' - < - > - \ - $ characters.

Author Batu
Partaker
#14 | Posted: 20 Dec 2015 21:57 
Wow, I'm flooding but some cookie problem occured so I could not edit my own post and lost everything I've written so far :)
kuopassa, thanks for the code again but it is not effective enough because of the reason I've explained in previous post. Instead of solving this problem, getting rid of all special characters in topic title would be what I'm exactly looking for. Since I'm looking for a way to prevent duplicated topics, deleting special characters with such as preg_replace function while creating topic would be exactly what I'm looking for. I'm actually trying to create something like urban dictionary and there's nothing to "define" except words builded in plain letters in dictionaries, as we all know :) Plus, forcing user to write all the topic body and topic title in lowercase or doing it on server side would be great feature for my project.
By the way, Paul, I know this is a very out-of-nowhere customisation and most of miniBB users may not need this feature as default, so I'm willing to pay kuopassa for his precious effort. I think this is how it has to be :) Thanks again.

Author kuopassa
Partaker
#15 | Posted: 21 Dec 2015 07:04 
tom322 and Batu: thanks for the feedback. :-) Paul is right, the plugin does basically those four things he listed, but not perfectly as Batu noted. I might be able to assist Batu in that project. My email is: pete(at)kuopassa.com

Page  Page 1 of 2:  1  2  Next » 
Specific miniBB Support Forums / Specific /
 How to check duplicated title while starting a new topic.
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


 ?
You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.

 
 
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
↑ TOP