mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/10073' into develop-ascraeus
* github-nickvergessen/ticket/10073: (36 commits) [ticket/10073] Fix button descriptions [ticket/10073] Do not check disable boxes by default [ticket/10073] Store values with config_text in the ACP [ticket/10073] Move config values to config_text [ticket/10073] Fix request usage [ticket/10073] Deduplicate template variable names [ticket/10073] Get service from container [ticket/10073] Fix more "Contact Us" strings [ticket/10073] Move template code into the template [ticket/10073] Make contact page available when board is disabled [ticket/10073] Change name of the ACP module [ticket/10073] Deduplicate posting buttons code in ACP [ticket/10073] Use phpbb_validate_email to verify email address [ticket/10073] Add tests for new validate_email() [ticket/10073] Split email validation from email ban and taken checks [ticket/10073] Deduplicate the if statement [ticket/10073] Fallback to board_contact when contact page is disabled [ticket/10073] Remove language string from rebase conflict [ticket/10073] Add ACP module to add bbcode text for contact admin info [ticket/10073] Add new configs to the schema ...
This commit is contained in:
129
phpBB/includes/acp/acp_contact.php
Normal file
129
phpBB/includes/acp/acp_contact.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acp
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package acp
|
||||
*/
|
||||
class acp_contact
|
||||
{
|
||||
public $u_action;
|
||||
|
||||
public function main($id, $mode)
|
||||
{
|
||||
global $user, $request, $template;
|
||||
global $config, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
|
||||
$user->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 = $phpbb_container->get('config_text');
|
||||
|
||||
$contact_admin_data = $config_text->get_array(array(
|
||||
'contact_admin_info',
|
||||
'contact_admin_info_uid',
|
||||
'contact_admin_info_bitfield',
|
||||
'contact_admin_info_flags',
|
||||
));
|
||||
|
||||
$contact_admin_info = $contact_admin_data['contact_admin_info'];
|
||||
$contact_admin_info_uid = $contact_admin_data['contact_admin_info_uid'];
|
||||
$contact_admin_info_bitfield= $contact_admin_data['contact_admin_info_bitfield'];
|
||||
$contact_admin_info_flags = $contact_admin_data['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');
|
||||
}
|
||||
|
||||
$contact_admin_info = $request->variable('contact_admin_info', '', true);
|
||||
|
||||
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_array(array(
|
||||
'contact_admin_info' => $contact_admin_info,
|
||||
'contact_admin_info_uid' => $contact_admin_info_uid,
|
||||
'contact_admin_info_bitfield' => $contact_admin_info_bitfield,
|
||||
'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_DISABLE_CHECKED' => !$contact_admin_edit['allow_bbcode'],
|
||||
'S_SMILIES_DISABLE_CHECKED' => !$contact_admin_edit['allow_smilies'],
|
||||
'S_MAGIC_URL_DISABLE_CHECKED' => !$contact_admin_edit['allow_urls'],
|
||||
|
||||
'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
|
||||
'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();
|
||||
}
|
||||
}
|
@@ -201,7 +201,7 @@ class acp_email
|
||||
$messenger->set_mail_priority($priority);
|
||||
|
||||
$messenger->assign_vars(array(
|
||||
'CONTACT_EMAIL' => $config['board_contact'],
|
||||
'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx),
|
||||
'MESSAGE' => htmlspecialchars_decode($message))
|
||||
);
|
||||
|
||||
|
@@ -814,7 +814,7 @@ class acp_users
|
||||
$check_ary += array(
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('email', $user_row['user_email'])
|
||||
array('user_email', $user_row['user_email']),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
26
phpBB/includes/acp/info/acp_contact.php
Normal file
26
phpBB/includes/acp/info/acp_contact.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package acp
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package module_install
|
||||
*/
|
||||
class acp_contact_info
|
||||
{
|
||||
public function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => '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')),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -96,7 +96,8 @@ class phpbb_captcha_plugins_captcha_abstract
|
||||
else
|
||||
{
|
||||
$link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type);
|
||||
$explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
|
||||
$contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
|
||||
$explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="' . $contact_link . '">', '</a>');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'CONFIRM_IMAGE_LINK' => $link,
|
||||
|
@@ -150,7 +150,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
|
||||
|
||||
function get_template()
|
||||
{
|
||||
global $config, $user, $template;
|
||||
global $config, $user, $template, $phpbb_root_path, $phpEx;
|
||||
|
||||
if ($this->is_solved())
|
||||
{
|
||||
@@ -158,7 +158,8 @@ class phpbb_recaptcha extends phpbb_default_captcha
|
||||
}
|
||||
else
|
||||
{
|
||||
$explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
|
||||
$contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx);
|
||||
$explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="' . $contact_link . '">', '</a>');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'RECAPTCHA_SERVER' => $this->recaptcha_server,
|
||||
|
@@ -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');
|
||||
|
@@ -2818,8 +2818,8 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
|
||||
$user->lang[$result['error_msg']],
|
||||
($config['email_enable']) ? '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') . '">' : '',
|
||||
($config['email_enable']) ? '</a>' : '',
|
||||
($config['board_contact']) ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '',
|
||||
($config['board_contact']) ? '</a>' : ''
|
||||
'<a href="' . phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx) . '">',
|
||||
'</a>'
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -2830,7 +2830,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
|
||||
// Assign admin contact to some error messages
|
||||
if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD')
|
||||
{
|
||||
$err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
|
||||
$err = sprintf($user->lang[$result['error_msg']], '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') . '">', '</a>');
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -4922,6 +4922,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||
'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
|
||||
'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'),
|
||||
'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'),
|
||||
'U_CONTACT_US' => ($config['contact_admin_form_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '',
|
||||
'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'),
|
||||
'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'),
|
||||
'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'),
|
||||
@@ -5298,3 +5299,42 @@ function phpbb_convert_30_dbms_to_31($dbms)
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the board contact details (e.g. for emails)
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param string $phpEx
|
||||
* @return string
|
||||
*/
|
||||
function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx)
|
||||
{
|
||||
if ($config['contact_admin_form_enable'])
|
||||
{
|
||||
return generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin';
|
||||
}
|
||||
else
|
||||
{
|
||||
return $config['board_contact'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a clickable board contact details link
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $phpEx
|
||||
* @return string
|
||||
*/
|
||||
function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
if ($config['contact_admin_form_enable'])
|
||||
{
|
||||
return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin');
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'mailto:' . htmlspecialchars($config['board_contact']);
|
||||
}
|
||||
}
|
||||
|
@@ -1746,24 +1746,20 @@ function validate_password($password)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if email address is banned or already present in the DB
|
||||
* Check to see if email address is a valid address and contains a MX record
|
||||
*
|
||||
* @param string $email The email to check
|
||||
* @param string $allowed_email An allowed email, default being $user->data['user_email']
|
||||
*
|
||||
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
|
||||
*/
|
||||
function validate_email($email, $allowed_email = false)
|
||||
function phpbb_validate_email($email, $config = null)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
if ($config === null)
|
||||
{
|
||||
global $config;
|
||||
}
|
||||
|
||||
$email = strtolower($email);
|
||||
$allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
|
||||
|
||||
if ($allowed_email == $email)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email))
|
||||
{
|
||||
@@ -1782,6 +1778,35 @@ function validate_email($email, $allowed_email = false)
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if email address is banned or already present in the DB
|
||||
*
|
||||
* @param string $email The email to check
|
||||
* @param string $allowed_email An allowed email, default being $user->data['user_email']
|
||||
*
|
||||
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
|
||||
*/
|
||||
function validate_user_email($email, $allowed_email = false)
|
||||
{
|
||||
global $config, $db, $user;
|
||||
|
||||
$email = strtolower($email);
|
||||
$allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
|
||||
|
||||
if ($allowed_email == $email)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$validate_email = phpbb_validate_email($email, $config);
|
||||
if ($validate_email)
|
||||
{
|
||||
return $validate_email;
|
||||
}
|
||||
|
||||
if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
|
||||
{
|
||||
return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
|
||||
|
@@ -66,7 +66,7 @@ class ucp_profile
|
||||
'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('email')),
|
||||
array('user_email')),
|
||||
);
|
||||
|
||||
if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
|
||||
|
@@ -211,7 +211,7 @@ class ucp_register
|
||||
'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']),
|
||||
'email' => array(
|
||||
array('string', false, 6, 60),
|
||||
array('email')),
|
||||
array('user_email')),
|
||||
'tz' => array('timezone'),
|
||||
'lang' => array('language_iso_name'),
|
||||
));
|
||||
|
Reference in New Issue
Block a user