예제 #1
0
 /**
  * Installs addons
  *
  * @param  bool  $install_demo
  * @param  array $addons       List of addons to be installed, if empty will be installed addons according <auto_install> tag
  * @return bool  Always true
  */
 public function setup($install_demo = true, $addons = array())
 {
     $app = App::instance();
     Registry::set('customer_theme_path', Registry::get('config.dir.install_themes') . '/' . App::THEME_NAME);
     $addons = empty($addons) ? $this->_getAddons() : $addons;
     foreach ($addons as $addon_name) {
         if (fn_install_addon($addon_name, false, $install_demo)) {
             fn_set_progress('echo', $app->t('addon_installed', array('addon' => $addon_name)) . '<br/>', true);
         }
         Registry::set('runtime.database.errors', '');
     }
     return true;
 }
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
/**
 * Move addon pack from temporarily folder to specified place and install it if possible
 *
 * @param string $from Source path
 * @param string $to Destination path
 * @return bool true if installed, false otherwise
 */
function fn_addons_move_and_install($from, $to)
{
    if (defined('AJAX_REQUEST')) {
        Registry::get('ajax')->assign('non_ajax_notifications', true);
    }
    $struct = fn_get_dir_contents($from, false, true, '', '', true);
    $addon_name = '';
    foreach ($struct as $file) {
        if (preg_match('/app.+?addons[^a-zA-Z0-9_]+([a-zA-Z0-9_-]+).+?addon.xml$/i', $file, $matches)) {
            if (!empty($matches[1])) {
                $addon_name = $matches[1];
                break;
            }
        }
    }
    $relative_addon_path = str_replace(Registry::get('config.dir.root') . '/', '', Registry::get('config.dir.addons'));
    if (!file_exists($from . $relative_addon_path . $addon_name . '/addon.xml')) {
        fn_set_notification('E', __('error'), __('broken_addon_pack'));
        return false;
    }
    fn_copy($from, $to);
    fn_install_addon($addon_name);
    fn_rm($from);
    return true;
}
예제 #4
0
 public static function import($store_data, $actualize_data = false)
 {
     set_time_limit(0);
     ini_set('memory_limit', '1024M');
     fn_define('STORE_IMPORT', 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);
     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) {
         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();
         fn_clear_cache();
         if (!$actualize_data) {
             self::_removeRussianServices($store_data);
             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();
             }
         }
         self::replaceOriginalDB($store_data, $actualize_data);
         fn_install_addon('store_import', 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;
 }
예제 #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
            if (!empty($item['post_handlers'])) {
                foreach ($item['post_handlers'] as $func_name => $args) {
                    $args = fn_settings_wizard_prepare_args($args, $_REQUEST);
                    call_user_func_array($func_name, $args);
                }
            }
        }
        if (!empty($_REQUEST['settings'])) {
            foreach ($_REQUEST['settings'] as $setting_name => $value) {
                Settings::instance()->updateValue($setting_name, $value);
            }
        }
        if (!empty($_REQUEST['addons'])) {
            foreach ($_REQUEST['addons'] as $addon_name => $enabled) {
                if ($enabled == 'Y') {
                    fn_install_addon($addon_name, false, false);
                }
            }
        }
        if ($action == 'finish' || empty($steps[$current_step]['next_step'])) {
            return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['return_url']);
        } else {
            return array(CONTROLLER_STATUS_REDIRECT, 'settings_wizard.view?current_step=' . $steps[$current_step]['next_step']);
        }
    }
    return array(CONTROLLER_STATUS_OK, '');
}
if ($mode == 'view') {
    $steps = fn_get_schema('settings_wizard', 'steps');
    if (empty($_REQUEST['current_step'])) {
        reset($steps);
예제 #7
0
파일: addons.php 프로젝트: askzap/ultimate
        }
    }
    if ($mode == 'update_status') {
        $is_snapshot_correct = fn_check_addon_snapshot($_REQUEST['id']);
        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']);
예제 #8
0
 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;
 }