diff --git a/acp/acp_mchat_info.php b/acp/acp_mchat_info.php index bffff83..f18ee57 100644 --- a/acp/acp_mchat_info.php +++ b/acp/acp_mchat_info.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/acp/acp_mchat_module.php b/acp/acp_mchat_module.php index 9a7b508..243c9d2 100644 --- a/acp/acp_mchat_module.php +++ b/acp/acp_mchat_module.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -19,21 +20,14 @@ class acp_mchat_module global $phpbb_container, $user; // Add the ACP lang file - $user->add_lang_ext('dmzx/mchat', 'info_acp_mchat'); + $user->add_lang_ext('dmzx/mchat', 'mchat_acp'); - // Load a template from adm/style for our ACP page + // Set template $this->tpl_name = 'acp_mchat'; + $this->page_title = 'MCHAT_ACP_TITLE'; - // Set the page title for our ACP page - $this->page_title = 'MCHAT_TITLE'; - - // Get an instance of the admin controller - $admin_controller = $phpbb_container->get('dmzx.mchat.admin.controller'); - - // Make the $u_action url available in the admin controller - $admin_controller->set_page_url($this->u_action); - - // Load the display settings handle in the admin controller - $admin_controller->display_options(); + // Get an instance of the ACP controller and display the options + $controller = $phpbb_container->get('dmzx.mchat.acp.controller'); + $controller->display_options($this->u_action); } } diff --git a/adm/style/acp_mchat.html b/adm/style/acp_mchat.html index 5a5350b..3c875b8 100644 --- a/adm/style/acp_mchat.html +++ b/adm/style/acp_mchat.html @@ -1,6 +1,8 @@ -

{L_ACP_MCHAT_TITLE}

{L_ACP_MCHAT_VERSION}{L_COLON} {MCHAT_VERSION} +

{L_MCHAT_TITLE}

+ +{L_MCHAT_VERSION}{L_COLON} {MCHAT_VERSION}
@@ -55,6 +57,11 @@ {L_MCHAT_MESSAGE_LIMIT_EXPLAIN}
+
+
+
+
+
{L_MCHAT_SETTINGS_ARCHIVE} @@ -108,6 +115,12 @@
style="display:none;">
+
+

+ {L_MCHAT_RELATIVE_TIME_EXPLAIN}
+
+
+

{L_MCHAT_PAUSE_ON_INPUT_EXPLAIN}
@@ -142,8 +155,8 @@
-

- {L_ACP_MCHAT_RULES_EXPLAIN}
+

+ {L_MCHAT_RULES_EXPLAIN}
@@ -224,4 +237,5 @@

+ diff --git a/adm/style/acp_users_mchat.html b/adm/style/acp_users_mchat.html deleted file mode 100644 index 869376f..0000000 --- a/adm/style/acp_users_mchat.html +++ /dev/null @@ -1,51 +0,0 @@ -
-
- {L_UCP_PROFILE_MCHAT} -
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
- - {S_FORM_TOKEN} -
-
diff --git a/adm/style/event/acp_users_prefs_append.html b/adm/style/event/acp_users_prefs_append.html new file mode 100644 index 0000000..7a3648a --- /dev/null +++ b/adm/style/event/acp_users_prefs_append.html @@ -0,0 +1,52 @@ +
+ {L_MCHAT_PREFERENCES} +
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
diff --git a/composer.json b/composer.json index 21ecf2e..8ad3513 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "dmzx/mchat", "type": "phpbb-extension", - "description": "mChat Extension for phpbb 3.1.x", + "description": "mChat Extension for phpBB 3.1", "homepage": "http://www.dmzx-web.net", - "version": "1.0.0-RC1", + "version": "1.0.0-RC2", "time": "2015-03-10", "keywords": ["phpbb", "extension", "mchat"], "license": "GPL-2.0", @@ -20,7 +20,7 @@ "role": "Extension Co-Developer" }, { - "name": "Rich McGirr", + "name": "RMcGirr83", "homepage": "http://rmcgirr83.org", "role": "Author" } @@ -34,12 +34,12 @@ "extra": { "display-name": "mChat Extension for phpBB 3.1", "soft-require": { - "phpbb/phpbb": "3.1.*" - }, + "phpbb/phpbb": ">=3.1.7-PL1,<3.2.0@dev" + }, "version-check": { "host": "www.dmzx-web.net", "directory": "/versions", "filename": "mchat_version.json" } } -} \ No newline at end of file +} diff --git a/config/routing.yml b/config/routing.yml index 5b0e1e4..74d1ad9 100644 --- a/config/routing.yml +++ b/config/routing.yml @@ -1,13 +1,16 @@ dmzx_mchat_controller: path: /mchat + methods: [GET] defaults: { _controller: dmzx.mchat.main.controller:page, page: custom } dmzx_mchat_page_controller: path: /mchat/{page} + methods: [GET] defaults: { _controller: dmzx.mchat.main.controller:page } requirements: - action: 'archive|rules|whois' + page: 'archive|rules|whois' dmzx_mchat_action_controller: - path: /mchat-{action} + path: /mchat/action-{action} + methods: [POST] defaults: { _controller: dmzx.mchat.main.controller:action } requirements: action: 'add|edit|del|refresh|whois' diff --git a/config/services.yml b/config/services.yml index d74ada4..99292f8 100644 --- a/config/services.yml +++ b/config/services.yml @@ -1,9 +1,10 @@ imports: - { resource: tables.yml } + - { resource: user_config_keys.yml } services: - dmzx.mchat.admin.controller: - class: dmzx\mchat\controller\admin_controller + dmzx.mchat.acp.controller: + class: dmzx\mchat\controller\acp_controller arguments: - '@config' - '@template' @@ -13,17 +14,28 @@ services: - '@cache' - '@request' - '%dmzx.mchat.table.mchat%' + - '%dmzx.mchat.table.mchat_deleted_messages%' - '%core.root_path%' - '%core.php_ext%' + dmzx.mchat.ucp.controller: + class: dmzx\mchat\controller\ucp_controller + arguments: + - '@config' + - '@template' + - '@user' + - '@dbal.conn' + - '@request' + - '%user_config_keys%' dmzx.mchat.main.controller: class: dmzx\mchat\controller\main_controller arguments: + - '@user' - '@dmzx.mchat.core' - '@request' dmzx.mchat.core: class: dmzx\mchat\core\mchat arguments: - - '@dmzx.mchat.functions_mchat' + - '@dmzx.mchat.functions' - '@config' - '@controller.helper' - '@template' @@ -32,10 +44,11 @@ services: - '@pagination' - '@request' - '@dispatcher' + - '@ext.manager' - '%core.root_path%' - '%core.php_ext%' - dmzx.mchat.functions_mchat: - class: dmzx\mchat\core\functions_mchat + dmzx.mchat.functions: + class: dmzx\mchat\core\functions arguments: - '@config' - '@user' @@ -46,11 +59,21 @@ services: - '%core.root_path%' - '%core.php_ext%' - '%dmzx.mchat.table.mchat%' + - '%dmzx.mchat.table.mchat_deleted_messages%' - '%dmzx.mchat.table.mchat_sessions%' - dmzx.mchat.listener: - class: dmzx\mchat\event\listener + dmzx.mchat.acp.listener: + class: dmzx\mchat\event\acp_listener arguments: - - '@dmzx.mchat.functions_mchat' + - '@template' + - '@request' + - '@user' + - '%user_config_keys%' + tags: + - { name: event.listener } + dmzx.mchat.main.listener: + class: dmzx\mchat\event\main_listener + arguments: + - '@dmzx.mchat.functions' - '@dmzx.mchat.core' - '@controller.helper' - '@user' diff --git a/config/tables.yml b/config/tables.yml index 86813a7..29d1a82 100644 --- a/config/tables.yml +++ b/config/tables.yml @@ -1,3 +1,4 @@ parameters: dmzx.mchat.table.mchat: %core.table_prefix%mchat + dmzx.mchat.table.mchat_deleted_messages: %core.table_prefix%mchat_deleted_messages dmzx.mchat.table.mchat_sessions: %core.table_prefix%mchat_sessions diff --git a/config/user_config_keys.yml b/config/user_config_keys.yml new file mode 100644 index 0000000..cc1afdc --- /dev/null +++ b/config/user_config_keys.yml @@ -0,0 +1,9 @@ +parameters: + user_config_keys: + - user_mchat_index + - user_mchat_sound + - user_mchat_stats_index + - user_mchat_topics + - user_mchat_avatars + - user_mchat_capital_letter + - user_mchat_input_area diff --git a/controller/admin_controller.php b/controller/acp_controller.php similarity index 72% rename from controller/admin_controller.php rename to controller/acp_controller.php index 41c96dd..3bc16d0 100644 --- a/controller/admin_controller.php +++ b/controller/acp_controller.php @@ -3,14 +3,15 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ namespace dmzx\mchat\controller; -class admin_controller +class acp_controller { /** @var \phpbb\config\config */ protected $config; @@ -36,47 +37,51 @@ class admin_controller /** @var string */ protected $mchat_table; + /** @var string */ + protected $mchat_deleted_messages_table; + /** @var string */ protected $root_path; /** @var string */ protected $php_ext; - /** @var string */ - public $u_action; - /** * Constructor * - * @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 $mchat_table - * @param $root_path - * @param $php_ext + * @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 string $mchat_table + * @param string $mchat_deleted_messages_table + * @param string $root_path + * @param string $php_ext */ - public function __construct(\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, $mchat_table, $root_path, $php_ext) + public function __construct(\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, $mchat_table, $mchat_deleted_messages_table, $root_path, $php_ext) { - $this->config = $config; - $this->template = $template; - $this->log = $log; - $this->user = $user; - $this->db = $db; - $this->cache = $cache; - $this->request = $request; - $this->mchat_table = $mchat_table; - $this->root_path = $root_path; - $this->php_ext = $php_ext; + $this->config = $config; + $this->template = $template; + $this->log = $log; + $this->user = $user; + $this->db = $db; + $this->cache = $cache; + $this->request = $request; + $this->mchat_table = $mchat_table; + $this->mchat_deleted_messages_table = $mchat_deleted_messages_table; + $this->root_path = $root_path; + $this->php_ext = $php_ext; } /** - * Display the options a user can configure for this extension + * Display the options the admin can configure for this extension + * + * @param $u_action */ - public function display_options() + public function display_options($u_action) { add_form_key('acp_mchat'); @@ -86,6 +91,7 @@ class admin_controller '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_relative_time' => 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)), @@ -96,6 +102,7 @@ class admin_controller '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_navbar_link' => array('default' => 1, '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()), @@ -124,9 +131,10 @@ class admin_controller if (check_form_key('acp_mchat') && $this->user->data['user_type'] == USER_FOUNDER) { $this->db->sql_query('TRUNCATE TABLE ' . $this->mchat_table); - $this->cache->destroy('sql', $this->mchat_table); - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED'); - trigger_error($this->user->lang('LOG_MCHAT_TABLE_PRUNED') . adm_back_link($this->u_action)); + $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')) @@ -154,18 +162,6 @@ class admin_controller $error[] = 'FORM_INVALID'; } - // Replace "error" strings with their real, localised form - // The /e modifier is deprecated since PHP 5.5.0 - //$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang('\\1'))) ? \$this->user->lang('\\1') : '\\1'", $error); - foreach ($error as $i => $err) - { - $lang = $this->user->lang($err); - if (!empty($lang)) - { - $error[$i] = $lang; - } - } - if (empty($error)) { // Set the options the user configured @@ -175,10 +171,13 @@ class admin_controller } // Add an entry into the log table - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE'); + $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE', false, array($this->user->data['username'])); - trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($this->u_action)); + trigger_error($this->user->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); } $dateformat_options = ''; @@ -198,31 +197,20 @@ class admin_controller } $dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . ''; - $template_variables = array(); - foreach ($mchat_config as $key => $value) + foreach (array_keys($mchat_config) as $key) { - $template_variables[strtoupper($key)] = $this->config[$key]; + $this->template->assign_var(strtoupper($key), $this->config[$key]); } - $this->template->assign_vars(array_merge($template_variables, array( + $this->template->assign_vars(array( 'MCHAT_ERROR' => !empty($error) ? implode('
', $error) : '', 'MCHAT_VERSION' => $this->config['mchat_version'], 'MCHAT_FOUNDER' => $this->user->data['user_type'] == USER_FOUNDER, - 'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN'), 'root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', ''), - 'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN'),'root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '', $this->config['session_length']), + 'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => $this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN', 'root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', ''), + 'L_MCHAT_TIMEOUT_EXPLAIN' => $this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN','root_path}adm/index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '', $this->config['session_length']), 'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, - 'U_ACTION' => $this->u_action, - ))); - } - - /** - * Set page url - * - * @param string $u_action Custom form action - */ - public function set_page_url($u_action) - { - $this->u_action = $u_action; + 'U_ACTION' => $u_action, + )); } } diff --git a/controller/main_controller.php b/controller/main_controller.php index bcea3e4..ed9349e 100644 --- a/controller/main_controller.php +++ b/controller/main_controller.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -14,6 +15,9 @@ use \Symfony\Component\HttpFoundation\JsonResponse; class main_controller { + /** @var \phpbb\user */ + protected $user; + /** @var \dmzx\mchat\core\mchat */ protected $mchat; @@ -23,11 +27,13 @@ class main_controller /** * Constructor * + * @param \phpbb\user $user * @param \dmzx\mchat\core\mchat $mchat * @param \phpbb\request\request $request */ - public function __construct(\dmzx\mchat\core\mchat $mchat, \phpbb\request\request $request) + public function __construct(\phpbb\user $user, \dmzx\mchat\core\mchat $mchat, \phpbb\request\request $request) { + $this->user = $user; $this->mchat = $mchat; $this->request = $request; } @@ -40,6 +46,7 @@ class main_controller */ public function page($page) { + $this->user->add_lang_ext('dmzx/mchat', 'mchat'); return call_user_func(array($this->mchat, 'page_' . $page)); } @@ -47,7 +54,7 @@ class main_controller * Controller for mChat actions called with Ajax requests * * @param string $action The action to perform, one of add|edit|del|refresh|whois - * @return A Symfony JsonResponse object + * @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JsonResponse object */ public function action($action) { @@ -56,6 +63,13 @@ class main_controller throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION'); } + // Fix avatars & smilies + if (!defined('PHPBB_USE_BOARD_URL_PATH')) + { + define('PHPBB_USE_BOARD_URL_PATH', true); + } + + $this->user->add_lang_ext('dmzx/mchat', 'mchat'); $data = call_user_func(array($this->mchat, 'action_' . $action)); return new JsonResponse($data); diff --git a/controller/ucp_controller.php b/controller/ucp_controller.php new file mode 100644 index 0000000..4d75e7a --- /dev/null +++ b/controller/ucp_controller.php @@ -0,0 +1,109 @@ +config = $config; + $this->template = $template; + $this->user = $user; + $this->db = $db; + $this->request = $request; + $this->user_config_keys = $user_config_keys; + } + + /** + * Display the options a user can configure for this extension + * + * @param $u_action + */ + public function display_options($u_action) + { + add_form_key('ucp_mchat'); + + $error = array(); + + if ($this->request->is_set_post('submit')) + { + if (!check_form_key('ucp_mchat')) + { + $error[] = 'FORM_INVALID'; + } + + if (empty($error)) + { + $data = array(); + foreach ($this->user_config_keys as $config_key) + { + $data[$config_key] = $this->request->variable($config_key, (int) $this->user->data[$config_key]); + } + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $data) . ' + WHERE user_id = ' . (int) $this->user->data['user_id']; + $this->db->sql_query($sql); + + meta_refresh(3, $u_action); + $message = $this->user->lang('PROFILE_UPDATED') . '

' . $this->user->lang('RETURN_UCP', '', ''); + trigger_error($message); + } + + // Replace "error" strings with their real, localised form + $error = array_map(array($this->user, 'lang'), $error); + } + + foreach ($this->user_config_keys as $config_key) + { + $this->template->assign_var(strtoupper($config_key), $this->user->data[$config_key]); + } + + $this->template->assign_vars(array( + 'ERROR' => sizeof($error) ? implode('
', $error) : '', + 'S_UCP_ACTION' => $u_action, + + 'S_MCHAT_TOPICS' => $this->config['mchat_new_posts_edit'] || $this->config['mchat_new_posts_quote'] || $this->config['mchat_new_posts_reply'] || $this->config['mchat_new_posts_topic'], + 'S_MCHAT_INDEX' => $this->config['mchat_on_index'], + 'S_MCHAT_INDEX_STATS' => $this->config['mchat_stats_index'], + 'S_MCHAT_AVATARS' => $this->config['mchat_avatars'], + )); + } +} diff --git a/core/functions_mchat.php b/core/functions.php similarity index 78% rename from core/functions_mchat.php rename to core/functions.php index f8588a4..2feb93f 100644 --- a/core/functions_mchat.php +++ b/core/functions.php @@ -3,14 +3,15 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ namespace dmzx\mchat\core; -class functions_mchat +class functions { /** @var \phpbb\config\config */ protected $config; @@ -39,6 +40,9 @@ class functions_mchat /** @var string */ protected $mchat_table; + /** @var string */ + protected $mchat_deleted_messages_table; + /** @var string */ protected $mchat_sessions_table; @@ -57,20 +61,22 @@ class functions_mchat * @param string $root_path * @param string $php_ext * @param string $mchat_table + * @param string $mchat_deleted_messages_table * @param string $mchat_sessions_table */ - function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $root_path, $php_ext, $mchat_table, $mchat_sessions_table) + function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $root_path, $php_ext, $mchat_table, $mchat_deleted_messages_table, $mchat_sessions_table) { - $this->config = $config; - $this->user = $user; - $this->auth = $auth; - $this->log = $log; - $this->db = $db; - $this->cache = $cache; - $this->root_path = $root_path; - $this->php_ext = $php_ext; - $this->mchat_table = $mchat_table; - $this->mchat_sessions_table = $mchat_sessions_table; + $this->config = $config; + $this->user = $user; + $this->auth = $auth; + $this->log = $log; + $this->db = $db; + $this->cache = $cache; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + $this->mchat_table = $mchat_table; + $this->mchat_deleted_messages_table = $mchat_deleted_messages_table; + $this->mchat_sessions_table = $mchat_sessions_table; } /** @@ -161,6 +167,8 @@ class functions_mchat /** * Inserts the current user into the mchat_sessions table + * + * @return bool */ public function mchat_add_user_session() { @@ -170,6 +178,8 @@ class functions_mchat WHERE user_lastupdate < ' . $check_time; $this->db->sql_query($sql); + $is_new_session = false; + if ($this->user->data['user_type'] == USER_FOUNDER || $this->user->data['user_type'] == USER_NORMAL && $this->user->data['user_id'] != ANONYMOUS && !$this->user->data['is_bot']) { $sql = 'SELECT * @@ -187,6 +197,7 @@ class functions_mchat } else { + $is_new_session = true; $sql = 'INSERT INTO ' . $this->mchat_sessions_table . ' ' . $this->db->sql_build_array('INSERT', array( 'user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['user_ip'], @@ -196,6 +207,8 @@ class functions_mchat $this->db->sql_query($sql); } + + return $is_new_session; } /** @@ -220,7 +233,7 @@ class functions_mchat $delete_id = $mchat_total_messages - $this->config['mchat_prune_num'] + $first_id; // Delete older messages - $this->mchat_action('prune', null, $delete_id); + $this->mchat_action('prune', null, $delete_id, $this->user->data['username']); } } } @@ -348,11 +361,11 @@ class functions_mchat */ public function mchat_sql_append_forbidden_bbcodes($sql_where) { - $disallowed_bbcodes = explode('|', strtoupper($this->config['mchat_bbcode_disallowed'])); + $disallowed_bbcodes = explode('|', $this->config['mchat_bbcode_disallowed']); if (!empty($disallowed_bbcodes)) { - $sql_where .= ' AND ' . $this->db->sql_in_set('UPPER(b.bbcode_tag)', $disallowed_bbcodes, true); + $sql_where .= ' AND ' . $this->db->sql_in_set('b.bbcode_tag', $disallowed_bbcodes, true); } return $sql_where; @@ -446,87 +459,22 @@ class functions_mchat * Returns an array of message IDs that have been deleted from the message table * * @param $start_id - * @param $end_id * @return array */ - public function mchat_missing_ids($start_id, $end_id) + public function mchat_deleted_ids($start_id) { - if ($this->config['mchat_edit_delete_limit']) - { - $sql_where = 'message_time < ' . (time() - $this->config['mchat_edit_delete_limit']); - $cache_ttl = 0; - } - else - { - $sql_where = 'message_id < ' . (int) $start_id; - $cache_ttl = 3600; - } - $sql = 'SELECT message_id - FROM ' . $this->mchat_table . ' - WHERE ' . $sql_where . ' + FROM ' . $this->mchat_deleted_messages_table . ' + WHERE message_id >= ' . (int) $start_id . ' ORDER BY message_id DESC'; - $result = $this->db->sql_query_limit($sql, 1, 0, $cache_ttl); - $earliest_id = (int) $this->db->sql_fetchfield('message_id'); - $this->db->sql_freeresult($result); - - if (!$earliest_id) - { - $sql = 'SELECT MIN(message_id) as earliest_id - FROM ' . $this->mchat_table; - $result = $this->db->sql_query($sql, 3600); - $earliest_id = $this->db->sql_fetchfield('earliest_id'); - $this->db->sql_freeresult($result); - } - - if (!$earliest_id) - { - return range($start_id, $end_id); - } - - $sql = 'SELECT (t1.message_id + 1) AS start, ( - SELECT MIN(t3.message_id) - 1 - FROM ' . $this->mchat_table . ' t3 - WHERE t3.message_id > t1.message_id - ) AS end - FROM ' . $this->mchat_table . ' t1 - WHERE t1.message_id > ' . (int) $earliest_id . ' AND NOT EXISTS ( - SELECT t2.message_id - FROM ' . $this->mchat_table . ' t2 - WHERE t2.message_id = t1.message_id + 1 - )'; - - $result = $this->db->sql_query($sql); - $rows = $this->db->sql_fetchrowset($result); + $result = $this->db->sql_query($sql, 3600); + $rows = $this->db->sql_fetchrowset(); $this->db->sql_freeresult($result); $missing_ids = array(); - - if ($start_id < $earliest_id && !$this->config['mchat_edit_delete_limit']) - { - $missing_ids[] = range($start_id, $earliest_id - 1); - } - foreach ($rows as $row) { - if ($row['end']) - { - $missing_ids[] = range($row['start'], $row['end']); - } - else - { - $latest_message = $row['start'] - 1; - if ($end_id > $latest_message) - { - $missing_ids[] = range($latest_message + 1, $end_id); - } - } - } - - // Flatten - if (!empty($missing_ids)) - { - $missing_ids = call_user_func_array('array_merge', $missing_ids); + $missing_ids[] = (int) $row['message_id']; } return $missing_ids; @@ -535,56 +483,66 @@ class functions_mchat /** * Performs AJAX actions * - * @param string $action One of add|edit|del|clean|prune + * @param string $action One of add|edit|del|prune * @param array $sql_ary * @param int $message_id * @param string $log_username + * @return bool */ public function mchat_action($action, $sql_ary = null, $message_id = 0, $log_username = '') { + $is_new_session = false; + switch ($action) { // User adds a message case 'add': - $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); - $this->mchat_add_user_session(); + $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)); break; + // User edits a message case 'edit': - $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id; - $this->mchat_add_user_session(); + $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->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($log_username)); break; + // User deletes a message case 'del': - $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id = ' . (int) $message_id; - $this->mchat_add_user_session(); + $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->db->sql_query('INSERT INTO ' . $this->mchat_deleted_messages_table . ' ' . $this->db->sql_build_array('INSERT', array('message_id' => (int) $message_id))); + $this->cache->destroy('sql', $this->mchat_deleted_messages_table); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($log_username)); - $this->cache->destroy('sql', $this->mchat_table); break; + // User triggers messages to be pruned case 'prune': - $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id < ' . (int) $message_id; - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED'); - $this->cache->destroy('sql', $this->mchat_table); + $sql = 'SELECT message_id + FROM ' . $this->mchat_table . ' + WHERE message_id < ' . (int) $message_id . ' + ORDER BY message_id DESC'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset(); + $this->db->sql_freeresult($result); + + $prune_ids = array(); + foreach ($rows as $row) + { + $prune_ids[] = (int) $row['message_id']; + } + + $this->db->sql_query('DELETE FROM ' . $this->mchat_table . ' WHERE ' .$this->db->sql_in_set('message_id', $prune_ids)); + $this->db->sql_multi_insert($this->mchat_deleted_messages_table, $rows); + $this->cache->destroy('sql', $this->mchat_deleted_messages_table); + // $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED', false, array($log_username)); break; - default: - return; } - $result = $this->db->sql_query($sql); - - if ($result !== false) - { - switch ($action) - { - case 'add': - if ($this->db->sql_nextid() == 1) - { - $this->cache->destroy('sql', $this->mchat_table); - } - break; - } - } + return $is_new_session; } } diff --git a/core/mchat.php b/core/mchat.php index 4aa9500..1d2234e 100644 --- a/core/mchat.php +++ b/core/mchat.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -12,8 +13,8 @@ namespace dmzx\mchat\core; class mchat { - /** @var \dmzx\mchat\core\functions_mchat */ - protected $functions_mchat; + /** @var \dmzx\mchat\core\functions */ + protected $functions; /** @var \phpbb\config\config */ protected $config; @@ -39,6 +40,9 @@ class mchat /** @var \phpbb\event\dispatcher_interface */ protected $dispatcher; + /** @var \phpbb\extension\manager */ + protected $extension_manager; + /** @var string */ protected $root_path; @@ -46,12 +50,12 @@ class mchat protected $php_ext; /** @var boolean */ - protected $is_mchat_rendered = false; + protected $remove_disallowed_bbcodes = false; /** * Constructor * - * @param \dmzx\mchat\core\functions_mchat $functions_mchat + * @param \dmzx\mchat\core\functions $functions * @param \phpbb\config\config $config * @param \phpbb\controller\helper $helper * @param \phpbb\template\template $template @@ -60,22 +64,24 @@ class mchat * @param \phpbb\pagination $pagination * @param \phpbb\request\request $request * @param \phpbb\event\dispatcher_interface $dispatcher + * @param \phpbb\extension\manager $extension_manager * @param string $root_path * @param string $php_ext */ - public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\event\dispatcher_interface $dispatcher, $root_path, $php_ext) + public function __construct(\dmzx\mchat\core\functions $functions, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \phpbb\request\request $request, \phpbb\event\dispatcher_interface $dispatcher,\phpbb\extension\manager $extension_manager, $root_path, $php_ext) { - $this->functions_mchat = $functions_mchat; - $this->config = $config; - $this->helper = $helper; - $this->template = $template; - $this->user = $user; - $this->auth = $auth; - $this->pagination = $pagination; - $this->request = $request; - $this->dispatcher = $dispatcher; - $this->root_path = $root_path; - $this->php_ext = $php_ext; + $this->functions = $functions; + $this->config = $config; + $this->helper = $helper; + $this->template = $template; + $this->user = $user; + $this->auth = $auth; + $this->pagination = $pagination; + $this->request = $request; + $this->dispatcher = $dispatcher; + $this->extension_manager = $extension_manager; + $this->root_path = $root_path; + $this->php_ext = $php_ext; } /** @@ -95,6 +101,13 @@ class mchat return; } + if (!$this->user->data['user_mchat_index']) + { + return; + } + + $this->user->add_lang_ext('dmzx/mchat', 'mchat'); + $this->assign_bbcodes_smilies(); $this->render_page('index'); @@ -107,14 +120,19 @@ class mchat */ public function page_custom() { - if (!$this->auth->acl_get('u_mchat_view') || !$this->config['mchat_custom_page']) + if (!$this->auth->acl_get('u_mchat_view')) + { + throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED'); + } + + if (!$this->config['mchat_custom_page']) { throw new \phpbb\exception\http_exception(403, 'MCHAT_NO_CUSTOM_PAGE'); } - $this->functions_mchat->mchat_prune(); + $this->functions->mchat_prune(); - $this->functions_mchat->mchat_add_user_session(); + $this->functions->mchat_add_user_session(); $this->assign_whois(); @@ -145,7 +163,7 @@ class mchat throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS_ARCHIVE'); } - $this->functions_mchat->mchat_prune(); + $this->functions->mchat_prune(); $this->template->assign_var('MCHAT_ARCHIVE_PAGE', true); @@ -175,7 +193,7 @@ class mchat { if (!$this->auth->acl_get('u_mchat_ip')) { - throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION'); + throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED'); } if (!function_exists('user_ipwhois')) @@ -195,17 +213,21 @@ class mchat */ public function page_rules() { - if (empty($this->config['mchat_rules']) && !$this->user->lang('MCHAT_RULES_MESSAGE')) + if (!$this->auth->acl_get('u_mchat_view')) + { + throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED'); + } + + $lang_rules = $this->user->lang('MCHAT_RULES_MESSAGE'); + if (!$this->config['mchat_rules'] && !$lang_rules) { throw new \phpbb\exception\http_exception(404, 'MCHAT_NO_RULES'); } // If the rules are defined in the language file use them, else just use the entry in the database - $mchat_rules = $this->user->lang('MCHAT_RULES_MESSAGE'); - $mchat_rules = !empty($mchat_rules) ? $mchat_rules : $this->config['mchat_rules']; - $mchat_rules = explode("\n", $mchat_rules); - $mchat_rules = array_map('htmlspecialchars_decode', $mchat_rules); - $mchat_rules = implode('
', $mchat_rules); + $mchat_rules = $lang_rules ?: $this->config['mchat_rules']; + $mchat_rules = htmlspecialchars_decode($mchat_rules); + $mchat_rules = str_replace("\n", '
', $mchat_rules); $this->template->assign_var('MCHAT_RULES', $mchat_rules); @@ -224,20 +246,25 @@ class mchat throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS'); } - if ($this->functions_mchat->mchat_is_user_flooding()) + if ($this->functions->mchat_is_user_flooding()) { throw new \phpbb\exception\http_exception(400, 'MCHAT_NOACCESS'); } $message = $this->request->variable('message', '', true); - $sql_ary = $this->process_message(utf8_ucfirst($message), array( + if ($this->user->data['user_mchat_capital_letter']) + { + $message = utf8_ucfirst($message); + } + + $sql_ary = $this->process_message($message, array( 'user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['session_ip'], 'message_time' => time(), )); - $this->functions_mchat->mchat_action('add', $sql_ary); + $is_new_session = $this->functions->mchat_action('add', $sql_ary); /** * Event render_helper_add @@ -247,7 +274,14 @@ class mchat */ $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_add'); - return $this->action_refresh(); + $data = $this->action_refresh(); + + if ($is_new_session) + { + $data['whois'] = true; + } + + return $data; } /** @@ -257,12 +291,6 @@ class mchat */ public function action_edit() { - // Fix avatar path when editing archived messages - if (!defined('PHPBB_USE_BOARD_URL_PATH')) - { - define('PHPBB_USE_BOARD_URL_PATH', true); - } - $message_id = $this->request->variable('message_id', 0); if (!$message_id || !check_form_key('mchat', -1)) @@ -270,21 +298,23 @@ class mchat throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS'); } - $author = $this->functions_mchat->mchat_author_for_message($message_id); + $author = $this->functions->mchat_author_for_message($message_id); if (!$author || !$this->auth_message('u_mchat_edit', $author['user_id'], $author['message_time'])) { throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS'); } + $is_archive = $this->request->variable('archive', 0); + $this->template->assign_var('MCHAT_ARCHIVE_PAGE', $is_archive); + $message = $this->request->variable('message', '', true); $sql_ary = $this->process_message($message, array( 'edit_time' => time(), )); - // TODO Don't update the message if the user submitted it unedited - $this->functions_mchat->mchat_action('edit', $sql_ary, $message_id, $author['username']); + $this->functions->mchat_action('edit', $sql_ary, $message_id, $author['username']); /** * Event render_helper_edit @@ -295,10 +325,10 @@ class mchat $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_edit'); $sql_where = 'm.message_id = ' . (int) $message_id; - $rows = $this->functions_mchat->mchat_get_messages($sql_where, 1); + $rows = $this->functions->mchat_get_messages($sql_where, 1); $this->assign_global_template_data(); - $this->assign_messages($rows); + $this->assign_messages($rows, $is_archive ? 'archive' : ''); return array('edit' => $this->render_template('mchat_messages.html')); } @@ -317,7 +347,7 @@ class mchat throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS'); } - $author = $this->functions_mchat->mchat_author_for_message($message_id); + $author = $this->functions->mchat_author_for_message($message_id); if (!$author || !$this->auth_message('u_mchat_delete', $author['user_id'], $author['message_time'])) { @@ -332,7 +362,7 @@ class mchat */ $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_delete'); - $this->functions_mchat->mchat_action('del', null, $message_id, $author['username']); + $this->functions->mchat_action('del', null, $message_id, $author['username']); return array('del' => true); } @@ -344,6 +374,17 @@ class mchat */ public function action_refresh() { + if (!$this->auth->acl_get('u_mchat_view')) + { + throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS'); + } + + // Keep the session alive forever if there is no user session timeout + if (!$this->config['mchat_timeout']) + { + $this->user->update_session_infos(); + } + $message_first_id = $this->request->variable('message_first_id', 0); $message_last_id = $this->request->variable('message_last_id', 0); $message_edits = $this->request->variable('message_edits', array(0)); @@ -354,8 +395,11 @@ class mchat // Request edited messages if ($this->config['mchat_live_updates'] && $message_last_id > 0) { - $sql_time_limit = $this->config['mchat_edit_delete_limit'] ? sprintf(' AND m.message_time > %d', time() - $this->config['mchat_edit_delete_limit']) : ''; - $sql_where .= sprintf(' OR (m.message_id BETWEEN %d AND %d AND m.edit_time > 0%s)', (int) $message_first_id , (int) $message_last_id, $sql_time_limit); + $sql_where .= sprintf(' OR (m.message_id BETWEEN %d AND %d AND m.edit_time > 0)', (int) $message_first_id , (int) $message_last_id); + if ($this->config['mchat_edit_delete_limit']) + { + $sql_where .= sprintf(' AND m.message_time > %d', time() - $this->config['mchat_edit_delete_limit']); + } } // Exclude post notifications @@ -364,7 +408,7 @@ class mchat $sql_where = '(' . $sql_where . ') AND m.forum_id = 0'; } - $rows = $this->functions_mchat->mchat_get_messages($sql_where); + $rows = $this->functions->mchat_get_messages($sql_where); $rows_refresh = array(); $rows_edit = array(); @@ -381,27 +425,32 @@ class mchat } } - // Assign new messages - $this->assign_global_template_data(); - $this->assign_messages($rows_refresh); - $response = array('refresh' => true, 'add' => $this->render_template('mchat_messages.html')); - - // Assign edited messages - if (!empty($rows_edit)) + if ($rows_refresh || $rows_edit) { - $response['edit'] = array(); - foreach ($rows_edit as $row) - { - $this->assign_messages(array($row)); - $response['edit'][$row['message_id']] = $this->render_template('mchat_messages.html'); - } + $this->assign_global_template_data(); } - // Request deleted messages + $response = array('refresh' => true); + + // Assign new messages + if ($rows_refresh) + { + $this->assign_messages($rows_refresh); + $response['add'] = $this->render_template('mchat_messages.html'); + } + + // Assign edited messages + if ($rows_edit) + { + $this->assign_messages($rows_edit); + $response['edit'] = $this->render_template('mchat_messages.html'); + } + + // Assign deleted messages if ($this->config['mchat_live_updates'] && $message_last_id > 0) { - $deleted_message_ids = $this->functions_mchat->mchat_missing_ids($message_first_id, $message_last_id); - if (!empty($deleted_message_ids)) + $deleted_message_ids = $this->functions->mchat_deleted_ids($message_first_id); + if ($deleted_message_ids) { $response['del'] = $deleted_message_ids; } @@ -429,28 +478,12 @@ class mchat { $this->template->assign_vars(array( 'MCHAT_ALLOW_VIEW' => $this->auth->acl_get('u_mchat_view'), + 'MCHAT_NAVBAR_LINK' => $this->config['mchat_navbar_link'], 'S_MCHAT_CUSTOM_PAGE' => $this->config['mchat_custom_page'], 'U_MCHAT' => $this->helper->route('dmzx_mchat_controller'), )); } - /** - * Appends a condition to the WHERE key of the SQL array to not fetch disallowed BBCodes from the database - * - * @param array $sql_ary - * @return array - */ - public function remove_disallowed_bbcodes($sql_ary) - { - // Add disallowed BBCodes to the template only if we're rendering for mChat - if ($this->is_mchat_rendered) - { - $sql_ary['WHERE'] = $this->functions_mchat->mchat_sql_append_forbidden_bbcodes($sql_ary['WHERE']); - } - - return $sql_ary; - } - /** * Renders data for a page * @@ -463,59 +496,95 @@ class mchat // If the static message is defined in the language file use it, else the entry in the database is used $lang_static_message = $this->user->lang('MCHAT_STATIC_MESSAGE'); - $static_message = !empty($lang_static_message) ? $lang_static_message : $this->config['mchat_static_message']; + $static_message = $lang_static_message ?: $this->config['mchat_static_message']; $this->template->assign_vars(array( - 'MCHAT_FILE_NAME' => $this->helper->route('dmzx_mchat_controller'), + 'U_MCHAT_CUSTOM_PAGE' => $this->helper->route('dmzx_mchat_controller'), 'MCHAT_REFRESH_JS' => 1000 * $this->config['mchat_refresh'], 'MCHAT_INPUT_TYPE' => $this->user->data['user_mchat_input_area'], - 'MCHAT_RULES' => $this->user->lang('MCHAT_RULES_MESSAGE') || !empty($this->config['mchat_rules']), + 'MCHAT_RULES' => $this->user->lang('MCHAT_RULES_MESSAGE') || $this->config['mchat_rules'], 'MCHAT_ALLOW_USE' => $this->auth->acl_get('u_mchat_use'), 'MCHAT_ALLOW_SMILES' => $this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies'), - 'MCHAT_ALLOW_BBCODES' => $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode'), + 'S_BBCODE_ALLOWED' => $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode'), 'MCHAT_MESSAGE_TOP' => $this->config['mchat_message_top'], 'MCHAT_ARCHIVE_URL' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'archive')), 'MCHAT_INDEX_HEIGHT' => $this->config['mchat_index_height'], 'MCHAT_CUSTOM_HEIGHT' => $this->config['mchat_custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $this->auth->acl_get('u_mchat_archive'), 'MCHAT_STATIC_MESS' => htmlspecialchars_decode($static_message), - 'L_MCHAT_COPYRIGHT' => base64_decode('PGEgaHJlZj0iaHR0cDovL3JtY2dpcnI4My5vcmciPlJNY0dpcnI4MzwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZG16eC13ZWIubmV0IiB0aXRsZT0id3d3LmRtengtd2ViLm5ldCI+ZG16eDwvYT4='), + 'L_MCHAT_COPYRIGHT' => base64_decode('PHNwYW4gY2xhc3M9Im1jaGF0LWNvcHlyaWdodCIgdGl0bGU9ImRtenggJmJ1bGw7IGthc2ltaSAmYnVsbDsgUk1jR2lycjgzIj4mY29weTs8L3NwYW4+'), 'MCHAT_MESSAGE_LNGTH' => $this->config['mchat_max_message_lngth'], - 'MCHAT_MESS_LONG' => sprintf($this->user->lang('MCHAT_MESS_LONG'), $this->config['mchat_max_message_lngth']), + 'MCHAT_MESS_LONG' => $this->user->lang('MCHAT_MESS_LONG', $this->config['mchat_max_message_lngth']), 'MCHAT_USER_TIMEOUT_TIME' => gmdate('H:i:s', (int) $this->config['mchat_timeout']), 'MCHAT_WHOIS_REFRESH' => $this->config['mchat_whois'] ? 1000 * $this->config['mchat_whois_refresh'] : 0, - 'MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($this->user->lang('WHO_IS_REFRESH_EXPLAIN'), $this->config['mchat_whois_refresh']), + 'MCHAT_WHOIS_REFRESH_EXPLAIN' => $this->user->lang('MCHAT_WHO_IS_REFRESH_EXPLAIN', $this->config['mchat_whois_refresh']), 'MCHAT_PAUSE_ON_INPUT' => $this->config['mchat_pause_on_input'], - 'MCHAT_REFRESH_YES' => sprintf($this->user->lang('MCHAT_REFRESH_YES'), $this->config['mchat_refresh']), + 'MCHAT_REFRESH_YES' => $this->user->lang('MCHAT_REFRESH_YES', $this->config['mchat_refresh']), 'MCHAT_LIVE_UPDATES' => $this->config['mchat_live_updates'], 'S_MCHAT_LOCATION' => $this->config['mchat_location'], 'S_MCHAT_SOUND_YES' => $this->user->data['user_mchat_sound'], 'U_MORE_SMILIES' => generate_board_url() . append_sid("/{$this->root_path}/posting.{$this->php_ext}", 'mode=smilies'), 'U_MCHAT_RULES' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'rules')), - 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && !empty($this->user->data['user_mchat_index']), + 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && $this->user->data['user_mchat_index'], )); + $md_manager = $this->extension_manager->create_extension_metadata_manager('dmzx/mchat', $this->template); + $md_manager->get_metadata('all'); + $md_manager->output_template_data(); + + // The template needs some language variables if we display relative time for messages + if ($this->config['mchat_relative_time'] && $page != 'archive') + { + $minutes_limit = $this->get_relative_minutes_limit(); + for ($i = 0; $i < $minutes_limit; $i++) + { + $this->template->assign_block_vars('mchattime', array( + 'KEY' => $i, + 'LANG' => $this->user->lang('MCHAT_MINUTES_AGO', $i), + 'IS_LAST' => $i + 1 === $minutes_limit, + )); + } + } + + // Get actions which the user is allowed to perform on the current page + $actions = array_keys(array_filter(array( + 'edit' => $this->auth_message('u_mchat_edit', true, time()), + 'del' => $this->auth_message('u_mchat_delete', true, time()), + 'refresh' => $page != 'archive' && $this->auth->acl_get('u_mchat_view'), + 'add' => $page != 'archive' && $this->auth->acl_get('u_mchat_use'), + 'whois' => $page != 'archive' && $this->config['mchat_whois'], + ))); + + foreach ($actions as $i => $action) + { + $this->template->assign_block_vars('mchaturl', array( + 'ACTION' => $action, + 'URL' => $this->helper->route('dmzx_mchat_action_controller', array('action' => $action)), + 'IS_LAST' => $i + 1 === count($actions), + )); + } + $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'm.forum_id = 0'; $limit = $page == 'archive' ? $this->config['mchat_archive_limit'] : $this->config[$page == 'index' ? 'mchat_message_num' : 'mchat_message_limit']; $start = $page == 'archive' ? $this->request->variable('start', 0) : 0; - $rows = $this->functions_mchat->mchat_get_messages($sql_where, $limit, $start); + $rows = $this->functions->mchat_get_messages($sql_where, $limit, $start); $this->assign_global_template_data(); - $this->assign_messages($rows); + $this->assign_messages($rows, $page); // Render pagination if ($page == 'archive') { $archive_url = $this->helper->route('dmzx_mchat_page_controller', array('page' => 'archive')); - $total_messages = $this->functions_mchat->mchat_total_message_count(); + $total_messages = $this->functions->mchat_total_message_count(); $this->pagination->generate_template_pagination($archive_url, 'pagination', 'start', $total_messages, $limit, $start); - $this->template->assign_var('MCHAT_TOTAL_MESSAGES', sprintf($this->user->lang('MCHAT_TOTALMESSAGES'), $total_messages)); + $this->template->assign_var('MCHAT_TOTAL_MESSAGES', $this->user->lang('MCHAT_TOTALMESSAGES', $total_messages)); } // Render legend if ($page != 'index' && $this->config['mchat_whois']) { - $legend = $this->functions_mchat->mchat_legend(); + $legend = $this->functions->mchat_legend(); $this->template->assign_var('LEGEND', implode(', ', $legend)); } @@ -524,8 +593,6 @@ class mchat add_form_key('mchat'); } - $this->is_mchat_rendered = true; - /** * Event render_helper_aft * @@ -536,7 +603,7 @@ class mchat } /** - * Assigns all message rows to the template + * Assigns common template data that is required for displaying messages */ protected function assign_global_template_data() { @@ -547,6 +614,7 @@ class mchat 'MCHAT_ALLOW_QUOTE' => $this->auth->acl_get('u_mchat_quote'), 'MCHAT_EDIT_DELETE_LIMIT' => 1000 * $this->config['mchat_edit_delete_limit'], 'MCHAT_EDIT_DELETE_IGNORE' => $this->config['mchat_edit_delete_limit'] && $this->auth->acl_get('m_'), + 'MCHAT_RELATIVE_TIME' => $this->config['mchat_relative_time'], 'MCHAT_USER_TIMEOUT' => 1000 * $this->config['mchat_timeout'], 'S_MCHAT_AVATARS' => $this->display_avatars(), 'EXT_URL' => generate_board_url() . '/ext/dmzx/mchat/', @@ -568,10 +636,11 @@ class mchat * Assigns all message rows to the template * * @param array $rows + * @param string $page */ - protected function assign_messages($rows) + protected function assign_messages($rows, $page = '') { - if (empty($rows)) + if (!$rows) { return; } @@ -582,7 +651,7 @@ class mchat $rows = array_reverse($rows); } - $foes = $this->functions_mchat->mchat_foes(); + $foes = $this->functions->mchat_foes(); $this->template->destroy_block_vars('mchatrow'); @@ -602,84 +671,149 @@ class mchat } } + $board_url = generate_board_url() . '/'; + foreach ($rows as $i => $row) { // Auth checks - if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) + if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) { continue; } $message_edit = $row['message']; decode_message($message_edit, $row['bbcode_uid']); - $message_edit = str_replace('"', '"', $message_edit); - $message_edit = mb_ereg_replace("'", '’', $message_edit); if (in_array($row['user_id'], $foes)) { - $row['message'] = sprintf($this->user->lang('MCHAT_FOE'), get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'))); + $row['message'] = $this->user->lang('MCHAT_FOE', get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'))); } - $row['username'] = mb_ereg_replace("'", "’", $row['username']); - $message = str_replace("'", '’', $row['message']); + $username_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')); + + // Fix profile link root path by replacing relative paths with absolute board URL + if ($this->request->is_ajax()) + { + $username_full = preg_replace('#(?<=href=")[\./]+?/(?=\w)#', $board_url, $username_full); + } + + $message_age = time() - $row['message_time']; + $minutes_ago = $this->get_minutes_ago($message_age, $page); + $datetime = $this->user->format_date($row['message_time'], $this->config['mchat_date']); $this->template->assign_block_vars('mchatrow', array( - 'S_ROW_COUNT' => $i, 'MCHAT_ALLOW_BAN' => $this->auth->acl_get('a_authusers'), 'MCHAT_ALLOW_EDIT' => $this->auth_message('u_mchat_edit', $row['user_id'], $row['message_time']), 'MCHAT_ALLOW_DEL' => $this->auth_message('u_mchat_delete', $row['user_id'], $row['message_time']), 'MCHAT_USER_AVATAR' => $user_avatars[$row['user_id']], - 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? generate_board_url() . append_sid("/{$this->root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $row['user_id']) : '', + 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$board_url}{$this->root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $row['user_id']) : '', 'MCHAT_IS_POSTER' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] == $row['user_id'], - 'MCHAT_PM' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? generate_board_url() . append_sid("/{$this->root_path}ucp.{$this->php_ext}", 'i=pm&mode=compose&u=' . $row['user_id']) : '', + 'MCHAT_PM' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$board_url}{$this->root_path}ucp.{$this->php_ext}", 'i=pm&mode=compose&u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, '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' => $username_full, '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_WHOIS_USER' => $this->user->lang('MCHAT_WHOIS_USER', $row['user_ip']), 'MCHAT_U_IP' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'whois', 'ip' => $row['user_ip'])), - 'MCHAT_U_BAN' => generate_board_url() . append_sid("/{$this->root_path}adm/index.{$this->php_ext}" ,'i=permissions&mode=setting_user_global&user_id[0]=' . $row['user_id'], true, $this->user->session_id), - 'MCHAT_MESSAGE' => censor_text(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_U_BAN' => append_sid("{$board_url}{$this->root_path}adm/index.{$this->php_ext}" ,'i=permissions&mode=setting_user_global&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_TIME' => $minutes_ago === -1 ? $datetime : $this->user->lang('MCHAT_MINUTES_AGO', $minutes_ago), + 'MCHAT_DATETIME' => $datetime, + 'MCHAT_MINUTES_AGO' => $minutes_ago, + 'MCHAT_RELATIVE_UPDATE' => 60 - $message_age % 60, 'MCHAT_MESSAGE_TIME' => $row['message_time'], 'MCHAT_EDIT_TIME' => $row['edit_time'], )); } } + /** + * Calculates the number of minutes that have passed since the message was posted. If relative time is disabled + * or the message is older than 59 minutes or we render for the archive, -1 is returned. + * + * @param int $message_age + * @param string $page + * @return int + */ + protected function get_minutes_ago($message_age, $page) + { + if ($this->config['mchat_relative_time'] && $page != 'archive') + { + $minutes_ago = floor($message_age / 60); + if ($minutes_ago < $this->get_relative_minutes_limit()) + { + return $minutes_ago; + } + } + + return -1; + } + + /** + * Calculates the amount of time after which messages switch from displaying relative time + * to displaying absolute time. Uses mChat's timeout if it's not zero, otherwise phpBB's + * global session timeout, but never shorter than 1 minute and never longer than 60 minutes. + * + * @return int + */ + protected function get_relative_minutes_limit() + { + $timeout = $this->config['session_length']; + + if ($this->config['mchat_timeout']) + { + $timeout = $this->config['mchat_timeout']; + } + + return min(max((int) ceil($timeout / 60), 1), 60); + } + /** * Assigns BBCodes and smilies to the template */ protected function assign_bbcodes_smilies() { - // Display custom bbcodes + // Display BBCodes if ($this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode')) { - $default_bbcodes = array('B', 'I', 'U', 'QUOTE', 'CODE', 'LIST', 'IMG', 'URL', 'SIZE', 'COLOR', 'EMAIL', 'FLASH'); + $bbcode_template_vars = array( + 'quote' => array( + 'allow' => true, + 'template_var' => 'S_BBCODE_QUOTE', + ), + 'img' => array( + 'allow' => true, + 'template_var' => 'S_BBCODE_IMG', + ), + 'url' => array( + 'allow' => $this->config['allow_post_links'], + 'template_var' => 'S_LINKS_ALLOWED', + ), + 'flash' => array( + 'allow' => $this->config['allow_post_flash'], + 'template_var' => 'S_BBCODE_FLASH', + ), + ); - // Let's remove the default bbcodes - $disallowed_bbcode_array = explode('|', strtoupper($this->config['mchat_bbcode_disallowed'])); - - foreach ($default_bbcodes as $default_bbcode) + foreach ($bbcode_template_vars as $bbcode => $option) { - if (!in_array($default_bbcode, $disallowed_bbcode_array)) - { - $this->template->assign_vars(array( - 'S_MCHAT_BBCODE_' . $default_bbcode => true, - )); - } + $is_disallowed = preg_match('#(^|\|)' . $bbcode . '($|\|)#Usi', $this->config['mchat_bbcode_disallowed']) || !$option['allow']; + $this->template->assign_var($option['template_var'], !$is_disallowed); } + $this->template->assign_var('S_DISALLOWED_BBCODES', str_replace('=', '-', $this->config['mchat_bbcode_disallowed'])); + if (!function_exists('display_custom_bbcodes')) { include($this->root_path . 'includes/functions_display.' . $this->php_ext); } + $this->remove_disallowed_bbcodes = true; display_custom_bbcodes(); } - // Smile row + // Display smilies if ($this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies')) { if (!function_exists('generate_smilies')) @@ -691,6 +825,23 @@ class mchat } } + /** + * Appends a condition to the WHERE key of the SQL array to not fetch disallowed BBCodes from the database + * + * @param array $sql_ary + * @return array + */ + public function remove_disallowed_bbcodes($sql_ary) + { + // Add disallowed BBCodes to the template only if we're rendering for mChat + if ($this->remove_disallowed_bbcodes) + { + $sql_ary['WHERE'] = $this->functions->mchat_sql_append_forbidden_bbcodes($sql_ary['WHERE']); + } + + return $sql_ary; + } + /** * Assigns whois and stats at the bottom of the index page */ @@ -698,11 +849,11 @@ class mchat { if ($this->config['mchat_whois'] || $this->config['mchat_stats_index'] && $this->user->data['user_mchat_stats_index']) { - $mchat_stats = $this->functions_mchat->mchat_active_users(); + $mchat_stats = $this->functions->mchat_active_users(); $this->template->assign_vars(array( 'MCHAT_INDEX_STATS' => $this->config['mchat_stats_index'] && $this->user->data['user_mchat_stats_index'], 'MCHAT_USERS_COUNT' => $mchat_stats['mchat_users_count'], - 'MCHAT_USERS_LIST' => !empty($mchat_stats['online_userlist']) ? $mchat_stats['online_userlist'] : '', + 'MCHAT_USERS_LIST' => $mchat_stats['online_userlist'] ?: '', 'MCHAT_ONLINE_EXPLAIN' => $mchat_stats['refresh_message'], )); } @@ -744,7 +895,7 @@ class mchat { // Must have something other than bbcode in the message $message_chars = trim(preg_replace('#\[/?[^\[\]]+\]#mi', '', $message)); - if (!$message || !utf8_strlen($message_chars)) + if (!utf8_strlen($message_chars)) { throw new \phpbb\exception\http_exception(501, 'MCHAT_NOACCESS'); } diff --git a/event/acp_listener.php b/event/acp_listener.php new file mode 100644 index 0000000..7d098c1 --- /dev/null +++ b/event/acp_listener.php @@ -0,0 +1,170 @@ +template = $template; + $this->request = $request; + $this->user = $user; + $this->user_config_keys = $user_config_keys; + } + + /** + * @return array + */ + static public function getSubscribedEvents() + { + return array( + 'core.permissions' => 'permissions', + 'core.acp_users_prefs_modify_data' => 'acp_users_prefs_modify_data', + 'core.acp_users_prefs_modify_sql' => 'acp_users_prefs_modify_sql', + 'core.acp_users_prefs_modify_template_data' => 'acp_users_prefs_modify_template_data', + ); + } + + /** + * @param object $event The event object + */ + public function permissions($event) + { + $event['permissions'] = array_merge($event['permissions'], array( + 'u_mchat_use' => array( + 'lang' => 'ACL_U_MCHAT_USE', + 'cat' => 'mChat' + ), + 'u_mchat_view' => array( + 'lang' => 'ACL_U_MCHAT_VIEW', + 'cat' => 'mChat' + ), + 'u_mchat_edit' => array( + 'lang' => 'ACL_U_MCHAT_EDIT', + 'cat' => 'mChat' + ), + 'u_mchat_delete' => array( + 'lang' => 'ACL_U_MCHAT_DELETE', + 'cat' => 'mChat' + ), + 'u_mchat_ip' => array( + 'lang' => 'ACL_U_MCHAT_IP', + 'cat' => 'mChat' + ), + 'u_mchat_pm' => array( + 'lang' => 'ACL_U_MCHAT_PM', + 'cat' => 'mChat' + ), + 'u_mchat_like' => array( + 'lang' => 'ACL_U_MCHAT_LIKE', + 'cat' => 'mChat' + ), + 'u_mchat_quote' => array( + 'lang' => 'ACL_U_MCHAT_QUOTE', + 'cat' => 'mChat' + ), + 'u_mchat_flood_ignore' => array( + 'lang' => 'ACL_U_MCHAT_FLOOD_IGNORE', + 'cat' => 'mChat' + ), + 'u_mchat_archive' => array( + 'lang' => 'ACL_U_MCHAT_ARCHIVE', + 'cat' => 'mChat' + ), + 'u_mchat_bbcode' => array( + 'lang' => 'ACL_U_MCHAT_BBCODE', + 'cat' => 'mChat' + ), + 'u_mchat_smilies' => array( + 'lang' => 'ACL_U_MCHAT_SMILIES', + 'cat' => 'mChat' + ), + 'u_mchat_urls' => array( + 'lang' => 'ACL_U_MCHAT_URLS', + 'cat' => 'mChat' + ), + 'a_mchat' => array( + 'lang' => 'ACL_A_MCHAT', + 'cat' => 'mChat' + ), + )); + + $event['categories'] = array_merge($event['categories'], array( + 'mChat' => 'ACP_CAT_MCHAT', + )); + } + + /** + * @param object $event The event object + */ + public function acp_users_prefs_modify_data($event) + { + $data = $event['data']; + + foreach ($this->user_config_keys as $config_key) + { + $data[$config_key] = $this->request->variable($config_key, (int) $event['user_row'][$config_key]); + } + + $event['data'] = $data; + } + + /** + * @param object $event The event object + */ + public function acp_users_prefs_modify_template_data($event) + { + $this->user->add_lang_ext('dmzx/mchat', 'mchat_ucp'); + + foreach ($this->user_config_keys as $config_key) + { + $this->template->assign_var(strtoupper($config_key), $event['data'][$config_key]); + } + } + + /** + * @param object $event The event object + */ + public function acp_users_prefs_modify_sql($event) + { + $sql_ary = $event['sql_ary']; + + foreach ($this->user_config_keys as $config_key) + { + $sql_ary[$config_key] = $event['data'][$config_key]; + } + + $event['sql_ary'] = $sql_ary; + } +} diff --git a/event/listener.php b/event/main_listener.php similarity index 51% rename from event/listener.php rename to event/main_listener.php index fc8a616..8d7f69e 100644 --- a/event/listener.php +++ b/event/main_listener.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -12,10 +13,10 @@ namespace dmzx\mchat\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class listener implements EventSubscriberInterface +class main_listener implements EventSubscriberInterface { - /** @var \dmzx\mchat\core\functions_mchat */ - protected $functions_mchat; + /** @var \dmzx\mchat\core\functions */ + protected $functions; /** @var \dmzx\mchat\core\mchat */ protected $mchat; @@ -32,19 +33,19 @@ class listener implements EventSubscriberInterface /** * Constructor * - * @param \dmzx\mchat\core\functions_mchat $functions_mchat - * @param \dmzx\mchat\core\mchat $mchat - * @param \phpbb\controller\helper $helper - * @param \phpbb\user $user - * @param string $php_ext + * @param \dmzx\mchat\core\functions $functions + * @param \dmzx\mchat\core\mchat $mchat + * @param \phpbb\controller\helper $helper + * @param \phpbb\user $user + * @param string $php_ext */ - public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \dmzx\mchat\core\mchat $mchat, \phpbb\controller\helper $helper, \phpbb\user $user, $php_ext) + public function __construct(\dmzx\mchat\core\functions $functions, \dmzx\mchat\core\mchat $mchat, \phpbb\controller\helper $helper, \phpbb\user $user, $php_ext) { - $this->functions_mchat = $functions_mchat; - $this->mchat = $mchat; - $this->helper = $helper; - $this->user = $user; - $this->php_ext = $php_ext; + $this->functions = $functions; + $this->mchat = $mchat; + $this->helper = $helper; + $this->user = $user; + $this->php_ext = $php_ext; } /** @@ -58,7 +59,6 @@ class listener implements EventSubscriberInterface 'core.page_header' => 'add_page_header_link', 'core.index_modify_page_title' => 'display_mchat_on_index', 'core.posting_modify_submit_post_after' => 'posting_modify_submit_post_after', - 'core.permissions' => 'permissions', 'core.display_custom_bbcodes_modify_sql' => 'display_custom_bbcodes_modify_sql', ); } @@ -113,7 +113,7 @@ class listener implements EventSubscriberInterface */ public function posting_modify_submit_post_after($event) { - $this->functions_mchat->mchat_insert_posting($event['mode'], array( + $this->functions->mchat_insert_posting($event['mode'], array( 'forum_id' => $event['forum_id'], 'forum_name' => $event['post_data']['forum_name'], 'post_id' => $event['data']['post_id'], @@ -128,73 +128,4 @@ class listener implements EventSubscriberInterface { $event['sql_ary'] = $this->mchat->remove_disallowed_bbcodes($event['sql_ary']); } - - /** - * @param object $event The event object - */ - public function permissions($event) - { - $event['permissions'] = array_merge($event['permissions'], array( - 'u_mchat_use' => array( - 'lang' => 'ACL_U_MCHAT_USE', - 'cat' => 'mChat' - ), - 'u_mchat_view' => array( - 'lang' => 'ACL_U_MCHAT_VIEW', - 'cat' => 'mChat' - ), - 'u_mchat_edit' => array( - 'lang' => 'ACL_U_MCHAT_EDIT', - 'cat' => 'mChat' - ), - 'u_mchat_delete' => array( - 'lang' => 'ACL_U_MCHAT_DELETE', - 'cat' => 'mChat' - ), - 'u_mchat_ip' => array( - 'lang' => 'ACL_U_MCHAT_IP', - 'cat' => 'mChat' - ), - 'u_mchat_pm' => array( - 'lang' => 'ACL_U_MCHAT_PM', - 'cat' => 'mChat' - ), - 'u_mchat_like' => array( - 'lang' => 'ACL_U_MCHAT_LIKE', - 'cat' => 'mChat' - ), - 'u_mchat_quote' => array( - 'lang' => 'ACL_U_MCHAT_QUOTE', - 'cat' => 'mChat' - ), - 'u_mchat_flood_ignore' => array( - 'lang' => 'ACL_U_MCHAT_FLOOD_IGNORE', - 'cat' => 'mChat' - ), - 'u_mchat_archive' => array( - 'lang' => 'ACL_U_MCHAT_ARCHIVE', - 'cat' => 'mChat' - ), - 'u_mchat_bbcode' => array( - 'lang' => 'ACL_U_MCHAT_BBCODE', - 'cat' => 'mChat' - ), - 'u_mchat_smilies' => array( - 'lang' => 'ACL_U_MCHAT_SMILIES', - 'cat' => 'mChat' - ), - 'u_mchat_urls' => array( - 'lang' => 'ACL_U_MCHAT_URLS', - 'cat' => 'mChat' - ), - 'a_mchat' => array( - 'lang' => 'ACL_A_MCHAT', - 'cat' => 'mChat' - ), - )); - - $event['categories'] = array_merge($event['categories'], array( - 'mChat' => 'ACP_CAT_MCHAT', - )); - } } diff --git a/language/en/common.php b/language/en/common.php index 590d6a1..e043710 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -29,21 +30,21 @@ if (empty($lang) || !is_array($lang)) // You do not need this where single placeholders are used, e.g. 'Message %d' is fine // equally where a string contains only two placeholders which are used to wrap text // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine +// +// Some characters for use +// ’ » “ ” … $lang = array_merge($lang, array( 'MCHAT_TITLE' => 'mChat', - 'MCHAT_ADD' => 'Send', - 'MCHAT_ANNOUNCEMENT' => 'Announcement', - 'MCHAT_ARCHIVE' => 'Archive', - 'MCHAT_ARCHIVE_PAGE' => 'mChat Archive', - 'MCHAT_BBCODES' => 'BBCodes', - 'MCHAT_CUSTOM_BBCODES' => 'Custom BBCodes', - 'MCHAT_DELCONFIRM' => 'Do you confirm removal?', - 'MCHAT_EDIT' => 'Edit', - 'MCHAT_EDITINFO' => 'Edit the message and click OK', - 'MCHAT_FLOOD' => 'You can not post another message so soon after your last', - 'MCHAT_FOE' => 'This message was made by %1$s who is currently on your ignore list.', - 'MCHAT_RULES' => 'Rules', + + // Who is chatting + 'MCHAT_WHO_IS_CHATTING' => 'Who is chatting', + 'MCHAT_ONLINE_USERS_TOTAL' => array( + 0 => 'No one is chatting', + 1 => 'There is %1$d user chatting', + 2 => 'There are %1$d users chatting', + ), + 'MCHAT_ONLINE_EXPLAIN' => 'based on users active over the past %1$s', 'MCHAT_HOURS' => array( 1 => '%1$d hour', 2 => '%1$d hours', @@ -56,68 +57,11 @@ $lang = array_merge($lang, array( 1 => '%1$d second', 2 => '%1$d seconds', ), - '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_RULES' => 'The mChat rules page is not activated at this time!', - 'MCHAT_NOACCESS' => 'You don’t have permission to post in the mChat', - 'MCHAT_NOACCESS_ARCHIVE' => 'You don’t have permission to view the archive', - 'MCHAT_NOJAVASCRIPT' => 'Your browser does not support JavaScript or JavaScript is disabled', - 'MCHAT_NOMESSAGE' => 'No messages', - 'MCHAT_NOMESSAGEINPUT' => 'You have not entered a message', - 'MCHAT_NOSMILE' => 'Smilies not found', - 'MCHAT_OK' => 'OK', - 'MCHAT_PAUSE' => 'Paused', - 'MCHAT_PERMISSIONS' => 'Change user’s permissions', - 'MCHAT_REFRESHING' => 'Refreshing...', - 'MCHAT_REFRESH_NO' => 'Update is off', - 'MCHAT_REFRESH_YES' => 'Updates every %1$d seconds', - 'MCHAT_RESPOND' => 'Respond to user', - 'MCHAT_RESET_QUESTION' => 'Clear the input area?', - 'MCHAT_SESSION_OUT' => 'Chat session has expired', - 'MCHAT_SESSION_ENDS' => 'Chat session ends in', - 'MCHAT_SMILES' => 'Smilies', - 'MCHAT_TOTALMESSAGES' => 'Total messages: %1$d', - 'MCHAT_USESOUND' => 'Use sound', - 'MCHAT_ONLINE_USERS_TOTAL' => array( - 0 => 'No one is chatting', - 1 => 'In total there is %1$d user chatting', - 2 => 'In total there are %1$d users chatting', - ), - 'MCHAT_ONLINE_EXPLAIN' => 'based on users active over the past %1$s', - 'WHO_IS_CHATTING' => 'Who is chatting', - 'WHO_IS_REFRESH_EXPLAIN' => 'Refreshes every %d seconds', + // 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', 'MCHAT_NEW_REPLY' => 'Posted a reply: %1$s in %2$s', 'MCHAT_NEW_QUOTE' => 'Replied with a quote: %1$s in %2$s', 'MCHAT_NEW_EDIT' => 'Edited a post: %1$s in %2$s', - // UCP - 'UCP_PROFILE_MCHAT' => 'mChat preferences', - 'DISPLAY_MCHAT' => 'Display mChat on index', - 'SOUND_MCHAT' => 'Enable mChat sound', - 'DISPLAY_STATS_INDEX' => 'Display who is chatting on index', - 'DISPLAY_NEW_TOPICS' => 'Display new topics in the chat', - 'DISPLAY_AVATARS' => 'Display avatars in the chat', - 'CHAT_AREA' => 'Input type', - 'CHAT_AREA_EXPLAIN' => 'The type of area to use for writing messages', - 'INPUT_AREA' => 'Input area', - 'TEXT_AREA' => 'Text area', - 'UCP_CAT_MCHAT' => 'mChat', - 'UCP_MCHAT_CONFIG' => 'mChat', - - // Preferences - 'LOG_MCHAT_TABLE_PRUNED' => 'mChat messages were pruned', - 'ACP_USER_MCHAT' => 'mChat settings', - 'LOG_DELETED_MCHAT' => 'Deleted mChat message
» %1$s', - 'LOG_EDITED_MCHAT' => 'Edited mChat message
» %1$s', - 'MCHAT_NEW_CHAT' => 'New chat message!', - 'MCHAT_SEND_PM' => 'Send private message', - 'MCHAT_LIKE' => 'Like this post', - 'MCHAT_LIKES' => 'Likes this post', - - // Custom translations for administrators - 'MCHAT_RULES_MESSAGE' => '', - 'MCHAT_STATIC_MESSAGE' => '', )); diff --git a/language/en/info_acp_mchat.php b/language/en/info_acp_mchat.php index a36fcd6..6711913 100644 --- a/language/en/info_acp_mchat.php +++ b/language/en/info_acp_mchat.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -34,137 +35,14 @@ if (empty($lang) || !is_array($lang)) // ’ » “ ” … $lang = array_merge($lang, array( - 'ACP_MCHAT_CONFIG' => 'Configuration', + // Module titles 'ACP_CAT_MCHAT' => 'mChat', - 'ACP_MCHAT_TITLE' => 'mChat Extension for phpBB 3.1', - 'ACP_MCHAT_VERSION' => 'Version', - 'UCP_CAT_MCHAT' => 'mChat Prefs', - 'UCP_MCHAT_CONFIG' => 'User mChat Prefs', + 'ACP_MCHAT_CONFIG' => 'Configuration', - // ACP configuration sections - 'MCHAT_SETTINGS_INDEX' => 'Index page settings', - 'MCHAT_SETTINGS_CUSTOM' => 'Custom page settings', - 'MCHAT_SETTINGS_ARCHIVE' => 'Archive page settings', - 'MCHAT_SETTINGS_POSTS' => 'New posts settings', - 'MCHAT_SETTINGS_MESSAGES' => 'Message settings', - 'MCHAT_SETTINGS_PRUNE' => 'Pruning settings', - 'MCHAT_SETTINGS_STATS' => 'Who is chatting settings', - - // ACP entries - 'ACP_MCHAT_RULES' => 'Rules', - 'ACP_MCHAT_RULES_EXPLAIN' => 'Enter the rules of the forum here. Each rule on a new line. HTML code is allowed. You are limited to 255 characters.
This message can be translated: edit the MCHAT_RULES_MESSAGE language key in /ext/dmzx/mchat/language/XX/common.php.', - 'LOG_MCHAT_CONFIG_UPDATE' => 'Updated mChat config', - 'MCHAT_CONFIG_SAVED' => 'mChat configuration has been updated', - 'MCHAT_TITLE' => 'mChat', - 'MCHAT_AVATARS' => 'Display avatars', - 'MCHAT_AVATARS_EXPLAIN' => 'If set to yes, resized user avatars will be displayed', - 'MCHAT_ON_INDEX' => 'Display mChat on the index page', - 'MCHAT_INDEX_HEIGHT' => 'Index page height', - 'MCHAT_INDEX_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the index page.
You are limited from 50 to 1000.', - 'MCHAT_LOCATION' => 'Location of mChat on the index page', - 'MCHAT_TOP_OF_FORUM' => 'Top', - 'MCHAT_BOTTOM_OF_FORUM' => 'Bottom', - 'MCHAT_REFRESH' => 'Refresh interval', - 'MCHAT_REFRESH_EXPLAIN' => 'Number of seconds before the chat refreshes.
You are limited from 5 to 60 seconds.', - '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', - 'MCHAT_PRUNE_EXPLAIN' => 'Only occurs if a user views the custom or archive pages.', - 'MCHAT_PRUNE_NUM' => 'Number of messages to retain when pruning', - 'MCHAT_MESSAGE_LIMIT' => 'Number of messages to display on the custom page', - 'MCHAT_MESSAGE_LIMIT_EXPLAIN' => 'The maximum number of messages to show on the custom page.
Recommended from 10 to 30.', - 'MCHAT_MESSAGE_NUM' => 'Number of messages to display on the index page', - 'MCHAT_MESSAGE_NUM_EXPLAIN' => 'The maximum number of messages to show on the index page.
Recommended from 10 to 50.', - 'MCHAT_ARCHIVE_LIMIT' => 'Number of messages to display on the archive page', - 'MCHAT_ARCHIVE_LIMIT_EXPLAIN' => 'The maximum number of messages to show per page on the archive page.
Recommended from 25 to 50.', - 'MCHAT_FLOOD_TIME' => 'Flood time', - 'MCHAT_FLOOD_TIME_EXPLAIN' => 'The number of seconds a user must wait before posting another message in the chat.
Recommended 5 to 30, set to 0 to disable.', - 'MCHAT_EDIT_DELETE_LIMIT' => 'Time limit for editing and deleting messages', - 'MCHAT_EDIT_DELETE_LIMIT_EXPLAIN' => 'Messages older than the specified number of seconds cannot be edited or deleted by the author any more.
Users who have edit/delete permission as well as moderator permission are exempt from this time limit.
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.
Recommended from 100 to 500, set to 0 to disable.', - 'MCHAT_CUSTOM_PAGE' => 'Enable custom Page', - 'MCHAT_CUSTOM_PAGE_EXPLAIN' => 'Allow the use of the custom page', - 'MCHAT_CUSTOM_HEIGHT' => 'Custom page height', - 'MCHAT_CUSTOM_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the custom page.
You are limited from 50 to 1000.', - 'MCHAT_DATE_FORMAT' => 'Date format', - 'MCHAT_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP date() function.', - 'MCHAT_CUSTOM_DATEFORMAT' => 'Custom…', - 'MCHAT_BBCODES_DISALLOWED' => 'Disallowed bbcodes', - 'MCHAT_BBCODES_DISALLOWED_EXPLAIN' => 'Here you can input the bbcodes that are not to be used in a message.
Separate bbcodes with a vertical bar, for example:
b|i|u|code|list|list=|flash|quote and/or a %1$scustom bbcode tag name%2$s', - 'MCHAT_STATIC_MESSAGE' => 'Static message', - 'MCHAT_STATIC_MESSAGE_EXPLAIN' => 'Here you can define a static message to display to users of the chat. HTML code is allowed.
Set to empty to disable the display. You are limited to 255 characters.
This message can be translated: edit the MCHAT_STATIC_MESSAGE language key in /ext/dmzx/mchat/language/XX/common.php.', - 'MCHAT_USER_TIMEOUT' => 'User session timeout', - 'MCHAT_USER_TIMEOUT_EXPLAIN' => 'Set the amount of time in seconds until a user session in the chat ends. Set to 0 for no timeout.
You are limited to the %1$sforum config setting for sessions%2$s which is currently set to %3$d seconds', - 'MCHAT_OVERRIDE_SMILIE_LIMIT' => 'Override smilie limit', - '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_NEW_POSTS_TOPIC' => 'Display new topics', - 'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Allow topics from the forum to be posted in the chat.', - 'MCHAT_NEW_POSTS_REPLY' => 'Display new replies', - 'MCHAT_NEW_POSTS_REPLY_EXPLAIN' => 'Allow replies from the forum to be posted in the chat.', - 'MCHAT_NEW_POSTS_EDIT' => 'Display edited posts', - 'MCHAT_NEW_POSTS_EDIT_EXPLAIN' => 'Allow edited posts from the forum to be posted in the chat.', - 'MCHAT_NEW_POSTS_QUOTE' => 'Display quoted posts', - 'MCHAT_NEW_POSTS_QUOTE_EXPLAIN' => 'Allow quoted posts from the forum to be posted in the chat.', - - 'MCHAT_WHOIS' => 'Display Who is chatting below the chat', - 'MCHAT_STATS_INDEX' => 'Display Who is chatting in the stats section', - 'MCHAT_STATS_INDEX_EXPLAIN' => 'Displays who is chatting below the Who is online section on the index page', - 'MCHAT_WHOIS_REFRESH' => 'Who is chatting refresh interval', - 'MCHAT_WHOIS_REFRESH_EXPLAIN' => 'Number of seconds before who is chatting refreshes.
You are limited from 30 to 300 seconds.', - '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_BOTTOM' => 'Bottom', - 'MCHAT_TOP' => 'Top', - 'MCHAT_PAUSE_ON_INPUT' => 'Pause on input', - 'MCHAT_PAUSE_ON_INPUT_EXPLAIN' => 'Do not autoupdate upon a user entering a message in the input area', - 'MCHAT_PURGE' => 'Delete all messages now', - 'MCHAT_PURGE_CONFIRM' => 'Confirm deleting all messages', - 'MCHAT_PURGED' => 'All mChat messages have been successfully deleted', - - // Error reporting - 'TOO_SMALL_MCHAT_ARCHIVE_LIMIT' => 'The archive limit value is too small.', - 'TOO_LARGE_MCHAT_ARCHIVE_LIMIT' => 'The archive limit value is too large.', - '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_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_LIMIT' => 'The message limit value is too small.', - 'TOO_LARGE_MCHAT_MESSAGE_LIMIT' => 'The message limit value is too large.', - 'TOO_SMALL_MCHAT_MESSAGE_NUM' => 'The number of messages to display on the index page is too small.', - 'TOO_LARGE_MCHAT_MESSAGE_NUM' => 'The number of messages to display on the index 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.', - - // User perms - 'ACL_U_MCHAT_USE' => 'Can use mChat', - 'ACL_U_MCHAT_VIEW' => 'Can view mChat', - 'ACL_U_MCHAT_EDIT' => 'Can edit messages', - 'ACL_U_MCHAT_DELETE' => 'Can delete 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_FLOOD_IGNORE' => 'Can ignore flood limit', - 'ACL_U_MCHAT_ARCHIVE' => 'Can view the archive', - 'ACL_U_MCHAT_BBCODE' => 'Can use bbcodes', - 'ACL_U_MCHAT_SMILIES' => 'Can use smilies', - 'ACL_U_MCHAT_URLS' => 'Can post URLs', - - // Admin perms - 'ACL_A_MCHAT' => 'Can manage mChat settings', + // Log entries (%1$s is replaced with the user name who triggered the event) + 'LOG_MCHAT_CONFIG_UPDATE' => 'mChat configuration updated
» %1$s', + 'LOG_MCHAT_TABLE_PRUNED' => 'mChat messages pruned
» %1$s', + 'LOG_MCHAT_TABLE_PURGED' => 'mChat messages purged
» %1$s', + 'LOG_DELETED_MCHAT' => 'mChat message deleted
» %1$s', + 'LOG_EDITED_MCHAT' => 'mChat message edited
» %1$s', )); diff --git a/language/en/info_ucp_mchat.php b/language/en/info_ucp_mchat.php new file mode 100644 index 0000000..17189b8 --- /dev/null +++ b/language/en/info_ucp_mchat.php @@ -0,0 +1,39 @@ + 'mChat', +)); diff --git a/language/en/mchat.php b/language/en/mchat.php new file mode 100644 index 0000000..8a93aad --- /dev/null +++ b/language/en/mchat.php @@ -0,0 +1,85 @@ + 'Send', + 'MCHAT_ARCHIVE' => 'Archive', + 'MCHAT_ARCHIVE_PAGE' => 'mChat Archive', + 'MCHAT_BBCODES' => 'BBCodes', + 'MCHAT_CUSTOM_BBCODES' => 'Custom BBCodes', + 'MCHAT_DELCONFIRM' => 'Do you confirm removal?', + 'MCHAT_EDIT' => 'Edit', + 'MCHAT_EDITINFO' => 'Edit the message and click OK', + 'MCHAT_NEW_CHAT' => 'New chat message!', + 'MCHAT_SEND_PM' => 'Send private message', + 'MCHAT_LIKE' => 'Like this post', + 'MCHAT_LIKES' => 'Likes this post', + 'MCHAT_FLOOD' => 'You can not post another message so soon after your last', + 'MCHAT_FOE' => 'This message was made by %1$s who is currently on your ignore list.', + '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_RULES' => 'The mChat rules page is not activated at this time!', + 'MCHAT_NOACCESS' => 'You don’t have permission to post in the chat', + 'MCHAT_NOACCESS_ARCHIVE' => 'You don’t have permission to view the archive', + 'MCHAT_NOJAVASCRIPT' => 'Your browser does not support JavaScript or JavaScript is disabled', + 'MCHAT_NOMESSAGE' => 'No messages', + 'MCHAT_NOMESSAGEINPUT' => 'You have not entered a message', + 'MCHAT_OK' => 'OK', + 'MCHAT_PAUSE' => 'Paused', + 'MCHAT_PERMISSIONS' => 'Change user’s permissions', + 'MCHAT_REFRESHING' => 'Refreshing…', + 'MCHAT_REFRESH_NO' => 'Update is off', + 'MCHAT_REFRESH_YES' => 'Updates every %1$d seconds', + 'MCHAT_RESPOND' => 'Respond to user', + 'MCHAT_RESET_QUESTION' => 'Clear the input area?', + 'MCHAT_SESSION_OUT' => 'Chat session has expired', + 'MCHAT_SESSION_ENDS' => 'Chat session ends in', + 'MCHAT_SMILES' => 'Smilies', + 'MCHAT_TOTALMESSAGES' => 'Total messages: %1$d', + 'MCHAT_USESOUND' => 'Use sound', + 'MCHAT_WHO_IS_REFRESH_EXPLAIN' => 'Refreshes every %1$d seconds', + 'MCHAT_MINUTES_AGO' => array( + 0 => 'just now', + 1 => '%1$d minute ago', + 2 => '%1$d minutes ago', + ), + + // Custom translations for administrators + 'MCHAT_RULES_MESSAGE' => '', + 'MCHAT_STATIC_MESSAGE' => '', +)); diff --git a/language/en/mchat_acp.php b/language/en/mchat_acp.php new file mode 100644 index 0000000..69567c7 --- /dev/null +++ b/language/en/mchat_acp.php @@ -0,0 +1,148 @@ + 'Index page settings', + 'MCHAT_SETTINGS_CUSTOM' => 'Custom page settings', + 'MCHAT_SETTINGS_ARCHIVE' => 'Archive page settings', + 'MCHAT_SETTINGS_POSTS' => 'New posts settings', + 'MCHAT_SETTINGS_MESSAGES' => 'Message settings', + 'MCHAT_SETTINGS_PRUNE' => 'Pruning settings', + 'MCHAT_SETTINGS_STATS' => 'Who is chatting settings', + + // ACP settings + 'MCHAT_ACP_TITLE' => 'mChat Configuration', + 'MCHAT_VERSION' => 'Version', + 'MCHAT_RULES' => 'Rules', + 'MCHAT_RULES_EXPLAIN' => 'Enter the rules of the forum here. HTML code is allowed. You are limited to 255 characters.
This message can be translated: edit the MCHAT_RULES_MESSAGE language key in /ext/dmzx/mchat/language/XX/common.php.', + 'MCHAT_CONFIG_SAVED' => 'mChat configuration has been updated', + 'MCHAT_AVATARS' => 'Display avatars', + 'MCHAT_AVATARS_EXPLAIN' => 'If set to yes, resized user avatars will be displayed', + 'MCHAT_ON_INDEX' => 'Display mChat on the index page', + 'MCHAT_INDEX_HEIGHT' => 'Index page height', + 'MCHAT_INDEX_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the index page.
You are limited from 50 to 1000.', + 'MCHAT_LOCATION' => 'Location of mChat on the index page', + 'MCHAT_TOP_OF_FORUM' => 'Top', + 'MCHAT_BOTTOM_OF_FORUM' => 'Bottom', + 'MCHAT_REFRESH' => 'Refresh interval', + 'MCHAT_REFRESH_EXPLAIN' => 'Number of seconds before the chat refreshes.
You are limited from 5 to 60 seconds.', + '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', + 'MCHAT_PRUNE_EXPLAIN' => 'Only occurs if a user views the custom or archive pages.', + 'MCHAT_PRUNE_NUM' => 'Number of messages to retain when pruning', + 'MCHAT_MESSAGE_LIMIT' => 'Initial number of messages to display on the custom page', + 'MCHAT_MESSAGE_LIMIT_EXPLAIN' => 'Recommended from 10 to 30.', + 'MCHAT_MESSAGE_NUM' => 'Initial number of messages to display on the index page', + 'MCHAT_MESSAGE_NUM_EXPLAIN' => 'Recommended from 10 to 50.', + 'MCHAT_NAVBAR_LINK' => 'Display link to the custom page in the navbar', + 'MCHAT_ARCHIVE_LIMIT' => 'Number of messages to display on the archive page', + 'MCHAT_ARCHIVE_LIMIT_EXPLAIN' => 'The maximum number of messages to show per page on the archive page.
Recommended from 25 to 50.', + 'MCHAT_FLOOD_TIME' => 'Flood time', + 'MCHAT_FLOOD_TIME_EXPLAIN' => 'The number of seconds a user must wait before posting another message in the chat.
Recommended 5 to 30, set to 0 to disable.', + 'MCHAT_EDIT_DELETE_LIMIT' => 'Time limit for editing and deleting messages', + 'MCHAT_EDIT_DELETE_LIMIT_EXPLAIN' => 'Messages older than the specified number of seconds cannot be edited or deleted by the author any more.
Users who have edit/delete permission as well as moderator permission are exempt from this time limit.
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.
Recommended from 100 to 500, set to 0 to disable.', + 'MCHAT_CUSTOM_PAGE' => 'Enable custom Page', + 'MCHAT_CUSTOM_PAGE_EXPLAIN' => 'Allow the use of the custom page', + 'MCHAT_CUSTOM_HEIGHT' => 'Custom page height', + 'MCHAT_CUSTOM_HEIGHT_EXPLAIN' => 'The height of the chat box in pixels on the custom page.
You are limited from 50 to 1000.', + 'MCHAT_DATE_FORMAT' => 'Date format', + 'MCHAT_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP date() function.', + 'MCHAT_CUSTOM_DATEFORMAT' => 'Custom…', + '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. Displays the full date for messages older than the current session length but limited to 60 minutes.
Set to No to always display the full date.', + 'MCHAT_BBCODES_DISALLOWED' => 'Disallowed bbcodes', + 'MCHAT_BBCODES_DISALLOWED_EXPLAIN' => 'Here you can input the bbcodes that are not to be used in a message.
Separate bbcodes with a vertical bar, for example:
b|i|u|code|list|list=|flash|quote and/or a %1$scustom bbcode tag name%2$s', + 'MCHAT_STATIC_MESSAGE' => 'Static message', + 'MCHAT_STATIC_MESSAGE_EXPLAIN' => 'Here you can define a static message to display to users of the chat. HTML code is allowed.
Set to empty to disable the display. You are limited to 255 characters.
This message can be translated: edit the MCHAT_STATIC_MESSAGE language key in /ext/dmzx/mchat/language/XX/common.php.', + 'MCHAT_USER_TIMEOUT' => 'User session timeout', + 'MCHAT_USER_TIMEOUT_EXPLAIN' => 'Set the amount of time in seconds until a user session in the chat ends.
Set to 0 for no timeout. Careful, the session of a user reading mChat will never expire!
You are limited to the %1$sforum config setting for sessions%2$s which is currently set to %3$d seconds', + 'MCHAT_OVERRIDE_SMILIE_LIMIT' => 'Override smilie limit', + '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_NEW_POSTS_TOPIC' => 'Display new topics', + 'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Allow topics from the forum to be posted in the chat.', + 'MCHAT_NEW_POSTS_REPLY' => 'Display new replies', + 'MCHAT_NEW_POSTS_REPLY_EXPLAIN' => 'Allow replies from the forum to be posted in the chat.', + 'MCHAT_NEW_POSTS_EDIT' => 'Display edited posts', + 'MCHAT_NEW_POSTS_EDIT_EXPLAIN' => 'Allow edited posts from the forum to be posted in the chat.', + 'MCHAT_NEW_POSTS_QUOTE' => 'Display quoted posts', + 'MCHAT_NEW_POSTS_QUOTE_EXPLAIN' => 'Allow quoted posts from the forum to be posted in the chat.', + 'MCHAT_WHOIS' => 'Display Who is chatting below the chat', + 'MCHAT_STATS_INDEX' => 'Display Who is chatting in the stats section', + 'MCHAT_STATS_INDEX_EXPLAIN' => 'Displays who is chatting below the Who is online section on the index page', + 'MCHAT_WHOIS_REFRESH' => 'Who is chatting refresh interval', + 'MCHAT_WHOIS_REFRESH_EXPLAIN' => 'Number of seconds before who is chatting refreshes.
You are limited from 30 to 300 seconds.', + '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_BOTTOM' => 'Bottom', + 'MCHAT_TOP' => 'Top', + 'MCHAT_PAUSE_ON_INPUT' => 'Pause on input', + 'MCHAT_PAUSE_ON_INPUT_EXPLAIN' => 'Do not autoupdate upon a user entering a message in the input area', + 'MCHAT_PURGE' => 'Delete all messages now', + 'MCHAT_PURGE_CONFIRM' => 'Confirm deleting all messages', + 'MCHAT_PURGED' => 'All mChat messages have been successfully deleted', + + // Error reporting + 'TOO_SMALL_MCHAT_ARCHIVE_LIMIT' => 'The archive limit value is too small.', + 'TOO_LARGE_MCHAT_ARCHIVE_LIMIT' => 'The archive limit value is too large.', + '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_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_LIMIT' => 'The message limit value is too small.', + 'TOO_LARGE_MCHAT_MESSAGE_LIMIT' => 'The message limit value is too large.', + 'TOO_SMALL_MCHAT_MESSAGE_NUM' => 'The number of messages to display on the index page is too small.', + 'TOO_LARGE_MCHAT_MESSAGE_NUM' => 'The number of messages to display on the index 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.', +)); diff --git a/language/en/mchat_ucp.php b/language/en/mchat_ucp.php new file mode 100644 index 0000000..f047d49 --- /dev/null +++ b/language/en/mchat_ucp.php @@ -0,0 +1,50 @@ + 'mChat preferences', + + 'MCHAT_DISPLAY' => 'Display on index', + 'MCHAT_SOUND' => 'Enable sound', + 'MCHAT_DISPLAY_STATS_INDEX' => 'Display who is chatting on index', + 'MCHAT_DISPLAY_NEW_TOPICS' => 'Display new topics in the chat', + 'MCHAT_DISPLAY_AVATARS' => 'Display avatars in the chat', + 'MCHAT_CAPITAL_LETTER' => 'Capital first letter in your messages', + 'MCHAT_CHAT_AREA' => 'Input type', + 'MCHAT_CHAT_AREA_EXPLAIN' => 'The type of area to use for writing messages', + 'MCHAT_INPUT_AREA' => 'Input area', + 'MCHAT_TEXT_AREA' => 'Text area', +)); diff --git a/language/en/permissions_mchat.php b/language/en/permissions_mchat.php new file mode 100644 index 0000000..38c77f8 --- /dev/null +++ b/language/en/permissions_mchat.php @@ -0,0 +1,53 @@ + 'Can use mChat', + 'ACL_U_MCHAT_VIEW' => 'Can view mChat', + 'ACL_U_MCHAT_EDIT' => 'Can edit messages', + 'ACL_U_MCHAT_DELETE' => 'Can delete 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_FLOOD_IGNORE' => 'Can ignore flood limit', + 'ACL_U_MCHAT_ARCHIVE' => 'Can view the archive', + 'ACL_U_MCHAT_BBCODE' => 'Can use bbcodes', + 'ACL_U_MCHAT_SMILIES' => 'Can use smilies', + 'ACL_U_MCHAT_URLS' => 'Can post URLs', + + 'ACL_A_MCHAT' => 'Can manage mChat settings', +)); diff --git a/migrations/install_mchat.php b/migrations/install_mchat.php index 352e2c9..7325cd4 100644 --- a/migrations/install_mchat.php +++ b/migrations/install_mchat.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -14,7 +15,7 @@ class install_mchat extends \phpbb\db\migration\migration { public function effectively_installed() { - return isset($this->config['mchat_version']) && version_compare($this->config['mchat_version'], '1.0.0-RC1', '>='); + return isset($this->config['mchat_version']) && version_compare($this->config['mchat_version'], '1.0.0-RC2', '>='); } static public function depends_on() @@ -26,12 +27,13 @@ class install_mchat extends \phpbb\db\migration\migration { return array( // Add configs - array('config.add', array('mchat_version', '1.0.0-RC1')), + array('config.add', array('mchat_version', '1.0.0-RC2')), array('config.add', array('mchat_archive_limit', 25)), array('config.add', array('mchat_avatars', 1)), array('config.add', array('mchat_bbcode_disallowed', '')), array('config.add', array('mchat_custom_height', 350)), array('config.add', array('mchat_custom_page', 1)), + array('config.add', array('mchat_relative_time', 1)), array('config.add', array('mchat_date', 'D M d, Y g:i a')), array('config.add', array('mchat_edit_delete_limit', 0)), array('config.add', array('mchat_flood_time', 0)), @@ -41,6 +43,7 @@ class install_mchat extends \phpbb\db\migration\migration array('config.add', array('mchat_max_message_lngth', 500)), array('config.add', array('mchat_message_limit', 10)), array('config.add', array('mchat_message_num', 10)), + array('config.add', array('mchat_navbar_link', 1)), array('config.add', array('mchat_message_top', 1)), array('config.add', array('mchat_new_posts_edit', 0)), array('config.add', array('mchat_new_posts_quote', 0)), @@ -101,63 +104,32 @@ class install_mchat extends \phpbb\db\migration\migration array('permission.permission_set', array('REGISTERED', 'u_mchat_smilies', 'group')), array('permission.permission_set', array('REGISTERED', 'u_mchat_urls', 'group')), - // Add ACP module + // Add ACP extension category array('module.add', array( 'acp', 'ACP_CAT_DOT_MODS', 'ACP_CAT_MCHAT' )), + // Add ACP preferences module array('module.add', array( 'acp', 'ACP_CAT_MCHAT', array( 'module_basename' => '\dmzx\mchat\acp\acp_mchat_module', 'modes' => array('configuration'), - 'module_auth' => 'a_mchat', + 'module_auth' => 'acl_a_mchat', ), )), - // Add ACP module - array('module.add', array( - 'acp', - 'ACP_CAT_USERS', - array( - 'module_basename' => 'users', - 'module_enabled' => 1, - 'module_display' => 0, - 'module_langname' => 'ACP_USER_MCHAT', - 'module_mode' => 'mchat', - 'module_auth' => 'acl_a_user', - ), - ), - - // First, lets add a new category named UCP_CAT_MCHAT - array( - 'ucp', - false, - 'UCP_CAT_MCHAT' - ), - - // next let's add our module - array( - 'ucp', - 'UCP_CAT_MCHAT', - array( - 'module_basename' => 'mchat', - 'modes' => array('configuration'), - 'module_auth' => 'u_mchat_use', - ), - ), - ), - - // Add UCP module + // Add UCP category array('module.add', array( 'ucp', false, 'UCP_MCHAT_CONFIG' )), + // Add UCP preferences module array('module.add', array( 'ucp', 'UCP_MCHAT_CONFIG', @@ -191,6 +163,13 @@ class install_mchat extends \phpbb\db\migration\migration 'PRIMARY_KEY' => 'message_id', ), + $this->table_prefix . 'mchat_deleted_messages' => array( + 'COLUMNS' => array( + 'message_id' => array('UINT', null), + ), + 'PRIMARY_KEY' => 'message_id', + ), + $this->table_prefix . 'mchat_sessions' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), @@ -208,6 +187,7 @@ class install_mchat extends \phpbb\db\migration\migration 'user_mchat_stats_index' => array('BOOL', '1'), 'user_mchat_topics' => array('BOOL', '1'), 'user_mchat_avatars' => array('BOOL', '1'), + 'user_mchat_capital_letter' => array('BOOL', '1'), 'user_mchat_input_area' => array('BOOL', '1'), ), ), @@ -219,6 +199,7 @@ class install_mchat extends \phpbb\db\migration\migration return array( 'drop_tables' => array( $this->table_prefix . 'mchat', + $this->table_prefix . 'mchat_deleted_messages', $this->table_prefix . 'mchat_sessions', ), diff --git a/styles/prosilver/template/event/index_body_block_online_append.html b/styles/all/template/event/index_body_block_online_append.html similarity index 71% rename from styles/prosilver/template/event/index_body_block_online_append.html rename to styles/all/template/event/index_body_block_online_append.html index 89c96c5..a0d1876 100644 --- a/styles/prosilver/template/event/index_body_block_online_append.html +++ b/styles/all/template/event/index_body_block_online_append.html @@ -1,4 +1,4 @@ -

{L_WHO_IS_CHATTING}

+

{L_MCHAT_WHO_IS_CHATTING}

{MCHAT_USERS_COUNT} {MCHAT_ONLINE_EXPLAIN}
{MCHAT_USERS_LIST}

diff --git a/styles/prosilver/template/event/index_body_forumlist_body_after.html b/styles/all/template/event/index_body_forumlist_body_after.html similarity index 100% rename from styles/prosilver/template/event/index_body_forumlist_body_after.html rename to styles/all/template/event/index_body_forumlist_body_after.html diff --git a/styles/prosilver/template/event/index_body_markforums_before.html b/styles/all/template/event/index_body_markforums_before.html similarity index 100% rename from styles/prosilver/template/event/index_body_markforums_before.html rename to styles/all/template/event/index_body_markforums_before.html diff --git a/styles/all/template/event/overall_footer_copyright_append.html b/styles/all/template/event/overall_footer_copyright_append.html new file mode 100644 index 0000000..62740f3 --- /dev/null +++ b/styles/all/template/event/overall_footer_copyright_append.html @@ -0,0 +1,9 @@ + +
+ {META_DISPLAY_NAME} © {L_POST_BY_AUTHOR} + + diff --git a/styles/all/template/event/overall_header_head_append.html b/styles/all/template/event/overall_header_head_append.html new file mode 100644 index 0000000..5615e3c --- /dev/null +++ b/styles/all/template/event/overall_header_head_append.html @@ -0,0 +1 @@ + diff --git a/styles/all/template/event/overall_header_navigation_append.html b/styles/all/template/event/overall_header_navigation_append.html new file mode 100644 index 0000000..f8a284c --- /dev/null +++ b/styles/all/template/event/overall_header_navigation_append.html @@ -0,0 +1,3 @@ + + + diff --git a/styles/all/template/javascript/jquery.auto-grow-input.js b/styles/all/template/javascript/jquery.auto-grow-input.js new file mode 100644 index 0000000..34deeca --- /dev/null +++ b/styles/all/template/javascript/jquery.auto-grow-input.js @@ -0,0 +1,47 @@ +/* + jQuery autoGrowInput v1.0.3 + Copyright (c) 2014 Simon Steinberger / Pixabay + Based on stackoverflow.com/questions/931207 (James Padolsey) + GitHub: https://github.com/Pixabay/jQuery-autoGrowInput + License: http://www.opensource.org/licenses/mit-license.php +*/ + +(function($){ + var event = 'oninput' in document.createElement('input') ? 'input' : 'keydown'; + + $.fn.autoGrowInput = function(options){ + var o = $.extend({ maxWidth: 500, minWidth: 20, comfortZone: 0 }, options); + + this.each(function(){ + var input = $(this), + val = ' ', + comfortZone = (options && 'comfortZone' in options) ? o.comfortZone : parseInt(input.css('fontSize')), + span = $('').css({ + position: 'absolute', + top: -9999, + left: -9999, + width: 'auto', + fontSize: input.css('fontSize'), + fontFamily: input.css('fontFamily'), + fontWeight: input.css('fontWeight'), + letterSpacing: input.css('letterSpacing'), + textTransform: input.css('textTransform'), + whiteSpace: 'nowrap', + ariaHidden: true + }).appendTo('body'), + check = function(e){ + if (val === (val = input.val()) && e.type !== 'autogrow') return; + if (!val) val = input.attr('placeholder') || ''; + span.html(val.replace(/&/g, '&').replace(/\s/g, ' ').replace(//g, '>')); + var newWidth = span.width() + comfortZone, mw = typeof(o.maxWidth) == "function" ? o.maxWidth() : o.maxWidth; + if (newWidth > mw) newWidth = mw; + else if (newWidth < o.minWidth) newWidth = o.minWidth; + if (newWidth != input.width()) input.width(newWidth); + }; + input.on(event+'.autogrow autogrow', check); + // init on page load + check(); + }); + return this; + } +}(jQuery)); diff --git a/styles/prosilver/template/jquery.titlealert.min.js b/styles/all/template/javascript/jquery.titlealert.min.js similarity index 100% rename from styles/prosilver/template/jquery.titlealert.min.js rename to styles/all/template/javascript/jquery.titlealert.min.js diff --git a/styles/prosilver/template/js.cookie-2.0.4.min.js b/styles/all/template/javascript/js.cookie-2.0.4.min.js similarity index 100% rename from styles/prosilver/template/js.cookie-2.0.4.min.js rename to styles/all/template/javascript/js.cookie-2.0.4.min.js diff --git a/styles/all/template/javascript/mchat.js b/styles/all/template/javascript/mchat.js new file mode 100644 index 0000000..6d55da4 --- /dev/null +++ b/styles/all/template/javascript/mchat.js @@ -0,0 +1,498 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2009 By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/ + * @copyright (c) 2013 By Rich McGirr (RMcGirr83) http://rmcgirr83.org + * @copyright (c) 2015 By dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 By kasimi + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * + */ + +// Support Opera +if (typeof document.hasFocus === 'undefined') { + document.hasFocus = function() { + return document.visibilityState == 'visible'; + }; +} + +Array.prototype.max = function() { + return Math.max.apply(null, this); +}; + +Array.prototype.min = function() { + return Math.min.apply(null, this); +}; + +jQuery.fn.reverse = function(reverse) { + reverse = typeof reverse === 'undefined' ? true : reverse; + return reverse ? jQuery(this.toArray().reverse()) : this; +}; + +jQuery(function($) { + var ajaxRequest = function(mode, sendHiddenFields, data) { + var deferred = $.Deferred(); + if (sendHiddenFields) { + $.extend(data, mChat.hiddenFields); + } + $.ajax({ + url: mChat.actionUrls[mode], + timeout: 5000, + type: 'POST', + dataType: 'json', + data: data + }).done(function(json, status, xhr) { + if (json[mode]) { + deferred.resolve(json, status, xhr); + } else { + deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format'); + } + }).fail(function(xhr, status, error) { + deferred.reject(xhr, status, error); + }); + return deferred.promise().fail(function(xhr, textStatus, errorThrown) { + mChat.sound('error'); + mChat.cached('refresh-load', 'refresh-ok', 'refresh-paused').hide(); + mChat.cached('refresh-error').show(); + if (errorThrown == 'format') { + // Unexpected format + } else if (errorThrown == 'session') { + mChat.endSession(true); + alert(mChat.sessOut); + } else if (xhr.status == 400) { + alert(mChat.flood); + } else if (xhr.status == 403) { + alert(mChat.noAccess); + } else if (xhr.status == 413) { + alert(mChat.mssgLngthLong); + } else if (xhr.status == 501) { + alert(mChat.noMessageInput); + } else if (typeof console !== 'undefined' && console.log) { + console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); + } + }); + }; + + $.extend(mChat, { + clear: function() { + if (mChat.cached('input').val() !== '') { + if (confirm(mChat.clearConfirm)) { + mChat.resetSession(); + mChat.cached('input').val(''); + } + setTimeout(function() { + mChat.cached('input').focus(); + }, 1); + } + }, + sound: function(file) { + if (!mChat.pageIsUnloading && !Cookies.get('mchat_no_sound')) { + var audio = mChat.cached('sound-' + file).get(0); + if (audio.duration) { + audio.pause(); + audio.currentTime = 0; + audio.play(); + } + } + }, + notice: function() { + if (!document.hasFocus()) { + $.titleAlert(mChat.newMessageAlert, {interval: 1000}); + } + }, + toggle: function(name) { + var $elem = mChat.cached(name); + $elem.stop().slideToggle(function() { + var cookieName = 'mchat_show_' + name; + if ($elem.is(':visible')) { + Cookies.set(cookieName, 'yes'); + } else { + Cookies.remove(cookieName); + } + }); + }, + add: function() { + if (mChat.cached('add').prop('disabled')) { + return; + } + var message = mChat.cached('input').val(); + if ($.trim(message) === '') { + return; + } + var messChars = message.replace(/\s/g, ''); + if (mChat.mssgLngth && messChars.length > mChat.mssgLngth) { + alert(mChat.mssgLngthLong); + return; + } + mChat.cached('add').prop('disabled', true); + mChat.pauseSession(); + mChat.lastInputValue = message; + mChat.cached('input').val(''); + mChat.refresh(message).done(function() { + mChat.resetSession(); + }).fail(function() { + mChat.cached('input').val(mChat.lastInputValue); + }).always(function() { + mChat.cached('add').prop('disabled', false); + setTimeout(function() { + mChat.cached('input').focus(); + }, 1); + }); + }, + edit: function() { + var $container = $(this).closest('.mchat-message'); + var $message = mChat.cached('confirm').find('textarea').show().val($container.data('mchat-message')); + mChat.cached('confirm').find('p').text(mChat.editInfo); + phpbb.confirm(mChat.cached('confirm'), function() { + ajaxRequest('edit', true, { + message_id: $container.data('mchat-id'), + message: $message.val(), + archive: mChat.archiveMode ? 1 : 0 + }).done(function(json) { + mChat.updateMessages($(json.edit)); + mChat.resetSession(); + }); + }); + }, + del: function() { + var $container = $(this).closest('.mchat-message'); + mChat.cached('confirm').find('textarea').hide(); + mChat.cached('confirm').find('p').text(mChat.delConfirm); + phpbb.confirm(mChat.cached('confirm'), function() { + var delId = $container.data('mchat-id'); + ajaxRequest('del', true, { + message_id: delId + }).done(function() { + mChat.removeMessages([delId]); + mChat.resetSession(); + }); + }); + }, + refresh: function(message) { + var $messages = mChat.cached('messages').children(); + var data = { + message_last_id: mChat.messageIds.length ? mChat.messageIds.max() : 0 + }; + if (message) { + data.message = message; + } + if (mChat.liveUpdates) { + data.message_first_id = mChat.messageIds.length ? mChat.messageIds.min() : 0; + data.message_edits = {}; + var now = Math.floor(Date.now() / 1000); + $.each($messages, function() { + var $message = $(this); + var editTime = $message.data('mchat-edit-time'); + if (editTime && (!mChat.editDeleteLimit || $message.data('mchat-message-time') >= now - mChat.editDeleteLimit / 1000)) { + data.message_edits[$message.data('mchat-id')] = editTime; + } + }); + } + mChat.cached('refresh-ok', 'refresh-error', 'refresh-paused').hide(); + mChat.cached('refresh-load').show(); + return ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) { + if (json.add) { + var $html = $(json.add); + $('#mchat-no-messages').remove(); + $html.reverse(mChat.messageTop).hide().each(function(i) { + var $message = $(this); + mChat.messageIds.push($message.data('mchat-id')); + setTimeout(function() { + if (mChat.messageTop) { + mChat.cached('messages').prepend($message); + } else { + mChat.cached('messages').append($message); + } + $message.css('opacity', 0).slideDown().animate({opacity: 1}, {queue: false}); + mChat.cached('messages').animate({scrollTop: mChat.messageTop ? 0 : mChat.cached('messages')[0].scrollHeight}); + }, i * 400); + if (mChat.editDeleteLimit && $message.data('mchat-edit-delete-limit') && $message.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length > 0) { + var id = $message.prop('id'); + setTimeout(function() { + $('#' + id).find('[data-mchat-action="edit"], [data-mchat-action="del"]').fadeOut(function() { + $(this).remove(); + }); + }, mChat.editDeleteLimit); + } + mChat.startRelativeTimeUpdate($message); + }); + mChat.sound('add'); + mChat.notice(); + } + if (json.edit) { + mChat.updateMessages($(json.edit)); + } + if (json.del) { + mChat.removeMessages(json.del); + } + if (json.whois) { + mChat.whois(); + } + if (mChat.refreshInterval) { + mChat.cached('refresh-load', 'refresh-error', 'refresh-paused').hide(); + mChat.cached('refresh-ok').show(); + } + }); + }, + whois: function() { + if (mChat.customPage) { + mChat.cached('refresh-pending').show(); + mChat.cached('refresh-explain').hide(); + } + ajaxRequest('whois', false, {}).done(function(json) { + var $whois = $(json.whois); + var $userlist = $whois.find('#mchat-userlist'); + if (Cookies.get('mchat_show_userlist')) { + $userlist.show(); + } + mChat.cached('whois').replaceWith($whois); + mChat.cache.whois = $whois; + mChat.cache.userlist = $userlist; + if (mChat.customPage) { + mChat.cached('refresh-pending').hide(); + mChat.cached('refresh-explain').show(); + } + }); + }, + updateMessages: function($messages) { + var soundPlayed = false; + $messages.each(function() { + var $newMessage = $(this); + var $oldMessage = $('#mchat-message-' + $newMessage.data('mchat-id')); + mChat.stopRelativeTimeUpdate($oldMessage); + mChat.startRelativeTimeUpdate($newMessage); + $oldMessage.fadeOut(function() { + $oldMessage.replaceWith($newMessage.hide().fadeIn()); + }); + if (!soundPlayed) { + soundPlayed = true; + mChat.sound('edit'); + } + }); + }, + removeMessages: function(ids) { + var soundPlayed = false; + $.each(ids, function(i, id) { + var index = 0; + while ((index = $.inArray(id, mChat.messageIds, index)) !== -1) { + mChat.messageIds.splice(index, 1); + var $message = $('#mchat-message-' + id); + mChat.stopRelativeTimeUpdate($message); + $message.fadeOut(function() { + $message.remove(); + }); + if (!soundPlayed) { + soundPlayed = true; + mChat.sound('del'); + } + } + }); + }, + startRelativeTimeUpdate: function($messages) { + if (mChat.relativeTime) { + $messages.find('.mchat-time[data-mchat-relative-update]').each(function() { + var $time = $(this); + setTimeout(function() { + mChat.relativeTimeUpdate($time); + $time.data('mchat-relative-interval', setInterval(function() { + mChat.relativeTimeUpdate($time); + }, 60 * 1000)); + }, $time.data('mchat-relative-update') * 1000); + }); + } + }, + relativeTimeUpdate: function($time) { + var minutesAgo = $time.data('mchat-minutes-ago') + 1; + var langMinutesAgo = mChat.minutesAgo[minutesAgo]; + if (langMinutesAgo) { + $time.text(langMinutesAgo).data('mchat-minutes-ago', minutesAgo); + } else { + mChat.stopRelativeTimeUpdate($time); + $time.text($time.attr('title')).removeAttr('data-mchat-relative-update data-mchat-minutes-ago data-mchat-relative-interval'); + } + }, + stopRelativeTimeUpdate: function($message) { + var selector = '.mchat-time[data-mchat-relative-update]'; + clearInterval($message.find(selector).addBack(selector).data('mchat-relative-interval')); + }, + timeLeft: function(sessionTime) { + return (new Date(sessionTime * 1000)).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0]; + }, + countDown: function() { + mChat.sessionTime -= 1; + mChat.cached('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime)); + if (mChat.sessionTime < 1) { + mChat.endSession(); + } + }, + pauseSession: function() { + clearInterval(mChat.refreshInterval); + if (mChat.userTimeout) { + clearInterval(mChat.sessionCountdown); + } + if (mChat.whoisRefresh) { + clearInterval(mChat.whoisInterval); + } + }, + resetSession: function() { + if (!mChat.archiveMode) { + clearInterval(mChat.refreshInterval); + mChat.refreshInterval = setInterval(mChat.refresh, mChat.refreshTime); + if (mChat.userTimeout) { + mChat.sessionTime = mChat.userTimeout / 1000; + clearInterval(mChat.sessionCountdown); + mChat.cached('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime)); + mChat.sessionCountdown = setInterval(mChat.countDown, 1000); + } + if (mChat.whoisRefresh) { + clearInterval(mChat.whoisInterval); + mChat.whoisInterval = setInterval(mChat.whois, mChat.whoisRefresh); + } + if (mChat.pause) { + mChat.cached('input').one('keypress', mChat.endSession); + } + mChat.cached('refresh-ok').show(); + mChat.cached('refresh-load', 'refresh-error', 'refresh-paused').hide(); + mChat.cached('refresh-text').html(mChat.refreshYes); + } + }, + endSession: function(skipUpdateWhois) { + clearInterval(mChat.refreshInterval); + mChat.refreshInterval = false; + if (mChat.userTimeout) { + clearInterval(mChat.sessionCountdown); + mChat.cached('session').html(mChat.sessOut); + } + if (mChat.whoisRefresh) { + clearInterval(mChat.whoisInterval); + if (!skipUpdateWhois) { + mChat.whois(); + } + } + mChat.cached('refresh-load', 'refresh-ok', 'refresh-error').hide(); + mChat.cached('refresh-paused').show(); + mChat.cached('refresh-text').html(mChat.refreshNo); + }, + mention: function() { + var $container = $(this).closest('.mchat-message'); + var username = mChat.entityDecode($container.data('mchat-username')); + var usercolor = $container.data('mchat-usercolor'); + if (usercolor) { + username = '[b][color=' + usercolor + ']' + username + '[/color][/b]'; + } else if (mChat.allowBBCodes) { + username = '[b]' + username + '[/b]'; + } + insert_text('@ ' + username + ', '); + }, + quote: function() { + var $container = $(this).closest('.mchat-message'); + var username = mChat.entityDecode($container.data('mchat-username')); + var quote = mChat.entityDecode($container.data('mchat-message')); + insert_text('[quote="' + username + '"] ' + quote + '[/quote]'); + }, + like: function() { + var $container = $(this).closest('.mchat-message'); + var username = mChat.entityDecode($container.data('mchat-username')); + var quote = mChat.entityDecode($container.data('mchat-message')); + insert_text(mChat.likes + '[quote="' + username + '"] ' + quote + '[/quote]'); + }, + entityDecode: function(text) { + var s = decodeURIComponent(text.toString().replace(/\+/g, ' ')); + s = s.replace(/</g, '<'); + s = s.replace(/>/g, '>'); + s = s.replace(/:/g, ':'); + s = s.replace(/./g, '.'); + s = s.replace(/&/g, '&'); + s = s.replace(/"/g, "'"); + return s; + }, + 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(); + }); + } + }); + + mChat.cache = {}; + mChat.cached('confirm').detach().show(); + + mChat.messageIds = mChat.cached('messages').children().map(function() { + return $(this).data('mchat-id'); + }).get(); + + mChat.hiddenFields = {}; + $('#mchat-form').find('input[type=hidden]').each(function() { + mChat.hiddenFields[this.name] = this.value; + }); + + if (!mChat.archiveMode) { + mChat.resetSession(); + + if (!mChat.messageTop) { + mChat.cached('messages').animate({scrollTop: mChat.cached('messages')[0].scrollHeight, easing: 'swing', duration: 'slow'}); + } + + if (!mChat.cached('user-sound').prop('checked')) { + Cookies.set('mchat_no_sound', 'yes'); + } + + mChat.cached('user-sound').prop('checked', mChat.playSound && !Cookies.get('mchat_no_sound')); + + mChat.cached('user-sound').change(function() { + if (this.checked) { + Cookies.remove('mchat_no_sound'); + } else { + Cookies.set('mchat_no_sound', 'yes'); + } + }); + + $.each(mChat.removeBBCodes.split('|'), function(i, bbcode) { + $('#format-buttons .bbcode-' + bbcode).remove(); + }); + + var $colourPalette = $('#colour_palette'); + $colourPalette.appendTo($colourPalette.parent()).wrap('
').show(); + $('#bbpalette,#abbc3_bbpalette').prop('onclick', null).attr('data-mchat-toggle', 'colour'); + + $.each(['userlist', 'smilies', 'bbcodes', 'colour'], function(i, elem) { + if (Cookies.get('mchat_show_' + elem)) { + mChat.cached(elem).toggle(); + } + }); + + mChat.startRelativeTimeUpdate(mChat.cached('messages')); + + if (mChat.cached('input').is('input')) { + $('#mchat-form').on('keypress', function(e) { + if (e.which == 13) { + mChat.add(); + e.preventDefault(); + } + }); + } + + mChat.cached('input').autoGrowInput({ + minWidth: mChat.cached('input').width(), + maxWidth: mChat.cached('form').width() - (mChat.cached('input').outerWidth(true) - mChat.cached('input').width()) + }); + } + + $(window).on('beforeunload', function() { + mChat.pageIsUnloading = true; + }); + + $('#phpbb').on('click', '[data-mchat-action]', function(e) { + var action = $(this).data('mchat-action'); + mChat[action].call(this); + e.preventDefault(); + }).on('click', '[data-mchat-toggle]', function(e) { + var elem = $(this).data('mchat-toggle'); + mChat.toggle(elem); + e.preventDefault(); + }); +}); diff --git a/styles/all/template/mchat_body.html b/styles/all/template/mchat_body.html new file mode 100644 index 0000000..a7395dd --- /dev/null +++ b/styles/all/template/mchat_body.html @@ -0,0 +1,224 @@ + + + + + + + + + + + + + +
+ +
+ + + +
+ +
+
    +
  • + +
  • +
+ +
+ + + + + + + + + +
+ +
    +
  • {MCHAT_STATIC_MESS}
  • +
+ + + +
    +
  • {L_MCHAT_NOMESSAGE}
  • +
+ + +
    style="height:{MCHAT_CUSTOM_HEIGHT}{MCHAT_INDEX_HEIGHT}px"> + +
+
+ +
+ + + + +
+ {S_FORM_TOKEN} + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + +
+ {L_LOADING} + {L_MCHAT_OK} + {L_MCHAT_PAUSE} + {L_ERROR} + {MCHAT_REFRESH_YES} + {L_MCHAT_SESSION_ENDS} {MCHAT_USER_TIMEOUT_TIME} + {L_MCHAT_COPYRIGHT} +
+ +
+
+
+
+
+ + +
+ +
+ + + +

{L_MCHAT_WHO_IS_CHATTING}

+ +
+ {MCHAT_WHOIS_REFRESH_EXPLAIN} + +
+ + + +
+ {L_LEGEND}{L_COLON} {LEGEND} +
+ + + + + diff --git a/styles/all/template/mchat_header.html b/styles/all/template/mchat_header.html new file mode 100644 index 0000000..4736cd3 --- /dev/null +++ b/styles/all/template/mchat_header.html @@ -0,0 +1,4 @@ +
+
{L_MCHAT_ARCHIVE_PAGE}{L_MCHAT_TITLE}{L_MCHAT_TITLE}
+
 
+
diff --git a/styles/all/template/mchat_messages.html b/styles/all/template/mchat_messages.html new file mode 100644 index 0000000..fb271d5 --- /dev/null +++ b/styles/all/template/mchat_messages.html @@ -0,0 +1,27 @@ + +
  • data-mchat-usercolor="{mchatrow.MCHAT_USERNAME_COLOR}" data-mchat-message="{mchatrow.MCHAT_MESSAGE_EDIT}" data-mchat-message-time="{mchatrow.MCHAT_MESSAGE_TIME}" data-mchat-edit-time="{mchatrow.MCHAT_EDIT_TIME}" data-mchat-edit-delete-limit="1"> + + + +
    +
    + style="color:{mchatrow.MCHAT_USERNAME_COLOR}">@ + {mchatrow.MCHAT_USERNAME_FULL} • data-mchat-minutes-ago="{mchatrow.MCHAT_MINUTES_AGO}" data-mchat-relative-update="{mchatrow.MCHAT_RELATIVE_UPDATE}">{mchatrow.MCHAT_TIME} +
    +
    + {L_MCHAT_SEND_PM} + {L_MCHAT_LIKE} + {L_REPLY_WITH_QUOTE} + {mchatrow.MCHAT_WHOIS_USER} + {L_MCHAT_PERMISSIONS} + {L_MCHAT_EDIT} + {L_DELETE} +
    +
    {mchatrow.MCHAT_MESSAGE}
    +
    +
  • + diff --git a/styles/all/template/mchat_navlink.html b/styles/all/template/mchat_navlink.html new file mode 100644 index 0000000..1681b48 --- /dev/null +++ b/styles/all/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/prosilver/template/mchat_rules.html b/styles/all/template/mchat_rules.html similarity index 100% rename from styles/prosilver/template/mchat_rules.html rename to styles/all/template/mchat_rules.html diff --git a/styles/all/template/mchat_whois.html b/styles/all/template/mchat_whois.html new file mode 100644 index 0000000..b5b2567 --- /dev/null +++ b/styles/all/template/mchat_whois.html @@ -0,0 +1,10 @@ +
    + + + {MCHAT_USERS_COUNT} + + {MCHAT_USERS_COUNT} + + + +
    diff --git a/styles/all/template/ucp_mchat.html b/styles/all/template/ucp_mchat.html new file mode 100644 index 0000000..2a6d526 --- /dev/null +++ b/styles/all/template/ucp_mchat.html @@ -0,0 +1,77 @@ + + +

    {L_MCHAT_PREFERENCES}

    + +
    +
    +
    +
    +

    {ERROR}

    + +
    +
    +
    + + +
    +
    + +
    +
    +
    + + +
    +
    + +
    +
    +
    + + +
    +
    + + +
    +
    +
    + + +
    +
    + + +
    +
    +
    + + +
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + {S_HIDDEN_FIELDS}  + + {S_FORM_TOKEN} +
    +
    + + diff --git a/styles/prosilver/theme/images/ban.gif b/styles/all/theme/images/ban.gif similarity index 100% rename from styles/prosilver/theme/images/ban.gif rename to styles/all/theme/images/ban.gif diff --git a/styles/prosilver/theme/images/bg_button.gif b/styles/all/theme/images/bg_button.gif similarity index 100% rename from styles/prosilver/theme/images/bg_button.gif rename to styles/all/theme/images/bg_button.gif diff --git a/styles/prosilver/theme/images/del.gif b/styles/all/theme/images/del.gif similarity index 100% rename from styles/prosilver/theme/images/del.gif rename to styles/all/theme/images/del.gif diff --git a/styles/prosilver/theme/images/edit.gif b/styles/all/theme/images/edit.gif similarity index 100% rename from styles/prosilver/theme/images/edit.gif rename to styles/all/theme/images/edit.gif diff --git a/styles/prosilver/theme/images/error.gif b/styles/all/theme/images/error.gif similarity index 100% rename from styles/prosilver/theme/images/error.gif rename to styles/all/theme/images/error.gif diff --git a/styles/all/theme/images/icon_mchat.png b/styles/all/theme/images/icon_mchat.png new file mode 100644 index 0000000..c3322d1 Binary files /dev/null and b/styles/all/theme/images/icon_mchat.png differ diff --git a/styles/prosilver/theme/images/ip.gif b/styles/all/theme/images/ip.gif similarity index 100% rename from styles/prosilver/theme/images/ip.gif rename to styles/all/theme/images/ip.gif diff --git a/styles/prosilver/theme/images/like.png b/styles/all/theme/images/like.png similarity index 100% rename from styles/prosilver/theme/images/like.png rename to styles/all/theme/images/like.png diff --git a/styles/prosilver/theme/images/load.gif b/styles/all/theme/images/load.gif similarity index 100% rename from styles/prosilver/theme/images/load.gif rename to styles/all/theme/images/load.gif diff --git a/styles/prosilver/theme/images/message.gif b/styles/all/theme/images/message.gif similarity index 100% rename from styles/prosilver/theme/images/message.gif rename to styles/all/theme/images/message.gif diff --git a/styles/prosilver/theme/images/ok.gif b/styles/all/theme/images/ok.gif similarity index 100% rename from styles/prosilver/theme/images/ok.gif rename to styles/all/theme/images/ok.gif diff --git a/styles/prosilver/theme/images/paused.gif b/styles/all/theme/images/paused.gif similarity index 100% rename from styles/prosilver/theme/images/paused.gif rename to styles/all/theme/images/paused.gif diff --git a/styles/prosilver/theme/images/quota.png b/styles/all/theme/images/quota.png similarity index 100% rename from styles/prosilver/theme/images/quota.png rename to styles/all/theme/images/quota.png diff --git a/styles/all/theme/mchat.css b/styles/all/theme/mchat.css new file mode 100644 index 0000000..36747e5 --- /dev/null +++ b/styles/all/theme/mchat.css @@ -0,0 +1,239 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +#mChat { + position: absolute; + visibility: hidden; +} + +#mChat + .inner li.header dd { + width: 0; +} + +.icon-mchat { + background-image: url("./images/icon_mchat.png"); +} + +#mchat-body { + width: 100% !important; +} + +#mchat-confirm textarea { + width: 100%; + height: 100px; +} + +.mchat-row-limit { + overflow: auto; + width: 100%; +} + +.mchat-message-wrapper { + overflow: hidden; +} + +.mchat-message-header { + float: left; +} + +.mchat-message-icons { + float: right; +} + +.mchat-message { + padding: 5px; + overflow: hidden; +} + +.mchat-avatar { + float: left; + width: 40px; + padding-right: 5px; +} + +@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) { + .mchat-avatar { + display: none; + } +} + +.mchat-avatar a { + unicode-bidi: normal; +} + +.mchat-avatar img { + display: block; +} + +.mchat-text { + clear: both; + padding: 0 5px 2px; + font-size: 1.1em; +} + +.mchat-text li { + display: list-item !important; + list-style-type: inherit !important; + list-style-position: inside; +} + +.mchat-text ul, .mchat-text ol { + list-style-position: inside; +} + +.mchat-text ul { + list-style-type: disc; +} + +.mchat-text ol { + list-style-type: decimal; +} + +.mchat-text ul ul { + list-style-type: circle; +} + +.mchat-text blockquote { + margin-bottom: 5px; +} + +.mchat-text blockquote, .mchat-text .codebox, .mchat-text ul, .mchat-text ol { + margin-left: 1em; +} + +.mchat-mention strong { + color: inherit !important; +} + +.mchat-mention, .mchat-message-icons > * { + cursor: pointer; +} + +#mchat-no-message { + font-size: 1.2em; +} + +#mchat-panel { + text-align: center; + max-height: initial; + padding: 0 5px 5px 5px; + margin: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +#mchat-form { + clear: both; +} + +#mchat-input { + cursor: text; + width: 50%; + font-size: 1.1em; + padding: 5px; + margin: 5px 20px; +} + +#mchat-buttons { + padding-bottom: 5px; +} + +#mchat-bbcodes { + padding: 0 5px; + display: none; +} + +#mchat-bbcodes #format-buttons { + margin: 0; +} + +#mchat-bbcodes #format-buttons input, #mchat-bbcodes #format-buttons select { + margin-bottom: 5px; +} + +#mchat-bbcodes #colour_palette label { + display: none; +} + +#mchat-bbcodes #colour_palette table { + margin: 0 auto 5px; +} + +#mchat-smilies { + padding: 0; +} + +#mchat-refresh-ok, #mchat-refresh-load, #mchat-refresh-error, #mchat-refresh-paused { + vertical-align: middle; +} + +#mchat-refresh-ok, #mchat-refresh-load, #mchat-refresh-error { + display: none; +} + +#mchat-refresh-load { + cursor: wait; +} + +#mchat-refresh-ok, #mchat-refresh-error, #mchat-refresh-paused { + cursor: help; +} + +#mchat-legend { + clear: both; +} + +.mchat-static, #mchat-stats, #mchat-whois, #mchat-refresh, #mchat-legend { + padding: 5px 0; + text-align: left; + font-size: 1.1em; +} + +.mchat-copyright { + position: relative; + top: 1px; + font-weight: bold; + font-size: 1.1em; + cursor: help; +} + +#mchat-copyright-footer { + display: inline; +} + +#mchat-copyright-footer li { + display: inline; +} + +#mchat-copyright-footer li:first-child:before{ + content: ""; +} + +#mchat-copyright-footer li:before{ + content: "• "; +} + +.mchat-static { + padding: 5px 5px 7px !important; +} + +#mchat-colour { + display: none; +} + +/* Compatibility with Advanced BBCode Box extension */ + +#abbc3_buttons { + margin: 0 !important; + padding-bottom: 5px; +} + +#abbc3_buttons .abbc3_buttons_row { + margin: 0 auto !important; +} diff --git a/styles/basic/template/event/overall_header_head_append.html b/styles/basic/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/basic/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/basic/template/mchat_navlink.html b/styles/basic/template/mchat_navlink.html new file mode 100644 index 0000000..99a90ef --- /dev/null +++ b/styles/basic/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/basic/theme/mchat_custom.css b/styles/basic/theme/mchat_custom.css new file mode 100644 index 0000000..dadd756 --- /dev/null +++ b/styles/basic/theme/mchat_custom.css @@ -0,0 +1,77 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @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; +} diff --git a/styles/black/template/event/overall_header_head_append.html b/styles/black/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/black/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/black/template/mchat_navlink.html b/styles/black/template/mchat_navlink.html new file mode 100644 index 0000000..99a90ef --- /dev/null +++ b/styles/black/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/black/theme/mchat_custom.css b/styles/black/theme/mchat_custom.css new file mode 100644 index 0000000..d222458 --- /dev/null +++ b/styles/black/theme/mchat_custom.css @@ -0,0 +1,81 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @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 { + padding: 5px !important; +} + +li.mchat-message:first-child { + border-top-width: 1px !important; + padding-top: 5px !important; +} + +li.mchat-message:last-child { + border-bottom-width: 1px !important; + padding-bottom: 5px !important; +} diff --git a/styles/elegance/template/event/overall_header_head_append.html b/styles/elegance/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/elegance/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/elegance/template/mchat_navlink.html b/styles/elegance/template/mchat_navlink.html new file mode 100644 index 0000000..99a90ef --- /dev/null +++ b/styles/elegance/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/elegance/theme/mchat_custom.css b/styles/elegance/theme/mchat_custom.css new file mode 100644 index 0000000..d222458 --- /dev/null +++ b/styles/elegance/theme/mchat_custom.css @@ -0,0 +1,81 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @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 { + padding: 5px !important; +} + +li.mchat-message:first-child { + border-top-width: 1px !important; + padding-top: 5px !important; +} + +li.mchat-message:last-child { + border-bottom-width: 1px !important; + padding-bottom: 5px !important; +} diff --git a/styles/latte/template/event/overall_header_head_append.html b/styles/latte/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/latte/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/latte/template/mchat_navlink.html b/styles/latte/template/mchat_navlink.html new file mode 100644 index 0000000..99a90ef --- /dev/null +++ b/styles/latte/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/latte/theme/mchat_custom.css b/styles/latte/theme/mchat_custom.css new file mode 100644 index 0000000..d222458 --- /dev/null +++ b/styles/latte/theme/mchat_custom.css @@ -0,0 +1,81 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @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 { + padding: 5px !important; +} + +li.mchat-message:first-child { + border-top-width: 1px !important; + padding-top: 5px !important; +} + +li.mchat-message:last-child { + border-bottom-width: 1px !important; + padding-bottom: 5px !important; +} diff --git a/styles/pbtech/template/event/overall_header_head_append.html b/styles/pbtech/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/pbtech/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/pbtech/template/mchat_header.html b/styles/pbtech/template/mchat_header.html new file mode 100644 index 0000000..b937d63 --- /dev/null +++ b/styles/pbtech/template/mchat_header.html @@ -0,0 +1,3 @@ +
    +

    {L_MCHAT_ARCHIVE_PAGE}{L_MCHAT_TITLE}{L_MCHAT_TITLE}

    +
    diff --git a/styles/pbtech/template/mchat_navlink.html b/styles/pbtech/template/mchat_navlink.html new file mode 100644 index 0000000..3dedc11 --- /dev/null +++ b/styles/pbtech/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/pbtech/theme/mchat_custom.css b/styles/pbtech/theme/mchat_custom.css new file mode 100644 index 0000000..231ab22 --- /dev/null +++ b/styles/pbtech/theme/mchat_custom.css @@ -0,0 +1,21 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +.icon-mchat > a:before { + content: '\f086'; + font-family: 'FontAwesome'; +} + +.cp-mini { + background-color: #E5E4E3; +} + +#mChat + .forabg .collapse-box a:before { + content: ''; +} diff --git a/styles/pbwow3/template/event/overall_header_head_append.html b/styles/pbwow3/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/pbwow3/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/pbwow3/template/mchat_header.html b/styles/pbwow3/template/mchat_header.html new file mode 100644 index 0000000..b937d63 --- /dev/null +++ b/styles/pbwow3/template/mchat_header.html @@ -0,0 +1,3 @@ +
    +

    {L_MCHAT_ARCHIVE_PAGE}{L_MCHAT_TITLE}{L_MCHAT_TITLE}

    +
    diff --git a/styles/pbwow3/template/mchat_navlink.html b/styles/pbwow3/template/mchat_navlink.html new file mode 100644 index 0000000..3dedc11 --- /dev/null +++ b/styles/pbwow3/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/pbwow3/theme/mchat_custom.css b/styles/pbwow3/theme/mchat_custom.css new file mode 100644 index 0000000..8306eee --- /dev/null +++ b/styles/pbwow3/theme/mchat_custom.css @@ -0,0 +1,22 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +.icon-mchat > a:before { + content: '\f086'; + font-family: 'FontAwesome'; +} + +#mChat + .forabg .collapse-box a { + color: inherit; +} + +#mChat + .forabg .collapse-box a:before { + content: ''; + margin-right: 0; +} diff --git a/styles/prosilver/template/event/overall_header_head_append.html b/styles/prosilver/template/event/overall_header_head_append.html deleted file mode 100644 index d927c39..0000000 --- a/styles/prosilver/template/event/overall_header_head_append.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/styles/prosilver/template/event/overall_header_navigation_append.html b/styles/prosilver/template/event/overall_header_navigation_append.html deleted file mode 100644 index c633ea3..0000000 --- a/styles/prosilver/template/event/overall_header_navigation_append.html +++ /dev/null @@ -1 +0,0 @@ -
  • {L_MCHAT_TITLE}
  • diff --git a/styles/prosilver/template/mchat.js b/styles/prosilver/template/mchat.js deleted file mode 100644 index ae0f4dd..0000000 --- a/styles/prosilver/template/mchat.js +++ /dev/null @@ -1,474 +0,0 @@ -/** - * - * @package mChat JavaScript Code mini - * @version 1.5.1 of 2016-01-17 - * @copyright (c) 2009 By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/ - * @copyright (c) 2013 By Rich McGirr (RMcGirr83) http://rmcgirr83.org - * @copyright (c) 2015 By dmzx - http://www.dmzx-web.net - * @copyright (c) 2015 By kasimi - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * - */ -// Support Opera -if (typeof document.hasFocus === 'undefined') { - document.hasFocus = function() { - return document.visibilityState == 'visible'; - }; -} - -jQuery(function($) { - var ajaxRequest = function(mode, sendHiddenFields, data) { - var deferred = $.Deferred(); - var promise = deferred.promise(); - if (sendHiddenFields) { - $.extend(data, mChat.hiddenFields); - } - $.ajax({ - url: mChat.file.replace('mchat', 'mchat-' + mode), - timeout: 5000, - type: 'POST', - dataType: 'json', - data: data - }).success(function(json, status, xhr) { - if (json[mode]) { - deferred.resolve(json, status, xhr); - } else { - deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format'); - } - }).error(function(xhr, status, error) { - deferred.reject(xhr, status, error); - }); - return promise.fail(function(xhr, textStatus, errorThrown) { - mChat.sound('error'); - mChat.$$('refresh-load', 'refresh-ok', 'refresh-paused').hide(); - mChat.$$('refresh-error').show(); - if (errorThrown == 'format') { - // Unexpected format - } else if (errorThrown == 'session') { - mChat.endSession(); - alert(mChat.sessOut); - } else if (xhr.status == 400) { - alert(mChat.flood); - } else if (xhr.status == 403) { - alert(mChat.noAccess); - } else if (xhr.status == 413) { - alert(mChat.mssgLngthLong); - } else if (xhr.status == 501) { - alert(mChat.noMessageInput); - } else if (typeof console !== 'undefined' && console.log) { - console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); - } - }); - }; - - $.extend(mChat, { - clear: function() { - if (mChat.$$('input').val() !== '') { - if (confirm(mChat.clearConfirm)) { - mChat.resetSession(true); - mChat.$$('input').val(''); - } - mChat.$$('input').focus(); - } - }, - sound: function(file) { - if (!mChat.pageIsUnloading && !Cookies.get('mchat_no_sound')) { - var audio = mChat.$$('sound-' + file).get(0); - if (audio.duration) { - audio.pause(); - audio.currentTime = 0; - audio.play(); - } - } - }, - notice: function() { - if (!document.hasFocus()) { - $.titleAlert(mChat.newMessageAlert, {interval: 1000}); - } - }, - toggle: function(name) { - var $elem = mChat.$$(name); - $elem.stop().slideToggle(function() { - var cookieName = 'mchat_show_' + name; - if ($elem.is(':visible')) { - Cookies.set(cookieName, 'yes'); - } else { - Cookies.remove(cookieName); - } - }); - }, - add: function() { - if (mChat.$$('add').prop('disabled')) { - return; - } - if ($.trim(mChat.$$('input').val()) === '') { - return; - } - var messChars = mChat.$$('input').val().replace(/\s/g, ''); - if (mChat.mssgLngth && messChars.length > mChat.mssgLngth) { - alert(mChat.mssgLngthLong); - return; - } - mChat.pauseSession(); - mChat.$$('add').prop('disabled', true); - mChat.refresh(mChat.$$('input').val()).done(function() { - mChat.$$('input').val(''); - }).always(function() { - mChat.$$('input').focus(); - mChat.$$('add').prop('disabled', false); - mChat.resetSession(false); - }); - }, - edit: function() { - var $container = $(this).closest('.mchat-message'); - var $message = mChat.$$('confirm').find('textarea').show().val($container.data('message')); - mChat.$$('confirm').find('p').text(mChat.editInfo); - phpbb.confirm(mChat.$$('confirm'), function() { - ajaxRequest('edit', true, { - message_id: $container.data('id'), - message: $message.val() - }).done(function(json) { - mChat.sound('edit'); - $container.fadeOut('slow', function() { - $container.replaceWith($(json.edit).hide().fadeIn('slow')); - }); - mChat.resetSession(true); - }); - }); - }, - del: function() { - var $container = $(this).closest('.mchat-message'); - mChat.$$('confirm').find('textarea').hide(); - mChat.$$('confirm').find('p').text(mChat.delConfirm); - phpbb.confirm(mChat.$$('confirm'), function() { - ajaxRequest('del', true, { - message_id: $container.data('id') - }).done(function() { - mChat.sound('del'); - $container.fadeOut('slow', function() { - $container.remove(); - }); - mChat.resetSession(true); - }); - }); - }, - refresh: function(message) { - var $messages = mChat.$$('messages').children(); - var data = { - message_last_id: $messages.filter(mChat.messageTop ? ':first' : ':last').data('id') - }; - if (message) { - data.message = message; - } - if (mChat.liveUpdates) { - data.message_first_id = $messages.filter(mChat.messageTop ? ':last' : ':first').data('id'); - data.message_edits = {}; - var now = Math.floor(Date.now() / 1000); - $.each($messages, function() { - var $message = $(this); - var editTime = $message.data('edit-time'); - if (editTime && (!mChat.editDeleteLimit || $message.data('message-time') >= now - mChat.editDeleteLimit / 1000)) { - data.message_edits[$message.data('id')] = editTime; - } - }); - } - mChat.$$('refresh-ok', 'refresh-error', 'refresh-paused').hide(); - mChat.$$('refresh-load').show(); - return ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) { - var $html = $(json.add); - if ($html.length) { - mChat.sound('add'); - mChat.notice(); - mChat.$$('no-messages').remove(); - $html.hide().each(function(i) { - var $message = $(this); - setTimeout(function() { - if (mChat.messageTop) { - mChat.$$('messages').prepend($message); - } else { - mChat.$$('messages').append($message); - } - $message.css('opacity', 0).slideDown('slow').animate({opacity: 1}, {queue: false, duration: 'slow'}); - mChat.$$('main').animate({scrollTop: mChat.messageTop ? 0 : mChat.$$('main')[0].scrollHeight}, 'slow'); - }, i * 600); - if (mChat.editDeleteLimit && $message.data('edit-delete-limit') && $message.find('[data-mchat-action="edit"], [data-mchat-action="del"]').length > 0) { - var id = $message.attr('id'); - setTimeout(function() { - $('#' + id).find('[data-mchat-action="edit"], [data-mchat-action="del"]').fadeOut('slow', function() { - $(this).remove(); - }); - }, mChat.editDeleteLimit); - } - }); - } - if (json.edit) { - var isFirstEdit = true; - $.each(json.edit, function(id, content) { - var $container = $('#mchat-message-' + id); - if ($container.length) { - if (isFirstEdit) { - isFirstEdit = false; - mChat.sound('edit'); - } - $container.fadeOut('slow', function() { - $container.replaceWith($(content).hide().fadeIn('slow')); - }); - } - }); - } - if (json.del) { - var isFirstDelete = true; - $.each(json.del, function(i, id) { - var $container = $('#mchat-message-' + id); - if ($container.length) { - if (isFirstDelete) { - isFirstDelete = false; - mChat.sound('del'); - } - $container.fadeOut('slow', function() { - $container.remove(); - }); - } - }); - } - setTimeout(function() { - if (mChat.refreshInterval) { - mChat.$$('refresh-load', 'refresh-error', 'refresh-paused').hide(); - mChat.$$('refresh-ok').show(); - } - }, 250); - }); - }, - whois: function() { - if (mChat.customPage) { - mChat.$$('refresh-pending').show(); - mChat.$$('refresh').hide(); - } - ajaxRequest('whois', false, {}).done(function(json) { - var $whois = $(json.whois); - var $userlist = $whois.find('#mchat-userlist'); - if (Cookies.get('mchat_show_userlist')) { - $userlist.show(); - } - mChat.$$('whois').replaceWith($whois); - mChat.cache.whois = $whois; - mChat.cache.userlist = $userlist; - if (mChat.customPage) { - setTimeout(function() { - mChat.$$('refresh-pending').hide(); - mChat.$$('refresh').show(); - }, 250); - } - }); - }, - timeLeft: function(sessionTime) { - return (new Date(sessionTime * 1000)).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0]; - }, - countDown: function() { - mChat.sessionTime -= 1; - mChat.$$('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime)); - if (mChat.sessionTime < 1) { - mChat.endSession(); - } - }, - pauseSession: function() { - clearInterval(mChat.refreshInterval); - if (mChat.userTimeout) { - clearInterval(mChat.sessionCountdown); - } - if (mChat.whoisRefresh) { - clearInterval(mChat.whoisInterval); - } - }, - resetSession: function(updateUi) { - clearInterval(mChat.refreshInterval); - mChat.refreshInterval = setInterval(mChat.refresh, mChat.refreshTime); - if (mChat.userTimeout) { - mChat.sessionTime = mChat.userTimeout / 1000; - clearInterval(mChat.sessionCountdown); - mChat.$$('session').html(mChat.sessEnds + ' ' + mChat.timeLeft(mChat.sessionTime)); - mChat.sessionCountdown = setInterval(mChat.countDown, 1000); - } - if (mChat.whoisRefresh) { - clearInterval(mChat.whoisInterval); - mChat.whoisInterval = setInterval(mChat.whois, mChat.whoisRefresh); - } - if (mChat.pause) { - mChat.$$('input').one('keypress', mChat.endSession); - } - if (updateUi) { - mChat.$$('refresh-ok').show(); - mChat.$$('refresh-load', 'refresh-error', 'refresh-paused').hide(); - mChat.$$('refresh-text').html(mChat.refreshYes); - } - }, - endSession: function() { - clearInterval(mChat.refreshInterval); - mChat.refreshInterval = false; - if (mChat.userTimeout) { - clearInterval(mChat.sessionCountdown); - mChat.$$('session').html(mChat.sessOut); - } - if (mChat.whoisRefresh) { - clearInterval(mChat.whoisInterval); - mChat.whois(); - } - mChat.$$('refresh-load', 'refresh-ok', 'refresh-error').hide(); - mChat.$$('refresh-paused').show(); - mChat.$$('refresh-text').html(mChat.refreshNo); - }, - mention: function() { - var $container = $(this).closest('.mchat-message'); - var username = mChat.entityDecode($container.data('username')); - var usercolor = $container.data('usercolor'); - if (usercolor) { - username = '[b][color=' + usercolor + ']' + username + '[/color][/b]'; - } else if (mChat.allowBBCodes) { - username = '[b]' + username + '[/b]'; - } - insert_text('@ ' + username + ', '); - }, - quote: function() { - var $container = $(this).closest('.mchat-message'); - var username = mChat.entityDecode($container.data('username')); - var quote = mChat.entityDecode($container.data('message')); - insert_text('[quote="' + username + '"] ' + quote + '[/quote]'); - }, - like: function() { - var $container = $(this).closest('.mchat-message'); - var username = mChat.entityDecode($container.data('username')); - var quote = mChat.entityDecode($container.data('message')); - insert_text(mChat.likes + '[quote="' + username + '"] ' + quote + '[/quote]'); - }, - entityDecode: function(text) { - var s = decodeURIComponent(text.toString().replace(/\+/g, ' ')); - s = s.replace(/</g, '<'); - s = s.replace(/>/g, '>'); - s = s.replace(/:/g, ':'); - s = s.replace(/./g, '.'); - s = s.replace(/&/g, '&'); - s = s.replace(/"/g, "'"); - return s; - }, - $$: function() { - return $($.map(arguments, function(name) { - if (!mChat.cache[name]) { - mChat.cache[name] = $('#mchat-' + name); - } - return mChat.cache[name]; - })).map(function() { - return this.toArray(); - }); - } - }); - - mChat.cache = {}; - mChat.$$('confirm').detach().show(); - - mChat.hiddenFields = {}; - $('#mchat-form').find('input[type=hidden]').each(function() { - mChat.hiddenFields[this.name] = this.value; - }); - - if (!mChat.archiveMode) { - $.fn.autoGrowInput = function() { - this.filter('input:text').each(function() { - var comfortZone = 20; - var minWidth = $(this).width(); - var val = ''; - var input = $(this); - var testSubject = $('
    ').css({ - position: 'absolute', - top: -9999, - left: -9999, - width: 'auto', - fontSize: input.css('fontSize'), - fontFamily: input.css('fontFamily'), - fontWeight: input.css('fontWeight'), - letterSpacing: input.css('letterSpacing'), - whiteSpace: 'nowrap' - }); - testSubject.insertAfter(input); - $(this).on('keypress blur change submit focus', function() { - if (val === (val = input.val())) { - return; - } - var escaped = val.replace(/&/g, '&').replace(/\s/g, ' ').replace(//g, '>'); - var testerWidth = testSubject.html(escaped).width(); - var newWidth = (testerWidth + comfortZone) >= minWidth ? testerWidth + comfortZone : minWidth; - if ((newWidth < input.width() && newWidth >= minWidth) || (newWidth > minWidth && newWidth < $('.mchat-panel').width() - comfortZone)) { - input.width(newWidth); - } - }); - }); - return this; - }; - - mChat.resetSession(true); - - if (!mChat.messageTop) { - mChat.$$('main').animate({scrollTop: mChat.$$('main')[0].scrollHeight}, 'slow', 'swing'); - } - - mChat.$$('user-sound').prop('checked', mChat.playSound && !Cookies.get('mchat_no_sound')); - - if (Cookies.get('mchat_show_smilies')) { - mChat.$$('smilies').slideToggle('slow'); - } - - if (Cookies.get('mchat_show_bbcodes')) { - mChat.$$('bbcodes').slideToggle('slow', function() { - if (Cookies.get('mchat_show_colour')) { - mChat.$$('colour').slideToggle('slow'); - } - }); - } - - if (Cookies.get('mchat_show_userlist')) { - mChat.$$('userlist').slideToggle('slow'); - } - - mChat.$$('colour').html(phpbb.colorPalette('h', 15, 10)).on('click', 'a', function(e) { - var color = $(this).data('color'); - bbfontstyle('[color=#' + color + ']', '[/color]'); - e.preventDefault(); - }); - - if (!mChat.$$('user-sound').prop('checked')) { - Cookies.set('mchat_no_sound', 'yes'); - } - - mChat.$$('user-sound').change(function() { - if (this.checked) { - Cookies.remove('mchat_no_sound'); - } else { - Cookies.set('mchat_no_sound', 'yes'); - } - }); - - if (mChat.$$('input').is('input')) { - $('#mchat-form').on('keypress', function(e) { - if (e.which == 13) { - mChat.add(); - e.preventDefault(); - } - }); - } - - mChat.$$('input').autoGrowInput(); - } - - $(window).on('beforeunload', function() { - mChat.pageIsUnloading = true; - }); - - $('#phpbb').on('click', '[data-mchat-action]', function(e) { - var action = $(this).data('mchat-action'); - mChat[action].call(this); - e.preventDefault(); - }).on('click', '[data-mchat-toggle]', function(e) { - var elem = $(this).data('mchat-toggle'); - mChat.toggle(elem); - e.preventDefault(); - }); -}); diff --git a/styles/prosilver/template/mchat_bbcodes.html b/styles/prosilver/template/mchat_bbcodes.html deleted file mode 100644 index 1ee41b4..0000000 --- a/styles/prosilver/template/mchat_bbcodes.html +++ /dev/null @@ -1,93 +0,0 @@ -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    diff --git a/styles/prosilver/template/mchat_body.html b/styles/prosilver/template/mchat_body.html deleted file mode 100644 index 0a38e46..0000000 --- a/styles/prosilver/template/mchat_body.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - -
    - -
    - - - - -
    -
    - - -
    - - - - - - - -
    style="height:{MCHAT_CUSTOM_HEIGHT}{MCHAT_INDEX_HEIGHT}px"> - - -
    -
    {L_MCHAT_NOMESSAGE}
    -
    - - -
    {L_MCHAT_ANNOUNCEMENT}{L_COLON} {MCHAT_STATIC_MESS}
    - - - - - - -
    - {S_FORM_TOKEN} - -
    - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {L_LOADING} - {L_MCHAT_OK} - {L_MCHAT_PAUSE} - {L_ERROR} - {MCHAT_REFRESH_YES} - {L_MCHAT_SESSION_ENDS} {MCHAT_USER_TIMEOUT_TIME} - {L_MCHAT_COPYRIGHT} -
    -
    - -
    -
    -
    -
    - - -
    - -
    - - - -

    {L_WHO_IS_CHATTING}

    - -
    - {MCHAT_WHOIS_REFRESH_EXPLAIN} - -

    {L_LEGEND}{L_COLON} {LEGEND} -
    - -
    - {L_LEGEND}{L_COLON} {LEGEND} -
    - - - - - diff --git a/styles/prosilver/template/mchat_messages.html b/styles/prosilver/template/mchat_messages.html deleted file mode 100644 index b8dcf62..0000000 --- a/styles/prosilver/template/mchat_messages.html +++ /dev/null @@ -1,26 +0,0 @@ - -
    data-usercolor="{mchatrow.MCHAT_USERNAME_COLOR}" data-message="{mchatrow.MCHAT_MESSAGE_EDIT}" data-message-time="{mchatrow.MCHAT_MESSAGE_TIME}" data-edit-time="{mchatrow.MCHAT_EDIT_TIME}" data-edit-delete-limit="1"> - - - -
    - style="color:{mchatrow.MCHAT_USERNAME_COLOR}">@ - {mchatrow.MCHAT_USERNAME_FULL} - {mchatrow.MCHAT_TIME} -
    -
    - {L_MCHAT_SEND_PM} - {L_MCHAT_LIKE} - {L_REPLY_WITH_QUOTE} - {mchatrow.MCHAT_WHOIS_USER} - {L_MCHAT_PERMISSIONS} - {L_MCHAT_EDIT} - {L_DELETE} -
    -
    -
    {mchatrow.MCHAT_MESSAGE}
    -
    - diff --git a/styles/prosilver/template/mchat_whois.html b/styles/prosilver/template/mchat_whois.html deleted file mode 100644 index 652d385..0000000 --- a/styles/prosilver/template/mchat_whois.html +++ /dev/null @@ -1,8 +0,0 @@ -
    - - {MCHAT_USERS_COUNT} - - {MCHAT_USERS_COUNT} - - {MCHAT_ONLINE_EXPLAIN}
    -
    diff --git a/styles/prosilver/template/ucp_mchat.html b/styles/prosilver/template/ucp_mchat.html deleted file mode 100644 index 917f641..0000000 --- a/styles/prosilver/template/ucp_mchat.html +++ /dev/null @@ -1,71 +0,0 @@ - - -
    - -

    {L_TITLE}

    - -
    -
    -
    -

    {ERROR}

    - -
    -
    -
    - - -
    -
    - -
    -
    -
    - - -
    -
    - -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - {S_HIDDEN_FIELDS}  - - {S_FORM_TOKEN} -
    -
    - - diff --git a/styles/prosilver/theme/mchat.css b/styles/prosilver/theme/mchat.css deleted file mode 100644 index 1150233..0000000 --- a/styles/prosilver/theme/mchat.css +++ /dev/null @@ -1,176 +0,0 @@ -/** - * - * @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 - * - */ -.mchat-message { - background: linear-gradient(#B6BFC4, #FFFFFF, #FFFFFF, #B6BFC4); - border: 1px solid #999999; - border-radius: 6px; - padding: 5px; - margin-right: 1px; - overflow: hidden; -} - -.mchat-message:hover { - background-color: #F6F4D0; -} - -.mchat-bg-1 { - color: #333333; -} - -.mchat-bg-2 { - color: #444444; -} - -.mchat-row-limit { - overflow: auto; - width: 100%; -} - -.mchat-panel { - text-align: center; - padding: 3px; - clear: both; -} - -#mchat-input { - cursor: text; - width: 50%; - background-color: #FFFFFF; - border: 1px solid #B4BAC0; - color: #333333; - font-size: 1.1em; - padding: 5px 5px 3px 5px; - margin: 3px 0px 3px 5px; -} - -#mchat-input:hover { - border-color: #11A3EA; -} - -#mchat-body { - width: 100% !important; - background-color: #E9F0F5 !important; -} - -#mchat-static, #mchat-stats, #mchat-whois, .mchat-refresh { - padding-left: 5px; - text-align: left; - font-size: 1.1em; -} - -#mchat-static { - color: #990000; -} - -#mchat-stats, #mchat-whois { - margin-top: 2px; - min-height: 1.3em; - height: auto !important; -} - -.mchat-refresh { - margin-top: 1.5em; - clear: both; -} - -.mchat-text { - padding: 3px; - font-size: 1.1em; - width: 98%; -} - -.mchat-text ul { - margin-left: 10px; -} - -.mchat-text blockquote { - margin: 5px 0 0 10px -} - -.mchat-panel-image { - margin-top: -4px; - vertical-align: middle; -} - -.mchat-message-header { - float: left; -} - -.mchat-message-icons { - float: right; -} - -.mchat-mention, .mchat-message-icons > * { - cursor: pointer; -} - -#mchat-smilies { - padding: 5px; -} - -#mchat-refresh-load { - vertical-align: middle; - cursor: wait; - display: none; -} - -#mchat-refresh-ok { - vertical-align: middle; - cursor: help; -} - -#mchat-refresh-error, #mchat-refresh-paused { - vertical-align: middle; - cursor: help; - display: none; -} - -#mchat-status { - padding: 5px; -} - -.mchat-alert { - color: #7E2217; - padding: 10px; -} - -#mchat-userlist { - float: left; -} - -.mchat-avatar { - float: left; - width: 40px; - padding-right: 5px; -} - -.mchat-message-avatar .mchat-text { - margin-left: 50px; - width: 90%; - margin-right: 5px; -} - -#mchat-confirm textarea { - width: 100%; - height: 100px; -} - -#mchat-colour { - margin-top: 5px; -} - -#mchat-colour table { - margin: 0 auto; - border-collapse: separate; - border-spacing: 1px; -} - -#mchat-bbcodes { - padding: 5px; - display: none; -} diff --git a/styles/simplicity/template/event/overall_header_head_append.html b/styles/simplicity/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/simplicity/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/simplicity/template/mchat_navlink.html b/styles/simplicity/template/mchat_navlink.html new file mode 100644 index 0000000..99a90ef --- /dev/null +++ b/styles/simplicity/template/mchat_navlink.html @@ -0,0 +1 @@ +
  • {L_MCHAT_TITLE}
  • diff --git a/styles/simplicity/theme/mchat_custom.css b/styles/simplicity/theme/mchat_custom.css new file mode 100644 index 0000000..d222458 --- /dev/null +++ b/styles/simplicity/theme/mchat_custom.css @@ -0,0 +1,81 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @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 { + padding: 5px !important; +} + +li.mchat-message:first-child { + border-top-width: 1px !important; + padding-top: 5px !important; +} + +li.mchat-message:last-child { + border-bottom-width: 1px !important; + padding-bottom: 5px !important; +} diff --git a/styles/we_universal/template/event/overall_header_head_append.html b/styles/we_universal/template/event/overall_header_head_append.html new file mode 100644 index 0000000..22a6a0f --- /dev/null +++ b/styles/we_universal/template/event/overall_header_head_append.html @@ -0,0 +1,2 @@ + + diff --git a/styles/we_universal/theme/mchat_custom.css b/styles/we_universal/theme/mchat_custom.css new file mode 100644 index 0000000..7ac850f --- /dev/null +++ b/styles/we_universal/theme/mchat_custom.css @@ -0,0 +1,12 @@ +/** + * + * @package phpBB Extension - mChat + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +#mchat-panel { + border-radius: 0; +} diff --git a/ucp/ucp_mchat_info.php b/ucp/ucp_mchat_info.php index 32c8dc1..51c3178 100644 --- a/ucp/ucp_mchat_info.php +++ b/ucp/ucp_mchat_info.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/ucp/ucp_mchat_module.php b/ucp/ucp_mchat_module.php index 2722ae7..a8b15f4 100644 --- a/ucp/ucp_mchat_module.php +++ b/ucp/ucp_mchat_module.php @@ -3,7 +3,8 @@ /** * * @package phpBB Extension - mChat - * @copyright (c) 2015 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 dmzx - http://www.dmzx-web.net + * @copyright (c) 2016 kasimi * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -12,83 +13,21 @@ namespace dmzx\mchat\ucp; class ucp_mchat_module { - function main($id, $mode) + public $u_action; + + public function main($id, $mode) { - global $config, $db, $user, $template, $request; + global $phpbb_container, $user; - $error = $data = array(); + // Add the UCP lang file + $user->add_lang_ext('dmzx/mchat', 'mchat_ucp'); - switch ($mode) - { - case 'configuration': - - $data = array( - '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_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_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']), - ); - - add_form_key('ucp_mchat'); - - if ($request->is_set_post('submit')) - { - if (!check_form_key('ucp_mchat')) - { - $error[] = 'FORM_INVALID'; - } - - if (!sizeof($error)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $data) . ' - WHERE user_id = ' . (int) $user->data['user_id']; - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang('PROFILE_UPDATED') . '

    ' . sprintf($user->lang('RETURN_UCP'), '', ''); - trigger_error($message); - } - - // Replace "error" strings with their real, localised form - // The /e modifier is deprecated since PHP 5.5.0 - //$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); - foreach ($error as $i => $err) - { - $lang = $user->lang($err); - if (!empty($lang)) - { - $error[$i] = $lang; - } - } - } - - $template->assign_vars(array( - 'ERROR' => sizeof($error) ? implode('
    ', $error) : '', - - 'S_DISPLAY_MCHAT' => $data['user_mchat_index'], - 'S_SOUND_MCHAT' => $data['user_mchat_sound'], - 'S_STATS_MCHAT' => $data['user_mchat_stats_index'], - 'S_TOPICS_MCHAT' => $data['user_mchat_topics'], - 'S_AVATARS_MCHAT' => $data['user_mchat_avatars'], - 'S_INPUT_MCHAT' => $data['user_mchat_input_area'], - 'S_MCHAT_TOPICS' => $config['mchat_new_posts_edit'] || $config['mchat_new_posts_quote'] || $config['mchat_new_posts_reply'] || $config['mchat_new_posts_topic'], - 'S_MCHAT_INDEX' => $config['mchat_on_index'], - 'S_MCHAT_INDEX_STATS' => $config['mchat_stats_index'], - 'S_MCHAT_AVATARS' => $config['mchat_avatars'], - )); - break; - } - - $template->assign_vars(array( - 'L_TITLE' => $user->lang('UCP_PROFILE_MCHAT'), - 'S_UCP_ACTION' => $this->u_action, - )); - - // Set desired template + // Set template $this->tpl_name = 'ucp_mchat'; $this->page_title = 'UCP_PROFILE_MCHAT'; + + // Get an instance of the UCP controller and display the options + $controller = $phpbb_container->get('dmzx.mchat.ucp.controller'); + $controller->display_options($this->u_action); } }