SpaccCommunityPlatform/phpBB/ext/spaccincphpbb/activitypub/controller/acp_controller.php

67 lines
1.7 KiB
PHP

<?php
namespace spaccincphpbb\activitypub\controller;
class acp_controller
{
protected $config;
protected $language;
protected $log;
protected $request;
protected $template;
protected $user;
protected $u_action;
public function __construct(
\phpbb\config\config $config,
\phpbb\language\language $language,
\phpbb\log\log $log,
\phpbb\request\request $request,
\phpbb\template\template $template,
\phpbb\user $user,
){
$this->config = $config;
$this->language = $language;
$this->log = $log;
$this->request = $request;
$this->template = $template;
$this->user = $user;
}
public function display_options()
{
$this->language->add_lang('common', 'spaccincphpbb/activitypub');
add_form_key('spaccincphpbb_activitypub_acp');
$errors = [];
if ($this->request->is_set_post('submit'))
{
if (!check_form_key('spaccincphpbb_activitypub_acp'))
{
$errors[] = $this->language->lang('FORM_INVALID');
}
if (empty($errors))
{
$this->config->set('spaccincphpbb_activitypub_setfederation', $this->request->variable('spaccincphpbb_activitypub_setfederation', 0));
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_ACP_SPACCINC_ACTIVITYPUB_SETTINGS');
trigger_error($this->language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
}
$s_errors = !empty($errors);
$this->template->assign_vars([
'S_ERROR' => $s_errors,
'ERROR_MSG' => $s_errors ? implode('<br />', $errors) : '',
'U_ACTION' => $this->u_action,
'SPACCINCPHPBB_ACTIVITYPUB_SETFEDERATION' => (bool)$this->config['spaccincphpbb_activitypub_setfederation'],
]);
}
public function set_page_url($u_action)
{
$this->u_action = $u_action;
}
}