Skip to content

Commit

Permalink
Check if message reparser has finished
Browse files Browse the repository at this point in the history
  • Loading branch information
kasimi committed Jul 10, 2020
1 parent fdaa43b commit fc6ed9e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adm/style/acp_mchat_globalsettings.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<h1>{{ lang('MCHAT_TITLE') }}</h1>

{{ lang('MCHAT_VERSION') ~ lang('COLON') }} <em>{{ MCHAT_VERSION }}</em>
{{ lang('MCHAT_VERSION') ~ lang('COLON') }} <em>{{ MCHAT_VERSION }}</em> | <span>{{ lang('MCHAT_REPARSER_STATUS') ~ lang('COLON') }} <span{{ S_REPARSER_ACTIVE ? ' class="errorbox"' }}>{{ lang(S_REPARSER_ACTIVE ? 'MCHAT_REPARSER_ACTIVE' : 'MCHAT_REPARSER_FINISHED') }}</span></span> <a href="https://www.phpbb.com/customise/db/extension/mchat_extension/faq/3311" title="{{ lang('MCHAT_REPARSER_STATUS') }}"><i class="icon fa-question-circle-o fa-fw" aria-hidden="true"></i></a>

{% if MCHAT_ERROR %}
<div class="errorbox">
Expand Down
1 change: 1 addition & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- '@user'
- '@language'
- '@dbal.conn'
- '@config_text'
- '@cache.driver'
- '@request'
- '@dispatcher'
Expand Down
31 changes: 31 additions & 0 deletions controller/acp_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use dmzx\mchat\core\functions;
use dmzx\mchat\core\settings;
use phpbb\cache\driver\driver_interface as cache_interface;
use phpbb\config\db_text as config_text;
use phpbb\db\driver\driver_interface as db_interface;
use phpbb\event\dispatcher_interface;
use phpbb\language\language;
Expand Down Expand Up @@ -42,6 +43,9 @@ class acp_controller
/** @var db_interface */
protected $db;

/** @var config_text */
protected $config_text;

/** @var cache_interface */
protected $cache;

Expand All @@ -63,6 +67,7 @@ class acp_controller
* @param user $user
* @param language $lang
* @param db_interface $db
* @param config_text $config_text
* @param cache_interface $cache
* @param request_interface $request
* @param dispatcher_interface $dispatcher
Expand All @@ -75,6 +80,7 @@ functions $mchat_functions,
user $user,
language $lang,
db_interface $db,
config_text $config_text,
cache_interface $cache,
request_interface $request,
dispatcher_interface $dispatcher,
Expand All @@ -87,6 +93,7 @@ functions $mchat_functions,
$this->user = $user;
$this->lang = $lang;
$this->db = $db;
$this->config_text = $config_text;
$this->cache = $cache;
$this->request = $request;
$this->dispatcher = $dispatcher;
Expand Down Expand Up @@ -216,6 +223,7 @@ public function globalsettings($u_action)
'S_MCHAT_PRUNE_MODE_OPTIONS' => $this->get_prune_mode_options($this->settings->cfg('mchat_prune_mode')),
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => $this->lang->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN', '<a href="' . append_sid($this->settings->url('adm/index'), ['i' => 'bbcodes']) . '">', '</a>'),
'L_MCHAT_TIMEOUT_EXPLAIN' => $this->lang->lang('MCHAT_TIMEOUT_EXPLAIN','<a href="' . append_sid($this->settings->url('adm/index'), ['i' => 'board', 'mode' => 'load']) . '">', '</a>', $this->settings->cfg('session_length')),
'S_REPARSER_ACTIVE' => $this->is_reparser_active('dmzx.mchat.text_reparser.mchat_messages'),
'U_ACTION' => $u_action,
];

Expand Down Expand Up @@ -380,4 +388,27 @@ protected function get_prune_mode_options($selected)

return $prune_mode_options;
}

/**
* @param string $reparser_name
* @return bool
*/
protected function is_reparser_active($reparser_name)
{
$reparser_resume = $this->config_text->get('reparser_resume');

if (empty($reparser_resume))
{
return false;
}

$reparser_resume = @unserialize($reparser_resume);

if (!isset($reparser_resume[$reparser_name]['range-min']) || !isset($reparser_resume[$reparser_name]['range-max']))
{
return false;
}

return $reparser_resume[$reparser_name]['range-max'] >= $reparser_resume[$reparser_name]['range-min'];
}
}
4 changes: 4 additions & 0 deletions language/en/mchat_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
'MCHAT_PURGE_CONFIRM' => 'Confirm deleting all messages',
'MCHAT_PURGED' => 'All mChat messages have been successfully deleted.',

'MCHAT_REPARSER_STATUS' => 'Message reparser status',
'MCHAT_REPARSER_ACTIVE' => 'active',
'MCHAT_REPARSER_FINISHED' => 'finished',

// '%1$s' contains 'Retain posts' and 'Delete posts' respectively
'MCHAT_RETAIN_MESSAGES' => '%1$s and retain mChat messages',
'MCHAT_DELETE_MESSAGES' => '%1$s and delete mChat messages',
Expand Down

0 comments on commit fc6ed9e

Please sign in to comment.