Good Post/Bad Post Mod

Started by OutofOrder, June 17, 2009, 10:08:41 AM

Previous topic - Next topic

Ihmeliö

Any hope of a feature listing all posts that have received at least *** upvotes?

Or at least "top 100 (or whatever) posts of all time"?

More statistics = always good.

(does someone know if there's still going to be updates for this mod?)

JohnWayne999

#401
Hi guys, hope what I'm going to say is useful to some people. I am running SMF 1.1.15 and successfully installed GoodPostBadPost1.1.3a.zip using the package manager. However I made some minor changes described as follows:

When I asked package manger to take on the original GoodPostBadPost1.1.3a.zip, the manager told me something like "version incompatible" or "may be corrupt".  So I unzipped the file and took a quick look myself.

I first looked at gpbp_1.1.x_install.php which looked like it's creating database/tables. Nothing interesting so I closed it.
Next I looked at install_1.1.x.xml. Looked like it's a mega find and insert machine. More like a patcher. Nothing interesting. Close it too.

Before I decided to giveup, I had a quick look in package-info.xml, and it contained version information. So what I tried was nothing tricky, I just changed all instances of 1.1.3 to 1.1.15. For example:  <install for="1.1-1.1.3"> became    <install for="1.1-1.1.15">.
Then I zipped up the whole thing (I called it GoodPostBadPost1.1.15.zip, attached to this post).

I was happy to guess that's the information the package manager used to check against SMF version. Apparently it must have taken the range 1.1-1.1.3 and compared against my SMF's 1.1.15 and then decided not to proceed. So after what I changed, hopefully the manager will now be fooled to go ahead with the rest of the installation. And I was right. I fed the package manager my modified zip and this time there was no complaint about version incompatibility.  However upon doing a simulation run on the package, the simulation complained of one failed test namely "Execute Modification --- ./Sources/ManagePermissions.php   --- Test failed". Didn't really care about it. Worse comes the worst I can just tweek that file manually myself. Anyway cut long story short, I just ignored the warning and proceeded to install the mod. Installed fine and the good feedback / bad feedback function worked smoothly for user logged in as admin.

But hang on. When I test logged in as a newbie, I couldn't leave good/bad feedbacks. I tried to set permissions to allow newbies to leave feedbacks but there's nothing for me to choose from in the permissions menu. It occurred to me, must be the Sources/ManagePermissions.php that's screwing around with me. So back I went to check install_1.1.x.xml inside which is this section about how to modify Sources/ManagePermissions.php:

<file name="$sourcedir/ManagePermissions.php">
<operation>
<search position="before"><![CDATA['edit_news' => false,]]></search>
<add><![CDATA[
'gpbp_manage' => false,]]></add>
</operation>

<operation>
<search position="after"><![CDATA[ )
),
'board' => array(]]></search>
<add><![CDATA[ ),
'gpbp' => array(
'gpbp_vote' => false,
'gpbp_reveal' => false,
]]></add>
</operation>

<operation>
<search position="before"><![CDATA['send_mail',]]></search>
<add><![CDATA[
'gpbp_manage',
'gpbp_vote',]]></add>
</operation>
</file>


I checked with the copy of ManagePermission.php on the server and only two spots were modified, not the required three.
This part is missing:
'gpbp' => array(
'gpbp_vote' => false,
'gpbp_reveal' => false,
                                )


So I manually added it in. Cut long story short, you should replace this
'chat' => array(
'chat_access' => false,
'chat_mod' => false,
'shout_view' => false,
'shout_access' => false,
'shout_mod' => false,
)


with this
'chat' => array(
'chat_access' => false,
'chat_mod' => false,
'shout_view' => false,
'shout_access' => false,
'shout_mod' => false,
),
                        'gpbp' => array(
'gpbp_vote' => false,
'gpbp_reveal' => false,
                        )


This time everything worked fine. First time around you need to log in as admin -> ADMIN -> Members -> Permission -> Once in, set normal users to be allowed to "Vote on posts (up or down)" and be allowed to "Reveal bad posts" -> Then confirm by clicking on "Set permissions" button. Now you are really done. Everything should work now. Admin and normal users can both leave positive or negative feedbacks.

Most people are probably fine with installing GoodPostBadPost to their SMF. Just in case you are like me using 1.1.15 and have no idea how to get past the Package Manager first time, I've attached to this post my modified and rezipped version. I called it GoodPostBadPost1.1.15.zip. See if works for you. Note you still need to do that last bit of modification to the ManagePermissions.php as described above, because I am too lazy to incoporate that into the zip. Also don't forget to backup everything beforehand as always.

So in a nutshell I just changed the version check information in the package, and I manually added a bit of detail into Sources/ManagePermissions.php that's all and the rest flowed on normally.

(By the way, people might want to consider FacebookLike MOD also. It's basically the same thing but each post can accumulate likes and no thumbs downs. http://custom.simplemachines.org/mods/index.php?mod=3105 )

girlfloyd

I made this install in 2.0.1 by modifying the versions in the package-info.xml as JohnWayne999 said. However, there were no issues with the ./Sources/ManagePermissions.php file for me. The problem was with ./Sources/Display.php.

Find this:

m.id_msg_modified < {int:new_from} AS is_read, k.message AS is_repped

Replace with:

m.id_msg_modified < {int:new_from} AS is_read, gpbp_score, k.message AS is_repped

That should fix it so that it saves the ratings in 2.0.1.

Now I need to figure out how to make the ratings show in the topic titles listed in the forum...  Let me know if anyone can help with this! :P

Guillelmus

Installs fine on 2.0.1 just can't see the list of voters.  ??? Any ideas?

Guillelmus

Also code for hiding the number if zero would be nice. Let's see if I can figure it out myself...

Guillelmus

Quote from: Guillelmus on October 18, 2011, 02:55:07 PM
Also code for hiding the number if zero would be nice. Let's see if I can figure it out myself...
Ok.

In Display.template.php
Replace
echo '
<span id="gpbp_score_', $message['id'], '" class="help" title="', $txt['gpbp_post_score'], '">', $message['gpbp_score'], '</span>';

with

         if (!empty($message['gpbp_score']))  echo '
<span id="gpbp_score_', $message['id'], '" class="help" title="', $txt['gpbp_post_score'], '">', $message['gpbp_score'], '</span>';

Guillelmus

Quote from: Guillelmus on October 18, 2011, 02:26:17 PM
Installs fine on 2.0.1 just can't see the list of voters.  ??? Any ideas?
Oh, it was disabled in the options. Admin -> Forum/Good Post Bad Post -> Advanced configuration -> Amount of members to display in post voters list: must be greater than zero.

I'd like to see the names on mouse hover on though. :-)

Guillelmus

For hiding voters list if no-one has voted:

In Display.template.php
Find:
if ($context['reveal_voterslist'])
Replace with:
if (($context['reveal_voterslist'])&&(!empty($message['gpbp_score'])))

Guillelmus

Quote from: Guillelmus on October 19, 2011, 06:46:03 AM
I'd like to see the names on mouse hover on though. :-)
Quick and not very smart fix to this is to change onclick value to onmouseover

In Display.template.php

Find:
<a class="gpbp_voterslist" id="gpbp_voterslist_', $message['id'], '" onclick="oVotePost.voterslist(\'', $message['id'], '\'); return false"><img class="gpbp_vote_img" src="', $settings['images_url'], '/gpbp_voterslist.gif" alt="', $txt['gpbp_show_voters'], '" title="', $txt['gpbp_show_voters'], '" /></a>
Replace with:
<a class="gpbp_voterslist" id="gpbp_voterslist_', $message['id'], '" onmouseover="oVotePost.voterslist(\'', $message['id'], '\'); return false"><img class="gpbp_vote_img" src="', $settings['images_url'], '/gpbp_voterslist.gif" alt="', $txt['gpbp_show_voters'], '" title="', $txt['gpbp_show_voters'], '" /></a>

Guillelmus

Liked messages should be hidden from the Messages of the week list if they're on a board the user cannot read.

Major Wood

Every time that I click on install (to go to the page that tests the various operations, not the confirmation page) for this mod, I start getting 500 errors sitewide.
Any thoughts? Running 2.0.1

Gambi

Hi, is this mod supposed to refresh the page when you click the up or down arrow? It'll register it if you refresh manually but it'll be great if it could update instantly or refresh the page kind of like how karma works. I've tried but couldn't get it to work. Does anyone know how they'd alter the code below so it refreshes the page at that post or even just updated the arrows instantly. I'd appreciate the help.

// Good Post/Bad Post score and voting.
if ($context['gpbp_enabled'])
{
$message['gpbp_score'] = ( $message['gpbp_score'] > 0 ? '+' : '' ) . $message['gpbp_score'];
echo '
<div class="gpbp_vote normaltext">
<span id="gpbp_score_', $message['id'], '" class="help" title="', $txt['gpbp_post_score'], '">', $message['gpbp_score'], '</span>';

if ($context['can_vote_gpbp'] && $message['member']['id'] != $context['user']['id'])
{
echo '
<a onclick="oVotePost.vote(\'down\', \'', $message['id'], '\', \'', $context['session_id'], '\'); return false" href="', $scripturl, '?action=gpbp;sa=down;msg=', $message['id'], ';sesc=', $context['session_id'], ';board=', $context['this_board'], ';topic=', $context['current_topic'], '"><img class="gpbp_vote_img" id="gpbp_vote_down_', $message['id'], '" src="', $settings['default_images_url'], '/gpbp_arrow_down', $message['gpbp_img']['down']['lit_suffix'], '.gif" alt="', $txt[ $message['gpbp_img']['down']['alt'] ], '" title="', $txt[ $message['gpbp_img']['down']['title'] ], '" /></a>
<a onclick="oVotePost.vote(\'up\', \'', $message['id'], '\', \'', $context['session_id'], '\'); return false" href="', $scripturl, '?action=gpbp;sa=up;msg=', $message['id'], ';sesc=', $context['session_id'], ';board=', $context['this_board'], ';topic=', $context['current_topic'], '"><img class="gpbp_vote_img" id="gpbp_vote_up_', $message['id'], '" src="', $settings['default_images_url'], '/gpbp_arrow_up', $message['gpbp_img']['up']['lit_suffix'], '.gif" alt="', $txt[ $message['gpbp_img']['up']['alt'] ], '" title="', $txt[ $message['gpbp_img']['up']['title'] ], '" /></a>';
}

echo  '
</div>';
}


Interested bystander

I installed this on one of my 2.0.1 forums and it worked fine.   I just installed it on a second forum of the same version today and only the admin can see the arrows and cast votes.   Where should I start looking for my problem?   

Interested bystander

Never mind, I figured it out.

crazyASD

After installation Google +1 button, user scores (under user`s avatar) doesn`t shown, it shown again only if user clicking on good/bad post control.
Please fix it!

valpo04

Trying to install this mod and I get an error with the modification of Load.php.  Every other modification is successful, except that one, it says "Test Failed."

Any ideas?

Major Wood

Quote from: Major Wood on October 21, 2011, 06:12:01 PM
Every time that I click on install (to go to the page that tests the various operations, not the confirmation page) for this mod, I start getting 500 errors sitewide.
Any thoughts? Running 2.0.1

Bump! Anyone?

Gambi

Quote from: Gambi on October 30, 2011, 07:13:01 AM
Hi, is this mod supposed to refresh the page when you click the up or down arrow? It'll register it if you refresh manually but it'll be great if it could update instantly or refresh the page kind of like how karma works. I've tried but couldn't get it to work. Does anyone know how they'd alter the code below so it refreshes the page at that post or even just updated the arrows instantly. I'd appreciate the help.

// Good Post/Bad Post score and voting.
if ($context['gpbp_enabled'])
{
$message['gpbp_score'] = ( $message['gpbp_score'] > 0 ? '+' : '' ) . $message['gpbp_score'];
echo '
<div class="gpbp_vote normaltext">
<span id="gpbp_score_', $message['id'], '" class="help" title="', $txt['gpbp_post_score'], '">', $message['gpbp_score'], '</span>';

if ($context['can_vote_gpbp'] && $message['member']['id'] != $context['user']['id'])
{
echo '
<a onclick="oVotePost.vote(\'down\', \'', $message['id'], '\', \'', $context['session_id'], '\'); return false" href="', $scripturl, '?action=gpbp;sa=down;msg=', $message['id'], ';sesc=', $context['session_id'], ';board=', $context['this_board'], ';topic=', $context['current_topic'], '"><img class="gpbp_vote_img" id="gpbp_vote_down_', $message['id'], '" src="', $settings['default_images_url'], '/gpbp_arrow_down', $message['gpbp_img']['down']['lit_suffix'], '.gif" alt="', $txt[ $message['gpbp_img']['down']['alt'] ], '" title="', $txt[ $message['gpbp_img']['down']['title'] ], '" /></a>
<a onclick="oVotePost.vote(\'up\', \'', $message['id'], '\', \'', $context['session_id'], '\'); return false" href="', $scripturl, '?action=gpbp;sa=up;msg=', $message['id'], ';sesc=', $context['session_id'], ';board=', $context['this_board'], ';topic=', $context['current_topic'], '"><img class="gpbp_vote_img" id="gpbp_vote_up_', $message['id'], '" src="', $settings['default_images_url'], '/gpbp_arrow_up', $message['gpbp_img']['up']['lit_suffix'], '.gif" alt="', $txt[ $message['gpbp_img']['up']['alt'] ], '" title="', $txt[ $message['gpbp_img']['up']['title'] ], '" /></a>';
}

echo  '
</div>';
}



And while you're at it, this as well.

krazytim

Any chance that this will be updated for SMF 2.0.1 any time soon??

Guillelmus

Quote from: krazytim on December 04, 2011, 09:21:28 PM
Any chance that this will be updated for SMF 2.0.1 any time soon??
Works just fine on 2.0.1. Install emulating SMF 2.0.

Advertisement: