Spuds / SMF-Member-Awards

Member Awards for SMF 2.0
Other
8 stars 8 forks source link

SMF 2.1 #58

Closed BodzioXs closed 9 months ago

BodzioXs commented 10 months ago

Hi, I'm just curious. Does it require a lot of changes to make this mod work with SMF 2.1? Do you plan to convert it in the future? Cheers

Spuds commented 9 months ago

I'm going to assume the issue would be with the template edits ... I have not tried to install this on 2.1. I would think the core of the addon would work fine, but the template edits for display.template would probably need an update.

BodzioXs commented 9 months ago

I see. For now I'm not planning to change into 2.1 but for sure if I do it, it would be nice to have this mod on board.

Btw, I switched PHP to 8.1 on my site and unfortunately I have the same critical error as in the past that is I can't see assigned orders in a panel, instead I have this error "Call to undefined function create_function()". I guess it's connected with PHP, because if I remember correctly last time it was the same issue so I only let you know.

Spuds commented 9 months ago

I thought I had removed all of those create_function calls in this release: https://github.com/Spuds/SMF-Member-Awards/releases/tag/3.0.1 I must have missed one. I'll try to look into this in the next couple of weeks (at least the 2.0 stuff, not sure on the 2.1)

BodzioXs commented 9 months ago

Ok, thanks in advance :)

ClanScript commented 9 months ago

I also updated few days ago for 2.1.4 (and php 8.2) and need this plugin - my several hundred users wanna their medals back. Hope you can update it. Thanks!

Spuds commented 9 months ago

@BodzioXs I looked through the 3.0.1 version of the addon and I do not find any uses of create_function so I have to assume you are using an old version of the mod. The 3.0.1 (current release) should work find with 8.x but I am checking for any 8.2/8.3 depreciation issues caused by the addon, SMF 2.0 has plenty of its own.

BodzioXs commented 9 months ago

I'm really sorry for taking your time. I didn't notice that you released 3.0.1 and I was still using 3.0. I updated it now and it seems to be woking fine with 2.0.19

Spuds commented 9 months ago

Here is a preliminary package which should install and work on SMF 2.1 ... This was just the basics to get it to install. If you want to help, install this on your test/backup forum and see how it goes. https://github.com/Spuds/SMF-Member-Awards/releases/download/3.1.0/MemberAwards_3-1-0.zip

ClanScript commented 9 months ago

Thanks a lot! Works fine!

BodzioXs commented 9 months ago

Please help.

Unfortunately, I have an issue on 2.0.19 but it's my fault not yours. I was too quick and careless while checking this 3.0.1 update.

  1. I didn't uninstall 3.0.0.
  2. Instead I installed 3.0.1
  3. Everything seemed to work OK but one user told me that he can't edit his profile. He has information "You are not allowed to manage awards!"
  4. All awards are seen on forum but the mod is not enabled. I guess it remembers somehow this 3.0.0. When I turn 3.0.1 on all is good (he can edit profile) but awards are doubled like here ;/ 3

Any idea how to repair it?

When I uninstall 3.0.1 I can't use my forum because everywhere there are these errors. While uninstalling I leave tables in database because I don't want to organise everything from the scratch.

1

2

Do I have to completely remove 3.0.1 and empty database? Will it work?

Spuds commented 9 months ago

Can you uninstall 3.0.1 and then uninstall 3.0.0 ? You should not have to remove the DB tables, that is not causing the problem.

If after uninstalling 3.0.1 you can not get back to the package manager to uninstall 3.0.0 because of the above error, you can try to just create a dummy AwardsManage.php file with

<?php

return;

just to get past that so you can uninstall 3.0.0

BodzioXs commented 9 months ago

I can uninstall 3.0.1 but than I can't do anything with 3.0.0 apart from installing it again. I tried to do it and then it works but again I have doubled awards. When I uninstall 3.0.0 I have errors as above.

Perhaps the issue is connected with this new setting? Enable Awards: This is the master setting that enables the awards for the site.

This setting is not present in 3.0.0, when I install 3.0.1 and have it turned off everything seems to be ok apart from some users who can't edit their profiles with information "You are not allowed to manage awards!"

When I turn on this setting everything is good apart from doubled awards in each post...

Spuds commented 9 months ago

What is probably happening is, since you did not uninstall first, the code edits are in there twice and the source of your issue is with the Load.php file in your source dir.

In that file see if you have these two blocks of code in there

        // I'm sorry, but I've got to stick this award somewhere ...
        if ($modSettings['awards_in_post'] > 0 && !empty($new_loaded_ids))
        {
            global $sourcedir;
            require_once($sourcedir . '/AwardsManage.php');
            AwardsLoad($new_loaded_ids);
            AwardsAutoCheck($new_loaded_ids);
        }

and

        // I'm sorry, but I've got to stick this award somewhere ...
        if ($modSettings['awards_in_post'] > 0 && !empty($new_loaded_ids) && !empty($modSettings['awards_enabled']))
        {
            global $sourcedir;
            require_once($sourcedir . '/AwardsManage.php');
            loadTemplate(false, 'awards');
            AwardsLoad($new_loaded_ids);
            AwardsAutoCheck($new_loaded_ids);
        }

You want to remove the fist one, which is 3.0.0, the second stays in place that is 3,0.1.

The other problem may be duplicate hooks, but lets start with the above first

BodzioXs commented 9 months ago

You're right. Everything seems to be doubled. I checked Load.php Who.php Admin.php and deleted all doubled lines which referred to your mod.

It didn't help.

However I checked also Display.template.php in each Theme that I use and there everything was doubled so I deleted this code in each file and for now everything seems to be working OK.

` // Show their below profile awards? if (!empty($message['member']['awards']) && $modSettings['awards_in_post'] > 0) { $awards_above = (empty($awards) ? 0 : $awards); $awards = 0; $award_output = '';

            foreach ($message['member']['awards'] as $award)
            {
                if (($award['location'] == 1) && ($awards < $modSettings['awards_in_post']))
                {
                    $award_output .= '
                            <a href="' . $scripturl . $award['more'] . '"><img src="' . dirname($scripturl) . $award['img'] . '" alt="' . $award['description'] . '" title="' . $award['description'] . '" /></a> ';
                    $awards++;
                }
            }

            // If we found some to output here, then show them
            if (!empty($awards))
            {
                $style = (empty($modSettings['awards_belowavatar_format']) || $modSettings['awards_belowavatar_format'] == 1) ? 'style="border:1px;border-style:solid; border-color:#CCC;padding:2px 2px 2px 5px;margin-right:15px;"'
                : ($modSettings['awards_belowavatar_format'] == 2 ? 'style="border-top:1px;border-bottom:0;border-right:0;border-left:0;border-style:solid;border-color:#CCC;padding:2px 2px 2px 5px;margin-right:15px;"'
                : 'style="border:0px;border-style:solid; border-color:#CCC; padding: 0 0;"');

                echo '
                    <li>
                        <fieldset ', $style, '>';

                if (isset($modSettings['awards_belowavatar_title']))
                    echo '
                            <legend><a href="' . $scripturl . '?action=profile;area=showAwards;u=' . $message['member']['id'] . '" title="' . $txt['awards'] . '">' . $modSettings['awards_belowavatar_title'] . '</a></legend>';

                echo $award_output;

                echo '
                        </fieldset>
                    </li>';
            }
        }

`

Spuds commented 9 months ago

Cool ... when you did not uninstall the old version first, the new version simply made the same edits in all those files. There should be several areas in the display.template (above/below and signature) .... just be sure to remove the 3.0.0 ones and leave the 3.0.1 edits. This is one of the several reasons source edits can be problematic, unfortunately there are no hooks in 2.0 to avoid those, especially the template.

BodzioXs commented 9 months ago

Yeah, thanks to your hint I hope I managed to clean this mess. I deleted the first entires so I hope they were from 3.0.0, not 3.0.1 :) For now everything works fine.

Unfortunately I need to stay with 2.0.19 because my theme doesn't support 2.1 but when I'll finally find a good replacement I'll check this updated version too.

Thanks again :)

Spuds commented 9 months ago

Sounds like we are all set ... I'll close this. If you have another problem just open a new issue.