Version 0.1.2

This commit is contained in:
dmzx
2015-08-22 21:32:33 +02:00
parent 3a4ac22d8c
commit 5ba5026c44
17 changed files with 214 additions and 253 deletions

View File

@@ -3,7 +3,7 @@
"type": "phpbb-extension", "type": "phpbb-extension",
"description": "mChat Extension for phpbb 3.1.x", "description": "mChat Extension for phpbb 3.1.x",
"homepage": "http://www.dmzx-web.net", "homepage": "http://www.dmzx-web.net",
"version": "0.1.1", "version": "0.1.2",
"time": "2015-03-10", "time": "2015-03-10",
"keywords": ["phpbb", "extension", "mchat"], "keywords": ["phpbb", "extension", "mchat"],
"license": "GPL-2.0", "license": "GPL-2.0",
@@ -27,6 +27,11 @@
"display-name": "mChat Extension", "display-name": "mChat Extension",
"soft-require": { "soft-require": {
"phpbb/phpbb": "3.1.*" "phpbb/phpbb": "3.1.*"
},
"version-check": {
"host": "www.dmzx-web.net",
"directory": "/versions",
"filename": "mchat_version.json"
} }
} }
} }

View File

@@ -40,6 +40,7 @@ services:
- @cache - @cache
- @pagination - @pagination
- @request - @request
- @dispatcher
- %core.root_path% - %core.root_path%
- %core.php_ext% - %core.php_ext%
- %core.table_prefix% - %core.table_prefix%
@@ -53,6 +54,7 @@ services:
- @log - @log
- @dbal.conn - @dbal.conn
- @cache - @cache
- @service_container
- %core.table_prefix% - %core.table_prefix%
- %dmzx.mchat.table.mchat% - %dmzx.mchat.table.mchat%
- %dmzx.mchat.table.mchat_config% - %dmzx.mchat.table.mchat_config%
@@ -67,6 +69,7 @@ services:
- @template - @template
- @user - @user
- @dbal.conn - @dbal.conn
- @service_container
- %core.root_path% - %core.root_path%
- %core.php_ext% - %core.php_ext%
- %core.table_prefix% - %core.table_prefix%

View File

@@ -94,17 +94,17 @@ class admin_controller
'date' => $this->request->variable('mchat_date', '', true), 'date' => $this->request->variable('mchat_date', '', true),
'whois' => $this->request->variable('mchat_whois', 0), 'whois' => $this->request->variable('mchat_whois', 0),
'whois_refresh' => $this->request->variable('mchat_whois_refresh', 0), 'whois_refresh' => $this->request->variable('mchat_whois_refresh', 0),
'bbcode_disallowed' => utf8_normalize_nfc($this->request->variable('mchat_bbcode_disallowed', '', true)), 'bbcode_disallowed' => $this->request->variable('mchat_bbcode_disallowed', '', true),
'prune_enable' => $this->request->variable('mchat_prune_enable', 0), 'prune_enable' => $this->request->variable('mchat_prune_enable', 0),
'prune_num' => $this->request->variable('mchat_prune_num', 0), 'prune_num' => $this->request->variable('mchat_prune_num', 0),
'index_height' => $this->request->variable('mchat_index_height', 0), 'index_height' => $this->request->variable('mchat_index_height', 0),
'custom_height' => $this->request->variable('mchat_custom_height', 0), 'custom_height' => $this->request->variable('mchat_custom_height', 0),
'static_message' => utf8_normalize_nfc($this->request->variable('mchat_static_message', '', true)), 'static_message' => $this->request->variable('mchat_static_message', '', true),
'override_min_post_chars' => $this->request->variable('mchat_override_min_post_chars', 0), 'override_min_post_chars' => $this->request->variable('mchat_override_min_post_chars', 0),
'override_smilie_limit' => $this->request->variable('mchat_override_smilie_limit', 0), 'override_smilie_limit' => $this->request->variable('mchat_override_smilie_limit', 0),
'timeout' => $this->request->variable('mchat_timeout', 0), 'timeout' => $this->request->variable('mchat_timeout', 0),
'pause_on_input' => $this->request->variable('mchat_pause_on_input', 0), 'pause_on_input' => $this->request->variable('mchat_pause_on_input', 0),
'rules' => utf8_normalize_nfc($this->request->variable('mchat_rules', '', true)), 'rules' => $this->request->variable('mchat_rules', '', true),
'avatars' => $this->request->variable('mchat_avatars', 0), 'avatars' => $this->request->variable('mchat_avatars', 0),
); );
@@ -169,7 +169,8 @@ class admin_controller
} }
// let's get it on // let's get it on
$sql = 'SELECT * FROM ' . $this->mchat_config_table; $sql = 'SELECT *
FROM ' . $this->mchat_config_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$mchat_config = array(); $mchat_config = array();
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))

View File

@@ -27,6 +27,9 @@ class functions_mchat
/** @var \phpbb\cache\service */ /** @var \phpbb\cache\service */
protected $cache; protected $cache;
/** @var \phpbb\event\dispatcher_interface */
protected $dispatcher;
protected $table_prefix; protected $table_prefix;
/** /**
@@ -50,13 +53,14 @@ class functions_mchat
* @param \phpbb\cache\service $cache * @param \phpbb\cache\service $cache
* @param $table_prefix * @param $table_prefix
*/ */
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $table_prefix, $mchat_table, $mchat_config_table, $mchat_sessions_table) public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $dispatcher, $table_prefix, $mchat_table, $mchat_config_table, $mchat_sessions_table)
{ {
$this->template = $template; $this->template = $template;
$this->user = $user; $this->user = $user;
$this->auth = $auth; $this->auth = $auth;
$this->db = $db; $this->db = $db;
$this->cache = $cache; $this->cache = $cache;
$this->dispatcher = $dispatcher;
$this->phpbb_log = $log; $this->phpbb_log = $log;
$this->table_prefix = $table_prefix; $this->table_prefix = $table_prefix;
$this->mchat_table = $mchat_table; $this->mchat_table = $mchat_table;
@@ -73,7 +77,8 @@ class functions_mchat
// Grab the config entries in the ACP...and cache em :P // Grab the config entries in the ACP...and cache em :P
if (($config_mchat = $this->cache->get('_mchat_config')) === false) if (($config_mchat = $this->cache->get('_mchat_config')) === false)
{ {
$sql = 'SELECT * FROM ' . $this->mchat_config_table; $sql = 'SELECT *
FROM ' . $this->mchat_config_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$config_mchat = array(); $config_mchat = array();
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
@@ -94,8 +99,8 @@ class functions_mchat
function mchat_user_fix($user_id) function mchat_user_fix($user_id)
{ {
$sql = 'UPDATE ' . $this->mchat_table . ' $sql = 'UPDATE ' . $this->mchat_table . '
SET user_id = ' . ANONYMOUS . ' SET user_id = ' . ANONYMOUS . '
WHERE user_id = ' . (int) $user_id; WHERE user_id = ' . (int) $user_id;
$this->db->sql_query($sql); $this->db->sql_query($sql);
return; return;
@@ -144,7 +149,8 @@ class functions_mchat
{ {
$check_time = time() - (int) $session_time; $check_time = time() - (int) $session_time;
$sql = 'DELETE FROM ' . $this->mchat_sessions_table . ' WHERE user_lastupdate < ' . $check_time; $sql = 'DELETE FROM ' . $this->mchat_sessions_table . '
WHERE user_lastupdate < ' . $check_time;
$this->db->sql_query($sql); $this->db->sql_query($sql);
// add the user into the sessions upon first visit // add the user into the sessions upon first visit
@@ -157,10 +163,10 @@ class functions_mchat
$mchat_user_list = ''; $mchat_user_list = '';
$sql = 'SELECT m.user_id, u.username, u.user_type, u.user_allow_viewonline, u.user_colour $sql = 'SELECT m.user_id, u.username, u.user_type, u.user_allow_viewonline, u.user_colour
FROM ' . $this->mchat_sessions_table . ' m FROM ' . $this->mchat_sessions_table . ' m
LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
WHERE m.user_lastupdate > ' . $check_time . ' WHERE m.user_lastupdate > ' . $check_time . '
ORDER BY u.username ASC'; ORDER BY u.username ASC';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$can_view_hidden = $this->auth->acl_get('u_viewonline'); $can_view_hidden = $this->auth->acl_get('u_viewonline');
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
@@ -214,7 +220,9 @@ class functions_mchat
// insert user into the mChat sessions table // insert user into the mChat sessions table
if ($this->user->data['user_type'] == USER_FOUNDER || $this->user->data['user_type'] == USER_NORMAL) if ($this->user->data['user_type'] == USER_FOUNDER || $this->user->data['user_type'] == USER_NORMAL)
{ {
$sql = 'SELECT * FROM ' . $this->mchat_sessions_table . ' WHERE user_id =' . (int) $this->user->data['user_id']; $sql = 'SELECT *
FROM ' . $this->mchat_sessions_table . '
WHERE user_id =' . (int) $this->user->data['user_id'];
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result); $row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@@ -251,7 +259,8 @@ class functions_mchat
return; return;
} }
$sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE post_id = ' . (int) $post_id; $sql = 'DELETE FROM ' . $this->mchat_table . '
WHERE post_id = ' . (int) $post_id;
$this->db->sql_query($sql); $this->db->sql_query($sql);
return; return;
@@ -265,7 +274,8 @@ class functions_mchat
function mchat_prune($mchat_prune_amount) function mchat_prune($mchat_prune_amount)
{ {
// Run query to get the total message rows... // Run query to get the total message rows...
$sql = 'SELECT COUNT(message_id) AS total_messages FROM ' . $this->mchat_table; $sql = 'SELECT COUNT(message_id) AS total_messages
FROM ' . $this->mchat_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$mchat_total_messages = (int) $this->db->sql_fetchfield('total_messages'); $mchat_total_messages = (int) $this->db->sql_fetchfield('total_messages');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@@ -281,7 +291,9 @@ class functions_mchat
if ($prune) if ($prune)
{ {
$result = $this->db->sql_query_limit('SELECT * FROM '. $this->mchat_table . ' ORDER BY message_id ASC', 1); $result = $this->db->sql_query_limit('SELECT *
FROM '. $this->mchat_table . '
ORDER BY message_id ASC', 1);
$row = $this->db->sql_fetchrow($result); $row = $this->db->sql_fetchrow($result);
$first_id = (int) $row['message_id']; $first_id = (int) $row['message_id'];
@@ -292,7 +304,7 @@ class functions_mchat
// let's go delete them...if the message id is less than the delete id // let's go delete them...if the message id is less than the delete id
$sql = 'DELETE FROM ' . $this->mchat_table . ' $sql = 'DELETE FROM ' . $this->mchat_table . '
WHERE message_id < ' . (int) $delete_id; WHERE message_id < ' . (int) $delete_id;
$this->db->sql_query($sql); $this->db->sql_query($sql);
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED'); $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
@@ -340,9 +352,9 @@ class functions_mchat
$num_predefined_bbcodes = 22; $num_predefined_bbcodes = 22;
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline $sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . ' FROM ' . BBCODES_TABLE . '
WHERE display_on_posting = 1 WHERE display_on_posting = 1
ORDER BY bbcode_tag'; ORDER BY bbcode_tag';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$i = 0; $i = 0;
@@ -374,4 +386,16 @@ class functions_mchat
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
} }
function functions_mchat_aft()
{
/**
* Event functions_mchat_aft
*
* @event dmzx.mchat.core.functions_mchat_aft
* @since 0.1.2
*/
$this->dispatcher->trigger_event('dmzx.mchat.core.functions_mchat_aft');
}
} }

View File

@@ -38,6 +38,9 @@ class render_helper
/** @var \phpbb\request\request */ /** @var \phpbb\request\request */
protected $request; protected $request;
/** @var \phpbb\event\dispatcher_interface */
protected $dispatcher;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $phpEx; protected $phpEx;
@@ -66,7 +69,7 @@ class render_helper
* @param $phpEx * @param $phpEx
* @param $table_prefix * @param $table_prefix
*/ */
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\pagination $pagination, \phpbb\request\request $request, $phpbb_root_path, $phpEx, $table_prefix, $mchat_table) public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx, $table_prefix, $mchat_table)
{ {
$this->functions_mchat = $functions_mchat; $this->functions_mchat = $functions_mchat;
$this->config = $config; $this->config = $config;
@@ -78,6 +81,7 @@ class render_helper
$this->cache = $cache; $this->cache = $cache;
$this->pagination = $pagination; $this->pagination = $pagination;
$this->request = $request; $this->request = $request;
$this->dispatcher = $dispatcher;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx; $this->phpEx = $phpEx;
$this->phpbb_log = $log; $this->phpbb_log = $log;
@@ -141,8 +145,10 @@ class render_helper
// grab fools..uhmmm, foes the user has // grab fools..uhmmm, foes the user has
$foes_array = array(); $foes_array = array();
$sql = 'SELECT * FROM ' . ZEBRA_TABLE . ' $sql = 'SELECT *
WHERE user_id = ' . $this->user->data['user_id'] . ' AND foe = 1'; FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $this->user->data['user_id'] . '
AND foe = 1';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
@@ -273,7 +279,8 @@ class render_helper
if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view) if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view)
{ {
// how many chats do we have? // how many chats do we have?
$sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->mchat_table; $sql = 'SELECT COUNT(message_id) AS messages
FROM ' . $this->mchat_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$mchat_total_messages = $this->db->sql_fetchfield('messages'); $mchat_total_messages = $this->db->sql_fetchfield('messages');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@@ -289,7 +296,7 @@ class render_helper
// Message row // Message row
$sql = '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 $sql = '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
FROM ' . $this->mchat_table . ' m FROM ' . $this->mchat_table . ' m
LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
' . $sql_where . ' ' . $sql_where . '
ORDER BY m.message_id DESC'; ORDER BY m.message_id DESC';
$result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['archive_limit'], $mchat_archive_start); $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
@@ -327,14 +334,14 @@ class render_helper
'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '',
'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'BOT_USER_ID' => $row['user_id'] != '1', 'BOT_USER_ID' => $row['user_id'] != '1',
'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_USER_IP' => $row['user_ip'],
'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])),
'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}" ,'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}" ,'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id),
'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']),
'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']),
@@ -350,7 +357,8 @@ class render_helper
} }
// Run query again to get the total message rows... // Run query again to get the total message rows...
$sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->mchat_table; $sql = 'SELECT COUNT(message_id) AS mess_id
FROM ' . $this->mchat_table;
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$mchat_total_message = $this->db->sql_fetchfield('mess_id'); $mchat_total_message = $this->db->sql_fetchfield('mess_id');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@@ -368,7 +376,7 @@ class render_helper
//add to navlinks //add to navlinks
$this->template->assign_block_vars('navlinks', array( $this->template->assign_block_vars('navlinks', array(
'FORUM_NAME' => $this->user->lang['MCHAT_ARCHIVE_PAGE'], 'FORUM_NAME' => $this->user->lang['MCHAT_ARCHIVE_PAGE'],
'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive')), 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive')),
)); ));
// If archive mode request set true // If archive mode request set true
$mchat_archive_mode = true; $mchat_archive_mode = true;
@@ -433,7 +441,7 @@ class render_helper
$message_edit = $row['message']; $message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']); decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '&quot;', $message_edit); $message_edit = str_replace('"', '&quot;', $message_edit);
$message_edit = mb_ereg_replace("'", "&#146;", $message_edit); // Edit Fix ;) $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);// Edit Fix ;)
if (sizeof($foes_array)) if (sizeof($foes_array))
{ {
if (in_array($row['user_id'], $foes_array)) if (in_array($row['user_id'], $foes_array))
@@ -450,7 +458,7 @@ class render_helper
'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '',
'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'BOT_USER_ID' => $row['user_id'] != '1', 'BOT_USER_ID' => $row['user_id'] != '1',
'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_EDIT' => $message_edit,
'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
@@ -524,7 +532,7 @@ class render_helper
} }
// Reguest... // Reguest...
$message = utf8_ucfirst(utf8_normalize_nfc($this->request->variable('message', '', true))); $message = utf8_ucfirst($this->request->variable('message', '', true));
// must have something other than bbcode in the message // must have something other than bbcode in the message
if (empty($mchatregex)) if (empty($mchatregex))
@@ -545,7 +553,8 @@ class render_helper
if (!$mchat_no_flood && $this->config_mchat['flood_time']) if (!$mchat_no_flood && $this->config_mchat['flood_time'])
{ {
$mchat_flood_current_time = time(); $mchat_flood_current_time = time();
$sql = 'SELECT message_time FROM ' . $this->mchat_table . ' $sql = 'SELECT message_time
FROM ' . $this->mchat_table . '
WHERE user_id = ' . (int) $this->user->data['user_id'] . ' WHERE user_id = ' . (int) $this->user->data['user_id'] . '
ORDER BY message_time DESC'; ORDER BY message_time DESC';
$result = $this->db->sql_query_limit($sql, 1); $result = $this->db->sql_query_limit($sql, 1);
@@ -588,13 +597,19 @@ class render_helper
{ {
if (empty($bbcode_replace)) if (empty($bbcode_replace))
{ {
$bbcode_replace = array('#\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\[\]]+\]#Usi', $bbcode_replace = array('#\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\[\]]+\]#Usi', '#\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\[\]]+\]#Usi',
'#\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\[\]]+\]#Usi', );
);
} }
$message = preg_replace($bbcode_replace, '', $message); $message = preg_replace($bbcode_replace, '', $message);
} }
} }
/**
* Event render_helper_add
*
* @event dmzx.mchat.core.render_helper_add
* @since 0.1.2
*/
$this->dispatcher->trigger_event('dmzx.mchat.core.render_helper_add');
$sql_ary = array( $sql_ary = array(
'forum_id' => 0, 'forum_id' => 0,
@@ -760,7 +775,7 @@ class render_helper
'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_VIEWPROFILE' => ($row['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '',
'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => ($row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'BOT_USER_ID' => $row['user_id'] != '1', 'BOT_USER_ID' => $row['user_id'] != '1',
'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'U_USER_ID' => ($row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_MESSAGE_ID' => $row['message_id'],
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']),
@@ -783,9 +798,8 @@ class render_helper
$this->config['max_post_smilies'] = $old_cfg['max_post_smilies']; $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
unset($old_cfg['max_post_smilies']); unset($old_cfg['max_post_smilies']);
} }
//adds a log //adds a log
// $message_author = get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']);
// add_log('admin', 'LOG_EDITED_MCHAT', $message_author);
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($row['username'])); $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($row['username']));
// insert user into the mChat sessions table // insert user into the mChat sessions table
$this->functions_mchat->mchat_sessions($mchat_session_time, true); $this->functions_mchat->mchat_sessions($mchat_session_time, true);
@@ -879,16 +893,18 @@ class render_helper
$order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; $order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{ {
$sql = 'SELECT group_id, group_name, group_colour, group_type FROM ' . GROUPS_TABLE . ' $sql = 'SELECT group_id, group_name, group_colour, group_type
WHERE group_legend <> 0 FROM ' . GROUPS_TABLE . '
WHERE group_legend <> 0
ORDER BY ' . $order_legend . ' ASC'; ORDER BY ' . $order_legend . ' ASC';
} }
else else
{ {
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0) FROM ' . GROUPS_TABLE . ' g
WHERE g.group_legend <> 0 LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0)
AND (g.group_type <> ' . GROUP_HIDDEN . ' WHERE g.group_legend <> 0
AND (g.group_type <> ' . GROUP_HIDDEN . '
OR ug.user_id = ' . (int) $this->user->data['user_id'] . ') OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
ORDER BY g.' . $order_legend . ' ASC'; ORDER BY g.' . $order_legend . ' ASC';
} }
@@ -1052,6 +1068,13 @@ class render_helper
} }
break; break;
} }
/**
* Event render_helper_aft
*
* @event dmzx.mchat.core.render_helper_aft
* @since 0.1.2
*/
$this->dispatcher->trigger_event('dmzx.mchat.core.render_helper_aft');
// show index stats // show index stats
if (!empty($this->config['mchat_stats_index']) && !empty($this->user->data['user_mchat_stats_index'])) if (!empty($this->config['mchat_stats_index']) && !empty($this->user->data['user_mchat_stats_index']))

View File

@@ -31,6 +31,9 @@ class listener implements EventSubscriberInterface
/** @var \phpbb\db\driver\driver_interface */ /** @var \phpbb\db\driver\driver_interface */
protected $db; protected $db;
/** @var ContainerInterface */
protected $phpbb_container;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $phpEx; protected $phpEx;
@@ -47,7 +50,7 @@ class listener implements EventSubscriberInterface
*/ */
protected $mchat_table; protected $mchat_table;
public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\template\template $template, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, $root_path, $phpEx, $table_prefix,$mchat_table) public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\template\template $template, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, $phpbb_container, $root_path, $phpEx, $table_prefix,$mchat_table)
{ {
$this->render_helper = $render_helper; $this->render_helper = $render_helper;
$this->auth = $auth; $this->auth = $auth;
@@ -56,6 +59,7 @@ class listener implements EventSubscriberInterface
$this->controller_helper = $controller_helper; $this->controller_helper = $controller_helper;
$this->user = $user; $this->user = $user;
$this->db = $db; $this->db = $db;
$this->phpbb_container = $phpbb_container;
$this->root_path = $root_path; $this->root_path = $root_path;
$this->phpEx = $phpEx; $this->phpEx = $phpEx;
$this->table_prefix = $table_prefix; $this->table_prefix = $table_prefix;
@@ -65,22 +69,20 @@ class listener implements EventSubscriberInterface
static public function getSubscribedEvents() static public function getSubscribedEvents()
{ {
return array( return array(
'core.viewonline_overwrite_location' => 'add_page_viewonline', 'core.viewonline_overwrite_location' => 'add_page_viewonline',
'core.user_setup' => 'load_language_on_setup', 'core.user_setup' => 'load_language_on_setup',
'core.page_header' => 'add_page_header_link', 'core.page_header' => 'add_page_header_link',
'core.index_modify_page_title' => 'display_mchat_on_index', 'core.index_modify_page_title' => 'display_mchat_on_index',
'core.posting_modify_submit_post_after' => 'posting_modify_submit_post_after', 'core.posting_modify_submit_post_after' => 'posting_modify_submit_post_after',
); );
} }
public function add_page_viewonline($event) public function add_page_viewonline($event)
{ {
global $user, $phpbb_container, $phpEx; if (strrpos($event['row']['session_page'], 'app.' . $this->phpEx . '/chat') === 0)
if (strrpos($event['row']['session_page'], 'app.' . $phpEx . '/chat') === 0)
{ {
$event['location'] = $user->lang('MCHAT_TITLE'); $event['location'] = $this->user->lang('MCHAT_TITLE');
$event['location_url'] = $phpbb_container->get('controller.helper')->route('dmzx_mchat_controller'); $event['location_url'] = $this->phpbb_container->get('controller.helper')->route('dmzx_mchat_controller');
} }
} }
@@ -147,7 +149,7 @@ class listener implements EventSubscriberInterface
{ {
$mchat_new_data = $this->user->lang['MCHAT_NEW_EDIT']; $mchat_new_data = $this->user->lang['MCHAT_NEW_EDIT'];
} }
else if ($event['mode'] == 'reply'&& (isset($this->config['mchat_new_posts_reply']) && $this->config['mchat_new_posts_reply'])) else if ($event['mode'] == 'reply' && (isset($this->config['mchat_new_posts_reply']) && $this->config['mchat_new_posts_reply']))
{ {
$mchat_new_data = $this->user->lang['MCHAT_NEW_REPLY']; $mchat_new_data = $this->user->lang['MCHAT_NEW_REPLY'];
} }
@@ -156,21 +158,21 @@ class listener implements EventSubscriberInterface
return; return;
} }
// Data... // Data...
$message = utf8_normalize_nfc($mchat_new_data . ': [url=' . generate_board_url() . '/viewtopic.' . $this->phpEx . '?p=' . $event['data']['post_id'] . '#p' . $event['data']['post_id'] . ']' . $event['post_data']['post_subject'] . '[/url] '. $this->user->lang['MCHAT_IN'] .' [url=' . generate_board_url() . '/viewforum.' . $this->phpEx . '?f=' . $event['forum_id'] . ']' . $event['post_data']['forum_name'] . ' [/url] ' . $this->user->lang['MCHAT_IN_SECTION']); $message = utf8_normalize_nfc($mchat_new_data . ': [url=' . generate_board_url() . '/viewtopic.' . $this->phpEx . '?p=' . $event['data']['post_id'] . '#p' . $event['data']['post_id'] . ']' . $event['post_data']['post_subject'] . '[/url] '. $this->user->lang['MCHAT_IN'] .' [url=' . generate_board_url() . '/viewforum.' . $this->phpEx . '?f=' . $event['forum_id'] . ']' . $event['post_data']['forum_name'] . ' [/url] ' . $this->user->lang['MCHAT_IN_SECTION']);
$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
generate_text_for_storage($message, $uid, $bitfield, $options, true, false, false); generate_text_for_storage($message, $uid, $bitfield, $options, true, false, false);
$sql_ary = array( $sql_ary = array(
'forum_id' => $event['forum_id'], 'forum_id' => $event['forum_id'],
'post_id' => $event['post_id'], 'post_id' => $event['post_id'],
'user_id' => $this->user->data['user_id'], 'user_id' => $this->user->data['user_id'],
'user_ip' => $this->user->data['session_ip'], 'user_ip' => $this->user->data['session_ip'],
'message' => $message, 'message' => $message,
'bbcode_bitfield' => $bitfield, 'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid, 'bbcode_uid' => $uid,
'bbcode_options' => $options, 'bbcode_options' => $options,
'message_time' => time() 'message_time' => time()
); );
$sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql); $this->db->sql_query($sql);

View File

@@ -9,7 +9,7 @@
namespace dmzx\mchat\migrations; namespace dmzx\mchat\migrations;
class mchat_module extends \phpbb\db\migration\migration class mchat_module_acp extends \phpbb\db\migration\migration
{ {
public function update_data() public function update_data()

View File

@@ -9,13 +9,13 @@
namespace dmzx\mchat\migrations; namespace dmzx\mchat\migrations;
class mchat_schema_6 extends \phpbb\db\migration\migration class mchat_module_cat extends \phpbb\db\migration\migration
{ {
static public function depends_on() static public function depends_on()
{ {
return array( return array(
'\dmzx\mchat\migrations\mchat_schema_5', '\dmzx\mchat\migrations\mchat_schema',
); );
} }
@@ -23,26 +23,26 @@ class mchat_schema_6 extends \phpbb\db\migration\migration
{ {
return array( return array(
array('module.add', array('acp', 'ACP_CAT_USERS', array( array('module.add', array('acp', 'ACP_CAT_USERS', array(
'module_basename' => 'users', 'module_basename' => 'users',
'module_enabled' => 1, 'module_enabled' => 1,
'module_display' => 0, 'module_display' => 0,
'module_langname' => 'ACP_USER_MCHAT', 'module_langname' => 'ACP_USER_MCHAT',
'module_mode' => 'mchat', 'module_mode' => 'mchat',
'module_auth' => 'acl_a_user', 'module_auth' => 'acl_a_user',
),
), ),
), // First, lets add a new category named UCP_CAT_MCHAT
// First, lets add a new category named UCP_CAT_MCHAT array('ucp', false, 'UCP_CAT_MCHAT'),
array('ucp', false, 'UCP_CAT_MCHAT'),
// next let's add our module // next let's add our module
array('ucp', 'UCP_CAT_MCHAT', array( array('ucp', 'UCP_CAT_MCHAT', array(
'module_basename' => 'mchat', 'module_basename' => 'mchat',
'modes' => array('configuration'), 'modes' => array('configuration'),
'module_auth' => 'u_mchat_use', 'module_auth' => 'u_mchat_use',
),
), ),
),
), ),
); );
} }
} }

View File

@@ -9,7 +9,7 @@
namespace dmzx\mchat\migrations; namespace dmzx\mchat\migrations;
class mchat_module1 extends \phpbb\db\migration\migration class mchat_module_ucp extends \phpbb\db\migration\migration
{ {
public function update_data() public function update_data()

View File

@@ -11,6 +11,7 @@ namespace dmzx\mchat\migrations;
class mchat_schema extends \phpbb\db\migration\migration class mchat_schema extends \phpbb\db\migration\migration
{ {
var $ext_version = '0.1.2';
public function update_data() public function update_data()
{ {
@@ -25,7 +26,7 @@ class mchat_schema extends \phpbb\db\migration\migration
array('config.add', array('mchat_new_posts_quote', false)), array('config.add', array('mchat_new_posts_quote', false)),
array('config.add', array('mchat_message_top', true)), array('config.add', array('mchat_message_top', true)),
array('config.add', array('mchat_stats_index', false)), array('config.add', array('mchat_stats_index', false)),
array('config.add', array('mchat_version','0.1.1')), array('config.add', array('mchat_version', $this->ext_version)),
// Add permissions // Add permissions
array('permission.add', array('u_mchat_use')), array('permission.add', array('u_mchat_use')),
@@ -78,6 +79,42 @@ class mchat_schema extends \phpbb\db\migration\migration
), ),
'PRIMARY_KEY' => 'config_name', 'PRIMARY_KEY' => 'config_name',
), ),
$this->table_prefix . 'mchat' => array(
'COLUMNS' => array(
'message_id' => array('UINT', NULL, 'auto_increment'),
'user_id' => array('UINT', 0),
'user_ip' => array('VCHAR:40', ''),
'message' => array('MTEXT_UNI', ''),
'bbcode_bitfield' => array('VCHAR', ''),
'bbcode_uid' => array('VCHAR:8', ''),
'bbcode_options' => array('BOOL', '7'),
'message_time' => array('INT:11', 0),
'forum_id' => array('UINT', 0),
'post_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'message_id',
),
$this->table_prefix . 'mchat_sessions' => array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'user_lastupdate' => array('TIMESTAMP', 0),
'user_ip' => array('VCHAR:40', ''),
),
'PRIMARY_KEY' => 'user_id',
),
),
'add_columns' => array(
$this->table_prefix . 'users' => array(
'user_mchat_index' => array('BOOL', '1'),
'user_mchat_sound' => array('BOOL', '1'),
'user_mchat_stats_index' => array('BOOL', '1'),
'user_mchat_topics' => array('BOOL', '1'),
'user_mchat_avatars' => array('BOOL', '1'),
'user_mchat_input_area' => array('BOOL', '1'),
),
), ),
); );
} }
@@ -86,8 +123,21 @@ class mchat_schema extends \phpbb\db\migration\migration
{ {
return array( return array(
'drop_tables' => array( 'drop_tables' => array(
$this->table_prefix . 'mchat',
$this->table_prefix . 'mchat_sessions',
$this->table_prefix . 'mchat_config', $this->table_prefix . 'mchat_config',
), ),
'drop_columns' => array(
$this->table_prefix . 'users' => array(
'user_mchat_index',
'user_mchat_sound',
'user_mchat_stats_index',
'user_mchat_topics',
'user_mchat_avatars',
'user_mchat_input_area',
),
),
); );
} }
} }

View File

@@ -1,52 +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\migrations;
class mchat_schema_2 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\dmzx\mchat\migrations\mchat_schema',
);
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'mchat' => array(
'COLUMNS' => array(
'message_id' => array('UINT', NULL, 'auto_increment'),
'user_id' => array('UINT', 0),
'user_ip' => array('VCHAR:40', ''),
'message' => array('MTEXT_UNI', ''),
'bbcode_bitfield' => array('VCHAR', ''),
'bbcode_uid' => array('VCHAR:8', ''),
'bbcode_options' => array('BOOL', '7'),
'message_time' => array('INT:11', 0),
'forum_id' => array('UINT', 0),
'post_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'message_id',
),
),
);
}
public function revert_schema()
{
return array(
'drop_tables' => array(
$this->table_prefix . 'mchat',
),
);
}
}

View File

@@ -1,53 +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\migrations;
class mchat_schema_4 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\dmzx\mchat\migrations\mchat_schema_3',
);
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'users' => array(
'user_mchat_index' => array('BOOL', '1'),
'user_mchat_sound' => array('BOOL', '1'),
'user_mchat_stats_index' => array('BOOL', '1'),
'user_mchat_topics' => array('BOOL', '1'),
'user_mchat_avatars' => array('BOOL', '1'),
'user_mchat_input_area' => array('BOOL', '1'),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'users' => array(
'user_mchat_index',
'user_mchat_sound',
'user_mchat_stats_index',
'user_mchat_topics',
'user_mchat_avatars',
'user_mchat_input_area',
),
),
);
}
}

View File

@@ -1,46 +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\migrations;
class mchat_schema_5 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array(
'\dmzx\mchat\migrations\mchat_schema_4',
);
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'mchat_sessions' => array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'user_lastupdate' => array('TIMESTAMP', 0),
'user_ip' => array('VCHAR:40', ''),
),
'PRIMARY_KEY' => 'user_id',
),
),
);
}
public function revert_schema()
{
return array(
'drop_tables' => array(
$this->table_prefix . 'mchat_sessions',
),
);
}
}

View File

@@ -9,13 +9,13 @@
namespace dmzx\mchat\migrations; namespace dmzx\mchat\migrations;
class mchat_schema_3 extends \phpbb\db\migration\migration class mchat_schema_sample_data extends \phpbb\db\migration\migration
{ {
static public function depends_on() static public function depends_on()
{ {
return array( return array(
'\dmzx\mchat\migrations\mchat_schema_2', '\dmzx\mchat\migrations\mchat_schema',
); );
} }

View File

@@ -182,6 +182,7 @@
<input type="button" class="button2" onclick="mChat.toggle('BBCodes');" value="{L_MCHAT_BBCODES}" /> <input type="button" class="button2" onclick="mChat.toggle('BBCodes');" value="{L_MCHAT_BBCODES}" />
<!-- ENDIF --> <!-- ENDIF -->
<!-- ENDIF --> <!-- ENDIF -->
<!-- EVENT dmzx_mchat_buttons_mid -->
<!-- IF MCHAT_READ_ARCHIVE_BUTTON --> <!-- IF MCHAT_READ_ARCHIVE_BUTTON -->
<input type="button" class="button2" onclick="window.location.href = '{MCHAT_ARCHIVE_URL}';" value="{L_MCHAT_ARCHIVE}" /> <input type="button" class="button2" onclick="window.location.href = '{MCHAT_ARCHIVE_URL}';" value="{L_MCHAT_ARCHIVE}" />
<!-- ENDIF --> <!-- ENDIF -->
@@ -192,6 +193,7 @@
<!-- IF MCHAT_RULES --> <!-- IF MCHAT_RULES -->
<input type="button" class="button2" onclick="popup('{U_MCHAT_RULES}', 450, 275); return false;" value="{L_MCHAT_HELP}" /> <input type="button" class="button2" onclick="popup('{U_MCHAT_RULES}', 450, 275); return false;" value="{L_MCHAT_HELP}" />
<!-- ENDIF --> <!-- ENDIF -->
<!-- EVENT dmzx_mchat_buttons_after -->
<!-- IF MCHAT_ALLOW_BBCODES --> <!-- IF MCHAT_ALLOW_BBCODES -->
<!-- INCLUDE mchat_bbcodes.html --> <!-- INCLUDE mchat_bbcodes.html -->
<!-- ENDIF --> <!-- ENDIF -->

View File

@@ -13,10 +13,12 @@ class ucp_mchat_info
{ {
function module() function module()
{ {
global $config;
return array( return array(
'filename' => '\dmzx\mchat\ucp\ucp_mchat_module', 'filename' => '\dmzx\mchat\ucp\ucp_mchat_module',
'title' => 'UCP_MCHAT_CONFIG', 'title' => 'UCP_MCHAT_CONFIG',
'version' => '1.3.8', 'version' => $config['mchat_version'],
'modes' => array( 'modes' => array(
'configuration' => array( 'configuration' => array(
'title' => 'UCP_MCHAT_CONFIG', 'title' => 'UCP_MCHAT_CONFIG',

View File

@@ -29,12 +29,12 @@ class ucp_mchat_module
case 'configuration': case 'configuration':
$data = array( $data = array(
'user_mchat_index' => $request->variable('user_mchat_index', (bool) $user->data['user_mchat_index']), 'user_mchat_index' => $request->variable('user_mchat_index', (bool) $user->data['user_mchat_index']),
'user_mchat_sound' => $request->variable('user_mchat_sound', (bool) $user->data['user_mchat_sound']), 'user_mchat_sound' => $request->variable('user_mchat_sound', (bool) $user->data['user_mchat_sound']),
'user_mchat_stats_index' => $request->variable('user_mchat_stats_index', (bool) $user->data['user_mchat_stats_index']), 'user_mchat_stats_index' => $request->variable('user_mchat_stats_index', (bool) $user->data['user_mchat_stats_index']),
'user_mchat_topics' => $request->variable('user_mchat_topics', (bool) $user->data['user_mchat_topics']), 'user_mchat_topics' => $request->variable('user_mchat_topics', (bool) $user->data['user_mchat_topics']),
'user_mchat_avatars' => $request->variable('user_mchat_avatars', (bool) $user->data['user_mchat_avatars']), 'user_mchat_avatars' => $request->variable('user_mchat_avatars', (bool) $user->data['user_mchat_avatars']),
'user_mchat_input_area' => $request->variable('user_mchat_input_area', (bool) $user->data['user_mchat_input_area']), 'user_mchat_input_area' => $request->variable('user_mchat_input_area', (bool) $user->data['user_mchat_input_area']),
); );
add_form_key('ucp_mchat'); add_form_key('ucp_mchat');
@@ -49,10 +49,10 @@ class ucp_mchat_module
if (!sizeof($error)) if (!sizeof($error))
{ {
$sql_ary = array( $sql_ary = array(
'user_mchat_index' => $data['user_mchat_index'], 'user_mchat_index' => $data['user_mchat_index'],
'user_mchat_sound' => $data['user_mchat_sound'], 'user_mchat_sound' => $data['user_mchat_sound'],
'user_mchat_stats_index' => $data['user_mchat_stats_index'], 'user_mchat_stats_index' => $data['user_mchat_stats_index'],
'user_mchat_topics' => $data['user_mchat_topics'], 'user_mchat_topics' => $data['user_mchat_topics'],
'user_mchat_avatars' => $data['user_mchat_avatars'], 'user_mchat_avatars' => $data['user_mchat_avatars'],
'user_mchat_input_area' => $data['user_mchat_input_area'], 'user_mchat_input_area' => $data['user_mchat_input_area'],
); );