Pligg CMS Forums


Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials



[SOLVED] Complete solution to approve the story after being submitted

Advanced Tutorials for Modifying your Pligg site


Reply
 
LinkBack Thread Tools Display Modes
  #31 (permalink)  
Old 06-16-2008, 11:48 AM
New Pligger
 
Join Date: May 2008
Posts: 2
Hello!

Can you help me please? I've modifid the fist step but now i can't change the next code in phpmyAdmin. I put the type (ENUM) and the value 'pending' in the field ´name´ | and put the type (ENUM) and the value 0 in the field ´total´ and the message error is:

#1062 - Duplicate entry '' for key 1

Please i need to undertans this step.

Regards,

Carlos

Then modify the “table_totals” to add a name and total for “pending”
Code:
insert into table_totals (`name`, `total`) values ('pending', 0); 
Reply With Quote
  #32 (permalink)  
Old 06-18-2008, 10:26 AM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 222
Alter tables

Quote:
Originally Posted by hotelsmadbar View Post
Hello!

Can you help me please? I've modifid the fist step but now i can't change the next code in phpmyAdmin. I put the type (ENUM) and the value 'pending' in the field ´name´ | and put the type (ENUM) and the value 0 in the field ´total´ and the message error is:

#1062 - Duplicate entry '' for key 1

Please i need to undertans this step.

Regards,

Carlos

Then modify the “table_totals” to add a name and total for “pending”
Code:
insert into table_totals (`name`, `total`) values ('pending', 0); 
The first part of your question is how to alter the table_links and add a "pending" value to it. This is not manually done. When you login to phpmyadmin, the default values of the link_status are as follows:
Code:
link_status` enum('discard','queued','published','abuse','duplicated') NOT NULL default 'discard'
So we want to add a "pendig" value to it. We just run the following sql code from within the database (copy the sql code below and paste it in the sql window and run it):
Code:
alter TABLE table prefix_links change link_status link_status enum('discard','queued','published','abuse','duplicated','pending') NOT NULL default 'discard';
Note that the prefix is what you gave your tables upon installation of pligg. The default is "pligg_".

For the second part, just run the sql code from the table_totals (copy the sql code below and paste it in the sql window and run it):
Code:
insert into table_totals (`name`, `total`) values ('pending', 0);
let me know how it goes.
Reply With Quote
  #33 (permalink)  
Old 06-21-2008, 09:30 AM
New Pligger
Pligg Version: 1.0.0
 
Join Date: Jun 2008
Posts: 12
The same solution also for COMMENTS?

I was wondering if you have the same solution also for approving comments after bing submitted?

Quote:
Originally Posted by redwine View Post
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
**** 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.

Upload the files listed at the top to your dev server and test. It works like a charm.

http://bio-network.org
Pligg 1.0.0 RC1 - Wednesday, 04th February, 2009 07:05pm
openSUSE 10.3 x86-64
MySQL 5.0.45
Reply With Quote
  #34 (permalink)  
Old 07-11-2008, 09:23 PM
Casual Pligger
 
Join Date: May 2008
Posts: 51
Great job with this. This is an absolute necessity IMO. Thank you very much!
Reply With Quote
  #35 (permalink)  
Old 07-30-2008, 08:17 PM
Casual Pligger
 
Join Date: May 2008
Posts: 51
Awesome on the tag fix! I highly recommend everyone that gets submitted articles to do this mod.
Reply With Quote
  #36 (permalink)  
Old 08-08-2008, 06:25 AM
New Pligger
 
Join Date: Mar 2008
Posts: 12
Thumbs up

works neatly.. thanks..
i have one question.. do you have any solution for approving the comments after being submitted ?
Reply With Quote
  #37 (permalink)  
Old 11-09-2008, 01:15 PM
Casual Pligger
Pligg Version: 9.8
Pligg Template: yellow
 
Join Date: Dec 2007
Posts: 40
awesome work......Thank you very much
Reply With Quote
  #38 (permalink)  
Old 04-05-2009, 09:17 AM
New Pligger
Pligg Version: 1 rc4
 
Join Date: Apr 2009
Posts: 8
Hello, thank you for your work.

This solution will work also in the last version of pligg? the 1.0.0 RC4 ?

Best Regards.
Reply With Quote
  #39 (permalink)  
Old 05-07-2009, 10:34 PM
Pligg Donor
Pligg Version: 1.0.0
Donation Level 1 
 
Join Date: Apr 2007
Location: Sydney, Australia
Posts: 71
Quote:
Originally Posted by cmedia View Post
Hello, thank you for your work.

This solution will work also in the last version of pligg? the 1.0.0 RC4 ?

Best Regards.
Yes it does.
Reply With Quote
  #40 (permalink)  
Old 06-18-2009, 02:39 PM
New Pligger
Pligg Version: 1.0
 
Join Date: Mar 2009
Posts: 17
does this work with 1.0 Final? i played around with it but for step three of story submission, it creates a link to the story and people can access it that way. is there a way to stop it from creating a page until it is approved from the admin?
Reply With Quote
Reply

Thread Tools
Display Modes


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

Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Use the coupon code PLIGG at Dreamhost.com to receive a discount of up to $84.00 Make a donation to support Pligg CMS development