Version 0.1.7
This commit is contained in:
@@ -17,21 +17,6 @@ class admin_controller
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\config\db_text */
|
||||
protected $config_text;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\cache\service */
|
||||
protected $cache;
|
||||
|
||||
/** @var \phpbb\log\log */
|
||||
protected $log;
|
||||
|
||||
/** @var \phpbb\request\request */
|
||||
protected $request;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
@@ -39,13 +24,25 @@ class admin_controller
|
||||
protected $user;
|
||||
|
||||
/** @var ContainerInterface */
|
||||
protected $phpbb_container;
|
||||
protected $container;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\cache\service */
|
||||
protected $cache;
|
||||
|
||||
/** @var \phpbb\request\request */
|
||||
protected $request;
|
||||
|
||||
/** @var \phpbb\extension\manager */
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext;
|
||||
protected $phpEx;
|
||||
|
||||
/** @var string */
|
||||
protected $table_prefix;
|
||||
@@ -53,23 +50,52 @@ class admin_controller
|
||||
/** @var string */
|
||||
public $u_action;
|
||||
|
||||
/**
|
||||
* The database table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mchat_config_table;
|
||||
|
||||
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, $container, \phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, $phpbb_root_path, $phpEx, $table_prefix, $mchat_config_table)
|
||||
/** @var \phpbb\config\db_text */
|
||||
protected $config_text;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\functions_mchat $functions_mchat
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\template\template $template
|
||||
* @param \phpbb\user $user
|
||||
* @param ContainerInterface $container
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\cache\service $cache
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \phpbb\extension\manager $phpbb_extension_manager
|
||||
* @param $phpbb_root_path
|
||||
* @param $phpEx
|
||||
* @param $table_prefix
|
||||
* @param $mchat_config_table
|
||||
* @param \phpbb\config\db_text $config_text
|
||||
*
|
||||
*/
|
||||
|
||||
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, $container, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, \phpbb\extension\manager $phpbb_extension_manager, $phpbb_root_path, $phpEx, $table_prefix, $mchat_config_table)
|
||||
{
|
||||
$this->functions_mchat = $container->get('dmzx.mchat.functions_mchat');
|
||||
$this->config = $config;
|
||||
$this->config_text = $container->get('config_text');
|
||||
$this->db = $db;
|
||||
$this->request = $request;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->container = $container;
|
||||
$this->cache = $cache;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->table_prefix = $container->getParameter('core.table_prefix');
|
||||
$this->mchat_config_table = $mchat_config_table;
|
||||
$this->functions_mchat = $container->get('dmzx.mchat.functions_mchat');
|
||||
$this->config = $config;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->container = $container;
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->request = $request;
|
||||
$this->phpbb_extension_manager = $phpbb_extension_manager;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->table_prefix = $container->getParameter('core.table_prefix');
|
||||
$this->mchat_config_table = $mchat_config_table;
|
||||
$this->config_text = $container->get('config_text');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,10 +264,10 @@ class admin_controller
|
||||
'MCHAT_OVERRIDE_MIN_POST_CHARS' => !empty($mchat_row['override_min_post_chars']) ? $mchat_row['override_min_post_chars'] : $mchat_config['override_min_post_chars'],
|
||||
'MCHAT_TIMEOUT' => !empty($mchat_row['timeout']) ? $mchat_row['timeout'] : $mchat_config['timeout'],
|
||||
'MCHAT_NEW_POSTS' => ($mchat_new_posts) ? true : false,
|
||||
'MCHAT_NEW_POSTS_TOPIC' => ($mchat_new_posts_topic) ? true : false,
|
||||
'MCHAT_NEW_POSTS_REPLY' => ($mchat_new_posts_reply) ? true : false,
|
||||
'MCHAT_NEW_POSTS_EDIT' => ($mchat_new_posts_edit) ? true : false,
|
||||
'MCHAT_NEW_POSTS_QUOTE' => ($mchat_new_posts_quote) ? true : false,
|
||||
'MCHAT_NEW_POSTS_TOPIC' => ($mchat_new_posts_topic) ? true : false,
|
||||
'MCHAT_NEW_POSTS_REPLY' => ($mchat_new_posts_reply) ? true : false,
|
||||
'MCHAT_NEW_POSTS_EDIT' => ($mchat_new_posts_edit) ? true : false,
|
||||
'MCHAT_NEW_POSTS_QUOTE' => ($mchat_new_posts_quote) ? true : false,
|
||||
'MCHAT_PAUSE_ON_INPUT' => !empty($mchat_row['pause_on_input']) ? $mchat_row['pause_on_input'] : $mchat_config['pause_on_input'],
|
||||
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang['MCHAT_BBCODES_DISALLOWED_EXPLAIN'], '<a href="' . append_sid("{$this->phpbb_root_path}index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
|
||||
'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang['MCHAT_USER_TIMEOUT_EXPLAIN'],'<a href="' . append_sid("{$this->phpbb_root_path}index.$this->php_ext", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']),
|
||||
@@ -251,7 +277,41 @@ class admin_controller
|
||||
'U_ACTION' => $this->u_action)
|
||||
);
|
||||
|
||||
// Version check
|
||||
$this->user->add_lang(array('install', 'acp/extensions', 'migrator'));
|
||||
$ext_name = 'dmzx/mchat';
|
||||
$md_manager = new \phpbb\extension\metadata_manager($ext_name, $this->config, $this->phpbb_extension_manager, $this->template, $this->user, $this->phpbb_root_path);
|
||||
try
|
||||
{
|
||||
$this->metadata = $md_manager->get_metadata('all');
|
||||
}
|
||||
catch(\phpbb\extension\exception $e)
|
||||
{
|
||||
trigger_error($e, E_USER_WARNING);
|
||||
}
|
||||
$md_manager->output_template_data();
|
||||
try
|
||||
{
|
||||
$updates_available = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false));
|
||||
$this->template->assign_vars(array(
|
||||
'S_UP_TO_DATE' => empty($updates_available),
|
||||
'S_VERSIONCHECK' => true,
|
||||
'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
|
||||
));
|
||||
foreach ($updates_available as $branch => $version_data)
|
||||
{
|
||||
$this->template->assign_block_vars('updates_available', $version_data);
|
||||
}
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$this->template->assign_vars(array(
|
||||
'S_VERSIONCHECK_STATUS' => $e->getCode(),
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $this->user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the options a user can configure
|
||||
*
|
||||
@@ -260,7 +320,6 @@ class admin_controller
|
||||
*/
|
||||
protected function set_options()
|
||||
{
|
||||
|
||||
//update setting in config table for mod enabled or not
|
||||
$this->config->set('mchat_enable', $this->request->variable('mchat_enable', 0));
|
||||
// update setting in config table for allowing on index or not
|
||||
@@ -279,8 +338,23 @@ class admin_controller
|
||||
$this->config->set('mchat_stats_index', $this->request->variable('mchat_stats_index', 0));
|
||||
// update setting in config table for message on top
|
||||
$this->config->set('mchat_message_top', $this->request->variable('mchat_message_top', 0));
|
||||
|
||||
}
|
||||
|
||||
protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
|
||||
{
|
||||
$meta = $md_manager->get_metadata('all');
|
||||
if (!isset($meta['extra']['version-check']))
|
||||
{
|
||||
throw new \RuntimeException($this->user->lang('NO_VERSIONCHECK'), 1);
|
||||
}
|
||||
$version_check = $meta['extra']['version-check'];
|
||||
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), $this->user);
|
||||
$version_helper->set_current_version($meta['version']);
|
||||
$version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
|
||||
$version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
|
||||
return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set page url
|
||||
*
|
||||
|
||||
@@ -23,15 +23,17 @@ class mchat
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \dmzx\mchat\core\render_helper $render_helper
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\request\request $request
|
||||
* @param \dmzx\mchat\core\render_helper $render_helper
|
||||
* @param \phpbb\controller\helper $helper
|
||||
* @param \phpbb\request\request $request
|
||||
*
|
||||
*/
|
||||
|
||||
public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\controller\helper $helper, \phpbb\request\request $request)
|
||||
{
|
||||
$this->render_helper = $render_helper;
|
||||
$this->helper = $helper;
|
||||
$this->request = $request;
|
||||
$this->render_helper = $render_helper;
|
||||
$this->helper = $helper;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user