Version 2.1.0

This commit is contained in:
dmzx
2018-08-02 11:34:39 +02:00
parent cd0f139598
commit 006a4e404e
140 changed files with 2695 additions and 2699 deletions

View File

@@ -15,21 +15,21 @@ class acp_mchat_info
{
function module()
{
return array(
return [
'filename' => '\dmzx\mchat\acp\acp_mchat_module',
'title' => 'ACP_CAT_MCHAT',
'modes' => array(
'globalsettings' => array(
'modes' => [
'globalsettings' => [
'title' => 'ACP_MCHAT_GLOBALSETTINGS',
'auth' => 'ext_dmzx/mchat && acl_a_mchat',
'cat' => array('ACP_CAT_MCHAT'),
),
'globalusersettings' => array(
'cat' => ['ACP_CAT_MCHAT'],
],
'globalusersettings' => [
'title' => 'ACP_MCHAT_GLOBALUSERSETTINGS',
'auth' => 'ext_dmzx/mchat && acl_a_mchat',
'cat' => array('ACP_CAT_MCHAT'),
),
),
);
'cat' => ['ACP_CAT_MCHAT'],
],
],
];
}
}

View File

@@ -19,10 +19,11 @@ class acp_mchat_module
public function main($id, $mode)
{
global $phpbb_container, $user;
global $phpbb_container;
// Add the ACP lang file
$user->add_lang_ext('dmzx/mchat', array('mchat_acp', 'mchat_ucp'));
$language = $phpbb_container->get('language');
$language->add_lang(['mchat_acp', 'mchat_ucp'], 'dmzx/mchat');
// Set template
$this->tpl_name = 'acp_mchat_' . strtolower($mode);

View File

@@ -1,5 +1,11 @@
{% INCLUDE 'overall_header.html' %}
<style>
dd label span {
white-space: normal;
}
</style>
<h1>{{ lang('MCHAT_TITLE') }}</h1>
{{ lang('MCHAT_VERSION') ~ lang('COLON') }} <em>{{ MCHAT_VERSION }}</em>
@@ -20,12 +26,12 @@
<dl>
<dt><label for="mchat_index_height">{{ lang('MCHAT_INDEX_HEIGHT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_INDEX_HEIGHT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_index_height" id="mchat_index_height" size="10" maxlength="4" value="{{ MCHAT_INDEX_HEIGHT }}" />&nbsp;<span>{{ lang('PIXEL') }}</span></dd>
<dd><input type="text" name="mchat_index_height" id="mchat_index_height" size="10" maxlength="4" value="{{ MCHAT_INDEX_HEIGHT }}">&nbsp;<span>{{ lang('PIXEL') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_message_num_index">{{ lang('MCHAT_MESSAGE_NUM_INDEX') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_MESSAGE_NUM_INDEX_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_message_num_index" id="mchat_message_num_index" size="10" maxlength="4" value="{{ MCHAT_MESSAGE_NUM_INDEX }}" />&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
<dd><input type="text" name="mchat_message_num_index" id="mchat_message_num_index" size="10" maxlength="4" value="{{ MCHAT_MESSAGE_NUM_INDEX }}">&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
</dl>
{% EVENT dmzx_mchat_acp_message_num_index_after %}
@@ -41,28 +47,18 @@
<dl>
<dt><label for="mchat_custom_page">{{ lang('MCHAT_CUSTOM_PAGE') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="mchat_custom_page" value="1"{% if MCHAT_CUSTOM_PAGE %} id="mchat_custom_page" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_custom_page" value="0"{% if not MCHAT_CUSTOM_PAGE %} id="mchat_custom_page" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><label><input type="radio" class="radio" name="mchat_custom_page" value="1"{% if MCHAT_CUSTOM_PAGE %} id="mchat_custom_page" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_custom_page" value="0"{% if not MCHAT_CUSTOM_PAGE %} id="mchat_custom_page" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_custom_height">{{ lang('MCHAT_CUSTOM_HEIGHT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_CUSTOM_HEIGHT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_custom_height" id="mchat_custom_height" size="10" maxlength="4" value="{{ MCHAT_CUSTOM_HEIGHT }}" />&nbsp;<span>{{ lang('PIXEL') }}</span></dd>
<dd><input type="text" name="mchat_custom_height" id="mchat_custom_height" size="10" maxlength="4" value="{{ MCHAT_CUSTOM_HEIGHT }}">&nbsp;<span>{{ lang('PIXEL') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_message_num_custom">{{ lang('MCHAT_MESSAGE_NUM_CUSTOM') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_MESSAGE_NUM_CUSTOM_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_message_num_custom" id="mchat_message_num_custom" size="10" value="{{ MCHAT_MESSAGE_NUM_CUSTOM }}" />&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_navbar_link">{{ lang('MCHAT_NAVBAR_LINK') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="mchat_navbar_link" value="1"{% if MCHAT_NAVBAR_LINK %} id="mchat_navbar_link" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_navbar_link" value="0"{% if not MCHAT_NAVBAR_LINK %} id="mchat_navbar_link" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_navbar_link_count">{{ lang('MCHAT_NAVBAR_LINK_COUNT') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="mchat_navbar_link_count" value="1"{% if MCHAT_NAVBAR_LINK_COUNT %} id="mchat_navbar_link_count" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_navbar_link_count" value="0"{% if not MCHAT_NAVBAR_LINK_COUNT %} id="mchat_navbar_link_count" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><input type="text" name="mchat_message_num_custom" id="mchat_message_num_custom" size="10" value="{{ MCHAT_MESSAGE_NUM_CUSTOM }}">&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
</dl>
{% EVENT dmzx_mchat_acp_navbar_link_count_after %}
@@ -76,7 +72,7 @@
<dl>
<dt><label for="mchat_message_num_archive">{{ lang('MCHAT_MESSAGE_NUM_ARCHIVE') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_MESSAGE_NUM_ARCHIVE_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_message_num_archive" id="mchat_message_num_archive" size="10" value="{{ MCHAT_MESSAGE_NUM_ARCHIVE }}" />&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
<dd><input type="text" name="mchat_message_num_archive" id="mchat_message_num_archive" size="10" value="{{ MCHAT_MESSAGE_NUM_ARCHIVE }}">&nbsp;<span>{{ lang('MCHAT_ACP_MESSAGES') }}</span></dd>
</dl>
{% EVENT dmzx_mchat_acp_message_num_archive_after %}
@@ -84,9 +80,9 @@
<dl>
<dt><label for="mchat_archive_sort">{{ lang('MCHAT_ARCHIVE_SORT') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="0"{% if MCHAT_ARCHIVE_SORT == 0 %} id="mchat_archive_sort" checked="checked"{% endif %} /> {{ lang('MCHAT_ARCHIVE_SORT_TOP_BOTTOM') }}</label><br>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="1"{% if MCHAT_ARCHIVE_SORT == 1 %} id="mchat_archive_sort" checked="checked"{% endif %} /> {{ lang('MCHAT_ARCHIVE_SORT_BOTTOM_TOP') }}</label><br>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="2"{% if MCHAT_ARCHIVE_SORT == 2 %} id="mchat_archive_sort" checked="checked"{% endif %} /> {{ lang('MCHAT_ARCHIVE_SORT_USER') }}</label>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="0"{% if MCHAT_ARCHIVE_SORT == 0 %} id="mchat_archive_sort" checked="checked"{% endif %}> {{ lang('MCHAT_ARCHIVE_SORT_TOP_BOTTOM') }}</label><br>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="1"{% if MCHAT_ARCHIVE_SORT == 1 %} id="mchat_archive_sort" checked="checked"{% endif %}> {{ lang('MCHAT_ARCHIVE_SORT_BOTTOM_TOP') }}</label><br>
<label><input type="radio" class="radio" name="mchat_archive_sort" value="2"{% if MCHAT_ARCHIVE_SORT == 2 %} id="mchat_archive_sort" checked="checked"{% endif %}> {{ lang('MCHAT_ARCHIVE_SORT_USER') }}</label>
</dd>
</dl>
</fieldset>
@@ -98,45 +94,50 @@
<dl>
<dt><label for="mchat_timeout">{{ lang('MCHAT_TIMEOUT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_TIMEOUT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_timeout" id="mchat_timeout" size="10" maxlength="4" value="{{ MCHAT_TIMEOUT }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<dd><input type="text" name="mchat_timeout" id="mchat_timeout" size="10" maxlength="4" value="{{ MCHAT_TIMEOUT }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_refresh">{{ lang('MCHAT_REFRESH') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_REFRESH_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_refresh" id="mchat_refresh" size="10" value="{{ MCHAT_REFRESH }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<dd><input type="text" name="mchat_refresh" id="mchat_refresh" size="10" value="{{ MCHAT_REFRESH }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_edit_delete_limit">{{ lang('MCHAT_EDIT_DELETE_LIMIT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_EDIT_DELETE_LIMIT_EXPLAIN') }}</span>
<dd><input type="text" name="mchat_edit_delete_limit" id="mchat_edit_delete_limit" size="10" value="{{ MCHAT_EDIT_DELETE_LIMIT }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<span>{{ lang('MCHAT_EDIT_DELETE_LIMIT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_edit_delete_limit" id="mchat_edit_delete_limit" size="10" value="{{ MCHAT_EDIT_DELETE_LIMIT }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_live_updates">{{ lang('MCHAT_LIVE_UPDATES') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_LIVE_UPDATES_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_live_updates" value="1"{% if MCHAT_LIVE_UPDATES %} id="mchat_live_updates" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_live_updates" value="0"{% if not MCHAT_LIVE_UPDATES %} id="mchat_live_updates" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><label><input type="radio" class="radio" name="mchat_live_updates" value="1"{% if MCHAT_LIVE_UPDATES %} id="mchat_live_updates" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_live_updates" value="0"{% if not MCHAT_LIVE_UPDATES %} id="mchat_live_updates" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_flood_time">{{ lang('MCHAT_FLOOD_TIME') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_FLOOD_TIME_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_flood_time" id="mchat_flood_time" size="10" value="{{ MCHAT_FLOOD_TIME }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<dd><input type="text" name="mchat_flood_time" id="mchat_flood_time" size="10" value="{{ MCHAT_FLOOD_TIME }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_max_message_lngth">{{ lang('MCHAT_MAX_MESSAGE_LENGTH') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_MAX_MESSAGE_LENGTH_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_max_message_lngth" id="mchat_max_message_lngth" size="10" value="{{ MCHAT_MAX_MESSAGE_LNGTH }}" />&nbsp;<span>{{ lang('MCHAT_ACP_CHARACTERS') }}</span></dd>
<dd><input type="text" name="mchat_max_message_lngth" id="mchat_max_message_lngth" size="10" value="{{ MCHAT_MAX_MESSAGE_LNGTH }}">&nbsp;<span>{{ lang('MCHAT_ACP_CHARACTERS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_max_input_height">{{ lang('MCHAT_MAX_INPUT_HEIGHT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_MAX_INPUT_HEIGHT_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_max_input_height" id="mchat_max_input_height" size="10" value="{{ MCHAT_MAX_INPUT_HEIGHT }}">&nbsp;<span>{{ lang('PIXEL') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_override_min_post_chars">{{ lang('MCHAT_OVERRIDE_MIN_POST_CHARS') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_override_min_post_chars" value="1"{% if MCHAT_OVERRIDE_MIN_POST_CHARS %} id="mchat_override_min_post_chars" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_override_min_post_chars" value="0"{% if not MCHAT_OVERRIDE_MIN_POST_CHARS %} id="mchat_override_min_post_chars" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><label><input type="radio" class="radio" name="mchat_override_min_post_chars" value="1"{% if MCHAT_OVERRIDE_MIN_POST_CHARS %} id="mchat_override_min_post_chars" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_override_min_post_chars" value="0"{% if not MCHAT_OVERRIDE_MIN_POST_CHARS %} id="mchat_override_min_post_chars" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_override_smilie_limit">{{ lang('MCHAT_OVERRIDE_SMILIE_LIMIT') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="1"{% if MCHAT_OVERRIDE_SMILIE_LIMIT %} id="mchat_override_smilie_limit" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="0"{% if not MCHAT_OVERRIDE_SMILIE_LIMIT %} id="mchat_override_smilie_limit" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="1"{% if MCHAT_OVERRIDE_SMILIE_LIMIT %} id="mchat_override_smilie_limit" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_override_smilie_limit" value="0"{% if not MCHAT_OVERRIDE_SMILIE_LIMIT %} id="mchat_override_smilie_limit" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_bbcode_disallowed">{{ lang('MCHAT_BBCODES_DISALLOWED') ~ lang('COLON') }}</label><br>
@@ -165,44 +166,44 @@
<dl>
<dt><label for="mchat_posts_topic">{{ lang('MCHAT_POSTS_TOPIC') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_posts_topic" value="1"{% if MCHAT_POSTS_TOPIC %} id="mchat_posts_topic" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_topic" value="0"{% if not MCHAT_POSTS_TOPIC %} id="mchat_posts_topic" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_topic" value="1"{% if MCHAT_POSTS_TOPIC %} id="mchat_posts_topic" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_topic" value="0"{% if not MCHAT_POSTS_TOPIC %} id="mchat_posts_topic" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_posts_reply">{{ lang('MCHAT_POSTS_REPLY') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_posts_reply" value="1"{% if MCHAT_POSTS_REPLY %} id="mchat_posts_reply" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_reply" value="0"{% if not MCHAT_POSTS_REPLY %} id="mchat_posts_reply" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_reply" value="1"{% if MCHAT_POSTS_REPLY %} id="mchat_posts_reply" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_reply" value="0"{% if not MCHAT_POSTS_REPLY %} id="mchat_posts_reply" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_posts_edit">{{ lang('MCHAT_POSTS_EDIT') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_posts_edit" value="1"{% if MCHAT_POSTS_EDIT %} id="mchat_posts_edit" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_edit" value="0"{% if not MCHAT_POSTS_EDIT %} id="mchat_posts_edit" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_edit" value="1"{% if MCHAT_POSTS_EDIT %} id="mchat_posts_edit" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_edit" value="0"{% if not MCHAT_POSTS_EDIT %} id="mchat_posts_edit" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_posts_quote">{{ lang('MCHAT_POSTS_QUOTE') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_posts_quote" value="1"{% if MCHAT_POSTS_QUOTE %} id="mchat_posts_quote" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_quote" value="0"{% if not MCHAT_POSTS_QUOTE %} id="mchat_posts_quote" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_quote" value="1"{% if MCHAT_POSTS_QUOTE %} id="mchat_posts_quote" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_quote" value="0"{% if not MCHAT_POSTS_QUOTE %} id="mchat_posts_quote" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_posts_login">{{ lang('MCHAT_POSTS_LOGIN') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_posts_login" value="1"{% if MCHAT_POSTS_LOGIN %} id="mchat_posts_login" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_login" value="0"{% if not MCHAT_POSTS_LOGIN %} id="mchat_posts_login" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_login" value="1"{% if MCHAT_POSTS_LOGIN %} id="mchat_posts_login" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_login" value="0"{% if not MCHAT_POSTS_LOGIN %} id="mchat_posts_login" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_posts_auth_check">{{ lang('MCHAT_POSTS_AUTH_CHECK') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_POSTS_AUTH_CHECK_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="mchat_posts_auth_check" value="1"{% if MCHAT_POSTS_AUTH_CHECK %} id="mchat_posts_auth_check" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_auth_check" value="0"{% if not MCHAT_POSTS_AUTH_CHECK %} id="mchat_posts_auth_check" checked="checked"{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_posts_auth_check" value="1"{% if MCHAT_POSTS_AUTH_CHECK %} id="mchat_posts_auth_check" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_posts_auth_check" value="0"{% if not MCHAT_POSTS_AUTH_CHECK %} id="mchat_posts_auth_check" checked="checked"{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
@@ -217,7 +218,12 @@
<dl>
<dt><label for="mchat_whois_refresh">{{ lang('MCHAT_WHOIS_REFRESH') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_WHOIS_REFRESH_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_whois_refresh" id="mchat_whois_refresh" size="10" value="{{ MCHAT_WHOIS_REFRESH }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<dd><input type="text" name="mchat_whois_refresh" id="mchat_whois_refresh" size="10" value="{{ MCHAT_WHOIS_REFRESH }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_navbar_link_count">{{ lang('MCHAT_NAVBAR_LINK_COUNT') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="mchat_navbar_link_count" value="1"{% if MCHAT_NAVBAR_LINK_COUNT %} id="mchat_navbar_link_count" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_navbar_link_count" value="0"{% if not MCHAT_NAVBAR_LINK_COUNT %} id="mchat_navbar_link_count" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
{% EVENT dmzx_mchat_acp_whois_refresh_after %}
@@ -231,19 +237,19 @@
<dl>
<dt><label for="mchat_prune">{{ lang('MCHAT_PRUNE') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="mchat_prune" value="1"{% if MCHAT_PRUNE %} id="mchat_prune" checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_prune" value="0"{% if not MCHAT_PRUNE %} id="mchat_prune" checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
<dd><label><input type="radio" class="radio" name="mchat_prune" value="1"{% if MCHAT_PRUNE %} id="mchat_prune" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_prune" value="0"{% if not MCHAT_PRUNE %} id="mchat_prune" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
<dl>
<dt><label for="mchat_prune_gc">{{ lang('MCHAT_PRUNE_GC') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_PRUNE_GC_EXPLAIN') }}</span></dt>
<dd><input type="text" name="mchat_prune_gc" id="mchat_prune_gc" size="10" value="{{ MCHAT_PRUNE_GC }}" />&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
<dd><input type="text" name="mchat_prune_gc" id="mchat_prune_gc" size="10" value="{{ MCHAT_PRUNE_GC }}">&nbsp;<span>{{ lang('MCHAT_ACP_SECONDS') }}</span></dd>
</dl>
<dl>
<dt><label for="mchat_prune_num">{{ lang('MCHAT_PRUNE_NUM') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_PRUNE_NUM_EXPLAIN') }}</span></dt>
<dd>
<input type="text" name="mchat_prune_num" size="10" id="mchat_prune_num" value="{{ MCHAT_PRUNE_NUM }}" />
<input type="text" name="mchat_prune_num" size="10" id="mchat_prune_num" value="{{ MCHAT_PRUNE_NUM }}">
<select name="mchat_prune_mode" id="mchat_prune_mode" title="{{ lang('MCHAT_PRUNE_NUM') }}">
{{ S_MCHAT_PRUNE_MODE_OPTIONS }}
</select>
@@ -252,24 +258,40 @@
<dl>
<dt><label for="mchat_prune_now">{{ lang('MCHAT_PRUNE_NOW') ~ lang('COLON') }}</label></dt>
<dd>
<input class="button1" type="submit" id="mchat_prune_now" name="mchat_prune_now" value="{{ lang('MCHAT_PRUNE_NOW') }}" />
<input class="button1" type="submit" id="mchat_prune_now" name="mchat_prune_now" value="{{ lang('MCHAT_PRUNE_NOW') }}">
<label>{{ lang('MCHAT_PRUNE_NOW_CONFIRM') ~ lang('COLON') }}</label>
<label><input type="radio" name="mchat_prune_now_confirm" value="1" /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_prune_now_confirm" value="0" id="mchat_prune_now_confirm" checked="checked" /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_prune_now_confirm" value="1"> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_prune_now_confirm" value="0" id="mchat_prune_now_confirm" checked="checked"> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_purge">{{ lang('MCHAT_PURGE') ~ lang('COLON') }}</label></dt>
<dd>
<input class="button1" type="submit" id="mchat_purge" name="mchat_purge" value="{{ lang('MCHAT_PURGE') }}" />
<input class="button1" type="submit" id="mchat_purge" name="mchat_purge" value="{{ lang('MCHAT_PURGE') }}">
<label>{{ lang('MCHAT_PURGE_CONFIRM') ~ lang('COLON') }}</label>
<label><input type="radio" name="mchat_purge_confirm" value="1" /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_purge_confirm" value="0" id="mchat_purge_confirm" checked="checked" /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_purge_confirm" value="1"> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_purge_confirm" value="0" id="mchat_purge_confirm" checked="checked"> {{ lang('NO') }}</label>
</dd>
</dl>
{% EVENT dmzx_mchat_acp_purge_after %}
</fieldset>
<fieldset>
<legend>{{ lang('MCHAT_SETTINGS_LOG') }}</legend>
{% EVENT dmzx_mchat_acp_log_before %}
<dl>
<dt><label for="mchat_log_enabled">{{ lang('MCHAT_LOG_ENABLED') ~ lang('COLON') }}</label><br>
<span>{{ lang('MCHAT_LOG_ENABLED_EXPLAIN') }}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_log_enabled" value="1"{% if MCHAT_LOG_ENABLED %} id="mchat_log_enabled" checked="checked"{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" class="radio" name="mchat_log_enabled" value="0"{% if not MCHAT_LOG_ENABLED %} id="mchat_log_enabled" checked="checked"{% endif %}> {{ lang('NO') }}</label></dd>
</dl>
{% EVENT dmzx_mchat_acp_log_after %}
</fieldset>
{% endif %}
@@ -278,8 +300,8 @@
<fieldset>
<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}" />
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}">&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}">
</p>
{{ S_FORM_TOKEN }}
</fieldset>

View File

@@ -23,23 +23,23 @@
<dl>
<dt><label for="mchat_overwrite">{{ lang('MCHAT_GLOBALUSERSETTINGS_OVERWRITE') ~ lang('COLON') }}</label><br><span>{{ lang('MCHAT_GLOBALUSERSETTINGS_OVERWRITE_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="mchat_overwrite" value="1" /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_overwrite" value="0" id="mchat_overwrite" checked="checked" /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_overwrite" value="1"> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_overwrite" value="0" id="mchat_overwrite" checked="checked"> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="mchat_overwrite_confirm">{{ lang('MCHAT_GLOBALUSERSETTINGS_OVERWRITE_CONFIRM') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="mchat_overwrite_confirm" value="1" /> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_overwrite_confirm" value="0" id="mchat_overwrite_confirm" checked="checked" /> {{ lang('NO') }}</label>
<label><input type="radio" name="mchat_overwrite_confirm" value="1"> {{ lang('YES') }}</label>
<label><input type="radio" name="mchat_overwrite_confirm" value="0" id="mchat_overwrite_confirm" checked="checked"> {{ lang('NO') }}</label>
</dd>
</dl>
</fieldset>
<fieldset>
<legend>{{ lang('ACP_SUBMIT_CHANGES') }}</legend>
<p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}" />
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}">&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{{ lang('RESET') }}">
</p>
{{ S_FORM_TOKEN }}
</fieldset>

View File

@@ -3,85 +3,78 @@
<dl>
<dt><label for="user_mchat_index">{{ lang('MCHAT_INDEX') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_index" value="1"{% if MCHAT_INDEX %} id="user_mchat_index" checked="checked"{% endif %}{% if MCHAT_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_index" value="0"{% if not MCHAT_INDEX %} id="user_mchat_index" checked="checked"{% endif %}{% if MCHAT_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_index" value="1"{% if MCHAT_INDEX %} id="user_mchat_index" checked="checked"{% endif %}{% if MCHAT_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_index" value="0"{% if not MCHAT_INDEX %} id="user_mchat_index" checked="checked"{% endif %}{% if MCHAT_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_whois_index">{{ lang('MCHAT_WHOIS_INDEX') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_whois_index" value="1"{% if MCHAT_WHOIS_INDEX %} id="user_mchat_whois_index" checked="checked"{% endif %}{% if MCHAT_WHOIS_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_whois_index" value="0"{% if not MCHAT_WHOIS_INDEX %} id="user_mchat_whois_index" checked="checked"{% endif %}{% if MCHAT_WHOIS_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_whois_index" value="1"{% if MCHAT_WHOIS_INDEX %} id="user_mchat_whois_index" checked="checked"{% endif %}{% if MCHAT_WHOIS_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_whois_index" value="0"{% if not MCHAT_WHOIS_INDEX %} id="user_mchat_whois_index" checked="checked"{% endif %}{% if MCHAT_WHOIS_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_stats_index">{{ lang('MCHAT_STATS_INDEX') ~ lang('COLON') }}</label><br><span>{{ lang('MCHAT_STATS_INDEX_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="user_mchat_stats_index" value="1"{% if MCHAT_STATS_INDEX %} id="user_mchat_stats_index" checked="checked"{% endif %}{% if MCHAT_STATS_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_stats_index" value="0"{% if not MCHAT_STATS_INDEX %} id="user_mchat_stats_index" checked="checked"{% endif %}{% if MCHAT_STATS_INDEX_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_stats_index" value="1"{% if MCHAT_STATS_INDEX %} id="user_mchat_stats_index" checked="checked"{% endif %}{% if MCHAT_STATS_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_stats_index" value="0"{% if not MCHAT_STATS_INDEX %} id="user_mchat_stats_index" checked="checked"{% endif %}{% if MCHAT_STATS_INDEX_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_location">{{ lang('MCHAT_LOCATION') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_location" value="1"{% if MCHAT_LOCATION %} id="user_mchat_location" checked="checked"{% endif %}{% if MCHAT_LOCATION_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_TOP') }}</label>
<label><input type="radio" name="user_mchat_location" value="0"{% if not MCHAT_LOCATION %} id="user_mchat_location" checked="checked"{% endif %}{% if MCHAT_LOCATION_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_BOTTOM') }}</label>
<label><input type="radio" name="user_mchat_location" value="1"{% if MCHAT_LOCATION %} id="user_mchat_location" checked="checked"{% endif %}{% if MCHAT_LOCATION_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_TOP') }}</label>
<label><input type="radio" name="user_mchat_location" value="0"{% if not MCHAT_LOCATION %} id="user_mchat_location" checked="checked"{% endif %}{% if MCHAT_LOCATION_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_BOTTOM') }}</label>
</dd>
</dl>
{% EVENT dmzx_mchat_acp_location_after %}
<hr />
<hr>
{% EVENT dmzx_mchat_acp_message_top_before %}
<dl>
<dt><label for="user_mchat_message_top">{{ lang('MCHAT_MESSAGE_TOP') ~ lang('COLON') }}</label><br><span>{{ lang('MCHAT_MESSAGE_TOP_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="user_mchat_message_top" value="1"{% if MCHAT_MESSAGE_TOP %} id="user_mchat_message_top" checked="checked"{% endif %}{% if MCHAT_MESSAGE_TOP_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_TOP') }}</label>
<label><input type="radio" name="user_mchat_message_top" value="0"{% if not MCHAT_MESSAGE_TOP %} id="user_mchat_message_top" checked="checked"{% endif %}{% if MCHAT_MESSAGE_TOP_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_BOTTOM') }}</label>
<label><input type="radio" name="user_mchat_message_top" value="1"{% if MCHAT_MESSAGE_TOP %} id="user_mchat_message_top" checked="checked"{% endif %}{% if MCHAT_MESSAGE_TOP_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_TOP') }}</label>
<label><input type="radio" name="user_mchat_message_top" value="0"{% if not MCHAT_MESSAGE_TOP %} id="user_mchat_message_top" checked="checked"{% endif %}{% if MCHAT_MESSAGE_TOP_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_BOTTOM') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_capital_letter">{{ lang('MCHAT_CAPITAL_LETTER') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_capital_letter" value="1"{% if MCHAT_CAPITAL_LETTER %} id="user_mchat_capital_letter" checked="checked"{% endif %}{% if MCHAT_CAPITAL_LETTER_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_capital_letter" value="0"{% if not MCHAT_CAPITAL_LETTER %} id="user_mchat_capital_letter" checked="checked"{% endif %}{% if MCHAT_CAPITAL_LETTER_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_capital_letter" value="1"{% if MCHAT_CAPITAL_LETTER %} id="user_mchat_capital_letter" checked="checked"{% endif %}{% if MCHAT_CAPITAL_LETTER_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_capital_letter" value="0"{% if not MCHAT_CAPITAL_LETTER %} id="user_mchat_capital_letter" checked="checked"{% endif %}{% if MCHAT_CAPITAL_LETTER_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_sound">{{ lang('MCHAT_SOUND') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_sound" value="1"{% if MCHAT_SOUND %} id="user_mchat_sound" checked="checked"{% endif %}{% if MCHAT_SOUND_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_sound" value="0"{% if not MCHAT_SOUND %} id="user_mchat_sound" checked="checked"{% endif %}{% if MCHAT_SOUND_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_sound" value="1"{% if MCHAT_SOUND %} id="user_mchat_sound" checked="checked"{% endif %}{% if MCHAT_SOUND_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_sound" value="0"{% if not MCHAT_SOUND %} id="user_mchat_sound" checked="checked"{% endif %}{% if MCHAT_SOUND_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_avatars">{{ lang('MCHAT_AVATARS') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_avatars" value="1"{% if MCHAT_AVATARS %} id="user_mchat_avatars" checked="checked"{% endif %}{% if MCHAT_AVATARS_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_avatars" value="0"{% if not MCHAT_AVATARS %} id="user_mchat_avatars" checked="checked"{% endif %}{% if MCHAT_AVATARS_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_avatars" value="1"{% if MCHAT_AVATARS %} id="user_mchat_avatars" checked="checked"{% endif %}{% if MCHAT_AVATARS_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_avatars" value="0"{% if not MCHAT_AVATARS %} id="user_mchat_avatars" checked="checked"{% endif %}{% if MCHAT_AVATARS_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_input_area">{{ lang('MCHAT_CHAT_AREA') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_input_area" value="1"{% if MCHAT_INPUT_AREA %} id="user_mchat_input_area" checked="checked"{% endif %}{% if MCHAT_INPUT_AREA_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_INPUT_AREA') }}</label>
<label><input type="radio" name="user_mchat_input_area" value="0"{% if not MCHAT_INPUT_AREA %} id="user_mchat_input_area" checked="checked"{% endif %}{% if MCHAT_INPUT_AREA_NOAUTH %} disabled{% endif %} /> {{ lang('MCHAT_TEXT_AREA') }}</label>
<label><input type="radio" name="user_mchat_input_area" value="1"{% if MCHAT_INPUT_AREA %} id="user_mchat_input_area" checked="checked"{% endif %}{% if MCHAT_INPUT_AREA_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_INPUT_AREA') }}</label>
<label><input type="radio" name="user_mchat_input_area" value="0"{% if not MCHAT_INPUT_AREA %} id="user_mchat_input_area" checked="checked"{% endif %}{% if MCHAT_INPUT_AREA_NOAUTH %} disabled{% endif %}> {{ lang('MCHAT_TEXT_AREA') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_character_count">{{ lang('MCHAT_DISPLAY_CHARACTER_COUNT') ~ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_character_count" value="1"{% if MCHAT_CHARACTER_COUNT %} id="user_mchat_character_count" checked="checked"{% endif %}{% if MCHAT_CHARACTER_COUNT_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_character_count" value="0"{% if not MCHAT_CHARACTER_COUNT %} id="user_mchat_character_count" checked="checked"{% endif %}{% if MCHAT_CHARACTER_COUNT_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_pause_on_input">{{ lang('MCHAT_PAUSE_ON_INPUT') ~ lang('COLON') }}</label><br><span>{{ lang('MCHAT_PAUSE_ON_INPUT_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="user_mchat_pause_on_input" value="1"{% if MCHAT_PAUSE_ON_INPUT %} id="user_mchat_pause_on_input" checked="checked"{% endif %}{% if MCHAT_PAUSE_ON_INPUT_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_pause_on_input" value="0"{% if not MCHAT_PAUSE_ON_INPUT %} id="user_mchat_pause_on_input" checked="checked"{% endif %}{% if MCHAT_PAUSE_ON_INPUT_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_character_count" value="1"{% if MCHAT_CHARACTER_COUNT %} id="user_mchat_character_count" checked="checked"{% endif %}{% if MCHAT_CHARACTER_COUNT_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_character_count" value="0"{% if not MCHAT_CHARACTER_COUNT %} id="user_mchat_character_count" checked="checked"{% endif %}{% if MCHAT_CHARACTER_COUNT_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
@@ -91,27 +84,31 @@
{{ S_MCHAT_DATEFORMAT_OPTIONS }}
</select>
</dd>
<dd><div id="user_mchat_custom_date"{% if not S_MCHAT_CUSTOM_DATEFORMAT %} style="display:none;"{% endif %}><input type="text" name="user_mchat_date" id="user_mchat_date" value="{{ MCHAT_DATE }}"{% if MCHAT_DATE_NOAUTH %} disabled{% endif %} /></div></dd>
<dd>
<div id="user_mchat_custom_date"{% if not S_MCHAT_CUSTOM_DATEFORMAT %} style="display:none;"{% endif %}>
<input type="text" name="user_mchat_date" id="user_mchat_date" value="{{ MCHAT_DATE }}"{% if MCHAT_DATE_NOAUTH %} disabled{% endif %}>
</div>
</dd>
</dl>
<dl>
<dt><label for="user_mchat_relative_time">{{ lang('MCHAT_RELATIVE_TIME') ~ lang('COLON') }}</label><br><span>{{ lang('MCHAT_RELATIVE_TIME_EXPLAIN') }}</span></dt>
<dd>
<label><input type="radio" name="user_mchat_relative_time" value="1"{% if MCHAT_RELATIVE_TIME %} id="user_mchat_relative_time" checked="checked"{% endif %}{% if MCHAT_RELATIVE_TIME_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_relative_time" value="0"{% if not MCHAT_RELATIVE_TIME %} id="user_mchat_relative_time" checked="checked"{% endif %}{% if MCHAT_RELATIVE_TIME_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_relative_time" value="1"{% if MCHAT_RELATIVE_TIME %} id="user_mchat_relative_time" checked="checked"{% endif %}{% if MCHAT_RELATIVE_TIME_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_relative_time" value="0"{% if not MCHAT_RELATIVE_TIME %} id="user_mchat_relative_time" checked="checked"{% endif %}{% if MCHAT_RELATIVE_TIME_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>
{% EVENT dmzx_mchat_acp_relative_time_after %}
<hr />
<hr>
{% EVENT dmzx_mchat_acp_posts_before %}
<dl>
<dt><label for="user_mchat_posts">{% if MCHAT_POSTS_ENABLED_LANG %}{{ MCHAT_POSTS_ENABLED_LANG }}{% else %}{{ lang('MCHAT_POSTS') }}{% endif %}{{ lang('COLON') }}</label></dt>
<dd>
<label><input type="radio" name="user_mchat_posts" value="1"{% if MCHAT_POSTS %} id="user_mchat_posts" checked="checked"{% endif %}{% if MCHAT_POSTS_NOAUTH %} disabled{% endif %} /> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_posts" value="0"{% if not MCHAT_POSTS %} id="user_mchat_posts" checked="checked"{% endif %}{% if MCHAT_POSTS_NOAUTH %} disabled{% endif %} /> {{ lang('NO') }}</label>
<label><input type="radio" name="user_mchat_posts" value="1"{% if MCHAT_POSTS %} id="user_mchat_posts" checked="checked"{% endif %}{% if MCHAT_POSTS_NOAUTH %} disabled{% endif %}> {{ lang('YES') }}</label>
<label><input type="radio" name="user_mchat_posts" value="0"{% if not MCHAT_POSTS %} id="user_mchat_posts" checked="checked"{% endif %}{% if MCHAT_POSTS_NOAUTH %} disabled{% endif %}> {{ lang('NO') }}</label>
</dd>
</dl>

View File

@@ -3,10 +3,10 @@
"type": "phpbb-extension",
"description": "mChat",
"homepage": "https://www.phpbb.com/customise/db/extension/mchat_extension/",
"version": "2.0.3",
"time": "2017-12-31",
"version": "2.1.0",
"time": "2018-06-22",
"keywords": ["phpbb", "extension", "mchat"],
"license": "GPL-2.0",
"license": "GPL-2.0-only",
"authors": [
{
"name": "kasimi",
@@ -27,7 +27,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.4.7",
"composer/installers": "~1.0"
},
"require-dev": {
@@ -36,7 +36,7 @@
"extra": {
"display-name": "mChat",
"soft-require": {
"phpbb/phpbb": ">=3.1.8-RC1"
"phpbb/phpbb": ">=3.2.0"
},
"version-check": {
"host": "www.phpbb.com",

View File

@@ -2,6 +2,7 @@ imports:
- { resource: tables.yml }
services:
dmzx.mchat.acp.controller:
class: dmzx\mchat\controller\acp_controller
arguments:
@@ -9,89 +10,119 @@ services:
- '@template'
- '@log'
- '@user'
- '@language'
- '@dbal.conn'
- '@cache.driver'
- '@request'
- '@dispatcher'
- '@dmzx.mchat.settings'
- '%dmzx.mchat.table.mchat%'
- '%dmzx.mchat.table.mchat_log%'
- '%core.root_path%'
- '%core.php_ext%'
dmzx.mchat.ucp.controller:
class: dmzx\mchat\controller\ucp_controller
arguments:
- '@template'
- '@user'
- '@language'
- '@auth'
- '@dbal.conn'
- '@request'
- '@dmzx.mchat.settings'
- '@dispatcher'
- '%core.root_path%'
- '%core.php_ext%'
dmzx.mchat.notifications:
class: dmzx\mchat\core\notifications
arguments:
- '@dmzx.mchat.settings'
- '@user'
- '@language'
- '@auth'
- '@dbal.conn'
- '@dispatcher'
- '@text_formatter.parser'
dmzx.mchat.log:
class: dmzx\mchat\core\log
arguments:
- '@dmzx.mchat.settings'
- '@user'
- '@dbal.conn'
- '@cache.driver'
- '@dispatcher'
dmzx.mchat.core:
class: dmzx\mchat\core\mchat
arguments:
- '@dmzx.mchat.functions'
- '@dmzx.mchat.notifications'
- '@dmzx.mchat.settings'
- '@dmzx.mchat.log'
- '@controller.helper'
- '@template'
- '@user'
- '@language'
- '@auth'
- '@pagination'
- '@request'
- '@dispatcher'
- '@ext.manager'
- '%core.root_path%'
- '%core.php_ext%'
- '@?text_formatter.s9e.parser'
- '@text_formatter.parser'
- '@?phpbb.collapsiblecategories.operator'
dmzx.mchat.functions:
class: dmzx\mchat\core\functions
arguments:
- '@dmzx.mchat.settings'
- '@dmzx.mchat.notifications'
- '@dmzx.mchat.log'
- '@user'
- '@language'
- '@auth'
- '@log'
- '@dbal.conn'
- '@cache.driver'
- '@dispatcher'
- '@group_helper'
- '@text_formatter.parser'
dmzx.mchat.settings:
class: dmzx\mchat\core\settings
arguments:
- '@user'
- '@language'
- '@config'
- '@config_text'
- '@auth'
- '@dispatcher'
- '%core.root_path%'
- '%core.php_ext%'
- '%dmzx.mchat.table.mchat%'
- '%dmzx.mchat.table.mchat_log%'
- '%dmzx.mchat.table.mchat_sessions%'
dmzx.mchat.settings:
class: dmzx\mchat\core\settings
arguments:
- '@user'
- '@config'
- '@config_text'
- '@auth'
- '@dispatcher'
dmzx.mchat.acp.listener:
class: dmzx\mchat\event\acp_listener
arguments:
- '@template'
- '@request'
- '@user'
- '@language'
- '@dmzx.mchat.settings'
- '@dmzx.mchat.functions'
- '%core.root_path%'
- '%core.php_ext%'
tags:
- { name: event.listener }
dmzx.mchat.main.listener:
class: dmzx\mchat\event\main_listener
arguments:
- '@dmzx.mchat.core'
- '@dmzx.mchat.notifications'
- '@controller.helper'
- '@user'
- '@language'
- '@request'
- '%core.php_ext%'
tags:
- { name: event.listener }
dmzx.mchat.cron.task.mchat_prune:
class: dmzx\mchat\cron\mchat_prune
arguments:
@@ -101,3 +132,27 @@ services:
- [set_name, [cron.task.mchat_prune]]
tags:
- { name: cron.task }
dmzx.mchat.text_reparser.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]]
tags:
- { name: text_reparser.plugin }
dmzx.mchat.text_reparser.reparser:
class: phpbb\cron\task\text_reparser\reparser
arguments:
- '@config'
- '@config_text'
- '@text_reparser.lock'
- '@text_reparser.manager'
- '@text_reparser_collection'
calls:
- [set_name, [dmzx.mchat.text_reparser.reparser]]
- [set_reparser, [dmzx.mchat.text_reparser.mchat_messages]]
tags:
- { name: cron.task }

View File

@@ -16,6 +16,7 @@ use dmzx\mchat\core\settings;
use phpbb\cache\driver\driver_interface as cache_interface;
use phpbb\db\driver\driver_interface as db_interface;
use phpbb\event\dispatcher_interface;
use phpbb\language\language;
use phpbb\log\log_interface;
use phpbb\request\request_interface;
use phpbb\template\template;
@@ -24,7 +25,7 @@ use phpbb\user;
class acp_controller
{
/** @var functions */
protected $functions;
protected $mchat_functions;
/** @var template */
protected $template;
@@ -35,6 +36,9 @@ class acp_controller
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var db_interface */
protected $db;
@@ -50,64 +54,43 @@ class acp_controller
/** @var settings */
protected $settings;
/** @var string */
protected $mchat_table;
/** @var string */
protected $mchat_log_table;
/** @var string */
protected $root_path;
/** @var string */
protected $php_ext;
/**
* Constructor
*
* @param functions $functions
* @param functions $mchat_functions
* @param template $template
* @param log_interface $log
* @param user $user
* @param language $lang
* @param db_interface $db
* @param cache_interface $cache
* @param request_interface $request
* @param dispatcher_interface $dispatcher
* @param settings $settings
* @param string $mchat_table
* @param string $mchat_log_table
* @param string $root_path
* @param string $php_ext
*/
public function __construct(
functions $functions,
functions $mchat_functions,
template $template,
log_interface $log,
user $user,
language $lang,
db_interface $db,
cache_interface $cache,
request_interface $request,
dispatcher_interface $dispatcher,
settings $settings,
$mchat_table,
$mchat_log_table,
$root_path,
$php_ext
settings $settings
)
{
$this->functions = $functions;
$this->mchat_functions = $mchat_functions;
$this->template = $template;
$this->log = $log;
$this->user = $user;
$this->lang = $lang;
$this->db = $db;
$this->cache = $cache;
$this->request = $request;
$this->dispatcher = $dispatcher;
$this->settings = $settings;
$this->mchat_table = $mchat_table;
$this->mchat_log_table = $mchat_log_table;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
}
/**
@@ -119,7 +102,7 @@ class acp_controller
{
add_form_key('acp_mchat');
$error = array();
$error = [];
$is_founder = $this->user->data['user_type'] == USER_FOUNDER;
@@ -127,8 +110,8 @@ class acp_controller
if ($this->request->is_set_post('submit'))
{
$mchat_new_config = array();
$validation = array();
$mchat_new_config = [];
$validation = [];
foreach ($settings as $config_name => $config_data)
{
$default = $this->settings->cfg($config_name);
@@ -143,19 +126,19 @@ class acp_controller
// Remove leading & trailing | characters to not break allowed BBCodes
$mchat_new_config['mchat_bbcode_disallowed'] = trim($mchat_new_config['mchat_bbcode_disallowed'], '|');
// Don't allow changing pruning settings for non founders
if (!$is_founder)
{
// Don't allow changing pruning settings for non founders
unset($mchat_new_config['mchat_prune']);
unset($mchat_new_config['mchat_prune_gc']);
unset($mchat_new_config['mchat_prune_mode']);
unset($mchat_new_config['mchat_prune_num']);
// Don't allow changing log settings for non founders
unset($mchat_new_config['mchat_log_enabled']);
}
if (!function_exists('validate_data'))
{
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
}
$this->settings->include_functions('user', 'validate_data');
$error = array_merge($error, validate_data($mchat_new_config, $validation));
@@ -172,10 +155,10 @@ class acp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'mchat_new_config',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.acp_globalsettings_update_data', compact($vars)));
if (!$error)
@@ -187,41 +170,50 @@ class acp_controller
}
// Add an entry into the log table
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE', false, array($this->user->data['username']));
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE', false, [$this->user->data['username']]);
trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($u_action));
trigger_error($this->lang->lang('MCHAT_CONFIG_SAVED') . adm_back_link($u_action));
}
// Replace "error" strings with their real, localised form
$error = array_map(array($this->user, 'lang'), $error);
$error = array_map([$this->lang, 'lang'], $error);
}
if (!$error)
{
if ($is_founder && $this->request->is_set_post('mchat_purge') && $this->request->variable('mchat_purge_confirm', false) && check_form_key('acp_mchat'))
{
$this->db->sql_query('DELETE FROM ' . $this->mchat_table);
$this->db->sql_query('DELETE FROM ' . $this->mchat_log_table);
$this->cache->destroy('sql', $this->mchat_log_table);
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PURGED', false, array($this->user->data['username']));
trigger_error($this->user->lang('MCHAT_PURGED') . adm_back_link($u_action));
/**
* Event that is triggered right before all mChat messages are
* deleted when using the Delete all messages button in the ACP
*
* @event dmzx.mchat.purge_before
* @since 2.1.0-RC1
*/
$this->dispatcher->dispatch('dmzx.mchat.purge_before');
$this->db->sql_query('DELETE FROM ' . $this->settings->get_table_mchat());
$this->db->sql_query('DELETE FROM ' . $this->settings->get_table_mchat_log());
$this->cache->destroy('sql', $this->settings->get_table_mchat_log());
$this->mchat_functions->phpbb_log('LOG_MCHAT_TABLE_PURGED');
trigger_error($this->lang->lang('MCHAT_PURGED') . adm_back_link($u_action));
}
else if ($is_founder && $this->request->is_set_post('mchat_prune_now') && $this->request->variable('mchat_prune_now_confirm', false) && check_form_key('acp_mchat'))
{
$num_pruned_messages = count($this->functions->mchat_prune());
trigger_error($this->user->lang('MCHAT_PRUNED', $num_pruned_messages) . adm_back_link($u_action));
$num_pruned_messages = count($this->mchat_functions->mchat_prune());
trigger_error($this->lang->lang('MCHAT_PRUNED', $num_pruned_messages) . adm_back_link($u_action));
}
}
$template_data = array(
$template_data = [
'MCHAT_ERROR' => implode('<br>', $error),
'MCHAT_VERSION' => $this->settings->cfg('mchat_version'),
'MCHAT_FOUNDER' => $is_founder,
'S_MCHAT_PRUNE_MODE_OPTIONS' => $this->get_prune_mode_options($this->settings->cfg('mchat_prune_mode')),
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => $this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN', '<a href="' . append_sid("{$this->root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
'L_MCHAT_TIMEOUT_EXPLAIN' => $this->user->lang('MCHAT_TIMEOUT_EXPLAIN','<a href="' . append_sid("{$this->root_path}adm/index.$this->php_ext", 'i=board&amp;mode=load', true, $this->user->session_id) . '">', '</a>', $this->settings->cfg('session_length')),
'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')),
'U_ACTION' => $u_action,
);
];
foreach (array_keys($settings) as $key)
{
@@ -236,10 +228,10 @@ class acp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'template_data',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.acp_globalsettings_modify_template_data', compact($vars)));
$this->template->assign_vars($template_data);
@@ -252,12 +244,12 @@ class acp_controller
{
add_form_key('acp_mchat');
$error = array();
$error = [];
if ($this->request->is_set_post('submit'))
{
$mchat_new_config = array();
$validation = array();
$mchat_new_config = [];
$validation = [];
foreach ($this->settings->ucp_settings() as $config_name => $config_data)
{
$default = $this->settings->cfg($config_name, true);
@@ -270,10 +262,7 @@ class acp_controller
}
}
if (!function_exists('validate_data'))
{
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
}
$this->settings->include_functions('user', 'validate_data');
$error = array_merge($error, validate_data($mchat_new_config, $validation));
@@ -282,7 +271,7 @@ class acp_controller
$error[] = 'FORM_INVALID';
}
$mchat_new_user_config = array();
$mchat_new_user_config = [];
if ($this->request->variable('mchat_overwrite', 0) && $this->request->variable('mchat_overwrite_confirm', 0))
{
@@ -301,11 +290,11 @@ class acp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'mchat_new_config',
'mchat_new_user_config',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.acp_globalusersettings_update_data', compact($vars)));
if (!$error)
@@ -323,13 +312,13 @@ class acp_controller
}
// Add an entry into the log table
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE', false, array($this->user->data['username']));
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE', false, [$this->user->data['username']]);
trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($u_action));
trigger_error($this->lang->lang('MCHAT_CONFIG_SAVED') . adm_back_link($u_action));
}
// Replace "error" strings with their real, localised form
$error = array_map(array($this->user, 'lang'), $error);
$error = array_map([$this->lang, 'lang'], $error);
}
// Force global date format for $selected_date value, not user-specific
@@ -341,12 +330,12 @@ class acp_controller
$template_data[strtoupper($key)] = $this->settings->cfg($key, true);
}
$template_data = array_merge($template_data, array(
$template_data = array_merge($template_data, [
'MCHAT_POSTS_ENABLED_LANG' => $this->settings->get_enabled_post_notifications_lang(),
'MCHAT_ERROR' => implode('<br>', $error),
'MCHAT_VERSION' => $this->settings->cfg('mchat_version'),
'U_ACTION' => $u_action,
));
]);
/**
* Event to modify ACP global user settings template data
@@ -356,10 +345,10 @@ class acp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'template_data',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.acp_globalusersettings_modify_template_data', compact($vars)));
$this->template->assign_vars($template_data);
@@ -381,7 +370,7 @@ class acp_controller
foreach ($this->settings->prune_modes as $i => $prune_mode)
{
$prune_mode_options .= '<option value="' . $i . '"' . (($i == $selected) ? ' selected="selected"' : '') . '>';
$prune_mode_options .= $this->user->lang('MCHAT_ACP_' . strtoupper($prune_mode));
$prune_mode_options .= $this->lang->lang('MCHAT_ACP_' . strtoupper($prune_mode));
$prune_mode_options .= '</option>';
}

View File

@@ -15,6 +15,7 @@ use dmzx\mchat\core\settings;
use phpbb\auth\auth;
use phpbb\db\driver\driver_interface as db_interface;
use phpbb\event\dispatcher_interface;
use phpbb\language\language;
use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb\user;
@@ -27,6 +28,9 @@ class ucp_controller
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var auth */
protected $auth;
@@ -37,51 +41,42 @@ class ucp_controller
protected $request;
/** @var settings */
protected $settings;
protected $mchat_settings;
/** @var dispatcher_interface */
protected $dispatcher;
/** @var string */
protected $root_path;
/** @var string */
protected $php_ext;
/**
* Constructor
*
* @param template $template
* @param user $user
* @param language $lang
* @param auth $auth
* @param db_interface $db
* @param request_interface $request
* @param settings $settings
* @param settings $mchat_settings
* @param dispatcher_interface $dispatcher
* @param string $root_path
* @param string $php_ext
*/
public function __construct(
template $template,
user $user,
language $lang,
auth $auth,
db_interface $db,
request_interface $request,
settings $settings,
dispatcher_interface $dispatcher,
$root_path,
$php_ext
settings $mchat_settings,
dispatcher_interface $dispatcher
)
{
$this->template = $template;
$this->user = $user;
$this->auth = $auth;
$this->db = $db;
$this->request = $request;
$this->settings = $settings;
$this->dispatcher = $dispatcher;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->template = $template;
$this->user = $user;
$this->lang = $lang;
$this->auth = $auth;
$this->db = $db;
$this->request = $request;
$this->mchat_settings = $mchat_settings;
$this->dispatcher = $dispatcher;
}
/**
@@ -93,13 +88,13 @@ class ucp_controller
{
add_form_key('ucp_mchat');
$error = array();
$error = [];
if ($this->request->is_set_post('submit'))
{
$mchat_new_config = array();
$validation = array();
foreach ($this->settings->ucp_settings() as $config_name => $config_data)
$mchat_new_config = [];
$validation = [];
foreach ($this->mchat_settings->ucp_settings() as $config_name => $config_data)
{
if ($this->auth->acl_get('u_' . $config_name))
{
@@ -114,10 +109,7 @@ class ucp_controller
}
}
if (!function_exists('validate_data'))
{
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
}
$this->mchat_settings->include_functions('user', 'validate_data');
$error = array_merge($error, validate_data($mchat_new_config, $validation));
@@ -134,10 +126,10 @@ class ucp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'mchat_new_config',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.ucp_update_data', compact($vars)));
if (!$error)
@@ -148,25 +140,25 @@ class ucp_controller
$this->db->sql_query($sql);
meta_refresh(3, $u_action);
$message = $this->user->lang('PROFILE_UPDATED') . '<br><br>' . $this->user->lang('RETURN_UCP', '<a href="' . $u_action . '">', '</a>');
$message = $this->lang->lang('PROFILE_UPDATED') . '<br><br>' . $this->lang->lang('RETURN_UCP', '<a href="' . $u_action . '">', '</a>');
trigger_error($message);
}
// Replace "error" strings with their real, localised form
$error = array_map(array($this->user, 'lang'), $error);
$error = array_map([$this->lang, 'lang'], $error);
}
$selected_date = $this->settings->cfg('mchat_date');
$template_data = $this->settings->get_date_template_data($selected_date);
$selected_date = $this->mchat_settings->cfg('mchat_date');
$template_data = $this->mchat_settings->get_date_template_data($selected_date);
$auth_count = 0;
foreach (array_keys($this->settings->ucp_settings()) as $config_name)
foreach (array_keys($this->mchat_settings->ucp_settings()) as $config_name)
{
$upper = strtoupper($config_name);
$auth = $this->auth->acl_get('u_' . $config_name);
$template_data[$upper] = $this->settings->cfg($config_name);
$template_data[$upper] = $this->mchat_settings->cfg($config_name);
$template_data[$upper . '_AUTH'] = $auth;
if ($auth)
@@ -175,13 +167,13 @@ class ucp_controller
}
}
$template_data = array_merge($template_data, array(
'MCHAT_ALLOW_USE' => $this->auth->acl_get('u_mchat_use'),
'MCHAT_POSTS_ENABLED_LANG' => $this->settings->get_enabled_post_notifications_lang(),
'ERROR' => sizeof($error) ? implode('<br>', $error) : '',
'MCHAT_AUTH_COUNT' => $auth_count,
'S_UCP_ACTION' => $u_action,
));
$template_data = array_merge($template_data, [
'MCHAT_ALLOW_USE' => $this->auth->acl_get('u_mchat_use'),
'MCHAT_POSTS_ENABLED_LANG' => $this->mchat_settings->get_enabled_post_notifications_lang(),
'ERROR' => sizeof($error) ? implode('<br>', $error) : '',
'MCHAT_AUTH_COUNT' => $auth_count,
'S_UCP_ACTION' => $u_action,
]);
/**
* Event to modify UCP settings template data
@@ -192,11 +184,11 @@ class ucp_controller
* @var array error Array with error lang keys
* @since 2.0.0-RC7
*/
$vars = array(
$vars = [
'template_data',
'auth_count',
'error',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.ucp_modify_template_data', compact($vars)));
$this->template->assign_vars($template_data);

View File

@@ -15,17 +15,28 @@ use phpbb\auth\auth;
use phpbb\cache\driver\driver_interface as cache_interface;
use phpbb\db\driver\driver_interface as db_interface;
use phpbb\event\dispatcher_interface;
use phpbb\group\helper;
use phpbb\language\language;
use phpbb\log\log_interface;
use phpbb\user;
class functions
{
/** @var settings */
protected $settings;
protected $mchat_settings;
/** @var notifications */
protected $mchat_notifications;
/** @var log */
protected $mchat_log;
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var auth */
protected $auth;
@@ -41,85 +52,53 @@ class functions
/** @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 helper */
protected $group_helper;
/** @var array */
protected $active_users;
/** @var array */
public $log_types = array(
1 => 'edit',
2 => 'del',
);
/**
* Value of the phpbb_mchat.post_id field for login notification
* messages if the user session is visible at the time of login
* Constructor
*
* @param settings $mchat_settings
* @param notifications $mchat_notifications
* @param log $mchat_log
* @param user $user
* @param language $lang
* @param auth $auth
* @param log_interface $log
* @param db_interface $db
* @param cache_interface $cache
* @param dispatcher_interface $dispatcher
* @param helper $group_helper
*/
const LOGIN_VISIBLE = 1;
/**
* Value of the phpbb_mchat.post_id field for login notification
* messages if the user session is hidden at the time of login
*/
const LOGIN_HIDDEN = 2;
/**
* Constructor
*
* @param settings $settings
* @param user $user
* @param auth $auth
* @param log_interface $log
* @param db_interface $db
* @param cache_interface $cache
* @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
*/
function __construct(
settings $settings,
settings $mchat_settings,
notifications $mchat_notifications,
log $mchat_log,
user $user,
language $lang,
auth $auth,
log_interface $log,
db_interface $db,
cache_interface $cache,
dispatcher_interface $dispatcher,
$root_path,
$php_ext,
$mchat_table,
$mchat_log_table,
$mchat_sessions_table
helper $group_helper
)
{
$this->settings = $settings;
$this->mchat_settings = $mchat_settings;
$this->mchat_notifications = $mchat_notifications;
$this->mchat_log = $mchat_log;
$this->user = $user;
$this->lang = $lang;
$this->auth = $auth;
$this->log = $log;
$this->db = $db;
$this->cache = $cache;
$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;
$this->group_helper = $group_helper;
}
/**
@@ -130,29 +109,29 @@ class functions
*/
protected function mchat_format_seconds($time)
{
$times = array();
$times = [];
$hours = floor($time / 3600);
if ($hours)
{
$time -= $hours * 3600;
$times[] = $this->user->lang('MCHAT_HOURS', $hours);
$times[] = $this->lang->lang('MCHAT_HOURS', $hours);
}
$minutes = floor($time / 60);
if ($minutes)
{
$time -= $minutes * 60;
$times[] = $this->user->lang('MCHAT_MINUTES', $minutes);
$times[] = $this->lang->lang('MCHAT_MINUTES', $minutes);
}
$seconds = ceil($time);
if ($seconds)
{
$times[] = $this->user->lang('MCHAT_SECONDS', $seconds);
$times[] = $this->lang->lang('MCHAT_SECONDS', $seconds);
}
return $this->user->lang('MCHAT_ONLINE_EXPLAIN', implode('&nbsp;', $times));
return $this->lang->lang('MCHAT_ONLINE_EXPLAIN', implode('&nbsp;', $times));
}
/**
@@ -162,19 +141,19 @@ class functions
*/
protected function mchat_session_time()
{
$mchat_timeout = $this->settings->cfg('mchat_timeout');
$mchat_timeout = $this->mchat_settings->cfg('mchat_timeout');
if ($mchat_timeout)
{
return $mchat_timeout;
}
$load_online_time = $this->settings->cfg('load_online_time');
$load_online_time = $this->mchat_settings->cfg('load_online_time');
if ($load_online_time)
{
return $load_online_time * 60;
}
return $this->settings->cfg('session_length');
return $this->mchat_settings->cfg('session_length');
}
/**
@@ -192,24 +171,22 @@ class functions
$check_time = time() - $this->mchat_session_time();
$sql_array = array(
$sql_array = [
'SELECT' => 'u.user_id, u.username, u.user_colour, s.session_viewonline',
'FROM' => array(
$this->mchat_sessions_table => 'ms'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(SESSIONS_TABLE => 's'),
'FROM' => [$this->mchat_settings->get_table_mchat_sessions() => 'ms'],
'LEFT_JOIN' => [
[
'FROM' => [SESSIONS_TABLE => 's'],
'ON' => 'ms.user_id = s.session_user_id',
),
array(
'FROM' => array(USERS_TABLE => 'u'),
],
[
'FROM' => [USERS_TABLE => 'u'],
'ON' => 'ms.user_id = u.user_id',
),
),
],
],
'WHERE' => 'u.user_id <> ' . ANONYMOUS . ' AND s.session_viewonline IS NOT NULL AND ms.user_lastupdate > ' . (int) $check_time,
'ORDER_BY' => 'u.username ASC',
);
];
/**
* Event to modify the SQL query that fetches active mChat users
@@ -218,9 +195,9 @@ class functions
* @var array sql_array Array with SQL query data to fetch the current active sessions
* @since 2.0.0-RC6
*/
$vars = array(
$vars = [
'sql_array',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.active_users_sql_before', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
@@ -228,7 +205,7 @@ class functions
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$mchat_users = array();
$mchat_users = [];
$can_view_hidden = $this->auth->acl_get('u_viewonline');
foreach ($rows as $row)
@@ -243,15 +220,15 @@ class functions
$row['username'] = '<em>' . $row['username'] . '</em>';
}
$mchat_users[$row['user_id']] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'));
$mchat_users[$row['user_id']] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->lang->lang('GUEST'));
}
$active_users = array(
'online_userlist' => implode($this->user->lang('COMMA_SEPARATOR'), $mchat_users),
'users_count_title' => $this->user->lang('MCHAT_TITLE_COUNT', count($mchat_users)),
'users_total' => $this->user->lang('MCHAT_ONLINE_USERS_TOTAL', count($mchat_users)),
$active_users = [
'online_userlist' => implode($this->lang->lang('COMMA_SEPARATOR'), $mchat_users),
'users_count_title' => $this->lang->lang('MCHAT_TITLE_COUNT', count($mchat_users)),
'users_total' => $this->lang->lang('MCHAT_ONLINE_USERS_TOTAL', count($mchat_users)),
'refresh_message' => $this->mchat_format_seconds($this->mchat_session_time()),
);
];
/**
* Event to modify collected data about active mChat users
@@ -261,10 +238,10 @@ class functions
* @var array active_users Array containing info about currently active mChat users
* @since 2.0.0-RC6
*/
$vars = array(
$vars = [
'mchat_users',
'active_users',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.active_users_after', compact($vars)));
$this->active_users = $active_users;
@@ -284,7 +261,7 @@ class functions
return false;
}
$sql = 'UPDATE ' . $this->mchat_sessions_table . '
$sql = 'UPDATE ' . $this->mchat_settings->get_table_mchat_sessions() . '
SET user_lastupdate = ' . time() . '
WHERE user_id = ' . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);
@@ -293,11 +270,11 @@ class functions
if ($is_new_session)
{
$sql = 'INSERT INTO ' . $this->mchat_sessions_table . ' ' . $this->db->sql_build_array('INSERT', array(
$sql = 'INSERT INTO ' . $this->mchat_settings->get_table_mchat_sessions() . ' ' . $this->db->sql_build_array('INSERT', [
'user_id' => (int) $this->user->data['user_id'],
'user_ip' => $this->user->ip,
'user_lastupdate' => time(),
));
]);
$this->db->sql_query($sql);
}
@@ -311,7 +288,7 @@ class functions
{
$check_time = time() - $this->mchat_session_time();
$sql = 'DELETE FROM ' . $this->mchat_sessions_table . '
$sql = 'DELETE FROM ' . $this->mchat_settings->get_table_mchat_sessions() . '
WHERE user_lastupdate <= ' . (int) $check_time;
$this->db->sql_query($sql);
}
@@ -322,32 +299,32 @@ class functions
* @param int|array $user_ids
* @return array
*/
public function mchat_prune($user_ids = array())
public function mchat_prune($user_ids = [])
{
$prune_num = (int) $this->settings->cfg('mchat_prune_num');
$prune_mode = (int) $this->settings->cfg('mchat_prune_mode');
$prune_num = (int) $this->mchat_settings->cfg('mchat_prune_num');
$prune_mode = (int) $this->mchat_settings->cfg('mchat_prune_mode');
if (empty($this->settings->prune_modes[$prune_mode]))
if (empty($this->mchat_settings->prune_modes[$prune_mode]))
{
return array();
return [];
}
$sql_array = array(
$sql_array = [
'SELECT' => 'message_id',
'FROM' => array($this->mchat_table => 'm'),
);
'FROM' => [$this->mchat_settings->get_table_mchat() => 'm'],
];
if ($user_ids)
{
if (!is_array($user_ids))
{
$user_ids = array($user_ids);
$user_ids = [$user_ids];
}
$sql_array['WHERE'] = $this->db->sql_in_set('m.user_id', $user_ids);
$offset = 0;
}
else if ($this->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';
@@ -368,10 +345,10 @@ class functions
* @var array sql_array SQL query data
* @since 2.0.2
*/
$vars = array(
$vars = [
'user_ids',
'sql_array',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.prune_sql_before', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
@@ -379,7 +356,7 @@ class functions
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$prune_ids = array();
$prune_ids = [];
foreach ($rows as $row)
{
@@ -395,22 +372,22 @@ class functions
* @since 2.0.0-RC6
* @changed 2.0.1 Added user_ids
*/
$vars = array(
$vars = [
'prune_ids',
'user_ids',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.prune_before', compact($vars)));
if ($prune_ids)
{
$this->db->sql_query('DELETE FROM ' . $this->mchat_table . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->db->sql_query('DELETE FROM ' . $this->mchat_log_table . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->cache->destroy('sql', $this->mchat_log_table);
$this->db->sql_query('DELETE FROM ' . $this->mchat_settings->get_table_mchat() . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->db->sql_query('DELETE FROM ' . $this->mchat_settings->get_table_mchat_log() . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->cache->destroy('sql', $this->mchat_settings->get_table_mchat_log());
// Only add a log entry if message pruning was not triggered by user pruning
if (!$user_ids)
{
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED', false, array($this->user->data['username'], count($prune_ids)));
$this->phpbb_log('LOG_MCHAT_TABLE_PRUNED', [count($prune_ids)]);
}
}
@@ -424,13 +401,11 @@ class functions
*/
public function mchat_total_message_count()
{
$sql_where_ary = $this->get_sql_where_for_notifcation_messages();
$sql_array = array(
$sql_array = [
'SELECT' => 'COUNT(*) AS rows_total',
'FROM' => array($this->mchat_table => 'm'),
'WHERE' => $sql_where_ary ? $this->db->sql_escape('(' . implode(') AND (', $sql_where_ary) . ')') : '',
);
'FROM' => [$this->mchat_settings->get_table_mchat() => 'm'],
'WHERE' => $this->mchat_notifications->get_sql_where(),
];
/**
* Event to modifying the SQL query that fetches the total number of mChat messages
@@ -439,9 +414,9 @@ class functions
* @var array sql_array Array with SQL query data to fetch the total message count
* @since 2.0.0-RC6
*/
$vars = array(
$vars = [
'sql_array',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.total_message_count_modify_sql', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
@@ -463,7 +438,7 @@ class functions
*/
public function mchat_get_messages($message_ids, $last_id = 0, $total = 0, $offset = 0)
{
$sql_where_message_id = array();
$sql_where_message_id = [];
// Fetch new messages
if ($last_id)
@@ -476,35 +451,33 @@ class functions
{
if (!is_array($message_ids))
{
$message_ids = array($message_ids);
$message_ids = [$message_ids];
}
$sql_where_message_id[] = $this->db->sql_in_set('m.message_id', array_map('intval', $message_ids));
}
$sql_where_ary = $this->get_sql_where_for_notifcation_messages();
$sql_where_ary = array_filter([
implode(' OR ', $sql_where_message_id),
$this->mchat_notifications->get_sql_where(),
]);
if ($sql_where_message_id)
{
$sql_where_ary[] = implode(' OR ', $sql_where_message_id);
}
$sql_array = array(
$sql_array = [
'SELECT' => 'm.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm, p.post_visibility',
'FROM' => array($this->mchat_table => 'm'),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'FROM' => [$this->mchat_settings->get_table_mchat() => 'm'],
'LEFT_JOIN' => [
[
'FROM' => [USERS_TABLE => 'u'],
'ON' => 'm.user_id = u.user_id',
),
array(
'FROM' => array(POSTS_TABLE => 'p'),
],
[
'FROM' => [POSTS_TABLE => 'p'],
'ON' => 'm.post_id = p.post_id AND m.forum_id <> 0',
),
),
],
],
'WHERE' => $sql_where_ary ? $this->db->sql_escape('(' . implode(') AND (', $sql_where_ary) . ')') : '',
'ORDER_BY' => 'm.message_id DESC',
);
];
/**
* Event to modify the SQL query that fetches mChat messages
@@ -517,13 +490,13 @@ class functions
* @var array sql_array Array containing the SQL query data
* @since 2.0.0-RC6
*/
$vars = array(
$vars = [
'message_ids',
'last_id',
'total',
'offset',
'sql_array',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.get_messages_modify_sql', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
@@ -543,88 +516,6 @@ class functions
return $rows;
}
/**
* Generates SQL where conditions to include or exlude notifacation
* messages based on the current user's settings and permissions
*
* @return array
*/
protected function get_sql_where_for_notifcation_messages()
{
$sql_where_ary = array();
if ($this->settings->cfg('mchat_posts'))
{
// If the current user doesn't have permission to see hidden users, exclude their login posts
if (!$this->auth->acl_get('u_viewonline'))
{
$sql_where_ary[] = 'm.post_id <> ' . (int) self::LOGIN_HIDDEN . // Exclude all notifications that were created by hidden users ...
' OR m.user_id = ' . (int) $this->user->data['user_id'] . // ... but include all login notifications of the current user
' OR m.forum_id <> 0'; // ... and include all post notifications
}
}
else
{
// Exclude all post notifications
$sql_where_ary[] = 'm.post_id = 0';
}
return $sql_where_ary;
}
/**
* Fetches log entries from the database and sorts them
*
* @param int $log_id The ID of the latest log entry that the user has
* @return array
*/
public function mchat_get_logs($log_id)
{
$sql_array = array(
'SELECT' => 'ml.*',
'FROM' => array($this->mchat_log_table => 'ml'),
'WHERE' => 'ml.log_id > ' . (int) $log_id,
);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql, 3600);
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$logs = array(
'id' => $log_id,
);
foreach ($rows as $row)
{
$logs['id'] = max((int) $logs['id'], (int) $row['log_id']);
$logs[] = $row;
}
return $logs;
}
/**
* Fetches the highest log ID
*
* @return int
*/
public function get_latest_log_id()
{
$sql_array = array(
'SELECT' => 'ml.log_id',
'FROM' => array($this->mchat_log_table => 'ml'),
'ORDER_BY' => 'log_id DESC',
);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, 1);
$max_log_id = (int) $this->db->sql_fetchfield('log_id');
$this->db->sql_freeresult($result);
return $max_log_id;
}
/**
* Generates the user legend markup
*
@@ -633,23 +524,23 @@ class functions
public function mchat_legend()
{
// Grab group details for legend display for who is online on the custom page
$order_legend = $this->settings->cfg('legend_sort_groupname') ? 'group_name' : 'group_legend';
$order_legend = $this->mchat_settings->cfg('legend_sort_groupname') ? 'group_name' : 'group_legend';
$sql_array = array(
'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type',
'FROM' => array(GROUPS_TABLE => 'g'),
'WHERE' => 'group_legend <> 0',
$sql_array = [
'SELECT' => 'g.group_id, g.group_name, g.group_colour',
'FROM' => [GROUPS_TABLE => 'g'],
'WHERE' => 'g.group_legend <> 0',
'ORDER_BY' => 'g.' . $order_legend . ' ASC',
);
];
if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql_array['LEFT_JOIN'] = array(
array(
'FROM' => array(USER_GROUP_TABLE => 'ug'),
$sql_array['LEFT_JOIN'] = [
[
'FROM' => [USER_GROUP_TABLE => 'ug'],
'ON' => 'g.group_id = ug.group_id AND ug.user_id = ' . (int) $this->user->data['user_id'] . ' AND ug.user_pending = 0',
),
);
],
];
$sql_array['WHERE'] .= ' AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')';
}
@@ -659,18 +550,18 @@ class functions
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$legend = array();
$legend = [];
foreach ($rows as $row)
{
$colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
$group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang('G_' . $row['group_name']) : $row['group_name'];
$group_name = $this->group_helper->get_name($row['group_name']);
if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile'))
{
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
}
else
{
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g='. $row['group_id']) . '">' . $group_name . '</a>';
$legend[] = '<a' . $colour_text . ' href="' . append_sid($this->mchat_settings->url('memberlist'), ['mode' => 'group', 'g' => $row['group_id']]) . '">' . $group_name . '</a>';
}
}
@@ -684,15 +575,18 @@ class functions
*/
public function mchat_foes()
{
$sql = 'SELECT zebra_id
FROM ' . ZEBRA_TABLE . '
WHERE foe = 1
AND user_id = ' . (int) $this->user->data['user_id'];
$sql_array = [
'SELECT' => 'z.zebra_id',
'FROM' => [ZEBRA_TABLE => 'z'],
'WHERE' => 'z.foe = 1 AND z.user_id = ' . (int) $this->user->data['user_id'],
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$foes = array();
$foes = [];
foreach ($rows as $row)
{
@@ -702,50 +596,6 @@ class functions
return $foes;
}
/**
* Fetches post subjects and their forum names
*
* @param array $post_ids
* @return array
*/
public function mchat_get_post_data($post_ids)
{
if (!$post_ids)
{
return array();
}
$sql = 'SELECT p.post_id, p.post_subject, f.forum_id, f.forum_name
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.forum_id = f.forum_id
AND ' . $this->db->sql_in_set('p.post_id', $post_ids);
$result = $this->db->sql_query($sql);
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$post_subjects = array();
foreach ($rows as $row)
{
$post_subjects[$row['post_id']] = array(
'post_subject' => $row['post_subject'],
'forum_id' => $row['forum_id'],
'forum_name' => $row['forum_name'],
);
}
// Handle deleted posts
$non_existent_post_ids = array_diff($post_ids, array_keys($post_subjects));
foreach ($non_existent_post_ids as $post_id)
{
$post_subjects[$post_id] = null;
}
return $post_subjects;
}
/**
* Adds forbidden BBCodes to the passed SQL where statement
*
@@ -754,7 +604,7 @@ class functions
*/
public function mchat_sql_append_forbidden_bbcodes($sql_where)
{
$disallowed_bbcodes = explode('|', $this->settings->cfg('mchat_bbcode_disallowed'));
$disallowed_bbcodes = explode('|', $this->mchat_settings->cfg('mchat_bbcode_disallowed'));
if (!empty($disallowed_bbcodes))
{
@@ -764,72 +614,6 @@ class functions
return $sql_where;
}
/**
* Inserts a message with posting information into the database
*
* @param string $mode One of post|quote|edit|reply|login
* @param int $forum_id
* @param int $post_id
* @param bool $is_hidden_login
*/
public function mchat_insert_posting($mode, $forum_id, $post_id, $is_hidden_login)
{
$mode_config = array(
'post' => 'mchat_posts_topic',
'quote' => 'mchat_posts_quote',
'edit' => 'mchat_posts_edit',
'reply' => 'mchat_posts_reply',
'login' => 'mchat_posts_login',
);
$is_mode_enabled = !empty($mode_config[$mode]) && $this->settings->cfg($mode_config[$mode]) && (!$this->settings->cfg('mchat_posts_auth_check') || $this->auth->acl_get('u_mchat_use'));
// Special treatment for login notifications
if ($mode === 'login')
{
$forum_id = 0;
$post_id = $is_hidden_login ? self::LOGIN_HIDDEN : self::LOGIN_VISIBLE;
}
$sql_array = array(
'forum_id' => (int) $forum_id,
'post_id' => (int) $post_id,
'user_id' => (int) $this->user->data['user_id'],
'user_ip' => $this->user->ip,
'message' => 'MCHAT_NEW_' . strtoupper($mode),
'message_time' => time(),
);
/**
* Event that allows to modify data of a posting notification before it is inserted in the database
*
* @event dmzx.mchat.insert_posting_before
* @var string mode The posting mode, one of post|quote|edit|reply|login
* @var int forum_id The ID of the forum where the post was made, or 0 if mode is login.
* @var int post_id The ID of the post that was made. If mode is login this value is
* one of the constants LOGIN_HIDDEN|LOGIN_VISIBLE
* @var bool is_hidden_login Whether or not the user session is hidden. Only used if mode is login.
* @var array is_mode_enabled Whether or not the posting should be added to the database.
* @var array sql_array An array containing the data that is about to be inserted into the messages table.
* @since 2.0.0-RC6
*/
$vars = array(
'mode',
'forum_id',
'post_id',
'is_hidden_login',
'is_mode_enabled',
'sql_array',
);
extract($this->dispatcher->trigger_event('dmzx.mchat.insert_posting_before', compact($vars)));
if ($is_mode_enabled)
{
$sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_array);
$this->db->sql_query($sql);
}
}
/**
* Checks if the current user is flooding the chat
*
@@ -837,20 +621,24 @@ class functions
*/
public function mchat_is_user_flooding()
{
if (!$this->settings->cfg('mchat_flood_time') || $this->auth->acl_get('u_mchat_flood_ignore'))
if (!$this->mchat_settings->cfg('mchat_flood_time') || $this->auth->acl_get('u_mchat_flood_ignore'))
{
return false;
}
$sql = 'SELECT message_time
FROM ' . $this->mchat_table . '
WHERE user_id = ' . (int) $this->user->data['user_id'] . '
ORDER BY message_time DESC';
$sql_array = [
'SELECT' => 'm.message_time',
'FROM' => [$this->mchat_settings->get_table_mchat() => 'm'],
'WHERE' => 'm.user_id = ' . (int) $this->user->data['user_id'],
'ORDER_BY' => 'm.message_time DESC',
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, 1);
$message_time = (int) $this->db->sql_fetchfield('message_time');
$this->db->sql_freeresult($result);
return $message_time && time() - $message_time < $this->settings->cfg('mchat_flood_time');
return $message_time && time() - $message_time < $this->mchat_settings->cfg('mchat_flood_time');
}
/**
@@ -861,9 +649,13 @@ class functions
*/
public function mchat_author_for_message($message_id)
{
$sql = 'SELECT m.user_id, m.message_time, m.post_id
FROM ' . $this->mchat_table . ' m
WHERE m.message_id = ' . (int) $message_id;
$sql_array = [
'SELECT' => 'm.user_id, m.message_time, m.post_id',
'FROM' => [$this->mchat_settings->get_table_mchat() => 'm'],
'WHERE' => 'm.message_id = ' . (int) $message_id,
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
@@ -871,6 +663,42 @@ class functions
return $row;
}
/**
* Adds an entry to phpBB's admin log
*
* @param string $log_lang_key
* @param array $additional_data
*/
public function phpbb_log($log_lang_key, $additional_data = [])
{
$mode = 'admin';
$log_enabled = $this->mchat_settings->cfg('mchat_log_enabled');
$additional_data = array_merge([$this->user->data['username']], $additional_data);
/**
* Event to modify the phpBB log data before it is added to the log table
*
* @event dmzx.mchat.phpbb_log_add_before
* @var string mode The log mode, one of admin|mod|user|critical
* @var string log_lang_key The language key of the log entry
* @var bool log_enabled Flag indicating whether this log entry should be added or not
* @var array additional_data Array with additional data for the log message
* @since 2.1.0-RC1
*/
$vars = [
'mode',
'log_lang_key',
'log_enabled',
'additional_data',
];
extract($this->dispatcher->trigger_event('dmzx.mchat.phpbb_log_add_before', compact($vars)));
if ($log_enabled)
{
$this->log->add($mode, $this->user->data['user_id'], $this->user->ip, $log_lang_key, false, $additional_data);
}
}
/**
* Performs AJAX actions
*
@@ -893,12 +721,12 @@ class functions
* @var bool update_session_infos Whether or not to update the user session
* @since 2.0.0-RC6
*/
$vars = array(
$vars = [
'action',
'sql_ary',
'message_id',
'update_session_infos',
);
];
extract($this->dispatcher->trigger_event('dmzx.mchat.action_before', compact($vars)));
$is_new_session = false;
@@ -912,7 +740,7 @@ class functions
$this->user->update_session_infos();
}
$is_new_session = $this->mchat_add_user_session();
$this->db->sql_query('INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));
$this->db->sql_query('INSERT INTO ' . $this->mchat_settings->get_table_mchat() . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));
break;
// User edits a message
@@ -922,9 +750,9 @@ class functions
$this->user->update_session_infos();
}
$is_new_session = $this->mchat_add_user_session();
$this->db->sql_query('UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id);
$this->mchat_insert_log('edit', $message_id);
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($this->user->data['username']));
$this->db->sql_query('UPDATE ' . $this->mchat_settings->get_table_mchat() . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id);
$this->mchat_log->add_log('edit', $message_id);
$this->phpbb_log('LOG_EDITED_MCHAT');
break;
// User deletes a message
@@ -934,34 +762,12 @@ class functions
$this->user->update_session_infos();
}
$is_new_session = $this->mchat_add_user_session();
$this->db->sql_query('DELETE FROM ' . $this->mchat_table . ' WHERE message_id = ' . (int) $message_id);
$this->mchat_insert_log('del', $message_id);
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($this->user->data['username']));
$this->db->sql_query('DELETE FROM ' . $this->mchat_settings->get_table_mchat() . ' WHERE message_id = ' . (int) $message_id);
$this->mchat_log->add_log('del', $message_id);
$this->phpbb_log('LOG_DELETED_MCHAT');
break;
}
return $is_new_session;
}
/**
* @param string $log_type The log type, one of edit|del
* @param int $message_id The ID of the message to which this log entry belongs
* @return int The ID of the newly added log row
*/
public function mchat_insert_log($log_type, $message_id)
{
$this->db->sql_query('INSERT INTO ' . $this->mchat_log_table . ' ' . $this->db->sql_build_array('INSERT', array(
'log_type' => array_search($log_type, $this->log_types),
'user_id' => (int) $this->user->data['user_id'],
'message_id' => (int) $message_id,
'log_ip' => $this->user->ip,
'log_time' => time(),
)));
$log_id = (int) $this->db->sql_nextid();
$this->cache->destroy('sql', $this->mchat_log_table);
return $log_id;
}
}

210
core/log.php Normal file
View File

@@ -0,0 +1,210 @@
<?php
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace dmzx\mchat\core;
use phpbb\cache\driver\driver_interface as cache_interface;
use phpbb\event\dispatcher_interface;
use phpbb\user;
use phpbb\db\driver\driver_interface as db_interface;
class log
{
/** @var settings */
protected $mchat_settings;
/** @var user */
protected $user;
/** @var db_interface */
protected $db;
/** @var cache_interface */
protected $cache;
/** @var dispatcher_interface */
protected $dispatcher;
/** @var array */
protected $log_types;
/**
* Constructor
*
* @param settings $mchat_settings
* @param user $user
* @param db_interface $db
* @param cache_interface $cache
* @param dispatcher_interface $dispatcher
*/
public function __construct(
settings $mchat_settings,
user $user,
db_interface $db,
cache_interface $cache,
dispatcher_interface $dispatcher
)
{
$this->mchat_settings = $mchat_settings;
$this->user = $user;
$this->db = $db;
$this->cache = $cache;
$this->dispatcher = $dispatcher;
}
/**
* Returns an array with all registered log types
*
* @return array
*/
public function get_types()
{
if (!$this->log_types)
{
// Default log types
$log_types = [
1 => 'edit',
2 => 'del',
];
/**
* Event that allows adding log types
*
* @event dmzx.mchat.log_types_init
* @var array log_types Array containing log types
* @since 2.1.0-RC1
*/
$vars = [
'log_types',
];
extract($this->dispatcher->trigger_event('dmzx.mchat.log_types_init', compact($vars)));
$this->log_types = $log_types;
}
return $this->log_types;
}
/**
* Returns the log type ID for the given string type
*
* @param string $type
* @return int
*/
public function get_type_id($type)
{
return (int) array_search($type, $this->get_types());
}
/**
* @param string $log_type The log type, one of edit|del
* @param int $message_id The ID of the message to which this log entry belongs
* @return int The ID of the newly added log row
*/
public function add_log($log_type, $message_id)
{
$this->db->sql_query('INSERT INTO ' . $this->mchat_settings->get_table_mchat_log() . ' ' . $this->db->sql_build_array('INSERT', [
'log_type' => $this->get_type_id($log_type),
'user_id' => (int) $this->user->data['user_id'],
'message_id' => (int) $message_id,
'log_ip' => $this->user->ip,
'log_time' => time(),
]));
$log_id = (int) $this->db->sql_nextid();
$this->cache->destroy('sql', $this->mchat_settings->get_table_mchat_log());
return $log_id;
}
/**
* Fetches log entries from the database and sorts them
*
* @param int $log_id The ID of the latest log entry that the user has
* @return array
*/
public function get_logs($log_id)
{
$sql_array = [
'SELECT' => 'ml.*',
'FROM' => [$this->mchat_settings->get_table_mchat_log() => 'ml'],
'WHERE' => 'ml.log_id > ' . (int) $log_id,
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql, 3600);
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
$log_rows = array_merge(array_fill_keys($this->get_types(), []), [
'latest' => (int) $log_id,
]);
$log_types = $this->get_types();
$edit_delete_limit = $this->mchat_settings->cfg('mchat_edit_delete_limit');
$time_limit = $edit_delete_limit ? time() - $edit_delete_limit : 0;
foreach ($rows as $log_row)
{
$log_rows['latest'] = max($log_rows['latest'], (int) $log_row['log_id']);
$log_type = $log_row['log_type'];
if (isset($log_types[$log_type]))
{
if ($log_row['user_id'] != $this->user->data['user_id'] && $log_row['log_time'] > $time_limit)
{
$log_type_name = $log_types[$log_type];
$log_rows[$log_type_name][] = (int) $log_row['message_id'];
}
}
/**
* Event that allows processing log messages
*
* @event dmzx.mchat.action_refresh_process_log_row
* @var array response The data that is sent back to the user (still incomplete at this point)
* @var array log_row The log data (read only)
* @since 2.0.0-RC6
*/
$vars = [
'response',
'log_row',
];
extract($this->dispatcher->trigger_event('dmzx.mchat.action_refresh_process_log_row', compact($vars)));
unset($log_row);
}
return $log_rows;
}
/**
* Fetches the highest log ID
*
* @return int
*/
public function get_latest_id()
{
$sql_array = [
'SELECT' => 'ml.log_id',
'FROM' => [$this->mchat_settings->get_table_mchat_log() => 'ml'],
'ORDER_BY' => 'log_id DESC',
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, 1);
$max_log_id = (int) $this->db->sql_fetchfield('log_id');
$this->db->sql_freeresult($result);
return $max_log_id;
}
}

File diff suppressed because it is too large Load Diff

399
core/notifications.php Normal file
View File

@@ -0,0 +1,399 @@
<?php
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace dmzx\mchat\core;
use phpbb\auth\auth;
use phpbb\event\dispatcher_interface;
use phpbb\language\language;
use phpbb\textformatter\parser_interface;
use phpbb\user;
use phpbb\db\driver\driver_interface as db_interface;
class notifications
{
/**
* Value of the phpbb_mchat.post_id field for login notification
* messages if the user session is visible at the time of login
*/
const LOGIN_VISIBLE = 1;
/**
* Value of the phpbb_mchat.post_id field for login notification
* messages if the user session is hidden at the time of login
*/
const LOGIN_HIDDEN = 2;
/**
* A notification of a new topic, quote, edit or reply
*/
const POST = 3;
/** @var settings */
protected $mchat_settings;
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var auth */
protected $auth;
/** @var db_interface */
protected $db;
/** @var dispatcher_interface */
protected $dispatcher;
/** @var parser_interface */
protected $textformatter_parser;
/**
* Constructor
*
* @param settings $mchat_settings
* @param user $user
* @param language $lang
* @param auth $auth
* @param db_interface $db
* @param dispatcher_interface $dispatcher
* @param parser_interface $textformatter_parser
*/
public function __construct(
settings $mchat_settings,
user $user,
language $lang,
auth $auth,
db_interface $db,
dispatcher_interface $dispatcher,
parser_interface $textformatter_parser
)
{
$this->mchat_settings = $mchat_settings;
$this->user = $user;
$this->lang = $lang;
$this->auth = $auth;
$this->db = $db;
$this->dispatcher = $dispatcher;
$this->textformatter_parser = $textformatter_parser;
}
/**
* Checks whether or not the given message row is a notification
*
* @param array $row The message row
* @return int the notification type, or 0 if the $row is not a notification
*/
public function is_notification($row)
{
// If post_id is 0 it's not a notification
if (isset($row['post_id']) && $row['post_id'])
{
// If forum_id is 0 it's a login notification
if (isset($row['forum_id']) && !$row['forum_id'])
{
// post_id is either LOGIN_VISIBLE or LOGIN_HIDDEN
return $row['post_id'];
}
return self::POST;
}
return 0;
}
/**
* Checks the post rows for notifications and converts their language keys
*
* @param array $rows The rows to modify
* @return array
*/
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.
$notification_lang = [
'MCHAT_NEW_POST',
'MCHAT_NEW_QUOTE',
'MCHAT_NEW_EDIT',
'MCHAT_NEW_REPLY',
'MCHAT_NEW_LOGIN',
];
$notification_langs = array_merge(
// Raw notification messages in phpBB < 3.2
array_combine($notification_lang, $notification_lang),
// XML notification messages in phpBB >= 3.2
array_combine(array_map([$this->textformatter_parser, 'parse'], $notification_lang), $notification_lang)
);
$notifications = [];
$post_ids = [];
foreach ($rows as $i => $row)
{
$type = $this->is_notification($row);
if ($type && isset($notification_langs[$row['message']]))
{
$notifications[$i] = $type;
if ($type == self::POST)
{
$post_ids[$i] = $row['post_id'];
}
}
}
$notification_post_data = $this->mchat_get_post_data($post_ids);
foreach ($notifications as $i => $type)
{
$lang_key = $notification_langs[$rows[$i]['message']];
$post_data = $type == self::POST ? $notification_post_data[$post_ids[$i]] : null;
$rows[$i] = $this->process_notification($rows[$i], $type, $lang_key, $post_data);
}
return $rows;
}
/**
* Fetches post subjects and their forum names. If a post_id can't be found the value for the post_id is set to null.
*
* @param array $post_ids
* @return array
*/
protected function mchat_get_post_data($post_ids)
{
if (!$post_ids)
{
return [];
}
$sql_array = [
'SELECT' => 'p.post_id, p.post_subject, f.forum_id, f.forum_name',
'FROM' => [POSTS_TABLE => 'p', FORUMS_TABLE => 'f'],
'WHERE' => 'p.forum_id = f.forum_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids),
];
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
$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'],
];
}
// Map IDs of missing posts to null
$missing_post_subjects = array_fill_keys(array_diff($post_ids, array_keys($post_subjects)), null);
return $post_subjects + $missing_post_subjects;
}
/**
* Converts the message field of the post row so that it can be passed to generate_text_for_display()
*
* @param array $row
* @param int $type
* @param string $lang_key
* @param array $post_data
* @return array
*/
protected function process_notification($row, $type, $lang_key, $post_data = null)
{
$lang_args = [];
$replacements = [];
$post_subject_placeholder = '%POST_SUBJECT%';
$forum_name_placeholder = '%FORUM_NAME%';
if ($type == self::POST)
{
if ($post_data)
{
$viewtopic_url = append_sid($this->mchat_settings->url('viewtopic', true), [
'p' => $row['post_id'],
'#' => 'p' . $row['post_id'],
]);
// We prefer $post_data because it was fetched from the forums table just now.
// $row might contain outdated data if a post was moved to a new forum.
$forum_id = isset($post_data['forum_id']) ? $post_data['forum_id'] : $row['forum_id'];
$viewforum_url = append_sid($this->mchat_settings->url('viewforum', true), [
'f' => $forum_id,
]);
$lang_args[] = '[url=' . $viewtopic_url . ']' . $post_subject_placeholder . '[/url]';
$lang_args[] = '[url=' . $viewforum_url . ']' . $forum_name_placeholder . '[/url]';
$replacements = [
$post_subject_placeholder => $post_data['post_subject'],
$forum_name_placeholder => $post_data['forum_name'],
];
}
else
{
$lang_key .= '_DELETED';
}
}
else if ($type == self::LOGIN_HIDDEN)
{
$row['username'] = '<em>' . $row['username'] . '</em>';
}
$row['message'] = $this->lang->lang_array($lang_key, $lang_args);
// Quick'n'dirty check if BBCodes are in the message
if (strpos($row['message'], '[') !== false)
{
generate_text_for_storage($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'], true, true, true, true, true, true, true, 'mchat');
}
$row['message'] = strtr($row['message'], $replacements);
return $row;
}
/**
* Inserts a message with posting information into the database
*
* @param string $mode One of post|quote|edit|reply
* @param int $forum_id
* @param int $post_id
*/
public function insert_post($mode, $forum_id, $post_id)
{
$this->insert($mode, $forum_id, $post_id);
}
/**
* Inserts a message with login information into the database
*
* @param bool $is_hidden
*/
public function insert_login($is_hidden)
{
$this->insert('login', 0, $is_hidden ? self::LOGIN_HIDDEN : self::LOGIN_VISIBLE);
}
/**
* Inserts a message with posting or login information into the database
*
* @param string $mode One of post|quote|edit|reply|login
* @param int $forum_id
* @param int $post_id Can be 0 if mode is login.
*/
protected function insert($mode, $forum_id, $post_id)
{
$mode_config = [
'post' => 'mchat_posts_topic',
'quote' => 'mchat_posts_quote',
'edit' => 'mchat_posts_edit',
'reply' => 'mchat_posts_reply',
'login' => 'mchat_posts_login',
];
$is_mode_enabled = !empty($mode_config[$mode]) && $this->mchat_settings->cfg($mode_config[$mode]) && (!$this->mchat_settings->cfg('mchat_posts_auth_check') || $this->can_use_mchat());
$sql_array = [
'forum_id' => (int) $forum_id,
'post_id' => (int) $post_id,
'user_id' => (int) $this->user->data['user_id'],
'user_ip' => $this->user->ip,
'message' => $this->textformatter_parser->parse('MCHAT_NEW_' . strtoupper($mode)),
'message_time' => time(),
];
/**
* Event that allows to modify data of a posting or login notification before it is inserted in the database
*
* @event dmzx.mchat.insert_posting_before
* @var string mode The posting mode, one of post|quote|edit|reply|login
* @var int forum_id The ID of the forum where the post was made, or 0 if mode is login.
* @var int post_id The ID of the post that was made. If mode is login this value is
* one of the constants LOGIN_HIDDEN|LOGIN_VISIBLE
* @var array is_mode_enabled Whether or not the posting should be added to the database.
* @var array sql_array An array containing the data that is about to be inserted into the messages table.
* @since 2.0.0-RC6
* @changed 2.1.0-RC1 Removed is_hidden_login
*/
$vars = [
'mode',
'forum_id',
'post_id',
'is_mode_enabled',
'sql_array',
];
extract($this->dispatcher->trigger_event('dmzx.mchat.insert_posting_before', compact($vars)));
if ($is_mode_enabled)
{
$sql = 'INSERT INTO ' . $this->mchat_settings->get_table_mchat() . ' ' . $this->db->sql_build_array('INSERT', $sql_array);
$this->db->sql_query($sql);
}
}
/**
* The user might have just logged in successfully in which case the permissions haven't been updated yet.
* Let's do that here so that notifications are recorded correctly.
*
* @return bool
*/
protected function can_use_mchat()
{
if ($this->auth->acl_get('u_mchat_use'))
{
return true;
}
$auth = new auth();
$auth->acl($this->user->data);
return $auth->acl_get('u_mchat_use');
}
/**
* Generates an SQL WHERE condition to include or exlude notifacation
* messages based on the current user's settings and permissions
*
* @return string
*/
public function get_sql_where()
{
// Exclude all post notifications
if (!$this->mchat_settings->cfg('mchat_posts'))
{
return 'm.post_id = 0';
}
// If the current user doesn't have permission to see hidden users, exclude their login posts
if (!$this->auth->acl_get('u_viewonline'))
{
return implode(' OR ', [
'm.post_id <> ' . self::LOGIN_HIDDEN, // Exclude all notifications that were created by hidden users ...
'm.user_id = ' . (int) $this->user->data['user_id'], // ... but include all login notifications of the current user
'm.forum_id <> 0', // ... and include all post notifications
]);
}
return '';
}
}

View File

@@ -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);
}
}
}

View File

@@ -18,35 +18,33 @@ use phpbb\cron\task\base;
class mchat_prune extends base
{
/** @var functions */
protected $functions;
protected $mchat_functions;
/** @var settings */
protected $settings;
protected $mchat_settings;
/**
* Constructor
*
* @param functions $functions
* @param settings $settings
* @param functions $mchat_functions
* @param settings $mchat_settings
*/
public function __construct(
functions $functions,
settings $settings
functions $mchat_functions,
settings $mchat_settings
)
{
$this->functions = $functions;
$this->settings = $settings;
$this->mchat_functions = $mchat_functions;
$this->mchat_settings = $mchat_settings;
}
/**
* Runs this cron task.
*
* @return null
*/
public function run()
{
$this->functions->mchat_prune();
$this->settings->set_cfg('mchat_prune_last_gc', time());
$this->mchat_functions->mchat_prune();
$this->mchat_settings->set_cfg('mchat_prune_last_gc', time());
}
/**
@@ -58,7 +56,7 @@ class mchat_prune extends base
*/
public function is_runnable()
{
return $this->settings->cfg('mchat_prune');
return $this->mchat_settings->cfg('mchat_prune');
}
/**
@@ -69,6 +67,6 @@ class mchat_prune extends base
*/
public function should_run()
{
return $this->settings->cfg('mchat_prune_last_gc') < time() - $this->settings->cfg('mchat_prune_gc');
return $this->mchat_settings->cfg('mchat_prune_last_gc') < time() - $this->mchat_settings->cfg('mchat_prune_gc');
}
}

View File

@@ -14,10 +14,10 @@ namespace dmzx\mchat\event;
use dmzx\mchat\core\functions;
use dmzx\mchat\core\settings;
use phpbb\auth\auth;
use phpbb\event\data;
use phpbb\language\language;
use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb\user;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class acp_listener implements EventSubscriberInterface
@@ -28,79 +28,67 @@ class acp_listener implements EventSubscriberInterface
/** @var request_interface */
protected $request;
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var settings */
protected $settings;
protected $mchat_settings;
/** @var functions */
protected $functions;
/** @var string */
protected $root_path;
/** @var string */
protected $php_ext;
protected $mchat_functions;
/**
* Constructor
*
* @param template $template
* @param request_interface $request
* @param user $user
* @param settings $settings
* @param functions $functions
* @param string $root_path
* @param string $php_ext
* @param language $lang
* @param settings $mchat_settings
* @param functions $mchat_functions
*/
public function __construct(
template $template,
request_interface $request,
user $user,
settings $settings,
functions $functions,
$root_path,
$php_ext
language $lang,
settings $mchat_settings,
functions $mchat_functions
)
{
$this->template = $template;
$this->request = $request;
$this->user = $user;
$this->settings = $settings;
$this->functions = $functions;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->template = $template;
$this->request = $request;
$this->lang = $lang;
$this->mchat_settings = $mchat_settings;
$this->mchat_functions = $mchat_functions;
}
/**
* @return array
*/
static public function getSubscribedEvents()
public static function getSubscribedEvents()
{
return array(
return [
'core.permissions' => 'permissions',
'core.acp_users_prefs_modify_sql' => 'acp_users_prefs_modify_sql',
'core.acp_users_prefs_modify_template_data' => 'acp_users_prefs_modify_template_data',
'core.acp_users_overview_before' => 'acp_users_overview_before',
'core.delete_user_after' => 'delete_user_after',
);
];
}
/**
* @param Event $event
* @param data $event
*/
public function permissions($event)
public function permissions(data $event)
{
$ucp_configs = array();
$ucp_configs = [];
foreach (array_keys($this->settings->ucp_settings()) as $config_name)
foreach (array_keys($this->mchat_settings->ucp_settings()) as $config_name)
{
$ucp_configs[] = 'u_' . $config_name;
}
$permission_categories = array(
'mchat' => array(
$permission_categories = [
'mchat' => [
'u_mchat_use',
'u_mchat_view',
'u_mchat_edit',
@@ -117,38 +105,38 @@ class acp_listener implements EventSubscriberInterface
'u_mchat_smilies',
'u_mchat_urls',
'a_mchat',
),
],
'mchat_user_config' => $ucp_configs,
);
];
$mchat_permissions = array();
$mchat_permissions = [];
foreach ($permission_categories as $cat => $permissions)
{
foreach ($permissions as $permission)
{
$mchat_permissions[$permission] = array(
$mchat_permissions[$permission] = [
'lang' => 'ACL_' . strtoupper($permission),
'cat' => $cat,
);
];
}
}
$event['permissions'] = array_merge($event['permissions'], $mchat_permissions);
$event['categories'] = array_merge($event['categories'], array(
$event['categories'] = array_merge($event['categories'], [
'mchat' => 'ACP_CAT_MCHAT',
'mchat_user_config' => 'ACP_CAT_MCHAT_USER_CONFIG',
));
]);
}
/**
* @param Event $event
* @param data $event
*/
public function acp_users_prefs_modify_sql($event)
public function acp_users_prefs_modify_sql(data $event)
{
$sql_ary = array();
$validation = array();
$sql_ary = [];
$validation = [];
$user_id = $event['user_row']['user_id'];
@@ -156,7 +144,7 @@ class acp_listener implements EventSubscriberInterface
$userdata = $auth->obtain_user_data($user_id);
$auth->acl($userdata);
foreach ($this->settings->ucp_settings() as $config_name => $config_data)
foreach ($this->mchat_settings->ucp_settings() as $config_name => $config_data)
{
if ($auth->acl_get('u_' . $config_name))
{
@@ -171,21 +159,18 @@ class acp_listener implements EventSubscriberInterface
}
}
if (!function_exists('validate_data'))
{
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
}
$this->mchat_settings->include_functions('user', 'validate_data');
$event['error'] = array_merge($event['error'], validate_data($sql_ary, $validation));
$event['sql_ary'] = array_merge($event['sql_ary'], $sql_ary);
}
/**
* @param Event $event
* @param data $event
*/
public function acp_users_prefs_modify_template_data($event)
public function acp_users_prefs_modify_template_data(data $event)
{
$this->user->add_lang_ext('dmzx/mchat', array('mchat_acp', 'mchat_ucp'));
$this->lang->add_lang(['mchat_acp', 'mchat_ucp'], 'dmzx/mchat');
$user_id = (int) $event['user_row']['user_id'];
@@ -193,44 +178,44 @@ class acp_listener implements EventSubscriberInterface
$userdata = $auth->obtain_user_data($user_id);
$auth->acl($userdata);
$selected = $this->settings->cfg_user('mchat_date', $event['user_row'], $auth);
$date_template_data = $this->settings->get_date_template_data($selected);
$selected = $this->mchat_settings->cfg_user('mchat_date', $event['user_row'], $auth);
$date_template_data = $this->mchat_settings->get_date_template_data($selected);
$this->template->assign_vars($date_template_data);
$notifications_template_data = $this->settings->get_enabled_post_notifications_lang();
$notifications_template_data = $this->mchat_settings->get_enabled_post_notifications_lang();
$this->template->assign_var('MCHAT_POSTS_ENABLED_LANG', $notifications_template_data);
foreach (array_keys($this->settings->ucp_settings()) as $config_name)
foreach (array_keys($this->mchat_settings->ucp_settings()) as $config_name)
{
$upper = strtoupper($config_name);
$this->template->assign_vars(array(
$upper => $this->settings->cfg_user($config_name, $event['user_row'], $auth),
$this->template->assign_vars([
$upper => $this->mchat_settings->cfg_user($config_name, $event['user_row'], $auth),
$upper . '_NOAUTH' => !$auth->acl_get('u_' . $config_name, $user_id),
));
]);
}
}
/**
* @param Event $event
*
*/
public function acp_users_overview_before($event)
public function acp_users_overview_before()
{
$this->user->add_lang_ext('dmzx/mchat', 'mchat_acp');
$this->lang->add_lang('mchat_acp', 'dmzx/mchat');
$this->template->assign_vars(array(
'L_RETAIN_POSTS' => $this->user->lang('MCHAT_RETAIN_MESSAGES', $this->user->lang('RETAIN_POSTS')),
'L_DELETE_POSTS' => $this->user->lang('MCHAT_DELETE_MESSAGES', $this->user->lang('DELETE_POSTS')),
));
$this->template->assign_vars([
'L_RETAIN_POSTS' => $this->lang->lang('MCHAT_RETAIN_MESSAGES', $this->lang->lang('RETAIN_POSTS')),
'L_DELETE_POSTS' => $this->lang->lang('MCHAT_DELETE_MESSAGES', $this->lang->lang('DELETE_POSTS')),
]);
}
/**
* @param Event $event
* @param data $event
*/
public function delete_user_after($event)
public function delete_user_after(data $event)
{
if ($event['mode'] == 'remove')
{
$this->functions->mchat_prune($event['user_ids']);
$this->mchat_functions->mchat_prune($event['user_ids']);
}
}
}

View File

@@ -12,8 +12,10 @@
namespace dmzx\mchat\event;
use dmzx\mchat\core\mchat;
use dmzx\mchat\core\notifications;
use phpbb\controller\helper;
use phpbb\event\data;
use phpbb\language\language;
use phpbb\request\request_interface;
use phpbb\user;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -23,12 +25,18 @@ class main_listener implements EventSubscriberInterface
/** @var mchat */
protected $mchat;
/** @var notifications */
protected $mchat_notifications;
/** @var helper */
protected $helper;
/** @var user */
protected $user;
/** @var language */
protected $lang;
/** @var request_interface */
protected $request;
@@ -39,52 +47,59 @@ class main_listener implements EventSubscriberInterface
* Constructor
*
* @param mchat $mchat
* @param notifications $mchat_notifications
* @param helper $helper
* @param user $user
* @param language $lang
* @param request_interface $request
* @param string $php_ext
*/
public function __construct(
mchat $mchat,
notifications $mchat_notifications,
helper $helper,
user $user,
language $lang,
request_interface $request,
$php_ext
)
{
$this->mchat = $mchat;
$this->helper = $helper;
$this->user = $user;
$this->request = $request;
$this->php_ext = $php_ext;
$this->mchat = $mchat;
$this->mchat_notifications = $mchat_notifications;
$this->helper = $helper;
$this->user = $user;
$this->lang = $lang;
$this->request = $request;
$this->php_ext = $php_ext;
}
/**
* @return array
*/
static public function getSubscribedEvents()
public static function getSubscribedEvents()
{
return array(
return [
'core.viewonline_overwrite_location' => 'add_page_viewonline',
'core.user_setup' => 'load_language_on_setup',
'core.page_header' => 'add_page_header_link',
'core.index_modify_page_title' => 'display_mchat_on_index',
'core.submit_post_end' => 'insert_posting',
'core.display_custom_bbcodes_modify_sql' => array(array('remove_disallowed_bbcodes'), array('pm_compose_add_quote')),
'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.login_box_redirect' => 'user_login_success',
'core.session_gc_after' => 'session_gc',
);
];
}
/**
* @param data $event
*/
public function add_page_viewonline($event)
public function add_page_viewonline(data $event)
{
if (strrpos($event['row']['session_page'], 'app.' . $this->php_ext . '/mchat') === 0)
{
$event['location'] = $this->user->lang('MCHAT_TITLE');
$event['location'] = $this->lang->lang('MCHAT_TITLE');
$event['location_url'] = $this->helper->route('dmzx_mchat_page_custom_controller');
}
}
@@ -92,13 +107,13 @@ class main_listener implements EventSubscriberInterface
/**
* @param data $event
*/
public function load_language_on_setup($event)
public function load_language_on_setup(data $event)
{
$lang_set_ext = $event['lang_set_ext'];
$lang_set_ext[] = array(
$lang_set_ext[] = [
'ext_name' => 'dmzx/mchat',
'lang_set' => 'common',
);
];
$event['lang_set_ext'] = $lang_set_ext;
}
@@ -121,23 +136,33 @@ class main_listener implements EventSubscriberInterface
/**
* @param data $event
*/
public function insert_posting($event)
public function insert_posting(data $event)
{
$this->mchat->insert_posting($event['mode'], $event['data']['forum_id'], $event['data']['post_id']);
$this->mchat_notifications->insert_post($event['mode'], $event['data']['forum_id'], $event['data']['post_id']);
}
/**
* @param data $event
*/
public function remove_disallowed_bbcodes($event)
public function remove_disallowed_bbcodes(data $event)
{
$event['sql_ary'] = $this->mchat->remove_disallowed_bbcodes($event['sql_ary']);
$this->mchat->set_custom_bbcodes_generated(true);
}
/**
*
*/
public function generate_smilies_after()
{
$this->mchat->set_smilies_generated(true);
}
/**
* @param data $event
*/
public function user_registration_set_default_values($event)
public function user_registration_set_default_values(data $event)
{
$event['sql_ary'] = $this->mchat->set_user_default_values($event['sql_ary']);
}
@@ -145,11 +170,12 @@ class main_listener implements EventSubscriberInterface
/**
* @param data $event
*/
public function user_login_success($event)
public function user_login_success(data $event)
{
if (!$event['admin'])
{
$this->mchat->insert_posting('login');
$is_hidden = $this->request->is_set_post('viewonline') || !$this->user->data['user_allow_viewonline'];
$this->mchat_notifications->insert_login($is_hidden);
}
}

31
ext.php
View File

@@ -11,11 +11,14 @@
namespace dmzx\mchat;
class ext extends \phpbb\extension\base
use phpbb\extension\base;
class ext extends base
{
/**
* Requires phpBB 3.1.7-PL1 due to usage of \phpbb\session:update_session_infos()
* Requires phpBB 3.1.8-RC1 due to HTTPS in version check
* Requires phpBB 3.2.0 due to EoL of phpBB 3.1
*
* @return bool
* @access public
@@ -37,28 +40,16 @@ class ext extends \phpbb\extension\base
if ($module_ids)
{
if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '>='))
{
// For phpBB >= 3.2.x
$lang = $this->container->get('language');
$lang->add_lang('mchat_acp', 'dmzx/mchat');
}
else
{
// For phpBB 3.1.x
$user = $this->container->get('user');
$user->add_lang_ext('dmzx/mchat', 'mchat_acp');
$lang = $user;
}
$lang = $this->container->get('language');
$lang->add_lang('mchat_acp', 'dmzx/mchat');
$php_ext = $this->container->getParameter('core.php_ext');
$error_msg = $lang->lang('MCHAT_30X_REMNANTS', $table_prefix, implode($lang->lang('COMMA_SEPARATOR'), $module_ids)) . adm_back_link(append_sid('index.' . $php_ext, 'i=acp_extensions&amp;mode=main'));
$error_msg = $lang->lang('MCHAT_30X_REMNANTS', $table_prefix, implode($lang->lang('COMMA_SEPARATOR'), $module_ids)) . adm_back_link(append_sid('index.' . $php_ext, ['i' => 'acp_extensions', 'mode' => 'main']));
trigger_error($error_msg, E_USER_WARNING);
}
}
return phpbb_version_compare(PHPBB_VERSION, '3.1.8-RC1', '>=');
return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=') && phpbb_version_compare(PHP_VERSION, '5.4.7', '>=');
}
/**
@@ -72,13 +63,13 @@ class ext extends \phpbb\extension\base
{
$db = $this->container->get('dbal.conn');
$mchat_30x_module_langnames = array(
$mchat_30x_module_langnames = [
'ACP_CAT_MCHAT',
'ACP_MCHAT_CONFIG',
'ACP_USER_MCHAT',
'UCP_CAT_MCHAT',
'UCP_MCHAT_CONFIG',
);
];
$sql = 'SELECT module_id
FROM ' . $table_prefix . 'modules
@@ -87,7 +78,7 @@ class ext extends \phpbb\extension\base
$rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$module_ids = array();
$module_ids = [];
foreach ($rows as $row)
{

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,30 +34,40 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
'MCHAT_TITLE' => 'mChat',
'MCHAT_TITLE_COUNT' => 'mChat [<strong>%1$d</strong>]',
'MCHAT_TITLE_COUNT' => [
0 => 'mChat',
1 => 'mChat [<strong>%1$d</strong>]',
],
'MCHAT_NAVBAR_CUSTOM_PAGE' => 'mChat page',
'MCHAT_NAVBAR_ARCHIVE' => 'Archive',
'MCHAT_NAVBAR_RULES' => 'Rules',
// Who is chatting
'MCHAT_WHO_IS_CHATTING' => 'Who is chatting',
'MCHAT_ONLINE_USERS_TOTAL' => array(
'MCHAT_ONLINE_USERS_TOTAL' => [
0 => 'No one is chatting',
1 => '<strong>%1$d</strong> user is chatting',
2 => '<strong>%1$d</strong> users are chatting',
),
],
'MCHAT_ONLINE_EXPLAIN' => 'based on users active over the past %1$s',
'MCHAT_HOURS' => array(
'MCHAT_HOURS' => [
1 => '%1$d hour',
2 => '%1$d hours',
),
'MCHAT_MINUTES' => array(
],
'MCHAT_MINUTES' => [
1 => '%1$d minute',
2 => '%1$d minutes',
),
'MCHAT_SECONDS' => array(
],
'MCHAT_SECONDS' => [
1 => '%1$d second',
2 => '%1$d seconds',
),
],
// Custom translations for administrators
'MCHAT_RULES_MESSAGE' => '',
'MCHAT_STATIC_MESSAGE' => '',
// Post notification messages (%1$s is replaced with a link to the new/edited post, %2$s is replaced with a link to the forum)
'MCHAT_NEW_POST' => 'posted a new topic: %1$s in %2$s',
@@ -69,4 +79,4 @@ $lang = array_merge($lang, array(
'MCHAT_NEW_EDIT' => 'edited a post: %1$s in %2$s',
'MCHAT_NEW_EDIT_DELETED' => 'edited a post that was deleted',
'MCHAT_NEW_LOGIN' => 'just logged in',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,7 +34,7 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
// Module titles
'ACP_CAT_MCHAT' => 'mChat',
'ACP_CAT_MCHAT_USER_CONFIG' => 'mChat in UCP',
@@ -47,4 +47,4 @@ $lang = array_merge($lang, array(
'LOG_MCHAT_TABLE_PURGED' => '<strong>mChat messages purged</strong><br>» %1$s',
'LOG_DELETED_MCHAT' => '<strong>mChat message deleted</strong><br>» %1$s',
'LOG_EDITED_MCHAT' => '<strong>mChat message edited</strong><br>» %1$s',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,6 +34,6 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
'UCP_MCHAT_CONFIG' => 'mChat',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,7 +34,7 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
'MCHAT_ADD' => 'Send',
'MCHAT_ARCHIVE' => 'Archive',
'MCHAT_ARCHIVE_PAGE' => 'mChat Archive',
@@ -53,7 +53,7 @@ $lang = array_merge($lang, array(
'MCHAT_RULES' => 'Rules',
'MCHAT_WHOIS_USER' => 'IP whois for %1$s',
'MCHAT_MESS_LONG' => 'Your message is too long. Please limit it to %1$d characters.',
'MCHAT_NO_CUSTOM_PAGE' => 'The mChat custom page is not activated at this time.',
'MCHAT_NO_CUSTOM_PAGE' => 'The mChat page is not activated at this time.',
'MCHAT_NO_RULES' => 'The mChat rules page is not activated at this time.',
'MCHAT_NOACCESS_ARCHIVE' => 'You dont have permission to view the archive.',
'MCHAT_NOJAVASCRIPT' => 'Please enable JavaScript to use mChat.',
@@ -64,29 +64,25 @@ $lang = array_merge($lang, array(
'MCHAT_PAUSE' => 'Paused',
'MCHAT_PERMISSIONS' => 'Change users permissions',
'MCHAT_REFRESHING' => 'Refreshing…',
'MCHAT_REFRESH_NO' => 'Update is off',
'MCHAT_REFRESH_YES' => 'Updates every <strong>%1$d</strong> seconds',
'MCHAT_RESPOND' => 'Respond to user',
'MCHAT_SESSION_ENDS' => 'Chat session ends in %1$s',
'MCHAT_SESSION_OUT' => 'Chat session has expired',
'MCHAT_SMILES' => 'Smilies',
'MCHAT_TOTALMESSAGES' => 'Total messages: <strong>%1$d</strong>',
'MCHAT_USESOUND' => 'Play sound',
'MCHAT_SOUND_ON' => 'Sound is on',
'MCHAT_SOUND_OFF' => 'Sound is off',
'MCHAT_ENTER' => 'Use Ctrl/Cmd + Enter for the alternative action',
'MCHAT_ENTER_SUBMIT' => 'Enter sends the message',
'MCHAT_ENTER_LINEBREAK' => 'Enter adds a new line',
'MCHAT_COLLAPSE_TITLE' => 'Toggle visibility of mChat',
'MCHAT_WHO_IS_REFRESH_EXPLAIN' => 'Refreshes every <strong>%1$d</strong> seconds',
'MCHAT_MINUTES_AGO' => array(
'MCHAT_MINUTES_AGO' => [
0 => 'just now',
1 => '%1$d minute ago',
2 => '%1$d minutes ago',
),
],
// These messages are formatted with JavaScript, hence {} and no %d
'MCHAT_CHARACTER_COUNT' => '<strong>{current}</strong> characters',
'MCHAT_CHARACTER_COUNT_LIMIT' => '<strong>{current}</strong> out of {max} characters',
'MCHAT_SESSION_ENDS_JS' => 'Chat session ends in {timeleft}',
'MCHAT_MENTION' => ' @{username} ',
// Custom translations for administrators
'MCHAT_RULES_MESSAGE' => '',
'MCHAT_STATIC_MESSAGE' => '',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,17 +34,18 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
// ACP Configuration sections
'MCHAT_SETTINGS_INDEX' => 'Index page settings',
'MCHAT_SETTINGS_CUSTOM' => 'Custom page settings',
'MCHAT_SETTINGS_CUSTOM' => 'mChat page settings',
'MCHAT_SETTINGS_ARCHIVE' => 'Archive page settings',
'MCHAT_SETTINGS_POSTS' => 'New posts settings',
'MCHAT_SETTINGS_MESSAGES' => 'Message settings',
'MCHAT_SETTINGS_PRUNE' => 'Pruning settings (adjustable for founders only)',
'MCHAT_SETTINGS_LOG' => 'Log settings (adjustable for founders only)',
'MCHAT_SETTINGS_STATS' => 'Who is chatting settings',
'MCHAT_GLOBALUSERSETTINGS_EXPLAIN' => 'Settings for which a user does <strong>not</strong> have permission to customise are applied as configured below.<br>New user accounts will have initial settings as configured below.<br><br>Go to the <em>mChat in UCP</em> tab of the user permissions section to adjust customisation permissions.<br>Go to the <em>Preferences</em> form in the <em>user management</em> section to see the status of each users settings.',
'MCHAT_GLOBALUSERSETTINGS_EXPLAIN' => 'Settings for which a user does <strong>not</strong> have permission to customise are applied as configured below.<br>New user accounts will have initial settings as configured below.<br><br>Go to the <em>mChat in UCP</em> tab of the user permissions section to adjust customisation permissions.<br>Go to the <em>Preferences</em> form in the <em>user management</em> section to adjust individual user settings.',
'MCHAT_GLOBALUSERSETTINGS_OVERWRITE' => 'Overwrite settings for all users',
'MCHAT_GLOBALUSERSETTINGS_OVERWRITE_EXPLAIN' => 'Applies the settings as defined above to <em>all</em> user accounts.',
'MCHAT_GLOBALUSERSETTINGS_OVERWRITE_CONFIRM' => 'Confirm overwriting mChat settings for all users',
@@ -72,7 +73,7 @@ $lang = array_merge($lang, array(
'MCHAT_TOP_OF_FORUM' => 'Top',
'MCHAT_BOTTOM_OF_FORUM' => 'Bottom',
'MCHAT_REFRESH' => 'Refresh interval',
'MCHAT_REFRESH_EXPLAIN' => 'Number of seconds before the chat refreshes.<br><em>You are limited from 5 to 60 seconds. Default is 10.</em>',
'MCHAT_REFRESH_EXPLAIN' => 'Number of seconds between refreshing messages.<br><em>You are limited from 5 to 60 seconds. Default is 10.</em>',
'MCHAT_LIVE_UPDATES' => 'Live updates of edited and deleted messages',
'MCHAT_LIVE_UPDATES_EXPLAIN' => 'When a user edits or deletes messages, the changes are updated live for all others, without them having to refresh the page. Disable this if you experience performance issues.',
'MCHAT_PRUNE' => 'Enable message pruning',
@@ -83,9 +84,8 @@ $lang = array_merge($lang, array(
'MCHAT_PRUNE_NOW' => 'Prune messages now',
'MCHAT_PRUNE_NOW_CONFIRM' => 'Confirm pruning messages',
'MCHAT_PRUNED' => '%1$d mChat messages have been pruned',
'MCHAT_NAVBAR_LINK' => 'Display link to the custom page in the navbar',
'MCHAT_NAVBAR_LINK_COUNT' => 'Display number of active chat sessions in navbar link',
'MCHAT_MESSAGE_NUM_CUSTOM' => 'Initial number of messages to display on the custom page',
'MCHAT_NAVBAR_LINK_COUNT' => 'Display number of active chat sessions in the navbar link',
'MCHAT_MESSAGE_NUM_CUSTOM' => 'Initial number of messages to display on the mChat page',
'MCHAT_MESSAGE_NUM_CUSTOM_EXPLAIN' => '<em>You are limited from 5 to 50. Default is 10.</em>',
'MCHAT_MESSAGE_NUM_INDEX' => 'Initial number of messages to display on the index page',
'MCHAT_MESSAGE_NUM_INDEX_EXPLAIN' => '<em>You are limited from 5 to 50. Default is 10.</em>',
@@ -101,9 +101,11 @@ $lang = array_merge($lang, array(
'MCHAT_EDIT_DELETE_LIMIT_EXPLAIN' => 'Messages older than the specified number of seconds cannot be edited or deleted by the author any more.<br>Users who have <em>edit/delete permission as well as moderator permission are exempt</em> from this time limit.<br>Set to 0 to allow unlimited editing and deleting.',
'MCHAT_MAX_MESSAGE_LENGTH' => 'Maximum message length',
'MCHAT_MAX_MESSAGE_LENGTH_EXPLAIN' => 'Maximum number of characters allowed per message posted.<br><em>You are limited from 0 to 1000. Default is 500. Set to 0 to disable.</em>',
'MCHAT_CUSTOM_PAGE' => 'Enable custom page',
'MCHAT_CUSTOM_HEIGHT' => 'Custom page height',
'MCHAT_CUSTOM_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the custom page.<br><em>You are limited from 50 to 1000. Default is 350.</em>',
'MCHAT_MAX_INPUT_HEIGHT' => 'Maximum input field height',
'MCHAT_MAX_INPUT_HEIGHT_EXPLAIN' => 'The input field will not expand beyond this number of pixels.<br><em>You are limited from 0 to 1000. Default is 150. Set to 0 to not allow multi-line messages.</em>',
'MCHAT_CUSTOM_PAGE' => 'Enable mChat page',
'MCHAT_CUSTOM_HEIGHT' => 'mChat page height',
'MCHAT_CUSTOM_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the mChat page.<br><em>You are limited from 50 to 1000. Default is 350.</em>',
'MCHAT_BBCODES_DISALLOWED' => 'Disallowed bbcodes',
'MCHAT_BBCODES_DISALLOWED_EXPLAIN' => 'Here you can input the bbcodes that are <strong>not</strong> to be used in a message.<br>Separate bbcodes with a vertical bar, for example:<br>b|i|u|code|list|list=|flash|quote and/or a %1$scustom bbcode tag name%2$s',
'MCHAT_STATIC_MESSAGE' => 'Static message',
@@ -114,6 +116,8 @@ $lang = array_merge($lang, array(
'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Set to yes to override the forums smilie limit setting for chat messages',
'MCHAT_OVERRIDE_MIN_POST_CHARS' => 'Override minimum characters limit',
'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Set to yes to override the forums minimum characters setting for chat messages',
'MCHAT_LOG_ENABLED' => 'Add entries to the admin log',
'MCHAT_LOG_ENABLED_EXPLAIN' => 'This affects message editing, deleting, pruning and purging.',
'MCHAT_POSTS_AUTH_CHECK' => 'Require user permission',
'MCHAT_POSTS_AUTH_CHECK_EXPLAIN' => 'If set to yes, users who can not use mChat will not generate any post/login notification messages.',
@@ -131,29 +135,27 @@ $lang = array_merge($lang, array(
// Error reporting
'TOO_LONG_MCHAT_BBCODE_DISALLOWED' => 'The disallowed bbcodes value is too long.',
'TOO_SMALL_MCHAT_CUSTOM_HEIGHT' => 'The custom height value is too small.',
'TOO_LARGE_MCHAT_CUSTOM_HEIGHT' => 'The custom height value is too large.',
'TOO_SMALL_MCHAT_CUSTOM_HEIGHT' => 'The mChat page height value is too small.',
'TOO_LARGE_MCHAT_CUSTOM_HEIGHT' => 'The mChat page height value is too large.',
'TOO_LONG_MCHAT_DATE' => 'The date format you entered is too long.',
'TOO_SHORT_MCHAT_DATE' => 'The date format you entered is too short.',
'TOO_SMALL_MCHAT_FLOOD_TIME' => 'The flood time value is too small.',
'TOO_LARGE_MCHAT_FLOOD_TIME' => 'The flood time value is too large.',
'TOO_SMALL_MCHAT_INDEX_HEIGHT' => 'The index height value is too small.',
'TOO_LARGE_MCHAT_INDEX_HEIGHT' => 'The index height value is too large.',
'TOO_SMALL_MCHAT_MAX_MESSAGE_LNGTH' => 'The max message length value is too small.',
'TOO_LARGE_MCHAT_MAX_MESSAGE_LNGTH' => 'The max message length value is too large.',
'TOO_SMALL_MCHAT_MESSAGE_NUM_CUSTOM' => 'The number of message to display on the custom page is too small.',
'TOO_LARGE_MCHAT_MESSAGE_NUM_CUSTOM' => 'The number of message to display on the custom page is too large.',
'TOO_LARGE_MCHAT_MAX_INPUT_HEIGHT' => 'The max input height value is too large.',
'TOO_SMALL_MCHAT_MESSAGE_NUM_CUSTOM' => 'The number of messages to display on the mChat page is too small.',
'TOO_LARGE_MCHAT_MESSAGE_NUM_CUSTOM' => 'The number of messages to display on the mChat page is too large.',
'TOO_SMALL_MCHAT_MESSAGE_NUM_INDEX' => 'The number of messages to display on the index page is too small.',
'TOO_LARGE_MCHAT_MESSAGE_NUM_INDEX' => 'The number of messages to display on the index page is too large.',
'TOO_SMALL_MCHAT_MESSAGE_NUM_ARCHIVE' => 'The number of message to display on the archive page is too small.',
'TOO_LARGE_MCHAT_MESSAGE_NUM_ARCHIVE' => 'The number of message to display on the archive page is too large.',
'TOO_SMALL_MCHAT_MESSAGE_NUM_ARCHIVE' => 'The number of messages to display on the archive page is too small.',
'TOO_LARGE_MCHAT_MESSAGE_NUM_ARCHIVE' => 'The number of messages to display on the archive page is too large.',
'TOO_SMALL_MCHAT_REFRESH' => 'The refresh value is too small.',
'TOO_LARGE_MCHAT_REFRESH' => 'The refresh value is too large.',
'TOO_LONG_MCHAT_STATIC_MESSAGE' => 'The static message value is too long.',
'TOO_SMALL_MCHAT_TIMEOUT' => 'The user timeout value is too small.',
'TOO_LARGE_MCHAT_TIMEOUT' => 'The user timeout value is too large.',
'TOO_SMALL_MCHAT_WHOIS_REFRESH' => 'The whois refresh value is too small.',
'TOO_LARGE_MCHAT_WHOIS_REFRESH' => 'The whois refresh value is too large.',
'MCHAT_30X_REMNANTS' => 'The installation has been aborted.<br>There are remnant modules from the mChat MOD for phpBB 3.0.x in the database. The mChat extension does not work correctly with these modules present.<br>You need to entirely uninstall the mChat MOD before being able to install the mChat extension. Specifically, the modules with the following IDs need to be deleted from the %1$smodules table: %2$s',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,7 +34,7 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
'MCHAT_PREFERENCES' => 'mChat preferences',
'MCHAT_NO_SETTINGS' => 'You are not authorised to customise any settings.',
@@ -52,8 +52,6 @@ $lang = array_merge($lang, array(
'MCHAT_DISPLAY_CHARACTER_COUNT' => 'Display number of characters when typing a message',
'MCHAT_RELATIVE_TIME' => 'Display relative time for new messages',
'MCHAT_RELATIVE_TIME_EXPLAIN' => 'Displays “just now”, “1 minute ago” and so on for each message. Set to <em>No</em> to always display the full date.',
'MCHAT_PAUSE_ON_INPUT' => 'Pause on input',
'MCHAT_PAUSE_ON_INPUT_EXPLAIN' => 'Do not update mChat upon entering a message',
'MCHAT_MESSAGE_TOP' => 'Location of new chat messages',
'MCHAT_MESSAGE_TOP_EXPLAIN' => 'New messages will appear at the top or at the bottom in the chat.',
'MCHAT_LOCATION' => 'Location on the index page',
@@ -69,4 +67,4 @@ $lang = array_merge($lang, array(
'MCHAT_DATE_FORMAT' => 'Date format',
'MCHAT_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP <a href="http://www.php.net/date">date()</a> function.',
'MCHAT_CUSTOM_DATEFORMAT' => 'Custom…',
));
]);

View File

@@ -16,7 +16,7 @@ if (!defined('IN_PHPBB'))
if (empty($lang) || !is_array($lang))
{
$lang = array();
$lang = [];
}
// DEVELOPERS PLEASE NOTE
@@ -34,7 +34,7 @@ if (empty($lang) || !is_array($lang))
// Some characters for use
// » “ ” …
$lang = array_merge($lang, array(
$lang = array_merge($lang, [
'ACL_U_MCHAT_USE' => 'Can use mChat',
'ACL_U_MCHAT_VIEW' => 'Can view mChat',
'ACL_U_MCHAT_EDIT' => 'Can edit own messages',
@@ -43,8 +43,8 @@ $lang = array_merge($lang, array(
'ACL_U_MCHAT_MODERATOR_DELETE' => 'Can delete anyones messages',
'ACL_U_MCHAT_IP' => 'Can view IP addresses',
'ACL_U_MCHAT_PM' => 'Can use private message',
'ACL_U_MCHAT_LIKE' => 'Can like messages',
'ACL_U_MCHAT_QUOTE' => 'Can quote messages',
'ACL_U_MCHAT_LIKE' => 'Can see like icon (requires BBCode permission)',
'ACL_U_MCHAT_QUOTE' => 'Can see quote icon (requires BBCode permission)',
'ACL_U_MCHAT_FLOOD_IGNORE' => 'Can ignore flood limit',
'ACL_U_MCHAT_ARCHIVE' => 'Can view the archive',
'ACL_U_MCHAT_BBCODE' => 'Can use BBCodes',
@@ -59,7 +59,6 @@ $lang = array_merge($lang, array(
'ACL_U_MCHAT_INPUT_AREA' => 'Can customise <em>Input type</em>',
'ACL_U_MCHAT_LOCATION' => 'Can customise <em>Location of mChat on the index page</em>',
'ACL_U_MCHAT_MESSAGE_TOP' => 'Can customise <em>Location of new chat messages</em>',
'ACL_U_MCHAT_PAUSE_ON_INPUT' => 'Can customise <em>Pause on input</em>',
'ACL_U_MCHAT_POSTS' => 'Can customise <em>Display new posts</em>',
'ACL_U_MCHAT_RELATIVE_TIME' => 'Can customise <em>Display relative time</em>',
'ACL_U_MCHAT_SOUND' => 'Can customise <em>Play sounds</em>',
@@ -67,4 +66,4 @@ $lang = array_merge($lang, array(
'ACL_U_MCHAT_STATS_INDEX' => 'Can customise <em>Display who is chatting in the stats section</em>',
'ACL_A_MCHAT' => 'Can manage mChat settings',
));
]);

View File

@@ -0,0 +1,30 @@
<?php
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 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_0_3 extends migration
{
static public function depends_on()
{
return array(
'\dmzx\mchat\migrations\mchat_2_0_2',
);
}
public function update_data()
{
return array(
array('config.update', array('mchat_version', '2.0.3')),
);
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 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_0 extends migration
{
public static function depends_on()
{
return [
'\dmzx\mchat\migrations\mchat_2_1_0_rc1',
];
}
public function update_data()
{
return [
['config.update', ['mchat_version', '2.1.0']],
];
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 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_0_rc1 extends migration
{
public static function depends_on()
{
return [
'\dmzx\mchat\migrations\mchat_2_0_3',
];
}
public function update_data()
{
return [
['config.update', ['mchat_version', '2.1.0-RC1']],
['config.remove', ['mchat_navbar_link']],
['config.add', ['mchat_max_input_height', 150]],
['config.add', ['mchat_log_enabled', 1]],
// Message reparser
['config.add', ['dmzx.mchat.text_reparser.mchat_messages_cron_interval', 10]],
['config.add', ['dmzx.mchat.text_reparser.mchat_messages_last_cron', 0]],
// Remove pause on input
['config.remove', ['mchat_pause_on_input']],
['permission.remove', ['u_mchat_pause_on_input', true]],
];
}
public function update_schema()
{
return [
'drop_columns' => [
$this->table_prefix . 'users' => [
'user_mchat_pause_on_input',
],
],
];
}
public function revert_schema()
{
return [
'add_columns' => [
$this->table_prefix . 'users' => [
'user_mchat_pause_on_input' => ['BOOL', 0],
],
],
];
}
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -0,0 +1 @@
{% INCLUDECSS '@dmzx_mchat/mchat_absolution.css' %}

View File

@@ -0,0 +1,18 @@
/**
*
* mChat CSS for Absolution
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
.mchat-nav-link-title {
color: #082c51;
font-weight: bold;
}
.mchat-nav-link-title i {
color: #EE8B0A;
}

View File

@@ -0,0 +1,5 @@
{% INCLUDECSS '@dmzx_mchat/mchat_allanstyle.css' %}
<script>
document.querySelector('#mchat-body').classList.add('topiclist');
document.querySelector('#mchat-body').classList.add('forums');
</script>

View File

@@ -0,0 +1,17 @@
/**
*
* mChat CSS for AllanStyle SUBSILVER
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@media only screen and (min-width: 700px), only screen and (min-device-width: 700px) {
.mchat-wrapper .list-inner {
margin-left: 5px;
}
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,6 +0,0 @@
.mchat-icon:before {
background-image: url("./images/message_icons_orange.png") !important;
}
.icon-mchat {
background-image: url("./images/icon_mchat.png");
}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1,11 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.mchat-wrapper {
height: 100%;
}

View File

@@ -0,0 +1 @@
{% INCLUDECSS '@dmzx_mchat/mchat_myinvision.css' %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1,12 +0,0 @@
.mchat-wrapper .row-item {
top: -10px;
}
.mchat-wrapper .header {
padding-left: 15px;
padding-top: 10px;
}
#mchat-panel {
border-bottom: 1px solid #ccc;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}

View File

@@ -0,0 +1,20 @@
/**
*
* mChat CSS for MyInvision
*
* @package phpBB Extension - mChat
* @copyright (c) 2017 MannixMD
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
.mchat-status {
padding-bottom: 10px;
}
#mchat-panel {
border-bottom: 1px solid #ccc;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -0,0 +1 @@
{% INCLUDECSS '@dmzx_mchat/mchat_se_gamer.css' %}

View File

@@ -0,0 +1,16 @@
/**
*
* mChat CSS for SE Gamer
*
* @package phpBB Extension - mChat
* @copyright (c) 2018 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
.mchat-nav-link-title,
.mchat-nav-link-title:hover,
.mchat-nav-link,
.mchat-nav-link:hover {
color: #FFFFFF;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = SOP_SKDARK_SW | default(false) %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="li-mchat"><a href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link-title"><i class="icon-mchat"></i><span class="mchat-nav-link">{{ MCHAT_TITLE }}</span></a></li>

View File

@@ -1,16 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.icon-mchat {
background: none;
}
.icon-mchat:before, #mChat + .inner li.header dt:before {
content: '\e0e6';
}

View File

@@ -0,0 +1,6 @@
/*!
autosize 4.0.1
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});

View File

@@ -1,211 +0,0 @@
// Based off https://code.google.com/p/gaequery/source/browse/trunk/src/static/scripts/jquery.autogrow-textarea.js?r=2
// Modified by David Beck
// Mofified by kasimi (c) 2016
( function( factory ) {
// UMD wrapper
if ( typeof define === 'function' && define.amd ) {
// AMD
define( [ 'jquery' ], factory );
} else if ( typeof exports !== 'undefined' ) {
// Node/CommonJS
module.exports = factory( require( 'jquery' ) );
} else {
// Browser globals
factory( jQuery );
}
}( function( $ ) {
/*
* Auto-growing textareas; technique ripped from Facebook
*/
$.fn.autogrow = function(options) {
options = $.extend( {
vertical: true,
horizontal: false,
characterSlop: 0
}, options);
this.filter('textarea,input').each(function() {
var $this = $(this),
borderBox = $this.css( 'box-sizing' ) === 'border-box',
// minHeight = borderBox ? $this.outerHeight() : $this.height(),
maxHeight = $this.attr( "maxHeight" ),
minWidth = typeof( $this.attr( "minWidth" ) ) == "undefined" ? 0 : $this.attr( "minWidth" );
if( typeof( maxHeight ) == "undefined" ) maxHeight = 1000000;
var shadow = $('<div class="autogrow-shadow"></div>').css( {
position: 'absolute',
top: -10000,
left: -10000,
fontSize: $this.css('fontSize'),
fontFamily: $this.css('fontFamily'),
fontWeight: $this.css('fontWeight'),
lineHeight: $this.css('lineHeight'),
paddingLeft: $this.css('paddingLeft'),
paddingRight: $this.css('paddingRight'),
paddingTop: $this.css('paddingTop'),
paddingBottom: $this.css('paddingBottom'),
borderTop: $this.css('borderTop'),
borderBottom: $this.css('borderBottom'),
borderLeft: $this.css('borderLeft'),
borderRight: $this.css('borderRight'),
whiteSpace: 'pre-wrap',
resize: 'none'
} ).appendTo(document.body);
shadow.html( 'a' );
var characterWidth = shadow.width();
shadow.html( '' );
var isTextarea = $this.is('textarea');
var update = function( val ) {
var times = function(string, number) {
for (var i = 0, r = ''; i < number; i ++) r += string;
return r;
};
if( typeof val === 'undefined' ) val = this.value;
if( val === '' && $(this).attr("placeholder") ) val = $(this).attr("placeholder");
if( options.vertical )
val = val.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\n$/, '<br/>&nbsp;')
.replace(/\n/g, '<br/>')
.replace(/ {2,}/g, function(space) { return times('&nbsp;', space.length -1) + ' '; });
else
val = escapeHtml( val );
//if( options.horizontal )
// val = $.trim( val );
// if( $(this).prop( 'tagName' ).toUpperCase() === 'INPUT' )
// shadow.text(val).css( "width", "auto" );
// else
shadow.html( val ).css( "width", "auto" ); // need to use html here otherwise no way to count spaces (with html we can use &nbsp;)
if( options.horizontal )
{
var slopWidth = options.characterSlop * characterWidth + 2;
var newWidth = Math.max( shadow.width() + slopWidth, minWidth );
var maxWidth = options.maxWidth;
//if( typeof( maxWidth ) === "undefined" ) maxWidth = $this.parent().width() - 12; // not sure why we were doing this but seems like a bad idea. doesn't work with inline-block parents for one thing, since it is the text area that should be "pushing" them to be wider
if( maxWidth ) newWidth = Math.min( newWidth, maxWidth );
// Take scrollbar into account
if (isTextarea && shadow.get(0).scrollHeight > shadow.height()) {
newWidth += 20;
}
$(this).css( "width", newWidth );
}
if( options.vertical )
{
var shadowWidth = $(this).width();
if( ! borderBox ) shadowWidth = shadowWidth - parseInt($this.css('paddingLeft'),10) - parseInt($this.css('paddingRight'),10);
shadow.css( "width", shadowWidth );
var shadowHeight = borderBox ? shadow.outerHeight() : shadow.height();
$(this).css( "height", "auto" );
minHeight = borderBox ? $this.outerHeight() : $this.height();
var newHeight = Math.min( Math.max( shadowHeight, minHeight ), maxHeight );
$(this).css( "height", newHeight );
$(this).css( "overflow", newHeight == maxHeight ? "auto" : "hidden" );
}
};
$(this)
.change(function(){update.call( this );return true;})
.keyup(function(){update.call( this );return true;})
.keypress(function( event ) {
if( event.ctrlKey || event.metaKey ) return;
var val = this.value;
var caretInfo = _getCaretInfo( this );
var typedChar = event.which === 13 ? "\n" : String.fromCharCode( event.which );
var valAfterKeypress = val.slice( 0, caretInfo.start ) + typedChar + val.slice( caretInfo.end );
update.call( this, valAfterKeypress );
return true;
})
.bind( "update.autogrow", function(){ update.apply(this); } )
.bind( "remove.autogrow", function() {
shadow.remove();
} );
update.apply(this);
});
return this;
};
// comes from https://github.com/madapaja/jquery.selection/blob/master/src/jquery.selection.js
var _getCaretInfo = function(element){
var res = {
text: '',
start: 0,
end: 0
};
if (!element.value) {
/* no value or empty string */
return res;
}
try {
if (window.getSelection) {
/* except IE */
res.start = element.selectionStart;
res.end = element.selectionEnd;
res.text = element.value.slice(res.start, res.end);
} else if (doc.selection) {
/* for IE */
element.focus();
var range = doc.selection.createRange(),
range2 = doc.body.createTextRange();
res.text = range.text;
try {
range2.moveToElementText(element);
range2.setEndPoint('StartToStart', range);
} catch (e) {
range2 = element.createTextRange();
range2.setEndPoint('StartToStart', range);
}
res.start = element.value.length - range2.text.length;
res.end = res.start + range.text.length;
}
} catch (e) {
/* give up */
}
return res;
};
var entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;',
" ": '&nbsp;'
};
function escapeHtml(string) {
return String(string).replace(/[&<>"'\/\ ]/g, function (s) {
return entityMap[s];
} );
}
} ) );

View File

@@ -1,4 +1,6 @@
/**
*
* mchat.collapse.js - Collapse mChat container for styles by Arty
*
* @package phpBB Extension - mChat
* @copyright (c) 2017 kasimi - https://kasimi.net
@@ -10,10 +12,10 @@ jQuery(function($) {
"use strict";
// Most code below copied from elegance/template/forum_fn.js for phpBB 3.2.1
// Most code below copied from elegance/template/forum_fn.js for phpBB 3.2.2
var $this = $('.mchat-wrapper li.header'),
forum = $this.parent().next('#mchat-body'),
var $this = $('.mchat-wrapper li.header').first(),
forum = $this.closest('.topiclist').next(),
id = 'mchat',
toggled = false,
toggle;
@@ -25,22 +27,24 @@ jQuery(function($) {
event.preventDefault();
$(mChat).trigger('mchat_collapse_toggle_before', [{collapsed: !toggle}]);
if (toggled) {
forum.stop(true, true).slideDown(200);
forum.stop(true, true).slideDown(200, function() {
$(mChat).trigger('mchat_collapse_toggle_after', [{collapsed: toggle}]);
});
toggled = false;
toggle.removeClass('toggled');
phpbb.deleteCookie('toggled-' + id, styleConfig.cookieConfig);
$(mChat).trigger('mchat_collapse_toggle_after', [{collapsed: toggle}]);
return;
}
forum.stop(true, true).slideUp(200);
forum.stop(true, true).slideUp(200, function() {
$(mChat).trigger('mchat_collapse_toggle_after', [{collapsed: toggle}]);
});
toggled = true;
toggle.addClass('toggled');
phpbb.setCookie('toggled-' + id, '1', styleConfig.cookieConfig);
$(mChat).trigger('mchat_collapse_toggle_after', [{collapsed: toggle}]);
});
// Check default state
if (phpbb.getCookie('toggled-' + id, styleConfig.cookieConfig) == '1') {
if (phpbb.getCookie('toggled-' + id, styleConfig.cookieConfig) === '1') {
forum.stop(true, true).slideUp(0);
toggled = true;
toggle.addClass('toggled');

View File

@@ -112,7 +112,7 @@ jQuery(function($) {
$(mChat).trigger('mchat_send_request_before', [mode, data]);
$.ajax({
url: mChat.actionUrls[mode],
timeout: Math.min(mChat.refreshTime, 10000),
timeout: Math.min(mChat.refreshTime, 10000) - 100,
type: 'POST',
dataType: 'json',
data: data,
@@ -133,7 +133,7 @@ jQuery(function($) {
};
$(mChat).trigger('mchat_ajax_done_before', [data]);
if (data.handle) {
if (json[this.mode]) {
if (json[data.mode]) {
this.deferred.resolve(data.json, data.status, data.xhr);
} else {
this.deferred.reject(data.xhr, data.status, mChat.lang.parserErr);
@@ -144,6 +144,7 @@ jQuery(function($) {
if (mChat.pageIsUnloading) {
return;
}
mChat.skipNextRefresh = true;
if (typeof console !== 'undefined' && console.log) {
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown + ' (' + xhr.responseText + ')');
}
@@ -162,24 +163,52 @@ jQuery(function($) {
};
$(mChat).trigger('mchat_ajax_fail_before', [data]);
mChat.sound('error');
mChat.cached('status-load', 'status-ok', 'status-paused').hide();
mChat.cached('status-error').show();
mChat.status('error');
var title = mChat.lang.err;
var responseText;
try {
responseText = data.xhr.responseJSON.message || data.errorThrown;
var json = data.xhr.responseJSON;
if (json.S_USER_WARNING || json.S_USER_NOTICE) {
title = json.MESSAGE_TITLE;
responseText = json.MESSAGE_TEXT;
data.xhr.status = 403;
} else {
responseText = json.message || data.errorThrown;
}
} catch (e) {
responseText = data.errorThrown;
}
if (responseText && responseText !== 'timeout') {
phpbb.alert(mChat.lang.err, responseText);
phpbb.alert(title, responseText);
}
data.updateSession();
},
registerNavItem: function(id, canEnable, onToggle) {
var isEnabled = canEnable && !mChat.storage.get('no_' + id);
var classEnabled = 'mchat-nav-item-enabled';
var classDisabled = 'mchat-nav-item-disabled';
mChat.cached(id).toggleClass(classEnabled, isEnabled).toggleClass(classDisabled, !isEnabled);
if (typeof onToggle === 'function') {
onToggle(isEnabled);
}
mChat['toggle_' + id] = function(e) {
e.preventDefault();
var hasClass = mChat.cached(id).toggleClass(classEnabled + ' ' + classDisabled).hasClass(classEnabled);
if (hasClass) {
mChat.storage.remove('no_' + id);
} else {
mChat.storage.set('no_' + id, 'yes');
}
if (typeof onToggle === 'function') {
onToggle(hasClass);
}
};
},
sound: function(file) {
var data = {
audio: mChat.cached('sound-' + file).get(0),
file: file,
play: !mChat.pageIsUnloading && mChat.cached('user-sound').is(':checked')
play: !mChat.pageIsUnloading && mChat.cached('sound').hasClass('mchat-nav-item-enabled')
};
$(mChat).trigger('mchat_sound_before', [data]);
if (data.play && data.audio && data.audio.duration) {
@@ -198,7 +227,8 @@ jQuery(function($) {
$.titleAlert(mChat.lang.newMessageAlert, data);
}
},
toggle: function(name) {
toggle: function() {
var name = $(this).data('mchat-element');
var $elem = mChat.cached(name);
$elem.stop().slideToggle(200, function() {
if ($elem.is(':visible')) {
@@ -229,36 +259,35 @@ jQuery(function($) {
});
},
add: function() {
if (mChat.cached('add').prop('disabled')) {
var $add = mChat.cached('add');
if ($add.prop('disabled')) {
return;
}
var messageLength = mChat.cached('input').val().length;
var $input = mChat.cached('input');
var originalInputValue = mChat.cleanMessage($input.val()).trim();
var messageLength = originalInputValue.length;
if (!messageLength) {
phpbb.alert(mChat.lang.err, mChat.lang.noMessageInput);
return;
}
if (mChat.mssgLngth && messageLength > mChat.mssgLngth) {
phpbb.alert(mChat.lang.err, mChat.lang.mssgLngthLong);
return;
}
mChat.cached('add').prop('disabled', true);
$add.prop('disabled', true);
mChat.pauseSession();
var originalInputValue = mChat.cached('input').val();
var inputValue = originalInputValue;
var color = mChat.storage.get('color');
if (color && inputValue.indexOf('[color=') === -1) {
inputValue = '[color=#' + color + '] ' + inputValue + ' [/color]';
}
mChat.cached('input').val('').trigger('update.autogrow').focus();
mChat.setText('');
mChat.refresh(inputValue).done(function() {
mChat.resetSession();
}).fail(function() {
mChat.cached('input').val(originalInputValue).trigger('update.autogrow');
mChat.setText(originalInputValue);
}).always(function() {
mChat.cached('add').prop('disabled', false);
setTimeout(function() {
mChat.cached('input').focus();
}, 1);
$add.prop('disabled', false);
$input.delay(1).focus();
});
},
edit: function() {
@@ -276,13 +305,14 @@ jQuery(function($) {
message_id: $message.data('mchat-id'),
message: $textarea.val(),
page: mChat.page
}).done(function(json) {
mChat.updateMessages($(json.edit));
mChat.resetSession();
});
}).done(mChat.editDone);
}
});
},
editDone: function(json) {
mChat.updateMessages($(json.edit));
mChat.resetSession();
},
del: function() {
var delId = $(this).closest('.mchat-message').data('mchat-id');
mChat.confirm({
@@ -295,60 +325,68 @@ jQuery(function($) {
confirm: function() {
mChat.ajaxRequest('del', true, {
message_id: delId
}).done(function() {
mChat.removeMessages([delId]);
mChat.resetSession();
});
}).done(mChat.delDone);
}
});
},
delDone: function(json) {
mChat.removeMessages([json.del]);
mChat.resetSession();
},
refresh: function(message) {
if (mChat.isPaused && !message) {
return false;
var isAdd = typeof message !== 'undefined';
if (!isAdd) {
mChat.sessionLength += mChat.refreshTime;
if (mChat.timeout && mChat.sessionLength >= mChat.timeout) {
mChat.endSession();
return;
} else if (mChat.skipNextRefresh) {
mChat.skipNextRefresh = false;
return;
}
}
var data = {
last: mChat.messageIds.length ? mChat.messageIds.max() : 0
last: mChat.messageIds.length ? mChat.messageIds.max() : 0,
log: mChat.liveUpdates ? mChat.logId : undefined,
message: isAdd ? message : undefined
};
if (message) {
data.message = message;
mChat.status('load');
return mChat.ajaxRequest(isAdd ? 'add' : 'refresh', isAdd, data).done(mChat.refreshDone);
},
refreshDone: function(json) {
$(mChat).trigger('mchat_response_handle_data_before', [json]);
if (json.add) {
mChat.addMessages($(json.add));
}
if (mChat.liveUpdates) {
data.log = mChat.logId;
if (json.edit) {
mChat.updateMessages($(json.edit));
}
mChat.cached('status-ok', 'status-error', 'status-paused').hide();
mChat.cached('status-load').show();
return mChat.ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) {
$(mChat).trigger('mchat_response_handle_data_before', [json]);
if (json.add) {
mChat.addMessages($(json.add));
}
if (json.edit) {
mChat.updateMessages($(json.edit));
}
if (json.del) {
mChat.removeMessages(json.del);
}
if (json.whois) {
mChat.handleWhoisResponse(json);
}
if (json.log) {
mChat.logId = json.log;
}
if (mChat.refreshInterval) {
mChat.cached('status-load', 'status-error', 'status-paused').hide();
mChat.cached('status-ok').show();
}
$(mChat).trigger('mchat_response_handle_data_after', [json]);
});
if (json.del) {
mChat.removeMessages(json.del);
}
if (json.whois) {
mChat.whoisDone(json);
}
if (json.log) {
mChat.logId = json.log;
}
if (mChat.refreshInterval) {
mChat.status('ok');
}
$(mChat).trigger('mchat_response_handle_data_after', [json]);
},
rules: function() {
$('.mchat-nav-link-title').each(phpbb.toggleDropdown);
popup(this.href, 450, 275);
},
whois: function() {
if (mChat.page === 'custom') {
mChat.cached('refresh-pending').show();
mChat.cached('refresh-explain').hide();
}
mChat.ajaxRequest('whois', false, {}).done(mChat.handleWhoisResponse);
mChat.ajaxRequest('whois', false, {}).done(mChat.whoisDone);
},
handleWhoisResponse: function(json) {
whoisDone: function(json) {
var $whois = $(json.container);
var $userlist = $whois.find('#mchat-userlist');
if (mChat.storage.get('show_userlist')) {
@@ -413,12 +451,13 @@ jQuery(function($) {
if (mChat.messageTop) {
container.animate({scrollTop: 0}, animateOptions);
} else {
(animateOptions.complete = function() {
animateOptions.complete = function() {
var scrollHeight = container.get(0).scrollHeight;
if (container.scrollTop() + container.height() < scrollHeight) {
container.animate({scrollTop: scrollHeight}, animateOptions);
}
})();
};
animateOptions.complete();
}
} else {
this.message.show();
@@ -515,81 +554,69 @@ jQuery(function($) {
var selector = '.mchat-time[data-mchat-relative-update]';
clearInterval($message.find(selector).addBack(selector).data('mchat-relative-interval'));
},
timeLeftRegex: /\d\d:(\d\d:\d\d)/,
timeLeft: function(sessionTime) {
return (new Date(sessionTime * 1000)).toUTCString().match(mChat.timeLeftRegex)[mChat.timeout >= 3600000 ? 0 : 1];
},
countDown: function() {
mChat.sessionTime -= 1;
mChat.cached('session').html(mChat.lang.sessEnds.format({timeleft: mChat.timeLeft(mChat.sessionTime)}));
if (mChat.sessionTime < 1) {
mChat.endSession();
status: function(status) {
var data = {
status: status,
container: mChat.cached('status')
};
$(mChat).trigger('mchat_status_before', [data]);
var $activeStatus = data.container.find('.mchat-status-' + data.status).removeClass('hidden');
if ($activeStatus.length) {
data.container.find('.mchat-status').not($activeStatus).addClass('hidden');
}
},
pauseSession: function() {
clearInterval(mChat.refreshInterval);
if (mChat.timeout) {
clearInterval(mChat.sessionCountdown);
}
mChat.refreshInterval = false;
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
mChat.whoisInterval = false;
}
},
resetSession: function() {
if (mChat.page !== 'archive') {
clearInterval(mChat.refreshInterval);
mChat.refreshInterval = setInterval(mChat.refresh, mChat.refreshTime);
if (mChat.timeout) {
mChat.sessionTime = mChat.timeout / 1000;
clearInterval(mChat.sessionCountdown);
mChat.cached('session').html(mChat.lang.sessEnds.format({timeleft: mChat.timeLeft(mChat.sessionTime)}));
mChat.sessionCountdown = setInterval(mChat.countDown, 1000);
}
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
mChat.whoisInterval = setInterval(mChat.whois, mChat.whoisRefresh);
}
mChat.cached('status-ok').show();
mChat.cached('status-load', 'status-error', 'status-paused').hide();
mChat.cached('refresh-text').html(mChat.lang.refreshYes);
if (mChat.page === 'archive') {
return;
}
mChat.pauseSession();
mChat.sessionLength = 0;
mChat.refreshInterval = setInterval(mChat.refresh, mChat.refreshTime);
if (mChat.whoisRefresh) {
mChat.whoisInterval = setInterval(mChat.whois, mChat.whoisRefresh);
}
mChat.status('ok');
},
endSession: function(skipUpdateWhois) {
clearInterval(mChat.refreshInterval);
mChat.refreshInterval = false;
if (mChat.timeout) {
clearInterval(mChat.sessionCountdown);
mChat.cached('session').html(mChat.lang.sessOut);
mChat.pauseSession();
if (mChat.whoisRefresh && !skipUpdateWhois) {
mChat.whois();
}
if (mChat.whoisRefresh) {
clearInterval(mChat.whoisInterval);
if (!skipUpdateWhois) {
mChat.whois();
}
}
mChat.cached('status-load', 'status-ok', 'status-error').hide();
mChat.cached('status-paused').show();
mChat.cached('refresh-text').html(mChat.lang.refreshNo);
},
pauseStart: function() {
mChat.isPaused = true;
mChat.cached('refresh-text').html(mChat.lang.refreshNo);
mChat.cached('status-load', 'status-ok', 'status-error').hide();
mChat.cached('status-paused').show();
},
pauseEnd: function() {
mChat.cached('refresh-text').html(mChat.lang.refreshYes);
mChat.cached('status-load', 'status-error', 'status-paused').hide();
mChat.cached('status-ok').show();
mChat.isPaused = false;
mChat.status('paused');
},
updateCharCount: function() {
var count = mChat.cached('input').val().length;
var charCount = mChat.lang.charCount.format({current: count, max: mChat.mssgLngth});
var $elem = mChat.cached('character-count').html(charCount).toggleClass('invisible', count === 0);
if (mChat.mssgLngth) {
$elem.toggleClass('error', count > mChat.mssgLngth);
var count = mChat.cleanMessage(mChat.cached('input').val()).length;
var exceedCount = Math.max(mChat.mssgLngth - count, -999);
if (mChat.showCharCount) {
var charCount = mChat.lang.charCount.format({current: count, max: mChat.mssgLngth});
var $elem = mChat.cached('character-count').html(charCount).toggleClass('invisible', count === 0);
if (mChat.mssgLngth) {
$elem.toggleClass('error', count > mChat.mssgLngth);
}
}
mChat.cached('exceed-character-count').text(exceedCount).toggleClass('hidden', exceedCount >= 0);
mChat.cached('input').parent().toggleClass('mchat-input-error', exceedCount < 0);
mChat.cached('add').toggleClass('hidden', exceedCount < 0);
},
cleanMessage: function(message) {
if (!mChat.maxInputHeight) {
message = message.replace(/\s+/g, ' ');
}
return message;
},
smiley: function() {
mChat.appendText($(this).data('smiley-code'), true);
},
smileyPopup: function() {
popup(this.href, 300, 350, '_phpbbsmilies');
},
mention: function() {
var $container = $(this).closest('.mchat-message');
@@ -605,38 +632,55 @@ jQuery(function($) {
}
}
}
insert_text(mChat.lang.mention.format({username: username}));
mChat.appendText(mChat.lang.mention.format({username: username}));
},
quote: function() {
var $container = $(this).closest('.mchat-message');
var username = $container.data('mchat-username');
var quote = $container.data('mchat-message');
insert_text('[quote="' + username + '"] ' + quote + '[/quote]');
mChat.cached('input').trigger('update.autogrow');
mChat.appendText('[quote="' + username + '"] ' + quote + '[/quote]');
},
like: function() {
var $container = $(this).closest('.mchat-message');
var username = $container.data('mchat-username');
var quote = $container.data('mchat-message');
insert_text('[i]' + mChat.lang.likes + '[/i][quote="' + username + '"] ' + quote + '[/quote]');
mChat.cached('input').trigger('update.autogrow');
mChat.appendText('[i]' + mChat.lang.likes + '[/i][quote="' + username + '"] ' + quote + '[/quote]');
},
ip: function() {
popup(this.href, 750, 500);
},
cached: function() {
return $($.map(arguments, function(name) {
if (!mChat.cache[name]) {
mChat.cache[name] = $('#mchat-' + name);
}
return mChat.cache[name];
})).map(function() {
return this.toArray();
});
custom: function() {
window.location.href = this.href;
},
archive: function() {
window.location.href = this.href;
},
setText: function(text) {
mChat.cached('input').val('');
mChat.appendText(text);
},
appendText: function(text, spaces, popup) {
var $input = mChat.cached('input');
if (text) {
insert_text(text, spaces, popup);
}
if (mChat.maxInputHeight) {
autosize.update($input);
} else {
$input.scrollLeft($input[0].scrollWidth - $input[0].clientWidth);
}
},
cached: function(name) {
if (!mChat.cache) {
mChat.cache = {};
}
if (!mChat.cache.hasOwnProperty(name)) {
mChat.cache[name] = $('#mchat-' + name);
}
return mChat.cache[name];
}
});
mChat.cache = {};
mChat.messageIds = mChat.cached('messages').children().map(function() {
return $(this).data('mchat-id');
}).get();
@@ -646,25 +690,13 @@ jQuery(function($) {
mChat.hiddenFields[this.name] = this.value;
});
mChat.isPaused = false;
if (mChat.page !== 'archive') {
mChat.resetSession();
if (!mChat.messageTop) {
setTimeout(function() {
mChat.cached('messages').scrollTop(mChat.cached('messages')[0].scrollHeight);
}, 1);
mChat.cached('messages').delay(1).scrollTop(mChat.cached('messages')[0].scrollHeight);
}
mChat.cached('user-sound').prop('checked', mChat.playSound && !mChat.storage.get('no_sound')).change(function() {
if (this.checked) {
mChat.storage.remove('no_sound');
} else {
mChat.storage.set('no_sound', 'yes');
}
});
$.each(mChat.removeBBCodes.split('|'), function(i, bbcode) {
var bbCodeClass = '.bbcode-' + bbcode.replaceMany({
'=': '-',
@@ -673,87 +705,88 @@ jQuery(function($) {
mChat.cached('body').find(bbCodeClass).remove();
});
var $colourPalette = $('#colour_palette');
var $colourPalette = $('#mchat-bbcodes').find('#colour_palette');
$colourPalette.appendTo($colourPalette.parent()).wrap('<div id="mchat-colour"></div>').show();
$('#bbpalette,#abbc3_bbpalette,#color_wheel').prop('onclick', null).attr('data-mchat-toggle', 'colour');
$('#bbpalette,#abbc3_bbpalette,#color_wheel').prop('onclick', null).attr({
'data-mchat-action': 'toggle',
'data-mchat-element': 'colour'
});
$.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();
}
});
mChat.isTextarea = mChat.cached('input').is('textarea');
mChat.cached('form').submit(function(e){
e.preventDefault();
}).keypress(function(e) {
if ((e.which === 10 || e.which === 13) && (!mChat.isTextarea || e.ctrlKey || e.metaKey) && mChat.cached('input').is(e.target)) {
mChat.add();
mChat.cached('colour').find('.colour-palette').on('click', 'a', function(e) {
if (e.ctrlKey || e.metaKey) {
e.preventDefault();
e.stopImmediatePropagation();
var $this = $(this);
var newColor = $this.data('color');
if (mChat.storage.get('color') === newColor) {
mChat.storage.remove('color');
} else {
mChat.storage.set('color', newColor);
mChat.cached('colour').find('.colour-palette a').removeClass('remember-color');
}
$this.toggleClass('remember-color');
}
});
if (mChat.pause) {
mChat.cached('form').on('input', function() {
if (mChat.refreshInterval !== false) {
var val = mChat.cached('input').val();
if (mChat.isPaused && val === '') {
mChat.pauseEnd();
} else if (!mChat.isPaused && val !== '') {
mChat.pauseStart();
}
}
var color = mChat.storage.get('color');
if (color) {
mChat.cached('colour').find('.colour-palette a[data-color="' + color + '"]').addClass('remember-color');
}
if (mChat.maxInputHeight) {
mChat.cached('input').one('focus', function() {
autosize(this);
});
}
if (mChat.showCharCount) {
mChat.cached('form').submit(function(e) {
e.preventDefault();
}).keypress(function(e) {
if ((e.which === 10 || e.which === 13) && mChat.cached('input').is(e.target)) {
var isCtrl = e.ctrlKey || e.metaKey;
if (!mChat.maxInputHeight || !isCtrl === !mChat.storage.get('no_enter')) {
e.preventDefault();
mChat.add();
} else if (mChat.maxInputHeight && isCtrl) {
mChat.appendText('\n');
}
}
});
if (mChat.showCharCount || mChat.mssgLngth) {
mChat.cached('form').on('input', mChat.updateCharCount);
mChat.cached('input').on('focus', function() {
setTimeout(function() {
mChat.updateCharCount();
}, 1);
setTimeout(mChat.updateCharCount, 1);
});
}
mChat.cached('input').autogrow({
vertical: false,
horizontal: true
});
}
mChat.startRelativeTimeUpdate(mChat.cached('messages'));
mChat.registerNavItem('sound', mChat.playSound);
if (mChat.maxInputHeight) {
mChat.registerNavItem('enter', true);
}
$(window).on('beforeunload', function() {
mChat.pageIsUnloading = true;
});
mChat.cached('colour').find('.colour-palette').on('click', 'a', function(e) {
if (e.ctrlKey || e.metaKey) {
e.preventDefault();
e.stopImmediatePropagation();
var $this = $(this);
var newColor = $this.data('color');
if (mChat.storage.get('color') === newColor) {
mChat.storage.remove('color');
} else {
mChat.storage.set('color', newColor);
mChat.cached('colour').find('.colour-palette a').removeClass('remember-color');
}
$this.toggleClass('remember-color');
}
});
var color = mChat.storage.get('color');
if (color) {
mChat.cached('colour').find('.colour-palette a[data-color="' + color + '"]').addClass('remember-color');
}
$('#phpbb').on('click', '[data-mchat-action]', function(e) {
e.preventDefault();
var action = $(this).data('mchat-action');
mChat[action].call(this);
}).on('click', '[data-mchat-toggle]', function(e) {
e.preventDefault();
var elem = $(this).data('mchat-toggle');
mChat.toggle(elem);
mChat[action].call(this, e);
}).on('click', '.mchat-panel-buttons button', function() {
var $this = $(this).blur();
if ($this.hasClass('mchat-button-down')) {
$this.toggleClass('mchat-button-is-down');
}
});
});

View File

@@ -1,13 +1,13 @@
{% if MCHAT_PAGE == 'archive' or not (MCHAT_ALLOW_USE and S_BBCODE_ALLOWED) %}
{% INCLUDEJS T_ASSETS_PATH ~ '/javascript/editor.js' %}
{% endif %}
{% INCLUDEJS '@dmzx_mchat/javascript/jquery.autogrow-textarea.js' %}
{% if MCHAT_MAX_INPUT_HEIGHT %}
{% INCLUDEJS '@dmzx_mchat/javascript/autosize.min.js' %}
{% endif %}
{% INCLUDEJS '@dmzx_mchat/javascript/jquery.titlealert.min.js' %}
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.js' %}
<script type="text/javascript">
// <![CDATA[
<script>
var form_name = 'postform';
var text_name = 'message';
var mChat = {
@@ -19,7 +19,6 @@
},
page : '{{ MCHAT_PAGE | escape('js') }}',
cookie : '{{ COOKIE_NAME | escape('js') }}',
pause : {{ MCHAT_PAUSE_ON_INPUT ? 'true' : 'false' }},
playSound : {{ MCHAT_SOUND ? 'true' : 'false' }},
messageTop : {{ MCHAT_MESSAGE_TOP ? 'true' : 'false' }},
allowBBCodes : {{ S_BBCODE_ALLOWED ? 'true' : 'false' }},
@@ -31,7 +30,8 @@
refreshTime : {{ MCHAT_REFRESH_JS }},
whoisRefresh : {{ MCHAT_WHOIS_REFRESH }},
timeout : {{ MCHAT_TIMEOUT }},
mssgLngth : {{ MCHAT_MESSAGE_LNGTH }},
mssgLngth : {{ MCHAT_MAX_MESSAGE_LENGTH }},
maxInputHeight : {{ MCHAT_MAX_INPUT_HEIGHT }},
editDeleteLimit : {{ MCHAT_EDIT_DELETE_LIMIT }},
logId : {{ MCHAT_LOG_ID }},
removeBBCodes : '{{ MCHAT_DISALLOWED_BBCODES | escape('js') }}',
@@ -48,18 +48,12 @@
err : '{{ lang('ERROR') | escape('js') }}',
parserErr : '{{ lang('AJAX_ERROR_TEXT_PARSERERROR') | escape('js') }}',
newMessageAlert : '{{ lang('MCHAT_NEW_CHAT') | escape('js') }}',
noMessageInput : '{{ lang('MCHAT_NOMESSAGEINPUT') | escape('js') }}',
editInfo : '{{ lang('MCHAT_EDITINFO') | escape('js') }}',
delConfirm : '{{ lang('MCHAT_DELCONFIRM') | escape('js') }}',
sessOut : '{{ lang('MCHAT_SESSION_OUT') | escape('js') }}',
sessEnds : '{{ lang('MCHAT_SESSION_ENDS_JS') | escape('js') }}',
mention : '{{ lang('MCHAT_MENTION') | escape('js') }}',
refreshYes : '{{ lang('MCHAT_REFRESH_YES', MCHAT_REFRESH_RATE) | escape('js') }}',
refreshNo : '{{ lang('MCHAT_REFRESH_NO') | escape('js') }}',
charCount : '{{ lang(MCHAT_MESSAGE_LNGTH ? 'MCHAT_CHARACTER_COUNT_LIMIT' : 'MCHAT_CHARACTER_COUNT') | escape('js') }}',
charCount : '{{ lang(MCHAT_MAX_MESSAGE_LENGTH ? 'MCHAT_CHARACTER_COUNT_LIMIT' : 'MCHAT_CHARACTER_COUNT') | escape('js') }}',
mssgLngthLong : '{{ lang('MCHAT_MESS_LONG', MCHAT_MAX_MESSAGE_LENGTH) | escape('js') }}',
likes : '{{ lang('MCHAT_LIKES') | escape('js') }}'
}
};
// ]]>
</script>

View File

@@ -0,0 +1,2 @@
{% INCLUDECSS '@dmzx_mchat/mchat.arty.css' %}
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.collapse.arty.js' %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="tab mchat" data-select-match="mchat" data-responsive-class="tab small-icon icon-mchat"><a class="nav-link" href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link mchat-nav-link-title" role="menuitem">{{ MCHAT_TITLE }}</a></li>

View File

@@ -1,77 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.icon-mchat {
position: relative;
}
.icon-mchat:after {
content: '\f086';
font-family: 'FontAwesome';
width: 18px;
text-align: center;
position: absolute;
top: 50%;
left: 0;
height: 14px;
margin-top: -7px;
font-size: 12px;
line-height: 14px;
vertical-align: baseline;
font-weight: normal;
font-style: normal;
text-transform: none;
text-indent: 0;
pointer-events: none;
}
.navbar .nav-tabs .mchat .nav-link {
position: relative;
text-indent: 999px;
width: 15px;
padding: 0 8px;
overflow: hidden;
}
.navbar .nav-tabs .mchat .nav-link:after {
content: '\f086';
font-family: 'FontAwesome';
position: absolute;
top: 50%;
margin-top: -7.5px;
width: 15px;
line-height: 15px;
height: 15px;
font-weight: normal;
font-style: normal;
text-indent: 0;
text-align: center;
font-size: 15px;
left:8px
}
.rtl .navbar .nav-tabs .mchat .nav-link {
padding-left: 12px;
padding-right: 30px;
}
.rtl .navbar .nav-tabs .mchat .nav-link:after {
left: auto;
right: 8px;
}
li.mchat-message:first-child {
border-top-width: 1px;
padding-top: 5px;
}
li.mchat-message:last-child {
border-bottom-width: 1px;
padding-bottom: 5px;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -0,0 +1 @@
{% INCLUDECSS '@dmzx_mchat/mchat.arty.css' %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="tab mchat" data-select-match="mchat" data-responsive-class="tab small-icon icon-mchat"><a class="nav-link" href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link mchat-nav-link-title" role="menuitem">{{ MCHAT_TITLE }}</a></li>

View File

@@ -1,67 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.icon-mchat {
position: relative;
}
.icon-mchat:after {
content: '\f086';
font-family: 'FontAwesome';
width: 18px;
text-align: center;
position: absolute;
top: 50%;
left: 0;
height: 14px;
margin-top: -7px;
font-size: 12px;
line-height: 14px;
vertical-align: baseline;
font-weight: normal;
font-style: normal;
text-transform: none;
text-indent: 0;
pointer-events: none;
}
.navbar .nav-tabs .mchat .nav-link {
position: relative;
text-indent: 999px;
width: 15px;
padding: 0 8px;
overflow: hidden;
}
.navbar .nav-tabs .mchat .nav-link:after {
content: '\f086';
font-family: 'FontAwesome';
position: absolute;
top: 50%;
margin-top: -7.5px;
width: 15px;
line-height: 15px;
height: 15px;
font-weight: normal;
font-style: normal;
text-indent: 0;
text-align: center;
font-size: 15px;
left:8px
}
.rtl .navbar .nav-tabs .mchat .nav-link {
padding-left: 12px;
padding-right: 30px;
}
.rtl .navbar .nav-tabs .mchat .nav-link:after {
left: auto;
right: 8px;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1,3 +0,0 @@
{% if MCHAT_INDEX and MCHAT_LOCATION %}
{% INCLUDE '@dmzx_mchat/mchat_body.html' %}
{% endif %}

View File

@@ -1 +0,0 @@
<!-- Leave empty -->

View File

@@ -1,3 +0,0 @@
{% if MCHAT_ALLOW_USE %}
<script>$.sceditor = false;</script>
{% endif %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1,40 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
ul#mchat-messages.topiclist li {
padding: 0;
}
.mchat-text {
font-size: 1.1em;
}
ul.mchat-buttons > li {
background: none !important;
}
#mchat-panel.cp-mini .button2 {
float: none;
}
#mchat-panel #st_editor_buttons {
display: block !important;
}
.mchat-footer label {
padding-left: 3px;
}
@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
#mchat-body {
overflow: auto;
}
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -0,0 +1,2 @@
{% INCLUDECSS '@dmzx_mchat/mchat.arty.css' %}
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.collapse.arty.js' %}

View File

@@ -1 +1,2 @@
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.collapse.js' %}
{% INCLUDECSS '@dmzx_mchat/mchat.arty.css' %}
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.collapse.arty.js' %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="tab mchat" data-select-match="mchat" data-responsive-class="tab small-icon icon-mchat"><a class="nav-link" href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link mchat-nav-link-title" role="menuitem">{{ MCHAT_TITLE }}</a></li>

View File

@@ -1,67 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.icon-mchat {
position: relative;
}
.icon-mchat:after {
content: '\f086';
font-family: 'FontAwesome';
width: 18px;
text-align: center;
position: absolute;
top: 50%;
left: 0;
height: 14px;
margin-top: -7px;
font-size: 12px;
line-height: 14px;
vertical-align: baseline;
font-weight: normal;
font-style: normal;
text-transform: none;
text-indent: 0;
pointer-events: none;
}
.navbar .nav-tabs .mchat .nav-link {
position: relative;
text-indent: 999px;
width: 15px;
padding: 0 8px;
overflow: hidden;
}
.navbar .nav-tabs .mchat .nav-link:after {
content: '\f086';
font-family: 'FontAwesome';
position: absolute;
top: 50%;
margin-top: -7.5px;
width: 15px;
line-height: 15px;
height: 15px;
font-weight: normal;
font-style: normal;
text-indent: 0;
text-align: center;
font-size: 15px;
left:8px
}
.rtl .navbar .nav-tabs .mchat .nav-link {
padding-left: 12px;
padding-right: 30px;
}
.rtl .navbar .nav-tabs .mchat .nav-link:after {
left: auto;
right: 8px;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -0,0 +1,2 @@
{% INCLUDECSS '@dmzx_mchat/mchat.arty.css' %}
{% INCLUDEJS '@dmzx_mchat/javascript/mchat.collapse.arty.js' %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="tab mchat" data-select-match="mchat" data-responsive-class="tab small-icon icon-mchat"><a class="nav-link" href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link mchat-nav-link-title" role="menuitem">{{ MCHAT_TITLE }}</a></li>

View File

@@ -1,67 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.icon-mchat {
position: relative;
}
.icon-mchat:after {
content: '\f086';
font-family: 'FontAwesome';
width: 18px;
text-align: center;
position: absolute;
top: 50%;
left: 0;
height: 14px;
margin-top: -7px;
font-size: 12px;
line-height: 14px;
vertical-align: baseline;
font-weight: normal;
font-style: normal;
text-transform: none;
text-indent: 0;
pointer-events: none;
}
.navbar .nav-tabs .mchat .nav-link {
position: relative;
text-indent: 999px;
width: 15px;
padding: 0 8px;
overflow: hidden;
}
.navbar .nav-tabs .mchat .nav-link:after {
content: '\f086';
font-family: 'FontAwesome';
position: absolute;
top: 50%;
margin-top: -7.5px;
width: 15px;
line-height: 15px;
height: 15px;
font-weight: normal;
font-style: normal;
text-indent: 0;
text-align: center;
font-size: 15px;
left:8px
}
.rtl .navbar .nav-tabs .mchat .nav-link {
padding-left: 12px;
padding-right: 30px;
}
.rtl .navbar .nav-tabs .mchat .nav-link:after {
left: auto;
right: 8px;
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

View File

@@ -1 +0,0 @@
<li class="small-icon icon-mchat" data-last-responsive="true"><a href="{{ U_MCHAT }}" title="{{ MCHAT_TITLE_HINT }}" class="mchat-nav-link-title" role="menuitem"><span class="mchat-nav-link">{{ MCHAT_TITLE }}</span></a></li>

View File

@@ -1 +0,0 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="-1100 -600 4000 4000"><path fill="#fff" d="M1408 768q0 139-94 257t-256.5 186.5-353.5 68.5q-86 0-176-16-124 88-278 128-36 9-86 16h-3q-11 0-20.5-8t-11.5-21q-1-3-1-6.5t.5-6.5 2-6l2.5-5 3.5-5.5 4-5 4.5-5 4-4.5q5-6 23-25t26-29.5 22.5-29 25-38.5 20.5-44q-124-72-195-177t-71-224q0-139 94-257t256.5-186.5 353.5-68.5 353.5 68.5 256.5 186.5 94 257zm384 256q0 120-71 224.5t-195 176.5q10 24 20.5 44t25 38.5 22.5 29 26 29.5 23 25q1 1 4 4.5t4.5 5 4 5 3.5 5.5l2.5 5 2 6 .5 6.5-1 6.5q-3 14-13 22t-22 7q-50-7-86-16-154-40-278-128-90 16-176 16-271 0-472-132 58 4 88 4 161 0 309-45t264-129q125-92 192-212t67-254q0-77-23-152 129 71 204 178t75 230z"/></svg>

Before

Width:  |  Height:  |  Size: 725 B

View File

@@ -1,12 +0,0 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.page-header-metro .navbar .nav-main-metro-tabs li.icon-mchat > a {
background-image: url("./images/tab-icon-mchat.svg");
}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1 +0,0 @@
{% DEFINE MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE %}

View File

@@ -1,3 +0,0 @@
{% if MCHAT_INDEX and MCHAT_LOCATION %}
{% INCLUDE '@dmzx_mchat/mchat_body.html' %}
{% endif %}

View File

@@ -1 +0,0 @@
<!-- Leave empty -->

View File

@@ -1,2 +0,0 @@
{% INCLUDECSS '@dmzx_mchat/mchat.css' %}
{% INCLUDECSS '@dmzx_mchat/mchat_custom.css' %}

Some files were not shown because too many files have changed in this diff Show More