Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Pligg Donor longcountdown's Avatar
    Joined
    Nov 2007
    Posts
    75

    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 Images Attached Images

  2. #2
    New Pligger Dijridew's Avatar
    Joined
    Jun 2008
    Posts
    15
    hmmm intresting .. I will look into it.. thanks

  3. #3
    New Pligger moto526's Avatar
    Joined
    Sep 2007
    Posts
    3
    Thanks! This works great!!!

  4. #4
    New Pligger moto526's Avatar
    Joined
    Sep 2007
    Posts
    3
    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

  5. #5
    Pligg Donor davemackey's Avatar
    Joined
    Aug 2007
    Posts
    226
    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.

  6. #6
    New Pligger moto526's Avatar
    Joined
    Sep 2007
    Posts
    3
    I fixed it...

  7. #7
    Pligg Donor longcountdown's Avatar
    Joined
    Nov 2007
    Posts
    75
    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.

  8. #8
    Pligg Donor longcountdown's Avatar
    Joined
    Nov 2007
    Posts
    75

    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 Images Attached Images

  9. #9
    New Pligger dano9258's Avatar
    Joined
    Nov 2010
    Posts
    3
    It still just goes down by 1 vote when i set it at -11....any thoughts??

  10. #10
    Constant Pligger gaurangitech's Avatar
    Joined
    Aug 2009
    Posts
    107
    in which ver it's working

Page 1 of 2 12 LastLast

Similar Threads

  1. JavaScript Vote Button and Bury Links Do Not Redirect Properly
    By trueMarketing in forum Questions & Comments
    Replies: 15
    Last Post: 10-12-2009, 06:24 PM
  2. Editor's choice
    By kanadeca in forum Questions & Comments
    Replies: 0
    Last Post: 05-06-2008, 12:19 PM
  3. Need help urgent.. with hosting choice..please
    By lacasuela in forum Questions & Comments
    Replies: 6
    Last Post: 02-12-2008, 07:01 AM
  4. A Bury button
    By Pligga in forum Questions & Comments
    Replies: 3
    Last Post: 07-21-2007, 07:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting