예제 #1
0
 /**
  * Custom uninstall method for components
  *
  * @access	public
  * @param	int		$cid	The id of the component to uninstall
  * @param	int		$clientId	The id of the client (unused)
  * @return	mixed	Return value for uninstall method in component uninstall file
  * @since	1.0
  */
 function uninstall($id, $clientId)
 {
     // Initialize variables
     $db =& $this->parent->getDBO();
     $row = null;
     $retval = true;
     // First order of business will be to load the component object table from the database.
     // This should give us the necessary information to proceed.
     $row =& JTable::getInstance('component');
     if (!$row->load((int) $id)) {
         JError::raiseWarning(100, JText::_('ERRORUNKOWNEXTENSION'));
         return false;
     }
     // Is the component we are trying to uninstall a core one?
     // Because that is not a good idea...
     if ($row->iscore) {
         JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::sprintf('WARNCORECOMPONENT', $row->name) . "<br />" . JText::_('WARNCORECOMPONENT2'));
         return false;
     }
     // Get the admin and site paths for the component
     $this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . DS . 'components' . DS . $row->option));
     $this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . DS . 'components' . DS . $row->option));
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Find and load the XML install file for the component
     $this->parent->setPath('source', $this->parent->getPath('extension_administrator'));
     // Get the package manifest objecct
     $manifest =& $this->parent->getManifest();
     if (!is_a($manifest, 'JSimpleXML')) {
         // Make sure we delete the folders if no manifest exists
         JFolder::delete($this->parent->getPath('extension_administrator'));
         JFolder::delete($this->parent->getPath('extension_site'));
         // Remove the menu
         $this->_removeAdminMenus($row);
         // Raise a warning
         JError::raiseWarning(100, JText::_('ERRORREMOVEMANUALLY'));
         // Return
         return false;
     }
     // Get the root node of the manifest document
     $this->manifest =& $manifest->document;
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Uninstallation Script Section
      * ---------------------------------------------------------------------------------------------
      */
     // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
     $uninstallfileElement =& $this->manifest->getElementByPath('uninstallfile');
     if (is_a($uninstallfileElement, 'JSimpleXMLElement')) {
         // Element exists, does the file exist?
         if (is_file($this->parent->getPath('extension_administrator') . DS . $uninstallfileElement->data())) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_administrator') . DS . $uninstallfileElement->data();
             if (function_exists('com_uninstall')) {
                 if (com_uninstall() === false) {
                     JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Custom Uninstall script unsuccessful'));
                     $retval = false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the uninstall queries for the component
      *	If backward compatibility is required - run queries in xml file
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf support
      */
     $result = $this->parent->parseQueries($this->manifest->getElementByPath('uninstall/queries'));
     if ($result === false) {
         // Install failed, rollback changes
         JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         $retval = false;
     } elseif ($result === 0) {
         // no backward compatibility queries found - try for Joomla 1.5 type queries
         // second argument is the utf compatible version attribute
         $utfresult = $this->parent->parseSQLFiles($this->manifest->getElementByPath('uninstall/sql'));
         if ($utfresult === false) {
             // Install failed, rollback changes
             JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
             $retval = false;
         }
     }
     $this->_removeAdminMenus($row);
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // Let's remove language files and media in the JROOT/images/ folder that are
     // associated with the component we are uninstalling
     $this->parent->removeFiles($this->manifest->getElementByPath('media'));
     $this->parent->removeFiles($this->manifest->getElementByPath('languages'));
     $this->parent->removeFiles($this->manifest->getElementByPath('administration/languages'), 1);
     // Now we need to delete the installation directories.  This is the final step in uninstalling the component.
     if (trim($row->option)) {
         // Delete the component site directory
         if (is_dir($this->parent->getPath('extension_site'))) {
             if (!JFolder::delete($this->parent->getPath('extension_site'))) {
                 JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Unable to remove the component site directory'));
                 $retval = false;
             }
         }
         // Delete the component admin directory
         if (is_dir($this->parent->getPath('extension_administrator'))) {
             if (!JFolder::delete($this->parent->getPath('extension_administrator'))) {
                 JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Unable to remove the component admin directory'));
                 $retval = false;
             }
         }
         return $retval;
     } else {
         // No component option defined... cannot delete what we don't know about
         JError::raiseWarning(100, 'Component Uninstall: Option field empty, cannot remove files');
         return false;
     }
 }
예제 #2
0
 /**
  * Custom uninstall method
  *
  * @access	public
  * @param	int		$cid	The id of the plugin to uninstall
  * @param	int		$clientId	The id of the client (unused)
  * @return	boolean	True on success
  * @since	1.5
  */
 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.
     // ^ Changes to plugin parameters. Use JCEPluginsTable class.
     $row =& JTable::getInstance('plugin', 'JCETable');
     $row->load((int) $id);
     // Is the plugin we are trying to uninstall a core one?
     // Because that is not a good idea...
     if ($row->iscore) {
         JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::sprintf('WARNCOREPLUGIN', $row->title) . "<br />" . JText::_('WARNCOREPLUGIN2'));
         return false;
     }
     // Get the plugin folder so we can properly build the plugin path
     if (trim($row->name) == '') {
         JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::_('Plugin field empty, cannot remove files'));
         return false;
     }
     // Set the plugin root path
     $this->parent->setPath('extension_root', JPATH_PLUGINS . DS . 'editors' . DS . 'jce' . DS . 'tiny_mce' . DS . 'plugins' . DS . $row->name);
     $manifestFile = $this->parent->getPath('extension_root') . DS . $row->name . '.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, 'Plugin 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, 'Plugin Uninstall: ' . JText::_('Invalid manifest file'));
             return false;
         }
         // Remove the plugin files
         $this->parent->removeFiles($root->getElementByPath('files'), -1);
         JFile::delete($manifestFile);
         // Remove all media and languages as well
         $this->parent->removeFiles($root->getElementByPath('languages'), 0);
         /**
          * ---------------------------------------------------------------------------------------------
          * Custom Uninstallation Script Section
          * ---------------------------------------------------------------------------------------------
          */
         // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
         $uninstallfileElement =& $root->getElementByPath('uninstallfile');
         if (is_a($uninstallfileElement, 'JSimpleXMLElement')) {
             // Element exists, does the file exist?
             if (is_file($this->parent->getPath('extension_root') . DS . $uninstallfileElement->data())) {
                 ob_start();
                 ob_implicit_flush(false);
                 require_once $this->parent->getPath('extension_root') . DS . $uninstallfileElement->data();
                 if (function_exists('com_uninstall')) {
                     if (com_uninstall() === false) {
                         JError::raiseWarning(100, JText::_('Plugin') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Custom Uninstall script unsuccessful'));
                         $retval = false;
                     }
                 }
                 $msg = ob_get_contents();
                 ob_end_clean();
                 if ($msg != '') {
                     $this->parent->set('extension.message', $msg);
                 }
             }
         }
         // Remove from Groups
         if ($row->type == 'plugin') {
             JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce' . DS . 'groups');
             $grow =& JTable::getInstance('groups', 'JCETable');
             $query = 'SELECT id, name, plugins, rows' . ' FROM #__jce_groups';
             $db->setQuery($query);
             $groups = $db->loadObjectList();
             foreach ($groups as $group) {
                 $plugins = explode(',', $group->plugins);
                 // Existence check
                 if (in_array($row->id, $plugins)) {
                     // Load tables
                     $grow->load($group->id);
                     // Remove from plugins list
                     foreach ($plugins as $k => $v) {
                         if ($row->id == $v) {
                             unset($plugins[$k]);
                         }
                     }
                     $grow->plugins = implode(',', $plugins);
                     // Remove from rows
                     if ($row->layout) {
                         $lists = array();
                         foreach (explode(';', $group->rows) as $list) {
                             $icons = explode(',', $list);
                             foreach ($icons as $k => $v) {
                                 if ($row->id == $v) {
                                     unset($icons[$k]);
                                 }
                             }
                             $lists[] = implode(',', $icons);
                         }
                         $grow->rows = implode(';', $lists);
                     }
                     if (!$grow->store()) {
                         JError::raiseWarning(100, 'Plugin Install: Unable to remove plugin from Group: ' . $grow->name);
                     }
                 }
             }
         }
         // Now we will no longer need the plugin object, so lets delete it
         $row->delete($row->id);
         unset($row);
     } else {
         JError::raiseWarning(100, 'Plugin Uninstall: Manifest File invalid or not found. Plugin entry removed from database.');
         $row->delete($row->id);
         unset($row);
         $retval = false;
     }
     // If the folder is empty, let's delete it
     $files = JFolder::files($this->parent->getPath('extension_root'));
     if (!count($files)) {
         JFolder::delete($this->parent->getPath('extension_root'));
     }
     return $retval;
 }
예제 #3
0
 /**
  * Custom uninstall method for components
  *
  * @param   integer  $id  The unique extension id of the component to uninstall
  *
  * @return  mixed  Return value for uninstall method in component uninstall file
  *
  * @since   11.1
  */
 public function uninstall($id)
 {
     // Initialise variables.
     $db = $this->parent->getDbo();
     $row = null;
     $retval = true;
     // First order of business will be to load the component object table from the database.
     // This should give us the necessary information to proceed.
     $row = JTable::getInstance('extension');
     if (!$row->load((int) $id)) {
         JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_ERRORUNKOWNEXTENSION'));
         return false;
     }
     // Is the component we are trying to uninstall a core one?
     // Because that is not a good idea...
     if ($row->protected) {
         JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_WARNCORECOMPONENT'));
         return false;
     }
     // Get the admin and site paths for the component
     $this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $row->element));
     $this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . '/components/' . $row->element));
     $this->parent->setPath('extension_root', $this->parent->getPath('extension_administrator'));
     // copy this as its used as a common base
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Find and load the XML install file for the component
     $this->parent->setPath('source', $this->parent->getPath('extension_administrator'));
     // Get the package manifest object
     // We do findManifest to avoid problem when uninstalling a list of extension: getManifest cache its manifest file
     $this->parent->findManifest();
     $this->manifest = $this->parent->getManifest();
     if (!$this->manifest) {
         // Make sure we delete the folders if no manifest exists
         JFolder::delete($this->parent->getPath('extension_administrator'));
         JFolder::delete($this->parent->getPath('extension_site'));
         // Remove the menu
         $this->_removeAdminMenus($row);
         // Raise a warning
         JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_ERRORREMOVEMANUALLY'));
         // Return
         return false;
     }
     // Set the extensions name
     $name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
     if (substr($name, 0, 4) == "com_") {
         $element = $name;
     } else {
         $element = "com_{$name}";
     }
     $this->set('name', $name);
     $this->set('element', $element);
     // Attempt to load the admin language file; might have uninstall strings
     $this->loadLanguage(JPATH_ADMINISTRATOR . '/components/' . $element);
     /**
      * ---------------------------------------------------------------------------------------------
      * Installer Trigger Loading and Uninstall
      * ---------------------------------------------------------------------------------------------
      */
     // If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
     $scriptFile = (string) $this->manifest->scriptfile;
     if ($scriptFile) {
         $manifestScriptFile = $this->parent->getPath('source') . '/' . $scriptFile;
         if (is_file($manifestScriptFile)) {
             // load the file
             include_once $manifestScriptFile;
         }
         // Set the class name
         $classname = $row->element . 'InstallerScript';
         if (class_exists($classname)) {
             // create a new instance
             $this->parent->manifestClass = new $classname($this);
             // and set this so we can copy it later
             $this->set('manifest_script', $scriptFile);
             // Note: if we don't find the class, don't bother to copy the file
         }
     }
     ob_start();
     ob_implicit_flush(false);
     // run uninstall if possible
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'uninstall')) {
         $this->parent->manifestClass->uninstall($this);
     }
     $msg = ob_get_contents();
     ob_end_clean();
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Uninstallation Script Section; Legacy CMS 1.5 Support
      * ---------------------------------------------------------------------------------------------
      */
     // Now let's load the uninstall file if there is one and execute the uninstall function if it exists.
     $uninstallFile = (string) $this->manifest->uninstallfile;
     if ($uninstallFile) {
         // Element exists, does the file exist?
         if (is_file($this->parent->getPath('extension_administrator') . '/' . $uninstallFile)) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_administrator') . '/' . $uninstallFile;
             if (function_exists('com_uninstall')) {
                 if (com_uninstall() === false) {
                     JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_CUSTOM'));
                     $retval = false;
                 }
             }
             // append this in case there was something else
             $msg .= ob_get_contents();
             ob_end_clean();
         }
     }
     if ($msg != '') {
         $this->parent->set('extension_message', $msg);
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the uninstall queries for the component
      * If Joomla CMS 1.5 compatible, with discrete sql files - execute appropriate
      * file for utf-8 support or non-utf support
      */
     // Try for Joomla 1.5 type queries
     // Second argument is the utf compatible version attribute
     if (isset($this->manifest->uninstall->sql)) {
         $utfresult = $this->parent->parseSQLFiles($this->manifest->uninstall->sql);
         if ($utfresult === false) {
             // Install failed, rollback changes
             JError::raiseWarning(100, JText::sprintf('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_SQL_ERROR', $db->stderr(true)));
             $retval = false;
         }
     }
     $this->_removeAdminMenus($row);
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // Let's remove those language files and media in the JROOT/images/ folder that are
     // associated with the component we are uninstalling
     $this->parent->removeFiles($this->manifest->media);
     $this->parent->removeFiles($this->manifest->languages);
     $this->parent->removeFiles($this->manifest->administration->languages, 1);
     // Remove the schema version
     $query = $db->getQuery(true);
     $query->delete()->from('#__schemas')->where('extension_id = ' . $id);
     $db->setQuery($query);
     $db->execute();
     // Remove the component container in the assets table.
     $asset = JTable::getInstance('Asset');
     if ($asset->loadByName($element)) {
         $asset->delete();
     }
     // Remove categories for this component
     $query = $db->getQuery(true);
     $query->delete()->from('#__categories')->where('extension=' . $db->quote($element), 'OR')->where('extension LIKE ' . $db->quote($element . '.%'));
     $db->setQuery($query);
     $db->execute();
     // Check for errors.
     if ($db->getErrorNum()) {
         JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_FAILED_DELETE_CATEGORIES'));
         $this->setError($db->getErrorMsg());
         $retval = false;
     }
     // Clobber any possible pending updates
     $update = JTable::getInstance('update');
     $uid = $update->find(array('element' => $row->element, 'type' => 'component', 'client_id' => '', 'folder' => ''));
     if ($uid) {
         $update->delete($uid);
     }
     // Now we need to delete the installation directories. This is the final step in uninstalling the component.
     if (trim($row->element)) {
         // Delete the component site directory
         if (is_dir($this->parent->getPath('extension_site'))) {
             if (!JFolder::delete($this->parent->getPath('extension_site'))) {
                 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_FAILED_REMOVE_DIRECTORY_SITE'));
                 $retval = false;
             }
         }
         // Delete the component admin directory
         if (is_dir($this->parent->getPath('extension_administrator'))) {
             if (!JFolder::delete($this->parent->getPath('extension_administrator'))) {
                 JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_COMP_UNINSTALL_FAILED_REMOVE_DIRECTORY_ADMIN'));
                 $retval = false;
             }
         }
         // Now we will no longer need the extension object, so let's delete it and free up memory
         $row->delete($row->extension_id);
         unset($row);
         return $retval;
     } else {
         // No component option defined... cannot delete what we don't know about
         JError::raiseWarning(100, 'JLIB_INSTALLER_ERROR_COMP_UNINSTALL_NO_OPTION');
         return false;
     }
 }
예제 #4
0
 /**
  * Uninstall method
  *
  * @access  public
  * @param 	string   $name  The name of the plugin to uninstall
  * @return  boolean True on success
  */
 public function uninstall($name)
 {
     // Initialize variables
     $row = null;
     $retval = true;
     $db = $this->parent->getDBO();
     $parts = explode('.', $name);
     // get name
     $name = array_pop($parts);
     // get type eg: plugin or extension
     $type = array_shift($parts);
     $this->parent->set('name', $name);
     // Load the language file
     $language = JFactory::getLanguage();
     switch ($type) {
         case 'plugin':
             // create $path
             $path = JPATH_COMPONENT_SITE . '/editor/tiny_mce/plugins/' . $name;
             // load language file
             $language->load('com_jce_' . $name, JPATH_SITE);
             break;
         case 'extension':
             $parts[] = $name;
             $path = dirname(JPATH_COMPONENT_SITE . '/editor/extensions/' . implode('/', $parts));
             // load language file
             $language->load('com_jce_' . trim(implode('_', $parts)), JPATH_SITE);
             break;
     }
     // Set the plugin root path
     $this->parent->setPath('extension_root', $path);
     // set manifest path
     $manifest = $this->parent->getPath('extension_root') . '/' . $name . '.xml';
     if (file_exists($manifest)) {
         $xml = WFXMLHelper::getXML($manifest);
         if (!$xml) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
         }
         $this->parent->set('name', (string) $xml->name);
         $this->parent->set('version', (string) $xml->version);
         $this->parent->set('message', (string) $xml->description);
         // can't remove a core plugin
         if ((int) $xml->attributes()->core == 1) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREPLUGIN', WFText::_((string) $xml->name)));
             return false;
         }
         if ($type == 'extension') {
             $this->parent->removeFiles($xml->files, -1);
             JFile::delete($manifest);
         }
         // Remove all media and languages as well
         $this->parent->removeFiles($xml->languages, 0);
         $this->parent->removeFiles($xml->media, 0);
         /**
          * ---------------------------------------------------------------------------------------------
          * Custom Uninstallation Script Section
          * ---------------------------------------------------------------------------------------------
          */
         // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
         $uninstall = (string) $xml->children('uninstall.script');
         if ($uninstall) {
             // Element exists, does the file exist?
             if (is_file($this->parent->getPath('extension_root') . '/' . $uninstall)) {
                 ob_start();
                 ob_implicit_flush(false);
                 require_once $this->parent->getPath('extension_root') . '/' . $uninstall;
                 if (function_exists('com_uninstall')) {
                     if (com_uninstall() === false) {
                         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
                         $retval = false;
                     }
                 }
                 $msg = ob_get_contents();
                 ob_end_clean();
                 if ($msg != '') {
                     $this->parent->set('extension.message', $msg);
                 }
             }
         }
         // remove form profile
         if ($xml->icon) {
             $plugin = new StdClass();
             $plugin->name = (string) $xml->plugin;
             $plugin->icon = (string) $xml->icon;
             $plugin->path = $this->parent->getPath('extension_root');
             wfimport('admin.models.plugins');
             $model = new WFModelPlugins();
             $model->postInstall('uninstall', $plugin, $this);
         }
     } else {
         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_ERROR'));
         $retval = false;
     }
     // set plugin path
     $path = $this->parent->getPath('extension_root');
     // set extension path
     if ($type == 'extension') {
         $path = $this->parent->getPath('extension_root') . '/' . $name;
     }
     if (JFolder::exists($path)) {
         // remove the plugin folder
         if (!JFolder::delete($path)) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_PLUGIN_FOLDER_ERROR'));
             $retval = false;
         }
     }
     return $retval;
 }
예제 #5
0
 /**
  * Custom install method
  * @param int The id of the module
  * @param string The URL option
  * @param int The client id
  */
 function uninstall($cid, $option, $client = 0)
 {
     global $database, $mosConfig_absolute_path;
     $uninstallret = "";
     $sql = "SELECT * FROM #__components WHERE id={$cid}";
     $database->setQuery($sql);
     $row = null;
     if (!$database->loadObject($row)) {
         HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall -  error', $this->returnTo($option, 'component', $client));
         exit;
     }
     if ($row->iscore) {
         HTML_installer::showInstallMessage("Component {$row->name} is a core component, and can not be uninstalled.<br />You need to unpublish it if you don't want to use it", 'Uninstall -  error', $this->returnTo($option, 'component', $client));
         exit;
     }
     // Delete entries in the DB
     $sql = "DELETE FROM #__components WHERE parent={$row->id}";
     $database->setQuery($sql);
     if (!$database->query()) {
         HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall -  error', $this->returnTo($option, 'component', $client));
         exit;
     }
     $sql = "DELETE FROM #__components WHERE id={$row->id}";
     $database->setQuery($sql);
     if (!$database->query()) {
         HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall -  error', $this->returnTo($option, 'component', $client));
         exit;
     }
     // Try to find the uninstall file
     $filesindir = mosReadDirectory($mosConfig_absolute_path . '/administrator/components/' . $row->option, 'uninstall');
     if (count($filesindir) > 0) {
         $uninstall_file = $filesindir[0];
         if (file_exists($mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file)) {
             require_once $mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file;
             $uninstallret = com_uninstall();
         }
     }
     // Try to find the XML file
     $filesindir = mosReadDirectory(mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option), '.xml$');
     if (count($filesindir) > 0) {
         $ismosinstall = false;
         foreach ($filesindir as $file) {
             $xmlDoc =& new DOMIT_Lite_Document();
             $xmlDoc->resolveErrors(true);
             if (!$xmlDoc->loadXML($mosConfig_absolute_path . "/administrator/components/" . $row->option . "/" . $file, false, true)) {
                 return false;
             }
             $element =& $xmlDoc->documentElement;
             if ($element->getTagName() != 'mosinstall') {
                 HTML_installer::showInstallMessage('XML File invalid', 'Uninstall -  error', $this->returnTo($option, 'component', $client));
                 exit;
             }
             $query_element =& $xmlDoc->getElementsbyPath('uninstall/queries', 1);
             if (!is_null($query_element)) {
                 $queries = $query_element->childNodes;
                 foreach ($queries as $query) {
                     $database->setQuery($query->getText());
                     if (!$database->query()) {
                         HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall -  error', $this->returnTo($option, 'component', $client));
                         exit;
                     }
                 }
             }
         }
     } else {
         /*
         HTML_installer::showInstallMessage( 'Could not find XML Setup file in '.$mosConfig_absolute_path.'/administrator/components/'.$row->option,
         	'Uninstall -  error', $option, 'component' );
         exit();
         */
     }
     // Delete directories
     if (trim($row->option)) {
         $result = 0;
         $path = mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option);
         if (is_dir($path)) {
             $result |= deldir($path);
         }
         $path = mosPathName($mosConfig_absolute_path . '/components/' . $row->option);
         if (is_dir($path)) {
             $result |= deldir($path);
         }
         return $result;
     } else {
         HTML_installer::showInstallMessage('Option field empty, cannot remove files', 'Uninstall -  error', $option, 'component');
         exit;
     }
     return $uninstallret;
 }
예제 #6
0
 /**
  * Custom uninstall method for components
  *
  * @access	public
  * @param	int		$id	The unique extension id of the component to uninstall
  * @return	mixed	Return value for uninstall method in component uninstall file
  * @since	1.0
  */
 public function uninstall($id)
 {
     // Initialise variables.
     $db =& $this->parent->getDbo();
     $row = null;
     $retval = true;
     // First order of business will be to load the component object table from the database.
     // This should give us the necessary information to proceed.
     $row =& JTable::getInstance('extension');
     if (!$row->load((int) $id)) {
         JError::raiseWarning(100, JText::_('ERRORUNKOWNEXTENSION'));
         return false;
     }
     // Is the component we are trying to uninstall a core one?
     // Because that is not a good idea...
     if ($row->protected) {
         JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::sprintf('WARNCORECOMPONENT', $row->name) . "<br />" . JText::_('WARNCORECOMPONENT2'));
         return false;
     }
     // Get the admin and site paths for the component
     $this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . DS . 'components' . DS . $row->element));
     $this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . DS . 'components' . DS . $row->element));
     $this->parent->setPath('extension_root', $this->parent->getPath('extension_administrator'));
     // copy this as its used as a common base
     // Attempt to load the admin language file; might have uninstall strings
     $lang =& JFactory::getLanguage();
     // 1.6
     $lang->load($row->element, $this->parent->getPath('extension_administrator'));
     // 1.5 or Core
     $lang->load($row->element);
     /**
      * ---------------------------------------------------------------------------------------------
      * Manifest Document Setup Section
      * ---------------------------------------------------------------------------------------------
      */
     // Find and load the XML install file for the component
     $this->parent->setPath('source', $this->parent->getPath('extension_administrator'));
     // Get the package manifest object
     $this->manifest = $this->parent->getManifest();
     if (!$this->manifest) {
         // Make sure we delete the folders if no manifest exists
         JFolder::delete($this->parent->getPath('extension_administrator'));
         JFolder::delete($this->parent->getPath('extension_site'));
         // Remove the menu
         $this->_removeAdminMenus($row);
         // Raise a warning
         JError::raiseWarning(100, JText::_('ERRORREMOVEMANUALLY'));
         // Return
         return false;
     }
     // Set the extensions name
     $name = JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd');
     $this->set('name', $name);
     /**
      * ---------------------------------------------------------------------------------------------
      * Installer Trigger Loading and Uninstall
      * ---------------------------------------------------------------------------------------------
      */
     // If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
     $scriptFile = (string) $this->manifest->scriptfile;
     if ($scriptFile) {
         $manifestScriptFile = $this->parent->getPath('source') . DS . $scriptFile;
         if (is_file($manifestScriptFile)) {
             // load the file
             include_once $manifestScriptFile;
         }
         // Set the class name
         $classname = $row->element . 'InstallerScript';
         if (class_exists($classname)) {
             // create a new instance
             $this->parent->manifestClass = new $classname($this);
             // and set this so we can copy it later
             $this->set('manifest_script', $scriptFile);
             // Note: if we don't find the class, don't bother to copy the file
         }
     }
     ob_start();
     ob_implicit_flush(false);
     // run uninstall if possible
     if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'uninstall')) {
         $this->parent->manifestClass->uninstall($this);
     }
     $msg = ob_get_contents();
     ob_end_clean();
     /**
      * ---------------------------------------------------------------------------------------------
      * Custom Uninstallation Script Section; Legacy 1.5 Support
      * ---------------------------------------------------------------------------------------------
      */
     // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
     $uninstallFile = (string) $this->manifest->uninstallfile;
     if ($uninstallFile) {
         // Element exists, does the file exist?
         if (is_file($this->parent->getPath('extension_administrator') . DS . $uninstallFile)) {
             ob_start();
             ob_implicit_flush(false);
             require_once $this->parent->getPath('extension_administrator') . DS . $uninstallFile;
             if (function_exists('com_uninstall')) {
                 if (com_uninstall() === false) {
                     JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Custom Uninstall script unsuccessful'));
                     $retval = false;
                 }
             }
             $msg .= ob_get_contents();
             // append this in case there was something else
             ob_end_clean();
         }
     }
     if ($msg != '') {
         $this->parent->set('extension_message', $msg);
     }
     /**
      * ---------------------------------------------------------------------------------------------
      * Database Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     /*
      * Let's run the uninstall queries for the component
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf support
      */
     // try for Joomla 1.5 type queries
     // second argument is the utf compatible version attribute
     $utfresult = $this->parent->parseSQLFiles($this->manifest->uninstall->sql);
     if ($utfresult === false) {
         // Install failed, rollback changes
         JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
         $retval = false;
     }
     $this->_removeAdminMenus($row);
     /**
      * ---------------------------------------------------------------------------------------------
      * Filesystem Processing Section
      * ---------------------------------------------------------------------------------------------
      */
     // Let's remove language files and media in the JROOT/images/ folder that are
     // associated with the component we are uninstalling
     $this->parent->removeFiles($this->manifest->media);
     $this->parent->removeFiles($this->manifest->languages);
     $this->parent->removeFiles($this->manifest->administration->languages, 1);
     // Clobber any possible pending updates
     $update =& JTable::getInstance('update');
     $uid = $update->find(array('element' => $row->element, 'type' => 'component', 'client_id' => '', 'folder' => ''));
     if ($uid) {
         $update->delete($uid);
     }
     // Now we need to delete the installation directories.  This is the final step in uninstalling the component.
     if (trim($row->element)) {
         // Delete the component site directory
         if (is_dir($this->parent->getPath('extension_site'))) {
             if (!JFolder::delete($this->parent->getPath('extension_site'))) {
                 JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('UNABLE_TO_REMOVE_THE_COMPONENT_SITE_DIRECTORY'));
                 $retval = false;
             }
         }
         // Delete the component admin directory
         if (is_dir($this->parent->getPath('extension_administrator'))) {
             if (!JFolder::delete($this->parent->getPath('extension_administrator'))) {
                 JError::raiseWarning(100, JText::_('Component') . ' ' . JText::_('Uninstall') . ': ' . JText::_('UNABLE_TO_REMOVE_THE_COMPONENT_ADMIN_DIRECTORY'));
                 $retval = false;
             }
         }
         // Now we will no longer need the extension object, so lets delete it and free up memory
         $row->delete($row->extension_id);
         unset($row);
         return $retval;
     } else {
         // No component option defined... cannot delete what we don't know about
         JError::raiseWarning(100, 'Component Uninstall: Option field empty, cannot remove files');
         return false;
     }
 }
예제 #7
0
 /**
  * Uninstall method
  *
  * @access  public
  * @param 	string   $name  The name of the plugin to uninstall
  * @return  boolean True on success
  */
 public function uninstall($name)
 {
     // Initialize variables
     $row = null;
     $retval = true;
     $db = $this->parent->getDBO();
     $this->parent->set('name', $name);
     // Set the plugin root path
     $this->parent->setPath('extension_root', JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'tiny_mce' . DS . 'plugins' . DS . $name);
     $manifest = $this->parent->getPath('extension_root') . DS . $name . '.xml';
     // Load the language file
     $language = JFactory::getLanguage();
     $language->load('com_jce_' . trim($name), JPATH_SITE);
     if (file_exists($manifest)) {
         $xml = WFXMLHelper::getXML($manifest);
         if (!$this->setManifest($xml)) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_INVALID'));
         }
         $this->parent->set('name', $this->get('name'));
         $this->parent->set('version', $this->get('version'));
         $this->parent->set('message', $this->get('description'));
         // can't remove a core plugin
         if ($this->get('core') == 1) {
             JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_WARNCOREPLUGIN', WFText::_($this->get('name'))));
             return false;
         }
         // Remove all media and languages as well
         $this->parent->removeFiles($this->get('languages'), 0);
         $this->parent->removeFiles($this->get('media'), 0);
         /**
          * ---------------------------------------------------------------------------------------------
          * Custom Uninstallation Script Section
          * ---------------------------------------------------------------------------------------------
          */
         // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
         $uninstall = $this->get('uninstall.script');
         if ($uninstall) {
             // Element exists, does the file exist?
             if (is_file($this->parent->getPath('extension_root') . DS . $uninstall)) {
                 ob_start();
                 ob_implicit_flush(false);
                 require_once $this->parent->getPath('extension_root') . DS . $uninstall;
                 if (function_exists('com_uninstall')) {
                     if (com_uninstall() === false) {
                         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_CUSTOM_UNINSTALL_ERROR'));
                         $retval = false;
                     }
                 }
                 $msg = ob_get_contents();
                 ob_end_clean();
                 if ($msg != '') {
                     $this->parent->set('extension.message', $msg);
                 }
             }
         }
         // Remove from Groups
         JTable::addIncludePath(WF_ADMINISTRATOR . DS . 'groups');
         $rows = JTable::getInstance('profiles', 'WFTable');
         $query = 'SELECT id, name, plugins, rows' . ' FROM #__wf_profiles';
         $db->setQuery($query);
         $profiles = $db->loadObjectList();
         foreach ($profiles as $profile) {
             $plugins = explode(',', $profile->plugins);
             // Existence check
             if (in_array($this->get('plugin'), $plugins)) {
                 // Load tables
                 $rows->load($profile->id);
                 // Remove from plugins list
                 foreach ($plugins as $k => $v) {
                     if ($this->get('plugin') == $v) {
                         unset($plugins[$k]);
                     }
                 }
                 $rows->plugins = implode(',', $plugins);
                 // Remove from rows
                 if ($this->get('icon')) {
                     $lists = array();
                     foreach (explode(';', $profile->rows) as $list) {
                         $icons = explode(',', $list);
                         foreach ($icons as $k => $v) {
                             if ($this->get('plugin') == $v) {
                                 unset($icons[$k]);
                             }
                         }
                         $lists[] = implode(',', $icons);
                     }
                     $rows->rows = implode(';', $lists);
                 }
                 if (!$rows->store()) {
                     JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . JText::sprintf('WF_INSTALLER_REMOVE_FROM_GROUP_ERROR', $prows->name));
                 }
             }
         }
     } else {
         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_MANIFEST_ERROR'));
         $retval = false;
     }
     // remove the plugin folder
     if (!JFolder::delete($this->parent->getPath('extension_root'))) {
         JError::raiseWarning(100, WFText::_('WF_INSTALLER_PLUGIN_UNINSTALL') . ' : ' . WFText::_('WF_INSTALLER_PLUGIN_FOLDER_ERROR'));
         $retval = false;
     }
     return $retval;
 }
예제 #8
0
 /**
  * Custom uninstall method
  *
  * @access	public
  * @param	int		$cid	The id of the plugin to uninstall
  * @param	int		$clientId	The id of the client (unused)
  * @return	boolean	True on success
  * @since	1.5
  */
 function uninstall($id)
 {
     // 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.
     // ^ Changes to plugin parameters. Use JCK Plugins Table class.
     $row =& JTable::getInstance('plugin', 'JCKTable');
     $row->load((int) $id);
     // Is the plugin we are trying to uninstall a core one?
     // Because that is not a good idea...
     if ($row->iscore) {
         JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::sprintf('WARNCOREPLUGIN', $row->title) . "<br />" . JText::_('WARNCOREPLUGIN2'));
         return false;
     }
     // Get the plugin folder so we can properly build the plugin path
     if (trim($row->name) == '') {
         JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::_('Plugin field empty, cannot remove files'));
         return false;
     }
     //Now delete dependencies
     $query = 'DELETE FROM #__jcktoolbarplugins' . ' WHERE pluginid =' . $row->id;
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseWarning(100, $db->getErrorMsg());
     }
     // Set the plugin root path
     $this->parent->setPath('extension_root', JCK_PLUGINS . DS . $row->name);
     $manifestFile = $this->parent->getPath('extension_root') . DS . $row->name . '.xml';
     if (file_exists($manifestFile)) {
         // If we cannot load the xml file return null
         if (!($xml =& JFactory::getXML($manifestFile))) {
             JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::_('Could not load manifest file'));
             return false;
         }
         $pname = (string) $xml->attributes()->plugin;
         if ((string) $xml->scriptfile) {
             $manifestScript = (string) $xml->scriptfile;
             $manifestScriptFile = $this->parent->getPath('extension_root') . DS . $manifestScript;
             if (is_file($manifestScriptFile)) {
                 // load the file
                 include_once $manifestScriptFile;
             }
             // Set the class name
             $classname = 'plgJCK' . $pname . 'InstallerScript';
             if (class_exists($classname)) {
                 // create a new instance
                 $this->parent->manifestClass = new $classname($this);
                 // and set this so we can copy it later
                 $this->set('manifest_script', $manifestScript);
                 // Note: if we don't find the class, don't bother to copy the file
             }
             // run preflight if possible
             ob_start();
             ob_implicit_flush(false);
             if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
                 if ($this->parent->manifestClass->preflight('uninstall', $this) === false) {
                     // Install failed, rollback changes
                     $this->parent->abort(JText::_('Installer abort for custom plugin install script'));
                     return false;
                 }
             }
             ob_end_clean();
             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();
             // append messages
             ob_end_clean();
         }
         /**  
          *
          * Remove plugin from toolbars file  AW
          *
          */
         $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar';
         $toolbarnames =& JCKHelper::getEditorToolbars();
         foreach ($toolbarnames as $toolbarname) {
             $tmpfilename = $CKfolder . DS . $toolbarname . '.php';
             require_once $tmpfilename;
             $classname = 'JCK' . ucfirst($toolbarname);
             $toolbar = new $classname();
             $pluginTitle = str_replace(' ', '', $row->title);
             $pluginTitle = ucfirst($pluginTitle);
             if (!isset($toolbar->{$pluginTitle})) {
                 continue;
             }
             //fix toolbar values or they will get wiped out
             foreach (get_object_vars($toolbar) as $k => $v) {
                 if (is_null($v)) {
                     $toolbar->{$k} = '';
                 }
                 if ($k[0] == '_') {
                     $toolbar->{$k} = NULL;
                 }
             }
             $toolbar->{$pluginTitle} = NULL;
             $toolbarConfig = new JRegistry('toolbar');
             $toolbarConfig->loadObject($toolbar);
             // Get the config registry in PHP class format and write it to configuation.php
             if (!JFile::write($tmpfilename, $toolbarConfig->toString('PHP', array('class' => $classname . ' extends JCKToolbar')))) {
                 JError::raiseWarning(100, 'Failed to remove ' . $row->name . 'plugin from  ' . $classname . ' toolbar');
             }
         }
         /**
          *
          * Remove plugin from config file  AW
          *
          */
         $config =& JCKHelper::getEditorPluginConfig();
         $config->setValue($row->name, NULL);
         // remove value from output
         $cfgFile = CKEDITOR_LIBRARY . DS . 'plugins' . DS . 'toolbarplugins.php';
         // Get the config registry in PHP class format and write it to configuation.php
         if (!JFile::write($cfgFile, $config->toString('PHP', array('class' => 'JCKToolbarPlugins extends JCKPlugins')))) {
             JError::raiseWarning(100, 'Failed to remove ' . $pname . ' jckeditor plugin from config file');
         }
         /*
          * 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;
         if ($root->getName() != 'extension' && $root->getName() != 'install') {
             JError::raiseWarning(100, 'Plugin Uninstall: ' . JText::_('Invalid manifest file'));
             return false;
         }
         // Remove the plugin files
         $this->parent->removeFiles($root->files, -1);
         JFile::delete($manifestFile);
         // Remove all media and languages as well
         $this->parent->removeFiles($root->languages, 0);
         /**
          * ---------------------------------------------------------------------------------------------
          * Custom Uninstallation Script Section
          * ---------------------------------------------------------------------------------------------
          */
         // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
         $uninstallfileElement =& $root->uninstallfile;
         if (is_a($uninstallfileElement, 'JXMLElement')) {
             // Element exists, does the file exist?
             if (is_file($this->parent->getPath('extension_root') . DS . $uninstallfileElement->data())) {
                 ob_start();
                 ob_implicit_flush(false);
                 require_once $this->parent->getPath('extension_root') . DS . $uninstallfileElement->data();
                 if (function_exists('com_uninstall')) {
                     if (com_uninstall() === false) {
                         JError::raiseWarning(100, JText::_('Plugin') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Custom Uninstall script unsuccessful'));
                         $retval = false;
                     }
                 }
                 $msg = ob_get_contents();
                 ob_end_clean();
                 if ($msg != '') {
                     $this->parent->set('extension.message', $msg);
                 }
             }
         }
     } else {
         JError::raiseWarning(100, 'Plugin Uninstall: Manifest File invalid or not found. Plugin entry removed from database.');
         $row->delete($row->id);
         unset($row);
         $retval = false;
     }
     // Now we will no longer need the plugin object, so lets delete it
     $row->delete($row->id);
     unset($row);
     // If the folder is empty, let's delete it
     $files = JFolder::files($this->parent->getPath('extension_root'));
     if (!count($files)) {
         JFolder::delete($this->parent->getPath('extension_root'));
     }
     //Now delete copy of plugin stored in the component
     $copyPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $pname;
     JFolder::delete($copyPath);
     return $retval;
 }
예제 #9
0
 function uninstall($id, $clientId)
 {
     // Initialize variables
     $db =& $this->parent->getDBO();
     $basepath = JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef_ext';
     $xmlFile = $basepath . DS . $id;
     $ext = str_replace('.xml', '', $id);
     $retval = true;
     $xml =& JFactory::getXMLParser('Simple');
     if (!$xml->loadFile($xmlFile)) {
         unset($xml);
         JError::raiseWarning(100, JText::_('Unable to load XML file.'));
         return false;
     }
     $root =& $xml->document;
     // Now lets load the uninstall file if there is one and execute the uninstall function if it exists.
     $uninstallfileElement =& $root->getElementByPath('uninstallfile');
     if (is_a($uninstallfileElement, 'JSimpleXMLElement')) {
         // Element exists, does the file exist?
         if (is_file($basepath . DS . $uninstallfileElement->data())) {
             ob_start();
             ob_implicit_flush(false);
             require_once $basepath . DS . $uninstallfileElement->data();
             if (function_exists('com_uninstall')) {
                 if (com_uninstall() === false) {
                     JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Custom Uninstall script unsuccessful'));
                     $retval = false;
                 }
             }
             $msg = ob_get_contents();
             ob_end_clean();
             if ($msg != '') {
                 $this->parent->set('extension.message', $msg);
             }
         }
     }
     /*
      * Let's run the uninstall queries for the component
      *	If backward compatibility is required - run queries in xml file
      *	If Joomla 1.5 compatible, with discreet sql files - execute appropriate
      *	file for utf-8 support or non-utf support
      */
     $result = $this->parent->parseQueries($root->getElementByPath('uninstall/queries'));
     if ($result === false) {
         // Install failed, rollback changes
         JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         $retval = false;
     } elseif ($result === 0) {
         // no backward compatibility queries found - try for Joomla 1.5 type queries
         // second argument is the utf compatible version attribute
         $utfresult = $this->parent->parseSQLFiles($root->getElementByPath('uninstall/sql'));
         if ($utfresult === false) {
             // Install failed, rollback changes
             JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQLERRORORFILE') . " " . $db->stderr(true));
             $retval = false;
         }
     }
     // Now remove files
     $fileselement = $root->getElementByPath('files');
     if (is_a($fileselement, 'JSimpleXMLElement')) {
         $files = $fileselement->children();
         if (count($files) > 0) {
             foreach ($files as $file) {
                 $filename = $file->data();
                 if (file_exists($basepath . DS . $filename)) {
                     if (!JFile::delete($basepath . DS . $filename)) {
                         JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Could not delete file') . ': ' . $filename);
                         $retval = false;
                     }
                 }
             }
         }
     }
     // Remove the XML file
     if (!JFile::delete($xmlFile)) {
         JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('Could not delete file') . ': ' . $id);
         $retval = false;
     }
     // Remove the extension's texts
     $query = "DELETE FROM `#__sefexttexts` WHERE `extension` = " . $db->Quote($ext);
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseWarning(100, JText::_('SEF Extension') . ' ' . JText::_('Uninstall') . ': ' . JText::_('SQL Error') . " " . $db->stderr(true));
         $retval = false;
     }
     return $retval;
 }
예제 #10
0
파일: install.php 프로젝트: 01J/bealtine
 function uninstall($parent)
 {
     com_uninstall();
 }
예제 #11
0
파일: install.php 프로젝트: naka211/kkvn
 public function uninstall()
 {
     com_uninstall();
 }
예제 #12
0
 function uninstall_component()
 {
     $com_name = 'com_' . str_replace(' ', '', strtolower($this->getName('component')));
     $this->user_dir = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/components/' . $com_name);
     $this->admin_dir = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $com_name);
     if ($this->uninstallfile) {
         $ufile = mosPathName($this->admin_dir) . $this->uninstallfile;
         if (is_file($ufile)) {
             require_once $ufile;
             com_uninstall();
         }
     }
     $database =& mamboDatabase::getInstance();
     foreach ($this->queries as $query) {
         $database->setQuery($query[0]);
         if (!$database->query()) {
             $this->errors->addErrorDetails(sprintf(T_('Uninstaller error with %s: %s %s SQL error %s'), $this->xmlfile, 'component', $com_name, $database->stderr(true)), _MOS_ERROR_SEVERE);
         }
     }
     $udir = new mosDirectory($this->user_dir);
     $udir->deleteAll();
     $adir = new mosDirectory($this->admin_dir);
     $adir->deleteAll();
     $sql = "DELETE FROM #__components WHERE `option`='{$com_name}'";
     $database->setQuery($sql);
     if (!$database->query()) {
         $this->errors->addErrorDetails(sprintf(T_('Uninstaller error with %s: %s %s not fully deleted from database'), $this->xmlfile, 'component', $com_name), _MOS_ERROR_SEVERE);
         return;
     }
     $this->errors->addErrorDetails($this->getDescription('component'), _MOS_ERROR_INFORM);
 }