mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-01 05:44:41 +03:00
Remove $default_locale and $home_locale globals
This commit is contained in:
parent
f48f50e09e
commit
56c163f6a9
@ -532,7 +532,6 @@ class ThreadProcessor extends ClientSideProcessor {
|
||||
* Process submitted leave message form.
|
||||
*
|
||||
* Send message to operator email and create special meil thread.
|
||||
* @global string $home_locale Code of the home locale
|
||||
* @global string $current_locale Code of the current locale
|
||||
* @param array $args Associative array of arguments. It must contains
|
||||
* following keys:
|
||||
@ -550,7 +549,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
||||
* exception if captcha or email is wrong.
|
||||
*/
|
||||
protected function apiProcessLeaveMessage($args) {
|
||||
global $home_locale, $current_locale;
|
||||
global $current_locale;
|
||||
|
||||
// Check captcha
|
||||
if(Settings::get('enablecaptcha') == '1' && can_show_captcha()) {
|
||||
@ -600,7 +599,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
||||
// Get message locale
|
||||
$message_locale = Settings::get('left_messages_locale');
|
||||
if(!locale_exists($message_locale)) {
|
||||
$message_locale = $home_locale;
|
||||
$message_locale = HOME_LOCALE;
|
||||
}
|
||||
|
||||
// Create thread
|
||||
|
@ -53,12 +53,11 @@ Class Settings {
|
||||
|
||||
/**
|
||||
* Settings class constructor. Set default values and load setting from database.
|
||||
* @global $home_locale Specifies home locale. Defined in libs/config.php
|
||||
* @global $default_cron_key Default value for cron security key. Defined
|
||||
* in libs/common/constants.php
|
||||
*/
|
||||
protected function __construct() {
|
||||
global $home_locale, $default_cron_key;
|
||||
global $default_cron_key;
|
||||
// Set default values
|
||||
$this->settings = array(
|
||||
'dbversion' => 0,
|
||||
@ -78,7 +77,7 @@ Class Settings {
|
||||
'thread_lifetime' => 600,
|
||||
|
||||
'email' => '', /* inbox for left messages */
|
||||
'left_messages_locale' => $home_locale,
|
||||
'left_messages_locale' => HOME_LOCALE,
|
||||
'sendmessagekey' => 'center',
|
||||
|
||||
'enableban' => '0',
|
||||
|
@ -692,13 +692,10 @@ Class Thread {
|
||||
* Check if thread is reassigned for another operator
|
||||
*
|
||||
* Updates thread info, send events messages and avatar message to user
|
||||
* @global string $home_locale
|
||||
* @param array $operator Operator for test
|
||||
*/
|
||||
public function checkForReassign($operator) {
|
||||
global $home_locale;
|
||||
|
||||
$operator_name = ($this->locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
$operator_name = ($this->locale == HOME_LOCALE) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
|
||||
if ($this->state == self::STATE_WAITING &&
|
||||
($this->nextAgent == $operator['operatorid'] || $this->agentId == $operator['operatorid'])) {
|
||||
@ -982,16 +979,13 @@ Class Thread {
|
||||
/**
|
||||
* Assign operator to thread
|
||||
*
|
||||
* @global string $home_locale
|
||||
* @param array $operator Operator who try to take thread
|
||||
* @return boolean Boolean TRUE on success or FALSE on failure
|
||||
*/
|
||||
public function take($operator) {
|
||||
global $home_locale;
|
||||
|
||||
$take_thread = false;
|
||||
$message = '';
|
||||
$operator_name = ($this->locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
$operator_name = ($this->locale == HOME_LOCALE) ? $operator['vclocalename'] : $operator['vccommonname'];
|
||||
|
||||
if ($this->state == self::STATE_QUEUE || $this->state == self::STATE_WAITING || $this->state == self::STATE_LOADING) {
|
||||
// User waiting
|
||||
|
@ -27,9 +27,19 @@ require_once(MIBEW_FS_ROOT.'/libs/common/verification.php');
|
||||
*/
|
||||
define('LOCALE_COOKIE_NAME', 'mibew_locale');
|
||||
|
||||
// test and set default locales
|
||||
$default_locale = locale_pattern_check($default_locale) && locale_exists($default_locale) ? $default_locale : 'en';
|
||||
$home_locale = locale_pattern_check($home_locale) && locale_exists($home_locale) ? $default_locale : 'en';
|
||||
// Test and set default locales
|
||||
|
||||
/**
|
||||
* Verified value of the $default_locale configuration parameter (see
|
||||
* "libs/default_config.php" for details)
|
||||
*/
|
||||
define('DEFAULT_LOCALE', locale_pattern_check($default_locale) && locale_exists($default_locale) ? $default_locale : 'en');
|
||||
|
||||
/**
|
||||
* Verified value of the $home_locale configuration parameter (see
|
||||
* "libs/default_config.php" for details)
|
||||
*/
|
||||
define('HOME_LOCALE', locale_pattern_check($home_locale) && locale_exists($home_locale) ? $home_locale : 'en');
|
||||
|
||||
function myiconv($in_enc, $out_enc, $string)
|
||||
{
|
||||
@ -80,8 +90,6 @@ function get_available_locales()
|
||||
|
||||
function get_user_locale()
|
||||
{
|
||||
global $default_locale;
|
||||
|
||||
if (isset($_COOKIE[LOCALE_COOKIE_NAME])) {
|
||||
$requested_lang = $_COOKIE[LOCALE_COOKIE_NAME];
|
||||
if (locale_pattern_check($requested_lang) && locale_exists($requested_lang))
|
||||
@ -99,8 +107,8 @@ function get_user_locale()
|
||||
}
|
||||
}
|
||||
|
||||
if (locale_pattern_check($default_locale) && locale_exists($default_locale))
|
||||
return $default_locale;
|
||||
if (locale_pattern_check(DEFAULT_LOCALE) && locale_exists(DEFAULT_LOCALE))
|
||||
return DEFAULT_LOCALE;
|
||||
|
||||
return 'en';
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ function group_by_id($id)
|
||||
|
||||
function get_group_name($group)
|
||||
{
|
||||
global $home_locale, $current_locale;
|
||||
if ($home_locale == $current_locale || !isset($group['vccommonname']) || !$group['vccommonname'])
|
||||
global $current_locale;
|
||||
if (HOME_LOCALE == $current_locale || !isset($group['vccommonname']) || !$group['vccommonname'])
|
||||
return $group['vclocalname'];
|
||||
else
|
||||
return $group['vccommonname'];
|
||||
@ -146,7 +146,6 @@ function group_is_online($group) {
|
||||
/**
|
||||
* Return local or common group description depending on current locale.
|
||||
*
|
||||
* @global string $home_locale Code of the home locale
|
||||
* @global string $current_locale Code of the current locale
|
||||
* @param array $group Associative group array. Should contain following keys:
|
||||
* - 'vccommondescription': string, contain common description of the group;
|
||||
@ -154,8 +153,8 @@ function group_is_online($group) {
|
||||
* @return string Group description
|
||||
*/
|
||||
function get_group_description($group) {
|
||||
global $home_locale, $current_locale;
|
||||
if ($home_locale == $current_locale
|
||||
global $current_locale;
|
||||
if (HOME_LOCALE == $current_locale
|
||||
|| !isset($group['vccommondescription'])
|
||||
|| !$group['vccommondescription']) {
|
||||
return $group['vclocaldescription'];
|
||||
|
@ -454,15 +454,14 @@ function is_operator_online($operatorid)
|
||||
/**
|
||||
* Returns name of the operator. Choose between vclocalname and vccommonname
|
||||
*
|
||||
* @global string $home_locale Code of the operator's home locale
|
||||
* @global string $current_locale Code of the current locale
|
||||
* @param array $operator Operator's array
|
||||
* @return string Operator's name
|
||||
*/
|
||||
function get_operator_name($operator)
|
||||
{
|
||||
global $home_locale, $current_locale;
|
||||
if ($home_locale == $current_locale)
|
||||
global $current_locale;
|
||||
if (HOME_LOCALE == $current_locale)
|
||||
return $operator['vclocalename'];
|
||||
else
|
||||
return $operator['vccommonname'];
|
||||
|
@ -125,7 +125,7 @@ $operator = check_login();
|
||||
force_password($operator);
|
||||
csrfchecktoken();
|
||||
|
||||
$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
|
||||
$source = verifyparam("source", "/^[\w-]{2,5}$/", DEFAULT_LOCALE);
|
||||
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);
|
||||
$stringid = verifyparam("key", "/^[_\.\w]+$/", "");
|
||||
|
||||
|
@ -89,7 +89,7 @@ if (Settings::get('enabletracking') == '1') {
|
||||
// Get operator info
|
||||
$operator = operator_by_id($thread->agentId);
|
||||
$locale = isset($_GET['locale']) ? $_GET['locale'] : '';
|
||||
$operator_name = ($locale == $home_locale)
|
||||
$operator_name = ($locale == HOME_LOCALE)
|
||||
? $operator['vclocalename']
|
||||
: $operator['vccommonname'];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user