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