Version 2.1.4
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
<h1>{{ lang('MCHAT_TITLE') }}</h1>
|
||||
|
||||
{{ lang('MCHAT_VERSION') ~ lang('COLON') }} <em>{{ MCHAT_VERSION }}</em>
|
||||
{{ lang('MCHAT_VERSION') ~ lang('COLON') }} <em>{{ MCHAT_VERSION }}</em> | <span>{{ lang('MCHAT_REPARSER_STATUS') ~ lang('COLON') }} <span{{ S_REPARSER_ACTIVE ? ' class="errorbox"' }}>{{ lang(S_REPARSER_ACTIVE ? 'MCHAT_REPARSER_ACTIVE' : 'MCHAT_REPARSER_FINISHED') }}</span></span> <a href="https://www.phpbb.com/customise/db/extension/mchat_extension/faq/3311" title="{{ lang('MCHAT_REPARSER_STATUS') }}"><i class="icon fa-question-circle-o fa-fw" aria-hidden="true"></i></a>
|
||||
|
||||
{% if MCHAT_ERROR %}
|
||||
<div class="errorbox">
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
"type": "phpbb-extension",
|
||||
"description": "mChat",
|
||||
"homepage": "https://www.phpbb.com/customise/db/extension/mchat_extension/",
|
||||
"version": "2.1.3",
|
||||
"time": "2019-06-06",
|
||||
"keywords": [
|
||||
"phpbb",
|
||||
"extension",
|
||||
"mchat"
|
||||
],
|
||||
"version": "2.1.4",
|
||||
"time": "2020-08-08",
|
||||
"keywords": ["phpbb", "extension", "mchat"],
|
||||
"license": "GPL-2.0-only",
|
||||
"authors": [
|
||||
{
|
||||
@@ -32,8 +28,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.7",
|
||||
"composer/installers": "~1.0.0",
|
||||
"phpbb/phpbb": ">=3.2.0"
|
||||
"composer/installers": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpbb/epv": "dev-master"
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
dmzx_mchat_page_custom_controller:
|
||||
path: /mchat
|
||||
methods: [GET]
|
||||
defaults: { _controller: dmzx.mchat.core:page_custom }
|
||||
path: '/mchat'
|
||||
methods: ['GET']
|
||||
defaults: { _controller: 'dmzx.mchat.core:page_custom' }
|
||||
dmzx_mchat_page_archive_controller:
|
||||
path: /mchat/archive
|
||||
methods: [GET]
|
||||
defaults: { _controller: dmzx.mchat.core:page_archive }
|
||||
path: '/mchat/archive'
|
||||
methods: ['GET']
|
||||
defaults: { _controller: 'dmzx.mchat.core:page_archive' }
|
||||
dmzx_mchat_page_rules_controller:
|
||||
path: /mchat/rules
|
||||
methods: [GET]
|
||||
defaults: { _controller: dmzx.mchat.core:page_rules }
|
||||
path: '/mchat/rules'
|
||||
methods: ['GET']
|
||||
defaults: { _controller: 'dmzx.mchat.core:page_rules' }
|
||||
dmzx_mchat_page_whois_controller:
|
||||
path: /mchat/whois/{ip}
|
||||
methods: [GET]
|
||||
defaults: { _controller: dmzx.mchat.core:page_whois }
|
||||
path: '/mchat/whois/{ip}'
|
||||
methods: ['GET']
|
||||
defaults: { _controller: 'dmzx.mchat.core:page_whois' }
|
||||
|
||||
dmzx_mchat_action_add_controller:
|
||||
path: /mchat/action/add
|
||||
methods: [POST]
|
||||
defaults: { _controller: dmzx.mchat.core:action_add }
|
||||
path: '/mchat/action/add'
|
||||
methods: ['POST']
|
||||
defaults: { _controller: 'dmzx.mchat.core:action_add' }
|
||||
dmzx_mchat_action_edit_controller:
|
||||
path: /mchat/action/edit
|
||||
methods: [POST]
|
||||
defaults: { _controller: dmzx.mchat.core:action_edit }
|
||||
path: '/mchat/action/edit'
|
||||
methods: ['POST']
|
||||
defaults: { _controller: 'dmzx.mchat.core:action_edit' }
|
||||
dmzx_mchat_action_del_controller:
|
||||
path: /mchat/action/del
|
||||
methods: [POST]
|
||||
defaults: { _controller: dmzx.mchat.core:action_del }
|
||||
path: '/mchat/action/del'
|
||||
methods: ['POST']
|
||||
defaults: { _controller: 'dmzx.mchat.core:action_del' }
|
||||
dmzx_mchat_action_refresh_controller:
|
||||
path: /mchat/action/refresh
|
||||
methods: [POST]
|
||||
defaults: { _controller: dmzx.mchat.core:action_refresh }
|
||||
path: '/mchat/action/refresh'
|
||||
methods: ['POST']
|
||||
defaults: { _controller: 'dmzx.mchat.core:action_refresh' }
|
||||
dmzx_mchat_action_whois_controller:
|
||||
path: /mchat/action/whois
|
||||
methods: [POST]
|
||||
defaults: { _controller: dmzx.mchat.core:action_whois }
|
||||
path: '/mchat/action/whois'
|
||||
methods: ['POST']
|
||||
defaults: { _controller: 'dmzx.mchat.core:action_whois' }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
imports:
|
||||
- { resource: tables.yml }
|
||||
- { resource: 'tables.yml' }
|
||||
|
||||
services:
|
||||
|
||||
dmzx.mchat.acp.controller:
|
||||
class: dmzx\mchat\controller\acp_controller
|
||||
class: 'dmzx\mchat\controller\acp_controller'
|
||||
arguments:
|
||||
- '@dmzx.mchat.functions'
|
||||
- '@template'
|
||||
@@ -12,13 +12,14 @@ services:
|
||||
- '@user'
|
||||
- '@language'
|
||||
- '@dbal.conn'
|
||||
- '@config_text'
|
||||
- '@cache.driver'
|
||||
- '@request'
|
||||
- '@dispatcher'
|
||||
- '@dmzx.mchat.settings'
|
||||
|
||||
dmzx.mchat.ucp.controller:
|
||||
class: dmzx\mchat\controller\ucp_controller
|
||||
class: 'dmzx\mchat\controller\ucp_controller'
|
||||
arguments:
|
||||
- '@template'
|
||||
- '@user'
|
||||
@@ -30,7 +31,7 @@ services:
|
||||
- '@dispatcher'
|
||||
|
||||
dmzx.mchat.notifications:
|
||||
class: dmzx\mchat\core\notifications
|
||||
class: 'dmzx\mchat\core\notifications'
|
||||
arguments:
|
||||
- '@dmzx.mchat.settings'
|
||||
- '@user'
|
||||
@@ -41,7 +42,7 @@ services:
|
||||
- '@text_formatter.parser'
|
||||
|
||||
dmzx.mchat.log:
|
||||
class: dmzx\mchat\core\log
|
||||
class: 'dmzx\mchat\core\log'
|
||||
arguments:
|
||||
- '@dmzx.mchat.settings'
|
||||
- '@user'
|
||||
@@ -50,7 +51,7 @@ services:
|
||||
- '@dispatcher'
|
||||
|
||||
dmzx.mchat.core:
|
||||
class: dmzx\mchat\core\mchat
|
||||
class: 'dmzx\mchat\core\mchat'
|
||||
arguments:
|
||||
- '@dmzx.mchat.functions'
|
||||
- '@dmzx.mchat.notifications'
|
||||
@@ -70,7 +71,7 @@ services:
|
||||
- '@?rmcgirr83.authorizedforurls.listener'
|
||||
|
||||
dmzx.mchat.functions:
|
||||
class: dmzx\mchat\core\functions
|
||||
class: 'dmzx\mchat\core\functions'
|
||||
arguments:
|
||||
- '@dmzx.mchat.settings'
|
||||
- '@dmzx.mchat.notifications'
|
||||
@@ -85,7 +86,7 @@ services:
|
||||
- '@group_helper'
|
||||
|
||||
dmzx.mchat.settings:
|
||||
class: dmzx\mchat\core\settings
|
||||
class: 'dmzx\mchat\core\settings'
|
||||
arguments:
|
||||
- '@user'
|
||||
- '@language'
|
||||
@@ -100,7 +101,7 @@ services:
|
||||
- '%dmzx.mchat.table.mchat_sessions%'
|
||||
|
||||
dmzx.mchat.acp.listener:
|
||||
class: dmzx\mchat\event\acp_listener
|
||||
class: 'dmzx\mchat\event\acp_listener'
|
||||
arguments:
|
||||
- '@template'
|
||||
- '@request'
|
||||
@@ -108,10 +109,10 @@ services:
|
||||
- '@dmzx.mchat.settings'
|
||||
- '@dmzx.mchat.functions'
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
- { name: 'event.listener' }
|
||||
|
||||
dmzx.mchat.main.listener:
|
||||
class: dmzx\mchat\event\main_listener
|
||||
class: 'dmzx\mchat\event\main_listener'
|
||||
arguments:
|
||||
- '@dmzx.mchat.core'
|
||||
- '@dmzx.mchat.notifications'
|
||||
@@ -121,30 +122,30 @@ services:
|
||||
- '@request'
|
||||
- '%core.php_ext%'
|
||||
tags:
|
||||
- { name: event.listener }
|
||||
- { name: 'event.listener' }
|
||||
|
||||
dmzx.mchat.cron.task.mchat_prune:
|
||||
class: dmzx\mchat\cron\mchat_prune
|
||||
class: 'dmzx\mchat\cron\mchat_prune'
|
||||
arguments:
|
||||
- '@dmzx.mchat.functions'
|
||||
- '@dmzx.mchat.settings'
|
||||
calls:
|
||||
- [set_name, [cron.task.mchat_prune]]
|
||||
- ['set_name', ['cron.task.mchat_prune']]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
- { name: 'cron.task' }
|
||||
|
||||
dmzx.mchat.text_reparser.mchat_messages:
|
||||
class: dmzx\mchat\textreparser\plugins\mchat_messages
|
||||
class: 'dmzx\mchat\textreparser\plugins\mchat_messages'
|
||||
arguments:
|
||||
- '@dbal.conn'
|
||||
- '%dmzx.mchat.table.mchat%'
|
||||
calls:
|
||||
- [set_name, [dmzx.mchat.text_reparser.mchat_messages]]
|
||||
- ['set_name', ['dmzx.mchat.text_reparser.mchat_messages']]
|
||||
tags:
|
||||
- { name: text_reparser.plugin }
|
||||
- { name: 'text_reparser.plugin' }
|
||||
|
||||
dmzx.mchat.text_reparser.reparser:
|
||||
class: phpbb\cron\task\text_reparser\reparser
|
||||
class: 'phpbb\cron\task\text_reparser\reparser'
|
||||
arguments:
|
||||
- '@config'
|
||||
- '@config_text'
|
||||
@@ -152,7 +153,7 @@ services:
|
||||
- '@text_reparser.manager'
|
||||
- '@text_reparser_collection'
|
||||
calls:
|
||||
- [set_name, [dmzx.mchat.text_reparser.reparser]]
|
||||
- [set_reparser, [dmzx.mchat.text_reparser.mchat_messages]]
|
||||
- ['set_name', ['dmzx.mchat.text_reparser.reparser']]
|
||||
- ['set_reparser', ['dmzx.mchat.text_reparser.mchat_messages']]
|
||||
tags:
|
||||
- { name: cron.task }
|
||||
- { name: 'cron.task' }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
parameters:
|
||||
dmzx.mchat.table.mchat: %core.table_prefix%mchat
|
||||
dmzx.mchat.table.mchat_log: %core.table_prefix%mchat_log
|
||||
dmzx.mchat.table.mchat_sessions: %core.table_prefix%mchat_sessions
|
||||
dmzx.mchat.table.mchat: '%core.table_prefix%mchat'
|
||||
dmzx.mchat.table.mchat_log: '%core.table_prefix%mchat_log'
|
||||
dmzx.mchat.table.mchat_sessions: '%core.table_prefix%mchat_sessions'
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace dmzx\mchat\controller;
|
||||
use dmzx\mchat\core\functions;
|
||||
use dmzx\mchat\core\settings;
|
||||
use phpbb\cache\driver\driver_interface as cache_interface;
|
||||
use phpbb\config\db_text as config_text;
|
||||
use phpbb\db\driver\driver_interface as db_interface;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
@@ -42,6 +43,9 @@ class acp_controller
|
||||
/** @var db_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var config_text */
|
||||
protected $config_text;
|
||||
|
||||
/** @var cache_interface */
|
||||
protected $cache;
|
||||
|
||||
@@ -63,6 +67,7 @@ class acp_controller
|
||||
* @param user $user
|
||||
* @param language $lang
|
||||
* @param db_interface $db
|
||||
* @param config_text $config_text
|
||||
* @param cache_interface $cache
|
||||
* @param request_interface $request
|
||||
* @param dispatcher_interface $dispatcher
|
||||
@@ -75,6 +80,7 @@ class acp_controller
|
||||
user $user,
|
||||
language $lang,
|
||||
db_interface $db,
|
||||
config_text $config_text,
|
||||
cache_interface $cache,
|
||||
request_interface $request,
|
||||
dispatcher_interface $dispatcher,
|
||||
@@ -87,6 +93,7 @@ class acp_controller
|
||||
$this->user = $user;
|
||||
$this->lang = $lang;
|
||||
$this->db = $db;
|
||||
$this->config_text = $config_text;
|
||||
$this->cache = $cache;
|
||||
$this->request = $request;
|
||||
$this->dispatcher = $dispatcher;
|
||||
@@ -123,6 +130,10 @@ class acp_controller
|
||||
}
|
||||
}
|
||||
|
||||
// Enable Emojis and rich text in Rules and Static Message
|
||||
$mchat_new_config['mchat_rules'] = utf8_encode_ncr($mchat_new_config['mchat_rules']);
|
||||
$mchat_new_config['mchat_static_message'] = utf8_encode_ncr($mchat_new_config['mchat_static_message']);
|
||||
|
||||
// Remove leading & trailing | characters to not break allowed BBCodes
|
||||
$mchat_new_config['mchat_bbcode_disallowed'] = trim($mchat_new_config['mchat_bbcode_disallowed'], '|');
|
||||
|
||||
@@ -212,6 +223,7 @@ class acp_controller
|
||||
'S_MCHAT_PRUNE_MODE_OPTIONS' => $this->get_prune_mode_options($this->settings->cfg('mchat_prune_mode')),
|
||||
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => $this->lang->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN', '<a href="' . append_sid($this->settings->url('adm/index'), ['i' => 'bbcodes']) . '">', '</a>'),
|
||||
'L_MCHAT_TIMEOUT_EXPLAIN' => $this->lang->lang('MCHAT_TIMEOUT_EXPLAIN','<a href="' . append_sid($this->settings->url('adm/index'), ['i' => 'board', 'mode' => 'load']) . '">', '</a>', $this->settings->cfg('session_length')),
|
||||
'S_REPARSER_ACTIVE' => $this->is_reparser_active('dmzx.mchat.text_reparser.mchat_messages'),
|
||||
'U_ACTION' => $u_action,
|
||||
];
|
||||
|
||||
@@ -376,4 +388,27 @@ class acp_controller
|
||||
|
||||
return $prune_mode_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $reparser_name
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_reparser_active($reparser_name)
|
||||
{
|
||||
$reparser_resume = $this->config_text->get('reparser_resume');
|
||||
|
||||
if (empty($reparser_resume))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$reparser_resume = @unserialize($reparser_resume);
|
||||
|
||||
if (!isset($reparser_resume[$reparser_name]['range-min']) || !isset($reparser_resume[$reparser_name]['range-max']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $reparser_resume[$reparser_name]['range-max'] >= $reparser_resume[$reparser_name]['range-min'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ class functions
|
||||
{
|
||||
if (!$row['session_viewonline'])
|
||||
{
|
||||
if (!$can_view_hidden && $row['user_id'] !== $this->user->data['user_id'])
|
||||
if (!$can_view_hidden && $row['user_id'] != $this->user->data['user_id'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ class functions
|
||||
$sql_array['WHERE'] = $this->db->sql_in_set('m.user_id', $user_ids);
|
||||
$offset = 0;
|
||||
}
|
||||
else if ($this->mchat_settings->prune_modes[$prune_mode] === 'messages')
|
||||
else if ($this->mchat_settings->prune_modes[$prune_mode] == 'messages')
|
||||
{
|
||||
// Skip fixed number of messages, delete all others
|
||||
$sql_array['ORDER_BY'] = 'm.message_id DESC';
|
||||
@@ -499,6 +499,7 @@ class functions
|
||||
* @var int offset SQL offset
|
||||
* @var array sql_array Array containing the SQL query data
|
||||
* @since 2.0.0-RC6
|
||||
* @deprecated 2.1.4-RC1, to be removed in 2.1.0.
|
||||
*/
|
||||
$vars = [
|
||||
'message_ids',
|
||||
@@ -523,6 +524,26 @@ class functions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to modify message rows before being processed and displayed
|
||||
*
|
||||
* @event dmzx.mchat.get_messages_modify_rowset
|
||||
* @var array message_ids IDs of specific messages to fetch, e.g. for fetching edited messages
|
||||
* @var int last_id The ID of the latest message that the user has, for fetching new messages
|
||||
* @var int total SQL limit
|
||||
* @var int offset SQL offset
|
||||
* @var array rows Array containing message data
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'message_ids',
|
||||
'last_id',
|
||||
'total',
|
||||
'offset',
|
||||
'rows',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.get_messages_modify_rowset', compact($vars)));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
102
core/mchat.php
102
core/mchat.php
@@ -733,6 +733,27 @@ class mchat
|
||||
$template_data['MCHAT_TITLE'] = $active_users['users_count_title'];
|
||||
$template_data['MCHAT_TITLE_HINT'] = strip_tags($active_users['users_total']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$active_users = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that is triggered before data for the navigation bar is assigned to the template
|
||||
*
|
||||
* @event dmzx.mchat.header_link_template_data
|
||||
* @var array template_data The data that is abbout to be assigned to the template
|
||||
* @var array active_users Array containing information about active users. Available array keys:
|
||||
* online_userlist, users_count_title, users_total, refresh_message
|
||||
* Note: This array is empty if the number of active chat sessions is not
|
||||
* displayed in the navbar.
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'template_data',
|
||||
'active_users',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.header_link_template_data', compact($vars)));
|
||||
|
||||
$this->template->assign_vars($template_data);
|
||||
}
|
||||
@@ -766,6 +787,8 @@ class mchat
|
||||
$static_message = $this->lang->lang('MCHAT_STATIC_MESSAGE') ?: $this->mchat_settings->cfg('mchat_static_message');
|
||||
$whois_refresh = $this->mchat_settings->cfg('mchat_whois_index') || $this->mchat_settings->cfg('mchat_navbar_link_count');
|
||||
|
||||
$total_messages = $this->mchat_functions->mchat_total_message_count();
|
||||
|
||||
$template_data = [
|
||||
'MCHAT_PAGE' => $page,
|
||||
'MCHAT_CURRENT_URL' => $this->mchat_settings->get_current_page(),
|
||||
@@ -787,6 +810,7 @@ class mchat
|
||||
'MCHAT_STATIC_MESS' => htmlspecialchars_decode($static_message),
|
||||
'MCHAT_MAX_INPUT_HEIGHT' => $this->mchat_settings->cfg('mchat_max_input_height'),
|
||||
'MCHAT_MAX_MESSAGE_LENGTH' => $this->mchat_settings->cfg('mchat_max_message_lngth'),
|
||||
'MCHAT_TOTAL_MESSAGES' => $total_messages,
|
||||
'MCHAT_JUMP_TO' => $jump_to_id,
|
||||
'COOKIE_NAME' => $this->mchat_settings->cfg('cookie_name', true) . '_',
|
||||
];
|
||||
@@ -850,7 +874,9 @@ class mchat
|
||||
* @var int jump_to_id The ID of the message that is being jumped to in the archive, usually when a user clicked on a quote reference
|
||||
* @var array actions Array containing URLs to actions the user is allowed to perform (read only)
|
||||
* @var array template_data The data that is about to be assigned to the template
|
||||
* @var int total_messages Total number of messages
|
||||
* @since 2.1.1
|
||||
* @changed 2.1.4-RC1 added total_messages
|
||||
*/
|
||||
$vars = [
|
||||
'page',
|
||||
@@ -861,26 +887,44 @@ class mchat
|
||||
'jump_to_id',
|
||||
'actions',
|
||||
'template_data',
|
||||
'total_messages',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.render_page_get_messages_before', compact($vars)));
|
||||
|
||||
$rows = $this->mchat_functions->mchat_get_messages($message_ids, $last_id, $limit, $start);
|
||||
|
||||
$this->assign_global_template_data();
|
||||
|
||||
// Always fetch at least one message so that we can extract the latest_message_id
|
||||
$soft_limit = max(1, $limit);
|
||||
|
||||
$rows = $this->mchat_functions->mchat_get_messages($message_ids, $last_id, $soft_limit, $start);
|
||||
|
||||
if ($limit)
|
||||
{
|
||||
$this->assign_messages($rows, $page);
|
||||
}
|
||||
|
||||
// Pass the latest_message_id to the template so that we know later where to start looking for new messages
|
||||
$latest_message_id = 0;
|
||||
|
||||
if ($rows)
|
||||
{
|
||||
$latest_message = reset($rows);
|
||||
$latest_message_id = $latest_message['message_id'];
|
||||
}
|
||||
|
||||
$template_data['MCHAT_LATEST_MESSAGE_ID'] = $latest_message_id;
|
||||
|
||||
// Render pagination
|
||||
if ($is_archive)
|
||||
{
|
||||
$archive_url = $this->helper->route('dmzx_mchat_page_archive_controller');
|
||||
$total_messages = $this->mchat_functions->mchat_total_message_count();
|
||||
|
||||
/**
|
||||
* Event to modify mChat pagination on the archive page
|
||||
*
|
||||
* @event dmzx.mchat.render_page_pagination_before
|
||||
* @var string archive_url Pagination base URL
|
||||
* @var int total_messages Total number of messages
|
||||
* @var int total_messages Total number of messages in the mChat table
|
||||
* @var int limit Number of messages to display per page
|
||||
* @var int start The message which should be considered currently active, used to determine the page we're on
|
||||
* @var int jump_to_id The ID of the message that is being jumped to in the archive, usually when a user clicked on a quote reference
|
||||
@@ -1054,8 +1098,8 @@ class mchat
|
||||
$user_avatars[$row['user_id']] = !$display_avatar || !$row['user_avatar'] ? '' : phpbb_get_user_avatar([
|
||||
'avatar' => $row['user_avatar'],
|
||||
'avatar_type' => $row['user_avatar_type'],
|
||||
'avatar_width' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 40 : 0,
|
||||
'avatar_height' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 0 : 40,
|
||||
'avatar_width' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 36 : 0,
|
||||
'avatar_height' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 0 : 36,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1235,8 +1279,26 @@ class mchat
|
||||
*/
|
||||
protected function assign_bbcodes_smilies()
|
||||
{
|
||||
$display_bbcodes = $this->mchat_settings->cfg('allow_bbcode') && $this->auth->acl_get('u_mchat_bbcode');
|
||||
|
||||
$display_smilies = $this->mchat_settings->cfg('allow_smilies') && $this->auth->acl_get('u_mchat_smilies') && !$this->smilies_generated;
|
||||
|
||||
/**
|
||||
* Event to decide whether or to display BBCodes or smilies
|
||||
*
|
||||
* @event dmzx.mchat.assign_bbcodes_smilies_before
|
||||
* @var bool display_bbcodes Whether or not to render BBCodes
|
||||
* @var bool display_smilies Whether or not to render smilies
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'display_bbcodes',
|
||||
'display_smilies',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.assign_bbcodes_smilies_before', compact($vars)));
|
||||
|
||||
// Display BBCodes
|
||||
if ($this->mchat_settings->cfg('allow_bbcode') && $this->auth->acl_get('u_mchat_bbcode'))
|
||||
if ($display_bbcodes)
|
||||
{
|
||||
$bbcode_template_vars = [
|
||||
'quote' => [
|
||||
@@ -1275,7 +1337,7 @@ class mchat
|
||||
}
|
||||
|
||||
// Display smilies
|
||||
if ($this->mchat_settings->cfg('allow_smilies') && $this->auth->acl_get('u_mchat_smilies') && !$this->smilies_generated)
|
||||
if ($display_smilies)
|
||||
{
|
||||
$this->mchat_settings->include_functions('posting', 'generate_smilies');
|
||||
|
||||
@@ -1468,6 +1530,30 @@ class mchat
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to modify the raw mChat message before it is processed
|
||||
*
|
||||
* @event dmzx.mchat.process_message_before
|
||||
* @var string message The raw message as entered by the user
|
||||
* @var string message_without_bbcode The message stripped of all BBCode tags
|
||||
* @var array disallowed_bbcodes The list of disallowed BBCode tags
|
||||
* @var bool mchat_img Whether or not the img BBCode is allowed
|
||||
* @var bool mchat_flash Whether or not the flash BBCode is allowed
|
||||
* @var bool mchat_quote Whether or not the quote BBCode is allowed
|
||||
* @var bool mchat_url Whether or not the url BBCode is allowed
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'message',
|
||||
'message_without_bbcode',
|
||||
'disallowed_bbcodes',
|
||||
'mchat_img',
|
||||
'mchat_flash',
|
||||
'mchat_quote',
|
||||
'mchat_url',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.process_message_before', compact($vars)));
|
||||
|
||||
$uid = $bitfield = $options = '';
|
||||
generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_bbcode, $mchat_magic_urls, $mchat_smilies, $mchat_img, $mchat_flash, $mchat_quote, $mchat_url, 'mchat');
|
||||
|
||||
|
||||
@@ -119,9 +119,8 @@ class notifications
|
||||
*/
|
||||
public function process($rows)
|
||||
{
|
||||
// All language keys of valid notifications for which we need to fetch post information
|
||||
// from the database. We need to check for them here because notifications in < 2.0.0-RC6
|
||||
// are plain text and don't need to be processed.
|
||||
// All language keys of valid notifications. We need to check for them here because
|
||||
// notifications in < 2.0.0-RC6 are plain text and don't need to be processed.
|
||||
$notification_lang = [
|
||||
'MCHAT_NEW_POST',
|
||||
'MCHAT_NEW_QUOTE',
|
||||
@@ -130,6 +129,20 @@ class notifications
|
||||
'MCHAT_NEW_LOGIN',
|
||||
];
|
||||
|
||||
/**
|
||||
* Event that allows to modify rows and language keys before checking for notifications
|
||||
*
|
||||
* @event dmzx.mchat.process_notifications_before
|
||||
* @var array rows Message rows about to be checked for notifications
|
||||
* @var array notification_lang Unprocessed language keys of valid/known notifications
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'rows',
|
||||
'notification_lang',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.process_notifications_before', compact($vars)));
|
||||
|
||||
$notification_langs = array_merge(
|
||||
// Raw notification messages in phpBB < 3.2
|
||||
array_combine($notification_lang, $notification_lang),
|
||||
@@ -164,6 +177,24 @@ class notifications
|
||||
$rows[$i] = $this->process_notification($rows[$i], $type, $lang_key, $post_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows to modify rows after processing their notifications
|
||||
*
|
||||
* @event dmzx.mchat.process_notifications_after
|
||||
* @var array rows Message rows about to be checked for notifications
|
||||
* @var array notification_lang Unprocessed language keys of valid/known notifications
|
||||
* @var array notification_langs Processed language keys of valid/known notifications
|
||||
* @var array notification_post_data Post data of notifications found in the rows array
|
||||
* @since 2.1.4-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'rows',
|
||||
'notification_lang',
|
||||
'notification_langs',
|
||||
'notification_post_data',
|
||||
];
|
||||
extract($this->dispatcher->trigger_event('dmzx.mchat.process_notifications_after', compact($vars)));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@@ -191,24 +222,15 @@ class notifications
|
||||
$rows = $this->db->sql_fetchrowset($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$post_subjects = [];
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$post_subjects[$row['post_id']] = [
|
||||
'post_subject' => $row['post_subject'],
|
||||
'forum_id' => $row['forum_id'],
|
||||
'forum_name' => $row['forum_name'],
|
||||
];
|
||||
}
|
||||
$existing_post_ids = array_column($rows, 'post_id');
|
||||
$existing_posts = array_combine($existing_post_ids, $rows);
|
||||
|
||||
// Map IDs of missing posts to null
|
||||
$missing_post_subjects = array_fill_keys(array_diff($post_ids, array_keys($post_subjects)), null);
|
||||
$missing_posts = array_fill_keys(array_diff($post_ids, $existing_post_ids), null);
|
||||
|
||||
return $post_subjects + $missing_post_subjects;
|
||||
return $existing_posts + $missing_posts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the message field of the post row so that it can be passed to generate_text_for_display()
|
||||
*
|
||||
@@ -399,4 +421,33 @@ class notifications
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete post notification messages, for example when disapproving posts
|
||||
*
|
||||
* @param array $post_ids
|
||||
*/
|
||||
public function delete_post_notifications($post_ids)
|
||||
{
|
||||
if ($post_ids)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . $this->mchat_settings->get_table_mchat() . '
|
||||
WHERE forum_id <> 0 AND ' . $this->db->sql_in_set('post_id', $post_ids);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the user to which a post notification belongs
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param int $user_id
|
||||
*/
|
||||
public function update_post_notification_user($post_id, $user_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->mchat_settings->get_table_mchat() . '
|
||||
SET user_id = ' . (int) $user_id . '
|
||||
WHERE forum_id <> 0 AND post_id = ' . (int) $post_id;
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use phpbb\auth\auth;
|
||||
use phpbb\config\config;
|
||||
use phpbb\config\db_text;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\exception\runtime_exception;
|
||||
use phpbb\language\language;
|
||||
use phpbb\user;
|
||||
|
||||
@@ -361,6 +362,11 @@ class settings
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->config[$config]))
|
||||
{
|
||||
return $this->config[$config];
|
||||
}
|
||||
|
||||
$global_text_settings = $this->global_text_settings();
|
||||
|
||||
if (isset($global_text_settings[$config]))
|
||||
@@ -369,7 +375,7 @@ class settings
|
||||
return $global_text_values[$config];
|
||||
}
|
||||
|
||||
return $this->config[$config];
|
||||
throw new runtime_exception();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,9 +84,11 @@ class main_listener implements EventSubscriberInterface
|
||||
'core.page_header' => 'add_page_header_link',
|
||||
'core.index_modify_page_title' => 'display_mchat_on_index',
|
||||
'core.submit_post_end' => 'insert_posting',
|
||||
'core.delete_posts_after' => 'delete_posts_after',
|
||||
'core.display_custom_bbcodes_modify_sql' => [['remove_disallowed_bbcodes'], ['pm_compose_add_quote']],
|
||||
'core.generate_smilies_after' => 'generate_smilies_after',
|
||||
'core.user_add_modify_data' => 'user_registration_set_default_values',
|
||||
'core.mcp_change_poster_after' => 'mcp_change_poster_after',
|
||||
'core.login_box_redirect' => 'user_login_success',
|
||||
'core.session_gc_after' => 'session_gc',
|
||||
];
|
||||
@@ -141,6 +143,14 @@ class main_listener implements EventSubscriberInterface
|
||||
$this->mchat_notifications->insert_post($event['mode'], $event['data']['forum_id'], $event['data']['post_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data $event
|
||||
*/
|
||||
public function delete_posts_after(data $event)
|
||||
{
|
||||
$this->mchat_notifications->delete_post_notifications($event['post_ids']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data $event
|
||||
*/
|
||||
@@ -167,6 +177,14 @@ class main_listener implements EventSubscriberInterface
|
||||
$event['sql_ary'] = $this->mchat->set_user_default_values($event['sql_ary']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data $event
|
||||
*/
|
||||
public function mcp_change_poster_after(data $event)
|
||||
{
|
||||
$this->mchat_notifications->update_post_notification_user($event['post_info']['post_id'], $event['userdata']['user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data $event
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ $lang = array_merge($lang, [
|
||||
'MCHAT_VERSION' => 'Version',
|
||||
'MCHAT_RULES' => 'Rules',
|
||||
'MCHAT_RULES_EXPLAIN' => 'Enter the rules here. HTML code is allowed. Set to empty to disable the display.<br>This message can be translated: edit the MCHAT_RULES_MESSAGE language key in /ext/dmzx/mchat/language/XX/mchat.php.',
|
||||
'MCHAT_CONFIG_SAVED' => 'mChat configuration has been updated',
|
||||
'MCHAT_CONFIG_SAVED' => 'mChat configuration has been updated.',
|
||||
'MCHAT_AVATARS' => 'Display avatars',
|
||||
'MCHAT_AVATARS_EXPLAIN' => 'If set to yes, resized user avatars will be displayed.',
|
||||
'MCHAT_INDEX' => 'Display mChat on the index page',
|
||||
@@ -129,7 +129,11 @@ $lang = array_merge($lang, [
|
||||
'MCHAT_SOUND' => 'Play sounds for new, edited and deleted messages',
|
||||
'MCHAT_PURGE' => 'Delete all messages now',
|
||||
'MCHAT_PURGE_CONFIRM' => 'Confirm deleting all messages',
|
||||
'MCHAT_PURGED' => 'All mChat messages have been successfully deleted',
|
||||
'MCHAT_PURGED' => 'All mChat messages have been successfully deleted.',
|
||||
|
||||
'MCHAT_REPARSER_STATUS' => 'Message reparser status',
|
||||
'MCHAT_REPARSER_ACTIVE' => 'active',
|
||||
'MCHAT_REPARSER_FINISHED' => 'finished',
|
||||
|
||||
// '%1$s' contains 'Retain posts' and 'Delete posts' respectively
|
||||
'MCHAT_RETAIN_MESSAGES' => '%1$s and retain mChat messages',
|
||||
|
||||
30
migrations/mchat_2_1_4.php
Normal file
30
migrations/mchat_2_1_4.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
* @copyright (c) 2020 kasimi - https://kasimi.net
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace dmzx\mchat\migrations;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class mchat_2_1_4 extends migration
|
||||
{
|
||||
public static function depends_on()
|
||||
{
|
||||
return [
|
||||
'\dmzx\mchat\migrations\mchat_2_1_4_rc2',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.update', ['mchat_version', '2.1.4']],
|
||||
];
|
||||
}
|
||||
}
|
||||
30
migrations/mchat_2_1_4_rc1.php
Normal file
30
migrations/mchat_2_1_4_rc1.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
* @copyright (c) 2020 kasimi - https://kasimi.net
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace dmzx\mchat\migrations;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class mchat_2_1_4_rc1 extends migration
|
||||
{
|
||||
public static function depends_on()
|
||||
{
|
||||
return [
|
||||
'\dmzx\mchat\migrations\mchat_2_1_3',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.update', ['mchat_version', '2.1.4-RC1']],
|
||||
];
|
||||
}
|
||||
}
|
||||
30
migrations/mchat_2_1_4_rc2.php
Normal file
30
migrations/mchat_2_1_4_rc2.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
* @copyright (c) 2020 kasimi - https://kasimi.net
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace dmzx\mchat\migrations;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class mchat_2_1_4_rc2 extends migration
|
||||
{
|
||||
public static function depends_on()
|
||||
{
|
||||
return [
|
||||
'\dmzx\mchat\migrations\mchat_2_1_4_rc1',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.update', ['mchat_version', '2.1.4-RC2']],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ ul#mchat-messages {
|
||||
color: #3a3a3a;
|
||||
}
|
||||
|
||||
ul.mchat-buttons .fa {
|
||||
ul.mchat-buttons .icon {
|
||||
color: #107c10;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
autosize 4.0.1
|
||||
autosize 4.0.2
|
||||
license: MIT
|
||||
http://www.jacklmoore.com/autosize
|
||||
*/
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1<n.indexOf(e)},get:function(e){return o[n.indexOf(e)]},set:function(e,t){-1===n.indexOf(e)&&(n.push(e),o.push(t))},delete:function(e){var t=n.indexOf(e);-1<t&&(n.splice(t,1),o.splice(t,1))}}),c=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){c=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(r){if(r&&r.nodeName&&"TEXTAREA"===r.nodeName&&!p.has(r)){var e,n=null,o=null,i=null,d=function(){r.clientWidth!==o&&a()},l=function(t){window.removeEventListener("resize",d,!1),r.removeEventListener("input",a,!1),r.removeEventListener("keyup",a,!1),r.removeEventListener("autosize:destroy",l,!1),r.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach(function(e){r.style[e]=t[e]}),p.delete(r)}.bind(r,{height:r.style.height,resize:r.style.resize,overflowY:r.style.overflowY,overflowX:r.style.overflowX,wordWrap:r.style.wordWrap});r.addEventListener("autosize:destroy",l,!1),"onpropertychange"in r&&"oninput"in r&&r.addEventListener("keyup",a,!1),window.addEventListener("resize",d,!1),r.addEventListener("input",a,!1),r.addEventListener("autosize:update",a,!1),r.style.overflowX="hidden",r.style.wordWrap="break-word",p.set(r,{destroy:l,update:a}),"vertical"===(e=window.getComputedStyle(r,null)).resize?r.style.resize="none":"both"===e.resize&&(r.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(e){var t=r.style.width;r.style.width="0px",r.offsetWidth,r.style.width=t,r.style.overflowY=e}function u(){if(0!==r.scrollHeight){var e=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(r),t=document.documentElement&&document.documentElement.scrollTop;r.style.height="",r.style.height=r.scrollHeight+n+"px",o=r.clientWidth,e.forEach(function(e){e.node.scrollTop=e.scrollTop}),t&&(document.documentElement.scrollTop=t)}}function a(){u();var e=Math.round(parseFloat(r.style.height)),t=window.getComputedStyle(r,null),n="content-box"===t.boxSizing?Math.round(parseFloat(t.height)):r.offsetHeight;if(n!==e?"hidden"===t.overflowY&&(s("scroll"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight):"hidden"!==t.overflowY&&(s("hidden"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight),i!==n){i=n;var o=c("autosize:resized");try{r.dispatchEvent(o)}catch(e){}}}}function i(e){var t=p.get(e);t&&t.destroy()}function d(e){var t=p.get(e);t&&t.update()}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return r(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],d),e}),t.default=l,e.exports=t.default});
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1<n.indexOf(e)},get:function(e){return o[n.indexOf(e)]},set:function(e,t){-1===n.indexOf(e)&&(n.push(e),o.push(t))},delete:function(e){var t=n.indexOf(e);-1<t&&(n.splice(t,1),o.splice(t,1))}}),c=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){c=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(r){if(r&&r.nodeName&&"TEXTAREA"===r.nodeName&&!p.has(r)){var e,n=null,o=null,i=null,d=function(){r.clientWidth!==o&&a()},l=function(t){window.removeEventListener("resize",d,!1),r.removeEventListener("input",a,!1),r.removeEventListener("keyup",a,!1),r.removeEventListener("autosize:destroy",l,!1),r.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach(function(e){r.style[e]=t[e]}),p.delete(r)}.bind(r,{height:r.style.height,resize:r.style.resize,overflowY:r.style.overflowY,overflowX:r.style.overflowX,wordWrap:r.style.wordWrap});r.addEventListener("autosize:destroy",l,!1),"onpropertychange"in r&&"oninput"in r&&r.addEventListener("keyup",a,!1),window.addEventListener("resize",d,!1),r.addEventListener("input",a,!1),r.addEventListener("autosize:update",a,!1),r.style.overflowX="hidden",r.style.wordWrap="break-word",p.set(r,{destroy:l,update:a}),"vertical"===(e=window.getComputedStyle(r,null)).resize?r.style.resize="none":"both"===e.resize&&(r.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(e){var t=r.style.width;r.style.width="0px",r.offsetWidth,r.style.width=t,r.style.overflowY=e}function u(){if(0!==r.scrollHeight){var e=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(r),t=document.documentElement&&document.documentElement.scrollTop;r.style.height="",r.style.height=r.scrollHeight+n+"px",o=r.clientWidth,e.forEach(function(e){e.node.scrollTop=e.scrollTop}),t&&(document.documentElement.scrollTop=t)}}function a(){u();var e=Math.round(parseFloat(r.style.height)),t=window.getComputedStyle(r,null),n="content-box"===t.boxSizing?Math.round(parseFloat(t.height)):r.offsetHeight;if(n<e?"hidden"===t.overflowY&&(s("scroll"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight):"hidden"!==t.overflowY&&(s("hidden"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight),i!==n){i=n;var o=c("autosize:resized");try{r.dispatchEvent(o)}catch(e){}}}}function i(e){var t=p.get(e);t&&t.destroy()}function d(e){var t=p.get(e);t&&t.update()}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return r(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],d),e}),t.default=l,e.exports=t.default});
|
||||
@@ -114,7 +114,7 @@ jQuery(function($) {
|
||||
$.ajax({
|
||||
url: mChat.actionUrls[mode],
|
||||
timeout: Math.min(mChat.refreshTime, 10000) - 100,
|
||||
type: 'POST',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
context: {
|
||||
@@ -207,7 +207,7 @@ jQuery(function($) {
|
||||
},
|
||||
sound: function(file) {
|
||||
var data = {
|
||||
audio: mChat.cached('sound-' + file).get(0),
|
||||
audio: mChat.cached('sound-' + file)[0],
|
||||
file: file,
|
||||
play: !mChat.pageIsUnloading && mChat.cached('sound').hasClass('mchat-nav-item-enabled')
|
||||
};
|
||||
@@ -250,7 +250,7 @@ jQuery(function($) {
|
||||
var $input = $confirmFields.find(':input:visible:enabled:first');
|
||||
if ($input.length) {
|
||||
var value = $input.val();
|
||||
$input.focus().val('').val(value);
|
||||
$input.trigger('focus').val('').val(value);
|
||||
}
|
||||
}, 1);
|
||||
phpbb.confirm(data.container.show(), function(success) {
|
||||
@@ -288,7 +288,7 @@ jQuery(function($) {
|
||||
mChat.setText(originalInputValue);
|
||||
}).always(function() {
|
||||
$add.prop('disabled', false);
|
||||
$input.delay(1).focus();
|
||||
$input.delay(1).trigger('focus');
|
||||
});
|
||||
},
|
||||
edit: function() {
|
||||
@@ -393,12 +393,12 @@ jQuery(function($) {
|
||||
whoisDone: function(json) {
|
||||
var $whois = $(json.container);
|
||||
var $userlist = $whois.find('#mchat-userlist');
|
||||
if (mChat.storage.get('show_userlist')) {
|
||||
$userlist.show();
|
||||
}
|
||||
mChat.cached('whois').replaceWith($whois);
|
||||
mChat.cache.whois = $whois;
|
||||
mChat.cache.userlist = $userlist;
|
||||
if (mChat.storage.get('show_userlist')) {
|
||||
$userlist.show();
|
||||
}
|
||||
if (mChat.page === 'custom') {
|
||||
mChat.cached('refresh-pending').hide();
|
||||
mChat.cached('refresh-explain').show();
|
||||
@@ -411,15 +411,17 @@ jQuery(function($) {
|
||||
}
|
||||
},
|
||||
addMessages: function($messages) {
|
||||
var playSound = true;
|
||||
mChat.cached('messages').find('.mchat-no-messages').remove();
|
||||
$messages.reverse(mChat.messageTop).hide().each(function(i) {
|
||||
$messages.reverse(mChat.messageTop).hide().each(this.addMessage);
|
||||
},
|
||||
addMessage: function(index) {
|
||||
var $message = $(this);
|
||||
var dataAddMessageBefore = {
|
||||
message: $message,
|
||||
delay: mChat.refreshInterval ? 400 : 0,
|
||||
abort: $.inArray($message.data('mchat-id'), mChat.messageIds) !== -1,
|
||||
playSound: playSound
|
||||
playSound: index === 0,
|
||||
titleAlert: index === 0
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_before', [dataAddMessageBefore]);
|
||||
if (dataAddMessageBefore.abort) {
|
||||
@@ -427,12 +429,12 @@ jQuery(function($) {
|
||||
}
|
||||
if (dataAddMessageBefore.playSound) {
|
||||
mChat.sound('add');
|
||||
}
|
||||
if (dataAddMessageBefore.titleAlert) {
|
||||
mChat.titleAlert();
|
||||
playSound = false;
|
||||
}
|
||||
mChat.messageIds.push($message.data('mchat-id'));
|
||||
mChat.fixJumpToUrl.call($message);
|
||||
setTimeout(function() {
|
||||
var dataAddMessageAnimateBefore = {
|
||||
container: mChat.cached('messages'),
|
||||
message: $message,
|
||||
@@ -444,39 +446,26 @@ jQuery(function($) {
|
||||
}
|
||||
},
|
||||
show: function() {
|
||||
var container = this.container;
|
||||
var scrollTop = container.scrollTop();
|
||||
var scrollLeeway = 20;
|
||||
if (mChat.messageTop && scrollTop <= scrollLeeway || !mChat.messageTop && scrollTop >= container.get(0).scrollHeight - container.height() - scrollLeeway) {
|
||||
var animateOptions = {
|
||||
duration: dataAddMessageBefore.delay - 10,
|
||||
easing: 'swing'
|
||||
};
|
||||
this.message.slideDown(animateOptions);
|
||||
if (mChat.messageTop) {
|
||||
container.animate({scrollTop: 0}, animateOptions);
|
||||
} else {
|
||||
animateOptions.complete = function() {
|
||||
var scrollHeight = container.get(0).scrollHeight;
|
||||
if (container.scrollTop() + container.innerHeight() < scrollHeight) {
|
||||
container.animate({scrollTop: scrollHeight}, animateOptions);
|
||||
}
|
||||
};
|
||||
animateOptions.complete();
|
||||
}
|
||||
} else {
|
||||
var scrollTop = this.container.scrollTop();
|
||||
var scrollHeight = this.container[0].scrollHeight;
|
||||
this.message.show();
|
||||
if (mChat.messageTop) {
|
||||
this.container.scrollTop(scrollTop + this.message.outerHeight());
|
||||
}
|
||||
}
|
||||
this.message.addClass('mchat-message-flash');
|
||||
if (mChat.messageTop) {
|
||||
if (scrollTop <= scrollLeeway) {
|
||||
this.container.scrollTop(0);
|
||||
}
|
||||
} else {
|
||||
var height = this.container.height();
|
||||
if (scrollHeight - height - scrollTop <= scrollLeeway) {
|
||||
this.container.scrollTop(scrollHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
$(mChat).trigger('mchat_add_message_animate_before', [dataAddMessageAnimateBefore]);
|
||||
dataAddMessageAnimateBefore.add();
|
||||
dataAddMessageAnimateBefore.show();
|
||||
}, i * dataAddMessageBefore.delay);
|
||||
if (mChat.editDeleteLimit && $message.data('mchat-edit-delete-limit') && $message.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length > 0) {
|
||||
var id = $message.prop('id');
|
||||
setTimeout(function() {
|
||||
@@ -486,7 +475,6 @@ jQuery(function($) {
|
||||
}, mChat.editDeleteLimit);
|
||||
}
|
||||
mChat.startRelativeTimeUpdate.call($message);
|
||||
});
|
||||
},
|
||||
updateMessages: function($messages) {
|
||||
var playSound = true;
|
||||
@@ -729,7 +717,22 @@ jQuery(function($) {
|
||||
mChat.cache[name] = $('#mchat-' + name);
|
||||
}
|
||||
return mChat.cache[name];
|
||||
},
|
||||
onKeyPress: function(e, callbacks) {
|
||||
var isEnter = e.which === 10 || e.which === 13;
|
||||
if (isEnter && $(e.target).is('textarea')) {
|
||||
var callback;
|
||||
var isCtrl = e.ctrlKey || e.metaKey;
|
||||
if (!mChat.maxInputHeight || !isCtrl === !mChat.storage.get('no_enter')) {
|
||||
callback = 'submit';
|
||||
} else if (mChat.maxInputHeight && isCtrl) {
|
||||
callback = 'newline';
|
||||
}
|
||||
if (typeof callbacks[callback] === 'function') {
|
||||
callbacks[callback].call(this, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
mChat.messageIds = mChat.cached('messages').children()
|
||||
@@ -737,6 +740,10 @@ jQuery(function($) {
|
||||
.each(mChat.fixJumpToUrl)
|
||||
.map(function() { return $(this).data('mchat-id'); }).get();
|
||||
|
||||
if (!mChat.messageIds.length) {
|
||||
mChat.messageIds.push(mChat.latestMessageId);
|
||||
}
|
||||
|
||||
mChat.hiddenFields = {};
|
||||
mChat.cached('form').find('input[type=hidden]').each(function() {
|
||||
mChat.hiddenFields[this.name] = this.value;
|
||||
@@ -772,10 +779,9 @@ jQuery(function($) {
|
||||
});
|
||||
|
||||
$.each(['userlist', 'smilies', 'bbcodes', 'colour'], function(i, elem) {
|
||||
if (mChat.storage.get('show_' + elem)) {
|
||||
$('.mchat-button-' + elem).addClass('mchat-button-is-down');
|
||||
mChat.cached(elem).toggle();
|
||||
}
|
||||
var isVisible = mChat.storage.get('show_' + elem) === 'yes';
|
||||
$('.mchat-button-' + elem).toggleClass('mchat-button-is-down', isVisible);
|
||||
mChat.cached(elem).toggle(isVisible);
|
||||
});
|
||||
|
||||
var toggleRememberColor = function() {
|
||||
@@ -827,19 +833,18 @@ jQuery(function($) {
|
||||
});
|
||||
}
|
||||
|
||||
mChat.cached('form').submit(function(e) {
|
||||
mChat.cached('form').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
}).keypress(function(e) {
|
||||
var isEnter = e.which === 10 || e.which === 13;
|
||||
if (isEnter && mChat.cached('input').is(e.target)) {
|
||||
var isCtrl = e.ctrlKey || e.metaKey;
|
||||
if (!mChat.maxInputHeight || !isCtrl === !mChat.storage.get('no_enter')) {
|
||||
}).on('keypress', function(e) {
|
||||
mChat.onKeyPress(e, {
|
||||
'submit': function(e) {
|
||||
e.preventDefault();
|
||||
mChat.add();
|
||||
} else if (mChat.maxInputHeight && isCtrl) {
|
||||
},
|
||||
'newline': function() {
|
||||
mChat.appendText('\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (mChat.showCharCount || mChat.mssgLngth) {
|
||||
@@ -870,9 +875,19 @@ jQuery(function($) {
|
||||
e.preventDefault();
|
||||
mChat.jumpToMessage.call(this);
|
||||
}).on('click', '.mchat-panel-buttons button', function() {
|
||||
var $this = $(this).blur();
|
||||
var $this = $(this).trigger('blur');
|
||||
if ($this.hasClass('mchat-button-down')) {
|
||||
$this.toggleClass('mchat-button-is-down');
|
||||
}
|
||||
}).on('keydown.phpbb.alert', mChat.cached('confirm'), function(e) {
|
||||
mChat.onKeyPress(e, {
|
||||
'newline': function(e) {
|
||||
e.stopImmediatePropagation();
|
||||
var $target = $(e.target);
|
||||
$target.val(function(i, text) {
|
||||
return text + '\n';
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
maxInputHeight : {{ MCHAT_MAX_INPUT_HEIGHT }},
|
||||
editDeleteLimit : {{ MCHAT_EDIT_DELETE_LIMIT }},
|
||||
logId : {{ MCHAT_LOG_ID }},
|
||||
latestMessageId : {{ MCHAT_LATEST_MESSAGE_ID | default(0) }},
|
||||
removeBBCodes : '{{ MCHAT_DISALLOWED_BBCODES | escape('js') }}',
|
||||
|
||||
// Language
|
||||
|
||||
@@ -84,13 +84,13 @@
|
||||
{% EVENT dmzx_mchat_static_container_after %}
|
||||
{% endif %}
|
||||
|
||||
<div id="mchat-main"{% if MCHAT_MESSAGE_TOP %} class="mchat-messages-top"{% endif %}>
|
||||
<div id="mchat-main" class="{{ MCHAT_MESSAGE_TOP ? 'mchat-messages-top' : 'mchat-messages-bottom' }}">
|
||||
{% EVENT dmzx_mchat_messages_container_before %}
|
||||
|
||||
<ul id="mchat-messages" class="topiclist forums">
|
||||
{% if loops.mchatrow|length %}
|
||||
{% INCLUDE '@dmzx_mchat/mchat_messages.html' %}
|
||||
{% else %}
|
||||
{% elseif not MCHAT_TOTAL_MESSAGES %}
|
||||
<li class="row mchat-static mchat-no-messages">{{ lang('MCHAT_NOMESSAGE') }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
{% if definition.MCHAT_ALLOW_MENTION or definition.MCHAT_ALLOW_QUOTE or definition.MCHAT_ALLOW_LIKE or definition.MCHAT_ALLOW_PM or MCHAT_ALLOW_IP or MCHAT_ALLOW_PERMISSIONS or definition.MCHAT_ALLOW_EDIT or definition.MCHAT_ALLOW_DEL or definition.MCHAT_ADD_CUSTOM_BUTTON %}
|
||||
<ul class="mchat-buttons">
|
||||
{% EVENT dmzx_mchat_messages_icons_add_before %}
|
||||
{% if definition.MCHAT_ALLOW_MENTION %}<li><a href="#" title="{{ lang('MCHAT_RESPOND') }}" data-mchat-action="mention"><i class="fa fa-at"><span>{{ lang('MCHAT_RESPOND') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_QUOTE %}<li><a href="#" title="{{ lang('REPLY_WITH_QUOTE') }}" data-mchat-action="quote"><i class="fa fa-quote-left"><span>{{ lang('REPLY_WITH_QUOTE') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_LIKE %}<li><a href="#" title="{{ lang('MCHAT_LIKE') }}" data-mchat-action="like"><i class="fa fa-thumbs-o-up"><span>{{ lang('MCHAT_LIKE') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_PM %}<li><a href="{{ mchatrow.MCHAT_PM }}" title="{{ lang('MCHAT_SEND_PM') }}"><i class="fa fa-envelope-o"><span>{{ lang('MCHAT_SEND_PM') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_IP %}<li><a href="{{ mchatrow.MCHAT_U_IP }}" title="{{ mchatrow.MCHAT_WHOIS_USER }}" data-mchat-action="ip"><i class="fa fa-wifi"><span>{{ mchatrow.MCHAT_WHOIS_USER }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_PERMISSIONS %}<li><a href="{{ mchatrow.MCHAT_U_PERMISSIONS }}" title="{{ lang('MCHAT_PERMISSIONS') }}"><i class="fa fa-exclamation-triangle"><span>{{ lang('MCHAT_PERMISSIONS') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_EDIT %}<li><a href="#" title="{{ lang('MCHAT_EDIT') }}" data-mchat-action="edit"><i class="fa fa-pencil"><span>{{ lang('MCHAT_EDIT') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_DEL %}<li><a href="#" title="{{ lang('DELETE') }}" data-mchat-action="del"><i class="fa fa-trash-o"><span>{{ lang('DELETE') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_MENTION %}<li><a href="#" title="{{ lang('MCHAT_RESPOND') }}" data-mchat-action="mention"><i class="icon fa-at"><span>{{ lang('MCHAT_RESPOND') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_QUOTE %}<li><a href="#" title="{{ lang('REPLY_WITH_QUOTE') }}" data-mchat-action="quote"><i class="icon fa-quote-left"><span>{{ lang('REPLY_WITH_QUOTE') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_LIKE %}<li><a href="#" title="{{ lang('MCHAT_LIKE') }}" data-mchat-action="like"><i class="icon fa-thumbs-o-up"><span>{{ lang('MCHAT_LIKE') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_PM %}<li><a href="{{ mchatrow.MCHAT_PM }}" title="{{ lang('MCHAT_SEND_PM') }}"><i class="icon fa-envelope-o"><span>{{ lang('MCHAT_SEND_PM') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_IP %}<li><a href="{{ mchatrow.MCHAT_U_IP }}" title="{{ mchatrow.MCHAT_WHOIS_USER }}" data-mchat-action="ip"><i class="icon fa-wifi"><span>{{ mchatrow.MCHAT_WHOIS_USER }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_PERMISSIONS %}<li><a href="{{ mchatrow.MCHAT_U_PERMISSIONS }}" title="{{ lang('MCHAT_PERMISSIONS') }}"><i class="icon fa-exclamation-triangle"><span>{{ lang('MCHAT_PERMISSIONS') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_EDIT %}<li><a href="#" title="{{ lang('MCHAT_EDIT') }}" data-mchat-action="edit"><i class="icon fa-pencil"><span>{{ lang('MCHAT_EDIT') }}</span></i></a></li>{% endif %}
|
||||
{% if definition.MCHAT_ALLOW_DEL %}<li><a href="#" title="{{ lang('DELETE') }}" data-mchat-action="del"><i class="icon fa-trash-o"><span>{{ lang('DELETE') }}</span></i></a></li>{% endif %}
|
||||
{% EVENT dmzx_mchat_messages_icons_add_after %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-box-pack: left;
|
||||
-ms-flex-pack: left;
|
||||
justify-content: left;
|
||||
-webkit-box-pack: start;
|
||||
-ms-flex-pack: start;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.mchat-wrapper li.header dd {
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
.mchat-avatar {
|
||||
float: left;
|
||||
width: 40px;
|
||||
width: 36px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
margin: 0 3px;
|
||||
}
|
||||
|
||||
.mchat-wrapper .mchat-buttons .fa {
|
||||
.mchat-wrapper .mchat-buttons .icon {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
.mchat-text {
|
||||
clear: both;
|
||||
overflow: hidden;
|
||||
padding: 2px 5px;
|
||||
padding: 0 5px 1px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user