Exemplo n.º 1
0
function fn_build_link_on_price($link, $mode, $return_url, $lang_code = CART_LANGUAGE)
{
    $text = '';
    if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) {
        $text .= '<ul class="standard-ul">';
        foreach (fn_get_all_companies_ids() as $company_id) {
            $_link = fn_url($link . $mode . '&company_id=' . $company_id, 'C', 'http');
            $text .= '<li><a href="' . $_link . '&sl=' . $lang_code . '&return_url=' . urlencode($return_url) . '">' . $_link . '</a></li>';
        }
        $text .= '</ul>';
    } else {
        $_link = fn_url($link, 'C', 'http');
        $text .= '<a href="' . $_link . $mode . '&sl=' . $lang_code . '&return_url=' . urlencode($return_url) . '">' . $_link . $mode . '</a><br />';
    }
    return $text;
}
Exemplo n.º 2
0
function fn_update_discussion($data)
{
    if (!empty($data['for_all_companies'])) {
        if (isset($data['thread_id'])) {
            unset($data['thread_id']);
        }
        foreach (fn_get_all_companies_ids() as $company) {
            $data['company_id'] = $company;
            db_replace_into('discussion', $data);
        }
    } else {
        if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
            $data['company_id'] = Registry::get('runtime.company_id');
        }
        db_replace_into('discussion', $data);
    }
    return true;
}
Exemplo n.º 3
0
function fn_gift_certificates_install($d, $action)
{
    if ($action == 'install') {
        if (fn_allowed_for('ULTIMATE')) {
            $company_ids = fn_get_all_companies_ids();
        } else {
            $company_ids = array(0);
        }
        Registry::set('runtime.allow_upload_external_paths', true);
        foreach ($company_ids as $company_id) {
            fn_update_logo(array('type' => 'gift_cert', 'image_path' => fn_get_theme_path('[themes]/[theme]/mail/media/', 'C', $company_id, false) . 'images/gift_cert_logo.png'), $company_id);
        }
        Registry::set('runtime.allow_upload_external_paths', false);
    } else {
        fn_delete_logo('gift_cert');
    }
}
Exemplo n.º 4
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;
    }
}
Exemplo n.º 5
0
 public static function installAddonsTabs()
 {
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $addons = db_get_array("SELECT addon, status FROM ?:addons");
     if (fn_allowed_for('ULTIMATE')) {
         $companies = fn_get_all_companies_ids(true);
         foreach ($addons as $addon) {
             ProductTabs::instance()->deleteAddonTabs($addon['addon']);
             foreach ($companies as $company) {
                 ProductTabs::instance($company)->createAddonTabs($addon['addon']);
             }
             ProductTabs::instance()->updateAddonTabStatus($addon['addon'], $addon['status']);
         }
     } else {
         foreach ($addons as $addon) {
             ProductTabs::instance()->deleteAddonTabs($addon['addon']);
             ProductTabs::instance()->createAddonTabs($addon['addon']);
             ProductTabs::instance()->updateAddonTabStatus($addon['addon'], $addon['status']);
         }
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * @param String $install_src_dir
  * @return Array
  */
 public static function getUpgradeDirs($install_src_dir)
 {
     self::init(array('install_src_dir' => $install_src_dir));
     self::setInstalledDirs();
     self::setRepoDirs();
     self::setDistrDirs();
     self::setBackupDirs();
     if (fn_allowed_for('ULTIMATE')) {
         $company_ids = fn_get_all_companies_ids();
         self::$dirs['backup_company_settings'] = array();
         foreach (array_keys(self::$file_areas) as $key) {
             self::$dirs['backup_files'][$key . '_frontend'] = self::$dirs['installed'][$key . '_frontend'] = array();
         }
         foreach ($company_ids as $company_id) {
             self::$dirs['backup_company_settings'][$company_id] = self::$dirs['backup_settings'] . 'companies/' . $company_id . '/';
             self::setInstalledFrontend($company_id);
             self::setBackupFrontend($company_id);
         }
     }
     return self::$dirs;
 }
Exemplo n.º 7
0
use Tygh\Settings;
use Tygh\Storage;
use Tygh\Cdn;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'update_storage') {
        if (!empty($_REQUEST['storage_data'])) {
            if (Registry::get('runtime.storage.storage') != $_REQUEST['storage_data']['storage']) {
                $test = Storage::instance('statics', $_REQUEST['storage_data'])->testSettings($_REQUEST['storage_data']);
                $themes = array();
                if ($test === true) {
                    $total = 0;
                    if (fn_allowed_for('ULTIMATE')) {
                        foreach (fn_get_all_companies_ids() as $company_id) {
                            $themes[$company_id] = fn_get_dir_contents(fn_get_theme_path('[themes]', 'C', $company_id));
                            $total += sizeof($themes[$company_id]);
                        }
                    } else {
                        $themes[0] = fn_get_dir_contents(fn_get_theme_path('[themes]', 'C'));
                        $total += sizeof($themes[0]);
                    }
                    $storage = Registry::get('config.storage');
                    unset($storage['statics']);
                    // Do not transfer auto-generated data
                    $total += sizeof($storage);
                    fn_set_progress('parts', $total);
                    // transfer storages
                    foreach ($storage as $type => $options) {
                        $from = Storage::instance($type, Registry::get('runtime.storage'));
Exemplo n.º 8
0
         }
     }
     $page_type = isset($page_data['page_type']) ? $page_data['page_type'] : PAGE_TYPE_TEXT;
 } else {
     $page_data = array();
     $page_data['page_type'] = $page_type;
     if (!empty($_REQUEST['parent_id'])) {
         $page_data['parent_id'] = $_REQUEST['parent_id'];
     }
 }
 if (!empty($_REQUEST['page_data']['company_id']) && fn_allowed_for('ULTIMATE') || isset($_REQUEST['page_data']['company_id']) && fn_allowed_for('MULTIVENDOR')) {
     $page_data['company_id'] = $_REQUEST['page_data']['company_id'];
 } elseif (empty($page_data['company_id']) && Registry::get('runtime.company_id')) {
     $page_data['company_id'] = Registry::get('runtime.company_id');
 } elseif (!isset($page_data['company_id']) && fn_allowed_for('ULTIMATE')) {
     $company_ids = fn_get_all_companies_ids();
     if (count($company_ids) > 1) {
         $page_data['company_id'] = reset($company_ids);
     }
 }
 if (Registry::get('runtime.company_id') && isset($page_data['company_id']) && $page_data['company_id'] != Registry::get('runtime.company_id')) {
     $var = Registry::get('navigation.dynamic.actions');
     $vars = array('delete_this_page', 'add_page', 'add_link');
     foreach ($vars as $val) {
         if (isset($var[$val])) {
             unset($var[$val]);
         }
     }
     Registry::set('navigation.dynamic.actions', $var);
 }
 if (!empty($page_id)) {
Exemplo n.º 9
0
function fn_gift_certificates_install($d, $action)
{
    if ($action == 'install') {
        if (fn_allowed_for('ULTIMATE')) {
            $company_ids = fn_get_all_companies_ids();
        } else {
            $company_ids = array(0);
        }
        foreach ($company_ids as $company_id) {
            fn_create_logo(array('type' => 'gift_cert', 'image_path' => fn_get_theme_path('[themes]/[theme]/mail/media/', 'C', $company_id, false) . 'images/gift_cert_logo.png'), $company_id);
        }
    } else {
        fn_delete_logo('gift_cert');
    }
}
Exemplo n.º 10
0
 /**
  * Closes storefront
  */
 protected function closeStore()
 {
     fn_set_store_mode('closed');
     if (fn_allowed_for('ULTIMATE')) {
         $company_ids = fn_get_all_companies_ids();
         foreach ($company_ids as $company_id) {
             fn_set_store_mode('closed', $company_id);
         }
     }
 }
Exemplo n.º 11
0
/**
 * Function finds files from base theme in all installed themes and return full path to those files.
 *
 * @param array $files Array with relative name of the files
 * @param string $source Path to root folder
 * @return array Array of the copies of file from all installed themes.
 */
function fn_uc_find_in_themes($files, $source)
{
    $base_theme = 'var/themes_repository/' . Registry::get('config.base_theme') . '/';
    $len = strlen($base_theme);
    $installed_themes = array();
    $themes_dirs = array();
    $root_themes_path = fn_get_theme_path('[relative]', 'C');
    $themes_dirs[$root_themes_path] = fn_get_dir_contents(Registry::get('config.dir.root') . '/' . $root_themes_path);
    if (fn_allowed_for('ULTIMATE')) {
        $company_ids = fn_get_all_companies_ids();
        foreach ($company_ids as $company_id) {
            $themes_path = fn_get_theme_path('[relative]', 'C', $company_id);
            $themes_dirs[$themes_path] = fn_get_dir_contents(Registry::get('config.dir.root') . '/' . $themes_path);
        }
    }
    $result = array();
    foreach ($files as $file) {
        if (substr($file, 0, $len) == $base_theme) {
            foreach ($themes_dirs as $rel_path => $installed_themes) {
                foreach ($installed_themes as $theme_name) {
                    $relative_name = "{$rel_path}/{$theme_name}/" . substr($file, $len);
                    if (file_exists($source . '/' . $relative_name)) {
                        $result[] = $relative_name;
                    }
                }
            }
        }
    }
    return $result;
}