/** * Form error notice and make redirect. Used in fn_init_company_id * * @param array $params request parameters * @param string $message language variable name for message * @param int $redirect_company_id New company id for redirecting, if null, company id saved in session will be used * @return array with init data (init status, redirect url in case of redirect) */ function fn_init_company_id_redirect(&$params, $message, $redirect_company_id = null) { if ('access_denied' == $message) { Tygh::$app['session']['auth'] = array(); $redirect_url = 'auth.login_form' . (!empty($params['return_url']) ? '?return_url=' . urldecode($params['return_url']) : ''); } elseif ('company_not_found' == $message) { $dispatch = !empty($params['dispatch']) ? $params['dispatch'] : 'auth.login_form'; unset($params['dispatch']); $params['switch_company_id'] = null === $redirect_company_id ? fn_init_company_id_find_in_session() : $redirect_company_id; $redirect_url = $dispatch . '?' . http_build_query($params); } if (!defined('CART_LANGUAGE')) { fn_init_language($params); // we need CART_LANGUAGE in Tygh\Languages\Values::getLangVar() fn_init_currency($params); // we need CART_SECONDARY_CURRENCY in Tygh\Languages\Values::getLangVar() $params['dispatch'] = 'index.index'; // we need dispatch in Tygh\Languages\Values::getLangVar() } fn_set_notification('E', __('error'), __($message)); return array(INIT_STATUS_REDIRECT, $redirect_url); }
/** * Form error notice and make redirect. Used in fn_init_company_id * * @param array $params request parameters * @param string $message language variable name for message * @param int $redirect_company_id New company id for redirecting, if null, company id saved in session will be used * @return array with init data (init status, redirect url in case of redirect) */ function fn_init_company_id_redirect(&$params, $message, $redirect_company_id = null) { if ('access_denied' == $message) { $_SESSION['auth'] = array(); $redirect_url = 'auth.login_form' . (!empty($params['return_url']) ? '?return_url=' . urldecode($params['return_url']) : ''); } elseif ('company_not_found' == $message) { $dispatch = !empty($params['dispatch']) ? $params['dispatch'] : 'auth.login_form'; unset($params['dispatch']); $params['switch_company_id'] = null === $redirect_company_id ? fn_init_company_id_find_in_session() : $redirect_company_id; $redirect_url = $dispatch . '?' . http_build_query($params); } if (!defined('CART_LANGUAGE')) { fn_init_language($params); // we need CART_LANGUAGE in fn_get_lang_var function } fn_set_notification('E', __('error'), __($message)); return array(INIT_STATUS_REDIRECT, $redirect_url); }