Version 0.3.3
This commit is contained in:
@@ -11,9 +11,6 @@ namespace dmzx\mchat\controller;
|
||||
|
||||
class admin_controller
|
||||
{
|
||||
/** @var \dmzx\mchat\core\functions_mchat */
|
||||
protected $functions_mchat;
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
@@ -26,9 +23,6 @@ class admin_controller
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\cache\service */
|
||||
protected $cache;
|
||||
|
||||
@@ -42,10 +36,7 @@ class admin_controller
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var string */
|
||||
protected $phpEx;
|
||||
|
||||
/** @var string */
|
||||
protected $mchat_config_table;
|
||||
protected $php_ext;
|
||||
|
||||
/** @var string */
|
||||
public $u_action;
|
||||
@@ -53,33 +44,27 @@ class admin_controller
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\functions_mchat $functions_mchat
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\log\log_interface $log
|
||||
* @param \phpbb\user $user
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\cache\service $cache
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\extension\manager $phpbb_extension_manager
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $phpEx
|
||||
* @param string $mchat_config_table
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \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, \phpbb\extension\manager $phpbb_extension_manager, $phpbb_root_path, $phpEx, $mchat_config_table)
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\cache\service $cache, \phpbb\request\request $request, \phpbb\extension\manager $phpbb_extension_manager, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->functions_mchat = $functions_mchat;
|
||||
$this->config = $config;
|
||||
$this->template = $template;
|
||||
$this->log = $log;
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->request = $request;
|
||||
$this->phpbb_extension_manager = $phpbb_extension_manager;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->mchat_config_table = $mchat_config_table;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,30 +77,40 @@ class admin_controller
|
||||
{
|
||||
add_form_key('acp_mchat');
|
||||
|
||||
$mchat_row = array(
|
||||
'location' => $this->request->variable('mchat_location', 0),
|
||||
'refresh' => $this->request->variable('mchat_refresh', 0),
|
||||
'message_limit' => $this->request->variable('mchat_message_limit', 0),
|
||||
'message_num' => $this->request->variable('mchat_message_num', 0),
|
||||
'archive_limit' => $this->request->variable('mchat_archive_limit', 0),
|
||||
'flood_time' => $this->request->variable('mchat_flood_time', 0),
|
||||
'max_message_lngth' => $this->request->variable('mchat_max_message_lngth', 0),
|
||||
'custom_page' => $this->request->variable('mchat_custom_page', 0),
|
||||
'date' => $this->request->variable('mchat_date', '', true),
|
||||
'whois' => $this->request->variable('mchat_whois', 0),
|
||||
'whois_refresh' => $this->request->variable('mchat_whois_refresh', 0),
|
||||
'bbcode_disallowed' => $this->request->variable('mchat_bbcode_disallowed', '', true),
|
||||
'prune_enable' => $this->request->variable('mchat_prune_enable', 0),
|
||||
'prune_num' => $this->request->variable('mchat_prune_num', 0),
|
||||
'index_height' => $this->request->variable('mchat_index_height', 0),
|
||||
'custom_height' => $this->request->variable('mchat_custom_height', 0),
|
||||
'static_message' => $this->request->variable('mchat_static_message', '', true),
|
||||
'override_min_post_chars' => $this->request->variable('mchat_override_min_post_chars', 0),
|
||||
'override_smilie_limit' => $this->request->variable('mchat_override_smilie_limit', 0),
|
||||
'timeout' => $this->request->variable('mchat_timeout', 0),
|
||||
'pause_on_input' => $this->request->variable('mchat_pause_on_input', 0),
|
||||
'rules' => $this->request->variable('mchat_rules', '', true),
|
||||
'avatars' => $this->request->variable('mchat_avatars', 0),
|
||||
$mchat_config = array(
|
||||
'mchat_archive_limit' => array('default' => 25, 'validation' => array('num', false, 25, 50)),
|
||||
'mchat_avatars' => array('default' => 1, 'validation' => array()),
|
||||
'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, 'validation' => array()),
|
||||
'mchat_date' => array('default' => 'D M d, Y g:i a', 'validation' => array('string', false, 0, 255)),
|
||||
'mchat_edit_delete_limit' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_flood_time' => array('default' => 0, 'validation' => array('num', false, 0, 30)),
|
||||
'mchat_index_height' => array('default' => 250, 'validation' => array('num', false, 50, 1000)),
|
||||
'mchat_live_updates' => array('default' => 1, 'validation' => array()),
|
||||
'mchat_location' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_max_message_lngth' => array('default' => 500, 'validation' => array('num', false, 0, 500)),
|
||||
'mchat_message_limit' => array('default' => 10, 'validation' => array('num', false, 10, 30)),
|
||||
'mchat_message_num' => array('default' => 10, 'validation' => array('num', false, 10, 50)),
|
||||
'mchat_message_top' => array('default' => 1, 'validation' => array()),
|
||||
'mchat_new_posts' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_new_posts_edit' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_new_posts_quote' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_new_posts_reply' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_new_posts_topic' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_on_index' => array('default' => 1, 'validation' => array()),
|
||||
'mchat_override_min_post_chars' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_override_smilie_limit' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_pause_on_input' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_prune' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_prune_num' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_refresh' => array('default' => 10, 'validation' => array('num', false, 5, 60)),
|
||||
'mchat_rules' => array('default' => '', 'validation' => array('string', false, 0, 255)),
|
||||
'mchat_static_message' => array('default' => '', 'validation' => array('string', false, 0, 255)),
|
||||
'mchat_stats_index' => array('default' => 0, 'validation' => array()),
|
||||
'mchat_timeout' => array('default' => 0, 'validation' => array('num', false, 0, (int) $this->config['session_length'])),
|
||||
'mchat_whois' => array('default' => 1, 'validation' => array()),
|
||||
'mchat_whois_refresh' => array('default' => 60, 'validation' => array('num', false, 30, 300)),
|
||||
);
|
||||
|
||||
if ($this->request->is_set_post('submit'))
|
||||
@@ -125,23 +120,18 @@ class admin_controller
|
||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
}
|
||||
|
||||
// validate the entries...most of them anyway
|
||||
$mchat_array = array(
|
||||
'static_message' => array('string', false, 0, 255),
|
||||
'index_height' => array('num', false, 50, 1000),
|
||||
'custom_height' => array('num', false, 50, 1000),
|
||||
'whois_refresh' => array('num', false, 30, 300),
|
||||
'refresh' => array('num', false, 5, 60),
|
||||
'message_limit' => array('num', false, 10, 30),
|
||||
'message_num' => array('num', false, 10, 50),
|
||||
'archive_limit' => array('num', false, 25, 50),
|
||||
'flood_time' => array('num', false, 0, 30),
|
||||
'max_message_lngth' => array('num', false, 0, 500),
|
||||
'timeout' => array('num', false, 0, (int) $this->config['session_length']),
|
||||
'rules' => array('string', false, 0, 255),
|
||||
);
|
||||
$mchat_new_config = array();
|
||||
$validation = array();
|
||||
foreach ($mchat_config as $key => $value)
|
||||
{
|
||||
$mchat_new_config[$key] = $this->request->variable($key, $value['default'], is_string($value['default']));
|
||||
if (!empty($value['validation']))
|
||||
{
|
||||
$validation[$key] = $value['validation'];
|
||||
}
|
||||
}
|
||||
|
||||
$error = validate_data($mchat_row, $mchat_array);
|
||||
$error = validate_data($mchat_new_config, $validation);
|
||||
|
||||
if (!check_form_key('acp_mchat'))
|
||||
{
|
||||
@@ -151,114 +141,53 @@ class admin_controller
|
||||
// Replace "error" strings with their real, localised form
|
||||
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang('\\1'))) ? \$this->user->lang('\\1') : '\\1'", $error);
|
||||
|
||||
if (!sizeof($error))
|
||||
if (empty($error))
|
||||
{
|
||||
foreach ($mchat_row as $config_name => $config_value)
|
||||
// Set the options the user configured
|
||||
foreach ($mchat_new_config as $config_name => $config_value)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->mchat_config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($config_value) . "'
|
||||
WHERE config_name = '" . $this->db->sql_escape($config_name) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
$this->config->set($config_name, $config_value);
|
||||
}
|
||||
|
||||
// Set the options the user configured
|
||||
$this->set_options();
|
||||
|
||||
// and an entry into the log table
|
||||
// Add an entry into the log table
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE');
|
||||
|
||||
// purge the cache
|
||||
$this->cache->destroy('_mchat_config');
|
||||
|
||||
// rebuild the cache
|
||||
$this->functions_mchat->mchat_cache();
|
||||
|
||||
trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($this->u_action));
|
||||
}
|
||||
}
|
||||
|
||||
// let's get it on
|
||||
$sql = 'SELECT *
|
||||
FROM ' . $this->mchat_config_table;
|
||||
$result = $this->db->sql_query($sql);
|
||||
$mchat_config = array();
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$mchat_config[$row['config_name']] = $row['config_value'];
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$mchat_enable = isset($this->config['mchat_enable']) ? $this->config['mchat_enable'] : 0;
|
||||
$mchat_on_index = isset($this->config['mchat_on_index']) ? $this->config['mchat_on_index'] : 0;
|
||||
$mchat_version = isset($this->config['mchat_version']) ? $this->config['mchat_version'] : '';
|
||||
$mchat_new_posts = isset($this->config['mchat_new_posts']) ? $this->config['mchat_new_posts'] : 0;
|
||||
$mchat_new_posts_topic = isset($this->config['mchat_new_posts_topic']) ? $this->config['mchat_new_posts_topic'] : 0;
|
||||
$mchat_new_posts_reply = isset($this->config['mchat_new_posts_reply']) ? $this->config['mchat_new_posts_reply'] : 0;
|
||||
$mchat_new_posts_edit = isset($this->config['mchat_new_posts_edit']) ? $this->config['mchat_new_posts_edit'] : 0;
|
||||
$mchat_new_posts_quote = isset($this->config['mchat_new_posts_quote']) ? $this->config['mchat_new_posts_quote'] : 0;
|
||||
$mchat_stats_index = isset($this->config['mchat_stats_index']) ? $this->config['mchat_stats_index'] : 0;
|
||||
$mchat_message_top = isset($this->config['mchat_message_top']) ? $this->config['mchat_message_top'] : 0;
|
||||
|
||||
$dateformat_options = '';
|
||||
foreach ($this->user->lang['dateformats'] as $format => $null)
|
||||
{
|
||||
$dateformat_options .= '<option value="' . $format . '"' . (($format == $mchat_config['date']) ? ' selected="selected"' : '') . '>';
|
||||
$dateformat_options .= '<option value="' . $format . '"' . (($format == $this->config['mchat_date']) ? ' 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 .= '</option>';
|
||||
}
|
||||
|
||||
$s_custom = false;
|
||||
$dateformat_options .= '<option value="custom"';
|
||||
if (!isset($this->user->lang['dateformats'][$mchat_config['date']]))
|
||||
if (!isset($this->user->lang['dateformats'][$this->config['mchat_date']]))
|
||||
{
|
||||
$dateformat_options .= ' selected="selected"';
|
||||
$s_custom = true;
|
||||
}
|
||||
$dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>';
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'MCHAT_ERROR' => isset($error) ? ((sizeof($error)) ? implode('<br />', $error) : '') : '',
|
||||
'MCHAT_VERSION' => $mchat_version,
|
||||
'MCHAT_PRUNE' => !empty($mchat_row['prune_enable']) ? $mchat_row['prune_enable'] : $mchat_config['prune_enable'],
|
||||
'MCHAT_PRUNE_NUM' => !empty($mchat_row['prune_num']) ? $mchat_row['prune_num'] : $mchat_config['prune_num'],
|
||||
'MCHAT_ENABLE' => ($mchat_enable) ? true : false,
|
||||
'MCHAT_ON_INDEX' => ($mchat_on_index) ? true : false,
|
||||
'MCHAT_MESSAGE_TOP' => ($mchat_message_top) ? true : false,
|
||||
'MCHAT_LOCATION' => !empty($mchat_row['location']) ? $mchat_row['location'] : $mchat_config['location'],
|
||||
'MCHAT_REFRESH' => !empty($mchat_row['refresh']) ? $mchat_row['refresh'] : $mchat_config['refresh'],
|
||||
'MCHAT_WHOIS_REFRESH' => !empty($mchat_row['whois_refresh']) ? $mchat_row['whois_refresh'] : $mchat_config['whois_refresh'],
|
||||
'MCHAT_MESSAGE_LIMIT' => !empty($mchat_row['message_limit']) ? $mchat_row['message_limit'] : $mchat_config['message_limit'],
|
||||
'MCHAT_MESSAGE_NUM' => !empty($mchat_row['message_num']) ? $mchat_row['message_num'] : $mchat_config['message_num'],
|
||||
'MCHAT_ARCHIVE_LIMIT' => !empty($mchat_row['archive_limit']) ? $mchat_row['archive_limit'] : $mchat_config['archive_limit'],
|
||||
'MCHAT_AVATARS' => !empty($mchat_row['avatars']) ? $mchat_row['avatars'] : $mchat_config['avatars'],
|
||||
'MCHAT_FLOOD_TIME' => !empty($mchat_row['flood_time']) ? $mchat_row['flood_time'] : $mchat_config['flood_time'],
|
||||
'MCHAT_MAX_MESSAGE_LNGTH' => !empty($mchat_row['max_message_lngth']) ? $mchat_row['max_message_lngth'] : $mchat_config['max_message_lngth'],
|
||||
'MCHAT_CUSTOM_PAGE' => !empty($mchat_row['custom_page']) ? $mchat_row['custom_page'] : $mchat_config['custom_page'],
|
||||
'MCHAT_DATE' => !empty($mchat_row['date']) ? $mchat_row['date'] : $mchat_config['date'],
|
||||
'MCHAT_DEFAULT_DATEFORMAT' => $this->config['default_dateformat'],
|
||||
'MCHAT_RULES' => !empty($mchat_row['rules']) ? $mchat_row['rules'] : $mchat_config['rules'],
|
||||
'MCHAT_WHOIS' => !empty($mchat_row['whois']) ? $mchat_row['whois'] : $mchat_config['whois'],
|
||||
'MCHAT_STATS_INDEX' => ($mchat_stats_index) ? true : false,
|
||||
'MCHAT_BBCODE_DISALLOWED' => !empty($mchat_row['bbcode_disallowed']) ? $mchat_row['bbcode_disallowed'] : $mchat_config['bbcode_disallowed'],
|
||||
'MCHAT_STATIC_MESSAGE' => !empty($mchat_row['static_message']) ? $mchat_row['static_message'] : $mchat_config['static_message'],
|
||||
'MCHAT_INDEX_HEIGHT' => !empty($mchat_row['index_height']) ? $mchat_row['index_height'] : $mchat_config['index_height'],
|
||||
'MCHAT_CUSTOM_HEIGHT' => !empty($mchat_row['custom_height']) ? $mchat_row['custom_height'] : $mchat_config['custom_height'],
|
||||
'MCHAT_OVERRIDE_SMILIE_LIMIT' => !empty($mchat_row['override_smilie_limit']) ? $mchat_row['override_smilie_limit'] : $mchat_config['override_smilie_limit'],
|
||||
'MCHAT_OVERRIDE_MIN_POST_CHARS' => !empty($mchat_row['override_min_post_chars']) ? $mchat_row['override_min_post_chars'] : $mchat_config['override_min_post_chars'],
|
||||
'MCHAT_TIMEOUT' => !empty($mchat_row['timeout']) ? $mchat_row['timeout'] : $mchat_config['timeout'],
|
||||
'MCHAT_NEW_POSTS' => ($mchat_new_posts) ? true : false,
|
||||
'MCHAT_NEW_POSTS_TOPIC' => ($mchat_new_posts_topic) ? true : false,
|
||||
'MCHAT_NEW_POSTS_REPLY' => ($mchat_new_posts_reply) ? true : false,
|
||||
'MCHAT_NEW_POSTS_EDIT' => ($mchat_new_posts_edit) ? true : false,
|
||||
'MCHAT_NEW_POSTS_QUOTE' => ($mchat_new_posts_quote) ? true : false,
|
||||
'MCHAT_PAUSE_ON_INPUT' => !empty($mchat_row['pause_on_input']) ? $mchat_row['pause_on_input'] : $mchat_config['pause_on_input'],
|
||||
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN'), '<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
|
||||
'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN'),'<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']),
|
||||
'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options,
|
||||
'S_CUSTOM_DATEFORMAT' => $s_custom,
|
||||
$template_variables = array();
|
||||
foreach ($mchat_config as $key => $value)
|
||||
{
|
||||
$template_variables[strtoupper($key)] = $this->config[$key];
|
||||
}
|
||||
|
||||
'U_ACTION' => $this->u_action)
|
||||
);
|
||||
$this->template->assign_vars(array_merge($template_variables, array(
|
||||
'MCHAT_ERROR' => !empty($error) ? implode('<br />', $error) : '',
|
||||
'MCHAT_VERSION' => $this->config['mchat_version'],
|
||||
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN'), '<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
|
||||
'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN'),'<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']),
|
||||
'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options,
|
||||
'S_CUSTOM_DATEFORMAT' => $s_custom,
|
||||
'U_ACTION' => $this->u_action,
|
||||
)));
|
||||
|
||||
// Version check
|
||||
$this->user->add_lang(array('install', 'acp/extensions', 'migrator'));
|
||||
@@ -290,39 +219,11 @@ class admin_controller
|
||||
{
|
||||
$this->template->assign_vars(array(
|
||||
'S_VERSIONCHECK_STATUS' => $e->getCode(),
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $this->user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
|
||||
'VERSIONCHECK_FAIL_REASON' => $e->getMessage() !== $this->user->lang('VERSIONCHECK_FAIL') ? $e->getMessage() : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the options a user can configure
|
||||
*
|
||||
* @return null
|
||||
* @access protected
|
||||
*/
|
||||
protected function set_options()
|
||||
{
|
||||
//update setting in config table for mod enabled or not
|
||||
$this->config->set('mchat_enable', $this->request->variable('mchat_enable', 0));
|
||||
// update setting in config table for allowing on index or not
|
||||
$this->config->set('mchat_on_index', $this->request->variable('mchat_on_index', 0));
|
||||
// update setting in config table to enable posts to display or not
|
||||
$this->config->set('mchat_new_posts', $this->request->variable('mchat_new_posts', 0));
|
||||
// update setting in config table to allow topic to display or not
|
||||
$this->config->set('mchat_new_posts_topic', $this->request->variable('mchat_new_posts_topic', 0));
|
||||
// update setting in config table to allow replies to display or not
|
||||
$this->config->set('mchat_new_posts_reply', $this->request->variable('mchat_new_posts_reply', 0));
|
||||
// update setting in config table to allow edit posts to display or not
|
||||
$this->config->set('mchat_new_posts_edit', $this->request->variable('mchat_new_posts_edit', 0));
|
||||
// update setting in config table to allow quoted posts to display or not
|
||||
$this->config->set('mchat_new_posts_quote', $this->request->variable('mchat_new_posts_quote', 0));
|
||||
// update setting in config table for stats on index
|
||||
$this->config->set('mchat_stats_index', $this->request->variable('mchat_stats_index', 0));
|
||||
// update setting in config table for message on top
|
||||
$this->config->set('mchat_message_top', $this->request->variable('mchat_message_top', 0));
|
||||
}
|
||||
|
||||
protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
|
||||
{
|
||||
$meta = $md_manager->get_metadata('all');
|
||||
|
||||
62
controller/main_controller.php
Normal file
62
controller/main_controller.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
* @copyright (c) 2015 dmzx - http://www.dmzx-web.net
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace dmzx\mchat\controller;
|
||||
|
||||
use \Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class main_controller
|
||||
{
|
||||
/** @var \dmzx\mchat\core\mchat */
|
||||
protected $mchat;
|
||||
|
||||
/** @var \phpbb\request\request */
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\mchat $mchat
|
||||
* @param \phpbb\request\request $request
|
||||
*/
|
||||
public function __construct(\dmzx\mchat\core\mchat $mchat, \phpbb\request\request $request)
|
||||
{
|
||||
$this->mchat = $mchat;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for mChat
|
||||
*
|
||||
* @param $page The page to render, one of custom|archive|rules|whois
|
||||
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
|
||||
*/
|
||||
public function page($page)
|
||||
{
|
||||
return call_user_func(array($this->mchat, 'page_' . $page));
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for mChat actions called with Ajax requests
|
||||
*
|
||||
* @param $action The action to perform, one of add|edit|del|clean|refresh|whois
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JsonResponse object
|
||||
*/
|
||||
public function action($action)
|
||||
{
|
||||
if (!$this->request->is_ajax())
|
||||
{
|
||||
throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
|
||||
}
|
||||
|
||||
$data = call_user_func(array($this->mchat, 'action_' . $action));
|
||||
|
||||
return new JsonResponse($data);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
* @copyright (c) 2015 dmzx - http://www.dmzx-web.net
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace dmzx\mchat\controller;
|
||||
|
||||
use \Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class mchat
|
||||
{
|
||||
/** @var \dmzx\mchat\core\render_helper*/
|
||||
protected $render_helper;
|
||||
|
||||
/** @var \phpbb\request\request*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\render_helper $render_helper
|
||||
* @param \phpbb\request\request $request
|
||||
*/
|
||||
public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\request\request $request)
|
||||
{
|
||||
$this->render_helper = $render_helper;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for mChat
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$content = $this->render_helper->render_data_for_page(false);
|
||||
return $this->request->is_ajax() ? new JsonResponse($content) : $content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user