Version 2.0.0-RC3
This commit is contained in:
@@ -24,23 +24,33 @@ class acp_listener implements EventSubscriberInterface
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var array */
|
||||
protected $user_config_keys;
|
||||
/** @var \dmzx\mchat\core\settings */
|
||||
protected $settings;
|
||||
|
||||
/** @var string */
|
||||
protected $root_path;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\user $user
|
||||
* @param array $user_config_keys
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\user $user
|
||||
* @param \dmzx\mchat\core\settings $settings
|
||||
* @param string $root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\phpbb\template\template $template, \phpbb\request\request $request, \phpbb\user $user, $user_config_keys)
|
||||
public function __construct(\phpbb\template\template $template, \phpbb\request\request $request, \phpbb\user $user, \dmzx\mchat\core\settings $settings, $root_path, $php_ext)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->user_config_keys = $user_config_keys;
|
||||
$this->template = $template;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +60,6 @@ class acp_listener implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
'core.permissions' => 'permissions',
|
||||
'core.acp_users_prefs_modify_data' => 'acp_users_prefs_modify_data',
|
||||
'core.acp_users_prefs_modify_sql' => 'acp_users_prefs_modify_sql',
|
||||
'core.acp_users_prefs_modify_template_data' => 'acp_users_prefs_modify_template_data',
|
||||
);
|
||||
@@ -61,83 +70,83 @@ class acp_listener implements EventSubscriberInterface
|
||||
*/
|
||||
public function permissions($event)
|
||||
{
|
||||
$event['permissions'] = array_merge($event['permissions'], array(
|
||||
'u_mchat_use' => array(
|
||||
'lang' => 'ACL_U_MCHAT_USE',
|
||||
'cat' => 'mChat'
|
||||
$mchat_permissions = array();
|
||||
|
||||
$permission_categories = array(
|
||||
'mchat' => array(
|
||||
'u_mchat_use',
|
||||
'u_mchat_view',
|
||||
'u_mchat_edit',
|
||||
'u_mchat_delete',
|
||||
'u_mchat_ip',
|
||||
'u_mchat_pm',
|
||||
'u_mchat_like',
|
||||
'u_mchat_quote',
|
||||
'u_mchat_flood_ignore',
|
||||
'u_mchat_archive',
|
||||
'u_mchat_bbcode',
|
||||
'u_mchat_smilies',
|
||||
'u_mchat_urls',
|
||||
'a_mchat',
|
||||
),
|
||||
'u_mchat_view' => array(
|
||||
'lang' => 'ACL_U_MCHAT_VIEW',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_edit' => array(
|
||||
'lang' => 'ACL_U_MCHAT_EDIT',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_delete' => array(
|
||||
'lang' => 'ACL_U_MCHAT_DELETE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_ip' => array(
|
||||
'lang' => 'ACL_U_MCHAT_IP',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_pm' => array(
|
||||
'lang' => 'ACL_U_MCHAT_PM',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_like' => array(
|
||||
'lang' => 'ACL_U_MCHAT_LIKE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_quote' => array(
|
||||
'lang' => 'ACL_U_MCHAT_QUOTE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_flood_ignore' => array(
|
||||
'lang' => 'ACL_U_MCHAT_FLOOD_IGNORE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_archive' => array(
|
||||
'lang' => 'ACL_U_MCHAT_ARCHIVE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_bbcode' => array(
|
||||
'lang' => 'ACL_U_MCHAT_BBCODE',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_smilies' => array(
|
||||
'lang' => 'ACL_U_MCHAT_SMILIES',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'u_mchat_urls' => array(
|
||||
'lang' => 'ACL_U_MCHAT_URLS',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
'a_mchat' => array(
|
||||
'lang' => 'ACL_A_MCHAT',
|
||||
'cat' => 'mChat'
|
||||
),
|
||||
));
|
||||
'mchat_user_config' => array_map(function($key) { return 'u_' . $key; }, array_keys($this->settings->ucp)),
|
||||
);
|
||||
|
||||
foreach ($permission_categories as $cat => $permissions)
|
||||
{
|
||||
foreach ($permissions as $permission)
|
||||
{
|
||||
$mchat_permissions[$permission] = array(
|
||||
'lang' => 'ACL_' . strtoupper($permission),
|
||||
'cat' => $cat,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$event['permissions'] = array_merge($event['permissions'], $mchat_permissions);
|
||||
|
||||
$event['categories'] = array_merge($event['categories'], array(
|
||||
'mChat' => 'ACP_CAT_MCHAT',
|
||||
'mchat' => 'ACP_CAT_MCHAT',
|
||||
'mchat_user_config' => 'ACP_CAT_MCHAT_USER_CONFIG'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $event The event object
|
||||
*/
|
||||
public function acp_users_prefs_modify_data($event)
|
||||
public function acp_users_prefs_modify_sql($event)
|
||||
{
|
||||
$data = $event['data'];
|
||||
$sql_ary = array();
|
||||
$validation = array();
|
||||
|
||||
foreach ($this->user_config_keys as $config_key)
|
||||
$user_id = $event['user_row']['user_id'];
|
||||
|
||||
$auth = new \phpbb\auth\auth();
|
||||
$userdata = $auth->obtain_user_data($user_id);
|
||||
$auth->acl($userdata);
|
||||
|
||||
foreach ($this->settings->ucp as $config_name => $config_data)
|
||||
{
|
||||
$data[$config_key] = $this->request->variable($config_key, (int) $event['user_row'][$config_key]);
|
||||
if ($auth->acl_get('u_' . $config_name))
|
||||
{
|
||||
$default = $event['user_row']['user_' . $config_name];
|
||||
settype($default, gettype($config_data['default']));
|
||||
$sql_ary['user_' . $config_name] = $this->request->variable('user_' . $config_name, $default, is_string($default));
|
||||
|
||||
if (isset($config_data['validation']))
|
||||
{
|
||||
$validation['user_' . $config_name] = $config_data['validation'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$event['data'] = $data;
|
||||
if (!function_exists('validate_data'))
|
||||
{
|
||||
include($this->root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
}
|
||||
|
||||
$event['error'] = array_merge($event['error'], validate_data($sql_ary, $validation));
|
||||
$event['sql_ary'] = array_merge($event['sql_ary'], $sql_ary);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,24 +156,26 @@ class acp_listener implements EventSubscriberInterface
|
||||
{
|
||||
$this->user->add_lang_ext('dmzx/mchat', 'mchat_ucp');
|
||||
|
||||
foreach ($this->user_config_keys as $config_key)
|
||||
$user_id = $event['user_row']['user_id'];
|
||||
|
||||
$auth = new \phpbb\auth\auth();
|
||||
$userdata = $auth->obtain_user_data($user_id);
|
||||
$auth->acl($userdata);
|
||||
|
||||
$selected = $this->settings->cfg_user('mchat_date', $event['user_row'], $auth);
|
||||
$date_template_data = $this->settings->get_date_template_data($selected);
|
||||
$this->template->assign_vars($date_template_data);
|
||||
|
||||
$notifications_template_data = $this->settings->get_enabled_post_notifications_lang();
|
||||
$this->template->assign_var('MCHAT_POSTS_ENABLED_LANG', $notifications_template_data);
|
||||
|
||||
foreach (array_keys($this->settings->ucp) as $config_name)
|
||||
{
|
||||
$this->template->assign_var(strtoupper($config_key), $event['data'][$config_key]);
|
||||
$upper = strtoupper($config_name);
|
||||
$this->template->assign_vars(array(
|
||||
$upper => $this->settings->cfg_user($config_name, $event['user_row'], $auth),
|
||||
$upper . '_NOAUTH' => !$auth->acl_get('u_' . $config_name, $user_id),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $event The event object
|
||||
*/
|
||||
public function acp_users_prefs_modify_sql($event)
|
||||
{
|
||||
$sql_ary = $event['sql_ary'];
|
||||
|
||||
foreach ($this->user_config_keys as $config_key)
|
||||
{
|
||||
$sql_ary[$config_key] = $event['data'][$config_key];
|
||||
}
|
||||
|
||||
$event['sql_ary'] = $sql_ary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class main_listener implements EventSubscriberInterface
|
||||
{
|
||||
/** @var \dmzx\mchat\core\functions */
|
||||
protected $functions;
|
||||
|
||||
/** @var \dmzx\mchat\core\mchat */
|
||||
protected $mchat;
|
||||
|
||||
@@ -31,17 +28,15 @@ class main_listener implements EventSubscriberInterface
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\functions $functions
|
||||
* @param \dmzx\mchat\core\mchat $mchat
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\user $user
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\dmzx\mchat\core\functions $functions, \dmzx\mchat\core\mchat $mchat, \phpbb\controller\helper $helper, \phpbb\user $user, $php_ext)
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\mchat $mchat
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\user $user
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\dmzx\mchat\core\mchat $mchat, \phpbb\controller\helper $helper, \phpbb\user $user, $php_ext)
|
||||
{
|
||||
$this->functions = $functions;
|
||||
$this->mchat = $mchat;
|
||||
$this->helper = $helper;
|
||||
$this->user = $user;
|
||||
@@ -113,7 +108,7 @@ class main_listener implements EventSubscriberInterface
|
||||
*/
|
||||
public function posting_modify_submit_post_after($event)
|
||||
{
|
||||
$this->functions->mchat_insert_posting($event['mode'], array(
|
||||
$this->mchat->insert_posting($event['mode'], array(
|
||||
'forum_id' => $event['forum_id'],
|
||||
'forum_name' => $event['post_data']['forum_name'],
|
||||
'post_id' => $event['data']['post_id'],
|
||||
|
||||
Reference in New Issue
Block a user