I searched around the forum for a good solution towards deleting published and unpublished content from my pligg site after X amount of days. My site relies on content to be removed after 30 days or so, so you can imagine that it's quite a pain to sift through 100's of stories. I then found this link to be quite helpful. The only problem was, I still had to sift though each story to see which one was older than 30 days -- in which case, I had to again use phpMyadmin and do it the hard way. I also found another solution on here that supposedly removed stories automatically with a cron job -- but that solution was written quite some ago and it didn't work for me on v 9.8.2. So anyway, I came up with my own solution of filtering out the content items, so I could then use the helpful mod I mentioned above. So install that mod first then add this feature.
This should make things easier for folks like me who wish to delete their content items after a certain amount of days. You will still have to discard/delete them manually, but at least it should be easier to find them now.
Please note: This is for v 9.8.2. It should work for other previous versions as well, but use at your own risk. Make a backup just in case.
Open admin_links_center.tpl and find this:
Code:
<form action="{$my_pligg_base}/admin_links.php" method="get">
<select name="filter">
<option value="all" {if $templatelite.get.filter eq "all"} selected="selected" {/if}>All</option>
<option value="published" {if $templatelite.get.filter eq "published"} selected="selected" {/if}>Published</option>
<option value="upcoming" {if $templatelite.get.filter eq "upcoming"} selected="selected" {/if}>Queued</option>
<option value="discard" {if $templatelite.get.filter eq "discard"} selected="selected" {/if}>Discard</option>
<option> --- </option>
<option value="today" {if $templatelite.get.filter eq "today"} selected="selected" {/if}>Today</option>
<option value="yesterday" {if $templatelite.get.filter eq "yesterday"} selected="selected" {/if}>Yesterday</option>
<option value="week" {if $templatelite.get.filter eq "week"} selected="selected" {/if}>This Week</option>
</select>
<input type="submit" value="Filter" class="log2">
</form> Code:
<form action="{$my_pligg_base}/admin_links.php" method="get">
<select name="filter">
<option value="all" {if $templatelite.get.filter eq "all"} selected="selected" {/if}>All</option>
<option value="published" {if $templatelite.get.filter eq "published"} selected="selected" {/if}>Published</option>
<option value="upcoming" {if $templatelite.get.filter eq "upcoming"} selected="selected" {/if}>Queued</option>
<option value="discard" {if $templatelite.get.filter eq "discard"} selected="selected" {/if}>Discard</option>
<option value="expired" {if $templatelite.get.filter eq "expired"} selected="selected" {/if}>Expired</option>
<option> --- </option>
<option value="today" {if $templatelite.get.filter eq "today"} selected="selected" {/if}>Today</option>
<option value="yesterday" {if $templatelite.get.filter eq "yesterday"} selected="selected" {/if}>Yesterday</option>
<option value="week" {if $templatelite.get.filter eq "week"} selected="selected" {/if}>This Week</option>
</select>
<input type="submit" value="Filter" class="log2">
</form> Code:
case 'week':
$wknum = date('w', strtotime("now"));
if ($wknum > 0) {
$tsdt = date('Ymd000000', strtotime("-{$wknum} day"));
$fsdt = date('Ymd235959', strtotime("now"));
} else {
$tsdt = date('Ymd000000', strtotime("now"));
$fsdt = date('Ymd235959', strtotime("now"));
}
$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,25");
$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");
break; Code:
case 'week':
$wknum = date('w', strtotime("now"));
if ($wknum > 0) {
$tsdt = date('Ymd000000', strtotime("-{$wknum} day"));
$fsdt = date('Ymd235959', strtotime("now"));
} else {
$tsdt = date('Ymd000000', strtotime("now"));
$fsdt = date('Ymd235959', strtotime("now"));
}
$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,25");
$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");
break;
case 'expired':
$tsdt = date('Ymd000000', strtotime("-99999 day"));
$fsdt = date('Ymd235959', strtotime("-31 day"));
$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,250");
$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");
break; I hope this makes things smoother for some of you who ran into the same problem as I have. It would great if someone could develop a way to set an automatic lifespan for the content and a cron job to delete "expired" stories altogether -- but until this method exists (that actually works), this should help you out for now as it did me.






Linear Mode




