News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Thanks for SMF 2.1

Started by GL700Wing, May 19, 2022, 07:25:39 PM

Previous topic - Next topic

GL700Wing

Link to the mod

Thanks for SMF 2.1 - v1.4

This mod is a 'Thanks' version of the 'Likes' feature that is a standard part of SMF 2.1.

For those who want/need a 'Thanks' feature, it provides a consistent look/feel and the same functionality the default SMF 2.1 'Likes' feature.

Notes:
All the source code for this mod is derived from the SMF 2.1 'Likes' system.
Apart from replacing the 'Like' word with the equivalent 'Thank' word the only other source code changes are as follows:
1. Configure an icon for the 'Thank' action/alert and an icon for the 'Unthank' action; and
2. Configure extra spacing to the left of the 'Thank' button in a message if the 'Likes' feature is also enabled.



Release History:
1.0 - 13-May-22
o Initial Release with support only for SMF 2.1.2

1.1 - 26-May-22
o As per this message specified resources in 'db-install.php' to enable mod to install on large forums.
o Fixed bug in './Themes/default/scripts/topic.js' that prevented 'Quick Edit' feature from working.

1.2 - 19-Jun-22
o As per this message fixed issue of incorrect thank/unthank icons being displayed and of thank/unthank text/icon not maintaining left spacing in relation to the like/unlike text/icon.

1.3 - 10-Jun-23
o As per this message fixed issue where clicking on Thank button repeatedly in quick succession generated a database error.
o Updated core and mod files to incorporate changes made in SMF 2.1.4 to inbuilt 'Likes' system.
o Added 'import-thanks.php' script to import 'Thanks'' created by SMF 2.0 'Thank Posts' mod - based on code provided by shawnb61 for importing ''Likes' from SMF 2.0.

1.4 - 19-Nov-23
o As per this report by @Dave J fixed issue that caused '500 internal server error' when trying to view who had liked a post (the same issue also prevented the removal of a thank).
o Made some minor changes to core files that were missed in v1.3 (these changes specifically relate to the adaptation of the inbuilt SMF 2.1.4  'Likes' system to this mod).




License
Copyright 2022-2023 Kathy Leslie

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

gevv

Hi, thanks @GL700Wing

I think it will be very difficult to install in the big forum.

I tried (my pc wampserver) 4 minutes later, the white page opened,

index.php?action=admin;area=packages;sa=install2;package=Thanks_for_SMF21_v1.0.zip;pid=0

the mod was not installed (didn't create error log)

ElkArte is a modern, powerful community building forum software. https://www.elkarte.net/

GL700Wing

Quote from: gevv on May 20, 2022, 03:00:49 PMI think it will be very difficult to install in the big forum.

I tried (my pc wampserver) 4 minutes later, the white page opened,

index.php?action=admin;area=packages;sa=install2;package=Thanks_for_SMF21_v1.0.zip;pid=0

the mod was not installed (didn't create error log)
The mod installation makes some database changes (ie, creates the 'user_thanks' table, adds a 'thanks' column and index to the 'messages' table, and adds a 'msg_thank' row to the alerts table) and I suspect that on a large forum  a timeout is occurring then the 'messages' table is being updated.

I've attached a replacement db_install.php file to which I've added the following lines before any changes are made to the database:
// Secure some resources
@set_time_limit(600);
@ini_set('mysql.connect_timeout', -1);
@ini_set('default_socket_timeout', 900);
@ini_set('memory_limit', '512M');

I've used the same values that are in the 'upgrade'php' file that is run when a forum is upgraded from SMF 2.0 to SMF 2.1 - you may need to adjust these values if you used different values when upgrading or if you still get timeout issues when installing this mod (you may need to check/adjust the corresponding timeout values configured in cPanel as well).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

gevv

Thanks @GL700Wing  Adding code worked. It took a while, but it was installed and working without any problems.
ElkArte is a modern, powerful community building forum software. https://www.elkarte.net/

GL700Wing

#4
Version 1.1 - 25-May-22
o As per this message specified reources in 'db-install.php' to enable mod to install on large forums.
o Fixed bug in './Themes/default/scripts/topic.js' that prevented 'Quick Edit' feature from working.


Note: Upgrade option for v1.0

@gevv - FYI
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

Will this give an alert like the 'like' feature?
DO NOT pm me for support unless asked to!

GL700Wing

Quote from: Steve on June 18, 2022, 01:28:48 PMWill this give an alert like the 'like' feature?
Yes.

All the source code for this mod is derived from the SMF 2.1 'Likes' system.
Apart from replacing the 'Like' word with the equivalent 'Thank' word the only other source code changes are as follows:
1. Configure an icon for the 'Thank' action/alert and an icon for the 'Unthank' action; and
2. Configure extra spacing to the left of the 'Thank' button in a message if the 'Likes' feature is also enabled.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

I read all that in your initial post lol ... just wanted to be sure it gave an alert. Thanks GL.  :)
DO NOT pm me for support unless asked to!

GL700Wing

Quote from: Steve on June 18, 2022, 07:10:40 PMI read all that in your initial post lol ... just wanted to be sure it gave an alert. Thanks GL.  :)
Yep - I have tested and confirmed that the alerts are generated!
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

It installed without a hitch and works but there a couple of issues.

The 'Thank' icon and text move when clicked and again when unthanked. A refresh shows it in the original position.

If you click 'Thank', then 'Unthank', then 'Thank' again, another refresh is needed to show it in the correct spot instead right next to 'Like'.

When 'Thank' is clicked a thumb down appears in order to unthank. However, if you refresh after clicking 'Thank', the thumb down becomes a red x.

It's getting late so I can give you screenshots of what I'm talking about in the morning if you want them.
DO NOT pm me for support unless asked to!

GL700Wing

#10
Quote from: Steve on June 18, 2022, 07:41:52 PMIt installed without a hitch and works but there a couple of issues.

The 'Thank' icon and text move when clicked and again when unthanked. A refresh shows it in the original position.

If you click 'Thank', then 'Unthank', then 'Thank' again, another refresh is needed to show it in the correct spot instead right next to 'Like'.

When 'Thank' is clicked a thumb down appears in order to unthank. However, if you refresh after clicking 'Thank', the thumb down becomes a red x.

It's getting late so I can give you screenshots of what I'm talking about in the morning if you want them.
Thanks for the feedback.

The icons for the 'thank'/'unthank' actions are a tick and a cross/X so I don't understand why the thumb up/down icons are coming into play or why a refresh is sometimes needed for stuff to display correctly.  These issues didn't occur when I was testing the mod but it could be related to a different browser/OS to what I'm using - I'll have to check the Javascript again ...

PS:  Confirmed and found cause of thumbup/thumbdown  icon issue and text/icon moving - working on a fix now ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

Version 1.2 - 19-Jun-22
o As per this message fixed issue of incorrect thank/unthank icons being displayed and of thank/unthank text/icon not maintaining left spacing in relation to the like/unlike text/icon.


Note: Upgrade option available for v1.0 and v1.1

@Steve - thanks for reporting the issues and apologies for not identifying them during original testing.

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

No worries GL. That's what you have us for, to find things that may have gotten missed.  ;D

Works beautifully now.
DO NOT pm me for support unless asked to!

sevamaster

Hello,
Tell me please, doesn't your mod conflict with "Pretty URLs" mod?

I have not install your mod yet. But I have that conflict with "Say Thanks" mod.

So, I want to know if I will not get the same result with your mod.

Thank you.

Steve

To be honest, it's not the mod author's responsibility to ensure that their mod doesn't conflict with any other. Conflicts can be reported and they may take a look at why.

In your case, backup your forum, uninstall the Say Thanks mod if you haven't already and try installing this one. I had errors with the Say Thanks mod (no offense to that mod's author) but this one works perfectly.
DO NOT pm me for support unless asked to!

Steve

If I accidentally hit the thanks button twice in rapid succession instead of once I get this error (twice):

Type of error
Database
Error message
Database Error: Duplicate entry '224902-msg-1' for key 'PRIMARY'
File
/home/steve/public_html/forums/Sources/Thanks.php
Line
314
URL of page causing the error
https://myforum/index.php?action=thanks;ltype=msg;sa=thank;thank=224902;f9f55c68=f139920d391efaf1fa359848cc5f9b0e;js=1&_=1665659189529
Backtrace information

    #0: smf_db_error()
    Called from /home/steve/public_html/forums/Sources/Subs-Db-mysql.php on line 494
    #1: smf_db_query()
    Called from /home/steve/public_html/forums/Sources/Subs-Db-mysql.php on line 802
    #2: smf_db_insert()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 314
    #3: insert()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 398
    #4: thank()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 150
    #5: call()
    Called from /home/steve/public_html/forums/index.php on line 191

I have Essential Tremors so this happens to me a lot and I was wondering if there was an easy way to stop it from doing this? If not, it's not a problem, I know this is a niche case. :)
DO NOT pm me for support unless asked to!

jsx

Hello @GL700Wing

This mod cannot be installed normally on SMF 2.1.3:



Only when I install by emulating 2.1.2

GL700Wing

Quote from: Steve on October 13, 2022, 07:25:33 AMIf I accidentally hit the thanks button twice in rapid succession instead of once I get this error (twice):

Type of error
Database
Error message
Database Error: Duplicate entry '224902-msg-1' for key 'PRIMARY'
File
/home/steve/public_html/forums/Sources/Thanks.php
Line
314
URL of page causing the error
https://myforum/index.php?action=thanks;ltype=msg;sa=thank;thank=224902;f9f55c68=f139920d391efaf1fa359848cc5f9b0e;js=1&_=1665659189529
Backtrace information

    #0: smf_db_error()
    Called from /home/steve/public_html/forums/Sources/Subs-Db-mysql.php on line 494
    #1: smf_db_query()
    Called from /home/steve/public_html/forums/Sources/Subs-Db-mysql.php on line 802
    #2: smf_db_insert()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 314
    #3: insert()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 398
    #4: thank()
    Called from /home/steve/public_html/forums/Sources/Thanks.php on line 150
    #5: call()
    Called from /home/steve/public_html/forums/index.php on line 191

I have Essential Tremors so this happens to me a lot and I was wondering if there was an easy way to stop it from doing this? If not, it's not a problem, I know this is a niche case. :)
@Steve I can't reproduce this error but I think it can be fixed by replacing the 'insert' mode with the 'ignore' mode for the 'db_insert' operations as follows:

In ./Sources/Thanks.php

Find:
        // Insert the thank.
        $smcFunc['db_insert']('insert',

Replace With:
        // Insert the thank.
        $smcFunc['db_insert']('ignore',


Find:
        if ($this->_type == 'msg')
            $smcFunc['db_insert']('insert',

Replace With:
        if ($this->_type == 'msg')
            $smcFunc['db_insert']('ignore',

Just wondering if you can make and test these changes and let me know the results (they won't prevent the mod from subsequently being uninstalled or upgraded).



Quote from: jsx on November 30, 2022, 04:39:06 AMThis mod cannot be installed normally on SMF 2.1.3:



Only when I install by emulating 2.1.2
@jsx Based on the testing I've done it's only an installer issue (ie, the mod works with SMF 2.1.3) and I'll update the installer to support SMF 2.1.3 when I've solved the issue @Steve reported.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

I've made the changes and the mod seems to be working normally. I can't definitively say it's fixed the problem but it appears to have. I tried hitting the Thanks as rapidly as I could with no issues.

Since it works with the changes made, I'd say go ahead and fix the installer issue.

And many thanks GL.  :)  (no pun intended :P )
DO NOT pm me for support unless asked to!

Steve

Problem ... if I add a new theme, the thanks link doesn't show up. I was going to uninstall and reinstall this but the Package Manager wants me to uninstall while emulating 2.1.2 but doing that gives me a multitude of errors on the uninstall test it does before the actual uninstall.

I know I could manually fix the errors but is there an easier way to do this?
DO NOT pm me for support unless asked to!

Advertisement: