Best Answer

Started by Avalanche91, December 05, 2013, 09:09:24 AM

Previous topic - Next topic

user86


user86


SilverKnight

Great idea for a mod however i believe it needs to have the following support:

Subforums mod
Enable\disable it by forum

This way you can have question\answer forums and it will have multiple forum support.

user86

Quote from: user86 on July 21, 2014, 03:06:19 AM
Hello,

thank you for this very good mod! I'm using it on SMF 1.1.19 but expirience a database error. When restoring deleted post from the recycle bin I get this error message:

Quote
Unknown column 'Array' in 'where clause'
File: /var/www/clients/client0/web1/web/smf/Sources/SplitTopics.php
Line: 991

Here is my code from splittopics.php. I have marked the line causing the error in bold.

// We're off to insert the new topic!  Use 0 for now to avoid UNIQUE errors.
db_query("
INSERT INTO {$db_prefix}topics
(ID_BOARD, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_FIRST_MSG, ID_LAST_MSG, numReplies, isSticky)
VALUES ($ID_BOARD, $split2_firstMem, $split2_lastMem, 0, 0, $split2_replies, $isSticky)", __FILE__, __LINE__);
$split2_ID_TOPIC = db_insert_id();
if ($split2_ID_TOPIC <= 0)
fatal_lang_error('smf273');


// If the best answer was amongst these posts that were moved, we have to move the best best answer as well
$query = db_query("SELECT id, id_msg FROM {$db_prefix}best_answer WHERE id_msg IN ($splitMessages)",
__FILE__, __LINE__);
if (mysql_num_rows($query) == 1) {
$data = mysql_fetch_row($query);
if ($data[1] == $splitMessages[0]) {
// The question cannot be an answer!
db_query(
"DELETE FROM {$db_prefix}best_answer WHERE `id`=$data[0]",
__FILE__, __LINE__
);
} else {
// Now that we are moving stuff, it's time for the best answer to be moved
db_query(
"UPDATE {$db_prefix}best_answer SET ID_TOPIC = $split2_ID_TOPIC WHERE id = $data[0]",
__FILE__, __LINE__
);
}
}
mysql_free_result($query);
$data = null;

// Move the messages over to the other topic.
$new_subject = $func['htmlspecialchars']($new_subject);
db_query("
UPDATE {$db_prefix}messages
SET
ID_TOPIC = $split2_ID_TOPIC,
subject = '$new_subject'
WHERE ID_MSG IN ($postList)
LIMIT " . ($split2_replies + 1), __FILE__, __LINE__);



It's this line of code:

$query = db_query("SELECT id, id_msg FROM {$db_prefix}best_answer WHERE id_msg IN ($splitMessages)",
      __FILE__, __LINE__);


The message get restored. But the error pops up.

Can you please suggest what I should change in order to make it work again? Thank you!

Bump Bump Bump

Rain Forest

Quote from: CHAOS-THEORY on December 15, 2013, 02:51:26 PM
1- Permission to choose specific Boards/Topics to ignor having a bestanswer.

+1

Mr. Jinx

Thanks for this very nice mod. I just installed it on my forum without problems.

Mr. Jinx

Question: If a topic is marked as best answer, it shows the users login name instead of the users display name.
Would it be possible to change this?

Mr. Jinx

Two hotfixes for this fine mod:

Fix 1: Show user's display name instead of login name

$sourcedir/Display.php
Find:
,`ba`.`id`,`ba`.`id_msg`,`ba`.`id_topic`,`ba`.`id_member`,UNIX_TIMESTAMP(`ba`.`time_marked`) AS `time`,`m`.`member_name`
Replace with:
,`ba`.`id`,`ba`.`id_msg`,`ba`.`id_topic`,`ba`.`id_member`,UNIX_TIMESTAMP(`ba`.`time_marked`) AS `time`,`m`.`real_name`

Find:
$context['ba']['member_name'] = $topicinfo['member_name'];
Replace with:
$context['ba']['member_name'] = $topicinfo['real_name'];

Fix 2: Allow Admins,Mods AND GlobalMods to select Best Answer (GlobalMod was not working)

$sourcedir/BestAnswer.php
Find:
if ($context['user']['id'] == $msgInfo['id_member_started'] || ($context['user']['is_mod'] || $context['user']['is_admin'])) {
Replace with:
if ($context['user']['id'] == $msgInfo['id_member_started'] || in_array($user_info['groups'][0], $adminOrModerator)) {

$themedir/Display.template.php
Find:
global $context, $settings, $options, $txt, $scripturl, $modSettings;
Replace with:
global $context, $settings, $options, $txt, $scripturl, $modSettings, $user_info;
$adminOrModerator = array(1, 2, 3); //BestAnswer mod 1=>Admin, 2=>Global Mod, 3=>Mod;


Find:
if (($context['topic_starter_id'] == $context['user']['id'] || $context['user']['is_mod'] || $context['user']['is_admin']) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 0) {
Replace with:
if (($context['topic_starter_id'] == $context['user']['id'] || in_array($user_info['groups'][0], $adminOrModerator)) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 0) {

Find:
if ($context['ba']['id_msg'] != 0 && $context['ba']['id_msg'] == $message['id'] && ($context['topic_starter_id'] == $context['user']['id'] || $context['user']['is_mod'] || $context['user']['is_admin']) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 1) {
Replace with:
if ($context['ba']['id_msg'] != 0 && $context['ba']['id_msg'] == $message['id'] && ($context['topic_starter_id'] == $context['user']['id'] || in_array($user_info['groups'][0], $adminOrModerator)) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 1) {

PLAYBOY

I use Mineral Multicolor theme and I dont have any part of this in my index.template.php


<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" /></a>


where should I make the change? Can someone help please?

PLAYBOY

Can someone please help me on this? I know it hasnt been 24 hours to bump it but it`ll be 24hrs in about 3 hrs :)

I just really need help on this

margarett

Default theme doesn't have it too. Try MessageIndex.template.php
:P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

PLAYBOY

Got it thank you very much

PLAYBOY

This mod doesnt show in Mineral_Multicolor theme. I tried everything but it doesnt show the button nor the writings.

It shows in default theme tho

Kindred

If you didn't do the full theme install, did you remember to copy over all of the images needed for this mod into your custom theme?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

PLAYBOY

Yes, I copied all images and even checked the files for manual modifications. There is one weird problem tho.

Mod is trying to make a code change in messageindex.template.php but the code it`s looking for is actually in display.template.php for my theme. I tried to add the code in both files an still cant see the button or the writing for it.

Also I should mention that it shows fine in Default theme and my forum is in Turkish so there is no language problem there.
If you need I can give any files or codes here

PS: some turkish characters are wrong but I can help on that once I get the mod working for me


PLAYBOY

This mod desperately needs an update. Spend literally 3 day on this and below is the result

- Icons didnt show
- Turkish characters were in wrong encoding
- When you`re installing it shows that it`s still 1.3 version while it shows 1.4 in the mod list
- None of the moderators could participate (this should be added in the permissions for each group so the person could choose who can participate who cant)
- Didnt create a green bar around the best answer while it gives the best answer notice there
- The edit in index.template.php is actually in  MessageIndex.template.php in my theme

Anyways, I really wish this mod could get a good update/upgrade. I`m willing to help with the Turkish part of it.
It`s sad seeing a great idea being wasted like this
Uninstalled


Is there a similar mod I can use?

Mr. Jinx

Quote from: PLAYBOY on March 09, 2016, 08:33:44 PM
- None of the moderators could participate (this should be added in the permissions for each group so the person could choose who can participate who cant)

Did you see my comment (Fix 2)? There was a problem with global mods.

Quote- The edit in index.template.php is actually in  MessageIndex.template.php in my theme
That is weird. You are using SMF 2?
I checked the mod, but doesn't modify index.template.php at all. Maybe you downloaded an old version?

Except the two fixes I mentioned, this mod works great for me.

PLAYBOY

QuoteDid you see my comment (Fix 2)? There was a problem with global mods.

Yes. I applied it manually but that didn`t fix my problem.

Quoteyou are using SMF 2?

Yes. 2.0.11

QuoteI checked the mod, but doesn't modify index.template.php at all.  Maybe you downloaded an old version?

You`re right. I looked at the manual install for 1.3.

It`d be the best if install Mineral Multicolor theme and check it. Cause I`m pretty sure my issues are valid except the index.template.php thing

Mr. Jinx

Update: Added extra security to prevent guests from changing answered/unanswered status. If someone started a topic and that member is deleted, all guests could modify the status of that post.

ps: I can't edit my previous post (?) so I'll have to post this modification again completely instead of editting the previous post.

Two hotfixes for this fine mod:

Fix 1:
Show user's display name instead of login name.

$sourcedir/Display.php
Find:
,`ba`.`id`,`ba`.`id_msg`,`ba`.`id_topic`,`ba`.`id_member`,UNIX_TIMESTAMP(`ba`.`time_marked`) AS `time`,`m`.`member_name`
Replace with:
,`ba`.`id`,`ba`.`id_msg`,`ba`.`id_topic`,`ba`.`id_member`,UNIX_TIMESTAMP(`ba`.`time_marked`) AS `time`,`m`.`real_name`

Find:
$context['ba']['member_name'] = $topicinfo['member_name'];
Replace with:
$context['ba']['member_name'] = $topicinfo['real_name'];

Fix 2:
Allow Admins,Mods AND GlobalMods to select Best Answer (GlobalMod was not working).
Disallow guests from changing best answer!

$sourcedir/BestAnswer.php
Find:
if ($context['user']['id'] == $msgInfo['id_member_started'] || ($context['user']['is_mod'] || $context['user']['is_admin'])) {
Replace with:
if ($context['user']['id'] != 0 && ($context['user']['id'] == $msgInfo['id_member_started'] || in_array($user_info['groups'][0], $adminOrModerator))) {

Find:
if (($msgInfo['id_member_started'] == $context['user']['id']) || in_array($user_info['groups'][0], $adminOrModerator)) {
Replace with:
if ($context['user']['id'] != 0 && ($context['user']['id'] == $msgInfo['id_member_started'] || in_array($user_info['groups'][0], $adminOrModerator))) {


$themedir/Display.template.php
Find:
global $context, $settings, $options, $txt, $scripturl, $modSettings;
Replace with:
global $context, $settings, $options, $txt, $scripturl, $modSettings, $user_info;
$adminOrModerator = array(1, 2, 3); //BestAnswer mod 1=>Admin, 2=>Global Mod, 3=>Mod;


Find:
if (($context['topic_starter_id'] == $context['user']['id'] || $context['user']['is_mod'] || $context['user']['is_admin']) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 0) {
Replace with:
if (($context['topic_starter_id'] == $context['user']['id'] || in_array($user_info['groups'][0], $adminOrModerator)) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 0 && $context['user']['id'] != 0) {

Find:
if ($context['ba']['id_msg'] != 0 && $context['ba']['id_msg'] == $message['id'] && ($context['topic_starter_id'] == $context['user']['id'] || $context['user']['is_mod'] || $context['user']['is_admin']) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 1) {
Replace with:
if ($context['ba']['id_msg'] != 0 && $context['ba']['id_msg'] == $message['id'] && ($context['topic_starter_id'] == $context['user']['id'] || in_array($user_info['groups'][0], $adminOrModerator)) && $message['id'] != $context['topic_first_message'] && $context['isMarkedBest'] == 1 && $context['user']['id'] != 0) {

Adrek


$adminOrModerator = array(1, 2, 3);



in_array($user_info['groups'][0], $adminOrModerator)


is it always going to return false or I'm reading it wrong?
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Advertisement: