Version 0.3.4

This commit is contained in:
dmzx
2016-02-07 14:57:51 +01:00
parent 3b003c669f
commit f4d19a5697
17 changed files with 234 additions and 168 deletions

View File

@@ -49,31 +49,25 @@
<label><input type="radio" class="radio" name="mchat_message_top" value="0"<!-- IF not MCHAT_MESSAGE_TOP --> id="mchat_message_top" checked="checked"<!-- ENDIF --> /> {L_MCHAT_BOTTOM}</label></dd> <label><input type="radio" class="radio" name="mchat_message_top" value="0"<!-- IF not MCHAT_MESSAGE_TOP --> id="mchat_message_top" checked="checked"<!-- ENDIF --> /> {L_MCHAT_BOTTOM}</label></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_new_posts">{L_MCHAT_NEW_POSTS}{L_COLON}</label><br /> <dt><label for="mchat_new_posts_topic">{L_MCHAT_NEW_POSTS_TOPIC}{L_COLON}</label><br />
<span>{L_MCHAT_NEW_POSTS_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_new_posts" value="1"<!-- IF MCHAT_NEW_POSTS --> id="mchat_new_posts" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="mchat_new_posts" value="0"<!-- IF not MCHAT_NEW_POSTS --> id="mchat_new_posts" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl>
<dl>
<dt><label for="mchat_new_posts">{L_MCHAT_NEW_POSTS_TOPIC}{L_COLON}</label><br />
<span>{L_MCHAT_NEW_POSTS_TOPIC_EXPLAIN}</span></dt> <span>{L_MCHAT_NEW_POSTS_TOPIC_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_new_posts_topic" value="1"<!-- IF MCHAT_NEW_POSTS_TOPIC --> id="mchat_new_posts_topic" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <dd><label><input type="radio" class="radio" name="mchat_new_posts_topic" value="1"<!-- IF MCHAT_NEW_POSTS_TOPIC --> id="mchat_new_posts_topic" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="mchat_new_posts_topic" value="0"<!-- IF not MCHAT_NEW_POSTS_TOPIC --> id="mchat_new_posts_topic" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> <label><input type="radio" class="radio" name="mchat_new_posts_topic" value="0"<!-- IF not MCHAT_NEW_POSTS_TOPIC --> id="mchat_new_posts_topic" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_new_posts">{L_MCHAT_NEW_POSTS_REPLY}{L_COLON}</label><br /> <dt><label for="mchat_new_posts_reply">{L_MCHAT_NEW_POSTS_REPLY}{L_COLON}</label><br />
<span>{L_MCHAT_NEW_POSTS_REPLY_EXPLAIN}</span></dt> <span>{L_MCHAT_NEW_POSTS_REPLY_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_new_posts_reply" value="1"<!-- IF MCHAT_NEW_POSTS_REPLY --> id="mchat_new_posts_reply" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <dd><label><input type="radio" class="radio" name="mchat_new_posts_reply" value="1"<!-- IF MCHAT_NEW_POSTS_REPLY --> id="mchat_new_posts_reply" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="mchat_new_posts_reply" value="0"<!-- IF not MCHAT_NEW_POSTS_REPLY --> id="mchat_new_posts_reply" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> <label><input type="radio" class="radio" name="mchat_new_posts_reply" value="0"<!-- IF not MCHAT_NEW_POSTS_REPLY --> id="mchat_new_posts_reply" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_new_posts">{L_MCHAT_NEW_POSTS_EDIT}{L_COLON}</label><br /> <dt><label for="mchat_new_posts_edit">{L_MCHAT_NEW_POSTS_EDIT}{L_COLON}</label><br />
<span>{L_MCHAT_NEW_POSTS_EDIT_EXPLAIN}</span></dt> <span>{L_MCHAT_NEW_POSTS_EDIT_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_new_posts_edit" value="1"<!-- IF MCHAT_NEW_POSTS_EDIT --> id="mchat_new_posts_edit" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <dd><label><input type="radio" class="radio" name="mchat_new_posts_edit" value="1"<!-- IF MCHAT_NEW_POSTS_EDIT --> id="mchat_new_posts_edit" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="mchat_new_posts_edit" value="0"<!-- IF not MCHAT_NEW_POSTS_EDIT --> id="mchat_new_posts_edit" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> <label><input type="radio" class="radio" name="mchat_new_posts_edit" value="0"<!-- IF not MCHAT_NEW_POSTS_EDIT --> id="mchat_new_posts_edit" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_new_posts">{L_MCHAT_NEW_POSTS_QUOTE}{L_COLON}</label><br /> <dt><label for="mchat_new_posts_quote">{L_MCHAT_NEW_POSTS_QUOTE}{L_COLON}</label><br />
<span>{L_MCHAT_NEW_POSTS_QUOTE_EXPLAIN}</span></dt> <span>{L_MCHAT_NEW_POSTS_QUOTE_EXPLAIN}</span></dt>
<dd><label><input type="radio" class="radio" name="mchat_new_posts_quote" value="1"<!-- IF MCHAT_NEW_POSTS_QUOTE --> id="mchat_new_posts_quote" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <dd><label><input type="radio" class="radio" name="mchat_new_posts_quote" value="1"<!-- IF MCHAT_NEW_POSTS_QUOTE --> id="mchat_new_posts_quote" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="mchat_new_posts_quote" value="0"<!-- IF not MCHAT_NEW_POSTS_QUOTE --> id="mchat_new_posts_quote" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> <label><input type="radio" class="radio" name="mchat_new_posts_quote" value="0"<!-- IF not MCHAT_NEW_POSTS_QUOTE --> id="mchat_new_posts_quote" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
@@ -105,9 +99,9 @@
<dd><input type="text" name="mchat_index_height" id="mchat_index_height" size="10" maxlength="4" value="{MCHAT_INDEX_HEIGHT}" /></dd> <dd><input type="text" name="mchat_index_height" id="mchat_index_height" size="10" maxlength="4" value="{MCHAT_INDEX_HEIGHT}" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_index_height">{L_MCHAT_MESSAGE_NUM}{L_COLON}</label><br /> <dt><label for="mchat_message_num">{L_MCHAT_MESSAGE_NUM}{L_COLON}</label><br />
<span>{L_MCHAT_MESSAGE_NUM_EXPLAIN}</span></dt> <span>{L_MCHAT_MESSAGE_NUM_EXPLAIN}</span></dt>
<dd><input type="text" name="mchat_message_num" size="10" maxlength="4" value="{MCHAT_MESSAGE_NUM}" /></dd> <dd><input type="text" name="mchat_message_num" id="mchat_message_num" size="10" maxlength="4" value="{MCHAT_MESSAGE_NUM}" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_location">{L_MCHAT_LOCATION}{L_COLON}</label><br /> <dt><label for="mchat_location">{L_MCHAT_LOCATION}{L_COLON}</label><br />
@@ -196,7 +190,7 @@
<dd><input type="text" name="mchat_max_message_lngth" id="mchat_max_message_lngth" size="10" value="{MCHAT_MAX_MESSAGE_LNGTH}" /></dd> <dd><input type="text" name="mchat_max_message_lngth" id="mchat_max_message_lngth" size="10" value="{MCHAT_MAX_MESSAGE_LNGTH}" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="mchat_date">{L_MCHAT_DATE_FORMAT}{L_COLON}</label><br /><span>{L_MCHAT_DATE_FORMAT_EXPLAIN}</span></dt> <dt><label for="mchat_dateoptions">{L_MCHAT_DATE_FORMAT}{L_COLON}</label><br /><span>{L_MCHAT_DATE_FORMAT_EXPLAIN}</span></dt>
<dd> <dd>
<select name="mchat_dateoptions" id="mchat_dateoptions" onchange="if(this.value=='custom'){phpbb.toggleDisplay('custom_date',1);}else{phpbb.toggleDisplay('custom_date',-1);} if (this.value == 'custom') { document.getElementById('mchat_date').value = default_dateformat; } else { document.getElementById('mchat_date').value = this.value; }"> <select name="mchat_dateoptions" id="mchat_dateoptions" onchange="if(this.value=='custom'){phpbb.toggleDisplay('custom_date',1);}else{phpbb.toggleDisplay('custom_date',-1);} if (this.value == 'custom') { document.getElementById('mchat_date').value = default_dateformat; } else { document.getElementById('mchat_date').value = this.value; }">
{S_MCHAT_DATEFORMAT_OPTIONS} {S_MCHAT_DATEFORMAT_OPTIONS}
@@ -232,7 +226,7 @@
<dl> <dl>
<dt><label for="mchat_whois">{L_MCHAT_WHOIS_REFRESH}{L_COLON}</label><br /> <dt><label for="mchat_whois">{L_MCHAT_WHOIS_REFRESH}{L_COLON}</label><br />
<span>{L_MCHAT_WHOIS_REFRESH_EXPLAIN}</span></dt> <span>{L_MCHAT_WHOIS_REFRESH_EXPLAIN}</span></dt>
<dd><input type="text" name="mchat_whois_refresh" size="10" value="{MCHAT_WHOIS_REFRESH}" /></dd> <dd><input type="text" name="mchat_whois_refresh" id="mchat_whois" size="10" value="{MCHAT_WHOIS_REFRESH}" /></dd>
</dl> </dl>
</fieldset> </fieldset>
@@ -242,4 +236,4 @@
{S_FORM_TOKEN} {S_FORM_TOKEN}
</p> </p>
</form> </form>
<!-- INCLUDE overall_footer.html --> <!-- INCLUDE overall_footer.html -->

View File

@@ -3,7 +3,7 @@
"type": "phpbb-extension", "type": "phpbb-extension",
"description": "mChat Extension for phpbb 3.1.x", "description": "mChat Extension for phpbb 3.1.x",
"homepage": "http://www.dmzx-web.net", "homepage": "http://www.dmzx-web.net",
"version": "0.3.2", "version": "0.3.4",
"time": "2015-03-10", "time": "2015-03-10",
"keywords": ["phpbb", "extension", "mchat"], "keywords": ["phpbb", "extension", "mchat"],
"license": "GPL-2.0", "license": "GPL-2.0",
@@ -14,6 +14,11 @@
"email": "info@dmzx-web.net", "email": "info@dmzx-web.net",
"role": "Extension Developer" "role": "Extension Developer"
}, },
{
"name": "kasimi",
"homepage": "https://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=1330603",
"role": "Extension Co-Developer"
},
{ {
"name": "Rich McGirr", "name": "Rich McGirr",
"homepage": "http://rmcgirr83.org", "homepage": "http://rmcgirr83.org",

View File

@@ -93,7 +93,6 @@ class admin_controller
'mchat_message_limit' => array('default' => 10, 'validation' => array('num', false, 10, 30)), '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_num' => array('default' => 10, 'validation' => array('num', false, 10, 50)),
'mchat_message_top' => array('default' => 1, 'validation' => array()), 'mchat_message_top' => array('default' => 1, 'validation' => array()),
'mchat_new_posts' => array('default' => 0, 'validation' => array()),
'mchat_new_posts_edit' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_edit' => array('default' => 0, 'validation' => array()),
'mchat_new_posts_quote' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_quote' => array('default' => 0, 'validation' => array()),
'mchat_new_posts_reply' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_reply' => array('default' => 0, 'validation' => array()),
@@ -139,7 +138,16 @@ class admin_controller
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang('\\1'))) ? \$this->user->lang('\\1') : '\\1'", $error); // 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)) if (empty($error))
{ {

View File

@@ -46,6 +46,7 @@ class main_controller
* Controller for mChat actions called with Ajax requests * Controller for mChat actions called with Ajax requests
* *
* @param $action The action to perform, one of add|edit|del|clean|refresh|whois * @param $action The action to perform, one of add|edit|del|clean|refresh|whois
* @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JsonResponse object
*/ */
public function action($action) public function action($action)
{ {

View File

@@ -341,11 +341,6 @@ class functions_mchat
*/ */
public function mchat_insert_posting($mode, $data) public function mchat_insert_posting($mode, $data)
{ {
if (!$this->config['mchat_new_posts'])
{
return;
}
$mode_config = array( $mode_config = array(
'post' => $this->config['mchat_new_posts_topic'], 'post' => $this->config['mchat_new_posts_topic'],
'quote' => $this->config['mchat_new_posts_quote'], 'quote' => $this->config['mchat_new_posts_quote'],
@@ -543,6 +538,19 @@ class functions_mchat
return; return;
} }
$this->db->sql_query($sql); $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;
}
}
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* *
* @package phpBB Extension - mChat * @package phpBB Extension - mChat
@@ -48,20 +49,20 @@ class mchat
protected $is_mchat_rendered = false; protected $is_mchat_rendered = false;
/** /**
* Constructor * Constructor
* *
* @param \dmzx\mchat\core\functions_mchat $functions_mchat * @param \dmzx\mchat\core\functions_mchat $functions_mchat
* @param \phpbb\config\config $config * @param \phpbb\config\config $config
* @param \phpbb\controller\helper $helper * @param \phpbb\controller\helper $helper
* @param \phpbb\template\template $template * @param \phpbb\template\template $template
* @param \phpbb\user $user * @param \phpbb\user $user
* @param \phpbb\auth\auth $auth * @param \phpbb\auth\auth $auth
* @param \phpbb\pagination $pagination * @param \phpbb\pagination $pagination
* @param \phpbb\request\request $request * @param \phpbb\request\request $request
* @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\event\dispatcher_interface $dispatcher
* @param string $root_path * @param string $root_path
* @param string $php_ext * @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_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->functions_mchat = $functions_mchat;
@@ -78,8 +79,8 @@ class mchat
} }
/** /**
* Render mChat on the index page * Render mChat on the index page
*/ */
public function page_index() public function page_index()
{ {
if (!$this->auth->acl_get('u_mchat_view')) if (!$this->auth->acl_get('u_mchat_view'))
@@ -94,6 +95,7 @@ class mchat
return; return;
} }
// TODO This might be redundant
// If mChat is used on the index by a user without an avatar, a default avatar is used. // 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... // 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. // Setting this value to true solves this.
@@ -111,8 +113,10 @@ class mchat
} }
/** /**
* Render the mChat custom page * Render the mChat custom page
*/ *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function page_custom() 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') || !$this->config['mchat_custom_page'])
@@ -142,8 +146,10 @@ class mchat
} }
/** /**
* Render the mChat archive * Render the mChat archive
*/ *
* @return \Symfony\Component\HttpFoundation\Response
*/
public function page_archive() public function page_archive()
{ {
if (!$this->auth->acl_get('u_mchat_view') || !$this->auth->acl_get('u_mchat_archive')) if (!$this->auth->acl_get('u_mchat_view') || !$this->auth->acl_get('u_mchat_archive'))
@@ -173,10 +179,10 @@ class mchat
} }
/** /**
* Controller for mChat IP WHOIS * Controller for mChat IP WHOIS
* *
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
*/ */
public function page_whois() public function page_whois()
{ {
if (!$this->auth->acl_get('u_mchat_ip')) if (!$this->auth->acl_get('u_mchat_ip'))
@@ -195,10 +201,10 @@ class mchat
} }
/** /**
* Controller for mChat Rules page * Controller for mChat Rules page
* *
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function page_rules() public function page_rules()
{ {
if (empty($this->config['mchat_rules']) && empty($this->user->lang['MCHAT_RULES'])) if (empty($this->config['mchat_rules']) && empty($this->user->lang['MCHAT_RULES']))
@@ -218,8 +224,10 @@ class mchat
} }
/** /**
* * User submits a message
*/ *
* @return array data sent to client as JSON
*/
public function action_add() public function action_add()
{ {
if (!$this->auth->acl_get('u_mchat_use') || !check_form_key('mchat', -1)) if (!$this->auth->acl_get('u_mchat_use') || !check_form_key('mchat', -1))
@@ -243,19 +251,21 @@ class mchat
$this->functions_mchat->mchat_action('add', $sql_ary); $this->functions_mchat->mchat_action('add', $sql_ary);
/** /**
* Event render_helper_add * Event render_helper_add
* *
* @event dmzx.mchat.core.render_helper_add * @event dmzx.mchat.core.render_helper_add
* @since 0.1.2 * @since 0.1.2
*/ */
$this->dispatcher->dispatch('dmzx.mchat.core.render_helper_add'); $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_add');
return array('add' => true); return $this->action_refresh();
} }
/** /**
* * User edits a message
*/ *
* @return array data sent to client as JSON
*/
public function action_edit() public function action_edit()
{ {
if (!defined('PHPBB_USE_BOARD_URL_PATH')) if (!defined('PHPBB_USE_BOARD_URL_PATH'))
@@ -287,11 +297,11 @@ class mchat
$this->functions_mchat->mchat_action('edit', $sql_ary, $message_id, $author['username']); $this->functions_mchat->mchat_action('edit', $sql_ary, $message_id, $author['username']);
/** /**
* Event render_helper_edit * Event render_helper_edit
* *
* @event dmzx.mchat.core.render_helper_edit * @event dmzx.mchat.core.render_helper_edit
* @since 0.1.4 * @since 0.1.4
*/ */
$this->dispatcher->dispatch('dmzx.mchat.core.render_helper_edit'); $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_edit');
$sql_where = 'm.message_id = ' . (int) $message_id; $sql_where = 'm.message_id = ' . (int) $message_id;
@@ -304,8 +314,10 @@ class mchat
} }
/** /**
* * User deletes a message
*/ *
* @return array data sent to client as JSON
*/
public function action_del() public function action_del()
{ {
$message_id = $this->request->variable('message_id', 0); $message_id = $this->request->variable('message_id', 0);
@@ -323,11 +335,11 @@ class mchat
} }
/** /**
* Event render_helper_delete * Event render_helper_delete
* *
* @event dmzx.mchat.core.render_helper_delete * @event dmzx.mchat.core.render_helper_delete
* @since 0.1.4 * @since 0.1.4
*/ */
$this->dispatcher->dispatch('dmzx.mchat.core.render_helper_delete'); $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_delete');
$this->functions_mchat->mchat_action('del', null, $message_id, $author['username']); $this->functions_mchat->mchat_action('del', null, $message_id, $author['username']);
@@ -336,8 +348,10 @@ class mchat
} }
/** /**
* * User purges all messagas
*/ *
* @return array data sent to client as JSON
*/
public function action_clean() public function action_clean()
{ {
if ($this->user->data['user_type'] != USER_FOUNDER || !check_form_key('mchat', -1)) if ($this->user->data['user_type'] != USER_FOUNDER || !check_form_key('mchat', -1))
@@ -351,8 +365,10 @@ class mchat
} }
/** /**
* * User checks for new messages
*/ *
* @return array sent to client as JSON
*/
public function action_refresh() public function action_refresh()
{ {
if (!defined('PHPBB_USE_BOARD_URL_PATH')) if (!defined('PHPBB_USE_BOARD_URL_PATH'))
@@ -400,7 +416,7 @@ class mchat
// Assign new messages // Assign new messages
$this->assign_global_template_data(); $this->assign_global_template_data();
$this->assign_messages($rows_refresh); $this->assign_messages($rows_refresh);
$response = array('refresh' => $this->render_template('mchat_messages.html')); $response = array('refresh' => true, 'add' => $this->render_template('mchat_messages.html'));
// Assign edited messages // Assign edited messages
if (!empty($rows_edit)) if (!empty($rows_edit))
@@ -427,8 +443,10 @@ class mchat
} }
/** /**
* * User requests who is chatting
*/ *
* @return array data sent to client as JSON
*/
public function action_whois() public function action_whois()
{ {
$this->assign_whois(); $this->assign_whois();
@@ -437,8 +455,8 @@ class mchat
} }
/** /**
* * Adds the template variables for the header link
*/ */
public function render_page_header_link() public function render_page_header_link()
{ {
$this->template->assign_vars(array( $this->template->assign_vars(array(
@@ -449,8 +467,11 @@ 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
* @return array
*/
public function remove_disallowed_bbcodes($sql_ary) public function remove_disallowed_bbcodes($sql_ary)
{ {
// Add disallowed BBCodes to the template only if we're rendering for mChat // Add disallowed BBCodes to the template only if we're rendering for mChat
@@ -463,12 +484,10 @@ class mchat
} }
/** /**
* Method to render the page data * Renders data for a page
* *
* @var page The page we are rendering for, one of index|custom|archive * @param $page The page we are rendering for, one of index|custom|archive
* @return null|array|string If we are rendering for the index, null is returned. For modes that are only */
* called via AJAX, an array is returned, otherwise the rendered content is returned.
*/
protected function render_page($page) protected function render_page($page)
{ {
// Add lang file // Add lang file
@@ -552,8 +571,8 @@ class mchat
} }
/** /**
* Assigns all message rows to the template * Assigns all message rows to the template
*/ */
protected function assign_global_template_data() protected function assign_global_template_data()
{ {
$this->template->assign_vars(array( $this->template->assign_vars(array(
@@ -564,15 +583,27 @@ class mchat
'MCHAT_EDIT_DELETE_LIMIT' => 1000 * $this->config['mchat_edit_delete_limit'], '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_EDIT_DELETE_IGNORE' => $this->config['mchat_edit_delete_limit'] && $this->auth->acl_get('m_'),
'MCHAT_USER_TIMEOUT' => 1000 * $this->config['mchat_timeout'], 'MCHAT_USER_TIMEOUT' => 1000 * $this->config['mchat_timeout'],
'S_MCHAT_AVATARS' => !empty($this->config['mchat_avatars']) && $this->user->optionget('viewavatars') && $this->user->data['user_mchat_avatars'], 'S_MCHAT_AVATARS' => $this->display_avatars(),
'EXT_URL' => generate_board_url() . '/ext/dmzx/mchat/', 'EXT_URL' => generate_board_url() . '/ext/dmzx/mchat/',
'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'], 'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'],
)); ));
} }
/** /**
* Assigns all message rows to the template * Returns true if we need do display avatars in the messages, otherwise false
*/ *
* @return bool
*/
protected function display_avatars()
{
return $this->config['mchat_avatars'] && $this->user->optionget('viewavatars') && $this->user->data['user_mchat_avatars'];
}
/**
* Assigns all message rows to the template
*
* @param $rows array
*/
protected function assign_messages($rows) protected function assign_messages($rows)
{ {
if (empty($rows)) if (empty($rows))
@@ -590,6 +621,22 @@ class mchat
$this->template->destroy_block_vars('mchatrow'); $this->template->destroy_block_vars('mchatrow');
$user_avatars = array();
foreach ($rows as $i => $row)
{
if (!isset($user_avatars[$row['user_id']]))
{
$display_avatar = $this->display_avatars() && $row['user_avatar'];
$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'],
));
}
}
foreach ($rows as $i => $row) foreach ($rows as $i => $row)
{ {
// Auth checks // Auth checks
@@ -611,13 +658,6 @@ class mchat
$row['username'] = mb_ereg_replace("'", "&#146;", $row['username']); $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
$message = str_replace("'", '&rsquo;', $row['message']); $message = str_replace("'", '&rsquo;', $row['message']);
$user_avatar = !$row['user_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'],
));
$username_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')); $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 // Remove root path if we render messages for the index page
@@ -631,7 +671,7 @@ class mchat
'MCHAT_ALLOW_BAN' => $this->auth->acl_get('a_authusers'), '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_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_ALLOW_DEL' => $this->auth_message('u_mchat_delete', $row['user_id'], $row['message_time']),
'MCHAT_USER_AVATAR' => $user_avatar, '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&amp;u=' . $row['user_id']) : '', 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? generate_board_url() . append_sid("/{$this->root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '',
'MCHAT_IS_POSTER' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] == $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&amp;mode=compose&amp;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_')) ? generate_board_url() . append_sid("/{$this->root_path}ucp.{$this->php_ext}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
@@ -652,8 +692,8 @@ class mchat
} }
/** /**
* Assigns BBCodes and smilies to the template * Assigns BBCodes and smilies to the template
*/ */
protected function assign_bbcodes_smilies() protected function assign_bbcodes_smilies()
{ {
// Display custom bbcodes // Display custom bbcodes
@@ -695,8 +735,8 @@ class mchat
} }
/** /**
* Assigns whois and stats at the bottom of the index page * Assigns whois and stats at the bottom of the index page
*/ */
protected function assign_whois() protected function assign_whois()
{ {
if ($this->config['mchat_whois'] || $this->config['mchat_stats_index'] && $this->user->data['user_mchat_stats_index']) if ($this->config['mchat_whois'] || $this->config['mchat_stats_index'] && $this->user->data['user_mchat_stats_index'])
@@ -712,8 +752,13 @@ class mchat
} }
/** /**
* Checks whether an author has edit or delete permissions for a message * 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
* @return bool
*/
protected function auth_message($permission, $author_id, $message_time) protected function auth_message($permission, $author_id, $message_time)
{ {
if (!$this->auth->acl_get($permission)) if (!$this->auth->acl_get($permission))
@@ -731,9 +776,13 @@ class mchat
} }
/** /**
* Performs bound checks on the message and returns an array containing the message, * 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 * BBCode options and additional data ready to be sent to the database
*/ *
* @param $message string
* @param $merge_ary array
* @return array
*/
protected function process_message($message, $merge_ary) protected function process_message($message, $merge_ary)
{ {
// Must have something other than bbcode in the message // Must have something other than bbcode in the message
@@ -809,9 +858,11 @@ class mchat
} }
/** /**
* Renders a template file and returns it * Renders a template file and returns it
* @return string *
*/ * @param $template_file string
* @return string
*/
protected function render_template($template_file) protected function render_template($template_file)
{ {
$this->template->set_filenames(array('body' => $template_file)); $this->template->set_filenames(array('body' => $template_file));

View File

@@ -103,8 +103,6 @@ $lang = array_merge($lang, array(
'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Falls JA eingestellt ist, wird das eingestellte Limit im Forum für Smilies im mChat aufgehoben.', 'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Falls JA eingestellt ist, wird das eingestellte Limit im Forum für Smilies im mChat aufgehoben.',
'MCHAT_OVERRIDE_MIN_POST_CHARS' => 'Minimale Anzahl von Zeichen aufheben?', 'MCHAT_OVERRIDE_MIN_POST_CHARS' => 'Minimale Anzahl von Zeichen aufheben?',
'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Falls ja eingestellt ist, wird das Limit für die minimale Anzahl an Zeichen für mChat-Nachrichten aufgehoben.', 'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Falls ja eingestellt ist, wird das Limit für die minimale Anzahl an Zeichen für mChat-Nachrichten aufgehoben.',
'MCHAT_NEW_POSTS' => 'Zeige aktivierte Beiträge an',
'MCHAT_NEW_POSTS_EXPLAIN' => 'Stelle auf Ja, und setze unter den Optionen, welche Nachricht im Chat-Nachrichtenbereich angezeigt werden können..',
'MCHAT_NEW_POSTS_TOPIC' => 'Zeige New Topic Beiträge an', 'MCHAT_NEW_POSTS_TOPIC' => 'Zeige New Topic Beiträge an',
'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Stelle auf Ja, damit neue Themen und Beiträge aus dem Forum im Chat Nachrichtenbereich angezeigt werden.', 'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Stelle auf Ja, damit neue Themen und Beiträge aus dem Forum im Chat Nachrichtenbereich angezeigt werden.',
'MCHAT_NEW_POSTS_REPLY' => 'Zeige neue Antworten in Beiträgen an', 'MCHAT_NEW_POSTS_REPLY' => 'Zeige neue Antworten in Beiträgen an',

View File

@@ -103,8 +103,6 @@ $lang = array_merge($lang, array(
'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Set to yes to override the forums smilie limit setting for chat messages', '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' => 'Override minimum characters limit',
'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Set to yes to override the forums minimum characters setting for chat messages', 'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Set to yes to override the forums minimum characters setting for chat messages',
'MCHAT_NEW_POSTS' => 'Enable Posts Display',
'MCHAT_NEW_POSTS_EXPLAIN' => 'Set to yes and you can set below the options what message to display in the chat message area.',
'MCHAT_NEW_POSTS_TOPIC' => 'Display New Topic Posts', 'MCHAT_NEW_POSTS_TOPIC' => 'Display New Topic Posts',
'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Set to yes to allow new topic posts from the forum to be posted into the chat message area.', 'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Set to yes to allow new topic posts from the forum to be posted into the chat message area.',
'MCHAT_NEW_POSTS_REPLY' => 'Display New Replied Posts', 'MCHAT_NEW_POSTS_REPLY' => 'Display New Replied Posts',

View File

@@ -103,8 +103,6 @@ $lang = array_merge($lang, array(
'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Establezca en Sí, para anular el ajustes del límite de emoticonos en los foros, para mensajes del chat', 'MCHAT_OVERRIDE_SMILIE_LIMIT_EXPLAIN' => 'Establezca en Sí, para anular el ajustes del límite de emoticonos en los foros, para mensajes del chat',
'MCHAT_OVERRIDE_MIN_POST_CHARS' => 'Anular límite mínimo caracteres', 'MCHAT_OVERRIDE_MIN_POST_CHARS' => 'Anular límite mínimo caracteres',
'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Establezca en Sí, para anular el ajustes del límite mínimo de caracteres en los foros, para mensajes del chat', 'MCHAT_OVERRIDE_MIN_POST_CHARS_EXPLAIN' => 'Establezca en Sí, para anular el ajustes del límite mínimo de caracteres en los foros, para mensajes del chat',
'MCHAT_NEW_POSTS' => 'Habilitar mostrar mensajes',
'MCHAT_NEW_POSTS_EXPLAIN' => 'Establezca en Si, y podrá establecer debajo las opciones de cuál es el mensaje que se mostrará en el área de mensajes del chat.',
'MCHAT_NEW_POSTS_TOPIC' => 'Mostrar mensaje de Nuevo Tema', 'MCHAT_NEW_POSTS_TOPIC' => 'Mostrar mensaje de Nuevo Tema',
'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Establezca en Sí, para permitir que los nuevos temas del foro puedan ser publicados en el área de mensajes del chat.', 'MCHAT_NEW_POSTS_TOPIC_EXPLAIN' => 'Establezca en Sí, para permitir que los nuevos temas del foro puedan ser publicados en el área de mensajes del chat.',
'MCHAT_NEW_POSTS_REPLY' => 'Mostrar mensaje de Nueva Respuesta', 'MCHAT_NEW_POSTS_REPLY' => 'Mostrar mensaje de Nueva Respuesta',

View File

@@ -13,7 +13,7 @@ class install_mchat extends \phpbb\db\migration\migration
{ {
public function effectively_installed() public function effectively_installed()
{ {
return isset($this->config['mchat_version']) && version_compare($this->config['mchat_version'], '0.3.2', '>='); return isset($this->config['mchat_version']) && version_compare($this->config['mchat_version'], '0.3.4', '>=');
} }
static public function depends_on() static public function depends_on()
@@ -25,7 +25,7 @@ class install_mchat extends \phpbb\db\migration\migration
{ {
return array( return array(
// Add configs // Add configs
array('config.add', array('mchat_version', '0.3.2')), array('config.add', array('mchat_version', '0.3.4')),
array('config.add', array('mchat_archive_limit', 25)), array('config.add', array('mchat_archive_limit', 25)),
array('config.add', array('mchat_avatars', 1)), array('config.add', array('mchat_avatars', 1)),
array('config.add', array('mchat_bbcode_disallowed', '')), array('config.add', array('mchat_bbcode_disallowed', '')),
@@ -41,7 +41,6 @@ class install_mchat extends \phpbb\db\migration\migration
array('config.add', array('mchat_message_limit', 10)), array('config.add', array('mchat_message_limit', 10)),
array('config.add', array('mchat_message_num', 10)), array('config.add', array('mchat_message_num', 10)),
array('config.add', array('mchat_message_top', 1)), array('config.add', array('mchat_message_top', 1)),
array('config.add', array('mchat_new_posts', 0)),
array('config.add', array('mchat_new_posts_edit', 0)), array('config.add', array('mchat_new_posts_edit', 0)),
array('config.add', array('mchat_new_posts_quote', 0)), array('config.add', array('mchat_new_posts_quote', 0)),
array('config.add', array('mchat_new_posts_reply', 0)), array('config.add', array('mchat_new_posts_reply', 0)),

View File

@@ -1,2 +1,2 @@
<!-- INCLUDECSS @dmzx_mchat/mchat.css --> <!-- INCLUDECSS @dmzx_mchat/mchat.css -->
<!-- IF MCHAT_ALLOW_SMILES and not MCHAT_ALLOW_BBCODES --><!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --><!-- ENDIF --> <!-- IF MCHAT_ALLOW_SMILES or MCHAT_ALLOW_BBCODES --><!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --><!-- ENDIF -->

View File

@@ -30,7 +30,7 @@ jQuery(function($) {
dataType: 'json', dataType: 'json',
data: data data: data
}).success(function(json, status, xhr) { }).success(function(json, status, xhr) {
if (json.hasOwnProperty(mode)) { if (json[mode]) {
deferred.resolve(json, status, xhr); deferred.resolve(json, status, xhr);
} else { } else {
deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format'); deferred.reject(xhr, status, xhr.responseJSON ? 'session' : 'format');
@@ -72,7 +72,7 @@ jQuery(function($) {
} }
}, },
sound: function(file) { sound: function(file) {
if (!Cookies.get('mchat_no_sound')) { if (!mChat.pageIsUnloading && !Cookies.get('mchat_no_sound')) {
var audio = mChat.$$('sound-' + file).get(0); var audio = mChat.$$('sound-' + file).get(0);
audio.pause(); audio.pause();
audio.currentTime = 0; audio.currentTime = 0;
@@ -109,11 +109,8 @@ jQuery(function($) {
} }
mChat.pauseSession(); mChat.pauseSession();
mChat.$$('add').prop('disabled', true); mChat.$$('add').prop('disabled', true);
ajaxRequest('add', true, { mChat.refresh(mChat.$$('input').val()).done(function() {
message: mChat.$$('input').val()
}).done(function(json) {
mChat.$$('input').val(''); mChat.$$('input').val('');
mChat.refresh();
}).always(function() { }).always(function() {
mChat.$$('input').focus(); mChat.$$('input').focus();
mChat.$$('add').prop('disabled', false); mChat.$$('add').prop('disabled', false);
@@ -144,7 +141,7 @@ jQuery(function($) {
phpbb.confirm(mChat.$$('confirm'), function() { phpbb.confirm(mChat.$$('confirm'), function() {
ajaxRequest('del', true, { ajaxRequest('del', true, {
message_id: $container.data('id') message_id: $container.data('id')
}).done(function(json) { }).done(function() {
mChat.sound('del'); mChat.sound('del');
$container.fadeOut('slow', function() { $container.fadeOut('slow', function() {
$container.remove(); $container.remove();
@@ -153,11 +150,14 @@ jQuery(function($) {
}); });
}); });
}, },
refresh: function() { refresh: function(message) {
var $messages = mChat.$$('messages').children(); var $messages = mChat.$$('messages').children();
var data = { var data = {
message_last_id: $messages.filter(mChat.messageTop ? ':first' : ':last').data('id') message_last_id: $messages.filter(mChat.messageTop ? ':first' : ':last').data('id')
}; };
if (message) {
data.message = message;
}
if (mChat.liveUpdates) { if (mChat.liveUpdates) {
data.message_first_id = $messages.filter(mChat.messageTop ? ':last' : ':first').data('id'); data.message_first_id = $messages.filter(mChat.messageTop ? ':last' : ':first').data('id');
data.message_edits = {}; data.message_edits = {};
@@ -172,8 +172,8 @@ jQuery(function($) {
} }
mChat.$$('refresh-ok', 'refresh-error', 'refresh-paused').hide(); mChat.$$('refresh-ok', 'refresh-error', 'refresh-paused').hide();
mChat.$$('refresh-load').show(); mChat.$$('refresh-load').show();
ajaxRequest('refresh', false, data).done(function(json) { return ajaxRequest(message ? 'add' : 'refresh', !!message, data).done(function(json) {
var $html = $(json.refresh); var $html = $(json.add);
if ($html.length) { if ($html.length) {
mChat.sound('add'); mChat.sound('add');
mChat.notice(); mChat.notice();
@@ -199,7 +199,7 @@ jQuery(function($) {
} }
}); });
} }
if (json.hasOwnProperty('edit')) { if (json.edit) {
var isFirstEdit = true; var isFirstEdit = true;
$.each(json.edit, function(id, content) { $.each(json.edit, function(id, content) {
var $container = $('#mchat-message-' + id); var $container = $('#mchat-message-' + id);
@@ -214,7 +214,7 @@ jQuery(function($) {
} }
}); });
} }
if (json.hasOwnProperty('del')) { if (json.del) {
var isFirstDelete = true; var isFirstDelete = true;
$.each(json.del, function(i, id) { $.each(json.del, function(i, id) {
var $container = $('#mchat-message-' + id); var $container = $('#mchat-message-' + id);
@@ -263,6 +263,7 @@ jQuery(function($) {
mChat.$$('confirm').find('textarea').hide(); mChat.$$('confirm').find('textarea').hide();
mChat.$$('confirm').find('p').text(mChat.cleanConfirm); mChat.$$('confirm').find('p').text(mChat.cleanConfirm);
phpbb.confirm(mChat.$$('confirm'), function() { phpbb.confirm(mChat.$$('confirm'), function() {
mChat.pauseSession();
ajaxRequest('clean', true, {}).done(function() { ajaxRequest('clean', true, {}).done(function() {
phpbb.alert('mChat', mChat.cleanDone); phpbb.alert('mChat', mChat.cleanDone);
setTimeout(function() { setTimeout(function() {
@@ -376,7 +377,7 @@ jQuery(function($) {
mChat.$$('confirm').detach().show(); mChat.$$('confirm').detach().show();
mChat.hiddenFields = {}; mChat.hiddenFields = {};
$('#' + form_name).find('input[type=hidden]').each(function() { $('#mchat-form').find('input[type=hidden]').each(function() {
mChat.hiddenFields[this.name] = this.value; mChat.hiddenFields[this.name] = this.value;
}); });
@@ -444,6 +445,10 @@ jQuery(function($) {
e.preventDefault(); e.preventDefault();
}); });
if (!mChat.$$('user-sound').prop('checked')) {
Cookies.set('mchat_no_sound', 'yes');
}
mChat.$$('user-sound').change(function() { mChat.$$('user-sound').change(function() {
if (this.checked) { if (this.checked) {
Cookies.remove('mchat_no_sound'); Cookies.remove('mchat_no_sound');
@@ -452,7 +457,7 @@ jQuery(function($) {
} }
}); });
$('#' + form_name).on('keypress', function(e) { $('#mchat-form').on('keypress', function(e) {
if (e.which == 13) { if (e.which == 13) {
mChat.add(); mChat.add();
e.preventDefault(); e.preventDefault();
@@ -462,6 +467,10 @@ jQuery(function($) {
mChat.$$('input').autoGrowInput(); mChat.$$('input').autoGrowInput();
} }
$(window).on('beforeunload', function() {
mChat.pageIsUnloading = true;
});
$('#phpbb').on('click', '[data-mchat-action]', function(e) { $('#phpbb').on('click', '[data-mchat-action]', function(e) {
var action = $(this).data('mchat-action'); var action = $(this).data('mchat-action');
mChat[action].call(this); mChat[action].call(this);

File diff suppressed because one or more lines are too long

View File

@@ -31,7 +31,6 @@
} }
// ]]> // ]]>
</script> </script>
<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->
<!-- IF S_MCHAT_BBCODE_B --> <!-- IF S_MCHAT_BBCODE_B -->
<input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" /> <input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" />
<!-- ENDIF --> <!-- ENDIF -->

View File

@@ -4,7 +4,7 @@
<!-- INCLUDEJS jquery.titlealert.min.js --> <!-- INCLUDEJS jquery.titlealert.min.js -->
<!-- INCLUDEJS js.cookie-2.0.4.min.js --> <!-- INCLUDEJS js.cookie-2.0.4.min.js -->
<!-- INCLUDEJS mchat.min.js --> <!-- INCLUDEJS mchat.js -->
<!-- IF MCHAT_ARCHIVE_PAGE and (.pagination or MCHAT_TOTAL_MESSAGES) --> <!-- IF MCHAT_ARCHIVE_PAGE and (.pagination or MCHAT_TOTAL_MESSAGES) -->
<div class="action-bar top"> <div class="action-bar top">
@@ -104,7 +104,7 @@
<!-- INCLUDE mchat_whois.html --> <!-- INCLUDE mchat_whois.html -->
<!-- ENDIF --> <!-- ENDIF -->
<form id="postform" action="{MCHAT_FILE_NAME}" method="POST"> <form name="postform" id="mchat-form" action="{MCHAT_FILE_NAME}" method="POST">
{S_FORM_TOKEN} {S_FORM_TOKEN}
<!-- IF not MCHAT_ARCHIVE_PAGE --> <!-- IF not MCHAT_ARCHIVE_PAGE -->
<div class="mchat-panel"> <div class="mchat-panel">

View File

@@ -13,7 +13,7 @@
<dt><label for="mchat_index">{L_DISPLAY_MCHAT}{L_COLON}</label></dt> <dt><label for="mchat_index">{L_DISPLAY_MCHAT}{L_COLON}</label></dt>
<dd> <dd>
<label><input type="radio" name="user_mchat_index" value="1"<!-- IF S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" name="user_mchat_index" value="1"<!-- IF S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" name="user_mchat_index" value="0"<!-- IF not S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label> <label><input type="radio" name="user_mchat_index" value="0"<!-- IF not S_DISPLAY_MCHAT --> id="mchat_index" checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd> </dd>
</dl> </dl>
<!-- ENDIF --> <!-- ENDIF -->
@@ -24,7 +24,7 @@
<label><input type="radio" name="user_mchat_sound" value="0"<!-- IF not S_SOUND_MCHAT --> id="mchat_sound" checked="checked"<!-- ENDIF --> /> {L_NO}</label> <label><input type="radio" name="user_mchat_sound" value="0"<!-- IF not S_SOUND_MCHAT --> id="mchat_sound" checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd> </dd>
</dl> </dl>
<!-- IF S_MCHAT_INDEX --> <!-- IF S_MCHAT_INDEX_STATS -->
<dl> <dl>
<dt><label for="mchat_statsindex">{L_DISPLAY_STATS_INDEX}{L_COLON}</label></dt> <dt><label for="mchat_statsindex">{L_DISPLAY_STATS_INDEX}{L_COLON}</label></dt>
<dd> <dd>
@@ -68,4 +68,4 @@
</fieldset> </fieldset>
</form> </form>
<!-- INCLUDE ucp_footer.html --> <!-- INCLUDE ucp_footer.html -->

View File

@@ -65,21 +65,31 @@ class ucp_mchat_module
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); // 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 = $this->user->lang($err);
if (!empty($lang))
{
$error[$i] = $lang;
}
}
} }
$template->assign_vars(array( $template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'S_DISPLAY_MCHAT' => $data['user_mchat_index'], 'S_DISPLAY_MCHAT' => $data['user_mchat_index'],
'S_SOUND_MCHAT' => $data['user_mchat_sound'], 'S_SOUND_MCHAT' => $data['user_mchat_sound'],
'S_STATS_MCHAT' => $data['user_mchat_stats_index'], 'S_STATS_MCHAT' => $data['user_mchat_stats_index'],
'S_TOPICS_MCHAT' => $data['user_mchat_topics'], 'S_TOPICS_MCHAT' => $data['user_mchat_topics'],
'S_AVATARS_MCHAT' => $data['user_mchat_avatars'], 'S_AVATARS_MCHAT' => $data['user_mchat_avatars'],
'S_INPUT_MCHAT' => $data['user_mchat_input_area'], 'S_INPUT_MCHAT' => $data['user_mchat_input_area'],
'S_MCHAT_TOPICS' => $config['mchat_new_posts'], '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'] || $config['mchat_stats_index'], 'S_MCHAT_INDEX' => $config['mchat_on_index'],
'S_MCHAT_AVATARS' => $config['mchat_avatars'], 'S_MCHAT_INDEX_STATS' => $config['mchat_stats_index'],
'S_MCHAT_AVATARS' => $config['mchat_avatars'],
)); ));
break; break;