diff options
Diffstat (limited to 'phpBB/includes/ucp')
| -rw-r--r-- | phpBB/includes/ucp/info/ucp_auth_link.php | 34 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_auth_link.php | 142 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_groups.php | 37 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_login_link.php | 243 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_main.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_notifications.php | 16 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_prefs.php | 77 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_register.php | 88 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_remind.php | 4 | ||||
| -rw-r--r-- | phpBB/includes/ucp/ucp_zebra.php | 2 | 
11 files changed, 597 insertions, 56 deletions
| diff --git a/phpBB/includes/ucp/info/ucp_auth_link.php b/phpBB/includes/ucp/info/ucp_auth_link.php new file mode 100644 index 0000000000..ee88b15ea8 --- /dev/null +++ b/phpBB/includes/ucp/info/ucp_auth_link.php @@ -0,0 +1,34 @@ +<?php +/** +* +* @package ucp +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @package module_install +*/ +class ucp_auth_link_info +{ +	function module() +	{ +		return array( +			'filename'	=> 'ucp_auth_link', +			'title'		=> 'UCP_AUTH_LINK', +			'version'	=> '1.0.0', +			'modes'		=> array( +				'auth_link'	=> array('title' => 'UCP_AUTH_LINK_MANAGE', 'auth' => '', 'cat' => array('UCP_PROFILE')), +			), +		); +	} + +	function install() +	{ +	} + +	function uninstall() +	{ +	} +} diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php new file mode 100644 index 0000000000..b86c4c8d52 --- /dev/null +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -0,0 +1,142 @@ +<?php +/** +* +* @package ucp +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ +	exit; +} + +class ucp_auth_link +{ +	/** +	* @var string +	*/ +	public $u_action; + +	/** +	* Generates the ucp_auth_link page and handles the auth link process +	* +	* @param	int		$id +	* @param	string	$mode +	*/ +	public function main($id, $mode) +	{ +		global $config, $request, $template, $phpbb_container, $user; + +		$error = array(); + +		$auth_provider = $phpbb_container->get('auth.provider.' . $config['auth_method']); + +		// confirm that the auth provider supports this page +		$provider_data = $auth_provider->get_auth_link_data(); +		if ($provider_data === null) +		{ +			$error[] = 'UCP_AUTH_LINK_NOT_SUPPORTED'; +		} + +		$s_hidden_fields = array(); +		add_form_key('ucp_auth_link'); + +		$submit	= $request->variable('submit', false, false, \phpbb\request\request_interface::POST); + +		// This path is only for primary actions +		if (!sizeof($error) && $submit) +		{ +			if (!check_form_key('ucp_auth_link')) +			{ +				$error[] = 'FORM_INVALID'; +			} + +			if (!sizeof($error)) +			{ +				// Any post data could be necessary for auth (un)linking +				$link_data = $request->get_super_global(\phpbb\request\request_interface::POST); + +				// The current user_id is also necessary +				$link_data['user_id'] = $user->data['user_id']; + +				// Tell the provider that the method is auth_link not login_link +				$link_data['link_method'] = 'auth_link'; + +				if ($request->variable('link', 0, false, \phpbb\request\request_interface::POST)) +				{ +					$error[] = $auth_provider->link_account($link_data); +				} +				else +				{ +					$error[] = $auth_provider->unlink_account($link_data); +				} + +				// Template data may have changed, get new data +				$provider_data = $auth_provider->get_auth_link_data(); +			} +		} + +		// In some cases, a request to an external server may be required. In +		// these cases, the GET parameter 'link' should exist and should be true +		if ($request->variable('link', false)) +		{ +			// In this case the link data should only be populated with the +			// link_method as the provider dictates how data is returned to it. +			$link_data = array('link_method' => 'auth_link'); + +			$error[] = $auth_provider->link_account($link_data); + +			// Template data may have changed, get new data +			$provider_data = $auth_provider->get_auth_link_data(); +		} + +		if (isset($provider_data['VARS'])) +		{ +			// Handle hidden fields separately +			if (isset($provider_data['VARS']['HIDDEN_FIELDS'])) +			{ +				$s_hidden_fields = array_merge($s_hidden_fields, $provider_data['VARS']['HIDDEN_FIELDS']); +				unset($provider_data['VARS']['HIDDEN_FIELDS']); +			} + +			$template->assign_vars($provider_data['VARS']); +		} + +		if (isset($provider_data['BLOCK_VAR_NAME'])) +		{ +			foreach ($provider_data['BLOCK_VARS'] as $block_vars) +			{ +				// See if there are additional hidden fields. This should be an associative array +				if (isset($block_vars['HIDDEN_FIELDS'])) +				{ +					$block_vars['HIDDEN_FIELDS'] = build_hidden_fields($block_vars['HIDDEN_FIELDS']); +				} + +				$template->assign_block_vars($provider_data['BLOCK_VAR_NAME'], $block_vars); +			} +		} + +		$s_hidden_fields = build_hidden_fields($s_hidden_fields); + +		// Replace "error" strings with their real, localised form +		$error = array_map(array($user, 'lang'), $error); +		$error = implode('<br />', $error); + +		$template->assign_vars(array( +			'ERROR'	=> $error, + +			'PROVIDER_TEMPLATE_FILE'	=> $provider_data['TEMPLATE_FILE'], + +			'S_HIDDEN_FIELDS'	=> $s_hidden_fields, +			'S_UCP_ACTION'		=> $this->u_action, +		)); + +		$this->tpl_name = 'ucp_auth_link'; +		$this->page_title = 'UCP_AUTH_LINK'; +	} +} diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 8620e33e47..a75d2e9bfc 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -34,8 +34,8 @@ class ucp_groups  		$return_page = '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '">', '</a>');  		$mark_ary	= request_var('mark', array(0)); -		$submit		= $request->variable('submit', false, false, phpbb_request_interface::POST); -		$delete		= $request->variable('delete', false, false, phpbb_request_interface::POST); +		$submit		= $request->variable('submit', false, false, \phpbb\request\request_interface::POST); +		$delete		= $request->variable('delete', false, false, \phpbb\request\request_interface::POST);  		$error = $data = array();  		switch ($mode) @@ -197,37 +197,6 @@ class ucp_groups  								else  								{  									group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1); - -									include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); -									$messenger = new messenger(); - -									$sql = 'SELECT u.username, u.username_clean, u.user_email, u.user_notify_type, u.user_jabber, u.user_lang -										FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u -										WHERE ug.user_id = u.user_id -											AND ug.group_leader = 1 -											AND ug.group_id = $group_id"; -									$result = $db->sql_query($sql); - -									while ($row = $db->sql_fetchrow($result)) -									{ -										$messenger->template('group_request', $row['user_lang']); - -										$messenger->set_addresses($row); - -										$messenger->assign_vars(array( -											'USERNAME'			=> htmlspecialchars_decode($row['username']), -											'GROUP_NAME'		=> htmlspecialchars_decode($group_row[$group_id]['group_name']), -											'REQUEST_USERNAME'	=> $user->data['username'], - -											'U_PENDING'		=> generate_board_url() . "/ucp.$phpEx?i=groups&mode=manage&action=list&g=$group_id", -											'U_GROUP'		=> generate_board_url() . "/memberlist.$phpEx?mode=group&g=$group_id") -										); - -										$messenger->send($row['user_notify_type']); -									} -									$db->sql_freeresult($result); - -									$messenger->save_queue();  								}  								add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_JOIN' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? '' : '_PENDING'), $group_row[$group_id]['group_name']); @@ -496,7 +465,7 @@ class ucp_groups  							$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();  							// This is normalised data, without the group_ prefix -							$avatar_data = phpbb_avatar_manager::clean_row($group_row); +							$avatar_data = \phpbb\avatar\manager::clean_row($group_row);  						}  						// Did we submit? diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php new file mode 100644 index 0000000000..80a553953d --- /dev/null +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -0,0 +1,243 @@ +<?php +/** +* +* @package ucp +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ +	exit; +} + +/** +* ucp_login_link +* Allows users of external accounts link those accounts to their phpBB accounts +* during an attempted login. +* @package ucp +*/ +class ucp_login_link +{ +	/** +	* @var	string +	*/ +	public $u_action; + +	/** +	* Generates the ucp_login_link page and handles login link process +	* +	* @param	int		$id +	* @param	string	$mode +	*/ +	function main($id, $mode) +	{ +		global $config, $phpbb_container, $request, $template, $user; +		global $phpbb_root_path, $phpEx; + +		// Initialize necessary variables +		$login_error = null; +		$login_link_error = null; +		$login_username = null; + +		// Build the data array +		$data = $this->get_login_link_data_array(); + +		// Ensure the person was sent here with login_link data +		if (empty($data)) +		{ +			$login_link_error = $user->lang['LOGIN_LINK_NO_DATA_PROVIDED']; +		} + +		// Use the auth_provider requested even if different from configured +		$auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); +		$auth_provider = $phpbb_container->get($auth_provider); + +		// Set the link_method to login_link +		$data['link_method'] = 'login_link'; + +		// Have the authentication provider check that all necessary data is available +		$result = $auth_provider->login_link_has_necessary_data($data); +		if ($result !== null) +		{ +			$login_link_error = $user->lang[$result]; +		} + +		// Perform link action if there is no error +		if (!$login_link_error) +		{ +			if ($request->is_set_post('login')) +			{ +				$login_username = $request->variable('login_username', '', false, \phpbb\request\request_interface::POST); +				$login_password = $request->untrimmed_variable('login_password', '', true, \phpbb\request\request_interface::POST); + +				$login_result = $auth_provider->login($login_username, $login_password); + +				// We only care if there is or is not an error +				$login_error = $this->process_login_result($login_result); + +				if (!$login_error) +				{ +					// Give the user_id to the data +					$data['user_id'] = $login_result['user_row']['user_id']; + +					// The user is now logged in, attempt to link the user to the external account +					$result = $auth_provider->link_account($data); + +					if ($result) +					{ +						$login_link_error = $user->lang[$result]; +					} +					else +					{ +						// Finish login +						$result = $user->session_create($login_result['user_row']['user_id'], false, false, true); + +						// Perform a redirect as the account has been linked +						$this->perform_redirect(); +					} +				} +			} +		} + +		$template->assign_vars(array( +			// Common template elements +			'LOGIN_LINK_ERROR'		=> $login_link_error, +			'PASSWORD_CREDENTIAL'	=> 'login_password', +			'USERNAME_CREDENTIAL'	=> 'login_username', +			'S_HIDDEN_FIELDS'		=> $this->get_hidden_fields($data), + +			// Registration elements +			'REGISTER_ACTION'	=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), + +			// Login elements +			'LOGIN_ERROR'		=> $login_error, +			'LOGIN_USERNAME'	=> $login_username, +		)); + +		$this->tpl_name = 'ucp_login_link'; +		$this->page_title = 'UCP_LOGIN_LINK'; +	} + +	/** +	* Builds the hidden fields string from the data array. +	* +	* @param	array	$data	This function only includes data in the array +	*							that has a key that begins with 'login_link_' +	* @return	string	A string of hidden fields that can be included in the +	*					template +	*/ +	protected function get_hidden_fields($data) +	{ +		$fields = array(); + +		foreach ($data as $key => $value) +		{ +			$fields['login_link_' . $key] = $value; +		} + +		return build_hidden_fields($fields); +	} + +	/** +	* Builds the login_link data array +	* +	* @return	array	All login_link data. This is all GET data whose names +	*					begin with 'login_link_' +	*/ +	protected function get_login_link_data_array() +	{ +		global $request; + +		$var_names = $request->variable_names(\phpbb\request\request_interface::GET); +		$login_link_data = array(); +		$string_start_length = strlen('login_link_'); + +		foreach ($var_names as $var_name) +		{ +			if (strpos($var_name, 'login_link_') === 0) +			{ +				$key_name = substr($var_name, $string_start_length); +				$login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::GET); +			} +		} + +		return $login_link_data; +	} + +	/** +	* Processes the result array from the login process +	* @param	array	$result	The login result array +	* @return	string|null	If there was an error in the process, a string is +	*						returned. If the login was successful, then null is +	*						returned. +	*/ +	protected function process_login_result($result) +	{ +		global $config, $request, $template, $user; + +		$login_error = null; + +		if ($result['status'] != LOGIN_SUCCESS) +		{ +			// Handle all errors first +			if ($result['status'] == LOGIN_BREAK) +			{ +				trigger_error($result['error_msg']); +			} + +			switch ($result['status']) +			{ +				case LOGIN_ERROR_ATTEMPTS: + +					$captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); +					$captcha->init(CONFIRM_LOGIN); + +					$template->assign_vars(array( +						'CAPTCHA_TEMPLATE'			=> $captcha->get_template(), +					)); + +					$login_error = $user->lang[$result['error_msg']]; +				break; + +				case LOGIN_ERROR_PASSWORD_CONVERT: +					$login_error = sprintf( +						$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>' : '' +					); +				break; + +				// Username, password, etc... +				default: +					$login_error = $user->lang[$result['error_msg']]; + +					// Assign admin contact to some error messages +					if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') +					{ +						$login_error = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); +					} + +				break; +			} +		} + +		return $login_error; +	} + +	/** +	* Performs a post login redirect +	*/ +	protected function perform_redirect() +	{ +		global $phpbb_root_path, $phpEx; +		$url = append_sid($phpbb_root_path . 'index.' . $phpEx); +		redirect($url); +	} +} diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 615b567134..b859413d92 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -296,7 +296,7 @@ class ucp_main  					}  					else  					{ -						$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_interface::COOKIE); +						$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);  						$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();  					} diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index 72c41776b3..2f22f6cf9c 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -163,11 +163,11 @@ class ucp_notifications  	* Output all the notification types to the template  	*  	* @param string $block -	* @param phpbb_notification_manager $phpbb_notifications -	* @param phpbb_template $template -	* @param phpbb_user $user +	* @param \phpbb\notification\manager $phpbb_notifications +	* @param \phpbb\template\template $template +	* @param \phpbb\user $user  	*/ -	public function output_notification_types($subscriptions, $block = 'notification_types', phpbb_notification_manager $phpbb_notifications, phpbb_template $template, phpbb_user $user) +	public function output_notification_types($subscriptions, $block = 'notification_types', \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user)  	{  		$notification_methods = $phpbb_notifications->get_subscription_methods(); @@ -210,11 +210,11 @@ class ucp_notifications  	* Output all the notification methods to the template  	*  	* @param string $block -	* @param phpbb_notification_manager $phpbb_notifications -	* @param phpbb_template $template -	* @param phpbb_user $user +	* @param \phpbb\notification\manager $phpbb_notifications +	* @param \phpbb\template\template $template +	* @param \phpbb\user $user  	*/ -	public function output_notification_methods($block = 'notification_methods', phpbb_notification_manager $phpbb_notifications, phpbb_template $template, phpbb_user $user) +	public function output_notification_methods($block = 'notification_methods', \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user)  	{  		$notification_methods = $phpbb_notifications->get_subscription_methods(); diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index f24578da84..e80cc2dce3 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -26,7 +26,7 @@ class ucp_prefs  	function main($id, $mode)  	{ -		global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; +		global $config, $db, $user, $auth, $template, $phpbb_dispatcher, $phpbb_root_path, $phpEx;  		$submit = (isset($_POST['submit'])) ? true : false;  		$error = $data = array(); @@ -55,6 +55,20 @@ class ucp_prefs  					$data['notifymethod'] = NOTIFY_BOTH;  				} +				/** +				* Add UCP edit global settings data before they are assigned to the template or submitted +				* +				* To assign data to the template, use $template->assign_vars() +				* +				* @event core.ucp_prefs_personal_data +				* @var	bool	submit		Do we display the form only +				*							or did the user press submit +				* @var	array	data		Array with current ucp options data +				* @since 3.1-A1 +				*/ +				$vars = array('submit', 'data'); +				extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars))); +  				if ($submit)  				{  					if ($config['override_user_style']) @@ -93,6 +107,17 @@ class ucp_prefs  							'user_style'			=> $data['style'],  						); +						/** +						* Update UCP edit global settings data on form submit +						* +						* @event core.ucp_prefs_personal_update_data +						* @var	array	data		Submitted display options data +						* @var	array	sql_ary		Display options data we udpate +						* @since 3.1-A1 +						*/ +						$vars = array('data', 'sql_ary'); +						extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_update_data', compact($vars))); +  						$sql = 'UPDATE ' . USERS_TABLE . '  							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '  							WHERE user_id = ' . $user->data['user_id']; @@ -209,6 +234,20 @@ class ucp_prefs  					'wordcensor'	=> request_var('wordcensor', (bool) $user->optionget('viewcensors')),  				); +				/** +				* Add UCP edit display options data before they are assigned to the template or submitted +				* +				* To assign data to the template, use $template->assign_vars() +				* +				* @event core.ucp_prefs_view_data +				* @var	bool	submit		Do we display the form only +				*							or did the user press submit +				* @var	array	data		Array with current ucp options data +				* @since 3.1-A1 +				*/ +				$vars = array('submit', 'data'); +				extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_data', compact($vars))); +  				if ($submit)  				{  					$error = validate_data($data, array( @@ -247,6 +286,17 @@ class ucp_prefs  							'user_post_show_days'	=> $data['post_st'],  						); +						/** +						* Update UCP edit display options data on form submit +						* +						* @event core.ucp_prefs_view_update_data +						* @var	array	data		Submitted display options data +						* @var	array	sql_ary		Display options data we udpate +						* @since 3.1-A1 +						*/ +						$vars = array('data', 'sql_ary'); +						extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_update_data', compact($vars))); +  						$sql = 'UPDATE ' . USERS_TABLE . '  							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '  							WHERE user_id = ' . $user->data['user_id']; @@ -335,6 +385,20 @@ class ucp_prefs  				);  				add_form_key('ucp_prefs_post'); +				/** +				* Add UCP edit posting defaults data before they are assigned to the template or submitted +				* +				* To assign data to the template, use $template->assign_vars() +				* +				* @event core.ucp_prefs_post_data +				* @var	bool	submit		Do we display the form only +				*							or did the user press submit +				* @var	array	data		Array with current ucp options data +				* @since 3.1-A1 +				*/ +				$vars = array('submit', 'data'); +				extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_data', compact($vars))); +  				if ($submit)  				{  					if (check_form_key('ucp_prefs_post')) @@ -348,6 +412,17 @@ class ucp_prefs  							'user_notify'	=> $data['notify'],  						); +						/** +						* Update UCP edit posting defaults data on form submit +						* +						* @event core.ucp_prefs_post_update_data +						* @var	array	data		Submitted display options data +						* @var	array	sql_ary		Display options data we udpate +						* @since 3.1-A1 +						*/ +						$vars = array('data', 'sql_ary'); +						extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_update_data', compact($vars))); +  						$sql = 'UPDATE ' . USERS_TABLE . '  							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '  							WHERE user_id = ' . $user->data['user_id']; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index e55569fdd5..8ae7acaa11 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -34,9 +34,9 @@ class ucp_profile  		$user->add_lang('posting'); -		$preview	= $request->variable('preview', false, false, phpbb_request_interface::POST); -		$submit		= $request->variable('submit', false, false, phpbb_request_interface::POST); -		$delete		= $request->variable('delete', false, false, phpbb_request_interface::POST); +		$preview	= $request->variable('preview', false, false, \phpbb\request\request_interface::POST); +		$submit		= $request->variable('submit', false, false, \phpbb\request\request_interface::POST); +		$delete		= $request->variable('delete', false, false, \phpbb\request\request_interface::POST);  		$error = $data = array();  		$s_hidden_fields = ''; @@ -567,7 +567,7 @@ class ucp_profile  					$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();  					// This is normalised data, without the user_ prefix -					$avatar_data = phpbb_avatar_manager::clean_row($user->data); +					$avatar_data = \phpbb\avatar\manager::clean_row($user->data);  					if ($submit)  					{ diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 7bc7ac8191..1f9ab23326 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -27,7 +27,7 @@ class ucp_register  	function main($id, $mode)  	{  		global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; -		global $request; +		global $request, $phpbb_container;  		//  		if ($config['require_activation'] == USER_ACTIVATION_DISABLE) @@ -78,19 +78,37 @@ class ucp_register  			}  		} -  		$cp = new custom_profile();  		$error = $cp_data = $cp_error = array(); +		$s_hidden_fields = array(); + +		// Handle login_link data added to $_hidden_fields +		$login_link_data = $this->get_login_link_data_array(); + +		if (!empty($login_link_data)) +		{ +			// Confirm that we have all necessary data +			$auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); +			$auth_provider = $phpbb_container->get($auth_provider); + +			$result = $auth_provider->login_link_has_necessary_data($login_link_data); +			if ($result !== null) +			{ +				$error[] = $user->lang[$result]; +			} + +			$s_hidden_fields = array_merge($s_hidden_fields, $this->get_login_link_data_for_hidden_fields($login_link_data)); +		}  		if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))  		{  			$add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : '';  			$add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; -			$s_hidden_fields = array( +			$s_hidden_fields = array_merge($s_hidden_fields, array(  				'change_lang'	=> '', -			); +			));  			// If we change the language, we want to pass on some more possible parameter.  			if ($change_lang) @@ -398,15 +416,28 @@ class ucp_register  					}  				} +				// Perform account linking if necessary +				if (!empty($login_link_data)) +				{ +					$login_link_data['user_id'] = $user_id; + +					$result = $auth_provider->link_account($login_link_data); + +					if ($result) +					{ +						$message = $message . '<br /><br />' . $user->lang[$result]; +					} +				} +  				$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');  				trigger_error($message);  			}  		} -		$s_hidden_fields = array( +		$s_hidden_fields = array_merge($s_hidden_fields, array(  			'agreed'		=> 'true',  			'change_lang'	=> 0, -		); +		));  		if ($config['coppa_enable'])  		{ @@ -474,4 +505,49 @@ class ucp_register  		$this->tpl_name = 'ucp_register';  		$this->page_title = 'UCP_REGISTRATION';  	} + +	/** +	* Creates the login_link data array +	* +	* @return	array	Returns an array of all POST paramaters whose names +	*					begin with 'login_link_' +	*/ +	protected function get_login_link_data_array() +	{ +		global $request; + +		$var_names = $request->variable_names(\phpbb\request\request_interface::POST); +		$login_link_data = array(); +		$string_start_length = strlen('login_link_'); + +		foreach ($var_names as $var_name) +		{ +			if (strpos($var_name, 'login_link_') === 0) +			{ +				$key_name = substr($var_name, $string_start_length); +				$login_link_data[$key_name] = $request->variable($var_name, '', false, \phpbb\request\request_interface::POST); +			} +		} + +		return $login_link_data; +	} + +	/** +	* Prepends they key names of an associative array with 'login_link_' for +	* inclusion on the page as hidden fields. +	* +	* @param	array	$data	The array to be modified +	* @return	array	The modified array +	*/ +	protected function get_login_link_data_for_hidden_fields($data) +	{ +		$new_data = array(); + +		foreach ($data as $key => $value) +		{ +			$new_data['login_link_' . $key] = $value; +		} + +		return $new_data; +	}  } diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index ff7ab53736..b3def63896 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -71,7 +71,7 @@ class ucp_remind  			}  			// Check users permissions -			$auth2 = new phpbb_auth(); +			$auth2 = new \phpbb\auth\auth();  			$auth2->acl($user_row);  			if (!$auth2->acl_get('u_chgpasswd')) @@ -101,6 +101,8 @@ class ucp_remind  			$messenger->set_addresses($user_row); +			$messenger->anti_abuse_headers($config, $user); +  			$messenger->assign_vars(array(  				'USERNAME'		=> htmlspecialchars_decode($user_row['username']),  				'PASSWORD'		=> htmlspecialchars_decode($user_password), diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index a669c450a4..6bb3cdc145 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -229,7 +229,7 @@ class ucp_zebra  					{  						$message = ($updated) ? $user->lang[$l_mode . '_UPDATED'] : implode('<br />', $error); -						$json_response = new phpbb_json_response; +						$json_response = new \phpbb\json_response;  						$json_response->send(array(  							'success' => $updated, | 
