Joomla! Discussion Forums



It is currently Sun Nov 08, 2009 12:44 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
Posted: Wed Sep 28, 2005 11:42 pm 
User avatar
Joomla! Intern
Joomla! Intern
Offline

Joined: Wed Aug 24, 2005 6:27 am
Posts: 54
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


Top
   
 
Posted: Wed Oct 26, 2005 11:33 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Fri Sep 02, 2005 4:29 pm
Posts: 109
this helped out a lot. thank you for taking the time to post this.

_________________
dreary query begone


Top
  E-mail  
 
Posted: Sun Jun 11, 2006 8:47 am 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Sun Jun 11, 2006 8:40 am
Posts: 1
hmm, i tried this it didn't work...


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

Quick reply

 



Who is online

Users browsing this forum: Ajaxlove, holidayrick, praga and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group