english/components/com_aicontactsafe/models/message.php
// function to delete attached files after the message is sent
function to delete attached files after the message is sent
function to delete attached files after the message is sent
function deleteFileAfterMessageSent( $message_id = 0, $postData ) {
		$message_id = (int)$message_id;
		$db = &JFactory::getDBO();
		jimport('joomla.filesystem.path');
		jimport('joomla.filesystem.file');
		$upload_folder = str_replace('\\',DS,$this->_config_values['upload_attachments']);
		$upload_folder = str_replace('/',DS,$upload_folder);
		$upload_folder = str_replace('&#92;',DS,$upload_folder);
		$path_upload = JPATH_ROOT.DS.$upload_folder;
		$query = 'SELECT id, name FROM #__aicontactsafe_messagefiles WHERE message_id = '.$message_id.' and r_id = '.$postData['r_id'];
		$db->setQuery($query);
		$files = $db->loadObjectList();
		if (count($files) > 0) {
			foreach($files as $file) {
				$delete_file = $path_upload.DS.$file->name;
				JFile::delete($delete_file);
				$query = 'DELETE FROM #__aicontactsafe_messagefiles WHERE id = '.$file->id;
				$db->setQuery($query);
				$db->query();
			}
		}
	}
function deleteFileAfterMessageSent ( $ message_id = 0 , $ postData ) { $ message_id = ( int ) $ message_id ; $ db = & JFactory :: getDBO ( ) ; jimport ( 'joomla.filesystem.path' ) ; jimport ( 'joomla.filesystem.file' ) ; $ upload_folder = str_replace ( '\\' , DS , $ this -> _config_values [ 'upload_attachments' ] ) ; $ upload_folder = str_replace ( '/' , DS , $ upload_folder ) ; $ upload_folder = str_replace ( '&#92;' , DS , $ upload_folder ) ; $ path_upload = JPATH_ROOT . DS . $ upload_folder ; $ query = 'SELECT id, name FROM #__aicontactsafe_messagefiles WHERE message_id = ' . $ message_id . ' and r_id = ' . $ postData [ 'r_id' ] ; $ db -> setQuery ( $ query ) ; $ files = $ db -> loadObjectList ( ) ; if ( count ( $ files ) > 0 ) { foreach ( $ files as $ file ) { $ delete_file = $ path_upload . DS . $ file -> name ; JFile :: delete ( $ delete_file ) ; $ query = 'DELETE FROM #__aicontactsafe_messagefiles WHERE id = ' . $ file -> id ; $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; } } }
function to delete attached files after the message is sent
function to delete attached files after the message is sent
// initialize the database // import joomla clases to manage file system // get the path to attachments upload // get the files to delete