Version 2.0.0-RC7

This commit is contained in:
dmzx
2016-10-16 17:25:31 +02:00
parent 233dc89a8a
commit 159d1d25b8
59 changed files with 1096 additions and 493 deletions

View File

@@ -4,34 +4,41 @@
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace dmzx\mchat\core;
use phpbb\auth\auth;
use phpbb\cache\driver\driver_interface as cache_interface;
use phpbb\db\driver\driver_interface as db_interface;
use phpbb\event\dispatcher_interface;
use phpbb\log\log_interface;
use phpbb\user;
class functions
{
/** @var \dmzx\mchat\core\settings */
/** @var settings */
protected $settings;
/** @var \phpbb\user */
/** @var user */
protected $user;
/** @var \phpbb\auth\auth */
/** @var auth */
protected $auth;
/** @var \phpbb\log\log */
/** @var log_interface */
protected $log;
/** @var \phpbb\db\driver\driver_interface */
/** @var db_interface */
protected $db;
/** @var \phpbb\cache\driver\driver_interface */
/** @var cache_interface */
protected $cache;
/** @var \phpbb\event\dispatcher_interface */
/** @var dispatcher_interface */
protected $dispatcher;
/** @var string */
@@ -70,33 +77,46 @@ class functions
/**
* Constructor
*
* @param \dmzx\mchat\core\settings $settings
* @param \phpbb\user $user
* @param \phpbb\auth\auth $auth
* @param \phpbb\log\log_interface $log
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\driver\driver_interface $cache
* @param \phpbb\event\dispatcher_interface $dispatcher
* @param string $root_path
* @param string $php_ext
* @param string $mchat_table
* @param string $mchat_log_table
* @param string $mchat_sessions_table
* @param settings $settings
* @param user $user
* @param auth $auth
* @param log_interface $log
* @param db_interface $db
* @param cache_interface $cache
* @param dispatcher_interface $dispatcher
* @param string $root_path
* @param string $php_ext
* @param string $mchat_table
* @param string $mchat_log_table
* @param string $mchat_sessions_table
*/
function __construct(\dmzx\mchat\core\settings $settings, \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\event\dispatcher_interface $dispatcher, $root_path, $php_ext, $mchat_table, $mchat_log_table, $mchat_sessions_table)
function __construct(
settings $settings,
user $user,
auth $auth,
log_interface $log,
db_interface $db,
cache_interface $cache,
dispatcher_interface $dispatcher,
$root_path,
$php_ext,
$mchat_table,
$mchat_log_table,
$mchat_sessions_table
)
{
$this->settings = $settings;
$this->user = $user;
$this->auth = $auth;
$this->log = $log;
$this->db = $db;
$this->cache = $cache;
$this->dispatcher = $dispatcher;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->mchat_table = $mchat_table;
$this->mchat_log_table = $mchat_log_table;
$this->mchat_sessions_table = $mchat_sessions_table;
$this->settings = $settings;
$this->user = $user;
$this->auth = $auth;
$this->log = $log;
$this->db = $db;
$this->cache = $cache;
$this->dispatcher = $dispatcher;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->mchat_table = $mchat_table;
$this->mchat_log_table = $mchat_log_table;
$this->mchat_sessions_table = $mchat_sessions_table;
}
/**
@@ -292,35 +312,33 @@ class functions
*/
public function mchat_prune()
{
$sql_aray = array(
$prune_num = (int) $this->settings->cfg('mchat_prune_num');
$prune_mode = (int) $this->settings->cfg('mchat_prune_mode');
if (empty($this->settings->prune_modes[$prune_mode]))
{
return array();
}
$sql_array = array(
'SELECT' => 'message_id',
'FROM' => array($this->mchat_table => 'm'),
);
$prune_num = $this->settings->cfg('mchat_prune_num');
if (ctype_digit($prune_num))
if ($this->settings->prune_modes[$prune_mode] === 'messages')
{
// Retain fixed number of messages
// Skip fixed number of messages, delete all others
$sql_array['ORDER_BY'] = 'm.message_id DESC';
$offset = $prune_num;
$sql_aray['ORDER_BY'] = 'message_id DESC';
}
else
{
// Retain messages of a time period
$time_period = strtotime($prune_num, 0);
if ($time_period === false)
{
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNE_FAIL', false, array($this->user->data['username']));
return false;
}
// Delete messages older than time period
$sql_array['WHERE'] = 'm.message_time < ' . (int) strtotime($prune_num * $prune_mode . ' hours ago');
$offset = 0;
$sql_aray['WHERE'] = 'message_time < ' . (int) (time() - $time_period);
}
$sql = $this->db->sql_build_query('SELECT', $sql_aray);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, 0, $offset);
$rows = $this->db->sql_fetchrowset();
$this->db->sql_freeresult($result);
@@ -349,9 +367,9 @@ class functions
$this->db->sql_query('DELETE FROM ' . $this->mchat_table . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->db->sql_query('DELETE FROM ' . $this->mchat_log_table . ' WHERE ' . $this->db->sql_in_set('message_id', $prune_ids));
$this->cache->destroy('sql', $this->mchat_log_table);
}
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED', false, array($this->user->data['username'], count($prune_ids)));
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED', false, array($this->user->data['username'], count($prune_ids)));
}
return $prune_ids;
}
@@ -363,9 +381,12 @@ class functions
*/
public function mchat_total_message_count()
{
$sql_where_ary = $this->get_sql_where_for_notifcation_messages();
$sql_array = array(
'SELECT' => 'COUNT(*) AS rows_total',
'FROM' => array($this->mchat_table => 'm'),
'WHERE' => $sql_where_ary ? $this->db->sql_escape('(' . implode(') AND (', $sql_where_ary) . ')') : '',
);
/**
@@ -418,22 +439,11 @@ class functions
$sql_where_message_id[] = $this->db->sql_in_set('m.message_id', array_map('intval', $message_ids));
}
$sql_where_ary = $sql_where_message_id ? array(implode(' OR ', $sql_where_message_id)) : array();
$sql_where_ary = $this->get_sql_where_for_notifcation_messages();
if ($this->settings->cfg('mchat_posts'))
if ($sql_where_message_id)
{
// If the current user doesn't have permission to see hidden users, exclude their login posts
if (!$this->auth->acl_get('u_viewonline'))
{
$sql_where_ary[] = 'm.post_id <> ' . (int) self::LOGIN_HIDDEN . // Exclude all notifications that were created by hidden users ...
' OR m.user_id = ' . (int) $this->user->data['user_id'] . // ... but include all login notifications of the current user
' OR m.forum_id <> 0'; // ... and include all post notifications
}
}
else
{
// Exclude all post notifications
$sql_where_ary[] = 'm.post_id = 0';
$sql_where_ary[] = implode(' OR ', $sql_where_message_id);
}
$sql_array = array(
@@ -490,6 +500,35 @@ class functions
return $rows;
}
/**
* Generates SQL where conditions to include or exlude notifacation
* messages based on the current user's settings and permissions
*
* @return array
*/
protected function get_sql_where_for_notifcation_messages()
{
$sql_where_ary = array();
if ($this->settings->cfg('mchat_posts'))
{
// If the current user doesn't have permission to see hidden users, exclude their login posts
if (!$this->auth->acl_get('u_viewonline'))
{
$sql_where_ary[] = 'm.post_id <> ' . (int) self::LOGIN_HIDDEN . // Exclude all notifications that were created by hidden users ...
' OR m.user_id = ' . (int) $this->user->data['user_id'] . // ... but include all login notifications of the current user
' OR m.forum_id <> 0'; // ... and include all post notifications
}
}
else
{
// Exclude all post notifications
$sql_where_ary[] = 'm.post_id = 0';
}
return $sql_where_ary;
}
/**
* Fetches log entries from the database and sorts them
*
@@ -646,14 +685,18 @@ class functions
foreach ($rows as $row)
{
// Skip deleted posts
if (isset($row['post_subject']))
{
$post_subjects[$row['post_id']] = array(
'post_subject' => $row['post_subject'],
'forum_name' => $row['forum_name'],
);
}
$post_subjects[$row['post_id']] = array(
'post_subject' => $row['post_subject'],
'forum_name' => $row['forum_name'],
);
}
// Handle deleted posts
$non_existent_post_ids = array_diff($post_ids, array_keys($post_subjects));
foreach ($non_existent_post_ids as $post_id)
{
$post_subjects[$post_id] = null;
}
return $post_subjects;

View File

@@ -4,46 +4,56 @@
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace dmzx\mchat\core;
use Symfony\Component\HttpFoundation\JsonResponse;
use phpbb\auth\auth;
use phpbb\collapsiblecategories\operator\operator as cc_operator;
use phpbb\controller\helper;
use phpbb\event\dispatcher_interface;
use phpbb\exception\http_exception;
use phpbb\extension\manager;
use phpbb\pagination;
use phpbb\request\request_interface;
use phpbb\template\template;
use phpbb\textformatter\parser_interface;
use phpbb\user;
use Symfony\Component\HttpFoundation\JsonResponse;
class mchat
{
/** @var \dmzx\mchat\core\functions */
/** @var functions */
protected $functions;
/** @var \dmzx\mchat\core\settings */
/** @var settings */
protected $settings;
/** @var \phpbb\controller\helper */
/** @var helper */
protected $helper;
/** @var \phpbb\template\template */
/** @var template */
protected $template;
/** @var \phpbb\user */
/** @var user */
protected $user;
/** @var \phpbb\auth\auth */
/** @var auth */
protected $auth;
/** @var \phpbb\pagination */
/** @var pagination */
protected $pagination;
/** @var \phpbb\request\request */
/** @var request_interface */
protected $request;
/** @var \phpbb\event\dispatcher_interface */
/** @var dispatcher_interface */
protected $dispatcher;
/** @var \phpbb\extension\manager */
/** @var manager */
protected $extension_manager;
/** @var string */
@@ -52,7 +62,10 @@ class mchat
/** @var string */
protected $php_ext;
/** @var \phpbb\collapsiblecategories\operator\operator */
/** @var parser_interface */
protected $parser;
/** @var cc_operator */
protected $cc_operator;
/** @var boolean */
@@ -67,21 +80,37 @@ class mchat
/**
* Constructor
*
* @param \dmzx\mchat\core\functions $functions
* @param \dmzx\mchat\core\settings $settings
* @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 \phpbb\extension\manager $extension_manager
* @param string $root_path
* @param string $php_ext
* @param \phpbb\collapsiblecategories\operator\operator $cc_operator
* @param functions $functions
* @param settings $settings
* @param helper $helper
* @param template $template
* @param user $user
* @param auth $auth
* @param pagination $pagination
* @param request_interface $request
* @param dispatcher_interface $dispatcher
* @param manager $extension_manager
* @param string $root_path
* @param string $php_ext
* @param parser_interface $parser
* @param cc_operator $cc_operator
*/
public function __construct(\dmzx\mchat\core\functions $functions, \dmzx\mchat\core\settings $settings, \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, \phpbb\extension\manager $extension_manager, $root_path, $php_ext, \phpbb\collapsiblecategories\operator\operator $cc_operator = null)
public function __construct(
functions $functions,
settings $settings,
helper $helper,
template $template,
user $user,
auth $auth,
pagination $pagination,
request_interface $request,
dispatcher_interface $dispatcher,
manager $extension_manager,
$root_path,
$php_ext,
parser_interface $parser = null,
cc_operator $cc_operator = null
)
{
$this->functions = $functions;
$this->settings = $settings;
@@ -95,6 +124,7 @@ class mchat
$this->extension_manager = $extension_manager;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->parser = $parser;
$this->cc_operator = $cc_operator;
$this->template->assign_vars(array(
@@ -315,11 +345,18 @@ class mchat
$message = $this->request->variable('message', '', true);
$message_data = array(
'user_id' => $this->user->data['user_id'],
'user_ip' => $this->user->data['session_ip'],
'message_time' => time(),
);
if ($this->settings->cfg('mchat_capital_letter'))
{
$message = utf8_ucfirst($message);
}
$message_data = $this->process_message($message);
$message_data = array_merge($message_data, array(
'user_id' => $this->user->data['user_id'],
'user_ip' => $this->user->data['session_ip'],
'message_time' => time(),
));
/**
* Event to modify a new message before it is inserted in the database
@@ -335,14 +372,7 @@ class mchat
);
extract($this->dispatcher->trigger_event('dmzx.mchat.action_add_before', compact($vars)));
$sql_ary = array_merge($this->process_message($message), $message_data);
if ($this->settings->cfg('mchat_capital_letter'))
{
$sql_ary['message'] = utf8_ucfirst($sql_ary['message']);
}
$is_new_session = $this->functions->mchat_action('add', $sql_ary);
$is_new_session = $this->functions->mchat_action('add', $message_data);
$response = $this->action_refresh(true);
@@ -815,7 +845,7 @@ class mchat
$rows = $this->functions->mchat_get_messages(array(), 0, $limit, $start);
$this->assign_global_template_data();
$this->assign_messages($rows);
$this->assign_messages($rows, $page);
// Render pagination
if ($page === 'archive')
@@ -907,8 +937,8 @@ class mchat
$this->template->assign_vars(array(
'MCHAT_DISPLAY_NAME' => $meta['extra']['display-name'],
'MCHAT_AUTHOR_NAMES' => implode(' &bull; ', $author_names),
'MCHAT_AUTHOR_HOMEPAGES' => implode(' &bull; ', $author_homepages),
'MCHAT_AUTHOR_NAMES' => implode(' &amp; ', $author_names),
'MCHAT_AUTHOR_HOMEPAGES' => implode(' &amp; ', $author_homepages),
));
}
@@ -963,8 +993,9 @@ class mchat
* Assigns all message rows to the template
*
* @param array $rows
* @param string $page
*/
public function assign_messages($rows)
public function assign_messages($rows, $page = '')
{
$rows = array_filter($rows, array($this, 'has_read_auth'));
@@ -974,7 +1005,7 @@ class mchat
}
// Reverse the array if messages appear at the bottom
if (!$this->settings->cfg('mchat_message_top'))
if ($page !== 'archive' && !$this->settings->cfg('mchat_message_top'))
{
$rows = array_reverse($rows);
}
@@ -1188,8 +1219,15 @@ class mchat
'f' => $row['forum_id'],
));
$args[] = '[url=' . $viewtopic_url . ']' . $post_data['post_subject'] . '[/url]';
$args[] = '[url=' . $viewforum_url . ']' . $post_data['forum_name'] . '[/url]';
if ($post_data)
{
$args[] = '[url=' . $viewtopic_url . ']' . $post_data['post_subject'] . '[/url]';
$args[] = '[url=' . $viewforum_url . ']' . $post_data['forum_name'] . '[/url]';
}
else
{
$args[0] .= '_DELETED';
}
}
else if ($row['post_id'] == functions::LOGIN_HIDDEN)
{
@@ -1328,7 +1366,7 @@ class mchat
*/
public function set_user_default_values($sql_ary)
{
foreach (array_keys($this->settings->ucp) as $config_name)
foreach (array_keys($this->settings->ucp_settings()) as $config_name)
{
$sql_ary['user_' . $config_name] = $this->settings->cfg($config_name, true);
}
@@ -1469,22 +1507,34 @@ class mchat
$this->settings->set_cfg('max_post_smilies', 0, true);
}
$mchat_bbcode = $this->settings->cfg('allow_bbcode') && $this->auth->acl_get('u_mchat_bbcode');
$mchat_urls = $this->settings->cfg('allow_post_links') && $this->auth->acl_get('u_mchat_urls');
$mchat_smilies = $this->settings->cfg('allow_smilies') && $this->auth->acl_get('u_mchat_smilies');
$disallowed_bbcodes = array_filter(explode('|', $this->settings->cfg('mchat_bbcode_disallowed')));
// Add function part code from http://wiki.phpbb.com/Parsing_text
$uid = $bitfield = $options = '';
generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_bbcode, $mchat_urls, $mchat_smilies);
$mchat_bbcode = $this->settings->cfg('allow_bbcode') && $this->auth->acl_get('u_mchat_bbcode');
$mchat_magic_urls = $this->settings->cfg('allow_post_links') && $this->auth->acl_get('u_mchat_urls');
$mchat_smilies = $this->settings->cfg('allow_smilies') && $this->auth->acl_get('u_mchat_smilies');
// Not allowed bbcodes
if (!$mchat_bbcode)
// These arguments for generate_text_for_storage() are ignored in 3.1.x
$mchat_img = $mchat_flash = $mchat_quote = $mchat_url = $mchat_bbcode;
// Disallowed bbcodes for 3.2.x
if ($disallowed_bbcodes && $this->parser !== null)
{
$message = preg_replace('#\[/?[^\[\]]+\]#Usi', '', $message);
$mchat_img &= !in_array('img', $disallowed_bbcodes);
$mchat_flash &= !in_array('flash', $disallowed_bbcodes);
$mchat_quote &= !in_array('quote', $disallowed_bbcodes);
$mchat_url &= !in_array('url', $disallowed_bbcodes);
foreach ($disallowed_bbcodes as $bbcode)
{
$this->parser->disable_bbcode($bbcode);
}
}
// Disallowed bbcodes
if ($this->settings->cfg('mchat_bbcode_disallowed'))
$uid = $bitfield = $options = '';
generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_bbcode, $mchat_magic_urls, $mchat_smilies, $mchat_img, $mchat_flash, $mchat_quote, $mchat_url);
// Disallowed bbcodes for 3.1.x
if ($disallowed_bbcodes && $this->parser === null)
{
$bbcode_replace = array(
'#\[(' . str_replace('*', '\*', $this->settings->cfg('mchat_bbcode_disallowed')) . ')[^\[\]]+\]#Usi',

View File

@@ -4,31 +4,39 @@
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace dmzx\mchat\core;
use phpbb\auth\auth;
use phpbb\config\config;
use phpbb\event\dispatcher_interface;
use phpbb\user;
class settings
{
/** @var \phpbb\user */
/** @var user */
protected $user;
/** @var \phpbb\config\config */
/** @var config */
protected $config;
/** @var \phpbb\auth\auth */
/** @var auth */
protected $auth;
/** @var dispatcher_interface */
protected $dispatcher;
/**
* Keys for global settings that only the administrator is allowed to modify.
* The values are stored in the phpbb_config table.
*
* @var array
*/
public $global;
protected $global_settings;
/**
* Keys for user-specific settings for which the administrator can set default
@@ -39,7 +47,20 @@ class settings
*
* @var array
*/
public $ucp;
protected $ucp_settings;
/**
* Prune modes listed in the ACP. For values other than messages the key is the
* amount of hours that is later multiplied with the value that is set in the ACP.
*
* @var array
*/
public $prune_modes = array(
0 => 'messages',
1 => 'hours',
24 => 'days',
168 => 'weeks',
);
/** @var bool */
public $is_phpbb31;
@@ -50,17 +71,33 @@ class settings
/**
* Constructor
*
* @param \phpbb\user $user
* @param \phpbb\config\config $config
* @param \phpbb\auth\auth $auth
* @param user $user
* @param config $config
* @param auth $auth
* @param dispatcher_interface $dispatcher
*/
public function __construct(\phpbb\user $user, \phpbb\config\config $config, \phpbb\auth\auth $auth)
public function __construct(
user $user,
config $config,
auth $auth,
dispatcher_interface $dispatcher
)
{
$this->user = $user;
$this->config = $config;
$this->auth = $auth;
$this->dispatcher = $dispatcher;
$this->global = array(
$this->is_phpbb31 = phpbb_version_compare(PHPBB_VERSION, '3.1.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '<');
$this->is_phpbb32 = phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<');
}
/**
* @return array
*/
public function initialize_global_settings()
{
$global_settings = array(
'mchat_bbcode_disallowed' => array('default' => '', 'validation' => array('string', false, 0, 255)),
'mchat_custom_height' => array('default' => 350, 'validation' => array('num', false, 50, 1000)),
'mchat_custom_page' => array('default' => 1),
@@ -82,7 +119,9 @@ class settings
'mchat_posts_topic' => array('default' => 0),
'mchat_posts_login' => array('default' => 0),
'mchat_prune' => array('default' => 0),
'mchat_prune_num' => array('default' => '0'),
'mchat_prune_gc' => array('default' => strtotime('1 day', 0)),
'mchat_prune_mode' => array('default' => 0),
'mchat_prune_num' => array('default' => 0),
'mchat_refresh' => array('default' => 10, 'validation' => array('num', false, 5, 60)),
'mchat_rules' => array('default' => '', 'validation' => array('string', false, 0, 255)),
'mchat_static_message' => array('default' => '', 'validation' => array('string', false, 0, 255)),
@@ -90,7 +129,27 @@ class settings
'mchat_whois_refresh' => array('default' => 60, 'validation' => array('num', false, 10, 300)),
);
$this->ucp = array(
/**
* Event to modify global settings data
*
* @event dmzx.mchat.global_settings_modify
* @var array global_settings Array containing global settings data
* @since 2.0.0-RC7
*/
$vars = array(
'global_settings',
);
extract($this->dispatcher->trigger_event('dmzx.mchat.global_settings_modify', compact($vars)));
return $global_settings;
}
/**
* @return array
*/
public function initialize_ucp_settings()
{
$ucp_settings = array(
'mchat_avatars' => array('default' => 1),
'mchat_capital_letter' => array('default' => 1),
'mchat_character_count' => array('default' => 1),
@@ -107,8 +166,45 @@ class settings
'mchat_whois_index' => array('default' => 1),
);
$this->is_phpbb31 = phpbb_version_compare(PHPBB_VERSION, '3.1.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '<');
$this->is_phpbb32 = phpbb_version_compare(PHPBB_VERSION, '3.2.0@dev', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<');
/**
* Event to modify UCP settings data
*
* @event dmzx.mchat.ucp_settings_modify
* @var array ucp_settings Array containing UCP settings data
* @since 2.0.0-RC7
*/
$vars = array(
'ucp_settings',
);
extract($this->dispatcher->trigger_event('dmzx.mchat.ucp_settings_modify', compact($vars)));
return $ucp_settings;
}
/**
* @return array
*/
public function global_settings()
{
if (empty($this->global_settings))
{
$this->global_settings = $this->initialize_global_settings();
}
return $this->global_settings;
}
/**
* @return array
*/
public function ucp_settings()
{
if (empty($this->ucp_settings))
{
$this->ucp_settings = $this->initialize_ucp_settings();
}
return $this->ucp_settings;
}
/**
@@ -124,13 +220,15 @@ class settings
/**
* @param string $config
* @param array $user_data
* @param \phpbb\auth\auth $auth
* @param auth $auth
* @param bool $force_global
* @return string
*/
public function cfg_user($config, $user_data, $auth, $force_global = false)
{
if (!$force_global && isset($this->ucp[$config]) && $auth->acl_get('u_' . $config))
$ucp_settings = $this->ucp_settings();
if (!$force_global && isset($ucp_settings[$config]) && $auth->acl_get('u_' . $config))
{
return $user_data['user_' . $config];
}
@@ -180,9 +278,11 @@ class settings
}
$dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>';
$ucp_settings = $this->ucp_settings();
return array(
'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options,
'A_MCHAT_DEFAULT_DATEFORMAT' => addslashes($this->ucp['mchat_date']['default']),
'A_MCHAT_DEFAULT_DATEFORMAT' => addslashes($ucp_settings['mchat_date']['default']),
'S_MCHAT_CUSTOM_DATEFORMAT' => $s_custom,
);
}