Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-29-2008, 09:05 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 18 Times in 11 Posts
Bury Button with Choice of Reasons

I wanted a way for users to specify a reason for burying a story and came up with these modifications to make that happen.

What it does:

When you click the 'bury' button, a choice of reasons will appear below the links (the same as when you click "Add this link to..."). When you click on one of the reasons, the story is buried as normal, but the "Live" page will show the action as "buried R1" instead of "report". I use R1-R7 to identify which reason was chosen. I then explain these on my FAQ so disgruntled users can find out why their story was buried.

See the attached screenshots to understand the results.

What it doesn't do:

It doesn't send any emails or leave any messages on the buried story. The only way for people to know the reason a story was buried is to check the "Live" page.
UPDATE: See my later post (#8) for how I've extended the mod to show a flag next to buried stories.

Tested on:
Pligg 9.8.2 using voting method 1. My template is "moderno-orange", but it should work for yget.
UPDATE: I've now tested this on .9.9.5 and it works.

Please read all these instructions before attempting this modification, just in case I've done something wrong. I'm just a novice playing with the code! You have been warned!

STEP 1: Create the choices that show when you click "bury"

Open /templates/your_template/link_summary.tpl and find:

Code:
{if $link_shakebox_currentuser_votes eq 0 && $link_shakebox_currentuser_reports eq 0}
	<span id="xreport-{$link_shakebox_index}"> <img src="{$my_pligg_base}/templates/{$the_template}/images/error.png" align="absmiddle" /> <a href="javascript:{$link_shakebox_javascript_report}">{#PLIGG_Visual_Vote_Bury#}</a></span>
{/if}
Replace that with:

Code:
{if $link_shakebox_currentuser_votes eq 0 && $link_shakebox_currentuser_reports eq 0}
	<span id="xreport-{$link_shakebox_index}"> 
		<img src="{$my_pligg_base}/templates/{$the_template}/images/error.png" align="absmiddle" /> <a href="javascript://" onclick="var reportdisplay=document.getElementById('report-{$link_shakebox_index}').style.display ? '' : 'none';document.getElementById('report-{$link_shakebox_index}').style.display = reportdisplay;" title="Click for 'bury' options"> {#PLIGG_Visual_Vote_Bury#}</a>&nbsp;
	</span>
{/if}
Then scroll down to the bottom of the file and copy this just before the closing </span> (note that I'm using 7 reasons):

Code:
{if $link_shakebox_currentuser_votes eq 0 && $link_shakebox_currentuser_reports eq 0}
	<span id="report-{$link_shakebox_index}" style="display:none"><br />{#PLIGG_Visual_LS_Bury#} <br />

		&nbsp;&nbsp;<a href="javascript:{$link_shakebox_javascript_report1}">{#PLIGG_Visual_Vote_Bury_1#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report2}">{#PLIGG_Visual_Vote_Bury_2#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report3}">{#PLIGG_Visual_Vote_Bury_3#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report4}">{#PLIGG_Visual_Vote_Bury_4#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report5}">{#PLIGG_Visual_Vote_Bury_5#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report6}">{#PLIGG_Visual_Vote_Bury_6#}</a> 
		| <a href="javascript:{$link_shakebox_javascript_report7}">{#PLIGG_Visual_Vote_Bury_7#}</a> 
	</span>
{/if}
STEP 2: Set the language.

Open /libs/lang.conf, find "PLIGG_Visual_LS_AddTo" and add our own "LS_Bury" below it as follows:

Code:
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.70</ADDED>
PLIGG_Visual_LS_AddTo = "Add to: "
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.70</ADDED>
PLIGG_Visual_LS_Bury = "Reason for burying this story: " 
Then find "PLIGG_Visual_Vote_Bury" and add the following below it as shown:

Code:
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury = "Bury"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_1 = "Spam"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_2 = "Inappropriate"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_3 = "Broken Link"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_4 = "Duplicate"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_5 = "Inaccurate"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_6 = "Wrong Category"
//<SECTION>LINK_SUMMARY</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Vote_Bury_7 = "Poor" 
STEP 3: Assign the smarty variables

Open /libs/link.php and find:

Code:
$jsreportlink = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-10)";
Notice that ends with -10. Whenever a story is buried, it gets a vote_value of -10. What I'm doing here is setting different values (-11 to -17) for each type of bury, so below that copy and paste:

Code:
$jsreportlink1 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-11)";
$jsreportlink2 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-12)";
$jsreportlink3 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-13)";
$jsreportlink4 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-14)";
$jsreportlink5 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-15)";
$jsreportlink6 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-16)";
$jsreportlink7 = "vote($current_user->user_id,$this->id,$link_index," . "'" . md5($current_user->user_id.$this->randkey) . "',-17)";
Scroll down a little and you'll see:

Code:
$smarty->assign('link_shakebox_javascript_report', $jsreportlink);
Copy and paste the following below that:

Code:
$smarty->assign('link_shakebox_javascript_report1', $jsreportlink1);
$smarty->assign('link_shakebox_javascript_report2', $jsreportlink2);
$smarty->assign('link_shakebox_javascript_report3', $jsreportlink3);
$smarty->assign('link_shakebox_javascript_report4', $jsreportlink4);
$smarty->assign('link_shakebox_javascript_report5', $jsreportlink5);
$smarty->assign('link_shakebox_javascript_report6', $jsreportlink6);
$smarty->assign('link_shakebox_javascript_report7', $jsreportlink7);
Now, while we're still in this file, find "function insert_vote($user=0, $value=10)"

I got really stuck with buried links getting random vote_values instead of the -11 to -17 that I specified. It was driving me crazy! Eventually, I found that karma was affecting the values. I couldn't see the need for karma here, so I just commented out the guilty lines in the insert_vote function, as follows:

Code:
// if($value<10) {$vote->value=($anon_karma/10)*$value;}
if($value<10) {$vote->value=$value;} 
and

Code:
// if($value<10) {$vote->value = ($dbuser->karma/10)*$value;}
if($value<10) {$vote->value = $value;} 
STEP 4: Showing the buried reasons on the "Live" page

Open /live2.php and find:

Code:
if ($event->vote_value < 0) {
				$type = 'report';
				$who = $user;
}
Replace that with:

Code:
if (($event->vote_value < 0) && ($event->vote_value > -11)) {
	$type = 'buried';
	$who = $user;
}
else if ($event->vote_value == -11) {
	$type = 'buried R1';
	$who = $user;
}
else if ($event->vote_value == -12) {
	$type = 'buried R2';
	$who = $user;
}
else if ($event->vote_value == -13) {
	$type = 'buried R3';
	$who = $user;
}
else if ($event->vote_value == -14) {
	$type = 'buried R4';
	$who = $user;
}
else if ($event->vote_value == -15) {
	$type = 'buried R5';
	$who = $user;
}
else if ($event->vote_value == -16) {
	$type = 'buried R6';
	$who = $user;
}
else if ($event->vote_value == -17) {
	$type = 'buried R7';
	$who = $user;
}
else if ($event->vote_value < -17) {
	$type = 'buried';
	$who = $user;
}
Now you can upload all the files, which were:

/templates/your_template/link_summary.tpl
/libs/lang.conf
/libs/link.php
/live2.php

and cross your fingers!
Attached Thumbnails
bury-button-choice-reasons-bury_link_story_image.gif   bury-button-choice-reasons-bury_link_live_image.gif  

Last edited by longcountdown; 08-08-2008 at 10:48 PM.. Reason: Included updates in orange.
Reply With Quote
The Following 4 Users Say Thank You to longcountdown For This Useful Post:
  #2 (permalink)  
Old 07-29-2008, 10:42 AM
New Pligger
Pligg Version: 9.9
 
Join Date: Jun 2008
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
hmmm intresting .. I will look into it.. thanks
Reply With Quote
  #3 (permalink)  
Old 07-31-2008, 02:58 AM
New Pligger
Pligg Version: 9.9.
Pligg Template: Sliverbullet
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks! This works great!!!
Reply With Quote
  #4 (permalink)  
Old 07-31-2008, 05:11 PM
New Pligger
Pligg Version: 9.9.
Pligg Template: Sliverbullet
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Okay now I killed my bury button, it is here but when I click on it nothing happens. Any ideas?

Pligg: 9.9.0
Template: Silverbullet
Reply With Quote
  #5 (permalink)  
Old 07-31-2008, 05:33 PM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 286
Thanks: 33
Thanked 18 Times in 14 Posts
Nice job. :-) Now just to add another field to the database that will provide common text for the reasons rather than R1-R7, etc.
David.
Reply With Quote
  #6 (permalink)  
Old 07-31-2008, 11:02 PM
New Pligger
Pligg Version: 9.9.
Pligg Template: Sliverbullet
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I fixed it...
Reply With Quote
  #7 (permalink)  
Old 07-31-2008, 11:06 PM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 18 Times in 11 Posts
Quote:
Originally Posted by davemackey View Post
Nice job. :-) Now just to add another field to the database that will provide common text for the reasons rather than R1-R7, etc.
David.
You can change the text in /live2.php, but keep it short because it will wrap around if it's too long for the action column on the Live page.
Reply With Quote
  #8 (permalink)  
Old 08-08-2008, 10:44 PM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks: 25
Thanked 18 Times in 11 Posts
Flagging Buried Stories

The problem with the previous modifications is that most users don't check the Live page to see if something has been buried. Even if they do, there's a good chance the bury "action" has scrolled off the bottom of the Live page.

EXTENDING THE MOD WITH "FLAGGING" - see attached screenshot.

I've extended this mod to show a red flag next to any upcoming story that someone has buried. Hovering over the flag shows the reason for why it was last buried.

Tested on Pligg .9.8.2 and .9.9.5 using voting method 1

Please read all these instructions before attempting this modification, just in case I've done something wrong. I'm just a novice playing with the code! You have been warned!

STEP 1: Get an image for your flag

I got a 16x16 png here on iconfinder.net.
Upload it to /templates/your_template/images/

STEP 2: Get last report value for reported links

Open /libs/link.php.

Find:

Code:
$smarty->assign('link_shakebox_votes', $this->votes);
Copy the following immediately below that line:

Code:
$smarty->assign('link_shakebox_reports', $this->reports);
if($this->reports > 0) {
		$report_value = $db->get_var("SELECT vote_value FROM " . table_votes . " WHERE vote_link_id = $this->id AND vote_value < 0 ORDER BY vote_id DESC");
		$smarty->assign('link_shakebox_report_value', $report_value);
		}
STEP 3: Show the flags

Open /templates/your_template/link_summary.tpl and find:

Code:
<div class="top">
	<div class="toptitle" id="ls_thetitle-{$link_shakebox_index}">
Add the red text, so the div looks like this:

Code:
<div class="top">
	<div class="toptitle" id="ls_thetitle-{$link_shakebox_index}">
		{if $use_title_as_link eq true}
			{if $url_short neq "http://" && $url_short neq "://"}
				<a href="{$url}" {if $open_in_new_window eq true} target="_blank"{/if} rel="nofollow">{$title_short}</a>
			{else}
				<a href="{$story_url}" rel="nofollow">{$title_short}</a>
			{/if}
		{else}
			{if $pagename eq "story"}
				<a href="{$url}" rel="nofollow">{$title_short}</a>
			{else} 
			  <a href="{$story_url}" rel="nofollow">{$title_short}</a>
			{/if}
		{/if}  
			
		{if $link_shakebox_reports > 0 && $story_status ne "published" } 
			{if $link_shakebox_report_value == -11}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_1#}">
			{elseif $link_shakebox_report_value == -12}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_2#}">
			{elseif $link_shakebox_report_value == -13}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_3#}">
			{elseif $link_shakebox_report_value == -14}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_4#}">
			{elseif $link_shakebox_report_value == -15}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_5#}">
			{elseif $link_shakebox_report_value == -16}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_6#}">
			{elseif $link_shakebox_report_value == -17}
					<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="{#PLIGG_Visual_Vote_Bury_7#}">
			{else}
				<img src="{$my_pligg_base}/templates/{$the_template}/images/flag.png" style="border: 0px; height: 16px; width: 16px;" title="Buried">
			{/if}
		{/if}
	</div>
Note that my image is named flag.png and I've set the height and width at 16px each. You might have to adjust the code to suit your image.

Save and upload those files, which were:

/libs/link.php
/templates/your_template/link_summary.tpl
Attached Thumbnails
bury-button-choice-reasons-bury_link_flag_image.gif  
Reply With Quote
The Following User Says Thank You to longcountdown For This Useful Post:
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
External Vote Button (EVB) Yankidank Modification Tutorials 59 07-24-2008 07:51 PM
Change when bury link appears jmundane General Help 5 07-02-2008 10:45 AM
"Report spam" button. AnAlienHolakres3 Modification Tutorials 6 05-22-2008 05:55 PM
Tracking clickthroughs from EVB voting button fingerprn General Help 0 04-18-2008 12:44 PM
A Bury button Pligga General Help 3 07-21-2007 10:13 PM


Search Engine Friendly URLs by vBSEO 3.2.0