Esempio n. 1
0
 public static function restoreSettings()
 {
     JCommentsSecurity::checkToken();
     $db = JCommentsFactory::getDBO();
     $db->setQuery("DELETE FROM `#__jcomments_settings`");
     $db->query();
     require_once dirname(__FILE__) . '/admin.jcomments.installer.php';
     $defaultSettings = dirname(__FILE__) . '/install/sql/settings.sql';
     JCommentsInstaller::executeSQL($defaultSettings);
     require_once dirname(__FILE__) . '/install/helpers/installer.php';
     JCommentsInstallerHelper::fixUsergroups();
     return JText::_('A_SETTINGS_RESTORED');
 }
 public static function postInstall()
 {
     $app = JCommentsFactory::getApplication('administrator');
     $db = JCommentsFactory::getDBO();
     $installer = new HTML_JCommentsInstaller();
     JCommentsInstallerHelper::extractJCommentsPlugins();
     // create database tables
     if (JCOMMENTS_JVERSION == '1.0') {
         $sql = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.nonutf8.sql';
         JCommentsInstaller::executeSQL($sql);
         // collation synchronization (for MySQL 4.1.2 or higher)
         if (version_compare(preg_replace('~\\-.+?$~', '', $db->getVersion()), '4.1.2') >= 0) {
             JCommentsInstallerDatabaseHelper::setupCollation();
         }
     } else {
         $config = JFactory::getConfig();
         $app = JFactory::getApplication();
         @ob_start();
         if ($config->getValue('config.legacy')) {
             $installSQL = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.utf8.sql';
             JCommentsInstaller::executeSQL($installSQL);
         }
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.file');
         $jomSocialRuleSrc = dirname(__FILE__) . DS . 'install' . DS . 'xml' . DS . 'jomsocial_rule.xm';
         $jomSocialRuleDst = JCOMMENTS_BASE . DS . 'jomsocial_rule.xml';
         if (!is_file($jomSocialRuleDst)) {
             JFile::copy($jomSocialRuleSrc, $jomSocialRuleDst);
         }
         if (is_dir(JCOMMENTS_BASE . DS . 'languages')) {
             JFolder::delete(JCOMMENTS_BASE . DS . 'languages');
         }
         if (is_file(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip')) {
             JFile::delete(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip');
         }
         @ob_end_clean();
         $app->setUserState('com_installer.message', '');
         $app->setUserState('com_installer.extension_message', '');
         $app->setUserState('com_installer.redirect_url', '');
     }
     $jxml10 = dirname(__FILE__) . DS . 'jcomments10.xml';
     $jxml15 = dirname(__FILE__) . DS . 'jcomments15.xml';
     $jxml = dirname(__FILE__) . DS . 'jcomments.xml';
     if (is_file($jxml10)) {
         @rename($jxml10, $jxml);
     } else {
         if (is_file($jxml15)) {
             @rename($jxml15, $jxml);
             // fix version in xml manifest file
             if (JCOMMENTS_JVERSION == '1.7') {
                 $contents = str_replace('1.5.0', '1.7.0', implode('', file($jxml)));
                 $fh = fopen($jxml, 'w');
                 if ($fh) {
                     fputs($fh, $contents);
                     fclose($fh);
                 }
             }
         }
     }
     unset($jxml10, $jxml15, $jxml);
     if (JCOMMENTS_JVERSION != '1.7') {
         // remove files from previous version
         $files = array(dirname(__FILE__) . DS . 'admin.jcomments.subcription.php', dirname(__FILE__) . DS . 'table' . DS . 'custombbcodes.php', JCOMMENTS_BASE . DS . 'model' . DS . 'index.html', JCOMMENTS_BASE . DS . 'model' . DS . 'jcomments.php', JCOMMENTS_BASE . DS . 'model');
         foreach ($files as $file) {
             if (is_file($file)) {
                 @unlink($file);
             } else {
                 if (is_dir($file)) {
                     @rmdir($file);
                 }
             }
         }
     }
     // small stuff for future update system
     $db->setQuery('SELECT `version` FROM `#__jcomments_version`');
     $version = $db->loadResult();
     require_once dirname(__FILE__) . DS . 'version.php';
     $jcommentsVersion = new JCommentsVersion();
     $currentVersion = $jcommentsVersion->getVersion();
     $currentDate = date('Y-m-d H:i:s');
     if (empty($version)) {
         $db->setQuery("INSERT IGNORE INTO `#__jcomments_version` (`version`,`installed`) VALUES ('{$currentVersion}', '{$currentDate}')");
         @$db->query();
         // if version isn't specified - we think that it was 2.2.0.0 or earlier...
         $version = '2.2.0.0';
     } else {
         $db->setQuery("UPDATE `#__jcomments_version` SET `version` = '{$currentVersion}', `updated` = '{$currentDate}';");
         @$db->query();
     }
     // install content plugin
     $result = JCommentsInstallerHelper::installPlugin('Content - JComments', 'jcomments', 'content');
     $installer->addMessage(JText::_('A_INSTALL_PLUGIN_CONTENT'), $result);
     // install search plugin
     $result = JCommentsInstallerHelper::installPlugin('Search - JComments', 'jcomments', 'search');
     $installer->addMessage(JText::_('A_INSTALL_PLUGIN_SEARCH'), $result);
     // install system plugin
     $result = JCommentsInstallerHelper::installPlugin('System - JComments', 'jcomments', 'system');
     $installer->addMessage(JText::_('A_INSTALL_PLUGIN_SYSTEM'), $result);
     // install editor buttons
     $result = JCommentsInstallerHelper::installPlugin('Editor Button - JComments ON', 'jcommentson', 'editors-xtd', array('jcommentson.gif'));
     $result = $result && JCommentsInstallerHelper::installPlugin('Editor Button - JComments OFF', 'jcommentsoff', 'editors-xtd', array('jcommentsoff.gif'));
     $installer->addMessage(JText::_('A_INSTALL_PLUGIN_EDITORS_XTD'), $result);
     if (JCOMMENTS_JVERSION != '1.0') {
         // install user plugin
         $result = JCommentsInstallerHelper::installPlugin('User - JComments', 'jcomments', 'user');
         $installer->addMessage(JText::_('A_INSTALL_PLUGIN_USER'), $result);
     }
     // Fix component menu icon
     if (JCOMMENTS_JVERSION == '1.0') {
         $menuiconpath = $app->getCfg('absolute_path') . DS . 'includes' . DS . 'js' . DS . 'ThemeOffice';
         $adminIconsPath = '../administrator/components/com_jcomments/assets';
         if (is_writable($menuiconpath)) {
             $currentIconsPath = dirname(__FILE__) . DS . 'images';
             ob_start();
             $res1 = @copy($currentIconsPath . DS . 'icon-16-jcomments.png', $menuiconpath . DS . 'icon-16-jcomments.png');
             $res2 = @copy($currentIconsPath . DS . 'icon-16-import.png', $menuiconpath . DS . 'icon-16-import.png');
             $res3 = @copy($currentIconsPath . DS . 'icon-16-settings.png', $menuiconpath . DS . 'icon-16-settings.png');
             $res4 = @copy($currentIconsPath . DS . 'icon-16-smiles.png', $menuiconpath . DS . 'icon-16-smiles.png');
             $res5 = @copy($currentIconsPath . DS . 'icon-16-comments.png', $menuiconpath . DS . 'icon-16-comments.png');
             $res6 = @copy($currentIconsPath . DS . 'icon-16-subscriptions.png', $menuiconpath . DS . 'icon-16-subscriptions.png');
             $res7 = @copy($currentIconsPath . DS . 'icon-16-custombbcodes.png', $menuiconpath . DS . 'icon-16-custombbcodes.png');
             $res8 = @copy($currentIconsPath . DS . 'icon-16-blacklist.png', $menuiconpath . DS . 'icon-16-blacklist.png');
             ob_end_clean();
             $result = $res1 && $res2 && $res3 && $res4 && $res5 && $res6 && $res7 && $res8;
             if ($result && is_file($menuiconpath . DS . 'jcomments16x16.png')) {
                 $adminIconsPath = 'js/ThemeOffice';
             }
         }
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-jcomments.png' " . "\n WHERE admin_menu_link='option=com_jcomments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-comments.png', name='" . JText::_('A_SUBMENU_COMMENTS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=comments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-settings.png', name='" . JText::_('A_SUBMENU_SETTINGS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=settings'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-smiles.png', name='" . JText::_('A_SUBMENU_SMILES') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=smiles'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-subscriptions.png', name='" . JText::_('A_SUBMENU_SUBSCRIPTIONS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=subscriptions'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-custombbcodes.png', name='" . JText::_('A_SUBMENU_CUSTOM_BBCODE') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=custombbcodes'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-blacklist.png', name='" . JText::_('A_SUBMENU_BLACKLIST') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=blacklist'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-import.png', name='" . JText::_('A_SUBMENU_IMPORT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=import'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/icon-16-jcomments.png', name='" . JText::_('A_SUBMENU_ABOUT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=about'");
         @$db->query();
     }
     if (version_compare($version, '2.3.0', 'le')) {
         // update db tables
         if (JCommentsInstallerDatabaseHelper::upgradeStructure()) {
             $installer->addMessage(JText::_('A_INSTALL_UPGRADE_TABLES'), true);
         }
         JCommentsInstallerDatabaseHelper::updateJoomGallery();
         if (JCOMMENTS_JVERSION != '1.7') {
             $db->setQuery("UPDATE `#__jcomments_settings` SET `value` = REPLACE(`value`, 'Unregistered', 'Public') ");
             $db->query();
             $db->setQuery("UPDATE `#__jcomments_settings` SET `value` = REPLACE(`value`, 'Super Administrator', 'Super Users') ");
             $db->query();
             $db->setQuery("UPDATE `#__jcomments_custom_bbcodes` SET `button_acl` = REPLACE(`button_acl`, 'Unregistered', 'Public') ");
             $db->query();
             $db->setQuery("UPDATE `#__jcomments_custom_bbcodes` SET `button_acl` = REPLACE(`button_acl`, 'Super Administrator', 'Super Users') ");
             $db->query();
         }
     }
     if (isset($_COOKIE['jcommentsadmin_group'])) {
         if (!headers_sent()) {
             setcookie('jcommentsadmin_group', '', time() - 3600, '/');
         }
         unset($_COOKIE['jcommentsadmin_group']);
     }
     $db->setQuery("SELECT `name`, `value` FROM `#__jcomments_settings`");
     $paramsList = $db->loadObjectList('name');
     if (count($paramsList) == 0) {
         $defaultSettings = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'settings.sql';
         JCommentsInstaller::executeSQL($defaultSettings);
     } else {
         JCommentsInstaller::checkParam($paramsList, 'delete_mode', '0');
         JCommentsInstaller::checkParam($paramsList, 'can_publish_for_my_object', '');
         JCommentsInstaller::checkParam($paramsList, 'can_edit_for_my_object', '');
         JCommentsInstaller::checkParam($paramsList, 'can_delete_for_my_object', '');
         JCommentsInstaller::checkParam($paramsList, 'enable_blacklist', '0');
         JCommentsInstaller::checkParam($paramsList, 'can_ban', 'Administrator,Super Administrator');
         JCommentsInstaller::checkParam($paramsList, 'feed_limit', '100');
         JCommentsInstaller::checkParam($paramsList, 'report_reason_required', '1');
         if (version_compare($version, '2.2.0.0') <= 0) {
             $smilesPath = DS . 'components' . DS . 'com_jcomments' . DS . 'images' . DS . 'smiles' . DS;
             JCommentsInstaller::checkParam($paramsList, 'smiles_path', $smilesPath, true);
         }
     }
     unset($paramsList);
     if (JCOMMENTS_JVERSION == '1.7') {
         // TODO remove this hack
         JCommentsInstallerHelper::fixComponentName();
     }
     JCommentsInstallerHelper::fixUsergroups();
     $joomfish = $app->getCfg('absolute_path') . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish) || JCommentsMultilingual::isEnabled()) {
         JCommentsInstaller::upgradeLanguages();
     }
     $db->setQuery("SELECT COUNT(*) FROM `#__jcomments_custom_bbcodes`;");
     $cnt = $db->loadResult();
     if ($cnt == 0) {
         $sql = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'custom_bbcodes.sql';
         JCommentsInstaller::executeSQL($sql);
     }
     JCommentsInstallerHelper::fixCustomBBCodeACL();
     $installer->showInstallLog();
     $cache = JCommentsFactory::getCache('com_jcomments');
     $cache->clean();
 }
 function postInstall()
 {
     global $mainframe;
     $db =& JCommentsFactory::getDBO();
     $installer = new HTML_JCommentsInstaller();
     JCommentsInstallerHelper::extractJCommentsPlugins();
     JCommentsInstallerHelper::setPermissions(JCOMMENTS_BASE . DS . 'tpl', '0644');
     // create database tables
     if (JCOMMENTS_JVERSION == '1.0') {
         $installSQL = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.nonutf8.sql';
         JCommentsInstaller::executeSQL($installSQL);
     } else {
         if (JCOMMENTS_JVERSION == '1.5') {
             require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'filesystem.php';
             $config =& JFactory::getConfig();
             $mainframe =& JFactory::getApplication();
             if ($config->getValue('config.legacy')) {
                 $installSQL = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.utf8.sql';
                 JCommentsInstaller::executeSQL($installSQL);
                 // path to languages directory
                 $path = JCOMMENTS_BASE . DS . 'languages';
                 $jpath = JPATH_ROOT . DS . 'language';
                 $languages = JoomlaTuneFS::readDirectory($path);
                 if (!is_writable($jpath)) {
                     @chmod($jpath, 0755);
                 }
                 foreach ($languages as $language) {
                     if (preg_match('#[a-z]{2}\\-[A-Z]{2}\\.com_jcomments.ini#is', (string) $language)) {
                         $languageCode = substr((string) $language, 0, 5);
                         $languageDir = $jpath . DS . $languageCode;
                         if (!is_dir($languageDir)) {
                             if (!JFolder::create($languageDir)) {
                                 continue;
                             }
                         }
                         if (is_dir($languageDir)) {
                             @chmod($languageDir, 0755);
                             $languageSrc = $path . DS . $language;
                             $languageDestination = $languageDir . DS . $language;
                             if (!@copy($languageSrc, $languageDestination)) {
                                 $errorMessage = JText::sprintf('Unable to copy file %s to language folder. Please set write persmission to language folder (%s) and press the Refresh/Reload button of your browser.', $language, $languageDir);
                                 $installer->addError($errorMessage);
                                 continue;
                             }
                         }
                     }
                 }
                 unset($languages);
                 $language =& JFactory::getLanguage();
                 $language->load('com_jcomments', JPATH_SITE, null, true);
             }
             @ob_start();
             // install JomSocial Rule
             $jomSocialRuleSrc = dirname(__FILE__) . DS . 'install' . DS . 'xml' . DS . 'jomsocial_rule.xm';
             $jomSocialRuleDst = JCOMMENTS_BASE . DS . 'jomsocial_rule.xml';
             if (!is_file($jomSocialRuleDst)) {
                 JCommentsInstallerHelper::copyFile($jomSocialRuleSrc, $jomSocialRuleDst);
                 JCommentsInstallerHelper::setPermissions($jomSocialRuleDst, 0755);
             }
             // remove language files
             $path = JCOMMENTS_BASE . DS . 'languages';
             $filter = '\\.ini';
             $files = JoomlaTuneFS::readDirectory($path, $filter, false, true);
             foreach ($files as $file) {
                 JCommentsInstallerHelper::deleteFile($file);
             }
             if (is_dir($path)) {
                 JCommentsInstallerHelper::deleteFolder($path);
             }
             // remove plugins.zip
             if (is_file(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip')) {
                 JCommentsInstallerHelper::deleteFile(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip');
             }
             @ob_end_clean();
         }
     }
     $jxml10 = dirname(__FILE__) . DS . 'jcomments10.xml';
     $jxml15 = dirname(__FILE__) . DS . 'jcomments15.xml';
     $jxml = dirname(__FILE__) . DS . 'jcomments.xml';
     if (is_file($jxml10)) {
         @rename($jxml10, $jxml);
     } else {
         if (is_file($jxml15)) {
             @rename($jxml15, $jxml);
         }
     }
     unset($jxml10, $jxml15, $jxml);
     // small stuff for future update system
     $db->setQuery('SELECT `version` FROM `#__jcomments_version`');
     $version = $db->loadResult();
     $versionInfo = JCommentsInstallerHelper::getVersionInfo('jcomments');
     $currentVersion = $versionInfo->releaseVersion;
     $currentDate = date('Y-m-d H:i:s');
     if (empty($version)) {
         $db->setQuery("INSERT IGNORE INTO `#__jcomments_version` (`version`,`installed`) VALUES ('{$currentVersion}', '{$currentDate}')");
         @$db->query();
         // if version isn't specified - we think that it was 1.4.0.9 or earlier...
         $version = '1.4.0.9';
     } else {
         $db->setQuery("UPDATE `#__jcomments_version` SET `version` = '{$currentVersion}', `updated` = '{$currentDate}';");
         @$db->query();
     }
     if (version_compare($version, '2.1.0.0') < 0) {
         JCommentsInstallerHelper::uninstallPlugin('jcomments.content', 'content');
         JCommentsInstallerHelper::uninstallPlugin('jcomments.search', 'search');
         JCommentsInstallerHelper::uninstallPlugin('jcomments.system', 'system');
     }
     // install content plugin
     JCommentsInstallerHelper::installPlugin('Content - JComments', 'jcomments', 'content', array(), 'AI_INSTALL_CONTENTBOT', 'AI_INSTALL_CONTENTBOT_WARNING', 1, $installer);
     // install search plugin
     JCommentsInstallerHelper::installPlugin('Search - JComments', 'jcomments', 'search', array(), 'AI_INSTALL_CONTENTSEARCHBOT', 'AI_INSTALL_CONTENTSEARCHBOT_WARNING', 1, $installer);
     // install system plugin
     JCommentsInstallerHelper::installPlugin('System - JComments', 'jcomments', 'system', array(), 'AI_INSTALL_SYSTEMBOT', 'AI_INSTALL_SYSTEMBOT_WARNING', 1, $installer);
     // install editor buttons
     JCommentsInstallerHelper::installPlugin('Editor Button - JComments ON', 'jcommentson', 'editors-xtd', array('jcommentson.gif'), '', '', 1, $installer);
     JCommentsInstallerHelper::installPlugin('Editor Button - JComments OFF', 'jcommentsoff', 'editors-xtd', array('jcommentsoff.gif'), '', '', 1, $installer);
     if (JCOMMENTS_JVERSION == '1.5') {
         // install user plugin
         JCommentsInstallerHelper::installPlugin('User - JComments', 'jcomments', 'user', array(), '', '', 1, $installer);
     }
     // Fix component menu icon
     if (JCOMMENTS_JVERSION == '1.0') {
         $menuiconpath = $mainframe->getCfg('absolute_path') . DS . 'includes' . DS . 'js' . DS . 'ThemeOffice';
         $adminIconsPath = '../administrator/components/com_jcomments/assets';
         if (is_writable($menuiconpath)) {
             $currentIconsPath = dirname(__FILE__) . DS . 'images';
             ob_start();
             $res1 = $res2 = $res3 = $res4 = $res5 = false;
             $res1 = @copy($currentIconsPath . DS . 'jcomments16x16.png', $menuiconpath . DS . 'jcomments16x16.png');
             $res2 = @copy($currentIconsPath . DS . 'import16x16.png', $menuiconpath . DS . 'import16x16.png');
             $res3 = @copy($currentIconsPath . DS . 'settings16x16.png', $menuiconpath . DS . 'settings16x16.png');
             $res4 = @copy($currentIconsPath . DS . 'smiles16x16.png', $menuiconpath . DS . 'smiles16x16.png');
             $res5 = @copy($currentIconsPath . DS . 'comments16x16.png', $menuiconpath . DS . 'comments16x16.png');
             $res6 = @copy($currentIconsPath . DS . 'subscriptions16x16.png', $menuiconpath . DS . 'subscriptions16x16.png');
             $res7 = @copy($currentIconsPath . DS . 'custombbcodes16x16.png', $menuiconpath . DS . 'custombbcodes16x16.png');
             ob_end_clean();
             $result = $res1 && $res2 && $res3 && $res4 && $res5 && $res6 && $res7;
             if ($result && is_file($menuiconpath . DS . 'jcomments16x16.png')) {
                 $adminIconsPath = 'js/ThemeOffice';
             }
         }
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png' " . "\n WHERE admin_menu_link='option=com_jcomments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/comments16x16.png', name='" . JText::_('AI_MENU_COMMENTS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=comments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/settings16x16.png', name='" . JText::_('AI_MENU_SETTINGS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=settings'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/smiles16x16.png', name='" . JText::_('AI_MENU_SMILES') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=smiles'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/subscriptions16x16.png', name='" . JText::_('AI_MENU_SUBSCRIPTIONS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=subscriptions'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/custombbcodes16x16.png', name='" . JText::_('Custom BBCode') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=custombbcodes'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/import16x16.png', name='" . JText::_('AI_MENU_IMPORT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=import'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png', name='" . JText::_('AI_MENU_ABOUT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=about'");
         @$db->query();
         // clear Joostina administrative menu cache
         if (function_exists('js_menu_cache_clear')) {
             @js_menu_cache_clear();
         }
     } else {
         $adminIconsPath = 'components/com_jcomments/assets';
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png' WHERE admin_menu_link='option=com_jcomments' OR admin_menu_link='option=com_jcomments&task=about'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/comments16x16.png' WHERE admin_menu_link='option=com_jcomments&task=comments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/settings16x16.png' WHERE admin_menu_link='option=com_jcomments&task=settings'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/smiles16x16.png' WHERE admin_menu_link='option=com_jcomments&task=smiles'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/subscriptions16x16.png' WHERE admin_menu_link='option=com_jcomments&task=subscriptions'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/custombbcodes16x16.png' WHERE admin_menu_link='option=com_jcomments&task=custombbcodes'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/import16x16.png' WHERE admin_menu_link='option=com_jcomments&task=import'");
         @$db->query();
     }
     $installer->addMessage(JText::_('AI_UPDATE_MENU_ICONS'), true);
     // update db tables
     $dbStructureChanged = version_compare($version, '2.2.0.0') <= 0;
     if ($dbStructureChanged) {
         require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'database.php';
         $upgradeStructure2000 = false;
         if (version_compare($version, '2.0.0.0') < 0) {
             // auto upgrade old table structure
             $upgradeStructure2000 = JCommentsInstallerDatabaseHelper::upgradeStructure();
         }
         $upgradeStructure2200 = JCommentsInstallerDatabaseHelper::upgradeStructure2200();
         if ($upgradeStructure2200) {
             // TODO upgrade tree structure during installation process
             // JCommentsInstallerDatabaseHelper::updateCommentsLevel();
             // JCommentsInstallerDatabaseHelper::updateCommentsPath();
         }
         if ($upgradeStructure2000 || $upgradeStructure2200) {
             $installer->addMessage(JText::_('AI_UPGRADE_TABLES'), true);
         }
     }
     // upgrade subscriptions to new comments
     $subscriptionsChanged = version_compare($version, '2.1.0.0') < 0;
     if ($subscriptionsChanged) {
         $upgradeSubs = JCommentsInstaller::upgradeSubscriptions($version);
         if ($upgradeSubs) {
             $installer->addMessage(JText::_('Upgrade subscriptions'), true);
         }
     }
     // collation synchronization (for MySQL 4.1.2 or higher)
     if (version_compare(preg_replace('~\\-.+?$~', '', $db->getVersion()), '4.1.2') >= 0) {
         require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'database.php';
         JCommentsInstallerDatabaseHelper::setupCollation();
     }
     $db->setQuery("SELECT `name`, `value` FROM `#__jcomments_settings`");
     $paramsList = $db->loadObjectList('name');
     if (count($paramsList) == 0) {
         $defaultSettings = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'settings.sql';
         JCommentsInstaller::executeSQL($defaultSettings);
     } else {
         JCommentsInstaller::checkParam($paramsList, 'comment_title', '0');
         JCommentsInstaller::checkParam($paramsList, 'enable_custom_bbcode', '0');
         JCommentsInstaller::checkParam($paramsList, 'enable_bbcode_quote', 'Unregistered,Registered,Author,Editor,Publisher,Manager,Administrator,Super Administrator');
         JCommentsInstaller::checkParam($paramsList, 'notification_type', '1,2');
         JCommentsInstaller::checkParam($paramsList, 'captcha_engine', 'kcaptcha');
         JCommentsInstaller::checkParam($paramsList, 'comment_minlength', '0');
     }
     unset($paramsList);
     $joomfish = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish)) {
         JCommentsInstaller::upgradeLanguages();
     }
     if (JCOMMENTS_JVERSION == '1.0') {
         // Update Artio JoomSEF configuration (add option to skip JComments urls)
         JCommentsInstaller::updateArtio();
     }
     $db->setQuery("SELECT COUNT(*) FROM `#__jcomments_custom_bbcodes`;");
     $cnt = $db->loadResult();
     if ($cnt == 0) {
         $sql = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'custom_bbcodes.sql';
         JCommentsInstaller::executeSQL($sql);
     }
     $installer->showInstallLog();
     JCommentsCache::cleanCache('com_jcomments');
 }
Esempio n. 4
0
 function restoreSettings()
 {
     $db =& JCommentsFactory::getDBO();
     $db->setQuery("DELETE FROM `#__jcomments_settings`");
     $db->query();
     require_once dirname(__FILE__) . DS . 'admin.jcomments.installer.php';
     $defaultSettings = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'settings.sql';
     JCommentsInstaller::executeSQL($defaultSettings);
     return JText::_('The default settings have been restored!');
 }