Version 1.0.0-RC1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package phpBB Extension - mChat
|
||||
@@ -30,7 +31,7 @@ class functions_mchat
|
||||
protected $cache;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path;
|
||||
protected $root_path;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext;
|
||||
@@ -53,12 +54,12 @@ class functions_mchat
|
||||
* @param \phpbb\log\log_interface $log
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\cache\driver\driver_interface $cache
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $root_path
|
||||
* @param string $php_ext
|
||||
* @param string $mchat_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, $phpbb_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_sessions_table)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
@@ -66,15 +67,18 @@ class functions_mchat
|
||||
$this->log = $log;
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->mchat_table = $mchat_table;
|
||||
$this->mchat_sessions_table = $mchat_sessions_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a number of seconds to a string in the format 'x hours y minutes z seconds'
|
||||
*/
|
||||
* Converts a number of seconds to a string in the format 'x hours y minutes z seconds'
|
||||
*
|
||||
* @param int $time
|
||||
* @return string
|
||||
*/
|
||||
protected function mchat_format_seconds($time)
|
||||
{
|
||||
$times = array();
|
||||
@@ -83,36 +87,40 @@ class functions_mchat
|
||||
if ($hours)
|
||||
{
|
||||
$time -= $hours * 3600;
|
||||
$times[] = $hours . ' ' . $this->user->lang($hours > 1 ? 'MCHAT_HOURS' : 'MCHAT_HOUR');
|
||||
$times[] = $this->user->lang('MCHAT_HOURS', $hours);
|
||||
}
|
||||
|
||||
$minutes = floor($time / 60);
|
||||
if ($minutes)
|
||||
{
|
||||
$time -= $minutes * 60;
|
||||
$times[] = $minutes . ' ' . $this->user->lang($minutes > 1 ? 'MCHAT_MINUTES' : 'MCHAT_MINUTE');
|
||||
$times[] = $this->user->lang('MCHAT_MINUTES', $minutes);
|
||||
}
|
||||
|
||||
$seconds = ceil($time);
|
||||
if ($seconds)
|
||||
{
|
||||
$times[] = $seconds . ' ' . $this->user->lang($seconds > 1 ? 'MCHAT_SECONDS' : 'MCHAT_SECOND');
|
||||
$times[] = $this->user->lang('MCHAT_SECONDS', $seconds);
|
||||
}
|
||||
|
||||
return sprintf($this->user->lang('MCHAT_ONLINE_EXPLAIN'), implode(' ', $times));
|
||||
return $this->user->lang('MCHAT_ONLINE_EXPLAIN', implode(' ', $times));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total session time in seconds
|
||||
*/
|
||||
* Returns the total session time in seconds
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function mchat_session_time()
|
||||
{
|
||||
return !empty($this->config['mchat_timeout']) ? $this->config['mchat_timeout'] : (!empty($this->config['load_online_time']) ? $this->config['load_online_time'] * 60 : $this->config['session_length']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data about users who are currently chatting
|
||||
*/
|
||||
* Returns data about users who are currently chatting
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function mchat_active_users()
|
||||
{
|
||||
$mchat_users = array();
|
||||
@@ -146,14 +154,14 @@ class functions_mchat
|
||||
|
||||
return array(
|
||||
'online_userlist' => implode($this->user->lang('COMMA_SEPARATOR'), $mchat_users),
|
||||
'mchat_users_count' => count($mchat_users) ? $this->user->lang(count($mchat_users) > 1 ? 'MCHAT_ONLINE_USERS_TOTAL' : 'MCHAT_ONLINE_USER_TOTAL', count($mchat_users)) : $this->user->lang('MCHAT_NO_CHATTERS'),
|
||||
'mchat_users_count' => $this->user->lang('MCHAT_ONLINE_USERS_TOTAL', count($mchat_users)),
|
||||
'refresh_message' => $this->mchat_format_seconds($this->mchat_session_time()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the current user into the mchat_sessions table
|
||||
*/
|
||||
* Inserts the current user into the mchat_sessions table
|
||||
*/
|
||||
public function mchat_add_user_session()
|
||||
{
|
||||
// Remove expired sessions from the database
|
||||
@@ -191,8 +199,8 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Prune messages
|
||||
*/
|
||||
* Prune messages
|
||||
*/
|
||||
public function mchat_prune()
|
||||
{
|
||||
if ($this->config['mchat_prune'])
|
||||
@@ -218,16 +226,23 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of messages
|
||||
*/
|
||||
* Returns the total number of messages
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function mchat_total_message_count()
|
||||
{
|
||||
return $this->db->get_row_count($this->mchat_table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch messages from the database
|
||||
*/
|
||||
* Fetch messages from the database
|
||||
*
|
||||
* @param $sql_where
|
||||
* @param int $total
|
||||
* @param int $offset
|
||||
* @return array
|
||||
*/
|
||||
public function mchat_get_messages($sql_where, $total = 0, $offset = 0)
|
||||
{
|
||||
$sql_array = array(
|
||||
@@ -252,8 +267,10 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the user legend markup
|
||||
*/
|
||||
* Generates the user legend markup
|
||||
*
|
||||
* @return array Array of HTML markup for each group
|
||||
*/
|
||||
public function mchat_legend()
|
||||
{
|
||||
// Grab group details for legend display for who is online on the custom page
|
||||
@@ -290,7 +307,7 @@ class functions_mchat
|
||||
}
|
||||
else
|
||||
{
|
||||
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&g='.$row['group_id']) . '">' . $group_name . '</a>';
|
||||
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=group&g='. $row['group_id']) . '">' . $group_name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,8 +315,10 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all foes of the current user
|
||||
*/
|
||||
* Returns a list of all foes of the current user
|
||||
*
|
||||
* @return array Array of user IDs
|
||||
*/
|
||||
public function mchat_foes()
|
||||
{
|
||||
if (is_null($this->foes))
|
||||
@@ -322,8 +341,11 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds forbidden BBCodes to the passed SQL where statement
|
||||
*/
|
||||
* Adds forbidden BBCodes to the passed SQL where statement
|
||||
*
|
||||
* @param string $sql_where
|
||||
* @return string
|
||||
*/
|
||||
public function mchat_sql_append_forbidden_bbcodes($sql_where)
|
||||
{
|
||||
$disallowed_bbcodes = explode('|', strtoupper($this->config['mchat_bbcode_disallowed']));
|
||||
@@ -337,8 +359,11 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a message with posting information into the database
|
||||
*/
|
||||
* Inserts a message with posting information into the database
|
||||
*
|
||||
* @param string $mode One of post|quote|edit|reply
|
||||
* @param $data The post data
|
||||
*/
|
||||
public function mchat_insert_posting($mode, $data)
|
||||
{
|
||||
$mode_config = array(
|
||||
@@ -353,9 +378,10 @@ class functions_mchat
|
||||
return;
|
||||
}
|
||||
|
||||
$mchat_new_data = $this->user->lang('MCHAT_NEW_' . strtoupper($mode));
|
||||
|
||||
$message = utf8_normalize_nfc($mchat_new_data . ': [url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $data['post_id'] . '#p' . $data['post_id'] . ']' . $data['post_subject'] . '[/url] '. $this->user->lang('MCHAT_IN') . ' [url=' . generate_board_url() . '/viewforum.' . $this->php_ext . '?f=' . $data['forum_id'] . ']' . $data['forum_name'] . ' [/url] ' . $this->user->lang('MCHAT_IN_SECTION'));
|
||||
$board_url = generate_board_url();
|
||||
$topic_url = '[url=' . $board_url . '/viewtopic.' . $this->php_ext . '?p=' . $data['post_id'] . '#p' . $data['post_id'] . ']' . $data['post_subject'] . '[/url]';
|
||||
$forum_url = '[url=' . $board_url . '/viewforum.' . $this->php_ext . '?f=' . $data['forum_id'] . ']' . $data['forum_name'] . '[/url]';
|
||||
$message = $this->user->lang('MCHAT_NEW_' . strtoupper($mode), $topic_url, $forum_url);
|
||||
|
||||
$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
|
||||
generate_text_for_storage($message, $uid, $bitfield, $options, true, false, false);
|
||||
@@ -364,19 +390,21 @@ class functions_mchat
|
||||
'post_id' => $data['post_id'],
|
||||
'user_id' => $this->user->data['user_id'],
|
||||
'user_ip' => $this->user->data['session_ip'],
|
||||
'message' => $message,
|
||||
'message' => utf8_normalize_nfc($message),
|
||||
'bbcode_bitfield' => $bitfield,
|
||||
'bbcode_uid' => $uid,
|
||||
'bbcode_options' => $options,
|
||||
'message_time' => time(),
|
||||
);
|
||||
$sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
||||
$sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user is flooding the chat
|
||||
*/
|
||||
* Checks if the current user is flooding the chat
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function mchat_is_user_flooding()
|
||||
{
|
||||
if (!$this->config['mchat_flood_time'] || $this->auth->acl_get('u_mchat_flood_ignore'))
|
||||
@@ -396,8 +424,11 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user ID & name of the specified message
|
||||
*/
|
||||
* Returns user ID & name of the specified message
|
||||
*
|
||||
* @param $message_id
|
||||
* @return array
|
||||
*/
|
||||
public function mchat_author_for_message($message_id)
|
||||
{
|
||||
$sql = 'SELECT u.user_id, u.username, m.message_time
|
||||
@@ -412,8 +443,12 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of message IDs that have been deleted from the message table
|
||||
*/
|
||||
* 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)
|
||||
{
|
||||
if ($this->config['mchat_edit_delete_limit'])
|
||||
@@ -498,8 +533,13 @@ class functions_mchat
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs add|edit|del|clean|prune actions
|
||||
*/
|
||||
* Performs AJAX actions
|
||||
*
|
||||
* @param string $action One of add|edit|del|clean|prune
|
||||
* @param array $sql_ary
|
||||
* @param int $message_id
|
||||
* @param string $log_username
|
||||
*/
|
||||
public function mchat_action($action, $sql_ary = null, $message_id = 0, $log_username = '')
|
||||
{
|
||||
switch ($action)
|
||||
@@ -522,12 +562,6 @@ class functions_mchat
|
||||
$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;
|
||||
// Founder purges all messages
|
||||
case 'clean':
|
||||
$sql = 'TRUNCATE TABLE ' . $this->mchat_table;
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
|
||||
$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;
|
||||
|
||||
140
core/mchat.php
140
core/mchat.php
@@ -51,31 +51,31 @@ class mchat
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\functions_mchat $functions_mchat
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\user $user
|
||||
* @param \phpbb\auth\auth $auth
|
||||
* @param \phpbb\pagination $pagination
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \dmzx\mchat\core\functions_mchat $functions_mchat
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\user $user
|
||||
* @param \phpbb\auth\auth $auth
|
||||
* @param \phpbb\pagination $pagination
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\event\dispatcher_interface $dispatcher
|
||||
* @param string $root_path
|
||||
* @param string $php_ext
|
||||
* @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)
|
||||
{
|
||||
$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_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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,18 +95,6 @@ class mchat
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO This might be redundant
|
||||
// If mChat is used on the index by a user without an avatar, a default avatar is used.
|
||||
// However, T_THEME_PATH points to ./../styles/... because the controller at /mchat is called, but we need it to be ./styles...
|
||||
// Setting this value to true solves this.
|
||||
if (!defined('PHPBB_USE_BOARD_URL_PATH'))
|
||||
{
|
||||
define('PHPBB_USE_BOARD_URL_PATH', true);
|
||||
}
|
||||
|
||||
global $root_path;
|
||||
$root_path = './';
|
||||
|
||||
$this->assign_bbcodes_smilies();
|
||||
|
||||
$this->render_page('index');
|
||||
@@ -207,20 +195,21 @@ class mchat
|
||||
*/
|
||||
public function page_rules()
|
||||
{
|
||||
if (empty($this->config['mchat_rules']) && empty($this->user->lang['MCHAT_RULES']))
|
||||
if (empty($this->config['mchat_rules']) && !$this->user->lang('MCHAT_RULES_MESSAGE'))
|
||||
{
|
||||
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 = isset($this->user->lang['MCHAT_RULES']) ? $this->user->lang('MCHAT_RULES') : $this->config['mchat_rules'];
|
||||
$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('utf8_htmlspecialchars', $mchat_rules);
|
||||
$mchat_rules = array_map('htmlspecialchars_decode', $mchat_rules);
|
||||
$mchat_rules = implode('<br />', $mchat_rules);
|
||||
|
||||
$this->template->assign_var('MCHAT_RULES', $mchat_rules);
|
||||
|
||||
return $this->helper->render('mchat_rules.html', $this->user->lang('MCHAT_HELP'));
|
||||
return $this->helper->render('mchat_rules.html', $this->user->lang('MCHAT_RULES'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,6 +257,7 @@ 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);
|
||||
@@ -347,23 +337,6 @@ class mchat
|
||||
return array('del' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* User purges all messagas
|
||||
*
|
||||
* @return array data sent to client as JSON
|
||||
*/
|
||||
public function action_clean()
|
||||
{
|
||||
if ($this->user->data['user_type'] != USER_FOUNDER || !check_form_key('mchat', -1))
|
||||
{
|
||||
throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS');
|
||||
}
|
||||
|
||||
$this->functions_mchat->mchat_action('clean');
|
||||
|
||||
return array('clean' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* User checks for new messages
|
||||
*
|
||||
@@ -371,11 +344,6 @@ class mchat
|
||||
*/
|
||||
public function action_refresh()
|
||||
{
|
||||
if (!defined('PHPBB_USE_BOARD_URL_PATH'))
|
||||
{
|
||||
define('PHPBB_USE_BOARD_URL_PATH', true);
|
||||
}
|
||||
|
||||
$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));
|
||||
@@ -469,7 +437,7 @@ class mchat
|
||||
/**
|
||||
* Appends a condition to the WHERE key of the SQL array to not fetch disallowed BBCodes from the database
|
||||
*
|
||||
* @param $sql_ary array
|
||||
* @param array $sql_ary
|
||||
* @return array
|
||||
*/
|
||||
public function remove_disallowed_bbcodes($sql_ary)
|
||||
@@ -486,7 +454,7 @@ class mchat
|
||||
/**
|
||||
* Renders data for a page
|
||||
*
|
||||
* @param $page The page we are rendering for, one of index|custom|archive
|
||||
* @param string $page The page we are rendering for, one of index|custom|archive
|
||||
*/
|
||||
protected function render_page($page)
|
||||
{
|
||||
@@ -494,16 +462,14 @@ class mchat
|
||||
$this->user->add_lang('posting');
|
||||
|
||||
// If the static message is defined in the language file use it, else the entry in the database is used
|
||||
if (isset($this->user->lang['STATIC_MESSAGE']))
|
||||
{
|
||||
$this->config['mchat_static_message'] = $this->user->lang('STATIC_MESSAGE');
|
||||
}
|
||||
$lang_static_message = $this->user->lang('MCHAT_STATIC_MESSAGE');
|
||||
$static_message = !empty($lang_static_message) ? $lang_static_message : $this->config['mchat_static_message'];
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'MCHAT_FILE_NAME' => $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' => !empty($this->user->lang['MCHAT_RULES']) || !empty($this->config['mchat_rules']),
|
||||
'MCHAT_RULES' => $this->user->lang('MCHAT_RULES_MESSAGE') || !empty($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'),
|
||||
@@ -512,8 +478,7 @@ class mchat
|
||||
'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_FOUNDER' => $this->user->data['user_type'] == USER_FOUNDER,
|
||||
'MCHAT_STATIC_MESS' => !empty($this->config['mchat_static_message']) ? htmlspecialchars_decode($this->config['mchat_static_message']) : '',
|
||||
'MCHAT_STATIC_MESS' => htmlspecialchars_decode($static_message),
|
||||
'L_MCHAT_COPYRIGHT' => base64_decode('PGEgaHJlZj0iaHR0cDovL3JtY2dpcnI4My5vcmciPlJNY0dpcnI4MzwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZG16eC13ZWIubmV0IiB0aXRsZT0id3d3LmRtengtd2ViLm5ldCI+ZG16eDwvYT4='),
|
||||
'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']),
|
||||
@@ -602,7 +567,7 @@ class mchat
|
||||
/**
|
||||
* Assigns all message rows to the template
|
||||
*
|
||||
* @param $rows array
|
||||
* @param array $rows
|
||||
*/
|
||||
protected function assign_messages($rows)
|
||||
{
|
||||
@@ -631,8 +596,8 @@ class mchat
|
||||
$user_avatars[$row['user_id']] = !$display_avatar ? '' : phpbb_get_user_avatar(array(
|
||||
'avatar' => $row['user_avatar'],
|
||||
'avatar_type' => $row['user_avatar_type'],
|
||||
'avatar_width' => $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : (40 / $row['user_avatar_height']) * $row['user_avatar_width'],
|
||||
'avatar_height' => $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : (40 / $row['user_avatar_width']) * $row['user_avatar_height'],
|
||||
'avatar_width' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 40 : 0,
|
||||
'avatar_height' => $row['user_avatar_width'] >= $row['user_avatar_height'] ? 0 : 40,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -658,14 +623,6 @@ class mchat
|
||||
$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'));
|
||||
|
||||
// Remove root path if we render messages for the index page
|
||||
if (strpos($this->user->data['session_page'], 'app.' . $this->php_ext) === false)
|
||||
{
|
||||
$username_full = str_replace('.' . $this->root_path, '', $username_full);
|
||||
}
|
||||
|
||||
$this->template->assign_block_vars('mchatrow', array(
|
||||
'S_ROW_COUNT' => $i,
|
||||
'MCHAT_ALLOW_BAN' => $this->auth->acl_get('a_authusers'),
|
||||
@@ -677,10 +634,10 @@ class mchat
|
||||
'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_MESSAGE_EDIT' => $message_edit,
|
||||
'MCHAT_MESSAGE_ID' => $row['message_id'],
|
||||
'MCHAT_USERNAME_FULL' => $username_full,
|
||||
'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')),
|
||||
'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')),
|
||||
'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')),
|
||||
'MCHAT_USER_IP' => $row['user_ip'],
|
||||
'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'])),
|
||||
@@ -754,9 +711,9 @@ class mchat
|
||||
/**
|
||||
* Checks whether an author has edit or delete permissions for a message
|
||||
*
|
||||
* @param $permission string One of u_mchat_edit|u_mchat_delete
|
||||
* @param $author_id int The user id of the message
|
||||
* @param $message_time int The message created time
|
||||
* @param string $permission One of u_mchat_edit|u_mchat_delete
|
||||
* @param int $author_id The user id of the message
|
||||
* @param int $message_time The message created time
|
||||
* @return bool
|
||||
*/
|
||||
protected function auth_message($permission, $author_id, $message_time)
|
||||
@@ -779,8 +736,8 @@ class mchat
|
||||
* Performs bound checks on the message and returns an array containing the message,
|
||||
* BBCode options and additional data ready to be sent to the database
|
||||
*
|
||||
* @param $message string
|
||||
* @param $merge_ary array
|
||||
* @param string $message
|
||||
* @param array $merge_ary
|
||||
* @return array
|
||||
*/
|
||||
protected function process_message($message, $merge_ary)
|
||||
@@ -793,10 +750,13 @@ class mchat
|
||||
}
|
||||
|
||||
// Must not exceed character limit, excluding whitespaces
|
||||
$message_chars = preg_replace('#\s#m', '', $message);
|
||||
if (utf8_strlen($message_chars) > $this->config['mchat_max_message_lngth'])
|
||||
if ($this->config['mchat_max_message_lngth'])
|
||||
{
|
||||
throw new \phpbb\exception\http_exception(413, 'MCHAT_MESS_LONG', array($this->config['mchat_max_message_lngth']));
|
||||
$message_chars = preg_replace('#\s#m', '', $message);
|
||||
if (utf8_strlen($message_chars) > $this->config['mchat_max_message_lngth'])
|
||||
{
|
||||
throw new \phpbb\exception\http_exception(413, 'MCHAT_MESS_LONG', array($this->config['mchat_max_message_lngth']));
|
||||
}
|
||||
}
|
||||
|
||||
// We override the $this->config['min_post_chars'] entry?
|
||||
@@ -860,7 +820,7 @@ class mchat
|
||||
/**
|
||||
* Renders a template file and returns it
|
||||
*
|
||||
* @param $template_file string
|
||||
* @param string $template_file
|
||||
* @return string
|
||||
*/
|
||||
protected function render_template($template_file)
|
||||
|
||||
Reference in New Issue
Block a user