예제 #1
0
파일: func.php 프로젝트: arpad9/bygmarket
function fn_twg_get_stores()
{
    if (fn_allowed_for('ULTIMATE')) {
        $auth = array();
        list($stores) = fn_get_companies(array(), $auth);
    } else {
        $stores = array(array('company_id' => 0, 'company' => Registry::get('settings.Company.company_name')));
    }
    $stores_settings = TwigmoSettings::get('customer_connections');
    $admin_is_connected = TwigmoConnector::adminIsConnected();
    $indexes = array();
    foreach ($stores as $key => $store) {
        $frontend_url = TwigmoConnector::getCustomerUrl($store);
        $indexes[] = $store['company_id'];
        $stores[$key]['is_connected'] = false;
        if ($admin_is_connected) {
            $store_id = $store['company_id'];
            if (!fn_is_empty($stores_settings) && isset($stores_settings[$store_id])) {
                $store = array_merge($store, $stores_settings[$store_id]);
                $store['is_connected'] = !empty($store['access_id']) && !empty($store['url']) && $store['url'] == $frontend_url;
                $store['is_platinum'] = $store['plan_display_name'] == 'Platinum';
                $stores[$key] = $store;
            }
        }
        $stores[$key]['clear_url'] = str_replace('?dispatch=twigmo.post', '', $frontend_url);
    }
    // Set company_id as index
    return array_combine($indexes, $stores);
}