/**
  * (non-PHPdoc)
  * @see components/com_jdefender/lib/actions/JD_Action#quarantine()
  */
 function quarantine()
 {
     jimport('joomla.filesystem.file');
     $config =& $this->getConfig();
     $quarantineDir = JPath::clean($config->get('dir_quarantine'));
     if (!JFolder::exists($quarantineDir)) {
         JFolder::create($quarantineDir);
     }
     if (empty($quarantineDir) || !JFolder::exists($quarantineDir)) {
         JError::raiseWarning('ME_D', JText::_('Please set the Quarantine Directory'));
         $this->setError(JText::_('Quarantine directory is not defined'));
         $this->_quarantines = array();
         return false;
     }
     // Get the files to quarantine
     list($files, $ids) = $this->_getFilesAndIds($this->_quarantines);
     // Move 'em all ;)
     $quarantinedFiles = array();
     $filesToRehash = array();
     foreach ($files as $file) {
         $file = JPath::clean($file);
         if (JFile::exists($file)) {
             $destFile = str_replace(JPATH_ROOT, '', $file);
             $destFile = trim($destFile, DS . ' ');
             $destFile = JPath::clean($quarantineDir . DS . $destFile);
             $filesToRehash[] = $file;
             $filesToRehash[] = $destFile;
             if (JFile::exists($destFile)) {
                 JFile::raiseWarning(JText::_('The file has been already quarantined') . ': ' . $destFile);
                 $this->setError(JText::_('The file has been already quarantined') . ': ' . $destFile);
                 return false;
             }
             $info = new stdClass();
             $info->original = $file;
             $info->quarantined = $destFile;
             $info->moved = false;
             $quarantinedFiles[] = $info;
         }
     }
     $rollback = false;
     foreach ($quarantinedFiles as $k => $info) {
         if (!JFolder::exists(dirname($info->quarantined))) {
             JFolder::create(dirname($info->quarantined));
         }
         if (!JFile::move($info->original, $info->quarantined)) {
             $rollback = true;
             $this->setError(JText::_('Cannot move file') . ' ' . $info->original . ' ' . JText::_('to') . ' ' . $info->quarantined);
             break;
         }
         $quarantinedFiles[$k]->moved = true;
     }
     if ($rollback) {
         // Rollback the changes
         foreach ($quarantinedFiles as $k => $info) {
             if ($info->moved) {
                 JFile::move($info->quarantined, $info->original);
             }
         }
         $this->_quarantines = array();
         return false;
     }
     $this->setLogStatus($ids, 'deleted');
     $this->refreshFilesystemTable($filesToRehash, true);
     $this->_quarantines = array();
     return true;
 }