Ejemplo n.º 1
1
            fn_em_delete_subscribers((array) $_REQUEST['subscriber_id']);
        }
        $suffix = '.manage';
    }
    if ($mode == 'sync') {
        EmailSync::instance()->sync();
        $suffix = '.manage';
    }
    if ($mode == 'import') {
        EmailSync::instance()->import();
        $suffix = '.manage';
    }
    return array(CONTROLLER_STATUS_OK, 'em_subscribers' . $suffix);
}
if ($mode == 'manage') {
    list($subscribers, $search) = fn_em_get_subscribers($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    // Get settings
    $em_settings = array();
    foreach (fn_em_get_managable_settings() as $option) {
        $option_data = Settings::instance()->getSettingDataByName($option);
        $em_settings[$option_data['object_id']] = $option_data;
    }
    Tygh::$app['view']->assign('em_settings', $em_settings);
    Tygh::$app['view']->assign('em_support', EmailSync::instance()->supports());
    Tygh::$app['view']->assign('subscribers', $subscribers);
    Tygh::$app['view']->assign('search', $search);
}
function fn_em_get_managable_settings()
{
    return array('em_show_on_checkout', 'em_checkout_enabled', 'em_double_opt_in', 'em_welcome_letter');
}
Ejemplo n.º 2
0
/**
 * Common functions
 */
function fn_yandex_metrika_sync_goals()
{
    $oauth_token = Settings::instance()->getValue('auth_token', 'rus_yandex_metrika');
    $counter_number = Settings::instance()->getValue('counter_number', 'rus_yandex_metrika');
    if (empty($oauth_token) || empty($counter_number)) {
        return false;
    }
    $goals_scheme = fn_get_schema('rus_yandex_metrika', 'goals');
    $selected_goals = Settings::instance()->getValue('collect_stats_for_goals', 'rus_yandex_metrika');
    $client = new RestClient('https://api-metrika.yandex.ru/');
    $ext_goals = array();
    $res = $client->get("/counter/{$counter_number}/goals.json", array('oauth_token' => $oauth_token));
    if (!empty($res['goals'])) {
        foreach ($res['goals'] as $goal) {
            $ext_goals[$goal['name']] = $goal;
        }
    }
    foreach ($goals_scheme as $goal_name => $goal) {
        $ext_goal_name = '[auto] ' . $goal['name'];
        if (!empty($ext_goals[$ext_goal_name])) {
            if (empty($selected_goals[$goal_name]) || $selected_goals[$goal_name] == 'N') {
                $client->delete("/counter/{$counter_number}/goal/" . $ext_goals[$ext_goal_name]['id'] . "?oauth_token={$oauth_token}");
            }
        } else {
            if (!empty($selected_goals[$goal_name]) && $selected_goals[$goal_name] == 'Y') {
                $goal['name'] = $ext_goal_name;
                $client->post("/counter/{$counter_number}/goals?oauth_token={$oauth_token}", array('goal' => $goal));
            }
        }
    }
    return true;
}
Ejemplo n.º 3
0
/**
 * Gets Google Analytics tracking code
 *
 * @param mixed $company_id Company identifier to get code for
 * @return string Google Analytics tracking code
 */
function fn_google_analytics_get_tracking_code($company_id = null)
{
    if (!fn_allowed_for('ULTIMATE')) {
        $company_id = null;
    }
    return Settings::instance()->getValue('tracking_code', 'google_analytics', $company_id);
}
Ejemplo n.º 4
0
function fn_mp_update_settings($mp_settings, $company_id = null)
{
    if (!($setting_id = Settings::instance()->getId('maps_provider_', ''))) {
        $setting_id = Settings::instance()->update(array('name' => 'maps_provider_', 'section_id' => 0, 'section_tab_id' => 0, 'type' => 'A', 'position' => 0, 'is_global' => 'N', 'handler' => ''));
    }
    Settings::instance()->updateValueById($setting_id, serialize($mp_settings), $company_id);
}
Ejemplo n.º 5
0
function fn_retargeting_get_domain_api_key($company_id = null)
{
    if (!fn_allowed_for('ULTIMATE')) {
        $company_id = null;
    }
    return Settings::instance()->getValue('retargeting_domain_api', 'google_analytics');
}
Ejemplo n.º 6
0
 protected function updateCompanySettings($params, $company_id)
 {
     $settings = array();
     foreach ($this->setting_names as $setting_name) {
         if (isset($params[$setting_name])) {
             Settings::instance()->updateValue($setting_name, $params[$setting_name], '', false, $company_id);
         }
     }
 }
Ejemplo n.º 7
0
function fn_get_paypal_settings($lang_code = DESCR_SL)
{
    $pp_settings = Settings::instance()->getValues('paypal', 'ADDON');
    if (!empty($pp_settings['general']['pp_statuses'])) {
        $pp_settings['general']['pp_statuses'] = unserialize($pp_settings['general']['pp_statuses']);
    }
    $pp_settings['general']['main_pair'] = fn_get_image_pairs(fn_paypal_get_logo_id(), 'paypal_logo', 'M', false, true, $lang_code);
    return $pp_settings['general'];
}
Ejemplo n.º 8
0
function fn_settings_actions_addons_hidpi(&$new_value, $old_value)
{
    Storage::instance('images')->deleteDir('thumbnails');
    if ($new_value == 'A') {
        $formats = fn_check_gd_formats();
        // Set thumbnail generation format to png to improve quality
        if (!empty($formats['png'])) {
            Settings::instance()->updateValue('convert_to', 'png', 'Thumbnails');
        }
    }
}
Ejemplo n.º 9
0
function fn_settings_variants_addons_hybrid_auth_icons_pack()
{
    $available_icons_packs = array();
    $theme_name = Settings::instance()->getValue('theme_name', '');
    $icons_dir = fn_get_theme_path('[themes]/', 'C') . $theme_name . '/media/images/addons/hybrid_auth/icons/';
    $icons_packs = fn_get_dir_contents($icons_dir);
    foreach ($icons_packs as $id => $icons_packs_name) {
        $available_icons_packs[$icons_packs_name] = $icons_packs_name;
    }
    return $available_icons_packs;
}
Ejemplo n.º 10
0
function fn_rus_ruble_install()
{
    $currencies = Registry::get('currencies');
    if (empty($currencies)) {
        $currencies = fn_get_currencies_list(array(), 'A', CART_LANGUAGE);
        Registry::set('currencies', $currencies);
    }
    $magic_key = fn_rus_ruble_gen_magic_key();
    Settings::instance()->updateValue('cron_key', $magic_key, 'rus_ruble');
    RusCurrency::process_sbrf_currencies(CURRENCY_RUB);
}
Ejemplo n.º 11
0
function fn_settings_actions_addons_hidpi(&$new_value, $old_value)
{
    Storage::instance('images')->deleteDir('thumbnails');
    if ($new_value == 'A') {
        $formats = fn_get_supported_image_format_variants();
        // Set thumbnail generation format to png to improve quality
        if (!empty($formats['png'])) {
            Settings::instance()->updateValue('convert_to', 'png', 'Thumbnails');
            fn_set_notification('W', __('warning'), __('addons.hidpi.thumbnail_format_changed', array('[settings_url]' => fn_url('settings.manage?section_id=Thumbnails'))));
        }
    }
}
Ejemplo n.º 12
0
function fn_mp_get_settings($company_id = null)
{
    static $cache;
    if (empty($cache['settings_' . $company_id])) {
        $settings = Settings::instance()->getValue('maps_provider_', '', $company_id);
        $settings = unserialize($settings);
        if (empty($settings)) {
            $settings = array();
        }
        $cache['settings_' . $company_id] = $settings;
    }
    return $cache['settings_' . $company_id];
}
Ejemplo n.º 13
0
 public function auth($code)
 {
     $client = new RestClient('https://oauth.yandex.ru/', Registry::get('addons.yandex_market.ym_application_id'), Registry::get('addons.yandex_market.ym_application_password'), 'basic', array(), '');
     try {
         $res = $client->post('token', array('grant_type' => 'authorization_code', 'code' => $code));
         $result = json_decode($res, true);
         if (!empty($result['access_token'])) {
             Settings::instance()->updateValue('ym_auth_token', $result['access_token'], 'yandex_market');
         }
     } catch (Pest_Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 14
0
 public function getDefault($theme_name = '')
 {
     $condition = '';
     if (empty($theme_name)) {
         $theme_name = Settings::instance()->getValue('theme_name', '');
     }
     if (fn_allowed_for('ULTIMATE')) {
         $condition = $this->getCompanyCondition('?:bm_layouts.company_id');
     }
     $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name);
     $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition);
     return $layout;
 }
Ejemplo n.º 15
0
 /**
  * Gets CDN object instance
  *
  * @return Cdn CDN object instance
  */
 public static function instance()
 {
     if (empty(self::$_instance)) {
         $backend = Registry::get('config.cdn_backend');
         if (empty($backend)) {
             throw new DeveloperException('CDN: undefined CDN backend');
         }
         $options = Settings::instance()->getValue('cdn', '');
         $options = !empty($options) ? unserialize($options) : array();
         $class = '\\Tygh\\Backend\\Cdn\\' . ucfirst($backend);
         self::$_instance = new $class($options);
     }
     return self::$_instance;
 }
Ejemplo n.º 16
0
 public function update($id, $params)
 {
     $data = array();
     $status = Response::STATUS_BAD_REQUEST;
     if (!empty($id) && array_key_exists('value', $params)) {
         $company_id = $this->safeGet($params, 'company_id', null);
         $result = CartSettings::instance()->updateValueById($id, $params['value'], $company_id);
         if ($result) {
             $status = Response::STATUS_OK;
             $data = array('setting_id' => $id);
         }
     }
     return array('status' => $status, 'data' => $data);
 }
Ejemplo n.º 17
0
/**
 * Check if secure connection is available
 */
function fn_settings_actions_security_secure_admin(&$new_value, $old_value)
{
    if ($new_value !== 'N') {
        $suffix = '';
        if (fn_allowed_for('ULTIMATE')) {
            $suffix = '&company_id=' . Registry::get('runtime.company_id');
        }
        $admin_url = fn_url('index.index?check_https=Y' . $suffix, 'A', 'https');
        $content = Http::get($admin_url);
        if (empty($content) || $content != 'OK') {
            // Disable https
            Settings::instance()->updateValue('secure_admin', 'N', 'Security');
            $new_value = 'N';
            fn_set_notification('W', __('warning'), __('warning_https_disabled'));
        }
    }
}
Ejemplo n.º 18
0
 /**
  * Get store auth key
  *
  * @return string store key
  */
 public static function getStoreKey()
 {
     $key = Registry::get('settings.store_key');
     $host_path = Registry::get('config.http_host') . Registry::get('config.http_path');
     if (!empty($key)) {
         list($token, $host) = explode(';', $key);
         if ($host != $host_path) {
             unset($key);
         }
     }
     if (empty($key)) {
         // Generate new value
         $key = fn_crc32(microtime());
         $key .= ';' . $host_path;
         Settings::instance()->updateValue('store_key', $key);
     }
     return $key;
 }
Ejemplo n.º 19
0
/**
 * Check if secure connection is available
 */
function fn_settings_actions_security_secure_admin(&$new_value, $old_value)
{
    if ($new_value !== 'N') {
        $suffix = '';
        if (fn_allowed_for('ULTIMATE')) {
            $suffix = '&company_id=' . Registry::get('runtime.company_id');
        }
        $admin_url = fn_url('index.index?check_https=Y' . $suffix, 'A', 'https');
        $content = Http::get($admin_url);
        if (empty($content) || $content != 'OK') {
            // Disable https
            Settings::instance()->updateValue('secure_admin', 'N', 'Security');
            $new_value = 'N';
            $error = Http::getErrorFields();
            $error_warning = __('warning_https_is_disabled', array('[href]' => Registry::get('config.resources.kb_https_failed_url')));
            $error_warning .= fn_settings_actions_build_detailed_error_message($error);
            fn_set_notification('W', __('warning'), $error_warning);
        }
    }
}
Ejemplo n.º 20
0
 public function getDefault($theme_name = '')
 {
     $condition = '';
     if (empty($theme_name)) {
         $theme_name = Settings::instance()->getValue('theme_name', '');
     }
     if (fn_allowed_for('ULTIMATE')) {
         $condition = $this->getCompanyCondition('?:bm_layouts.company_id');
     }
     $condition .= db_quote(" AND is_default = 1 AND theme_name = ?s", $theme_name);
     /**
      * Modifies the way to get default layout
      *
      * @param object  $this Layout object
      * @param string  $theme_name theme name
      * @param string  $condition part of SQL condition
      */
     fn_set_hook('layout_get_default', $this, $theme_name, $condition);
     $layout = db_get_row("SELECT * FROM ?:bm_layouts WHERE 1 ?p", $condition);
     return $layout;
 }
Ejemplo n.º 21
0
 public function update($id, $params)
 {
     $data = array();
     $valid_params = true;
     $status = Response::STATUS_BAD_REQUEST;
     unset($params['shipment_id']);
     list($shipments, ) = fn_get_shipments_info(array('shipment_id' => $id));
     $shipment_data = reset($shipments);
     $order_info = fn_get_order_info($shipment_data['order_id'], false, true, true);
     if (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) == 'Y') {
         $data['message'] = __('api_shipments_not_allow_update');
         $valid_params = false;
     }
     if ($valid_params) {
         $shipment_id = fn_update_shipment($params, $id);
         if ($shipment_id) {
             $status = Response::STATUS_OK;
             $data = array('shipment_id' => $shipment_id);
         }
     }
     return array('status' => $status, 'data' => $data);
 }
Ejemplo n.º 22
0
        unset($_REQUEST['redirect_url']);
        fn_clear_cache();
        return array(CONTROLLER_STATUS_REDIRECT, $redirect_url);
    }
    return array(CONTROLLER_STATUS_OK, 'settings' . $_suffix . '?section_id=' . Settings::instance()->getSectionTextId($section_id));
}
//
// OUPUT routines
//
if ($mode == 'manage') {
    $subsections = Settings::instance()->getSectionTabs($section_id, CART_LANGUAGE);
    $options = Settings::instance()->getList($section_id);
    fn_update_lang_objects('subsections', $subsections);
    // [Page sections]
    if (!empty($subsections)) {
        Registry::set('navigation.tabs.main', array('title' => __('main'), 'js' => true));
        foreach ($subsections as $k => $v) {
            Registry::set('navigation.tabs.' . $k, array('title' => $v['description'], 'js' => true));
        }
    }
    // [/Page sections]
    // Set navigation menu
    $sections = Registry::get('navigation.static.top.settings.items');
    fn_update_lang_objects('sections', $sections);
    Registry::set('navigation.dynamic.sections', $sections);
    Registry::set('navigation.dynamic.active_section', Settings::instance()->getSectionTextId($section_id));
    Tygh::$app['view']->assign('options', $options);
    Tygh::$app['view']->assign('subsections', $subsections);
    Tygh::$app['view']->assign('section_id', Settings::instance()->getSectionTextId($section_id));
    Tygh::$app['view']->assign('settings_title', Settings::instance()->getSectionName($section_id));
}
Ejemplo n.º 23
0
/**
 * Resizes image
 * @param string $src source image path
 * @param integer $new_width new image width
 * @param integer $new_height new image height
 * @param string $bg_color new image background color
 * @param array $custom_settings custom convertion settings
 * @return array - new image contents and format
 */
function fn_resize_image($src, $new_width = 0, $new_height = 0, $bg_color = '#ffffff', $custom_settings = array())
{
    static $notification_set = false;
    static $gd_settings = array();
    if (empty($gd_settings)) {
        $gd_settings = Settings::instance()->getValues('Thumbnails');
    }
    $settings = !empty($custom_settings) ? $custom_settings : $gd_settings;
    $class = '\\Tygh\\Backend\\Images\\' . ucfirst(Registry::ifGet('config.tweaks.image_resize_lib', 'gd'));
    if (file_exists($src) && (!empty($new_width) || !empty($new_height))) {
        $img_functions = $class::supportedFormats();
        list($width, $height, $mime_type) = fn_get_image_size($src);
        $ext = fn_get_image_extension($mime_type);
        if (empty($width) || empty($height) || empty($ext)) {
            return false;
        }
        if (empty($img_functions[$ext])) {
            if ($notification_set == false) {
                fn_set_notification('E', __('error'), __('error_image_format_not_supported', array('[format]' => $ext)));
                $notification_set = true;
            }
            return false;
        }
        if (empty($new_width) || empty($new_height)) {
            if ($width < $new_width) {
                $new_width = $width;
            }
            if ($height < $new_height) {
                $new_height = $height;
            }
        }
        $dst_width = $new_width;
        $dst_height = $new_height;
        $x = 0;
        $y = 0;
        if (empty($new_height)) {
            // if we passed width only, calculate height
            $dst_height = $new_height = $height / $width * $new_width;
        } elseif (empty($new_width)) {
            // if we passed height only, calculate width
            $dst_width = $new_width = $width / $height * $new_height;
        } else {
            // we passed width and height, we need to fit image in this sizes
            if ($new_width * $height / $width > $dst_height) {
                $new_width = $width * $dst_height / $height;
            }
            $new_height = $height / $width * $new_width;
            if ($new_height * $width / $height > $dst_width) {
                $new_height = $height * $dst_width / $width;
            }
            $new_width = $width / $height * $new_height;
            $x = intval(($dst_width - $new_width) / 2);
            $y = intval(($dst_height - $new_height) / 2);
        }
        $new_width = intval($new_width);
        $new_height = intval($new_height);
        if (!empty($bg_color) && !preg_match('/^#([0-9a-f]{3}){1,2}$/i', $bg_color)) {
            $bg_color = '#ffffff';
        }
        try {
            return $class::resize($src, array('ext' => $ext, 'new_width' => $new_width, 'new_height' => $new_height, 'dst_width' => $dst_width, 'dst_height' => $dst_height, 'width' => $width, 'height' => $height, 'bg_color' => $bg_color, 'convert_to' => $settings['convert_to'], 'jpeg_quality' => $settings['jpeg_quality'], 'x' => $x, 'y' => $y));
        } catch (Exception $e) {
            return array('', $ext);
        }
    }
    return false;
}
Ejemplo n.º 24
0
    fn_set_storage_data('timeout_check_failed', false);
    Tygh::$app['view']->assign('timeout_check_failed', $timeout_check_failed);
    Tygh::$app['view']->assign('show_pre_upgrade_notice', true);
    Tygh::$app['view']->assign('upgrade_packages', $upgrade_packages);
    Tygh::$app['view']->assign('installed_packages', $installed_packages);
} elseif ($mode == 'package_content' && !empty($_REQUEST['package_id'])) {
    $package_id = $_REQUEST['package_id'];
    $content = $app->getPackageContent($package_id);
    Tygh::$app['view']->assign('package_id', $package_id);
    Tygh::$app['view']->assign('content', $content);
} elseif ($mode == 'conflicts' && !empty($_REQUEST['package_id'])) {
    $package_id = $_REQUEST['package_id'];
    $params = array('id' => $package_id);
    $packages = $app->getInstalledPackagesList($params);
    if (!isset($packages[$package_id])) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $package = $packages[$package_id];
    if (!empty($package['conflicts'])) {
        $package['conflicts'] = unserialize($package['conflicts']);
    }
    Tygh::$app['view']->assign('package_id', $package_id);
    Tygh::$app['view']->assign('package', $package);
} elseif ($mode == 'resolve_conflict' && !empty($_REQUEST['package_id'])) {
    $app->resolveConflict($_REQUEST['package_id'], $_REQUEST['file_id'], $_REQUEST['status']);
    return array(CONTROLLER_STATUS_REDIRECT, 'upgrade_center.conflicts?package_id=' . $_REQUEST['package_id']);
} elseif ($mode == 'ftp_settings') {
    Tygh::$app['view']->assign('id', $_REQUEST['package_id']);
    Tygh::$app['view']->assign('type', $_REQUEST['package_type']);
    Tygh::$app['view']->assign('uc_settings', Settings::instance()->getValues('Upgrade_center'));
}
Ejemplo n.º 25
0
function fn_em_install()
{
    $token = md5(uniqid());
    Settings::instance()->updateValue('em_token', $token, 'email_marketing');
    Settings::instance()->updateValue('em_lastsync', time(), 'email_marketing');
}
Ejemplo n.º 26
0
/**
 * Function returns address of company and emails of company' departments.
 *
 * @param integer $company_id ID of company
 * @param string $lang_code Language of retrieving data. If null, lang_code of company will be used.
 * @return array Company address, emails and lang_code.
 */
function fn_get_company_placement_info($company_id, $lang_code = null)
{
    $default_company_placement_info = Registry::get('settings.Company');
    if (empty($company_id)) {
        $company_placement_info = $default_company_placement_info;
        $company_placement_info['lang_code'] = !empty($lang_code) ? $lang_code : CART_LANGUAGE;
    } else {
        $company = fn_get_company_data($company_id, !empty($lang_code) ? $lang_code : CART_LANGUAGE);
        if (fn_allowed_for('ULTIMATE')) {
            $company_placement_info = Settings::instance()->getValues('Company', Settings::CORE_SECTION, true, $company_id);
            $default_company_placement_info = $company_placement_info;
            $company_placement_info['lang_code'] = $company['lang_code'];
        } else {
            $company_placement_info = array('company_name' => $company['company'], 'company_address' => $company['address'], 'company_city' => $company['city'], 'company_country' => $company['country'], 'company_state' => $company['state'], 'company_zipcode' => $company['zipcode'], 'company_phone' => $company['phone'], 'company_phone_2' => '', 'company_fax' => $company['fax'], 'company_website' => $company['url'], 'company_users_department' => $company['email'], 'company_site_administrator' => $company['email'], 'company_orders_department' => $company['email'], 'company_support_department' => $company['email'], 'company_newsletter_email' => $company['email'], 'lang_code' => $company['lang_code']);
        }
    }
    foreach ($default_company_placement_info as $k => $v) {
        $company_placement_info['default_' . $k] = $v;
    }
    $lang_code = !empty($lang_code) ? $lang_code : $company_placement_info['lang_code'];
    $company_placement_info['company_country_descr'] = fn_get_country_name($company_placement_info['company_country'], $lang_code);
    $company_placement_info['company_state_descr'] = fn_get_state_name($company_placement_info['company_state'], $company_placement_info['company_country'], $lang_code);
    return $company_placement_info;
}
Ejemplo n.º 27
0
 /**
  * Sets new default language for backend/frontend
  *
  * @param  string $lang_code 2-letters language code (en, ru, etc)
  * @return bool   Always true
  */
 public static function changeDefaultLanguage($lang_code)
 {
     Settings::instance()->updateValue('backend_default_language', $lang_code);
     Settings::instance()->updateValue('frontend_default_language', $lang_code);
     Registry::set('settings.Appearance.backend_default_language', $lang_code);
     Registry::set('settings.Appearance.frontend_default_language', $lang_code);
     return true;
 }
Ejemplo n.º 28
0
                 $_countries[$code] = $countries_list[$code];
                 unset($countries_list[$code]);
             }
         }
         $company_data['countries_list'] = $_countries;
         unset($_countries, $company_countries);
     }
     Tygh::$app['view']->assign('countries_list', $countries_list);
     if ($mode == 'add') {
         $schema = fn_init_clone_schemas();
         Tygh::$app['view']->assign('clone_schema', $schema);
     }
     // Get "Company" settings from the DB
     $settings_values = fn_restore_post_data('update');
     $section = Settings::instance()->getSectionByName('Company');
     $settings_data = Settings::instance()->getList($section['section_id'], 0, false, $company_id, CART_LANGUAGE);
     foreach ($settings_data['main'] as $field_id => &$field_data) {
         unset($field_data['update_for_all']);
         if (!empty($settings_values) && !empty($settings_values[$field_id])) {
             $field_data['value'] = $settings_values[$field_id];
         } elseif ($mode == 'add') {
             unset($field_data['value']);
         }
     }
     Tygh::$app['view']->assign('company_settings', $settings_data['main']);
     unset($settings_data, $section);
 }
 Tygh::$app['view']->assign('company_data', $company_data);
 Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
 Tygh::$app['view']->assign('states', fn_get_all_states());
 $profile_fields = fn_get_profile_fields('A', array(), CART_LANGUAGE, array('get_custom' => true, 'get_profile_required' => true));
Ejemplo n.º 29
0
function fn_facebook_prepare_meta_data($provider_data, $params)
{
    $addon_settings = Settings::instance()->getValues('social_buttons', 'ADDON');
    if (fn_allowed_for('ULTIMATE')) {
        $company_id = Registry::ifGet('runtime.company_id', fn_get_default_company_id());
        $site_name = fn_get_company_name($company_id);
    }
    if ($params['object'] == 'products') {
        $product = Registry::get('view')->getTemplateVars('product');
        $return = array('type' => !empty($product['facebook_product_type']) ? $product['facebook_product_type'] : '', 'title' => fn_sb_format_page_title(), 'url' => fn_url('products.view?product_id=' . $params['object_id']), 'image' => !empty($product['main_pair']['detailed']['http_image_path']) ? $product['main_pair']['detailed']['http_image_path'] : '', 'site_name' => !empty($site_name) ? $site_name : Registry::get('settings.Company.company_name'), 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : '');
    } elseif ($params['object'] == 'pages') {
        $page = Registry::get('view')->getTemplateVars('page');
        $logos = fn_get_logos();
        if (fn_allowed_for('ULTIMATE')) {
            $logos = fn_get_logos($company_id);
        }
        $return = array('type' => !empty($page['facebook_obj_type']) ? $page['facebook_obj_type'] : '', 'title' => $page['page'], 'url' => !empty($page['link']) ? $page['link'] : fn_url('pages.view?product_id=' . $params['object_id']), 'image' => $logos['theme']['image']['http_image_path'], 'site_name' => !empty($site_name) ? $site_name : Registry::get('settings.Company.company_name'), 'app_id' => !empty($addon_settings['facebook']['facebook_app_id']) ? $addon_settings['facebook']['facebook_app_id'] : '');
    }
    return $return;
}
Ejemplo n.º 30
0
/**
 * Gets addons list
 *
 * @param array $params search params
 * @param int $items_per_page items per page for pagination
 * @param string $lang_code language code
 * @return array addons list and filtered search params
 */
function fn_get_addons($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $params = LastView::instance()->update('addons', $params);
    $default_params = array('type' => 'any');
    $params = array_merge($default_params, $params);
    $addons = array();
    $sections = Settings::instance()->getAddons();
    $all_addons = fn_get_dir_contents(Registry::get('config.dir.addons'), true, false);
    $installed_addons = db_get_hash_array('SELECT a.addon, a.status, b.name as name, b.description as description, a.separate, a.unmanaged, a.has_icon ' . 'FROM ?:addons as a LEFT JOIN ?:addon_descriptions as b ON b.addon = a.addon AND b.lang_code = ?s' . 'ORDER BY b.name ASC', 'addon', $lang_code);
    foreach ($installed_addons as $key => $addon) {
        $installed_addons[$key]['has_sections'] = Settings::instance()->sectionExists($sections, $addon['addon']);
        $installed_addons[$key]['has_options'] = $installed_addons[$key]['has_sections'] ? Settings::instance()->optionsExists($addon['addon'], 'ADDON') : false;
        // Check add-on snaphot
        if (!fn_check_addon_snapshot($key)) {
            $installed_addons[$key]['status'] = 'D';
            $installed_addons[$key]['snapshot_correct'] = false;
        } else {
            $installed_addons[$key]['snapshot_correct'] = true;
        }
    }
    foreach ($all_addons as $addon) {
        $addon_scheme = SchemesManager::getScheme($addon);
        if (in_array($params['type'], array('any', 'installed', 'active', 'disabled'))) {
            $search_status = $params['type'] == 'active' ? 'A' : ($params['type'] == 'disabled' ? 'D' : '');
            if (!empty($installed_addons[$addon])) {
                // exclude unmanaged addons from the list
                if ($installed_addons[$addon]['unmanaged'] == true) {
                    continue;
                }
                if (!empty($search_status) && $installed_addons[$addon]['status'] != $search_status) {
                    continue;
                }
                $addons[$addon] = $installed_addons[$addon];
                if ($addon_scheme != false && !$addon_scheme->getUnmanaged()) {
                    $addons[$addon]['originals'] = $addon_scheme->getOriginals();
                }
                fn_update_lang_objects('installed_addon', $addons[$addon]);
                // Generate custom description
                $func = 'fn_addon_dynamic_description_' . $addon;
                if (function_exists($func)) {
                    $addons[$addon]['description'] = $func($addons[$addon]['description']);
                }
            }
        }
        if (empty($installed_addons[$addon]) && empty($params['for_company']) && in_array($params['type'], array('any', 'not_installed'))) {
            if ($addon_scheme != false && !$addon_scheme->getUnmanaged()) {
                $addons[$addon] = array('status' => 'N', 'name' => $addon_scheme->getName(), 'snapshot_correct' => fn_check_addon_snapshot($addon), 'description' => $addon_scheme->getDescription(), 'has_icon' => $addon_scheme->hasIcon());
            }
        }
    }
    if (!empty($params['q'])) {
        foreach ($addons as $addon => $addon_data) {
            if (!preg_match('/' . preg_quote($params['q'], '/') . '/ui', $addon_data['name'], $m)) {
                unset($addons[$addon]);
            }
        }
    }
    $addons = fn_sort_array_by_key($addons, 'name', SORT_ASC);
    return array($addons, $params);
}