ElkArte Community

Extending Elk => Addons => Topic started by: emanuele on May 14, 2014, 06:06:12 pm

Title: [ADDON][beta] Topic Prefix
Post by: emanuele on May 14, 2014, 06:06:12 pm
Topic Prefixes v0.0.3
Introduction
This addons introduces (guess what?) the topic prefixes feature.
Each topic can be "tagged" with a prefix that will be displayed next to the subject of the topic in several places around the forum.
The admin can create new prefixes and can apply custom styles to them (there is a simple web-interface for that, but it works only for the default theme of the board, and only if the "custom.css" file is present in the root of the theme).

The current version (v0.0.3) is still a beta, some things are not yet implemented (permissions) and others may be broken.

Currently working features are:
adding/modifying prefixes to a topic
showing prefixes in some places (MessageIndex and Display)
list of topics with a certain prefix
list of prefixes present in a certain board (above the list of messages)
filter topics in a board by prefix (based on the list of prefixes in the board)
admin interface to actually create and edit prefixes

Missing for first release:
list of all prefixes (I'm working on that)
permissions
show prefixes "everywhere"

Future plans:
multiple prefixes per topic
merge with tags addon with a switch to decide if a tag is a prefix or a tag or something like that?
any suggestion that would come up in the topic

If you are comfortable with development you are welcome to give your contribution! (In that case feel free to adapt the headers of the files accordingly.)

The repo is here at the moment:
https://github.com/emanuele45/TopicPrefix


License
o This ElkArte Addon is subject to the terms of the BSD "3-clause" license. You can obtain a copy of the License at http://opensource.org/licenses/BSD-3-Clause

Repository / Download
Title: Re: [ADDON][W.I.P.] Topic Prefix
Post by: Allan on May 14, 2014, 06:41:42 pm
Great work, would there be a way to style the prefixes from the acp.
Title: Re: [ADDON][W.I.P.] Topic Prefix
Post by: meetdilip on May 15, 2014, 01:48:13 am
This deserves a like  8)
Title: Re: [ADDON][W.I.P.] Topic Prefix
Post by: emanuele on May 15, 2014, 02:40:47 am
Quote from: Allan – Great work, would there be a way to style the prefixes from the acp.
I'm not yet sure.
TBH, I still have to find a proper way to solve the "theming issue" on any addon. The main problem I have in mind, is that I'd have to:
It looks like a lot of stuff to deal with for the users that want to style their own theme.

TL;DR: tes, I would do it, though "in a while".
At the moment the addon relies on an external css (rather simple for the start), and I think custom.css can be modified using the theme editor (even if the file doesn't exist? hmm... that may be a sort of bug, to be tracked.)
Title: Re: [ADDON][W.I.P.] Topic Prefix
Post by: Allan on May 15, 2014, 10:34:03 am
Quote from: emanuele – TL;DR: tes, I would do it, though "in a while".
At the moment the addon relies on an external css (rather simple for the start), and I think custom.css can be modified using the theme editor (even if the file doesn't exist? hmm... that may be a sort of bug, to be tracked.)

Even being able to custom in css is great. This way user could add colors, borders, images to fit there needs.
Title: Re: [ADDON][W.I.P.] Topic Prefix
Post by: emanuele on November 10, 2014, 05:57:17 pm
First beta released. :D

The code is still messy and some features are missing, though if anyone has some time for testing it out and see what I missed as usual would be great! ;D
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on November 11, 2014, 02:24:26 am
I get an error when I try to install it

10.   Estrai File   ./themes/default/scripts/TopicPrefix.js   Errore durante il parsing della modifica

after click to continue

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 'NOT NULL auto_increment,
prefix varchar(30) NOT NULL default '',
id_boards' at line 3
File: ******sources/database/DbTable-mysql.php
Riga: 174

Nota: la versione del tuo database è 1.0.1.
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on November 11, 2014, 03:36:15 am
And I even wrote the package-info yesterday night...
I also likely forgot to add the tables to the install.

Big fail. :-[
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on November 11, 2014, 06:04:02 am
Updated the package with the fixes and a couple of new features. ;D
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on November 14, 2014, 04:09:13 am
I just test it, but when I click filter I get double prefix. I attach an image

maybe is my installation which was first broken, I'll try on a fresh install
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on November 14, 2014, 05:25:35 am
At least is works! :P LOL

Interesting, I have to figure out how it is possible...
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 25, 2015, 04:30:08 pm
Some screeshots of the admin panel.
You can also see the "style picker" in a javascript/ajax-like version with a "live preview" of the result.
The main listing (screen_352) actually is not yet really in the final version, the "edit" buttons should disappear or become "advanced", I'm not yet sure.
Title: Re: [ADDON][beta] Topic Prefix
Post by: meetdilip on January 25, 2015, 04:37:09 pm
Cool !
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 25, 2015, 05:54:29 pm
I'll sure test this addon, thanks Emanuele!
Title: Re: [ADDON][beta] Topic Prefix
Post by: Mstcool on January 25, 2015, 10:32:25 pm
Yo, why don't yall add this mod to this support sit? It'll make it easier for yall to know whether a support topic is solved or not. ;P
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 26, 2015, 02:33:14 pm
There is also a "mark solved" addon as well. :D

It would be cool a "right answer" (question&answer-like) addon. O:-)
Title: Re: [ADDON][beta] Topic Prefix
Post by: Mstcool on January 27, 2015, 08:10:11 am
But a mark solved is soo mainstream. Make it something unique ;p

Oh, yeah, you can make it right answer. But it depends on who can mark it as a right answer because everyone's gonna mark their own threads as a right answer, whether it is right or no. :P
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 27, 2015, 08:26:18 am
I think the biggest challenge with the "right answer" is that frequently it's not a single answer the "right one", but a combination of multiple... :-\
Title: Re: [ADDON][beta] Topic Prefix
Post by: Mstcool on January 28, 2015, 03:55:16 am
Omg, a cool thing would be that with every post, there is a button called "right answer" or something like that. And when you click on it, it adds that exact post (as a quote) into one main post. So the one main post can have all the combinations of right answers, in one answer. But wouldn't this feature be hard to implement?
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 30, 2015, 06:42:37 pm
Yep, that could be idea too.
It wouldn't be much more difficult than a single answer, it may make the first post (or the corresponding area) a bit long depending on how many answers are picked. lol

A kind of more flexible solution, could be to pick one answer and then make that a sort of "wiki-article" where people can extend and improve it (well nothing too new because I think stackoverflow works somehow like that).
Title: Re: [ADDON][beta] Topic Prefix
Post by: Mstcool on January 31, 2015, 07:27:02 am
Quote from: emanuele – Yep, that could be idea too.
It wouldn't be much more difficult than a single answer, it may make the first post (or the corresponding area) a bit long depending on how many answers are picked. lol

A kind of more flexible solution, could be to pick one answer and then make that a sort of "wiki-article" where people can extend and improve it (well nothing too new because I think stackoverflow works somehow like that).

So like a best answer kinda thing? In which you allow people to edit. :P
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 31, 2015, 08:12:19 am
Yep.
Of course with tracked changes.

/me thinks it's about time to split the topic. :P
Title: Re: [ADDON][beta] Topic Prefix
Post by: Mstcool on January 31, 2015, 09:41:08 am
Oh, Ok. That's cool :P
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 05, 2017, 02:34:43 pm
Quote from: emanuele – Some screeshots of the admin panel.
You can also see the "style picker" in a javascript/ajax-like version with a "live preview" of the result.
The main listing (screen_352) actually is not yet really in the final version, the "edit" buttons should disappear or become "advanced", I'm not yet sure.
Emanuele will you release this version? Last time I installed this addon it was different from the screenshots you published
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 05, 2017, 06:03:53 pm
Pretty awesome! (If I'm allowed to say something like this to myself LOL)
If you download the "master" from github (the green button "clone or download" here (https://github.com/emanuele45/TopicPrefix) and then "download") should have all that admin panel.
TBH I'm not sure any more why I didn't pack it, so it may have bugz!... well, even the other may have pretty awesome bugs, so it doesn't really matter that much I guess. lol
Title: Re: [ADDON][beta] Topic Prefix
Post by: Jorin on January 06, 2017, 01:30:58 am
Will there ever be a bug free version?  ;)

@radu81: Did you experienced any problems with this addon?

Edit: Is it possible to move the "filter by prefix"-list in the theme, so it will be part of the standard filter list of the topic, where I can filter by topic name, date, author, etc.?
Title: Re: [ADDON][beta] Topic Prefix
Post by: Jorin on January 06, 2017, 02:22:09 am
Found a few bugs already!  :D

When I define the css of a prefix in the admin section the changed prefix is copied, I have two with the same name now, but the CSS change (I changed the background-color) is not shown anywhere.

And when I change the boards the prefix is shown in, the prefix is copied too!

And where can I delete the double (false) prefix? No option for that. De-selecting all boards the prefix is shown in leads to an error message.  :o

And: In one board the buttons have no background and border, in another board they have (in boardindex).

Since the installation of the addon I can't use the quick edit anymore. I can quickedit a post, but I can't save it then. Nothings happening when I click on "save", the editor is still shown, the edit is not saved.

Conclusion: It seems every change in the prefixes (no matter what changes) copies them. Plus there are design flaws and quickedit isn't functioning anymore!  :o  >:(

I have to deinstall the addon...  :(
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 06, 2017, 05:51:12 am
Ohh... that may be the reason I didn't make a release with this new interface... :-[
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 06, 2017, 06:02:33 am
Quote from: Jorin – Will there ever be a bug free version?  ;)

@radu81: Did you experienced any problems with this addon?
I only installed and did some quick tests in localhost, I should install the new version and test it
Title: Re: [ADDON][beta] Topic Prefix
Post by: Trekkie101 on January 06, 2017, 05:01:08 pm
Core feature 1.2 great idea.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 12, 2017, 11:12:02 am
Quote from: emanuele – If you download the "master" from github (the green button "clone or download" here (https://github.com/emanuele45/TopicPrefix) and then "download") should have all that admin panel.
I just tried that but I still see the old version

edit: it was not a clean install, I uninstalled the old version, I removed the old package and installed the new version
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 05, 2018, 08:41:44 pm
I vote for this!
In the meantime @emanuele‍ do you have any plans to update this for elkarte 1.1?
Title: Re: [ADDON][beta] Topic Prefix
Post by: ahrasis on January 05, 2018, 08:46:09 pm
This is an addon I have overlooked. I vote for this as a feature too.
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 06, 2018, 12:31:22 pm
Quote from: radu81 – In the meantime @emanuele‍ do you have any plans to update this for elkarte 1.1?
I guess that means it doesn't work, right? xD
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 06, 2018, 12:46:23 pm
I installed the add-on on Elkarte 1.1 using the emulating mode, but when I go to ACP -> Post and topic -> Prefixes I get this error:

(Link-5386)

In error logs of elkarte I see:

Code: [Select]
Type of error: General
Warning: filemtime(): stat failed for /themes/default/scripts/TopicPrefix.js
http://test.sss.ovh/skoda/index.php?action=admin;area=postsettings;sa=prefix;S8pcnEv=gZotfnpY7AtFRo6iANOV9aBvpMFwjjL2
File: /sources/SiteCombiner.class.php
Line: 348
Title: Re: [ADDON][beta] Topic Prefix
Post by: ahrasis on January 06, 2018, 06:06:46 pm
Quote from: emanuele –
Quote from: radu81 – In the meantime @emanuele‍ do you have any plans to update this for elkarte 1.1?
I guess that means it doesn't work, right? xD
He means "please update this @emanuele." :D
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 08, 2018, 07:07:27 am
Quote from: radu81 –
Code: [Select]
Type of error: General
Warning: filemtime(): stat failed for /themes/default/scripts/TopicPrefix.js
http://test.sss.ovh/skoda/index.php?action=admin;area=postsettings;sa=prefix;S8pcnEv=gZotfnpY7AtFRo6iANOV9aBvpMFwjjL2
File: /sources/SiteCombiner.class.php
Line: 348

Ohh... that's easy: I forgot to put the TopicPrefix.js file in the package-info.xml and so it's not copied into the theme. O:-)
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 08, 2018, 08:34:32 am
Ok, downloaded the .js file from github and uploaded to themes/default/js and I am able to access the Prefixes in ACP. I am able to add prefixes and assign them to a board, but if I edit a topic and assign a prefix I get this error:

count(): Parameter must be an array or an object that implements Countable

In elkarte logs I have 2 errors:
Code: [Select]
Type of error: General
Warning: count(): Parameter must be an array or an object that implements Countable
File: sources/subs/TopicPrefixTcCRUD.class.php
Line: 209
and:
Code: [Select]
Type of error: Non specificato
Notice: Undefined index: is_first_post
iindex.php?action=quotefast;quote=66659;modify;xml
File: sources/TopicPrefix.integrate.php
Line: 77

Another error: when you edit a prefix, the custom css is not saved.
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on March 11, 2018, 12:47:56 pm
Uploaded a version that should fix all these little bugs.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 11, 2018, 06:17:36 pm
Thanks for watching into this, there is still an old bug that editing a prefix will get a copy of that prefix.
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on March 11, 2018, 07:08:06 pm
O:-)

I forgot it was the prefixes, I thought it was another addon...
Title: Re: [ADDON][beta] Topic Prefix
Post by: Jorin on October 26, 2018, 01:40:42 am
Quote from: ahrasis – This is an addon I have overlooked. I vote for this as a feature too.

+1!  ;)
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on October 30, 2018, 03:57:29 am
@emanuele‍ I know you are busy writing the SEF part for Elkarte, but when you get some free time please have a look at this add-on.

Quote from: radu81 – there is still an old bug that editing a prefix will get a copy of that prefix.

Also will be nice to see an option under the Quick moderation so you can apply prefixes from board view to multiple topics. This will be useful for an old forum with some topics.
 
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 06, 2020, 07:02:27 pm
Some time ago @vbgamer45‍ made some edits and corrected some bugs on this add-on, @emanuele‍ maybe you want to merge them
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 07, 2020, 03:29:32 am
I started using this add-on but it's still buggy.

The big bug is that a prefix cannot be edited, if you go to topic view and click "Edit" there is no prefix displayed, if I change the prefix I get The database value you're trying to insert does not exist: new_prefix.

(Link-6402)
In the image above there are 2 ways to select a prefix, clicking in prefix list (1) or near a topic title (2)
The first one will get you to /index.php?action=prefix;sa=prefixedtopics;id=2;board=12
The second one to /index.php?action=prefix;sa=prefixedtopics;id=2
Don't know if this is intended...
If you click the first link the breadcrumb looks like this:
(Link-6404)
If I click where the red arrow is I get a database error:
Too few arguments to function TopicPrefix_PxCRUD::count(), 1 passed in sources/subs/TopicPrefixPxCRUD.class.php on line 38 and exactly 2 expected

Second scenario, link /index.php?action=prefix;sa=prefixedtopics;id=2 which I guess displays all topics from all boards
(Link-6406)
if I click the right arrow I get
Too few arguments to function TopicPrefix_PxCRUD::count(), 1 passed in /public/sources/subs/TopicPrefixPxCRUD.class.php on line 38 and exactly 2 expected
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 09, 2020, 07:28:45 am
Another problem with this add-an, @emanuele‍ don't hate me ;D
In topic list, if you select a prefix and there is more than one page of topics with the same prefix, the link to page number is not working
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 13, 2020, 10:31:47 pm
Still very much a [WIP] but here are some updates ... this is for 1.1 only.  This is for testing and bug feedback only.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 14, 2020, 05:21:48 pm
Thanks for your help Spuds!
This add-on is getting better, tomorrow I will report a couple of small bugs ;) one is this:
Quote from: radu81 – In topic list, if you select a prefix and there is more than one page of topics with the same prefix, the link to page number is not working

 probably "board view" is more appropriate than "topic list"
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 14, 2020, 07:19:31 pm
Cool ... find them and I'll try to fix them.  The page index is now fixed on my local
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 16, 2020, 10:31:25 am
Latest updates, this should have the page issue fixed and added the delete function to the ACP plus some tweaks here and there.  Again 1.1 only

ETA: updated package in follow on posts
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 18, 2020, 04:56:27 am
Sorry for the late reply, I had a very busy week. I installed and tested the add-on, here is what I found:
I have this scenario:  10 prefixes, all applied to a few boards.

1.
If I go to a board and select a prefix from the list, I see correctly the first page with filtered topics, but I also get the page number to see other pages. The page number should not be present since there are less than 10 topics with that prefix from that board. If I click on next page I get the other topics with the same prefix but from other boards. 
Here a screenshot, as you can see there are only two topics with selected prefix, and I get seven pages of results.
(Link-6413)

2.
In board view, if I select a prefix from a topic (see the red arrow) I get as results topics from all boards:
(Link-6415)

3.
Imho the links from prefixes should all have the "nofollow" attribute, this is not a bug and I could add it myself. Don't know if this was intended or not.

4.
I get a few errors in Elkarte log:

Guest
Type: Not specified
Notice: Undefined index: view_num_guests
/index.php?action=prefix;sa=prefixedtopics;id=12
/public/themes/default/MessageIndex.template.php
Line: 85

Member
Tipo di errore: Non specificato
Notice: Undefined index: is_first_post
/index.php?action=quotefast;quote=233513;xml;pb=message;mode=0
/public/sources/subs/TopicPrefix.class.php
Line: 55

The second error has "action=quotefast" which could be related to Quick quote add-on https://www.elkarte.net/community/index.php?topic=3456.0

I also see that you corrected some bugs like the prefix not set when editing the first post of a topic and I confirm is working fine. Not tested the red icon "Delete" prefix since it's in my live forum.

Thanks again for watching this add-on Spuds.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 19, 2020, 01:49:05 pm
Quote from: radu81 – 1.
If I go to a board and select a prefix from the list, I see correctly the first page with filtered topics, but I also get the page number to see other pages. The page number should not be present since there are less than 10 topics with that prefix from that board. If I click on next page I get the other topics with the same prefix but from other boards.
Here a screenshot, as you can see there are only two topics with selected prefix, and I get seven pages of results.
[attach type=thumb]6413[/attach]
I could not repo this one ... but I could have been doing things wrong as well.  Please also check your topic_prefix table and make sure there are not duplicate topics, I did see that happen on my local but I thought it was a debug/testing issue.

The only way you should see multiple boards listed is when you select the "Prefix List" from the bread crumbs, for there you can list all topics, across boards, that a prefix was used on.  Once in a board the filtering should be for that board only.
Quote from: radu81 – 2.
In board view, if I select a prefix from a topic (see the red arrow) I get as results topics from all boards:
[attach type=thumb]6415[/attach]
This should be fixed now
Quote from: radu81 – 3.
Imho the links from prefixes should all have the "nofollow" attribute, this is not a bug and I could add it myself. Don't know if this was intended or not.
No opinion either way, but I added them ;)
Quote from: radu81 – 4.
I get a few errors in Elkarte log:

Guest
Type: Not specified
Notice: Undefined index: view_num_guests
/index.php?action=prefix;sa=prefixedtopics;id=12
/public/themes/default/MessageIndex.template.php
Line: 85

Member
Tipo di errore: Non specificato
Notice: Undefined index: is_first_post
/index.php?action=quotefast;quote=233513;xml;pb=message;mode=0
/public/sources/subs/TopicPrefix.class.php
Line: 55

The second error has "action=quotefast" which could be related to Quick quote add-on https://www.elkarte.net/community/index.php?topic=3456.0
The first one should be fixed now


Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 19, 2020, 05:29:41 pm
There is something wrong with the version you just posted, I got a db error when I try to enter in a board or view a topic, I get a white screen with this message:
Code: [Select]
  Fatal error: Uncaught Elk_Exception: The database value you're trying to insert does not exist: group_list in /....//public/sources/database/Db-abstract.class.php:404 Stack trace: #0 /....//public/sources/database/Db-abstract.class.php(102): Database_Abstract->error_backtrace('The database va...', 'The database va...', 256, '/srv/users/serv...', 1231) #1 [internal function]: Database_Abstract->replacement__callback(Array) #2 /....//public/sources/database/Db-mysql.class.php(180): preg_replace_callback('~{([a-z_]+)(?::...', Array, '\n\t\tSELECT b.id_...') #3 /....//public/sources/Security.php(1231): Database_MySQL->query('', '\n\t\tSELECT b.id_...', Array) #4 /....//public/sources/subs/Moderation.subs.php(250): boardsAllowedTo(Array) #5 /....//public/themes/default/Theme.php(847): loadModeratorMenuCounts() #6 /srv/users/serverpilot/apps/sko in /....//public/sources/database/Db-abstract.class.php on line 404
I removed the full path to my forum

In elkarte log I have:
Type of error: Critical
Database error, given array of integer values is empty. (current_topic)
Function: topicAttribute
/index.php?topic=1688.msg233434;topicseen
File: /sources/subs/Topic.subs.php
Line: 1962

== edit ==
I checked the table topic_prefix and there are no duplicates (exported in csv then checked with Libreoffice Calc)
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 19, 2020, 05:58:13 pm
Replace your TopicPrefix.class.php file (in subs) with this one and see if that clears it up.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 19, 2020, 06:11:21 pm
I did, but nothing changed, I got the same error.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 19, 2020, 07:20:25 pm
Well that makes no sense .... I protected that function, maybe its some stupid PHP level issue, try this one.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 20, 2020, 02:46:36 am
The same problem ::)
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 20, 2020, 09:41:43 am
Well TBH at the moment I can't see how that is even possible ... I've removed the package since its broken, but I'm not seeing any errors on my install sooooo I'm at a dead end.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 20, 2020, 11:59:51 am
I really don't know ::)
If could be useful, I can setup a test forum, and give you access.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 20, 2020, 12:09:34 pm
I think I found it .... its a stupid error made when editing the MessageIndex.controller.php

Open that file and go to line 714 ... you should see a } ... just delete that as there are 1 to many now.

I've attached a new version which fixes the above error, so uninstall, delete and use this package instead.  It has a couple of the other improvements as well.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 20, 2020, 03:32:18 pm
Yep, I confirm that the version you just posted solves my problem 8)

But the problem I mentioned at post n° 50 (https://www.elkarte.net/community/index.php?topic=1424.msg40535#msg40535)is still present. To explain it better you can see it in my live forum.
Go to skodaclub.it/index.php?board=12.0
as you can see there are less than 30 topics
if on that board you select first prefix called "motore" (link skodaclub.it/index.php?action=prefix;sa=prefixedtopics;id=1;board=12 ) you will see that there are only 2 topics with that prefix, but there are also 7 pages available. If you click on page 2 (link skodaclub.it/index.php?action=prefix;sa=prefixedtopics;id=1.%1$d;start=15 ) you will see a list of topics with the same prefix called "motore" but from other boards.
(Link-6413)
I don't know if this is intended or not, I hope not  ::)

=== edit ===
I think I found another one, If I have a topic with a prefix, and I edit the first post choosing "no prefix" and save, I still see the old prefix applied.
On the same topic if I try to change the prefix editing the first post I get an error "The database value you're trying to insert does not exist: new_prefix". In elkarte log I see:
Type of error: Critical
The database value you're trying to insert does not exist: new_prefix
Function: runQuery
File: /sources/subs/TopicPrefixTcCRUD.class.php
Line: 84

IIRC this was working on the previous version, but I'm not 100% sure.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 20, 2020, 05:56:52 pm
I see that .... humm .... Well thats a bit of a bugger.  Clearly a glutton for punishment so try this.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 20, 2020, 06:05:05 pm
Quote from: radu81 – === edit ===
I think I found another one, If I have a topic with a prefix, and I edit the first post choosing "no prefix" and save, I still see the old prefix applied.
Just did this on my local and the prefix was removed as expected :(
Quote from: radu81 – On the same topic if I try to change the prefix editing the first post I get an error "The database value you're trying to insert does not exist: new_prefix". In elkarte log I see:
Type of error: Critical
The database value you're trying to insert does not exist: new_prefix
Function: runQuery
File: /sources/subs/TopicPrefixTcCRUD.class.php
Line: 84

IIRC this was working on the previous version, but I'm not 100% sure.
That error I also see  :'(
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 20, 2020, 06:12:53 pm
It's getting better with every update, I confirm that the problem with page numbers and topics from other boards is now solved. 8)

For the other error I am almost sure it worked on the previous version. Thanks again for your help.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 20, 2020, 06:49:44 pm
Quote from: radu81 – It's getting better with every update, I confirm that the problem with page numbers and topics from other boards is now solved. 8)

For the other error I am almost sure it worked on the previous version. Thanks again for your help.
I almost think I'm spinning my wheels LOL, glad you think its getting better.  Here is a version that should fix the removing / editing of prefixes from the post page.

ETA: Updates Below
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 20, 2020, 08:22:48 pm
I confirm, changing or removing the prefix from first post edit is working fine now. 8)
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 21, 2020, 05:19:22 pm
Spuds, don't hate me, but I found another one ::)
To replicate it:
- go to skodaclub.it/index.php?board=19.0
- choose the first prefix called "motore"
- you will see 3 pages of results and that should be correct
- click on page 2, you will get a page without topics, and the total pages are now 8 (8 pages of results are probably all topics from all boards with that prefix)
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 28, 2020, 07:38:45 pm
And once more .... I did find a couple of additional issues that were certainly causing pagination issues .... could be more though !
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 29, 2020, 06:26:38 pm
I thought you forgot about this :D  I confirm that the last bug is gone now, thanks again for your help.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on January 29, 2020, 06:46:05 pm
Quote from: radu81 – I thought you forgot about this :D  I confirm that the last bug is gone now, thanks again for your help.
Nah .. I just had to look away for a short while :D
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on February 12, 2020, 05:24:56 pm
What do you think about adding the prefix in topic view (index.php?topic=x) near to the title and also on the list of unread posts and replies?
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on April 04, 2020, 10:20:54 pm
Quote from: radu81 – prefix in topic view (index.php?topic=x) near to the title

This is working with Light theme, but not with BeSocial, seems there is a little bug reported here. (https://www.elkarte.net/community/index.php?topic=5768.0)

Also in message view I suggest to not display the prefix inside the number views ,but before the title. (The prefix will not be displayed on mobile view since the views are not displayed on mobile)
FIle: TopicPrefix.Integrate.php
Code: [Select]
			$context['num_views_text'] = sprintf($txt['topicprefix_linktree'], topicprefix_prefix_marktup($prefixes[$topic])) . ' ' . $context['num_views_text'];
should became something like
Code: [Select]
			$context['subject'] = sprintf(topicprefix_prefix_marktup($prefixes[$topic])) . $context['subject'];

my code is not  correct, it works but also creates an html error in quick reply (see screenshot). Any suggestion on how to solve this?
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on September 20, 2020, 06:09:06 am
I get some errors in elkarte log using this add-on and PHP 7.3:

Type of error: Undefined
Notice: Undefined offset: 15365
index.php?action=post2;start=0;board=2
File: /sources/subs/TopicPrefixTcCRUD.class.php
Line: 204
Code: [Select]
return $this->deleteByTopicPrefix($id_topic, $current[$id_topic]['id_prefix']);
and there are more similar, same file, same line
Notice: Undefined offset: 15366
Notice: Undefined offset: 15370

Type of error: Undefined
Notice: Undefined index: is_first_post
/index.php?action=quotefast;quote=242607;xml
File: /sources/subs/TopicPrefix.class.php
Line: 55
Code: [Select]
if (!$context['is_first_post'])
This is probably a conflict with Quick Quote add-on (https://www.elkarte.net/community/index.php?topic=3456.0)
Title: Re: [ADDON][beta] Topic Prefix
Post by: JPalmer on September 28, 2020, 04:09:59 pm
Discovered this add-on recently, and would love to use it. After some fiddling I could make it to work with my non-default theme too.

I'm observing the very same error message in the log file:

Undefined offset: ...
File: .../sources/subs/TopicPrefixTcCRUD.class.php
    Line: 204

So far it looks like it doesn't affect the functionality in a bad way. Anyway, thought it would be good to confirm the problem. Please let me know how I could help with more/further information.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 06, 2021, 04:44:01 am
@emanuele‍ I unistalled the add-on and installed the version from github since you update it recently, but that makes the forum unusable, I don't remember exactly the error (it was a white page with an error in TopicPrefix.Integrate.php), I cannot see any topic or admin page, only the index page was working. I had to overwrite the file TopicPrefix.Integrate.php from https://www.elkarte.net/community/index.php?topic=1424.msg40565#msg40565 to make it working again.
Probably the best solution is to update the whole add-on on github using the version provided by Spuds on reply #67 of this topic.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 14, 2021, 06:01:32 pm
https://github.com/emanuele45/TopicPrefix/commit/1914371195520762b3e49453120f6635ed0f5a52
this solves the error in elkarte log, but the prefix disappear if you try to edit the first post
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 31, 2021, 05:11:55 am
Another bug, duplicate prefixes, to reproduce it:
- choose a topic which already have a prefix
- in topc view, select the topic and choose Add prefix, then select a different prefix
- that topic will have now two prefixes into database
- if you try to edit the topic and choose a prefix you will get a database error:
Code: [Select]
Duplicate entry '1-14638' for key 'id_topic_prefix'
File: /public/sources/subs/TopicPrefixTcCRUD.class.php
Riga: 85

Nota: la versione del tuo database è 1.1.1.
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 31, 2021, 03:17:40 pm
Quote from: radu81 – https://github.com/emanuele45/TopicPrefix/commit/1914371195520762b3e49453120f6635ed0f5a52
this solves the error in elkarte log, but the prefix disappear if you try to edit the first post
yeah... it was not !empty, but just empty. facepalm

Quote from: radu81 – Another bug, duplicate prefixes, to reproduce it:
- choose a topic which already have a prefix
- in topc view, select the topic and choose Add prefix, then select a different prefix
I'm a bit lost in that step... where exactly?
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on January 31, 2021, 04:14:59 pm
my mistake, not in topic view, but in topic list
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on January 31, 2021, 06:32:40 pm
Ooohh... that was something I didn't notice it was added and I did not merge into my branch.
I'm playing around with it a bit trying to figure out how to move that code out of MessageIndex.controller.php.
In the meantime, instead of the code:
Code: [Select]
						if (!empty($prefix))
{
$db = database();
$db->insert('ignore',
'{db_prefix}topic_prefix',
array(
'id_prefix' => 'int',
'id_topic' => 'int',
),
array(
$prefix,
$row['id_topic']
),
array('id_prefix', 'id_topic')
);
}

You should be able to use something like this:
Code: [Select]
$prefix = new TopicPrefix();
$prefix_id = (int) $_REQUEST['prefix'];
foreach ($_REQUEST['topics'] as $topic)
{
$prefix->updateTopicPrefix($topic, $prefix_id);
}

Not tested, so it may be broken... okay, let's face reality: knowing myself it is broken.
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on February 01, 2021, 05:51:11 pm
Quote from: emanuele – okay, let's face reality: knowing myself it is broken.
 you're wrong this time, :P  your code seems to work, I did the same procedure mentioned above, the prefix is changed without adding a duplicate into the database. I'll test it better in the next days, probably something else will pop out. :D
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on February 01, 2021, 07:33:17 pm
Heck, that's embarrassing...
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on February 08, 2021, 06:53:09 am
Okay, updated the repo with some code that should allow to have the quick-moderation without requiring code edits.
https://github.com/emanuele45/TopicPrefix/
IIRC it's enough to download and apply, but well, usual disclaimer applies. xD
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on February 08, 2021, 07:45:40 am
@emanuele‍ the version from github is unusable, it has different bugs that Spuds already corrected, please see the latest version posted here https://www.elkarte.net/community/index.php?topic=1424.msg40565#msg40565

I just installed on a test forum the version from github (clean forum with 1.1.7 patch applied), here is what I found:

I have 1 board with 3 prefixes, just click on prefix, prefix2, prefix3 and got this error:
Too few arguments to function TopicPrefix_PxCRUD::count(), 1 passed in sources/subs/TopicPrefixPxCRUD.class.php on line 38 and exactly 2 expected

There is no quick way to add a prefix here:
(Link-6893)

If you click on a prefix that it is not applied to any topic, the prefix list does not have any css applied (in my case p3)
(Link-6895) (Link-6897)

Probably there are more bugs

edit
yep, another one: if I try to edit a topic using the full editor and I set up a prefix, I get this error:
An Error Has Occurred
The database value you're trying to insert does not exist: new_prefix

    Type of error: Critical
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)
    The database value you're trying to insert does not exist: new_prefix
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    Function: runQuery
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    index.php?action=post2;start=0;msg=4;c120S8EG=64c120uWgzEiG4oG71d9vXmwSJ0wSIEg;board=1
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    File:/sources/subs/TopicPrefixTcCRUD.class.php
    Line: 185 (https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on February 08, 2021, 10:05:44 am
No guarantees but I think all the changes I made are here: https://github.com/Spuds/Elk_Topic_Prefix/commits/master I thought I pr'ed those back, but that was a year ago so who knows!
Title: Re: [ADDON][beta] Topic Prefix
Post by: emanuele on February 08, 2021, 03:44:19 pm
Quote from: radu81 – @emanuele‍ the version from github is unusable, it has different bugs that Spuds already corrected, please see the latest version posted here https://www.elkarte.net/community/index.php?topic=1424.msg40565#msg40565
@radu81 the version on github includes anything that is in Spuds' repo (I ported it at the end of December).

Quote from: radu81 – I have 1 board with 3 prefixes, just click on prefix, prefix2, prefix3 and got this error:
Too few arguments to function TopicPrefix_PxCRUD::count(), 1 passed in sources/subs/TopicPrefixPxCRUD.class.php on line 38 and exactly 2 expected
Considering:
https://github.com/emanuele45/TopicPrefix/blob/master/Sources/subs/TopicPrefixPxCRUD.class.php#L38
there is no "count" at line 38 of the current version, I have the feeling you are using an older package for some reason.

Quote from: radu81 – If you click on a prefix that it is not applied to any topic, the prefix list does not have any css applied (in my case p3)
[attach type=thumb]6895[/attach] [attach type=thumb]6897[/attach]
(https://i.imgur.com/uWNZ3j9.png)
(https://i.imgur.com/OUd1zX7.png)

Quote from: radu81 – Probably there are more bugs
Very well possible.

Quote from: radu81 – edit
yep, another one: if I try to edit a topic using the full editor and I set up a prefix, I get this error:
An Error Has Occurred
The database value you're trying to insert does not exist: new_prefix

    Type of error: Critical
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)
    The database value you're trying to insert does not exist: new_prefix
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    Function: runQuery
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    index.php?action=post2;start=0;msg=4;c120S8EG=64c120uWgzEiG4oG71d9vXmwSJ0wSIEg;board=1
(https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)    File:/sources/subs/TopicPrefixTcCRUD.class.php
    Line: 185 (https://www.elkarte.net/community/javascript:window.location.assign(document.referrer);)
And again, line 185 has not that code:
https://github.com/emanuele45/TopicPrefix/blob/master/Sources/subs/TopicPrefixPxCRUD.class.php#L185

Guess this image may help:
(https://i.imgur.com/MgBlpKJ.png)

:P
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on February 08, 2021, 04:02:40 pm
Sorry Ema, github is not for me, guess what version I downloaded? The one with a big red X :-X :-[
https://github.com/emanuele45/TopicPrefix/releases/download/v0.0.3/TopicsPrefix_0-0-3.zip


I just downloaded the correct version, seems to work, I will also install it on my live site. For now I only see an undefined error in elkarte log:

Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on September 24, 2021, 04:37:31 am
Sorry if I insist on this, but is there a way to see the topic prefix on "New Posts" and "New Replies" lists?
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 17, 2023, 10:56:59 am
I know that this add-on is in beta version and somehow abbandoned, and I'm probaly the only one to use it on Elkarte, but here is my problem using PHP 8.1:
When entering a board which does not have prefixes assigned I get this error "Undefined variable $quick_prefixes" and cannot enter the board.

In Elkarte log I got:
    Warning: Undefined variable $quick_prefixes
    File: /sources/TopicPrefix.integrate.php
    Line: 102

Code: [Select]
93: 	// _debug($available_prefixes);
94: if (count($available_prefixes) > 1)
95: {
96: $quick_prefixes = 'var quick_prefixes = [';
97: foreach ($available_prefixes as $id => $value)
98: {
99: $quick_prefixes .= '{"id": ' . $id . ', "text": ' . JavaScriptEscape($value['text']) . '},';
100: }
101: }
102: $quick_prefixes = substr($quick_prefixes, 0, -1) . ']';
103: addInlineJavascript($quick_prefixes);
104: }
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on March 17, 2023, 03:29:48 pm
Try the following:

In TopicPrefix.integrate.php find
Code: [Select]
		if (count($available_prefixes) > 1)
{
$quick_prefixes = 'var quick_prefixes = [';
foreach ($available_prefixes as $id => $value)
{
$quick_prefixes .= '{"id": ' . $id . ', "text": ' . JavaScriptEscape($value['text']) . '},';
}
}
$quick_prefixes = substr($quick_prefixes, 0, -1) . ']';
addInlineJavascript($quick_prefixes);
and replace it with
Code: [Select]
		if (count($available_prefixes) > 1)
{
$quick_prefixes = 'var quick_prefixes = [';
foreach ($available_prefixes as $id => $value)
{
$quick_prefixes .= '{"id": ' . $id . ', "text": ' . JavaScriptEscape($value['text']) . '},';
}

$quick_prefixes = substr($quick_prefixes, 0, -1) . ']';
addInlineJavascript($quick_prefixes);
}
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 18, 2023, 04:28:07 am
Thanks, this seems to work, I've switched back to PHP 8.1.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on March 18, 2023, 09:21:41 am
Awesome.  I noticed another issue when you edit the prefix style.  The existing colors are not loaded correctly, I'll post a fix for that in a bit.
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on March 18, 2023, 05:54:32 pm
Here is a version to test. 

attempted to find all the php8 level issues and fix them (there were several)
fixed the issue where editing a prefix style would loose the color values
attempted to add the prefix to the Recent Message listing and the New Topic listing
some misc stuff
labeled it as version 0.0.6

Give it a test, on a backup site of course !
Title: Re: [ADDON][beta] Topic Prefix
Post by: Steeley on March 18, 2023, 06:11:31 pm
Quote from: Spuds – ...  Give it a test, on a backup site of course !

It's hard to believe anyone running a server should need that reminder... but yea, since the FAA shut down fights across the whole east coast for two days back in early January (by some "contractor" the story goes), patching the production "NOTAM" (Notice To Airmen) server that supplies critical system and airspace flight safety information to pilots and airlines directly..   😧

[hey, who likes updating Cobol anyway?  :tongue: ]
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 20, 2023, 11:35:41 am
I just installed the add-on and seems to work for now, but I did not tested all the functions from ACP.
And yes, I installed it on my live forum :embarrassed: . I do have daily backups and I hope to never use them.
Thanks Spuds for keeping this add-on updated!
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 20, 2023, 11:58:33 am
Quote from: Spuds – attempted to add the prefix to the Recent Message listing and the New Topic listing
I noticed that now! wow, thank you! :cool: 
Title: Re: [ADDON][beta] Topic Prefix
Post by: Steeley on March 20, 2023, 01:46:58 pm
Quote from: radu81 – ..
And yes, I installed it on my live forum :embarrassed: . I do have daily backups and I hope to never use them.
..

You sound like a couple of C++ programmers I know - I've made a special note to never give them fissionable material, because they too know no fear..
😛

(In the FAA's case, they were supposedly trying to "sync the production server back up with the back up server" {take note}, when they crashed the production server.  I strongly suspect the whole thing stemmed from an effort to incorporate a bunch of "woke" changes that were scheduled to be implemented around that same time (renaming "Notice To Airmen" to "Notice to Air Mission", "cockpit" to "flight deck" etc.  Crashing the system is a small price to pay, I assume, to assure nobody might be offended by legacy terms and etymologies they don't understand or can tolerate). 

But you have given Spuds a warm-fuzzy, showing you trust his craftsmanship more than he does..😉
Title: Re: [ADDON][beta] Topic Prefix
Post by: radu81 on March 20, 2023, 04:00:58 pm
To be honest, until a few months ago I always had a copy of my forum as test, and I used to test everything there and not on my live site, but this is a messy period for me [1] and I don't have much time to dedicate. I had to free some space on my VPS and I deleted the tests environments. 
I work 4 days/week and the other 3 days I work in my future house which is in renovation. I really have limited time to dedicate on other activities, just to give an example, last time I turned on the TV was probably for Christmas. When I work at my house I often finish at 8 pm, sometimes even later at 10pm. I also asked the next week as "vacation" but I'm not sure they will accept my request. anyway I hope to finish this year...
Title: Re: [ADDON][beta] Topic Prefix
Post by: Steeley on March 20, 2023, 10:35:55 pm
Long long ago, my grandfather had a sign in the back of his store that said:
Code: [Select]
"How come we never have time to do the task right, but we can find the time to do it over?" 
:undecided:

I think the technical term is "proceeding at risk:.. 🤞🤞
Title: Re: [ADDON][beta] Topic Prefix
Post by: Spuds on March 21, 2023, 10:13:01 am
(Link-10344)