From d3f65cd66e4c3cbf2a8af45a7db99b40d0153214 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 15:59:06 +0200 Subject: [PATCH] [ticket/10073] Add ACP module to add bbcode text for contact admin info PHPBB3-10073 --- phpBB/adm/style/acp_contact.html | 136 ++++++++++++++++++ phpBB/includes/acp/acp_contact.php | 118 +++++++++++++++ phpBB/includes/acp/info/acp_contact.php | 26 ++++ phpBB/includes/constants.php | 1 + phpBB/language/en/acp/board.php | 13 ++ phpBB/language/en/acp/common.php | 2 + .../data/v310/contact_admin_acp_module.php | 27 ++++ 7 files changed, 323 insertions(+) create mode 100644 phpBB/adm/style/acp_contact.html create mode 100644 phpBB/includes/acp/acp_contact.php create mode 100644 phpBB/includes/acp/info/acp_contact.php create mode 100644 phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html new file mode 100644 index 0000000000..b7a70e6f47 --- /dev/null +++ b/phpBB/adm/style/acp_contact.html @@ -0,0 +1,136 @@ + + + + + + + +

{L_ACP_CONTACT_SETTINGS}

+ +

{L_ACP_CONTACT_SETTINGS_EXPLAIN}

+ +
+
+ {L_GENERAL_OPTIONS} +
+

{L_CONTACT_US_ENABLE_EXPLAIN}
+
+ + +
+
+
+ + +
+ {L_CONTACT_US_INFO_PREVIEW} +

{CONTACT_US_INFO_PREVIEW}

+
+ + +
+ {L_CONTACT_US_INFO} +

{L_CONTACT_US_INFO_EXPLAIN}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+ +
+ + + + + + + + + +
+
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
+
+
+ +
+   + + {S_FORM_TOKEN} +
+
+ + diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php new file mode 100644 index 0000000000..21807082fc --- /dev/null +++ b/phpBB/includes/acp/acp_contact.php @@ -0,0 +1,118 @@ +add_lang(array('acp/board', 'posting')); + + $this->tpl_name = 'acp_contact'; + $this->page_title = 'ACP_CONTACT_SETTINGS'; + $form_name = 'acp_contact'; + add_form_key($form_name); + $error = ''; + + if (!function_exists('display_custom_bbcodes')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } + if (!class_exists('parse_message')) + { + include($phpbb_root_path . 'includes/message_parser.' . $phpEx); + } + + $config_text = new \phpbb\config\db_text($db, CONFIG_TEXT_TABLE); + + $contact_admin_info = $request->variable('contact_admin_info', $config_text->get('contact_admin_info'), true); + $contact_admin_info_uid = $config['contact_admin_info_uid']; + $contact_admin_info_bitfield= $config['contact_admin_info_bitfield']; + $contact_admin_info_flags = $config['contact_admin_info_flags']; + + if ($request->is_set_post('submit') || $request->is_set_post('preview')) + { + if (!check_form_key($form_name)) + { + $error = $user->lang('FORM_INVALID'); + } + + generate_text_for_storage( + $contact_admin_info, + $contact_admin_info_uid, + $contact_admin_info_bitfield, + $contact_admin_info_flags, + !$request->variable('disable_bbcode', false), + !$request->variable('disable_magic_url', false), + !$request->variable('disable_smilies', false) + ); + + if (empty($error) && $request->is_set_post('submit')) + { + $config->set('contact_admin_form_enable', $request->variable('contact_admin_form_enable', false)); + + $config_text->set('contact_admin_info', $contact_admin_info); + $config->set('contact_admin_info_uid', $contact_admin_info_uid); + $config->set('contact_admin_info_bitfield', $contact_admin_info_bitfield); + $config->set('contact_admin_info_flags', $contact_admin_info_flags); + + trigger_error($user->lang['CONTACT_US_INFO_UPDATED'] . adm_back_link($this->u_action)); + } + } + + $contact_admin_info_preview = ''; + if ($request->is_set_post('preview')) + { + $contact_admin_info_preview = generate_text_for_display($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_bitfield, $contact_admin_info_flags); + } + + $contact_admin_edit = generate_text_for_edit($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_flags); + + $template->assign_vars(array( + 'ERRORS' => $error, + 'CONTACT_ENABLED' => $config['contact_admin_form_enable'], + + 'CONTACT_US_INFO' => $contact_admin_edit['text'], + 'CONTACT_US_INFO_PREVIEW' => $contact_admin_info_preview, + + 'S_BBCODE_CHECKED' => (!$contact_admin_edit['allow_bbcode']) ? ' checked="checked"' : '', + 'S_SMILIES_CHECKED' => (!$contact_admin_edit['allow_smilies']) ? ' checked="checked"' : '', + 'S_MAGIC_URL_CHECKED' => (!$contact_admin_edit['allow_urls']) ? ' checked="checked"' : '', + + 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '', ''), + 'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'], + 'IMG_STATUS' => $user->lang['IMAGES_ARE_ON'], + 'FLASH_STATUS' => $user->lang['FLASH_IS_ON'], + 'URL_STATUS' => $user->lang['URL_IS_ON'], + + 'S_BBCODE_ALLOWED' => true, + 'S_SMILIES_ALLOWED' => true, + 'S_BBCODE_IMG' => true, + 'S_BBCODE_FLASH' => true, + 'S_LINKS_ALLOWED' => true, + )); + + // Assigning custom bbcodes + display_custom_bbcodes(); + } +} diff --git a/phpBB/includes/acp/info/acp_contact.php b/phpBB/includes/acp/info/acp_contact.php new file mode 100644 index 0000000000..b8326f34ea --- /dev/null +++ b/phpBB/includes/acp/info/acp_contact.php @@ -0,0 +1,26 @@ + 'acp_contact', + 'title' => 'ACP_CONTACT', + 'version' => '1.0.0', + 'modes' => array( + 'contact' => array('title' => 'ACP_CONTACT_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + ), + ); + } +} diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 602067a0e7..4259ae203c 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -233,6 +233,7 @@ define('BBCODES_TABLE', $table_prefix . 'bbcodes'); define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks'); define('BOTS_TABLE', $table_prefix . 'bots'); define('CONFIG_TABLE', $table_prefix . 'config'); +define('CONFIG_TEXT_TABLE', $table_prefix . 'config_text'); define('CONFIRM_TABLE', $table_prefix . 'confirm'); define('DISALLOW_TABLE', $table_prefix . 'disallow'); define('DRAFTS_TABLE', $table_prefix . 'drafts'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index e2f89839c5..8cb6a8f171 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -352,6 +352,19 @@ $lang = array_merge($lang, array( 'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.', )); +// Contact Settings +$lang = array_merge($lang, array( + 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the “Contact Us” page and also add a text that is displayed on the page.', + + 'CONTACT_US_ENABLE' => 'Enable “Contact Us” page', + 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators', + + 'CONTACT_US_INFO' => '“Contact Us” information', + 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the “Contact Us” page', + 'CONTACT_US_INFO_PREVIEW' => '“Contact Us” information - Preview', + 'CONTACT_US_INFO_UPDATED' => '“Contact Us” information has been updated.', +)); + // Load Settings $lang = array_merge($lang, array( 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index d340e467be..b81b9c2693 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -75,6 +75,8 @@ $lang = array_merge($lang, array( 'ACP_CAT_USERS' => 'Users', 'ACP_CLIENT_COMMUNICATION' => 'Client communication', 'ACP_COOKIE_SETTINGS' => 'Cookie settings', + 'ACP_CONTACT' => 'Contact page', + 'ACP_CONTACT_SETTINGS' => '“Contact Us” settings', 'ACP_CRITICAL_LOGS' => 'Error log', 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php new file mode 100644 index 0000000000..bd682e2f7c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -0,0 +1,27 @@ + 'acp_contact', + 'modes' => array('contact'), + ), + )), + ); + } +}