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