Skip to main content
Topic: [ADDON][beta] Topic Prefix (Read 110277 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

Re: [ADDON][beta] Topic Prefix

Reply #76

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.
Last Edit: January 31, 2021, 05:20:16 am by radu81
sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #77

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?
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][beta] Topic Prefix

Reply #78

my mistake, not in topic view, but in topic list

Re: [ADDON][beta] Topic Prefix

Reply #79

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.
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][beta] Topic Prefix

Reply #80

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
sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #81

Heck, that's embarrassing...
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][beta] Topic Prefix

Reply #82

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
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][beta] Topic Prefix

Reply #83

@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:
Screenshot_2021-02-08_12-37-00.png

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)
Screenshot_2021-02-08_12-41-39.png Screenshot_2021-02-08_12-42-22.png

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

    The database value you're trying to insert does not exist: new_prefix
    Function: runQuery
    index.php?action=post2;start=0;msg=4;c120S8EG=64c120uWgzEiG4oG71d9vXmwSJ0wSIEg;board=1
    File:/sources/subs/TopicPrefixTcCRUD.class.php
    Line: 185
Last Edit: February 08, 2021, 07:52:38 am by radu81
sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #84

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!

Re: [ADDON][beta] Topic Prefix

Reply #85

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]



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

    The database value you're trying to insert does not exist: new_prefix
    Function: runQuery
    index.php?action=post2;start=0;msg=4;c120S8EG=64c120uWgzEiG4oG71d9vXmwSJ0wSIEg;board=1
    File:/sources/subs/TopicPrefixTcCRUD.class.php
    Line: 185
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:


:P
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][beta] Topic Prefix

Reply #86

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:
  • Type of error: Undefined
  • /index.php?action=admin;area=logs;sa=errorlog;desc;filter=message;value=Tm90aWNlOiBVbmRlZmluZWQgaW5kZXg6IGRlbnlcX2JvYXJkc1xfYWNjZXNz
  • Notice: Undefined index: deny_boards_access
  • File: /themes/default/TopicPrefix.template.php
  • Line: 80

sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #87

Sorry if I insist on this, but is there a way to see the topic prefix on "New Posts" and "New Replies" lists?
sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #88

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: }
sorry for my bad english

Re: [ADDON][beta] Topic Prefix

Reply #89

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);
}