Version 2.0.0-RC6
This commit is contained in:
@@ -13,6 +13,9 @@ namespace dmzx\mchat\controller;
|
||||
|
||||
class acp_controller
|
||||
{
|
||||
/** @var \dmzx\mchat\core\functions */
|
||||
protected $functions;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
@@ -38,7 +41,7 @@ class acp_controller
|
||||
protected $mchat_table;
|
||||
|
||||
/** @var string */
|
||||
protected $mchat_deleted_messages_table;
|
||||
protected $mchat_log_table;
|
||||
|
||||
/** @var string */
|
||||
protected $root_path;
|
||||
@@ -49,6 +52,7 @@ class acp_controller
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\functions $functions
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\log\log_interface $log
|
||||
* @param \phpbb\user $user
|
||||
@@ -57,23 +61,24 @@ class acp_controller
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \dmzx\mchat\core\settings $settings
|
||||
* @param string $mchat_table
|
||||
* @param string $mchat_deleted_messages_table
|
||||
* @param string $mchat_log_table
|
||||
* @param string $root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, \dmzx\mchat\core\settings $settings, $mchat_table, $mchat_deleted_messages_table, $root_path, $php_ext)
|
||||
public function __construct(\dmzx\mchat\core\functions $functions, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, \dmzx\mchat\core\settings $settings, $mchat_table, $mchat_log_table, $root_path, $php_ext)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->log = $log;
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->request = $request;
|
||||
$this->settings = $settings;
|
||||
$this->mchat_table = $mchat_table;
|
||||
$this->mchat_deleted_messages_table = $mchat_deleted_messages_table;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->functions = $functions;
|
||||
$this->template = $template;
|
||||
$this->log = $log;
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->request = $request;
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,15 +92,9 @@ class acp_controller
|
||||
|
||||
$error = array();
|
||||
|
||||
if ($this->request->is_set_post('mchat_purge') && $this->request->variable('mchat_purge_confirm', false) && check_form_key('acp_mchat') && $this->user->data['user_type'] == USER_FOUNDER)
|
||||
{
|
||||
$this->db->sql_query('TRUNCATE TABLE ' . $this->mchat_table);
|
||||
$this->db->sql_query('TRUNCATE TABLE ' . $this->mchat_deleted_messages_table);
|
||||
$this->cache->destroy('sql', $this->mchat_deleted_messages_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));
|
||||
}
|
||||
else if ($this->request->is_set_post('submit'))
|
||||
$is_founder = $this->user->data['user_type'] == USER_FOUNDER;
|
||||
|
||||
if ($this->request->is_set_post('submit'))
|
||||
{
|
||||
$mchat_new_config = array();
|
||||
$validation = array();
|
||||
@@ -110,6 +109,13 @@ class acp_controller
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow changing pruning settings for non founders
|
||||
if (!$is_founder)
|
||||
{
|
||||
unset($mchat_new_config['mchat_prune']);
|
||||
unset($mchat_new_config['mchat_prune_num']);
|
||||
}
|
||||
|
||||
if (!function_exists('validate_data'))
|
||||
{
|
||||
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
@@ -140,17 +146,34 @@ class acp_controller
|
||||
$error = array_map(array($this->user, '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('TRUNCATE TABLE ' . $this->mchat_table);
|
||||
$this->db->sql_query('TRUNCATE TABLE ' . $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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys($this->settings->global) as $key)
|
||||
{
|
||||
$this->template->assign_var(strtoupper($key), $this->settings->cfg($key));
|
||||
}
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'MCHAT_ERROR' => $error ? implode('<br />', $error) : '',
|
||||
'MCHAT_ERROR' => implode('<br />', $error),
|
||||
'MCHAT_VERSION' => $this->settings->cfg('mchat_version'),
|
||||
'MCHAT_FOUNDER' => $this->user->data['user_type'] == USER_FOUNDER,
|
||||
'MCHAT_FOUNDER' => $is_founder,
|
||||
'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_USER_TIMEOUT_EXPLAIN','<a href="' . append_sid("{$this->root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->settings->cfg('session_length')),
|
||||
'L_MCHAT_TIMEOUT_EXPLAIN' => $this->user->lang('MCHAT_TIMEOUT_EXPLAIN','<a href="' . append_sid("{$this->root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->settings->cfg('session_length')),
|
||||
'U_ACTION' => $u_action,
|
||||
));
|
||||
}
|
||||
@@ -238,9 +261,9 @@ class acp_controller
|
||||
$this->template->assign_var('MCHAT_POSTS_ENABLED_LANG', $notifications_template_data);
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'MCHAT_ERROR' => $error ? implode('<br />', $error) : '',
|
||||
'MCHAT_VERSION' => $this->settings->cfg('mchat_version'),
|
||||
'U_ACTION' => $u_action,
|
||||
'MCHAT_ERROR' => implode('<br />', $error),
|
||||
'MCHAT_VERSION' => $this->settings->cfg('mchat_version'),
|
||||
'U_ACTION' => $u_action,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user