I have modified two files and have created a "Trash" button on the front end so users can delete their own articles. If anyone is interested, the hack is posted below (please back up each file mentioned before changing them):
Open components\com_content\content.php and under this line:
Code:
case 'save':
Add this line:
Code:
// Trash hack
case 'remove':
removeContent( $id, $sectionid, $option );
break;
//End Trash hack
Then add this code after the 'SaveContent()" function, around line 1450
Code:
// RemoveContent hack
function removeContent( $id, $sectionid, $option ) {
global $database;
$state = '-2';
$ordering = '0';
//seperate contentids
$query = "UPDATE #__content"
. "\n SET state = $state, ordering = $ordering"
. "\n WHERE id = $id"
;
$database->setQuery( $query );
if ( !$database->query() ) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
$msg = $total ." Item(s) sent to the Trash";
$return = mosGetParam( $_POST, 'returntask', '' );
mosRedirect( 'index.php' );
}
// End Remove Content Hack
Save the file.
Now open includes\HTML_toolbar.php, add this code after the savenew() function. Around line 305.
Code:
/**
* Write a trash button that will move items to Trash Manager
*/
function trash () {
$image = mosAdminMenus::ImageCheck( 'delete_f2.png', '/administrator/images/', NULL, NULL, 'Trash', 'remove', 1 );
$js = "javascript:if (confirm('Are you sure you want to delete this item?')){ submitbutton('remove');}";
?>
<td>
<a class="toolbar" href="<?php echo $js; ?>">
<?php echo $image; ?></a>
</td>
<?php
}
Save the file.
Now open components\com_content\content.html.php. Add this code after mosToolBar::apply( 'apply_new' );
Code:
// Add Trash button
mosToolBar::trash();
// End Trash Button
Your code should look like this for the toolbar:
Code:
// Toolbar Top
mosToolBar::startTable();
mosToolBar::save();
mosToolBar::apply( 'apply_new' );
// Add Trash button
mosToolBar::trash();
// End Trash Button
mosToolBar::cancel();
mosToolBar::endtable();
Hope this helps people out.
Silver