update version 0.0.9
update version 0.0.9
This commit is contained in:
@@ -19,23 +19,29 @@ class listener implements EventSubscriberInterface
|
||||
/** @var \phpbb\auth\auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
protected $root_path;
|
||||
protected $phpbb_root_path;
|
||||
|
||||
protected $php_ext;
|
||||
protected $phpEx;
|
||||
|
||||
/** @var string */
|
||||
protected $table_prefix;
|
||||
|
||||
/** @var \phpbb\controller\helper */
|
||||
protected $controller_helper;
|
||||
|
||||
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, $php_ext)
|
||||
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)
|
||||
{
|
||||
$this->render_helper = $render_helper;
|
||||
$this->auth = $auth;
|
||||
@@ -45,7 +51,9 @@ class listener implements EventSubscriberInterface
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->table_prefix = $table_prefix;
|
||||
|
||||
}
|
||||
|
||||
static public function getSubscribedEvents()
|
||||
@@ -54,6 +62,7 @@ class listener implements EventSubscriberInterface
|
||||
'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',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,4 +109,55 @@ class listener implements EventSubscriberInterface
|
||||
$this->render_helper->render_data_for_page(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function posting_modify_submit_post_after($event)
|
||||
{
|
||||
// only trigger if mode is post
|
||||
$mchat_forums_allowed = array();
|
||||
if ($event['mode'] == 'post' || $event['mode'] == 'reply' || $event['mode'] == 'quote'|| $event['mode'] == 'edit' && (isset($this->config['mchat_enable']) && $this->config['mchat_enable']) && (isset($this->config['mchat_new_posts']) && $this->config['mchat_new_posts']))
|
||||
{
|
||||
|
||||
if ($event['mode'] == 'post' && (isset($this->config['mchat_new_posts_topic']) && $this->config['mchat_new_posts_topic']))
|
||||
{
|
||||
$mchat_new_data = $this->user->lang['MCHAT_NEW_TOPIC'];
|
||||
}
|
||||
else if ($event['mode'] == 'quote' && (isset($this->config['mchat_new_posts_quote']) && $this->config['mchat_new_posts_quote']))
|
||||
{
|
||||
$mchat_new_data = $this->user->lang['MCHAT_NEW_QUOTE'];
|
||||
}
|
||||
else if ($event['mode'] == 'edit' && (isset($this->config['mchat_new_posts_edit']) && $this->config['mchat_new_posts_edit']))
|
||||
{
|
||||
$mchat_new_data = $this->user->lang['MCHAT_NEW_EDIT'];
|
||||
}
|
||||
else if ($event['mode'] == 'reply'&& (isset($this->config['mchat_new_posts_reply']) && $this->config['mchat_new_posts_reply']))
|
||||
{
|
||||
$mchat_new_data = $this->user->lang['MCHAT_NEW_REPLY'];
|
||||
}
|
||||
else
|
||||
{
|
||||
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] in [url=' . generate_board_url() . '/viewforum.' . $this->phpEx . '?f=' . $event['forum_id'] . ']' . $event['post_data']['forum_name'] . ' Section[/url] ');
|
||||
|
||||
$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' => ($topic_type == POST_GLOBAL) ? 0 : $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->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user