Version 2.1.0
This commit is contained in:
@@ -15,6 +15,7 @@ use phpbb\auth\auth;
|
||||
use phpbb\config\config;
|
||||
use phpbb\config\db_text;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\user;
|
||||
|
||||
class settings
|
||||
@@ -22,6 +23,9 @@ class settings
|
||||
/** @var user */
|
||||
protected $user;
|
||||
|
||||
/** @var language */
|
||||
protected $lang;
|
||||
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
@@ -34,6 +38,24 @@ class settings
|
||||
/** @var dispatcher_interface */
|
||||
protected $dispatcher;
|
||||
|
||||
/** @var string */
|
||||
protected $root_path;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext;
|
||||
|
||||
/** @var string */
|
||||
protected $mchat_table;
|
||||
|
||||
/** @var string */
|
||||
protected $mchat_log_table;
|
||||
|
||||
/** @var string */
|
||||
protected $mchat_sessions_table;
|
||||
|
||||
/** @var string */
|
||||
protected $board_url;
|
||||
|
||||
/**
|
||||
* Keys for global settings that only the administrator is allowed to modify.
|
||||
* The values are stored in the phpbb_config table.
|
||||
@@ -74,18 +96,12 @@ class settings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $prune_modes = array(
|
||||
public $prune_modes = [
|
||||
0 => 'messages',
|
||||
1 => 'hours',
|
||||
24 => 'days',
|
||||
168 => 'weeks',
|
||||
);
|
||||
|
||||
/** @var bool */
|
||||
public $is_phpbb31;
|
||||
|
||||
/** @var bool */
|
||||
public $is_phpbb32;
|
||||
];
|
||||
|
||||
/**
|
||||
* Possible values of the global setting mchat_archive_sort
|
||||
@@ -98,27 +114,42 @@ class settings
|
||||
* Constructor
|
||||
*
|
||||
* @param user $user
|
||||
* @param language $lang
|
||||
* @param config $config
|
||||
* @param db_text $config_text
|
||||
* @param auth $auth
|
||||
* @param dispatcher_interface $dispatcher
|
||||
* @param string $root_path
|
||||
* @param string $php_ext
|
||||
* @param string $mchat_table
|
||||
* @param string $mchat_log_table
|
||||
* @param string $mchat_sessions_table
|
||||
*/
|
||||
public function __construct(
|
||||
user $user,
|
||||
language $lang,
|
||||
config $config,
|
||||
db_text $config_text,
|
||||
auth $auth,
|
||||
dispatcher_interface $dispatcher
|
||||
dispatcher_interface $dispatcher,
|
||||
$root_path,
|
||||
$php_ext,
|
||||
$mchat_table,
|
||||
$mchat_log_table,
|
||||
$mchat_sessions_table
|
||||
)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->config = $config;
|
||||
$this->config_text = $config_text;
|
||||
$this->auth = $auth;
|
||||
$this->dispatcher = $dispatcher;
|
||||
|
||||
$this->is_phpbb31 = phpbb_version_compare(PHPBB_VERSION, '3.1.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '<');
|
||||
$this->is_phpbb32 = phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<');
|
||||
$this->user = $user;
|
||||
$this->lang = $lang;
|
||||
$this->config = $config;
|
||||
$this->config_text = $config_text;
|
||||
$this->auth = $auth;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->mchat_table = $mchat_table;
|
||||
$this->mchat_log_table = $mchat_log_table;
|
||||
$this->mchat_sessions_table = $mchat_sessions_table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,37 +157,38 @@ class settings
|
||||
*/
|
||||
public function initialize_global_settings()
|
||||
{
|
||||
$global_settings = array(
|
||||
'mchat_archive_sort' => array('default' => self::ARCHIVE_SORT_BOTTOM_TOP),
|
||||
'mchat_bbcode_disallowed' => array('default' => '', 'validation' => array('string', false, 0, 255)),
|
||||
'mchat_custom_height' => array('default' => 350, 'validation' => array('num', false, 50, 1000)),
|
||||
'mchat_custom_page' => array('default' => 1),
|
||||
'mchat_edit_delete_limit' => array('default' => 0),
|
||||
'mchat_flood_time' => array('default' => 0, 'validation' => array('num', false, 0, 60)),
|
||||
'mchat_index_height' => array('default' => 250, 'validation' => array('num', false, 50, 1000)),
|
||||
'mchat_live_updates' => array('default' => 1),
|
||||
'mchat_max_message_lngth' => array('default' => 500, 'validation' => array('num', false, 0, 1000)),
|
||||
'mchat_message_num_archive' => array('default' => 25, 'validation' => array('num', false, 10, 100)),
|
||||
'mchat_message_num_custom' => array('default' => 10, 'validation' => array('num', false, 5, 50)),
|
||||
'mchat_message_num_index' => array('default' => 10, 'validation' => array('num', false, 5, 50)),
|
||||
'mchat_navbar_link' => array('default' => 1),
|
||||
'mchat_navbar_link_count' => array('default' => 1),
|
||||
'mchat_override_min_post_chars' => array('default' => 0),
|
||||
'mchat_override_smilie_limit' => array('default' => 0),
|
||||
'mchat_posts_auth_check' => array('default' => 0),
|
||||
'mchat_posts_edit' => array('default' => 0),
|
||||
'mchat_posts_quote' => array('default' => 0),
|
||||
'mchat_posts_reply' => array('default' => 0),
|
||||
'mchat_posts_topic' => array('default' => 0),
|
||||
'mchat_posts_login' => array('default' => 0),
|
||||
'mchat_prune' => array('default' => 0),
|
||||
'mchat_prune_gc' => array('default' => strtotime('1 day', 0)),
|
||||
'mchat_prune_mode' => array('default' => 0),
|
||||
'mchat_prune_num' => array('default' => 0),
|
||||
'mchat_refresh' => array('default' => 10, 'validation' => array('num', false, 5, 60)),
|
||||
'mchat_timeout' => array('default' => 0, 'validation' => array('num', false, 0, (int) $this->cfg('session_length'))),
|
||||
'mchat_whois_refresh' => array('default' => 60, 'validation' => array('num', false, 10, 300)),
|
||||
);
|
||||
$global_settings = [
|
||||
'mchat_archive_sort' => ['default' => self::ARCHIVE_SORT_BOTTOM_TOP],
|
||||
'mchat_bbcode_disallowed' => ['default' => '', 'validation' => ['string', false, 0, 255]],
|
||||
'mchat_custom_height' => ['default' => 350, 'validation' => ['num', false, 50, 1000]],
|
||||
'mchat_custom_page' => ['default' => 1],
|
||||
'mchat_edit_delete_limit' => ['default' => 0],
|
||||
'mchat_flood_time' => ['default' => 0, 'validation' => ['num', false, 0, 60]],
|
||||
'mchat_index_height' => ['default' => 250, 'validation' => ['num', false, 50, 1000]],
|
||||
'mchat_live_updates' => ['default' => 1],
|
||||
'mchat_log_enabled' => ['default' => 1],
|
||||
'mchat_max_input_height' => ['default' => 150, 'validation' => ['num', false, 0, 1000]],
|
||||
'mchat_max_message_lngth' => ['default' => 500, 'validation' => ['num', false, 0, 1000]],
|
||||
'mchat_message_num_archive' => ['default' => 25, 'validation' => ['num', false, 10, 100]],
|
||||
'mchat_message_num_custom' => ['default' => 10, 'validation' => ['num', false, 5, 50]],
|
||||
'mchat_message_num_index' => ['default' => 10, 'validation' => ['num', false, 5, 50]],
|
||||
'mchat_navbar_link_count' => ['default' => 1],
|
||||
'mchat_override_min_post_chars' => ['default' => 0],
|
||||
'mchat_override_smilie_limit' => ['default' => 0],
|
||||
'mchat_posts_auth_check' => ['default' => 0],
|
||||
'mchat_posts_edit' => ['default' => 0],
|
||||
'mchat_posts_quote' => ['default' => 0],
|
||||
'mchat_posts_reply' => ['default' => 0],
|
||||
'mchat_posts_topic' => ['default' => 0],
|
||||
'mchat_posts_login' => ['default' => 0],
|
||||
'mchat_prune' => ['default' => 0],
|
||||
'mchat_prune_gc' => ['default' => strtotime('1 day', 0)],
|
||||
'mchat_prune_mode' => ['default' => 0],
|
||||
'mchat_prune_num' => ['default' => 0],
|
||||
'mchat_refresh' => ['default' => 10, 'validation' => ['num', false, 5, 60]],
|
||||
'mchat_timeout' => ['default' => 0, 'validation' => ['num', false, 0, (int) $this->cfg('session_length')]],
|
||||
'mchat_whois_refresh' => ['default' => 60, 'validation' => ['num', false, 10, 300]],
|
||||
];
|
||||
|
||||
/**
|
||||
* Event to modify global settings data
|
||||
@@ -165,9 +197,9 @@ class settings
|
||||
* @var array global_settings Array containing global settings data
|
||||
* @since 2.0.0-RC7
|
||||
*/
|
||||
$vars = array(
|
||||
$vars = [
|
||||
'global_settings',
|
||||
);
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.global_settings_modify', compact($vars)));
|
||||
|
||||
return $global_settings;
|
||||
@@ -178,10 +210,10 @@ class settings
|
||||
*/
|
||||
public function initialize_global_text_settings()
|
||||
{
|
||||
$global_text_settings = array(
|
||||
'mchat_rules' => array('default' => ''),
|
||||
'mchat_static_message' => array('default' => ''),
|
||||
);
|
||||
$global_text_settings = [
|
||||
'mchat_rules' => ['default' => ''],
|
||||
'mchat_static_message' => ['default' => ''],
|
||||
];
|
||||
|
||||
/**
|
||||
* Event to modify global text settings data
|
||||
@@ -190,9 +222,9 @@ class settings
|
||||
* @var array global_text_settings Array containing global text settings data
|
||||
* @since 2.0.2
|
||||
*/
|
||||
$vars = array(
|
||||
$vars = [
|
||||
'global_text_settings',
|
||||
);
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.global_text_settings_modify', compact($vars)));
|
||||
|
||||
return $global_text_settings;
|
||||
@@ -203,22 +235,21 @@ class settings
|
||||
*/
|
||||
public function initialize_ucp_settings()
|
||||
{
|
||||
$ucp_settings = array(
|
||||
'mchat_avatars' => array('default' => 1),
|
||||
'mchat_capital_letter' => array('default' => 1),
|
||||
'mchat_character_count' => array('default' => 1),
|
||||
'mchat_date' => array('default' => 'D M d, Y g:i a', 'validation' => array('string', false, 0, 64)),
|
||||
'mchat_index' => array('default' => 1),
|
||||
'mchat_input_area' => array('default' => 1),
|
||||
'mchat_location' => array('default' => 1),
|
||||
'mchat_message_top' => array('default' => 1),
|
||||
'mchat_pause_on_input' => array('default' => 0),
|
||||
'mchat_posts' => array('default' => 1),
|
||||
'mchat_relative_time' => array('default' => 1),
|
||||
'mchat_sound' => array('default' => 1),
|
||||
'mchat_stats_index' => array('default' => 0),
|
||||
'mchat_whois_index' => array('default' => 1),
|
||||
);
|
||||
$ucp_settings = [
|
||||
'mchat_avatars' => ['default' => 1],
|
||||
'mchat_capital_letter' => ['default' => 1],
|
||||
'mchat_character_count' => ['default' => 1],
|
||||
'mchat_date' => ['default' => 'D M d, Y g:i a', 'validation' => ['string', false, 0, 64]],
|
||||
'mchat_index' => ['default' => 1],
|
||||
'mchat_input_area' => ['default' => 1],
|
||||
'mchat_location' => ['default' => 1],
|
||||
'mchat_message_top' => ['default' => 1],
|
||||
'mchat_posts' => ['default' => 1],
|
||||
'mchat_relative_time' => ['default' => 1],
|
||||
'mchat_sound' => ['default' => 1],
|
||||
'mchat_stats_index' => ['default' => 0],
|
||||
'mchat_whois_index' => ['default' => 1],
|
||||
];
|
||||
|
||||
/**
|
||||
* Event to modify UCP settings data
|
||||
@@ -227,9 +258,9 @@ class settings
|
||||
* @var array ucp_settings Array containing UCP settings data
|
||||
* @since 2.0.0-RC7
|
||||
*/
|
||||
$vars = array(
|
||||
$vars = [
|
||||
'ucp_settings',
|
||||
);
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.ucp_settings_modify', compact($vars)));
|
||||
|
||||
return $ucp_settings;
|
||||
@@ -277,9 +308,9 @@ class settings
|
||||
* @var array global_text_values Array containing global text values
|
||||
* @since 2.0.2
|
||||
*/
|
||||
$vars = array(
|
||||
$vars = [
|
||||
'global_text_values',
|
||||
);
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.global_text_values_modify', compact($vars)));
|
||||
|
||||
$this->global_text_values = $global_text_values;
|
||||
@@ -372,6 +403,30 @@ class settings
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_mchat()
|
||||
{
|
||||
return $this->mchat_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_mchat_log()
|
||||
{
|
||||
return $this->mchat_log_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_table_mchat_sessions()
|
||||
{
|
||||
return $this->mchat_sessions_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $selected
|
||||
* @return array
|
||||
@@ -379,31 +434,32 @@ class settings
|
||||
public function get_date_template_data($selected)
|
||||
{
|
||||
$dateformat_options = '';
|
||||
$dateformats = $this->lang->lang_raw('dateformats');
|
||||
|
||||
foreach ($this->user->lang['dateformats'] as $format => $null)
|
||||
foreach (array_keys($dateformats) as $format)
|
||||
{
|
||||
$dateformat_options .= '<option value="' . $format . '"' . (($format == $selected) ? ' selected="selected"' : '') . '>';
|
||||
$dateformat_options .= $this->user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $this->user->lang('VARIANT_DATE_SEPARATOR') . $this->user->format_date(time(), $format, true) : '');
|
||||
$dateformat_options .= $this->user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $this->lang->lang('VARIANT_DATE_SEPARATOR') . $this->user->format_date(time(), $format, true) : '');
|
||||
$dateformat_options .= '</option>';
|
||||
}
|
||||
|
||||
$s_custom = false;
|
||||
|
||||
$dateformat_options .= '<option value="custom"';
|
||||
if (!isset($this->user->lang['dateformats'][$selected]))
|
||||
if (!isset($dateformats[$selected]))
|
||||
{
|
||||
$dateformat_options .= ' selected="selected"';
|
||||
$s_custom = true;
|
||||
}
|
||||
$dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>';
|
||||
$dateformat_options .= '>' . $this->lang->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>';
|
||||
|
||||
$ucp_settings = $this->ucp_settings();
|
||||
|
||||
return array(
|
||||
return [
|
||||
'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options,
|
||||
'MCHAT_DEFAULT_DATEFORMAT' => $ucp_settings['mchat_date']['default'],
|
||||
'S_MCHAT_CUSTOM_DATEFORMAT' => $s_custom,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,16 +467,51 @@ class settings
|
||||
*/
|
||||
public function get_enabled_post_notifications_lang()
|
||||
{
|
||||
$enabled_notifications_lang = array();
|
||||
$enabled_notifications_lang = [];
|
||||
|
||||
foreach (array('topic', 'reply', 'quote', 'edit', 'login') as $notification)
|
||||
foreach (['topic', 'reply', 'quote', 'edit', 'login'] as $notification)
|
||||
{
|
||||
if ($this->cfg('mchat_posts_' . $notification))
|
||||
{
|
||||
$enabled_notifications_lang[] = $this->user->lang('MCHAT_POSTS_' . strtoupper($notification));
|
||||
$enabled_notifications_lang[] = $this->lang->lang('MCHAT_POSTS_' . strtoupper($notification));
|
||||
}
|
||||
}
|
||||
|
||||
return implode($this->user->lang('COMMA_SEPARATOR'), $enabled_notifications_lang);
|
||||
return implode($this->lang->lang('COMMA_SEPARATOR'), $enabled_notifications_lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $absolute_url
|
||||
* @param bool $append_ext
|
||||
* @return string
|
||||
*/
|
||||
public function url($path, $absolute_url = false, $append_ext = true)
|
||||
{
|
||||
if ($absolute_url && !$this->board_url)
|
||||
{
|
||||
$this->board_url = generate_board_url() . '/';
|
||||
}
|
||||
|
||||
$url = ($absolute_url ? $this->board_url : $this->root_path) . $path;
|
||||
|
||||
if ($append_ext)
|
||||
{
|
||||
$url .= '.' . $this->php_ext;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $function
|
||||
*/
|
||||
public function include_functions($file, $function)
|
||||
{
|
||||
if (!function_exists($function))
|
||||
{
|
||||
include($this->root_path . 'includes/functions_' . $file . '.' . $this->php_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user