Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-07-2008, 09:21 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
[SOLVED] Complete solution to approve the story after being submitted

I've already posted a quick fix answering few questions about this subject:
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:
  1. /submit.php
  2. /libs/html1.php
  3. /templates/yourtemplate/admin_templates/admin_links_center.tpl
  4. /admin_links.php
  5. /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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:mark_all_queued()">Mark all for Queued</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:mark_all_pending()">Mark all for Pending</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:mark_all_discard()">Mark all for Discarded</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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;
                }
    }
} 
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;
                }
    }
} 
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'");
break; 
Locate if ($_GET['action'] == "bulkmod") {

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.'"');
} 
Save and Close.

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'";}
Save and close.
Upload the files listed at the top to your dev server and test. It works like a charm.

Last edited by redwine; 07-28-2008 at 10:53 PM..
Reply With Quote
The Following 8 Users Say Thank You to redwine For This Useful Post:
  #2 (permalink)  
Old 01-07-2008, 09:25 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 849
Thanks: 74
Thanked 49 Times in 45 Posts
Though I probably wouldn't use this mod, I gave you a thanks for the time and work put into creating it.

Good job.

Geoserv.
Reply With Quote
  #3 (permalink)  
Old 01-09-2008, 04:28 PM
modernste's Avatar
Casual Pligger
Pligg Version: 9.8.2
Pligg Template: yget
 
Join Date: Nov 2007
Posts: 43
Thanks: 6
Thanked 5 Times in 5 Posts
awesome mod, I can really see where this would be a major help with sites getting lots of garbage submissions or sites that only allow a specific type of submission. I'm thinking about where I can use this.
Reply With Quote
  #4 (permalink)  
Old 01-14-2008, 08:27 AM
New Pligger
Pligg Version: Beta 9.9.0
Pligg Template: yget
 
Join Date: Dec 2007
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Wink Sending email when a story is pending

Hi,

Thank you for the nice work. It would be great if the server could send an email to the admin/moderator when a story is submitted and pending.

Any ideas?

Thanks.
Reply With Quote
  #5 (permalink)  
Old 01-14-2008, 08:40 AM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
Quote:
Originally Posted by Skandy View Post
Hi,

Thank you for the nice work. It would be great if the server could send an email to the admin/moderator when a story is submitted and pending.

Any ideas?

Thanks.
It is coming. I am working on it as well as a global options for users to select when they want to receive emails.
Reply With Quote
  #6 (permalink)  
Old 01-14-2008, 08:42 AM
New Pligger
Pligg Version: Beta 9.9.0
Pligg Template: yget
 
Join Date: Dec 2007
Posts: 28
Thanks: 3
Thanked 0 Times in 0 Posts
Thumbs up Cant' wait!

Quote:
Originally Posted by redwine View Post
It is coming. I am working on it as well as a global options for users to select when they want to receive emails.
Cool! Any dates?
Reply With Quote
  #7 (permalink)  
Old 01-14-2008, 07:56 PM
not2serious's Avatar
Pligg Donor
Pligg Version: v0.96 w/modifications
Pligg Template: Yget w/modifications
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 226
Thanks: 16
Thanked 16 Times in 15 Posts
It also would be nice if this approval process could be limited to a "god" level user, a "admin" level user or BOTH. This would have to be a setting in the admin user panel, which can only be edited by a "god" level user.
__________________
My Pligg Site: Critique My Art
My Arts Directory: Links 2 Arts
Reply With Quote
  #8 (permalink)  
Old 01-19-2008, 09:26 AM
Pligg Donor
 
Join Date: Sep 2007
Posts: 184
Thanks: 7
Thanked 37 Times in 26 Posts
Can you please let people know what version this is for in the FIRST POST? Your first step doesn't make sense to those using v9.82, as there is no "table_totals" in the database. Also, will this work for v9.82 or less?

Last edited by blaze; 01-19-2008 at 09:31 AM..
Reply With Quote
  #9 (permalink)  
Old 01-20-2008, 02:52 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
Makin sense!

Quote:
Originally Posted by blaze View Post
Can you please let people know what version this is for in the FIRST POST? Your first step doesn't make sense to those using v9.82, as there is no "table_totals" in the database. Also, will this work for v9.82 or less?
It does make sense to those who asked for it. You can read the version number I am using, and if it applies for you then good for you, if not you can either customize it if you know how or ask for specifics!

Last edited by redwine; 01-20-2008 at 06:13 PM..
Reply With Quote
  #10 (permalink)  
Old 01-24-2008, 04:47 AM
Constant Pligger
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 164
Thanks: 8
Thanked 24 Times in 16 Posts
Nicely done, with this, some people are interested in something like this..
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Direct link to story instead of going throught out.php or /out/ doit Suggestions 10 01-27-2008 05:29 PM
Removing part of the story from summary, but not from the complete story not2serious General Help 10 12-29-2007 10:56 AM
[SOLVED] When I upload a image when submitting a news story... gossipqueenie General Help 3 10-27-2007 11:44 AM
Idea for scalable story promotion jvallery Suggestions 6 04-18-2006 09:41 PM


Search Engine Friendly URLs by vBSEO 3.2.0