english/libraries/joomla/installer/adapters/plugin.php
/**
	 * Custom uninstall method
	 * @param   integer  $id	The id of the plugin to uninstall

	 * @return  boolean  True on success
	 * @since   11.1
	 */
Custom uninstall method
@param   integer  $id        The id of the plugin to uninstall

@return  boolean  True on success
@since   11.1
Custom uninstall method @param integer $id The id of the plugin to uninstall @return boolean True on success @since 11 . 1
public function uninstall($id)
	{
		$this->route = 'uninstall';
		$row	= null;
		$retval = true;
		$db		= $this->parent->getDbo();
		$row = JTable::getInstance('extension');
		if (!$row->load((int) $id))
		{
			JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_ERRORUNKOWNEXTENSION'));
			return false;
		}
		if ($row->protected)
		{
			JError::raiseWarning(100, JText::sprintf('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_WARNCOREPLUGIN', $row->name));
			return false;
		}
		if (trim($row->folder) == '')
		{
			JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_FOLDER_FIELD_EMPTY'));
			return false;
		}
		if (is_dir(JPATH_PLUGINS . '/' . $row->folder . '/' . $row->element)) {
			$this->parent->setPath('extension_root', JPATH_PLUGINS . '/' . $row->folder . '/' . $row->element);
		}
		else {
			$this->parent->setPath('extension_root', JPATH_PLUGINS . '/' . $row->folder);
		}
		$manifestFile = $this->parent->getPath('extension_root') . '/' . $row->element.'.xml';
		if ( ! file_exists($manifestFile))
		{
			JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_INVALID_NOTFOUND_MANIFEST'));
			return false;
		}
		$xml = JFactory::getXML($manifestFile);
		$this->manifest = $xml;
		if (!$xml)
		{
			JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_LOAD_MANIFEST'));
			return false;
		}
		if ($xml->getName() != 'install' && $xml->getName() != 'extension')
		{
			JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_INVALID_MANIFEST'));
			return false;
		}
		$this->parent->setPath('source', JPATH_PLUGINS .'/'.$row->folder.'/'.$row->element);
		$this->loadLanguage(JPATH_PLUGINS .'/'.$row->folder.'/'.$row->element);
		$manifestScript = (string)$xml->scriptfile;
		if ($manifestScript)
		{
			$manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript;
			if (is_file($manifestScriptFile)) {
				include_once $manifestScriptFile;
			}
			$folderClass = str_replace('-', '', $row->folder);
			$classname = 'plg'.$folderClass.$row->element.'InstallerScript';
			if (class_exists($classname))
			{
				$this->parent->manifestClass = new $classname($this);
				$this->set('manifest_script', $manifestScript);
			}
		}
		ob_start();
		ob_implicit_flush(false);
		if ($this->parent->manifestClass && method_exists($this->parent->manifestClass,'preflight'))
		{
			if($this->parent->manifestClass->preflight($this->route, $this) === false)
			{
				$this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_PLG_INSTALL_CUSTOM_INSTALL_FAILURE'));
				return false;
			}
		}
		$msg = ob_get_contents();
		ob_end_clean();
		$utfresult = $this->parent->parseSQLFiles($xml->{strtolower($this->route)}->sql);
		if ($utfresult === false)
		{
			$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PLG_UNINSTALL_SQL_ERROR', $db->stderr(true)));
			return false;
		}
		ob_start();
		ob_implicit_flush(false);
		if ($this->parent->manifestClass && method_exists($this->parent->manifestClass,'uninstall'))
		{
			$this->parent->manifestClass->uninstall($this);
		}
		$msg = ob_get_contents();
		ob_end_clean();
		$this->parent->removeFiles($xml->images, -1);
		$this->parent->removeFiles($xml->files, -1);
		JFile::delete($manifestFile);
		$this->parent->removeFiles($xml->media);
		$this->parent->removeFiles($xml->languages, 1);
		$query = $db->getQuery(true);
		$query->delete()->from('#__schemas')->where('extension_id = '. $row->extension_id);
		$db->setQuery($query);
		$db->Query();
		$row->delete($row->extension_id);
		unset ($row);
		$files = JFolder::files($this->parent->getPath('extension_root'));
		JFolder::delete($this->parent->getPath('extension_root'));
		if ($msg) {
			$this->parent->set('extension_message',$msg);
		}
		return $retval;
	}
public function uninstall ( $ id ) { $ this -> route = 'uninstall' ; $ row = null ; $ retval = true ; $ db = $ this -> parent -> getDbo ( ) ; $ row = JTable :: getInstance ( 'extension' ) ; if ( ! $ row -> load ( ( int ) $ id ) ) { JError :: raiseWarning ( 100 , JText :: _ ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_ERRORUNKOWNEXTENSION' ) ) ; return false ; } if ( $ row -> protected ) { JError :: raiseWarning ( 100 , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_WARNCOREPLUGIN' , $ row -> name ) ) ; return false ; } if ( trim ( $ row -> folder ) == '' ) { JError :: raiseWarning ( 100 , JText :: _ ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_FOLDER_FIELD_EMPTY' ) ) ; return false ; } if ( is_dir ( JPATH_PLUGINS . '/' . $ row -> folder . '/' . $ row -> element ) ) { $ this -> parent -> setPath ( 'extension_root' , JPATH_PLUGINS . '/' . $ row -> folder . '/' . $ row -> element ) ; } else { $ this -> parent -> setPath ( 'extension_root' , JPATH_PLUGINS . '/' . $ row -> folder ) ; } $ manifestFile = $ this -> parent -> getPath ( 'extension_root' ) . '/' . $ row -> element . '.xml' ; if ( ! file_exists ( $ manifestFile ) ) { JError :: raiseWarning ( 100 , JText :: _ ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_INVALID_NOTFOUND_MANIFEST' ) ) ; return false ; } $ xml = JFactory :: getXML ( $ manifestFile ) ; $ this -> manifest = $ xml ; if ( ! $ xml ) { JError :: raiseWarning ( 100 , JText :: _ ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_LOAD_MANIFEST' ) ) ; return false ; } if ( $ xml -> getName ( ) != 'install' && $ xml -> getName ( ) != 'extension' ) { JError :: raiseWarning ( 100 , JText :: _ ( 'JLIB_INSTALLER_ERROR_PLG_UNINSTALL_INVALID_MANIFEST' ) ) ; return false ; } $ this -> parent -> setPath ( 'source' , JPATH_PLUGINS . '/' . $ row -> folder . '/' . $ row -> element ) ; $ this -> loadLanguage ( JPATH_PLUGINS . '/' . $ row -> folder . '/' . $ row -> element ) ; $ manifestScript = ( string ) $ xml -> scriptfile ; if ( $ manifestScript ) { $ manifestScriptFile = $ this -> parent -> getPath ( 'source' ) . '/' . $ manifestScript ; if ( is_file ( $ manifestScriptFile ) ) { include_once $ manifestScriptFile ; } $ folderClass = str_replace ( '-' , '' , $ row -> folder ) ; $ classname = 'plg' . $ folderClass . $ row -> element . 'InstallerScript' ; if ( class_exists ( $ classname ) ) { $ this -> parent -> manifestClass = new $ classname ( $ this ) ; $ this -> set ( 'manifest_script' , $ manifestScript ) ; } } ob_start ( ) ; ob_implicit_flush ( false ) ; if ( $ this -> parent -> manifestClass && method_exists ( $ this -> parent -> manifestClass , 'preflight' ) ) { if ( $ this -> parent -> manifestClass -> preflight ( $ this -> route , $ this ) === false ) { $ this -> parent -> abort ( JText :: _ ( 'JLIB_INSTALLER_ABORT_PLG_INSTALL_CUSTOM_INSTALL_FAILURE' ) ) ; return false ; } } $ msg = ob_get_contents ( ) ; ob_end_clean ( ) ; $ utfresult = $ this -> parent -> parseSQLFiles ( $ xml -> { strtolower ( $ this -> route ) } -> sql ) ; if ( $ utfresult === false ) { $ this -> parent -> abort ( JText :: sprintf ( 'JLIB_INSTALLER_ABORT_PLG_UNINSTALL_SQL_ERROR' , $ db -> stderr ( true ) ) ) ; return false ; } ob_start ( ) ; ob_implicit_flush ( false ) ; if ( $ this -> parent -> manifestClass && method_exists ( $ this -> parent -> manifestClass , 'uninstall' ) ) { $ this -> parent -> manifestClass -> uninstall ( $ this ) ; } $ msg = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> parent -> removeFiles ( $ xml -> images , - 1 ) ; $ this -> parent -> removeFiles ( $ xml -> files , - 1 ) ; JFile :: delete ( $ manifestFile ) ; $ this -> parent -> removeFiles ( $ xml -> media ) ; $ this -> parent -> removeFiles ( $ xml -> languages , 1 ) ; $ query = $ db -> getQuery ( true ) ; $ query -> delete ( ) -> from ( '#__schemas' ) -> where ( 'extension_id = ' . $ row -> extension_id ) ; $ db -> setQuery ( $ query ) ; $ db -> Query ( ) ; $ row -> delete ( $ row -> extension_id ) ; unset ( $ row ) ; $ files = JFolder :: files ( $ this -> parent -> getPath ( 'extension_root' ) ) ; JFolder :: delete ( $ this -> parent -> getPath ( 'extension_root' ) ) ; if ( $ msg ) { $ this -> parent -> set ( 'extension_message' , $ msg ) ; } return $ retval ; }
Custom uninstall method
 @param   integer  $id        The id of the plugin to uninstall
Custom uninstall method @param integer $id The id of the plugin to uninstall
// Initialise variables. // First order of business will be to load the plugin object table from the database. // This should give us the necessary information to proceed. // Is the plugin we are trying to uninstall a core one?
 // Because that is not a good idea... // Get the plugin folder so we can properly build the plugin path // Set the plugin root path // Use 1.6 plugins // Use Legacy 1.5 plugins // Because 1.5 plugins don't have their own folders we cannot use the standard method of finding an installation manifest // Since 1.6 they do, however until we move to 1.7 and remove 1.6 legacy we still need to use this method. // When we get there it'll be something like "$this->parent->findManifest();$manifest = $this->parent->getManifest();" // If we cannot load the XML file return null /*
		 * Check for a valid XML root tag.
		 * @todo: Remove backwards compatability in a future version
		 * Should be 'extension', but for backward compatability we will accept 'install'.
		 */ // Attempt to load the language file; might have uninstall strings // Installer Trigger Loading // If there is an manifest class file, let's load it; we'll copy it later (don't have dest yet) // Load the file // If a dash is present in the folder, remove it // Set the class name // Create a new instance // And set this so we can copy it later // Note: if we don't find the class, don't bother to copy the file // Run preflight if possible (since we know we're not an update) // Install failed, rollback changes // Create msg object; first use here // Let's run the queries for the module // If Joomla 1.5 compatible, with discreet sql files - execute appropriate // file for utf-8 support or non-utf-8 support // Try for Joomla 1.5 type queries // Second argument is the utf compatible version attribute // Install failed, rollback changes // Start Joomla! 1.6 // Append messages // Remove the plugin files // Remove all media and languages as well // Remove the schema version // Now we will no longer need the plugin object, so let's delete it // If the folder is empty, let's delete it