I've already posted a quick fix answering few questions about this subject:
http://forums.pligg.com/general-help...l-stories.html
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
**** WARNING ****
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'; Then modify the “table_totals” to add a name and total for “pending”
Code:
insert into table_totals (`name`, `total`) values ('pending', 0); Now, we have to make sure that upon finishing the 3rd step of submitting the story, the story status is set to “pending” instead of queued, and the totals in the totals table is adjusted.
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'; Change to:
Code:
totals_adjust_count($linkres->status, -1);
totals_adjust_count('pending', 1);
$linkres->status='pending'; Note: If you started having grey hair or more grey hair from verifying the stories, all you have to do to revert back is changing the above changes to the original code above it. All the below modifications can remain and will be used if you want to manually change the status of the story to “pending” instead of “discard”
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; Save and close.
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> And few lines down, change this code (add the code in red):
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> Change this code (add the code in red)
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> Find this bloc of code and add the code (in red)
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>
Finally, add this function at the end of the file:
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;
}
}
[FONT=Verdana][FONT=Times New Roman]}[/FONT][/FONT] And modify this function (add the code in red):
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;
}
}
[FONT=Verdana][FONT=Times New Roman]}[/FONT][/FONT] Save and close.
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'");
[FONT=Verdana][FONT=Times New Roman]break;[/FONT][/FONT] Locate if ($_GET['action'] == "bulkmod") {
[FONT=Times New Roman][FONT=Verdana]And add this code at the end of the foreach[/FONT][/FONT]
Code:
elseif ($value == "pending") {
$db->query('UPDATE `' . table_links . '` SET `link_status` = "pending" WHERE `link_id` = "'.$key.'"');
[FONT=Verdana][FONT=Times New Roman]}[/FONT][/FONT] Save and Close.
Thanks to method20, who brought the issue of the Tags related to the pending story (http://forums.pligg.com/general-help...on-syndk8.html).
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'";} Save and close.
Upload the files listed at the top to your dev server and test. It works like a charm.