english/administrator/components/com_media/controllers/folder.php
/**
	 * Deletes paths from the current path
	 *
	 * @param string $listFolder The image directory to delete a file from
	 * @since 1.5
	 */
Deletes paths from the current path
@param string $listFolder The image directory to delete a file from
@since 1.5
Deletes paths from the current path @param string $listFolder The image directory to delete a file from @since 1 . 5
function delete()
	{
		JRequest::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
		$user	= JFactory::getUser();
		$tmpl	= JRequest::getCmd('tmpl');
		$paths	= JRequest::getVar('rm', array(), '', 'array');
		$folder = JRequest::getVar('folder', '', '', 'path');
		if ($tmpl == 'component') {
			$this->setRedirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component');
		} else {
			$this->setRedirect('index.php?option=com_media&folder='.$folder);
		}
		if (!$user->authorise('core.delete','com_media'))
		{
			JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
			return false;
		}
		else
		{
			jimport('joomla.client.helper');
			JClientHelper::setCredentialsFromRequest('ftp');
			$ret = true;
			if (count($paths)) {
				JPluginHelper::importPlugin('content');
				$dispatcher	= JDispatcher::getInstance();
				foreach ($paths as $path) {
					if ($path !== JFile::makeSafe($path)) {
						$dirname = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
						JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_WARNDIRNAME', substr($dirname, strlen(COM_MEDIA_BASE))));
						continue;
					}
					$fullPath = JPath::clean(COM_MEDIA_BASE . '/' . $folder . '/' . $path);
					$object_file = new JObject(array('filepath' => $fullPath));
					if (is_file($fullPath))
					{
						$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.file', &$object_file));
						if (in_array(false, $result, true)) {
							JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
							continue;
						}
						$ret &= JFile::delete($fullPath);
						$dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file));
						$this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
					}
					else if (is_dir($fullPath))
					{
						if (count(JFolder::files($fullPath, '.', true, false, array('.svn', 'CVS','.DS_Store','__MACOSX'), array('index.html', '^\..*','.*~'))) == 0)
						{
							$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.folder', &$object_file));
							if (in_array(false, $result, true)) {
								JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
								continue;
							}
							$ret &= !JFolder::delete($fullPath);
							$dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file));
							$this->setMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
						}
						else
						{
							JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY',substr($fullPath, strlen(COM_MEDIA_BASE))));
						}
					}
				}
			}
			return $ret;
		}
	}
function delete ( ) { JRequest :: checkToken ( 'request' ) or jexit ( JText :: _ ( 'JINVALID_TOKEN' ) ) ; $ user = JFactory :: getUser ( ) ; $ tmpl = JRequest :: getCmd ( 'tmpl' ) ; $ paths = JRequest :: getVar ( 'rm' , array ( ) , '' , 'array' ) ; $ folder = JRequest :: getVar ( 'folder' , '' , '' , 'path' ) ; if ( $ tmpl == 'component' ) { $ this -> setRedirect ( 'index.php?option=com_media&view=mediaList&folder=' . $ folder . '&tmpl=component' ) ; } else { $ this -> setRedirect ( 'index.php?option=com_media&folder=' . $ folder ) ; } if ( ! $ user -> authorise ( 'core.delete' , 'com_media' ) ) { JError :: raiseWarning ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED' ) ) ; return false ; } else { jimport ( 'joomla.client.helper' ) ; JClientHelper :: setCredentialsFromRequest ( 'ftp' ) ; $ ret = true ; if ( count ( $ paths ) ) { JPluginHelper :: importPlugin ( 'content' ) ; $ dispatcher = JDispatcher :: getInstance ( ) ; foreach ( $ paths as $ path ) { if ( $ path !== JFile :: makeSafe ( $ path ) ) { $ dirname = htmlspecialchars ( $ path , ENT_COMPAT , 'UTF-8' ) ; JError :: raiseWarning ( 100 , JText :: sprintf ( 'COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_WARNDIRNAME' , substr ( $ dirname , strlen ( COM_MEDIA_BASE ) ) ) ) ; continue ; } $ fullPath = JPath :: clean ( COM_MEDIA_BASE . '/' . $ folder . '/' . $ path ) ; $ object_file = new JObject ( array ( 'filepath' => $ fullPath ) ) ; if ( is_file ( $ fullPath ) ) { $ result = $ dispatcher -> trigger ( 'onContentBeforeDelete' , array ( 'com_media.file' , & $ object_file ) ) ; if ( in_array ( false , $ result , true ) ) { JError :: raiseWarning ( 100 , JText :: plural ( 'COM_MEDIA_ERROR_BEFORE_DELETE' , count ( $ errors = $ object_file -> getErrors ( ) ) , implode ( '<br />' , $ errors ) ) ) ; continue ; } $ ret &= JFile :: delete ( $ fullPath ) ; $ dispatcher -> trigger ( 'onContentAfterDelete' , array ( 'com_media.file' , & $ object_file ) ) ; $ this -> setMessage ( JText :: sprintf ( 'COM_MEDIA_DELETE_COMPLETE' , substr ( $ fullPath , strlen ( COM_MEDIA_BASE ) ) ) ) ; } else if ( is_dir ( $ fullPath ) ) { if ( count ( JFolder :: files ( $ fullPath , '.' , true , false , array ( '.svn' , 'CVS' , '.DS_Store' , '__MACOSX' ) , array ( 'index.html' , '^\..*' , '.*~' ) ) ) == 0 ) { $ result = $ dispatcher -> trigger ( 'onContentBeforeDelete' , array ( 'com_media.folder' , & $ object_file ) ) ; if ( in_array ( false , $ result , true ) ) { JError :: raiseWarning ( 100 , JText :: plural ( 'COM_MEDIA_ERROR_BEFORE_DELETE' , count ( $ errors = $ object_file -> getErrors ( ) ) , implode ( '<br />' , $ errors ) ) ) ; continue ; } $ ret &= ! JFolder :: delete ( $ fullPath ) ; $ dispatcher -> trigger ( 'onContentAfterDelete' , array ( 'com_media.folder' , & $ object_file ) ) ; $ this -> setMessage ( JText :: sprintf ( 'COM_MEDIA_DELETE_COMPLETE' , substr ( $ fullPath , strlen ( COM_MEDIA_BASE ) ) ) ) ; } else { JError :: raiseWarning ( 100 , JText :: sprintf ( 'COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY' , substr ( $ fullPath , strlen ( COM_MEDIA_BASE ) ) ) ) ; } } } } return $ ret ; } }
Deletes paths from the current path
 @param string $listFolder The image directory to delete a file from
 @since 1.5
Deletes paths from the current path @param string $listFolder The image directory to delete a file from @since 1 . 5
// Get some data from the request // We are inside the iframe // User is not authorised to delete // Set FTP credentials, if given // Initialise variables. // Trigger the onContentBeforeDelete event. // There are some errors in the plugins // Trigger the onContentAfterDelete event. // Trigger the onContentBeforeDelete event. // There are some errors in the plugins // Trigger the onContentAfterDelete event. //This makes no sense...