It is interesting that by default, Joomla requires an article to be approved by an administrator before it is published live, but once the article has been published, the author can edit it in any way they choose. It seems to me that any time an article is edited by someone other than an administrator, it should be resubmitted for approval, which is why I created the following plugin:
unpublish.php
defined ('_JEXEC') or die('Restricted Access');
jimport('joomla.plugin.plugin');
class plgContentUnpublish extends JPlugin{
function plgContentUnpublish(&$subject, $params){
parent::__construct($subject,$params);
}
function onAfterContentSave(&$article, $isNew){
global $mainframe;
$user = & JFactory::getUser();
//ID's of users this plugin wont apply to
$allowed_users = array('xx');
if(!in_array($user->id,$allowed_users)){
$db = JFactory::getDBO();
$query = "UPDATE #__content SET state = 0 WHERE id = {$article->id}";
$db->setQuery($query);
$db->query();
JFactory::getApplication()->enqueueMessage(
'Your article will be temporarily unavailable while
our Administrators review your changes.' );
}
return true;
}
}
This plugin will set the article's state to 0, or unpublished each time the article is saved. If the current user's id is found in the $allowed_users array, the update will not take place. That way administrators and editors can make as many updates as they want from the front end without having to re-publish the article in the back end each time.
To install this plugin, copy the code and save as unpublish.php in /plugins/content.
The plugin will also have to be entered into the database under jos_plugins
INSERT INTO jos_plugins
(name,element,folder,access,ordering,published,iscore,client_id, checked_out, checked_out_time, params)
VALUES('Unpublish','unpublish','content','0','1','1','0','0','0','0000-00-00 00:00:00','')
You should also include an XML file with the plugin's details in /plugins/content
unpublish.xml
Unpublish Article After Edit3/10/2011YouThis will unpublish an article after it is edited.
Admin will then be required to approve the article after each edit.unpublish.php