From Joomla! Documentation

< API15:JInstallerPlugin

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.


Custom uninstall method

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >


uninstall($id, $clientId)
Parameter Name Default Value Description
$id $cid The id of the plugin to uninstall
$clientId $clientId The id of the client (unused)


boolean True on success

Defined in



jimport( 'joomla.installer.adapters.plugin' );

Source Body

function uninstall($id, $clientId )
        // Initialize variables
        $row    = null;
        $retval = true;
        $db             =& $this->parent->getDBO();

        // First order of business will be to load the module object table from the database.
        // This should give us the necessary information to proceed.
        $row = & JTable::getInstance('plugin');
        if ( !$row->load((int) $id) ) {
                JError::raiseWarning(100, JText::_('ERRORUNKOWNEXTENSION'));
                return false;

        // Is the plugin we are trying to uninstall a core one?
        // Because that is not a good idea...
        if ($row->iscore) {
                JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.JText::sprintf('WARNCOREPLUGIN', $row->name)."<br />".JText::_('WARNCOREPLUGIN2'));
                return false;

        // Get the plugin folder so we can properly build the plugin path
        if (trim($row->folder) == '') {
                JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.JText::_('Folder field empty, cannot remove files'));
                return false;

        // Set the plugin root path
        $this->parent->setPath('extension_root', JPATH_ROOT.DS.'plugins'.DS.$row->folder);

        // Because plugins don't have their own folders we cannot use the standard method of finding an installation manifest
        $manifestFile = JPATH_ROOT.DS.'plugins'.DS.$row->folder.DS.$row->element.'.xml';
        if (file_exists($manifestFile))
                $xml =& JFactory::getXMLParser('Simple');

                // If we cannot load the xml file return null
                if (!$xml->loadFile($manifestFile)) {
                        JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.JText::_('Could not load manifest file'));
                        return false;

                 * Check for a valid XML root tag.
                 * @todo: Remove backwards compatability in a future version
                 * Should be 'install', but for backward compatability we will accept 'mosinstall'.
                $root =& $xml->document;
                if ($root->name() != 'install' && $root->name() != 'mosinstall') {
                        JError::raiseWarning(100, JText::_('Plugin').' '.JText::_('Uninstall').': '.JText::_('Invalid manifest file'));
                        return false;

                // Remove the plugin files
                $this->parent->removeFiles($root->getElementByPath('images'), -1);
                $this->parent->removeFiles($root->getElementByPath('files'), -1);

                // Remove all media and languages as well
                $this->parent->removeFiles($root->getElementByPath('languages'), 1);
        } else {
                JError::raiseWarning(100, 'Plugin Uninstall: Manifest File invalid or not found');
                return false;

        // Now we will no longer need the plugin object, so lets delete it
        unset ($row);

        // If the folder is empty, let's delete it
        $files = JFolder::files($this->parent->getPath('extension_root'));
        if (!count($files)) {

        return $retval;

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >


Code Examples