Thanks a lot for this mod. I went all the way and made a button in my admin panel that uses this, here's how if someone is interested, as it goes well with this modification also:
http://forums.pligg.com/pligg-mods/1...d-stories.html EDIT # 1: I have edited this post to reflect the changes Ablaye made to this mod just below. If it's bugged, please let me know. STEP 1:
Open admin_links_center.tpl found in your templates admin_templates folder.
Find:
Code:
<a href="javascript:uncheck_all()">Uncheck All</a>
Add after it:
Code:
<br><a href="admin_links.php" onclick="javascript:window.open('admin_discard_upcoming.php', 'resultwindow', 'width=300, height=200')">Discard old Upcoming stories</a>
STEP 2:
Create a new file called admin_discard_upcoming.php in your root folder and add the following:
Code:
<?php
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'ts.php');
include(mnminclude.'link.php');
include(mnminclude.'tags.php');
include(mnminclude.'search.php');
include(mnminclude.'smartyvariables.php');
// require user to log in
force_authentication();
// restrict access to god only
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('god');
// module system hook
check_actions('upcoming_top');
check_actions('index_top');
// Discard upcoming stories after 7 days if they are not published. Change the 7 below if you would like to specify a different number of days
$tsdt = date('Ymd000000', strtotime("-7 day"));
$retire_cond = " WHERE link_status='queued' AND link_date <= $tsdt";
$sql1 = "SELECT count(*) FROM ".table_links.$retire_cond;
$retire_count = $db->get_var($sql1);
if ($retire_count > 0) {
$sql2 = "SELECT total FROM ".table_totals." WHERE name='queued'";
$old_count = $db->get_var($sql2);
$update_count = $old_count - $retire_count;
$sql3 = "UPDATE ".table_totals." SET total='".$update_count."' WHERE name='queued'";
$db->query($sql3);
$sql4 = "UPDATE ".table_links." SET link_status='discard'".$retire_cond;
$db->query($sql4);
}
<p><center>All Old Upcoming Stories Have Been Discarded. <br>You Can Close This Window Now.</center></p>
That's it. Every time you go to your admin panel, under news management, you will find a new link that discards all old stories.