How to set admin approval for all stories
Then, I thought about providing a complete solution for it.
This is applicable only if you want, as administrator, to verify and approve the story before appearing in the “Upcoming”.
The files involved are:
- /submit.php
- /libs/html1.php
- /templates/yourtemplate/admin_templates/admin_links_center.tpl
- /admin_links.php
- /libs/search.php
Always backup your files before making any modifications
First, change the table:
Code:
alter TABLE table prefix_links change link_status link_status enum('discard','queued','published','abuse','duplicated','pending') NOT NULL default 'discard';
Code:
insert into table_totals (`name`, `total`) values ('pending', 0); Open /submit.php and locate function do_submit3() {
Change this code:
Code:
totals_adjust_count($linkres->status, -1);
totals_adjust_count('queued', 1);
$linkres->status='queued'; Code:
totals_adjust_count($linkres->status, -1);
totals_adjust_count('pending', 1);
$linkres->status='pending'; Save and close.
Now, we have to modify the function totals_regenerate() to reflect this in the table_links and table_totals.
Open /libs/html1.php and locate function totals_regenerate(){
Right before the if(caching == 1){
Add this code:
Code:
$name = 'pending';
$count = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE link_status='$name';");
$db->query("UPDATE `" . table_totals . "` set `total` = $count where `name` = '$name';");
$cached_totals[$name] = $count; Up to here, any new submitted story is “pending”. The administrator has to review it and, if approved, change the status to “queued”.
We need to modify few other files to filter (in News Management) by “pending” and also show the radio button to reverse a published or queued story to “pending”.
Open /templates/yourtemplate/admin_templates/admin_links_center.tpl
We have to add an option to the select (dropdown) to be able to filter by “pending”
Add this code anywhere you want after <select name="filter">:
Code:
<option value="pending" {if $templatelite.get.filter eq "pending"} selected="selected" {/if}>Pending</option> Code:
<tr><th>{#PLIGG_Visual_View_Links_Status#}</th><th>{#PLIGG_Visual_View_Links_Author#}</th><th>{#PLIGG_Visual_View_Links_New_Window#}</th><th><center>Publish</center></th><th><center>Queued</center></th><th><center>Pending</center></th><th><center>Discard</center></th></tr> Code:
Find this bloc of code and add the code (in red)
<tr>
<td>{$template_stories[id].link_status}</td>
<td><a href="{$URL_user, $template_stories[id].link_author}">{$template_stories[id].link_author}</a></td>
<td><a href="{$my_pligg_base}/story.php?title={$template_stories[id].link_title_url}" target="_blank">{$template_stories[id].link_title}</a></td>
<td><center><input type="radio" name="link[{$template_stories[id].link_id}]" id="link-{$template_stories[id].link_id}" value="publish"></center></td>
<td><center><input type="radio" name="link[{$template_stories[id].link_id}]" id="link-{$template_stories[id].link_id}" value="queued"></center></td>
<td><center><input type="radio" name="link[{$template_stories[id].link_id}]" id="link-{$template_stories[id].link_id}" value="pending"></center></td>
<td><center><input type="radio" name="link[{$template_stories[id].link_id}]" id="link-{$template_stories[id].link_id}" value="discard"></center></td>
</tr> Code:
<center><a href="javascript:mark_all_publish()">Mark all for Published</a> <a href="javascript:mark_all_queued()">Mark all for Queued</a> <a href="javascript:mark_all_pending()">Mark all for Pending</a> <a href="javascript:mark_all_discard()">Mark all for Discarded</a> <a href="javascript:uncheck_all()">Uncheck All</a></center>
Code:
function mark_all_pending() {
for (var i=0; i< document.bulk_moderate.length; i++) {
if (document.bulk_moderate[i].value == "pending") {
document.bulk_moderate[i].checked = true;
}
}
} Code:
function uncheck_all() {
for (var i=0; i< document.bulk_moderate.length; i++) {
if ((document.bulk_moderate[i].value == "queued")||(document.bulk_moderate[i].value == "pending")||(document.bulk_moderate[i].value == "discard")|| (document.bulk_moderate[i].value == "publish")){
document.bulk_moderate[i].checked = false;
}
}
} Now open /admin_links.php
Locate if(isset($_GET["filter"])) {
And add this (to be able to filter by “pending” from the “News Management”:
Code:
case 'pending':
$filtered = $db->get_results("SELECT link_id FROM " . table_links . " where link_status = 'pending' ORDER BY link_date DESC LIMIT $offset,25");
$rows = $db->get_var("SELECT count(*) FROM " . table_links . " where link_status = 'pending'");
break; And add this code at the end of the foreach
Code:
elseif ($value == "pending") {
$db->query('UPDATE `' . table_links . '` SET `link_status` = "pending" WHERE `link_id` = "'.$key.'"');
} Thanks to method20, who brought the issue of the Tags related to the pending story (Need Help! how to block Auto Pligg submission from Syndk8).
Open /libs/search.php, look the following code and add the part in RED
Code:
if ($this->filterToStatus == 'all') {$from_where .= " link_status!='discard' AND link_status!='pending'";}
Upload the files listed at the top to your dev server and test. It works like a charm.





Linear Mode

