C5 Issue With Automatic Publishing/ Blog Posting

Permalink
When you add a page (blog post) via the sitemap on your dashboard it is immediately published even though you have not yet added content to any areas.

This is a problem if your posts are being automatically indexed - as the new empty post will come up at the top of your page for all to see!

Now I know the correct way to safely add a page is to go directly to the main blog index page and add it from there. However, for clients who are not all too aware, they are likely to publish an empty page via this method!

Any ideas how to lock this off or make all initial file versions "pending approval" by default?

 
cowland replied on at Permalink Reply
Theoretically you could make all users require admin approval but the admin still has the potential to make a mistake. - if you see what I'm getting at..

QUESTION:
1. Is there a way to modify this via a controller to be "pending approval" by default?
Mnkras replied on at Permalink Reply
Mnkras
well, what you can do, (needs 5.4+) is use page events, hook the blog pagetype, and set permissions on it so that guests cannot see it,
cowland replied on at Permalink Reply
thanks mnkras, sounds like that will do the job.

So based uponhttp://www.concrete5.org/documentation/developers/system/events... what needs to be done:

Add
define('ENABLE_APPLICATION_EVENTS', true);
To site.php

Create site_events.php in config folder and add
$event = 'on_page_add';
$class = 'requireApproval';
$method = 'pageAddApproval';
$filename = 'modules/auto_disapprove.php';
Events::extend($event, $class, $method, $filename);

So for the new class extension which I assume will look something like this:

class requireApproval extends Controller {
   function pageAddApproval() {
      ...
   }
}


I had a look athttp://www.concrete5.org/documentation/developers/permissions/conte... to set the new page in question to disapprove but didn't see a function.

Is there anything in the API for set page permissions -> disapprove() or would I go via mySQL query?
cowland replied on at Permalink Reply
I could write the query:

<?php
defined('C5_EXECUTE') or die("Access Denied.");
class requireApproval extends Controller {
   function pageAddApproval() {
      $c = Page::getCurrentPage();
      $newcID = $c->getCollectionID();
      $q = "UPDATE CollectionVersions 
           SET cvIsApproved = 0
           WHERE cID = $newcID";
      mysql_query($q);
   }
}
?>

However, how do you get the new page's cID for the query? - $newcID
cowland replied on at Permalink Reply
.
cowland replied on at Permalink Reply
Ok, bringing this up again since it seems to be an issue with the actual page addition through the dashboard sitemap.

I.e. Adding a site event will not prevent a page from being automatically published on_page_add!!

There seems to be something overriding it once the dashboard form is submitted. I'm currently having another look at this.

Starting with: tools/edit_collection_popup.php

If anyone has any ideas it would be much appreciated!!
RadiantWeb replied on at Permalink Reply
RadiantWeb
not to be rude or add shameless plug. :-P but proBlog has a draft mode for this very reason.

The $$ may very well be worth your time. That is why I made it.

C
Mnkras replied on at Permalink Reply
Mnkras
you can make it so that the person does not have approve priveledges
cowland replied on at Permalink Reply
thanks chad. for the moment the main thing enticing me is the multiple blog capability - although admittedly we don't really need it right now.

The C5 glitch adding pages through sitemap is just a bit of a concern. Does your addon prevent that from happening only via the pro-blog tab or also via the sitemap tab?
RadiantWeb replied on at Permalink Reply
RadiantWeb
ProBlog can maintain as many blogs as you wish. fyi.

regarding blogs...problog would make it so you don't even need the site map visible all together for users whereas this is a concern.

you manage everything from the blog tab.

C
cowland replied on at Permalink Reply
Ok, an update on this. Got a bit frustrated with trying to find what code was running - post page add (via sitemap). [Rendering the on_page_add event code ineffective]

Instead I've gone the unrecommended way and edited out the "Add Page" functionality directly from js/ccm.sitemap.js on line 79. - (Forces the user to do it the safe way - inpage editing directly on the site)

Again, it's not preferred since it removes functionality - but its safer for the client. (Akin to setting permissions)