Update Version 0.1.0

Update Version 0.1.0
This commit is contained in:
dmzx
2015-05-02 10:58:11 +02:00
parent bdd08b5d61
commit 5f77698758
13 changed files with 753 additions and 299 deletions

View File

@@ -41,6 +41,12 @@ class render_helper
protected $phpbb_root_path;
protected $phpEx;
protected $table_prefix;
/**
* The database tables
*
* @var string
*/
protected $mchat_table;
/**
* Constructor
@@ -58,7 +64,7 @@ class render_helper
* @param $phpEx
* @param $table_prefix
*/
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, $phpbb_root_path, $phpEx, $table_prefix)
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\pagination $pagination, \phpbb\request\request $request, $phpbb_root_path, $phpEx, $table_prefix, $mchat_table)
{
$this->functions_mchat = $functions_mchat;
$this->config = $config;
@@ -68,11 +74,13 @@ class render_helper
$this->auth = $auth;
$this->db = $db;
$this->cache = $cache;
$this->pagination = $pagination;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
$this->phpbb_log = $log;
$this->table_prefix = $table_prefix;
$this->mchat_table = $mchat_table;
}
/**
@@ -160,7 +168,7 @@ class render_helper
foreach ($mchat_rules as $mchat_rule)
{
$mchat_rule = htmlspecialchars($mchat_rule);
$mchat_rule = utf8_htmlspecialchars($mchat_rule);
$this->template->assign_block_vars('rule', array(
'MCHAT_RULE' => $mchat_rule,
));
@@ -234,7 +242,7 @@ class render_helper
if(confirm_box(true))
{
// Run cleaner
$sql = 'TRUNCATE TABLE ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE;
$sql = 'TRUNCATE TABLE ' . $this->mchat_table;
$this->db->sql_query($sql);
meta_refresh(3, $mchat_redirect);
@@ -264,7 +272,7 @@ class render_helper
if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view)
{
// how many chats do we have?
$sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE;
$sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->mchat_table;
$result = $this->db->sql_query($sql);
$mchat_total_messages = $this->db->sql_fetchfield('messages');
$this->db->sql_freeresult($result);
@@ -279,7 +287,7 @@ class render_helper
$sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
// Message row
$sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' m
FROM ' . $this->mchat_table . ' m
LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
' . $sql_where . '
ORDER BY m.message_id DESC';
@@ -341,15 +349,19 @@ class render_helper
}
// Run query again to get the total message rows...
$sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE;
$sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->mchat_table;
$result = $this->db->sql_query($sql);
$mchat_total_message = $this->db->sql_fetchfield('mess_id');
$this->db->sql_freeresult($result);
// Page list function...
$pagination_url = $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'));
$start = $this->request->variable('start', 0);
$this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
$this->template->assign_vars(array(
// 'MCHAT_PAGE_NUMBER' => $pagination->get_on_page($mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start),
'MCHAT_TOTAL_MESSAGES' => sprintf($this->user->lang['MCHAT_TOTALMESSAGES'], $mchat_total_message),
//\\ 'MCHAT_PAGINATION' => generate_pagination(append_sid("{$this->phpbb_root_path}mchat.{$this->phpEx}", 'mode=archive'), $mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start, true)
));
//add to navlinks
@@ -382,7 +394,7 @@ class render_helper
$mchat_message_last_id = $this->request->variable('message_last_id', 0);
$sql_and = $this->user->data['user_mchat_topics'] ? '' : 'AND m.forum_id = 0';
$sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' m, ' . USERS_TABLE . ' u
FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
WHERE m.user_id = u.user_id
AND m.message_id > ' . (int) $mchat_message_last_id . '
' . $sql_and . '
@@ -532,7 +544,7 @@ class render_helper
if (!$mchat_no_flood && $this->config_mchat['flood_time'])
{
$mchat_flood_current_time = time();
$sql = 'SELECT message_time FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . '
$sql = 'SELECT message_time FROM ' . $this->mchat_table . '
WHERE user_id = ' . (int) $this->user->data['user_id'] . '
ORDER BY message_time DESC';
$result = $this->db->sql_query_limit($sql, 1);
@@ -594,7 +606,7 @@ class render_helper
'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);
$sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
// reset the config settings
@@ -638,7 +650,7 @@ class render_helper
// check for the correct user
$sql = 'SELECT *
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . '
FROM ' . $this->mchat_table . '
WHERE message_id = ' . (int) $message_id;
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
@@ -717,13 +729,13 @@ class render_helper
'bbcode_options' => $options
);
$sql = 'UPDATE ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary).'
$sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary).'
WHERE message_id = ' . (int) $message_id;
$this->db->sql_query($sql);
// Message edited...now read it
$sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' m, ' . USERS_TABLE . ' u
FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
WHERE m.user_id = u.user_id
AND m.message_id = ' . (int) $message_id . '
ORDER BY m.message_id DESC';
@@ -793,7 +805,7 @@ class render_helper
}
// check for the correct user
$sql = 'SELECT m.*, u.username, u.user_colour
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' m
FROM ' . $this->mchat_table . ' m
LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
WHERE m.message_id = ' . (int) $message_id;
$result = $this->db->sql_query($sql);
@@ -811,7 +823,7 @@ class render_helper
}
// Run delete!
$sql = 'DELETE FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . '
$sql = 'DELETE FROM ' . $this->mchat_table . '
WHERE message_id = ' . (int) $message_id;
$this->db->sql_query($sql);
//adds a log
@@ -857,7 +869,7 @@ class render_helper
// user has permissions to view the custom chat?
if (!$mchat_view && $mchat_custom_page)
{
trigger_error($user->lang['NOT_AUTHORISED'], E_USER_NOTICE);
trigger_error('NOT_AUTHORISED', E_USER_NOTICE);
}
// if whois true
@@ -917,7 +929,7 @@ class render_helper
$sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
// Message row
$sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
FROM ' . $this->table_prefix . \dmzx\mchat\core\functions_mchat::MCHAT_TABLE . ' m
FROM ' . $this->mchat_table . ' m
LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
' . $sql_where . '
ORDER BY message_id DESC';