diff --git a/administrator/components/com_admin/helpers/html/directory.php b/administrator/components/com_admin/helpers/html/directory.php index 34243641609b0..70eb5e0df9dfe 100644 --- a/administrator/components/com_admin/helpers/html/directory.php +++ b/administrator/components/com_admin/helpers/html/directory.php @@ -29,10 +29,8 @@ public static function writable($writable) { return '' . JText::_('COM_ADMIN_WRITABLE') . ''; } - else - { - return '' . JText::_('COM_ADMIN_UNWRITABLE') . ''; - } + + return '' . JText::_('COM_ADMIN_UNWRITABLE') . ''; } /** @@ -46,22 +44,13 @@ public static function writable($writable) */ public static function message($dir, $message, $visible = true) { - if ($visible) - { - $output = $dir; - } - else - { - $output = ''; - } + $output = $visible ? $dir : ''; if (empty($message)) { return $output; } - else - { - return $output . ' ' . JText::_($message) . ''; - } + + return $output . ' ' . JText::_($message) . ''; } } diff --git a/administrator/components/com_admin/helpers/html/phpsetting.php b/administrator/components/com_admin/helpers/html/phpsetting.php index 425d7b45e765c..312c15c4b94c7 100644 --- a/administrator/components/com_admin/helpers/html/phpsetting.php +++ b/administrator/components/com_admin/helpers/html/phpsetting.php @@ -25,14 +25,7 @@ abstract class JHtmlPhpSetting */ public static function boolean($val) { - if ($val) - { - return JText::_('JON'); - } - else - { - return JText::_('JOFF'); - } + return JText::_($val ? 'JON' : 'JOFF'); } /** @@ -44,14 +37,7 @@ public static function boolean($val) */ public static function set($val) { - if ($val) - { - return JText::_('JYES'); - } - else - { - return JText::_('JNO'); - } + return JText::_($val ? 'JYES' : 'JNO'); } /** @@ -63,14 +49,7 @@ public static function set($val) */ public static function string($val) { - if (empty($val)) - { - return JText::_('JNONE'); - } - else - { - return $val; - } + return !empty($val) ? $val : JText::_('JNONE'); } /** diff --git a/administrator/components/com_admin/helpers/html/system.php b/administrator/components/com_admin/helpers/html/system.php index 4189c9c5859c1..33b7a840d5cca 100644 --- a/administrator/components/com_admin/helpers/html/system.php +++ b/administrator/components/com_admin/helpers/html/system.php @@ -25,13 +25,6 @@ abstract class JHtmlSystem */ public static function server($val) { - if (empty($val)) - { - return JText::_('COM_ADMIN_NA'); - } - else - { - return $val; - } + return !empty($val) ? $val : JText::_('COM_ADMIN_NA'); } } diff --git a/administrator/components/com_admin/models/help.php b/administrator/components/com_admin/models/help.php index 23497cd9775bb..763fe6353355d 100644 --- a/administrator/components/com_admin/models/help.php +++ b/administrator/components/com_admin/models/help.php @@ -127,68 +127,72 @@ public function getLangTag() */ public function &getToc() { - if (is_null($this->toc)) + if (!is_null($this->toc)) { - // Get vars - $lang_tag = $this->getLangTag(); - $help_search = $this->getHelpSearch(); + return $this->toc; + } - // New style - Check for a TOC JSON file - if (file_exists(JPATH_BASE . '/help/' . $lang_tag . '/toc.json')) - { - $data = json_decode(file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/toc.json')); + // Get vars + $lang_tag = $this->getLangTag(); + $help_search = $this->getHelpSearch(); - // Loop through the data array - foreach ($data as $key => $value) - { - $this->toc[$key] = JText::_('COM_ADMIN_HELP_' . $value); - } - } - else + // New style - Check for a TOC JSON file + if (file_exists(JPATH_BASE . '/help/' . $lang_tag . '/toc.json')) + { + $data = json_decode(file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/toc.json')); + + // Loop through the data array + foreach ($data as $key => $value) { - // Get Help files - jimport('joomla.filesystem.folder'); - $files = JFolder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$'); - $this->toc = array(); - - foreach ($files as $file) - { - $buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file); - - if (preg_match('#(.*?)#', $buffer, $m)) - { - $title = trim($m[1]); - - if ($title) - { - // Translate the page title - $title = JText::_($title); - - // Strip the extension - $file = preg_replace('#\.xml$|\.html$#', '', $file); - - if ($help_search) - { - if (JString::strpos(JString::strtolower(strip_tags($buffer)), JString::strtolower($help_search)) !== false) - { - // Add an item in the Table of Contents - $this->toc[$file] = $title; - } - } - else - { - // Add an item in the Table of Contents - $this->toc[$file] = $title; - } - } - } - } + $this->toc[$key] = JText::_('COM_ADMIN_HELP_' . $value); } // Sort the Table of Contents asort($this->toc); + + return $this->toc; + } + + // Get Help files + jimport('joomla.filesystem.folder'); + $files = JFolder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$'); + $this->toc = array(); + + foreach ($files as $file) + { + $buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file); + + if (!preg_match('#(.*?)#', $buffer, $m)) + { + continue; + } + + $title = trim($m[1]); + + if (!$title) + { + continue; + } + + // Translate the page title + $title = JText::_($title); + + // Strip the extension + $file = preg_replace('#\.xml$|\.html$#', '', $file); + + if ($help_search + && JString::strpos(JString::strtolower(strip_tags($buffer)), JString::strtolower($help_search)) === false) + { + continue; + } + + // Add an item in the Table of Contents + $this->toc[$file] = $title; } + // Sort the Table of Contents + asort($this->toc); + return $this->toc; } diff --git a/administrator/components/com_admin/models/sysinfo.php b/administrator/components/com_admin/models/sysinfo.php index 3d5905eaa1a59..2eb42ad00b055 100644 --- a/administrator/components/com_admin/models/sysinfo.php +++ b/administrator/components/com_admin/models/sysinfo.php @@ -67,27 +67,29 @@ class AdminModelSysInfo extends JModelLegacy */ public function &getPhpSettings() { - if (is_null($this->php_settings)) + if (!is_null($this->php_settings)) { - $this->php_settings = array(); - $this->php_settings['safe_mode'] = ini_get('safe_mode') == '1'; - $this->php_settings['display_errors'] = ini_get('display_errors') == '1'; - $this->php_settings['short_open_tag'] = ini_get('short_open_tag') == '1'; - $this->php_settings['file_uploads'] = ini_get('file_uploads') == '1'; - $this->php_settings['magic_quotes_gpc'] = ini_get('magic_quotes_gpc') == '1'; - $this->php_settings['register_globals'] = ini_get('register_globals') == '1'; - $this->php_settings['output_buffering'] = (bool) ini_get('output_buffering'); - $this->php_settings['open_basedir'] = ini_get('open_basedir'); - $this->php_settings['session.save_path'] = ini_get('session.save_path'); - $this->php_settings['session.auto_start'] = ini_get('session.auto_start'); - $this->php_settings['disable_functions'] = ini_get('disable_functions'); - $this->php_settings['xml'] = extension_loaded('xml'); - $this->php_settings['zlib'] = extension_loaded('zlib'); - $this->php_settings['zip'] = function_exists('zip_open') && function_exists('zip_read'); - $this->php_settings['mbstring'] = extension_loaded('mbstring'); - $this->php_settings['iconv'] = function_exists('iconv'); + return $this->php_settings; } + $this->php_settings = array(); + $this->php_settings['safe_mode'] = ini_get('safe_mode') == '1'; + $this->php_settings['display_errors'] = ini_get('display_errors') == '1'; + $this->php_settings['short_open_tag'] = ini_get('short_open_tag') == '1'; + $this->php_settings['file_uploads'] = ini_get('file_uploads') == '1'; + $this->php_settings['magic_quotes_gpc'] = ini_get('magic_quotes_gpc') == '1'; + $this->php_settings['register_globals'] = ini_get('register_globals') == '1'; + $this->php_settings['output_buffering'] = (bool) ini_get('output_buffering'); + $this->php_settings['open_basedir'] = ini_get('open_basedir'); + $this->php_settings['session.save_path'] = ini_get('session.save_path'); + $this->php_settings['session.auto_start'] = ini_get('session.auto_start'); + $this->php_settings['disable_functions'] = ini_get('disable_functions'); + $this->php_settings['xml'] = extension_loaded('xml'); + $this->php_settings['zlib'] = extension_loaded('zlib'); + $this->php_settings['zip'] = function_exists('zip_open') && function_exists('zip_read'); + $this->php_settings['mbstring'] = extension_loaded('mbstring'); + $this->php_settings['iconv'] = function_exists('iconv'); + return $this->php_settings; } @@ -100,16 +102,18 @@ public function &getPhpSettings() */ public function &getConfig() { - if (is_null($this->config)) + if (!is_null($this->config)) { - $registry = new Registry(new JConfig); - $this->config = $registry->toArray(); - $hidden = array('host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass'); + return $this->config; + } - foreach ($hidden as $key) - { - $this->config[$key] = 'xxxxxx'; - } + $registry = new Registry(new JConfig); + $this->config = $registry->toArray(); + $hidden = array('host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass'); + + foreach ($hidden as $key) + { + $this->config[$key] = 'xxxxxx'; } return $this->config; @@ -124,33 +128,26 @@ public function &getConfig() */ public function &getInfo() { - if (is_null($this->info)) + if (!is_null($this->info)) { - $this->info = array(); - $version = new JVersion; - $platform = new JPlatform; - $db = JFactory::getDbo(); - - if (isset($_SERVER['SERVER_SOFTWARE'])) - { - $sf = $_SERVER['SERVER_SOFTWARE']; - } - else - { - $sf = getenv('SERVER_SOFTWARE'); - } - - $this->info['php'] = php_uname(); - $this->info['dbversion'] = $db->getVersion(); - $this->info['dbcollation'] = $db->getCollation(); - $this->info['phpversion'] = phpversion(); - $this->info['server'] = $sf; - $this->info['sapi_name'] = php_sapi_name(); - $this->info['version'] = $version->getLongVersion(); - $this->info['platform'] = $platform->getLongVersion(); - $this->info['useragent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; + return $this->info; } + $this->info = array(); + $version = new JVersion; + $platform = new JPlatform; + $db = JFactory::getDbo(); + + $this->info['php'] = php_uname(); + $this->info['dbversion'] = $db->getVersion(); + $this->info['dbcollation'] = $db->getCollation(); + $this->info['phpversion'] = phpversion(); + $this->info['server'] = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : getenv('SERVER_SOFTWARE'); + $this->info['sapi_name'] = php_sapi_name(); + $this->info['version'] = $version->getLongVersion(); + $this->info['platform'] = $platform->getLongVersion(); + $this->info['useragent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; + return $this->info; } @@ -163,9 +160,7 @@ public function &getInfo() */ public function phpinfoEnabled() { - $disabled = explode(',', ini_get('disable_functions')); - - return !in_array('phpinfo', $disabled); + return !in_array('phpinfo', explode(',', ini_get('disable_functions'))); } /** @@ -177,28 +172,33 @@ public function phpinfoEnabled() */ public function &getPHPInfo() { - if (is_null($this->php_info) && $this->phpinfoEnabled()) + if (!$this->phpinfoEnabled()) { - ob_start(); - date_default_timezone_set('UTC'); - phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES); - $phpInfo = ob_get_contents(); - ob_end_clean(); - preg_match_all('#]*>(.*)#siU', $phpInfo, $output); - $output = preg_replace('#]*>#', '', $output[1][0]); - $output = preg_replace('#(\w),(\w)#', '\1, \2', $output); - $output = preg_replace('#
#', '', $output); - $output = str_replace('
', '', $output); - $output = preg_replace('#
(.*)<\/tr>#', '$1', $output); - $output = str_replace('
', '', $output); - $output = str_replace('', '', $output); - $this->php_info = $output; + $this->php_info = JText::_('COM_ADMIN_PHPINFO_DISABLED'); + + return $this->php_info; } - else + + if (!is_null($this->php_info)) { - $this->php_info = JText::_('COM_ADMIN_PHPINFO_DISABLED'); + return $this->php_info; } + ob_start(); + date_default_timezone_set('UTC'); + phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES); + $phpInfo = ob_get_contents(); + ob_end_clean(); + preg_match_all('#]*>(.*)#siU', $phpInfo, $output); + $output = preg_replace('#]*>#', '', $output[1][0]); + $output = preg_replace('#(\w),(\w)#', '\1, \2', $output); + $output = preg_replace('#
#', '', $output); + $output = str_replace('
', '', $output); + $output = preg_replace('#
(.*)<\/tr>#', '$1', $output); + $output = str_replace('
', '', $output); + $output = str_replace('', '', $output); + $this->php_info = $output; + return $this->php_info; } @@ -211,104 +211,106 @@ public function &getPHPInfo() */ public function getDirectory() { - if (is_null($this->directories)) + if (!is_null($this->directories)) { - $this->directories = array(); + return $this->directories; + } - $registry = JFactory::getConfig(); - $cparams = JComponentHelper::getParams('com_media'); + $this->directories = array(); - $this->_addDirectory('administrator/components', JPATH_ADMINISTRATOR . '/components'); - $this->_addDirectory('administrator/language', JPATH_ADMINISTRATOR . '/language'); + $registry = JFactory::getConfig(); + $cparams = JComponentHelper::getParams('com_media'); - // List all admin languages - $admin_langs = new DirectoryIterator(JPATH_ADMINISTRATOR . '/language'); + $this->_addDirectory('administrator/components', JPATH_ADMINISTRATOR . '/components'); + $this->_addDirectory('administrator/language', JPATH_ADMINISTRATOR . '/language'); - foreach ($admin_langs as $folder) - { - if (!$folder->isDir() || $folder->isDot()) - { - continue; - } + // List all admin languages + $admin_langs = new DirectoryIterator(JPATH_ADMINISTRATOR . '/language'); - $this->_addDirectory('administrator/language/' . $folder->getFilename(), JPATH_ADMINISTRATOR . '/language/' . $folder->getFilename()); + foreach ($admin_langs as $folder) + { + if (!$folder->isDir() || $folder->isDot()) + { + continue; } - // List all manifests folders - $manifests = new DirectoryIterator(JPATH_ADMINISTRATOR . '/manifests'); + $this->_addDirectory('administrator/language/' . $folder->getFilename(), JPATH_ADMINISTRATOR . '/language/' . $folder->getFilename()); + } - foreach ($manifests as $folder) - { - if (!$folder->isDir() || $folder->isDot()) - { - continue; - } + // List all manifests folders + $manifests = new DirectoryIterator(JPATH_ADMINISTRATOR . '/manifests'); - $this->_addDirectory('administrator/manifests/' . $folder->getFilename(), JPATH_ADMINISTRATOR . '/manifests/' . $folder->getFilename()); + foreach ($manifests as $folder) + { + if (!$folder->isDir() || $folder->isDot()) + { + continue; } - $this->_addDirectory('administrator/modules', JPATH_ADMINISTRATOR . '/modules'); - $this->_addDirectory('administrator/templates', JPATH_THEMES); + $this->_addDirectory('administrator/manifests/' . $folder->getFilename(), JPATH_ADMINISTRATOR . '/manifests/' . $folder->getFilename()); + } - $this->_addDirectory('components', JPATH_SITE . '/components'); + $this->_addDirectory('administrator/modules', JPATH_ADMINISTRATOR . '/modules'); + $this->_addDirectory('administrator/templates', JPATH_THEMES); - $this->_addDirectory($cparams->get('image_path'), JPATH_SITE . '/' . $cparams->get('image_path')); + $this->_addDirectory('components', JPATH_SITE . '/components'); - // List all images folders - $image_folders = new DirectoryIterator(JPATH_SITE . '/' . $cparams->get('image_path')); + $this->_addDirectory($cparams->get('image_path'), JPATH_SITE . '/' . $cparams->get('image_path')); - foreach ($image_folders as $folder) - { - if (!$folder->isDir() || $folder->isDot()) - { - continue; - } + // List all images folders + $image_folders = new DirectoryIterator(JPATH_SITE . '/' . $cparams->get('image_path')); - $this->_addDirectory('images/' . $folder->getFilename(), JPATH_SITE . '/' . $cparams->get('image_path') . '/' . $folder->getFilename()); + foreach ($image_folders as $folder) + { + if (!$folder->isDir() || $folder->isDot()) + { + continue; } - $this->_addDirectory('language', JPATH_SITE . '/language'); + $this->_addDirectory('images/' . $folder->getFilename(), JPATH_SITE . '/' . $cparams->get('image_path') . '/' . $folder->getFilename()); + } - // List all site languages - $site_langs = new DirectoryIterator(JPATH_SITE . '/language'); + $this->_addDirectory('language', JPATH_SITE . '/language'); - foreach ($site_langs as $folder) - { - if (!$folder->isDir() || $folder->isDot()) - { - continue; - } + // List all site languages + $site_langs = new DirectoryIterator(JPATH_SITE . '/language'); - $this->_addDirectory('language/' . $folder->getFilename(), JPATH_SITE . '/language/' . $folder->getFilename()); + foreach ($site_langs as $folder) + { + if (!$folder->isDir() || $folder->isDot()) + { + continue; } - $this->_addDirectory('libraries', JPATH_LIBRARIES); + $this->_addDirectory('language/' . $folder->getFilename(), JPATH_SITE . '/language/' . $folder->getFilename()); + } - $this->_addDirectory('media', JPATH_SITE . '/media'); - $this->_addDirectory('modules', JPATH_SITE . '/modules'); - $this->_addDirectory('plugins', JPATH_PLUGINS); + $this->_addDirectory('libraries', JPATH_LIBRARIES); - $plugin_groups = new DirectoryIterator(JPATH_SITE . '/plugins'); + $this->_addDirectory('media', JPATH_SITE . '/media'); + $this->_addDirectory('modules', JPATH_SITE . '/modules'); + $this->_addDirectory('plugins', JPATH_PLUGINS); - foreach ($plugin_groups as $folder) - { - if (!$folder->isDir() || $folder->isDot()) - { - continue; - } + $plugin_groups = new DirectoryIterator(JPATH_SITE . '/plugins'); - $this->_addDirectory('plugins/' . $folder->getFilename(), JPATH_PLUGINS . '/' . $folder->getFilename()); + foreach ($plugin_groups as $folder) + { + if (!$folder->isDir() || $folder->isDot()) + { + continue; } - $this->_addDirectory('templates', JPATH_SITE . '/templates'); - $this->_addDirectory('configuration.php', JPATH_CONFIGURATION . '/configuration.php'); - $this->_addDirectory('cache', JPATH_SITE . '/cache', 'COM_ADMIN_CACHE_DIRECTORY'); - $this->_addDirectory('administrator/cache', JPATH_CACHE, 'COM_ADMIN_CACHE_DIRECTORY'); - - $this->_addDirectory($registry->get('log_path', JPATH_ROOT . '/log'), $registry->get('log_path', JPATH_ROOT . '/log'), 'COM_ADMIN_LOG_DIRECTORY'); - $this->_addDirectory($registry->get('tmp_path', JPATH_ROOT . '/tmp'), $registry->get('tmp_path', JPATH_ROOT . '/tmp'), 'COM_ADMIN_TEMP_DIRECTORY'); + $this->_addDirectory('plugins/' . $folder->getFilename(), JPATH_PLUGINS . '/' . $folder->getFilename()); } + $this->_addDirectory('templates', JPATH_SITE . '/templates'); + $this->_addDirectory('configuration.php', JPATH_CONFIGURATION . '/configuration.php'); + $this->_addDirectory('cache', JPATH_SITE . '/cache', 'COM_ADMIN_CACHE_DIRECTORY'); + $this->_addDirectory('administrator/cache', JPATH_CACHE, 'COM_ADMIN_CACHE_DIRECTORY'); + + $this->_addDirectory($registry->get('log_path', JPATH_ROOT . '/log'), $registry->get('log_path', JPATH_ROOT . '/log'), 'COM_ADMIN_LOG_DIRECTORY'); + $this->_addDirectory($registry->get('tmp_path', JPATH_ROOT . '/tmp'), $registry->get('tmp_path', JPATH_ROOT . '/tmp'), 'COM_ADMIN_TEMP_DIRECTORY'); + return $this->directories; } @@ -343,11 +345,13 @@ private function _addDirectory($name, $path, $message = '') */ public function &getEditor() { - if (is_null($this->editor)) + if (!is_null($this->editor)) { - $this->editor = JFactory::getConfig()->get('editor'); + return $this->editor; } + $this->editor = JFactory::getConfig()->get('editor'); + return $this->editor; } } diff --git a/administrator/components/com_admin/postinstall/languageaccess340.php b/administrator/components/com_admin/postinstall/languageaccess340.php index bad4153699bb0..4de4266b78c42 100644 --- a/administrator/components/com_admin/postinstall/languageaccess340.php +++ b/administrator/components/com_admin/postinstall/languageaccess340.php @@ -39,9 +39,7 @@ function admin_postinstall_languageaccess340_condition() // one row with access set to 0 return true; } - else - { - // All good the query return nothing. - return false; - } + + // All good the query return nothing. + return false; } diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 72e2dc6eb5b54..0aa96b357f388 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -49,11 +49,46 @@ protected function updateDatabase() if (substr($db->name, 0, 5) == 'mysql') { - $db->setQuery('SHOW ENGINES'); + $this->updateDatabaseMySQL(); + } + + $this->uninstallEosPlugin(); + } + + /** + * Method to update MySQL Database + * + * @return void + */ + protected function updateDatabaseMySQL() + { + $db = JFactory::getDbo(); + + $db->setQuery('SHOW ENGINES'); + + try + { + $results = $db->loadObjectList(); + } + catch (Exception $e) + { + echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '
'; + + return; + } + + foreach ($results as $result) + { + if ($result->Support != 'DEFAULT') + { + continue; + } + + $db->setQuery('ALTER TABLE #__update_sites_extensions ENGINE = ' . $result->Engine); try { - $results = $db->loadObjectList(); + $db->execute(); } catch (Exception $e) { @@ -62,27 +97,18 @@ protected function updateDatabase() return; } - foreach ($results as $result) - { - if ($result->Support == 'DEFAULT') - { - $db->setQuery('ALTER TABLE #__update_sites_extensions ENGINE = ' . $result->Engine); - - try - { - $db->execute(); - } - catch (Exception $e) - { - echo JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '
'; - - return; - } - - break; - } - } + break; } + } + + /** + * Uninstall the 2.5 EOS plugin + * + * @return void + */ + protected function uninstallEosPlugin() + { + $db = JFactory::getDbo(); // Check if the 2.5 EOS plugin is present and uninstall it if so $id = $db->setQuery( @@ -92,19 +118,21 @@ protected function updateDatabase() ->where('name = ' . $db->quote('PLG_EOSNOTIFY')) )->loadResult(); - if ($id) + if (!$id) { - // We need to unprotect the plugin so we can uninstall it - $db->setQuery( - $db->getQuery(true) - ->update('#__extensions') - ->set('protected = 0') - ->where($db->quoteName('extension_id') . ' = ' . $id) - )->execute(); - - $installer = new JInstaller; - $installer->uninstall('plugin', $id); + return; } + + // We need to unprotect the plugin so we can uninstall it + $db->setQuery( + $db->getQuery(true) + ->update('#__extensions') + ->set('protected = 0') + ->where($db->quoteName('extension_id') . ' = ' . $id) + )->execute(); + + $installer = new JInstaller; + $installer->uninstall('plugin', $id); } /** @@ -114,153 +142,153 @@ protected function updateDatabase() */ protected function updateManifestCaches() { - $extensions = array(); - - // Components - // `type`, `element`, `folder`, `client_id` - $extensions[] = array('component', 'com_mailto', '', 0); - $extensions[] = array('component', 'com_wrapper', '', 0); - $extensions[] = array('component', 'com_admin', '', 1); - $extensions[] = array('component', 'com_ajax', '', 1); - $extensions[] = array('component', 'com_banners', '', 1); - $extensions[] = array('component', 'com_cache', '', 1); - $extensions[] = array('component', 'com_categories', '', 1); - $extensions[] = array('component', 'com_checkin', '', 1); - $extensions[] = array('component', 'com_contact', '', 1); - $extensions[] = array('component', 'com_cpanel', '', 1); - $extensions[] = array('component', 'com_installer', '', 1); - $extensions[] = array('component', 'com_languages', '', 1); - $extensions[] = array('component', 'com_login', '', 1); - $extensions[] = array('component', 'com_media', '', 1); - $extensions[] = array('component', 'com_menus', '', 1); - $extensions[] = array('component', 'com_messages', '', 1); - $extensions[] = array('component', 'com_modules', '', 1); - $extensions[] = array('component', 'com_newsfeeds', '', 1); - $extensions[] = array('component', 'com_plugins', '', 1); - $extensions[] = array('component', 'com_search', '', 1); - $extensions[] = array('component', 'com_templates', '', 1); - $extensions[] = array('component', 'com_content', '', 1); - $extensions[] = array('component', 'com_config', '', 1); - $extensions[] = array('component', 'com_redirect', '', 1); - $extensions[] = array('component', 'com_users', '', 1); - $extensions[] = array('component', 'com_tags', '', 1); - $extensions[] = array('component', 'com_contenthistory', '', 1); - $extensions[] = array('component', 'com_postinstall', '', 1); + $extensions = array( + // Components + // `type`, `element`, `folder`, `client_id` + array('component', 'com_mailto', '', 0), + array('component', 'com_wrapper', '', 0), + array('component', 'com_admin', '', 1), + array('component', 'com_ajax', '', 1), + array('component', 'com_banners', '', 1), + array('component', 'com_cache', '', 1), + array('component', 'com_categories', '', 1), + array('component', 'com_checkin', '', 1), + array('component', 'com_contact', '', 1), + array('component', 'com_cpanel', '', 1), + array('component', 'com_installer', '', 1), + array('component', 'com_languages', '', 1), + array('component', 'com_login', '', 1), + array('component', 'com_media', '', 1), + array('component', 'com_menus', '', 1), + array('component', 'com_messages', '', 1), + array('component', 'com_modules', '', 1), + array('component', 'com_newsfeeds', '', 1), + array('component', 'com_plugins', '', 1), + array('component', 'com_search', '', 1), + array('component', 'com_templates', '', 1), + array('component', 'com_content', '', 1), + array('component', 'com_config', '', 1), + array('component', 'com_redirect', '', 1), + array('component', 'com_users', '', 1), + array('component', 'com_tags', '', 1), + array('component', 'com_contenthistory', '', 1), + array('component', 'com_postinstall', '', 1), - // Libraries - $extensions[] = array('library', 'simplepie', '', 0); - $extensions[] = array('library', 'phputf8', '', 0); - $extensions[] = array('library', 'joomla', '', 0); - $extensions[] = array('library', 'idna_convert', '', 0); - $extensions[] = array('library', 'fof', '', 0); - $extensions[] = array('library', 'phpass', '', 0); + // Libraries + array('library', 'phpmailer', '', 0), + array('library', 'simplepie', '', 0), + array('library', 'phputf8', '', 0), + array('library', 'joomla', '', 0), + array('library', 'idna_convert', '', 0), + array('library', 'fof', '', 0), - // Modules site - // Site - $extensions[] = array('module', 'mod_articles_archive', '', 0); - $extensions[] = array('module', 'mod_articles_latest', '', 0); - $extensions[] = array('module', 'mod_articles_popular', '', 0); - $extensions[] = array('module', 'mod_banners', '', 0); - $extensions[] = array('module', 'mod_breadcrumbs', '', 0); - $extensions[] = array('module', 'mod_custom', '', 0); - $extensions[] = array('module', 'mod_feed', '', 0); - $extensions[] = array('module', 'mod_footer', '', 0); - $extensions[] = array('module', 'mod_login', '', 0); - $extensions[] = array('module', 'mod_menu', '', 0); - $extensions[] = array('module', 'mod_articles_news', '', 0); - $extensions[] = array('module', 'mod_random_image', '', 0); - $extensions[] = array('module', 'mod_related_items', '', 0); - $extensions[] = array('module', 'mod_search', '', 0); - $extensions[] = array('module', 'mod_stats', '', 0); - $extensions[] = array('module', 'mod_syndicate', '', 0); - $extensions[] = array('module', 'mod_users_latest', '', 0); - $extensions[] = array('module', 'mod_whosonline', '', 0); - $extensions[] = array('module', 'mod_wrapper', '', 0); - $extensions[] = array('module', 'mod_articles_category', '', 0); - $extensions[] = array('module', 'mod_articles_categories', '', 0); - $extensions[] = array('module', 'mod_languages', '', 0); - $extensions[] = array('module', 'mod_tags_popular', '', 0); - $extensions[] = array('module', 'mod_tags_similar', '', 0); + // Modules site + // Site + array('module', 'mod_articles_archive', '', 0), + array('module', 'mod_articles_latest', '', 0), + array('module', 'mod_articles_popular', '', 0), + array('module', 'mod_banners', '', 0), + array('module', 'mod_breadcrumbs', '', 0), + array('module', 'mod_custom', '', 0), + array('module', 'mod_feed', '', 0), + array('module', 'mod_footer', '', 0), + array('module', 'mod_login', '', 0), + array('module', 'mod_menu', '', 0), + array('module', 'mod_articles_news', '', 0), + array('module', 'mod_random_image', '', 0), + array('module', 'mod_related_items', '', 0), + array('module', 'mod_search', '', 0), + array('module', 'mod_stats', '', 0), + array('module', 'mod_syndicate', '', 0), + array('module', 'mod_users_latest', '', 0), + array('module', 'mod_whosonline', '', 0), + array('module', 'mod_wrapper', '', 0), + array('module', 'mod_articles_category', '', 0), + array('module', 'mod_articles_categories', '', 0), + array('module', 'mod_languages', '', 0), + array('module', 'mod_tags_popular', '', 0), + array('module', 'mod_tags_similar', '', 0), - // Administrator - $extensions[] = array('module', 'mod_custom', '', 1); - $extensions[] = array('module', 'mod_feed', '', 1); - $extensions[] = array('module', 'mod_latest', '', 1); - $extensions[] = array('module', 'mod_logged', '', 1); - $extensions[] = array('module', 'mod_login', '', 1); - $extensions[] = array('module', 'mod_menu', '', 1); - $extensions[] = array('module', 'mod_popular', '', 1); - $extensions[] = array('module', 'mod_quickicon', '', 1); - $extensions[] = array('module', 'mod_stats_admin', '', 1); - $extensions[] = array('module', 'mod_status', '', 1); - $extensions[] = array('module', 'mod_submenu', '', 1); - $extensions[] = array('module', 'mod_title', '', 1); - $extensions[] = array('module', 'mod_toolbar', '', 1); - $extensions[] = array('module', 'mod_multilangstatus', '', 1); + // Administrator + array('module', 'mod_custom', '', 1), + array('module', 'mod_feed', '', 1), + array('module', 'mod_latest', '', 1), + array('module', 'mod_logged', '', 1), + array('module', 'mod_login', '', 1), + array('module', 'mod_menu', '', 1), + array('module', 'mod_popular', '', 1), + array('module', 'mod_quickicon', '', 1), + array('module', 'mod_stats_admin', '', 1), + array('module', 'mod_status', '', 1), + array('module', 'mod_submenu', '', 1), + array('module', 'mod_title', '', 1), + array('module', 'mod_toolbar', '', 1), + array('module', 'mod_multilangstatus', '', 1), - // Plug-ins - $extensions[] = array('plugin', 'gmail', 'authentication', 0); - $extensions[] = array('plugin', 'joomla', 'authentication', 0); - $extensions[] = array('plugin', 'ldap', 'authentication', 0); - $extensions[] = array('plugin', 'contact', 'content', 0); - $extensions[] = array('plugin', 'emailcloak', 'content', 0); - $extensions[] = array('plugin', 'loadmodule', 'content', 0); - $extensions[] = array('plugin', 'pagebreak', 'content', 0); - $extensions[] = array('plugin', 'pagenavigation', 'content', 0); - $extensions[] = array('plugin', 'vote', 'content', 0); - $extensions[] = array('plugin', 'codemirror', 'editors', 0); - $extensions[] = array('plugin', 'none', 'editors', 0); - $extensions[] = array('plugin', 'tinymce', 'editors', 0); - $extensions[] = array('plugin', 'article', 'editors-xtd', 0); - $extensions[] = array('plugin', 'image', 'editors-xtd', 0); - $extensions[] = array('plugin', 'pagebreak', 'editors-xtd', 0); - $extensions[] = array('plugin', 'readmore', 'editors-xtd', 0); - $extensions[] = array('plugin', 'categories', 'search', 0); - $extensions[] = array('plugin', 'contacts', 'search', 0); - $extensions[] = array('plugin', 'content', 'search', 0); - $extensions[] = array('plugin', 'newsfeeds', 'search', 0); - $extensions[] = array('plugin', 'tags', 'search', 0); - $extensions[] = array('plugin', 'languagefilter', 'system', 0); - $extensions[] = array('plugin', 'p3p', 'system', 0); - $extensions[] = array('plugin', 'cache', 'system', 0); - $extensions[] = array('plugin', 'debug', 'system', 0); - $extensions[] = array('plugin', 'log', 'system', 0); - $extensions[] = array('plugin', 'redirect', 'system', 0); - $extensions[] = array('plugin', 'remember', 'system', 0); - $extensions[] = array('plugin', 'sef', 'system', 0); - $extensions[] = array('plugin', 'logout', 'system', 0); - $extensions[] = array('plugin', 'contactcreator', 'user', 0); - $extensions[] = array('plugin', 'joomla', 'user', 0); - $extensions[] = array('plugin', 'profile', 'user', 0); - $extensions[] = array('plugin', 'joomla', 'extension', 0); - $extensions[] = array('plugin', 'joomla', 'content', 0); - $extensions[] = array('plugin', 'languagecode', 'system', 0); - $extensions[] = array('plugin', 'joomlaupdate', 'quickicon', 0); - $extensions[] = array('plugin', 'extensionupdate', 'quickicon', 0); - $extensions[] = array('plugin', 'recaptcha', 'captcha', 0); - $extensions[] = array('plugin', 'categories', 'finder', 0); - $extensions[] = array('plugin', 'contacts', 'finder', 0); - $extensions[] = array('plugin', 'content', 'finder', 0); - $extensions[] = array('plugin', 'newsfeeds', 'finder', 0); - $extensions[] = array('plugin', 'tags', 'finder', 0); - $extensions[] = array('plugin', 'totp', 'twofactorauth', 0); - $extensions[] = array('plugin', 'yubikey', 'twofactorauth', 0); + // Plug-ins + array('plugin', 'gmail', 'authentication', 0), + array('plugin', 'joomla', 'authentication', 0), + array('plugin', 'ldap', 'authentication', 0), + array('plugin', 'contact', 'content', 0), + array('plugin', 'emailcloak', 'content', 0), + array('plugin', 'loadmodule', 'content', 0), + array('plugin', 'pagebreak', 'content', 0), + array('plugin', 'pagenavigation', 'content', 0), + array('plugin', 'vote', 'content', 0), + array('plugin', 'codemirror', 'editors', 0), + array('plugin', 'none', 'editors', 0), + array('plugin', 'tinymce', 'editors', 0), + array('plugin', 'article', 'editors-xtd', 0), + array('plugin', 'image', 'editors-xtd', 0), + array('plugin', 'pagebreak', 'editors-xtd', 0), + array('plugin', 'readmore', 'editors-xtd', 0), + array('plugin', 'categories', 'search', 0), + array('plugin', 'contacts', 'search', 0), + array('plugin', 'content', 'search', 0), + array('plugin', 'newsfeeds', 'search', 0), + array('plugin', 'tags', 'search', 0), + array('plugin', 'languagefilter', 'system', 0), + array('plugin', 'p3p', 'system', 0), + array('plugin', 'cache', 'system', 0), + array('plugin', 'debug', 'system', 0), + array('plugin', 'log', 'system', 0), + array('plugin', 'redirect', 'system', 0), + array('plugin', 'remember', 'system', 0), + array('plugin', 'sef', 'system', 0), + array('plugin', 'logout', 'system', 0), + array('plugin', 'contactcreator', 'user', 0), + array('plugin', 'joomla', 'user', 0), + array('plugin', 'profile', 'user', 0), + array('plugin', 'joomla', 'extension', 0), + array('plugin', 'joomla', 'content', 0), + array('plugin', 'languagecode', 'system', 0), + array('plugin', 'joomlaupdate', 'quickicon', 0), + array('plugin', 'extensionupdate', 'quickicon', 0), + array('plugin', 'recaptcha', 'captcha', 0), + array('plugin', 'categories', 'finder', 0), + array('plugin', 'contacts', 'finder', 0), + array('plugin', 'content', 'finder', 0), + array('plugin', 'newsfeeds', 'finder', 0), + array('plugin', 'tags', 'finder', 0), + array('plugin', 'totp', 'twofactorauth', 0), + array('plugin', 'yubikey', 'twofactorauth', 0), - // Templates - $extensions[] = array('template', 'beez3', '', 0); - $extensions[] = array('template', 'hathor', '', 1); - $extensions[] = array('template', 'protostar', '', 0); - $extensions[] = array('template', 'isis', '', 1); + // Templates + array('template', 'beez3', '', 0), + array('template', 'hathor', '', 1), + array('template', 'protostar', '', 0), + array('template', 'isis', '', 1), - // Languages - $extensions[] = array('language', 'en-GB', '', 0); - $extensions[] = array('language', 'en-GB', '', 1); + // Languages + array('language', 'en-GB', '', 0), + array('language', 'en-GB', '', 1), - // Files - $extensions[] = array('file', 'joomla', '', 0); + // Files + array('file', 'joomla', '', 0), - // Packages - // None in core at this time + // Packages + // None in core at this time + ); // Attempt to refresh manifest caches $db = JFactory::getDbo(); @@ -1372,12 +1400,10 @@ public function deleteUnexistingFiles() * Needed for updates post-3.4 * If com_weblinks doesn't exist then assume we can delete the weblinks package manifest (included in the update packages) */ - if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_weblinks/weblinks.php')) + if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_weblinks/weblinks.php') + && JFile::exists(JPATH_MANIFESTS . '/packages/pkg_weblinks.xml')) { - if (JFile::exists(JPATH_MANIFESTS . '/packages/pkg_weblinks.xml')) - { - JFile::delete(JPATH_MANIFESTS . '/packages/pkg_weblinks.xml'); - } + JFile::delete(JPATH_MANIFESTS . '/packages/pkg_weblinks.xml'); } } @@ -1422,21 +1448,23 @@ public function updateAssets() { $asset = JTable::getInstance('Asset'); - if (!$asset->loadByName($component)) + if ($asset->loadByName($component)) { - $asset->name = $component; - $asset->parent_id = 1; - $asset->rules = '{}'; - $asset->title = $component; - $asset->setLocation(1, 'last-child'); + continue; + } + + $asset->name = $component; + $asset->parent_id = 1; + $asset->rules = '{}'; + $asset->title = $component; + $asset->setLocation(1, 'last-child'); - if (!$asset->store()) - { - // Install failed, roll back changes - $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_COMP_INSTALL_ROLLBACK', $db->stderr(true))); + if (!$asset->store()) + { + // Install failed, roll back changes + $this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_COMP_INSTALL_ROLLBACK', $asset->stderr(true))); - return false; - } + return false; } }