コード例 #1
0
 public function up()
 {
     fn_uninstall_addon("help_tutorial", false);
     fn_uninstall_addon("rss_feed", false);
     fn_uninstall_addon("customers_also_bought", false);
     fn_uninstall_addon("blog", false);
     fn_uninstall_addon("reward_points", false);
     $addons = array('hidpi' => 'A', 'watermarks' => 'A');
     foreach ($addons as $addon => $status) {
         db_query("UPDATE ?:addons SET status = ?s WHERE addon = ?s", $status, $addon);
     }
 }
コード例 #2
0
function uninstall(&$STACK, $addon)
{
    $INSTALLED = array();
    $STACK->rewind();
    foreach ($STACK as $item) {
        $INSTALLED[] = $item;
    }
    // Check dependencies for this $addon - recurse if necessary
    $dependencies = SchemesManager::getUninstallDependencies($addon);
    if (!empty($dependencies)) {
        foreach ($dependencies as $shortcode => $name) {
            // print "$addon depends on $shortcode\n";
            if (!in_array($shortcode, $INSTALLED)) {
                uninstall($STACK, $shortcode);
            } else {
                echo "warning: {$addon} already uninstalled\n";
            }
        }
    }
    if (!isset($INSTALLED) || !in_array($addon, $INSTALLED)) {
        $result = fn_uninstall_addon($addon, true);
        if (empty($result)) {
            echo "could not uninstall '{$addon}' - aborting...\n\n";
            echo "Re-installing previously uninstalled addons to restore system to good state\n";
            foreach ($STACK as $item) {
                $addon = $STACK->pop();
                fn_install_addon($addon, true, false);
                fn_update_addon_status($addon, 'A', true, false);
                print "INSTALL: {$addon}\n";
            }
            exit;
        }
        echo "UNINSTALL: {$addon}\n";
        $STACK->push($addon);
    }
}
コード例 #3
0
/**
 * Installes addon
 *
 * @param string $addon Addon to install
 * @param bool $show_notification Display notification if set to true
 * @param bool $install_demo If defined as true, addon's demo data will be installed
 * @return bool True if addons installed successfully, false otherwise
 */
function fn_install_addon($addon, $show_notification = true, $install_demo = false)
{
    $status = db_get_field("SELECT status FROM ?:addons WHERE addon = ?s", $addon);
    // Return true if addon is installed
    if (!empty($status)) {
        return true;
    }
    $addon_scheme = SchemesManager::getScheme($addon);
    if (empty($addon_scheme)) {
        // Required add-on was not found in store.
        return false;
    }
    // Unmanaged addons can be installed via console only
    if ($addon_scheme->getUnmanaged() && !defined('CONSOLE')) {
        return false;
    }
    if ($addon_scheme != false) {
        // Register custom classes
        Registry::get('class_loader')->add('', Registry::get('config.dir.addons') . $addon);
        if ($addon_scheme->isPromo()) {
            $texts = fn_get_addon_permissions_text();
            fn_set_notification('E', __('error'), $texts['text']);
            return false;
        }
        $_data = array('addon' => $addon_scheme->getId(), 'priority' => $addon_scheme->getPriority(), 'dependencies' => implode(',', $addon_scheme->getDependencies()), 'conflicts' => implode(',', $addon_scheme->getConflicts()), 'requirements' => $addon_scheme->getRequirements(), 'version' => $addon_scheme->getVersion(), 'separate' => $addon_scheme->getSettingsLayout() == 'separate' ? 1 : 0, 'has_icon' => $addon_scheme->hasIcon(), 'unmanaged' => $addon_scheme->getUnmanaged(), 'status' => 'D');
        // Check system requirements (needed versions, installed extensions, etc.)
        if (!$addon_scheme->checkRequirements($_data['requirements'])) {
            return false;
        }
        $dependencies = SchemesManager::getInstallDependencies($_data['addon']);
        if (!empty($dependencies)) {
            fn_set_notification('W', __('warning'), __('text_addon_install_dependencies', array('[addon]' => implode(',', $dependencies))));
            return false;
        }
        if ($addon_scheme->callCustomFunctions('before_install') == false) {
            fn_uninstall_addon($addon, false);
            return false;
        }
        // Add add-on to registry
        Registry::set('addons.' . $addon, array('status' => 'D', 'priority' => $_data['priority']));
        // Execute optional queries
        if ($addon_scheme->processQueries('install', Registry::get('config.dir.addons') . $addon) == false) {
            fn_uninstall_addon($addon, false);
            return false;
        }
        if (fn_update_addon_settings($addon_scheme) == false) {
            fn_uninstall_addon($addon, false);
            return false;
        }
        db_query("REPLACE INTO ?:addons ?e", $_data);
        foreach ($addon_scheme->getAddonTranslations() as $translation) {
            db_query("REPLACE INTO ?:addon_descriptions ?e", array('lang_code' => $translation['lang_code'], 'addon' => $addon_scheme->getId(), 'name' => $translation['value'], 'description' => $translation['description']));
        }
        if ($original = $addon_scheme->getOriginals()) {
            db_query("REPLACE INTO ?:original_values ?e", array('msgctxt' => 'Addon:' . $addon, 'msgid' => $original['name']));
            db_query("REPLACE INTO ?:original_values ?e", array('msgctxt' => 'AddonDescription:' . $addon, 'msgid' => $original['description']));
        }
        // Install templates
        fn_install_addon_templates($addon_scheme->getId());
        // Put this addon settings to the registry
        $settings = Settings::instance()->getValues($addon_scheme->getId(), Settings::ADDON_SECTION, false);
        if (!empty($settings)) {
            Registry::set('settings.' . $addon, $settings);
            $addon_data = Registry::get('addons.' . $addon);
            Registry::set('addons.' . $addon, fn_array_merge($addon_data, $settings));
        }
        // Add optional language variables
        $language_variables = $addon_scheme->getLanguageValues(false);
        if (!empty($language_variables)) {
            db_query('REPLACE INTO ?:language_values ?m', $language_variables);
        }
        // Get only original values
        $language_variables = $addon_scheme->getLanguageValues(true);
        if (!empty($language_variables)) {
            db_query('REPLACE INTO ?:original_values ?m', $language_variables);
        }
        if (fn_allowed_for('ULTIMATE')) {
            foreach (fn_get_all_companies_ids() as $company) {
                ProductTabs::instance($company)->createAddonTabs($addon_scheme->getId(), $addon_scheme->getTabOrder());
            }
        } else {
            ProductTabs::instance()->createAddonTabs($addon_scheme->getId(), $addon_scheme->getTabOrder());
        }
        // Execute custom functions
        if ($addon_scheme->callCustomFunctions('install') == false) {
            fn_uninstall_addon($addon, false);
            return false;
        }
        if ($show_notification == true) {
            fn_set_notification('N', __('notice'), __('text_addon_installed', array('[addon]' => $addon_scheme->getName())));
        }
        // If we need to activate addon after install, call "update status" procedure
        if ($addon_scheme->getStatus() != 'D') {
            fn_update_addon_status($addon, $addon_scheme->getStatus(), false);
        }
        if (file_exists(Registry::get('config.dir.addons') . $addon . '/layouts.xml')) {
            if (fn_allowed_for('ULTIMATE')) {
                foreach (fn_get_all_companies_ids() as $company) {
                    $layouts = Layout::instance($company)->getList();
                    foreach ($layouts as $layout_id => $layout) {
                        Exim::instance($company, $layout_id)->importFromFile(Registry::get('config.dir.addons') . $addon . '/layouts.xml');
                    }
                }
            } else {
                $layouts = Layout::instance()->getList();
                foreach ($layouts as $layout_id => $layout) {
                    Exim::instance(0, $layout_id)->importFromFile(Registry::get('config.dir.addons') . $addon . '/layouts.xml');
                }
            }
        }
        // Clean cache
        fn_clear_cache();
        if ($install_demo) {
            $addon_scheme->processQueries('demo', Registry::get('config.dir.addons') . $addon);
            if ($addon_scheme->callCustomFunctions('demo') == false) {
                fn_uninstall_addon($addon, false);
                return false;
            }
        }
        return true;
    } else {
        // Addon was not installed because scheme is not exists.
        return false;
    }
}
コード例 #4
0
 private static function _uninstallAllAddons()
 {
     $addons = db_get_fields("SELECT addon FROM ?:addons WHERE addon != 'store_import'");
     if (!empty($addons)) {
         foreach ($addons as $addon) {
             fn_uninstall_addon($addon, false);
         }
     }
 }
コード例 #5
0
        fn_install_addon('twigmo', false);
        $_SESSION['twigmo_upgrade'] = array('upgrade_dirs' => $upgrade_dirs, 'install_src_dir' => $install_src_dir);
        fn_stop_scroller();
        echo '<br><br>';
        fn_redirect('upgrade_center.upgrade_twigmo.step2');
    }
}
if ($mode == 'upgrade_twigmo' and $action == 'step2' and isset($_SESSION['twigmo_upgrade']) && !fn_twg_is_on_saas()) {
    fn_start_scroller();
    fn_echo(__('twgadmin_restore_settings') . '<br>');
    fn_ftp_connect(Settings::instance()->getValues('Upgrade_center'));
    fn_echo('.');
    $upgrade_dirs = $_SESSION['twigmo_upgrade']['upgrade_dirs'];
    fn_echo('.');
    // Uninstal addon
    fn_uninstall_addon('twigmo', false);
    fn_echo('.');
    // Install
    fn_install_addon('twigmo', false);
    fn_echo('.');
    // Restore settings
    TwigmoUpgrade::restoreSettingsAndCSS($upgrade_dirs, $auth['user_id']);
    fn_echo('.');
    // Clear template cache
    fn_rm(Registry::get('config.dir.cache_templates'));
    fn_echo('.');
    fn_echo('<br><b>' . __('twgadmin_upgrade_completed') . '<b><br>');
    unset($_SESSION['twigmo_upgrade']);
    fn_stop_scroller();
    return array(CONTROLLER_STATUS_REDIRECT, 'addons.update?addon=twigmo');
}
コード例 #6
0
ファイル: addons.php プロジェクト: askzap/ultimate
        if (!$is_snapshot_correct) {
            $status = false;
        } else {
            $status = fn_update_addon_status($_REQUEST['id'], $_REQUEST['status']);
        }
        if ($status !== true) {
            Tygh::$app['ajax']->assign('return_status', $status);
        }
        Registry::clearCachedKeyValues();
    }
    if ($mode == 'install') {
        fn_install_addon($_REQUEST['addon']);
        Registry::clearCachedKeyValues();
    }
    if ($mode == 'uninstall') {
        fn_uninstall_addon($_REQUEST['addon']);
    }
    return array(CONTROLLER_STATUS_OK, 'addons.manage');
}
if ($mode == 'update') {
    $addon_name = addslashes($_REQUEST['addon']);
    $section = Settings::instance()->getSectionByName($_REQUEST['addon'], Settings::ADDON_SECTION);
    if (empty($section)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $subsections = Settings::instance()->getSectionTabs($section['section_id'], CART_LANGUAGE);
    $options = Settings::instance()->getList($section['section_id']);
    fn_update_lang_objects('sections', $subsections);
    fn_update_lang_objects('options', $options);
    Tygh::$app['view']->assign('options', $options);
    Tygh::$app['view']->assign('subsections', $subsections);
コード例 #7
0
 public function up()
 {
     fn_uninstall_addon('yandex_market');
     fn_uninstall_addon('yandex_search');
     die;
 }
コード例 #8
0
ファイル: General.php プロジェクト: heg-arc-ne/cscart
 public static function import($store_data, $actualize_data = false)
 {
     set_time_limit(0);
     ini_set('memory_limit', '1024M');
     fn_define('STORE_IMPORT', true);
     fn_define('DISABLE_HOOK_CACHE', true);
     $log_dir = Registry::get('config.dir.store_import');
     fn_mkdir($log_dir);
     $logger = \Tygh\Logger::instance();
     $logger->logfile = $log_dir . date('Y-m-d_H-i') . '.log';
     if ($actualize_data) {
         $logos = self::_backupLogos();
     }
     $import_classes_cascade = self::getImportClassesCascade($store_data);
     $db_already_cloned = false;
     Registry::set('runtime.skip_sharing_selection', true);
     self::_removeTempTables();
     self::_setUnavailableLangVars();
     if (!$actualize_data) {
         self::_uninstallAllAddons();
     }
     fn_set_progress('parts', count($import_classes_cascade) * 6 + 2);
     $result = !empty($import_classes_cascade) ? true : false;
     self::setDefaultLanguage($store_data);
     $store_data['skin_name'] = self::setDefaultSkinName($store_data);
     $theme_to_be_installed = db_get_field("SELECT value FROM ?:settings_vendor_values WHERE object_id = (SELECT object_id FROM ?:settings_objects WHERE name = 'theme_name')");
     if (empty($theme_to_be_installed)) {
         $theme_to_be_installed = db_get_field("SELECT value FROM ?:settings_objects WHERE name = 'theme_name'");
     }
     $style_id_to_be_installed = db_get_field("SELECT style_id FROM ?:bm_layouts WHERE is_default = '1'");
     foreach ($import_classes_cascade as $class_name) {
         if ($result) {
             if (class_exists($class_name)) {
                 $obj = new $class_name($store_data);
                 $result = $db_already_cloned = $obj->import($db_already_cloned);
                 Settings::instance()->reloadSections();
             } else {
                 $result = false;
                 fn_set_notification('E', __('error'), __('store_import.class_not_found'));
                 break;
             }
         } else {
             fn_set_notification('E', __('error'), __('store_import.import_failed'));
             break;
         }
     }
     Registry::set('runtime.skip_sharing_selection', false);
     if ($result) {
         if (fn_allowed_for('ULTIMATE')) {
             General::setForcedCompanyId();
         }
         General::setLicenseData();
         //First, we should install all addons from old version in the new version that all templates, etc were installed in the new version
         self::installAddons();
         //Next, we should install all tabs in the upgraded database (mostly for the old version, 2.2.x)
         self::installAddonsTabs();
         if (fn_allowed_for('ULTIMATE')) {
             General::ultProcessImages($store_data);
         } else {
             General::mveProcessImages($store_data);
         }
         General::processFiles($store_data, 'downloads');
         General::processFiles($store_data, 'attachments');
         General::processFiles($store_data, 'custom_files');
         fn_clear_cache();
         if (!$actualize_data) {
             self::_removeRussianServices($store_data);
             General::uninstallAddons(array('twigmo', 'searchanise', 'live_help', 'exim_store', 'webmail'));
             /*
                             if (fn_allowed_for('ULTIMATE')) {
                $company_ids = db_get_fields("SELECT company_id FROM ?:companies");
                foreach ($company_ids as $company_id) {
                    self::_installTheme($company_id);
                }
                             } else {
                self::_installTheme();
                             }
             */
             db_query("UPDATE ?:settings_objects SET value = '{$theme_to_be_installed}' WHERE name = 'theme_name'");
             db_query("UPDATE ?:settings_vendor_values SET value = '{$theme_to_be_installed}' WHERE object_id = (SELECT object_id FROM ?:settings_objects WHERE name = 'theme_name')");
             db_query("UPDATE ?:bm_layouts SET style_id = '{$style_id_to_be_installed}'");
             db_query("UPDATE ?:bm_layouts SET theme_name  = '{$theme_to_be_installed}'");
         }
         self::replaceOriginalDB($store_data, $actualize_data);
         fn_install_addon('store_import', false);
         fn_uninstall_addon('twigmo', false);
         self::_removeTempTables();
         if (defined('AJAX_REQUEST')) {
             Registry::get('ajax')->assign('non_ajax_notifications', true);
             Registry::get('ajax')->assign('force_redirection', fn_url('index.index'));
         }
         if ($actualize_data) {
             self::_restoreLogos($logos);
         }
         fn_set_progress('step_scale', '1');
         fn_set_progress('echo', __('store_import.done'), true);
         return true;
     }
     return false;
 }