News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Karma Description Mod

Started by Grek.Kamchatka, September 11, 2005, 11:48:26 PM

Previous topic - Next topic

dexx

Ooo good idea with the dual forums, I'll do that.

I did upgrade via the package, so uninstall and reinstall and my database should upgrade so the mod has no problem? (Just changed all files in the /smf folder to 777 permission?)

My profiles are link with Joomla! community builder and not the regular SMF profile, if that makes a diff.

TrueSatan

 Put it this way...it might save you having to do manual work on the database and if not it won't do any harm to try it...those mods shouldn't make a difference...fingers crossed for you.

dexx

Heh well I just tried uninstalling the Karma Mod for now and it worked fine except it wasnt able to unmodify Karma.php it said, and now attempts to change Karma give a main.template error.

Good thing I backed up the site first tho, so I'll just reupload the previous Karma.php from before install. :P

TrueSatan

 That's odd...wonder if there was an error uninstalling prior to my fiddling with it?

I added the necessary changes to the uninstall in the package so it looks as though there shouldn't have been a problem.

Generally SMF tries to help...it makes a copy of the file it modifies with a tilde (~) after the extension so that it ceases to be a php file...you can often reverse damage by using that copy. Mind you doing it how you've done it is the right way...take a proper file and database backup.

Grek.Kamchatka

A new version now available.

Sarke


My MODs          Please don't PM me for support, post in the appropriate topic.

Grek.Kamchatka

I don't know what the problem. If your mod search this lines after my mod was installed it can find it in 227, 228 and 229 lines. So, if i will remove this code (between /* and */) you will asking me to stay it there, because your mod cand find this code? LoL

TrueSatan

Grek,

I've been playing around with an idea...dexx reported his uninstall issue and on investigation I saw that the problem is that SMF doesn't (for some odd reason) properly backup the karma.php file. I wondered if we could get around that and the sad fact that many users won't read your many notes about backing up their files prior to installing the mod (yes I know you've told them countless times...I know how you must feel.)  I wondered if we could include a folder in the package that would install with it and if we could make the package move copies of the old versions of the existing files to it as part of the installation process. I chose to call the folder kdm_bak...it would be part of the package.

I tried the idea out but didn't make it work...the folder installed properly but the file in it (karma.php) is o bytes long so obviously the backup failed. Would you have a look at what I did and see if you might be able to see a way round the failure and if the idea would be of use. I have a feeling that it's the package manager at issue and that it can't copy between folders on the server...hope I'm wrong.

Thanks!

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
        <id>IvanV.PetrovichAkaGrek:KarmaDescriptionMod</id>
          <name>Karma Description Mod</name>
          <version>2.3</version>
          <type>modification</type>
          <install>
                <readme type="inline">Karma Description Mod (ver. 2.3) Don't forget to BACKUP, please.</readme>
                <modification>Karma_Description_Mod_1.xml</modification>
    <modification>Karma_Description_Mod_2.xml</modification>
                <code>db_change.php</code>
                <require-dir name="kdm_bak" destination="$sourcedir" />
                <require-file name="$sourcedir/karma.php" destination="$sourcedir/kdm_bak" />
                <require-file name="Viewkarma.php" destination="$sourcedir" />
                <require-file name="Viewkarma.template.php" destination="$boarddir/Themes/default" />
                <require-file name="DescriptionKarma.template.php" destination="$boarddir/Themes/default" />
        </install>
        <uninstall>
                <readme type="inline">Thank you for testing my mod.</readme>
                <modification reverse="true">Karma_Description_Mod_1.xml</modification>
                <modification reverse="true">Karma_Description_Mod_2.xml</modification>
                <require-file name="$sourcedir/kdm_bak/karma.php" destination="$sourcedir/karma.php" />
</uninstall>
</package-info>

Grek.Kamchatka

require-file name="$sourcedir/karma.php in your code... it is easy create a file named karma.php with 0 syms it's not backing up this file.

TrueSatan

 Maybe I'm missing something...I'm trying to take the existing karma.php (8.565Kb in a fresh SMF install) in the sources directory and copy it to the new directory kdm_bak prior to doing the rest of the mod. I tried having a karma.php with 0Kb in the kdm_bak directory but that didn't help....as you say it's not backing up the file. Any ideas?

Sarke

#610
Quote from: Grek_Kamchatka on March 19, 2007, 05:40:13 AM
I don't know what the problem. If your mod search this lines after my mod was installed it can find it in 227, 228 and 229 lines. So, if i will remove this code (between /* and */) you will asking me to stay it there, because your mod cand find this code? LoL

The problem is that there are now two places where the code is, and so any mod that tries to change that code finds the first one and applies it there, but this area of the code is commented out so even though the install works fine the changes aren't in effect becayse theyve been commented out by your code.

The second thing I mention was that the duplicate code you made alters that code as well by not preserving the correct whitespace.

My point was that your mod doesn't need to make these kinds of changes; it can be installed with fewer changes to the code.

My MODs          Please don't PM me for support, post in the appropriate topic.

Grek.Kamchatka

Quotefinds the first one and applies it there
Nope, if there will be a second code you search and the third code, your mod will make changes everywhere.

QuoteMy point was that your mod doesn't need to make these kinds of changes; it can be installed with fewer changes to the code.
No again. It is a difficult construction there. I can't put my code to that place, cause there only <tr> <td> tags. Of course i can try to find </td>
                                </tr>';
but this code meets during the all the file profile.template.php so i can't past my code before or after it.

Sarke

Sorry, you don't seem to understand what I'm saying.  The code in question is also not complex, and there is no reason for your code to change this:


echo '
<tr>
<td><b>', $txt[233], ': </b></td>
<td>', $context['member']['registered'], '</td>
</tr><tr>
<td><b>', $txt['lastLoggedIn'], ': </b></td>
<td>', $context['member']['last_login'], '</td>
</tr>';


Just do the following:


<operation>
<search position="replace"><![CDATA[ // If karma enabled show the members karma.
if ($modSettings['karmaMode'] == '1')
echo '
<tr>
<td>
<b>', $modSettings['karmaLabel'], ' </b>
</td><td>
', ($context['member']['karma']['good'] - $context['member']['karma']['bad']), '
</td>
</tr>';
elseif ($modSettings['karmaMode'] == '2')
echo '
<tr>
<td>
<b>', $modSettings['karmaLabel'], ' </b>
</td><td>
+', $context['member']['karma']['good'], '/-', $context['member']['karma']['bad'], '
</td>
</tr>';
]]></search>
<add><![CDATA[// If karma enabled show the members karma.
        if ($modSettings['karmaMode'] == '1')
        {        echo '
                                <tr>
                                        <td>
                                                <b>', $modSettings['karmaLabel'], ' </b>
                                        </td><td>
                                                ', ($context['member']['karma']['good'] - $context['member']['karma']['bad']), '
                                        </td>
                                </tr>';
        if (!empty($modSettings['karmadescmod']) && !empty($modSettings['karmalinks']))
        {    if ($context['show_karmastat'])
     echo '
                                <tr>';
                                if (!empty($modSettings['karmaisowner']) && ($context['owner']==1)) echo '
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                ';
                                elseif (empty($modSettings['karmaisowner'])) echo'
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                ';
                                elseif ($context['user']['is_admin']) echo '
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                </tr>'
                                ;}
         }
                               
        elseif ($modSettings['karmaMode'] == '2')
        {        echo '
                                <tr>
                                        <td>
                                                <b>', $modSettings['karmaLabel'], ' </b>
                                        </td><td>
                                                +', $context['member']['karma']['good'], '/-', $context['member']['karma']['bad'], '
                                        </td>
                                </tr>';
        if (!empty($modSettings['karmadescmod']) && !empty($modSettings['karmalinks']))
        {    if ($context['show_karmastat'])
     echo '
                                <tr>';
                                if (!empty($modSettings['karmaisowner']) && ($context['owner']==1)) echo '
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                ';
                                elseif (empty($modSettings['karmaisowner'])) echo'
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                ';
                                elseif ($context['user']['is_admin']) echo '
                                        <td><a href="'. $scripturl . '?action=ownkarma;u=' . $context['member']['id'] . '">'.$txt['who_change_my_karma'].'</a></td>
                                        <td><a href="'. $scripturl . '?action=otherkarma;u=' . $context['member']['id'] . '">'.$txt['whom_i_change_karma'].'</a></td>
                                </tr>'
                                ;}
        }]]></add>
</operation>



This way you mod doesn't change what it doesn't need to, and it doesn't leave duplicate code.

My MODs          Please don't PM me for support, post in the appropriate topic.

Grek.Kamchatka


tsmalmbe

This seems to work, although a little work to get it installed on a custom theme and other language. Thanks.
..:: http://www.kontrollrummet.com - Studio och musik ::.. RSS?

MoPed

#615
When I try to install it, I get thist message :(
And me and my users would love to have this mod.




Installations actions for "Karma Description Mod":
Installing this package will perform the following actions: 
Type Action Description
1. Execute Modification Karma_Description_Mod_1.xml   Modification parse error
2. Execute Modification -                                            Modification parse error
3. Execute Modification Karma_Description_Mod_2.xml   Modification parse error
4. Execute Modification -                                            Modification parse error
5. Execute Code db_change.php 
6. Extract File ./Sources/Viewkarma.php 
7. Extract File ./Themes/default/Viewkarma.template.php 
8. Extract File ./Themes/default/DescriptionKarma.template.php


And in the error-log I get this message:
http://***.*****.dk/index.php?action=packages;sa=install;package=Karma_Description_Mod_ver1.2.3.zip 
8: Undefined index: package_readme
File: /******/******/*****/Sources/Packages.php
Line: 294  

Grek.Kamchatka

Quotehttp://***.*****.dk/index.php?action=packages;sa=install;package=Karma_Description_Mod_ver1.2.3.zip
ver1.2.3 ? What is this? I havn't this mod version. 2.3 only.

tsmalmbe

Any possibility of having a version where you could exclude certain boards (in a comma separated list) from having the karma enabled? I have offtopic-boards where the karma has gone wild (in a not-so-good way).

Thanks for listening.
..:: http://www.kontrollrummet.com - Studio och musik ::.. RSS?

MoPed

Quote from: Grek_Kamchatka on March 22, 2007, 09:58:56 PM
Quotehttp://***.*****.dk/index.php?action=packages;sa=install;package=Karma_Description_Mod_ver1.2.3.zip
ver1.2.3 ? What is this? I havn't this mod version. 2.3 only.

It is the version 2.3 downloadet here at SMF I am trying to install..

I don't know why it writes "Karma_Description_Mod_ver1.2.3.zip" in the error-log   :-\

MoPed

Ohh, I just tried to have a look at the zip-file..

It is called "Karma_Description_Mod_ver[1].2.3.zip" Can that be the reason?

(It is, what is suggested as filename, when downloading the file)

Advertisement: